@a-t-h-i/bot-lobby 0.6.29 → 0.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/package.json +1 -1
- package/prompts/master.md +17 -2
- package/src/delivery/operations.ts +29 -4
- package/src/delivery/store.ts +33 -0
- package/src/delivery/types.ts +4 -0
- package/src/lobby/feed.ts +2 -0
- package/src/lobby/host.ts +2 -1
- package/src/lobby/knowledge.ts +17 -0
- package/src/lobby/service.ts +11 -37
- package/src/pi/tools.ts +4 -4
- package/src/state/auto.ts +2 -1
- package/src/webui/api/index.ts +5 -1
- package/src/webui/api/knowledge.ts +9 -0
- package/src/webui/dev/fake-service.ts +4 -0
- package/src/webui/protocol.ts +1 -0
- package/src/workflow/workflow.ts +57 -7
- package/webui/dist/assets/{index-qisGNoCh.js → index-CaSemZv6.js} +6 -6
- package/webui/dist/assets/index-J551U6af.css +2 -0
- package/webui/dist/build.json +10 -10
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-BzCxEueR.css +0 -2
|
@@ -88,21 +88,21 @@ Error generating stack: `+e.message+`
|
|
|
88
88
|
`)),n=[]),n.push(i);return t.push(n.join(`
|
|
89
89
|
`)),t}function az(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 oz(e,t){return!e&&!t}async function sz(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var cz=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function lz(e){let t=e.lastIndexOf(`${VD}\n`);if(t<0||t>0&&e[t-1]!==`
|
|
90
90
|
`)return{body:e,files:[]};let n=e.slice(t+VD.length+1).split(`
|
|
91
|
-
`).filter(Boolean),r=[];for(let t of n){let n=cz.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 uz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function dz({files:e}){return e.length===0?null:(0,L.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,L.jsx)(`li`,{children:uz.has(e.mime)?(0,L.jsx)(`a`,{href:N(`/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,L.jsx)(`img`,{src:N(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-56 object-cover`})}):(0,L.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,L.jsx)(Pm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,L.jsx)(Eh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var fz=!1,pz=[],mz=0,hz=900;function gz(){fz=!0,window.clearTimeout(mz),mz=window.setTimeout(_z,hz)}function _z(){fz=!1,window.clearTimeout(mz);let e=pz;pz=[];for(let t of e)t()}function vz(e){if(!fz)return e(),()=>{};let t=()=>e();return pz.push(t),()=>{pz=pz.filter(e=>e!==t)}}var yz=8;function bz(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=vz(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Rv.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*yz/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function xz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(xz).join(``)}function Sz(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}),Sz(t,n)}function Cz(){return e=>Sz(e)}function wz(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await sz(e,navigator.clipboard),n(!0),V.success(`Code copied.`)}catch{V.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function Tz({text:e,children:t,block:n=!1}){let{copy:r}=wz(e),i=(0,m.useRef)(void 0);return(0,L.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(),oz(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),oz(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,L.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function Ez({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=wz(az(n,r?.position,!0)??xz(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,L.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,L.jsx)(Y,{label:i?`Copied`:`Copy the code`,icon:i?Hp:Sm,iconOnly:!0,onClick:()=>void a()})]}),(0,L.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 Dz(e){return{pre:t=>(0,L.jsx)(Ez,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,L.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,L.jsx)(Tz,{text:az(e,r?.position,i)??xz(r),block:i,children:n})},a:({href:e,children:t})=>(0,L.jsx)(`a`,{href:e?N(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,L.jsx)(`img`,{src:e?N(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,L.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var Oz=(0,m.memo)(function({text:e}){return(0,L.jsx)(GF,{remarkPlugins:[ZR],rehypePlugins:[Cz],urlTransform:$R,components:Dz(e),children:e})}),kz=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=lz(e),i=n?iz(n):[],a=bz(i.length,3);return(0,L.jsxs)(`div`,{className:q(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,L.jsx)(Oz,{text:e},t)),(0,L.jsx)(dz,{files:r})]})});function Az({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,L.jsxs)(`section`,{className:q(`group/frame relative flex min-h-0 min-w-0 flex-col`,i&&`flex-none`,n),...s,children:[e||t||a?(0,L.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,L.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,L.jsx)(`span`,{}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,L.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,L.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,L.jsx)(ED,{chord:o,className:`kbd-hint`}):null,(0,L.jsx)(Wp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function jz({title:e,right:t,className:n}){return(0,L.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,L.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function Mz({title:e,right:t,prominent:n,children:r}){return(0,L.jsxs)(`section`,{className:q(`flex flex-col`,n?`gap-3`:`gap-2.5`),children:[(0,L.jsx)(`h3`,{className:n?`text-sm text-foreground`:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var Nz=`Pull requests`,Pz=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,Fz=`nothing is posted to GitHub`,Iz=`Refresh to load open pull requests with the GitHub CLI (gh).`,Lz=`No open pull requests.`,Rz=`loading pull requests from GitHub…`,zz=`reading the diff…`,Bz=`the pull request has new commits since this review — review it again`,Vz=`(no description)`,Hz=`Review with a focus (optional)`,Uz=`Leave it empty for a full review.`;function Wz(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function Gz(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function Kz(e,t){return`+${e} −${t}`}function qz(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function Jz(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function Yz(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function Xz(e,t){if(e.status===`running`)return Zz(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?Zz(e,t):e.status;return[Yz(e.verdict),n].filter(Boolean).join(` · `)}function Zz(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 Qz(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${ZO(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function $z(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${Kz(e.additions,e.deletions)} · ${t}`}function eB(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,qz(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function tB(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function nB(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function rB(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 iB({pull:e,now:t}){return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Qz(e,t)}),(0,L.jsx)(`p`,{className:`text-sm tabular-nums`,children:$z(e)}),eB(e)?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:eB(e)}):null,e.url?(0,L.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 aB({read:e}){return(0,L.jsxs)(Mz,{title:`Jev's read`,right:nB(e),children:[e.status===`running`?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),zz]}):null,e.status===`failed`?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,L.jsx)(kz,{text:e.line}):null]})}function oB({review:e,now:t}){return(0,L.jsxs)(L.Fragment,{children:[e.model?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,ZO(t-e.startedAt)]}):null,e.stale?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:Bz}):null,e.status===`running`?(0,L.jsx)(sB,{steps:e.steps}):null,e.status===`cancelled`?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,L.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,L.jsx)(kz,{text:e.text}):null]})}function sB({steps:e}){return(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,L.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function cB({number:e,focus:t,onChange:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:Hz}),(0,L.jsx)(KO,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Uz})]})}function lB({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,L.jsxs)(Mz,{title:`Review`,right:t?Xz(t,n):void 0,children:[t?(0,L.jsx)(oB,{review:t,now:n}):null,(0,L.jsx)(cB,{number:e,focus:r,onChange:i}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,Fz,`.`]})]})}function uB({files:e}){return(0,L.jsx)(Mz,{title:`Files`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,L.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:Kz(e.additions,e.deletions)})]},e.path))})})})})}function dB({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?ZO(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,L.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,L.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,L.jsx)(kz,{text:e.body.trim()}):null]})}function fB({notes:e,now:t}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Discussion`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,L.jsx)(dB,{note:e,now:t},n))})})}function pB({number:e,error:t}){return t?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),`loading #`,e,`…`]})}function mB({number:e,onChanged:t}){let n=sO(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=rB(a);if(!n.data)return(0,L.jsx)(pB,{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 H(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await H(`git.jev`,{number:e}),u()},p=async()=>{await H(`git.cancelReview`,{number:e}),u()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Review`,icon:Rh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,L.jsx)(Y,{label:`Jev's read`,icon:Ip,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,L.jsx)(ck,{icon:um,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,L.jsx)(iB,{pull:s,now:o}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Pz}),l?(0,L.jsx)(aB,{read:l}):null,(0,L.jsx)(lB,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,L.jsx)(uB,{files:s.files}):null,(0,L.jsx)(Mz,{title:`Description`,children:s.body.trim()?(0,L.jsx)(kz,{text:s.body.trim()}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Vz})}),(0,L.jsx)(fB,{notes:s.notes,now:o})]})}var hB=Gg(`group/badge inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-lg border border-transparent px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/40 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-accent text-foreground [a]:hover:bg-primary/20`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-accent`,destructive:`bg-destructive/12 text-destructive [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-accent`,ghost:`hover:bg-accent hover:text-foreground`,link:`text-link underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function gB({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?Tv:`span`;return(0,L.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:q(hB({variant:t}),e),...r})}var _B=`flex min-h-10 w-full flex-col gap-0.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:bg-accent`,vB=`flex flex-col gap-0.5 px-2 pb-2`,yB=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function bB({checks:e}){let t=Wz(e);return t?(0,L.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,Gz(e)),"aria-hidden":`true`,children:t}):(0,L.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function xB({pull:e,selected:t,onSelect:n}){let r=Jz(e.review);return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,L.jsx)(bB,{checks:e.checks}),e.draft?(0,L.jsx)(gB,{variant:`secondary`,children:`draft`}):null,(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:tB(e)}),(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,L.jsx)(`span`,{children:r}):null,(0,L.jsx)(`span`,{className:`tabular-nums`,children:Kz(e.additions,e.deletions)})]})]})]})})}function SB({pulls:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(xB,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var CB=()=>GD(WD(`git`)),wB=e=>GD(WD(`git`,String(e)));function TB(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function EB({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?Lz:e?Rz:Iz;return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Rm,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,L.jsx)(J,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function DB({rest:e}){let t=BO(),n=sO(`git.pulls`,{},[`git`]),r=TB(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{H(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,L.jsx)(EB,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:Nz,count:n.data?`${i.length} open`:void 0,children:(0,L.jsx)(Y,{label:`Refresh`,icon:Hh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,L.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,L.jsx)(SB,{pulls:i,selectedId:r,onSelect:wB}):(0,L.jsx)(GO,{})]}),c=r===void 0?null:(0,L.jsx)(mB,{number:r,onChanged:n.reload},r);return(0,L.jsx)(UO,{wide:t,list:s,detail:c,open:r!==void 0,onClose:CB,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function OB(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function kB({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,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,L.jsx)(KO,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{OB(e)&&(e.preventDefault(),l())}}),t?(0,L.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,L.jsx)(`div`,{className:`flex self-end`,children:(0,L.jsx)(Y,{label:n,icon:s?Qm:Pp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var AB=`Issues`,jB=`Issue`,MB=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,NB=`Refresh to load open issues with the GitHub CLI (gh).`,PB=`No open issues. File one with New issue.`,FB=`loading issues from GitHub…`,IB=`issues are off (lobby.issues)`,LB=`(no description)`;function RB(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${ZO(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function zB(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?ZO(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function BB(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function VB({issue:e,now:t}){return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:RB(e,t)}),e.url?(0,L.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 HB({comment:e,now:t}){return(0,L.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,L.jsx)(`span`,{children:ZO(t-Date.parse(e.createdAt))}):null]}),(0,L.jsx)(kz,{text:e.body.trim()})]})}function UB({comments:e,now:t}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Comments`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,L.jsx)(HB,{comment:e,now:t},n))})})}function WB({issue:e}){let t=async()=>{await H(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&GD(WD(`plan`))};return(0,L.jsx)(ck,{icon:Ig,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 GB({number:e}){let t=sO(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${jB} #${e}`,children:[(0,L.jsx)(jO,{children:(0,L.jsx)(WB,{issue:r})}),(0,L.jsx)(VB,{issue:r,now:n}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:MB}),(0,L.jsx)(Mz,{title:`Description`,children:r.body.trim()?(0,L.jsx)(kz,{text:r.body.trim()}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:LB})}),(0,L.jsx)(UB,{comments:r.comments,now:n})]})}function KB({issue:e,selected:t,now:n,onSelect:r}){let i=BB(e.labels);return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,L.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,L.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:zB(e,n)})]})})}function qB({issues:e,selectedId:t,now:n,onSelect:r}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(KB,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var JB=()=>GD(WD(`issues`)),YB=e=>GD(WD(`issues`,String(e)));function XB(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function ZB(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(om,{"aria-hidden":`true`})}),(0,L.jsx)(ZD,{children:`Issues are off`}),(0,L.jsx)(QD,{className:`font-mono`,children:IB})]})})}function QB({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?PB:e?FB:NB;return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(om,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,L.jsx)(J,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function $B({onCreate:e}){return(0,L.jsx)(VO,{className:`shrink-0 border-t border-border p-4`,children:(0,L.jsx)(kB,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function eV({rest:e}){let t=BO(),n=aO(`status`).data?.issuesEnabled??!0,r=sO(`issues.list`,{},[`issues`],n),i=XB(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{H(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await H(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,L.jsx)(ZB,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,L.jsx)(ZB,{}):(0,L.jsx)(tO,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:AB,count:r.data?`${a.length} open`:void 0,children:(0,L.jsx)(Y,{label:`Refresh`,icon:Hh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,L.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,L.jsx)(qB,{issues:a,selectedId:i,now:o,onSelect:YB}):(0,L.jsx)(GO,{}),(0,L.jsx)($B,{onCreate:c})]}),d=i===void 0?null:(0,L.jsx)(GB,{number:i},i),f=r.data&&a.length===0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(QB,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,L.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,L.jsx)($B,{onCreate:c})})]}):(0,L.jsx)(UO,{wide:t,list:u,detail:d,open:i!==void 0,onClose:JB,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}var tV=[`master`,`designer`,`backend`,`qa`],nV={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},rV={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},iV=`Every write archives the version before it.`;function aV(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function oV(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function sV(e){return{text:e.text,occurrence:e.occurrence}}function cV(e){return tV.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 lV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function uV({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,L.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,L.jsx)(KO,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{lV(e)&&(e.preventDefault(),o())}}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:iV}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,L.jsxs)(J,{onClick:o,disabled:t||!i.trim(),children:[t?(0,L.jsx)($D,{}):null,`Save`]})]})]})]})}function dV({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=ID(e,FD.confirm);return(0,L.jsx)(OD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:iV,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iV})]}),(0,L.jsx)(KO,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,L.jsxs)(J,{onClick:()=>a(o),disabled:r,children:[r?(0,L.jsx)($D,{}):null,`Save file`]})]})]})})}function fV({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,L.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(Mh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,L.jsx)(Y,{label:`Take the note back`,icon:wg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function pV({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,L.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,L.jsx)(`div`,{className:`flex gap-2`,children:(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(kz,{text:e.text})})}),r.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,L.jsx)(fV,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function mV({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Notes on entries that changed`,right:String(e.length),children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,L.jsx)(fV,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function hV({view:e}){let t=e.entries.length;return(0,L.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:[rV[e.agent],` `,(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,aV(e.chars),` chars`]}),e.over?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:oV(e.file)}):null]})}function gV({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Edit the entry`,text:`Edit`,icon:Ih,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,L.jsx)(Y,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Bh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,L.jsx)(Y,{label:`Comment on the entry`,text:`Comment`,icon:oh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,L.jsx)(Y,{label:`Edit the whole file`,text:`Edit file`,icon:Am,shortcut:`F`,disabled:a,onClick:r}),(0,L.jsx)(ck,{icon:bg,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 _V({agent:e,file:t,onChanged:n}){let r=sO(`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(()=>H(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>H(`knowledge.remove`,{agent:e,file:t,ref:sV(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>H(`knowledge.edit`,{agent:e,file:t,ref:sV(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>H(`knowledge.comment`,{agent:e,file:t,ref:sV(r),text:n}));g(()=>H(`knowledge.add`,{agent:e,file:t,...h?{ref:sV(h)}:{},text:n}))};return f?(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${rV[e]} ${t}`,children:[(0,L.jsx)(gV,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,L.jsx)(hV,{view:f}),p.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,L.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map((e,t)=>(0,L.jsx)(pV,{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,L.jsx)(uV,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,L.jsx)(kB,{label:`Comment on this entry`,hint:iV,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,L.jsx)(kB,{label:`Add an entry`,hint:iV,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{}),` saving…`]}):null,(0,L.jsx)(mV,{notes:f.detached,onTakeBack:_,busy:u}),(0,L.jsx)(dV,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>H(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}var vV={DEV:vm,DESIGN:Sh,QA:ig,RESEARCH:gg,"QUICK FIX":Bg,SCOUT:bm,PLANNER:Xh,CLASSIFIER:mg,LOBBY:uh,LINT:Jm};function yV(e){return e?vV[e.toUpperCase()]??Rp:Bp}function bV(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function xV({source:e,className:t,strokeWidth:n}){if(bV(e))return(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=yV(e);return(0,L.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var SV={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 CV(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function wV(e){return SV[e]??`text-muted-foreground`}var TV={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 EV(e){return TV[e]??`var(--muted-foreground)`}function DV(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 OV(e){return e?.runs??[]}function kV(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 AV(e){return`${e.agent}/${e.file}`}var jV={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},MV=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function NV({info:e}){return(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`span`,{children:aV(e.chars)}),e.over?(0,L.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,L.jsx)(`span`,{className:`text-primary`,children:MV(e.notes,`note`)}):null]})}function PV({info:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{className:`ktree-leaf`,children:(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(AV(e)),className:q(_B,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,L.jsx)(NV,{info:e})]})})}var FV=`bot-lobby.knowledge.folded`;function IV(){try{let e=JSON.parse(window.localStorage.getItem(FV)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function LV({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(IV),o=cV(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(FV,JSON.stringify(r))}catch{}return r})}return(0,L.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,L.jsxs)(`p`,{className:`ktree-root`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,L.jsx)(Ip,{className:`size-4`})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[MV(e.length,`file`),` · `,MV(o.length,`agent`),s>0?` · ${MV(s,`note`)}`:``]})]})]}),(0,L.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=jV[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,L.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":EV(o)},children:[(0,L.jsx)(`h3`,{children:(0,L.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,L.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,L.jsx)(xV,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:nV[e.agent]}),l?(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,L.jsxs)(`span`,{className:`text-primary`,children:[MV(e.notes,`note`),` · `]}):null,MV(e.files.length,`file`)]}),(0,L.jsx)(Jp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,L.jsx)(Ou,{initial:!1,children:a?(0,L.jsx)(z.ul,{id:s,"aria-label":`${nV[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,L.jsx)(PV,{info:e,selected:AV(e)===n,onSelect:r},AV(e)))},`files`):null})]},e.agent)})})]})}var RV=()=>GD(WD(`knowledge`)),zV=e=>{let[t,n]=e.split(`/`);GD(WD(`knowledge`,t??``,n??``))};function BV(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Ip,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{children:`No knowledge files yet.`})]})})}function VV(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,L.jsx)(_V,{agent:i.agent,file:i.file,onChanged:r},AV(i)):t&&n?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function HV({agent:e,file:t}){let n=BO(),r=sO(`knowledge.files`,{},[`knowledge`]),i=r.data?.files??[];if(!r.data&&r.error)return(0,L.jsx)(tO,{message:`Could not load the knowledge files. ${r.error}`,onRetry:r.reload});if(r.data&&i.length===0)return(0,L.jsx)(BV,{});let a=i.reduce((e,t)=>e+t.notes,0),o=i.find(n=>n.agent===e&&n.file===t),s=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Knowledge`,count:a>0?`${a} note${a===1?``:`s`}`:void 0}),r.data?(0,L.jsx)(LV,{files:i,models:r.data.models??{},selectedKey:o?AV(o):void 0,onSelect:zV}):(0,L.jsx)(GO,{})]});return(0,L.jsx)(UO,{wide:n,list:s,detail:VV(i,e,t,r.reload),open:!!(e&&t),onClose:RV,hint:`Select a file to read its entries.`,describe:`Knowledge file`})}function UV({className:e,...t}){return(0,L.jsx)($S,{"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,L.jsx)(tC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var WV=`Sessions`,GV=`No sessions yet.`,KV=`Up to 5 sessions; each can be assigned to one agent or several.`,qV=`A session is a live Excalidraw room that you and your agents draw in together.`,JV=[{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.`}],YV=`Sessions`,XV=`Pick a session on the left to see its link, its room and its agents.`,ZV=`Room link`,QV=`Masked until revealed. A revealed link stays in this tab and is never saved.`,$V=`Room`,eH=`Drawing`,tH=`Last check`,nH=`not checked yet`,rH=`Add a session`,iH=`https://excalidraw.com/#room=…`,aH=`Optional name`;function oH(e){return`${e} of 5 in use`}var sH=`Agents may draw here.`,cH=`Agents may only look.`,lH=`checking the room…`,uH=`Check that the room can be reached.`,dH=`Assigned to`,fH=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,pH=`Add or rename`,mH=`Add by link`,hH=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,gH=`New room`,_H=`Makes a fresh room link to open in Excalidraw; the name is optional.`,vH=`Rename`,yH=`draw`,bH=`look only`,xH=`Copied to the clipboard`,SH=`Could not reveal the link.`,CH=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],wH={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function TH(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function EH(e){return e?e.ok?`✓`:`!`:``}function DH({title:e,right:t,className:n,children:r}){return(0,L.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,L.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function OH({row:e=!1}){return(0,L.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:JV.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function kH({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,L.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,L.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.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,L.jsx)(Y,{type:`submit`,label:n,icon:f?Qm:Bh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,L.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function AH({onChanged:e,primary:t}){return(0,L.jsx)(kH,{label:mH,hint:hH,buttonLabel:`Add`,placeholder:iH,required:!0,mono:!0,primary:t,onSubmit:async t=>await H(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function jH({onChanged:e,primary:t}){return(0,L.jsx)(kH,{label:gH,hint:_H,buttonLabel:`Create`,placeholder:aH,primary:t,onSubmit:async t=>{let n=t.trim();return await H(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function MH({onChanged:e,stacked:t=!1}){return(0,L.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,L.jsx)(AH,{onChanged:e,primary:!0}),(0,L.jsx)(jH,{onChanged:e,primary:!0})]})}function NH({session:e,onChanged:t}){return(0,L.jsx)(kH,{label:vH,initial:e.name,required:!0,buttonLabel:vH,onSubmit:async n=>await H(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function PH({icon:e,tone:t=`muted`,children:n}){return(0,L.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,L.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function FH({check:e,checking:t}){return t?(0,L.jsx)(PH,{icon:Qm,children:lH}):e?e.ok?(0,L.jsx)(PH,{icon:nm,tone:`primary`,children:`reachable`}):(0,L.jsx)(PH,{icon:em,tone:`warning`,children:`unreachable`}):(0,L.jsx)(PH,{icon:im,children:nH})}function IH({label:e,children:t}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm`,children:[(0,L.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsx)(`dd`,{className:`min-w-0`,children:t})]})}function LH({check:e,checking:t}){return t?(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}),lH]}):e?(0,L.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:uH})}function RH({agent:e,on:t,onToggle:n}){return(0,L.jsx)(`li`,{children:(0,L.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,L.jsx)(UV,{checked:t,onCheckedChange:()=>n(e)}),(0,L.jsx)(`span`,{className:`truncate`,children:wH[e]})]})})}function zH({session:e,onChanged:t}){let n=async n=>{await H(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await H(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===CH.length;return(0,L.jsxs)(DH,{title:dH,right:TH(e.agents.length),children:[(0,L.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:CH.map(t=>(0,L.jsx)(RH,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:fH}),(0,L.jsx)(Y,{label:i?`Take every agent off`:`Assign every agent`,icon:Jm,onClick:()=>void r()})]})]})}function BH({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await De(`excalidraw.reveal`,{id:e.id})).link)}catch(e){V.error(e instanceof Error?e.message:SH)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>V(xH)).catch(()=>void 0),u=async()=>{await H(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,L.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,L.jsxs)(jO,{children:[o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Y,{label:`Copy the link`,text:`Copy`,icon:Sm,shortcut:`C`,onClick:l}),(0,L.jsx)(Y,{label:`Open board`,icon:Em,tone:`primary`,shortcut:`O`,href:o})]}):(0,L.jsx)(Y,{label:`Reveal the link`,text:`Reveal`,icon:Om,shortcut:`R`,onClick:()=>void c()}),(0,L.jsx)(Y,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?Ph:Ih,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,L.jsx)(Y,{label:`Check the room`,text:`Check`,icon:n?Qm:ig,shortcut:`T`,disabled:n,onClick:r}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,L.jsx)(PH,{icon:e.contribute?Ih:Om,tone:e.contribute?`primary`:`muted`,children:e.contribute?yH:bH}),(0,L.jsx)(PH,{icon:Og,children:TH(e.agents.length)}),(0,L.jsx)(FH,{check:t,checking:n})]})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,L.jsxs)(DH,{title:ZV,children:[(0,L.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,L.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:QV})]}),(0,L.jsx)(DH,{title:$V,children:(0,L.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(IH,{label:eH,children:(0,L.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?sH:cH})}),(0,L.jsx)(IH,{label:tH,children:(0,L.jsx)(LH,{check:t,checking:n})})]})})]}),(0,L.jsx)(zH,{session:e,onChanged:i})]}),(0,L.jsx)(DH,{title:pH,children:(0,L.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,L.jsx)(NH,{session:e,onChanged:i}),(0,L.jsx)(AH,{onChanged:i}),(0,L.jsx)(jH,{onChanged:i})]})})]})}function VH({check:e,checking:t}){if(t)return(0,L.jsx)($D,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=EH(e);return n?(0,L.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,L.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function HH({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,L.jsx)(VH,{check:t,checking:n}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:TH(e.agents.length)})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,L.jsx)(gB,{variant:`secondary`,children:e.contribute?yH:bH})]})]})})}function UH({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(HH,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var WH=()=>GD(WD(`excalidraw`)),GH=e=>GD(WD(`excalidraw`,e));function KH({count:e}){return(0,L.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,L.jsx)(`span`,{className:`tabular-nums`,children:oH(e)})]})}function qH({count:e,onChanged:t}){return(0,L.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:YV}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:XV})]}),(0,L.jsx)(KH,{count:e})]}),(0,L.jsx)(OH,{row:!0}),e<5?(0,L.jsx)(DH,{title:rH,children:(0,L.jsx)(MH,{onChanged:t})}):null,(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,L.jsx)(DD,{chord:`ArrowDown`,children:`next session`}),(0,L.jsx)(DD,{chord:`ArrowRight`,children:`into its detail`})]})]})}function JH({onChanged:e}){return(0,L.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock sm:px-8`,children:(0,L.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,L.jsx)(Ah,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:GV}),(0,L.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:qV})]}),(0,L.jsx)(OH,{}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:KV})]}),(0,L.jsx)(DH,{title:rH,className:`self-start`,children:(0,L.jsx)(MH,{onChanged:e,stacked:!0})})]})})}function YH({id:e}){let t=BO(),n=sO(`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 H(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await H(`excalidraw.remove`,{id:c.id})&&(n.reload(),WH())};if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,L.jsx)(JH,{onChanged:n.reload});let d=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:WV,count:n.data?`${s.length}/5`:void 0}),n.data?(0,L.jsx)(UH,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:GH}):(0,L.jsx)(GO,{})]}),f=c?(0,L.jsx)(BH,{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,L.jsx)(qH,{count:s.length,onChanged:n.reload}):null;return(0,L.jsx)(UO,{wide:t,list:d,detail:f,open:c!==void 0,onClose:WH,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function XH(e,t){return e===`lobby.thinking`||t===`1`}var ZH=`bot-lobby.collapsed.`,QH=new Set,$H=new Map;function eU(e){if($H.has(e))return $H.get(e);if(e===`lobby.thinking`)return XH(e);try{return XH(e,localStorage.getItem(ZH+e))}catch{return!1}}function tU(e,t){$H.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(ZH+e,t?`1`:`0`)}catch{}for(let e of[...QH])e()}function nU(e){return QH.add(e),()=>{QH.delete(e)}}function rU(e){tU(e,!eU(e))}function iU(e){return[(0,m.useSyncExternalStore)(nU,()=>eU(e),()=>XH(e)),(0,m.useCallback)(()=>tU(e,!eU(e)),[e])]}function aU(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))},[])}}function oU({entry:e}){return e.pending?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,L.jsx)(Sg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function sU({entry:e}){return(0,L.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,L.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:JO(e.at)}),(0,L.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,wV(e.source)),children:CV(e.source)}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,L.jsx)(oU,{entry:e})}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,L.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 cU({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}=aU(JSON.stringify(a));return(0,L.jsxs)(Az,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,L.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,L.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,L.jsx)(`ul`,{children:a.map(e=>(0,L.jsx)(sU,{entry:e},e.id))})}),c?null:(0,L.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,L.jsx)(Y,{label:`Jump to latest`,text:`Latest`,icon:Op,className:`rounded-full bg-card shadow-card`,onClick:l})})]})}function lU({source:e,live:t}){let n=bV(e);return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":EV(e)},children:(0,L.jsx)(xV,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function uU({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,L.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,L.jsx)(`div`,{className:`chat-gutter`,children:r?(0,L.jsx)(lU,{source:e,live:i}):n?(0,L.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,L.jsxs)(`p`,{className:`chat-speaker`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,L.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,L.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,L.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":EV(e)},children:a}):a]})]})}function dU({time:e,head:t,note:n,children:r,below:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,L.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,L.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,L.jsx)(`span`,{children:n}):null]}):null,(0,L.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function fU({failed:e,children:t}){return(0,L.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,L.jsx)(`span`,{children:t})})}function pU({className:e}){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]})}var mU=3e5,hU=`earlier messages load as you scroll up`,gU=`No task is running in this session.`,_U=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,vU=`Nothing said yet. Type below to talk to the oracle about this task.`;function yU({entry:e}){return(0,L.jsxs)(fU,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${JO(e.at)}`:``]})}function bU({entry:e,head:t}){if(e.role===`you`)return(0,L.jsx)(dU,{time:JO(e.at),head:t,children:(0,L.jsx)(kz,{text:e.text})});let n=e.role===`panel`;return(0,L.jsx)(uU,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:JO(e.at),head:t,children:(0,L.jsx)(kz,{text:e.text})})}var xU=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,L.jsx)(z.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,L.jsx)(yU,{entry:e}):(0,L.jsx)(bU,{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 SU({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,L.jsx)(uU,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,L.jsx)(kz,{text:e??``}):(0,L.jsx)(pU,{className:`mt-1`})})}function CU({hasTask:e}){return(0,L.jsxs)(qD,{className:`h-full border-0`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(ch,{"aria-hidden":`true`})}),e?null:(0,L.jsx)(ZD,{children:gU}),(0,L.jsx)(QD,{children:e?vU:_U})]}),e?null:(0,L.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,L.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,L.jsx)(ED,{chord:`3`}),` Plan`]}),(0,L.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,L.jsx)(ED,{chord:`4`}),` Quick fix`]})]})]})}async function wU(e){let t=await De(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function TU(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 wU(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 EU({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i,bare:a}){let{ref:o,atBottom:s,stick:c,onScroll:l}=aU(e.length+(t?.length??0)),{merged:u,more:d,loading:f,load:p}=TU(e,r,o),h=(0,m.useCallback)(()=>{l();let e=o.current;e&&e.scrollTop<80&&d&&!f&&p()},[l,o,d,f,p]),g=u.length===0&&!t?.trim()&&!n,[_,v]=(0,m.useState)(!1);return(0,m.useEffect)(()=>v(!0),[]),(0,L.jsxs)(Az,{"aria-label":`Conversation`,...a?{}:{title:`Conversation`},note:d?hU:void 0,className:`flex-1`,children:[(0,L.jsx)(`div`,{ref:o,onScroll:h,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:g?(0,L.jsx)(CU,{hasTask:i}):(0,L.jsxs)(`div`,{className:`chat-column`,children:[u.map((e,t)=>{let n=u[t-1],r=!n||n.role!==e.role||e.at-n.at>mU;return(0,L.jsx)(xU,{entry:e,head:r,fresh:_},e.id)}),(0,L.jsx)(SU,{text:t,busy:n})]})}),s?null:(0,L.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,L.jsx)(Y,{label:`Jump to latest`,text:`Latest`,icon:Op,tone:`primary`,className:`rounded-full shadow-sm`,onClick:c})})]})}function DU(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 OU(e){return e===`running`?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):e===`success`?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):e===`failed`||e===`timeout`||e===`error`?(0,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`})}function kU(e,t){let n=e.startedAt?Date.parse(e.startedAt):NaN;return YO((e.finishedAt?Date.parse(e.finishedAt):t)-n)}function AU({runs:e}){let t=DU(e.some(e=>e.status===`running`));return e.length===0?null:(0,L.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,L.jsxs)(`li`,{className:`flex items-center gap-2 rounded-full bg-muted py-1 pr-3 pl-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:OU(e.status)}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.status??`unknown`}),(0,L.jsx)(`span`,{className:q(`font-medium`,wV(DV(e))),children:CV(DV(e))}),e.activity??e.step?(0,L.jsx)(`span`,{className:`max-w-[18rem] truncate text-muted-foreground`,children:e.activity??e.step}):null,(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:kU(e,t)})]},e.runId??n))})}function jU(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 MU(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 NU(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 PU=8;function FU(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function IU(e,t){let n=Math.min(t,PU);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 LU({done:e,total:t}){return(0,L.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:IU(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function RU({check:e,className:t}){return(0,L.jsx)(e===`done`?nm:e===`dropped`?fm:mm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function zU({children:e}){return(0,L.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function BU({ms:e,running:t,sample:n}){let r=NU(t,n);return(0,L.jsx)(`span`,{className:`tabular-nums`,children:MU(e+r)})}function VU({work:e}){return(0,L.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,L.jsx)(vg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,L.jsx)(BU,{ms:e.workedMs,running:e.running,sample:e})]})}function HU({active:e,current:t}){let n=e?.[0];return n?(0,L.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,L.jsx)(`span`,{className:`truncate text-foreground`,children:n.text}),(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,L.jsx)(BU,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]}):t?(0,L.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,L.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function UU({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,L.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,L.jsx)(z.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,L.jsx)(HU,{...r?{active:r}:{},...n?{current:n}:{}})]})}function WU({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,L.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,L.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,L.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,L.jsx)(zU,{children:e.id}),e.track?(0,L.jsx)(zU,{children:FU(e.track)}):null,(e.domains??[]).length>0?(0,L.jsx)(zU,{children:e.domains.join(`, `)}):null,r?(0,L.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,L.jsx)(Im,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,L.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,L.jsx)(VU,{work:e.work}):null,e.progress?(0,L.jsx)(UU,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var GU=(e,t)=>e?.keys.find(e=>e.action===t)?.label,KU=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function qU({name:e,icon:t,shortcut:n,onClick:r}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsxs)(dO,{side:`left`,children:[`Expand `,e,n?(0,L.jsx)(ED,{chord:n}):null]})]})}function JU(e){let t=KU(e.status);return(0,L.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,L.jsx)(qU,{name:`Activity`,icon:Sp,shortcut:GU(e.status,`activity`),onClick:e.toggleActivity}):null})}function YU(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=KU(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,L.jsxs)(`div`,{className:q(`grid min-h-0 flex-1`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)] divide-x divide-border`:`grid-cols-1`),children:[a.conversation?(0,L.jsx)(EU,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,L.jsx)(cU,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:GU(n,`activity`)}):null]})}function XU(e){let{status:t}=e,n=KU(t).activity&&e.activityFolded;return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,L.jsx)(YU,{...e})}),n?(0,L.jsx)(JU,{...e}):null]})}function ZU({data:e,status:t}){let n=KU(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ch}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:Sp}]:[]],[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,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,L.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,L.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,L.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,L.jsx)(EU,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task,bare:!0}):null,o.id===`activity`?(0,L.jsx)(cU,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function QU(e){let{data:t,status:n}=e,r=BO();return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,L.jsx)(WU,{task:t?.task,status:n}),(0,L.jsx)(AU,{runs:OV(t)})]}),r?(0,L.jsx)(XU,{...e}):(0,L.jsx)(ZU,{...e})]})}function $U(){let e=aO(`lobby`),t=aO(`status`),[n,r]=iU(`lobby.activity`);return!e.data&&e.loading?(0,L.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{}),(0,L.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,L.jsx)(tO,{message:e.error,onRetry:()=>me.onHello({})}):(0,L.jsx)(QU,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var eW={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function tW(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 nW(e){return e>0?tW(e):`—`}function rW(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function iW(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function aW(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 oW(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function sW(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function cW(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function lW(e,t){let n=t===`model-kind`?eW[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var uW=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],dW={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 fW(e){let t=dW[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%uW.length;return uW[n]??uW[0]}function pW(e){return eW[e]??e}var mW=6;function hW({title:e,right:t,children:n}){return(0,L.jsxs)(`section`,{className:`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,"aria-label":e,children:[(0,L.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-medium`,children:[(0,L.jsx)(`span`,{children:e}),t?(0,L.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]}),n]})}function gW({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,mW);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>mW?(0,L.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 _W(e,t){return t>0?Math.max(1.5,e/t*100):0}function vW({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,L.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,L.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,L.jsxs)(`div`,{className:`relative h-1.5 rounded-full bg-muted`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,L.jsx)(`div`,{className:`h-full rounded-full bg-primary/70`,style:{width:`${_W(t,r)}%`}}),n?(0,L.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,_W(n,r))}%`}}):null]})]})}function yW({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,L.jsx)(hW,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,L.jsx)(gW,{rows:n,render:e=>(0,L.jsx)(vW,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:nW(e.avgMs),sub:`p90 ${nW(e.p90Ms)}`},t(e))})})}var bW={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},xW={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function SW({label:e,rate:t,runs:n}){let r=sW(t),i=`${Math.round(t*100)}%`;return(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 ${xW[r.tone]}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${bW[r.tone]}`}),(0,L.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,L.jsxs)(`div`,{className:`flex h-1.5 overflow-hidden rounded-full bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,L.jsx)(`div`,{className:`h-full bg-success/70`,style:{width:`${t*100}%`}}),(0,L.jsx)(`div`,{className:`h-full bg-destructive/45`,style:{width:`${(1-t)*100}%`}})]})]})}function CW({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,L.jsx)(hW,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,L.jsx)(gW,{rows:n,render:e=>(0,L.jsx)(SW,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function wW({share:e}){return(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${fW(e.agent)}`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-[0.8125rem]`,children:CV(e.agent)}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,L.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,tW(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function TW({share:e}){return(0,L.jsx)(`div`,{className:`flex h-2.5 gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,L.jsx)(`span`,{className:`${fW(e.agent)} opacity-75 first:rounded-l-full last:rounded-r-full`,style:{width:`${e.share*100}%`},title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function EW({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,L.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,L.jsx)(gW,{rows:e,render:e=>(0,L.jsx)(vW,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:tW(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function DW({timeShare:e}){let t=e.byAgent;return(0,L.jsx)(hW,{title:`Where the time goes`,right:`share of run time by agent`,children:t.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(TW,{share:t}),(0,L.jsx)(wW,{share:t}),(0,L.jsx)(EW,{times:e.taskTimes})]})})}function OW({label:e,value:t,sub:n}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var kW=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function AW({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,L.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,L.jsx)(OW,{label:`Calls`,value:kW(e.calls,`call`),sub:`${rW(e.ok,e.calls)} ok`}),(0,L.jsx)(OW,{label:`Speed`,value:`p50 ${oW(e.p50Ms)}`,sub:`p90 ${oW(e.p90Ms)}`}),(0,L.jsx)(OW,{label:`Read`,value:e.input>0?`${aW(e.input)} tokens`:`—`}),(0,L.jsx)(OW,{label:`Routed down`,value:e.routed>0?kW(e.routed,`run`):`none`,sub:e.routed>0?`${rW(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,kW(e.seatRunsSkipped,`seat run`),` skipped · `,kW(e.questionsAnswered,`question`),` answered · `,kW(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,L.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var jW=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function MW(e,t=0){return e>0?e.toFixed(t):`—`}function NW(e){return[String(e.runs),rW(e.successes,e.runs),nW(e.avgMs),nW(e.p50Ms),nW(e.p90Ms),MW(e.avgTurns,1),MW(e.avgTools,1),e.avgTokens>0?aW(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,iW(e.avgCost),iW(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function PW(e,t){return t===`model-kind`?pW(e.kinds[0]??``):e.kinds.map(pW).join(`, `)}function FW({groups:e,groupBy:t}){return(0,L.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,L.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,L.jsx)(`span`,{children:`All models`}),(0,L.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,L.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,L.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),jW.map(e=>(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,L.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:PW(e,t)||`—`}),NW(e).map((e,t)=>(0,L.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},jW[t]))]},lW(e,t)))})]})})]})}var IW={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function LW({label:e,value:t,sub:n,dot:r}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 bg-card px-4 py-3.5`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${IW[r.tone]}`}),(0,L.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function RW({tiles:e}){let t=sW(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-xl border border-border bg-border shadow-card sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,L.jsx)(LW,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,L.jsx)(LW,{label:`Success`,value:rW(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,L.jsx)(LW,{label:`Avg run`,value:nW(e.avgMs),sub:`p90 ${nW(e.p90Ms)}`}),(0,L.jsx)(LW,{label:`Cost`,value:iW(e.cost),sub:e.runs>0?`${iW(e.cost/e.runs)} per run`:`—`}),(0,L.jsx)(LW,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${tW(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var zW=`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 BW({groupBy:e,onGroup:t}){return(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex 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,L.jsx)(J,{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:cW(n)},n))})}function VW({query:e,onQuery:t}){return(0,L.jsxs)(`label`,{className:`relative flex items-center`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,L.jsx)(eg,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,L.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,L.jsx)(ED,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function HW({data:e,groupBy:t,query:n}){let r=e=>lW(e,t);return e.tiles.runs===0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(RW,{tiles:e.tiles}),(0,L.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}".`:zW})]}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(RW,{tiles:e.tiles}),e.classifier?(0,L.jsx)(AW,{summary:e.classifier}):null,(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(yW,{groups:e.groups,label:r}),(0,L.jsx)(CW,{groups:e.groups,label:r})]}),(0,L.jsx)(DW,{timeShare:e.timeShare}),(0,L.jsx)(FW,{groups:e.groups,groupBy:t})]})}function UW(){return(0,L.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,L.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function WW(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),i=sO(`metrics.get`,{groupBy:e,query:n},[`metrics`]);return!i.data&&i.error?(0,L.jsx)(tO,{message:`Could not load metrics. ${i.error}`,onRetry:i.reload}):(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),i.loading&&i.data?(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),(0,L.jsx)(BW,{groupBy:e,onGroup:t}),(0,L.jsx)(VW,{query:n,onQuery:r})]}),i.data?(0,L.jsx)(HW,{data:i.data,groupBy:e,query:n}):(0,L.jsx)(UW,{})]})}var GW=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 KW(e,t){return JSON.stringify([e,`prompt`,t])}function qW(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function JW(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var YW=`bot-lobby.prompt-sound-muted`,XW=new Set,ZW,QW=!1;function $W(){try{return localStorage.getItem(YW)===`on`}catch{return QW}}function eG(e){QW=e;try{localStorage.setItem(YW,e?`on`:`off`)}catch{}for(let e of XW)e()}function tG(e){return XW.add(e),()=>{XW.delete(e)}}function nG(){return(0,m.useSyncExternalStore)(tG,$W,()=>!1)}function rG(){(0,m.useEffect)(()=>{let e=()=>{try{ZW??=new AudioContext,ZW.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function iG(){if(!$W()&&ZW&&ZW.state===`running`)try{let e=ZW.currentTime,t=ZW.createOscillator(),n=ZW.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(ZW.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var aG=`bot-lobby.notifications`,oG=`/icon-192.png`,sG=new Set;function cG(){for(let e of[...sG])e()}function lG(){try{return localStorage.getItem(aG)===`on`}catch{return!1}}function uG(e){return sG.add(e),()=>{sG.delete(e)}}function dG(e){try{localStorage.setItem(aG,e?`on`:`off`)}catch{}cG()}function fG(){return(0,m.useSyncExternalStore)(uG,lG,()=>!1)}async function pG(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(dG(!0),`granted`):`denied`)}function mG(){dG(!1)}function hG(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function gG(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function _G(e){try{new Notification(`bot-lobby`,{body:e,icon:oG,tag:`bot-lobby`})}catch{}}function vG(){try{return new GW(sessionStorage)}catch{return new GW}}function yG(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?qW(e,t.sessionId??n.key??t.from,n.dialog.id):KW(e,t.id)}function bG(){let e=fG();rG(),rO();let t=sO(`tasks.list`,{},[`tasks`]),n=sO(`sessions.list`,{},[`sessions`]),r=me.get(`prompts`),i=me.get(`lobby`).data,a=(0,m.useRef)(vG()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=M()??`current`,l=me.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 xG(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(()=>iG()),c&&gG()&&_G(r),t===`delivery`&&V.info(r,{action:{label:`Review tasks`,onClick:()=>GD(`#/tasks`)}}))}function SG(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;xG(e,`prompts`,(a??[]).map(e=>yG(i,e)),`A question is waiting for you.`,!!a&&!t.loading),xG(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>qW(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),xG(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=>JW(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function CG(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}SG(e);let s=a?.task?.state??``,c=hG(s);i.current&&c&&s!==i.current&&o&&gG()&&_G(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function wG(){let e=bG(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>CG(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function TG({className:e,type:t,...n}){return(0,L.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})}function EG({className:e,thumbClassName:t,...n}){return(0,L.jsx)(EE,{"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,L.jsx)(OE,{"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 DG=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],OG={repeat:1/0},kG=`M0 -4 L1 -1 L4 0 L1 1 L0 4 L-1 1 L-4 0 L-1 -1Z`,AG=[`var(--rainbow-1)`,`var(--rainbow-2)`,`var(--rainbow-3)`,`var(--rainbow-4)`,`var(--rainbow-5)`,`var(--rainbow-6)`,`var(--rainbow-7)`],jG={transformBox:`fill-box`,transformOrigin:`center`};function MG(e){switch(e){case`off`:return{animate:{scale:[1,1.03,1],rotate:-5},transition:{...OG,duration:4,ease:`easeInOut`}};case`minimal`:return{animate:{rotate:[0,0,7,9,0,0],y:[0,0,1.5,2,0,0]},transition:{...OG,duration:4.2,times:[0,.35,.7,.82,.86,1],ease:`easeInOut`}};case`low`:return{animate:{rotate:[-4,4,-4],y:[0,-1,0]},transition:{...OG,duration:3.2,ease:`easeInOut`}};case`medium`:return{animate:{rotate:[0,-5,-5,5,5,0],y:[0,-1,-1,-1,-1,0]},transition:{...OG,duration:4,times:[0,.12,.4,.52,.8,1],ease:`easeInOut`}};case`high`:return{animate:{y:[0,-1.5,0]},transition:{...OG,duration:.6,ease:`easeInOut`}};case`xhigh`:return{animate:{y:[0,-7,0,0],scaleY:[1,1.06,.88,1],scaleX:[1,.96,1.1,1]},transition:{...OG,duration:.7,times:[0,.4,.75,1],ease:`easeInOut`}};case`max`:return{animate:{y:[-1,-4,-1],rotate:[-3,3,-3]},transition:{...OG,duration:1.6,ease:`easeInOut`}}}}function NG(){return(0,L.jsx)(`g`,{className:`fill-muted-foreground`,fontWeight:`700`,children:[0,1,2].map(e=>(0,L.jsx)(z.text,{x:44+e*4.5,y:17-e*5.5,fontSize:5.5+e*2,initial:{opacity:0},animate:{opacity:[0,1,0],y:[3,-4],x:[0,2.5]},transition:{...OG,duration:2.6,delay:e*.8,ease:`easeOut`},children:`z`},e))})}function PG(){return(0,L.jsx)(`g`,{className:`fill-primary`,fontSize:`9`,children:[0,1].map(e=>(0,L.jsx)(z.text,{x:48,y:20,initial:{opacity:0},animate:{opacity:[0,1,1,0],y:[2,-5,-11,-17],x:[0,3,1,5],rotate:[0,12,-8,10]},transition:{...OG,duration:3,delay:e*1.5,ease:`easeOut`},style:jG,children:e?`♫`:`♪`},e))})}function FG(){return(0,L.jsx)(z.text,{x:52,y:14,fontSize:`12`,fontWeight:`700`,className:`fill-primary`,initial:{opacity:0,scale:0},animate:{opacity:[0,0,1,1,0],scale:[0,0,1.2,1,.6],rotate:[0,0,-12,8,0]},transition:{...OG,duration:4,times:[0,.5,.58,.85,1]},style:jG,children:`?`})}function IG({spots:e,rainbow:t}){return(0,L.jsx)(`g`,{children:e.map(([e,n,r],i)=>(0,L.jsx)(z.path,{d:kG,className:t?void 0:`fill-primary`,style:{x:e,y:n,...t?{fill:AG[i%AG.length]}:{}},initial:{scale:0},animate:{scale:[0,1.1,0],rotate:[0,90,180]},transition:{...OG,duration:1.3,delay:r,ease:`easeInOut`}},i))})}function LG(){return(0,L.jsx)(`g`,{children:[-20,20].map((e,t)=>(0,L.jsxs)(`g`,{transform:`rotate(${e} 32 34)`,children:[(0,L.jsx)(`ellipse`,{cx:32,cy:34,rx:30,ry:9,fill:`none`,strokeWidth:.8,strokeDasharray:`2 3`,className:`stroke-primary/35`}),(0,L.jsx)(z.circle,{r:2,className:`fill-primary`,animate:{cx:[2,32,62,32,2],cy:[34,43,34,25,34]},transition:{...OG,duration:1.1,delay:t*.55,ease:`linear`}})]},e))})}function RG(){return(0,L.jsx)(z.path,{d:`M53 22 Q56 27 53 29 Q50 27 53 22Z`,className:`fill-primary/60`,animate:{y:[0,8],opacity:[0,1,0]},transition:{...OG,duration:.9,ease:`easeIn`,repeatDelay:.5}})}function zG({id:e}){return(0,L.jsx)(z.circle,{cx:32,cy:34,r:27,fill:`url(#${e}-glow)`,animate:{scale:[.92,1.08,.92],opacity:[.5,.85,.5]},transition:{...OG,duration:1.6,ease:`easeInOut`},style:{transformOrigin:`32px 34px`}})}function BG({rainbow:e}){return(0,L.jsx)(`g`,{children:Array.from({length:8},(t,n)=>{let r=n/8*Math.PI*2;return(0,L.jsx)(z.circle,{cx:32,cy:34,r:2,className:e?void 0:`fill-primary`,style:e?{fill:AG[n%AG.length]}:void 0,initial:{opacity:1,scale:1},animate:{cx:32+Math.cos(r)*32,cy:34+Math.sin(r)*30,opacity:0,scale:.3},transition:{duration:.6,ease:`easeOut`}},n)})})}function VG({level:e,move:t}){let n={fill:`none`,strokeWidth:2.2,strokeLinecap:`round`,className:`stroke-foreground`};if(e===`off`)return(0,L.jsx)(`path`,{d:`M20 33 Q24.5 36.5 29 33 M35 33 Q39.5 36.5 44 33`,...n});if(e===`low`)return(0,L.jsx)(`path`,{d:`M20 34 Q24.5 29.5 29 34 M35 34 Q39.5 29.5 44 34`,...n});if(e===`max`)return(0,L.jsx)(`g`,{children:[25,39].map((e,n)=>(0,L.jsx)(z.path,{d:`M0 -5.5 L1.6 -1.6 L5.5 0 L1.6 1.6 L0 5.5 L-1.6 1.6 L-5.5 0 L-1.6 -1.6Z`,style:{x:e,y:33,fill:AG[n?4:0]},animate:t?{rotate:[0,90,180],scale:[1,1.25,1]}:{},transition:{...OG,duration:1.2,ease:`easeInOut`,delay:n*.2}},e))});let r=e===`minimal`?.45:e===`high`?.7:e===`xhigh`?1.2:1,i=t&&e===`medium`?{x:[0,-2.5,-2.5,2.5,2.5,0]}:{x:0},a=t&&e===`medium`?{...OG,duration:4,times:[0,.12,.4,.52,.8,1]}:{duration:.2},o=e===`minimal`?3.2:e===`xhigh`?1.4:3.6,s=t?{scaleY:[r,r,.1,r,r]}:{scaleY:r},c=t?{...OG,duration:o,times:[0,.44,.5,.56,1]}:{duration:.2};return(0,L.jsx)(z.g,{animate:i,transition:a,children:[25,39].map(t=>(0,L.jsxs)(`g`,{children:[(0,L.jsx)(z.ellipse,{cx:t,cy:33,rx:3.4,ry:3.8,className:`fill-foreground`,style:jG,animate:s,transition:c}),e===`minimal`?null:(0,L.jsx)(`circle`,{cx:t+1.2,cy:31.6,r:1,className:`fill-card`})]},t))})}function HG({level:e,move:t}){let n={fill:`none`,strokeWidth:2,strokeLinecap:`round`,className:`stroke-foreground`};switch(e){case`off`:return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`circle`,{cx:32,cy:42,r:1.4,className:`fill-foreground`}),t?(0,L.jsx)(z.circle,{cx:35,cy:42,r:3,fill:`none`,strokeWidth:.9,className:`stroke-primary/60`,animate:{scale:[.2,1.3,1.5,0],opacity:[.6,.9,.9,0]},transition:{...OG,duration:4,times:[0,.7,.9,1]},style:{transformOrigin:`33px 42px`}}):null]});case`minimal`:return(0,L.jsx)(z.ellipse,{cx:32,cy:42,rx:3,ry:.8,className:`fill-foreground`,animate:t?{ry:[.8,.8,3.6,3.6,.8],rx:[3,3,3.6,3.6,3]}:{},transition:{...OG,duration:6,times:[0,.6,.7,.85,1]}});case`low`:return(0,L.jsx)(`path`,{d:`M26 40 Q32 45 38 40`,...n});case`medium`:return(0,L.jsx)(`path`,{d:`M28 41.5 Q32 43 36 41.5`,...n});case`high`:return(0,L.jsx)(`path`,{d:`M27 42 L37 41`,...n});case`xhigh`:return(0,L.jsx)(`path`,{d:`M25.5 39.5 Q32 47 38.5 39.5Z`,className:`fill-foreground`});case`max`:return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`path`,{d:`M24 38.5 Q32 50 40 38.5Z`,className:`fill-foreground`}),(0,L.jsx)(`path`,{d:`M28.5 44.5 Q32 47.5 35.5 44.5 Q32 43 28.5 44.5Z`,style:{fill:`var(--rainbow-1)`}})]})}}function UG({level:e,className:t}){let n=Sf()??!1,r=DG.includes(e)?e:`medium`,i=`m${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,a=!n,o=DG.indexOf(r),s=(0,m.useRef)(o),[c,l]=(0,m.useState)({n:0,up:!0});(0,m.useEffect)(()=>{o!==s.current&&(l(e=>({n:e.n+1,up:o>s.current})),s.current=o)},[o]);let u=MG(r),d=r===`max`,f=d?{stroke:`url(#${i}-rainbow)`}:void 0,p=!a||c.n===0?void 0:c.up?{y:[0,-9,0,0],scaleX:[1,.9,1.1,1],scaleY:[1,1.12,.9,1]}:{y:[0,0,0],scaleX:[1,1.12,1],scaleY:[1,.84,1]};return(0,L.jsxs)(`svg`,{viewBox:`0 0 64 64`,"data-slot":`effort-mascot`,"data-level":r,"aria-hidden":`true`,focusable:`false`,className:q(`size-14 shrink-0 overflow-visible`,t),children:[(0,L.jsxs)(`defs`,{children:[(0,L.jsxs)(`linearGradient`,{id:`${i}-rainbow`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[AG.map((e,t)=>(0,L.jsx)(`stop`,{offset:t/(AG.length-1),stopColor:e},t)),a&&d?(0,L.jsx)(`animateTransform`,{attributeName:`gradientTransform`,type:`rotate`,from:`0 0.5 0.5`,to:`360 0.5 0.5`,dur:`2.4s`,repeatCount:`indefinite`}):null]}),(0,L.jsxs)(`radialGradient`,{id:`${i}-glow`,children:[(0,L.jsx)(`stop`,{offset:`0.35`,stopColor:`var(--rainbow-6)`,stopOpacity:`0.45`}),(0,L.jsx)(`stop`,{offset:`0.7`,stopColor:`var(--rainbow-1)`,stopOpacity:`0.18`}),(0,L.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-3)`,stopOpacity:`0`})]})]}),d?a?(0,L.jsx)(zG,{id:i}):(0,L.jsx)(`circle`,{cx:32,cy:34,r:27,fill:`url(#${i}-glow)`}):null,a&&r===`xhigh`?(0,L.jsx)(LG,{}):null,(0,L.jsx)(z.g,{animate:p,transition:{duration:c.up?.55:.45,ease:`easeOut`},style:{transformOrigin:`32px 56px`},children:(0,L.jsxs)(z.g,{animate:a?u.animate:{rotate:r===`off`?-5:0},transition:a?u.transition:{duration:0},style:{transformOrigin:`32px 56px`},children:[(0,L.jsxs)(z.g,{style:{transformOrigin:`32px 17px`},animate:r===`off`?{rotate:32}:r===`minimal`?{rotate:14}:a&&r===`medium`?{rotate:[0,-12,10,0]}:a&&(r===`xhigh`||r===`max`)?{rotate:[-10,10,-10]}:{rotate:0},transition:a&&(r===`medium`||r===`xhigh`||r===`max`)?{...OG,duration:r===`medium`?2:.5,ease:`easeInOut`}:{type:`spring`,stiffness:200,damping:14},children:[(0,L.jsx)(`path`,{d:`M32 17 V10`,strokeWidth:2,strokeLinecap:`round`,className:d?void 0:`stroke-primary/70`,style:f}),(0,L.jsx)(z.circle,{cx:32,cy:7.5,r:3.2,className:d?void 0:r===`off`?`fill-muted-foreground/40`:`fill-primary`,style:{...jG,...d?{fill:`url(#${i}-rainbow)`}:{}},animate:a?r===`high`?{opacity:[1,.3,1]}:r===`medium`?{scale:[1,1.25,1]}:d||r===`xhigh`?{scale:[1,1.5,1]}:{scale:1,opacity:1}:{scale:1,opacity:1},transition:{...OG,duration:r===`high`?.5:r===`medium`?1.6:.4}})]}),[4.5,54].map((e,t)=>(0,L.jsx)(z.rect,{x:e,y:29,width:5.5,height:11,rx:2.5,className:d?void 0:`fill-primary/25`,style:{...jG,...d?{fill:AG[t?5:1],opacity:.6}:{}},animate:a&&(r===`xhigh`||d)?{rotate:t?[0,18,0]:[0,-18,0]}:{rotate:0},transition:{...OG,duration:.35}},e)),(0,L.jsx)(`rect`,{x:10,y:17,width:44,height:36,rx:11,strokeWidth:d?2.6:2,className:d?`fill-primary/10`:`fill-primary/10 stroke-primary/75`,style:f}),(0,L.jsx)(`rect`,{x:15,y:23,width:34,height:25,rx:7.5,className:`fill-card stroke-border`,strokeWidth:1}),a&&r===`high`?(0,L.jsx)(z.rect,{y:24,width:2,height:23,rx:1,className:`fill-primary/25`,animate:{x:[16,46,16]},transition:{...OG,duration:1.6,ease:`easeInOut`}}):null,r===`low`||d?(0,L.jsxs)(`g`,{className:`fill-destructive/25`,children:[(0,L.jsx)(`ellipse`,{cx:19.5,cy:39.5,rx:2.6,ry:1.6}),(0,L.jsx)(`ellipse`,{cx:44.5,cy:39.5,rx:2.6,ry:1.6})]}):null,(0,L.jsx)(VG,{level:r,move:a}),r===`high`||r===`xhigh`?(0,L.jsx)(`path`,{d:`M20 27 L28.5 28.8 M44 27 L35.5 28.8`,strokeWidth:1.9,strokeLinecap:`round`,className:`stroke-foreground`}):null,(0,L.jsx)(HG,{level:r,move:a}),(0,L.jsx)(`rect`,{x:20,y:53,width:24,height:4,rx:2,className:d?void 0:`fill-primary/25`,style:d?{fill:`url(#${i}-rainbow)`}:void 0})]})},c.n),r===`off`?a?(0,L.jsx)(NG,{}):(0,L.jsx)(`text`,{x:48,y:14,fontSize:`9`,fontWeight:`700`,className:`fill-muted-foreground`,children:`z`}):null,a&&r===`minimal`?(0,L.jsx)(NG,{}):null,a&&r===`low`?(0,L.jsx)(PG,{}):null,a&&r===`medium`?(0,L.jsx)(FG,{}):null,a&&r===`high`?(0,L.jsx)(IG,{spots:[[6,14,0],[58,12,.6]]}):null,a&&r===`xhigh`?(0,L.jsx)(RG,{}):null,d?a?(0,L.jsx)(IG,{rainbow:!0,spots:[[5,12,0],[59,10,.2],[2,44,.45],[62,46,.65],[32,-2,.85],[14,60,1.05],[50,60,.3]]}):(0,L.jsx)(`g`,{children:[[5,12],[59,10],[32,-2]].map(([e,t],n)=>(0,L.jsx)(`path`,{d:kG,style:{x:e,y:t,fill:AG[n*2]}},n))}):null,a&&c.n>0&&c.up?(0,L.jsx)(BG,{rainbow:d},`burst-${c.n}`):null]})}var WG={minimal:`min`,medium:`med`},GG={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 KG(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 qG(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 JG({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),_=KG(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 KG(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:qG(t,n,r,1),ArrowUp:qG(t,n,r,1),ArrowLeft:qG(t,n,r,-1),ArrowDown:qG(t,n,r,-1),Home:KG(t,n,0),End:KG(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,L.jsxs)(`div`,{className:q(`flex flex-col gap-1`,a&&`opacity-60`),children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:GG[b]??``})]}),(0,L.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,L.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,L.jsx)(z.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,L.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,L.jsx)(z.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,L.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,L.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:WG[e]??e},e)})}),x?(0,L.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})}function YG(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function XG({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=>YG(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,L.jsxs)(fE,{open:o,onOpenChange:s,children:[(0,L.jsxs)(pE,{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(`btn-raised 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,L.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,L.jsx)(Wp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,L.jsx)(mE,{children:(0,L.jsxs)(hE,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`glass-pop z-50 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,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,L.jsx)(eg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.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,L.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,L.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,L.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})})]})}function ZG({label:e,help:t,children:n,stacked:r}){return(0,L.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,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,L.jsx)(`div`,{className:`min-w-0`,children:n})]})}function QG({children:e}){return(0,L.jsx)(`div`,{className:`card-raised flex flex-col divide-y divide-border rounded-xl border px-4 [&>*]:py-3`,children:e})}function $G({value:e,items:t,label:n,onChange:r}){return(0,L.jsx)(XG,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var eK=`(prefers-color-scheme: dark)`,tK=[`dark`,`light`,`system`],nK=m.createContext(void 0);function rK(e){return e!==null&&tK.includes(e)}function iK(){return window.matchMedia(eK).matches?`dark`:`light`}function aK(){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 oK(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function sK({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return rK(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`?iK():e,i=r?aK():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(eK),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||oK(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:iK()===`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(rK(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,L.jsx)(nK.Provider,{...i,value:l,children:e})}var cK=()=>{let e=m.useContext(nK);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},lK=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],uK={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},dK={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},fK=`inherit`,pK=`inherit`,mK=`Use the session's current model`,hK=`__custom__`,gK=`custom…`,_K=`Type a provider/model id`,vK=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],yK={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},bK=[{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`}],xK=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],SK=`shown on the Lobby tab`,CK=`Planning rounds`,wK=`how many rounds the panel gets before the oracle settles the rest alone`,TK=[2,3,5,8,0],EK=`Split long plans`,DK=`saving a plan with more steps offers to split it into up to 5 tasks`,OK=[6,8,10,12,0],kK=`Port`,AK=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,jK=`Open browser`,MK=`open this page in the browser when pi starts`,NK=[{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`}],PK=`Git isolation`,FK=[{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`}],IK={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`},LK=[{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`}],RK=[{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`}],zK={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`},BK={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`},VK=`https://tweakcn.com/editor/theme`;function HK(){let{theme:e}=cK();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function UK({palette:e,dark:t}){let n=le(e,t);return(0,L.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,L.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,L.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,L.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function WK(){let e=Ge(),t=HK(),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,L.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,L.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,L.jsx)(UK,{palette:n,dark:t}),(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,L.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,L.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function GK({entry:e}){let t=Ge(),[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),V.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,L.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,L.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,L.jsx)(TG,{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,L.jsx)(Y,{label:`Save the name`,text:`Save`,icon:Hp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,L.jsx)(Y,{label:`Keep the old name`,icon:Rg,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,L.jsx)(Y,{label:`Rename ${e.name}`,text:`Rename`,icon:Ih,onClick:()=>{a(e.name),r(!0)}}),(0,L.jsx)(ck,{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:bg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>V.error(e.message))})]}),o?(0,L.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function KK(){let e=Ge();return e.saved.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,L.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,L.jsx)(GK,{entry:e},e.id))})}function qK(){let e=Ge(),[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=te(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`;V.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,L.jsxs)(`div`,{className:`grid gap-2`,children:[(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,L.jsxs)(`a`,{href:VK,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,L.jsx)(Em,{"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,L.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,L.jsx)(TG,{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,L.jsx)(KO,{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=cz.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 uz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function dz({files:e}){return e.length===0?null:(0,L.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,L.jsx)(`li`,{children:uz.has(e.mime)?(0,L.jsx)(`a`,{href:N(`/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,L.jsx)(`img`,{src:N(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-56 object-cover`})}):(0,L.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,L.jsx)(Pm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,L.jsx)(Eh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var fz=!1,pz=[],mz=0,hz=900;function gz(){fz=!0,window.clearTimeout(mz),mz=window.setTimeout(_z,hz)}function _z(){fz=!1,window.clearTimeout(mz);let e=pz;pz=[];for(let t of e)t()}function vz(e){if(!fz)return e(),()=>{};let t=()=>e();return pz.push(t),()=>{pz=pz.filter(e=>e!==t)}}var yz=8;function bz(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=vz(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Rv.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*yz/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function xz(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(xz).join(``)}function Sz(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}),Sz(t,n)}function Cz(){return e=>Sz(e)}function wz(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await sz(e,navigator.clipboard),n(!0),V.success(`Code copied.`)}catch{V.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function Tz({text:e,children:t,block:n=!1}){let{copy:r}=wz(e),i=(0,m.useRef)(void 0);return(0,L.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(),oz(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),oz(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,L.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function Ez({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=wz(az(n,r?.position,!0)??xz(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,L.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,L.jsx)(Y,{label:i?`Copied`:`Copy the code`,icon:i?Hp:Sm,iconOnly:!0,onClick:()=>void a()})]}),(0,L.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 Dz(e){return{pre:t=>(0,L.jsx)(Ez,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,L.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,L.jsx)(Tz,{text:az(e,r?.position,i)??xz(r),block:i,children:n})},a:({href:e,children:t})=>(0,L.jsx)(`a`,{href:e?N(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,L.jsx)(`img`,{src:e?N(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,L.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var Oz=(0,m.memo)(function({text:e}){return(0,L.jsx)(GF,{remarkPlugins:[ZR],rehypePlugins:[Cz],urlTransform:$R,components:Dz(e),children:e})}),kz=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=lz(e),i=n?iz(n):[],a=bz(i.length,3);return(0,L.jsxs)(`div`,{className:q(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,L.jsx)(Oz,{text:e},t)),(0,L.jsx)(dz,{files:r})]})});function Az({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,L.jsxs)(`section`,{className:q(`group/frame relative flex min-h-0 min-w-0 flex-col`,i&&`flex-none`,n),...s,children:[e||t||a?(0,L.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,L.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,L.jsx)(`span`,{}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,L.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,L.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,L.jsx)(ED,{chord:o,className:`kbd-hint`}):null,(0,L.jsx)(Wp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function jz({title:e,right:t,className:n}){return(0,L.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,L.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function Mz({title:e,right:t,prominent:n,children:r}){return(0,L.jsxs)(`section`,{className:q(`flex flex-col`,n?`gap-3`:`gap-2.5`),children:[(0,L.jsx)(`h3`,{className:n?`text-sm text-foreground`:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var Nz=`Pull requests`,Pz=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,Fz=`nothing is posted to GitHub`,Iz=`Refresh to load open pull requests with the GitHub CLI (gh).`,Lz=`No open pull requests.`,Rz=`loading pull requests from GitHub…`,zz=`reading the diff…`,Bz=`the pull request has new commits since this review — review it again`,Vz=`(no description)`,Hz=`Review with a focus (optional)`,Uz=`Leave it empty for a full review.`;function Wz(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function Gz(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function Kz(e,t){return`+${e} −${t}`}function qz(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function Jz(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function Yz(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function Xz(e,t){if(e.status===`running`)return Zz(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?Zz(e,t):e.status;return[Yz(e.verdict),n].filter(Boolean).join(` · `)}function Zz(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 Qz(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${ZO(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function $z(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${Kz(e.additions,e.deletions)} · ${t}`}function eB(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,qz(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function tB(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function nB(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function rB(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 iB({pull:e,now:t}){return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Qz(e,t)}),(0,L.jsx)(`p`,{className:`text-sm tabular-nums`,children:$z(e)}),eB(e)?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:eB(e)}):null,e.url?(0,L.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 aB({read:e}){return(0,L.jsxs)(Mz,{title:`Jev's read`,right:nB(e),children:[e.status===`running`?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),zz]}):null,e.status===`failed`?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,L.jsx)(kz,{text:e.line}):null]})}function oB({review:e,now:t}){return(0,L.jsxs)(L.Fragment,{children:[e.model?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,ZO(t-e.startedAt)]}):null,e.stale?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:Bz}):null,e.status===`running`?(0,L.jsx)(sB,{steps:e.steps}):null,e.status===`cancelled`?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,L.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,L.jsx)(kz,{text:e.text}):null]})}function sB({steps:e}){return(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,L.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function cB({number:e,focus:t,onChange:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:Hz}),(0,L.jsx)(KO,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,onChange:e=>n(e.target.value)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Uz})]})}function lB({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,L.jsxs)(Mz,{title:`Review`,right:t?Xz(t,n):void 0,children:[t?(0,L.jsx)(oB,{review:t,now:n}):null,(0,L.jsx)(cB,{number:e,focus:r,onChange:i}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,Fz,`.`]})]})}function uB({files:e}){return(0,L.jsx)(Mz,{title:`Files`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,L.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:Kz(e.additions,e.deletions)})]},e.path))})})})})}function dB({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?ZO(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,L.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,L.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,L.jsx)(kz,{text:e.body.trim()}):null]})}function fB({notes:e,now:t}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Discussion`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,L.jsx)(dB,{note:e,now:t},n))})})}function pB({number:e,error:t}){return t?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),`loading #`,e,`…`]})}function mB({number:e,onChanged:t}){let n=sO(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=rB(a);if(!n.data)return(0,L.jsx)(pB,{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 H(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await H(`git.jev`,{number:e}),u()},p=async()=>{await H(`git.cancelReview`,{number:e}),u()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Review`,icon:Rh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,L.jsx)(Y,{label:`Jev's read`,icon:Ip,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,L.jsx)(ck,{icon:um,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,L.jsx)(iB,{pull:s,now:o}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Pz}),l?(0,L.jsx)(aB,{read:l}):null,(0,L.jsx)(lB,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,L.jsx)(uB,{files:s.files}):null,(0,L.jsx)(Mz,{title:`Description`,children:s.body.trim()?(0,L.jsx)(kz,{text:s.body.trim()}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Vz})}),(0,L.jsx)(fB,{notes:s.notes,now:o})]})}var hB=Gg(`group/badge inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-lg border border-transparent px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/40 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-accent text-foreground [a]:hover:bg-primary/20`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-accent`,destructive:`bg-destructive/12 text-destructive [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-accent`,ghost:`hover:bg-accent hover:text-foreground`,link:`text-link underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function gB({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?Tv:`span`;return(0,L.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:q(hB({variant:t}),e),...r})}var _B=`flex min-h-10 w-full flex-col gap-0.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:bg-accent`,vB=`flex flex-col gap-0.5 px-2 pb-2`,yB=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function bB({checks:e}){let t=Wz(e);return t?(0,L.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,Gz(e)),"aria-hidden":`true`,children:t}):(0,L.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function xB({pull:e,selected:t,onSelect:n}){let r=Jz(e.review);return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,L.jsx)(bB,{checks:e.checks}),e.draft?(0,L.jsx)(gB,{variant:`secondary`,children:`draft`}):null,(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:tB(e)}),(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,L.jsx)(`span`,{children:r}):null,(0,L.jsx)(`span`,{className:`tabular-nums`,children:Kz(e.additions,e.deletions)})]})]})]})})}function SB({pulls:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(xB,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var CB=()=>GD(WD(`git`)),wB=e=>GD(WD(`git`,String(e)));function TB(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function EB({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?Lz:e?Rz:Iz;return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Rm,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,L.jsx)(J,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function DB({rest:e}){let t=BO(),n=sO(`git.pulls`,{},[`git`]),r=TB(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{H(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,L.jsx)(EB,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:Nz,count:n.data?`${i.length} open`:void 0,children:(0,L.jsx)(Y,{label:`Refresh`,icon:Hh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,L.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,L.jsx)(SB,{pulls:i,selectedId:r,onSelect:wB}):(0,L.jsx)(GO,{})]}),c=r===void 0?null:(0,L.jsx)(mB,{number:r,onChanged:n.reload},r);return(0,L.jsx)(UO,{wide:t,list:s,detail:c,open:r!==void 0,onClose:CB,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function OB(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function kB({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,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,L.jsx)(KO,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{OB(e)&&(e.preventDefault(),l())}}),t?(0,L.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,L.jsx)(`div`,{className:`flex self-end`,children:(0,L.jsx)(Y,{label:n,icon:s?Qm:Pp,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var AB=`Issues`,jB=`Issue`,MB=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,NB=`Refresh to load open issues with the GitHub CLI (gh).`,PB=`No open issues. File one with New issue.`,FB=`loading issues from GitHub…`,IB=`issues are off (lobby.issues)`,LB=`(no description)`;function RB(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${ZO(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function zB(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?ZO(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function BB(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function VB({issue:e,now:t}){return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:RB(e,t)}),e.url?(0,L.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 HB({comment:e,now:t}){return(0,L.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,L.jsx)(`span`,{children:ZO(t-Date.parse(e.createdAt))}):null]}),(0,L.jsx)(kz,{text:e.body.trim()})]})}function UB({comments:e,now:t}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Comments`,right:String(e.length),children:(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,L.jsx)(HB,{comment:e,now:t},n))})})}function WB({issue:e}){let t=async()=>{await H(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&GD(WD(`plan`))};return(0,L.jsx)(ck,{icon:Ig,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 GB({number:e}){let t=sO(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${jB} #${e}`,children:[(0,L.jsx)(jO,{children:(0,L.jsx)(WB,{issue:r})}),(0,L.jsx)(VB,{issue:r,now:n}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:MB}),(0,L.jsx)(Mz,{title:`Description`,children:r.body.trim()?(0,L.jsx)(kz,{text:r.body.trim()}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:LB})}),(0,L.jsx)(UB,{comments:r.comments,now:n})]})}function KB({issue:e,selected:t,now:n,onSelect:r}){let i=BB(e.labels);return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,L.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,L.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:zB(e,n)})]})})}function qB({issues:e,selectedId:t,now:n,onSelect:r}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(KB,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var JB=()=>GD(WD(`issues`)),YB=e=>GD(WD(`issues`,String(e)));function XB(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function ZB(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(om,{"aria-hidden":`true`})}),(0,L.jsx)(ZD,{children:`Issues are off`}),(0,L.jsx)(QD,{className:`font-mono`,children:IB})]})})}function QB({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?PB:e?FB:NB;return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(om,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,L.jsx)(J,{variant:`outline`,onClick:r,children:`Retry`}):null]})}function $B({onCreate:e}){return(0,L.jsx)(VO,{className:`shrink-0 border-t border-border p-4`,children:(0,L.jsx)(kB,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function eV({rest:e}){let t=BO(),n=aO(`status`).data?.issuesEnabled??!0,r=sO(`issues.list`,{},[`issues`],n),i=XB(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{H(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await H(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,L.jsx)(ZB,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,L.jsx)(ZB,{}):(0,L.jsx)(tO,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:AB,count:r.data?`${a.length} open`:void 0,children:(0,L.jsx)(Y,{label:`Refresh`,icon:Hh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,L.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,L.jsx)(qB,{issues:a,selectedId:i,now:o,onSelect:YB}):(0,L.jsx)(GO,{}),(0,L.jsx)($B,{onCreate:c})]}),d=i===void 0?null:(0,L.jsx)(GB,{number:i},i),f=r.data&&a.length===0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(QB,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,L.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,L.jsx)($B,{onCreate:c})})]}):(0,L.jsx)(UO,{wide:t,list:u,detail:d,open:i!==void 0,onClose:JB,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function tV(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 nV={DEV:vm,DESIGN:Sh,QA:ig,RESEARCH:gg,"QUICK FIX":Bg,SCOUT:bm,PLANNER:Xh,CLASSIFIER:mg,LOBBY:uh,LINT:Jm};function rV(e){return e?nV[e.toUpperCase()]??Rp:Bp}function iV(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function aV({source:e,className:t,strokeWidth:n}){if(iV(e))return(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=rV(e);return(0,L.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var oV={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 sV(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function cV(e){return oV[e]??`text-muted-foreground`}var lV={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 uV(e){return lV[e]??`var(--muted-foreground)`}function dV(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 fV(e){return e?.runs??[]}function pV(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 mV({source:e,live:t}){let n=iV(e);return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":uV(e)},children:(0,L.jsx)(aV,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function hV({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,L.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,L.jsx)(`div`,{className:`chat-gutter`,children:r?(0,L.jsx)(mV,{source:e,live:i}):n?(0,L.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,L.jsxs)(`p`,{className:`chat-speaker`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,L.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,L.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,L.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":uV(e)},children:a}):a]})]})}function gV({time:e,head:t,note:n,children:r,below:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,L.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,L.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,L.jsx)(`span`,{children:n}):null]}):null,(0,L.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function _V({failed:e,children:t}){return(0,L.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,L.jsx)(`span`,{children:t})})}function vV({className:e}){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]})}var yV=3e5,bV=`No task is running in this session.`,xV=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,SV=`Nothing said yet. Type below to talk to the oracle about this task.`;function CV({entry:e}){return(0,L.jsxs)(_V,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${JO(e.at)}`:``]})}function wV({entry:e,head:t}){if(e.role===`you`)return(0,L.jsx)(gV,{time:JO(e.at),head:t,children:(0,L.jsx)(kz,{text:e.text})});let n=e.role===`panel`;return(0,L.jsx)(hV,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:JO(e.at),head:t,children:(0,L.jsx)(kz,{text:e.text})})}var TV=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,L.jsx)(z.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,L.jsx)(CV,{entry:e}):(0,L.jsx)(wV,{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 EV({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,L.jsx)(hV,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,L.jsx)(kz,{text:e??``}):(0,L.jsx)(vV,{className:`mt-1`})})}function DV({hasTask:e}){return(0,L.jsxs)(qD,{className:`h-full border-0`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(ch,{"aria-hidden":`true`})}),e?null:(0,L.jsx)(ZD,{children:bV}),(0,L.jsx)(QD,{children:e?SV:xV})]}),e?null:(0,L.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,L.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,L.jsx)(ED,{chord:`3`}),` Plan`]}),(0,L.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,L.jsx)(ED,{chord:`4`}),` Quick fix`]})]})]})}async function OV(e){let t=await De(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function kV(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 OV(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 AV({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i}){let{ref:a,atBottom:o,stick:s,onScroll:c}=tV(e.length+(t?.length??0)),{merged:l,more:u,loading:d,load:f}=kV(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,L.jsxs)(Az,{"aria-label":`Conversation`,className:`flex-1`,children:[(0,L.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,L.jsx)(DV,{hasTask:i}):(0,L.jsxs)(`div`,{className:`chat-column`,children:[u?(0,L.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>yV;return(0,L.jsx)(TV,{entry:e,head:r,fresh:g},e.id)}),(0,L.jsx)(EV,{text:t,busy:n})]})}),o?null:(0,L.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,L.jsx)(Y,{label:`Jump to latest`,text:`Latest`,icon:Op,tone:`primary`,className:`rounded-full shadow-sm`,onClick:s})})]})}var jV=[`master`,`designer`,`backend`,`qa`],MV={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},NV={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},PV=`Every write archives the version before it.`;function FV(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function IV(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function LV(e){return{text:e.text,occurrence:e.occurrence}}function RV(e){return jV.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 zV(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function BV({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,L.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,L.jsx)(KO,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{zV(e)&&(e.preventDefault(),o())}}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:PV}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:r,disabled:t,children:`Cancel`}),(0,L.jsxs)(J,{onClick:o,disabled:t||!i.trim(),children:[t?(0,L.jsx)($D,{}):null,`Save`]})]})]})]})}function VV({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=ID(e,FD.confirm);return(0,L.jsx)(OD,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:PV,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:PV})]}),(0,L.jsx)(KO,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:i,disabled:r,children:`Cancel`}),(0,L.jsxs)(J,{onClick:()=>a(o),disabled:r,children:[r?(0,L.jsx)($D,{}):null,`Save file`]})]})]})})}function HV({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,L.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(Mh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,L.jsx)(Y,{label:`Take the note back`,icon:wg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function UV({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,L.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,L.jsx)(`div`,{className:`flex gap-2`,children:(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(kz,{text:e.text})})}),r.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,L.jsx)(HV,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function WV({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Notes on entries that changed`,right:String(e.length),children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,L.jsx)(HV,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function GV({view:e}){let t=e.entries.length;return(0,L.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:[NV[e.agent],` `,(0,L.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,FV(e.chars),` chars`]}),e.over?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:IV(e.file)}):null]})}function KV({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Edit the entry`,text:`Edit`,icon:Ih,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,L.jsx)(Y,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Bh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,L.jsx)(Y,{label:`Comment on the entry`,text:`Comment`,icon:oh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,L.jsx)(Y,{label:`Edit the whole file`,text:`Edit file`,icon:Am,shortcut:`F`,disabled:a,onClick:r}),(0,L.jsx)(ck,{icon:bg,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 qV({agent:e,file:t,onChanged:n}){let r=sO(`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(()=>H(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>H(`knowledge.remove`,{agent:e,file:t,ref:LV(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>H(`knowledge.edit`,{agent:e,file:t,ref:LV(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>H(`knowledge.comment`,{agent:e,file:t,ref:LV(r),text:n}));g(()=>H(`knowledge.add`,{agent:e,file:t,...h?{ref:LV(h)}:{},text:n}))};return f?(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${NV[e]} ${t}`,children:[(0,L.jsx)(KV,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,L.jsx)(GV,{view:f}),p.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,L.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map((e,t)=>(0,L.jsx)(UV,{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,L.jsx)(BV,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,L.jsx)(kB,{label:`Comment on this entry`,hint:PV,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,L.jsx)(kB,{label:`Add an entry`,hint:PV,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{}),` saving…`]}):null,(0,L.jsx)(WV,{notes:f.detached,onTakeBack:_,busy:u}),(0,L.jsx)(VV,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>H(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function JV(e){return`${e.agent}/${e.file}`}var YV={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},XV=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function ZV({info:e}){return(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`span`,{children:FV(e.chars)}),e.over?(0,L.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,L.jsx)(`span`,{className:`text-primary`,children:XV(e.notes,`note`)}):null]})}function QV({info:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{className:`ktree-leaf`,children:(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(JV(e)),className:q(_B,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,L.jsx)(ZV,{info:e})]})})}var $V=`bot-lobby.knowledge.folded`;function eH(){try{let e=JSON.parse(window.localStorage.getItem($V)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function tH({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(eH),o=RV(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($V,JSON.stringify(r))}catch{}return r})}return(0,L.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,L.jsxs)(`p`,{className:`ktree-root`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,L.jsx)(Ip,{className:`size-4`})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[XV(e.length,`file`),` · `,XV(o.length,`agent`),s>0?` · ${XV(s,`note`)}`:``]})]})]}),(0,L.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=YV[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,L.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":uV(o)},children:[(0,L.jsx)(`h3`,{children:(0,L.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,L.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,L.jsx)(aV,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:MV[e.agent]}),l?(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,L.jsxs)(`span`,{className:`text-primary`,children:[XV(e.notes,`note`),` · `]}):null,XV(e.files.length,`file`)]}),(0,L.jsx)(Jp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,L.jsx)(Ou,{initial:!1,children:a?(0,L.jsx)(z.ul,{id:s,"aria-label":`${MV[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,L.jsx)(QV,{info:e,selected:JV(e)===n,onSelect:r},JV(e)))},`files`):null})]},e.agent)})})]})}var nH=()=>GD(WD(`knowledge`)),rH=e=>{let[t,n]=e.split(`/`);GD(WD(`knowledge`,t??``,n??``))};function iH(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Ip,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{children:`No knowledge files yet.`})]})})}function aH(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,L.jsx)(qV,{agent:i.agent,file:i.file,onChanged:r},JV(i)):t&&n?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function oH({agent:e,file:t}){let n=BO(),r=sO(`knowledge.files`,{},[`knowledge`]),i=r.data?.files??[];if(!r.data&&r.error)return(0,L.jsx)(tO,{message:`Could not load the knowledge files. ${r.error}`,onRetry:r.reload});if(r.data&&i.length===0)return(0,L.jsx)(iH,{});let a=i.reduce((e,t)=>e+t.notes,0),o=i.find(n=>n.agent===e&&n.file===t),s=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Knowledge`,count:a>0?`${a} note${a===1?``:`s`}`:void 0}),r.data?(0,L.jsx)(tH,{files:i,models:r.data.models??{},selectedKey:o?JV(o):void 0,onSelect:rH}):(0,L.jsx)(GO,{})]});return(0,L.jsx)(UO,{wide:n,list:s,detail:aH(i,e,t,r.reload),open:!!(e&&t),onClose:nH,hint:`Select a file to read its entries.`,describe:`Knowledge file`})}function sH({agent:e,file:t}){let n=e===`ask`,r=aO(`lobby`),i=aO(`status`),a=r.data,o=i.data?.busy??!1,s=!a?.chat.length&&!a?.reply&&!o;return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Ask about the project`,text:`Ask`,icon:ch,pressed:n,onClick:()=>GD(WD(`knowledge`,`ask`))}),(0,L.jsx)(Y,{label:`Browse knowledge files`,text:`Files`,icon:Ip,pressed:!n,onClick:nH})]}),n?s?(0,L.jsx)(`p`,{className:`m-auto max-w-md px-5 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,L.jsx)(AV,{chat:a?.chat??[],reply:a?.reply,busy:o,hasOlder:a?.hasOlderChat??!1,hasTask:!!a?.task}):(0,L.jsx)(oH,{agent:e,file:t})]})}function cH({className:e,...t}){return(0,L.jsx)($S,{"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,L.jsx)(tC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var lH=`Sessions`,uH=`No sessions yet.`,dH=`Up to 5 sessions; each can be assigned to one agent or several.`,fH=`A session is a live Excalidraw room that you and your agents draw in together.`,pH=[{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.`}],mH=`Sessions`,hH=`Pick a session on the left to see its link, its room and its agents.`,gH=`Room link`,_H=`Masked until revealed. A revealed link stays in this tab and is never saved.`,vH=`Room`,yH=`Drawing`,bH=`Last check`,xH=`not checked yet`,SH=`Add a session`,CH=`https://excalidraw.com/#room=…`,wH=`Optional name`;function TH(e){return`${e} of 5 in use`}var EH=`Agents may draw here.`,DH=`Agents may only look.`,OH=`checking the room…`,kH=`Check that the room can be reached.`,AH=`Assigned to`,jH=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,MH=`Add or rename`,NH=`Add by link`,PH=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,FH=`New room`,IH=`Makes a fresh room link to open in Excalidraw; the name is optional.`,LH=`Rename`,RH=`draw`,zH=`look only`,BH=`Copied to the clipboard`,VH=`Could not reveal the link.`,HH=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],UH={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function WH(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function GH(e){return e?e.ok?`✓`:`!`:``}function KH({title:e,right:t,className:n,children:r}){return(0,L.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,L.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function qH({row:e=!1}){return(0,L.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:pH.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function JH({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,L.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,L.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.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,L.jsx)(Y,{type:`submit`,label:n,icon:f?Qm:Bh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,L.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function YH({onChanged:e,primary:t}){return(0,L.jsx)(JH,{label:NH,hint:PH,buttonLabel:`Add`,placeholder:CH,required:!0,mono:!0,primary:t,onSubmit:async t=>await H(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function XH({onChanged:e,primary:t}){return(0,L.jsx)(JH,{label:FH,hint:IH,buttonLabel:`Create`,placeholder:wH,primary:t,onSubmit:async t=>{let n=t.trim();return await H(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function ZH({onChanged:e,stacked:t=!1}){return(0,L.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,L.jsx)(YH,{onChanged:e,primary:!0}),(0,L.jsx)(XH,{onChanged:e,primary:!0})]})}function QH({session:e,onChanged:t}){return(0,L.jsx)(JH,{label:LH,initial:e.name,required:!0,buttonLabel:LH,onSubmit:async n=>await H(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function $H({icon:e,tone:t=`muted`,children:n}){return(0,L.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,L.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function eU({check:e,checking:t}){return t?(0,L.jsx)($H,{icon:Qm,children:OH}):e?e.ok?(0,L.jsx)($H,{icon:nm,tone:`primary`,children:`reachable`}):(0,L.jsx)($H,{icon:em,tone:`warning`,children:`unreachable`}):(0,L.jsx)($H,{icon:im,children:xH})}function tU({label:e,children:t}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm`,children:[(0,L.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsx)(`dd`,{className:`min-w-0`,children:t})]})}function nU({check:e,checking:t}){return t?(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}),OH]}):e?(0,L.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:kH})}function rU({agent:e,on:t,onToggle:n}){return(0,L.jsx)(`li`,{children:(0,L.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,L.jsx)(cH,{checked:t,onCheckedChange:()=>n(e)}),(0,L.jsx)(`span`,{className:`truncate`,children:UH[e]})]})})}function iU({session:e,onChanged:t}){let n=async n=>{await H(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await H(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===HH.length;return(0,L.jsxs)(KH,{title:AH,right:WH(e.agents.length),children:[(0,L.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:HH.map(t=>(0,L.jsx)(rU,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:jH}),(0,L.jsx)(Y,{label:i?`Take every agent off`:`Assign every agent`,icon:Jm,onClick:()=>void r()})]})]})}function aU({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await De(`excalidraw.reveal`,{id:e.id})).link)}catch(e){V.error(e instanceof Error?e.message:VH)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>V(BH)).catch(()=>void 0),u=async()=>{await H(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,L.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,L.jsxs)(jO,{children:[o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Y,{label:`Copy the link`,text:`Copy`,icon:Sm,shortcut:`C`,onClick:l}),(0,L.jsx)(Y,{label:`Open board`,icon:Em,tone:`primary`,shortcut:`O`,href:o})]}):(0,L.jsx)(Y,{label:`Reveal the link`,text:`Reveal`,icon:Om,shortcut:`R`,onClick:()=>void c()}),(0,L.jsx)(Y,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?Ph:Ih,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,L.jsx)(Y,{label:`Check the room`,text:`Check`,icon:n?Qm:ig,shortcut:`T`,disabled:n,onClick:r}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,L.jsx)($H,{icon:e.contribute?Ih:Om,tone:e.contribute?`primary`:`muted`,children:e.contribute?RH:zH}),(0,L.jsx)($H,{icon:Og,children:WH(e.agents.length)}),(0,L.jsx)(eU,{check:t,checking:n})]})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,L.jsxs)(KH,{title:gH,children:[(0,L.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,L.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:_H})]}),(0,L.jsx)(KH,{title:vH,children:(0,L.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(tU,{label:yH,children:(0,L.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?EH:DH})}),(0,L.jsx)(tU,{label:bH,children:(0,L.jsx)(nU,{check:t,checking:n})})]})})]}),(0,L.jsx)(iU,{session:e,onChanged:i})]}),(0,L.jsx)(KH,{title:MH,children:(0,L.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,L.jsx)(QH,{session:e,onChanged:i}),(0,L.jsx)(YH,{onChanged:i}),(0,L.jsx)(XH,{onChanged:i})]})})]})}function oU({check:e,checking:t}){if(t)return(0,L.jsx)($D,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=GH(e);return n?(0,L.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,L.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function sU({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,L.jsx)(oU,{check:t,checking:n}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:WH(e.agents.length)})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,L.jsx)(gB,{variant:`secondary`,children:e.contribute?RH:zH})]})]})})}function cU({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(sU,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var lU=()=>GD(WD(`excalidraw`)),uU=e=>GD(WD(`excalidraw`,e));function dU({count:e}){return(0,L.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,L.jsx)(`span`,{className:`tabular-nums`,children:TH(e)})]})}function fU({count:e,onChanged:t}){return(0,L.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:mH}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:hH})]}),(0,L.jsx)(dU,{count:e})]}),(0,L.jsx)(qH,{row:!0}),e<5?(0,L.jsx)(KH,{title:SH,children:(0,L.jsx)(ZH,{onChanged:t})}):null,(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,L.jsx)(DD,{chord:`ArrowDown`,children:`next session`}),(0,L.jsx)(DD,{chord:`ArrowRight`,children:`into its detail`})]})]})}function pU({onChanged:e}){return(0,L.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock sm:px-8`,children:(0,L.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,L.jsx)(Ah,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:uH}),(0,L.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:fH})]}),(0,L.jsx)(qH,{}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:dH})]}),(0,L.jsx)(KH,{title:SH,className:`self-start`,children:(0,L.jsx)(ZH,{onChanged:e,stacked:!0})})]})})}function mU({id:e}){let t=BO(),n=sO(`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 H(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await H(`excalidraw.remove`,{id:c.id})&&(n.reload(),lU())};if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,L.jsx)(pU,{onChanged:n.reload});let d=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:lH,count:n.data?`${s.length}/5`:void 0}),n.data?(0,L.jsx)(cU,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:uU}):(0,L.jsx)(GO,{})]}),f=c?(0,L.jsx)(aU,{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,L.jsx)(fU,{count:s.length,onChanged:n.reload}):null;return(0,L.jsx)(UO,{wide:t,list:d,detail:f,open:c!==void 0,onClose:lU,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function hU(e,t){return e===`lobby.thinking`||t===`1`}var gU=`bot-lobby.collapsed.`,_U=new Set,vU=new Map;function yU(e){if(vU.has(e))return vU.get(e);if(e===`lobby.thinking`)return hU(e);try{return hU(e,localStorage.getItem(gU+e))}catch{return!1}}function bU(e,t){vU.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(gU+e,t?`1`:`0`)}catch{}for(let e of[..._U])e()}function xU(e){return _U.add(e),()=>{_U.delete(e)}}function SU(e){bU(e,!yU(e))}function CU(e){return[(0,m.useSyncExternalStore)(xU,()=>yU(e),()=>hU(e)),(0,m.useCallback)(()=>bU(e,!yU(e)),[e])]}function wU({entry:e}){return e.pending?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,L.jsx)(Sg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function TU({entry:e}){return(0,L.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,L.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:JO(e.at)}),(0,L.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,cV(e.source)),children:sV(e.source)}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,L.jsx)(wU,{entry:e})}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,L.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 EU({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}=tV(JSON.stringify(a));return(0,L.jsxs)(Az,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,L.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,L.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,L.jsx)(`ul`,{children:a.map(e=>(0,L.jsx)(TU,{entry:e},e.id))})}),c?null:(0,L.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,L.jsx)(Y,{label:`Jump to latest`,text:`Latest`,icon:Op,className:`rounded-full bg-card shadow-card`,onClick:l})})]})}function DU(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 OU(e){return e===`running`?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):e===`success`?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):e===`failed`||e===`timeout`||e===`error`?(0,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`})}function kU(e,t){let n=e.startedAt?Date.parse(e.startedAt):NaN;return YO((e.finishedAt?Date.parse(e.finishedAt):t)-n)}function AU({runs:e}){let t=DU(e.some(e=>e.status===`running`));return e.length===0?null:(0,L.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,L.jsxs)(`li`,{className:`flex items-center gap-2 rounded-full bg-muted py-1 pr-3 pl-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:OU(e.status)}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.status??`unknown`}),(0,L.jsx)(`span`,{className:q(`font-medium`,cV(dV(e))),children:sV(dV(e))}),e.activity??e.step?(0,L.jsx)(`span`,{className:`max-w-[18rem] truncate text-muted-foreground`,children:e.activity??e.step}):null,(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:kU(e,t)})]},e.runId??n))})}function jU(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 MU(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 NU(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 PU=8;function FU(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function IU(e,t){let n=Math.min(t,PU);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 LU({done:e,total:t}){return(0,L.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:IU(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function RU({check:e,className:t}){return(0,L.jsx)(e===`done`?nm:e===`dropped`?fm:mm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function zU({children:e}){return(0,L.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function BU({ms:e,running:t,sample:n}){let r=NU(t,n);return(0,L.jsx)(`span`,{className:`tabular-nums`,children:MU(e+r)})}function VU({work:e}){return(0,L.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,L.jsx)(vg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,L.jsx)(BU,{ms:e.workedMs,running:e.running,sample:e})]})}function HU({active:e,current:t}){let n=e?.[0];return n?(0,L.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,L.jsx)(`span`,{className:`truncate text-foreground`,children:n.text}),(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,L.jsx)(BU,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]}):t?(0,L.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,L.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function UU({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,L.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,L.jsx)(z.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,L.jsx)(HU,{...r?{active:r}:{},...n?{current:n}:{}})]})}function WU({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,L.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,L.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,L.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,L.jsx)(zU,{children:e.id}),e.track?(0,L.jsx)(zU,{children:FU(e.track)}):null,(e.domains??[]).length>0?(0,L.jsx)(zU,{children:e.domains.join(`, `)}):null,r?(0,L.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,L.jsx)(Im,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,L.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,L.jsx)(VU,{work:e.work}):null,e.progress?(0,L.jsx)(UU,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var GU=(e,t)=>e?.keys.find(e=>e.action===t)?.label,KU=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function qU({name:e,icon:t,shortcut:n,onClick:r}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsxs)(dO,{side:`left`,children:[`Expand `,e,n?(0,L.jsx)(ED,{chord:n}):null]})]})}function JU(e){let t=KU(e.status);return(0,L.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,L.jsx)(qU,{name:`Activity`,icon:Sp,shortcut:GU(e.status,`activity`),onClick:e.toggleActivity}):null})}function YU(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=KU(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,L.jsxs)(`div`,{className:q(`grid min-h-0 flex-1`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)] divide-x divide-border`:`grid-cols-1`),children:[a.conversation?(0,L.jsx)(AV,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,L.jsx)(EU,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:GU(n,`activity`)}):null]})}function XU(e){let{status:t}=e,n=KU(t).activity&&e.activityFolded;return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,L.jsx)(YU,{...e})}),n?(0,L.jsx)(JU,{...e}):null]})}function ZU({data:e,status:t}){let n=KU(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ch}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:Sp}]:[]],[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,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,L.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,L.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,L.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,L.jsx)(AV,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task}):null,o.id===`activity`?(0,L.jsx)(EU,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function QU(e){let{data:t,status:n}=e,r=BO();return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,L.jsx)(WU,{task:t?.task,status:n}),(0,L.jsx)(AU,{runs:fV(t)})]}),r?(0,L.jsx)(XU,{...e}):(0,L.jsx)(ZU,{...e})]})}function $U(){let e=aO(`lobby`),t=aO(`status`),[n,r]=CU(`lobby.activity`);return!e.data&&e.loading?(0,L.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)($D,{}),(0,L.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,L.jsx)(tO,{message:e.error,onRetry:()=>me.onHello({})}):(0,L.jsx)(QU,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var eW={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function tW(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 nW(e){return e>0?tW(e):`—`}function rW(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function iW(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function aW(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 oW(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function sW(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function cW(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function lW(e,t){let n=t===`model-kind`?eW[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var uW=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],dW={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 fW(e){let t=dW[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%uW.length;return uW[n]??uW[0]}function pW(e){return eW[e]??e}var mW=6;function hW({title:e,right:t,children:n}){return(0,L.jsxs)(`section`,{className:`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,"aria-label":e,children:[(0,L.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-medium`,children:[(0,L.jsx)(`span`,{children:e}),t?(0,L.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]}),n]})}function gW({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,mW);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>mW?(0,L.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 _W(e,t){return t>0?Math.max(1.5,e/t*100):0}function vW({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,L.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,L.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,L.jsxs)(`div`,{className:`relative h-1.5 rounded-full bg-muted`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,L.jsx)(`div`,{className:`h-full rounded-full bg-primary/70`,style:{width:`${_W(t,r)}%`}}),n?(0,L.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,_W(n,r))}%`}}):null]})]})}function yW({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,L.jsx)(hW,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,L.jsx)(gW,{rows:n,render:e=>(0,L.jsx)(vW,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:nW(e.avgMs),sub:`p90 ${nW(e.p90Ms)}`},t(e))})})}var bW={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},xW={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function SW({label:e,rate:t,runs:n}){let r=sW(t),i=`${Math.round(t*100)}%`;return(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 ${xW[r.tone]}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${bW[r.tone]}`}),(0,L.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,L.jsxs)(`div`,{className:`flex h-1.5 overflow-hidden rounded-full bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,L.jsx)(`div`,{className:`h-full bg-success/70`,style:{width:`${t*100}%`}}),(0,L.jsx)(`div`,{className:`h-full bg-destructive/45`,style:{width:`${(1-t)*100}%`}})]})]})}function CW({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,L.jsx)(hW,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,L.jsx)(gW,{rows:n,render:e=>(0,L.jsx)(SW,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function wW({share:e}){return(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${fW(e.agent)}`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-[0.8125rem]`,children:sV(e.agent)}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,L.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,tW(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function TW({share:e}){return(0,L.jsx)(`div`,{className:`flex h-2.5 gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,L.jsx)(`span`,{className:`${fW(e.agent)} opacity-75 first:rounded-l-full last:rounded-r-full`,style:{width:`${e.share*100}%`},title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function EW({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,L.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,L.jsx)(gW,{rows:e,render:e=>(0,L.jsx)(vW,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:tW(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function DW({timeShare:e}){let t=e.byAgent;return(0,L.jsx)(hW,{title:`Where the time goes`,right:`share of run time by agent`,children:t.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(TW,{share:t}),(0,L.jsx)(wW,{share:t}),(0,L.jsx)(EW,{times:e.taskTimes})]})})}function OW({label:e,value:t,sub:n}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var kW=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function AW({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,L.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,L.jsx)(OW,{label:`Calls`,value:kW(e.calls,`call`),sub:`${rW(e.ok,e.calls)} ok`}),(0,L.jsx)(OW,{label:`Speed`,value:`p50 ${oW(e.p50Ms)}`,sub:`p90 ${oW(e.p90Ms)}`}),(0,L.jsx)(OW,{label:`Read`,value:e.input>0?`${aW(e.input)} tokens`:`—`}),(0,L.jsx)(OW,{label:`Routed down`,value:e.routed>0?kW(e.routed,`run`):`none`,sub:e.routed>0?`${rW(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,kW(e.seatRunsSkipped,`seat run`),` skipped · `,kW(e.questionsAnswered,`question`),` answered · `,kW(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,L.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var jW=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function MW(e,t=0){return e>0?e.toFixed(t):`—`}function NW(e){return[String(e.runs),rW(e.successes,e.runs),nW(e.avgMs),nW(e.p50Ms),nW(e.p90Ms),MW(e.avgTurns,1),MW(e.avgTools,1),e.avgTokens>0?aW(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,iW(e.avgCost),iW(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function PW(e,t){return t===`model-kind`?pW(e.kinds[0]??``):e.kinds.map(pW).join(`, `)}function FW({groups:e,groupBy:t}){return(0,L.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,L.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,L.jsx)(`span`,{children:`All models`}),(0,L.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,L.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,L.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),jW.map(e=>(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,L.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,L.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:PW(e,t)||`—`}),NW(e).map((e,t)=>(0,L.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},jW[t]))]},lW(e,t)))})]})})]})}var IW={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function LW({label:e,value:t,sub:n,dot:r}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 bg-card px-4 py-3.5`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${IW[r.tone]}`}),(0,L.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function RW({tiles:e}){let t=sW(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-xl border border-border bg-border shadow-card sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,L.jsx)(LW,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,L.jsx)(LW,{label:`Success`,value:rW(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,L.jsx)(LW,{label:`Avg run`,value:nW(e.avgMs),sub:`p90 ${nW(e.p90Ms)}`}),(0,L.jsx)(LW,{label:`Cost`,value:iW(e.cost),sub:e.runs>0?`${iW(e.cost/e.runs)} per run`:`—`}),(0,L.jsx)(LW,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${tW(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var zW=`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 BW({groupBy:e,onGroup:t}){return(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex 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,L.jsx)(J,{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:cW(n)},n))})}function VW({query:e,onQuery:t}){return(0,L.jsxs)(`label`,{className:`relative flex items-center`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,L.jsx)(eg,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,L.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,L.jsx)(ED,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function HW({data:e,groupBy:t,query:n}){let r=e=>lW(e,t);return e.tiles.runs===0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(RW,{tiles:e.tiles}),(0,L.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}".`:zW})]}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(RW,{tiles:e.tiles}),e.classifier?(0,L.jsx)(AW,{summary:e.classifier}):null,(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(yW,{groups:e.groups,label:r}),(0,L.jsx)(CW,{groups:e.groups,label:r})]}),(0,L.jsx)(DW,{timeShare:e.timeShare}),(0,L.jsx)(FW,{groups:e.groups,groupBy:t})]})}function UW(){return(0,L.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,L.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function WW(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),i=sO(`metrics.get`,{groupBy:e,query:n},[`metrics`]);return!i.data&&i.error?(0,L.jsx)(tO,{message:`Could not load metrics. ${i.error}`,onRetry:i.reload}):(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),i.loading&&i.data?(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)($D,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),(0,L.jsx)(BW,{groupBy:e,onGroup:t}),(0,L.jsx)(VW,{query:n,onQuery:r})]}),i.data?(0,L.jsx)(HW,{data:i.data,groupBy:e,query:n}):(0,L.jsx)(UW,{})]})}var GW=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 KW(e,t){return JSON.stringify([e,`prompt`,t])}function qW(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function JW(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var YW=`bot-lobby.prompt-sound-muted`,XW=new Set,ZW,QW=!1;function $W(){try{return localStorage.getItem(YW)===`on`}catch{return QW}}function eG(e){QW=e;try{localStorage.setItem(YW,e?`on`:`off`)}catch{}for(let e of XW)e()}function tG(e){return XW.add(e),()=>{XW.delete(e)}}function nG(){return(0,m.useSyncExternalStore)(tG,$W,()=>!1)}function rG(){(0,m.useEffect)(()=>{let e=()=>{try{ZW??=new AudioContext,ZW.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function iG(){if(!$W()&&ZW&&ZW.state===`running`)try{let e=ZW.currentTime,t=ZW.createOscillator(),n=ZW.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(ZW.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var aG=`bot-lobby.notifications`,oG=`/icon-192.png`,sG=new Set;function cG(){for(let e of[...sG])e()}function lG(){try{return localStorage.getItem(aG)===`on`}catch{return!1}}function uG(e){return sG.add(e),()=>{sG.delete(e)}}function dG(e){try{localStorage.setItem(aG,e?`on`:`off`)}catch{}cG()}function fG(){return(0,m.useSyncExternalStore)(uG,lG,()=>!1)}async function pG(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(dG(!0),`granted`):`denied`)}function mG(){dG(!1)}function hG(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function gG(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function _G(e){try{new Notification(`bot-lobby`,{body:e,icon:oG,tag:`bot-lobby`})}catch{}}function vG(){try{return new GW(sessionStorage)}catch{return new GW}}function yG(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?qW(e,t.sessionId??n.key??t.from,n.dialog.id):KW(e,t.id)}function bG(){let e=fG();rG(),rO();let t=sO(`tasks.list`,{},[`tasks`]),n=sO(`sessions.list`,{},[`sessions`]),r=me.get(`prompts`),i=me.get(`lobby`).data,a=(0,m.useRef)(vG()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=M()??`current`,l=me.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 xG(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(()=>iG()),c&&gG()&&_G(r),t===`delivery`&&V.info(r,{action:{label:`Review tasks`,onClick:()=>GD(`#/tasks`)}}))}function SG(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;xG(e,`prompts`,(a??[]).map(e=>yG(i,e)),`A question is waiting for you.`,!!a&&!t.loading),xG(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>qW(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),xG(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=>JW(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function CG(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}SG(e);let s=a?.task?.state??``,c=hG(s);i.current&&c&&s!==i.current&&o&&gG()&&_G(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function wG(){let e=bG(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>CG(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function TG({className:e,type:t,...n}){return(0,L.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})}function EG({className:e,thumbClassName:t,...n}){return(0,L.jsx)(EE,{"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,L.jsx)(OE,{"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 DG=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],OG={repeat:1/0},kG=`M0 -4 L1 -1 L4 0 L1 1 L0 4 L-1 1 L-4 0 L-1 -1Z`,AG=[`var(--rainbow-1)`,`var(--rainbow-2)`,`var(--rainbow-3)`,`var(--rainbow-4)`,`var(--rainbow-5)`,`var(--rainbow-6)`,`var(--rainbow-7)`],jG={transformBox:`fill-box`,transformOrigin:`center`};function MG(e){switch(e){case`off`:return{animate:{scale:[1,1.03,1],rotate:-5},transition:{...OG,duration:4,ease:`easeInOut`}};case`minimal`:return{animate:{rotate:[0,0,7,9,0,0],y:[0,0,1.5,2,0,0]},transition:{...OG,duration:4.2,times:[0,.35,.7,.82,.86,1],ease:`easeInOut`}};case`low`:return{animate:{rotate:[-4,4,-4],y:[0,-1,0]},transition:{...OG,duration:3.2,ease:`easeInOut`}};case`medium`:return{animate:{rotate:[0,-5,-5,5,5,0],y:[0,-1,-1,-1,-1,0]},transition:{...OG,duration:4,times:[0,.12,.4,.52,.8,1],ease:`easeInOut`}};case`high`:return{animate:{y:[0,-1.5,0]},transition:{...OG,duration:.6,ease:`easeInOut`}};case`xhigh`:return{animate:{y:[0,-7,0,0],scaleY:[1,1.06,.88,1],scaleX:[1,.96,1.1,1]},transition:{...OG,duration:.7,times:[0,.4,.75,1],ease:`easeInOut`}};case`max`:return{animate:{y:[-1,-4,-1],rotate:[-3,3,-3]},transition:{...OG,duration:1.6,ease:`easeInOut`}}}}function NG(){return(0,L.jsx)(`g`,{className:`fill-muted-foreground`,fontWeight:`700`,children:[0,1,2].map(e=>(0,L.jsx)(z.text,{x:44+e*4.5,y:17-e*5.5,fontSize:5.5+e*2,initial:{opacity:0},animate:{opacity:[0,1,0],y:[3,-4],x:[0,2.5]},transition:{...OG,duration:2.6,delay:e*.8,ease:`easeOut`},children:`z`},e))})}function PG(){return(0,L.jsx)(`g`,{className:`fill-primary`,fontSize:`9`,children:[0,1].map(e=>(0,L.jsx)(z.text,{x:48,y:20,initial:{opacity:0},animate:{opacity:[0,1,1,0],y:[2,-5,-11,-17],x:[0,3,1,5],rotate:[0,12,-8,10]},transition:{...OG,duration:3,delay:e*1.5,ease:`easeOut`},style:jG,children:e?`♫`:`♪`},e))})}function FG(){return(0,L.jsx)(z.text,{x:52,y:14,fontSize:`12`,fontWeight:`700`,className:`fill-primary`,initial:{opacity:0,scale:0},animate:{opacity:[0,0,1,1,0],scale:[0,0,1.2,1,.6],rotate:[0,0,-12,8,0]},transition:{...OG,duration:4,times:[0,.5,.58,.85,1]},style:jG,children:`?`})}function IG({spots:e,rainbow:t}){return(0,L.jsx)(`g`,{children:e.map(([e,n,r],i)=>(0,L.jsx)(z.path,{d:kG,className:t?void 0:`fill-primary`,style:{x:e,y:n,...t?{fill:AG[i%AG.length]}:{}},initial:{scale:0},animate:{scale:[0,1.1,0],rotate:[0,90,180]},transition:{...OG,duration:1.3,delay:r,ease:`easeInOut`}},i))})}function LG(){return(0,L.jsx)(`g`,{children:[-20,20].map((e,t)=>(0,L.jsxs)(`g`,{transform:`rotate(${e} 32 34)`,children:[(0,L.jsx)(`ellipse`,{cx:32,cy:34,rx:30,ry:9,fill:`none`,strokeWidth:.8,strokeDasharray:`2 3`,className:`stroke-primary/35`}),(0,L.jsx)(z.circle,{r:2,className:`fill-primary`,animate:{cx:[2,32,62,32,2],cy:[34,43,34,25,34]},transition:{...OG,duration:1.1,delay:t*.55,ease:`linear`}})]},e))})}function RG(){return(0,L.jsx)(z.path,{d:`M53 22 Q56 27 53 29 Q50 27 53 22Z`,className:`fill-primary/60`,animate:{y:[0,8],opacity:[0,1,0]},transition:{...OG,duration:.9,ease:`easeIn`,repeatDelay:.5}})}function zG({id:e}){return(0,L.jsx)(z.circle,{cx:32,cy:34,r:27,fill:`url(#${e}-glow)`,animate:{scale:[.92,1.08,.92],opacity:[.5,.85,.5]},transition:{...OG,duration:1.6,ease:`easeInOut`},style:{transformOrigin:`32px 34px`}})}function BG({rainbow:e}){return(0,L.jsx)(`g`,{children:Array.from({length:8},(t,n)=>{let r=n/8*Math.PI*2;return(0,L.jsx)(z.circle,{cx:32,cy:34,r:2,className:e?void 0:`fill-primary`,style:e?{fill:AG[n%AG.length]}:void 0,initial:{opacity:1,scale:1},animate:{cx:32+Math.cos(r)*32,cy:34+Math.sin(r)*30,opacity:0,scale:.3},transition:{duration:.6,ease:`easeOut`}},n)})})}function VG({level:e,move:t}){let n={fill:`none`,strokeWidth:2.2,strokeLinecap:`round`,className:`stroke-foreground`};if(e===`off`)return(0,L.jsx)(`path`,{d:`M20 33 Q24.5 36.5 29 33 M35 33 Q39.5 36.5 44 33`,...n});if(e===`low`)return(0,L.jsx)(`path`,{d:`M20 34 Q24.5 29.5 29 34 M35 34 Q39.5 29.5 44 34`,...n});if(e===`max`)return(0,L.jsx)(`g`,{children:[25,39].map((e,n)=>(0,L.jsx)(z.path,{d:`M0 -5.5 L1.6 -1.6 L5.5 0 L1.6 1.6 L0 5.5 L-1.6 1.6 L-5.5 0 L-1.6 -1.6Z`,style:{x:e,y:33,fill:AG[n?4:0]},animate:t?{rotate:[0,90,180],scale:[1,1.25,1]}:{},transition:{...OG,duration:1.2,ease:`easeInOut`,delay:n*.2}},e))});let r=e===`minimal`?.45:e===`high`?.7:e===`xhigh`?1.2:1,i=t&&e===`medium`?{x:[0,-2.5,-2.5,2.5,2.5,0]}:{x:0},a=t&&e===`medium`?{...OG,duration:4,times:[0,.12,.4,.52,.8,1]}:{duration:.2},o=e===`minimal`?3.2:e===`xhigh`?1.4:3.6,s=t?{scaleY:[r,r,.1,r,r]}:{scaleY:r},c=t?{...OG,duration:o,times:[0,.44,.5,.56,1]}:{duration:.2};return(0,L.jsx)(z.g,{animate:i,transition:a,children:[25,39].map(t=>(0,L.jsxs)(`g`,{children:[(0,L.jsx)(z.ellipse,{cx:t,cy:33,rx:3.4,ry:3.8,className:`fill-foreground`,style:jG,animate:s,transition:c}),e===`minimal`?null:(0,L.jsx)(`circle`,{cx:t+1.2,cy:31.6,r:1,className:`fill-card`})]},t))})}function HG({level:e,move:t}){let n={fill:`none`,strokeWidth:2,strokeLinecap:`round`,className:`stroke-foreground`};switch(e){case`off`:return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`circle`,{cx:32,cy:42,r:1.4,className:`fill-foreground`}),t?(0,L.jsx)(z.circle,{cx:35,cy:42,r:3,fill:`none`,strokeWidth:.9,className:`stroke-primary/60`,animate:{scale:[.2,1.3,1.5,0],opacity:[.6,.9,.9,0]},transition:{...OG,duration:4,times:[0,.7,.9,1]},style:{transformOrigin:`33px 42px`}}):null]});case`minimal`:return(0,L.jsx)(z.ellipse,{cx:32,cy:42,rx:3,ry:.8,className:`fill-foreground`,animate:t?{ry:[.8,.8,3.6,3.6,.8],rx:[3,3,3.6,3.6,3]}:{},transition:{...OG,duration:6,times:[0,.6,.7,.85,1]}});case`low`:return(0,L.jsx)(`path`,{d:`M26 40 Q32 45 38 40`,...n});case`medium`:return(0,L.jsx)(`path`,{d:`M28 41.5 Q32 43 36 41.5`,...n});case`high`:return(0,L.jsx)(`path`,{d:`M27 42 L37 41`,...n});case`xhigh`:return(0,L.jsx)(`path`,{d:`M25.5 39.5 Q32 47 38.5 39.5Z`,className:`fill-foreground`});case`max`:return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`path`,{d:`M24 38.5 Q32 50 40 38.5Z`,className:`fill-foreground`}),(0,L.jsx)(`path`,{d:`M28.5 44.5 Q32 47.5 35.5 44.5 Q32 43 28.5 44.5Z`,style:{fill:`var(--rainbow-1)`}})]})}}function UG({level:e,className:t}){let n=Sf()??!1,r=DG.includes(e)?e:`medium`,i=`m${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,a=!n,o=DG.indexOf(r),s=(0,m.useRef)(o),[c,l]=(0,m.useState)({n:0,up:!0});(0,m.useEffect)(()=>{o!==s.current&&(l(e=>({n:e.n+1,up:o>s.current})),s.current=o)},[o]);let u=MG(r),d=r===`max`,f=d?{stroke:`url(#${i}-rainbow)`}:void 0,p=!a||c.n===0?void 0:c.up?{y:[0,-9,0,0],scaleX:[1,.9,1.1,1],scaleY:[1,1.12,.9,1]}:{y:[0,0,0],scaleX:[1,1.12,1],scaleY:[1,.84,1]};return(0,L.jsxs)(`svg`,{viewBox:`0 0 64 64`,"data-slot":`effort-mascot`,"data-level":r,"aria-hidden":`true`,focusable:`false`,className:q(`size-14 shrink-0 overflow-visible`,t),children:[(0,L.jsxs)(`defs`,{children:[(0,L.jsxs)(`linearGradient`,{id:`${i}-rainbow`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[AG.map((e,t)=>(0,L.jsx)(`stop`,{offset:t/(AG.length-1),stopColor:e},t)),a&&d?(0,L.jsx)(`animateTransform`,{attributeName:`gradientTransform`,type:`rotate`,from:`0 0.5 0.5`,to:`360 0.5 0.5`,dur:`2.4s`,repeatCount:`indefinite`}):null]}),(0,L.jsxs)(`radialGradient`,{id:`${i}-glow`,children:[(0,L.jsx)(`stop`,{offset:`0.35`,stopColor:`var(--rainbow-6)`,stopOpacity:`0.45`}),(0,L.jsx)(`stop`,{offset:`0.7`,stopColor:`var(--rainbow-1)`,stopOpacity:`0.18`}),(0,L.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-3)`,stopOpacity:`0`})]})]}),d?a?(0,L.jsx)(zG,{id:i}):(0,L.jsx)(`circle`,{cx:32,cy:34,r:27,fill:`url(#${i}-glow)`}):null,a&&r===`xhigh`?(0,L.jsx)(LG,{}):null,(0,L.jsx)(z.g,{animate:p,transition:{duration:c.up?.55:.45,ease:`easeOut`},style:{transformOrigin:`32px 56px`},children:(0,L.jsxs)(z.g,{animate:a?u.animate:{rotate:r===`off`?-5:0},transition:a?u.transition:{duration:0},style:{transformOrigin:`32px 56px`},children:[(0,L.jsxs)(z.g,{style:{transformOrigin:`32px 17px`},animate:r===`off`?{rotate:32}:r===`minimal`?{rotate:14}:a&&r===`medium`?{rotate:[0,-12,10,0]}:a&&(r===`xhigh`||r===`max`)?{rotate:[-10,10,-10]}:{rotate:0},transition:a&&(r===`medium`||r===`xhigh`||r===`max`)?{...OG,duration:r===`medium`?2:.5,ease:`easeInOut`}:{type:`spring`,stiffness:200,damping:14},children:[(0,L.jsx)(`path`,{d:`M32 17 V10`,strokeWidth:2,strokeLinecap:`round`,className:d?void 0:`stroke-primary/70`,style:f}),(0,L.jsx)(z.circle,{cx:32,cy:7.5,r:3.2,className:d?void 0:r===`off`?`fill-muted-foreground/40`:`fill-primary`,style:{...jG,...d?{fill:`url(#${i}-rainbow)`}:{}},animate:a?r===`high`?{opacity:[1,.3,1]}:r===`medium`?{scale:[1,1.25,1]}:d||r===`xhigh`?{scale:[1,1.5,1]}:{scale:1,opacity:1}:{scale:1,opacity:1},transition:{...OG,duration:r===`high`?.5:r===`medium`?1.6:.4}})]}),[4.5,54].map((e,t)=>(0,L.jsx)(z.rect,{x:e,y:29,width:5.5,height:11,rx:2.5,className:d?void 0:`fill-primary/25`,style:{...jG,...d?{fill:AG[t?5:1],opacity:.6}:{}},animate:a&&(r===`xhigh`||d)?{rotate:t?[0,18,0]:[0,-18,0]}:{rotate:0},transition:{...OG,duration:.35}},e)),(0,L.jsx)(`rect`,{x:10,y:17,width:44,height:36,rx:11,strokeWidth:d?2.6:2,className:d?`fill-primary/10`:`fill-primary/10 stroke-primary/75`,style:f}),(0,L.jsx)(`rect`,{x:15,y:23,width:34,height:25,rx:7.5,className:`fill-card stroke-border`,strokeWidth:1}),a&&r===`high`?(0,L.jsx)(z.rect,{y:24,width:2,height:23,rx:1,className:`fill-primary/25`,animate:{x:[16,46,16]},transition:{...OG,duration:1.6,ease:`easeInOut`}}):null,r===`low`||d?(0,L.jsxs)(`g`,{className:`fill-destructive/25`,children:[(0,L.jsx)(`ellipse`,{cx:19.5,cy:39.5,rx:2.6,ry:1.6}),(0,L.jsx)(`ellipse`,{cx:44.5,cy:39.5,rx:2.6,ry:1.6})]}):null,(0,L.jsx)(VG,{level:r,move:a}),r===`high`||r===`xhigh`?(0,L.jsx)(`path`,{d:`M20 27 L28.5 28.8 M44 27 L35.5 28.8`,strokeWidth:1.9,strokeLinecap:`round`,className:`stroke-foreground`}):null,(0,L.jsx)(HG,{level:r,move:a}),(0,L.jsx)(`rect`,{x:20,y:53,width:24,height:4,rx:2,className:d?void 0:`fill-primary/25`,style:d?{fill:`url(#${i}-rainbow)`}:void 0})]})},c.n),r===`off`?a?(0,L.jsx)(NG,{}):(0,L.jsx)(`text`,{x:48,y:14,fontSize:`9`,fontWeight:`700`,className:`fill-muted-foreground`,children:`z`}):null,a&&r===`minimal`?(0,L.jsx)(NG,{}):null,a&&r===`low`?(0,L.jsx)(PG,{}):null,a&&r===`medium`?(0,L.jsx)(FG,{}):null,a&&r===`high`?(0,L.jsx)(IG,{spots:[[6,14,0],[58,12,.6]]}):null,a&&r===`xhigh`?(0,L.jsx)(RG,{}):null,d?a?(0,L.jsx)(IG,{rainbow:!0,spots:[[5,12,0],[59,10,.2],[2,44,.45],[62,46,.65],[32,-2,.85],[14,60,1.05],[50,60,.3]]}):(0,L.jsx)(`g`,{children:[[5,12],[59,10],[32,-2]].map(([e,t],n)=>(0,L.jsx)(`path`,{d:kG,style:{x:e,y:t,fill:AG[n*2]}},n))}):null,a&&c.n>0&&c.up?(0,L.jsx)(BG,{rainbow:d},`burst-${c.n}`):null]})}var WG={minimal:`min`,medium:`med`},GG={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 KG(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 qG(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 JG({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),_=KG(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 KG(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:qG(t,n,r,1),ArrowUp:qG(t,n,r,1),ArrowLeft:qG(t,n,r,-1),ArrowDown:qG(t,n,r,-1),Home:KG(t,n,0),End:KG(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,L.jsxs)(`div`,{className:q(`flex flex-col gap-1`,a&&`opacity-60`),children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:GG[b]??``})]}),(0,L.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,L.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,L.jsx)(z.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,L.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,L.jsx)(z.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,L.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,L.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:WG[e]??e},e)})}),x?(0,L.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})}function YG(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function XG({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=>YG(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,L.jsxs)(fE,{open:o,onOpenChange:s,children:[(0,L.jsxs)(pE,{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(`btn-raised 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,L.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,L.jsx)(Wp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,L.jsx)(mE,{children:(0,L.jsxs)(hE,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`glass-pop z-50 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,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,L.jsx)(eg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.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,L.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,L.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,L.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})})]})}function ZG({label:e,help:t,children:n,stacked:r}){return(0,L.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,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,L.jsx)(`div`,{className:`min-w-0`,children:n})]})}function QG({children:e}){return(0,L.jsx)(`div`,{className:`card-raised flex flex-col divide-y divide-border rounded-xl border px-4 [&>*]:py-3`,children:e})}function $G({value:e,items:t,label:n,onChange:r}){return(0,L.jsx)(XG,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r})}var eK=`(prefers-color-scheme: dark)`,tK=[`dark`,`light`,`system`],nK=m.createContext(void 0);function rK(e){return e!==null&&tK.includes(e)}function iK(){return window.matchMedia(eK).matches?`dark`:`light`}function aK(){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 oK(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function sK({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return rK(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`?iK():e,i=r?aK():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(eK),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||oK(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:iK()===`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(rK(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,L.jsx)(nK.Provider,{...i,value:l,children:e})}var cK=()=>{let e=m.useContext(nK);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},lK=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],uK={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},dK={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},fK=`inherit`,pK=`inherit`,mK=`Use the session's current model`,hK=`__custom__`,gK=`custom…`,_K=`Type a provider/model id`,vK=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],yK={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},bK=[{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`}],xK=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],SK=`shown on the Lobby tab`,CK=`Planning rounds`,wK=`how many rounds the panel gets before the oracle settles the rest alone`,TK=[2,3,5,8,0],EK=`Split long plans`,DK=`saving a plan with more steps offers to split it into up to 5 tasks`,OK=[6,8,10,12,0],kK=`Port`,AK=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,jK=`Open browser`,MK=`open this page in the browser when pi starts`,NK=[{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`}],PK=`Git isolation`,FK=[{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`}],IK={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`},LK=[{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`}],RK=[{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`}],zK={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`},BK={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`},VK=`https://tweakcn.com/editor/theme`;function HK(){let{theme:e}=cK();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function UK({palette:e,dark:t}){let n=le(e,t);return(0,L.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,L.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,L.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,L.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function WK(){let e=Ge(),t=HK(),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,L.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,L.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,L.jsx)(UK,{palette:n,dark:t}),(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,L.jsxs)(`span`,{className:`truncate`,children:[n.name,e.isSaved(n.id)?(0,L.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function GK({entry:e}){let t=Ge(),[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),V.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,L.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,L.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,L.jsx)(TG,{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,L.jsx)(Y,{label:`Save the name`,text:`Save`,icon:Hp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,L.jsx)(Y,{label:`Keep the old name`,icon:Rg,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,L.jsx)(Y,{label:`Rename ${e.name}`,text:`Rename`,icon:Ih,onClick:()=>{a(e.name),r(!0)}}),(0,L.jsx)(ck,{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:bg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>V.error(e.message))})]}),o?(0,L.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function KK(){let e=Ge();return e.saved.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,L.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,L.jsx)(GK,{entry:e},e.id))})}function qK(){let e=Ge(),[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=te(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`;V.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,L.jsxs)(`div`,{className:`grid gap-2`,children:[(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,L.jsxs)(`a`,{href:VK,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,L.jsx)(Em,{"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,L.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,L.jsx)(TG,{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,L.jsx)(KO,{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
|
…
|
|
95
95
|
}
|
|
96
|
-
.dark { … }`,className:`max-h-56 font-mono text-xs md:text-xs`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,L.jsx)(Y,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Hp,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,L.jsx)(Y,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Eg,disabled:s,onClick:()=>l.current?.click()}),a?(0,L.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function JK(){let{theme:e,setTheme:t}=cK(),n=nG();return(0,L.jsx)(Mz,{prominent:!0,title:yK.appearance,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,L.jsx)(EG,{checked:!n,onCheckedChange:e=>eG(!e),"aria-label":`Prompt sounds`})}),(0,L.jsx)(ZG,{label:BK.themeLabel,help:BK.appearanceHelp,children:(0,L.jsx)($G,{value:e,items:BK.themeItems.map(e=>({value:e.id,label:e.label})),label:BK.themeLabel,onChange:e=>t(e)})}),(0,L.jsx)(ZG,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,L.jsx)(WK,{})}),(0,L.jsx)(ZG,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,L.jsx)(KK,{})}),(0,L.jsx)(ZG,{label:`Import a theme`,stacked:!0,children:(0,L.jsx)(qK,{})})]})})}var YK={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],quickfix:[`quickFix`],planner:[`planner`]},XK=[...bK,...xK.map(e=>({id:`panel:${e.id}`,label:e.label,help:SK}))];function ZK(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,timeoutMs:e.scout.timeoutMs};case`researcher`:return e.researcher;case`quickfix`:return e.quickFix;case`planner`:return e.planner;default:return e.agents[t]}}function QK(e,t){return YK[e].reduceRight((e,t)=>({[t]:e}),t)}function $K(e,t){return e.find(e=>e.id===t)?.thinkingLevels??vK}function eq(e,t){return vK[KG(vK,e,Math.max(0,vK.indexOf(t)))]??t}var tq=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`,nq=e=>e>0?`over ${e} steps`:`never`;function rq({label:e,children:t}){return(0,L.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),t]})}function iq(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:fK,label:pK,help:mK}]:[],...e.none?[{value:fK,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:fK,label:pK,help:mK}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:_K}]:[],{value:hK,label:gK,help:_K}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)($G,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(TG,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,L.jsx)(Y,{label:`Use this model`,icon:Hp,tone:`primary`,onClick:c})]}):null]})}function aq({label:e,help:t,checked:n,onChange:r}){return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,L.jsx)(EG,{checked:n,onCheckedChange:r,"aria-label":e})]})}function oq({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,L.jsx)(TG,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function sq({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,L.jsx)(lq,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(V.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function cq({value:e,onSave:t}){return(0,L.jsx)(lq,{label:kK,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(V.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function lq({label:e,value:t,min:n,max:r,suffix:i,onSave:a}){let[o,s]=(0,m.useState)(t);(0,m.useEffect)(()=>s(t),[t]);let c=()=>{o!==t&&(a(o.trim())||s(t))};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(TG,{type:`number`,inputMode:`numeric`,min:n,max:r,value:o,"aria-label":e,className:i?`pr-10`:void 0,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),i?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:i}):null]})}function uq({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(KO,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function dq({kind:e,config:t,models:n,save:r}){let i=ZK(t,e),a=t=>r(QK(e,t)),o=uK[e],s=$K(n,i.model),c=t=>{let r={model:t};e!==`scout`&&!$K(n,t).includes(i.thinking)&&(r.thinking=eq($K(n,t),i.thinking)),a(r)},l=e===`scout`?`low`:eq(s,i.thinking),u=e!==`scout`&&e!==`researcher`,[d,f]=(0,m.useState)(!!i.instructions);return(0,L.jsxs)(`section`,{className:`glass flex min-w-0 flex-col gap-3 rounded-xl p-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:o}),(0,L.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[i.model===`inherit`?`session model`:i.model,` · `,e===`scout`?`low`:i.thinking]})]}),(0,L.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-1`,children:(0,L.jsx)(rq,{label:dK.model,children:(0,L.jsx)(iq,{value:i.model,models:n,label:`${o} model`,inherit:e===`master`,onChange:c})})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-muted p-3`,children:[(0,L.jsx)(UG,{level:l,className:`size-16`}),(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:e===`scout`?(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:dK.thinking}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`low`,` (fixed for scouts)`]})]}):(0,L.jsx)(JG,{value:i.thinking,levels:vK,supported:s,model:i.model===`inherit`?`the session model`:i.model,label:`${o} effort`,onChange:e=>a({thinking:e})})})]}),(0,L.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[u?(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":d,onClick:()=>f(e=>!e),className:`flex min-h-8 items-center gap-1 rounded-md text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:[(0,L.jsx)(Jp,{"aria-hidden":`true`,className:q(`size-3.5 transition-transform duration-200 ease-snap`,d&&`rotate-90`)}),dK.instructions,!d&&i.instructions?(0,L.jsx)(`span`,{className:`text-primary`,children:`· set`}):null]}):(0,L.jsx)(`span`,{}),e===`master`?null:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Time limit`}),(0,L.jsx)(`div`,{className:`w-24`,children:(0,L.jsx)(sq,{value:i.timeoutMs??t.workflow.agentTimeoutMs,label:`${o} time limit`,onSave:e=>a({timeoutMs:e})})})]})]}),u&&d?(0,L.jsx)(uq,{value:i.instructions??``,label:`${o} instructions`,onSave:e=>a({instructions:e})}):null]})}function fq(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function pq({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,L.jsx)(aq,{label:t.label,help:t.help,checked:fq(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function mq({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,L.jsx)(Mz,{prominent:!0,title:yK.workflow,children:(0,L.jsx)(QG,{children:(0,L.jsx)(ZG,{label:PK,help:NK.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,L.jsx)($G,{value:n,items:NK.map(e=>({value:e.id,label:e.label})),label:PK,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var hq=e=>e?`${e}/`:IK.top;function gq(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function _q({replaced:e}){let t=sO(`settings.linters`,{},[]),n=t.data?.linters;return(0,L.jsx)(ZG,{label:IK.found,help:e?IK.foundReplaced:IK.foundHelp,children:n?n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:IK.foundNone}):(0,L.jsx)(`ul`,{"aria-label":IK.found,className:q(`flex flex-col gap-1.5 sm:items-end`,e&&`opacity-60`),children:n.map(e=>(0,L.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.tool}),(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:hq(e.folder)}),(0,L.jsxs)(`span`,{title:e.installed?void 0:IK.missingHelp,className:q(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,L.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5`}):(0,L.jsx)(em,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?IK.installed:IK.missing]})]},`${e.tool}:${e.folder}`))}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:t.error?t.error:`Looking…`})})}function vq({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,L.jsxs)(Mz,{prominent:!0,title:yK.lint,children:[(0,L.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:IK.intro}),(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:IK.mode,help:FK.find(e=>e.id===n.mode)?.help,children:(0,L.jsx)($G,{value:n.mode,items:FK.map(e=>({value:e.id,label:e.label})),label:IK.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,L.jsxs)(`div`,{className:q(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,L.jsx)(ZG,{label:IK.command,help:IK.commandHelp,children:(0,L.jsx)(oq,{value:n.command,label:IK.command,placeholder:IK.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,L.jsx)(ZG,{label:IK.extensions,help:IK.extensionsHelp,children:(0,L.jsx)(oq,{value:n.extensions.join(` `),label:IK.extensions,placeholder:IK.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:gq(e)}})})}):null,(0,L.jsx)(ZG,{label:IK.timeout,help:IK.timeoutHelp,children:(0,L.jsx)(sq,{value:n.timeoutMs,label:`Lint ${IK.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,L.jsx)(_q,{replaced:i})]})]})]})}function yq({config:e,save:t}){let n=e.lobby.web;return(0,L.jsx)(Mz,{prominent:!0,title:yK.lobby,children:(0,L.jsxs)(QG,{children:[XK.map(n=>(0,L.jsx)(pq,{config:e,item:n,save:t},n.id)),(0,L.jsx)(ZG,{label:CK,help:wK,children:(0,L.jsx)($G,{value:String(e.lobby.maxPlanningRounds),items:TK.map(e=>({value:String(e),label:tq(e)})),label:CK,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,L.jsx)(ZG,{label:EK,help:DK,children:(0,L.jsx)($G,{value:String(e.lobby.splitPlanAbove),items:OK.map(e=>({value:String(e),label:nq(e)})),label:EK,onChange:e=>void t({lobby:{splitPlanAbove:Number(e)}})})}),(0,L.jsx)(ZG,{label:kK,help:AK,children:(0,L.jsx)(cq,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,L.jsx)(aq,{label:jK,help:MK,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})})]})})}function bq({config:e,models:t,save:n}){let r=e.classifier,i=LK.find(e=>e.id===r.provider)?.label;return(0,L.jsx)(Mz,{prominent:!0,title:yK.classifier,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(aq,{label:zK.enabled,help:zK.enabledHelp,checked:r.enabled,onChange:e=>void n({classifier:{enabled:e}})}),(0,L.jsx)(ZG,{label:zK.host,children:(0,L.jsx)($G,{value:r.provider,items:LK.map(e=>({value:e.id,label:e.label})),label:zK.host,onChange:e=>void n({classifier:{provider:e}})})}),(0,L.jsx)(ZG,{label:zK.model,help:zK.modelHelp,children:(0,L.jsx)(oq,{value:r.model,label:zK.model,placeholder:`the host's default`,onSave:e=>void n({classifier:{model:e}})})}),(0,L.jsx)(ZG,{label:zK.key,help:zK.keyNote,children:(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:i??r.provider})}),RK.map(e=>(0,L.jsx)(aq,{label:e.label,help:e.help,checked:r.features[e.id],onChange:t=>void n({classifier:{features:{[e.id]:t}}})},e.id)),(0,L.jsx)(ZG,{label:zK.cheap,help:zK.cheapHelp,children:(0,L.jsx)(iq,{value:r.effort.cheapModel,models:t,label:zK.cheap,none:!0,onChange:e=>void n({classifier:{effort:{cheapModel:e}}})})})]})})}function xq(){let e=fG(),t=async e=>{if(!e)return mG();let t=await pG();t===`granted`?V.success(BK.notificationsOn):V.error(t===`unsupported`?BK.notificationsUnsupported:BK.notificationsBlocked)};return(0,L.jsx)(Mz,{prominent:!0,title:yK.notifications,children:(0,L.jsx)(QG,{children:(0,L.jsx)(aq,{label:BK.notificationsLabel,help:BK.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function Sq(){let{available:e,install:t}=y(),n=b(),r=x();return(0,L.jsx)(Mz,{prominent:!0,title:yK.install,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:BK.installLabel,help:n?BK.installedNow:BK.installHelp,children:n?null:(0,L.jsx)(`div`,{className:`flex sm:justify-end`,children:(0,L.jsx)(Y,{label:BK.installButton,icon:wm,tone:`primary`,onClick:()=>e?void t().then(()=>V.success(BK.installDone)):V.warning(BK.installUnavailable)})})}),r.supported?(0,L.jsx)(ZG,{label:BK.fullscreenLabel,help:BK.fullscreenHelp,children:(0,L.jsx)(`div`,{className:`flex sm:justify-end`,children:(0,L.jsx)(Y,{label:r.on?BK.fullscreenOn:BK.fullscreenOff,icon:r.on?mh:nh,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var Cq=[`Agents`,`Workflow`,`Linting`,`Lobby`,`Classifier`,`Appearance & notifications`];function wq({config:e,models:t,onConfig:n}){let[r,i]=(0,m.useState)(`Agents`),a=(0,m.useRef)(Promise.resolve()),o=e=>{let t=async()=>{try{return n((await De(`settings.set`,{patch:e})).config),V.success(BK.saved),!0}catch(e){return V.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},r=a.current.then(t,t);return a.current=r,r};return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-6 px-5 pt-5 pb-dock sm:px-8 sm:pt-8`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:BK.title}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:BK.intro})]}),(0,L.jsx)(`nav`,{"aria-label":`Settings sections`,className:`-mx-1 flex flex-wrap gap-1 border-b border-border pb-3`,children:Cq.map(e=>(0,L.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-current":r===e?`page`:void 0,"aria-controls":`settings-${e.split(` `)[0]}`,onClick:()=>i(e),className:q(`h-8 rounded-lg border border-transparent px-3 text-sm font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,r===e?`btn-raised bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e},e))}),(0,L.jsx)(`div`,{id:`settings-Agents`,hidden:r!==`Agents`,"aria-hidden":r!==`Agents`,children:(0,L.jsx)(Mz,{prominent:!0,title:yK.agents,children:(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:lK.map(n=>(0,L.jsx)(dq,{kind:n,config:e,models:t,save:o},n))})})}),(0,L.jsx)(`div`,{id:`settings-Workflow`,hidden:r!==`Workflow`,"aria-hidden":r!==`Workflow`,children:(0,L.jsx)(mq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Linting`,hidden:r!==`Linting`,"aria-hidden":r!==`Linting`,children:(0,L.jsx)(vq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Lobby`,hidden:r!==`Lobby`,"aria-hidden":r!==`Lobby`,children:(0,L.jsx)(yq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Classifier`,hidden:r!==`Classifier`,"aria-hidden":r!==`Classifier`,children:(0,L.jsx)(bq,{config:e,models:t,save:o})}),(0,L.jsx)(`div`,{id:`settings-Appearance`,hidden:r!==`Appearance & notifications`,"aria-hidden":r!==`Appearance & notifications`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,L.jsx)(JK,{}),(0,L.jsx)(xq,{}),(0,L.jsx)(Sq,{})]})})]})}function Tq(){return(0,L.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-5 pt-5 pb-dock sm:px-8 sm:pt-8`,role:`status`,"aria-label":BK.loading,children:[0,1,2,3].map(e=>(0,L.jsx)(`div`,{className:`h-48 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function Eq(){let e=sO(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,L.jsx)(tO,{message:`${BK.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,L.jsx)(wq,{config:t,models:e.data?.models??[],onConfig:i}):(0,L.jsx)(Tq,{})}function Dq(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var Oq=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,kq=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style`.split(` `)),Aq=new Set(`class id title role aria-label aria-hidden colspan rowspan scope`.split(` `));function jq(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>5e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function Mq(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function Nq(e){if(!kq.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,Mq(t.value)):Aq.has(t.name)||e.removeAttribute(t.name);e.localName===`style`&&(e.textContent=Mq(e.textContent??``));for(let t of[...e.children])Nq(t)}function Pq(e,t){try{return Fq(e,t??Dq())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Oq}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function Fq(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])Nq(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Oq}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${Mq(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function Iq({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>Pq(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,L.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:q(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,L.jsxs)(`div`,{ref:s,className:q(`group/mock relative h-80 w-full overflow-hidden rounded-lg border bg-background`,n),children:[(0,L.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,tabIndex:a?-1:void 0,className:q(`absolute top-0 left-0 origin-top-left border-0`,a&&`pointer-events-none`),style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,L.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`absolute inset-0 flex items-end justify-end p-2 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:ring-inset`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity group-hover/mock:opacity-100 group-focus-within/mock:opacity-100`,children:[(0,L.jsx)(eh,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var Lq=/\s*\(recommended\)\s*$/i,Rq=1024,zq=e=>e.replace(Lq,``);function Bq(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function Vq({option:e}){let t=zq(e.label);return Bq(e)?(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,L.jsx)(Iq,{preview:e.htmlPreview,label:t,minWidth:Rq,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,L.jsx)(`img`,{src:N(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,L.jsx)(kz,{text:e.preview,className:q(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,L.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function Hq({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Sf(),l=(0,m.useRef)(null),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),p=e[d],h=e.length-1;(0,m.useEffect)(()=>s?.(d),[d,s]),(0,m.useLayoutEffect)(()=>{let e=l.current;e&&(e.scrollLeft=d*e.clientWidth),u.current?.focus()},[]);let g=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),h),n=l.current;f(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[h,c]);(0,m.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=d*e.clientWidth});return t.observe(e),()=>t.disconnect()},[d]);function _(){let e=l.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==d&&t>=0&&t<=h&&f(t)}function v(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),g(d+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),g(t.key===`Home`?0:h);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),g(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(d))}let y=r.includes(d);return(0,L.jsxs)(`div`,{ref:u,tabIndex:-1,"data-autofocus":``,onKeyDown:v,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 sm:px-5`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,L.jsx)(fh,{"aria-hidden":`true`})}),(0,L.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===d,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>g(t),className:q(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,t===d?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,L.jsx)(`span`,{className:`truncate`,children:zq(e.label)}),r.includes(t)?(0,L.jsx)(Hp,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{ref:l,onScroll:_,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,L.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${zq(t.label)}`,"aria-hidden":n!==d,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 px-4 py-4 sm:px-14`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,L.jsx)(`span`,{className:`font-medium`,children:zq(t.label)}),Lq.test(t.label)?(0,L.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,L.jsx)(kz,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(Vq,{option:t})})]},n))}),d>0?(0,L.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:`Previous · ←`,onClick:()=>g(d-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full max-sm:hidden`,children:(0,L.jsx)(Kp,{"aria-hidden":`true`})}):null,d<h?(0,L.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:`Next · →`,onClick:()=>g(d+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full max-sm:hidden`,children:(0,L.jsx)(Jp,{"aria-hidden":`true`})}):null]}),(0,L.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3 sm:px-5`,children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`←→`,children:`option`}),a?(0,L.jsx)(DD,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,L.jsx)(DD,{chord:`Esc`,children:`back`})]}),a&&p?(0,L.jsxs)(J,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,L.jsx)(`span`,{className:`truncate`,children:zq(p.label)})]}):null]})]})}function Uq(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function Wq({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,L.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>Uq(e,()=>void d(),()=>{o||r()}),children:[(0,L.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,L.jsx)(KO,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(J,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,L.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var Gq=1200;function Kq({question:e}){let[t,n]=(0,m.useState)(),r=ID(t!==void 0,FD.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:i.map(({option:e,index:t,mockup:r})=>(0,L.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,L.jsx)(Iq,{preview:r,label:zq(e.label),frameWidth:Gq,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,L.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,zq(e.label)]})]},t))}),(0,L.jsx)(OD,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,L.jsx)(Hq,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function qq({questions:e}){return(0,L.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised flex flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":EV(e.from)},children:[(0,L.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,L.jsx)(xV,{source:e.from,className:`size-3`}),CV(e.from)]}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,L.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,L.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,L.jsx)(Kq,{question:e})]},t))})}function Jq({message:e}){let t=e.decided??[];return t.length?(0,L.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:t.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2 rounded-lg bg-muted/60 px-2.5 py-1.5 text-sm`,children:[(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-success`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:q(`font-medium`,wV(e.from)),children:CV(e.from)}),` `,e.question,` → `,(0,L.jsx)(`strong`,{children:e.answer}),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`decided by the classifier (`,e.probability.toFixed(2),`); comment on the plan to overrule`]})]})]},t))}):null}function Yq({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await De(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,L.jsxs)(J,{size:`xs`,variant:`ghost`,disabled:l,onClick:()=>a(!0),className:`text-muted-foreground`,children:[(0,L.jsx)(Ih,{"aria-hidden":`true`}),`Edit`]}):null;return(0,L.jsx)(dU,{time:e.at>0?JO(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,below:d,children:i?(0,L.jsx)(Wq,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,L.jsx)(kz,{text:c.text})})}function Xq({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,L.jsx)(Yq,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,L.jsxs)(uU,{source:`PLANNER`,name:`Panel`,time:e.at>0?JO(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,L.jsx)(qq,{questions:i}):(0,L.jsx)(kz,{text:e.text}),(0,L.jsx)(Jq,{message:e})]})}function Zq({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,L.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,L.jsx)(fU,{children:t}):null,e.map((e,t)=>(0,L.jsx)(Xq,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,L.jsx)(uU,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,aside:`the panel is thinking`,children:(0,L.jsx)(pU,{className:`mt-1`})}):null]})}var Qq=`ORACLE`,$q=`No draft yet.`,eJ=`The draft appears after the panel's first round.`,tJ=`What each seat needs`,nJ=[`backend`,`designer`,`qa`,`researcher`],rJ={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},iJ=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,aJ={ORACLE:`Chairs the panel, and settles the last round alone.`,DEV:`Code, data and the APIs it touches.`,DESIGN:`Screens, flows and the words on them.`,QA:`Tests, edge cases and what could break.`,RESEARCH:`Prior art, docs and sources.`},oJ=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function sJ(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function cJ(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function lJ(e,t){return`${e} ${t}${e===1?``:`s`}`}function uJ(e){return e.round===0&&e.messages.length===0&&!e.busy}function dJ(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${rJ[t.member]} failed`).split(`
|
|
96
|
+
.dark { … }`,className:`max-h-56 font-mono text-xs md:text-xs`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,L.jsx)(Y,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Hp,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,L.jsx)(Y,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:Eg,disabled:s,onClick:()=>l.current?.click()}),a?(0,L.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function JK(){let{theme:e,setTheme:t}=cK(),n=nG();return(0,L.jsx)(Mz,{prominent:!0,title:yK.appearance,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,L.jsx)(EG,{checked:!n,onCheckedChange:e=>eG(!e),"aria-label":`Prompt sounds`})}),(0,L.jsx)(ZG,{label:BK.themeLabel,help:BK.appearanceHelp,children:(0,L.jsx)($G,{value:e,items:BK.themeItems.map(e=>({value:e.id,label:e.label})),label:BK.themeLabel,onChange:e=>t(e)})}),(0,L.jsx)(ZG,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,L.jsx)(WK,{})}),(0,L.jsx)(ZG,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,L.jsx)(KK,{})}),(0,L.jsx)(ZG,{label:`Import a theme`,stacked:!0,children:(0,L.jsx)(qK,{})})]})})}var YK={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],quickfix:[`quickFix`],planner:[`planner`]},XK=[...bK,...xK.map(e=>({id:`panel:${e.id}`,label:e.label,help:SK}))];function ZK(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,timeoutMs:e.scout.timeoutMs};case`researcher`:return e.researcher;case`quickfix`:return e.quickFix;case`planner`:return e.planner;default:return e.agents[t]}}function QK(e,t){return YK[e].reduceRight((e,t)=>({[t]:e}),t)}function $K(e,t){return e.find(e=>e.id===t)?.thinkingLevels??vK}function eq(e,t){return vK[KG(vK,e,Math.max(0,vK.indexOf(t)))]??t}var tq=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`,nq=e=>e>0?`over ${e} steps`:`never`;function rq({label:e,children:t}){return(0,L.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),t]})}function iq(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:fK,label:pK,help:mK}]:[],...e.none?[{value:fK,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:fK,label:pK,help:mK}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:_K}]:[],{value:hK,label:gK,help:_K}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)($G,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(TG,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,L.jsx)(Y,{label:`Use this model`,icon:Hp,tone:`primary`,onClick:c})]}):null]})}function aq({label:e,help:t,checked:n,onChange:r}){return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:e}),t?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),(0,L.jsx)(EG,{checked:n,onCheckedChange:r,"aria-label":e})]})}function oq({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,L.jsx)(TG,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function sq({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,L.jsx)(lq,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(V.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function cq({value:e,onSave:t}){return(0,L.jsx)(lq,{label:kK,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(V.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function lq({label:e,value:t,min:n,max:r,suffix:i,onSave:a}){let[o,s]=(0,m.useState)(t);(0,m.useEffect)(()=>s(t),[t]);let c=()=>{o!==t&&(a(o.trim())||s(t))};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(TG,{type:`number`,inputMode:`numeric`,min:n,max:r,value:o,"aria-label":e,className:i?`pr-10`:void 0,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),i?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:i}):null]})}function uq({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(KO,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function dq({kind:e,config:t,models:n,save:r}){let i=ZK(t,e),a=t=>r(QK(e,t)),o=uK[e],s=$K(n,i.model),c=t=>{let r={model:t};e!==`scout`&&!$K(n,t).includes(i.thinking)&&(r.thinking=eq($K(n,t),i.thinking)),a(r)},l=e===`scout`?`low`:eq(s,i.thinking),u=e!==`scout`&&e!==`researcher`,[d,f]=(0,m.useState)(!!i.instructions);return(0,L.jsxs)(`section`,{className:`glass flex min-w-0 flex-col gap-3 rounded-xl p-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:o}),(0,L.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[i.model===`inherit`?`session model`:i.model,` · `,e===`scout`?`low`:i.thinking]})]}),(0,L.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-1`,children:(0,L.jsx)(rq,{label:dK.model,children:(0,L.jsx)(iq,{value:i.model,models:n,label:`${o} model`,inherit:e===`master`,onChange:c})})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-muted p-3`,children:[(0,L.jsx)(UG,{level:l,className:`size-16`}),(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:e===`scout`?(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:dK.thinking}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`low`,` (fixed for scouts)`]})]}):(0,L.jsx)(JG,{value:i.thinking,levels:vK,supported:s,model:i.model===`inherit`?`the session model`:i.model,label:`${o} effort`,onChange:e=>a({thinking:e})})})]}),(0,L.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[u?(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":d,onClick:()=>f(e=>!e),className:`flex min-h-8 items-center gap-1 rounded-md text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:[(0,L.jsx)(Jp,{"aria-hidden":`true`,className:q(`size-3.5 transition-transform duration-200 ease-snap`,d&&`rotate-90`)}),dK.instructions,!d&&i.instructions?(0,L.jsx)(`span`,{className:`text-primary`,children:`· set`}):null]}):(0,L.jsx)(`span`,{}),e===`master`?null:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Time limit`}),(0,L.jsx)(`div`,{className:`w-24`,children:(0,L.jsx)(sq,{value:i.timeoutMs??t.workflow.agentTimeoutMs,label:`${o} time limit`,onSave:e=>a({timeoutMs:e})})})]})]}),u&&d?(0,L.jsx)(uq,{value:i.instructions??``,label:`${o} instructions`,onSave:e=>a({instructions:e})}):null]})}function fq(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function pq({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,L.jsx)(aq,{label:t.label,help:t.help,checked:fq(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function mq({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,L.jsx)(Mz,{prominent:!0,title:yK.workflow,children:(0,L.jsx)(QG,{children:(0,L.jsx)(ZG,{label:PK,help:NK.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,L.jsx)($G,{value:n,items:NK.map(e=>({value:e.id,label:e.label})),label:PK,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var hq=e=>e?`${e}/`:IK.top;function gq(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function _q({replaced:e}){let t=sO(`settings.linters`,{},[]),n=t.data?.linters;return(0,L.jsx)(ZG,{label:IK.found,help:e?IK.foundReplaced:IK.foundHelp,children:n?n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:IK.foundNone}):(0,L.jsx)(`ul`,{"aria-label":IK.found,className:q(`flex flex-col gap-1.5 sm:items-end`,e&&`opacity-60`),children:n.map(e=>(0,L.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.tool}),(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:hq(e.folder)}),(0,L.jsxs)(`span`,{title:e.installed?void 0:IK.missingHelp,className:q(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,L.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5`}):(0,L.jsx)(em,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?IK.installed:IK.missing]})]},`${e.tool}:${e.folder}`))}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:t.error?t.error:`Looking…`})})}function vq({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,L.jsxs)(Mz,{prominent:!0,title:yK.lint,children:[(0,L.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:IK.intro}),(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:IK.mode,help:FK.find(e=>e.id===n.mode)?.help,children:(0,L.jsx)($G,{value:n.mode,items:FK.map(e=>({value:e.id,label:e.label})),label:IK.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,L.jsxs)(`div`,{className:q(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,L.jsx)(ZG,{label:IK.command,help:IK.commandHelp,children:(0,L.jsx)(oq,{value:n.command,label:IK.command,placeholder:IK.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,L.jsx)(ZG,{label:IK.extensions,help:IK.extensionsHelp,children:(0,L.jsx)(oq,{value:n.extensions.join(` `),label:IK.extensions,placeholder:IK.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:gq(e)}})})}):null,(0,L.jsx)(ZG,{label:IK.timeout,help:IK.timeoutHelp,children:(0,L.jsx)(sq,{value:n.timeoutMs,label:`Lint ${IK.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,L.jsx)(_q,{replaced:i})]})]})]})}function yq({config:e,save:t}){let n=e.lobby.web;return(0,L.jsx)(Mz,{prominent:!0,title:yK.lobby,children:(0,L.jsxs)(QG,{children:[XK.map(n=>(0,L.jsx)(pq,{config:e,item:n,save:t},n.id)),(0,L.jsx)(ZG,{label:CK,help:wK,children:(0,L.jsx)($G,{value:String(e.lobby.maxPlanningRounds),items:TK.map(e=>({value:String(e),label:tq(e)})),label:CK,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,L.jsx)(ZG,{label:EK,help:DK,children:(0,L.jsx)($G,{value:String(e.lobby.splitPlanAbove),items:OK.map(e=>({value:String(e),label:nq(e)})),label:EK,onChange:e=>void t({lobby:{splitPlanAbove:Number(e)}})})}),(0,L.jsx)(ZG,{label:kK,help:AK,children:(0,L.jsx)(cq,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,L.jsx)(aq,{label:jK,help:MK,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})})]})})}function bq({config:e,models:t,save:n}){let r=e.classifier,i=LK.find(e=>e.id===r.provider)?.label;return(0,L.jsx)(Mz,{prominent:!0,title:yK.classifier,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(aq,{label:zK.enabled,help:zK.enabledHelp,checked:r.enabled,onChange:e=>void n({classifier:{enabled:e}})}),(0,L.jsx)(ZG,{label:zK.host,children:(0,L.jsx)($G,{value:r.provider,items:LK.map(e=>({value:e.id,label:e.label})),label:zK.host,onChange:e=>void n({classifier:{provider:e}})})}),(0,L.jsx)(ZG,{label:zK.model,help:zK.modelHelp,children:(0,L.jsx)(oq,{value:r.model,label:zK.model,placeholder:`the host's default`,onSave:e=>void n({classifier:{model:e}})})}),(0,L.jsx)(ZG,{label:zK.key,help:zK.keyNote,children:(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground sm:text-right`,children:i??r.provider})}),RK.map(e=>(0,L.jsx)(aq,{label:e.label,help:e.help,checked:r.features[e.id],onChange:t=>void n({classifier:{features:{[e.id]:t}}})},e.id)),(0,L.jsx)(ZG,{label:zK.cheap,help:zK.cheapHelp,children:(0,L.jsx)(iq,{value:r.effort.cheapModel,models:t,label:zK.cheap,none:!0,onChange:e=>void n({classifier:{effort:{cheapModel:e}}})})})]})})}function xq(){let e=fG(),t=async e=>{if(!e)return mG();let t=await pG();t===`granted`?V.success(BK.notificationsOn):V.error(t===`unsupported`?BK.notificationsUnsupported:BK.notificationsBlocked)};return(0,L.jsx)(Mz,{prominent:!0,title:yK.notifications,children:(0,L.jsx)(QG,{children:(0,L.jsx)(aq,{label:BK.notificationsLabel,help:BK.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function Sq(){let{available:e,install:t}=y(),n=b(),r=x();return(0,L.jsx)(Mz,{prominent:!0,title:yK.install,children:(0,L.jsxs)(QG,{children:[(0,L.jsx)(ZG,{label:BK.installLabel,help:n?BK.installedNow:BK.installHelp,children:n?null:(0,L.jsx)(`div`,{className:`flex sm:justify-end`,children:(0,L.jsx)(Y,{label:BK.installButton,icon:wm,tone:`primary`,onClick:()=>e?void t().then(()=>V.success(BK.installDone)):V.warning(BK.installUnavailable)})})}),r.supported?(0,L.jsx)(ZG,{label:BK.fullscreenLabel,help:BK.fullscreenHelp,children:(0,L.jsx)(`div`,{className:`flex sm:justify-end`,children:(0,L.jsx)(Y,{label:r.on?BK.fullscreenOn:BK.fullscreenOff,icon:r.on?mh:nh,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var Cq=[`Agents`,`Workflow`,`Linting`,`Lobby`,`Classifier`,`Appearance & notifications`];function wq({config:e,models:t,onConfig:n}){let[r,i]=(0,m.useState)(`Agents`),a=(0,m.useRef)(Promise.resolve()),o=e=>{let t=async()=>{try{return n((await De(`settings.set`,{patch:e})).config),V.success(BK.saved),!0}catch(e){return V.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},r=a.current.then(t,t);return a.current=r,r};return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-6 px-5 pt-5 pb-dock sm:px-8 sm:pt-8`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:BK.title}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:BK.intro})]}),(0,L.jsx)(`nav`,{"aria-label":`Settings sections`,className:`-mx-1 flex flex-wrap gap-1 border-b border-border pb-3`,children:Cq.map(e=>(0,L.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-current":r===e?`page`:void 0,"aria-controls":`settings-${e.split(` `)[0]}`,onClick:()=>i(e),className:q(`h-8 rounded-lg border border-transparent px-3 text-sm font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,r===e?`btn-raised bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e},e))}),(0,L.jsx)(`div`,{id:`settings-Agents`,hidden:r!==`Agents`,"aria-hidden":r!==`Agents`,children:(0,L.jsx)(Mz,{prominent:!0,title:yK.agents,children:(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:lK.map(n=>(0,L.jsx)(dq,{kind:n,config:e,models:t,save:o},n))})})}),(0,L.jsx)(`div`,{id:`settings-Workflow`,hidden:r!==`Workflow`,"aria-hidden":r!==`Workflow`,children:(0,L.jsx)(mq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Linting`,hidden:r!==`Linting`,"aria-hidden":r!==`Linting`,children:(0,L.jsx)(vq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Lobby`,hidden:r!==`Lobby`,"aria-hidden":r!==`Lobby`,children:(0,L.jsx)(yq,{config:e,save:o})}),(0,L.jsx)(`div`,{id:`settings-Classifier`,hidden:r!==`Classifier`,"aria-hidden":r!==`Classifier`,children:(0,L.jsx)(bq,{config:e,models:t,save:o})}),(0,L.jsx)(`div`,{id:`settings-Appearance`,hidden:r!==`Appearance & notifications`,"aria-hidden":r!==`Appearance & notifications`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,L.jsx)(JK,{}),(0,L.jsx)(xq,{}),(0,L.jsx)(Sq,{})]})})]})}function Tq(){return(0,L.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-5 pt-5 pb-dock sm:px-8 sm:pt-8`,role:`status`,"aria-label":BK.loading,children:[0,1,2,3].map(e=>(0,L.jsx)(`div`,{className:`h-48 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function Eq(){let e=sO(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,L.jsx)(tO,{message:`${BK.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,L.jsx)(wq,{config:t,models:e.data?.models??[],onConfig:i}):(0,L.jsx)(Tq,{})}function Dq(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var Oq=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,kq=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style`.split(` `)),Aq=new Set(`class id title role aria-label aria-hidden colspan rowspan scope`.split(` `));function jq(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>5e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function Mq(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function Nq(e){if(!kq.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,Mq(t.value)):Aq.has(t.name)||e.removeAttribute(t.name);e.localName===`style`&&(e.textContent=Mq(e.textContent??``));for(let t of[...e.children])Nq(t)}function Pq(e,t){try{return Fq(e,t??Dq())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Oq}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function Fq(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])Nq(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Oq}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${Mq(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function Iq({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>Pq(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,L.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:q(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,L.jsxs)(`div`,{ref:s,className:q(`group/mock relative h-80 w-full overflow-hidden rounded-lg border bg-background`,n),children:[(0,L.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,tabIndex:a?-1:void 0,className:q(`absolute top-0 left-0 origin-top-left border-0`,a&&`pointer-events-none`),style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,L.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`absolute inset-0 flex items-end justify-end p-2 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:ring-inset`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity group-hover/mock:opacity-100 group-focus-within/mock:opacity-100`,children:[(0,L.jsx)(eh,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var Lq=/\s*\(recommended\)\s*$/i,Rq=1024,zq=e=>e.replace(Lq,``);function Bq(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function Vq({option:e}){let t=zq(e.label);return Bq(e)?(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,L.jsx)(Iq,{preview:e.htmlPreview,label:t,minWidth:Rq,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,L.jsx)(`img`,{src:N(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,L.jsx)(kz,{text:e.preview,className:q(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,L.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function Hq({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Sf(),l=(0,m.useRef)(null),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),p=e[d],h=e.length-1;(0,m.useEffect)(()=>s?.(d),[d,s]),(0,m.useLayoutEffect)(()=>{let e=l.current;e&&(e.scrollLeft=d*e.clientWidth),u.current?.focus()},[]);let g=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),h),n=l.current;f(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[h,c]);(0,m.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=d*e.clientWidth});return t.observe(e),()=>t.disconnect()},[d]);function _(){let e=l.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==d&&t>=0&&t<=h&&f(t)}function v(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),g(d+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),g(t.key===`Home`?0:h);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),g(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(d))}let y=r.includes(d);return(0,L.jsxs)(`div`,{ref:u,tabIndex:-1,"data-autofocus":``,onKeyDown:v,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 sm:px-5`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,L.jsx)(fh,{"aria-hidden":`true`})}),(0,L.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===d,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>g(t),className:q(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,t===d?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,L.jsx)(`span`,{className:`truncate`,children:zq(e.label)}),r.includes(t)?(0,L.jsx)(Hp,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{ref:l,onScroll:_,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,L.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${zq(t.label)}`,"aria-hidden":n!==d,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 px-4 py-4 sm:px-14`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,L.jsx)(`span`,{className:`font-medium`,children:zq(t.label)}),Lq.test(t.label)?(0,L.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,L.jsx)(kz,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(Vq,{option:t})})]},n))}),d>0?(0,L.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:`Previous · ←`,onClick:()=>g(d-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full max-sm:hidden`,children:(0,L.jsx)(Kp,{"aria-hidden":`true`})}):null,d<h?(0,L.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:`Next · →`,onClick:()=>g(d+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full max-sm:hidden`,children:(0,L.jsx)(Jp,{"aria-hidden":`true`})}):null]}),(0,L.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3 sm:px-5`,children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`←→`,children:`option`}),a?(0,L.jsx)(DD,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,L.jsx)(DD,{chord:`Esc`,children:`back`})]}),a&&p?(0,L.jsxs)(J,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,L.jsx)(`span`,{className:`truncate`,children:zq(p.label)})]}):null]})]})}function Uq(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function Wq({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,L.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>Uq(e,()=>void d(),()=>{o||r()}),children:[(0,L.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,L.jsx)(KO,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(J,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,L.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var Gq=1200;function Kq({question:e}){let[t,n]=(0,m.useState)(),r=ID(t!==void 0,FD.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:i.map(({option:e,index:t,mockup:r})=>(0,L.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,L.jsx)(Iq,{preview:r,label:zq(e.label),frameWidth:Gq,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,L.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,zq(e.label)]})]},t))}),(0,L.jsx)(OD,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,L.jsx)(Hq,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function qq({questions:e}){return(0,L.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised flex flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":uV(e.from)},children:[(0,L.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,L.jsx)(aV,{source:e.from,className:`size-3`}),sV(e.from)]}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,L.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,L.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,L.jsx)(Kq,{question:e})]},t))})}function Jq({message:e}){let t=e.decided??[];return t.length?(0,L.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:t.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2 rounded-lg bg-muted/60 px-2.5 py-1.5 text-sm`,children:[(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-success`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:q(`font-medium`,cV(e.from)),children:sV(e.from)}),` `,e.question,` → `,(0,L.jsx)(`strong`,{children:e.answer}),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`decided by the classifier (`,e.probability.toFixed(2),`); comment on the plan to overrule`]})]})]},t))}):null}function Yq({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await De(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,L.jsxs)(J,{size:`xs`,variant:`ghost`,disabled:l,onClick:()=>a(!0),className:`text-muted-foreground`,children:[(0,L.jsx)(Ih,{"aria-hidden":`true`}),`Edit`]}):null;return(0,L.jsx)(gV,{time:e.at>0?JO(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,below:d,children:i?(0,L.jsx)(Wq,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,L.jsx)(kz,{text:c.text})})}function Xq({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,L.jsx)(Yq,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,L.jsxs)(hV,{source:`PLANNER`,name:`Panel`,time:e.at>0?JO(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,L.jsx)(qq,{questions:i}):(0,L.jsx)(kz,{text:e.text}),(0,L.jsx)(Jq,{message:e})]})}function Zq({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,L.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,L.jsx)(_V,{children:t}):null,e.map((e,t)=>(0,L.jsx)(Xq,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,L.jsx)(hV,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,aside:`the panel is thinking`,children:(0,L.jsx)(vV,{className:`mt-1`})}):null]})}var Qq=`ORACLE`,$q=`No draft yet.`,eJ=`The draft appears after the panel's first round.`,tJ=`What each seat needs`,nJ=[`backend`,`designer`,`qa`,`researcher`],rJ={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},iJ=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,aJ={ORACLE:`Chairs the panel, and settles the last round alone.`,DEV:`Code, data and the APIs it touches.`,DESIGN:`Screens, flows and the words on them.`,QA:`Tests, edge cases and what could break.`,RESEARCH:`Prior art, docs and sources.`},oJ=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function sJ(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function cJ(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function lJ(e,t){return`${e} ${t}${e===1?``:`s`}`}function uJ(e){return e.round===0&&e.messages.length===0&&!e.busy}function dJ(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${rJ[t.member]} failed`).split(`
|
|
97
97
|
`)[0]}function fJ(e){let t=[],n=dJ(e);return e.busy?t.push(cJ(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${lJ(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(cJ(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 pJ(e,t){let n=rJ[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`:lJ(o,`question`)}}function mJ(e){let t=e.questions.filter(e=>e.from===Qq).length;return[{label:Qq,seated:!0,working:e.busy,text:e.busy?`chairing`:t?lJ(t,`question`):`·`},...nJ.map(t=>pJ(t,e))]}function hJ(e){let t=!1;return e.split(`
|
|
98
|
-
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function gJ({notes:e}){return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>(0,L.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 _J=[],vJ=(0,m.memo)(function({row:e,notes:t,onComment:n}){let r=e.text.trim(),i=()=>n(r);return(0,L.jsxs)(`li`,{className:`group/line [contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,L.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:t.length>0?(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,L.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,L.jsx)(kz,{text:e.text})}),(0,L.jsx)(J,{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,L.jsx)(oh,{"aria-hidden":`true`})})]}),(0,L.jsx)(gJ,{notes:t})]})});function yJ({draft:e,comments:t,onComment:n}){let r=(0,m.useMemo)(()=>hJ(e),[e]),i=bz(r.length);return(0,L.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:r.slice(0,i).map((e,r)=>e.text.trim()?(0,L.jsx)(vJ,{row:e,notes:t.get(e.text.trim())??_J,onComment:n},r):(0,L.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},r))})}function bJ({notes:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:tJ,children:(0,L.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`dt`,{className:q(`w-20 shrink-0 font-medium`,wV(e.from)),children:CV(e.from)}),(0,L.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(kz,{text:e.text})})]},t))})})}function xJ({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:q(`inline-flex items-center gap-1.5 font-medium`,e.seated?wV(e.label):`text-muted-foreground`),children:[(0,L.jsx)(xV,{source:e.label,className:`size-3.5`}),CV(e.label)]}),e.working&&!t?(0,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}):null,(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function SJ({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,L.jsx)(`li`,{className:q(i,`bg-muted`),children:(0,L.jsx)(xJ,{cell:e,intro:t})});let a=async()=>{await H(`planner.toggleSeat`,{member:r})&&n()};return(0,L.jsx)(`li`,{children:(0,L.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,L.jsx)(UV,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${CV(e.label)} sits on the panel`}),(0,L.jsx)(xJ,{cell:e,intro:t})]})})}function CJ({cells:e,intro:t,onToggled:n}){return(0,L.jsx)(`ul`,{"aria-label":`Panel`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,L.jsx)(SJ,{cell:e,intro:t,onToggled:n},e.label))})}function wJ({cell:e,onToggled:t}){let{member:n}=e,r=CV(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,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.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,L.jsx)(xV,{source:e.label,className:`size-3.5`})}),(0,L.jsx)(`span`,{className:q(`truncate text-sm font-semibold`,e.seated?wV(e.label):`text-muted-foreground`),children:r})]}),n?(0,L.jsx)(UV,{checked:e.seated,onCheckedChange:()=>void TJ(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:aJ[e.label]}),(0,L.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":EV(e.label)};return n?(0,L.jsx)(`li`,{style:o,children:(0,L.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,L.jsx)(`li`,{style:o,children:(0,L.jsx)(`div`,{className:i,children:a})})}async function TJ(e,t){await H(`planner.toggleSeat`,{member:e})&&t()}function EJ({cells:e,onToggled:t}){return(0,L.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,L.jsx)(wJ,{cell:e,onToggled:t},e.label))})}function DJ({snap:e}){let t=fJ(e),n=!e.busy&&dJ(e)!==void 0;return(0,L.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,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}):null,t.join(` · `)]})}function OJ(){return(0,L.jsx)(Y,{label:`Previous plans`,text:`Previous`,icon:Wh,shortcut:`H`,onClick:()=>GD(WD(`plan`,`previous`))})}function kJ({snap:e,onDone:t}){let n=aO(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await H(e,{})&&t()};return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.questions.length>0&&!e.busy?(0,L.jsx)(Y,{label:`Answer questions`,icon:ih,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,L.jsx)(Y,{label:`Retry`,icon:Jh,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,L.jsx)(OJ,{}),(0,L.jsx)(Y,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:Qh,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,L.jsx)(ck,{icon:Mm,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 H(`planner.new`,{}).then(t)})]})}function AJ({snap:e,onDone:t}){return(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border px-5 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,L.jsx)(DJ,{snap:e})]}),(0,L.jsx)(kJ,{snap:e,onDone:t})]}),(0,L.jsx)(CJ,{cells:mJ(e),intro:!1,onToggled:t})]})}var jJ=()=>GD(WD(`plan`,`previous`)),MJ=e=>GD(WD(`plan`,`previous`,e));function NJ(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?ZO(Math.max(0,t)):``}function PJ(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,NJ(e.updatedAt)].filter(Boolean).join(` · `)}function FJ({plan:e,selected:t}){return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>MJ(e.id),className:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,L.jsx)(gB,{variant:`secondary`,children:`draft`}):null]}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:PJ(e,e.messages)})]})})}function IJ({id:e,onGone:t}){let n=sO(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,L.jsx)(tO,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await H(`planner.previousOpen`,{id:e})&&GD(WD(`plan`))},o=async()=>{await H(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await H(`planner.previousDelete`,{id:e})&&t()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Carry on planning`,text:`Carry on`,icon:Rh,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,L.jsx)(Y,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?wp:Ep,shortcut:`E`,onClick:()=>void o()}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,PJ(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,L.jsxs)(Mz,{title:`Draft plan`,children:[r.draft?(0,L.jsx)(kz,{text:r.draft}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,L.jsx)(bJ,{notes:r.notes})]}),(0,L.jsx)(Mz,{title:`Conversation`,children:(0,L.jsx)(Zq,{messages:r.messages,readOnly:!0})})]})}function LJ({id:e}){let t=BO(),[n,r]=(0,m.useState)(!1),i=sO(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,L.jsx)(tO,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,L.jsxs)(WO,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,L.jsx)(Y,{label:`Back to the current plan`,icon:Ap,iconOnly:!0,onClick:()=>GD(WD(`plan`))}),(0,L.jsx)(Y,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?Wh:Ep,pressed:n,onClick:()=>{r(e=>!e),jJ()}})]}),s=i.data?a.length===0?(0,L.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,L.jsx)(`ul`,{className:q(vB,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,L.jsx)(FJ,{plan:t,selected:t.id===e},t.id))}):(0,L.jsx)(GO,{});return(0,L.jsx)(UO,{wide:t,list:(0,L.jsxs)(L.Fragment,{children:[o,s]}),detail:e?(0,L.jsx)(IJ,{id:e,onGone:()=>{i.reload(),jJ()}},e):null,open:e!==void 0,onClose:jJ,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function RJ({line:e,onClose:t,onSent:n}){let r=ID(e!==void 0,FD.confirm);return(0,L.jsx)(OD,{open:e!==void 0&&r,onOpenChange:e=>!e&&t(),label:`Comment on this line`,className:`max-w-xl`,children:(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-base font-medium`,children:`Comment on this line`}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-3 text-sm break-words text-muted-foreground`,children:e})]}),(0,L.jsx)(kB,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async r=>e===void 0||!await H(`planner.commentLine`,{line:e,text:r.trim()})?!1:(n(e,r.trim()),t(),!0)})]})})}function zJ({limit:e}){return e<=0?null:(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,L.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function BJ({snap:e,onDone:t}){let n=mJ(e);return(0,L.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-8 pb-dock sm:px-8 sm:pt-10`,children:(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,L.jsx)(Xh,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,L.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:iJ})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,L.jsx)(OJ,{}),(0,L.jsx)(zJ,{limit:e.limit})]})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:`The panel`,right:sJ(n)})}),(0,L.jsx)(EJ,{cells:n,onToggled:t})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:`How a plan comes together`})}),(0,L.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:oJ.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised relative flex gap-3 rounded-xl border p-3.5`,children:[(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(Op,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,L.jsx)(DD,{chord:`/`,children:`write`}),(0,L.jsx)(DD,{chord:`Enter`,children:`send to the panel`})]})]})})}function VJ({snap:e,wide:t}){let{ref:n,onScroll:r}=aU(JSON.stringify(e.messages));return(0,L.jsxs)(VO,{className:`flex flex-col`,children:[(0,L.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,L.jsx)(jz,{title:`Conversation`,className:`w-full`})}),(0,L.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,L.jsx)(Zq,{messages:e.messages,busy:e.busy})})]})}function HJ({snap:e,comments:t,onComment:n,wide:r}){return(0,L.jsxs)(VO,{className:`flex flex-col`,children:[(0,L.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,L.jsx)(jz,{title:`Draft plan`,className:`w-full`})}),(0,L.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,L.jsx)(yJ,{draft:e.draft,comments:t,onComment:n}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.busy?eJ:$q}),(0,L.jsx)(bJ,{notes:e.notes})]})]})}function UJ({snap:e,reload:t}){let n=BO(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(new Map);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(AJ,{snap:e,onDone:t}),(0,L.jsxs)(`div`,{className:n?`grid min-h-0 flex-1 grid-cols-[minmax(0,46fr)_minmax(0,54fr)] grid-rows-[minmax(0,1fr)] divide-x divide-border`:`flex flex-col divide-y divide-border`,children:[(0,L.jsx)(VJ,{snap:e,wide:n}),(0,L.jsx)(HJ,{snap:e,comments:a,onComment:i,wide:n})]}),(0,L.jsx)(RJ,{line:r,onClose:()=>i(void 0),onSent:(e,t)=>o(n=>new Map(n).set(e,[...n.get(e)??[],t]))})]})}function WJ({rest:e=[]}){return e[0]===`previous`?(0,L.jsx)(LJ,{id:e[1]}):(0,L.jsx)(GJ,{})}function GJ(){let e=sO(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,L.jsx)(tO,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,L.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=uJ(t);return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,L.jsx)(BJ,{snap:t,onDone:e.reload}):(0,L.jsx)(UJ,{snap:t,reload:e.reload})})}var KJ=`Describe a small change in the box below and one agent makes it now, beside any running task.`;function qJ(e){return e.prompt.split(`
|
|
98
|
+
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function gJ({notes:e}){return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>(0,L.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 _J=[],vJ=(0,m.memo)(function({row:e,notes:t,onComment:n}){let r=e.text.trim(),i=()=>n(r);return(0,L.jsxs)(`li`,{className:`group/line [contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,L.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:t.length>0?(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,L.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,L.jsx)(kz,{text:e.text})}),(0,L.jsx)(J,{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,L.jsx)(oh,{"aria-hidden":`true`})})]}),(0,L.jsx)(gJ,{notes:t})]})});function yJ({draft:e,comments:t,onComment:n}){let r=(0,m.useMemo)(()=>hJ(e),[e]),i=bz(r.length);return(0,L.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:r.slice(0,i).map((e,r)=>e.text.trim()?(0,L.jsx)(vJ,{row:e,notes:t.get(e.text.trim())??_J,onComment:n},r):(0,L.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},r))})}function bJ({notes:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:tJ,children:(0,L.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`dt`,{className:q(`w-20 shrink-0 font-medium`,cV(e.from)),children:sV(e.from)}),(0,L.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(kz,{text:e.text})})]},t))})})}function xJ({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:q(`inline-flex items-center gap-1.5 font-medium`,e.seated?cV(e.label):`text-muted-foreground`),children:[(0,L.jsx)(aV,{source:e.label,className:`size-3.5`}),sV(e.label)]}),e.working&&!t?(0,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}):null,(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function SJ({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,L.jsx)(`li`,{className:q(i,`bg-muted`),children:(0,L.jsx)(xJ,{cell:e,intro:t})});let a=async()=>{await H(`planner.toggleSeat`,{member:r})&&n()};return(0,L.jsx)(`li`,{children:(0,L.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,L.jsx)(cH,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${sV(e.label)} sits on the panel`}),(0,L.jsx)(xJ,{cell:e,intro:t})]})})}function CJ({cells:e,intro:t,onToggled:n}){return(0,L.jsx)(`ul`,{"aria-label":`Panel`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,L.jsx)(SJ,{cell:e,intro:t,onToggled:n},e.label))})}function wJ({cell:e,onToggled:t}){let{member:n}=e,r=sV(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,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.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,L.jsx)(aV,{source:e.label,className:`size-3.5`})}),(0,L.jsx)(`span`,{className:q(`truncate text-sm font-semibold`,e.seated?cV(e.label):`text-muted-foreground`),children:r})]}),n?(0,L.jsx)(cH,{checked:e.seated,onCheckedChange:()=>void TJ(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:aJ[e.label]}),(0,L.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":uV(e.label)};return n?(0,L.jsx)(`li`,{style:o,children:(0,L.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,L.jsx)(`li`,{style:o,children:(0,L.jsx)(`div`,{className:i,children:a})})}async function TJ(e,t){await H(`planner.toggleSeat`,{member:e})&&t()}function EJ({cells:e,onToggled:t}){return(0,L.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,L.jsx)(wJ,{cell:e,onToggled:t},e.label))})}function DJ({snap:e}){let t=fJ(e),n=!e.busy&&dJ(e)!==void 0;return(0,L.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,L.jsx)($D,{className:`size-3.5`,"aria-hidden":`true`}):null,t.join(` · `)]})}function OJ(){return(0,L.jsx)(Y,{label:`Previous plans`,text:`Previous`,icon:Wh,shortcut:`H`,onClick:()=>GD(WD(`plan`,`previous`))})}function kJ({snap:e,onDone:t}){let n=aO(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await H(e,{})&&t()};return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.questions.length>0&&!e.busy?(0,L.jsx)(Y,{label:`Answer questions`,icon:ih,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,L.jsx)(Y,{label:`Retry`,icon:Jh,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,L.jsx)(OJ,{}),(0,L.jsx)(Y,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:Qh,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,L.jsx)(ck,{icon:Mm,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 H(`planner.new`,{}).then(t)})]})}function AJ({snap:e,onDone:t}){return(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border px-5 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,L.jsx)(DJ,{snap:e})]}),(0,L.jsx)(kJ,{snap:e,onDone:t})]}),(0,L.jsx)(CJ,{cells:mJ(e),intro:!1,onToggled:t})]})}var jJ=()=>GD(WD(`plan`,`previous`)),MJ=e=>GD(WD(`plan`,`previous`,e));function NJ(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?ZO(Math.max(0,t)):``}function PJ(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,NJ(e.updatedAt)].filter(Boolean).join(` · `)}function FJ({plan:e,selected:t}){return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>MJ(e.id),className:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,L.jsx)(gB,{variant:`secondary`,children:`draft`}):null]}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:PJ(e,e.messages)})]})})}function IJ({id:e,onGone:t}){let n=sO(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,L.jsx)(tO,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await H(`planner.previousOpen`,{id:e})&&GD(WD(`plan`))},o=async()=>{await H(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await H(`planner.previousDelete`,{id:e})&&t()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Carry on planning`,text:`Carry on`,icon:Rh,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,L.jsx)(Y,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?wp:Ep,shortcut:`E`,onClick:()=>void o()}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,PJ(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,L.jsxs)(Mz,{title:`Draft plan`,children:[r.draft?(0,L.jsx)(kz,{text:r.draft}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,L.jsx)(bJ,{notes:r.notes})]}),(0,L.jsx)(Mz,{title:`Conversation`,children:(0,L.jsx)(Zq,{messages:r.messages,readOnly:!0})})]})}function LJ({id:e}){let t=BO(),[n,r]=(0,m.useState)(!1),i=sO(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,L.jsx)(tO,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,L.jsxs)(WO,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,L.jsx)(Y,{label:`Back to the current plan`,icon:Ap,iconOnly:!0,onClick:()=>GD(WD(`plan`))}),(0,L.jsx)(Y,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?Wh:Ep,pressed:n,onClick:()=>{r(e=>!e),jJ()}})]}),s=i.data?a.length===0?(0,L.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,L.jsx)(`ul`,{className:q(vB,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,L.jsx)(FJ,{plan:t,selected:t.id===e},t.id))}):(0,L.jsx)(GO,{});return(0,L.jsx)(UO,{wide:t,list:(0,L.jsxs)(L.Fragment,{children:[o,s]}),detail:e?(0,L.jsx)(IJ,{id:e,onGone:()=>{i.reload(),jJ()}},e):null,open:e!==void 0,onClose:jJ,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function RJ({line:e,onClose:t,onSent:n}){let r=ID(e!==void 0,FD.confirm);return(0,L.jsx)(OD,{open:e!==void 0&&r,onOpenChange:e=>!e&&t(),label:`Comment on this line`,className:`max-w-xl`,children:(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-base font-medium`,children:`Comment on this line`}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-3 text-sm break-words text-muted-foreground`,children:e})]}),(0,L.jsx)(kB,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async r=>e===void 0||!await H(`planner.commentLine`,{line:e,text:r.trim()})?!1:(n(e,r.trim()),t(),!0)})]})})}function zJ({limit:e}){return e<=0?null:(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,L.jsx)(`span`,{className:q(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,L.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function BJ({snap:e,onDone:t}){let n=mJ(e);return(0,L.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-8 pb-dock sm:px-8 sm:pt-10`,children:(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,L.jsx)(Xh,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,L.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:iJ})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,L.jsx)(OJ,{}),(0,L.jsx)(zJ,{limit:e.limit})]})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:`The panel`,right:sJ(n)})}),(0,L.jsx)(EJ,{cells:n,onToggled:t})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,L.jsx)(jz,{title:`How a plan comes together`})}),(0,L.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:oJ.map((e,t)=>(0,L.jsxs)(`li`,{className:`card-raised relative flex gap-3 rounded-xl border p-3.5`,children:[(0,L.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,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,L.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(Op,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,L.jsx)(DD,{chord:`/`,children:`write`}),(0,L.jsx)(DD,{chord:`Enter`,children:`send to the panel`})]})]})})}function VJ({snap:e,wide:t}){let{ref:n,onScroll:r}=tV(JSON.stringify(e.messages));return(0,L.jsxs)(VO,{className:`flex flex-col`,children:[(0,L.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,L.jsx)(jz,{title:`Conversation`,className:`w-full`})}),(0,L.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,L.jsx)(Zq,{messages:e.messages,busy:e.busy})})]})}function HJ({snap:e,comments:t,onComment:n,wide:r}){return(0,L.jsxs)(VO,{className:`flex flex-col`,children:[(0,L.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,L.jsx)(jz,{title:`Draft plan`,className:`w-full`})}),(0,L.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,L.jsx)(yJ,{draft:e.draft,comments:t,onComment:n}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.busy?eJ:$q}),(0,L.jsx)(bJ,{notes:e.notes})]})]})}function UJ({snap:e,reload:t}){let n=BO(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(new Map);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(AJ,{snap:e,onDone:t}),(0,L.jsxs)(`div`,{className:n?`grid min-h-0 flex-1 grid-cols-[minmax(0,46fr)_minmax(0,54fr)] grid-rows-[minmax(0,1fr)] divide-x divide-border`:`flex flex-col divide-y divide-border`,children:[(0,L.jsx)(VJ,{snap:e,wide:n}),(0,L.jsx)(HJ,{snap:e,comments:a,onComment:i,wide:n})]}),(0,L.jsx)(RJ,{line:r,onClose:()=>i(void 0),onSent:(e,t)=>o(n=>new Map(n).set(e,[...n.get(e)??[],t]))})]})}function WJ({rest:e=[]}){return e[0]===`previous`?(0,L.jsx)(LJ,{id:e[1]}):(0,L.jsx)(GJ,{})}function GJ(){let e=sO(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,L.jsx)(tO,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,L.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=uJ(t);return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,L.jsx)(BJ,{snap:t,onDone:e.reload}):(0,L.jsx)(UJ,{snap:t,reload:e.reload})})}var KJ=`Describe a small change in the box below and one agent makes it now, beside any running task.`;function qJ(e){return e.prompt.split(`
|
|
99
99
|
`).find(e=>e.trim())?.trim()??`(empty)`}function JJ(e){return[...e].reverse()}function YJ(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 XJ(e,t){return e.startedAt?YJ((e.finishedAt??t)-e.startedAt):``}function ZJ(e,t){let n=e.model?`${e.model}${e.thinking?` · ${e.thinking}`:``}`:e.thinking??``;return[XJ(e,t),n,e.tools?`${e.tools} tool${e.tools===1?``:`s`}`:``,e.usage?.cost?`$${e.usage.cost.toFixed(2)}`:``].filter(Boolean).join(` · `)}function QJ(e){return e===`queued`?`Waiting for the quick fix ahead of it.`:e===`running`?`starting…`:e===`held`?`Not started.`:`No tool calls.`}function $J({job:e}){let t=e.status===`held`;return(0,L.jsxs)(L.Fragment,{children:[e.route?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Routed `,e.route]}):null,e.note&&t?(0,L.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,L.jsx)(Sg,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,L.jsxs)(`span`,{children:[`Held: `,e.note,`.`]})]}):null,e.note&&!t?(0,L.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,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Routed here by the oracle.`}):null]})}function eY({job:e}){let t=e.status===`running`;return e.steps.length===0?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[t?(0,L.jsx)($D,{className:`size-3.5`}):null,QJ(e.status)]}):(0,L.jsx)(`ol`,{className:`flex flex-col gap-1 text-sm`,children:e.steps.map((e,n)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:JO(e.at)}),(0,L.jsx)(`span`,{className:`flex h-5 w-3.5 shrink-0 items-center justify-center`,"aria-hidden":`true`,children:e.pending&&t?(0,L.jsx)($D,{className:`size-3.5`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}),(0,L.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:e.pending&&t?`${e.text}…`:e.text})]},n))})}function tY({job:e}){return e.status===`held`?(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Run anyway`,icon:Rh,tone:`primary`,shortcut:`R`,onClick:()=>void H(`quickfix.runAnyway`,{id:e.id})}),(0,L.jsx)(Y,{label:`Turn it into a task`,text:`Make it a task`,icon:Xm,shortcut:`T`,onClick:()=>void H(`quickfix.movedToTask`,{id:e.id})})]}):e.status!==`queued`&&e.status!==`running`?null:(0,L.jsx)(jO,{children:(0,L.jsx)(ck,{icon:um,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 H(`quickfix.cancel`,{id:e.id})})})}function nY({job:e,now:t}){return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Quick fix detail`,children:[(0,L.jsx)(tY,{job:e}),(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:qJ(e)}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:e.status}),ZJ(e,t)?(0,L.jsx)(`span`,{children:ZJ(e,t)}):null]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),e.prompt.trim().includes(`
|
|
100
|
-
`)?(0,L.jsx)(kz,{text:e.prompt}):null,(0,L.jsx)($J,{job:e}),(0,L.jsx)(Mz,{title:`Steps`,children:(0,L.jsx)(eY,{job:e})}),e.files?.length?(0,L.jsx)(Mz,{title:`Edited`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,L.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,L.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,L.jsx)(Mz,{title:`Report`,children:(0,L.jsx)(kz,{text:e.report})}):null]})}function rY({status:e}){if(e===`running`)return(0,L.jsx)($D,{className:`size-3.5`,"aria-label":`running`});let t={queued:gm,success:Hp,failed:Rg,timeout:Rg,cancelled:gh,held:Oh,running:gm}[e];return(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsx)(`span`,{className:`sr-only`,children:e})]})}function iY({job:e,selected:t,now:n,onSelect:r}){let i=XJ(e,n);return(0,L.jsx)(`li`,{children:(0,L.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(_B,`flex-row items-start gap-2.5 text-sm`),children:[(0,L.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,L.jsx)(rY,{status:e.status})}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:qJ(e)}),i?(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function aY({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(iY,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var oY=()=>GD(WD(`quickfix`)),sY=e=>GD(WD(`quickfix`,e));function cY(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 lY(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Bg,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:`font-medium text-foreground`,children:KJ})]})})}function uY({id:e}){let t=BO(),n=sO(`quickfix.list`,{},[`quickfix`]),r=JJ(n.data?.jobs??[]),i=cY(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,L.jsx)(lY,{}):(0,L.jsx)(dY,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function dY({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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Quick fixes`,count:String(r.length)}),n?(0,L.jsx)(aY,{jobs:r,selectedId:a,now:i,onSelect:sY}):(0,L.jsx)(GO,{})]});return(0,L.jsx)(UO,{wide:t,list:s,detail:o?(0,L.jsx)(nY,{job:o,now:i}):e?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:oY,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var fY={},pY=new Set;function mY(e){fY=e;for(let e of[...pY])e()}function hY(e){fY.taskId!==e&&mY({...fY,taskId:e})}function gY(e){(fY.session?.name!==e?.name||JSON.stringify(fY.session?.address)!==JSON.stringify(e?.address))&&mY({...fY,session:e})}function _Y(e){return pY.add(e),()=>{pY.delete(e)}}function vY(){return(0,m.useSyncExternalStore)(_Y,()=>fY,()=>fY)}function yY({entry:e}){let t=e.at?JO(e.at):``;return e.role===`note`?(0,L.jsxs)(`li`,{className:`text-center text-xs text-muted-foreground`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,L.jsxs)(`li`,{className:`flex flex-col items-end gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,L.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,L.jsx)(kz,{text:e.text})})]}):(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,L.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,L.jsx)(kz,{text:e.text})})]})}function bY({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t?(0,L.jsx)(`div`,{className:`flex self-center`,children:(0,L.jsx)(Y,{label:`Load earlier messages`,icon:Qp,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,L.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex flex-col gap-4`,children:e.map(e=>(0,L.jsx)(yY,{entry:e},e.id))})]})}function xY({address:e,empty:t}){let n=sO(`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 H(`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,L.jsx)(bY,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var SY={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},CY=[`this window`,`background`,`other terminal`],wY=`Nothing said yet.`,TY=`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.`,EY=`No other sessions. Start one below.`;function DY(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 OY(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 kY(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 AY(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[DY(e,t,n),...r.map(OY),...o.map(kY)]}function jY(e){return`${e} question${e===1?``:`s`} waiting for you`}function MY(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function NY(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function PY(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function FY({options:e,send:t}){return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,L.jsx)(J,{variant:`outline`,onClick:()=>void t({value:e}),children:e},e))})}function IY({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,L.jsx)(KO,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,L.jsx)(`div`,{className:`flex self-end`,children:(0,L.jsx)(Y,{label:`Send the answer`,text:`Send`,icon:Pp,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function LY({dialog:e,send:t}){return e.method===`select`?(0,L.jsx)(FY,{options:e.options??[],send:t}):e.method===`confirm`?(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(J,{onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,L.jsx)(J,{variant:`outline`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,L.jsx)(IY,{dialog:e,send:t})}function RY({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await H(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,L.jsxs)(`div`,{className:`card-raised flex flex-col gap-3 rounded-lg border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}),t.message?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.message}):null]}),(0,L.jsx)(LY,{dialog:t,send:r}),(0,L.jsx)(`div`,{className:`flex self-start`,children:(0,L.jsx)(Y,{label:`Put it away`,text:`Put away`,icon:Rg,onClick:()=>void r({cancelled:!0})})})]})}function zY({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,L.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,L.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:jY(t.length)}),t.map(t=>(0,L.jsx)(RY,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var BY={"this window":vh,background:Km,"other terminal":cg};function VY({where:e,className:t}){let n=BY[e];return(0,L.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function HY({task:e}){let t=e.progress;return(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(LU,{done:t.done,total:t.total}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function UY({entry:e}){let{key:t}=e;return e.where===`this window`?(0,L.jsx)(jO,{children:(0,L.jsx)(Y,{label:`Back to this window`,text:`Back to the Lobby`,icon:Ap,tone:`primary`,shortcut:`B`,onClick:()=>GD(`#/lobby`)})}):t?(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Move here`,icon:Mp,tone:`primary`,shortcut:`M`,onClick:()=>void H(`sessions.switch`,{key:t})}),(0,L.jsx)(ck,{icon:um,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 H(`sessions.stop`,{key:t})})]}):null}function WY({entry:e,lobby:t}){let n=PY(e);return e.where===`this window`?(0,L.jsx)(bY,{entries:t?.chat??[],more:!1,empty:wY}):n?(0,L.jsx)(xY,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:MY(e)},e.id):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:wY})}function GY({entry:e,lobby:t,onChanged:n}){return(0,L.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex flex-col gap-4`,children:[(0,L.jsx)(UY,{entry:e}),(0,L.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`h3`,{className:`flex items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,L.jsx)(VY,{where:e.where,className:`size-[1.1rem]`}),e.name]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:NY(e)}),e.task?(0,L.jsx)(HY,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:jY(e.waiting)}):null]}),e.where===`other terminal`?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:TY}):null,e.key?(0,L.jsx)(zY,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,L.jsx)(Mz,{title:`Conversation`,children:(0,L.jsx)(WY,{entry:e,lobby:t})})]})}function KY({entry:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{children:(0,L.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(_B,`flex-row items-start gap-2.5 text-sm`),children:[(0,L.jsx)(VY,{where:e.where,className:`mt-0.5`}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.name}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,L.jsx)($D,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,L.jsx)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-medium text-warning tabular-nums`,children:e.waiting}):null]})]})})}function qY({where:e,entries:t,selectedId:n,onSelect:r}){return(0,L.jsxs)(`section`,{"aria-label":SY[e],className:`flex flex-col`,children:[(0,L.jsx)(`h3`,{className:yB,children:(0,L.jsx)(jz,{title:SY[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,L.jsx)(`ul`,{className:vB,children:t.map(e=>(0,L.jsx)(KY,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function JY({entries:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`div`,{className:`flex flex-col pb-2`,children:CY.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,L.jsx)(qY,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var YY=()=>GD(`#/sessions`),XY=e=>GD(`#/sessions/${encodeURIComponent(e)}`);function ZY({windows:e}){return e.length===0?null:(0,L.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,L.jsx)(Mz,{title:`Other windows`,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.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 QY(){return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function $Y({id:e}){let t=BO(),n=aO(`status`).data,r=aO(`lobby`).data,i=aO(`prompts`).data?.prompts.length??0,a=sO(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,L.jsx)(tO,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=AY(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?PY(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(gY(l&&d?{name:d,address:l}:void 0),()=>gY(void 0)),[u,d]);let f=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Sessions`,count:String(o.length)}),a.data?(0,L.jsx)(JY,{entries:o,selectedId:s,onSelect:XY}):(0,L.jsx)(GO,{}),a.data&&o.length===1?(0,L.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:EY}):null,(0,L.jsx)(ZY,{windows:n?.windows??[]})]}),p=c?(0,L.jsx)(GY,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,L.jsx)(QY,{}):null;return(0,L.jsx)(UO,{wide:t,list:f,detail:p,open:!!e,onClose:YY,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function eX({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,L.jsxs)(`span`,{className:`tabular-nums`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,MU(jU(e,n,t)),` execution`]})}function tX({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=NU(r,e);return(0,L.jsxs)(`span`,{className:`tabular-nums`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,MU(e.workedMs+i)]})}function nX({timing:e,work:t,stopped:n=!1}){return t?(0,L.jsx)(tX,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,L.jsx)(eX,{timing:e,stopped:n},JSON.stringify(e)):(0,L.jsx)(`span`,{children:`Timing unavailable`})}var rX=`This directly merges the reviewed commit into main and pushes main. It does not create a pull request.`,iX={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function aX({delivery:e,title:t}){return(0,L.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,L.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,L.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,L.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,L.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,L.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,L.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,L.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,L.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,L.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 oX({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=n||t.status===`in_progress`||t.status===`successful`||!!i;return(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(J,{variant:`outline`,disabled:a,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:`Merge to main`}),(0,L.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.`:`Directly updates and pushes main. Requires confirmation.`}),i?(0,L.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function sX(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?De(`tasks.deliveryReview`,{taskId:t}):e===`defer`?De(`tasks.deliveryDefer`,r):De(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function cX({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=M(),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 lX(e){return e.scope.current===e.identity&&e.project===M()}function uX(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 sX(r,t.taskId,e.current.reviewId);lX(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){lX(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function dX(e){let t=cX(e),n=uX(t,e),r=ID(t.confirm,FD.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 fX({review:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,L.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:iX[e.current.status]}),e.current.error||e.error?(0,L.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.result?(0,L.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,L.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function pX({review:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,L.jsx)(oX,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,L.jsx)(oX,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsx)(J,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,L.jsx)(J,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function mX({review:e}){return(0,L.jsx)(OD,{open:e.slot,onOpenChange:e.setConfirm,label:`Confirm merge to main`,description:rX,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,L.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:`Merge to main?`}),(0,L.jsx)(`p`,{className:`text-sm`,children:rX}),(0,L.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,L.jsx)(J,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal,onClick:()=>void e.request(`merge_main`),children:`Confirm merge and push main`})]})]})})}function hX({title:e,review:t}){return(0,L.jsxs)(Mz,{title:`Completed work · delivery review`,right:iX[t.current.status],children:[(0,L.jsx)(aX,{delivery:t.current,title:e}),(0,L.jsx)(fX,{review:t}),(0,L.jsx)(pX,{review:t}),(0,L.jsx)(mX,{review:t})]})}function gX(e){let t=dX(e);return(0,L.jsx)(hX,{title:e.title,review:t})}var _X={open:mm,delivered:om,addressed:nm},vX={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function yX({comment:e}){let t=ZO(Date.now()-Date.parse(e.createdAt)),n=_X[e.status];return(0,L.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),vX[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function bX({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,L.jsxs)(`li`,{className:`card-raised rounded-lg border px-3.5 py-2.5`,children:[r?(0,L.jsx)(Wq,{text:s.text,onSave:async n=>{let r=await De(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,L.jsx)(kz,{text:s.text}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(yX,{comment:s}),n&&!r?(0,L.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function xX({taskId:e,finished:t,canComment:n}){let r=sO(`tasks.comments`,{taskId:e},[`tasks`]),i=aO(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,L.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,L.jsx)(jz,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,L.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,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,L.jsx)(bX,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var SX={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},CX={open:`open`,done:`done`,dropped:`abandoned`},wX={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 TX(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 EX=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function DX(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function OX(e){return e===`now`?`just now`:`${e} ago`}function kX(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[DX(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function AX(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 jX(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 MX({step:e,stopped:t}){let n=NU(!t,e);return(0,L.jsx)(`span`,{className:`tabular-nums`,children:MU((e.workedMs??0)+n)})}function NX(){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,L.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function PX({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=e.status===`done`,a=i?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,o=i?nm:mm;return(0,L.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm`,"data-step":r?`active`:e.status,children:[r?(0,L.jsx)(NX,{}):(0,L.jsx)(o,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${a}`}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,L.jsx)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),r?(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,L.jsx)(MX,{step:e,stopped:n}),(0,L.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,L.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]})}function FX({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,L.jsx)(Mz,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,L.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,L.jsx)(PX,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function IX({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,L.jsxs)(Mz,{title:`Full plan`,children:[(0,L.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,L.jsx)(Jp,{"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,L.jsx)(`div`,{id:r,children:(0,L.jsx)(kz,{text:e})}):null]})}function LX({detail:e,finished:t}){return e.plan&&e.planDetails?(0,L.jsx)(IX,{text:e.planDetails}):e.plan?(0,L.jsx)(Mz,{title:`Approved plan`,children:(0,L.jsx)(kz,{text:e.plan})}):e.proposal?(0,L.jsx)(Mz,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,L.jsx)(kz,{text:e.proposal})}):(0,L.jsx)(Mz,{title:`Plan`,children:(0,L.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 RX({amendments:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Amendments`,children:(0,L.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,L.jsx)(`li`,{className:`break-words`,children:e},e))})})}function zX({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,L.jsx)(Mz,{title:`Waiting on`,children:(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex gap-2`,children:[(0,L.jsx)(em,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,L.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,L.jsxs)(`li`,{className:`flex gap-2`,children:[(0,L.jsx)(fm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,L.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function BX({risk:e}){let t=wX[e.risk];return(0,L.jsxs)(Mz,{title:`QA risk`,right:TX(e),children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,L.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,L.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,L.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,L.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 VX({runs:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Recent runs`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,L.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function HX({detail:e,finished:t}){return(0,L.jsxs)(L.Fragment,{children:[e.steps.length>0?(0,L.jsx)(FX,{steps:e.steps,stopped:t}):null,e.request?(0,L.jsx)(Mz,{title:`Request`,children:(0,L.jsx)(kz,{text:e.request})}):null,(0,L.jsx)(LX,{detail:e,finished:t})]})}function UX({detail:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(RX,{amendments:e.amendments}),(0,L.jsx)(zX,{detail:e}),e.qaRisk?(0,L.jsx)(BX,{risk:e.qaRisk}):null,(0,L.jsx)(VX,{runs:e.runs})]})}function WX({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 GD(`#/lobby`);let t=M(),r=()=>n.current&&M()===t;try{let t=await De(`tasks.open`,{taskId:e.id});if(!r())return;let n=await De(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return GD(`#/lobby`);if(t.sessionId&&!t.key)return V.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return V.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await H(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&GD(`#/lobby`)}catch(e){r()&&V.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,L.jsx)(Y,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:Mp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function GX({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,L.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,L.jsxs)(`span`,{children:[n>0?(0,L.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,L.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function KX({planId:e}){let t=sO(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,L.jsxs)(L.Fragment,{children:[n.issue?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,L.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,L.jsx)(GX,{split:n.split}):null,(0,L.jsx)(Mz,{title:`Agreed plan`,children:(0,L.jsx)(kz,{text:n.brief})})]}):t.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function qX({row:e,onGone:t}){let n=async n=>{await H(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await H(`plans.discard`,{planId:e.id})&&t()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":e.title,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Start here`,icon:Rh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,L.jsx)(Y,{label:`Start in a new session`,text:`New session`,icon:og,shortcut:`N`,onClick:()=>void n(`session`)}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,L.jsx)(RU,{check:`open`,className:`mt-1.5`}),(0,L.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${OX(e.age)}`:``]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,L.jsx)(KX,{planId:e.id})]})}function JX({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=M();r(!0);try{let r=await De(`tasks.resume`,{taskId:e.id});if(M()!==n)return;let i=r.key;V(r.notice,i?{action:{label:`Watch`,onClick:()=>GD(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){M()===n&&V.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,L.jsx)(Y,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Rh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function YX(e){if(e.kind===`archived`)return{state:`archived`,rest:OX(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`} ${OX(e.age)}`:``;return{state:DX(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function XX(e){return e?[FU(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function ZX({row:e}){return e.progress?(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,L.jsx)(LU,{done:e.progress.done,total:e.progress.total}),(0,L.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function QX({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=YX(e);return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,L.jsx)(RU,{check:e.check,className:`mt-1.5`}),(0,L.jsxs)(`span`,{className:`sr-only`,children:[CX[e.check],`:`]}),(0,L.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,L.jsx)(`span`,{children:i}):null]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,XX(t),n].filter(Boolean).join(` · `)}),(0,L.jsx)(ZX,{row:e})]})}function $X({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await H(`tasks.restore`,{taskId:r},{undo:()=>void H(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await H(`tasks.archive`,{taskId:r},{undo:()=>void H(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await H(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void H(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function eZ({row:e,archive:t}){return e.check===`open`?(0,L.jsx)(ck,{label:`Archive`,icon:Ep,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,L.jsx)(Y,{label:`Archive`,icon:Ep,shortcut:`E`,onClick:()=>void t()})}function tZ({on:e,toggle:t}){return kO(`a`,t),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,L.jsx)(`span`,{children:`Auto`}),(0,L.jsx)(EG,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,L.jsx)(ED,{chord:`A`,className:`kbd-hint`})]})}),(0,L.jsx)(dO,{children:`Auto mode: the oracle decides without asking`})]})}function nZ(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=$X(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,L.jsxs)(jO,{children:[s?(0,L.jsx)(JX,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,L.jsx)(WX,{row:t,quiet:s}):null,t.kind===`task`?(0,L.jsx)(rZ,{taskId:t.id}):null,o?(0,L.jsx)(Y,{label:`Restore`,icon:Kh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,L.jsx)(tZ,{on:!!t.auto,toggle:a}):null,o?null:(0,L.jsx)(eZ,{row:t,archive:r}),(0,L.jsx)(ck,{icon:bg,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 rZ({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=M();try{let r=await De(`tasks.open`,{taskId:e});if(!t.current||M()!==n)return;r.notice&&V.info(r.notice);let i=await De(`status.get`,{});if(!t.current||M()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?GD(`#/sessions/${encodeURIComponent(a)}`):r.notice||V.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&M()===n&&V.error(e instanceof Error?e.message:String(e))}}return(0,L.jsx)(Y,{label:`Open task conversation`,text:`Conversation`,icon:ch,shortcut:`O`,onClick:()=>void n()})}function iZ(e){let{row:t}=e,n=t.kind===`plan`,r=sO(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=aO(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,L.jsx)(qX,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,L.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":t.title,children:[(0,L.jsx)(nZ,{...e}),(0,L.jsx)(QX,{row:t,task:a}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,L.jsx)(nX,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,L.jsx)(gX,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,L.jsx)(HX,{detail:r.data,finished:!o}):null,(0,L.jsx)(xX,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,L.jsx)(UX,{detail:r.data}):null,r.error&&!r.data?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function aZ({row:e}){return e.check===`open`&&e.progress?(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,L.jsx)(LU,{done:e.progress.done,total:e.progress.total}),(0,L.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function oZ(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function sZ({row:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(RU,{check:e.check,className:`mt-0.5`}),(0,L.jsxs)(`span`,{className:`sr-only`,children:[CX[e.check],`:`]}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,oZ(e),t&&`font-medium text-foreground`),children:e.title}),(0,L.jsx)(aZ,{row:e})]}),e.check===`open`?(0,L.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:kX(e)}):null,e.kind===`plan`?null:(0,L.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,L.jsx)(nX,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,L.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})})}function cZ({rows:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`div`,{className:`flex flex-col pb-2`,children:AX(e).map(({section:e,rows:r})=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:yB,children:(0,L.jsx)(jz,{title:SX[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,L.jsx)(`ul`,{className:vB,children:r.map(e=>(0,L.jsx)(sZ,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var lZ=()=>GD(WD(`tasks`)),uZ=e=>GD(WD(`tasks`,e));function dZ(){return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Jm,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{children:EX})]}),(0,L.jsx)(J,{onClick:()=>GD(WD(`plan`)),children:`Plan a task`})]})}function fZ({shown:e,count:t,onToggle:n}){return(0,L.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,L.jsx)(UV,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,L.jsx)(gB,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function pZ({id:e}){let t=BO(),[n,r]=(0,m.useState)(!1),i=sO(`tasks.list`,{},[`tasks`,`plans`]),a=sO(`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)(()=>(hY(u),()=>hY(void 0)),[u]),!i.data&&i.error)return(0,L.jsx)(tO,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,L.jsx)(dZ,{});let d=[...c,...s].find(e=>e.id===l),f=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Tasks`,count:jX(c),children:(0,L.jsx)(fZ,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:EX}):(0,L.jsx)(cZ,{rows:c,selectedId:l,onSelect:uZ}):(0,L.jsx)(GO,{})]}),p=d?(0,L.jsx)(iZ,{row:d,onGone:lZ,onChanged:i.reload},d.id):e?(0,L.jsx)(mZ,{}):null;return(0,L.jsx)(UO,{wide:t,list:f,detail:p,open:!!e,onClose:lZ,hint:`Select a task to see its detail.`,describe:`Task detail`})}function mZ(){return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var hZ={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function gZ(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function _Z(e){if(e.kind===`settings`)return(0,L.jsx)(Eq,{});if(e.kind===`sessions`)return(0,L.jsx)($Y,{id:gZ(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,L.jsx)($U,{});case`tasks`:return(0,L.jsx)(pZ,{id:gZ(e.rest)});case`plan`:return(0,L.jsx)(WJ,{rest:e.rest});case`quickfix`:return(0,L.jsx)(uY,{id:gZ(e.rest)});case`issues`:return(0,L.jsx)(eV,{rest:e.rest});case`metrics`:return(0,L.jsx)(WW,{});case`git`:return(0,L.jsx)(DB,{rest:e.rest});case`knowledge`:return(0,L.jsx)(HV,{agent:e.rest[0],file:e.rest[1]});case`excalidraw`:return(0,L.jsx)(YH,{id:gZ(e.rest)})}}function vZ(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var yZ={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 bZ(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:yZ[e]}function xZ(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=bZ(n);if(!e)return;t.code=e}return t.code?t:void 0}function SZ(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function CZ(e,t){let n=xZ(t);return n?SZ(e,n):!1}function wZ(e,t){for(let n of t)if(CZ(e,n.key))return n.action}function TZ(e,t){for(let n of t)if(CZ(e,n.key))return n.id}function EZ(e){return mO(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||LD()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function DZ(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`)bO(e.key===`j`?1:-1);else return!1;return!0}function OZ(e,t){let n=TZ(e,t.tabs),r=wZ(e,t.keys);return!n&&!r?!1:vZ(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||LD(),typing:mO(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 kZ(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=hZ[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(DZ(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function AZ(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){wZ(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&EZ(n)){t=0;return}if(OZ(n,e)){t=0;return}t=r?kZ(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 jZ=[{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`}],MZ=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(hZ).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`}],NZ=[{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`]]}],PZ=[{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`}],FZ=[{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 IZ({line:e}){return(0,L.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,L.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,L.jsx)(bD,{children:e},e))}):(0,L.jsx)(ED,{chord:e.label??``})}),(0,L.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function LZ(){return(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),NZ.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,L.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,L.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,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(ED,{chord:e}),t]},e))})]},e.id))]})}function RZ({title:e,lines:t}){return(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,L.jsx)(IZ,{line:e},e.id))]})}function zZ(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function BZ(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function VZ({open:e,onOpenChange:t,keys:n,tabs:r}){let i=ID(e,FD.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&&CZ(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,i,t,n]),(0,L.jsxs)(OD,{open:e&&i,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,L.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ED,{chord:`Esc`}),(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,L.jsx)(Rg,{"aria-hidden":`true`})})]})]}),(0,L.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,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(RZ,{title:`Everywhere`,lines:zZ(n)}),(0,L.jsx)(RZ,{title:`Jump to a tab`,lines:BZ(r)}),(0,L.jsx)(RZ,{title:`Navigation and editing`,lines:MZ}),(0,L.jsx)(RZ,{title:`Message box`,lines:jZ})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(RZ,{title:`Lists and panes`,lines:PZ}),(0,L.jsx)(LZ,{}),(0,L.jsx)(RZ,{title:`Questions`,lines:FZ})]})]})]})}function HZ(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function UZ(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(N(`/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 Te(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Te(r.error,r.code,n.status);return r.result}function WZ(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 GZ(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 KZ=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function qZ(e,t){let n=e.lastIndexOf(`
|
|
100
|
+
`)?(0,L.jsx)(kz,{text:e.prompt}):null,(0,L.jsx)($J,{job:e}),(0,L.jsx)(Mz,{title:`Steps`,children:(0,L.jsx)(eY,{job:e})}),e.files?.length?(0,L.jsx)(Mz,{title:`Edited`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,L.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,L.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,L.jsx)(Mz,{title:`Report`,children:(0,L.jsx)(kz,{text:e.report})}):null]})}function rY({status:e}){if(e===`running`)return(0,L.jsx)($D,{className:`size-3.5`,"aria-label":`running`});let t={queued:gm,success:Hp,failed:Rg,timeout:Rg,cancelled:gh,held:Oh,running:gm}[e];return(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsx)(`span`,{className:`sr-only`,children:e})]})}function iY({job:e,selected:t,now:n,onSelect:r}){let i=XJ(e,n);return(0,L.jsx)(`li`,{children:(0,L.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(_B,`flex-row items-start gap-2.5 text-sm`),children:[(0,L.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,L.jsx)(rY,{status:e.status})}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:qJ(e)}),i?(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function aY({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,L.jsx)(`ul`,{className:vB,children:e.map(e=>(0,L.jsx)(iY,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var oY=()=>GD(WD(`quickfix`)),sY=e=>GD(WD(`quickfix`,e));function cY(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 lY(){return(0,L.jsx)(qD,{className:`m-4 flex-1`,children:(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Bg,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{className:`font-medium text-foreground`,children:KJ})]})})}function uY({id:e}){let t=BO(),n=sO(`quickfix.list`,{},[`quickfix`]),r=JJ(n.data?.jobs??[]),i=cY(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,L.jsx)(tO,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,L.jsx)(lY,{}):(0,L.jsx)(dY,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function dY({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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Quick fixes`,count:String(r.length)}),n?(0,L.jsx)(aY,{jobs:r,selectedId:a,now:i,onSelect:sY}):(0,L.jsx)(GO,{})]});return(0,L.jsx)(UO,{wide:t,list:s,detail:o?(0,L.jsx)(nY,{job:o,now:i}):e?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:oY,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var fY={},pY=new Set;function mY(e){fY=e;for(let e of[...pY])e()}function hY(e){fY.taskId!==e&&mY({...fY,taskId:e})}function gY(e){(fY.session?.name!==e?.name||JSON.stringify(fY.session?.address)!==JSON.stringify(e?.address))&&mY({...fY,session:e})}function _Y(e){return pY.add(e),()=>{pY.delete(e)}}function vY(){return(0,m.useSyncExternalStore)(_Y,()=>fY,()=>fY)}function yY({entry:e}){let t=e.at?JO(e.at):``;return e.role===`note`?(0,L.jsxs)(`li`,{className:`text-center text-xs text-muted-foreground`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,L.jsxs)(`li`,{className:`flex flex-col items-end gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,L.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,L.jsx)(kz,{text:e.text})})]}):(0,L.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,L.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,L.jsx)(kz,{text:e.text})})]})}function bY({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t?(0,L.jsx)(`div`,{className:`flex self-center`,children:(0,L.jsx)(Y,{label:`Load earlier messages`,icon:Qp,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,L.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex flex-col gap-4`,children:e.map(e=>(0,L.jsx)(yY,{entry:e},e.id))})]})}function xY({address:e,empty:t}){let n=sO(`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 H(`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,L.jsx)(bY,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var SY={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},CY=[`this window`,`background`,`other terminal`],wY=`Nothing said yet.`,TY=`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.`,EY=`No other sessions. Start one below.`;function DY(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 OY(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 kY(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 AY(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[DY(e,t,n),...r.map(OY),...o.map(kY)]}function jY(e){return`${e} question${e===1?``:`s`} waiting for you`}function MY(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function NY(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function PY(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function FY({options:e,send:t}){return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,L.jsx)(J,{variant:`outline`,onClick:()=>void t({value:e}),children:e},e))})}function IY({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,L.jsx)(KO,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,L.jsx)(`div`,{className:`flex self-end`,children:(0,L.jsx)(Y,{label:`Send the answer`,text:`Send`,icon:Pp,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function LY({dialog:e,send:t}){return e.method===`select`?(0,L.jsx)(FY,{options:e.options??[],send:t}):e.method===`confirm`?(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(J,{onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,L.jsx)(J,{variant:`outline`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,L.jsx)(IY,{dialog:e,send:t})}function RY({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await H(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,L.jsxs)(`div`,{className:`card-raised flex flex-col gap-3 rounded-lg border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}),t.message?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.message}):null]}),(0,L.jsx)(LY,{dialog:t,send:r}),(0,L.jsx)(`div`,{className:`flex self-start`,children:(0,L.jsx)(Y,{label:`Put it away`,text:`Put away`,icon:Rg,onClick:()=>void r({cancelled:!0})})})]})}function zY({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,L.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,L.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:jY(t.length)}),t.map(t=>(0,L.jsx)(RY,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var BY={"this window":vh,background:Km,"other terminal":cg};function VY({where:e,className:t}){let n=BY[e];return(0,L.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function HY({task:e}){let t=e.progress;return(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(LU,{done:t.done,total:t.total}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function UY({entry:e}){let{key:t}=e;return e.where===`this window`?(0,L.jsx)(jO,{children:(0,L.jsx)(Y,{label:`Back to this window`,text:`Back to the Lobby`,icon:Ap,tone:`primary`,shortcut:`B`,onClick:()=>GD(`#/lobby`)})}):t?(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Move here`,icon:Mp,tone:`primary`,shortcut:`M`,onClick:()=>void H(`sessions.switch`,{key:t})}),(0,L.jsx)(ck,{icon:um,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 H(`sessions.stop`,{key:t})})]}):null}function WY({entry:e,lobby:t}){let n=PY(e);return e.where===`this window`?(0,L.jsx)(bY,{entries:t?.chat??[],more:!1,empty:wY}):n?(0,L.jsx)(xY,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:MY(e)},e.id):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:wY})}function GY({entry:e,lobby:t,onChanged:n}){return(0,L.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex flex-col gap-4`,children:[(0,L.jsx)(UY,{entry:e}),(0,L.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`h3`,{className:`flex items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,L.jsx)(VY,{where:e.where,className:`size-[1.1rem]`}),e.name]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:NY(e)}),e.task?(0,L.jsx)(HY,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:jY(e.waiting)}):null]}),e.where===`other terminal`?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:TY}):null,e.key?(0,L.jsx)(zY,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,L.jsx)(Mz,{title:`Conversation`,children:(0,L.jsx)(WY,{entry:e,lobby:t})})]})}function KY({entry:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{children:(0,L.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(_B,`flex-row items-start gap-2.5 text-sm`),children:[(0,L.jsx)(VY,{where:e.where,className:`mt-0.5`}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.name}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,L.jsx)($D,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,L.jsx)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-medium text-warning tabular-nums`,children:e.waiting}):null]})]})})}function qY({where:e,entries:t,selectedId:n,onSelect:r}){return(0,L.jsxs)(`section`,{"aria-label":SY[e],className:`flex flex-col`,children:[(0,L.jsx)(`h3`,{className:yB,children:(0,L.jsx)(jz,{title:SY[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,L.jsx)(`ul`,{className:vB,children:t.map(e=>(0,L.jsx)(KY,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function JY({entries:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`div`,{className:`flex flex-col pb-2`,children:CY.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,L.jsx)(qY,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var YY=()=>GD(`#/sessions`),XY=e=>GD(`#/sessions/${encodeURIComponent(e)}`);function ZY({windows:e}){return e.length===0?null:(0,L.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,L.jsx)(Mz,{title:`Other windows`,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.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 QY(){return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function $Y({id:e}){let t=BO(),n=aO(`status`).data,r=aO(`lobby`).data,i=aO(`prompts`).data?.prompts.length??0,a=sO(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,L.jsx)(tO,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=AY(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?PY(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(gY(l&&d?{name:d,address:l}:void 0),()=>gY(void 0)),[u,d]);let f=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Sessions`,count:String(o.length)}),a.data?(0,L.jsx)(JY,{entries:o,selectedId:s,onSelect:XY}):(0,L.jsx)(GO,{}),a.data&&o.length===1?(0,L.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:EY}):null,(0,L.jsx)(ZY,{windows:n?.windows??[]})]}),p=c?(0,L.jsx)(GY,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,L.jsx)(QY,{}):null;return(0,L.jsx)(UO,{wide:t,list:f,detail:p,open:!!e,onClose:YY,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function eX({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,L.jsxs)(`span`,{className:`tabular-nums`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,MU(jU(e,n,t)),` execution`]})}function tX({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=NU(r,e);return(0,L.jsxs)(`span`,{className:`tabular-nums`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,MU(e.workedMs+i)]})}function nX({timing:e,work:t,stopped:n=!1}){return t?(0,L.jsx)(tX,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,L.jsx)(eX,{timing:e,stopped:n},JSON.stringify(e)):(0,L.jsx)(`span`,{children:`Timing unavailable`})}var rX=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,iX={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function aX({delivery:e,title:t}){return(0,L.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,L.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,L.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,L.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,L.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,L.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,L.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,L.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,L.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,L.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 oX({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,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(J,{variant:`outline`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,L.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,L.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function sX(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?De(`tasks.deliveryReview`,{taskId:t}):e===`defer`?De(`tasks.deliveryDefer`,r):De(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function cX({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=M(),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 lX(e){return e.scope.current===e.identity&&e.project===M()}function uX(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 sX(r,t.taskId,e.current.reviewId);lX(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){lX(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function dX(e){let t=cX(e),n=uX(t,e),r=ID(t.confirm,FD.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 fX({review:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,L.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:iX[e.current.status]}),e.current.error||e.error?(0,L.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,L.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,L.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,L.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,L.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function pX({review:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,L.jsx)(oX,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,L.jsx)(oX,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsx)(J,{variant:`ghost`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,L.jsx)(J,{variant:`ghost`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function mX({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.`:rX;return(0,L.jsx)(OD,{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,L.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,L.jsx)(`p`,{className:`text-sm`,children:n}),(0,L.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(J,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,L.jsx)(J,{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 hX({title:e,review:t}){return(0,L.jsxs)(Mz,{title:`Completed work · delivery review`,right:iX[t.current.status],children:[(0,L.jsx)(aX,{delivery:t.current,title:e}),(0,L.jsx)(fX,{review:t}),(0,L.jsx)(pX,{review:t}),(0,L.jsx)(mX,{review:t})]})}function gX(e){let t=dX(e);return(0,L.jsx)(hX,{title:e.title,review:t})}var _X={open:mm,delivered:om,addressed:nm},vX={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function yX({comment:e}){let t=ZO(Date.now()-Date.parse(e.createdAt)),n=_X[e.status];return(0,L.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),vX[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function bX({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,L.jsxs)(`li`,{className:`card-raised rounded-lg border px-3.5 py-2.5`,children:[r?(0,L.jsx)(Wq,{text:s.text,onSave:async n=>{let r=await De(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,L.jsx)(kz,{text:s.text}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(yX,{comment:s}),n&&!r?(0,L.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function xX({taskId:e,finished:t,canComment:n}){let r=sO(`tasks.comments`,{taskId:e},[`tasks`]),i=aO(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,L.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,L.jsx)(jz,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,L.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,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,L.jsx)(bX,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var SX={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},CX={open:`open`,done:`done`,dropped:`abandoned`},wX={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 TX(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 EX=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function DX(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function OX(e){return e===`now`?`just now`:`${e} ago`}function kX(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[DX(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function AX(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 jX(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 MX({step:e,stopped:t}){let n=NU(!t,e);return(0,L.jsx)(`span`,{className:`tabular-nums`,children:MU((e.workedMs??0)+n)})}function NX(){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,L.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function PX({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=e.status===`done`,a=i?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,o=i?nm:mm;return(0,L.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm`,"data-step":r?`active`:e.status,children:[r?(0,L.jsx)(NX,{}):(0,L.jsx)(o,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${a}`}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,L.jsx)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),r?(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,L.jsx)(MX,{step:e,stopped:n}),(0,L.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,L.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,L.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]})}function FX({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,L.jsx)(Mz,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,L.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,L.jsx)(PX,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function IX({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,L.jsxs)(Mz,{title:`Full plan`,children:[(0,L.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,L.jsx)(Jp,{"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,L.jsx)(`div`,{id:r,children:(0,L.jsx)(kz,{text:e})}):null]})}function LX({detail:e,finished:t}){return e.plan&&e.planDetails?(0,L.jsx)(IX,{text:e.planDetails}):e.plan?(0,L.jsx)(Mz,{title:`Approved plan`,children:(0,L.jsx)(kz,{text:e.plan})}):e.proposal?(0,L.jsx)(Mz,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,L.jsx)(kz,{text:e.proposal})}):(0,L.jsx)(Mz,{title:`Plan`,children:(0,L.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 RX({amendments:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Amendments`,children:(0,L.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,L.jsx)(`li`,{className:`break-words`,children:e},e))})})}function zX({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,L.jsx)(Mz,{title:`Waiting on`,children:(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex gap-2`,children:[(0,L.jsx)(em,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,L.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,L.jsxs)(`li`,{className:`flex gap-2`,children:[(0,L.jsx)(fm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,L.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function BX({risk:e}){let t=wX[e.risk];return(0,L.jsxs)(Mz,{title:`QA risk`,right:TX(e),children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,L.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,L.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,L.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,L.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 VX({runs:e}){return e.length===0?null:(0,L.jsx)(Mz,{title:`Recent runs`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,L.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function HX({detail:e,finished:t}){return(0,L.jsxs)(L.Fragment,{children:[e.steps.length>0?(0,L.jsx)(FX,{steps:e.steps,stopped:t}):null,e.request?(0,L.jsx)(Mz,{title:`Request`,children:(0,L.jsx)(kz,{text:e.request})}):null,(0,L.jsx)(LX,{detail:e,finished:t})]})}function UX({detail:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(RX,{amendments:e.amendments}),(0,L.jsx)(zX,{detail:e}),e.qaRisk?(0,L.jsx)(BX,{risk:e.qaRisk}):null,(0,L.jsx)(VX,{runs:e.runs})]})}function WX({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 GD(`#/lobby`);let t=M(),r=()=>n.current&&M()===t;try{let t=await De(`tasks.open`,{taskId:e.id});if(!r())return;let n=await De(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return GD(`#/lobby`);if(t.sessionId&&!t.key)return V.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return V.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await H(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&GD(`#/lobby`)}catch(e){r()&&V.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,L.jsx)(Y,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:Mp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function GX({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,L.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,L.jsxs)(`span`,{children:[n>0?(0,L.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,L.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function KX({planId:e}){let t=sO(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,L.jsxs)(L.Fragment,{children:[n.issue?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,L.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,L.jsx)(GX,{split:n.split}):null,(0,L.jsx)(Mz,{title:`Agreed plan`,children:(0,L.jsx)(kz,{text:n.brief})})]}):t.error?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function qX({row:e,onGone:t}){let n=async n=>{await H(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await H(`plans.discard`,{planId:e.id})&&t()};return(0,L.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":e.title,children:[(0,L.jsxs)(jO,{children:[(0,L.jsx)(Y,{label:`Start here`,icon:Rh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,L.jsx)(Y,{label:`Start in a new session`,text:`New session`,icon:og,shortcut:`N`,onClick:()=>void n(`session`)}),(0,L.jsx)(ck,{icon:bg,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,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,L.jsx)(RU,{check:`open`,className:`mt-1.5`}),(0,L.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${OX(e.age)}`:``]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,L.jsx)(KX,{planId:e.id})]})}function JX({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=M();r(!0);try{let r=await De(`tasks.resume`,{taskId:e.id});if(M()!==n)return;let i=r.key;V(r.notice,i?{action:{label:`Watch`,onClick:()=>GD(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){M()===n&&V.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,L.jsx)(Y,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Rh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function YX(e){if(e.kind===`archived`)return{state:`archived`,rest:OX(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`} ${OX(e.age)}`:``;return{state:DX(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function XX(e){return e?[FU(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function ZX({row:e}){return e.progress?(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,L.jsx)(LU,{done:e.progress.done,total:e.progress.total}),(0,L.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function QX({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=YX(e);return(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,L.jsx)(RU,{check:e.check,className:`mt-1.5`}),(0,L.jsxs)(`span`,{className:`sr-only`,children:[CX[e.check],`:`]}),(0,L.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,L.jsx)(`span`,{children:i}):null]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,XX(t),n].filter(Boolean).join(` · `)}),(0,L.jsx)(ZX,{row:e})]})}function $X({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await H(`tasks.restore`,{taskId:r},{undo:()=>void H(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await H(`tasks.archive`,{taskId:r},{undo:()=>void H(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await H(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void H(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function eZ({row:e,archive:t}){return e.check===`open`?(0,L.jsx)(ck,{label:`Archive`,icon:Ep,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,L.jsx)(Y,{label:`Archive`,icon:Ep,shortcut:`E`,onClick:()=>void t()})}function tZ({on:e,toggle:t}){return kO(`a`,t),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,L.jsx)(`span`,{children:`Auto`}),(0,L.jsx)(EG,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,L.jsx)(ED,{chord:`A`,className:`kbd-hint`})]})}),(0,L.jsx)(dO,{children:`Auto mode: the oracle decides without asking`})]})}function nZ(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=$X(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,L.jsxs)(jO,{children:[s?(0,L.jsx)(JX,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,L.jsx)(WX,{row:t,quiet:s}):null,t.kind===`task`?(0,L.jsx)(rZ,{taskId:t.id}):null,o?(0,L.jsx)(Y,{label:`Restore`,icon:Kh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,L.jsx)(tZ,{on:!!t.auto,toggle:a}):null,o?null:(0,L.jsx)(eZ,{row:t,archive:r}),(0,L.jsx)(ck,{icon:bg,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 rZ({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=M();try{let r=await De(`tasks.open`,{taskId:e});if(!t.current||M()!==n)return;r.notice&&V.info(r.notice);let i=await De(`status.get`,{});if(!t.current||M()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?GD(`#/sessions/${encodeURIComponent(a)}`):r.notice||V.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&M()===n&&V.error(e instanceof Error?e.message:String(e))}}return(0,L.jsx)(Y,{label:`Open task conversation`,text:`Conversation`,icon:ch,shortcut:`O`,onClick:()=>void n()})}function iZ(e){let{row:t}=e,n=t.kind===`plan`,r=sO(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=aO(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,L.jsx)(qX,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,L.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":t.title,children:[(0,L.jsx)(nZ,{...e}),(0,L.jsx)(QX,{row:t,task:a}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,L.jsx)(nX,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,L.jsx)(gX,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,L.jsx)(HX,{detail:r.data,finished:!o}):null,(0,L.jsx)(xX,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,L.jsx)(UX,{detail:r.data}):null,r.error&&!r.data?(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function aZ({row:e}){return e.check===`open`&&e.progress?(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,L.jsx)(LU,{done:e.progress.done,total:e.progress.total}),(0,L.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function oZ(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function sZ({row:e,selected:t,onSelect:n}){return(0,L.jsx)(`li`,{children:(0,L.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:_B,children:[(0,L.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(RU,{check:e.check,className:`mt-0.5`}),(0,L.jsxs)(`span`,{className:`sr-only`,children:[CX[e.check],`:`]}),(0,L.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,oZ(e),t&&`font-medium text-foreground`),children:e.title}),(0,L.jsx)(aZ,{row:e})]}),e.check===`open`?(0,L.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:kX(e)}):null,e.kind===`plan`?null:(0,L.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,L.jsx)(nX,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,L.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})})}function cZ({rows:e,selectedId:t,onSelect:n}){return(0,L.jsx)(`div`,{className:`flex flex-col pb-2`,children:AX(e).map(({section:e,rows:r})=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:yB,children:(0,L.jsx)(jz,{title:SX[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,L.jsx)(`ul`,{className:vB,children:r.map(e=>(0,L.jsx)(sZ,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var lZ=()=>GD(WD(`tasks`)),uZ=e=>GD(WD(`tasks`,e));function dZ(){return(0,L.jsxs)(qD,{className:`m-4 flex-1`,children:[(0,L.jsxs)(JD,{children:[(0,L.jsx)(XD,{variant:`icon`,children:(0,L.jsx)(Jm,{"aria-hidden":`true`})}),(0,L.jsx)(QD,{children:EX})]}),(0,L.jsx)(J,{onClick:()=>GD(WD(`plan`)),children:`Plan a task`})]})}function fZ({shown:e,count:t,onToggle:n}){return(0,L.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,L.jsx)(cH,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,L.jsx)(gB,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function pZ({id:e}){let t=BO(),[n,r]=(0,m.useState)(!1),i=sO(`tasks.list`,{},[`tasks`,`plans`]),a=sO(`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)(()=>(hY(u),()=>hY(void 0)),[u]),!i.data&&i.error)return(0,L.jsx)(tO,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,L.jsx)(dZ,{});let d=[...c,...s].find(e=>e.id===l),f=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(WO,{title:`Tasks`,count:jX(c),children:(0,L.jsx)(fZ,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:EX}):(0,L.jsx)(cZ,{rows:c,selectedId:l,onSelect:uZ}):(0,L.jsx)(GO,{})]}),p=d?(0,L.jsx)(iZ,{row:d,onGone:lZ,onChanged:i.reload},d.id):e?(0,L.jsx)(mZ,{}):null;return(0,L.jsx)(UO,{wide:t,list:f,detail:p,open:!!e,onClose:lZ,hint:`Select a task to see its detail.`,describe:`Task detail`})}function mZ(){return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var hZ={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function gZ(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function _Z(e){if(e.kind===`settings`)return(0,L.jsx)(Eq,{});if(e.kind===`sessions`)return(0,L.jsx)($Y,{id:gZ(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,L.jsx)($U,{});case`tasks`:return(0,L.jsx)(pZ,{id:gZ(e.rest)});case`plan`:return(0,L.jsx)(WJ,{rest:e.rest});case`quickfix`:return(0,L.jsx)(uY,{id:gZ(e.rest)});case`issues`:return(0,L.jsx)(eV,{rest:e.rest});case`metrics`:return(0,L.jsx)(WW,{});case`git`:return(0,L.jsx)(DB,{rest:e.rest});case`knowledge`:return(0,L.jsx)(sH,{agent:e.rest[0],file:e.rest[1]});case`excalidraw`:return(0,L.jsx)(mU,{id:gZ(e.rest)})}}function vZ(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var yZ={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 bZ(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:yZ[e]}function xZ(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=bZ(n);if(!e)return;t.code=e}return t.code?t:void 0}function SZ(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function CZ(e,t){let n=xZ(t);return n?SZ(e,n):!1}function wZ(e,t){for(let n of t)if(CZ(e,n.key))return n.action}function TZ(e,t){for(let n of t)if(CZ(e,n.key))return n.id}function EZ(e){return mO(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||LD()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function DZ(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`)bO(e.key===`j`?1:-1);else return!1;return!0}function OZ(e,t){let n=TZ(e,t.tabs),r=wZ(e,t.keys);return!n&&!r?!1:vZ(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||LD(),typing:mO(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 kZ(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=hZ[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(DZ(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function AZ(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){wZ(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&EZ(n)){t=0;return}if(OZ(n,e)){t=0;return}t=r?kZ(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 jZ=[{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`}],MZ=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(hZ).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`}],NZ=[{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`]]}],PZ=[{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`}],FZ=[{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 IZ({line:e}){return(0,L.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,L.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,L.jsx)(bD,{children:e},e))}):(0,L.jsx)(ED,{chord:e.label??``})}),(0,L.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function LZ(){return(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),NZ.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,L.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,L.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,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(ED,{chord:e}),t]},e))})]},e.id))]})}function RZ({title:e,lines:t}){return(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,L.jsx)(IZ,{line:e},e.id))]})}function zZ(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function BZ(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function VZ({open:e,onOpenChange:t,keys:n,tabs:r}){let i=ID(e,FD.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&&CZ(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,i,t,n]),(0,L.jsxs)(OD,{open:e&&i,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,L.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ED,{chord:`Esc`}),(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,L.jsx)(Rg,{"aria-hidden":`true`})})]})]}),(0,L.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,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(RZ,{title:`Everywhere`,lines:zZ(n)}),(0,L.jsx)(RZ,{title:`Jump to a tab`,lines:BZ(r)}),(0,L.jsx)(RZ,{title:`Navigation and editing`,lines:MZ}),(0,L.jsx)(RZ,{title:`Message box`,lines:jZ})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(RZ,{title:`Lists and panes`,lines:PZ}),(0,L.jsx)(LZ,{}),(0,L.jsx)(RZ,{title:`Questions`,lines:FZ})]})]})]})}function HZ(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function UZ(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(N(`/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 Te(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Te(r.error,r.code,n.status);return r.result}function WZ(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 GZ(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 KZ=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function qZ(e,t){let n=e.lastIndexOf(`
|
|
101
101
|
`,t-1)+1,r=e.indexOf(`
|
|
102
|
-
`,t),i=e.slice(n,r<0?e.length:r),a=KZ.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}}var JZ={id:`oracle`,pill:`Oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`};function YZ(e){if(e)try{return decodeURIComponent(e)}catch{return e}}function XZ(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,JZ]:[e,JZ]}if(e.kind!==`tab`)return[JZ];if(e.tab===`plan`)return[{id:`panel`,pill:`Panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`},JZ];if(e.tab===`quickfix`)return[{id:`quickfix`,pill:`Quick fix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`},JZ];let r=e.tab===`tasks`?YZ(e.rest[0])??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},JZ]:[JZ]}var ZZ=0,QZ=`btn-ghost relative inline-flex size-8 items-center justify-center rounded-lg border border-transparent before:absolute before:-inset-1 before:content-[''] 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 aria-pressed:text-foreground`;function $Z(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function eQ({file:e,onRemove:t}){let n=(0,L.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,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,L.jsxs)(z.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} · ${HZ(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,L.jsx)(`img`,{src:N(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,L.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-background/60`,children:(0,L.jsx)($D,{className:`size-4`,"aria-hidden":`true`,role:`presentation`})}):null,n]}):(0,L.jsxs)(z.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,L.jsxs)(`span`,{className:`relative flex shrink-0 items-center justify-center text-muted-foreground`,children:[(0,L.jsx)(Pm,{"aria-hidden":`true`,className:`size-4`}),e.state===`uploading`?(0,L.jsx)($D,{className:`absolute -right-1 -bottom-1 size-2.5`,"aria-hidden":`true`,role:`presentation`}):null]}),(0,L.jsxs)(`span`,{className:`min-w-0 max-w-40`,children:[(0,L.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:e.name}),(0,L.jsx)(`span`,{className:`block text-[0.65rem] leading-tight text-muted-foreground`,children:e.state===`uploading`?`uploading…`:HZ(e.size)})]}),n]})}function tQ({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=aO(`status`),_=aO(`lobby`),v=RD(),y=(g.data?.busy??!1)||!!_.data?.reply?.trim(),{taskId:b,session:x}=vY(),S=(0,m.useMemo)(()=>XZ(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 ee=(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 te=(0,m.useCallback)(e=>{let t=[...e],n=8-O.current.length;t.length>n&&V.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++ZZ}`,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`}]),UZ(e).then(e=>o(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{V.error(e instanceof Error?e.message:`That file did not upload.`),o(e=>e.filter(e=>e.key!==t))})}},[]),ne=(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)})},[]),A=a.some(e=>e.state===`uploading`),re=a.flatMap(e=>e.info?[e.info.id]:[]),ie=(r.trim().length>0||re.length>0)&&!A&&!l,j=(0,m.useCallback)(async()=>{if(!ie)return;u(!0);let e=re.length>0?re:void 0,t={text:r,...e?{attachments:e}:{}};try{let n=!0;if(w.id===`oracle`){let e=await De(`lobby.send`,t);e.notice&&V(e.notice)}else if(w.id===`panel`)n=await H(`planner.send`,t)!==void 0;else if(w.id===`quickfix`)n=await H(`quickfix.submit`,t)!==void 0;else if(w.id===`task`)n=await H(`tasks.message`,{taskId:w.taskId,...t})!==void 0;else if(w.id===`session`)n=await H(`sessions.message`,{...w.session.address,...t})!==void 0;else if(w.id===`newsession`){let t=await H(`sessions.start`,{request:r,...e?{attachments:e}:{}});n=t!==void 0,t?.key&&GD(`#/sessions/${encodeURIComponent(t.key)}`)}else n=await H(`tasks.comment`,{taskId:w.taskId,...t})!==void 0;if(n){i(``);for(let e of O.current)e.image&&URL.revokeObjectURL(e.image);o([])}}catch(e){V.error(e instanceof Error?e.message:`Could not send`)}finally{u(!1)}},[ie,re,w,r]),ae=(0,m.useCallback)(async()=>{try{await De(`lobby.abort`,{})}catch(e){V.error(e instanceof Error?e.message:`Could not stop`)}},[]);return(0,L.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,L.jsx)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl`,children:(0,L.jsxs)(`div`,{className:q(`group/composer relative rounded-2xl border border-dock-border bg-dock shadow-dock backdrop-blur-xl backdrop-saturate-150 transition-[border-color,box-shadow] duration-300 ease-snap focus-within:border-ring/45 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&&te(e.dataTransfer.files)},children:[(0,L.jsx)(Ou,{initial:!1,children:a.length>0?(0,L.jsx)(z.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,L.jsx)(eQ,{file:e,onRemove:()=>ne(e.key)},e.key))},`files`):null}),s?(0,L.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,L.jsx)(kz,{text:r}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing to preview yet.`})}):null,(0,L.jsx)(`div`,{className:`flex px-4 pt-3 pb-1`,children:(0,L.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(),CO();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;ee(n===`k`?GZ(a,r,i):WZ(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=qZ(t.value,t.selectionStart);n&&(e.preventDefault(),ee(n));return}if(e.key===`Backspace`&&t.value===``&&O.current.length>0){e.preventDefault(),ne(O.current.at(-1).key);return}($Z(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),j())},onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),te(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,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-1 px-2 pt-1 pb-2`,children:[(0,L.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{te(e.target.files??[]),e.target.value=``}}),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:QZ,children:(0,L.jsx)(Eh,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsx)(dO,{children:`Attach images, PDFs or files`})]}),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:QZ,children:(0,L.jsx)(Om,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsxs)(dO,{children:[`Preview `,(0,L.jsx)(ED,{chord:`Alt+P`})]})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-4 w-px bg-border`}),S.length>1?(0,L.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,L.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 bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e.pill},e.id))}):(0,L.jsxs)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:[`To the `,w.pill.toLowerCase()]}),(0,L.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end overflow-hidden px-2`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-3.5`,children:[e.kind===`tab`&&e.tab===`plan`?(0,L.jsx)(DD,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[34rem]:inline-flex`,children:`save plan`}):null,(0,L.jsx)(DD,{chord:`/`,className:`hidden group-focus-within/composer:!hidden @[28rem]:inline-flex`,children:`write`}),(0,L.jsx)(DD,{chord:`Esc`,className:`hidden group-[:not(:focus-within)]/composer:!hidden @[28rem]:inline-flex`,children:`tabs`}),(0,L.jsx)(DD,{chord:`Shift+Enter`,className:`hidden @[22rem]:inline-flex`,children:`new line`}),(0,L.jsx)(DD,{chord:`Enter`,className:`hidden @[11rem]:inline-flex`,children:`send`}),(0,L.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,L.jsx)(ED,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,L.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})}),y&&w.id===`oracle`?(0,L.jsx)(ck,{label:`Stop`,icon:ug,iconOnly:!0,compact:!0,title:`Stop the oracle?`,description:`The current response stops. Work already recorded is kept.`,confirmLabel:`Stop`,variant:`destructive`,onConfirm:()=>void ae()}):null,(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Send`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>void j(),disabled:!ie,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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5 text-primary-foreground`}):(0,L.jsx)(Pp,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.25})})}),(0,L.jsxs)(dO,{children:[`Send `,(0,L.jsx)(ED,{chord:`Enter`})]})]})]}),d?(0,L.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 nQ(){try{return{id:M()}}catch(e){return{error:e.message}}}function rQ(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. Start a project in Pi, then refresh.`}}function iQ(){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 De(`projects.list`,{});Se(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 aQ({data:e,error:t}){let n=nQ();return n.error??t??rQ(e,n.id)}function oQ({projects:e}){let t=aQ(e);return t?(0,L.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,L.jsx)(Sg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:t})]}):null}function sQ(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 cQ({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=nQ(),d=aQ(e),f=u.error?`invalid`:u.id??i?.currentId??``,p=!!i?.projects.length;kO(`p`,()=>l(!0),{enabled:p}),kO(`r`,()=>void s(),{enabled:c,inDialog:!0});function h(e){l(!1),e!==f&&_e(e,t)}return(0,L.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(fE,{open:c&&p,onOpenChange:l,children:[(0,L.jsxs)(pE,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c&&p,"aria-keyshortcuts":`P ArrowDown`,disabled:!p,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,L.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2.5 shrink-0 rounded-full`,d?`bg-destructive`:`bg-primary`)}),(0,L.jsx)(`span`,{className:`truncate`,children:n}),(0,L.jsx)(Xp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground`,!p&&`opacity-40`)})]}),(0,L.jsx)(mE,{children:(0,L.jsxs)(hE,{align:`start`,sideOffset:6,"aria-label":`Projects`,onKeyDown:sQ,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`glass-pop z-50 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,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,L.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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,L.jsx)(ED,{chord:`R`,className:`kbd-hint`})]})]}),(0,L.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===f;return(0,L.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>h(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,L.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})})]})})]}),r?(0,L.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,L.jsx)(Im,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:r})]}):null,o||d?(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-4`}):(0,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsx)(dO,{side:`bottom`,children:`Refresh projects`})]}):null]})}function lQ({state:e}){return e===`live`?(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,L.jsx)(dO,{children:`Connected`})]}):e===`connecting`?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),`reconnecting…`]}):(0,L.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}var uQ=`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-[background-color,color,box-shadow,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 aria-[current=page]:text-foreground`;function dQ({label:e,hint:t,href:n,active:r,children:i}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`a`,{href:n,"aria-label":e,"aria-current":r?`page`:void 0,"aria-keyshortcuts":t,"aria-describedby":`focused-action-help`,className:uQ,children:i})}),(0,L.jsxs)(dO,{side:`bottom`,children:[e,` `,(0,L.jsx)(ED,{chord:t})]})]})}function fQ({hint:e,onHelp:t}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:uQ,children:(0,L.jsx)(Wm,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsxs)(dO,{side:`bottom`,children:[`Keyboard shortcuts `,(0,L.jsx)(ED,{chord:e})]})]})}function pQ(){let e=nG(),t=e?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,"aria-describedby":`focused-action-help`,className:uQ,onClick:()=>eG(!e),children:e?(0,L.jsx)(Mg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,L.jsx)(Ag,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsx)(dO,{side:`bottom`,children:t})]})}function mQ(){let{theme:e,setTheme:t}=cK(),n=e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:uQ,children:n?(0,L.jsx)(fg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,L.jsx)(bh,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsxs)(dO,{side:`bottom`,children:[n?`Light mode`:`Dark mode`,` `,(0,L.jsx)(ED,{chord:`D`})]})]})}function hQ({busy:e,task:t,sessionName:n}){return(0,L.jsxs)(`div`,{className:`mr-1 flex min-w-0 items-center gap-2 text-[0.8125rem]`,children:[e?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):null,t?(0,L.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate md:inline`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,L.jsxs)(`span`,{className:`hidden text-muted-foreground min-[1500px]:inline`,children:[` · `,t.state.replace(/_/g,` `)]})]}):(0,L.jsx)(`span`,{className:`hidden max-w-[10rem] truncate text-muted-foreground min-[1500px]:inline`,children:n??`no task in this session`})]})}function gQ(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 _Q=24;function vQ(){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=gQ(t.querySelector(`.where`))+(r?.offsetWidth??0)+gQ(t.querySelector(`.tools`))+a*2;n(s+_Q<=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 yQ({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=iQ(),{header:f,one:p}=vQ();return(0,L.jsxs)(`header`,{ref:f,className:`app-header shrink-0`,"data-one-row":p||void 0,children:[(0,L.jsx)(`div`,{className:`where flex min-w-0 items-center`,children:(0,L.jsx)(cQ,{projects:d,tab:r.kind===`tab`?r.tab:r.kind,name:c,branch:l})}),(0,L.jsx)(`div`,{className:`tabs min-w-0`,children:i}),(0,L.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-0.5`,children:[a,(0,L.jsx)(hQ,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,L.jsx)(lQ,{state:n}),(0,L.jsx)(dQ,{label:`Sessions`,hint:o.sessions??`Alt+O`,href:`#/sessions`,active:r.kind===`sessions`,children:(0,L.jsx)(Km,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,L.jsx)(dQ,{label:`Settings`,hint:o.settings??`Alt+S`,href:`#/settings`,active:r.kind===`settings`,children:(0,L.jsx)(ng,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,L.jsx)(fQ,{hint:o.help??`Alt+H`,onHelp:s}),(0,L.jsx)(mQ,{}),(0,L.jsx)(pQ,{}),(0,L.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,L.jsx)(oQ,{projects:d})]})}function bQ(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 xQ(){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 ke()?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(bQ(e))}return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,L.jsxs)(`form`,{onSubmit:s,className:`glass flex w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Hm,{className:`size-5`,"aria-hidden":`true`}),(0,L.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,L.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,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,L.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,L.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,L.jsx)(J,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var SQ=.6;function CQ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:SQ,...n}}}var wQ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function TQ(e,t=0,n=1){return CQ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:SQ,times:wQ(t,n),ease:`easeInOut`},strokeOpacity:{duration:SQ,times:wQ(t,t+.02)}})}function EQ(e,t){return CQ(e,{scale:[0,0,1.3,1]},{times:wQ(t,t+.18),ease:`easeOut`})}function DQ(e,t,n=1.3){return CQ(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 OQ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function kQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(.1,.9),...CQ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,L.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,L.jsx)(z.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...CQ(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 AQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.path,{d:`M13 5h8`,...TQ(e,.15,.45)}),(0,L.jsx)(z.path,{d:`M13 12h8`,...TQ(e,.3,.6)}),(0,L.jsx)(z.path,{d:`M13 19h8`,...TQ(e,.45,.75)}),(0,L.jsx)(z.path,{d:`m3 17 2 2 4-4`,...TQ(e,.35,.7)}),(0,L.jsx)(z.path,{d:`m3 7 2 2 4-4`,...TQ(e,0,.35)})]})}function jQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:6,cy:19,r:3,style:OQ(),...DQ(e,0)}),(0,L.jsx)(z.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...TQ(e,.1,.7)}),(0,L.jsx)(z.circle,{cx:18,cy:5,r:3,style:OQ(),...EQ(e,.62)})]})}function MQ({play:e}){return(0,L.jsx)(z.g,{style:OQ(),...CQ(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,L.jsx)(z.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`,...CQ(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function NQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:12,cy:12,r:10,style:OQ(),...CQ(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,L.jsx)(z.circle,{cx:12,cy:12,r:10,style:OQ(),...CQ(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,L.jsx)(z.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:OQ(),...CQ(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function PQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}),[`M8 17v-3`,`M13 17V5`,`M18 17V9`].map((t,n)=>(0,L.jsx)(z.path,{d:t,style:OQ(.5,1),...CQ(e,{scaleY:[0,0,1.18,1]},{times:wQ(.08+n*.14,.4+n*.14),ease:`easeOut`})},t))]})}function FQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:6,cy:6,r:3,style:OQ(),...DQ(e,0)}),(0,L.jsx)(z.line,{x1:6,x2:6,y1:9,y2:21,...TQ(e,.05,.45)}),(0,L.jsx)(z.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...TQ(e,.2,.62)}),(0,L.jsx)(z.circle,{cx:18,cy:18,r:3,style:OQ(),...EQ(e,.58)})]})}function IQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(),...CQ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,L.jsx)(z.path,{d:`M12 5v16`,style:OQ(),...CQ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,L.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 LQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(.6,.6),...CQ(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,L.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,L.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,L.jsx)(z.path,{d:`m2.3 2.3 7.286 7.286`,...TQ(e,.1,.6)}),(0,L.jsx)(z.circle,{cx:11,cy:11,r:2,style:OQ(),...DQ(e,.5,1.5)})]})}var RQ={lobby:kQ,tasks:AQ,plan:jQ,quickfix:MQ,issues:NQ,metrics:PQ,git:FQ,knowledge:IQ,excalidraw:LQ};function zQ({id:e,play:t,className:n}){let r=RQ[e];return r?(0,L.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,L.jsx)(r,{play:t})},t):null}function BQ(e){return/(\d)$/.exec(e)?.[1]}var VQ=160;function HQ(e){let t=Sf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+SQ*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,VQ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var UQ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=BQ(e.key),{play:i,onPointerEnter:a}=HQ(t);return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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-input 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`:`text-muted-foreground hover:text-foreground`),children:[(0,L.jsx)(zQ,{id:e.id,play:i,className:q(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,L.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,L.jsx)(`span`,{children:e.label})]})}),(0,L.jsxs)(dO,{children:[e.label,` `,(0,L.jsx)(ED,{chord:e.key})]})]})}),WQ=1.5;function GQ(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 KQ(e,t){let n=e.right-e.left,{height:r}=e,i=WQ/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 qQ(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}`),KQ(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 JQ={type:`spring`,visualDuration:.12,bounce:0},YQ={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},XQ={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},ZQ={type:`spring`,visualDuration:.22,bounce:.25},QQ={type:`spring`,visualDuration:.2,bounce:0},$Q={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},e$=(()=>{let e=wr({keyframes:[0,1],visualDuration:ZQ.visualDuration,bounce:ZQ.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),t$={type:`spring`,visualDuration:.28,bounce:.6};function n$(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);GQ(r.current,t),GQ(i.current,void 0),qQ(a.current,t,`left`,1),qQ(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);_z()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),gz(),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);GQ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),qQ(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));GQ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),qQ(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Gf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,ee=()=>{if(k)return;k=!0;let e=O(`filled`,0,ZQ,e=>{d.current=e});e.then(()=>{l.current===t&&_z()}),O(`squash`,.8,t$),O(`rung`,0,QQ,e=>{f.current=e}),O(`budge`,0,{...$Q,delay:e$},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,JQ),O(`unrung`,T.unrung,JQ),O(`head`,0,YQ,e=>{e>=w&&ee()}),O(`tail`,0,XQ),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 r$=(0,m.forwardRef)(function({which:e},t){return(0,L.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,L.jsx)(`path`,{pathLength:1,strokeWidth:WQ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,L.jsx)(`path`,{pathLength:1,strokeWidth:WQ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function i$(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 a$({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=n$(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){SO()&&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];wO.active=!0,wO.to=o.id,window.setTimeout(()=>{wO.active=!1,wO.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,L.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:i$(d),WebkitMaskImage:i$(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,L.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,L.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,L.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,L.jsx)(r$,{ref:s,which:`unring`}),(0,L.jsx)(r$,{ref:o,which:`ring`}),e.map((e,n)=>(0,L.jsxs)(m.Fragment,{children:[n>0?(0,L.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,L.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,L.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,L.jsx)(UQ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function o$({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(CV(DV(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:CV(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 s$(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var c$=6,l$=`bot-lobby.orb`,u$=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function d$(e,t,n,r){let i=e=>e+c$,a=(e,t)=>Math.max(e+c$,e+t-r-c$);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 f$(e,t,n,r){let i=e=>Math.max(1,e-r),a=d$(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 p$(e,t,n){return d$(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function m$(e){if(e)try{let t=JSON.parse(e);return u$(t.fx)&&u$(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function h$(){try{return m$(localStorage.getItem(l$))}catch{return}}function g$(e){try{localStorage.setItem(l$,JSON.stringify(e))}catch{}}var _$=5,v$=16;function y$(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?{left:e.left,top:e.top,width:e.width,height:e.height}:void 0}function b$(){let[e,t]=(0,m.useState)(y$);return(0,m.useEffect)(()=>{let e=()=>t(y$()),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 x$=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=b$(),[u,d]=(0,m.useState)(h$),[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?p$(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=y$();if(!n)return;let r=f$(e,t,n,y.current);d(r),g$(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)<_$)return;t.moved=!0;let i=y$();i&&p(d$(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:v$,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?CV(e):E?s$(n):void 0,O=e?`${t.map(CV).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,k=b&&l?b.x-l.left<140:!1,ee={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,L.jsxs)(lO,{open:h&&!f,onOpenChange:g,children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:ee,"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,L.jsx)(Ou,{initial:!1,children:D?(0,L.jsx)(z.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,L.jsx)(Ou,{mode:`popLayout`,initial:!1,children:(0,L.jsx)(z.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,L.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,L.jsx)(`span`,{className:`orb-icon`,children:(0,L.jsx)(xV,{source:e,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,L.jsxs)(dO,{side:`top`,children:[`Thinking `,o?(0,L.jsx)(ED,{chord:o}):null,(0,L.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),S$=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,C$=260,w$=200,T$=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function E$(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(`
|
|
102
|
+
`,t),i=e.slice(n,r<0?e.length:r),a=KZ.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}}var JZ={id:`oracle`,pill:`Oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`};function YZ(e){if(e)try{return decodeURIComponent(e)}catch{return e}}function XZ(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,JZ]:[e,JZ]}if(e.kind!==`tab`)return[JZ];if(e.tab===`knowledge`)return[{id:`knowledge`,pill:`Ask`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`},JZ];if(e.tab===`plan`)return[{id:`panel`,pill:`Panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`},JZ];if(e.tab===`quickfix`)return[{id:`quickfix`,pill:`Quick fix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`},JZ];let r=e.tab===`tasks`?YZ(e.rest[0])??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},JZ]:[JZ]}var ZZ=0,QZ=`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 $Z(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function eQ({file:e,onRemove:t}){let n=(0,L.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,L.jsx)(Rg,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,L.jsxs)(z.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} · ${HZ(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,L.jsx)(`img`,{src:N(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,L.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-background/60`,children:(0,L.jsx)($D,{className:`size-4`,"aria-hidden":`true`,role:`presentation`})}):null,n]}):(0,L.jsxs)(z.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,L.jsxs)(`span`,{className:`relative flex shrink-0 items-center justify-center text-muted-foreground`,children:[(0,L.jsx)(Pm,{"aria-hidden":`true`,className:`size-4`}),e.state===`uploading`?(0,L.jsx)($D,{className:`absolute -right-1 -bottom-1 size-2.5`,"aria-hidden":`true`,role:`presentation`}):null]}),(0,L.jsxs)(`span`,{className:`min-w-0 max-w-40`,children:[(0,L.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:e.name}),(0,L.jsx)(`span`,{className:`block text-[0.65rem] leading-tight text-muted-foreground`,children:e.state===`uploading`?`uploading…`:HZ(e.size)})]}),n]})}function tQ({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=aO(`status`),_=aO(`lobby`),v=RD(),y=(g.data?.busy??!1)||!!_.data?.reply?.trim(),{taskId:b,session:x}=vY(),S=(0,m.useMemo)(()=>XZ(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 ee=(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 te=(0,m.useCallback)(e=>{let t=[...e],n=8-O.current.length;t.length>n&&V.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++ZZ}`,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`}]),UZ(e).then(e=>o(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{V.error(e instanceof Error?e.message:`That file did not upload.`),o(e=>e.filter(e=>e.key!==t))})}},[]),ne=(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)})},[]),A=a.some(e=>e.state===`uploading`),re=a.flatMap(e=>e.info?[e.info.id]:[]),ie=(r.trim().length>0||re.length>0)&&!A&&!l,j=(0,m.useCallback)(async()=>{if(!ie)return;u(!0);let e=re.length>0?re:void 0,t={text:r,...e?{attachments:e}:{}};try{let n=!0;if(w.id===`oracle`){let e=await De(`lobby.send`,t);e.notice&&V(e.notice)}else if(w.id===`knowledge`)n=await H(`knowledge.ask`,t)!==void 0,n&&GD(`#/knowledge/ask`);else if(w.id===`panel`)n=await H(`planner.send`,t)!==void 0;else if(w.id===`quickfix`)n=await H(`quickfix.submit`,t)!==void 0;else if(w.id===`task`)n=await H(`tasks.message`,{taskId:w.taskId,...t})!==void 0;else if(w.id===`session`)n=await H(`sessions.message`,{...w.session.address,...t})!==void 0;else if(w.id===`newsession`){let t=await H(`sessions.start`,{request:r,...e?{attachments:e}:{}});n=t!==void 0,t?.key&&GD(`#/sessions/${encodeURIComponent(t.key)}`)}else n=await H(`tasks.comment`,{taskId:w.taskId,...t})!==void 0;if(n){i(``);for(let e of O.current)e.image&&URL.revokeObjectURL(e.image);o([])}}catch(e){V.error(e instanceof Error?e.message:`Could not send`)}finally{u(!1)}},[ie,re,w,r]),ae=(0,m.useCallback)(async()=>{try{await De(`lobby.abort`,{})}catch(e){V.error(e instanceof Error?e.message:`Could not stop`)}},[]);return(0,L.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,L.jsx)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl`,children:(0,L.jsxs)(`div`,{className:q(`group/composer relative rounded-2xl border border-dock-border bg-dock shadow-dock backdrop-blur-xl backdrop-saturate-150 transition-[border-color,box-shadow] duration-300 ease-snap focus-within:border-ring/45 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&&te(e.dataTransfer.files)},children:[(0,L.jsx)(Ou,{initial:!1,children:a.length>0?(0,L.jsx)(z.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,L.jsx)(eQ,{file:e,onRemove:()=>ne(e.key)},e.key))},`files`):null}),s?(0,L.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,L.jsx)(kz,{text:r}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing to preview yet.`})}):null,(0,L.jsx)(`div`,{className:`flex px-4 pt-3 pb-1`,children:(0,L.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(),CO();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;ee(n===`k`?GZ(a,r,i):WZ(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=qZ(t.value,t.selectionStart);n&&(e.preventDefault(),ee(n));return}if(e.key===`Backspace`&&t.value===``&&O.current.length>0){e.preventDefault(),ne(O.current.at(-1).key);return}($Z(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),j())},onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),te(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,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 px-2 pt-1 pb-2`,children:[(0,L.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{te(e.target.files??[]),e.target.value=``}}),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:QZ,children:(0,L.jsx)(Eh,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsx)(dO,{children:`Attach images, PDFs or files`})]}),(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:QZ,children:(0,L.jsx)(Om,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsxs)(dO,{children:[`Preview `,(0,L.jsx)(ED,{chord:`Alt+P`})]})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-4 w-px bg-border`}),S.length>1?(0,L.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,L.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 bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e.pill},e.id))}):(0,L.jsxs)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:[`To the `,w.pill.toLowerCase()]}),(0,L.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end overflow-hidden px-2`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-3.5`,children:[e.kind===`tab`&&e.tab===`plan`?(0,L.jsx)(DD,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[34rem]:inline-flex`,children:`save plan`}):null,(0,L.jsx)(DD,{chord:`/`,className:`hidden group-focus-within/composer:!hidden @[28rem]:inline-flex`,children:`write`}),(0,L.jsx)(DD,{chord:`Esc`,className:`hidden group-[:not(:focus-within)]/composer:!hidden @[28rem]:inline-flex`,children:`tabs`}),(0,L.jsx)(DD,{chord:`Shift+Enter`,className:`hidden @[22rem]:inline-flex`,children:`new line`}),(0,L.jsx)(DD,{chord:`Enter`,className:`hidden @[11rem]:inline-flex`,children:`send`}),(0,L.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,L.jsx)(ED,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,L.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})}),y&&w.id===`oracle`?(0,L.jsx)(ck,{label:`Stop`,icon:ug,iconOnly:!0,compact:!0,title:`Stop the oracle?`,description:`The current response stops. Work already recorded is kept.`,confirmLabel:`Stop`,variant:`destructive`,onConfirm:()=>void ae()}):null,(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Send`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>void j(),disabled:!ie,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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5 text-primary-foreground`}):(0,L.jsx)(Pp,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.25})})}),(0,L.jsxs)(dO,{children:[`Send `,(0,L.jsx)(ED,{chord:`Enter`})]})]})]}),d?(0,L.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 nQ(){try{return{id:M()}}catch(e){return{error:e.message}}}function rQ(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. Start a project in Pi, then refresh.`}}function iQ(){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 De(`projects.list`,{});Se(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 aQ({data:e,error:t}){let n=nQ();return n.error??t??rQ(e,n.id)}function oQ({projects:e}){let t=aQ(e);return t?(0,L.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,L.jsx)(Sg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:t})]}):null}function sQ(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 cQ({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=nQ(),d=aQ(e),f=u.error?`invalid`:u.id??i?.currentId??``,p=!!i?.projects.length;kO(`p`,()=>l(!0),{enabled:p}),kO(`r`,()=>void s(),{enabled:c,inDialog:!0});function h(e){l(!1),e!==f&&_e(e,t)}return(0,L.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(fE,{open:c&&p,onOpenChange:l,children:[(0,L.jsxs)(pE,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c&&p,"aria-keyshortcuts":`P ArrowDown`,disabled:!p,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,L.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2.5 shrink-0 rounded-full`,d?`bg-destructive`:`bg-primary`)}),(0,L.jsx)(`span`,{className:`truncate`,children:n}),(0,L.jsx)(Xp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground`,!p&&`opacity-40`)})]}),(0,L.jsx)(mE,{children:(0,L.jsxs)(hE,{align:`start`,sideOffset:6,"aria-label":`Projects`,onKeyDown:sQ,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`glass-pop z-50 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,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,L.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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,L.jsx)(ED,{chord:`R`,className:`kbd-hint`})]})]}),(0,L.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===f;return(0,L.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>h(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,L.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,L.jsx)(Hp,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})})]})})]}),r?(0,L.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,L.jsx)(Im,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:r})]}):null,o||d?(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-4`}):(0,L.jsx)(Hh,{"aria-hidden":`true`,className:`size-4`})})}),(0,L.jsx)(dO,{side:`bottom`,children:`Refresh projects`})]}):null]})}function lQ({state:e}){return e===`live`?(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,L.jsx)(dO,{children:`Connected`})]}):e===`connecting`?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),`reconnecting…`]}):(0,L.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}var uQ=`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 dQ({label:e,hint:t,href:n,active:r,children:i}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`a`,{href:n,"aria-label":e,"aria-current":r?`page`:void 0,"aria-keyshortcuts":t,"aria-describedby":`focused-action-help`,className:uQ,children:i})}),(0,L.jsxs)(dO,{side:`bottom`,children:[e,` `,(0,L.jsx)(ED,{chord:t})]})]})}function fQ({hint:e,onHelp:t}){return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:uQ,children:(0,L.jsx)(Wm,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsxs)(dO,{side:`bottom`,children:[`Keyboard shortcuts `,(0,L.jsx)(ED,{chord:e})]})]})}function pQ(){let e=nG(),t=e?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,"aria-describedby":`focused-action-help`,className:uQ,onClick:()=>eG(!e),children:e?(0,L.jsx)(Mg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,L.jsx)(Ag,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsx)(dO,{side:`bottom`,children:t})]})}function mQ(){let{theme:e,setTheme:t}=cK(),n=e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:uQ,children:n?(0,L.jsx)(fg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,L.jsx)(bh,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,L.jsxs)(dO,{side:`bottom`,children:[n?`Light mode`:`Dark mode`,` `,(0,L.jsx)(ED,{chord:`D`})]})]})}function hQ({busy:e,task:t,sessionName:n}){return(0,L.jsxs)(`div`,{className:`mr-1 flex min-w-0 items-center gap-2 text-[0.8125rem]`,children:[e?(0,L.jsx)($D,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):null,t?(0,L.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate md:inline`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,L.jsxs)(`span`,{className:`hidden text-muted-foreground min-[1500px]:inline`,children:[` · `,t.state.replace(/_/g,` `)]})]}):(0,L.jsx)(`span`,{className:`hidden max-w-[10rem] truncate text-muted-foreground min-[1500px]:inline`,children:n??`no task in this session`})]})}function gQ(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 _Q=24;function vQ(){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=gQ(t.querySelector(`.where`))+(r?.offsetWidth??0)+gQ(t.querySelector(`.tools`))+a*2;n(s+_Q<=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 yQ({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=iQ(),{header:f,one:p}=vQ();return(0,L.jsxs)(`header`,{ref:f,className:`app-header shrink-0`,"data-one-row":p||void 0,children:[(0,L.jsx)(`div`,{className:`where flex min-w-0 items-center`,children:(0,L.jsx)(cQ,{projects:d,tab:r.kind===`tab`?r.tab:r.kind,name:c,branch:l})}),(0,L.jsx)(`div`,{className:`tabs min-w-0`,children:i}),(0,L.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[a,(0,L.jsx)(hQ,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,L.jsx)(lQ,{state:n}),(0,L.jsx)(dQ,{label:`Sessions`,hint:o.sessions??`Alt+O`,href:`#/sessions`,active:r.kind===`sessions`,children:(0,L.jsx)(Km,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,L.jsx)(dQ,{label:`Settings`,hint:o.settings??`Alt+S`,href:`#/settings`,active:r.kind===`settings`,children:(0,L.jsx)(ng,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,L.jsx)(fQ,{hint:o.help??`Alt+H`,onHelp:s}),(0,L.jsx)(mQ,{}),(0,L.jsx)(pQ,{}),(0,L.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,L.jsx)(oQ,{projects:d})]})}function bQ(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 xQ(){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 ke()?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(bQ(e))}return(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,L.jsxs)(`form`,{onSubmit:s,className:`glass flex w-full max-w-md flex-col gap-4 rounded-xl p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Hm,{className:`size-5`,"aria-hidden":`true`}),(0,L.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,L.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,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,L.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,L.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,L.jsx)(J,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var SQ=.6;function CQ(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:SQ,...n}}}var wQ=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function TQ(e,t=0,n=1){return CQ(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:SQ,times:wQ(t,n),ease:`easeInOut`},strokeOpacity:{duration:SQ,times:wQ(t,t+.02)}})}function EQ(e,t){return CQ(e,{scale:[0,0,1.3,1]},{times:wQ(t,t+.18),ease:`easeOut`})}function DQ(e,t,n=1.3){return CQ(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 OQ=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function kQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(.1,.9),...CQ(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,L.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,L.jsx)(z.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...CQ(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 AQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.path,{d:`M13 5h8`,...TQ(e,.15,.45)}),(0,L.jsx)(z.path,{d:`M13 12h8`,...TQ(e,.3,.6)}),(0,L.jsx)(z.path,{d:`M13 19h8`,...TQ(e,.45,.75)}),(0,L.jsx)(z.path,{d:`m3 17 2 2 4-4`,...TQ(e,.35,.7)}),(0,L.jsx)(z.path,{d:`m3 7 2 2 4-4`,...TQ(e,0,.35)})]})}function jQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:6,cy:19,r:3,style:OQ(),...DQ(e,0)}),(0,L.jsx)(z.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...TQ(e,.1,.7)}),(0,L.jsx)(z.circle,{cx:18,cy:5,r:3,style:OQ(),...EQ(e,.62)})]})}function MQ({play:e}){return(0,L.jsx)(z.g,{style:OQ(),...CQ(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,L.jsx)(z.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`,...CQ(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function NQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:12,cy:12,r:10,style:OQ(),...CQ(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,L.jsx)(z.circle,{cx:12,cy:12,r:10,style:OQ(),...CQ(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,L.jsx)(z.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:OQ(),...CQ(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function PQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}),[`M8 17v-3`,`M13 17V5`,`M18 17V9`].map((t,n)=>(0,L.jsx)(z.path,{d:t,style:OQ(.5,1),...CQ(e,{scaleY:[0,0,1.18,1]},{times:wQ(.08+n*.14,.4+n*.14),ease:`easeOut`})},t))]})}function FQ({play:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z.circle,{cx:6,cy:6,r:3,style:OQ(),...DQ(e,0)}),(0,L.jsx)(z.line,{x1:6,x2:6,y1:9,y2:21,...TQ(e,.05,.45)}),(0,L.jsx)(z.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...TQ(e,.2,.62)}),(0,L.jsx)(z.circle,{cx:18,cy:18,r:3,style:OQ(),...EQ(e,.58)})]})}function IQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(),...CQ(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,L.jsx)(z.path,{d:`M12 5v16`,style:OQ(),...CQ(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,L.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 LQ({play:e}){return(0,L.jsxs)(z.g,{style:OQ(.6,.6),...CQ(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,L.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,L.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,L.jsx)(z.path,{d:`m2.3 2.3 7.286 7.286`,...TQ(e,.1,.6)}),(0,L.jsx)(z.circle,{cx:11,cy:11,r:2,style:OQ(),...DQ(e,.5,1.5)})]})}var RQ={lobby:kQ,tasks:AQ,plan:jQ,quickfix:MQ,issues:NQ,metrics:PQ,git:FQ,knowledge:IQ,excalidraw:LQ};function zQ({id:e,play:t,className:n}){let r=RQ[e];return r?(0,L.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,L.jsx)(r,{play:t})},t):null}function BQ(e){return/(\d)$/.exec(e)?.[1]}var VQ=160;function HQ(e){let t=Sf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+SQ*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,VQ);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var UQ=(0,m.forwardRef)(function({tab:e,active:t},n){let r=BQ(e.key),{play:i,onPointerEnter:a}=HQ(t);return(0,L.jsxs)(lO,{children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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-input 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`:`text-muted-foreground hover:text-foreground`),children:[(0,L.jsx)(zQ,{id:e.id,play:i,className:q(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,L.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,L.jsx)(`span`,{children:e.label})]})}),(0,L.jsxs)(dO,{children:[e.label,` `,(0,L.jsx)(ED,{chord:e.key})]})]})}),WQ=1.5;function GQ(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 KQ(e,t){let n=e.right-e.left,{height:r}=e,i=WQ/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 qQ(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}`),KQ(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 JQ={type:`spring`,visualDuration:.12,bounce:0},YQ={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},XQ={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},ZQ={type:`spring`,visualDuration:.22,bounce:.25},QQ={type:`spring`,visualDuration:.2,bounce:0},$Q={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},e$=(()=>{let e=wr({keyframes:[0,1],visualDuration:ZQ.visualDuration,bounce:ZQ.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),t$={type:`spring`,visualDuration:.28,bounce:.6};function n$(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);GQ(r.current,t),GQ(i.current,void 0),qQ(a.current,t,`left`,1),qQ(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);_z()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),gz(),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);GQ(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),qQ(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));GQ(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),qQ(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Gf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,ee=()=>{if(k)return;k=!0;let e=O(`filled`,0,ZQ,e=>{d.current=e});e.then(()=>{l.current===t&&_z()}),O(`squash`,.8,t$),O(`rung`,0,QQ,e=>{f.current=e}),O(`budge`,0,{...$Q,delay:e$},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,JQ),O(`unrung`,T.unrung,JQ),O(`head`,0,YQ,e=>{e>=w&&ee()}),O(`tail`,0,XQ),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 r$=(0,m.forwardRef)(function({which:e},t){return(0,L.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,L.jsx)(`path`,{pathLength:1,strokeWidth:WQ,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,L.jsx)(`path`,{pathLength:1,strokeWidth:WQ,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function i$(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 a$({tabs:e,activeId:t,onSelect:n}){let{track:r,fill:i,drain:a,ring:o,unring:s,cells:c,liquids:l}=n$(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){SO()&&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];wO.active=!0,wO.to=o.id,window.setTimeout(()=>{wO.active=!1,wO.to=void 0},3e3),n(o.id),c.current[o.id]?.focus({preventScroll:!0})}return(0,L.jsx)(`div`,{ref:u,onScroll:p,style:{maskImage:i$(d),WebkitMaskImage:i$(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,L.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,L.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,L.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,L.jsx)(r$,{ref:s,which:`unring`}),(0,L.jsx)(r$,{ref:o,which:`ring`}),e.map((e,n)=>(0,L.jsxs)(m.Fragment,{children:[n>0?(0,L.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,L.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,L.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,L.jsx)(UQ,{ref:t=>{c.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function o$({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(sV(dV(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:sV(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 s$(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}var c$=6,l$=`bot-lobby.orb`,u$=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function d$(e,t,n,r){let i=e=>e+c$,a=(e,t)=>Math.max(e+c$,e+t-r-c$);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 f$(e,t,n,r){let i=e=>Math.max(1,e-r),a=d$(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 p$(e,t,n){return d$(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function m$(e){if(e)try{let t=JSON.parse(e);return u$(t.fx)&&u$(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function h$(){try{return m$(localStorage.getItem(l$))}catch{return}}function g$(e){try{localStorage.setItem(l$,JSON.stringify(e))}catch{}}var _$=5,v$=16;function y$(){let e=document.getElementById(`main`)?.getBoundingClientRect();return e?{left:e.left,top:e.top,width:e.width,height:e.height}:void 0}function b$(){let[e,t]=(0,m.useState)(y$);return(0,m.useEffect)(()=>{let e=()=>t(y$()),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 x$=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=b$(),[u,d]=(0,m.useState)(h$),[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?p$(u,l,y.current):void 0),x=(0,m.useCallback)((e,t)=>{let n=y$();if(!n)return;let r=f$(e,t,n,y.current);d(r),g$(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)<_$)return;t.moved=!0;let i=y$();i&&p(d$(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:v$,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?sV(e):E?s$(n):void 0,O=e?`${t.map(sV).join(`, `)} thinking. `:E?`${n.join(`, `)} at work. `:``,k=b&&l?b.x-l.left<140:!1,ee={"--orb":r,...b?{left:b.x,top:b.y,right:`auto`,bottom:`auto`}:{}};return(0,L.jsxs)(lO,{open:h&&!f,onOpenChange:g,children:[(0,L.jsx)(uO,{asChild:!0,children:(0,L.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:ee,"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,L.jsx)(Ou,{initial:!1,children:D?(0,L.jsx)(z.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,L.jsx)(Ou,{mode:`popLayout`,initial:!1,children:(0,L.jsx)(z.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,L.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,L.jsx)(`span`,{className:`orb-icon`,children:(0,L.jsx)(aV,{source:e,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,L.jsxs)(dO,{side:`top`,children:[`Thinking `,o?(0,L.jsx)(ED,{chord:o}):null,(0,L.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),S$=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,C$=260,w$=200,T$=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function E$(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(`
|
|
103
103
|
`).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
|
|
104
104
|
`).trim()),t.filter(Boolean)}function D$(e){let t=e.split(/(?<=[.!?…])\s+(?=[A-Z"'“‘`(\[])/),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&(t.split("`").length-1)%2==1?n[n.length-1]=`${t} ${e}`:n.push(e)}return n}function O$(e){if(e.length<=C$||T$.test(e))return[e];let t=[],n=``;for(let r of D$(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>w$?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function k$(e){let t=e.replace(/\r\n?/g,`
|
|
105
105
|
`).trim().split(`
|
|
106
106
|
`),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:S$.exec(e),i=t?(t[1]??t[2]??t[3])?.trim():void 0;i?n.push({title:i,lines:[]}):n.at(-1).lines.push(e)}let i=[];for(let e of n){let t=E$(e.lines);if(e.title)i.push({title:e.title,text:t.join(`
|
|
107
107
|
|
|
108
|
-
`)});else for(let e of t)for(let t of O$(e))i.push({text:t})}return i}var A$=4,j$=1800,M$=e=>({"--orb":e});function N$(e){let[t,n]=(0,m.useState)(0),r=e.join(`|`);return(0,m.useEffect)(()=>{if(n(0),e.length<2)return;let t=window.setInterval(()=>n(e=>e+1),j$);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function P$({thought:e}){let t=(0,m.useMemo)(()=>k$(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-A$),a=t.slice(i),o=CV(e.source);return(0,L.jsxs)(`li`,{className:`thought`,style:M$(EV(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`thought-label`,children:[(0,L.jsx)(xV,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,L.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):ZO(Date.now()-e.at)}),t.length>1?(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,L.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,L.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,L.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,L.jsx)(kz,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function F$(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!CZ(e,t)||e.target?.closest(`input, textarea, [contenteditable='true']`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,n])}function I$(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function L$({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=I$(kV(e)),o=a.filter(e=>e.live).map(e=>e.source),s=N$(o),c=s?EV(s):i.length?`var(--primary)`:`var(--orb-idle)`,l=s?`thinking`:i.length?`busy`:void 0,u=(0,m.useRef)(null),d=(0,m.useRef)(t);d.current=t,(0,m.useEffect)(()=>()=>{d.current||n()},[n]);let f=ID(!t,FD.sheet),p=RD();F$(f,r,n);let h=a.length>0||i.length>0;return(0,L.jsxs)(L.Fragment,{children:[h&&(0,Rv.createPortal)((0,L.jsx)(x$,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:p,shortcut:r,onOpen:n}),document.body),(0,L.jsxs)(OD,{open:f,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:q(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:M$(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,L.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,L.jsx)(`div`,{className:`relative min-h-0 overflow-y-auto p-3 outline-none sm:p-4`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,L.jsx)(P$,{thought:e},e.id))}):(0,L.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})})]})]})}function R$({status:e,lobby:t}){let[n,r]=iU(`lobby.thinking`),i=sO(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=o$({oracleBusy:e.busy,runs:OV(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,L.jsx)(L$,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var z$=/\s*\(recommended\)\s*$/i,B$=1200,V$=`Type something.`;function H$(e){return{text:e.replace(z$,``),recommended:z$.test(e)}}function U$({label:e}){let{text:t,recommended:n}=H$(e);return(0,L.jsxs)(`span`,{className:`leading-snug`,children:[t,n?(0,L.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function W$({multi:e,on:t}){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:q(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,L.jsx)(Hp,{className:q(e?`size-3`:`hidden`)}):null,t&&!e?(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function G$({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsxs)(`label`,{className:q(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99]`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,L.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,L.jsx)(W$,{multi:n,on:i}),(0,L.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,L.jsx)(U$,{label:e.label})]})})]}),e.description?(0,L.jsx)(kz,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function K$({option:e,onExpand:t}){return!e||!Bq(e)?null:(0,L.jsxs)(`div`,{className:`card-raised flex flex-col gap-2 rounded-lg border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,H$(e.label).text]}),(0,L.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,L.jsx)(eh,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,L.jsx)(`img`,{src:N(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,L.jsx)(Iq,{preview:e.htmlPreview,label:H$(e.label).text,frameWidth:B$,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,L.jsx)(kz,{text:e.preview,className:`text-xs`}):null]})}function q$({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i}){return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),(0,L.jsx)(J,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function J$(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function Y$({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:q(`inline-flex min-h-8 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[a+1,` `,e.header,o?(0,L.jsx)(Hp,{className:`size-3`,"aria-hidden":`true`}):null]},a)})})}function X$({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a}){let[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(!1),u=i??c,d=e=>a?a(e):l(e),[f,p]=(0,m.useState)(0),h=(0,m.useRef)(0),g=(0,m.useRef)(!1),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)({}),[x,S]=(0,m.useState)({}),C=(0,m.useRef)(null),w=e[o],T=_[o]??[],E=y[o]??``,D=w?.options[x[o]??T[0]??0],O=J$(e,_,y,o),k=w?.multiSelect===!0;if((0,m.useEffect)(()=>{let e=C.current;e&&(e.querySelector(`[data-option="${_[o]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[o]),(0,m.useEffect)(()=>{let e=g.current&&!u;g.current=u,e&&(S(e=>({...e,[o]:h.current})),C.current?.querySelector(`[data-option="${h.current}"]`)?.focus())},[u]),!w)return null;let ee=w.options.some(Bq);function te(e){p(Math.max(0,e)),h.current=Math.max(0,e),d(!0)}function ne(e){h.current=e,d(!1)}if(u&&ee)return(0,L.jsx)(Hq,{options:w.options,start:f,title:w.header||w.question,picked:T,multi:k,onChoose:e=>{A(e),k||ne(e)},onClose:ne,onIndex:e=>{h.current=e}},o);function A(e){let t=k?T.includes(e)?T.filter(t=>t!==e):[...T,e]:[e];v({..._,[o]:t}),k||b({...y,[o]:``}),S({...x,[o]:e})}function re(t,r){if(J$(e,t,r,o)){if(o<e.length-1){s(o+1);return}n({answers:e.map((n,i)=>J$(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function ie(e){e.preventDefault(),t||re(_,y)}function j(t){t>=0&&t<e.length&&s(t)}function ae(e){let n=e.target,r=C.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||re(_,y);return}if(n instanceof HTMLTextAreaElement){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),t||re(_,y)):e.key===`ArrowUp`&&n.selectionStart===0&&n.selectionEnd===0&&(e.preventDefault(),pO(r,n,-1));return}let i=hO(e.key);if(i){e.preventDefault(),pO(r,n,i);return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),pO(r,n,e.key===`Home`?`first`:`last`);return}let a=gO(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),j(o+a);return}let s=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&s>=0){if(e.preventDefault(),k)T.length>0&&T.includes(s)?re(_,y):A(s);else{let e={..._,[o]:[s]},t={...y,[o]:``};v(e),b(t),re(e,t)}return}if(e.key===` `&&s>=0){e.preventDefault(),A(s);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=w.options.length){e.preventDefault(),A(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&ee&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),te(s>=0?s:x[o]??T[0]??0))}return(0,L.jsxs)(`form`,{ref:C,className:`flex flex-col gap-3`,onSubmit:ie,onKeyDown:ae,children:[(0,L.jsx)(Y$,{questions:e,picks:_,own:y,index:o,onGo:s}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length>1?`Question ${o+1} of ${e.length}`:`Question`}),(0,L.jsx)(kz,{text:w.question,className:`mt-1 text-base`})]}),(0,L.jsxs)(`div`,{className:q(`grid min-w-0 gap-4`,D?.preview||D?.image||D?.htmlPreview?`lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]`:``),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[w.options.map((e,t)=>(0,L.jsx)(G$,{option:e,index:t,multi:k,name:`question-${o}`,selected:T.includes(t),onToggle:()=>A(t),onFocusOption:()=>S({...x,[o]:t})},t)),(0,L.jsxs)(`label`,{className:`flex min-h-9 flex-col gap-1 rounded-lg border border-input px-3 py-1.5 text-sm focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/30`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Your own answer`}),(0,L.jsx)(KO,{"data-nav":``,value:E,onChange:e=>{b({...y,[o]:e.target.value}),e.target.value&&v({..._,[o]:[]})},placeholder:V$,"aria-label":`Your own answer`,rows:2,className:`min-h-9 resize-none border-0 bg-transparent p-0 text-sm shadow-none focus-visible:ring-0 md:text-sm`})]})]}),(0,L.jsx)(K$,{option:D,onExpand:()=>te(w.options.indexOf(D))})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:k?`Pick several`:`Pick one`}),(0,L.jsx)(DD,{chord:`↑↓`,children:`move`}),(0,L.jsx)(DD,{chord:k?`Space`:`Enter`,children:k?`pick`:`choose`}),k?(0,L.jsx)(DD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,L.jsx)(DD,{chord:`←→`,children:`question`}):null,ee?(0,L.jsx)(DD,{chord:`E`,children:`expand mockups`}):null,(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:o<e.length-1?`Next`:`Answer`,disabled:!O,submitting:t,onCancel:r})]})}function Z$(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||mO(i))return;let a=hO(e.key);if(a){e.preventDefault(),pO(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function Q$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,L.jsxs)(`form`,{ref:o,className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>Z$(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,L.jsx)(kz,{text:e.title,className:`text-base`}),(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,L.jsx)(G$,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`↑↓`,children:`move`}),(0,L.jsx)(DD,{chord:`Enter`,children:`choose`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function $$({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,L.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex flex-col gap-3 outline-none`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(kz,{text:e.question,className:`text-base`}),e.detail?(0,L.jsx)(kz,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`Y`,children:`yes`}),(0,L.jsx)(DD,{chord:`N`,children:`no`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,L.jsx)(J,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function e1({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,L.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,L.jsx)(kz,{text:e.question,className:`text-base`}),(0,L.jsx)(KO,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??V$,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm md:text-sm`}),(0,L.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`Enter`,children:`answer`}),(0,L.jsx)(DD,{chord:`Shift+Enter`,children:`new line`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function t1({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,L.jsxs)(`form`,{ref:l,className:`flex flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&Z$(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,L.jsx)(kz,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,L.jsx)(G$,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,L.jsx)(KO,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??V$,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm md:text-sm`}):null,(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,L.jsx)(J,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,L.jsx)(J,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function n1(e){let{view:t}=e;return t.kind===`questionnaire`?(0,L.jsx)(X$,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,L.jsx)(Q$,{...e,view:t}):t.kind===`confirm`?(0,L.jsx)($$,{...e,view:t}):t.kind===`text`?(0,L.jsx)(e1,{...e,view:t}):(0,L.jsx)(t1,{...e,dialog:t.dialog})}function r1(e){return typeof e==`object`&&e?e:{}}function i1(e){return typeof e==`string`?e.trim():``}function a1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function o1(e){let t=r1(e),n=i1(t.label);if(!n)return;let r=i1(t.description),i=i1(t.preview),a=i1(t.image),o=jq(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function s1(e){let t=r1(e),n=i1(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(o1).filter(e=>!!e);return{question:n,header:i1(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function c1(e){let t=r1(e),n=i1(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=i1(t.message),i=a1(t.options),a=i1(t.placeholder),o=i1(t.prefill);return{id:i1(t.id),method:n,title:i1(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function l1(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(s1).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function u1(e){return{kind:`choose`,title:i1(e.title)||`Choose an option`,options:a1(e.options)}}function d1(e){let t=i1(e.question)||i1(e.title)||`Continue?`,n=i1(e.detail)||i1(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function f1(e){let t=i1(e.question)||i1(e.title)||`Type an answer`,n=i1(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function p1(e){let t=r1(e.payload);if(e.kind===`questionnaire`)return l1(t);if(e.kind===`choose`)return u1(t);if(e.kind===`confirm`)return d1(t);if(e.kind===`text`)return f1(t);let n=c1(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}function m1({submitting:e,onKeep:t,onLeave:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`alert`,children:[(0,L.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,L.jsx)(J,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function h1({count:e,onOpen:t}){return(0,L.jsxs)(J,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,L.jsx)(cm,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:`waiting`})]})}function g1({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=e.length,f=e[0],p=f?p1(f):void 0,h=d>0&&!r,g=ID(h,FD.question);(0,m.useEffect)(()=>{d===0&&(o(!1),i(!1))},[d,i]);let _=f?.id;(0,m.useEffect)(()=>u(!1),[_]);async function v(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof Te&&e.code===`question_withdrawn`?V(BD):V.error(e instanceof Error?e.message:t)}finally{c(!1)}}let y=f?.from?`${f.from} asks`:`A question`;return(0,L.jsx)(OD,{open:h&&g&&!!f,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:q(`max-w-3xl`,l&&`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`),children:f?(0,L.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`header`,{className:q(`flex items-center gap-3 px-6 pt-5 pb-3`,l&&`hidden`),children:[(0,L.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[y,d>1?` · 1 of ${d}`:``]}),(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,L.jsx)(Rg,{"aria-hidden":`true`})})]}),(0,L.jsx)(`div`,{className:l?`flex min-h-0 flex-1 flex-col`:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:p?a?(0,L.jsx)(m1,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void v(n(f.id),`Could not leave the question`)}):(0,L.jsx)(n1,{view:p,submitting:s,onAnswer:e=>void v(t(f.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u},f.id):(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,L.jsx)(J,{type:`button`,disabled:s,onClick:()=>void v(n(f.id),`Could not dismiss the question`),children:`Dismiss`})]})})]}):null})}var _1=2;function v1(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function y1(e){try{return JSON.parse(e)}catch{return}}function b1(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function x1(e,t=v1){let n=t(N(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===_1?`offline`:`connecting`),n.onmessage=t=>{let n=y1(t.data);n&&b1(n,e)},()=>n.close()}var S1=2e3,C1=()=>De(`projects.list`,{});async function w1(){let e;try{e=M()}catch{return}if(e&&!Ce(e))try{Se((await C1()).projects)}catch{}}function T1(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{M()}catch{me.onStatus({connection:`offline`});return}e.current=x1({onHello:e=>{me.onHello(e),w1()},onChanged:(e,t)=>me.onChanged(e,t),onFeed:e=>me.onFeedDelta(e),onReply:e=>me.onReplyDelta(e),onNotice:(e,t)=>V[t](e),onConnection:e=>{me.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{we(C1).catch(()=>!1).finally(n)},S1))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var E1=`bot-lobby.recoveredAt`,D1;function O1(e,t=k1()){try{D1===void 0&&(D1=Number(t?.getItem(E1)??0))}catch{D1??=0}if(D1!==void 0&&e<=D1)return!1;D1=e;try{t?.setItem(E1,String(e))}catch{}return!0}function k1(){try{return globalThis.sessionStorage}catch{return}}function A1(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&O1(t)&&V.success(n)},[t,n])}function j1(){let e=aO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await De(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await De(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function M1(e,t,n,r){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?GD(`#/settings`):e===`sessions`?GD(`#/sessions`):e===`thinking`?rU(`lobby.thinking`):e===`activity`?t.kind===`tab`&&t.tab===`lobby`?rU(`lobby.activity`):GD(WD(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&H(`planner.save`,{})}var N1=2500;function P1(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),N1);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function F1({connection:e,onRetry:t}){return P1(e)?(0,L.jsx)(nO,{onRetry:t}):null}var I1={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{I1.route=++I1.tick}),document.addEventListener(`focusin`,()=>{I1.focus=++I1.tick});var L1=()=>I1.focus>I1.route;function R1(e){return e.kind===`tab`?e.tab:e.kind}function z1(){let e=KD(),t=aO(`status`),n=aO(`lobby`),{prompts:r,answer:i,dismiss:a}=j1(),{connection:o,signedOut:s}=iO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=T1();wG();let h=t.data;A1(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Ue()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>GD(WD(e)),[]),x=(0,m.useCallback)(e=>{if(_.length===0)return;let t=Math.max(0,_.findIndex(e=>e.id===y)),n=_[(t+e+_.length)%_.length];n&&GD(WD(n.id))},[_,y]),S=(0,m.useCallback)(()=>l(e=>!e),[]),C=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&M1(t,UD(window.location.hash)??e,S,x)},[e,S,x,h?.panels]),w=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble`)?!0:e.closest(`[data-state='closed']`)!==null},[]);AZ({enabled:!!h,keys:v,tabs:_,insideApp:w,onAction:C,onTab:b});let T=(0,m.useCallback)(()=>me.onHello({}),[]),E=e.kind===`tab`?e.tab:e.kind,D=!!h;(0,m.useEffect)(()=>{if(!D)return;let e=wO.active&&wO.to===E;if(wO.active=!1,wO.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(L1()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`),t=typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches;e&&!e.disabled&&!t?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[E,D]);let O=Object.fromEntries(v.map(e=>[e.action,e.label])),k=(0,L.jsx)(yQ,{status:h,task:n.data?.task,connection:o,route:e,keys:O,onHelp:S,tabs:(0,L.jsx)(a$,{tabs:_,activeId:y,onSelect:b}),extra:u&&r.length>0?(0,L.jsx)(h1,{count:r.length,onOpen:()=>d(!1)}):null});return s||!h?(0,L.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[k,(0,L.jsx)(`main`,{className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto max-sm:mx-0 max-sm:mb-0`,children:s?(0,L.jsx)(xQ,{}):t.error?(0,L.jsx)(tO,{message:t.error,onRetry:T}):(0,L.jsx)(eO,{})})]}):(0,L.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[k,(0,L.jsx)(F1,{connection:o,onRetry:p}),(0,L.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||mO(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||CO()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto outline-none max-sm:mx-0 max-sm:mb-0`,children:(0,L.jsx)(z.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:_Z(e)},R1(e))}),(0,L.jsx)(tQ,{route:e,keys:O,onHelp:S}),(0,L.jsx)(R$,{status:h,lobby:n.data}),(0,L.jsx)(g1,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,L.jsx)(VZ,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function B1(e){switch(e){case`status`:return De(`status.get`,{});case`lobby`:return De(`lobby.snapshot`,{});case`prompts`:return De(`prompts.list`,{});default:return}}var V1=[`status`,`lobby`,`prompts`];function H1(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await ke(),e&&(me.markUsed(V1,B1),t(!0))})(),()=>{e=!1}},[]),e}function U1(){return H1()?(0,L.jsx)(z1,{}):(0,L.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,L.jsx)(eO,{})})}var W1={info:Bm,success:nm,warning:Sg,error:fm},G1={info:`text-primary`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function K1(){let{item:e,waiting:t}=op(),n=RD(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>ip(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed inset-x-0 z-40 flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + 0.25rem)`},children:(0,L.jsx)(Ou,{mode:`wait`,children:r?(0,L.jsxs)(z.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-3 rounded-xl border border-glass-border bg-popover/80 px-4 py-2.5 text-sm text-popover-foreground shadow-glass backdrop-blur-xs`,children:[(0,L.jsx)(q1,{kind:e.kind}),(0,L.jsx)(`span`,{className:`min-w-0 break-words`,children:e.message}),e.action?(0,L.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-raised -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border bg-card px-2.5 font-medium text-primary transition-[box-shadow,translate] active:translate-y-px focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none`,onClick:()=>{e.action?.onClick(),ip(e.id)},children:e.action.label}):null]},e.id):null})})}function q1({kind:e}){let t=W1[e];return(0,L.jsx)(t,{"aria-hidden":`true`,className:q(`size-5 shrink-0`,G1[e])})}(0,Zf.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(m.StrictMode,{children:(0,L.jsx)(sK,{children:(0,L.jsx)(Fu,{reducedMotion:`user`,children:(0,L.jsxs)(cO,{children:[(0,L.jsx)(U1,{}),(0,L.jsx)(K1,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});
|
|
108
|
+
`)});else for(let e of t)for(let t of O$(e))i.push({text:t})}return i}var A$=4,j$=1800,M$=e=>({"--orb":e});function N$(e){let[t,n]=(0,m.useState)(0),r=e.join(`|`);return(0,m.useEffect)(()=>{if(n(0),e.length<2)return;let t=window.setInterval(()=>n(e=>e+1),j$);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function P$({thought:e}){let t=(0,m.useMemo)(()=>k$(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-A$),a=t.slice(i),o=sV(e.source);return(0,L.jsxs)(`li`,{className:`thought`,style:M$(uV(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`thought-label`,children:[(0,L.jsx)(aV,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,L.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):ZO(Date.now()-e.at)}),t.length>1?(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,L.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,L.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,L.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,L.jsx)(kz,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function F$(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!CZ(e,t)||e.target?.closest(`input, textarea, [contenteditable='true']`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,n])}function I$(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function L$({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=I$(pV(e)),o=a.filter(e=>e.live).map(e=>e.source),s=N$(o),c=s?uV(s):i.length?`var(--primary)`:`var(--orb-idle)`,l=s?`thinking`:i.length?`busy`:void 0,u=(0,m.useRef)(null),d=(0,m.useRef)(t);d.current=t,(0,m.useEffect)(()=>()=>{d.current||n()},[n]);let f=ID(!t,FD.sheet),p=RD();F$(f,r,n);let h=a.length>0||i.length>0;return(0,L.jsxs)(L.Fragment,{children:[h&&(0,Rv.createPortal)((0,L.jsx)(x$,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:p,shortcut:r,onOpen:n}),document.body),(0,L.jsxs)(OD,{open:f,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:q(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:M$(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,L.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,L.jsx)(`div`,{className:`relative min-h-0 overflow-y-auto p-3 outline-none sm:p-4`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,L.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,L.jsx)(P$,{thought:e},e.id))}):(0,L.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})})]})]})}function R$({status:e,lobby:t}){let[n,r]=CU(`lobby.thinking`),i=sO(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=o$({oracleBusy:e.busy,runs:fV(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,L.jsx)(L$,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var z$=/\s*\(recommended\)\s*$/i,B$=1200,V$=`Type something.`;function H$(e){return{text:e.replace(z$,``),recommended:z$.test(e)}}function U$({label:e}){let{text:t,recommended:n}=H$(e);return(0,L.jsxs)(`span`,{className:`leading-snug`,children:[t,n?(0,L.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function W$({multi:e,on:t}){return(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:q(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,L.jsx)(Hp,{className:q(e?`size-3`:`hidden`)}):null,t&&!e?(0,L.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function G$({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsxs)(`label`,{className:q(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99]`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,L.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,L.jsx)(W$,{multi:n,on:i}),(0,L.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,L.jsx)(U$,{label:e.label})]})})]}),e.description?(0,L.jsx)(kz,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function K$({option:e,onExpand:t}){return!e||!Bq(e)?null:(0,L.jsxs)(`div`,{className:`card-raised flex flex-col gap-2 rounded-lg border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,H$(e.label).text]}),(0,L.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:`Expand · E`,className:`-my-1 shrink-0`,children:[(0,L.jsx)(eh,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,L.jsx)(`img`,{src:N(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,L.jsx)(Iq,{preview:e.htmlPreview,label:H$(e.label).text,frameWidth:B$,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,L.jsx)(kz,{text:e.preview,className:`text-xs`}):null]})}function q$({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i}){return(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),(0,L.jsx)(J,{type:e,disabled:n||r,children:r?`Sending…`:t})]})}function J$(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function Y$({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,L.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:q(`inline-flex min-h-8 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[a+1,` `,e.header,o?(0,L.jsx)(Hp,{className:`size-3`,"aria-hidden":`true`}):null]},a)})})}function X$({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a}){let[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(!1),u=i??c,d=e=>a?a(e):l(e),[f,p]=(0,m.useState)(0),h=(0,m.useRef)(0),g=(0,m.useRef)(!1),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)({}),[x,S]=(0,m.useState)({}),C=(0,m.useRef)(null),w=e[o],T=_[o]??[],E=y[o]??``,D=w?.options[x[o]??T[0]??0],O=J$(e,_,y,o),k=w?.multiSelect===!0;if((0,m.useEffect)(()=>{let e=C.current;e&&(e.querySelector(`[data-option="${_[o]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[o]),(0,m.useEffect)(()=>{let e=g.current&&!u;g.current=u,e&&(S(e=>({...e,[o]:h.current})),C.current?.querySelector(`[data-option="${h.current}"]`)?.focus())},[u]),!w)return null;let ee=w.options.some(Bq);function te(e){p(Math.max(0,e)),h.current=Math.max(0,e),d(!0)}function ne(e){h.current=e,d(!1)}if(u&&ee)return(0,L.jsx)(Hq,{options:w.options,start:f,title:w.header||w.question,picked:T,multi:k,onChoose:e=>{A(e),k||ne(e)},onClose:ne,onIndex:e=>{h.current=e}},o);function A(e){let t=k?T.includes(e)?T.filter(t=>t!==e):[...T,e]:[e];v({..._,[o]:t}),k||b({...y,[o]:``}),S({...x,[o]:e})}function re(t,r){if(J$(e,t,r,o)){if(o<e.length-1){s(o+1);return}n({answers:e.map((n,i)=>J$(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function ie(e){e.preventDefault(),t||re(_,y)}function j(t){t>=0&&t<e.length&&s(t)}function ae(e){let n=e.target,r=C.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||re(_,y);return}if(n instanceof HTMLTextAreaElement){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),t||re(_,y)):e.key===`ArrowUp`&&n.selectionStart===0&&n.selectionEnd===0&&(e.preventDefault(),pO(r,n,-1));return}let i=hO(e.key);if(i){e.preventDefault(),pO(r,n,i);return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),pO(r,n,e.key===`Home`?`first`:`last`);return}let a=gO(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),j(o+a);return}let s=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&s>=0){if(e.preventDefault(),k)T.length>0&&T.includes(s)?re(_,y):A(s);else{let e={..._,[o]:[s]},t={...y,[o]:``};v(e),b(t),re(e,t)}return}if(e.key===` `&&s>=0){e.preventDefault(),A(s);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=w.options.length){e.preventDefault(),A(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&ee&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),te(s>=0?s:x[o]??T[0]??0))}return(0,L.jsxs)(`form`,{ref:C,className:`flex flex-col gap-3`,onSubmit:ie,onKeyDown:ae,children:[(0,L.jsx)(Y$,{questions:e,picks:_,own:y,index:o,onGo:s}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length>1?`Question ${o+1} of ${e.length}`:`Question`}),(0,L.jsx)(kz,{text:w.question,className:`mt-1 text-base`})]}),(0,L.jsxs)(`div`,{className:q(`grid min-w-0 gap-4`,D?.preview||D?.image||D?.htmlPreview?`lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]`:``),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[w.options.map((e,t)=>(0,L.jsx)(G$,{option:e,index:t,multi:k,name:`question-${o}`,selected:T.includes(t),onToggle:()=>A(t),onFocusOption:()=>S({...x,[o]:t})},t)),(0,L.jsxs)(`label`,{className:`flex min-h-9 flex-col gap-1 rounded-lg border border-input px-3 py-1.5 text-sm focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/30`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Your own answer`}),(0,L.jsx)(KO,{"data-nav":``,value:E,onChange:e=>{b({...y,[o]:e.target.value}),e.target.value&&v({..._,[o]:[]})},placeholder:V$,"aria-label":`Your own answer`,rows:2,className:`min-h-9 resize-none border-0 bg-transparent p-0 text-sm shadow-none focus-visible:ring-0 md:text-sm`})]})]}),(0,L.jsx)(K$,{option:D,onExpand:()=>te(w.options.indexOf(D))})]}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:k?`Pick several`:`Pick one`}),(0,L.jsx)(DD,{chord:`↑↓`,children:`move`}),(0,L.jsx)(DD,{chord:k?`Space`:`Enter`,children:k?`pick`:`choose`}),k?(0,L.jsx)(DD,{chord:`Enter`,children:`next`}):null,e.length>1?(0,L.jsx)(DD,{chord:`←→`,children:`question`}):null,ee?(0,L.jsx)(DD,{chord:`E`,children:`expand mockups`}):null,(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:o<e.length-1?`Next`:`Answer`,disabled:!O,submitting:t,onCancel:r})]})}function Z$(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||mO(i))return;let a=hO(e.key);if(a){e.preventDefault(),pO(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function Q$({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,L.jsxs)(`form`,{ref:o,className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>Z$(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,L.jsx)(kz,{text:e.title,className:`text-base`}),(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,L.jsx)(G$,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`↑↓`,children:`move`}),(0,L.jsx)(DD,{chord:`Enter`,children:`choose`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function $$({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,L.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex flex-col gap-3 outline-none`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(kz,{text:e.question,className:`text-base`}),e.detail?(0,L.jsx)(kz,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`Y`,children:`yes`}),(0,L.jsx)(DD,{chord:`N`,children:`no`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),children:`No`}),(0,L.jsx)(J,{type:`button`,disabled:t,onClick:()=>n(!0),children:t?`Sending…`:`Yes`})]})]})]})}function e1({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,L.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,L.jsx)(kz,{text:e.question,className:`text-base`}),(0,L.jsx)(KO,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??V$,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm md:text-sm`}),(0,L.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,L.jsx)(DD,{chord:`Enter`,children:`answer`}),(0,L.jsx)(DD,{chord:`Shift+Enter`,children:`new line`}),(0,L.jsx)(DD,{chord:`Esc`,children:`later`})]}),(0,L.jsx)(q$,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function t1({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,L.jsxs)(`form`,{ref:l,className:`flex flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&Z$(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,L.jsx)(kz,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,L.jsx)(G$,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,L.jsx)(KO,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??V$,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm md:text-sm`}):null,(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),children:`Cancel`}),e.method===`confirm`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),children:`No`}),(0,L.jsx)(J,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),children:t?`Sending…`:`Yes`})]}):(0,L.jsx)(J,{type:`submit`,disabled:!c||t,children:t?`Sending…`:`Answer`})]})]})}function n1(e){let{view:t}=e;return t.kind===`questionnaire`?(0,L.jsx)(X$,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,L.jsx)(Q$,{...e,view:t}):t.kind===`confirm`?(0,L.jsx)($$,{...e,view:t}):t.kind===`text`?(0,L.jsx)(e1,{...e,view:t}):(0,L.jsx)(t1,{...e,dialog:t.dialog})}function r1(e){return typeof e==`object`&&e?e:{}}function i1(e){return typeof e==`string`?e.trim():``}function a1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function o1(e){let t=r1(e),n=i1(t.label);if(!n)return;let r=i1(t.description),i=i1(t.preview),a=i1(t.image),o=jq(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function s1(e){let t=r1(e),n=i1(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(o1).filter(e=>!!e);return{question:n,header:i1(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function c1(e){let t=r1(e),n=i1(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=i1(t.message),i=a1(t.options),a=i1(t.placeholder),o=i1(t.prefill);return{id:i1(t.id),method:n,title:i1(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function l1(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(s1).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function u1(e){return{kind:`choose`,title:i1(e.title)||`Choose an option`,options:a1(e.options)}}function d1(e){let t=i1(e.question)||i1(e.title)||`Continue?`,n=i1(e.detail)||i1(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function f1(e){let t=i1(e.question)||i1(e.title)||`Type an answer`,n=i1(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function p1(e){let t=r1(e.payload);if(e.kind===`questionnaire`)return l1(t);if(e.kind===`choose`)return u1(t);if(e.kind===`confirm`)return d1(t);if(e.kind===`text`)return f1(t);let n=c1(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}function m1({submitting:e,onKeep:t,onLeave:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`alert`,children:[(0,L.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(J,{type:`button`,variant:`outline`,onClick:t,children:`Keep answering`}),(0,L.jsx)(J,{type:`button`,disabled:e,onClick:n,children:e?`Leaving…`:`Leave`})]})]})}function h1({count:e,onOpen:t}){return(0,L.jsxs)(J,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning`,children:[(0,L.jsx)(cm,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:`waiting`})]})}function g1({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=e.length,f=e[0],p=f?p1(f):void 0,h=d>0&&!r,g=ID(h,FD.question);(0,m.useEffect)(()=>{d===0&&(o(!1),i(!1))},[d,i]);let _=f?.id;(0,m.useEffect)(()=>u(!1),[_]);async function v(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof Te&&e.code===`question_withdrawn`?V(BD):V.error(e instanceof Error?e.message:t)}finally{c(!1)}}let y=f?.from?`${f.from} asks`:`A question`;return(0,L.jsx)(OD,{open:h&&g&&!!f,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},className:q(`max-w-3xl`,l&&`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`),children:f?(0,L.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`header`,{className:q(`flex items-center gap-3 px-6 pt-5 pb-3`,l&&`hidden`),children:[(0,L.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[y,d>1?` · 1 of ${d}`:``]}),(0,L.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:`Later · Esc`,onClick:()=>i(!0),children:(0,L.jsx)(Rg,{"aria-hidden":`true`})})]}),(0,L.jsx)(`div`,{className:l?`flex min-h-0 flex-1 flex-col`:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:p?a?(0,L.jsx)(m1,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void v(n(f.id),`Could not leave the question`)}):(0,L.jsx)(n1,{view:p,submitting:s,onAnswer:e=>void v(t(f.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u},f.id):(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,L.jsx)(J,{type:`button`,disabled:s,onClick:()=>void v(n(f.id),`Could not dismiss the question`),children:`Dismiss`})]})})]}):null})}var _1=2;function v1(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function y1(e){try{return JSON.parse(e)}catch{return}}function b1(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function x1(e,t=v1){let n=t(N(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===_1?`offline`:`connecting`),n.onmessage=t=>{let n=y1(t.data);n&&b1(n,e)},()=>n.close()}var S1=2e3,C1=()=>De(`projects.list`,{});async function w1(){let e;try{e=M()}catch{return}if(e&&!Ce(e))try{Se((await C1()).projects)}catch{}}function T1(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{M()}catch{me.onStatus({connection:`offline`});return}e.current=x1({onHello:e=>{me.onHello(e),w1()},onChanged:(e,t)=>me.onChanged(e,t),onFeed:e=>me.onFeedDelta(e),onReply:e=>me.onReplyDelta(e),onNotice:(e,t)=>V[t](e),onConnection:e=>{me.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{we(C1).catch(()=>!1).finally(n)},S1))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var E1=`bot-lobby.recoveredAt`,D1;function O1(e,t=k1()){try{D1===void 0&&(D1=Number(t?.getItem(E1)??0))}catch{D1??=0}if(D1!==void 0&&e<=D1)return!1;D1=e;try{t?.setItem(E1,String(e))}catch{}return!0}function k1(){try{return globalThis.sessionStorage}catch{return}}function A1(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&O1(t)&&V.success(n)},[t,n])}function j1(){let e=aO(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await De(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await De(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function M1(e,t,n,r){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?GD(`#/settings`):e===`sessions`?GD(`#/sessions`):e===`thinking`?SU(`lobby.thinking`):e===`activity`?t.kind===`tab`&&t.tab===`lobby`?SU(`lobby.activity`):GD(WD(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&H(`planner.save`,{})}var N1=2500;function P1(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),N1);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function F1({connection:e,onRetry:t}){return P1(e)?(0,L.jsx)(nO,{onRetry:t}):null}var I1={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{I1.route=++I1.tick}),document.addEventListener(`focusin`,()=>{I1.focus=++I1.tick});var L1=()=>I1.focus>I1.route;function R1(e){return e.kind===`tab`?e.tab:e.kind}function z1(){let e=KD(),t=aO(`status`),n=aO(`lobby`),{prompts:r,answer:i,dismiss:a}=j1(),{connection:o,signedOut:s}=iO(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=T1();wG();let h=t.data;A1(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Ue()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>GD(WD(e)),[]),x=(0,m.useCallback)(e=>{if(_.length===0)return;let t=Math.max(0,_.findIndex(e=>e.id===y)),n=_[(t+e+_.length)%_.length];n&&GD(WD(n.id))},[_,y]),S=(0,m.useCallback)(()=>l(e=>!e),[]),C=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&M1(t,UD(window.location.hash)??e,S,x)},[e,S,x,h?.panels]),w=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble`)?!0:e.closest(`[data-state='closed']`)!==null},[]);AZ({enabled:!!h,keys:v,tabs:_,insideApp:w,onAction:C,onTab:b});let T=(0,m.useCallback)(()=>me.onHello({}),[]),E=e.kind===`tab`?e.tab:e.kind,D=!!h;(0,m.useEffect)(()=>{if(!D)return;let e=wO.active&&wO.to===E;if(wO.active=!1,wO.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(L1()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`),t=typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches;e&&!e.disabled&&!t?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[E,D]);let O=Object.fromEntries(v.map(e=>[e.action,e.label])),k=(0,L.jsx)(yQ,{status:h,task:n.data?.task,connection:o,route:e,keys:O,onHelp:S,tabs:(0,L.jsx)(a$,{tabs:_,activeId:y,onSelect:b}),extra:u&&r.length>0?(0,L.jsx)(h1,{count:r.length,onOpen:()=>d(!1)}):null});return s||!h?(0,L.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[k,(0,L.jsx)(`main`,{className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto max-sm:mx-0 max-sm:mb-0`,children:s?(0,L.jsx)(xQ,{}):t.error?(0,L.jsx)(tO,{message:t.error,onRetry:T}):(0,L.jsx)(eO,{})})]}):(0,L.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[k,(0,L.jsx)(F1,{connection:o,onRetry:p}),(0,L.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||mO(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||CO()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto outline-none max-sm:mx-0 max-sm:mb-0`,children:(0,L.jsx)(z.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:_Z(e)},R1(e))}),(0,L.jsx)(tQ,{route:e,keys:O,onHelp:S}),(0,L.jsx)(R$,{status:h,lobby:n.data}),(0,L.jsx)(g1,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,L.jsx)(VZ,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function B1(e){switch(e){case`status`:return De(`status.get`,{});case`lobby`:return De(`lobby.snapshot`,{});case`prompts`:return De(`prompts.list`,{});default:return}}var V1=[`status`,`lobby`,`prompts`];function H1(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await ke(),e&&(me.markUsed(V1,B1),t(!0))})(),()=>{e=!1}},[]),e}function U1(){return H1()?(0,L.jsx)(z1,{}):(0,L.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,L.jsx)(eO,{})})}var W1={info:Bm,success:nm,warning:Sg,error:fm},G1={info:`text-primary`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function K1(){let{item:e,waiting:t}=op(),n=RD(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>ip(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed inset-x-0 z-40 flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + 0.25rem)`},children:(0,L.jsx)(Ou,{mode:`wait`,children:r?(0,L.jsxs)(z.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-3 rounded-xl border border-glass-border bg-popover/80 px-4 py-2.5 text-sm text-popover-foreground shadow-glass backdrop-blur-xs`,children:[(0,L.jsx)(q1,{kind:e.kind}),(0,L.jsx)(`span`,{className:`min-w-0 break-words`,children:e.message}),e.action?(0,L.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-raised -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border bg-card px-2.5 font-medium text-primary transition-[box-shadow,translate] active:translate-y-px focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none`,onClick:()=>{e.action?.onClick(),ip(e.id)},children:e.action.label}):null]},e.id):null})})}function q1({kind:e}){let t=W1[e];return(0,L.jsx)(t,{"aria-hidden":`true`,className:q(`size-5 shrink-0`,G1[e])})}(0,Zf.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(m.StrictMode,{children:(0,L.jsx)(sK,{children:(0,L.jsx)(Fu,{reducedMotion:`user`,children:(0,L.jsxs)(cO,{children:[(0,L.jsx)(U1,{}),(0,L.jsx)(K1,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});
|