@a-t-h-i/bot-lobby 0.6.34 → 0.6.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/execution/delegation.ts +10 -2
- package/src/lobby/quickfix.ts +2 -1
- package/webui/dist/assets/{index-C8hgfw6m.css → index-4Zm1DbOM.css} +1 -1
- package/webui/dist/assets/{index-B4zpEv7K.js → index-CjhlNym4.js} +2 -2
- package/webui/dist/build.json +5 -5
- package/webui/dist/index.html +2 -2
|
@@ -88,7 +88,7 @@ Error generating stack: `+e.message+`
|
|
|
88
88
|
`)),n=[]),n.push(i);return t.push(n.join(`
|
|
89
89
|
`)),t}function WV(e,t,n=!1){let r=t?.start?.offset,i=t?.end?.offset;if(r===void 0||i===void 0)return;let a=e.slice(r,i);if(!n){let e=a.match(/^`+/)?.[0];return e&&a.endsWith(e)?a.slice(e.length,-e.length):a}let o=a.match(/^ {0,3}(`{3,}|~{3,})[^\r\n]*(?:\r\n|\n|\r)/);if(!o)return a;let s=a.slice(o[0].length),c=RegExp(`^ {0,3}${o[1][0]}{${o[1].length},}[ \\t]*$`,`m`).exec(s);return c?s.slice(0,c.index):s}function GV(e,t){return!e&&!t}async function KV(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var qV=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function JV(e){let t=e.lastIndexOf(`${bA}\n`);if(t<0||t>0&&e[t-1]!==`
|
|
90
90
|
`)return{body:e,files:[]};let n=e.slice(t+bA.length+1).split(`
|
|
91
|
-
`).filter(Boolean),r=[];for(let t of n){let n=qV.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var YV=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function XV({files:e}){return e.length===0?null:(0,R.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,R.jsx)(`li`,{children:YV.has(e.mime)?(0,R.jsx)(`a`,{href:F(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02]`,children:(0,R.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-56 object-cover`})}):(0,R.jsxs)(`span`,{className:`inline-flex max-w-64 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var ZV=!1,QV=[],$V=0,eH=900;function tH(){ZV=!0,window.clearTimeout($V),$V=window.setTimeout(nH,eH)}function nH(){ZV=!1,window.clearTimeout($V);let e=QV;QV=[];for(let t of e)t()}function rH(e){if(!ZV)return e(),()=>{};let t=()=>e();return QV.push(t),()=>{QV=QV.filter(e=>e!==t)}}var iH=8;function aH(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=rH(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Wv.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*iH/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function oH(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(oH).join(``)}function sH(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),sH(t,n)}function cH(){return e=>sH(e)}function lH(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await KV(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function uH({text:e,children:t,block:n=!1}){let{copy:r}=lH(e),i=(0,m.useRef)(void 0);return(0,R.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),GV(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),GV(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,R.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function dH({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=lH(WV(n,r?.position,!0)??oH(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,R.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,R.jsx)(X,{label:i?`Copied`:`Copy the code`,icon:i?Vp:Cm,iconOnly:!0,onClick:()=>void a()})]}),(0,R.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function fH(e){return{pre:t=>(0,R.jsx)(dH,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,R.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,R.jsx)(uH,{text:WV(e,r?.position,i)??oH(r),block:i,children:n})},a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,R.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,R.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var pH=(0,m.memo)(function({text:e}){return(0,R.jsx)(AR,{remarkPlugins:[IV],rehypePlugins:[cH],urlTransform:RV,components:fH(e),children:e})}),mH=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=JV(e),i=n?UV(n):[],a=aH(i.length,3);return(0,R.jsxs)(`div`,{className:q(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,R.jsx)(pH,{text:e},t)),(0,R.jsx)(XV,{files:r})]})});function hH({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,R.jsxs)(`section`,{className:q(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,R.jsxs)(`div`,{className:q(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,R.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:[o?(0,R.jsx)(aA,{chord:o,className:`kbd-hint`}):null,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function gH({title:e,right:t,className:n}){return(0,R.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,R.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function _H({title:e,right:t,prominent:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,R.jsx)(gH,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var vH=`Pull requests`,yH=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,bH=`nothing is posted to GitHub`,xH=`Refresh to load open pull requests with the GitHub CLI (gh).`,SH=`No open pull requests.`,CH=`loading pull requests from GitHub…`,wH=`reading the diff…`,TH=`the pull request has new commits since this review — review it again`,EH=`(no description)`,DH=`Review with a focus (optional)`,OH=`Leave it empty for a full review.`;function kH(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function AH(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function jH(e,t){return`+${e} −${t}`}function MH(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function NH(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function PH(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function FH(e,t){if(e.status===`running`)return IH(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?IH(e,t):e.status;return[PH(e.verdict),n].filter(Boolean).join(` · `)}function IH(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function LH(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Fj(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function RH(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${jH(e.additions,e.deletions)} · ${t}`}function zH(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,MH(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function BH(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function VH(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function HH(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function UH({pull:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:LH(e,t)}),(0,R.jsx)(`p`,{className:`text-sm tabular-nums`,children:RH(e)}),zH(e)?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:zH(e)}):null,e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`text-xs break-all text-primary underline underline-offset-4`,children:e.url}):null]})}function WH({read:e}){return(0,R.jsxs)(_H,{title:`Jev's read`,right:VH(e),children:[e.status===`running`?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),wH]}):null,e.status===`failed`?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,R.jsx)(mH,{text:e.line}):null]})}function GH({review:e,now:t}){return(0,R.jsxs)(R.Fragment,{children:[e.model?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,Fj(t-e.startedAt)]}):null,e.stale?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:TH}):null,e.status===`running`?(0,R.jsx)(KH,{steps:e.steps}):null,e.status===`cancelled`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,R.jsx)(mH,{text:e.text}):null]})}function KH({steps:e}){return(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,R.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function qH({number:e,focus:t,onChange:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:DH}),(0,R.jsx)(Aj,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:OH})]})}function JH({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,R.jsxs)(_H,{title:`Review`,right:t?FH(t,n):void 0,children:[t?(0,R.jsx)(GH,{review:t,now:n}):null,(0,R.jsx)(qH,{number:e,focus:r,onChange:i}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,bH,`.`]})]})}function YH({files:e}){return(0,R.jsx)(_H,{title:`Files`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:jH(e.additions,e.deletions)})]},e.path))})})})})}function XH({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?Fj(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,R.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,R.jsx)(mH,{text:e.body.trim()}):null]})}function ZH({notes:e,now:t}){return e.length===0?null:(0,R.jsx)(_H,{title:`Discussion`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(XH,{note:e,now:t},n))})})}function QH({number:e,error:t}){return t?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),`loading #`,e,`…`]})}function $H({number:e,onChanged:t}){let n=WA(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=HH(a);if(!n.data)return(0,R.jsx)(QH,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Review`,icon:Uh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,R.jsx)(X,{label:`Jev's read`,icon:Fp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,R.jsx)(Kj,{icon:dm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,R.jsx)(UH,{pull:s,now:o}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:yH}),l?(0,R.jsx)(WH,{read:l}):null,(0,R.jsx)(JH,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,R.jsx)(YH,{files:s.files}):null,(0,R.jsx)(_H,{title:`Description`,children:s.body.trim()?(0,R.jsx)(mH,{text:s.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:EH})}),(0,R.jsx)(ZH,{notes:s.notes,now:o})]})}var eU=Xg([`relative inline-flex shrink-0 items-center justify-center w-fit border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3`],{variants:{variant:{default:`bg-primary text-primary-foreground`,outline:`border-border bg-transparent dark:bg-input/32`,secondary:`bg-secondary text-secondary-foreground`,info:`bg-info text-white`,success:`bg-success text-white`,warning:`bg-warning text-white`,destructive:`bg-destructive text-white`,focus:`bg-focus text-focus-foreground`,invert:`bg-invert text-invert-foreground`,"primary-light":`border-primary/10 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/15 dark:text-primary`,"warning-light":`border-warning/15 bg-warning/10 text-warning-foreground dark:border-warning/25 dark:bg-warning/15 dark:text-warning`,"success-light":`border-success/15 bg-success/10 text-success-foreground dark:border-success/25 dark:bg-success/15 dark:text-success`,"info-light":`border-info/15 bg-info/10 text-info-foreground dark:border-info/25 dark:bg-info/15 dark:text-info`,"destructive-light":`border-destructive/15 bg-destructive/10 text-destructive-foreground dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive`,"invert-light":`border-invert/15 bg-invert/10 text-foreground dark:border-invert/45 dark:bg-invert/35 dark:text-invert-foreground`,"focus-light":`border-focus/15 bg-focus/10 text-focus-foreground dark:border-focus/25 dark:bg-focus/15 dark:text-focus`,"primary-outline":`bg-background border-border text-primary dark:bg-input/30`,"warning-outline":`bg-background border-border text-warning-foreground dark:bg-input/30`,"success-outline":`bg-background border-border text-success-foreground dark:bg-input/30`,"info-outline":`bg-background border-border text-info-foreground dark:bg-input/30`,"destructive-outline":`bg-background border-border text-destructive-foreground dark:bg-input/30`,"invert-outline":`bg-background border-border text-invert-foreground dark:bg-input/30`,"focus-outline":`bg-background border-border text-focus-foreground dark:bg-input/30`},size:{xs:`px-1 py-0.25 text-[0.6rem] leading-none h-4 min-w-4 gap-1`,sm:`px-1 py-0.25 text-[0.625rem] leading-none h-4.5 min-w-4.5 gap-1`,default:`px-1.25 py-0.5 text-xs h-5 min-w-5 gap-1`,lg:`px-1.5 py-0.5 text-xs h-5.5 min-w-5.5 gap-1`,xl:`px-2 py-0.75 text-sm h-6 min-w-6 gap-1.5`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function tU({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?jv:`span`;return(0,R.jsx)(o,{"data-slot":`badge`,className:q(eU({variant:t,size:n,radius:r,className:e})),...a})}var nU=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:border-primary/40 aria-[current=true]:bg-accent`,rU=`flex flex-col gap-1 px-2 pb-3`,iU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function aU({checks:e}){let t=kH(e);return t?(0,R.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,AH(e)),"aria-hidden":`true`,children:t}):(0,R.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function oU({pull:e,selected:t,onSelect:n}){let r=NH(e.review);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(aU,{checks:e.checks}),e.draft?(0,R.jsx)(tU,{variant:`secondary`,children:`draft`}):null,(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:BH(e)}),(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,R.jsx)(`span`,{children:r}):null,(0,R.jsx)(`span`,{className:`tabular-nums`,children:jH(e.additions,e.deletions)})]})]})]})})}function sU({pulls:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(oU,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var cU=()=>wA(CA(`git`)),lU=e=>wA(CA(`git`,String(e)));function uU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function dU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?SH:e?CH:xH;return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Um,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function fU({rest:e}){let t=Cj(),n=WA(`git.pulls`,{},[`git`]),r=uU(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,R.jsx)(dU,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:vH,count:n.data?`${i.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,R.jsx)(sU,{pulls:i,selectedId:r,onSelect:lU}):(0,R.jsx)(kj,{})]}),c=r===void 0?null:(0,R.jsx)($H,{number:r,onChanged:n.reload},r);return(0,R.jsx)(Dj,{wide:t,list:s,detail:c,open:r!==void 0,onClose:cU,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function pU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function mU({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(Aj,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{pU(e)&&(e.preventDefault(),l())}}),t?(0,R.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:n,icon:s?rh:Np,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var hU=`Issues`,gU=`Issue`,_U=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,vU=`Refresh to load open issues with the GitHub CLI (gh).`,yU=`No open issues. File one with New issue.`,bU=`loading issues from GitHub…`,xU=`issues are off (lobby.issues)`,SU=`(no description)`;function CU(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Fj(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function wU(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?Fj(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function TU(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function EU({issue:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:CU(e,t)}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`text-xs break-all text-primary underline underline-offset-4`,children:e.url}):null]})}function DU({comment:e,now:t}){return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,R.jsx)(`span`,{children:Fj(t-Date.parse(e.createdAt))}):null]}),(0,R.jsx)(mH,{text:e.body.trim()})]})}function OU({comments:e,now:t}){return e.length===0?null:(0,R.jsx)(_H,{title:`Comments`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(DU,{comment:e,now:t},n))})})}function kU({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&wA(CA(`plan`))};return(0,R.jsx)(Kj,{icon:Vg,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function AU({number:e}){let t=WA(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${gU} #${e}`,children:[(0,R.jsx)(mj,{children:(0,R.jsx)(kU,{issue:r})}),(0,R.jsx)(EU,{issue:r,now:n}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_U}),(0,R.jsx)(_H,{title:`Description`,children:r.body.trim()?(0,R.jsx)(mH,{text:r.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:SU})}),(0,R.jsx)(OU,{comments:r.comments,now:n})]})}function jU({issue:e,selected:t,now:n,onSelect:r}){let i=TU(e.labels);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,R.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,R.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:wU(e,n)})]})})}function MU({issues:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(jU,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var NU=()=>wA(CA(`issues`)),PU=e=>wA(CA(`issues`,String(e)));function FU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function IU(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(AA,{children:`Issues are off`}),(0,R.jsx)(jA,{className:`font-mono`,children:xU})]})})}function LU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?yU:e?bU:vU;return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function RU({onCreate:e}){return(0,R.jsx)(wj,{className:`shrink-0 border-t border-border p-4`,children:(0,R.jsx)(mU,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function zU({rest:e}){let t=Cj(),n=HA(`status`).data?.issuesEnabled??!0,r=WA(`issues.list`,{},[`issues`],n),i=FU(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{U(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await U(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,R.jsx)(IU,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,R.jsx)(IU,{}):(0,R.jsx)(RA,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:hU,count:r.data?`${a.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,R.jsx)(MU,{issues:a,selectedId:i,now:o,onSelect:PU}):(0,R.jsx)(kj,{}),(0,R.jsx)(RU,{onCreate:c})]}),d=i===void 0?null:(0,R.jsx)(AU,{number:i},i),f=r.data&&a.length===0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(LU,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,R.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,R.jsx)(RU,{onCreate:c})})]}):(0,R.jsx)(Dj,{wide:t,list:u,detail:d,open:i!==void 0,onClose:NU,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function BU(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var VU={DEV:ym,DESIGN:Dh,QA:lg,RESEARCH:xg,"QUICK FIX":Gg,SCOUT:xm,PLANNER:tg,CLASSIFIER:yg,LOBBY:hh,LINT:$m};function HU(e){return e?VU[e.toUpperCase()]??Lp:zp}function UU(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function WU({source:e,className:t,strokeWidth:n}){if(UU(e))return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=HU(e);return(0,R.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var GU={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function KU(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function qU(e){return GU[e]??`text-muted-foreground`}var JU={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function YU(e){return JU[e]??`var(--muted-foreground)`}function XU(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function ZU(e){return e?.runs??[]}function QU(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function $U({source:e,live:t}){let n=UU(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":YU(e)},children:(0,R.jsx)(WU,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function eW({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,R.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,R.jsx)(`div`,{className:`chat-gutter`,children:r?(0,R.jsx)($U,{source:e,live:i}):n?(0,R.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,R.jsxs)(`p`,{className:`chat-speaker`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,R.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,R.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,R.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":YU(e)},children:a}):a]})]})}function tW({time:e,head:t,note:n,children:r,below:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,R.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,R.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,R.jsx)(`span`,{children:n}):null]}):null,(0,R.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function nW({failed:e,children:t}){return(0,R.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,R.jsx)(`span`,{children:t})})}function rW({className:e}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{})]})}var iW=3e5,aW=`No task is running in this session.`,oW=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,sW=`Nothing said yet. Type below to talk to the oracle about this task.`;function cW({entry:e}){return(0,R.jsxs)(nW,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${Mj(e.at)}`:``]})}function lW({entry:e,head:t}){if(e.role===`you`)return(0,R.jsx)(tW,{time:Mj(e.at),head:t,children:(0,R.jsx)(mH,{text:e.text})});let n=e.role===`panel`;return(0,R.jsx)(eW,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:Mj(e.at),head:t,children:(0,R.jsx)(mH,{text:e.text})})}var uW=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,R.jsx)(B.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,R.jsx)(cW,{entry:e}):(0,R.jsx)(lW,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at);function dW({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,R.jsx)(eW,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,R.jsx)(mH,{text:e??``}):(0,R.jsx)(rW,{className:`mt-1`})})}function fW({hasTask:e}){return(0,R.jsxs)(EA,{className:`h-full border-0`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(ph,{"aria-hidden":`true`})}),e?null:(0,R.jsx)(AA,{children:aW}),(0,R.jsx)(jA,{children:e?sW:oW})]}),e?null:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,R.jsx)(aA,{chord:`3`}),` Plan`]}),(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,R.jsx)(aA,{chord:`4`}),` Quick fix`]})]})]})}async function pW(e){let t=await Te(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function mW(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await pW(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}function hW({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i}){let{ref:a,atBottom:o,stick:s,onScroll:c}=BU(e.length+(t?.length??0)),{merged:l,more:u,loading:d,load:f}=mW(e,r,a),p=(0,m.useCallback)(()=>{c();let e=a.current;e&&e.scrollTop<80&&u&&!d&&f()},[c,a,u,d,f]),h=l.length===0&&!t?.trim()&&!n,[g,_]=(0,m.useState)(!1);return(0,m.useEffect)(()=>_(!0),[]),(0,R.jsxs)(hH,{"aria-label":`Conversation`,className:`flex-1`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:p,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:h?(0,R.jsx)(fW,{hasTask:i}):(0,R.jsxs)(`div`,{className:`chat-column`,children:[u?(0,R.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,l.map((e,t)=>{let n=l[t-1],r=!n||n.role!==e.role||e.at-n.at>iW;return(0,R.jsx)(uW,{entry:e,head:r,fresh:g},e.id)}),(0,R.jsx)(dW,{text:t,busy:n})]})}),o?null:(0,R.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,R.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,tone:`primary`,className:`rounded-full shadow-sm`,onClick:s})})]})}function gW(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function _W(e,t){let{agent:n,file:r}=gW(e);return CA(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var vW=[`master`,`designer`,`backend`,`qa`],yW={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},bW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},xW=`Every write archives the version before it.`;function SW(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function CW(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function wW(e){return{text:e.text,occurrence:e.occurrence}}function TW(e){return vW.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function EW(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function DW({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,R.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,R.jsx)(Aj,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{EW(e)&&(e.preventDefault(),o())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:xW}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,R.jsxs)(Y,{onClick:o,disabled:t||!i.trim(),children:[t?(0,R.jsx)(MA,{}):null,`Save`]})]})]})]})}function OW({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=hA(e,mA.confirm);return(0,R.jsx)(sA,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:xW,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:xW})]}),(0,R.jsx)(Aj,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,R.jsxs)(Y,{onClick:()=>a(o),disabled:r,children:[r?(0,R.jsx)(MA,{}):null,`Save file`]})]})]})})}function kW({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Lh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,R.jsx)(X,{label:`Take the note back`,icon:kg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function AW({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,R.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-3 focus-visible:ring-ring/40`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`div`,{className:`flex gap-2`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(mH,{text:e.text})})}),r.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,R.jsx)(kW,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function jW({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,R.jsx)(_H,{title:`Notes on entries that changed`,right:String(e.length),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,R.jsx)(kW,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function MW({view:e}){let t=e.entries.length;return(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:[bW[e.agent],` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,SW(e.chars),` chars`]}),e.over?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:CW(e.file)}):null]})}function NW({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Edit the entry`,text:`Edit`,icon:Vh,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,R.jsx)(X,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Gh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,R.jsx)(X,{label:`Comment on the entry`,text:`Comment`,icon:dh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,R.jsx)(X,{label:`Edit the whole file`,text:`Edit file`,icon:jm,shortcut:`F`,disabled:a,onClick:r}),(0,R.jsx)(Kj,{icon:Tg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function PW({agent:e,file:t,onChanged:n}){let r=WA(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:wW(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:wW(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:wW(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:wW(h)}:{},text:n}))};return f?(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${bW[e]} ${t}`,children:[(0,R.jsx)(NW,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,R.jsx)(MW,{view:f}),p.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,R.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,R.jsx)(AW,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,R.jsx)(DW,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,R.jsx)(mU,{label:`Comment on this entry`,hint:xW,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,R.jsx)(mU,{label:`Add an entry`,hint:xW,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{}),` saving…`]}):null,(0,R.jsx)(jW,{notes:f.detached,onTakeBack:_,busy:u}),(0,R.jsx)(OW,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function FW(e){return`${e.agent}/${e.file}`}var IW={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},LW=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function RW({info:e}){return(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(`span`,{children:SW(e.chars)}),e.over?(0,R.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,R.jsx)(`span`,{className:`text-primary`,children:LW(e.notes,`note`)}):null]})}function zW({info:e,selected:t,onSelect:n}){return(0,R.jsx)(`li`,{className:`ktree-leaf`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(FW(e)),className:q(nU,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,R.jsx)(RW,{info:e})]})})}var BW=`bot-lobby.knowledge.folded`;function VW(){try{let e=JSON.parse(window.localStorage.getItem(BW)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function HW({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(VW),o=TW(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(BW,JSON.stringify(r))}catch{}return r})}return(0,R.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,R.jsxs)(`p`,{className:`ktree-root`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,R.jsx)(Fp,{className:`size-4`})}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[LW(e.length,`file`),` · `,LW(o.length,`agent`),s>0?` · ${LW(s,`note`)}`:``]})]})]}),(0,R.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=IW[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,R.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":YU(o)},children:[(0,R.jsx)(`h3`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":s,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-node`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,R.jsx)(WU,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:yW[e.agent]}),l?(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,R.jsxs)(`span`,{className:`text-primary`,children:[LW(e.notes,`note`),` · `]}):null,LW(e.files.length,`file`)]}),(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,R.jsx)(Du,{initial:!1,children:a?(0,R.jsx)(B.ul,{id:s,"aria-label":`${yW[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,R.jsx)(zW,{info:e,selected:FW(e)===n,onSelect:r},FW(e)))},`files`):null})]},e.agent)})})]})}var UW=()=>wA(CA(`knowledge`)),WW=e=>{let[t,n]=e.split(`/`);wA(CA(`knowledge`,t??``,n??``))};function GW(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Fp,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{children:`No knowledge files yet.`})]})})}function KW(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,R.jsx)(PW,{agent:i.agent,file:i.file,onChanged:r},FW(i)):t&&n?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function qW(){let e=HA(`lobby`),t=HA(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,R.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,R.jsx)(hW,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function JW({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,R.jsx)(YW,{read:e,selected:t})]})}function YW({read:e,selected:t}){return!e.data&&e.error?(0,R.jsx)(RA,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,R.jsx)(HW,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:WW}):(0,R.jsx)(GW,{}):(0,R.jsx)(kj,{})}function XW({rest:e}){let{chat:t,agent:n,file:r}=gW(e),i=Cj(),a=WA(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,R.jsx)(Dj,{wide:i,inlineDetail:!0,list:(0,R.jsx)(JW,{read:a,selected:s?FW(s):void 0}),detail:t?(0,R.jsx)(qW,{}):KW(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:UW,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function ZW(e){let t=e[0]===`board`,n=e[+!!t];try{return{board:t,id:n?decodeURIComponent(n):void 0}}catch{return{board:t,id:n}}}function QW({className:e,...t}){return(0,R.jsx)(xC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:q(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[5px] border border-input bg-background text-primary-foreground transition-colors duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,R.jsx)(CC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var $W=`Sessions`,eG=`No sessions yet.`,tG=`Up to 5 sessions; each can be assigned to one agent or several.`,nG=`A session is a live Excalidraw room that you and your agents draw in together.`,rG=[{title:`Start a live room`,text:`In Excalidraw: Share → Live collaboration → Start session.`},{title:`Add it here`,text:`Paste the room link, or make a new room and open it in Excalidraw.`},{title:`Assign agents`,text:`They read the board and draw on it, under their own name.`}],iG=`Sessions`,aG=`Pick a session on the left to see its link, its room and its agents.`,oG=`Room link`,sG=`Masked until revealed. A revealed link stays in this tab and is never saved.`,cG=`Room`,lG=`Drawing`,uG=`Last check`,dG=`not checked yet`,fG=`Add a session`,pG=`https://excalidraw.com/#room=…`,mG=`Optional name`;function hG(e){return`${e} of 5 in use`}var gG=`Agents may draw here.`,_G=`Agents may only look.`,vG=`checking the room…`,yG=`Check that the room can be reached.`,bG=`Assigned to`,xG=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,SG=`Add or rename`,CG=`Add by link`,wG=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,TG=`New room`,EG=`Makes a fresh room link to open in Excalidraw; the name is optional.`,DG=`Rename`,OG=`draw`,kG=`look only`,AG=`Copied to the clipboard`,jG=`Could not reveal the link.`,MG=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],NG={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function PG(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function FG(e){return e?e.ok?`✓`:`!`:``}function IG({title:e,right:t,className:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,R.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function LG({row:e=!1}){return(0,R.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:rG.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function RG({label:e,hint:t,buttonLabel:n,placeholder:r,initial:i=``,required:a,mono:o,primary:s,onSubmit:c}){let l=(0,m.useId)(),[u,d]=(0,m.useState)(i),[f,p]=(0,m.useState)(!1),h=a&&!u.trim(),g=async()=>{h||f||(p(!0),await c(u)&&d(i),p(!1))};return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{id:l,value:u,maxLength:o?2e3:80,placeholder:r,"aria-describedby":t?`${l}-hint`:void 0,onChange:e=>d(e.target.value),className:q(`h-8 min-w-0 flex-1 rounded-lg border border-input bg-background px-3 text-sm outline-none transition-[border-color,box-shadow] placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`,o&&`font-mono text-[0.8125rem]`)}),(0,R.jsx)(X,{type:`submit`,label:n,icon:f?rh:Gh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,R.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function zG({onChanged:e,primary:t}){return(0,R.jsx)(RG,{label:CG,hint:wG,buttonLabel:`Add`,placeholder:pG,required:!0,mono:!0,primary:t,onSubmit:async t=>await U(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function BG({onChanged:e,primary:t}){return(0,R.jsx)(RG,{label:TG,hint:EG,buttonLabel:`Create`,placeholder:mG,primary:t,onSubmit:async t=>{let n=t.trim();return await U(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function VG({onChanged:e,stacked:t=!1}){return(0,R.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,R.jsx)(zG,{onChanged:e,primary:!0}),(0,R.jsx)(BG,{onChanged:e,primary:!0})]})}function HG({session:e,onChanged:t}){return(0,R.jsx)(RG,{label:DG,initial:e.name,required:!0,buttonLabel:DG,onSubmit:async n=>await U(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function UG({icon:e,tone:t=`muted`,children:n}){return(0,R.jsxs)(`span`,{className:q(`inline-flex h-6 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,t===`primary`?`bg-accent text-primary`:t===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,R.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function WG({check:e,checking:t}){return t?(0,R.jsx)(UG,{icon:rh,children:vG}):e?e.ok?(0,R.jsx)(UG,{icon:rm,tone:`primary`,children:`reachable`}):(0,R.jsx)(UG,{icon:tm,tone:`warning`,children:`unreachable`}):(0,R.jsx)(UG,{icon:am,children:dG})}function GG({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm`,children:[(0,R.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`dd`,{className:`min-w-0`,children:t})]})}function KG({check:e,checking:t}){return t?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`,"aria-hidden":`true`}),vG]}):e?(0,R.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:yG})}function qG({agent:e,on:t,onToggle:n}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-lg border px-2.5 text-sm transition-[background-color,border-color,color]`,t?`border-primary/25 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(QW,{checked:t,onCheckedChange:()=>n(e)}),(0,R.jsx)(`span`,{className:`truncate`,children:NG[e]})]})})}function JG({session:e,onChanged:t}){let n=async n=>{await U(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await U(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===MG.length;return(0,R.jsxs)(IG,{title:bG,right:PG(e.agents.length),children:[(0,R.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:MG.map(t=>(0,R.jsx)(qG,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:xG}),(0,R.jsx)(X,{label:i?`Take every agent off`:`Assign every agent`,icon:$m,onClick:()=>void r()})]})]})}function YG({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await Te(`excalidraw.reveal`,{id:e.id})).link)}catch(e){H.error(e instanceof Error?e.message:jG)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>H(AG)).catch(()=>void 0),u=async()=>{await U(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,R.jsxs)(mj,{children:[o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{label:`Copy the link`,text:`Copy`,icon:Cm,shortcut:`C`,onClick:l}),(0,R.jsx)(X,{label:`Open board`,icon:Dm,tone:`primary`,shortcut:`O`,href:o})]}):(0,R.jsx)(X,{label:`Reveal the link`,text:`Reveal`,icon:km,shortcut:`R`,onClick:()=>void c()}),(0,R.jsx)(X,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?zh:Vh,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,R.jsx)(X,{label:`Check the room`,text:`Check`,icon:n?rh:lg,shortcut:`T`,disabled:n,onClick:r}),(0,R.jsx)(Kj,{icon:Tg,label:`Remove the session`,text:`Remove`,shortcut:`Delete`,title:`Remove "${e.name}"?`,description:`Agents lose this session at once; the Excalidraw room itself is not touched.`,confirmLabel:`Remove session`,variant:`destructive`,onConfirm:a})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(UG,{icon:e.contribute?Vh:km,tone:e.contribute?`primary`:`muted`,children:e.contribute?OG:kG}),(0,R.jsx)(UG,{icon:Ng,children:PG(e.agents.length)}),(0,R.jsx)(WG,{check:t,checking:n})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,R.jsxs)(IG,{title:oG,children:[(0,R.jsx)(`p`,{className:`rounded-lg border border-border bg-muted px-3 py-2 font-mono text-[0.8125rem] break-all text-foreground`,children:o??e.masked}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:sG})]}),(0,R.jsx)(IG,{title:cG,children:(0,R.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(GG,{label:lG,children:(0,R.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?gG:_G})}),(0,R.jsx)(GG,{label:uG,children:(0,R.jsx)(KG,{check:t,checking:n})})]})})]}),(0,R.jsx)(JG,{session:e,onChanged:i})]}),(0,R.jsx)(IG,{title:SG,children:(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,R.jsx)(HG,{session:e,onChanged:i}),(0,R.jsx)(zG,{onChanged:i}),(0,R.jsx)(BG,{onChanged:i})]})})]})}function XG({check:e,checking:t}){if(t)return(0,R.jsx)(MA,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=FG(e);return n?(0,R.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,R.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function ZG({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":r?`true`:void 0,onClick:()=>i(e.id),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(XG,{check:t,checking:n}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:PG(e.agents.length)})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,R.jsx)(tU,{variant:`secondary`,children:e.contribute?OG:kG})]})]})})}function QG({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(ZG,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var $G=()=>wA(CA(`excalidraw`)),eK=e=>wA(CA(`excalidraw`,e));function tK({count:e}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:hG(e)})]})}function nK({count:e,onChanged:t}){return(0,R.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:iG}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:aG})]}),(0,R.jsx)(tK,{count:e})]}),(0,R.jsx)(LG,{row:!0}),e<5?(0,R.jsx)(IG,{title:fG,children:(0,R.jsx)(VG,{onChanged:t})}):null,(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,R.jsx)(oA,{chord:`ArrowDown`,children:`next session`}),(0,R.jsx)(oA,{chord:`ArrowRight`,children:`into its detail`})]})]})}function rK({onChanged:e}){return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock sm:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(Fh,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:eG}),(0,R.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:nG})]}),(0,R.jsx)(LG,{}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:tG})]}),(0,R.jsx)(IG,{title:fG,className:`self-start`,children:(0,R.jsx)(VG,{onChanged:e,stacked:!0})})]})})}function iK({id:e}){let t=Cj(),n=WA(`excalidraw.list`,{},[`excalidraw`]),[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),s=n.data?.sessions??[],c=s.find(t=>t.id===e),l=async e=>{o(t=>[...t,e]);let t=await U(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await U(`excalidraw.remove`,{id:c.id})&&(n.reload(),$G())};if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,R.jsx)(rK,{onChanged:n.reload});let d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:$W,count:n.data?`${s.length}/5`:void 0}),n.data?(0,R.jsx)(QG,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:eK}):(0,R.jsx)(kj,{})]}),f=c?(0,R.jsx)(YG,{session:c,check:r[c.id],checking:a.includes(c.id),onCheck:()=>void l(c.id),onChanged:n.reload,onRemove:()=>void u()}):t&&n.data?(0,R.jsx)(nK,{count:s.length,onChanged:n.reload}):null;return(0,R.jsx)(Dj,{wide:t,list:d,detail:f,open:c!==void 0,onClose:$G,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function aK(e,t){return e===`lobby.thinking`||t===`1`}var oK=`bot-lobby.collapsed.`,sK=new Set,cK=new Map;function lK(e){if(cK.has(e))return cK.get(e);if(e===`lobby.thinking`)return aK(e);try{return aK(e,localStorage.getItem(oK+e))}catch{return!1}}function uK(e,t){cK.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(oK+e,t?`1`:`0`)}catch{}for(let e of[...sK])e()}function dK(e){return sK.add(e),()=>{sK.delete(e)}}function fK(e){uK(e,!lK(e))}function pK(e){return[(0,m.useSyncExternalStore)(dK,()=>lK(e),()=>aK(e)),(0,m.useCallback)(()=>uK(e,!lK(e)),[e])]}function mK({entry:e}){return e.pending?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,R.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,R.jsx)(Dg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function hK({entry:e}){return(0,R.jsxs)(`li`,{className:`grid grid-cols-[2.75rem_5rem_1rem_minmax(0,1fr)] items-baseline gap-x-2 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-muted`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:Mj(e.at)}),(0,R.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,qU(e.source)),children:KU(e.source)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,R.jsx)(mK,{entry:e})}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,e.kind===`error`?`text-destructive`:e.pending?``:`text-muted-foreground`),children:e.pending?`${e.text}…`:e.text})]})}function gK({entries:e,collapsed:t,onToggle:n,shortcut:r,bare:i}){let a=e.slice(-400),o=a.filter(e=>e.pending).length,{ref:s,atBottom:c,stick:l,onScroll:u}=BU(JSON.stringify(a));return(0,R.jsxs)(hH,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,R.jsx)(`div`,{ref:s,onScroll:u,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-2 pt-2 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Activity`,tabIndex:0,children:a.length===0?(0,R.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,R.jsx)(`ul`,{children:a.map(e=>(0,R.jsx)(hK,{entry:e},e.id))})}),c?null:(0,R.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,R.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,className:`rounded-full bg-card shadow-card`,onClick:l})})]})}function _K(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function vK(e){return e===`running`?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):e===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):e===`failed`||e===`timeout`||e===`error`?(0,R.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`})}function yK(e,t){let n=e.startedAt?Date.parse(e.startedAt):NaN;return Nj((e.finishedAt?Date.parse(e.finishedAt):t)-n)}function bK({runs:e}){let t=_K(e.some(e=>e.status===`running`));return e.length===0?null:(0,R.jsx)(`ul`,{className:`-mt-1 flex shrink-0 flex-wrap items-center gap-1.5 px-4 pb-3`,"aria-label":`Runs`,children:e.map((e,n)=>(0,R.jsx)(tU,{asChild:!0,variant:`secondary`,radius:`full`,className:`h-auto gap-2 py-1 pr-3 pl-2`,children:(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:vK(e.status)}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.status??`unknown`}),(0,R.jsx)(`span`,{className:q(`font-medium`,qU(XU(e))),children:KU(XU(e))}),e.parentRunId?(0,R.jsx)(`span`,{className:`text-muted-foreground`,title:`Child of ${e.parentRunId}`,children:`child`}):null,e.activity??e.step?(0,R.jsx)(`span`,{className:`max-w-[18rem] truncate text-muted-foreground`,children:e.activity??e.step}):null,(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:yK(e,t)})]})},e.runId??n))})}function xK(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function SK(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function CK(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}var wK=8;function TK(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function EK(e,t){let n=Math.min(t,wK);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function DK({done:e,total:t}){return(0,R.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:EK(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function OK({check:e,className:t}){return(0,R.jsx)(e===`done`?rm:e===`dropped`?pm:hm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function kK({children:e}){return(0,R.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function AK({ms:e,running:t,sample:n}){let r=CK(t,n);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:SK(e+r)})}function jK({work:e}){return(0,R.jsxs)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,title:`How long the agents have worked on this task (idle time left out)`,children:[(0,R.jsx)(Cg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,R.jsx)(AK,{ms:e.workedMs,running:e.running,sample:e})]})}function MK({active:e,current:t}){let n=e?.[0];if(n){let t=n.activeAgentCount??1;return(0,R.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,R.jsx)(`span`,{className:`truncate text-foreground`,title:n.text,children:n.text}),(0,R.jsxs)(`span`,{className:`shrink-0 text-primary`,children:[`(`,t,` `,t===1?`dev working`:`devs working`,`)`]}),(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,R.jsx)(AK,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,R.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]})}return t?(0,R.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,R.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function NK({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,R.jsx)(`div`,{className:`h-1.5 w-16 overflow-hidden rounded-full bg-border`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":e,"aria-label":`Plan progress`,children:(0,R.jsx)(B.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,R.jsx)(MK,{...r?{active:r}:{},...n?{current:n}:{}})]})}function PK({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,R.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,R.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] font-medium`,title:e?.title,children:[e?.title??`No task yet`,e?null:(0,R.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,R.jsx)(kK,{children:e.id}),e.track?(0,R.jsx)(kK,{children:TK(e.track)}):null,(e.domains??[]).length>0?(0,R.jsx)(kK,{children:e.domains.join(`, `)}):null,r?(0,R.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,R.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,R.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,R.jsx)(jK,{work:e.work}):null,e.progress?(0,R.jsx)(NK,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var FK=(e,t)=>e?.keys.find(e=>e.action===t)?.label,IK=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function LK({name:e,icon:t,shortcut:n,onClick:r}){return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Expand ${e}`,"aria-expanded":!1,"aria-keyshortcuts":n,onClick:r,className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(JA,{side:`left`,children:[`Expand `,e,n?(0,R.jsx)(aA,{chord:n}):null]})]})}function RK(e){let t=IK(e.status);return(0,R.jsx)(`aside`,{"aria-label":`Minimized panes`,className:`flex w-12 shrink-0 flex-col items-center gap-1 border-l border-border py-2`,children:t.activity&&e.activityFolded?(0,R.jsx)(LK,{name:`Activity`,icon:xp,shortcut:FK(e.status,`activity`),onClick:e.toggleActivity}):null})}function zK(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=IK(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,R.jsxs)(`div`,{className:q(`grid min-h-0 flex-1 gap-3 p-3`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`:`grid-cols-1`),children:[a.conversation?(0,R.jsx)(hW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,R.jsx)(gK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:FK(n,`activity`)}):null]})}function BK(e){let{status:t}=e,n=IK(t).activity&&e.activityFolded;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,R.jsx)(zK,{...e})}),n?(0,R.jsx)(RK,{...e}):null]})}function VK({data:e,status:t}){let n=IK(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ph}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:xp}]:[]],[i,a]=(0,m.useState)(`conversation`),o=r.find(e=>e.id===i)??r[0],s=(e?.activity??[]).filter(e=>e.pending).length;return o?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Pane`,className:`flex shrink-0 items-center gap-0.5 border-b border-border px-3 py-2`,children:r.map(e=>{let t=e.id===o.id,n=e.icon;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>a(e.id),className:q(`inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2.5 text-[0.8125rem] font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,t?`btn-raised bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,R.jsx)(hW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task}):null,o.id===`activity`?(0,R.jsx)(gK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function HK(e){let{data:t,status:n}=e,r=Cj();return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,R.jsx)(PK,{task:t?.task,status:n}),(0,R.jsx)(bK,{runs:ZU(t)})]}),r?(0,R.jsx)(BK,{...e}):(0,R.jsx)(VK,{...e})]})}function UK(){let e=HA(`lobby`),t=HA(`status`),[n,r]=pK(`lobby.activity`);return!e.data&&e.loading?(0,R.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{}),(0,R.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,R.jsx)(RA,{message:e.error,onRetry:()=>fe.onHello({})}):(0,R.jsx)(HK,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var WK=Xg([`relative flex flex-col bg-muted/50 gap-(--frame-gap) px-(--frame-px) py-(--frame-py) rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:--spacing(0.75)] [--frame-px:--spacing(0.75)] [--frame-py:--spacing(0.75)] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:[`gap-0 *:has-[+[data-slot=frame-panel]]:rounded-b-none`,`*:has-[+[data-slot=frame-panel]]:before:hidden`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:rounded-t-none`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:border-t-0`],false:[`data-[spacing=sm]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-0.5`,`data-[spacing=default]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-1`,`data-[spacing=lg]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-2`]},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function GK({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,R.jsx)(`div`,{className:q(WK({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function KK({className:e,fit:t,...n}){return(0,R.jsx)(`div`,{className:q(`relative overflow-hidden rounded-(--frame-panel-radius) border border-(--frame-panel-border-color) bg-(--frame-panel-bg) bg-clip-padding shadow-xs`,!t&&`grow`,`before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--frame-panel-radius)-1px)] before:shadow-black/5`,`dark:bg-clip-border dark:before:shadow-white/5`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function qK({className:e,...t}){return(0,R.jsx)(`header`,{className:q(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}var JK={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function YK(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function XK(e){return e>0?YK(e):`—`}function ZK(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function QK(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function $K(e){return!Number.isFinite(e)||e<1e3?String(Math.max(0,Math.round(e||0))):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function eq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function tq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function nq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function rq(e,t){let n=t===`model-kind`?JK[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var iq=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],aq={MASTER:`bg-primary`,ORACLE:`bg-primary`,DEV:`bg-source-dev`,DESIGN:`bg-source-design`,QA:`bg-source-qa`,RESEARCH:`bg-source-research`,"QUICK FIX":`bg-source-quickfix`};function oq(e){let t=aq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%iq.length;return iq[n]??iq[0]}function sq(e){return JK[e]??e}var cq=6;function lq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=xf(),[i,a]=(0,m.useState)(null),o=t?`Daily cost`:`Daily runs`,s=e.map(e=>t?e.cost:e.runs),c=Math.max(...s,t?.01:1),l=t?[0,c/2,c]:[...new Set([0,Math.ceil(c/2),c])],u=Date.parse(e[0]?.date??`1970-01-01`),d=Date.parse(e.at(-1)?.date??`1970-01-01`),f=Math.max(1,(d-u)/864e5),p=e=>52+(Date.parse(e)-u)/(f*864e5)*424,h=Math.max(.5,Math.min(28,424/(f+1)*.65)),g=e=>t?`$${e.toFixed(2)}`:String(Math.round(e)),_=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),v=[...new Set([e[0]?.date,e[Math.floor(e.length/2)]?.date,e.at(-1)?.date])].filter(e=>!!e);return(0,R.jsxs)(dq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,R.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,R.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,R.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,R.jsx)(`line`,{x1:`36`,x2:`494`,y1:180-e/c*144,y2:180-e/c*144,stroke:`var(--workspace-border)`,strokeDasharray:`3 5`,opacity:`0.6`}),(0,R.jsx)(`text`,{x:`29`,y:184-e/c*144,textAnchor:`end`,fill:`var(--muted-foreground)`,fontSize:`10`,children:g(e)})]},e)),e.map((e,o)=>{let s=(t?e.cost:e.runs)/c*144,l=u===d?264:p(e.date),f=`${e.date}: ${t?g(e.cost):`${e.runs} runs, ${e.successes} successful`}`;return(0,R.jsxs)(`g`,{role:`img`,"aria-label":f,tabIndex:0,className:`outline-none`,onFocus:()=>a(e),onBlur:()=>a(null),onPointerEnter:()=>a(e),onPointerLeave:()=>a(null),children:[(0,R.jsx)(`title`,{children:f}),(0,R.jsx)(`rect`,{x:l-Math.max(h,12)/2,y:`26`,width:Math.max(h,12),height:`156`,rx:`4`,fill:`var(--accent)`,opacity:+(i?.date===e.date)}),(0,R.jsx)(B.rect,{"data-trend-bar":!0,x:l-h/2,width:h,rx:`3`,fill:`url(#${n}-fill)`,initial:!r&&{height:0,y:180},animate:{height:s,y:180-s},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3),ease:[.22,1,.36,1]}}),t?null:(0,R.jsx)(B.rect,{x:l-h/2,width:h,rx:`3`,fill:`var(--success)`,initial:!r&&{height:0,y:180},animate:{height:e.successes/c*144,y:180-e.successes/c*144},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3)}})]},e.date)}),v.map(e=>(0,R.jsx)(`text`,{"aria-hidden":`true`,x:u===d?264:p(e),y:`205`,textAnchor:`middle`,fill:`var(--muted-foreground)`,fontSize:`11`,children:_(e)},e))]}),t?null:(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function uq({daily:e}){return(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(lq,{daily:e}),(0,R.jsx)(lq,{daily:e,cost:!0})]})}function dq({title:e,right:t,children:n}){return(0,R.jsxs)(GK,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,R.jsx)(qK,{className:`py-2.5`,children:(0,R.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,R.jsx)(`span`,{children:e}),t?(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,R.jsx)(KK,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function fq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,cq);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>cq?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`h-6 self-start rounded-lg text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:n?`Show fewer`:`Show all ${e.length}`}):null]})}function pq({width:e,className:t,title:n}){let r=xf();return(0,R.jsx)(B.div,{"data-chart-bar":!0,title:n,className:`h-full ${t}`,initial:!r&&{width:0},animate:{width:`${e}%`},transition:{duration:r?0:.7,ease:[.22,1,.36,1]}})}function mq(e,t){return t>0?Math.max(1.5,e/t*100):0}function hq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,R.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,R.jsxs)(`div`,{className:`relative h-5 overflow-hidden rounded-md border border-border bg-muted chart-track`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,R.jsx)(pq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:mq(t,r)}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-foreground/40`,style:{left:`${Math.min(99.5,mq(n,r))}%`}}):null]})]})}function gq({groups:e,label:t}){let n=e.filter(e=>e.avgMs>0).sort((e,t)=>t.avgMs-e.avgMs),r=Math.max(...n.map(e=>Math.max(e.avgMs,e.p90Ms)),1);return(0,R.jsx)(dq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsx)(fq,{rows:n,render:e=>(0,R.jsx)(hq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:XK(e.avgMs),sub:`p90 ${XK(e.p90Ms)}`},t(e))})})}var _q={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},vq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function yq({label:e,rate:t,runs:n}){let r=tq(t),i=`${Math.round(t*100)}%`;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${vq[r.tone]}`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${_q[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,R.jsxs)(`div`,{className:`flex h-5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,R.jsx)(pq,{className:`bg-success/80`,width:t*100}),(0,R.jsx)(pq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function bq({groups:e,label:t}){let n=e.filter(e=>e.runs>0).sort((e,t)=>e.successes/e.runs-t.successes/t.runs);return(0,R.jsx)(dq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,R.jsx)(fq,{rows:n,render:e=>(0,R.jsx)(yq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function xq({share:e}){return(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${oq(e.agent)}`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`text-[0.8125rem]`,children:KU(e.agent)}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,YK(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function Sq({share:e}){return(0,R.jsx)(`div`,{className:`flex h-6 gap-0.5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,R.jsx)(pq,{className:`${oq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function Cq({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,R.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,R.jsx)(fq,{rows:e,render:e=>(0,R.jsx)(hq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:YK(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function wq({timeShare:e}){let t=e.byAgent;return(0,R.jsxs)(dq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(Sq,{share:t}),(0,R.jsx)(xq,{share:t})]}),(0,R.jsx)(Cq,{times:e.taskTimes})]})}function Tq(e){return(0,R.jsx)(LD,{...e})}function Eq(e){return(0,R.jsx)(VD,{"data-slot":`select-value`,...e})}function Dq({className:e,children:t,...n}){return(0,R.jsxs)(zD,{"data-slot":`select-trigger`,className:q(`reui-select flex h-9 min-w-36 items-center justify-between gap-3 rounded-lg border px-3 text-xs outline-none focus-visible:ring-3 focus-visible:ring-ring/30 disabled:opacity-50`,e),...n,children:[t,(0,R.jsx)(HD,{asChild:!0,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function Oq({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,R.jsx)(GD,{children:(0,R.jsxs)(qD,{"data-slot":`select-content`,position:n,align:r,sideOffset:4,className:q(`reui-menu z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) origin-(--radix-select-content-transform-origin) overflow-hidden rounded-xl border p-1 shadow-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 motion-reduce:animate-none`,e),...i,children:[(0,R.jsx)(_O,{className:`flex justify-center py-1`,children:(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,R.jsx)(aO,{children:t}),(0,R.jsx)(yO,{className:`flex justify-center py-1`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function kq({className:e,children:t,...n}){return(0,R.jsxs)(dO,{"data-slot":`select-item`,className:q(`relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-3 text-xs outline-none select-none data-highlighted:bg-accent data-disabled:opacity-50`,e),...n,children:[(0,R.jsx)(pO,{children:t}),(0,R.jsx)(hO,{className:`absolute right-2`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function Aq({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`flex h-8 w-full rounded-lg border border-input bg-background px-3 py-1 text-base transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:disabled:bg-input/80`,e),...n})}var jq=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function Mq(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Nq({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=Mq(new Date),[i,a]=(0,m.useState)(r),[o,s]=(0,m.useState)(r),[c,l]=(0,m.useState)(``);function u(t){if(n(t),l(``),t===`all`)e({});else if(t===`range`)i&&o&&i<=o&&e({from:i,to:o});else{let n=new Date;t===`week`&&n.setDate(n.getDate()-6),e({from:Mq(n),to:r})}}return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,R.jsxs)(Tq,{value:t,onValueChange:u,children:[(0,R.jsx)(Dq,{"aria-label":`Metrics period`,children:(0,R.jsx)(Eq,{})}),(0,R.jsx)(Oq,{children:jq.map(e=>(0,R.jsx)(kq,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-wrap items-end gap-2`,onSubmit:t=>{if(t.preventDefault(),!i||!o||i>o){l(`Choose an end date on or after the start date.`);return}l(``),e({from:i,to:o})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,R.jsx)(Aq,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,R.jsx)(Aq,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function Pq({label:e,value:t,sub:n}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var Fq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Iq({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,R.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,R.jsx)(Pq,{label:`Calls`,value:Fq(e.calls,`call`),sub:`${ZK(e.ok,e.calls)} ok`}),(0,R.jsx)(Pq,{label:`Speed`,value:`p50 ${eq(e.p50Ms)}`,sub:`p90 ${eq(e.p90Ms)}`}),(0,R.jsx)(Pq,{label:`Read`,value:e.input>0?`${$K(e.input)} tokens`:`—`}),(0,R.jsx)(Pq,{label:`Routed down`,value:e.routed>0?Fq(e.routed,`run`):`none`,sub:e.routed>0?`${ZK(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,Fq(e.seatRunsSkipped,`seat run`),` skipped · `,Fq(e.questionsAnswered,`question`),` answered · `,Fq(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,R.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var Lq=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function Rq(e,t=0){return e>0?e.toFixed(t):`—`}function zq(e){return[String(e.runs),ZK(e.successes,e.runs),XK(e.avgMs),XK(e.p50Ms),XK(e.p90Ms),Rq(e.avgTurns,1),Rq(e.avgTools,1),e.avgTokens>0?$K(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,QK(e.avgCost),QK(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function Bq(e,t){return t===`model-kind`?sq(e.kinds[0]??``):e.kinds.map(sq).join(`, `)}function Vq({groups:e,groupBy:t}){return(0,R.jsxs)(`section`,{className:`card-raised flex min-h-0 flex-col gap-2 overflow-hidden rounded-xl border pt-4`,"aria-label":`All models`,children:[(0,R.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`All models`}),(0,R.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,tabIndex:0,role:`region`,"aria-label":`All model metrics, scroll horizontally to see all columns`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),Lq.map(e=>(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,R.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:Bq(e,t)||`—`}),zq(e).map((e,t)=>(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},Lq[t]))]},rq(e,t)))})]})})]})}var Hq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function Uq({label:e,value:t,sub:n,dot:r}){return(0,R.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${Hq[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function Wq({tiles:e}){let t=tq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,R.jsx)(Uq,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,R.jsx)(Uq,{label:`Success`,value:ZK(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,R.jsx)(Uq,{label:`Avg run`,value:XK(e.avgMs),sub:`p90 ${XK(e.p90Ms)}`}),(0,R.jsx)(Uq,{label:`Cost`,value:QK(e.cost),sub:e.runs>0?`${QK(e.cost/e.runs)} per run`:`—`}),(0,R.jsx)(Uq,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${YK(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var Gq=`No runs recorded yet. Every Master turn, subagent run, quick fix and planning round lands here with its model, thinking level, time, tokens and cost.`;function Kq({groupBy:e,onGroup:t}){return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=[`model`,`model-kind`],a=i[(i.indexOf(e)+r+i.length)%i.length];t(a),requestAnimationFrame(()=>n.currentTarget.querySelector(`[aria-checked='true']`)?.focus())},children:[`model`,`model-kind`].map(n=>(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,role:`radio`,tabIndex:e===n?0:-1,className:e===n?`bg-card text-foreground shadow-card hover:bg-card`:`text-muted-foreground`,"aria-checked":e===n,onClick:()=>t(n),children:nq(n)},n))})}function qq({query:e,onQuery:t}){return(0,R.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,R.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{id:`metrics-search`,type:`search`,value:e,maxLength:500,placeholder:`Search runs: model, agent, tool…`,onChange:e=>t(e.target.value),className:`h-8 w-64 max-w-full rounded-lg border border-input bg-background pr-9 pl-8 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`}),(0,R.jsx)(aA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function Jq({data:e,groupBy:t,query:n}){let r=e=>rq(e,t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(Wq,{tiles:e.tiles}),e.tiles.runs===0?(0,R.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}" in this period.`:`No runs in this period. ${Gq}`}):null,e.daily.length>0?(0,R.jsx)(uq,{daily:e.daily}):null,e.classifier?(0,R.jsx)(Iq,{summary:e.classifier}):null,e.tiles.runs>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(gq,{groups:e.groups,label:r}),(0,R.jsx)(bq,{groups:e.groups,label:r})]}),(0,R.jsx)(Vq,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,R.jsx)(wq,{timeShare:e.timeShare}):null]})}function Yq(){return(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,role:`status`,"aria-label":`Loading metrics`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function Xq(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=WA(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,R.jsx)(RA,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,R.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,R.jsx)(Nq,{onChange:a}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-end gap-3 lg:w-auto lg:flex-1 lg:justify-end`,children:[(0,R.jsx)(Kq,{groupBy:e,onGroup:t}),(0,R.jsx)(qq,{query:n,onQuery:r})]}),(0,R.jsxs)(`p`,{className:`w-full text-xs text-muted-foreground`,children:[i.from?`${i.from} – ${i.to}`:`All recorded dates`,` · `,o,`. Runs and active tasks use their start date; completed tasks use their completion date.`]})]}),s.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,R.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,R.jsx)(Jq,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,R.jsx)(Yq,{})})]})}var Zq=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function Qq(e,t){return JSON.stringify([e,`prompt`,t])}function $q(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function eJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var tJ=`bot-lobby.prompt-sound-muted`,nJ=new Set,rJ,iJ=!1;function aJ(){try{return localStorage.getItem(tJ)===`on`}catch{return iJ}}function oJ(e){iJ=e;try{localStorage.setItem(tJ,e?`on`:`off`)}catch{}for(let e of nJ)e()}function sJ(e){return nJ.add(e),()=>{nJ.delete(e)}}function cJ(){return(0,m.useSyncExternalStore)(sJ,aJ,()=>!1)}function lJ(){(0,m.useEffect)(()=>{let e=()=>{try{rJ??=new AudioContext,rJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function uJ(){if(!aJ()&&rJ&&rJ.state===`running`)try{let e=rJ.currentTime,t=rJ.createOscillator(),n=rJ.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(rJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var dJ=`bot-lobby.notifications`,fJ=`/icon-192.png`,pJ=new Set;function mJ(){for(let e of[...pJ])e()}function hJ(){try{return localStorage.getItem(dJ)===`on`}catch{return!1}}function gJ(e){return pJ.add(e),()=>{pJ.delete(e)}}function _J(e){try{localStorage.setItem(dJ,e?`on`:`off`)}catch{}mJ()}function vJ(){return(0,m.useSyncExternalStore)(gJ,hJ,()=>!1)}async function yJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(_J(!0),`granted`):`denied`)}function bJ(){_J(!1)}function xJ(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function SJ(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function CJ(e){try{new Notification(`bot-lobby`,{body:e,icon:fJ,tag:`bot-lobby`})}catch{}}function wJ(){try{return new Zq(sessionStorage)}catch{return new Zq}}function TJ(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?$q(e,t.sessionId??n.key??t.from,n.dialog.id):Qq(e,t.id)}function EJ(){let e=vJ();lJ(),BA();let t=WA(`tasks.list`,{},[`tasks`]),n=WA(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(wJ()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=P()??`current`,l=fe.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function DJ(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>uJ()),c&&SJ()&&CJ(r),t===`delivery`&&H.info(r,{action:{label:`Review tasks`,onClick:()=>wA(`#/tasks`)}}))}function OJ(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;DJ(e,`prompts`,(a??[]).map(e=>TJ(i,e)),`A question is waiting for you.`,!!a&&!t.loading),DJ(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>$q(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),DJ(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>eJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function kJ(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}OJ(e);let s=a?.task?.state??``,c=xJ(s);i.current&&c&&s!==i.current&&o&&SJ()&&CJ(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function AJ(){let e=EJ(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>kJ(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function jJ({className:e,thumbClassName:t,...n}){return(0,R.jsx)(RO,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:q(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors duration-150 outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(BO,{"data-slot":`switch-thumb`,className:q(`pointer-events-none block size-4 rounded-full bg-white shadow-sm ring-0 transition-transform duration-200 ease-snap data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`,t)})})}var MJ=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],NJ=`M32 17 C28 10 19 12 17 19 C10 19 7 26 10 32 C5 38 9 46 15 47 C16 54 25 56 32 50 C39 56 48 54 49 47 C55 46 59 38 54 32 C57 26 54 19 47 19 C45 12 36 10 32 17Z`,PJ=`M32 17 C28 12 21 12 18 19 C12 19 9 25 11 31 C7 36 9 44 15 46 C16 53 26 55 32 50 C38 55 48 53 49 46 C55 44 57 36 53 31 C55 25 52 19 46 19 C43 12 36 12 32 17Z`,FJ=[`M19 22 C16 25 17 29 22 29 C27 29 28 33 25 36`,`M12 35 C16 32 20 35 18 39 C16 43 20 47 24 45`,`M25 17 C22 20 26 22 28 22 C31 23 29 27 26 27`,`M11 42 C13 44 16 42 15 39 M22 49 C26 49 29 45 27 41`,`M15 25 C12 27 14 31 17 31 M21 32 C22 35 20 37 22 39 C24 41 28 38 29 35`,`M20 18 C22 18 23 20 21 22 M24 24 C21 23 20 25 21 27 M12 37 C14 36 16 38 15 40 M20 43 C23 44 25 42 24 40 M28 29 C30 30 30 32 28 33`];function IJ({level:e,className:t}){let n=xf(),r=Math.max(0,MJ.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===MJ.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,R.jsxs)(`svg`,{viewBox:`0 0 64 72`,"data-slot":`effort-mascot`,"data-level":e,"data-folds":i*2,"data-elevated":a||void 0,"aria-hidden":`true`,focusable:`false`,className:q(`size-16 shrink-0 overflow-visible`,t),children:[(0,R.jsxs)(`defs`,{children:[(0,R.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,R.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,R.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,R.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,R.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,R.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,R.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,R.jsxs)(`feMerge`,{children:[(0,R.jsx)(`feMergeNode`,{}),(0,R.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,R.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,R.jsx)(`path`,{d:NJ})}),(0,R.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,R.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,R.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,R.jsx)(B.circle,{"data-brain-halo":!0,cx:`32`,cy:`32`,r:`33`,fill:`url(#${o}-halo)`,initial:!1,animate:{opacity:n?.8:[.65,1,.65]},transition:{duration:n?0:3,repeat:n?0:1/0}}):null,(0,R.jsxs)(B.g,{"data-brain-body":!0,initial:!1,animate:{y:a?n?-5:[-5,-7,-5]:0},transition:{duration:n?0:a?3:.3,repeat:a&&!n?1/0:0,ease:`easeInOut`},stroke:`url(#${o}-ink)`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,filter:a?`url(#${o}-glow)`:void 0,children:[a?[`cyan`,`magenta`].map(e=>(0,R.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,R.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,R.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,R.jsx)(`path`,{d:r<=3?PJ:NJ,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,R.jsx)(`path`,{d:`M32 17 C29 24 34 28 32 34 C30 40 34 45 32 50`,fill:`none`,opacity:r===0?.35:.8}),[!1,!0].map(e=>(0,R.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:FJ.slice(0,i).map((e,t)=>(0,R.jsx)(B.path,{"data-brain-fold":!0,d:e,initial:!n&&{opacity:0,pathLength:0},animate:{opacity:.85,pathLength:1},transition:{duration:n?0:.3,delay:n?0:t*.025}},e))},String(e))),r>0&&r<5?(0,R.jsx)(`g`,{stroke:`none`,fill:`var(--primary)`,children:[[20,27],[43,36],[25,44]].slice(0,Math.min(r,3)).map(([e,t],n)=>(0,R.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,R.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,R.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,R.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,R.jsx)(`path`,{d:NJ,fill:`url(#${o}-hologram)`}),(0,R.jsx)(`rect`,{"data-brain-scan":!0,className:`brain-phase-scan`,x:`7`,y:`14`,width:`50`,height:`2`,fill:`var(--rainbow-5)`,opacity:`0.45`})]}):null]}),a?(0,R.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,R.jsx)(`path`,{d:`M0 -3 L0.8 -0.8 L3 0 L0.8 0.8 L0 3 L-0.8 0.8 L-3 0 L-0.8 -0.8Z`,transform:`translate(${e} ${t})`},e))}):null]})}var LJ={minimal:`min`,medium:`med`},RJ={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function zJ(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}function BJ(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}function VJ({value:e,levels:t,supported:n,model:r,label:i,disabled:a,onChange:o}){let s=(0,m.useRef)(null),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),f=(0,m.useRef)(void 0),p=(0,m.useRef)(0),h=(0,m.useCallback)(()=>{f.current=void 0,p.current=0,d(void 0)},[]),g=Math.max(t.length-1,1),_=zJ(t,n,Math.max(0,t.indexOf(e))),v=c??u??_,y=v<0?0:v/g*100,b=t[v]??e,x=v>=0&&b!==e;(0,m.useEffect)(()=>{if(u===void 0)return;let e=window.setTimeout(h,1e4);return()=>window.clearTimeout(e)},[u,h]);let S=(0,m.useCallback)(e=>{let r=s.current?.getBoundingClientRect();if(!r||r.width===0)return _;let i=Math.min(1,Math.max(0,(e-r.left)/r.width));return zJ(t,n,Math.round(i*g))},[g,t,_,n]);function C(e){a||n.length===0||(e.currentTarget.setPointerCapture(e.pointerId),l(S(e.clientX)))}function w(e){if(c===void 0)return;let t=S(e.clientX);t!==c&&l(t)}function T(){if(c===void 0)return;let n=t[c];l(void 0),n&&n!==e&&o(n)}function E(e){if(a||v<0)return;let r=f.current??v,i={ArrowRight:BJ(t,n,r,1),ArrowUp:BJ(t,n,r,1),ArrowLeft:BJ(t,n,r,-1),ArrowDown:BJ(t,n,r,-1),Home:zJ(t,n,0),End:zJ(t,n,g)}[e.key];if(i===void 0)return;e.preventDefault();let s=t[i];s&&i!==r&&(f.current=i,d(i),p.current+=1,Promise.resolve(o(s)).catch(()=>void 0).then(()=>{--p.current,p.current<=0&&h()}))}return(0,R.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,R.jsx)(IJ,{level:b}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:RJ[b]??``})]}),(0,R.jsxs)(`div`,{ref:s,role:`slider`,tabIndex:a?-1:0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":Math.max(v,0),"aria-valuetext":b,"aria-disabled":a||void 0,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:()=>l(void 0),onKeyDown:E,className:`relative mx-2.5 h-6 touch-none cursor-pointer rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-muted`}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:`absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-primary`,animate:{width:`${y}%`},transition:{type:`spring`,stiffness:520,damping:34}}),t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,title:i?e:`${r??`This model`} does not support ${e}`,className:q(`absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full`,i?t<=v?`bg-primary-foreground/80`:`bg-muted-foreground/40`:`bg-transparent ring-1 ring-muted-foreground/30`),style:{left:`${t/g*100}%`}},e)}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:q(`absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm`,c!==void 0&&`scale-110`),animate:{left:`${y}%`},transition:{type:`spring`,stiffness:520,damping:28}})]}),(0,R.jsx)(`div`,{className:`relative mx-2.5 h-3.5 text-[0.68rem] text-muted-foreground`,"aria-hidden":`true`,children:t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{title:i?void 0:`${r??`This model`} does not support ${e}`,className:q(`absolute -translate-x-1/2 whitespace-nowrap`,t===v&&`font-medium text-foreground`,!i&&`opacity-40`),style:{left:`${t/g*100}%`},children:LJ[e]??e},e)})}),x?(0,R.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function HJ(e){return(0,R.jsx)(_D,{...e})}function UJ(e){return(0,R.jsx)(vD,{"data-slot":`popover-trigger`,...e})}function WJ({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(yD,{children:(0,R.jsx)(bD,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-xl border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}function GJ(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function KJ({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>GJ(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,R.jsxs)(HJ,{open:o,onOpenChange:s,children:[(0,R.jsxs)(UJ,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:q(`reui-select flex h-8 w-full min-w-0 items-center justify-between gap-2 overflow-hidden rounded-lg border bg-card px-2.5 text-[0.8125rem] whitespace-nowrap outline-none transition-[border-color,box-shadow] duration-150 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50`,i),children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(WJ,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,R.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-[0.8125rem] outline-none placeholder:text-muted-foreground`})]}),(0,R.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,R.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,R.jsxs)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:q(`flex cursor-default items-center gap-2 rounded-lg px-2.5 py-1.5 text-[0.8125rem] select-none`,n===u&&`bg-accent`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function qJ({label:e,help:t,children:n,stacked:r}){return(0,R.jsxs)(`div`,{className:r?`grid gap-1.5`:`grid gap-1.5 sm:grid-cols-[minmax(0,1fr)_minmax(0,18rem)] sm:items-center sm:gap-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,R.jsx)(`div`,{className:`min-w-0`,children:n})]})}function JJ({children:e}){return(0,R.jsx)(GK,{dense:!0,children:(0,R.jsx)(KK,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function YJ({value:e,items:t,label:n,onChange:r}){return(0,R.jsx)(KJ,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var XJ=`(prefers-color-scheme: dark)`,ZJ=[`dark`,`light`,`system`],QJ=m.createContext(void 0);function $J(e){return e!==null&&ZJ.includes(e)}function eY(){return window.matchMedia(XJ).matches?`dark`:`light`}function tY(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function nY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function rY({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return $J(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?eY():e,i=r?tY():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(XJ),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||nY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:eY()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if($J(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,R.jsx)(QJ.Provider,{...i,value:l,children:e})}var iY=()=>{let e=m.useContext(QJ);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},aY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],oY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},sY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},cY=`inherit`,lY=`inherit`,uY=`Use the session's current model`,dY=`__custom__`,fY=`custom…`,pY=`Type a provider/model id`,mY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],hY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},gY=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`},{id:`issues`,label:`Issues tab`,help:`the GitHub Issues tab`}],_Y=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],vY=`shown on the Lobby tab`,yY=`Planning rounds`,bY=`how many rounds the panel gets before the oracle settles the rest alone`,xY=[2,3,5,8,0],SY=`Split long plans`,CY=`saving a plan with more steps offers to split it into up to 5 tasks`,wY=[6,8,10,12,0],TY=`Port`,EY=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,DY=`Open browser`,OY=`open this page in the browser when pi starts`,kY=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],AY=`Git isolation`,jY=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],MY={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},NY=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],PY=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, Jev reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, Jev picks the sections that bear on the step, and the agent is told where the rest is`},{id:`files`,label:`File hints`,help:`scouts, workers, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],FY={enabled:`Classifier`,enabledHelp:`Jev makes the obvious decisions so large models spend fewer tokens on them`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},IY={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},LY=`https://tweakcn.com/editor/theme`;function RY(){let{theme:e}=iY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function zY({palette:e,dark:t}){let n=se(e,t);return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,R.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,R.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,R.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function BY(){let e=Ue(),t=RY(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,R.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:q(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,R.jsx)(zY,{palette:n,dark:t}),(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,R.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,R.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function VY({entry:e}){let t=Ue(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),H.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,R.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,R.jsx)(Aq,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64`}),(0,R.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,R.jsx)(X,{label:`Keep the old name`,icon:Ug,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,R.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,R.jsx)(Kj,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Tg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>H.error(e.message))})]}),o?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function HY(){let e=Ue();return e.saved.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,R.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,R.jsx)(VY,{entry:e},e.id))})}function UY(){let e=Ue(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;H.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,R.jsxs)(`a`,{href:LY,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,R.jsx)(Dm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,R.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,R.jsx)(Aq,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground`})]}),(0,R.jsx)(Aj,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
91
|
+
`).filter(Boolean),r=[];for(let t of n){let n=qV.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var YV=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function XV({files:e}){return e.length===0?null:(0,R.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,R.jsx)(`li`,{children:YV.has(e.mime)?(0,R.jsx)(`a`,{href:F(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02]`,children:(0,R.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-56 object-cover`})}):(0,R.jsxs)(`span`,{className:`inline-flex max-w-64 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var ZV=!1,QV=[],$V=0,eH=900;function tH(){ZV=!0,window.clearTimeout($V),$V=window.setTimeout(nH,eH)}function nH(){ZV=!1,window.clearTimeout($V);let e=QV;QV=[];for(let t of e)t()}function rH(e){if(!ZV)return e(),()=>{};let t=()=>e();return QV.push(t),()=>{QV=QV.filter(e=>e!==t)}}var iH=8;function aH(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=rH(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Wv.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*iH/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function oH(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(oH).join(``)}function sH(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),sH(t,n)}function cH(){return e=>sH(e)}function lH(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await KV(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function uH({text:e,children:t,block:n=!1}){let{copy:r}=lH(e),i=(0,m.useRef)(void 0);return(0,R.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),GV(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),GV(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,R.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function dH({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=lH(WV(n,r?.position,!0)??oH(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,R.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,R.jsx)(X,{label:i?`Copied`:`Copy the code`,icon:i?Vp:Cm,iconOnly:!0,onClick:()=>void a()})]}),(0,R.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function fH(e){return{pre:t=>(0,R.jsx)(dH,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,R.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,R.jsx)(uH,{text:WV(e,r?.position,i)??oH(r),block:i,children:n})},a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,R.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,R.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var pH=(0,m.memo)(function({text:e}){return(0,R.jsx)(AR,{remarkPlugins:[IV],rehypePlugins:[cH],urlTransform:RV,components:fH(e),children:e})}),mH=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=JV(e),i=n?UV(n):[],a=aH(i.length,3);return(0,R.jsxs)(`div`,{className:q(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,R.jsx)(pH,{text:e},t)),(0,R.jsx)(XV,{files:r})]})});function hH({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,R.jsxs)(`section`,{className:q(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,R.jsxs)(`div`,{className:q(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,R.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:[o?(0,R.jsx)(aA,{chord:o,className:`kbd-hint`}):null,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function gH({title:e,right:t,className:n}){return(0,R.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,R.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function _H({title:e,right:t,prominent:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs`),children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,R.jsx)(gH,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var vH=`Pull requests`,yH=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,bH=`nothing is posted to GitHub`,xH=`Refresh to load open pull requests with the GitHub CLI (gh).`,SH=`No open pull requests.`,CH=`loading pull requests from GitHub…`,wH=`reading the diff…`,TH=`the pull request has new commits since this review — review it again`,EH=`(no description)`,DH=`Review with a focus (optional)`,OH=`Leave it empty for a full review.`;function kH(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function AH(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function jH(e,t){return`+${e} −${t}`}function MH(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function NH(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function PH(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function FH(e,t){if(e.status===`running`)return IH(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?IH(e,t):e.status;return[PH(e.verdict),n].filter(Boolean).join(` · `)}function IH(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function LH(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Fj(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function RH(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${jH(e.additions,e.deletions)} · ${t}`}function zH(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,MH(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function BH(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function VH(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function HH(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function UH({pull:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:LH(e,t)}),(0,R.jsx)(`p`,{className:`text-sm tabular-nums`,children:RH(e)}),zH(e)?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:zH(e)}):null,e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`text-xs break-all text-primary underline underline-offset-4`,children:e.url}):null]})}function WH({read:e}){return(0,R.jsxs)(_H,{title:`Jev's read`,right:VH(e),children:[e.status===`running`?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),wH]}):null,e.status===`failed`?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,R.jsx)(mH,{text:e.line}):null]})}function GH({review:e,now:t}){return(0,R.jsxs)(R.Fragment,{children:[e.model?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,Fj(t-e.startedAt)]}):null,e.stale?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:TH}):null,e.status===`running`?(0,R.jsx)(KH,{steps:e.steps}):null,e.status===`cancelled`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,R.jsx)(mH,{text:e.text}):null]})}function KH({steps:e}){return(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,R.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function qH({number:e,focus:t,onChange:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:DH}),(0,R.jsx)(Aj,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:OH})]})}function JH({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,R.jsxs)(_H,{title:`Review`,right:t?FH(t,n):void 0,children:[t?(0,R.jsx)(GH,{review:t,now:n}):null,(0,R.jsx)(qH,{number:e,focus:r,onChange:i}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,bH,`.`]})]})}function YH({files:e}){return(0,R.jsx)(_H,{title:`Files`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:jH(e.additions,e.deletions)})]},e.path))})})})})}function XH({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?Fj(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,R.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,R.jsx)(mH,{text:e.body.trim()}):null]})}function ZH({notes:e,now:t}){return e.length===0?null:(0,R.jsx)(_H,{title:`Discussion`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(XH,{note:e,now:t},n))})})}function QH({number:e,error:t}){return t?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),`loading #`,e,`…`]})}function $H({number:e,onChanged:t}){let n=WA(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=HH(a);if(!n.data)return(0,R.jsx)(QH,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Review`,icon:Uh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,R.jsx)(X,{label:`Jev's read`,icon:Fp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,R.jsx)(Kj,{icon:dm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,R.jsx)(UH,{pull:s,now:o}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:yH}),l?(0,R.jsx)(WH,{read:l}):null,(0,R.jsx)(JH,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,R.jsx)(YH,{files:s.files}):null,(0,R.jsx)(_H,{title:`Description`,children:s.body.trim()?(0,R.jsx)(mH,{text:s.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:EH})}),(0,R.jsx)(ZH,{notes:s.notes,now:o})]})}var eU=Xg([`relative inline-flex shrink-0 items-center justify-center w-fit border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3`],{variants:{variant:{default:`bg-primary text-primary-foreground`,outline:`border-border bg-transparent dark:bg-input/32`,secondary:`bg-secondary text-secondary-foreground`,info:`bg-info text-white`,success:`bg-success text-white`,warning:`bg-warning text-white`,destructive:`bg-destructive text-white`,focus:`bg-focus text-focus-foreground`,invert:`bg-invert text-invert-foreground`,"primary-light":`border-primary/10 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/15 dark:text-primary`,"warning-light":`border-warning/15 bg-warning/10 text-warning-foreground dark:border-warning/25 dark:bg-warning/15 dark:text-warning`,"success-light":`border-success/15 bg-success/10 text-success-foreground dark:border-success/25 dark:bg-success/15 dark:text-success`,"info-light":`border-info/15 bg-info/10 text-info-foreground dark:border-info/25 dark:bg-info/15 dark:text-info`,"destructive-light":`border-destructive/15 bg-destructive/10 text-destructive-foreground dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive`,"invert-light":`border-invert/15 bg-invert/10 text-foreground dark:border-invert/45 dark:bg-invert/35 dark:text-invert-foreground`,"focus-light":`border-focus/15 bg-focus/10 text-focus-foreground dark:border-focus/25 dark:bg-focus/15 dark:text-focus`,"primary-outline":`bg-background border-border text-primary dark:bg-input/30`,"warning-outline":`bg-background border-border text-warning-foreground dark:bg-input/30`,"success-outline":`bg-background border-border text-success-foreground dark:bg-input/30`,"info-outline":`bg-background border-border text-info-foreground dark:bg-input/30`,"destructive-outline":`bg-background border-border text-destructive-foreground dark:bg-input/30`,"invert-outline":`bg-background border-border text-invert-foreground dark:bg-input/30`,"focus-outline":`bg-background border-border text-focus-foreground dark:bg-input/30`},size:{xs:`px-1 py-0.25 text-[0.6rem] leading-none h-4 min-w-4 gap-1`,sm:`px-1 py-0.25 text-[0.625rem] leading-none h-4.5 min-w-4.5 gap-1`,default:`px-1.25 py-0.5 text-xs h-5 min-w-5 gap-1`,lg:`px-1.5 py-0.5 text-xs h-5.5 min-w-5.5 gap-1`,xl:`px-2 py-0.75 text-sm h-6 min-w-6 gap-1.5`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function tU({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?jv:`span`;return(0,R.jsx)(o,{"data-slot":`badge`,className:q(eU({variant:t,size:n,radius:r,className:e})),...a})}var nU=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:border-primary/40 aria-[current=true]:bg-accent`,rU=`flex flex-col gap-1 px-2 pb-3`,iU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function aU({checks:e}){let t=kH(e);return t?(0,R.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,AH(e)),"aria-hidden":`true`,children:t}):(0,R.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function oU({pull:e,selected:t,onSelect:n}){let r=NH(e.review);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(aU,{checks:e.checks}),e.draft?(0,R.jsx)(tU,{variant:`secondary`,children:`draft`}):null,(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:BH(e)}),(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,R.jsx)(`span`,{children:r}):null,(0,R.jsx)(`span`,{className:`tabular-nums`,children:jH(e.additions,e.deletions)})]})]})]})})}function sU({pulls:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(oU,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var cU=()=>wA(CA(`git`)),lU=e=>wA(CA(`git`,String(e)));function uU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function dU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?SH:e?CH:xH;return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Um,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function fU({rest:e}){let t=Cj(),n=WA(`git.pulls`,{},[`git`]),r=uU(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,R.jsx)(dU,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:vH,count:n.data?`${i.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,R.jsx)(sU,{pulls:i,selectedId:r,onSelect:lU}):(0,R.jsx)(kj,{})]}),c=r===void 0?null:(0,R.jsx)($H,{number:r,onChanged:n.reload},r);return(0,R.jsx)(Dj,{wide:t,list:s,detail:c,open:r!==void 0,onClose:cU,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function pU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function mU({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(Aj,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{pU(e)&&(e.preventDefault(),l())}}),t?(0,R.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:n,icon:s?rh:Np,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var hU=`Issues`,gU=`Issue`,_U=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,vU=`Refresh to load open issues with the GitHub CLI (gh).`,yU=`No open issues. File one with New issue.`,bU=`loading issues from GitHub…`,xU=`issues are off (lobby.issues)`,SU=`(no description)`;function CU(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${Fj(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function wU(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?Fj(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function TU(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function EU({issue:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:CU(e,t)}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`text-xs break-all text-primary underline underline-offset-4`,children:e.url}):null]})}function DU({comment:e,now:t}){return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,R.jsx)(`span`,{children:Fj(t-Date.parse(e.createdAt))}):null]}),(0,R.jsx)(mH,{text:e.body.trim()})]})}function OU({comments:e,now:t}){return e.length===0?null:(0,R.jsx)(_H,{title:`Comments`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(DU,{comment:e,now:t},n))})})}function kU({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&wA(CA(`plan`))};return(0,R.jsx)(Kj,{icon:Vg,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function AU({number:e}){let t=WA(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${gU} #${e}`,children:[(0,R.jsx)(mj,{children:(0,R.jsx)(kU,{issue:r})}),(0,R.jsx)(EU,{issue:r,now:n}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_U}),(0,R.jsx)(_H,{title:`Description`,children:r.body.trim()?(0,R.jsx)(mH,{text:r.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:SU})}),(0,R.jsx)(OU,{comments:r.comments,now:n})]})}function jU({issue:e,selected:t,now:n,onSelect:r}){let i=TU(e.labels);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,R.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,R.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:wU(e,n)})]})})}function MU({issues:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(jU,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var NU=()=>wA(CA(`issues`)),PU=e=>wA(CA(`issues`,String(e)));function FU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function IU(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(AA,{children:`Issues are off`}),(0,R.jsx)(jA,{className:`font-mono`,children:xU})]})})}function LU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?yU:e?bU:vU;return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function RU({onCreate:e}){return(0,R.jsx)(wj,{className:`shrink-0 border-t border-border p-4`,children:(0,R.jsx)(mU,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function zU({rest:e}){let t=Cj(),n=HA(`status`).data?.issuesEnabled??!0,r=WA(`issues.list`,{},[`issues`],n),i=FU(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{U(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await U(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,R.jsx)(IU,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,R.jsx)(IU,{}):(0,R.jsx)(RA,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:hU,count:r.data?`${a.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,R.jsx)(MU,{issues:a,selectedId:i,now:o,onSelect:PU}):(0,R.jsx)(kj,{}),(0,R.jsx)(RU,{onCreate:c})]}),d=i===void 0?null:(0,R.jsx)(AU,{number:i},i),f=r.data&&a.length===0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(LU,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,R.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,R.jsx)(RU,{onCreate:c})})]}):(0,R.jsx)(Dj,{wide:t,list:u,detail:d,open:i!==void 0,onClose:NU,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function BU(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var VU={DEV:ym,DESIGN:Dh,QA:lg,RESEARCH:xg,"QUICK FIX":Gg,SCOUT:xm,PLANNER:tg,CLASSIFIER:yg,LOBBY:hh,LINT:$m};function HU(e){return e?VU[e.toUpperCase()]??Lp:zp}function UU(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function WU({source:e,className:t,strokeWidth:n}){if(UU(e))return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=HU(e);return(0,R.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var GU={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function KU(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function qU(e){return GU[e]??`text-muted-foreground`}var JU={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function YU(e){return JU[e]??`var(--muted-foreground)`}function XU(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function ZU(e){return e?.runs??[]}function QU(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function $U({source:e,live:t}){let n=UU(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":YU(e)},children:(0,R.jsx)(WU,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function eW({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,R.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,R.jsx)(`div`,{className:`chat-gutter`,children:r?(0,R.jsx)($U,{source:e,live:i}):n?(0,R.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,R.jsxs)(`p`,{className:`chat-speaker`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,R.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,R.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,R.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":YU(e)},children:a}):a]})]})}function tW({time:e,head:t,note:n,children:r,below:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,R.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,R.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,R.jsx)(`span`,{children:n}):null]}):null,(0,R.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function nW({failed:e,children:t}){return(0,R.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,R.jsx)(`span`,{children:t})})}function rW({className:e}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{})]})}var iW=3e5,aW=`No task is running in this session.`,oW=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,sW=`Nothing said yet. Type below to talk to the oracle about this task.`;function cW({entry:e}){return(0,R.jsxs)(nW,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${Mj(e.at)}`:``]})}function lW({entry:e,head:t}){if(e.role===`you`)return(0,R.jsx)(tW,{time:Mj(e.at),head:t,children:(0,R.jsx)(mH,{text:e.text})});let n=e.role===`panel`;return(0,R.jsx)(eW,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:Mj(e.at),head:t,children:(0,R.jsx)(mH,{text:e.text})})}var uW=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,R.jsx)(B.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,R.jsx)(cW,{entry:e}):(0,R.jsx)(lW,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at);function dW({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,R.jsx)(eW,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,R.jsx)(mH,{text:e??``}):(0,R.jsx)(rW,{className:`mt-1`})})}function fW({hasTask:e}){return(0,R.jsxs)(EA,{className:`h-full border-0`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(ph,{"aria-hidden":`true`})}),e?null:(0,R.jsx)(AA,{children:aW}),(0,R.jsx)(jA,{children:e?sW:oW})]}),e?null:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,R.jsx)(aA,{chord:`3`}),` Plan`]}),(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,R.jsx)(aA,{chord:`4`}),` Quick fix`]})]})]})}async function pW(e){let t=await Te(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function mW(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await pW(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}function hW({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i}){let{ref:a,atBottom:o,stick:s,onScroll:c}=BU(e.length+(t?.length??0)),{merged:l,more:u,loading:d,load:f}=mW(e,r,a),p=(0,m.useCallback)(()=>{c();let e=a.current;e&&e.scrollTop<80&&u&&!d&&f()},[c,a,u,d,f]),h=l.length===0&&!t?.trim()&&!n,[g,_]=(0,m.useState)(!1);return(0,m.useEffect)(()=>_(!0),[]),(0,R.jsxs)(hH,{"aria-label":`Conversation`,className:`flex-1`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:p,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:h?(0,R.jsx)(fW,{hasTask:i}):(0,R.jsxs)(`div`,{className:`chat-column`,children:[u?(0,R.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,l.map((e,t)=>{let n=l[t-1],r=!n||n.role!==e.role||e.at-n.at>iW;return(0,R.jsx)(uW,{entry:e,head:r,fresh:g},e.id)}),(0,R.jsx)(dW,{text:t,busy:n})]})}),o?null:(0,R.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,R.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,tone:`primary`,className:`rounded-full shadow-sm`,onClick:s})})]})}function gW(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function _W(e,t){let{agent:n,file:r}=gW(e);return CA(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var vW=[`master`,`designer`,`backend`,`qa`],yW={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},bW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},xW=`Every write archives the version before it.`;function SW(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function CW(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function wW(e){return{text:e.text,occurrence:e.occurrence}}function TW(e){return vW.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function EW(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function DW({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,R.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,R.jsx)(Aj,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{EW(e)&&(e.preventDefault(),o())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:xW}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,R.jsxs)(Y,{onClick:o,disabled:t||!i.trim(),children:[t?(0,R.jsx)(MA,{}):null,`Save`]})]})]})]})}function OW({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=hA(e,mA.confirm);return(0,R.jsx)(sA,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:xW,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:xW})]}),(0,R.jsx)(Aj,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,R.jsxs)(Y,{onClick:()=>a(o),disabled:r,children:[r?(0,R.jsx)(MA,{}):null,`Save file`]})]})]})})}function kW({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Lh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,R.jsx)(X,{label:`Take the note back`,icon:kg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function AW({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,R.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-3 focus-visible:ring-ring/40`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`div`,{className:`flex gap-2`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(mH,{text:e.text})})}),r.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,R.jsx)(kW,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function jW({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,R.jsx)(_H,{title:`Notes on entries that changed`,right:String(e.length),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,R.jsx)(kW,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function MW({view:e}){let t=e.entries.length;return(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:[bW[e.agent],` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,SW(e.chars),` chars`]}),e.over?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:CW(e.file)}):null]})}function NW({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Edit the entry`,text:`Edit`,icon:Vh,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,R.jsx)(X,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Gh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,R.jsx)(X,{label:`Comment on the entry`,text:`Comment`,icon:dh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,R.jsx)(X,{label:`Edit the whole file`,text:`Edit file`,icon:jm,shortcut:`F`,disabled:a,onClick:r}),(0,R.jsx)(Kj,{icon:Tg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function PW({agent:e,file:t,onChanged:n}){let r=WA(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:wW(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:wW(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:wW(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:wW(h)}:{},text:n}))};return f?(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${bW[e]} ${t}`,children:[(0,R.jsx)(NW,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,R.jsx)(MW,{view:f}),p.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,R.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,R.jsx)(AW,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,R.jsx)(DW,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,R.jsx)(mU,{label:`Comment on this entry`,hint:xW,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,R.jsx)(mU,{label:`Add an entry`,hint:xW,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{}),` saving…`]}):null,(0,R.jsx)(jW,{notes:f.detached,onTakeBack:_,busy:u}),(0,R.jsx)(OW,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function FW(e){return`${e.agent}/${e.file}`}var IW={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},LW=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function RW({info:e}){return(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(`span`,{children:SW(e.chars)}),e.over?(0,R.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,R.jsx)(`span`,{className:`text-primary`,children:LW(e.notes,`note`)}):null]})}function zW({info:e,selected:t,onSelect:n}){return(0,R.jsx)(`li`,{className:`ktree-leaf`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(FW(e)),className:q(nU,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,R.jsx)(RW,{info:e})]})})}var BW=`bot-lobby.knowledge.folded`;function VW(){try{let e=JSON.parse(window.localStorage.getItem(BW)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function HW({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(VW),o=TW(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(BW,JSON.stringify(r))}catch{}return r})}return(0,R.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,R.jsxs)(`p`,{className:`ktree-root`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,R.jsx)(Fp,{className:`size-4`})}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[LW(e.length,`file`),` · `,LW(o.length,`agent`),s>0?` · ${LW(s,`note`)}`:``]})]})]}),(0,R.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=IW[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,R.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":YU(o)},children:[(0,R.jsx)(`h3`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":s,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-node`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,R.jsx)(WU,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:yW[e.agent]}),l?(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,R.jsxs)(`span`,{className:`text-primary`,children:[LW(e.notes,`note`),` · `]}):null,LW(e.files.length,`file`)]}),(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,R.jsx)(Du,{initial:!1,children:a?(0,R.jsx)(B.ul,{id:s,"aria-label":`${yW[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,R.jsx)(zW,{info:e,selected:FW(e)===n,onSelect:r},FW(e)))},`files`):null})]},e.agent)})})]})}var UW=()=>wA(CA(`knowledge`)),WW=e=>{let[t,n]=e.split(`/`);wA(CA(`knowledge`,t??``,n??``))};function GW(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Fp,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{children:`No knowledge files yet.`})]})})}function KW(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,R.jsx)(PW,{agent:i.agent,file:i.file,onChanged:r},FW(i)):t&&n?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function qW(){let e=HA(`lobby`),t=HA(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,R.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,R.jsx)(hW,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function JW({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,R.jsx)(YW,{read:e,selected:t})]})}function YW({read:e,selected:t}){return!e.data&&e.error?(0,R.jsx)(RA,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,R.jsx)(HW,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:WW}):(0,R.jsx)(GW,{}):(0,R.jsx)(kj,{})}function XW({rest:e}){let{chat:t,agent:n,file:r}=gW(e),i=Cj(),a=WA(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,R.jsx)(Dj,{wide:i,inlineDetail:!0,list:(0,R.jsx)(JW,{read:a,selected:s?FW(s):void 0}),detail:t?(0,R.jsx)(qW,{}):KW(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:UW,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function ZW(e){let t=e[0]===`board`,n=e[+!!t];try{return{board:t,id:n?decodeURIComponent(n):void 0}}catch{return{board:t,id:n}}}function QW({className:e,...t}){return(0,R.jsx)(xC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:q(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[5px] border border-input bg-background text-primary-foreground transition-colors duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,R.jsx)(CC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var $W=`Sessions`,eG=`No sessions yet.`,tG=`Up to 5 sessions; each can be assigned to one agent or several.`,nG=`A session is a live Excalidraw room that you and your agents draw in together.`,rG=[{title:`Start a live room`,text:`In Excalidraw: Share → Live collaboration → Start session.`},{title:`Add it here`,text:`Paste the room link, or make a new room and open it in Excalidraw.`},{title:`Assign agents`,text:`They read the board and draw on it, under their own name.`}],iG=`Sessions`,aG=`Pick a session on the left to see its link, its room and its agents.`,oG=`Room link`,sG=`Masked until revealed. A revealed link stays in this tab and is never saved.`,cG=`Room`,lG=`Drawing`,uG=`Last check`,dG=`not checked yet`,fG=`Add a session`,pG=`https://excalidraw.com/#room=…`,mG=`Optional name`;function hG(e){return`${e} of 5 in use`}var gG=`Agents may draw here.`,_G=`Agents may only look.`,vG=`checking the room…`,yG=`Check that the room can be reached.`,bG=`Assigned to`,xG=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,SG=`Add or rename`,CG=`Add by link`,wG=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,TG=`New room`,EG=`Makes a fresh room link to open in Excalidraw; the name is optional.`,DG=`Rename`,OG=`draw`,kG=`look only`,AG=`Copied to the clipboard`,jG=`Could not reveal the link.`,MG=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],NG={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function PG(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function FG(e){return e?e.ok?`✓`:`!`:``}function IG({title:e,right:t,className:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,R.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function LG({row:e=!1}){return(0,R.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:rG.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function RG({label:e,hint:t,buttonLabel:n,placeholder:r,initial:i=``,required:a,mono:o,primary:s,onSubmit:c}){let l=(0,m.useId)(),[u,d]=(0,m.useState)(i),[f,p]=(0,m.useState)(!1),h=a&&!u.trim(),g=async()=>{h||f||(p(!0),await c(u)&&d(i),p(!1))};return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{id:l,value:u,maxLength:o?2e3:80,placeholder:r,"aria-describedby":t?`${l}-hint`:void 0,onChange:e=>d(e.target.value),className:q(`h-8 min-w-0 flex-1 rounded-lg border border-input bg-background px-3 text-sm outline-none transition-[border-color,box-shadow] placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`,o&&`font-mono text-[0.8125rem]`)}),(0,R.jsx)(X,{type:`submit`,label:n,icon:f?rh:Gh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,R.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function zG({onChanged:e,primary:t}){return(0,R.jsx)(RG,{label:CG,hint:wG,buttonLabel:`Add`,placeholder:pG,required:!0,mono:!0,primary:t,onSubmit:async t=>await U(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function BG({onChanged:e,primary:t}){return(0,R.jsx)(RG,{label:TG,hint:EG,buttonLabel:`Create`,placeholder:mG,primary:t,onSubmit:async t=>{let n=t.trim();return await U(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function VG({onChanged:e,stacked:t=!1}){return(0,R.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,R.jsx)(zG,{onChanged:e,primary:!0}),(0,R.jsx)(BG,{onChanged:e,primary:!0})]})}function HG({session:e,onChanged:t}){return(0,R.jsx)(RG,{label:DG,initial:e.name,required:!0,buttonLabel:DG,onSubmit:async n=>await U(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function UG({icon:e,tone:t=`muted`,children:n}){return(0,R.jsxs)(`span`,{className:q(`inline-flex h-6 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,t===`primary`?`bg-accent text-primary`:t===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,R.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function WG({check:e,checking:t}){return t?(0,R.jsx)(UG,{icon:rh,children:vG}):e?e.ok?(0,R.jsx)(UG,{icon:rm,tone:`primary`,children:`reachable`}):(0,R.jsx)(UG,{icon:tm,tone:`warning`,children:`unreachable`}):(0,R.jsx)(UG,{icon:am,children:dG})}function GG({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm`,children:[(0,R.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`dd`,{className:`min-w-0`,children:t})]})}function KG({check:e,checking:t}){return t?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3.5`,"aria-hidden":`true`}),vG]}):e?(0,R.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:yG})}function qG({agent:e,on:t,onToggle:n}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-lg border px-2.5 text-sm transition-[background-color,border-color,color]`,t?`border-primary/25 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(QW,{checked:t,onCheckedChange:()=>n(e)}),(0,R.jsx)(`span`,{className:`truncate`,children:NG[e]})]})})}function JG({session:e,onChanged:t}){let n=async n=>{await U(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await U(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===MG.length;return(0,R.jsxs)(IG,{title:bG,right:PG(e.agents.length),children:[(0,R.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:MG.map(t=>(0,R.jsx)(qG,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:xG}),(0,R.jsx)(X,{label:i?`Take every agent off`:`Assign every agent`,icon:$m,onClick:()=>void r()})]})]})}function YG({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await Te(`excalidraw.reveal`,{id:e.id})).link)}catch(e){H.error(e instanceof Error?e.message:jG)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>H(AG)).catch(()=>void 0),u=async()=>{await U(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,R.jsxs)(mj,{children:[o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{label:`Copy the link`,text:`Copy`,icon:Cm,shortcut:`C`,onClick:l}),(0,R.jsx)(X,{label:`Open board`,icon:Dm,tone:`primary`,shortcut:`O`,href:o})]}):(0,R.jsx)(X,{label:`Reveal the link`,text:`Reveal`,icon:km,shortcut:`R`,onClick:()=>void c()}),(0,R.jsx)(X,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?zh:Vh,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,R.jsx)(X,{label:`Check the room`,text:`Check`,icon:n?rh:lg,shortcut:`T`,disabled:n,onClick:r}),(0,R.jsx)(Kj,{icon:Tg,label:`Remove the session`,text:`Remove`,shortcut:`Delete`,title:`Remove "${e.name}"?`,description:`Agents lose this session at once; the Excalidraw room itself is not touched.`,confirmLabel:`Remove session`,variant:`destructive`,onConfirm:a})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(UG,{icon:e.contribute?Vh:km,tone:e.contribute?`primary`:`muted`,children:e.contribute?OG:kG}),(0,R.jsx)(UG,{icon:Ng,children:PG(e.agents.length)}),(0,R.jsx)(WG,{check:t,checking:n})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,R.jsxs)(IG,{title:oG,children:[(0,R.jsx)(`p`,{className:`rounded-lg border border-border bg-muted px-3 py-2 font-mono text-[0.8125rem] break-all text-foreground`,children:o??e.masked}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:sG})]}),(0,R.jsx)(IG,{title:cG,children:(0,R.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(GG,{label:lG,children:(0,R.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?gG:_G})}),(0,R.jsx)(GG,{label:uG,children:(0,R.jsx)(KG,{check:t,checking:n})})]})})]}),(0,R.jsx)(JG,{session:e,onChanged:i})]}),(0,R.jsx)(IG,{title:SG,children:(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,R.jsx)(HG,{session:e,onChanged:i}),(0,R.jsx)(zG,{onChanged:i}),(0,R.jsx)(BG,{onChanged:i})]})})]})}function XG({check:e,checking:t}){if(t)return(0,R.jsx)(MA,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=FG(e);return n?(0,R.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,R.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function ZG({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":r?`true`:void 0,onClick:()=>i(e.id),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(XG,{check:t,checking:n}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:PG(e.agents.length)})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,R.jsx)(tU,{variant:`secondary`,children:e.contribute?OG:kG})]})]})})}function QG({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(ZG,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var $G=()=>wA(CA(`excalidraw`)),eK=e=>wA(CA(`excalidraw`,e));function tK({count:e}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:hG(e)})]})}function nK({count:e,onChanged:t}){return(0,R.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:iG}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:aG})]}),(0,R.jsx)(tK,{count:e})]}),(0,R.jsx)(LG,{row:!0}),e<5?(0,R.jsx)(IG,{title:fG,children:(0,R.jsx)(VG,{onChanged:t})}):null,(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,R.jsx)(oA,{chord:`ArrowDown`,children:`next session`}),(0,R.jsx)(oA,{chord:`ArrowRight`,children:`into its detail`})]})]})}function rK({onChanged:e}){return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock sm:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(Fh,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:eG}),(0,R.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:nG})]}),(0,R.jsx)(LG,{}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:tG})]}),(0,R.jsx)(IG,{title:fG,className:`self-start`,children:(0,R.jsx)(VG,{onChanged:e,stacked:!0})})]})})}function iK({id:e}){let t=Cj(),n=WA(`excalidraw.list`,{},[`excalidraw`]),[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),s=n.data?.sessions??[],c=s.find(t=>t.id===e),l=async e=>{o(t=>[...t,e]);let t=await U(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await U(`excalidraw.remove`,{id:c.id})&&(n.reload(),$G())};if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,R.jsx)(rK,{onChanged:n.reload});let d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:$W,count:n.data?`${s.length}/5`:void 0}),n.data?(0,R.jsx)(QG,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:eK}):(0,R.jsx)(kj,{})]}),f=c?(0,R.jsx)(YG,{session:c,check:r[c.id],checking:a.includes(c.id),onCheck:()=>void l(c.id),onChanged:n.reload,onRemove:()=>void u()}):t&&n.data?(0,R.jsx)(nK,{count:s.length,onChanged:n.reload}):null;return(0,R.jsx)(Dj,{wide:t,list:d,detail:f,open:c!==void 0,onClose:$G,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function aK(e,t){return e===`lobby.thinking`||t===`1`}var oK=`bot-lobby.collapsed.`,sK=new Set,cK=new Map;function lK(e){if(cK.has(e))return cK.get(e);if(e===`lobby.thinking`)return aK(e);try{return aK(e,localStorage.getItem(oK+e))}catch{return!1}}function uK(e,t){cK.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(oK+e,t?`1`:`0`)}catch{}for(let e of[...sK])e()}function dK(e){return sK.add(e),()=>{sK.delete(e)}}function fK(e){uK(e,!lK(e))}function pK(e){return[(0,m.useSyncExternalStore)(dK,()=>lK(e),()=>aK(e)),(0,m.useCallback)(()=>uK(e,!lK(e)),[e])]}function mK({entry:e}){return e.pending?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,R.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,R.jsx)(Dg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function hK({entry:e}){return(0,R.jsxs)(`li`,{className:`grid grid-cols-[2.75rem_5rem_1rem_minmax(0,1fr)] items-baseline gap-x-2 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-muted`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:Mj(e.at)}),(0,R.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,qU(e.source)),children:KU(e.source)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,R.jsx)(mK,{entry:e})}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,e.kind===`error`?`text-destructive`:e.pending?``:`text-muted-foreground`),children:e.pending?`${e.text}…`:e.text})]})}function gK({entries:e,collapsed:t,onToggle:n,shortcut:r,bare:i}){let a=e.slice(-400),o=a.filter(e=>e.pending).length,{ref:s,atBottom:c,stick:l,onScroll:u}=BU(JSON.stringify(a));return(0,R.jsxs)(hH,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,R.jsx)(`div`,{ref:s,onScroll:u,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-2 pt-2 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Activity`,tabIndex:0,children:a.length===0?(0,R.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,R.jsx)(`ul`,{children:a.map(e=>(0,R.jsx)(hK,{entry:e},e.id))})}),c?null:(0,R.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,R.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,className:`rounded-full bg-card shadow-card`,onClick:l})})]})}function _K(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function vK(e){return e===`running`?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):e===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):e===`failed`||e===`timeout`||e===`error`?(0,R.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`})}function yK(e,t){let n=e.startedAt?Date.parse(e.startedAt):NaN;return Nj((e.finishedAt?Date.parse(e.finishedAt):t)-n)}function bK({runs:e}){let t=_K(e.some(e=>e.status===`running`));return e.length===0?null:(0,R.jsx)(`ul`,{className:`-mt-1 flex shrink-0 flex-wrap items-center gap-1.5 px-4 pb-3`,"aria-label":`Runs`,children:e.map((e,n)=>(0,R.jsx)(tU,{asChild:!0,variant:`secondary`,radius:`full`,className:`h-auto gap-2 py-1 pr-3 pl-2`,children:(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:vK(e.status)}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.status??`unknown`}),(0,R.jsx)(`span`,{className:q(`font-medium`,qU(XU(e))),children:KU(XU(e))}),e.parentRunId?(0,R.jsx)(`span`,{className:`text-muted-foreground`,title:`Child of ${e.parentRunId}`,children:`child`}):null,e.activity??e.step?(0,R.jsx)(`span`,{className:`max-w-[18rem] truncate text-muted-foreground`,children:e.activity??e.step}):null,(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:yK(e,t)})]})},e.runId??n))})}function xK(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function SK(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function CK(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}var wK=8;function TK(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function EK(e,t){let n=Math.min(t,wK);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function DK({done:e,total:t}){return(0,R.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:EK(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function OK({check:e,className:t}){return(0,R.jsx)(e===`done`?rm:e===`dropped`?pm:hm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function kK({children:e}){return(0,R.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function AK({ms:e,running:t,sample:n}){let r=CK(t,n);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:SK(e+r)})}function jK({work:e}){return(0,R.jsxs)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,title:`How long the agents have worked on this task (idle time left out)`,children:[(0,R.jsx)(Cg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,R.jsx)(AK,{ms:e.workedMs,running:e.running,sample:e})]})}function MK({active:e,current:t}){let n=e?.[0];if(n){let t=n.activeAgentCount??1;return(0,R.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,R.jsx)(`span`,{className:`truncate text-foreground`,title:n.text,children:n.text}),(0,R.jsxs)(`span`,{className:`shrink-0 text-primary`,children:[`(`,t,` `,t===1?`agent working`:`agents working`,`)`]}),(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,R.jsx)(AK,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,R.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]})}return t?(0,R.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,R.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function NK({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,R.jsx)(`div`,{className:`h-1.5 w-16 overflow-hidden rounded-full bg-border`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":e,"aria-label":`Plan progress`,children:(0,R.jsx)(B.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,R.jsx)(MK,{...r?{active:r}:{},...n?{current:n}:{}})]})}function PK({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,R.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,R.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] font-medium`,title:e?.title,children:[e?.title??`No task yet`,e?null:(0,R.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,R.jsx)(kK,{children:e.id}),e.track?(0,R.jsx)(kK,{children:TK(e.track)}):null,(e.domains??[]).length>0?(0,R.jsx)(kK,{children:e.domains.join(`, `)}):null,r?(0,R.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,R.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,R.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,R.jsx)(jK,{work:e.work}):null,e.progress?(0,R.jsx)(NK,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var FK=(e,t)=>e?.keys.find(e=>e.action===t)?.label,IK=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function LK({name:e,icon:t,shortcut:n,onClick:r}){return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Expand ${e}`,"aria-expanded":!1,"aria-keyshortcuts":n,onClick:r,className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(JA,{side:`left`,children:[`Expand `,e,n?(0,R.jsx)(aA,{chord:n}):null]})]})}function RK(e){let t=IK(e.status);return(0,R.jsx)(`aside`,{"aria-label":`Minimized panes`,className:`flex w-12 shrink-0 flex-col items-center gap-1 border-l border-border py-2`,children:t.activity&&e.activityFolded?(0,R.jsx)(LK,{name:`Activity`,icon:xp,shortcut:FK(e.status,`activity`),onClick:e.toggleActivity}):null})}function zK(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=IK(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,R.jsxs)(`div`,{className:q(`grid min-h-0 flex-1 gap-3 p-3`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`:`grid-cols-1`),children:[a.conversation?(0,R.jsx)(hW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,R.jsx)(gK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:FK(n,`activity`)}):null]})}function BK(e){let{status:t}=e,n=IK(t).activity&&e.activityFolded;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,R.jsx)(zK,{...e})}),n?(0,R.jsx)(RK,{...e}):null]})}function VK({data:e,status:t}){let n=IK(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ph}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:xp}]:[]],[i,a]=(0,m.useState)(`conversation`),o=r.find(e=>e.id===i)??r[0],s=(e?.activity??[]).filter(e=>e.pending).length;return o?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Pane`,className:`flex shrink-0 items-center gap-0.5 border-b border-border px-3 py-2`,children:r.map(e=>{let t=e.id===o.id,n=e.icon;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>a(e.id),className:q(`inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2.5 text-[0.8125rem] font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,t?`btn-raised bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,R.jsx)(hW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task}):null,o.id===`activity`?(0,R.jsx)(gK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function HK(e){let{data:t,status:n}=e,r=Cj();return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,R.jsx)(PK,{task:t?.task,status:n}),(0,R.jsx)(bK,{runs:ZU(t)})]}),r?(0,R.jsx)(BK,{...e}):(0,R.jsx)(VK,{...e})]})}function UK(){let e=HA(`lobby`),t=HA(`status`),[n,r]=pK(`lobby.activity`);return!e.data&&e.loading?(0,R.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(MA,{}),(0,R.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,R.jsx)(RA,{message:e.error,onRetry:()=>fe.onHello({})}):(0,R.jsx)(HK,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var WK=Xg([`relative flex flex-col bg-muted/50 gap-(--frame-gap) px-(--frame-px) py-(--frame-py) rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:--spacing(0.75)] [--frame-px:--spacing(0.75)] [--frame-py:--spacing(0.75)] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:[`gap-0 *:has-[+[data-slot=frame-panel]]:rounded-b-none`,`*:has-[+[data-slot=frame-panel]]:before:hidden`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:rounded-t-none`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:border-t-0`],false:[`data-[spacing=sm]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-0.5`,`data-[spacing=default]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-1`,`data-[spacing=lg]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-2`]},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function GK({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,R.jsx)(`div`,{className:q(WK({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function KK({className:e,fit:t,...n}){return(0,R.jsx)(`div`,{className:q(`relative overflow-hidden rounded-(--frame-panel-radius) border border-(--frame-panel-border-color) bg-(--frame-panel-bg) bg-clip-padding shadow-xs`,!t&&`grow`,`before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--frame-panel-radius)-1px)] before:shadow-black/5`,`dark:bg-clip-border dark:before:shadow-white/5`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function qK({className:e,...t}){return(0,R.jsx)(`header`,{className:q(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}var JK={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function YK(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function XK(e){return e>0?YK(e):`—`}function ZK(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function QK(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function $K(e){return!Number.isFinite(e)||e<1e3?String(Math.max(0,Math.round(e||0))):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function eq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function tq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function nq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function rq(e,t){let n=t===`model-kind`?JK[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var iq=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],aq={MASTER:`bg-primary`,ORACLE:`bg-primary`,DEV:`bg-source-dev`,DESIGN:`bg-source-design`,QA:`bg-source-qa`,RESEARCH:`bg-source-research`,"QUICK FIX":`bg-source-quickfix`};function oq(e){let t=aq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%iq.length;return iq[n]??iq[0]}function sq(e){return JK[e]??e}var cq=6;function lq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=xf(),[i,a]=(0,m.useState)(null),o=t?`Daily cost`:`Daily runs`,s=e.map(e=>t?e.cost:e.runs),c=Math.max(...s,t?.01:1),l=t?[0,c/2,c]:[...new Set([0,Math.ceil(c/2),c])],u=Date.parse(e[0]?.date??`1970-01-01`),d=Date.parse(e.at(-1)?.date??`1970-01-01`),f=Math.max(1,(d-u)/864e5),p=e=>52+(Date.parse(e)-u)/(f*864e5)*424,h=Math.max(.5,Math.min(28,424/(f+1)*.65)),g=e=>t?`$${e.toFixed(2)}`:String(Math.round(e)),_=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),v=[...new Set([e[0]?.date,e[Math.floor(e.length/2)]?.date,e.at(-1)?.date])].filter(e=>!!e);return(0,R.jsxs)(dq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,R.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,R.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,R.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,R.jsx)(`line`,{x1:`36`,x2:`494`,y1:180-e/c*144,y2:180-e/c*144,stroke:`var(--workspace-border)`,strokeDasharray:`3 5`,opacity:`0.6`}),(0,R.jsx)(`text`,{x:`29`,y:184-e/c*144,textAnchor:`end`,fill:`var(--muted-foreground)`,fontSize:`10`,children:g(e)})]},e)),e.map((e,o)=>{let s=(t?e.cost:e.runs)/c*144,l=u===d?264:p(e.date),f=`${e.date}: ${t?g(e.cost):`${e.runs} runs, ${e.successes} successful`}`;return(0,R.jsxs)(`g`,{role:`img`,"aria-label":f,tabIndex:0,className:`outline-none`,onFocus:()=>a(e),onBlur:()=>a(null),onPointerEnter:()=>a(e),onPointerLeave:()=>a(null),children:[(0,R.jsx)(`title`,{children:f}),(0,R.jsx)(`rect`,{x:l-Math.max(h,12)/2,y:`26`,width:Math.max(h,12),height:`156`,rx:`4`,fill:`var(--accent)`,opacity:+(i?.date===e.date)}),(0,R.jsx)(B.rect,{"data-trend-bar":!0,x:l-h/2,width:h,rx:`3`,fill:`url(#${n}-fill)`,initial:!r&&{height:0,y:180},animate:{height:s,y:180-s},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3),ease:[.22,1,.36,1]}}),t?null:(0,R.jsx)(B.rect,{x:l-h/2,width:h,rx:`3`,fill:`var(--success)`,initial:!r&&{height:0,y:180},animate:{height:e.successes/c*144,y:180-e.successes/c*144},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3)}})]},e.date)}),v.map(e=>(0,R.jsx)(`text`,{"aria-hidden":`true`,x:u===d?264:p(e),y:`205`,textAnchor:`middle`,fill:`var(--muted-foreground)`,fontSize:`11`,children:_(e)},e))]}),t?null:(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function uq({daily:e}){return(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(lq,{daily:e}),(0,R.jsx)(lq,{daily:e,cost:!0})]})}function dq({title:e,right:t,children:n}){return(0,R.jsxs)(GK,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,R.jsx)(qK,{className:`py-2.5`,children:(0,R.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,R.jsx)(`span`,{children:e}),t?(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,R.jsx)(KK,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function fq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,cq);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>cq?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`h-6 self-start rounded-lg text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:n?`Show fewer`:`Show all ${e.length}`}):null]})}function pq({width:e,className:t,title:n}){let r=xf();return(0,R.jsx)(B.div,{"data-chart-bar":!0,title:n,className:`h-full ${t}`,initial:!r&&{width:0},animate:{width:`${e}%`},transition:{duration:r?0:.7,ease:[.22,1,.36,1]}})}function mq(e,t){return t>0?Math.max(1.5,e/t*100):0}function hq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,R.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,R.jsxs)(`div`,{className:`relative h-5 overflow-hidden rounded-md border border-border bg-muted chart-track`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,R.jsx)(pq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:mq(t,r)}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-foreground/40`,style:{left:`${Math.min(99.5,mq(n,r))}%`}}):null]})]})}function gq({groups:e,label:t}){let n=e.filter(e=>e.avgMs>0).sort((e,t)=>t.avgMs-e.avgMs),r=Math.max(...n.map(e=>Math.max(e.avgMs,e.p90Ms)),1);return(0,R.jsx)(dq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsx)(fq,{rows:n,render:e=>(0,R.jsx)(hq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:XK(e.avgMs),sub:`p90 ${XK(e.p90Ms)}`},t(e))})})}var _q={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},vq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function yq({label:e,rate:t,runs:n}){let r=tq(t),i=`${Math.round(t*100)}%`;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${vq[r.tone]}`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${_q[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,R.jsxs)(`div`,{className:`flex h-5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,R.jsx)(pq,{className:`bg-success/80`,width:t*100}),(0,R.jsx)(pq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function bq({groups:e,label:t}){let n=e.filter(e=>e.runs>0).sort((e,t)=>e.successes/e.runs-t.successes/t.runs);return(0,R.jsx)(dq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,R.jsx)(fq,{rows:n,render:e=>(0,R.jsx)(yq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function xq({share:e}){return(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${oq(e.agent)}`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`text-[0.8125rem]`,children:KU(e.agent)}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,YK(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function Sq({share:e}){return(0,R.jsx)(`div`,{className:`flex h-6 gap-0.5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,R.jsx)(pq,{className:`${oq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function Cq({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,R.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,R.jsx)(fq,{rows:e,render:e=>(0,R.jsx)(hq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:YK(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function wq({timeShare:e}){let t=e.byAgent;return(0,R.jsxs)(dq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(Sq,{share:t}),(0,R.jsx)(xq,{share:t})]}),(0,R.jsx)(Cq,{times:e.taskTimes})]})}function Tq(e){return(0,R.jsx)(LD,{...e})}function Eq(e){return(0,R.jsx)(VD,{"data-slot":`select-value`,...e})}function Dq({className:e,children:t,...n}){return(0,R.jsxs)(zD,{"data-slot":`select-trigger`,className:q(`reui-select flex h-9 min-w-36 items-center justify-between gap-3 rounded-lg border px-3 text-xs outline-none focus-visible:ring-3 focus-visible:ring-ring/30 disabled:opacity-50`,e),...n,children:[t,(0,R.jsx)(HD,{asChild:!0,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function Oq({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,R.jsx)(GD,{children:(0,R.jsxs)(qD,{"data-slot":`select-content`,position:n,align:r,sideOffset:4,className:q(`reui-menu z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) origin-(--radix-select-content-transform-origin) overflow-hidden rounded-xl border p-1 shadow-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 motion-reduce:animate-none`,e),...i,children:[(0,R.jsx)(_O,{className:`flex justify-center py-1`,children:(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,R.jsx)(aO,{children:t}),(0,R.jsx)(yO,{className:`flex justify-center py-1`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function kq({className:e,children:t,...n}){return(0,R.jsxs)(dO,{"data-slot":`select-item`,className:q(`relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-3 text-xs outline-none select-none data-highlighted:bg-accent data-disabled:opacity-50`,e),...n,children:[(0,R.jsx)(pO,{children:t}),(0,R.jsx)(hO,{className:`absolute right-2`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function Aq({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`flex h-8 w-full rounded-lg border border-input bg-background px-3 py-1 text-base transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:disabled:bg-input/80`,e),...n})}var jq=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function Mq(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Nq({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=Mq(new Date),[i,a]=(0,m.useState)(r),[o,s]=(0,m.useState)(r),[c,l]=(0,m.useState)(``);function u(t){if(n(t),l(``),t===`all`)e({});else if(t===`range`)i&&o&&i<=o&&e({from:i,to:o});else{let n=new Date;t===`week`&&n.setDate(n.getDate()-6),e({from:Mq(n),to:r})}}return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,R.jsxs)(Tq,{value:t,onValueChange:u,children:[(0,R.jsx)(Dq,{"aria-label":`Metrics period`,children:(0,R.jsx)(Eq,{})}),(0,R.jsx)(Oq,{children:jq.map(e=>(0,R.jsx)(kq,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-wrap items-end gap-2`,onSubmit:t=>{if(t.preventDefault(),!i||!o||i>o){l(`Choose an end date on or after the start date.`);return}l(``),e({from:i,to:o})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,R.jsx)(Aq,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,R.jsx)(Aq,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function Pq({label:e,value:t,sub:n}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var Fq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Iq({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,R.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,R.jsx)(Pq,{label:`Calls`,value:Fq(e.calls,`call`),sub:`${ZK(e.ok,e.calls)} ok`}),(0,R.jsx)(Pq,{label:`Speed`,value:`p50 ${eq(e.p50Ms)}`,sub:`p90 ${eq(e.p90Ms)}`}),(0,R.jsx)(Pq,{label:`Read`,value:e.input>0?`${$K(e.input)} tokens`:`—`}),(0,R.jsx)(Pq,{label:`Routed down`,value:e.routed>0?Fq(e.routed,`run`):`none`,sub:e.routed>0?`${ZK(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,Fq(e.seatRunsSkipped,`seat run`),` skipped · `,Fq(e.questionsAnswered,`question`),` answered · `,Fq(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,R.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var Lq=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function Rq(e,t=0){return e>0?e.toFixed(t):`—`}function zq(e){return[String(e.runs),ZK(e.successes,e.runs),XK(e.avgMs),XK(e.p50Ms),XK(e.p90Ms),Rq(e.avgTurns,1),Rq(e.avgTools,1),e.avgTokens>0?$K(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,QK(e.avgCost),QK(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function Bq(e,t){return t===`model-kind`?sq(e.kinds[0]??``):e.kinds.map(sq).join(`, `)}function Vq({groups:e,groupBy:t}){return(0,R.jsxs)(`section`,{className:`card-raised flex min-h-0 flex-col gap-2 overflow-hidden rounded-xl border pt-4`,"aria-label":`All models`,children:[(0,R.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`All models`}),(0,R.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,tabIndex:0,role:`region`,"aria-label":`All model metrics, scroll horizontally to see all columns`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),Lq.map(e=>(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,R.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:Bq(e,t)||`—`}),zq(e).map((e,t)=>(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},Lq[t]))]},rq(e,t)))})]})})]})}var Hq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function Uq({label:e,value:t,sub:n,dot:r}){return(0,R.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${Hq[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function Wq({tiles:e}){let t=tq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,R.jsx)(Uq,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,R.jsx)(Uq,{label:`Success`,value:ZK(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,R.jsx)(Uq,{label:`Avg run`,value:XK(e.avgMs),sub:`p90 ${XK(e.p90Ms)}`}),(0,R.jsx)(Uq,{label:`Cost`,value:QK(e.cost),sub:e.runs>0?`${QK(e.cost/e.runs)} per run`:`—`}),(0,R.jsx)(Uq,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${YK(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var Gq=`No runs recorded yet. Every Master turn, subagent run, quick fix and planning round lands here with its model, thinking level, time, tokens and cost.`;function Kq({groupBy:e,onGroup:t}){return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=[`model`,`model-kind`],a=i[(i.indexOf(e)+r+i.length)%i.length];t(a),requestAnimationFrame(()=>n.currentTarget.querySelector(`[aria-checked='true']`)?.focus())},children:[`model`,`model-kind`].map(n=>(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,role:`radio`,tabIndex:e===n?0:-1,className:e===n?`bg-card text-foreground shadow-card hover:bg-card`:`text-muted-foreground`,"aria-checked":e===n,onClick:()=>t(n),children:nq(n)},n))})}function qq({query:e,onQuery:t}){return(0,R.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,R.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{id:`metrics-search`,type:`search`,value:e,maxLength:500,placeholder:`Search runs: model, agent, tool…`,onChange:e=>t(e.target.value),className:`h-8 w-64 max-w-full rounded-lg border border-input bg-background pr-9 pl-8 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`}),(0,R.jsx)(aA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function Jq({data:e,groupBy:t,query:n}){let r=e=>rq(e,t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(Wq,{tiles:e.tiles}),e.tiles.runs===0?(0,R.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}" in this period.`:`No runs in this period. ${Gq}`}):null,e.daily.length>0?(0,R.jsx)(uq,{daily:e.daily}):null,e.classifier?(0,R.jsx)(Iq,{summary:e.classifier}):null,e.tiles.runs>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(gq,{groups:e.groups,label:r}),(0,R.jsx)(bq,{groups:e.groups,label:r})]}),(0,R.jsx)(Vq,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,R.jsx)(wq,{timeShare:e.timeShare}):null]})}function Yq(){return(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,role:`status`,"aria-label":`Loading metrics`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function Xq(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=WA(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,R.jsx)(RA,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(MA,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,R.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,R.jsx)(Nq,{onChange:a}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-end gap-3 lg:w-auto lg:flex-1 lg:justify-end`,children:[(0,R.jsx)(Kq,{groupBy:e,onGroup:t}),(0,R.jsx)(qq,{query:n,onQuery:r})]}),(0,R.jsxs)(`p`,{className:`w-full text-xs text-muted-foreground`,children:[i.from?`${i.from} – ${i.to}`:`All recorded dates`,` · `,o,`. Runs and active tasks use their start date; completed tasks use their completion date.`]})]}),s.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,R.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,R.jsx)(Jq,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,R.jsx)(Yq,{})})]})}var Zq=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function Qq(e,t){return JSON.stringify([e,`prompt`,t])}function $q(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function eJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var tJ=`bot-lobby.prompt-sound-muted`,nJ=new Set,rJ,iJ=!1;function aJ(){try{return localStorage.getItem(tJ)===`on`}catch{return iJ}}function oJ(e){iJ=e;try{localStorage.setItem(tJ,e?`on`:`off`)}catch{}for(let e of nJ)e()}function sJ(e){return nJ.add(e),()=>{nJ.delete(e)}}function cJ(){return(0,m.useSyncExternalStore)(sJ,aJ,()=>!1)}function lJ(){(0,m.useEffect)(()=>{let e=()=>{try{rJ??=new AudioContext,rJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function uJ(){if(!aJ()&&rJ&&rJ.state===`running`)try{let e=rJ.currentTime,t=rJ.createOscillator(),n=rJ.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(rJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var dJ=`bot-lobby.notifications`,fJ=`/icon-192.png`,pJ=new Set;function mJ(){for(let e of[...pJ])e()}function hJ(){try{return localStorage.getItem(dJ)===`on`}catch{return!1}}function gJ(e){return pJ.add(e),()=>{pJ.delete(e)}}function _J(e){try{localStorage.setItem(dJ,e?`on`:`off`)}catch{}mJ()}function vJ(){return(0,m.useSyncExternalStore)(gJ,hJ,()=>!1)}async function yJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(_J(!0),`granted`):`denied`)}function bJ(){_J(!1)}function xJ(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function SJ(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function CJ(e){try{new Notification(`bot-lobby`,{body:e,icon:fJ,tag:`bot-lobby`})}catch{}}function wJ(){try{return new Zq(sessionStorage)}catch{return new Zq}}function TJ(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?$q(e,t.sessionId??n.key??t.from,n.dialog.id):Qq(e,t.id)}function EJ(){let e=vJ();lJ(),BA();let t=WA(`tasks.list`,{},[`tasks`]),n=WA(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(wJ()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=P()??`current`,l=fe.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function DJ(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>uJ()),c&&SJ()&&CJ(r),t===`delivery`&&H.info(r,{action:{label:`Review tasks`,onClick:()=>wA(`#/tasks`)}}))}function OJ(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;DJ(e,`prompts`,(a??[]).map(e=>TJ(i,e)),`A question is waiting for you.`,!!a&&!t.loading),DJ(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>$q(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),DJ(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>eJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function kJ(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}OJ(e);let s=a?.task?.state??``,c=xJ(s);i.current&&c&&s!==i.current&&o&&SJ()&&CJ(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function AJ(){let e=EJ(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>kJ(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function jJ({className:e,thumbClassName:t,...n}){return(0,R.jsx)(RO,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:q(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors duration-150 outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(BO,{"data-slot":`switch-thumb`,className:q(`pointer-events-none block size-4 rounded-full bg-white shadow-sm ring-0 transition-transform duration-200 ease-snap data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`,t)})})}var MJ=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],NJ=`M32 17 C28 10 19 12 17 19 C10 19 7 26 10 32 C5 38 9 46 15 47 C16 54 25 56 32 50 C39 56 48 54 49 47 C55 46 59 38 54 32 C57 26 54 19 47 19 C45 12 36 10 32 17Z`,PJ=`M32 17 C28 12 21 12 18 19 C12 19 9 25 11 31 C7 36 9 44 15 46 C16 53 26 55 32 50 C38 55 48 53 49 46 C55 44 57 36 53 31 C55 25 52 19 46 19 C43 12 36 12 32 17Z`,FJ=[`M19 22 C16 25 17 29 22 29 C27 29 28 33 25 36`,`M12 35 C16 32 20 35 18 39 C16 43 20 47 24 45`,`M25 17 C22 20 26 22 28 22 C31 23 29 27 26 27`,`M11 42 C13 44 16 42 15 39 M22 49 C26 49 29 45 27 41`,`M15 25 C12 27 14 31 17 31 M21 32 C22 35 20 37 22 39 C24 41 28 38 29 35`,`M20 18 C22 18 23 20 21 22 M24 24 C21 23 20 25 21 27 M12 37 C14 36 16 38 15 40 M20 43 C23 44 25 42 24 40 M28 29 C30 30 30 32 28 33`];function IJ({level:e,className:t}){let n=xf(),r=Math.max(0,MJ.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===MJ.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,R.jsxs)(`svg`,{viewBox:`0 0 64 72`,"data-slot":`effort-mascot`,"data-level":e,"data-folds":i*2,"data-elevated":a||void 0,"aria-hidden":`true`,focusable:`false`,className:q(`size-16 shrink-0 overflow-visible`,t),children:[(0,R.jsxs)(`defs`,{children:[(0,R.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,R.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,R.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,R.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,R.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,R.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,R.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,R.jsxs)(`feMerge`,{children:[(0,R.jsx)(`feMergeNode`,{}),(0,R.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,R.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,R.jsx)(`path`,{d:NJ})}),(0,R.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,R.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,R.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,R.jsx)(B.circle,{"data-brain-halo":!0,cx:`32`,cy:`32`,r:`33`,fill:`url(#${o}-halo)`,initial:!1,animate:{opacity:n?.8:[.65,1,.65]},transition:{duration:n?0:3,repeat:n?0:1/0}}):null,(0,R.jsxs)(B.g,{"data-brain-body":!0,initial:!1,animate:{y:a?n?-5:[-5,-7,-5]:0},transition:{duration:n?0:a?3:.3,repeat:a&&!n?1/0:0,ease:`easeInOut`},stroke:`url(#${o}-ink)`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,filter:a?`url(#${o}-glow)`:void 0,children:[a?[`cyan`,`magenta`].map(e=>(0,R.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,R.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,R.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,R.jsx)(`path`,{d:r<=3?PJ:NJ,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,R.jsx)(`path`,{d:`M32 17 C29 24 34 28 32 34 C30 40 34 45 32 50`,fill:`none`,opacity:r===0?.35:.8}),[!1,!0].map(e=>(0,R.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:FJ.slice(0,i).map((e,t)=>(0,R.jsx)(B.path,{"data-brain-fold":!0,d:e,initial:!n&&{opacity:0,pathLength:0},animate:{opacity:.85,pathLength:1},transition:{duration:n?0:.3,delay:n?0:t*.025}},e))},String(e))),r>0&&r<5?(0,R.jsx)(`g`,{stroke:`none`,fill:`var(--primary)`,children:[[20,27],[43,36],[25,44]].slice(0,Math.min(r,3)).map(([e,t],n)=>(0,R.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,R.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,R.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,R.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,R.jsx)(`path`,{d:NJ,fill:`url(#${o}-hologram)`}),(0,R.jsx)(`rect`,{"data-brain-scan":!0,className:`brain-phase-scan`,x:`7`,y:`14`,width:`50`,height:`2`,fill:`var(--rainbow-5)`,opacity:`0.45`})]}):null]}),a?(0,R.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,R.jsx)(`path`,{d:`M0 -3 L0.8 -0.8 L3 0 L0.8 0.8 L0 3 L-0.8 0.8 L-3 0 L-0.8 -0.8Z`,transform:`translate(${e} ${t})`},e))}):null]})}var LJ={minimal:`min`,medium:`med`},RJ={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function zJ(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}function BJ(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}function VJ({value:e,levels:t,supported:n,model:r,label:i,disabled:a,onChange:o}){let s=(0,m.useRef)(null),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),f=(0,m.useRef)(void 0),p=(0,m.useRef)(0),h=(0,m.useCallback)(()=>{f.current=void 0,p.current=0,d(void 0)},[]),g=Math.max(t.length-1,1),_=zJ(t,n,Math.max(0,t.indexOf(e))),v=c??u??_,y=v<0?0:v/g*100,b=t[v]??e,x=v>=0&&b!==e;(0,m.useEffect)(()=>{if(u===void 0)return;let e=window.setTimeout(h,1e4);return()=>window.clearTimeout(e)},[u,h]);let S=(0,m.useCallback)(e=>{let r=s.current?.getBoundingClientRect();if(!r||r.width===0)return _;let i=Math.min(1,Math.max(0,(e-r.left)/r.width));return zJ(t,n,Math.round(i*g))},[g,t,_,n]);function C(e){a||n.length===0||(e.currentTarget.setPointerCapture(e.pointerId),l(S(e.clientX)))}function w(e){if(c===void 0)return;let t=S(e.clientX);t!==c&&l(t)}function T(){if(c===void 0)return;let n=t[c];l(void 0),n&&n!==e&&o(n)}function E(e){if(a||v<0)return;let r=f.current??v,i={ArrowRight:BJ(t,n,r,1),ArrowUp:BJ(t,n,r,1),ArrowLeft:BJ(t,n,r,-1),ArrowDown:BJ(t,n,r,-1),Home:zJ(t,n,0),End:zJ(t,n,g)}[e.key];if(i===void 0)return;e.preventDefault();let s=t[i];s&&i!==r&&(f.current=i,d(i),p.current+=1,Promise.resolve(o(s)).catch(()=>void 0).then(()=>{--p.current,p.current<=0&&h()}))}return(0,R.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,R.jsx)(IJ,{level:b}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:RJ[b]??``})]}),(0,R.jsxs)(`div`,{ref:s,role:`slider`,tabIndex:a?-1:0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":Math.max(v,0),"aria-valuetext":b,"aria-disabled":a||void 0,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:()=>l(void 0),onKeyDown:E,className:`relative mx-2.5 h-6 touch-none cursor-pointer rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-muted`}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:`absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-primary`,animate:{width:`${y}%`},transition:{type:`spring`,stiffness:520,damping:34}}),t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,title:i?e:`${r??`This model`} does not support ${e}`,className:q(`absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full`,i?t<=v?`bg-primary-foreground/80`:`bg-muted-foreground/40`:`bg-transparent ring-1 ring-muted-foreground/30`),style:{left:`${t/g*100}%`}},e)}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:q(`absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm`,c!==void 0&&`scale-110`),animate:{left:`${y}%`},transition:{type:`spring`,stiffness:520,damping:28}})]}),(0,R.jsx)(`div`,{className:`relative mx-2.5 h-3.5 text-[0.68rem] text-muted-foreground`,"aria-hidden":`true`,children:t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{title:i?void 0:`${r??`This model`} does not support ${e}`,className:q(`absolute -translate-x-1/2 whitespace-nowrap`,t===v&&`font-medium text-foreground`,!i&&`opacity-40`),style:{left:`${t/g*100}%`},children:LJ[e]??e},e)})}),x?(0,R.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function HJ(e){return(0,R.jsx)(_D,{...e})}function UJ(e){return(0,R.jsx)(vD,{"data-slot":`popover-trigger`,...e})}function WJ({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(yD,{children:(0,R.jsx)(bD,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-xl border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}function GJ(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function KJ({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>GJ(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,R.jsxs)(HJ,{open:o,onOpenChange:s,children:[(0,R.jsxs)(UJ,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:q(`reui-select flex h-8 w-full min-w-0 items-center justify-between gap-2 overflow-hidden rounded-lg border bg-card px-2.5 text-[0.8125rem] whitespace-nowrap outline-none transition-[border-color,box-shadow] duration-150 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50`,i),children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(WJ,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,R.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-[0.8125rem] outline-none placeholder:text-muted-foreground`})]}),(0,R.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,R.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,R.jsxs)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:q(`flex cursor-default items-center gap-2 rounded-lg px-2.5 py-1.5 text-[0.8125rem] select-none`,n===u&&`bg-accent`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function qJ({label:e,help:t,children:n,stacked:r}){return(0,R.jsxs)(`div`,{className:r?`grid gap-1.5`:`grid gap-1.5 sm:grid-cols-[minmax(0,1fr)_minmax(0,18rem)] sm:items-center sm:gap-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,R.jsx)(`div`,{className:`min-w-0`,children:n})]})}function JJ({children:e}){return(0,R.jsx)(GK,{dense:!0,children:(0,R.jsx)(KK,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function YJ({value:e,items:t,label:n,onChange:r}){return(0,R.jsx)(KJ,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var XJ=`(prefers-color-scheme: dark)`,ZJ=[`dark`,`light`,`system`],QJ=m.createContext(void 0);function $J(e){return e!==null&&ZJ.includes(e)}function eY(){return window.matchMedia(XJ).matches?`dark`:`light`}function tY(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function nY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function rY({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return $J(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?eY():e,i=r?tY():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(XJ),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||nY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:eY()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if($J(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,R.jsx)(QJ.Provider,{...i,value:l,children:e})}var iY=()=>{let e=m.useContext(QJ);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},aY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],oY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},sY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},cY=`inherit`,lY=`inherit`,uY=`Use the session's current model`,dY=`__custom__`,fY=`custom…`,pY=`Type a provider/model id`,mY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],hY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},gY=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`},{id:`issues`,label:`Issues tab`,help:`the GitHub Issues tab`}],_Y=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],vY=`shown on the Lobby tab`,yY=`Planning rounds`,bY=`how many rounds the panel gets before the oracle settles the rest alone`,xY=[2,3,5,8,0],SY=`Split long plans`,CY=`saving a plan with more steps offers to split it into up to 5 tasks`,wY=[6,8,10,12,0],TY=`Port`,EY=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,DY=`Open browser`,OY=`open this page in the browser when pi starts`,kY=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],AY=`Git isolation`,jY=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],MY={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},NY=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],PY=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, Jev reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, Jev picks the sections that bear on the step, and the agent is told where the rest is`},{id:`files`,label:`File hints`,help:`scouts, workers, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],FY={enabled:`Classifier`,enabledHelp:`Jev makes the obvious decisions so large models spend fewer tokens on them`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},IY={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},LY=`https://tweakcn.com/editor/theme`;function RY(){let{theme:e}=iY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function zY({palette:e,dark:t}){let n=se(e,t);return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,R.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,R.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,R.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function BY(){let e=Ue(),t=RY(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,R.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:q(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,R.jsx)(zY,{palette:n,dark:t}),(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,R.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,R.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function VY({entry:e}){let t=Ue(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),H.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,R.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,R.jsx)(Aq,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64`}),(0,R.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,R.jsx)(X,{label:`Keep the old name`,icon:Ug,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,R.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,R.jsx)(Kj,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Tg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>H.error(e.message))})]}),o?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function HY(){let e=Ue();return e.saved.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,R.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,R.jsx)(VY,{entry:e},e.id))})}function UY(){let e=Ue(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;H.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,R.jsxs)(`a`,{href:LY,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,R.jsx)(Dm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,R.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,R.jsx)(Aq,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground`})]}),(0,R.jsx)(Aj,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
92
92
|
--background: oklch(0.98 0 0);
|
|
93
93
|
--primary: oklch(0.55 0.2 260);
|
|
94
94
|
…
|
|
@@ -98,7 +98,7 @@ Error generating stack: `+e.message+`
|
|
|
98
98
|
`)[0]}function cZ(e){let t=[],n=sZ(e);return e.busy?t.push(iZ(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${aZ(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(iZ(e.round,e.limit)),!e.busy&&e.limit>0&&e.round+1===e.limit&&t.push(`the next round is the last: the oracle settles the rest`),t}function lZ(e,t){let n=$X[e],r=t.seats.includes(e),i=t.members.find(t=>t.member===e),a={member:e,label:n,seated:r,working:!1};if(!r)return{...a,text:`off`};if(i?.status===`thinking`)return{...a,working:!0,text:i.step??`thinking`};if(i?.status===`failed`)return{...a,text:`failed — Retry`};if(!i)return{...a,text:`·`};if(i.reply?.status===`ready`)return{...a,text:`ready`};let o=t.questions.filter(e=>e.from===n).length;return{...a,text:o===0?`done`:aZ(o,`question`)}}function uZ(e){let t=e.questions.filter(e=>e.from===JX).length;return[{label:JX,seated:!0,working:e.busy,text:e.busy?`chairing`:t?aZ(t,`question`):`·`},...QX.map(t=>lZ(t,e))]}function dZ(e){let t=!1;return e.split(`
|
|
99
99
|
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function fZ({notes:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsx)(`p`,{className:`ml-6 rounded-lg border border-primary/15 bg-accent px-3 py-1.5 text-sm text-foreground italic`,children:e},t))})}var pZ=[],mZ=(0,m.memo)(function({row:e,notes:t,onComment:n}){let r=e.text.trim(),i=()=>n(r);return(0,R.jsxs)(`li`,{className:`group/line [contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,R.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:t.length>0?(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,R.jsx)(`div`,{className:q(`min-w-0 flex-1 cursor-pointer rounded-lg px-2 py-1.5 transition-colors hover:bg-muted`,e.fenced&&`font-mono text-sm whitespace-pre-wrap break-words`),onClick:e=>!e.target.closest(`a`)&&i(),children:e.fenced?e.text:(0,R.jsx)(mH,{text:e.text})}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/line:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":`Comment on this line: ${r}`,onClick:i,children:(0,R.jsx)(dh,{"aria-hidden":`true`})})]}),(0,R.jsx)(fZ,{notes:t})]})});function hZ({draft:e,comments:t,onComment:n}){let r=(0,m.useMemo)(()=>dZ(e),[e]),i=aH(r.length);return(0,R.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:r.slice(0,i).map((e,r)=>e.text.trim()?(0,R.jsx)(mZ,{row:e,notes:t.get(e.text.trim())??pZ,onComment:n},r):(0,R.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},r))})}function gZ({notes:e}){return e.length===0?null:(0,R.jsx)(_H,{title:ZX,children:(0,R.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex gap-3`,children:[(0,R.jsx)(`dt`,{className:q(`w-20 shrink-0 font-medium`,qU(e.from)),children:KU(e.from)}),(0,R.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(mH,{text:e.text})})]},t))})})}function _Z({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:q(`inline-flex items-center gap-1.5 font-medium`,e.seated?qU(e.label):`text-muted-foreground`),children:[(0,R.jsx)(WU,{source:e.label,className:`size-3.5`}),KU(e.label)]}),e.working&&!t?(0,R.jsx)(MA,{className:`size-3.5`,"aria-hidden":`true`}):null,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function vZ({cell:e,intro:t,onToggled:n}){let{member:r}=e,i=`inline-flex min-h-8 items-center gap-2 rounded-lg border border-border px-3 text-[0.8125rem]`;if(!r)return(0,R.jsx)(`li`,{className:q(i,`bg-muted`),children:(0,R.jsx)(_Z,{cell:e,intro:t})});let a=async()=>{await U(`planner.toggleSeat`,{member:r})&&n()};return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(i,`cursor-pointer transition-colors`,e.seated?`btn-raised bg-card`:`border-dashed text-muted-foreground hover:bg-muted`),children:[(0,R.jsx)(QW,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${KU(e.label)} sits on the panel`}),(0,R.jsx)(_Z,{cell:e,intro:t})]})})}function yZ({cells:e,intro:t,onToggled:n}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(vZ,{cell:e,intro:t,onToggled:n},e.label))})}function bZ({cell:e,onToggled:t}){let{member:n}=e,r=KU(e.label),i=q(`flex h-full flex-col gap-2 rounded-xl border p-3.5 transition-[background-color,border-color,box-shadow]`,e.seated?`border-[color-mix(in_oklab,var(--orb)_26%,var(--border))] bg-[color-mix(in_oklab,var(--orb)_5%,var(--card))] shadow-card`:`border-dashed border-input bg-transparent`),a=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid size-6 place-items-center rounded-lg bg-[color-mix(in_oklab,var(--orb)_14%,transparent)] text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,!e.seated&&`opacity-50 grayscale`),children:(0,R.jsx)(WU,{source:e.label,className:`size-3.5`})}),(0,R.jsx)(`span`,{className:q(`truncate text-sm font-semibold`,e.seated?qU(e.label):`text-muted-foreground`),children:r})]}),n?(0,R.jsx)(QW,{checked:e.seated,onCheckedChange:()=>void xZ(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:tZ[e.label]}),(0,R.jsx)(`span`,{className:q(`mt-auto text-xs font-medium`,e.seated?`text-foreground`:`text-muted-foreground`),children:n?e.seated?`seated`:`sits this one out`:`always chairs`})]}),o={"--orb":YU(e.label)};return n?(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`label`,{className:q(i,`cursor-pointer`,e.seated?`hover:shadow-[0_0_0_3px_color-mix(in_oklab,var(--orb)_10%,transparent)]`:`hover:bg-muted`),children:a})}):(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`div`,{className:i,children:a})})}async function xZ(e,t){await U(`planner.toggleSeat`,{member:e})&&t()}function SZ({cells:e,onToggled:t}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-5`,children:e.map(e=>(0,R.jsx)(bZ,{cell:e,onToggled:t},e.label))})}function CZ({snap:e}){let t=cZ(e),n=!e.busy&&sZ(e)!==void 0;return(0,R.jsxs)(`p`,{role:`status`,className:n?`flex items-center gap-2 text-sm text-destructive`:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e.busy?(0,R.jsx)(MA,{className:`size-3.5`,"aria-hidden":`true`}):null,t.join(` · `)]})}function wZ(){return(0,R.jsx)(X,{label:`Previous plans`,text:`Previous`,icon:Yh,shortcut:`H`,onClick:()=>wA(CA(`plan`,`previous`))})}function TZ({snap:e,onDone:t}){let n=HA(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await U(e,{})&&t()};return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.questions.length>0&&!e.busy?(0,R.jsx)(X,{label:`Answer questions`,icon:lh,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,R.jsx)(X,{label:`Retry`,icon:$h,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,R.jsx)(wZ,{}),(0,R.jsx)(X,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:rg,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,R.jsx)(Kj,{icon:Nm,label:`New plan`,shortcut:`N`,title:`Start a new plan?`,description:`The conversation and the draft are left behind. Saved plans are not touched.`,confirmLabel:`New plan`,onConfirm:()=>void U(`planner.new`,{}).then(t)})]})}function EZ({snap:e,onDone:t}){return(0,R.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border px-5 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,R.jsx)(CZ,{snap:e})]}),(0,R.jsx)(TZ,{snap:e,onDone:t})]}),(0,R.jsx)(yZ,{cells:uZ(e),intro:!1,onToggled:t})]})}var DZ=()=>wA(CA(`plan`,`previous`)),OZ=e=>wA(CA(`plan`,`previous`,e));function kZ(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?Fj(Math.max(0,t)):``}function AZ(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,kZ(e.updatedAt)].filter(Boolean).join(` · `)}function jZ({plan:e,selected:t}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>OZ(e.id),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,R.jsx)(tU,{variant:`secondary`,children:`draft`}):null]}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:AZ(e,e.messages)})]})})}function MZ({id:e,onGone:t}){let n=WA(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,R.jsx)(RA,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&wA(CA(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Carry on planning`,text:`Carry on`,icon:Uh,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,R.jsx)(X,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Cp:Tp,shortcut:`E`,onClick:()=>void o()}),(0,R.jsx)(Kj,{icon:Tg,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,AZ(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(_H,{title:`Draft plan`,children:[r.draft?(0,R.jsx)(mH,{text:r.draft}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,R.jsx)(gZ,{notes:r.notes})]}),(0,R.jsx)(_H,{title:`Conversation`,children:(0,R.jsx)(qX,{messages:r.messages,readOnly:!0})})]})}function NZ({id:e}){let t=Cj(),[n,r]=(0,m.useState)(!1),i=WA(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,R.jsx)(RA,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,R.jsxs)(Oj,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,R.jsx)(X,{label:`Back to the current plan`,icon:kp,iconOnly:!0,onClick:()=>wA(CA(`plan`))}),(0,R.jsx)(X,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?Yh:Tp,pressed:n,onClick:()=>{r(e=>!e),DZ()}})]}),s=i.data?a.length===0?(0,R.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:n?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,R.jsx)(`ul`,{className:q(rU,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,R.jsx)(jZ,{plan:t,selected:t.id===e},t.id))}):(0,R.jsx)(kj,{});return(0,R.jsx)(Dj,{wide:t,list:(0,R.jsxs)(R.Fragment,{children:[o,s]}),detail:e?(0,R.jsx)(MZ,{id:e,onGone:()=>{i.reload(),DZ()}},e):null,open:e!==void 0,onClose:DZ,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function PZ({line:e,onClose:t,onSent:n}){let r=hA(e!==void 0,mA.confirm);return(0,R.jsx)(sA,{open:e!==void 0&&r,onOpenChange:e=>!e&&t(),label:`Comment on this line`,className:`max-w-xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-medium`,children:`Comment on this line`}),(0,R.jsx)(`p`,{className:`mt-1 line-clamp-3 text-sm break-words text-muted-foreground`,children:e})]}),(0,R.jsx)(mU,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async r=>e===void 0||!await U(`planner.commentLine`,{line:e,text:r.trim()})?!1:(n(e,r.trim()),t(),!0)})]})})}function FZ({limit:e}){return e<=0?null:(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,R.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function IZ({snap:e,onDone:t}){let n=uZ(e);return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-8 pb-dock sm:px-8 sm:pt-10`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(tg,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,R.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:eZ})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,R.jsx)(wZ,{}),(0,R.jsx)(FZ,{limit:e.limit})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(gH,{title:`The panel`,right:rZ(n)})}),(0,R.jsx)(SZ,{cells:n,onToggled:t})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(gH,{title:`How a plan comes together`})}),(0,R.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:nZ.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised relative flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Dp,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,R.jsx)(oA,{chord:`/`,children:`write`}),(0,R.jsx)(oA,{chord:`Enter`,children:`send to the panel`})]})]})})}function LZ({snap:e,wide:t}){let{ref:n,onScroll:r}=BU(JSON.stringify(e.messages));return(0,R.jsxs)(wj,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(gH,{title:`Conversation`,className:`w-full`})}),(0,R.jsx)(`div`,{ref:n,onScroll:r,className:q(`min-h-0 overflow-y-auto overscroll-y-contain`,t?`flex-1 px-5 pt-5 pb-dock`:`max-h-[45svh] p-5`),children:(0,R.jsx)(qX,{messages:e.messages,busy:e.busy})})]})}function RZ({snap:e,comments:t,onComment:n,wide:r}){return(0,R.jsxs)(wj,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(gH,{title:`Draft plan`,className:`w-full`})}),(0,R.jsxs)(`div`,{className:q(`flex min-h-0 flex-col gap-5 overflow-y-auto overscroll-y-contain px-5 pt-5 pb-dock`,r&&`flex-1`),children:[e.draft?(0,R.jsx)(hZ,{draft:e.draft,comments:t,onComment:n}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.busy?XX:YX}),(0,R.jsx)(gZ,{notes:e.notes})]})]})}function zZ({snap:e,reload:t}){let n=Cj(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(new Map);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(EZ,{snap:e,onDone:t}),(0,R.jsxs)(`div`,{className:n?`grid min-h-0 flex-1 grid-cols-[minmax(0,46fr)_minmax(0,54fr)] grid-rows-[minmax(0,1fr)] gap-3 p-3`:`flex flex-col gap-3 p-3`,children:[(0,R.jsx)(LZ,{snap:e,wide:n}),(0,R.jsx)(RZ,{snap:e,comments:a,onComment:i,wide:n})]}),(0,R.jsx)(PZ,{line:r,onClose:()=>i(void 0),onSent:(e,t)=>o(n=>new Map(n).set(e,[...n.get(e)??[],t]))})]})}function BZ({rest:e=[]}){return e[0]===`previous`?(0,R.jsx)(NZ,{id:e[1]}):(0,R.jsx)(VZ,{})}function VZ(){let e=WA(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,R.jsx)(RA,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,R.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=oZ(t);return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,R.jsx)(IZ,{snap:t,onDone:e.reload}):(0,R.jsx)(zZ,{snap:t,reload:e.reload})})}var HZ=`Describe a small change in the box below and one agent makes it now, beside any running task.`;function UZ(e){return e.prompt.split(`
|
|
100
100
|
`).find(e=>e.trim())?.trim()??`(empty)`}function WZ(e){return[...e].reverse()}function GZ(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function KZ(e,t){return e.startedAt?GZ((e.finishedAt??t)-e.startedAt):``}function qZ(e,t){let n=e.model?`${e.model}${e.thinking?` · ${e.thinking}`:``}`:e.thinking??``;return[KZ(e,t),n,e.tools?`${e.tools} tool${e.tools===1?``:`s`}`:``,e.usage?.cost?`$${e.usage.cost.toFixed(2)}`:``].filter(Boolean).join(` · `)}function JZ(e){return e===`queued`?`Waiting for the quick fix ahead of it.`:e===`running`?`starting…`:e===`held`?`Not started.`:`No tool calls.`}function YZ({job:e}){let t=e.status===`held`;return(0,R.jsxs)(R.Fragment,{children:[e.route?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Routed `,e.route]}):null,e.note&&t?(0,R.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-sm text-foreground`,children:[(0,R.jsx)(Dg,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{children:[`Held: `,e.note,`.`]})]}):null,e.note&&!t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.routed?`Routed here by the oracle — ${e.note}`:e.note}):null,e.routed&&!e.note?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Routed here by the oracle.`}):null]})}function XZ({job:e}){let t=e.status===`running`;return e.steps.length===0?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[t?(0,R.jsx)(MA,{className:`size-3.5`}):null,JZ(e.status)]}):(0,R.jsx)(`ol`,{className:`flex flex-col gap-1 text-sm`,children:e.steps.map((e,n)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:Mj(e.at)}),(0,R.jsx)(`span`,{className:`flex h-5 w-3.5 shrink-0 items-center justify-center`,"aria-hidden":`true`,children:e.pending&&t?(0,R.jsx)(MA,{className:`size-3.5`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:e.pending&&t?`${e.text}…`:e.text})]},n))})}function ZZ({job:e}){return e.status===`held`?(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Run anyway`,icon:Uh,tone:`primary`,shortcut:`R`,onClick:()=>void U(`quickfix.runAnyway`,{id:e.id})}),(0,R.jsx)(X,{label:`Turn it into a task`,text:`Make it a task`,icon:th,shortcut:`T`,onClick:()=>void U(`quickfix.movedToTask`,{id:e.id})})]}):e.status!==`queued`&&e.status!==`running`?null:(0,R.jsx)(mj,{children:(0,R.jsx)(Kj,{icon:dm,label:`Cancel the quick fix`,text:`Cancel`,shortcut:`C`,title:`Cancel this quick fix?`,description:`The agent stops. Files it already edited stay as they are.`,confirmLabel:`Cancel quick fix`,variant:`destructive`,onConfirm:()=>void U(`quickfix.cancel`,{id:e.id})})})}function QZ({job:e,now:t}){return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Quick fix detail`,children:[(0,R.jsx)(ZZ,{job:e}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:UZ(e)}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:e.status}),qZ(e,t)?(0,R.jsx)(`span`,{children:qZ(e,t)}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),e.prompt.trim().includes(`
|
|
101
|
-
`)?(0,R.jsx)(mH,{text:e.prompt}):null,(0,R.jsx)(YZ,{job:e}),(0,R.jsx)(_H,{title:`Steps`,children:(0,R.jsx)(XZ,{job:e})}),e.files?.length?(0,R.jsx)(_H,{title:`Edited`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,R.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,R.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:e.error}):null,e.report?(0,R.jsx)(_H,{title:`Report`,children:(0,R.jsx)(mH,{text:e.report})}):null]})}function $Z({status:e}){if(e===`running`)return(0,R.jsx)(MA,{className:`size-3.5`,"aria-label":`running`});let t={queued:_m,success:Vp,failed:Ug,timeout:Ug,cancelled:xh,held:Nh,running:_m}[e];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4 ${e===`success`?`text-success`:e===`failed`||e===`timeout`?`text-destructive`:e===`held`?`text-warning`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:e})]})}function eQ({job:e,selected:t,now:n,onSelect:r}){let i=KZ(e,n);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.id),className:q(nU,`flex-row items-start gap-2.5 text-sm`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,R.jsx)($Z,{status:e.status})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:UZ(e)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function tQ({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(eQ,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var nQ=()=>wA(CA(`quickfix`)),rQ=e=>wA(CA(`quickfix`,e));function iQ(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function aQ(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Gg,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:`font-medium text-foreground`,children:HZ})]})})}function oQ({id:e}){let t=Cj(),n=WA(`quickfix.list`,{},[`quickfix`]),r=WZ(n.data?.jobs??[]),i=iQ(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,R.jsx)(aQ,{}):(0,R.jsx)(sQ,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function sQ({id:e,wide:t,loaded:n,jobs:r,now:i}){let a=e??(t?r[0]?.id:void 0),o=r.find(e=>e.id===a),s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Quick fixes`,count:String(r.length)}),n?(0,R.jsx)(tQ,{jobs:r,selectedId:a,now:i,onSelect:rQ}):(0,R.jsx)(kj,{})]});return(0,R.jsx)(Dj,{wide:t,list:s,detail:o?(0,R.jsx)(QZ,{job:o,now:i}):e?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:nQ,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var cQ={},lQ=new Set;function uQ(e){cQ=e;for(let e of[...lQ])e()}function dQ(e){cQ.taskId!==e&&uQ({...cQ,taskId:e})}function fQ(e){(cQ.session?.name!==e?.name||JSON.stringify(cQ.session?.address)!==JSON.stringify(e?.address))&&uQ({...cQ,session:e})}function pQ(e){return lQ.add(e),()=>{lQ.delete(e)}}function mQ(){return(0,m.useSyncExternalStore)(pQ,()=>cQ,()=>cQ)}function hQ({entry:e}){let t=e.at?Mj(e.at):``;return e.role===`note`?(0,R.jsxs)(`li`,{className:`text-center text-xs text-muted-foreground`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,R.jsxs)(`li`,{className:`flex flex-col items-end gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,R.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,R.jsx)(mH,{text:e.text})})]}):(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,R.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,R.jsx)(mH,{text:e.text})})]})}function gQ({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t?(0,R.jsx)(`div`,{className:`flex self-center`,children:(0,R.jsx)(X,{label:`Load earlier messages`,icon:$p,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,R.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex flex-col gap-4`,children:e.map(e=>(0,R.jsx)(hQ,{entry:e},e.id))})]})}function _Q({address:e,empty:t}){let n=WA(`sessions.chat`,e,[`sessions`]),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=n.data?.entries??[],c=new Set(s.map(e=>e.id)),l=[...(r?.entries??[]).filter(e=>!c.has(e.id)),...s],u=async()=>{let t=l[0];if(!t)return;o(!0);let n=await U(`sessions.chat`,{...e,before:t.id});n&&i({entries:[...n.entries,...r?.entries??[]],more:n.hasOlder}),o(!1)},d=r?.more??n.data?.hasOlder??!1;return(0,R.jsx)(gQ,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var vQ={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},yQ=[`this window`,`background`,`other terminal`],bQ=`Nothing said yet.`,xQ=`This session runs in another terminal: its conversation shows here and your messages reach its oracle within seconds, but live activity only streams from sessions started in this window.`,SQ=`No other sessions. Start one below.`;function CQ(e,t,n){let r=t?.task;return{id:`here`,where:`this window`,name:e?.sessionName??r?.title??`unnamed session`,status:e?.busy?`working`:r?.state??`no task`,waiting:n,alive:!0,dialogs:[],...r?{task:r}:{}}}function wQ(e){let t=e.status===`exited`?`ended`:e.status===`starting`?`starting`:e.busy?`working`:`idle`;return{id:e.key,where:`background`,name:e.name,status:t,waiting:e.dialogs.length,key:e.key,alive:e.alive,dialogs:e.dialogs,...e.sessionId?{sessionId:e.sessionId}:{}}}function TQ(e){return{id:e.sessionId,where:`other terminal`,name:e.name??`unnamed session`,status:`running`,waiting:0,pid:e.pid,sessionId:e.sessionId,alive:!0,dialogs:[]}}function EQ(e,t,n,r,i){let a=new Set([e?.sessionId,...r.map(e=>e.sessionId)].filter(e=>!!e)),o=i.filter(e=>!a.has(e.sessionId));return[CQ(e,t,n),...r.map(wQ),...o.map(TQ)]}function DQ(e){return`${e} question${e===1?``:`s`} waiting for you`}function OQ(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function kQ(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function AQ(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function jQ({options:e,send:t}){return(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(Y,{variant:`outline`,onClick:()=>void t({value:e}),children:e},e))})}function MQ({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,R.jsx)(Aj,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:`Send the answer`,text:`Send`,icon:Np,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function NQ({dialog:e,send:t}){return e.method===`select`?(0,R.jsx)(jQ,{options:e.options??[],send:t}):e.method===`confirm`?(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,R.jsx)(Y,{variant:`outline`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,R.jsx)(MQ,{dialog:e,send:t})}function PQ({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await U(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,R.jsxs)(`div`,{className:`card-raised flex flex-col gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}),t.message?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.message}):null]}),(0,R.jsx)(NQ,{dialog:t,send:r}),(0,R.jsx)(`div`,{className:`flex self-start`,children:(0,R.jsx)(X,{label:`Put it away`,text:`Put away`,icon:Ug,onClick:()=>void r({cancelled:!0})})})]})}function FQ({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,R.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:DQ(t.length)}),t.map(t=>(0,R.jsx)(PQ,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var IQ={"this window":Ch,background:Zm,"other terminal":pg};function LQ({where:e,className:t}){let n=IQ[e];return(0,R.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function RQ({task:e}){let t=e.progress;return(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(DK,{done:t.done,total:t.total}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function zQ({entry:e}){let{key:t}=e;return e.where===`this window`?(0,R.jsx)(mj,{children:(0,R.jsx)(X,{label:`Back to this window`,text:`Back to the Lobby`,icon:kp,tone:`primary`,shortcut:`B`,onClick:()=>wA(`#/lobby`)})}):t?(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Move here`,icon:jp,tone:`primary`,shortcut:`M`,onClick:()=>void U(`sessions.switch`,{key:t})}),(0,R.jsx)(Kj,{icon:dm,label:`Stop the session`,text:`Stop`,shortcut:`S`,title:`Stop ${e.name}?`,description:`Its process ends. The task keeps its state and can be resumed in this window.`,confirmLabel:`Stop session`,variant:`destructive`,disabled:!e.alive,onConfirm:()=>void U(`sessions.stop`,{key:t})})]}):null}function BQ({entry:e,lobby:t}){let n=AQ(e);return e.where===`this window`?(0,R.jsx)(gQ,{entries:t?.chat??[],more:!1,empty:bQ}):n?(0,R.jsx)(_Q,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:OQ(e)},e.id):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:bQ})}function VQ({entry:e,lobby:t,onChanged:n}){return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex flex-col gap-4`,children:[(0,R.jsx)(zQ,{entry:e}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h3`,{className:`flex items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,R.jsx)(LQ,{where:e.where,className:`size-[1.1rem]`}),e.name]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:kQ(e)}),e.task?(0,R.jsx)(RQ,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:DQ(e.waiting)}):null]}),e.where===`other terminal`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:xQ}):null,e.key?(0,R.jsx)(FQ,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,R.jsx)(_H,{title:`Conversation`,children:(0,R.jsx)(BQ,{entry:e,lobby:t})})]})}function HQ({entry:e,selected:t,onSelect:n}){let r=xf();return(0,R.jsx)(B.li,{layout:!r&&`position`,initial:!1,"data-slot":`active-session`,className:`border-t border-border first:border-t-0`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(nU,`flex-row items-start gap-3 rounded-none px-4 py-3 text-sm focus-visible:ring-inset`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg bg-foreground/4 text-foreground/75 shadow-[inset_0_0_0_1px_var(--border)]`,children:(0,R.jsx)(LQ,{where:e.where})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:q(`flex flex-wrap items-center gap-2 break-words text-foreground`,t&&`font-medium`),children:[e.name,e.where===`this window`?(0,R.jsx)(tU,{variant:`secondary`,radius:`full`,size:`sm`,children:`This window`}):null]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,R.jsx)(MA,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,R.jsxs)(tU,{variant:`warning-light`,radius:`full`,className:`text-warning tabular-nums`,children:[e.waiting,` waiting`]}):null]})]})]})})}function UQ({where:e,entries:t,selectedId:n,onSelect:r}){return(0,R.jsxs)(`section`,{"aria-label":vQ[e],className:`flex flex-col`,children:[(0,R.jsx)(`h3`,{className:iU,children:(0,R.jsx)(gH,{title:vQ[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:`workspace-section mx-3 mb-2 flex flex-col overflow-hidden rounded-xl border shadow-xs`,children:t.map(e=>(0,R.jsx)(HQ,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function WQ({entries:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:yQ.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,R.jsx)(UQ,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var GQ=()=>wA(`#/sessions`),KQ=e=>wA(`#/sessions/${encodeURIComponent(e)}`);function qQ({windows:e}){return e.length===0?null:(0,R.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,R.jsx)(_H,{title:`Other windows`,children:(0,R.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-h-8 items-center rounded-lg px-2.5 text-sm text-foreground underline-offset-4 transition-colors hover:bg-muted hover:underline`,children:e.name})},e.url))})})})}function JQ(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function YQ({id:e}){let t=Cj(),n=HA(`status`).data,r=HA(`lobby`).data,i=HA(`prompts`).data?.prompts.length??0,a=WA(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,R.jsx)(RA,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=EQ(n,r,i,a.data?.background??[],a.data?.live??[]),s=e??(t?o[0]?.id:void 0),c=o.find(e=>e.id===s),l=c&&c.where!==`this window`&&c.alive?AQ(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(fQ(l&&d?{name:d,address:l}:void 0),()=>fQ(void 0)),[u,d]);let f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Sessions`,count:String(o.length)}),a.data?(0,R.jsx)(WQ,{entries:o,selectedId:s,onSelect:KQ}):(0,R.jsx)(kj,{}),a.data&&o.length===1?(0,R.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:SQ}):null,(0,R.jsx)(qQ,{windows:n?.windows??[]})]}),p=c?(0,R.jsx)(VQ,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,R.jsx)(JQ,{}):null;return(0,R.jsx)(Dj,{wide:t,list:f,detail:p,open:!!e,onClose:GQ,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function XQ({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,SK(xK(e,n,t)),` execution`]})}function ZQ({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=CK(r,e);return(0,R.jsxs)(`span`,{className:`tabular-nums`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,SK(e.workedMs+i)]})}function QQ({timing:e,work:t,stopped:n=!1}){return t?(0,R.jsx)(ZQ,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,R.jsx)(XQ,{timing:e,stopped:n},JSON.stringify(e)):(0,R.jsx)(`span`,{children:`Timing unavailable`})}var $Q=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,e$={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function t$({delivery:e,title:t}){return(0,R.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,R.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,R.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,R.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,R.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function n$({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(Y,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function r$(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?Te(`tasks.deliveryReview`,{taskId:t}):e===`defer`?Te(`tasks.deliveryDefer`,r):Te(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function i$({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=P(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function a$(e){return e.scope.current===e.identity&&e.project===P()}function o$(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await r$(r,t.taskId,e.current.reviewId);a$(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){a$(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function s$(e){let t=i$(e),n=o$(t,e),r=hA(t.confirm,mA.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function c$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:e$[e.current.status]}),e.current.error||e.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,R.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,R.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,R.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function l$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(n$,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,R.jsx)(n$,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,R.jsx)(Y,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function u$({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:$Q;return(0,R.jsx)(sA,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,R.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,R.jsx)(`p`,{className:`text-sm`,children:n}),(0,R.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,R.jsx)(Y,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function d$({title:e,review:t}){return(0,R.jsxs)(_H,{title:`Completed work · delivery review`,right:e$[t.current.status],children:[(0,R.jsx)(t$,{delivery:t.current,title:e}),(0,R.jsx)(c$,{review:t}),(0,R.jsx)(l$,{review:t}),(0,R.jsx)(u$,{review:t})]})}function f$(e){let t=s$(e);return(0,R.jsx)(d$,{title:e.title,review:t})}var p$={open:hm,delivered:sm,addressed:rm},m$={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function h$({comment:e}){let t=Fj(Date.now()-Date.parse(e.createdAt)),n=p$[e.status];return(0,R.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),m$[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function g$({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,R.jsxs)(`li`,{className:`card-raised rounded-lg border px-3.5 py-2.5`,children:[r?(0,R.jsx)(BX,{text:s.text,onSave:async n=>{let r=await Te(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,R.jsx)(mH,{text:s.text}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(h$,{comment:s}),n&&!r?(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function _$({taskId:e,finished:t,canComment:n}){let r=WA(`tasks.comments`,{taskId:e},[`tasks`]),i=HA(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,R.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,R.jsx)(gH,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,R.jsx)(g$,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var v$={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},y$={open:`open`,done:`done`,dropped:`abandoned`},b$={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function x$(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var S$=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function C$(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function w$(e){return e===`now`?`just now`:`${e} ago`}function T$(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[C$(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function E$(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function D$(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}function O$({step:e,stopped:t}){let n=CK(!t,e);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:SK((e.workedMs??0)+n)})}function k$(){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,R.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function A$({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=e.activeAgentCount??1,a=e.status===`done`,o=a?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,s=a?rm:hm;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm`,"data-step":r?`active`:e.status,children:[r?(0,R.jsx)(k$,{}):(0,R.jsx)(s,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${o}`}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsxs)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:[e.text,r?(0,R.jsxs)(`span`,{className:`ml-1 text-xs text-primary`,children:[`(`,i,` `,i===1?`dev working`:`devs working`,`)`]}):null]}),r?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,R.jsx)(O$,{step:e,stopped:n}),(0,R.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,R.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]})}function j$({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,R.jsx)(_H,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,R.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,R.jsx)(A$,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function M$({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,R.jsxs)(_H,{title:`Full plan`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,R.jsx)(`div`,{id:r,children:(0,R.jsx)(mH,{text:e})}):null]})}function N$({detail:e,finished:t}){return e.plan&&e.planDetails?(0,R.jsx)(M$,{text:e.planDetails}):e.plan?(0,R.jsx)(_H,{title:`Approved plan`,children:(0,R.jsx)(mH,{text:e.plan})}):e.proposal?(0,R.jsx)(_H,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,R.jsx)(mH,{text:e.proposal})}):(0,R.jsx)(_H,{title:`Plan`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function P$({amendments:e}){return e.length===0?null:(0,R.jsx)(_H,{title:`Amendments`,children:(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))})})}function F$({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,R.jsx)(_H,{title:`Waiting on`,children:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(tm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.kind,` `,e.detail]})]},`${t}-${e.kind}`)),e.blockers.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(pm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function I$({risk:e}){let t=b$[e.risk];return(0,R.jsxs)(_H,{title:`QA risk`,right:x$(e),children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,R.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,R.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function L$({runs:e}){return e.length===0?null:(0,R.jsx)(_H,{title:`Recent runs`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,R.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function R$({detail:e,finished:t}){return(0,R.jsxs)(R.Fragment,{children:[e.steps.length>0?(0,R.jsx)(j$,{steps:e.steps,stopped:t}):null,e.request?(0,R.jsx)(_H,{title:`Request`,children:(0,R.jsx)(mH,{text:e.request})}):null,(0,R.jsx)(N$,{detail:e,finished:t})]})}function z$({detail:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P$,{amendments:e.amendments}),(0,R.jsx)(F$,{detail:e}),e.qaRisk?(0,R.jsx)(I$,{risk:e.qaRisk}):null,(0,R.jsx)(L$,{runs:e.runs})]})}function B$({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return wA(`#/lobby`);let t=P(),r=()=>n.current&&P()===t;try{let t=await Te(`tasks.open`,{taskId:e.id});if(!r())return;let n=await Te(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return wA(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&wA(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,R.jsx)(X,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:jp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function V$({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,R.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,R.jsxs)(`span`,{children:[n>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,R.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function H$({planId:e}){let t=WA(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,R.jsxs)(R.Fragment,{children:[n.issue?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,R.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,R.jsx)(V$,{split:n.split}):null,(0,R.jsx)(_H,{title:`Agreed plan`,children:(0,R.jsx)(mH,{text:n.brief})})]}):t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function U$({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":e.title,children:[(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Start here`,icon:Uh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,R.jsx)(X,{label:`Start in a new session`,text:`New session`,icon:dg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,R.jsx)(Kj,{icon:Tg,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,R.jsx)(OK,{check:`open`,className:`mt-1.5`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${w$(e.age)}`:``]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,R.jsx)(H$,{planId:e.id})]})}function W$({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=P();r(!0);try{let r=await Te(`tasks.resume`,{taskId:e.id});if(P()!==n)return;let i=r.key;H(r.notice,i?{action:{label:`Watch`,onClick:()=>wA(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){P()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,R.jsx)(X,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Uh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function G$(e){if(e.kind===`archived`)return{state:`archived`,rest:w$(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${w$(e.age)}`:``;return{state:C$(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function K$(e){return e?[TK(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function q$({row:e}){return e.progress?(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(DK,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function J$({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=G$(e);return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,R.jsx)(OK,{check:e.check,className:`mt-1.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[y$[e.check],`:`]}),(0,R.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,R.jsx)(`span`,{children:i}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,K$(t),n].filter(Boolean).join(` · `)}),(0,R.jsx)(q$,{row:e})]})}function Y$({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function X$({row:e,archive:t}){return e.check===`open`?(0,R.jsx)(Kj,{label:`Archive`,icon:Tp,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,R.jsx)(X,{label:`Archive`,icon:Tp,shortcut:`E`,onClick:()=>void t()})}function Z$({on:e,toggle:t}){return fj(`a`,t),(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent`,children:[(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Auto`}),(0,R.jsx)(jJ,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,R.jsx)(aA,{chord:`A`,className:`kbd-hint`})]})}),(0,R.jsx)(JA,{children:`Auto mode: the oracle decides without asking`})]})}function Q$(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=Y$(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,R.jsxs)(mj,{children:[s?(0,R.jsx)(W$,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,R.jsx)(B$,{row:t,quiet:s}):null,t.kind===`task`?(0,R.jsx)($$,{taskId:t.id}):null,o?(0,R.jsx)(X,{label:`Restore`,icon:Zh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,R.jsx)(Z$,{on:!!t.auto,toggle:a}):null,o?null:(0,R.jsx)(X$,{row:t,archive:r}),(0,R.jsx)(Kj,{icon:Tg,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function $$({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=P();try{let r=await Te(`tasks.open`,{taskId:e});if(!t.current||P()!==n)return;r.notice&&H.info(r.notice);let i=await Te(`status.get`,{});if(!t.current||P()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?wA(`#/sessions/${encodeURIComponent(a)}`):r.notice||H.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&P()===n&&H.error(e instanceof Error?e.message:String(e))}}return(0,R.jsx)(X,{label:`Open task conversation`,text:`Conversation`,icon:ph,shortcut:`O`,onClick:()=>void n()})}function e1(e){let{row:t}=e,n=t.kind===`plan`,r=WA(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=HA(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,R.jsx)(U$,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":t.title,children:[(0,R.jsx)(Q$,{...e}),(0,R.jsx)(J$,{row:t,task:a}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,R.jsx)(QQ,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,R.jsx)(f$,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,R.jsx)(R$,{detail:r.data,finished:!o}):null,(0,R.jsx)(_$,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,R.jsx)(z$,{detail:r.data}):null,r.error&&!r.data?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function t1({row:e}){return e.check===`open`&&e.progress?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(DK,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function n1(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function r1({row:e,card:t}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:e.status.replaceAll(`_`,` `)}):null,e.check===`open`?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:T$(e)}):null,e.kind===`plan`?null:(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,R.jsx)(QQ,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,R.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function i1({row:e,selected:t,onSelect:n,card:r=!1}){return(0,R.jsx)(`li`,{className:r?`overflow-hidden rounded-lg border border-input bg-card shadow-sm`:void 0,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsx)(OK,{check:e.check,className:`mt-0.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[y$[e.check],`:`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,n1(e),t&&`font-medium text-foreground`),children:e.title}),(0,R.jsx)(t1,{row:e})]}),(0,R.jsx)(r1,{row:e,card:r})]})})}function a1({rows:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:E$(e).map(({section:e,rows:r})=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:iU,children:(0,R.jsx)(gH,{title:v$[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:rU,children:r.map(e=>(0,R.jsx)(i1,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var o1=()=>wA(CA(`tasks`,`board`)),s1=e=>wA(CA(`tasks`,`board`,e)),c1=[`Backlog`,`In progress`,`Completed`];function l1(e){if(e.kind!==`archived`&&e.section!==`archived`)return e.check===`done`?`Completed`:e.kind===`plan`||e.status===`created`||e.check===`dropped`?`Backlog`:`In progress`}function u1({title:e,rows:t,id:n}){return(0,R.jsxs)(GK,{role:`region`,"aria-label":e,spacing:`sm`,className:`min-w-0`,children:[(0,R.jsx)(qK,{className:`py-2`,children:(0,R.jsxs)(`h2`,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[e,(0,R.jsx)(tU,{variant:`secondary`,radius:`full`,children:t.length})]})}),(0,R.jsxs)(KK,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,R.jsx)(i1,{row:e,selected:e.id===n,onSelect:s1,card:!0},`${e.kind}-${e.id}`))}),t.length?null:(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tasks here.`})]})]})}function d1({rows:e,id:t}){return(0,R.jsx)(`div`,{className:`grid items-start gap-4 p-4 md:grid-cols-3`,"aria-label":`Task board`,children:c1.map(n=>(0,R.jsx)(u1,{title:n,rows:e.filter(e=>l1(e)===n),id:t},n))})}function f1({id:e}){let t=WA(`tasks.list`,{},[`tasks`,`plans`]),n=t.data?.rows??[],r=n.find(t=>t.id===e&&l1(t)!==void 0),i=r?.kind===`task`?r.id:void 0;if((0,m.useEffect)(()=>(dQ(i),()=>dQ(void 0)),[i]),!t.data&&t.error)return(0,R.jsx)(RA,{message:`Could not load tasks. ${t.error}`,onRetry:t.reload});let a=r?(0,R.jsx)(e1,{row:r,onGone:o1,onChanged:t.reload},r.id):null;return(0,R.jsx)(Dj,{wide:!1,list:t.data?(0,R.jsx)(d1,{rows:n,id:e}):(0,R.jsx)(kj,{}),detail:a,open:!!r,onClose:o1,hint:`Select a task to see its detail.`,describe:`Task detail`})}var p1=()=>wA(CA(`tasks`)),m1=e=>wA(CA(`tasks`,e));function h1(){return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)($m,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{children:S$})]}),(0,R.jsx)(Y,{onClick:()=>wA(CA(`plan`)),children:`Plan a task`})]})}function g1({shown:e,count:t,onToggle:n}){return(0,R.jsxs)(`label`,{className:`btn-raised flex h-7 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow]`,children:[(0,R.jsx)(QW,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,R.jsx)(tU,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function _1({id:e,board:t=!1}){return(0,R.jsxs)(ck,{value:t?`board`:`list`,onValueChange:e=>wA(CA(`tasks`,...e===`board`?[`board`]:[])),className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(lk,{"aria-label":`Task views`,className:`flex gap-1 border-b border-border px-4 py-2`,children:[(0,R.jsx)(uk,{value:`list`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`List`}),(0,R.jsx)(uk,{value:`board`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`Board`})]}),(0,R.jsx)(dk,{value:`list`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(v1,{id:e})}),(0,R.jsx)(dk,{value:`board`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(f1,{id:e})})]})}function v1({id:e}){let t=Cj(),[n,r]=(0,m.useState)(!1),i=WA(`tasks.list`,{},[`tasks`,`plans`]),a=WA(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(dQ(u),()=>dQ(void 0)),[u]),!i.data&&i.error)return(0,R.jsx)(RA,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,R.jsx)(h1,{});let d=[...c,...s].find(e=>e.id===l),f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Tasks`,count:D$(c),children:(0,R.jsx)(g1,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:S$}):(0,R.jsx)(a1,{rows:c,selectedId:l,onSelect:m1}):(0,R.jsx)(kj,{})]}),p=d?(0,R.jsx)(e1,{row:d,onGone:p1,onChanged:i.reload},d.id):e?(0,R.jsx)(y1,{}):null;return(0,R.jsx)(Dj,{wide:t,list:f,detail:p,open:!!e,onClose:p1,hint:`Select a task to see its detail.`,describe:`Task detail`})}function y1(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var b1={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function x1(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function S1(e){if(e.kind===`settings`)return(0,R.jsx)(SX,{});if(e.kind===`sessions`)return(0,R.jsx)(YQ,{id:x1(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,R.jsx)(UK,{});case`tasks`:return(0,R.jsx)(_1,{...ZW(e.rest)});case`plan`:return(0,R.jsx)(BZ,{rest:e.rest});case`quickfix`:return(0,R.jsx)(oQ,{id:x1(e.rest)});case`issues`:return(0,R.jsx)(zU,{rest:e.rest});case`metrics`:return(0,R.jsx)(Xq,{});case`git`:return(0,R.jsx)(fU,{rest:e.rest});case`knowledge`:return(0,R.jsx)(XW,{rest:e.rest});case`excalidraw`:return(0,R.jsx)(iK,{id:x1(e.rest)})}}function C1(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var w1={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function T1(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:w1[e]}function E1(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=T1(n);if(!e)return;t.code=e}return t.code?t:void 0}function D1(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function O1(e,t){let n=E1(t);return n?D1(e,n):!1}function k1(e,t){for(let n of t)if(O1(e,n.key))return n.action}function A1(e,t){for(let n of t)if(O1(e,n.key))return n.id}function j1(e){return ZA(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||gA()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function M1(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)rj(e.key===`j`?1:-1);else return!1;return!0}function N1(e,t){let n=A1(e,t.tabs),r=k1(e,t.keys);return!n&&!r?!1:C1(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||gA(),typing:ZA(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function P1(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=b1[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(M1(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function F1(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){k1(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&j1(n)){t=0;return}if(N1(n,e)){t=0;return}t=r?P1(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var I1=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],L1=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(b1).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],R1=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`quickfix`,page:`Quick fix`,keys:[[`R`,`run anyway`],[`T`,`make a task`],[`C`,`cancel`]]},{id:`git`,page:`Git`,keys:[[`R`,`refresh`],[`V`,`review`],[`Q`,`Jev's read`],[`X`,`stop`]]},{id:`issues`,page:`Issues`,keys:[[`R`,`refresh`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`excalidraw`,page:`Excalidraw`,keys:[[`R`,`reveal`],[`C`,`copy`],[`O`,`open`],[`W`,`draw`],[`T`,`check`],[`Delete`,`remove`]]},{id:`sessions`,page:`Sessions`,keys:[[`M`,`move here`],[`S`,`stop`],[`B`,`back`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],z1=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],B1=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function V1({line:e}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,R.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,R.jsx)($k,{children:e},e))}):(0,R.jsx)(aA,{chord:e.label??``})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function H1(){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),R1.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(aA,{chord:e}),t]},e))})]},e.id))]})}function U1({title:e,lines:t}){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,R.jsx)(V1,{line:e},e.id))]})}function W1(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function G1(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function K1({open:e,onOpenChange:t,keys:n,tabs:r}){let i=hA(e,mA.help);return(0,m.useEffect)(()=>{if(!e||!i)return;let r=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&O1(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,i,t,n]),(0,R.jsxs)(sA,{open:e&&i,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,R.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(aA,{chord:`Esc`}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,R.jsx)(Ug,{"aria-hidden":`true`})})]})]}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-10 gap-y-6 overflow-y-auto px-6 py-5 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(U1,{title:`Everywhere`,lines:W1(n)}),(0,R.jsx)(U1,{title:`Jump to a tab`,lines:G1(r)}),(0,R.jsx)(U1,{title:`Navigation and editing`,lines:L1}),(0,R.jsx)(U1,{title:`Message box`,lines:I1})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(U1,{title:`Lists and panes`,lines:z1}),(0,R.jsx)(H1,{}),(0,R.jsx)(U1,{title:`Questions`,lines:B1})]})]})]})}function q1(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function J1(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Ce(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Ce(r.error,r.code,n.status);return r.result}function Y1(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function X1(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var Z1=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function Q1(e,t){let n=e.lastIndexOf(`
|
|
101
|
+
`)?(0,R.jsx)(mH,{text:e.prompt}):null,(0,R.jsx)(YZ,{job:e}),(0,R.jsx)(_H,{title:`Steps`,children:(0,R.jsx)(XZ,{job:e})}),e.files?.length?(0,R.jsx)(_H,{title:`Edited`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,R.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,R.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:e.error}):null,e.report?(0,R.jsx)(_H,{title:`Report`,children:(0,R.jsx)(mH,{text:e.report})}):null]})}function $Z({status:e}){if(e===`running`)return(0,R.jsx)(MA,{className:`size-3.5`,"aria-label":`running`});let t={queued:_m,success:Vp,failed:Ug,timeout:Ug,cancelled:xh,held:Nh,running:_m}[e];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4 ${e===`success`?`text-success`:e===`failed`||e===`timeout`?`text-destructive`:e===`held`?`text-warning`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:e})]})}function eQ({job:e,selected:t,now:n,onSelect:r}){let i=KZ(e,n);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.id),className:q(nU,`flex-row items-start gap-2.5 text-sm`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,R.jsx)($Z,{status:e.status})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:UZ(e)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function tQ({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:rU,children:e.map(e=>(0,R.jsx)(eQ,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var nQ=()=>wA(CA(`quickfix`)),rQ=e=>wA(CA(`quickfix`,e));function iQ(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function aQ(){return(0,R.jsx)(EA,{className:`m-4 flex-1`,children:(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)(Gg,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{className:`font-medium text-foreground`,children:HZ})]})})}function oQ({id:e}){let t=Cj(),n=WA(`quickfix.list`,{},[`quickfix`]),r=WZ(n.data?.jobs??[]),i=iQ(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,R.jsx)(RA,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,R.jsx)(aQ,{}):(0,R.jsx)(sQ,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function sQ({id:e,wide:t,loaded:n,jobs:r,now:i}){let a=e??(t?r[0]?.id:void 0),o=r.find(e=>e.id===a),s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Quick fixes`,count:String(r.length)}),n?(0,R.jsx)(tQ,{jobs:r,selectedId:a,now:i,onSelect:rQ}):(0,R.jsx)(kj,{})]});return(0,R.jsx)(Dj,{wide:t,list:s,detail:o?(0,R.jsx)(QZ,{job:o,now:i}):e?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:nQ,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var cQ={},lQ=new Set;function uQ(e){cQ=e;for(let e of[...lQ])e()}function dQ(e){cQ.taskId!==e&&uQ({...cQ,taskId:e})}function fQ(e){(cQ.session?.name!==e?.name||JSON.stringify(cQ.session?.address)!==JSON.stringify(e?.address))&&uQ({...cQ,session:e})}function pQ(e){return lQ.add(e),()=>{lQ.delete(e)}}function mQ(){return(0,m.useSyncExternalStore)(pQ,()=>cQ,()=>cQ)}function hQ({entry:e}){let t=e.at?Mj(e.at):``;return e.role===`note`?(0,R.jsxs)(`li`,{className:`text-center text-xs text-muted-foreground`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,R.jsxs)(`li`,{className:`flex flex-col items-end gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,R.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,R.jsx)(mH,{text:e.text})})]}):(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,R.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,R.jsx)(mH,{text:e.text})})]})}function gQ({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t?(0,R.jsx)(`div`,{className:`flex self-center`,children:(0,R.jsx)(X,{label:`Load earlier messages`,icon:$p,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,R.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex flex-col gap-4`,children:e.map(e=>(0,R.jsx)(hQ,{entry:e},e.id))})]})}function _Q({address:e,empty:t}){let n=WA(`sessions.chat`,e,[`sessions`]),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=n.data?.entries??[],c=new Set(s.map(e=>e.id)),l=[...(r?.entries??[]).filter(e=>!c.has(e.id)),...s],u=async()=>{let t=l[0];if(!t)return;o(!0);let n=await U(`sessions.chat`,{...e,before:t.id});n&&i({entries:[...n.entries,...r?.entries??[]],more:n.hasOlder}),o(!1)},d=r?.more??n.data?.hasOlder??!1;return(0,R.jsx)(gQ,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var vQ={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},yQ=[`this window`,`background`,`other terminal`],bQ=`Nothing said yet.`,xQ=`This session runs in another terminal: its conversation shows here and your messages reach its oracle within seconds, but live activity only streams from sessions started in this window.`,SQ=`No other sessions. Start one below.`;function CQ(e,t,n){let r=t?.task;return{id:`here`,where:`this window`,name:e?.sessionName??r?.title??`unnamed session`,status:e?.busy?`working`:r?.state??`no task`,waiting:n,alive:!0,dialogs:[],...r?{task:r}:{}}}function wQ(e){let t=e.status===`exited`?`ended`:e.status===`starting`?`starting`:e.busy?`working`:`idle`;return{id:e.key,where:`background`,name:e.name,status:t,waiting:e.dialogs.length,key:e.key,alive:e.alive,dialogs:e.dialogs,...e.sessionId?{sessionId:e.sessionId}:{}}}function TQ(e){return{id:e.sessionId,where:`other terminal`,name:e.name??`unnamed session`,status:`running`,waiting:0,pid:e.pid,sessionId:e.sessionId,alive:!0,dialogs:[]}}function EQ(e,t,n,r,i){let a=new Set([e?.sessionId,...r.map(e=>e.sessionId)].filter(e=>!!e)),o=i.filter(e=>!a.has(e.sessionId));return[CQ(e,t,n),...r.map(wQ),...o.map(TQ)]}function DQ(e){return`${e} question${e===1?``:`s`} waiting for you`}function OQ(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function kQ(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function AQ(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function jQ({options:e,send:t}){return(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(Y,{variant:`outline`,onClick:()=>void t({value:e}),children:e},e))})}function MQ({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,R.jsx)(Aj,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:`Send the answer`,text:`Send`,icon:Np,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function NQ({dialog:e,send:t}){return e.method===`select`?(0,R.jsx)(jQ,{options:e.options??[],send:t}):e.method===`confirm`?(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,R.jsx)(Y,{variant:`outline`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,R.jsx)(MQ,{dialog:e,send:t})}function PQ({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await U(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,R.jsxs)(`div`,{className:`card-raised flex flex-col gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}),t.message?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.message}):null]}),(0,R.jsx)(NQ,{dialog:t,send:r}),(0,R.jsx)(`div`,{className:`flex self-start`,children:(0,R.jsx)(X,{label:`Put it away`,text:`Put away`,icon:Ug,onClick:()=>void r({cancelled:!0})})})]})}function FQ({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,R.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:DQ(t.length)}),t.map(t=>(0,R.jsx)(PQ,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var IQ={"this window":Ch,background:Zm,"other terminal":pg};function LQ({where:e,className:t}){let n=IQ[e];return(0,R.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function RQ({task:e}){let t=e.progress;return(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(DK,{done:t.done,total:t.total}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function zQ({entry:e}){let{key:t}=e;return e.where===`this window`?(0,R.jsx)(mj,{children:(0,R.jsx)(X,{label:`Back to this window`,text:`Back to the Lobby`,icon:kp,tone:`primary`,shortcut:`B`,onClick:()=>wA(`#/lobby`)})}):t?(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Move here`,icon:jp,tone:`primary`,shortcut:`M`,onClick:()=>void U(`sessions.switch`,{key:t})}),(0,R.jsx)(Kj,{icon:dm,label:`Stop the session`,text:`Stop`,shortcut:`S`,title:`Stop ${e.name}?`,description:`Its process ends. The task keeps its state and can be resumed in this window.`,confirmLabel:`Stop session`,variant:`destructive`,disabled:!e.alive,onConfirm:()=>void U(`sessions.stop`,{key:t})})]}):null}function BQ({entry:e,lobby:t}){let n=AQ(e);return e.where===`this window`?(0,R.jsx)(gQ,{entries:t?.chat??[],more:!1,empty:bQ}):n?(0,R.jsx)(_Q,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:OQ(e)},e.id):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:bQ})}function VQ({entry:e,lobby:t,onChanged:n}){return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex flex-col gap-4`,children:[(0,R.jsx)(zQ,{entry:e}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h3`,{className:`flex items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,R.jsx)(LQ,{where:e.where,className:`size-[1.1rem]`}),e.name]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:kQ(e)}),e.task?(0,R.jsx)(RQ,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:DQ(e.waiting)}):null]}),e.where===`other terminal`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:xQ}):null,e.key?(0,R.jsx)(FQ,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,R.jsx)(_H,{title:`Conversation`,children:(0,R.jsx)(BQ,{entry:e,lobby:t})})]})}function HQ({entry:e,selected:t,onSelect:n}){let r=xf();return(0,R.jsx)(B.li,{layout:!r&&`position`,initial:!1,"data-slot":`active-session`,className:`border-t border-border first:border-t-0`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(nU,`flex-row items-start gap-3 rounded-none px-4 py-3 text-sm focus-visible:ring-inset`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg bg-foreground/4 text-foreground/75 shadow-[inset_0_0_0_1px_var(--border)]`,children:(0,R.jsx)(LQ,{where:e.where})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:q(`flex flex-wrap items-center gap-2 break-words text-foreground`,t&&`font-medium`),children:[e.name,e.where===`this window`?(0,R.jsx)(tU,{variant:`secondary`,radius:`full`,size:`sm`,children:`This window`}):null]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,R.jsx)(MA,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,R.jsxs)(tU,{variant:`warning-light`,radius:`full`,className:`text-warning tabular-nums`,children:[e.waiting,` waiting`]}):null]})]})]})})}function UQ({where:e,entries:t,selectedId:n,onSelect:r}){return(0,R.jsxs)(`section`,{"aria-label":vQ[e],className:`flex flex-col`,children:[(0,R.jsx)(`h3`,{className:iU,children:(0,R.jsx)(gH,{title:vQ[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:`workspace-section mx-3 mb-2 flex flex-col overflow-hidden rounded-xl border shadow-xs`,children:t.map(e=>(0,R.jsx)(HQ,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function WQ({entries:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:yQ.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,R.jsx)(UQ,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var GQ=()=>wA(`#/sessions`),KQ=e=>wA(`#/sessions/${encodeURIComponent(e)}`);function qQ({windows:e}){return e.length===0?null:(0,R.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,R.jsx)(_H,{title:`Other windows`,children:(0,R.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-h-8 items-center rounded-lg px-2.5 text-sm text-foreground underline-offset-4 transition-colors hover:bg-muted hover:underline`,children:e.name})},e.url))})})})}function JQ(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function YQ({id:e}){let t=Cj(),n=HA(`status`).data,r=HA(`lobby`).data,i=HA(`prompts`).data?.prompts.length??0,a=WA(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,R.jsx)(RA,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=EQ(n,r,i,a.data?.background??[],a.data?.live??[]),s=e??(t?o[0]?.id:void 0),c=o.find(e=>e.id===s),l=c&&c.where!==`this window`&&c.alive?AQ(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(fQ(l&&d?{name:d,address:l}:void 0),()=>fQ(void 0)),[u,d]);let f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Sessions`,count:String(o.length)}),a.data?(0,R.jsx)(WQ,{entries:o,selectedId:s,onSelect:KQ}):(0,R.jsx)(kj,{}),a.data&&o.length===1?(0,R.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:SQ}):null,(0,R.jsx)(qQ,{windows:n?.windows??[]})]}),p=c?(0,R.jsx)(VQ,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,R.jsx)(JQ,{}):null;return(0,R.jsx)(Dj,{wide:t,list:f,detail:p,open:!!e,onClose:GQ,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function XQ({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,SK(xK(e,n,t)),` execution`]})}function ZQ({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=CK(r,e);return(0,R.jsxs)(`span`,{className:`tabular-nums`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,SK(e.workedMs+i)]})}function QQ({timing:e,work:t,stopped:n=!1}){return t?(0,R.jsx)(ZQ,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,R.jsx)(XQ,{timing:e,stopped:n},JSON.stringify(e)):(0,R.jsx)(`span`,{children:`Timing unavailable`})}var $Q=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,e$={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function t$({delivery:e,title:t}){return(0,R.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,R.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,R.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,R.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,R.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function n$({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(Y,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function r$(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?Te(`tasks.deliveryReview`,{taskId:t}):e===`defer`?Te(`tasks.deliveryDefer`,r):Te(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function i$({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=P(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function a$(e){return e.scope.current===e.identity&&e.project===P()}function o$(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await r$(r,t.taskId,e.current.reviewId);a$(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){a$(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function s$(e){let t=i$(e),n=o$(t,e),r=hA(t.confirm,mA.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function c$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:e$[e.current.status]}),e.current.error||e.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,R.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,R.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,R.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function l$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(n$,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,R.jsx)(n$,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,R.jsx)(Y,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function u$({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:$Q;return(0,R.jsx)(sA,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,R.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,R.jsx)(`p`,{className:`text-sm`,children:n}),(0,R.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,R.jsx)(Y,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function d$({title:e,review:t}){return(0,R.jsxs)(_H,{title:`Completed work · delivery review`,right:e$[t.current.status],children:[(0,R.jsx)(t$,{delivery:t.current,title:e}),(0,R.jsx)(c$,{review:t}),(0,R.jsx)(l$,{review:t}),(0,R.jsx)(u$,{review:t})]})}function f$(e){let t=s$(e);return(0,R.jsx)(d$,{title:e.title,review:t})}var p$={open:hm,delivered:sm,addressed:rm},m$={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function h$({comment:e}){let t=Fj(Date.now()-Date.parse(e.createdAt)),n=p$[e.status];return(0,R.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),m$[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function g$({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,R.jsxs)(`li`,{className:`card-raised rounded-lg border px-3.5 py-2.5`,children:[r?(0,R.jsx)(BX,{text:s.text,onSave:async n=>{let r=await Te(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,R.jsx)(mH,{text:s.text}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(h$,{comment:s}),n&&!r?(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function _$({taskId:e,finished:t,canComment:n}){let r=WA(`tasks.comments`,{taskId:e},[`tasks`]),i=HA(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,R.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,R.jsx)(gH,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,R.jsx)(g$,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var v$={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},y$={open:`open`,done:`done`,dropped:`abandoned`},b$={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function x$(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var S$=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function C$(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function w$(e){return e===`now`?`just now`:`${e} ago`}function T$(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[C$(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function E$(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function D$(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}function O$({step:e,stopped:t}){let n=CK(!t,e);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:SK((e.workedMs??0)+n)})}function k$(){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,R.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function A$({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=e.activeAgentCount??1,a=e.status===`done`,o=a?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,s=a?rm:hm;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm`,"data-step":r?`active`:e.status,children:[r?(0,R.jsx)(k$,{}):(0,R.jsx)(s,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${o}`}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsxs)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:[e.text,r?(0,R.jsxs)(`span`,{className:`ml-1 text-xs text-primary`,children:[`(`,i,` `,i===1?`agent working`:`agents working`,`)`]}):null]}),r?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,R.jsx)(O$,{step:e,stopped:n}),(0,R.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,R.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]})}function j$({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,R.jsx)(_H,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,R.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,R.jsx)(A$,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function M$({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,R.jsxs)(_H,{title:`Full plan`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,R.jsx)(`div`,{id:r,children:(0,R.jsx)(mH,{text:e})}):null]})}function N$({detail:e,finished:t}){return e.plan&&e.planDetails?(0,R.jsx)(M$,{text:e.planDetails}):e.plan?(0,R.jsx)(_H,{title:`Approved plan`,children:(0,R.jsx)(mH,{text:e.plan})}):e.proposal?(0,R.jsx)(_H,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,R.jsx)(mH,{text:e.proposal})}):(0,R.jsx)(_H,{title:`Plan`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function P$({amendments:e}){return e.length===0?null:(0,R.jsx)(_H,{title:`Amendments`,children:(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))})})}function F$({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,R.jsx)(_H,{title:`Waiting on`,children:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(tm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.kind,` `,e.detail]})]},`${t}-${e.kind}`)),e.blockers.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(pm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function I$({risk:e}){let t=b$[e.risk];return(0,R.jsxs)(_H,{title:`QA risk`,right:x$(e),children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,R.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,R.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function L$({runs:e}){return e.length===0?null:(0,R.jsx)(_H,{title:`Recent runs`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,R.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function R$({detail:e,finished:t}){return(0,R.jsxs)(R.Fragment,{children:[e.steps.length>0?(0,R.jsx)(j$,{steps:e.steps,stopped:t}):null,e.request?(0,R.jsx)(_H,{title:`Request`,children:(0,R.jsx)(mH,{text:e.request})}):null,(0,R.jsx)(N$,{detail:e,finished:t})]})}function z$({detail:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P$,{amendments:e.amendments}),(0,R.jsx)(F$,{detail:e}),e.qaRisk?(0,R.jsx)(I$,{risk:e.qaRisk}):null,(0,R.jsx)(L$,{runs:e.runs})]})}function B$({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return wA(`#/lobby`);let t=P(),r=()=>n.current&&P()===t;try{let t=await Te(`tasks.open`,{taskId:e.id});if(!r())return;let n=await Te(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return wA(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&wA(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,R.jsx)(X,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:jp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function V$({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,R.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,R.jsxs)(`span`,{children:[n>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,R.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function H$({planId:e}){let t=WA(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,R.jsxs)(R.Fragment,{children:[n.issue?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,R.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,R.jsx)(V$,{split:n.split}):null,(0,R.jsx)(_H,{title:`Agreed plan`,children:(0,R.jsx)(mH,{text:n.brief})})]}):t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function U$({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":e.title,children:[(0,R.jsxs)(mj,{children:[(0,R.jsx)(X,{label:`Start here`,icon:Uh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,R.jsx)(X,{label:`Start in a new session`,text:`New session`,icon:dg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,R.jsx)(Kj,{icon:Tg,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,R.jsx)(OK,{check:`open`,className:`mt-1.5`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${w$(e.age)}`:``]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,R.jsx)(H$,{planId:e.id})]})}function W$({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=P();r(!0);try{let r=await Te(`tasks.resume`,{taskId:e.id});if(P()!==n)return;let i=r.key;H(r.notice,i?{action:{label:`Watch`,onClick:()=>wA(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){P()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,R.jsx)(X,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Uh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function G$(e){if(e.kind===`archived`)return{state:`archived`,rest:w$(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${w$(e.age)}`:``;return{state:C$(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function K$(e){return e?[TK(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function q$({row:e}){return e.progress?(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(DK,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function J$({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=G$(e);return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,R.jsx)(OK,{check:e.check,className:`mt-1.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[y$[e.check],`:`]}),(0,R.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,R.jsx)(`span`,{children:i}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,K$(t),n].filter(Boolean).join(` · `)}),(0,R.jsx)(q$,{row:e})]})}function Y$({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function X$({row:e,archive:t}){return e.check===`open`?(0,R.jsx)(Kj,{label:`Archive`,icon:Tp,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,R.jsx)(X,{label:`Archive`,icon:Tp,shortcut:`E`,onClick:()=>void t()})}function Z$({on:e,toggle:t}){return fj(`a`,t),(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent`,children:[(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Auto`}),(0,R.jsx)(jJ,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,R.jsx)(aA,{chord:`A`,className:`kbd-hint`})]})}),(0,R.jsx)(JA,{children:`Auto mode: the oracle decides without asking`})]})}function Q$(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=Y$(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,R.jsxs)(mj,{children:[s?(0,R.jsx)(W$,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,R.jsx)(B$,{row:t,quiet:s}):null,t.kind===`task`?(0,R.jsx)($$,{taskId:t.id}):null,o?(0,R.jsx)(X,{label:`Restore`,icon:Zh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,R.jsx)(Z$,{on:!!t.auto,toggle:a}):null,o?null:(0,R.jsx)(X$,{row:t,archive:r}),(0,R.jsx)(Kj,{icon:Tg,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function $$({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=P();try{let r=await Te(`tasks.open`,{taskId:e});if(!t.current||P()!==n)return;r.notice&&H.info(r.notice);let i=await Te(`status.get`,{});if(!t.current||P()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?wA(`#/sessions/${encodeURIComponent(a)}`):r.notice||H.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&P()===n&&H.error(e instanceof Error?e.message:String(e))}}return(0,R.jsx)(X,{label:`Open task conversation`,text:`Conversation`,icon:ph,shortcut:`O`,onClick:()=>void n()})}function e1(e){let{row:t}=e,n=t.kind===`plan`,r=WA(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=HA(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,R.jsx)(U$,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":t.title,children:[(0,R.jsx)(Q$,{...e}),(0,R.jsx)(J$,{row:t,task:a}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,R.jsx)(QQ,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,R.jsx)(f$,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,R.jsx)(R$,{detail:r.data,finished:!o}):null,(0,R.jsx)(_$,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,R.jsx)(z$,{detail:r.data}):null,r.error&&!r.data?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function t1({row:e}){return e.check===`open`&&e.progress?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(DK,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function n1(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function r1({row:e,card:t}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:e.status.replaceAll(`_`,` `)}):null,e.check===`open`?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:T$(e)}):null,e.kind===`plan`?null:(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,R.jsx)(QQ,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,R.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function i1({row:e,selected:t,onSelect:n,card:r=!1}){return(0,R.jsx)(`li`,{className:r?`overflow-hidden rounded-lg border border-input bg-card shadow-sm`:void 0,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:nU,children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsx)(OK,{check:e.check,className:`mt-0.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[y$[e.check],`:`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,n1(e),t&&`font-medium text-foreground`),children:e.title}),(0,R.jsx)(t1,{row:e})]}),(0,R.jsx)(r1,{row:e,card:r})]})})}function a1({rows:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:E$(e).map(({section:e,rows:r})=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:iU,children:(0,R.jsx)(gH,{title:v$[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:rU,children:r.map(e=>(0,R.jsx)(i1,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var o1=()=>wA(CA(`tasks`,`board`)),s1=e=>wA(CA(`tasks`,`board`,e)),c1=[`Backlog`,`In progress`,`Completed`];function l1(e){if(e.kind!==`archived`&&e.section!==`archived`)return e.check===`done`?`Completed`:e.kind===`plan`||e.status===`created`||e.check===`dropped`?`Backlog`:`In progress`}function u1({title:e,rows:t,id:n}){return(0,R.jsxs)(GK,{role:`region`,"aria-label":e,spacing:`sm`,className:`min-w-0`,children:[(0,R.jsx)(qK,{className:`py-2`,children:(0,R.jsxs)(`h2`,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[e,(0,R.jsx)(tU,{variant:`secondary`,radius:`full`,children:t.length})]})}),(0,R.jsxs)(KK,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,R.jsx)(i1,{row:e,selected:e.id===n,onSelect:s1,card:!0},`${e.kind}-${e.id}`))}),t.length?null:(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tasks here.`})]})]})}function d1({rows:e,id:t}){return(0,R.jsx)(`div`,{className:`grid items-start gap-4 p-4 md:grid-cols-3`,"aria-label":`Task board`,children:c1.map(n=>(0,R.jsx)(u1,{title:n,rows:e.filter(e=>l1(e)===n),id:t},n))})}function f1({id:e}){let t=WA(`tasks.list`,{},[`tasks`,`plans`]),n=t.data?.rows??[],r=n.find(t=>t.id===e&&l1(t)!==void 0),i=r?.kind===`task`?r.id:void 0;if((0,m.useEffect)(()=>(dQ(i),()=>dQ(void 0)),[i]),!t.data&&t.error)return(0,R.jsx)(RA,{message:`Could not load tasks. ${t.error}`,onRetry:t.reload});let a=r?(0,R.jsx)(e1,{row:r,onGone:o1,onChanged:t.reload},r.id):null;return(0,R.jsx)(Dj,{wide:!1,list:t.data?(0,R.jsx)(d1,{rows:n,id:e}):(0,R.jsx)(kj,{}),detail:a,open:!!r,onClose:o1,hint:`Select a task to see its detail.`,describe:`Task detail`})}var p1=()=>wA(CA(`tasks`)),m1=e=>wA(CA(`tasks`,e));function h1(){return(0,R.jsxs)(EA,{className:`m-4 flex-1`,children:[(0,R.jsxs)(DA,{children:[(0,R.jsx)(kA,{variant:`icon`,children:(0,R.jsx)($m,{"aria-hidden":`true`})}),(0,R.jsx)(jA,{children:S$})]}),(0,R.jsx)(Y,{onClick:()=>wA(CA(`plan`)),children:`Plan a task`})]})}function g1({shown:e,count:t,onToggle:n}){return(0,R.jsxs)(`label`,{className:`btn-raised flex h-7 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow]`,children:[(0,R.jsx)(QW,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,R.jsx)(tU,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function _1({id:e,board:t=!1}){return(0,R.jsxs)(ck,{value:t?`board`:`list`,onValueChange:e=>wA(CA(`tasks`,...e===`board`?[`board`]:[])),className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(lk,{"aria-label":`Task views`,className:`flex gap-1 border-b border-border px-4 py-2`,children:[(0,R.jsx)(uk,{value:`list`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`List`}),(0,R.jsx)(uk,{value:`board`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`Board`})]}),(0,R.jsx)(dk,{value:`list`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(v1,{id:e})}),(0,R.jsx)(dk,{value:`board`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(f1,{id:e})})]})}function v1({id:e}){let t=Cj(),[n,r]=(0,m.useState)(!1),i=WA(`tasks.list`,{},[`tasks`,`plans`]),a=WA(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(dQ(u),()=>dQ(void 0)),[u]),!i.data&&i.error)return(0,R.jsx)(RA,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,R.jsx)(h1,{});let d=[...c,...s].find(e=>e.id===l),f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Oj,{title:`Tasks`,count:D$(c),children:(0,R.jsx)(g1,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:S$}):(0,R.jsx)(a1,{rows:c,selectedId:l,onSelect:m1}):(0,R.jsx)(kj,{})]}),p=d?(0,R.jsx)(e1,{row:d,onGone:p1,onChanged:i.reload},d.id):e?(0,R.jsx)(y1,{}):null;return(0,R.jsx)(Dj,{wide:t,list:f,detail:p,open:!!e,onClose:p1,hint:`Select a task to see its detail.`,describe:`Task detail`})}function y1(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var b1={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function x1(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function S1(e){if(e.kind===`settings`)return(0,R.jsx)(SX,{});if(e.kind===`sessions`)return(0,R.jsx)(YQ,{id:x1(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,R.jsx)(UK,{});case`tasks`:return(0,R.jsx)(_1,{...ZW(e.rest)});case`plan`:return(0,R.jsx)(BZ,{rest:e.rest});case`quickfix`:return(0,R.jsx)(oQ,{id:x1(e.rest)});case`issues`:return(0,R.jsx)(zU,{rest:e.rest});case`metrics`:return(0,R.jsx)(Xq,{});case`git`:return(0,R.jsx)(fU,{rest:e.rest});case`knowledge`:return(0,R.jsx)(XW,{rest:e.rest});case`excalidraw`:return(0,R.jsx)(iK,{id:x1(e.rest)})}}function C1(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var w1={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function T1(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:w1[e]}function E1(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=T1(n);if(!e)return;t.code=e}return t.code?t:void 0}function D1(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function O1(e,t){let n=E1(t);return n?D1(e,n):!1}function k1(e,t){for(let n of t)if(O1(e,n.key))return n.action}function A1(e,t){for(let n of t)if(O1(e,n.key))return n.id}function j1(e){return ZA(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||gA()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function M1(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)rj(e.key===`j`?1:-1);else return!1;return!0}function N1(e,t){let n=A1(e,t.tabs),r=k1(e,t.keys);return!n&&!r?!1:C1(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||gA(),typing:ZA(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function P1(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=b1[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(M1(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function F1(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){k1(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&j1(n)){t=0;return}if(N1(n,e)){t=0;return}t=r?P1(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var I1=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],L1=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(b1).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],R1=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`quickfix`,page:`Quick fix`,keys:[[`R`,`run anyway`],[`T`,`make a task`],[`C`,`cancel`]]},{id:`git`,page:`Git`,keys:[[`R`,`refresh`],[`V`,`review`],[`Q`,`Jev's read`],[`X`,`stop`]]},{id:`issues`,page:`Issues`,keys:[[`R`,`refresh`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`excalidraw`,page:`Excalidraw`,keys:[[`R`,`reveal`],[`C`,`copy`],[`O`,`open`],[`W`,`draw`],[`T`,`check`],[`Delete`,`remove`]]},{id:`sessions`,page:`Sessions`,keys:[[`M`,`move here`],[`S`,`stop`],[`B`,`back`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],z1=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],B1=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function V1({line:e}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,R.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,R.jsx)($k,{children:e},e))}):(0,R.jsx)(aA,{chord:e.label??``})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function H1(){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),R1.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(aA,{chord:e}),t]},e))})]},e.id))]})}function U1({title:e,lines:t}){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,R.jsx)(V1,{line:e},e.id))]})}function W1(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function G1(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function K1({open:e,onOpenChange:t,keys:n,tabs:r}){let i=hA(e,mA.help);return(0,m.useEffect)(()=>{if(!e||!i)return;let r=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&O1(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,i,t,n]),(0,R.jsxs)(sA,{open:e&&i,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,R.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(aA,{chord:`Esc`}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,R.jsx)(Ug,{"aria-hidden":`true`})})]})]}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-10 gap-y-6 overflow-y-auto px-6 py-5 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(U1,{title:`Everywhere`,lines:W1(n)}),(0,R.jsx)(U1,{title:`Jump to a tab`,lines:G1(r)}),(0,R.jsx)(U1,{title:`Navigation and editing`,lines:L1}),(0,R.jsx)(U1,{title:`Message box`,lines:I1})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(U1,{title:`Lists and panes`,lines:z1}),(0,R.jsx)(H1,{}),(0,R.jsx)(U1,{title:`Questions`,lines:B1})]})]})]})}function q1(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function J1(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Ce(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Ce(r.error,r.code,n.status);return r.result}function Y1(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function X1(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var Z1=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function Q1(e,t){let n=e.lastIndexOf(`
|
|
102
102
|
`,t-1)+1,r=e.indexOf(`
|
|
103
103
|
`,t),i=e.slice(n,r<0?e.length:r),a=Z1.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function $1({rest:e}){let{chat:t}=gW(e);return(0,R.jsx)(`div`,{role:`group`,"aria-label":`Knowledge pane`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5`,children:[`Chat`,`Docs`].map(n=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>wA(_W(e,n===`Chat`)),className:q(`h-6 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,t===(n===`Chat`)?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:n},n))})}var e0={id:`oracle`,pill:`Oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`};function t0(e,t,n){if(e.kind===`sessions`){let e={id:`newsession`,pill:`New session`,label:`Start a task in a new session`,placeholder:`Describe a task for a new session…`};return n?[{id:`session`,pill:`Message`,label:`Message ${n.name}`,placeholder:`Message ${n.name}…`,session:n},e,e0]:[e,e0]}if(e.kind!==`tab`)return[e0];if(e.tab===`knowledge`)return[{id:`knowledge`,pill:`Oracle`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`}];if(e.tab===`plan`)return[{id:`panel`,pill:`Panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`},e0];if(e.tab===`quickfix`)return[{id:`quickfix`,pill:`Quick fix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`},e0];let r=e.tab===`tasks`?ZW(e.rest).id??t:void 0;return r?[{id:`comment`,pill:`Comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r},{id:`task`,pill:`Task's oracle`,label:`Message ${r}'s oracle`,placeholder:`Leave a message for ${r}'s oracle…`,taskId:r},e0]:[e0]}var n0=0,r0=`toolbar-button relative inline-flex size-8 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function i0(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function a0({file:e,onRemove:t}){let n=(0,R.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:q(`btn-ghost flex shrink-0 items-center justify-center rounded-lg border text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,e.image?`absolute top-1 right-1 size-5 bg-background/80 text-foreground backdrop-blur-sm`:`size-7`),children:(0,R.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},title:`${e.name} · ${q1(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,R.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-background/60`,children:(0,R.jsx)(MA,{className:`size-4`,"aria-hidden":`true`,role:`presentation`})}):null,n]}):(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},className:`flex h-9 min-w-0 items-center gap-2 rounded-lg border border-border bg-muted pr-1 pl-2.5`,children:[(0,R.jsxs)(`span`,{className:`relative flex shrink-0 items-center justify-center text-muted-foreground`,children:[(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4`}),e.state===`uploading`?(0,R.jsx)(MA,{className:`absolute -right-1 -bottom-1 size-2.5`,"aria-hidden":`true`,role:`presentation`}):null]}),(0,R.jsxs)(`span`,{className:`min-w-0 max-w-40`,children:[(0,R.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`block text-[0.65rem] leading-tight text-muted-foreground`,children:e.state===`uploading`?`uploading…`:q1(e.size)})]}),n]})}function o0({route:e,keys:t,onHelp:n}){let[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(),g=HA(`status`),_=HA(`lobby`),v=_A(),y=(g.data?.busy??!1)||!!_.data?.reply?.trim(),{taskId:b,session:x}=mQ(),S=(0,m.useMemo)(()=>t0(e,b,x),[e,b,x]),C=S.map(e=>`${e.id}:${e.taskId??e.session?.name??``}`).join(`|`),w=S.find(e=>e.id===p)??S[0];(0,m.useEffect)(()=>h(void 0),[C]);let T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=(0,m.useRef)(null),O=(0,m.useRef)(a);O.current=a;let k=(0,m.useRef)(void 0);(0,m.useLayoutEffect)(()=>{let e=k.current,t=E.current;e&&t&&(k.current=void 0,t.setSelectionRange(e.start,e.end))},[r]);let A=(0,m.useCallback)(e=>{k.current={start:e.start,end:e.end},i(e.value)},[]);(0,m.useEffect)(()=>{let e=T.current;if(!e)return;let t=document.documentElement,n=()=>t.style.setProperty(`--composer-h`,v?`0px`:`${Math.ceil(e.getBoundingClientRect().height)}px`);n();let r=new ResizeObserver(n);return r.observe(e),()=>{r.disconnect(),t.style.setProperty(`--composer-h`,`0px`)}},[v]);let ee=(0,m.useCallback)(e=>{let t=[...e],n=8-O.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++n0}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;o(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),J1(e).then(e=>o(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),o(e=>e.filter(e=>e.key!==t))})}},[]),j=(0,m.useCallback)(e=>{o(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),M=a.some(e=>e.state===`uploading`),te=a.flatMap(e=>e.info?[e.info.id]:[]),ne=(r.trim().length>0||te.length>0)&&!M&&!l,N=(0,m.useCallback)(async()=>{if(!ne)return;u(!0);let t=te.length>0?te:void 0,n={text:r,...t?{attachments:t}:{}};try{let a=!0;if(w.id===`oracle`){let e=await Te(`lobby.send`,n);e.notice&&H(e.notice)}else if(w.id===`knowledge`)a=await U(`knowledge.ask`,n)!==void 0,a&&e.kind===`tab`&&wA(_W(e.rest,!0));else if(w.id===`panel`)a=await U(`planner.send`,n)!==void 0;else if(w.id===`quickfix`)a=await U(`quickfix.submit`,n)!==void 0;else if(w.id===`task`)a=await U(`tasks.message`,{taskId:w.taskId,...n})!==void 0;else if(w.id===`session`)a=await U(`sessions.message`,{...w.session.address,...n})!==void 0;else if(w.id===`newsession`){let e=await U(`sessions.start`,{request:r,...t?{attachments:t}:{}});a=e!==void 0,e?.key&&wA(`#/sessions/${encodeURIComponent(e.key)}`)}else a=await U(`tasks.comment`,{taskId:w.taskId,...n})!==void 0;if(a){i(``);for(let e of O.current)e.image&&URL.revokeObjectURL(e.image);o([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{u(!1)}},[ne,te,w,r,e]),re=(0,m.useCallback)(async()=>{try{await Te(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]);return(0,R.jsx)(`div`,{ref:T,className:q(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(1.25rem,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap max-sm:px-2 max-sm:pb-[max(0.5rem,env(safe-area-inset-bottom))]`,v&&`opacity-0`),inert:v,children:(0,R.jsx)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl`,children:(0,R.jsxs)(`div`,{className:q(`group/composer relative rounded-2xl border border-dock-border bg-dock shadow-dock transition-[border-color,box-shadow] duration-300 ease-snap focus-within:border-ring focus-within:shadow-dock-focus`,d&&`border-primary shadow-[0_0_0_3px_color-mix(in_oklab,var(--ring)_30%,transparent)]`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),f(!0))},onDragLeave:()=>f(!1),onDrop:e=>{e.preventDefault(),f(!1),e.dataTransfer.files.length>0&&ee(e.dataTransfer.files)},children:[(0,R.jsx)(Du,{initial:!1,children:a.length>0?(0,R.jsx)(B.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:420,damping:36},"aria-label":`Attachments`,className:`flex flex-wrap items-end gap-2 overflow-hidden px-3 pt-3`,children:a.map(e=>(0,R.jsx)(a0,{file:e,onRemove:()=>j(e.key)},e.key))},`files`):null}),s?(0,R.jsx)(`div`,{"aria-label":`Markdown preview`,role:`region`,className:`max-h-48 overflow-y-auto border-b border-border px-4 py-3`,children:r.trim()?(0,R.jsx)(mH,{text:r}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing to preview yet.`})}):null,(0,R.jsx)(`div`,{className:`flex px-4 pt-3 pb-1`,children:(0,R.jsx)(`textarea`,{ref:E,id:`composer-text`,"aria-label":w.label,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),oj();return}let t=e.currentTarget,n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(n)){e.preventDefault();let{selectionStart:r,selectionEnd:i,value:a}=t;A(n===`k`?X1(a,r,i):Y1(a,r,i,n===`b`?`**`:n===`i`?`_`:"`"));return}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&n===`p`){e.preventDefault(),c(e=>!e);return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=Q1(t.value,t.selectionStart);n&&(e.preventDefault(),A(n));return}if(e.key===`Backspace`&&t.value===``&&O.current.length>0){e.preventDefault(),j(O.current.at(-1).key);return}(i0(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),N())},onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),ee(t))},placeholder:y&&w.id===`oracle`?`The oracle is working. Enter steers it…`:w.placeholder,rows:1,className:`field-sizing-content max-h-[min(45vh,20rem)] min-h-[1.75rem] w-full min-w-0 flex-1 resize-none bg-transparent text-base leading-relaxed caret-primary outline-none placeholder:text-muted-foreground md:text-[0.9375rem] md:leading-relaxed`})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 px-2 pt-1 pb-2`,children:[(0,R.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{ee(e.target.files??[]),e.target.value=``}}),(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onClick:()=>D.current?.click(),className:r0,children:(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(JA,{children:`Attach images, PDFs or files`})]}),(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Preview the Markdown`,"aria-pressed":s,"aria-keyshortcuts":`Alt+P`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>c(e=>!e),className:r0,children:(0,R.jsx)(km,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(JA,{children:[`Preview `,(0,R.jsx)(aA,{chord:`Alt+P`})]})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-4 w-px bg-border`}),e.kind===`tab`&&e.tab===`knowledge`?(0,R.jsx)($1,{rest:e.rest}):S.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Send to`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5 shadow-[inset_0_1px_2px_rgb(0_0_0/0.07)]`,children:S.map(e=>(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"data-compact":!0,"aria-checked":e.id===w.id,onClick:()=>h(e.id),className:q(`h-6 rounded-md border border-transparent px-2.5 text-xs font-medium transition-[background-color,color,box-shadow] duration-150 outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,e.id===w.id?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:e.pill},e.id))}):(0,R.jsxs)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:[`To the `,w.pill.toLowerCase()]}),(0,R.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end overflow-hidden px-2`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3.5`,children:[e.kind===`tab`&&e.tab===`plan`?(0,R.jsx)(oA,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[34rem]:inline-flex`,children:`save plan`}):null,(0,R.jsx)(oA,{chord:`/`,className:`hidden group-focus-within/composer:!hidden @[28rem]:inline-flex`,children:`write`}),(0,R.jsx)(oA,{chord:`Esc`,className:`hidden group-[:not(:focus-within)]/composer:!hidden @[28rem]:inline-flex`,children:`tabs`}),(0,R.jsx)(oA,{chord:`Shift+Enter`,className:`hidden @[22rem]:inline-flex`,children:`new line`}),(0,R.jsx)(oA,{chord:`Enter`,className:`hidden @[11rem]:inline-flex`,children:`send`}),(0,R.jsxs)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"data-compact":!0,onClick:n,className:`kbd-hint btn-ghost inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(aA,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,R.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})}),y&&w.id===`oracle`?(0,R.jsx)(Kj,{label:`Stop`,icon:hg,iconOnly:!0,compact:!0,title:`Stop the oracle?`,description:`The current response stops. Work already recorded is kept.`,confirmLabel:`Stop`,variant:`destructive`,onConfirm:()=>void re()}):null,(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Send`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>void N(),disabled:!ne,className:`btn-tint relative inline-flex size-8 items-center justify-center rounded-lg border [--tint:var(--primary)] before:absolute before:-inset-1 before:content-[''] text-primary-foreground transition-[background-color,color,box-shadow,translate,filter] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none disabled:text-muted-foreground`,children:l?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5 text-primary-foreground`}):(0,R.jsx)(Np,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.25})})}),(0,R.jsxs)(JA,{children:[`Send `,(0,R.jsx)(aA,{chord:`Enter`})]})]})]}),d?(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center rounded-xl bg-card/90 text-sm font-medium text-primary backdrop-blur-[2px]`,children:`Drop to attach`}):null]})})})}function s0(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await Te(`projects.open`,{path:r});be([t]),he(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function c0({path:e,busy:t,browse:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,R.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),n(r)},children:[(0,R.jsx)(Aq,{"aria-label":`Folder path`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,R.jsx)(Y,{type:`submit`,disabled:t||!r.trim(),children:`Go`})]})}function l0({data:e,busy:t,browse:n}){return(0,R.jsxs)(`div`,{className:`min-h-24 max-h-64 overflow-y-auto rounded-lg border border-border`,"aria-label":`Folders`,role:`group`,children:[e?.parent?(0,R.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start`,disabled:t,onClick:()=>n(e.parent),children:[(0,R.jsx)(Np,{}),` Parent folder`]}):null,e?.folders.map(e=>(0,R.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start`,disabled:t,onClick:()=>n(e.path),children:[(0,R.jsx)(zm,{className:`shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),e&&!e.folders.length?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No subfolders. You can open this folder.`}):null,e?.truncated?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`Listing limited to 2,000 entries. Enter a path to browse further.`}):null]})}function u0({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=WA(`projects.browse`,r===void 0?{}:{path:r},[]),o=s0(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-5`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Open project folder`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Browse folders on the machine running bot-lobby. Opening starts a separate session; your current project keeps running. Project-local extensions are not enabled automatically.`}),(0,R.jsx)(c0,{path:a.data?.path??r??``,busy:o.opening,browse:i}),(0,R.jsx)(l0,{data:a.data,busy:a.loading||o.opening,browse:i}),a.loading?(0,R.jsx)(`p`,{role:`status`,children:`Loading folders…`}):null,a.error||o.error?(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a.error??o.error}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[a.error?(0,R.jsx)(Y,{variant:`outline`,onClick:a.reload,disabled:a.loading,children:`Retry`}):null,(0,R.jsx)(Y,{variant:`outline`,onClick:t,disabled:o.opening,children:`Cancel`}),(0,R.jsx)(Y,{disabled:!a.data||a.loading||!!a.error||o.opening,onClick:()=>void o.open(a.data.path),children:o.opening?`Opening project…`:`Open this folder`})]})]})}function d0({open:e,onClose:t,tab:n}){let r=hA(e,mA.help),[i,a]=(0,m.useState)(!1);return(0,R.jsx)(sA,{open:r,label:`Open project folder`,onOpenChange:e=>{!e&&!i&&t()},dismissOnBackdrop:!i,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[role="combobox"][aria-label="Project"]`)?.focus()},children:e?(0,R.jsx)(u0,{tab:n,close:t,busyChanged:a}):null})}function f0(){try{return{id:P()}}catch(e){return{error:e.message}}}function p0(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function m0(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await Te(`projects.list`,{});be(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function h0({data:e,error:t}){let n=f0();return n.error??t??p0(e,n.id)}function g0({projects:e}){let t=h0(e);return t?(0,R.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,R.jsx)(Dg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,R.jsx)(`span`,{children:t})]}):null}function _0(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option']`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}function v0({projects:e,tab:t,name:n,branch:r}){let{data:i,busy:a,slow:o,refresh:s}=e,[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=f0(),p=h0(e),h=f.error?`invalid`:f.id??i?.currentId??``;fj(`p`,()=>l(!0)),fj(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&he(e,t)}return(0,R.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsxs)(HJ,{open:c,onOpenChange:l,children:[(0,R.jsxs)(UJ,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c,"aria-keyshortcuts":`P ArrowDown`,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),l(!0))},className:`btn-ghost group flex h-8 min-w-0 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40 disabled:pointer-events-none`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2.5 shrink-0 rounded-full`,p?`bg-destructive`:`bg-primary`)}),(0,R.jsx)(`span`,{className:`truncate`,children:n}),(0,R.jsx)(Zp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(WJ,{align:`start`,sideOffset:6,"aria-label":`Projects`,onKeyDown:_0,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`p-0 flex w-[min(26rem,calc(100vw-1.5rem))] origin-(--radix-popover-content-transform-origin) flex-col overflow-hidden rounded-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 disabled:opacity-60`,children:[a?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,R.jsx)(aA,{chord:`R`,className:`kbd-hint`})]})]}),(0,R.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`flex max-h-72 flex-col overflow-y-auto p-1`,children:i?.projects.map(e=>{let t=e.id===h;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:q(`flex min-h-10 w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-3 focus-visible:ring-ring/30`,t&&`bg-accent`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 border-t border-border px-3 py-3 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/40`,onClick:()=>{l(!1),d(!0)},children:[(0,R.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,R.jsx)(d0,{open:u,onClose:()=>d(!1),tab:t}),r?(0,R.jsxs)(`span`,{className:`hidden min-w-0 items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground sm:inline-flex`,children:[(0,R.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:r})]}):null,o||p?(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground outline-none transition-[box-shadow,color,translate] hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px disabled:opacity-60`,children:a?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-4`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(JA,{side:`bottom`,children:`Refresh projects`})]}):null]})}function y0({state:e}){return e===`live`?(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,R.jsx)(JA,{children:`Connected`})]}):e===`connecting`?(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),`reconnecting…`]}):(0,R.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}var b0=`toolbar-button inline-flex size-8 shrink-0 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function x0({label:e,hint:t,href:n,active:r,children:i}){return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`a`,{href:n,"aria-label":e,"aria-current":r?`page`:void 0,"aria-keyshortcuts":t,"aria-describedby":`focused-action-help`,className:b0,children:i})}),(0,R.jsxs)(JA,{side:`bottom`,children:[e,` `,(0,R.jsx)(aA,{chord:t})]})]})}function S0({hint:e,onHelp:t}){return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:b0,children:(0,R.jsx)(Ym,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(JA,{side:`bottom`,children:[`Keyboard shortcuts `,(0,R.jsx)(aA,{chord:e})]})]})}function C0(){let e=cJ(),t=e?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,"aria-describedby":`focused-action-help`,className:b0,onClick:()=>oJ(!e),children:e?(0,R.jsx)(Lg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Fg,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsx)(JA,{side:`bottom`,children:t})]})}function w0(){let{theme:e,setTheme:t}=iY(),n=e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>t(n?`light`:`dark`),className:b0,children:n?(0,R.jsx)(_g,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Th,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(JA,{side:`bottom`,children:[n?`Light mode`:`Dark mode`,` `,(0,R.jsx)(aA,{chord:`D`})]})]})}function T0({busy:e,task:t,sessionName:n}){return(0,R.jsxs)(`div`,{className:`mr-1 flex min-w-0 items-center gap-2 text-[0.8125rem]`,children:[e?(0,R.jsx)(MA,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):null,t?(0,R.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate md:inline`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,R.jsxs)(`span`,{className:`hidden text-muted-foreground min-[1500px]:inline`,children:[` · `,t.state.replace(/_/g,` `)]})]}):(0,R.jsx)(`span`,{className:`hidden max-w-[10rem] truncate text-muted-foreground min-[1500px]:inline`,children:n??`no task in this session`})]})}function E0(e){if(!e)return 0;let t=[...e.children].filter(e=>e instanceof HTMLElement&&e.offsetParent!==null&&getComputedStyle(e).position!==`absolute`);if(!t.length)return 0;let n=Math.min(...t.map(e=>e.getBoundingClientRect().left)),r=Math.max(...t.map(e=>e.getBoundingClientRect().right)),i=0;for(let t of e.querySelectorAll(`*`))t.clientWidth<=1||t.offsetParent===null||t.scrollWidth<=t.clientWidth+1||getComputedStyle(t).textOverflow===`ellipsis`&&(i+=t.scrollWidth-t.clientWidth);return r-n+i}var D0=24;function O0(){let e=(0,m.useRef)(null),[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(()=>{});return r.current=()=>{let t=e.current;if(!t)return;let r=t.querySelector(`[role="tablist"]`),i=getComputedStyle(t),a=parseFloat(i.columnGap)||0,o=t.clientWidth-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0),s=E0(t.querySelector(`.where`))+(r?.offsetWidth??0)+E0(t.querySelector(`.tools`))+a*2;n(s+D0<=o)},(0,m.useLayoutEffect)(()=>r.current()),(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r.current());n.observe(t);for(let e of t.querySelectorAll(`[role="tablist"], .where, .tools`))n.observe(e);return()=>n.disconnect()},[]),{header:e,one:t}}function k0({status:e,task:t,connection:n,route:r,tabs:i,extra:a,keys:o,onHelp:s}){let c=e?.workspace.name??`bot-lobby`,l=e?.branch??e?.workspace.branch,u=e?.busy??!1,d=m0(),{header:f,one:p}=O0();return(0,R.jsxs)(`header`,{ref:f,className:`app-header shrink-0`,"data-one-row":p||void 0,children:[(0,R.jsx)(`div`,{className:`where flex min-w-0 items-center`,children:(0,R.jsx)(v0,{projects:d,tab:r.kind===`tab`?r.tab:r.kind,name:c,branch:l})}),(0,R.jsx)(`div`,{className:`tabs min-w-0`,children:i}),(0,R.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[a,(0,R.jsx)(T0,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,R.jsx)(y0,{state:n}),(0,R.jsx)(x0,{label:`Sessions`,hint:o.sessions??`Alt+O`,href:`#/sessions`,active:r.kind===`sessions`,children:(0,R.jsx)(Zm,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,R.jsx)(x0,{label:`Settings`,hint:o.settings??`Alt+S`,href:`#/settings`,active:r.kind===`settings`,children:(0,R.jsx)(sg,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,R.jsx)(S0,{hint:o.help??`Alt+H`,onHelp:s}),(0,R.jsx)(w0,{}),(0,R.jsx)(C0,{}),(0,R.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,R.jsx)(g0,{projects:d})]})}function A0(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function j0(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await De()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(A0(e))}return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,R.jsxs)(`form`,{onSubmit:s,className:`glass flex w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(qm,{className:`size-5`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,R.jsx)(`code`,{className:`rounded-lg bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`/bot-lobby web`}),`to see it again). Paste it here.`]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,R.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:`http://127.0.0.1:7347/#token=…`,className:`h-8 rounded-lg border border-input bg-background px-3.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`})]}),n?(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,R.jsx)(Y,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var M0=.6;function N0(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:M0,...n}}}var P0=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function F0(e,t=0,n=1){return N0(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:M0,times:P0(t,n),ease:`easeInOut`},strokeOpacity:{duration:M0,times:P0(t,t+.02)}})}function I0(e,t){return N0(e,{scale:[0,0,1.3,1]},{times:P0(t,t+.18),ease:`easeOut`})}function L0(e,t,n=1.3){return N0(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var R0=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function z0({play:e}){return(0,R.jsxs)(B.g,{style:R0(.1,.9),...N0(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,R.jsx)(B.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...N0(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function B0({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.path,{d:`M13 5h8`,...F0(e,.15,.45)}),(0,R.jsx)(B.path,{d:`M13 12h8`,...F0(e,.3,.6)}),(0,R.jsx)(B.path,{d:`M13 19h8`,...F0(e,.45,.75)}),(0,R.jsx)(B.path,{d:`m3 17 2 2 4-4`,...F0(e,.35,.7)}),(0,R.jsx)(B.path,{d:`m3 7 2 2 4-4`,...F0(e,0,.35)})]})}function V0({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:19,r:3,style:R0(),...L0(e,0)}),(0,R.jsx)(B.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...F0(e,.1,.7)}),(0,R.jsx)(B.circle,{cx:18,cy:5,r:3,style:R0(),...I0(e,.62)})]})}function H0({play:e}){return(0,R.jsx)(B.g,{style:R0(),...N0(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,R.jsx)(B.path,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,fill:`currentColor`,...N0(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function U0({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:R0(),...N0(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:R0(),...N0(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:R0(),...N0(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function W0({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}),[`M8 17v-3`,`M13 17V5`,`M18 17V9`].map((t,n)=>(0,R.jsx)(B.path,{d:t,style:R0(.5,1),...N0(e,{scaleY:[0,0,1.18,1]},{times:P0(.08+n*.14,.4+n*.14),ease:`easeOut`})},t))]})}function G0({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:6,r:3,style:R0(),...L0(e,0)}),(0,R.jsx)(B.line,{x1:6,x2:6,y1:9,y2:21,...F0(e,.05,.45)}),(0,R.jsx)(B.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...F0(e,.2,.62)}),(0,R.jsx)(B.circle,{cx:18,cy:18,r:3,style:R0(),...I0(e,.58)})]})}function K0({play:e}){return(0,R.jsxs)(B.g,{style:R0(),...N0(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,R.jsx)(B.path,{d:`M12 5v16`,style:R0(),...N0(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,R.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]})}function q0({play:e}){return(0,R.jsxs)(B.g,{style:R0(.6,.6),...N0(e,{x:[0,1.5,-1.5,1,0],y:[0,-1,.5,-.5,0],rotate:[0,-8,6,-3,0]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`}),(0,R.jsx)(`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`}),(0,R.jsx)(B.path,{d:`m2.3 2.3 7.286 7.286`,...F0(e,.1,.6)}),(0,R.jsx)(B.circle,{cx:11,cy:11,r:2,style:R0(),...L0(e,.5,1.5)})]})}var J0={lobby:z0,tasks:B0,plan:V0,quickfix:H0,issues:U0,metrics:W0,git:G0,knowledge:K0,excalidraw:q0};function Y0({id:e,play:t,className:n}){let r=J0[e];return r?(0,R.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:q(`overflow-visible`,n),children:(0,R.jsx)(r,{play:t})},t):null}function X0(e){return/(\d)$/.exec(e)?.[1]}var Z0=160;function Q0(e){let t=xf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+M0*1e3,r(e=>e+1))},[t]),o=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let t=e&&!o.current;if(o.current=e,!t)return;let n=window.setTimeout(a,Z0);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var $0=(0,m.forwardRef)(function({tab:e,active:t},n){let r=X0(e.key),{play:i,onPointerEnter:a}=Q0(t);return(0,R.jsxs)(KA,{children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsxs)(`a`,{ref:n,role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":t,"aria-keyshortcuts":e.key,tabIndex:t?0:-1,onPointerEnter:a,className:q(`relative z-10 inline-flex h-7.5 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tab-outline)] px-2.5 text-[0.8125rem] leading-none font-medium whitespace-nowrap outline-none`,`transition-colors duration-200 ease-snap focus-visible:ring-3 focus-visible:ring-ring/40`,t?`text-foreground`:`bg-[var(--tab-idle)] text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(Y0,{id:e.id,play:i,className:q(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,R.jsx)(`span`,{children:e.label})]})}),(0,R.jsxs)(JA,{children:[e.label,` `,(0,R.jsx)(aA,{chord:e.key})]})]})}),e2=1.5;function t2(e,t,n=t?.left??0,r=t?.right??0,i=1){if(e){if(!t||r-n<.5){e.style.opacity=`0`;return}e.style.opacity=String(Math.min(1,(r-n)/14)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${r-n}px`,e.style.transform=`translateX(${n}px)`,e.style.scale=i===1?``:`1 ${i}`}}function n2(e,t){let n=e.right-e.left,{height:r}=e,i=e2/2,a=Math.max(0,Math.min(e.radius-i,r/2-i,n/2-i)),o=r/2,s=e=>+(t===`left`?e:n-e).toFixed(2),c=+(t===`left`),l=1-c,u=i,d=n-i,f=r-i;return[`M${s(u)} ${o}L${s(u)} ${i+a}A${a} ${a} 0 0 ${c} ${s(u+a)} ${i}L${s(d-a)} ${i}A${a} ${a} 0 0 ${c} ${s(d)} ${i+a}L${s(d)} ${o}`,`M${s(u)} ${o}L${s(u)} ${f-a}A${a} ${a} 0 0 ${l} ${s(u+a)} ${f}L${s(d-a)} ${f}A${a} ${a} 0 0 ${l} ${s(d)} ${f-a}L${s(d)} ${o}`]}function r2(e,t,n,r){if(!e)return;if(!t||r<=.002){e.style.opacity=`0`;return}let i=t.right-t.left,a=`${i}x${t.height}r${t.radius}${n}`;e.dataset.shape!==a&&(e.dataset.shape=a,e.dataset.port=n,e.setAttribute(`viewBox`,`0 0 ${i} ${t.height}`),n2(t,n).forEach((t,n)=>e.children[n]?.setAttribute(`d`,t))),e.style.opacity=String(Math.min(1,r*12)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${i}px`,e.style.transform=`translateX(${t.left}px)`;let o=`${Math.min(1,r)} 2`;for(let t of e.children)t.style.strokeDasharray=o}var i2={type:`spring`,visualDuration:.12,bounce:0},a2={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},o2={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},s2={type:`spring`,visualDuration:.22,bounce:.25},c2={type:`spring`,visualDuration:.2,bounce:0},l2={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},u2=(()=>{let e=Sr({keyframes:[0,1],visualDuration:s2.visualDuration,bounce:s2.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),d2={type:`spring`,visualDuration:.28,bounce:.6};function f2(e,t){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)({}),c=(0,m.useRef)([]),l=(0,m.useRef)(void 0),u=(0,m.useRef)([]),d=(0,m.useRef)(1),f=(0,m.useRef)(1),p=(0,m.useCallback)(e=>{let t=e?s.current[e]:void 0;if(!t)return;let n=parseFloat(getComputedStyle(t).borderTopLeftRadius)||0;return{left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,height:t.offsetHeight,radius:n}},[]),h=(0,m.useCallback)(()=>{for(let e of u.current)e.stop();u.current=[];for(let e of Object.values(s.current))e?.style.translate&&(e.style.translate=``)},[]),g=(0,m.useCallback)(e=>{h(),l.current=e,d.current=1,f.current=1;let t=p(e);t2(r.current,t),t2(i.current,void 0),r2(a.current,t,`left`,1),r2(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);nH()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),tH(),l.current=t;let _=m.left>n.left?1:-1,v=_>0?n.right:n.left,y=_>0?m.left:m.right,b=Math.abs(y-v),x=_>0?`right`:`left`,S=_>0?`left`:`right`,C=c.current.map(e=>{let t=e?.parentElement;return t?{liquid:e,from:t.offsetLeft,to:t.offsetLeft+t.offsetWidth}:void 0}),w=b>4?1-4/b:0,T={drained:1-Math.min(1,d.current),unrung:1-Math.min(1,f.current),head:0,tail:0,filled:0,rung:0,squash:1,budge:0},E=s.current[t];d.current=0,f.current=0;let D=()=>{let e=(n.right-n.left)*Math.min(1,T.drained);t2(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),r2(o.current,n,x,1-T.unrung);let t=v+_*b*T.head,s=v+_*b*T.tail,c=Math.min(t,s),l=Math.max(t,s);for(let e of C){if(!e?.liquid)continue;let t=Math.max(c,e.from),n=Math.min(l,e.to);e.liquid.style.width=`${Math.max(0,n-t)}px`,e.liquid.style.transform=`translateX(${Math.max(0,t-e.from)}px)`}let u=_*T.budge,d=u?{...m,left:m.left+u,right:m.right+u}:m;E&&(E.style.translate=Math.abs(u)>.01?`${u.toFixed(2)}px`:``);let f=(d.right-d.left)*Math.min(1,Math.max(0,T.filled));t2(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),r2(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Wf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,A=()=>{if(k)return;k=!0;let e=O(`filled`,0,s2,e=>{d.current=e});e.then(()=>{l.current===t&&nH()}),O(`squash`,.8,d2),O(`rung`,0,c2,e=>{f.current=e}),O(`budge`,0,{...l2,delay:u2},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,i2),O(`unrung`,T.unrung,i2),O(`head`,0,a2,e=>{e>=w&&A()}),O(`tail`,0,o2),D()},[p,g,h]);(0,m.useLayoutEffect)(()=>{let t=l.current,n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;!t||!e||t===e||n?g(e):_(t,e)},[e,t,_,g]);let v=(0,m.useRef)(e);return v.current=e,(0,m.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=!0,r=new ResizeObserver(()=>{if(t){t=!1;return}g(v.current)});return r.observe(e),()=>{r.disconnect(),h()}},[g,h]),{track:n,fill:r,drain:i,ring:a,unring:o,cells:s,liquids:c}}var p2=(0,m.forwardRef)(function({which:e},t){return(0,R.jsxs)(`svg`,{ref:t,"aria-hidden":`true`,[`data-tab-${e}`]:``,className:`pointer-events-none absolute left-0 z-20 overflow-visible opacity-0 will-change-transform`,fill:`none`,children:[(0,R.jsx)(`path`,{pathLength:1,strokeWidth:e2,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,R.jsx)(`path`,{pathLength:1,strokeWidth:e2,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function m2(e){if(e.left||e.right)return`linear-gradient(to right, ${e.left?`transparent 0, black 28px`:`black 0`}, ${e.right?`black calc(100% - 28px), transparent 100%`:`black 100%`})`}function h2({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=f2(t,e.length),u=(0,m.useRef)(null),[d,f]=(0,m.useState)({left:!1,right:!1}),p=(0,m.useCallback)(()=>{let e=u.current;if(!e)return;let t=e.scrollLeft>2,n=e.scrollLeft+e.clientWidth<e.scrollWidth-2;f(e=>e.left===t&&e.right===n?e:{left:t,right:n})},[]);(0,m.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;p();let t=new ResizeObserver(p);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[p,e.length]),(0,m.useEffect)(()=>{let e=u.current,n=t?c.current[t]:void 0;e&&n&&(n.offsetLeft<e.scrollLeft?e.scrollLeft=n.offsetLeft-8:n.offsetLeft+n.offsetWidth>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n.offsetLeft+n.offsetWidth-e.clientWidth+8))},[t,c]);function h(r){if(r.key===`ArrowDown`&&!r.altKey){aj()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;r.preventDefault();let a=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];sj.active=!0,sj.to=o.id,window.setTimeout(()=>{sj.active=!1,sj.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,R.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:m2(d),WebkitMaskImage:m2(d)},className:`min-w-0 max-w-full overflow-x-auto [scrollbar-width:none] pointer-coarse:-my-1.5 pointer-coarse:py-1.5 [&::-webkit-scrollbar]:hidden`,children:(0,R.jsxs)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:h,className:`relative mx-auto flex w-max items-center py-0.5`,children:[(0,R.jsx)(`span`,{ref:a,"aria-hidden":`true`,"data-tab-drain":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(`span`,{ref:i,"aria-hidden":`true`,"data-tab-fill":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(p2,{ref:s,which:`unring`}),(0,R.jsx)(p2,{ref:o,which:`ring`}),e.map((e,n)=>(0,R.jsxs)(m.Fragment,{children:[n>0?(0,R.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,R.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,R.jsx)(`span`,{ref:e=>{l.current[n-1]=e},"data-tab-liquid":!0,className:`absolute top-0 left-0 h-[2px] w-0 rounded-full bg-tab-liquid shadow-[0_0_6px_var(--tab-liquid)] will-change-transform`})]}):null,(0,R.jsx)($0,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function g2({oracleBusy:e,runs:t,activity:n,background:r}){let i=new Set;e&&i.add(`Oracle`);for(let e of t)e.status===`running`&&i.add(KU(XU(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:KU(e.source));let a=r.filter(e=>e.alive&&e.busy).length;return a&&i.add(a===1?`1 in the background`:`${a} in the background`),[...i]}function _2(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var v2=6,y2=`bot-lobby.orb`,b2=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function x2(e,t,n,r){let i=e=>e+v2,a=(e,t)=>Math.max(e+v2,e+t-r-v2);return{x:Math.min(a(n.left,n.width),Math.max(i(n.left),e)),y:Math.min(a(n.top,n.height),Math.max(i(n.top),t))}}function S2(e,t,n,r){let i=e=>Math.max(1,e-r),a=x2(e,t,n,r);return{fx:Math.min(1,Math.max(0,(a.x-n.left)/i(n.width))),fy:Math.min(1,Math.max(0,(a.y-n.top)/i(n.height)))}}function C2(e,t,n){return x2(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function w2(e){if(e)try{let t=JSON.parse(e);return b2(t.fx)&&b2(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function T2(){try{return w2(localStorage.getItem(y2))}catch{return}}function E2(e){try{localStorage.setItem(y2,JSON.stringify(e))}catch{}}var D2=5,O2=16;function k2(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?{left:e.left,top:e.top,width:e.width,height:e.height}:void 0}function A2(){let[e,t]=(0,m.useState)(k2);return(0,m.useEffect)(()=>{let e=()=>t(k2()),n=document.getElementById(`main`),r=typeof ResizeObserver>`u`||!n?void 0:new ResizeObserver(e);return n&&r?.observe(n),window.addEventListener(`resize`,e),e(),()=>{r?.disconnect(),window.removeEventListener(`resize`,e)}},[]),e}var j2=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=A2(),[u,d]=(0,m.useState)(T2),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(void 0),v=(0,m.useRef)(!1),y=(0,m.useRef)(44),b=f??(u&&l?C2(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=k2();if(!n)return;let r=S2(e,t,n,y.current);d(r),E2(r)},[]);function S(e){if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();y.current=t.width,_.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,ox:t.left,oy:t.top,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId)}function C(e){let t=_.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.sx,r=e.clientY-t.sy;if(!t.moved&&Math.hypot(n,r)<D2)return;t.moved=!0;let i=k2();i&&p(x2(t.ox+n,t.oy+r,i,y.current))}function w(e){let t=_.current;_.current=void 0,t?.moved&&(v.current=!0,x(t.ox+e.clientX-t.sx,t.oy+e.clientY-t.sy),p(void 0))}function T(e){let t=e.shiftKey?64:O2,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];if(!n||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let r=e.currentTarget.getBoundingClientRect();y.current=r.width,x(r.left+n[0],r.top+n[1])}let E=!e&&n.length>0,D=e?KU(e):E?_2(n):void 0,O=e?`${t.map(KU).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,k=b&&l?b.x-l.left<140:!1,A={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,R.jsxs)(KA,{open:h&&!f,onOpenChange:g,children:[(0,R.jsx)(qA,{asChild:!0,children:(0,R.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${O}Drag, or use the arrow keys, to move it.`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,onClick:e=>{if(v.current){v.current=!1,e.preventDefault();return}s()},onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:()=>{_.current=void 0,p(void 0)},onKeyDown:T,style:A,"data-thinking":e?``:void 0,"data-busy":E?``:void 0,"data-dragging":f?``:void 0,"data-placed":b?``:void 0,"data-flip":k||void 0,className:q(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,a&&`invisible`),children:[(0,R.jsx)(Du,{initial:!1,children:D?(0,R.jsx)(B.span,{className:`orb-label`,initial:{opacity:0,x:k?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:k?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,R.jsx)(Du,{mode:`popLayout`,initial:!1,children:(0,R.jsx)(B.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:D},D)})},`label`):null}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,R.jsx)(`span`,{className:`orb-icon`,children:(0,R.jsx)(WU,{source:e,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,R.jsxs)(JA,{side:`top`,children:[`Thinking `,o?(0,R.jsx)(aA,{chord:o}):null,(0,R.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),M2=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,N2=260,P2=200,F2=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function I2(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
104
104
|
`).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
|