const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RenderedNestedSessionTimeline-W0dSAwvH.js","assets/rolldown-runtime-B1FJdls4.js","assets/index-Dzmo3iV3.js","assets/preload-helper-Bf_JiD2A.js","assets/axisEvents-Dhd0R1o7.js","assets/issueStore-B3ra7txM.js","assets/vendor-dnd-C1cICjTT.js","assets/vendor-zustand-XkaRs3NT.js","assets/browserWindowFocus-CmAEq05h.js","assets/sessionStore-DVOX7Q2x.js","assets/queryKeys-CqjQpLLd.js","assets/api-DwzfFfgX.js","assets/vendor-misc-D1uXP2P6.js","assets/vendor-markdown-Db1-9wH7.js","assets/serverStorage-7ZBX37kd.js","assets/posthog-B2WbfR0W.js","assets/projectPaths-CJsPUl9Q.js","assets/terminalPreloader-Cdc78bb2.js","assets/vendor-react-RfPYMgDE.js","assets/index-DH5fKre3.css","assets/RenderedTurnTranscript-pNU6vfTW.js","assets/useSessionMessages-CABX2U-R.js"])))=>i.map(i=>d[i]);
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t,p as n}from"./vendor-dnd-C1cICjTT.js";import{C as r,G as i,R as a,S as o,U as s,ct as c,et as l,h as u,it as d,k as f,lt as p,w as m,x as ee}from"./vendor-misc-D1uXP2P6.js";import{n as h,r as g,s as _}from"./vendor-markdown-Db1-9wH7.js";import{i as te}from"./api-DwzfFfgX.js";import{t as v}from"./preload-helper-Bf_JiD2A.js";import{w as y}from"./index-Dzmo3iV3.js";import{t as ne}from"./ZoomablePane-Be18Awlh.js";var b=`[axis-reference-context]`,re=`[/axis-reference-context]`,ie=[{id:`btw`,kind:`command`,label:`/btw`,detail:`Open a linked consultation agent in the right pane`,insertText:`/btw`}];function x(e,t){if(e?.kind!==`command`)return!1;let n=`/${e.query.trim()}`.toLowerCase();return t.some(e=>e.kind===`command`&&e.insertText?.trim().toLowerCase()===n)}function ae(e,t){return e?.kind===`command`&&(t===` `||t===`Spacebar`)}function S(e){let t=e.replace(/\x1b\[200~/g,``).replace(/\x1b\[201~/g,``).replace(/\r\n?/g,`
`).trim().match(/^\/([a-z0-9_-]+)(?:[ \t]+([\s\S]*))?$/i);return t?{name:t[1].toLowerCase(),prompt:(t[2]??``).trim()}:null}function oe(e,t){let n=Math.max(0,Math.min(typeof t==`number`?t:e.length,e.length)),r=e.slice(0,n),i=r.lastIndexOf(`
`)+1,a=r.slice(i),o=a.match(/^\s*\/([^\s\n]*)$/);if(o){let e=a.indexOf(`/`);return{kind:`command`,query:o[1].trimStart(),start:i+e,end:n}}let s=a.lastIndexOf(`@`);if(s<0)return null;let c=s===0?``:a[s-1];if(c&&!/\s/.test(c))return null;let l=a.slice(s+1);return l.includes(`@`)?null:{kind:`reference`,query:l.trimStart(),start:i+s,end:n}}function se(e,t,n){if(!n.insertText)return ce(e,t);let r=e.slice(0,t.start),i=e.slice(t.end),a=i.length===0||!/^\s/.test(i),o=`${n.insertText}${a?` `:``}`;return{text:`${r}${o}${i}`,caret:r.length+o.length}}function ce(e,t){let n=e.slice(0,t.start);return{text:`${n}${e.slice(t.end)}`,caret:n.length}}function le(e,t){let n=C(e).trimEnd();if(t.length===0)return n;let r=JSON.stringify({references:t.map(({kind:e,label:t,detail:n,target:r,annotation:i})=>({kind:e,display_label:t,display_detail:n,target:r,...e===`session`?{pi_session_id:r}:{},...e===`project`?{project_path:r}:{},...e===`file`?{file_path:r}:{},...e===`artifact`?{artifact_target:r}:{},annotation:i}))});return`${n}${n?`

`:``}${b}\n${r}\n${re}`}function ue(e){if(!e)return[];let t=[];for(let n of e.matchAll(de()))try{let e=JSON.parse(n[1]);for(let n of e.references??[]){if(!n||typeof n!=`object`)continue;let e=n;if(!fe(e.kind)||typeof e.target!=`string`||typeof e.display_label!=`string`)continue;let r=e.target;t.push({id:`${e.kind}:${r}`,kind:e.kind,label:e.display_label,detail:typeof e.display_detail==`string`?e.display_detail:r,target:r,annotation:typeof e.annotation==`string`?e.annotation:`Referenced ${e.kind}`})}}catch{}return t}function C(e){return e?e.replace(de(),``).trimEnd():``}function de(){return/\[axis-reference-context\]\s*([\s\S]*?)\s*\[\/axis-reference-context\]/g}function fe(e){return e===`project`||e===`session`||e===`file`||e===`artifact`}function pe(e,t){let n=w(t);return n?w(`${e.label} ${e.detail}`).includes(n):!0}function w(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,` `).replace(/\s+/g,` `)}var T=`[a-z0-9][a-z0-9._-]*\\.(?:png|jpe?g|webp|gif|avif)`,me=RegExp(`^/tmp/(?:[^/\\s'")]+/)?axis-images/(${T})$`,`i`),E=T,he=RegExp(`^/tmp/(?:[^/\\s'")]+/)?axis-workspace-screenshots/(${E})$`,`i`),ge=RegExp(`^/api/terminal/workspace/screenshot/file/(${E})(?:[?#].*)?$`,`i`),_e=`(?:\\.axis/artifacts|\\.pi/(?:mission-control-artifacts|axis-artifacts))`,ve=RegExp(`^/home/[^/\\s]+/${_e}/([^/\\s'")]+)/(${T})$`,`i`),ye=`[a-z0-9][a-z0-9._-]*\\.(?:mp4|webm|mov|m4v)`,be=RegExp(`^/home/[^/\\s]+/${_e}/([^/\\s'")]+)/(${ye})$`,`i`),xe=RegExp(`^/api/artifacts/([^/\\s'")]+)/(${ye})(?:[?#].*)?$`,`i`);function Se(){return RegExp(`/tmp/(?:[^/\\s)'"]+/)?axis-images/${T}`,`gi`)}function Ce(){return RegExp(`/tmp/(?:[^/\\s)'"]+/)?axis-workspace-screenshots/${E}`,`gi`)}function we(){return RegExp(`/api/terminal/workspace/screenshot/file/${E}`,`gi`)}function Te(){return RegExp(`/home/[^/\\s]+/${_e}/[^/\\s)'"]+/${T}`,`gi`)}function Ee(){return RegExp(`/home/[^/\\s]+/${_e}/[^/\\s)'"]+/${ye}`,`gi`)}function De(){return RegExp(`/api/artifacts/[^/\\s)'"]+/${ye}`,`gi`)}function D(e){return e.trim().replace(/[),.;:!?]+$/g,``)}function Oe(e){let t=D(e).match(me);if(t)return`/api/upload-image/file/${encodeURIComponent(t[1])}`}function ke(e){let t=D(e),n=t.match(he);if(n)return`/api/terminal/workspace/screenshot/file/${encodeURIComponent(n[1])}`;let r=t.match(ge);if(r)return`/api/terminal/workspace/screenshot/file/${encodeURIComponent(decodeURIComponent(r[1]))}`}function Ae(e){let t=D(e).match(ve);if(t)return`/api/artifacts/${encodeURIComponent(t[1])}/${encodeURIComponent(t[2])}`}function je(e){return Oe(e)??ke(e)??Ae(e)}function Me(e){let t=D(e),n=t.match(be);if(n)return`/api/artifacts/${encodeURIComponent(n[1])}/${encodeURIComponent(n[2])}`;let r=t.match(xe);if(r)return`/api/artifacts/${encodeURIComponent(decodeURIComponent(r[1]))}/${encodeURIComponent(decodeURIComponent(r[2]))}`}function Ne(e){let t=[Ee(),De()].flatMap(t=>Array.from(e.matchAll(t),e=>({value:D(e[0]),index:e.index??0}))).sort((e,t)=>e.index-t.index),n=new Set,r=[];for(let e of t)n.has(e.value)||(n.add(e.value),r.push(e.value));return r}function Pe(e){return Array.from(e.matchAll(Se()),e=>D(e[0]))}function Fe(e){let t=[Se(),Ce(),we(),Te()].flatMap(t=>Array.from(e.matchAll(t),e=>({value:D(e[0]),index:e.index??0}))).sort((e,t)=>e.index-t.index),n=new Set,r=[];for(let e of t)n.has(e.value)||(n.add(e.value),r.push(e.value));return r}function Ie(e,t){return t.reduce((e,t)=>e.replace(t,``),e).replace(/[ \t]+\n/g,`
`).replace(/\n[ \t]+/g,`
`).replace(/[ \t]{2,}/g,` `).replace(/\n{3,}/g,`

`).trim()}function Le(e){return Ie(e,[Se()])}function Re(e){return Ie(e,[Se(),Ce(),we(),Te(),Ee(),De()])}function ze(e){if(!e)return;let t=e.match(/^\/api\/upload-image\/file\/([^?#]+)([?#].*)?$/i);if(!t)return e;let n=decodeURIComponent(t[1]).match(/^([a-z0-9][a-z0-9._-]*?)(?:-64|-128|-384)?\.(png|jpe?g|webp|avif)$/i);return n?`/api/upload-image/file/${encodeURIComponent(`${n[1]}-384.webp`)}`:e}function Be(e){return ze(Oe(e))}function Ve(e){return e.sourceUrl?.startsWith(`/api/upload-image/file/`)?e.sourceUrl:e.previewUrl}var He=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Ue(e){return typeof e==`string`&&He.includes(e)}function We(e){return e.replace(/^\[Axis [^\]]+\]\s*/i,``)}var O=_(),Ge={project:`Project`,session:`Pi session`,file:`File`,artifact:`Artifact`},Ke={project:`⌂`,session:`◌`,file:`⌘`,artifact:`◇`};function qe({references:e,onRemove:t,compact:n=!1}){return e.length===0?null:(0,O.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 ${n?`mb-2`:`px-2 pb-1 pt-0.5`}`,"data-testid":t?`pi-composer-reference-pills`:`pi-message-reference-pills`,children:e.map(e=>{let r=`${Ge[e.kind]} · ${e.detail}\n${e.target}\n${e.annotation}`;return(0,O.jsxs)(`span`,{className:`group/reference inline-flex max-w-full items-center rounded-full border border-terminal-cyan/25 bg-terminal-cyan/[0.08] text-terminal-cyan shadow-sm shadow-black/10 ${n?`h-6 gap-1 px-2 text-[10px]`:`h-7 gap-1.5 pl-2.5 pr-1 text-[11px]`}`,title:r,"data-reference-kind":e.kind,"data-reference-target":e.target,children:[(0,O.jsx)(`span`,{className:`shrink-0 text-terminal-cyan/70`,"aria-hidden":`true`,children:Ke[e.kind]}),(0,O.jsx)(`span`,{className:`min-w-0 max-w-[240px] truncate font-medium`,children:e.label}),t?(0,O.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`grid h-5 w-5 shrink-0 place-items-center rounded-full text-terminal-muted/70 transition-colors hover:bg-terminal-cyan/15 hover:text-terminal-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-cyan/60`,"aria-label":`Remove ${e.label} reference`,title:`Remove ${e.label}`,"data-testid":`pi-composer-reference-remove`,children:(0,O.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,O.jsx)(`path`,{d:`m3 3 6 6M9 3 3 9`})})}):null]},e.id)})})}var k=e(t(),1);function Je(e){return e.status===`aborted`||e.status===`stopping`||e.status===`stop_failed`}function Ye(e){return e.status===`aborted`?{label:/stopped/i.test(e.lastError??``)?`Current process stopped`:`Agent operation aborted`,detail:e.lastError??`Press Continue to resume.`,tone:`red`}:e.status===`stopping`?{label:`Stopping agent`,detail:e.lastError??`Sending Pi interrupt…`,tone:`yellow`}:e.status===`stop_failed`?{label:`Stop failed`,detail:e.lastError??`Could not deliver Pi interrupt.`,tone:`red`}:{label:`Agent unavailable`,detail:e.lastError??`The agent stopped unexpectedly.`,tone:`red`}}function Xe(e){return e===`red`?{text:`text-terminal-red/85`,dot:`bg-terminal-red animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.55)]`,border:`border-terminal-red/35`,bg:`bg-terminal-red/[0.06]`}:e===`green`?{text:`text-terminal-green/80`,dot:`bg-terminal-green shadow-[0_0_8px_rgba(34,197,94,0.55)]`,border:`border-terminal-green/25`,bg:`bg-terminal-green/[0.04]`}:e===`cyan`?{text:`text-terminal-cyan/80`,dot:`bg-terminal-cyan animate-pulse shadow-[0_0_8px_rgba(34,211,238,0.55)]`,border:`border-terminal-cyan/25`,bg:`bg-terminal-cyan/[0.04]`}:{text:`text-terminal-yellow/80`,dot:`bg-terminal-yellow animate-pulse shadow-[0_0_8px_rgba(234,179,8,0.55)]`,border:`border-terminal-yellow/25`,bg:`bg-terminal-yellow/[0.04]`}}var Ze=k.memo(function({state:e}){let t=Ye(e),n=Xe(t.tone);return Je(e)?(0,O.jsx)(`div`,{className:`mr-auto flex max-w-full flex-wrap items-center gap-2 px-1 py-0.5 font-mono text-[10px] font-bold uppercase tracking-[0.16em] ${n.text}`,"data-testid":`pi-rendered-live-input-status`,"data-status":e.status,"data-intent-status":e.intentStatus,"aria-live":`polite`,title:t.detail,children:(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${n.dot}`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`shrink-0 text-terminal-muted/70`,children:t.label}),(0,O.jsx)(`span`,{className:`truncate text-terminal-muted/60 normal-case font-normal tracking-normal`,children:t.detail})]})}):null},(e,t)=>e.state.status===t.state.status&&e.state.pendingCount===t.state.pendingCount&&e.state.lastError===t.state.lastError&&e.state.intentStatus===t.state.intentStatus);function Qe(e){let t=(e??``).replace(/\r/g,`
`).split(`
`).map(e=>e.trim()).filter(Boolean).at(-1)??``;return/^(?:[✕×x!\s-]*)?(?:agent |pi )?(?:operation |request |generation )?aborted\.?$/i.test(t)?t:null}function $e({abortState:e,onContinue:t,compact:n=!1}){let r=/stopped/i.test(e.message);return(0,O.jsxs)(`div`,{className:`${n?`mr-auto max-w-full`:`mx-auto my-auto max-w-xl`} flex items-center gap-3 px-1 py-1 font-mono text-[11px]`,"data-testid":`pi-rendered-abort-notice`,"aria-live":`assertive`,title:e.message,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-terminal-yellow animate-pulse`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`font-bold uppercase tracking-[0.14em] text-terminal-yellow`,children:r?`Current process stopped`:`Agent operation aborted`}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-terminal-yellow/40 px-2 py-1 text-[10px] font-bold uppercase tracking-[0.12em] text-terminal-yellow transition-colors hover:bg-terminal-yellow/10 active:scale-95`,"data-testid":`pi-rendered-continue-after-abort`,children:`Continue`})]})}function et(e=[],t=[]){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.name!==i.name||r.path!==i.path||r.previewUrl!==i.previewUrl||r.mimeType!==i.mimeType||r.uploadStatus!==i.uploadStatus||r.uploadProgress!==i.uploadProgress||r.error!==i.error||r.processingError!==i.processingError||r.analysis!==i.analysis||JSON.stringify(r.keyframes??[])!==JSON.stringify(i.keyframes??[]))return!1}return!0}var tt=n();function nt(e){return je(e)??null}function rt(e){let t=e.trim().replace(/[),.;:!?]+$/g,``).match(/^\/tmp\/axis-videos\/(pi-video-[^\s/'\")]+\.(?:mp4|mpeg|mpg|mov|webm))$/i);return t?`/api/upload-video/file/${encodeURIComponent(t[1])}`:null}function A(e){return e.split(`/`).pop()||`pasted image`}function it(e){let t=e.split(`.`).pop()?.toLowerCase();return t===`jpg`||t===`jpeg`?`image/jpeg`:t?`image/${t}`:`image/png`}function at(e){let t=e.split(`.`).pop()?.toLowerCase();return t===`mov`?`video/quicktime`:t===`webm`?`video/webm`:t===`mpeg`||t===`mpg`?`video/mpeg`:`video/mp4`}function ot(e,t){let n=e.replace(/[),.;:!?]+$/g,``),r=nt(n);return r?{kind:`attachment`,id:`${t}-${n}`,name:A(n),size:0,path:n,mimeType:it(n),previewUrl:r,sourceUrl:r,uploadStatus:`ready`}:null}function st(e){let t=e.textContent??``,n=new Map;for(let e of Fe(t)){let t=ot(e,`inline-proof-image`);!t?.previewUrl||n.has(t.previewUrl)||n.set(t.previewUrl,t)}for(let e of Ne(t)){let t=e.replace(/[),.;:!?]+$/g,``),r=Me(t);!r||n.has(r)||n.set(r,{kind:`attachment`,id:`inline-proof-video-${t}`,name:A(t),size:0,path:t,mimeType:at(t),previewUrl:r,sourceUrl:r,uploadStatus:`ready`})}return[...n.values()]}function ct(e){let t=new Map,n=[];for(let r of e.optimisticAttachments??[])r.path?t.set(r.path,r):(r.previewUrl||r.uploadStatus||r.mimeType?.startsWith(`image/`)||r.mimeType?.startsWith(`video/`))&&n.push(r);let r=e.textContent??``,i=Pe(r);for(let e of i){let n=e.replace(/[),.;:!?]+$/g,``);if(t.has(n))continue;let r=nt(n);r&&t.set(n,{kind:`attachment`,id:`jsonl-image-${n}`,name:A(n),size:0,path:n,mimeType:it(n),previewUrl:r})}let a=r.match(/\/tmp\/axis-videos\/pi-video-[^\s)'\"]+\.(?:mp4|mpeg|mpg|mov|webm)/gi)??[];for(let e of a){let n=e.replace(/[),.;:!?]+$/g,``);if(t.has(n))continue;let r=rt(n);r&&t.set(n,{kind:`attachment`,id:`jsonl-video-${n}`,name:A(n),size:0,path:n,mimeType:at(n),previewUrl:r,uploadStatus:`ready`})}let o=[...r.matchAll(/\[video\]([\s\S]*?)\[\/video\]/gi)];for(let e of o){let n=e[1]??``,r=n.match(/^path:\s*(.+)$/im)?.[1]?.trim();if(!r)continue;let i=t.get(r);if(!i)continue;let a=n.match(/^name:\s*(.+)$/im)?.[1]?.trim()||i.name,o=n.match(/^model:\s*(.+)$/im)?.[1]?.trim()||i.model,s=n.match(/transcript_or_analysis:\s*\n?([\s\S]*?)(?:\nprocessing_error:|$)/i),c=n.match(/processing_error:\s*\n?([\s\S]*?)$/i);t.set(r,{...i,name:a,model:o,analysis:s?.[1]?.trim()||i.analysis,processingError:c?.[1]?.trim()||i.processingError,uploadStatus:`ready`})}let s=new Set(t.keys()),c=[...t.values()],l=new Set,u=e=>{if(e.path||e.uploadStatus===`error`)return!1;let t=e.mimeType?.split(`/`)[0]??``,n=c.findIndex((n,r)=>l.has(r)||t&&!n.mimeType?.startsWith(`${t}/`)?!1:n.name===e.name||n.mimeType===e.mimeType||t===`image`||t===`video`);return n<0?!1:(l.add(n),!0)};return[...n.filter(e=>e.path?!s.has(e.path):!u(e)),...c]}var lt=k.memo(function({attachment:e,fit:t=`cover`}){let n=ze(e.previewUrl),[r,i]=(0,k.useState)(!1);return(0,k.useEffect)(()=>i(!1),[n]),(0,O.jsx)(`img`,{src:r?e.previewUrl:n,alt:e.name,className:`transition-transform duration-150 group-hover/image:scale-[1.015] ${t===`natural`?`h-auto w-full object-contain`:t===`contain`?`h-full w-full object-contain`:`h-full w-full object-cover`}`,loading:`eager`,decoding:`async`,draggable:!1,onError:()=>i(!0)})});function ut({attachment:e,canNavigate:t=!1,currentIndex:n=-1,totalCount:r=0,onPrevious:i,onNext:a,onClose:o}){(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.preventDefault(),o()):e.key===`ArrowLeft`&&t?(e.preventDefault(),i?.()):e.key===`ArrowRight`&&t&&(e.preventDefault(),a?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,o,a,i]),(0,k.useLayoutEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[]);let s=Ve(e),c=e.mimeType?.startsWith(`video/`)??!1;return s?(0,tt.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[2147483647] flex flex-col bg-black/92 text-white backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,"aria-label":`${e.name} image preview`,onClick:e=>{e.target===e.currentTarget&&o()},"data-testid":`pi-rendered-image-preview-overlay`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-white/10 bg-black/55 px-3 sm:px-4`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate font-mono text-xs font-bold text-white`,title:e.name,children:e.name}),(0,O.jsx)(`div`,{className:`truncate font-mono text-[10px] text-white/45`,title:e.path,children:e.path})]}),t?(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 font-mono text-[10px] text-white/60`,"data-testid":`pi-rendered-image-preview-nav`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:`flex h-9 w-9 items-center justify-center rounded-full border border-white/15 bg-white/10 text-lg text-white transition-colors hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-cyan/80`,"aria-label":`Previous image`,title:`Previous image (Left arrow)`,"data-testid":`pi-rendered-image-preview-previous`,children:`←`}),(0,O.jsxs)(`span`,{className:`hidden min-w-[4.5rem] text-center sm:inline`,children:[n+1,` / `,r]}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a?.()},className:`flex h-9 w-9 items-center justify-center rounded-full border border-white/15 bg-white/10 text-lg text-white transition-colors hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-cyan/80`,"aria-label":`Next image`,title:`Next image (Right arrow)`,"data-testid":`pi-rendered-image-preview-next`,children:`→`})]}):null,(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),o()},className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-white/20 bg-white/10 text-2xl leading-none text-white shadow-lg transition-colors hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-cyan/80`,"aria-label":`Close image preview`,title:`Close`,"data-testid":`pi-rendered-image-preview-close`,children:`×`})]}),c?(0,O.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-black p-3 sm:p-6`,children:(0,O.jsx)(`video`,{src:s,controls:!0,autoPlay:!0,playsInline:!0,className:`max-h-full max-w-full shadow-2xl shadow-black`,"data-testid":`pi-rendered-video-preview`})}):(0,O.jsx)(ne,{className:`min-h-0 flex-1 bg-black`,contentClassName:`flex items-center justify-center p-3 sm:p-6`,title:`Pinch/trackpad zoom, then drag to pan this image`,children:(0,O.jsx)(`img`,{src:s,alt:e.name,className:`max-h-full max-w-full select-none object-contain shadow-2xl shadow-black`,draggable:!1})})]}),document.body):null}var j=k.memo(function({attachments:e,onRemove:t,variant:n=`grid`}){let[r,i]=(0,k.useState)(null),a=(0,k.useMemo)(()=>e.filter(e=>e.mimeType?.startsWith(`image/`)&&e.previewUrl),[e]),o=(0,k.useCallback)(e=>{i(e)},[]),s=(0,k.useCallback)(e=>{i(t=>{if(!t||a.length<2)return t;let n=a.findIndex(e=>e.id===t.id);return a[n>=0?(n+e+a.length)%a.length:0]??t})},[a]);if(e.length===0)return null;let c=n===`proof`,l=n===`message`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:c?`mb-3 flex flex-wrap gap-2`:l?`mb-2 flex max-w-full flex-wrap justify-end gap-2`:`mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3`,"data-testid":c?`pi-rendered-proof-image-grid`:l?`pi-rendered-message-attachment-strip`:`pi-rendered-attachment-grid`,children:e.map(e=>{let n=e.mimeType?.startsWith(`image/`)&&e.previewUrl,r=e.mimeType?.startsWith(`video/`)&&e.previewUrl,i=e.path&&e.uploadStatus&&e.uploadStatus!==`error`&&e.uploadStatus!==`processing`?`ready`:e.uploadStatus;return(0,O.jsxs)(`div`,{className:`relative overflow-hidden ${c?`w-full max-w-[420px] rounded-lg`:l?`h-32 w-32 shrink-0 rounded-2xl border border-terminal-border/70 bg-terminal-bg/60 shadow-sm sm:h-40 sm:w-40`:`rounded-lg border border-terminal-cyan/20 bg-terminal-bg/60`}`,children:[n?(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),o(e)},className:`group/image relative block w-full overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-cyan/70 ${c?``:l?`h-full bg-black/10`:`h-24`}`,title:`Open ${e.name} image preview`,"aria-label":`Open ${e.name} image preview`,"data-testid":c?`pi-rendered-proof-image-thumbnail`:`pi-rendered-image-thumbnail`,children:(0,O.jsx)(lt,{attachment:e,fit:c?`natural`:`cover`})}):r?(0,O.jsxs)(`div`,{className:`group/video relative`,children:[(0,O.jsx)(`video`,{src:e.previewUrl,controls:!0,muted:!0,preload:`metadata`,className:`${c?`h-56 sm:h-72`:l?`h-full`:`h-24`} w-full bg-black object-contain`,"data-testid":`pi-rendered-video-thumbnail`}),(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),o(e)},className:`absolute right-1.5 top-1.5 z-10 flex h-7 w-7 items-center justify-center rounded-full border border-white/20 bg-black/70 text-xs text-white opacity-0 transition-opacity focus-visible:opacity-100 focus-visible:outline-none group-hover/video:opacity-100`,title:`Expand ${e.name}`,"aria-label":`Expand ${e.name}`,"data-testid":`pi-rendered-video-expand`,children:`⤢`})]}):(0,O.jsx)(`div`,{className:`flex items-center justify-center text-2xl text-terminal-muted ${l?`h-full`:`h-24`}`,children:`📎`}),t&&(0,O.jsx)(`button`,{type:`button`,onClick:n=>{n.preventDefault(),n.stopPropagation(),t(e.id)},className:`absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-full border border-black/50 bg-black/75 shadow-lg transition-colors hover:bg-terminal-red`,title:`Remove ${e.name}`,"aria-label":`Remove ${e.name}`,"data-testid":`pi-rendered-remove-attachment`,children:(0,O.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#fff`,strokeOpacity:`0.92`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,O.jsx)(`path`,{d:`M7 7l10 10M17 7 7 17`})})}),!l&&!c&&(0,O.jsxs)(`div`,{className:`space-y-0.5 border-t border-terminal-cyan/10 px-2 py-1.5`,children:[(0,O.jsx)(`div`,{className:`truncate font-mono text-[10px] text-terminal-text`,title:e.name,children:e.name}),(0,O.jsx)(`div`,{className:`truncate font-mono text-[9px] text-terminal-muted`,title:e.path,children:e.path}),i&&i!==`ready`&&(0,O.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 rounded border px-2 py-1 font-mono text-[9px] ${i===`error`?`border-red-500/30 bg-red-500/10 text-red-300`:`border-terminal-cyan/20 bg-terminal-cyan/10 text-terminal-cyan/80`}`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:i===`error`?e.error||e.processingError||`Upload failed`:i===`processing`?e.mimeType?.startsWith(`video/`)?`Processing with AI…`:`Processing…`:`Uploading${e.mimeType?.startsWith(`video/`)?` video`:e.mimeType?.startsWith(`image/`)?` image`:``}${typeof e.uploadProgress==`number`&&!e.mimeType?.startsWith(`image/`)?` ${e.uploadProgress}%`:``}…`}),i===`error`&&e.onRetry&&(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),e.onRetry?.()},className:`shrink-0 rounded border border-red-400/40 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-red-200 hover:bg-red-400/15`,title:`Retry upload`,"aria-label":`Retry ${e.name} upload`,children:`↻ Retry`}),i===`uploading`&&typeof e.uploadProgress==`number`&&!e.mimeType?.startsWith(`image/`)&&(0,O.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-1 bg-terminal-cyan/10`,"aria-hidden":`true`,children:(0,O.jsx)(`div`,{className:`h-full rounded-r-full bg-terminal-cyan transition-[width] duration-150 ease-out`,style:{width:`${Math.max(1,Math.min(100,e.uploadProgress))}%`}})})]}),e.mimeType?.startsWith(`video/`)&&e.keyframes&&e.keyframes.length>0&&(0,O.jsx)(`div`,{className:`mt-1 grid grid-cols-3 gap-1`,children:e.keyframes.slice(0,6).map((t,n)=>(0,O.jsxs)(`button`,{type:`button`,onClick:r=>{r.preventDefault(),r.stopPropagation(),o({...e,id:`${e.id}-keyframe-${n}`,name:`${e.name} keyframe ${n+1} (${t.timestampSec}s)`,path:t.path,previewUrl:t.previewUrl,mimeType:`image/jpeg`})},className:`relative h-12 overflow-hidden rounded border border-terminal-cyan/15 bg-black focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-cyan/70`,title:`Open keyframe ${n+1} at ${t.timestampSec}s`,children:[(0,O.jsx)(`img`,{src:t.previewUrl,alt:`Keyframe ${n+1}`,className:`h-full w-full object-cover`,loading:`lazy`,draggable:!1}),(0,O.jsxs)(`span`,{className:`absolute bottom-0 right-0 bg-black/75 px-1 font-mono text-[8px] text-white/80`,children:[t.timestampSec,`s`]})]},`${t.path}-${n}`))}),e.mimeType?.startsWith(`video/`)&&e.analysis&&(0,O.jsxs)(`div`,{className:`mt-1 max-h-24 overflow-y-auto whitespace-pre-wrap rounded border border-terminal-cyan/15 bg-terminal-cyan/[0.04] px-2 py-1 font-mono text-[9px] text-terminal-cyan/80`,title:e.analysis,children:[`Transcript / analysis:\\n`,e.analysis]}),e.mimeType?.startsWith(`video/`)&&e.processingError&&!e.error&&(0,O.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] text-amber-300`,title:e.processingError,children:e.processingError})]})]},e.id)})}),r?(0,O.jsx)(ut,{attachment:r,canNavigate:a.length>1&&a.some(e=>e.id===r.id),currentIndex:a.findIndex(e=>e.id===r.id),totalCount:a.length,onPrevious:()=>s(-1),onNext:()=>s(1),onClose:()=>i(null)}):null]})},(e,t)=>e.onRemove===t.onRemove&&e.variant===t.variant&&et(e.attachments,t.attachments)),dt=k.memo(function({attachments:e,onRemove:t}){return(0,O.jsxs)(`div`,{className:`ml-auto max-w-[92%] rounded-xl border border-terminal-cyan/25 bg-terminal-cyan/[0.035] px-4 py-3 shadow-sm`,"data-testid":`pi-rendered-attachment-draft`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-mono text-[10px] font-bold uppercase tracking-wider text-terminal-cyan`,children:[(0,O.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-terminal-cyan animate-pulse`}),(0,O.jsx)(`span`,{children:`Attached — add text, then Send`})]}),(0,O.jsx)(j,{attachments:e,onRemove:t})]})},(e,t)=>e.onRemove===t.onRemove&&et(e.attachments,t.attachments));function ft(e){return(e?.name??``).split(`.`).pop()?.replace(/[^a-z0-9]/gi,``).toLowerCase()??``}function pt(e){let t=ft(e);return t===`askclaude`?`claude`:t===`askgpt`?`gpt`:null}function mt(e){return pt(e)!==null}function ht(e,t,n){return t.id?.trim()||`${e}:${n}`}function M(e,t){if(typeof e!=`string`)return;let n=e.replace(/\s+/g,` `).trim();if(n)return n.length>t?`${n.slice(0,t-1).trim()}…`:n}function gt(e){return e.nativeStatus===`running`?`active`:e.nativeStatus===`failed`?`failed`:e.nativeStatus===`completed`?`completed`:e.isError?`failed`:e.result!==void 0||e.resultText!==void 0?`completed`:`active`}var _t=/<!-- mc-consultation-session:(\{[^\n]+\}) -->/;function vt(e){return!e.result||typeof e.result!=`object`||Array.isArray(e.result)?null:e.result}function yt(e){let t=vt(e);if(!t)return null;let n=t.details;return n&&typeof n==`object`&&!Array.isArray(n)?n:t}function bt(e){let t=typeof e.resultText==`string`?e.resultText.match(_t):null;if(t?.[1])try{let e=JSON.parse(t[1]);if(e&&typeof e==`object`)return e}catch{}let n=yt(e);return{sessionId:M(n?.sessionId,80),sessionFilePath:M(n?.sessionFilePath,500),cwd:M(n?.cwd,500)}}function xt(e){if(typeof e.resultText==`string`&&e.resultText.trim())return e.resultText.replace(_t,``).trim();if(typeof e.result==`string`&&e.result.trim())return e.result.trim();let t=yt(e)?.output;if(typeof t==`string`&&t.trim())return t.trim();let n=vt(e)?.content;if(Array.isArray(n)){let e=n.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.text;return typeof t==`string`?[t]:[]}).join(`
`).trim();if(e)return e}if(!(e.result===void 0||e.result===null))try{let t=JSON.stringify(e.result,null,2);return t===`{}`?void 0:t}catch{return String(e.result)}}function St(e,t,n,r){let i=pt(n);if(!i)return null;let a=ht(e,n,r),o=bt(n),s=yt(n),c=typeof n.arguments?.prompt==`string`&&n.arguments.prompt.trim()||void 0,l=M(c,180),u=`[Consultation] ${i===`claude`?`Claude`:`GPT`}${l?` · ${l.slice(0,72)}`:``}`;return{id:a,messageId:e,toolCallId:a,provider:i,title:M(s?.sessionTitle,180)??u,prompt:c,promptPreview:l,response:xt(n),sessionId:o.sessionId,sessionFilePath:o.sessionFilePath,cwd:o.cwd,model:M(n.arguments?.model,64)??M(s?.model,64),mode:M(n.arguments?.mode,32)??M(s?.mode,32),status:gt(n),createdAt:t}}function Ct(e){let t=[];for(let n of e)for(let[e,r]of(n.toolCalls??[]).entries()){let i=St(n.id,n.timestamp,r,e);i&&t.push(i)}return t}function wt(e){return{displayText:e.text,revealing:!1}}var Tt=new Set,Et=new Set,Dt=new Set;function Ot(e){return Dt.add(e),()=>{Dt.delete(e)}}function kt(e){return e.startsWith(`narration:`)?e:`narration:${e}`}function At(e){let{enabled:t,messageId:n,text:r,timestamp:i,now:a=Date.now()}=e;if(!t||!n||Tt.has(n)||r.trim().length<24)return!1;if(i!=null){let e=typeof i==`number`?i:Date.parse(String(i));if(Number.isFinite(e)&&a-e>45e3)return Tt.add(n),!1}return!0}function jt(e){let t=kt(e.messageId);return Tt.has(t)?!1:Et.has(t)?!0:At({enabled:e.enabled,messageId:t,text:e.text,timestamp:e.timestamp,now:e.now})}function Mt(e,t){if(!t.enabled||e.length===0)return e;let n=[];for(let r of e){if(r.kind===`narration`){if(n.push(r),jt({enabled:t.enabled,messageId:String(r.messageId??``),text:String(r.text??``),timestamp:typeof r.timestamp==`string`?r.timestamp:void 0,now:t.now}))break;continue}n.push(r)}return n}function Nt(){return(0,O.jsx)(`span`,{className:`mc-reveal-caret ml-px inline-block w-[2px] shrink-0 bg-terminal-cyan/85 align-[-0.18em]`,style:{height:`1.05em`},"aria-hidden":`true`,"data-testid":`pi-rendered-assistant-reveal-caret`})}var Pt=(0,k.lazy)(()=>v(()=>import(`./RenderedNestedSessionTimeline-W0dSAwvH.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])));function Ft(e,t){let n=e[0],r=e.flatMap(e=>e.kind===`message`?[e.message]:e.messages),i=e.flatMap(e=>e.toolCalls);return{kind:`toolGroup`,id:t,timestamp:n?n.kind===`message`?n.message.timestamp:n.timestamp:new Date(0).toISOString(),previousTimestamp:n?.previousTimestamp,messages:r,toolCalls:i}}function It(e){let t=(e?.name??``).toLowerCase();return t===`axis_handoff`||t.endsWith(`.axis_handoff`)}function Lt(e){let t=(e?.name??``).toLowerCase();return t===`axis_spawn_subagents`||t.endsWith(`.axis_spawn_subagents`)}function Rt(e){return It(e)||Lt(e)}function N(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():null}function zt(e,t){let n=t?.arguments,r=N(n,`issue_id`);if(r&&e.issue_id===r)return!0;let i=N(n,`cwd`)??N(n,`project_path`);if(i&&e.cwd===i)return!0;let a=N(n,`issue_title`);if(a&&e.title.toLowerCase().includes(a.toLowerCase().slice(0,30)))return!0;let o=N(n,`initial_prompt`);return o&&e.lastActivitySummary?.toLowerCase().includes(o.toLowerCase().slice(0,40))?!0:!r&&!i&&!a&&!o}function Bt(e){let t=e?.arguments?.slices;return Array.isArray(t)?t.flatMap(e=>{if(typeof e==`string`)return[e];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e;return[N(t,`title`),N(t,`prompt`),N(t,`task`),N(t,`description`)].filter(e=>!!e)}):[]}function Vt(e,t){let n=`${e.title} ${e.lastActivitySummary??``} ${e.recommended_next_step??``}`.toLowerCase();return Bt(t).some(e=>{let t=e.toLowerCase().replace(/\s+/g,` `).trim().slice(0,42);return t.length>=8&&n.includes(t)})}function Ht(e){if(e.role!==`assistant`||(e.optimisticAttachments?.length??0)>0)return!1;let t=e.toolCalls??[];return t.length===0?!1:!t.some(Rt)}function Ut(e){let t=e?.trim()??``;if(!t)return!1;let n=t.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),r=/^```/.test(t)||/^[{[]/.test(t)||/^(?:import|export|const|let|var|function|class|interface|type|expect)\b/.test(n[0]??``),i=n.filter(e=>/^\|.*\|$/.test(e)).length;if(r)return!1;let a=t.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_>#~]+/g,` `).replace(/\s+/g,` `).trim(),o=a.split(/\s+/).filter(Boolean).length,s=(a.match(/[.!?](?:\s|$)/g)??[]).length;return o>=48||a.length>=340||i>=2&&o>=35||/\n\s*\n/.test(t)&&o>=44||s>=3&&o>=44}function Wt(e){let t=Ut(e.thinking),n=Ut(e.textContent);if(!t&&!n)return null;let r=[t?e.thinking?.trim():``,n?e.textContent?.trim():``].filter(Boolean).join(`

`);return{visibleMessage:{...e,thinking:``,textContent:r,toolCalls:[]},workMessage:{...e,thinking:t?``:e.thinking,textContent:n?``:e.textContent}}}function Gt(e){return typeof e.arguments?.action==`string`?e.arguments.action.toLowerCase():null}function Kt(e){let t=e.arguments?.id;return typeof t==`number`&&Number.isFinite(t)?t:typeof t==`string`&&t.trim()&&Number.isFinite(Number(t))?Number(t):null}function qt(e){return((e.name??``).toLowerCase().split(`.`).pop()??``)===`todo`}function Jt(e){let t=[],n=[],r,i=new Map,a=1,o=e=>(e.toolCalls??[]).map((t,n)=>{let r=qt(t)?Gt(t):null,o=Kt(t),s=typeof t.arguments?.text==`string`?t.arguments.text.trim():``,c={tc:t,messageId:e.id,index:n,timestamp:e.timestamp,todoTitle:r===`add`?s||void 0:o?i.get(o):void 0};return qt(t)&&(r===`clear`?(i.clear(),a=1):r===`add`?(s&&i.set(a,s),a+=1):r===`update`&&o&&s?i.set(o,s):r===`remove`&&o&&i.delete(o)),c}),s=()=>{if(n.length===0)return;let e=n.map(e=>e.message),r=n.flatMap(e=>e.toolCalls);t.push({kind:`toolGroup`,id:`tool-group-${e[0].id||t.length}`,timestamp:e[0].timestamp,previousTimestamp:n[0].previousTimestamp,messages:e,toolCalls:r}),n=[]};for(let i of e){let e=o(i),a={kind:`message`,previousTimestamp:r,message:i,toolCalls:e};if(r=i.timestamp,Ht(i)){let r=Wt(i);if(r){s(),t.push({kind:`message`,previousTimestamp:a.previousTimestamp,message:r.visibleMessage,toolCalls:[],promotedNarration:!0}),n.push({kind:`message`,previousTimestamp:i.timestamp,message:r.workMessage,toolCalls:e});continue}n.push(a);continue}s(),t.push(a)}return s(),t}function Yt(e,t){let n=new Map;if(t.length===0)return n;let r=[...t].sort((e,t)=>(new Date(e.startedAt).getTime()||0)-(new Date(t.startedAt).getTime()||0)),i=new Set;for(let t of e){let e=(t.toolCalls??[]).filter(Rt);if(e.length===0)continue;let a=new Date(t.timestamp).getTime()||0,o=[];for(let t of e){let e=Lt(t),n=r.find(n=>{if(i.has(n.id))return!1;let r=new Date(n.startedAt).getTime()||0;return!a||!r||r>=a-3e4?e?Vt(n,t):zt(n,t):!1})??r.find(e=>{if(i.has(e.id))return!1;let t=new Date(e.startedAt).getTime()||0;return!a||!t||t>=a-3e4});n&&(i.add(n.id),o.push(n))}o.length>0&&n.set(t.id,o)}return n}function Xt(e=[],t=[]){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.id!==i.id||r.title!==i.title||r.filePath!==i.filePath||r.lastActivity!==i.lastActivity||r.lastActivitySummary!==i.lastActivitySummary||r.status!==i.status||r.task_status!==i.task_status||r.recommended_next_step!==i.recommended_next_step||JSON.stringify(r.agent_hypothesis??null)!==JSON.stringify(i.agent_hypothesis??null)||r.agent_hypothesis_updated_at!==i.agent_hypothesis_updated_at||r.awaiting_approval!==i.awaiting_approval||r.awaiting_approval_question!==i.awaiting_approval_question||r.issue_id!==i.issue_id||r.messageCount!==i.messageCount)return!1}return!0}function P(e){return e.split(`.`).pop()?.replace(/_/g,` `)||e.replace(/_/g,` `)}function F(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():null}function Zt(e,t){let n=e?.[t];return Array.isArray(n)?n.length:0}function Qt(e){let t=F(e,`user_problem`)||F(e,`user_intent`)||F(e,`problem`);if(t)return t;let n=e?.task_level??e?.taskLevel,r=F(e,`delegation_decision`)||F(e,`decision`),i=[typeof n==`number`?`level ${n}`:typeof n==`string`?n:null,r?r.replace(/_/g,` `):null].filter(e=>!!e);return i.length>0?i.join(` · `):null}function I(e,t=150){let n=(e??``).replace(/\s+/g,` `).trim();if(n)return n.length>t?`${n.slice(0,t-1).trim()}…`:n}function $t(e){let t=e.trim();return t?t.replace(/^['"]|['"]$/g,``):``}function en(e){return(e.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map($t).filter(Boolean)}function tn(e){let t=[],n=new Set([`-g`,`--glob`,`-t`,`--type`,`-T`,`--type-not`,`-e`,`--regexp`,`-f`,`--file`,`--iglob`]);for(let r=1;r<e.length;r+=1){let i=e[r];if(!(!i||i===`--`)){if(n.has(i)){r+=1;continue}i.startsWith(`-`)||t.push(i)}}return t.slice(1,3).join(` `)||null}function nn(e,t){let n=[],r=new Set([`-n`,`--lines`,`-c`,`--bytes`,`-s`,`--separator`,`-w`,`--number-width`,`-v`,`--starting-line-number`]);for(let e=1;e<t.length;e+=1){let i=t[e];if(!(!i||i===`--`)){if(r.has(i)){e+=1;continue}i.startsWith(`-`)||n.push(i)}}return(e===`sed`&&/^[0-9,$~+\-;]+[a-z]?$/i.test(n[0]??``)?n.slice(1):n).slice(0,2).join(` `)||null}function rn(e){let t=I(e,180),n=e?.trim();if(!n)return null;let r=n.toLowerCase(),i=en(n),a=i[0]?.toLowerCase()??``,o=a===`timeout`&&i.length>2?i.slice(2):i,s=o[0]?.toLowerCase()??a,c=t&&t.length<=90?t:void 0;if(s===`rg`||s===`ripgrep`){let e=tn(o);return{icon:`$`,tone:`yellow`,title:e?`Searched ${e}`:`Searched code`,detail:I(n,120)}}if([`sed`,`cat`,`nl`,`head`,`tail`,`less`].includes(s)){let e=nn(s,o);return{icon:`$`,tone:`green`,title:e?`Read ${e}`:`Read file context`,detail:c}}if(s===`git`){let e=o[1]?.toLowerCase()??``;return[`status`,`diff`,`show`].includes(e)?{icon:`$`,tone:`yellow`,title:`Checked git changes`,detail:c}:[`log`,`branch`].includes(e)?{icon:`$`,tone:`yellow`,title:`Inspected git history`,detail:c}:{icon:`$`,tone:`yellow`,title:`Ran git command`,detail:c}}if(s===`npx`&&o.some(e=>e.toLowerCase()===`tsc`)){let e=o.findIndex(e=>e===`-p`||e===`--project`);return{icon:`$`,tone:`yellow`,title:`Checked TypeScript`,detail:I((e>=0?o[e+1]:null)??n,120)}}return r.includes(`vite build`)?{icon:`$`,tone:`yellow`,title:`Built client`,detail:I(n,120)}:r.includes(`vitest`)?{icon:`$`,tone:`yellow`,title:`Ran tests`,detail:I(n,120)}:r.includes(`playwright test`)?{icon:`$`,tone:`yellow`,title:`Ran browser tests`,detail:I(n,120)}:r.includes(`npm run build`)||r.includes(`pnpm build`)||r.includes(`yarn build`)?{icon:`$`,tone:`yellow`,title:`Built project`,detail:I(n,120)}:r.includes(`npm test`)||r.includes(`pnpm test`)||r.includes(`yarn test`)?{icon:`$`,tone:`yellow`,title:`Ran tests`,detail:I(n,120)}:[`mkdir`,`mv`,`cp`,`rm`].includes(s)?{icon:`$`,tone:`yellow`,title:`Updated filesystem`,detail:c}:{icon:`$`,tone:`yellow`,title:t?`Ran ${t}`:`Ran command`}}function L(e){return e.resultText??(typeof e.result==`string`?e.result:``)}function R(e){if(e.isError)return!0;let t=G(e.result)??G(K(e.resultText));if(t?.ok===!1||t?.success===!1||t?.status===`error`||t?.status===`failed`)return!0;let n=L(e).replace(/^[^a-z0-9]+/i,``).trim().toLowerCase().slice(0,280);return/^(?:failed|error|could not|unable|command failed|timed out|socket hang up)\b/.test(n)||/^(?:error|failed):/m.test(n)}function z(e,t){return I(L(e)||t||`Tool failed`,180)}function an(e){if(R(e))return!1;let t=(e.name??``).toLowerCase(),n=Z(e),r=F(e.arguments??{},`command`),i=L(e),a=`${t}\n${r??``}\n${i}`.toLowerCase();return!!((n===`bash`||t.includes(`exec`))&&!r||t.includes(`repl`)||a.includes(`repl loop`)||/\b(polling|heartbeat|keepalive|keep-alive|no-op|noop)\b/.test(a)||r&&/^(?:while\s+true|for\s+\(\(|watch\s+|.*wait-log\.mjs\b)/i.test(r.trim())||n===`bash`&&r&&/^(?:true|:|continue)\s*$/i.test(r.trim()))}var on=new Set([`axis_set_hypothesis`,`axis_set_next_step`,`axis_title_session`,`axis_comment_issue`,`axis_link_session`,`axis_update_session_status`,`axis_update_issue`,`axis_ask`]);function sn(e){if(R(e))return!1;let t=(e.name??``).toLowerCase().split(`.`).pop()??``;return on.has(t)}function cn(e){let t=Z(e);return t.includes(`screenshot`)?`screenshot`:t.includes(`crop`)?`crop`:t.includes(`observation`)||t.includes(`observe`)?`observation`:t.includes(`image`)&&(t.includes(`view`)||t.includes(`overview`)||t.includes(`inspect`)||t.includes(`analyze`)||t.includes(`describe`))?`overview`:null}function ln(e){return e===`crop`?`Crop evidence`:e===`observation`?`Saved observation`:e===`screenshot`?`Screenshot proof`:`Image overview`}function un(e){let t=e.trim().replace(/[),.;:!?]+$/g,``);return t&&(/^\/api\/terminal\/workspace\/screenshot\/file\/[^?#]+\.(?:png|jpe?g|webp|gif|avif)(?:[?#].*)?$/i.test(t)||/^(?:\/|~\/|https?:\/\/|file:\/\/).+\.(?:png|jpe?g|webp|gif|avif)(?:[?#].*)?$/i.test(t))?t:null}function B(e,t,n=0){if(e==null||n>5)return;if(typeof e==`string`){for(let n of Fe(e))t.add(n);let n=un(e);n&&t.add(n);return}if(Array.isArray(e)){for(let r of e)B(r,t,n+1);return}let r=G(e);if(r)for(let e of Object.values(r))B(e,t,n+1)}function V(e,t=0){if(e==null||t>4||typeof e==`string`)return;if(Array.isArray(e)){for(let n of e){let e=V(n,t+1);if(e)return e}return}let n=G(e);if(n){for(let e of[`observation`,`observations`,`analysis`,`summary`,`description`,`caption`,`note`,`text`]){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}for(let e of Object.values(n)){let n=V(e,t+1);if(n)return n}}}function H(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()&&Number.isFinite(Number(e)))return Number(e)}function dn(e){let t={x:H(e.x),y:H(e.y),width:H(e.width??e.w),height:H(e.height??e.h),left:H(e.left),top:H(e.top),right:H(e.right),bottom:H(e.bottom)};return Object.values(t).some(e=>typeof e==`number`)?t:null}function U(e,t=0){if(e==null||t>4)return;if(Array.isArray(e)){if(e.length>=4&&e.slice(0,4).every(e=>H(e)!==void 0)){let[t,n,r,i]=e.map(H);return{x:t,y:n,width:r,height:i}}for(let n of e){let e=U(n,t+1);if(e)return e}return}let n=G(e);if(!n)return;let r=dn(n);if(r)return r;for(let e of[`crop`,`region`,`rect`,`bbox`,`box`,`selection`]){let r=U(n[e],t+1);if(r)return r}for(let e of Object.values(n)){let n=U(e,t+1);if(n)return n}}function fn(e){let t=cn(e);if(!t)return null;let n=new Set;B(e.arguments,n),B(e.result,n),B(K(e.resultText),n),B(e.resultText,n);let r=new Map,i=[];for(let e of n){let n=ot(e,`tool-${t}-image`);if(n?.previewUrl){let e=n.name.toLowerCase();r.has(e)||r.set(e,n);continue}i.push(e)}let a=V(e.result)??V(K(e.resultText))??V(e.arguments),o=t===`crop`?U(e.result)??U(K(e.resultText))??U(e.arguments):void 0;return{kind:t,label:ln(t),attachments:[...r.values()],referencedPaths:i,observation:a,crop:o}}function W(e){return(e.toLowerCase().split(`.`).pop()??e.toLowerCase()).startsWith(`axis_graph_`)}function G(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function pn(e){if(Array.isArray(e))return[{label:`Results`,items:e}];let t=G(e);return t?[[`sessions`,`Sessions`],[`results`,`Results`],[`keywordFallback`,`Keyword fallback`],[`chunks`,`Chunks`],[`nodes`,`Nodes`],[`edges`,`Edges`],[`insights`,`Insights`],[`top_sessions`,`Top sessions`],[`topSessions`,`Top sessions`],[`evidence`,`Evidence`]].flatMap(([e,n])=>Array.isArray(t[e])?[{label:n,items:t[e]}]:[]):[]}function mn(e){return e.result!==void 0||!!e.resultText?.trim()}function hn(e){if(e.result!==void 0&&e.result!==null)return e.result;let t=e.resultText?.trim();if(!t||!t.startsWith(`{`)&&!t.startsWith(`[`))return e.result;try{return JSON.parse(t)}catch{return e.result}}function gn(e){let t=pn(e);if(t.length>0)return t.reduce((e,t)=>e+t.items.length,0);let n=G(e);if(!n)return null;for(let e of[`count`,`total`,`totalCount`,`matched`,`matches`]){let t=n[e];if(typeof t==`number`&&Number.isFinite(t))return t}return null}function _n(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(t!==null){let e=n.id??n.todoId??n.todo_id;if(e!==void 0&&Number(e)!==t)return null}for(let e of[`text`,`title`,`task`,`description`,`body`,`name`]){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}var vn=/\s+\((pending|todo|not_started|in_progress|blocked|cancelled|canceled|completed|done)\)\s*$/i;function yn(e,t){for(let n of e.split(`
`)){let e=n.trim(),r=e.match(/^(Added|Updated|Removed)\s+todo\s+#(\d+):\s*(.+)$/i),i=e.match(/^\[[^\]]*\]\s*#(\d+):\s*(.+)$/i);if(!(r??i))continue;let a=Number(r?r[2]:i?.[1]);if(!Number.isFinite(a)||t!==null&&a!==t)continue;let o=(r?r[3]:i?.[2]??``).trim(),s=o.match(vn);return{id:a,item:o.replace(vn,``).trim()||null,action:r?r[1].toLowerCase().replace(`added`,`add`).replace(`updated`,`update`).replace(`removed`,`remove`):`list`,status:s?.[1]?.toLowerCase()??null}}return null}function bn(e,t){if(typeof e==`string`)return yn(e,t)?.item??null;let n=_n(e,t);if(n)return n;let r=G(e);if(!r)return null;for(let e of[`todo`,`item`,`updated`,`removed`,`created`]){let n=_n(r[e],t);if(n)return n}for(let e of[`todos`,`items`,`list`]){let n=r[e];if(Array.isArray(n))for(let e of n){let n=_n(e,t);if(n)return n}}return null}function xn(e){let t=Kt(e),n=[e.result,K(e.resultText),e.resultText];for(let e of n){if(typeof e!=`string`)continue;let n=yn(e,t);if(n)return n}return null}function Sn(e,t){let n=e.arguments??{},r=Kt(e);return F(n,`text`)||t||bn(e.result,r)||bn(K(e.resultText),r)||bn(e.resultText,r)||(r===null?`Todo item`:`Todo #${r}`)}function K(e){let t=e?.trim();if(!(!t||!t.startsWith(`{`)&&!t.startsWith(`[`)))try{return JSON.parse(t)}catch{return}}function Cn(e){return e?e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):null}function wn(e,t){let n=e.arguments??{},r=xn(e),i=F(n,`action`)?.toLowerCase()??r?.action??null,a=F(n,`status`)?.toLowerCase()??r?.status??null,o=Sn(e,t);if(i===`clear`)return{icon:`✓`,tone:`cyan`,title:`Cleared todos`};if(i===`add`)return{icon:`+`,tone:`cyan`,title:`Added: ${o}`};if(i===`remove`)return{icon:`−`,tone:`cyan`,title:`Removed: ${o}`};if(i===`list`)return{icon:`☷`,tone:`cyan`,title:`Listed todos`};if(i===`update`){if(a===`in_progress`)return{icon:`▶`,tone:`cyan`,title:`Started: ${o}`};if(a===`completed`)return{icon:`✓`,tone:`cyan`,title:`Completed: ${o}`};let e=Cn(a);return{icon:`↻`,tone:`cyan`,title:`Updated: ${o}`,detail:I(e??void 0)}}return{icon:`☷`,tone:`cyan`,title:`Todo update: ${o}`,detail:I(i)}}function Tn(e){let t=e.tc.arguments??{},n=xn(e.tc),r=F(t,`action`)?.toLowerCase()??n?.action??null,i=F(t,`status`)?.toLowerCase()??n?.status??null,a=Sn(e.tc,e.todoTitle);return r===`remove`?{label:a,statusLabel:`Removed`,state:`removed`}:r===`clear`?{label:`All to-dos`,statusLabel:`Cleared`,state:`neutral`}:r===`list`?{label:a,statusLabel:i?Cn(i):null,state:i===`completed`||i===`done`?`completed`:`pending`}:i===`completed`||i===`done`?{label:a,statusLabel:`Done`,state:`completed`}:i===`in_progress`?{label:a,statusLabel:`In progress`,state:`in_progress`}:r===`add`||i===`pending`||i===`todo`||i===`not_started`?{label:a,statusLabel:`To do`,state:`pending`}:{label:a,statusLabel:Cn(i),state:`neutral`}}function q(e,t){let n=e.name??`tool`,r=n.toLowerCase().split(`.`).pop()??n.toLowerCase(),i=e.arguments??{},a=R(e),o=cn(e);if(W(n)){let t=gn(hn(e)),r=F(i,`question`)||F(i,`query`)||F(i,`search`)||F(i,`topic`);return!e.isError&&!mn(e)?{icon:`◇`,tone:`cyan`,title:`${P(n)} · searching…`,detail:I(r||`Searching Axis graph`,180)}:{icon:`◇`,tone:`cyan`,title:t===null?P(n):`${P(n)} · ${t} result${t===1?``:`s`}`,detail:I(e.isError?e.resultText??`Tool returned an error`:r,180)}}if(wr(n)&&!a){let t=F(i,`question`)||F(i,`query`);if(!mn(e))return{icon:`⟡`,tone:`purple`,title:`Recalling memory…`,detail:I(t,180)};let n=Dr(e),r=n?n.facts.length||n.entries.length:0,a=n?.kind===`pack`?`fact`:n?.kind===`expand`?`chunk`:`memory`,o=a===`memory`?`memories`:`${a}s`;return{icon:`⟡`,tone:`purple`,title:r>0?`Recalled memory · ${r} ${r===1?a:o}`:`Recalled memory`,detail:I(t,180)}}if(r===`axis_set_hypothesis`)return a?{icon:`!`,tone:`yellow`,title:`Hypothesis not saved`,detail:z(e,Qt(i))}:{icon:`⟡`,tone:`purple`,title:`Set hypothesis`,detail:I(Qt(i))};if(r===`axis_set_next_step`)return a?{icon:`!`,tone:`yellow`,title:`Next step not saved`,detail:z(e,F(i,`next_step`))}:{icon:`↪`,tone:`purple`,title:`Set next step`,detail:I(F(i,`next_step`))};if(r===`axis_title_session`)return a?{icon:`!`,tone:`yellow`,title:`Session title not saved`,detail:z(e,F(i,`title`))}:{icon:`✎`,tone:`purple`,title:`Named session`,detail:I(F(i,`title`))};if(r===`axis_comment_issue`)return a?{icon:`!`,tone:`yellow`,title:`Issue update failed`,detail:z(e,F(i,`comment`))}:{icon:`☰`,tone:`purple`,title:`Updated issue thread`,detail:I(F(i,`comment`))};if(r===`axis_get_workspace`){if(a)return{icon:`!`,tone:`yellow`,title:`Workspace unavailable`,detail:z(e,`Axis workspace context`)};let t=(e.resultText??(typeof e.result==`string`?e.result:``)).match(/\*\*Available projects:\*\*\n([\s\S]*?)(?:\n\n\*\*|$)/)?.[1]?.split(`
`).filter(e=>e.trim().startsWith(`- `)).length??null;return{icon:`⌘`,tone:`purple`,title:`Inspected workspace`,detail:I(t?`${t} projects visible to agent`:`Current tabs, panes, services, projects`)}}if(r===`axis_get_children`)return{icon:`↳`,tone:`purple`,title:`Checked child agents`,detail:I(e.resultText??(typeof e.result==`string`?e.result:void 0),180)};if(r===`axis_switch_project`){let t=F(i,`project_path`);return a?{icon:`!`,tone:`yellow`,title:`Project switch failed`,detail:z(e,t)}:{icon:`↪`,tone:`purple`,title:`Switched main project`,detail:I(t||F(i,`reason`))}}if(r===`axis_open_workspace`){let t=Zt(i,`tabs`);return a?{icon:`!`,tone:`yellow`,title:`Workspace not opened`,detail:z(e,F(i,`reason`))}:{icon:`▤`,tone:`purple`,title:t>0?`Opened ${t} workspace pane${t===1?``:`s`}`:`Opened workspace`,detail:I(F(i,`reason`))}}if(r===`axis_render_artifact`)return a?{icon:`!`,tone:`yellow`,title:`Artifact not rendered`,detail:z(e,F(i,`title`)||F(i,`file_path`))}:{icon:`◈`,tone:`purple`,title:`Rendered artifact`,detail:I(F(i,`title`)||F(i,`file_path`))};if(r===`axis_capture_workspace_screenshot`)return{icon:`📸`,tone:`purple`,title:`Captured workspace pane`,detail:I(F(i,`target`)||F(i,`pane_key`)||F(i,`url`)||`Local browser/preview pane`)};if(o===`crop`)return{icon:`▧`,tone:`cyan`,title:`Cropped image region`,detail:I(F(i,`path`)||F(i,`image_path`)||F(i,`sourceImagePath`)||F(i,`source_image_path`))};if(o===`observation`)return{icon:`◉`,tone:`cyan`,title:`Saved image observation`,detail:I(F(i,`observation`)||F(i,`text`)||F(i,`note`),180)};if(o===`overview`)return{icon:`◰`,tone:`cyan`,title:`Reviewed image`,detail:I(F(i,`path`)||F(i,`image_path`)||F(i,`imagePath`))};if(o===`screenshot`)return{icon:`📸`,tone:`cyan`,title:`Captured screenshot`,detail:I(F(i,`path`)||F(i,`url`)||F(i,`target`))};if(r===`axis_spawn_subagents`){let e=Zt(i,`slices`),t=F(i,`rationale`);return{icon:`🤖`,tone:`purple`,title:e>0?`Spawned ${e} sub-agent${e===1?``:`s`}`:`Spawned sub-agents`,detail:I(t||F(i,`parent_context`),180)}}if(r===`todo`)return wn(e,t);if(r===`bash`)return rn(F(i,`command`))??{icon:`$`,tone:`muted`,title:`Internal command wrapper`,detail:I(L(e),120)};if(r===`apply_patch`)return{icon:`±`,tone:`green`,title:`Updated files`,detail:I(F(i,`patch`)||F(i,`input`),120)};if(r===`read`)return{icon:`◰`,tone:`green`,title:`Read file`,detail:I(F(i,`path`))};if(r===`edit`){let e=F(i,`path`),t=Zt(i,`edits`);return{icon:`±`,tone:`green`,title:t>1?`Edited ${t} regions`:`Edited file`,detail:I(e)}}return r===`write`?{icon:`▣`,tone:`green`,title:`Wrote file`,detail:I(F(i,`path`))}:r.startsWith(`browser_`)||r.startsWith(`web_`)?{icon:`🌐`,tone:`cyan`,title:P(n),detail:I(F(i,`url`)||F(i,`query`)||F(i,`task`))}:{icon:`⚙`,tone:`muted`,title:P(n),detail:I(F(i,`path`)||F(i,`command`)||F(i,`title`)||F(i,`text`))}}function En(e){let t=e.tc.name??`tool`,n=Z(e.tc);return n===`todo`?`todo`:n===`bash`?`command`:n===`read`?`read`:n===`edit`||n===`write`?`edit`:W(t)?`graph`:n===`axis_capture_workspace_screenshot`?`screenshot`:cn(e.tc)?`image`:n.startsWith(`browser_`)||n.startsWith(`web_`)?`web`:n.startsWith(`axis_`)?`mc`:`other`}function J(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Dn(e){let t=I(e.detail,80);return t&&e.title===`Read file`?`Read ${t}`:t&&e.title===`Edited file`?`Edited ${t}`:t&&e.title===`Wrote file`?`Wrote ${t}`:t&&e.title===`Rendered artifact`?`Rendered ${t}`:e.title}var On=/\n\n…\[truncated \d+ chars from fast tail payload\]\s*$/;function kn(e){return(e??``).replace(On,``).trimEnd()}function An(e,t){let n=new Map;for(let e of t){let t=n.get(e.messageId)??[];t.push(e),n.set(e.messageId,t)}let r=[];for(let t of e){let e=[t.thinking,t.textContent].map(e=>kn(e)).filter(e=>e.trim().length>0).join(`

`).trim();e&&r.push({kind:`narration`,messageId:t.id,timestamp:t.timestamp,text:e,streaming:t.nativeStreaming===!0});for(let e of n.get(t.id)??[])r.push({kind:`tool`,entry:e});n.delete(t.id)}for(let e of t)n.has(e.messageId)&&r.push({kind:`tool`,entry:e});return r}function Y(e){let t=e.tc.name??``,n=Z(e.tc);return n===`bash`||n.includes(`exec`)||n===`apply_patch`?n===`apply_patch`?`edit`:`command`:cn(e.tc)?`image`:n===`read`?`read`:n===`edit`||n===`write`?`edit`:W(t)||n.includes(`search`)?`search`:n.startsWith(`browser_`)||n.startsWith(`web_`)?`web`:n===`todo`?`todo`:mt(e.tc)||n===`axis_spawn_subagents`||n===`axis_get_children`||n===`axis_handoff`||n===`subagent`?`agent`:`tool`}function jn(e){let t=q(e.tc,e.todoTitle).detail?.replace(/\s+/g,` `).trim();if(!t)return null;if(Y(e)===`read`||Y(e)===`edit`)return t.split(/[\\/]/).filter(Boolean).at(-1)??t;if(Y(e)===`web`)try{return new URL(t).hostname||t}catch{return null}return null}function Mn(e){if(e)try{let t=new URL(e),n=t.pathname===`/`?``:t.pathname;return I(`${t.hostname}${n}`,110)}catch{return I(e,110)}}function Nn(e,t=0){if(t>3)return null;let n=G(e);if(!n)return null;let r=[`liveUrl`,`live_url`,`viewerUrl`,`viewer_url`].map(e=>n[e]).find(e=>typeof e==`string`&&e.trim().length>0);if(r)try{let e=new URL(r);if(e.protocol!==`http:`&&e.protocol!==`https:`)return null;let t=e=>e.map(e=>n[e]).find(e=>typeof e==`string`&&e.trim().length>0)?.trim();return{liveUrl:e.toString(),id:t([`id`,`sessionId`,`session_id`]),title:t([`title`,`name`]),status:t([`status`,`state`]),output:t([`output`,`summary`,`result`])}}catch{return null}for(let e of[`live`,`browser`,`session`,`data`,`result`]){let r=Nn(n[e],t+1);if(r)return r}return null}function Pn(e){return Nn(e.result)??Nn(K(e.resultText))}function Fn(e){let t=Z(e.tc),n=e.tc.arguments??{},r=I(F(n,`selector`)||F(n,`target`)||F(n,`element`)||F(n,`aria_label`),100),i=Mn(F(n,`url`));if(t.includes(`navigate`)||t===`web_fetch`)return{label:t===`web_fetch`?`Fetched page`:`Navigated`,detail:i};if(t.includes(`click`))return{label:`Clicked`,detail:r??`Page control`};if(t.includes(`fill`))return{label:`Filled field`,detail:r};if(t.includes(`type`))return{label:`Typed in field`,detail:r};if(t.includes(`evaluate`)||t.includes(`script`))return{label:`Evaluated page state`};if(t.includes(`html`))return{label:`Read page HTML`,detail:r};if(t.includes(`screenshot`))return{label:`Captured screenshot`};if(t.includes(`scroll`))return{label:`Scrolled page`,detail:I(F(n,`direction`),60)};if(t.includes(`wait`)){let e=n.ms;return{label:`Waited`,detail:typeof e==`number`&&Number.isFinite(e)?`${Math.max(0,e)/1e3}s`:void 0}}return t.includes(`search`)?{label:`Searched web`,detail:I(F(n,`query`),110)}:{label:P(e.tc.name??`Browser action`),detail:i??r}}function In(e){if(Y(e)===`web`)return Fn(e);let t=q(e.tc,e.todoTitle);return{label:I(t.title,100)??`Tool action`,detail:I(t.detail,140)}}function Ln(e,t){let n=typeof e==`string`?e.trim().split(`/`).pop():``;if(!n)return t===`claude`?`Claude`:t===`gpt`?`GPT`:`sub-agent`;if(t===`claude`&&/^(opus|sonnet|haiku)$/i.test(n))return`Claude ${n.charAt(0).toUpperCase()}${n.slice(1)}`;if(/^gpt-/i.test(n))return n.toUpperCase().replace(/^GPT-/,`GPT `);let r=n.match(/^claude-([a-z]+)-(.+)$/i);return r?`Claude ${`${r[1].charAt(0).toUpperCase()}${r[1].slice(1)}`} ${r[2].replace(/-/g,`.`)}`:n}function X(e){if(typeof e!=`string`)return null;let t=e.split(/\r?\n/,1)[0]?.replace(/\s+/g,` `).trim();return I(t,72)??null}function Rn(e){if(e.length!==1)return null;let t=e[0],n=Z(t.tc),r=t.tc.arguments??{},i=St(t.messageId,t.timestamp??new Date().toISOString(),t.tc,t.index);if(i){let e=X(r.task_summary)??X(r.title)??X(i.title.replace(/^\[Consultation\]\s*(?:Claude|GPT)\s*[·—-]?\s*/i,``))??X(r.prompt);return`Asked ${Ln(i.model,i.provider)}${e?` — ${e}`:``}`}if(n===`axis_spawn_subagents`){let e=Array.isArray(r.slices)?r.slices.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[];if(e.length===1){let t=e[0],n=t.agent===`claude`||t.agent===`gpt`?t.agent:`pi`,r=Ln(t.model,n),i=X(t.title);return`Asked ${r}${i?` — ${i}`:``}`}if(e.length>1){let t=e.flatMap(e=>{let t=X(e.title);return t?[t]:[]}),n=t.length>0?I(t.join(`, `),96):null;return`Delegated ${e.length} sub-agents${n?` — ${n}`:``}`}}if(n===`subagent`){let e=Array.isArray(r.tasks)?r.tasks.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[];if(e.length>1)return`Delegated ${e.length} sub-agents`;let t=e[0]??r,n=X(t.agent)??`sub-agent`,i=X(t.title)??X(t.task);return`Delegated ${n}${i?` — ${i}`:``}`}return null}function zn(e,t,n){let r=Rn(t);if(r)return r;let i=t.length,a=i===1?jn(t[0]):null;if(e===`command`){if(n&&i===1){let e=I(F(t[0].tc.arguments??{},`command`),120);return e?`Running ${e}`:q(t[0].tc,t[0].todoTitle).title.replace(/^Ran\b/i,`Running`)}return n?`Running commands`:i===1?`Ran command`:`Ran commands`}if(e===`image`)return n?i===1?`Viewing image`:`Viewing ${i} images`:i===1?`Viewed image`:`Viewed ${i} images`;if(e===`read`)return n?`Reading ${a??(i===1?`file`:`${i} files`)}`:`Read ${a??(i===1?`file`:`${i} files`)}`;if(e===`edit`)return n?`Updating ${a??(i===1?`file`:`${i} files`)}`:`Updated ${a??(i===1?`file`:`${i} files`)}`;if(e===`web`){let e=t.map(jn).filter(e=>!!e),r=[...new Set(e)],i=r.length===1?r[0]:a;return n?`Browsing ${i??`web`}`:`Browsed ${i??`web`}`}return e===`search`?n?`Searching`:`Searched`:e===`todo`?n?`Updating tasks`:`Updated tasks`:e===`agent`?n?`Checking agents`:`Checked agents`:q(t[t.length-1].tc,t[t.length-1].todoTitle).title}function Bn(e,t){let n=[];for(let t of e){if(t.kind===`narration`){n.push(t);continue}let e=Y(t.entry),r=n[n.length-1];r?.kind===`action`&&r.bucket===e?r.entries.push(t.entry):n.push({kind:`action`,bucket:e,entries:[t.entry],label:``,current:!1})}let r=-1;for(let e=n.length-1;e>=0;--e)if(n[e].kind===`action`){r=e;break}return n.map((e,n)=>{if(e.kind===`narration`)return e;let i=e.entries.some(e=>e.tc.nativeStatus===`running`),a=e.entries.every(e=>e.tc.nativeStatus===`completed`||e.tc.nativeStatus===`failed`),o=i||t&&n===r&&!a;return{...e,current:o,label:zn(e.bucket,e.entries,o)}})}function Vn(e,t){let n=[],r=null,i=e=>Gn(e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).at(-1)??e,150),a=e=>e.replace(/\s+/g,` `).trim().toLocaleLowerCase(),o=(e,t)=>{let n=a(e.title),r=a(t.title);return n===r?!0:!(e.narration?.streaming||t.narration?.streaming)||Math.min(n.length,r.length)<12?!1:n.startsWith(r)||r.startsWith(n)},s=e=>`${Z(e.tc)}:${JSON.stringify(e.tc.arguments??{})}`,c=(e,t)=>!!e.tc.id&&!!t.tc.id&&e.tc.id===t.tc.id||s(e)===s(t),l=(e,t)=>{for(let n of t){let t=e.find(e=>e.bucket===n.bucket);if(!t){e.push({...n,entries:[...n.entries]});continue}for(let e of n.entries){let n=t.entries.findIndex(t=>c(t,e));n>=0?t.entries[n]=e:t.entries.push(e)}t.label=n.label,t.current=n.current}},u=e=>e.at(-1)?.entries.at(-1)?.timestamp,d=e=>{if(!r)return;r.endedAt=e??u(r.actions)??r.startedAt,r.current=!!r.narration?.streaming||r.actions.some(e=>e.current),r.toolCount=r.actions.reduce((e,t)=>e+t.entries.length,0);let t=n.at(-1);t&&o(t,r)?(l(t.actions,r.actions),t.title=r.title,t.narration=r.narration??t.narration,t.endedAt=r.endedAt,t.current=!!t.narration?.streaming||t.actions.some(e=>e.current),t.toolCount=t.actions.reduce((e,t)=>e+t.entries.length,0)):n.push(r),r=null};for(let a of e){if(a.kind===`narration`){if(r&&r.actions.length===0){r.title=i(a.text),r.narration=a,r.endedAt=a.timestamp,r.current=!!a.streaming;continue}d(a.timestamp),r={id:`phase-${a.messageId}-${n.length}`,title:i(a.text),narration:a,actions:[],startedAt:a.timestamp,endedAt:a.timestamp,current:!!a.streaming,toolCount:0};continue}r?r.narration||(r.title=a.label):r={id:`phase-action-${a.entries[0]?.messageId??`none`}-${n.length}`,title:a.label,narration:null,actions:[],startedAt:n.length===0?t??a.entries[0]?.timestamp:a.entries[0]?.timestamp,endedAt:a.entries.at(-1)?.timestamp,current:!1,toolCount:0},r.actions.push(a)}return d(),n}function Hn(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`+${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`+${n}m ${String(r).padStart(2,`0`)}s`:`+${n}m`;let i=Math.floor(n/60),a=n%60;return a>0?`+${i}h ${String(a).padStart(2,`0`)}m`:`+${i}h`}function Un({timestamp:e,previousTimestamp:t,live:n=!1,className:r=``}){let[i,a]=(0,k.useState)(()=>Date.now());(0,k.useEffect)(()=>{if(!n)return;let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[n]);let o=Date.parse(e??``),s=Date.parse(t??``);if(!Number.isFinite(o)||!Number.isFinite(s))return null;let c=Hn((n?i:o)-s);return(0,O.jsx)(`span`,{title:`${c} since the previous event${n?` · counting`:``}`,className:`shrink-0 font-mono text-[9px] font-normal tabular-nums tracking-tight text-terminal-muted/55 ${r}`,"data-testid":`pi-rendered-event-elapsed`,"data-live":n?`true`:void 0,children:c})}function Wn({text:e,messageId:t,timestamp:n,streaming:r=!1}){let{displayText:i,revealing:a}=wt({messageId:t?`narration:${t}`:``,text:e,timestamp:n}),o=a?i:e;return(0,O.jsx)(`div`,{className:`flex w-fit max-w-full min-w-0 items-start gap-2.5 bg-transparent px-1 py-1.5`,"data-testid":`pi-rendered-tool-narration`,"data-streaming":r?`true`:void 0,"data-assistant-revealing":a?`true`:void 0,children:a?(0,O.jsxs)(`div`,{className:`min-w-0 whitespace-pre-wrap break-words text-[11px] font-normal leading-[1.75] text-terminal-text/95`,"data-testid":`pi-rendered-assistant-revealing`,"data-rendered-writing":`1`,children:[o,(0,O.jsx)(Nt,{})]}):(0,O.jsx)(`div`,{className:`min-w-0 text-[11px] font-normal leading-[1.75] text-terminal-text/95 [overflow-wrap:anywhere] [&_p]:my-0 [&_p]:bg-transparent [&_p]:leading-[1.75] [&_p]:text-terminal-text/95 [&_strong]:font-semibold [&_strong]:text-terminal-text [&_ul]:my-1.5 [&_ul]:pl-5 [&_ol]:my-1.5 [&_ol]:pl-5 [&_li]:my-0.5 [&_table]:my-2 [&_table]:w-auto [&_table]:max-w-full [&_table]:border-collapse [&_table]:border [&_table]:border-terminal-border/55 [&_table]:bg-transparent [&_th]:border [&_th]:border-terminal-border/55 [&_th]:px-3 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-semibold [&_th]:leading-[1.6] [&_th]:text-terminal-text/95 [&_td]:border [&_td]:border-terminal-border/45 [&_td]:px-3 [&_td]:py-1 [&_td]:leading-[1.6] [&_td]:text-terminal-text/90 [&_pre]:max-w-full [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:overflow-x-hidden [&_pre]:bg-transparent`,children:(0,O.jsx)(g,{remarkPlugins:[h],children:o})})})}function Gn(e,t=160){let n=kn(e).trim();if(!n)return`Receiving response…`;let r=n.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),i=/^[{[]/.test(n)||/^```/.test(n)||/^(?:import|export|const|let|var|function|class|interface|type|expect)\b/.test(r[0]??``),a=r.filter(e=>/^(?:import|export|const|let|var|function|class|interface|type|expect)\b/.test(e)||/^[{}[\]();]+$/.test(e)).length;if(i||a>=2||r.length>6&&/[{};]/.test(n))return`Receiving live tool output…`;let o=n.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_>#~]+/g,` `).replace(/\s+/g,` `).trim();return o?o.length>t?`${o.slice(0,t-1).trimEnd()}…`:o:`Receiving response…`}var Kn={command:o,image:i,read:p,edit:a,web:l,search:f,todo:s,agent:c,tool:u};function qn(e){let t=e.trim().split(`
`),n=t.slice(Math.max(0,t.length-80)).join(`
`);return n.length>6e3?`${n.slice(0,5999)}…`:n}function Jn({preview:e}){let t=e.status?.replace(/_/g,` `)??`connected`;return(0,O.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-terminal-border/40 bg-black/20`,"data-testid":`pi-rendered-browser-session-preview`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 border-b border-terminal-border/30 px-2.5 py-1.5 text-[10px]`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-terminal-green`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-terminal-text/80`,children:e.title??`Connected browser`}),(0,O.jsx)(`span`,{className:`shrink-0 text-terminal-muted/55`,children:t}),(0,O.jsx)(`a`,{href:e.liveUrl,target:`_blank`,rel:`noreferrer noopener`,className:`ml-auto shrink-0 text-terminal-muted/65 transition-colors hover:text-terminal-text focus-visible:outline-none focus-visible:text-terminal-text`,children:`Open browser`})]}),(0,O.jsx)(`div`,{className:`aspect-video min-h-44 max-h-[22rem] bg-black`,children:(0,O.jsx)(`iframe`,{src:e.liveUrl,title:e.title??`Connected browser session`,className:`h-full w-full border-0 bg-black`,sandbox:`allow-scripts allow-forms allow-same-origin allow-popups allow-downloads allow-presentation`,allow:`clipboard-read; clipboard-write`,referrerPolicy:`no-referrer-when-downgrade`,loading:`lazy`})}),e.id&&(0,O.jsxs)(`div`,{className:`truncate border-t border-terminal-border/25 px-2.5 py-1 font-mono text-[9px] text-terminal-muted/45`,title:e.id,children:[`Browser session · `,e.id]})]})}function Yn({entries:e,cwd:t,onOpenFileAsArtifact:n}){let r=e.flatMap(e=>{let t=St(e.messageId,e.timestamp??new Date().toISOString(),e.tc,e.index);return t?[t]:[]});return(0,O.jsx)(`div`,{className:`min-w-0 space-y-3 py-1`,"data-testid":`pi-rendered-consultation-details`,children:r.map(e=>{let r=e.status===`active`,i=e.provider===`claude`?`Claude`:`GPT`,a=[i,e.model,e.mode].filter(Boolean).join(` · `);return e.sessionId?(0,O.jsx)(k.Suspense,{fallback:(0,O.jsx)(`div`,{className:`text-[10px] text-terminal-muted/55`,children:`Loading agent transcript…`}),children:(0,O.jsx)(Pt,{sessionId:e.sessionId,sessionFilePath:e.sessionFilePath,cwd:e.cwd??t,title:e.title.replace(/^\[Consultation\]\s*/i,``),subtitle:a,parentReportedActive:r,onOpenFileAsArtifact:n})},e.id):(0,O.jsx)(`div`,{className:`min-w-0 text-[10px] text-terminal-muted/60`,"data-consultation-state":e.status,children:r?`Starting ${i}…`:`${i} did not record a session.`},e.id)})})}function Xn({entry:e,cwd:t,onOpenFileAsArtifact:n}){let{tc:r}=e,i=Z(r),a=Y(e),o=ar(r).slice(0,4),s=Rr(r),c=qn(L(r)),l=a===`web`?Fn(e):null,u=a===`web`?Pn(r):null;return mt(r)?(0,O.jsx)(Yn,{entries:[e],cwd:t,onOpenFileAsArtifact:n}):l?(0,O.jsxs)(`div`,{className:`min-w-0 space-y-2 py-1 text-[10px] leading-relaxed text-terminal-muted/65`,"data-testid":`pi-rendered-minimal-tool-evidence`,children:[u&&(0,O.jsx)(Jn,{preview:u}),(0,O.jsxs)(`div`,{className:`space-y-1 px-0.5`,"data-testid":`pi-rendered-browser-action-details`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`text-terminal-muted/45`,children:`Action`}),` `,(0,O.jsx)(`span`,{className:`ml-2 text-terminal-text/75`,children:l.label})]}),l.detail&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`text-terminal-muted/45`,children:`Target`}),` `,(0,O.jsx)(`span`,{className:`ml-2 text-terminal-text/75`,children:l.detail})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`text-terminal-muted/45`,children:`Status`}),` `,(0,O.jsx)(`span`,{className:`ml-2 ${R(r)?`text-terminal-red/80`:`text-terminal-text/75`}`,children:R(r)?`Failed`:r.nativeStatus===`running`?`Running`:mn(r)?`Completed`:`Running`})]})]}),u?.output&&(0,O.jsx)(Q,{value:qn(u.output),path:`browser-result.md`,label:`Browser result`})]}):(0,O.jsxs)(`div`,{className:`min-w-0 space-y-2 py-1`,"data-testid":`pi-rendered-minimal-tool-evidence`,children:[o.map((e,t)=>(0,O.jsx)(or,{oldText:e.oldText,newText:e.newText,label:e.label},`${e.label??`diff`}-${t}`)),(0,O.jsx)(Lr,{tc:r,todoTitle:e.todoTitle,diffs:o,cwd:t}),i===`bash`&&c&&(0,O.jsx)(Q,{value:c,path:`output.txt`,label:`Output`}),(a===`tool`||a===`command`)&&i!==`bash`&&i!==`apply_patch`&&!i.startsWith(`axis_`)&&!W(r.name)&&o.length===0&&c&&(0,O.jsx)(Q,{value:c,path:`result.txt`,label:`Result`}),s.length>0&&n&&(0,O.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-x-3 gap-y-1`,children:s.map(e=>{let t=e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,O.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1.5 py-0.5 text-left text-[10px] text-terminal-muted/65 transition-colors hover:text-terminal-text/90 focus-visible:outline-none focus-visible:text-terminal-text/90`,onClick:()=>n(e,t),title:`Open ${e} in artifact pane`,"data-openable-file":`true`,children:[(0,O.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`truncate`,children:[`Open `,t,` in Artifact`]})]},e)})})]})}function Zn({entries:e}){let t=e.map(e=>Pn(e.tc)).find(e=>!!e)??null;return(0,O.jsxs)(`div`,{className:`min-w-0 space-y-2 py-1`,"data-testid":`pi-rendered-browser-group-details`,children:[t&&(0,O.jsx)(Jn,{preview:t}),(0,O.jsx)(`div`,{className:`space-y-1`,"aria-label":`Browser actions`,children:e.map((e,t)=>{let n=Fn(e),r=R(e.tc);return(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-1 py-0.5 text-[10px] ${r?`text-terminal-red/80`:`text-terminal-text/75`}`,children:[(0,O.jsx)(`span`,{className:`h-1 w-1 shrink-0 rounded-full ${r?`bg-terminal-red/70`:`bg-terminal-muted/45`}`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`shrink-0`,children:n.label}),n.detail&&(0,O.jsx)(`span`,{className:`min-w-0 truncate text-terminal-muted/55`,children:n.detail})]},`${e.messageId}-${e.index}-${e.tc.id??t}`)})}),t?.output&&(0,O.jsx)(Q,{value:qn(t.output),path:`browser-result.md`,label:`Browser result`})]})}function Qn({entries:e}){let t=e.map(e=>fn(e.tc)).filter(e=>!!e),n=[...new Map(t.flatMap(e=>e.attachments).filter(e=>e.previewUrl).map(e=>[e.previewUrl,e])).values()],r=[...new Set(t.flatMap(e=>e.referencedPaths))];return(0,O.jsx)(`div`,{className:`min-w-0 py-1`,"data-testid":`pi-rendered-image-group-details`,children:n.length>0?(0,O.jsx)(j,{attachments:n}):(0,O.jsxs)(`div`,{className:`rounded-md border border-terminal-yellow/25 bg-terminal-yellow/[0.06] px-2.5 py-2 text-[10px] leading-relaxed text-terminal-yellow/85`,children:[`These image actions did not record a locally previewable image.`,r.length>0&&(0,O.jsx)(`span`,{className:`mt-1 block break-all text-terminal-muted/70`,children:r.join(`
`)})]})})}function $n({entry:e,cwd:t,onOpenFileAsArtifact:n}){let r=In(e),i=R(e.tc),[a,o]=(0,k.useState)(!1);return(0,O.jsxs)(`details`,{open:a,onToggle:e=>o(e.currentTarget.open),className:`group/minimal-step min-w-0`,"data-testid":`pi-rendered-minimal-tool-step`,"data-secondary-disclosure":`true`,children:[(0,O.jsxs)(`summary`,{className:`flex w-fit max-w-full min-w-0 cursor-pointer list-none items-start gap-2 px-1.5 py-1.5 text-[10px] leading-[1.6] text-terminal-text/90 marker:hidden focus-visible:outline-none [&::-webkit-details-marker]:hidden`,title:r.detail?`${r.label}: ${r.detail}`:r.label,children:[(0,O.jsx)(`span`,{className:`mt-[0.42rem] h-1 w-1 shrink-0 rounded-full ${i?`bg-terminal-red/70`:`bg-terminal-muted/45`}`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`shrink-0 ${i?`text-terminal-red/95`:`text-terminal-text/95`}`,children:r.label}),(0,O.jsx)(d,{className:`mt-0.5 h-3 w-3 shrink-0 opacity-0 transition-[opacity,transform] group-hover/minimal-step:opacity-100 group-focus-within/minimal-step:opacity-100 group-open/minimal-step:rotate-90 group-open/minimal-step:opacity-100`,strokeWidth:1.7,"aria-hidden":`true`}),r.detail&&(0,O.jsx)(`span`,{className:`min-w-0 truncate text-terminal-muted/75`,children:r.detail})]}),a&&(0,O.jsx)(`div`,{className:`ml-3 min-w-0 border-l border-terminal-border/20 pb-1 pl-3 pr-1`,children:(0,O.jsx)(Xn,{entry:e,cwd:t,onOpenFileAsArtifact:n})})]})}function er({entries:e}){return(0,O.jsx)(`div`,{className:`min-w-0 space-y-0.5 py-0.5`,"data-testid":`pi-rendered-todo-steps`,children:e.map((e,t)=>{let n=Tn(e),i=n.state===`completed`?m:n.state===`removed`?r:ee,a=R(e.tc),o=a?`text-terminal-red/90`:n.state===`completed`?`text-terminal-green/85`:n.state===`in_progress`?`text-terminal-cyan/90`:`text-terminal-muted/70`;return(0,O.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 px-1.5 py-1.5 text-[10px] leading-[1.6] ${a?`text-terminal-red/90`:`text-terminal-text/90`}`,"data-todo-state":n.state,title:n.statusLabel?`${n.label} — ${n.statusLabel}`:n.label,children:[(0,O.jsxs)(`span`,{className:`relative mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`,children:[(0,O.jsx)(i,{className:`h-3.5 w-3.5 ${o}`,strokeWidth:1.8}),n.state===`in_progress`&&(0,O.jsx)(`span`,{className:`absolute inset-[4px] rounded-full bg-terminal-cyan animate-pulse`})]}),(0,O.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${n.state===`completed`?`text-terminal-text/70`:``}`,children:n.label}),n.statusLabel&&(0,O.jsx)(`span`,{className:`shrink-0 text-[9px] ${n.state===`in_progress`?`text-terminal-cyan/80`:`text-terminal-muted/60`}`,children:n.statusLabel})]},`${e.messageId}-${e.index}-${e.tc.id??t}`)})})}function tr({item:e,cwd:t,onOpenFileAsArtifact:n}){return e.bucket===`todo`?(0,O.jsx)(er,{entries:e.entries}):e.entries.every(e=>mt(e.tc))?(0,O.jsx)(Yn,{entries:e.entries,cwd:t,onOpenFileAsArtifact:n}):e.bucket===`image`?(0,O.jsx)(Qn,{entries:e.entries}):e.entries.length===1?(0,O.jsx)(Xn,{entry:e.entries[0],cwd:t,onOpenFileAsArtifact:n}):e.bucket===`web`?(0,O.jsx)(Zn,{entries:e.entries}):e.entries.map((e,r)=>(0,O.jsx)($n,{entry:e,cwd:t,onOpenFileAsArtifact:n},`${e.messageId}-${e.index}-${e.tc.id??e.tc.name??r}`))}function nr({item:e,cwd:t,onOpenFileAsArtifact:n}){let r=Kn[e.bucket],i=e.current,a=e.entries.some(e=>R(e.tc)),o=e.entries.map(e=>{let t=q(e.tc,e.todoTitle);return t.detail?`${t.title}: ${t.detail}`:t.title}).join(`
`),s=`flex w-fit max-w-full min-w-0 items-center gap-2 px-1 py-1.5 text-left text-[11px] leading-[1.6] text-terminal-text/95 ${i?`mc-rendered-current-action`:``}`,[c,l]=(0,k.useState)(!1),u=e.entries.filter(e=>mt(e.tc)).map(e=>ht(e.messageId,e.tc,e.index)).join(` `),f=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(r,{className:`h-4 w-4 shrink-0 ${a?`text-terminal-red/95`:`text-terminal-text/80`}`,strokeWidth:1.7,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate font-normal text-terminal-text/95`,children:e.label}),(0,O.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 opacity-0 transition-[opacity,transform] group-hover/minimal-action:opacity-100 group-focus-within/minimal-action:opacity-100 group-open/minimal-action:rotate-90 group-open/minimal-action:opacity-100`,strokeWidth:1.7,"aria-hidden":`true`})]});return(0,O.jsxs)(`details`,{open:c,onToggle:e=>l(e.currentTarget.open),className:`group/minimal-action min-w-0`,"data-testid":`pi-rendered-minimal-tool-action`,"data-tool-bucket":e.bucket,"data-current":i?`true`:void 0,"data-rendered-consultation-ids":u||void 0,"aria-label":o,"data-expandable-details":`true`,children:[(0,O.jsx)(`summary`,{className:`${s} cursor-pointer list-none transition-colors marker:hidden hover:text-terminal-text/85 focus-visible:outline-none focus-visible:text-terminal-text/90 [&::-webkit-details-marker]:hidden`,children:f}),c&&(0,O.jsx)(`div`,{className:`ml-6 min-w-0 space-y-0.5 border-l border-terminal-border/25 py-0.5 pl-2`,"data-testid":`pi-rendered-minimal-tool-details`,"data-live-action":i?`true`:void 0,"aria-live":i?`polite`:void 0,children:(0,O.jsx)(tr,{item:e,cwd:t,onOpenFileAsArtifact:n})})]})}function rr({phase:e,cwd:t,onOpenFileAsArtifact:n}){let r=e.actions.length>0;return(0,O.jsxs)(`div`,{className:`mc-rendered-turn-event min-w-0`,"data-rendered-turn-event":`phase`,"data-current":e.current?`true`:void 0,"data-testid":`pi-rendered-tool-phase`,children:[(0,O.jsx)(Un,{timestamp:e.endedAt,previousTimestamp:e.startedAt,live:e.current,className:`mc-rendered-turn-event-elapsed`}),(0,O.jsxs)(`div`,{className:`min-w-0 py-0.5`,children:[e.narration&&(0,O.jsx)(`div`,{className:`min-w-0 font-normal`,"data-testid":`pi-rendered-tool-phase-reasoning`,"data-phase-streaming":e.narration.streaming?`true`:void 0,children:(0,O.jsx)(Wn,{text:e.narration.text,messageId:e.narration.messageId,timestamp:e.narration.timestamp,streaming:e.narration.streaming})}),r&&(0,O.jsx)(`div`,{className:`${e.narration?`ml-4 border-l border-terminal-border/30 pl-3`:``} min-w-0 space-y-0.5 pb-1`,"data-testid":`pi-rendered-tool-phase-actions`,"data-phase-tool-count":e.toolCount,children:e.actions.map((r,i)=>(0,O.jsx)(nr,{item:r,cwd:t,onOpenFileAsArtifact:n},`${e.id}-${r.bucket}-${r.entries[0]?.messageId??i}-${i}`))})]})]})}function ir(e){let t=e.filter(e=>an(e.tc)).length,n=e.filter(e=>!an(e.tc)).map(e=>Dn(q(e.tc,e.todoTitle))).filter((e,t,n)=>n.indexOf(e)===t).slice(0,3);if(n.length>0){let e=t>0?` · ${t} internal event${t===1?``:`s`} folded`:``;return`${n.join(` · `)}${e}`}if(t>0)return`Internal loop activity hidden · ${t} low-value progress event${t===1?``:`s`}`;let r=new Map;for(let t of e){let e=En(t);r.set(e,(r.get(e)??0)+1)}return[[`todo`,`Updated ${J(r.get(`todo`)??0,`todo`)}`],[`command`,`Ran ${J(r.get(`command`)??0,`command`)}`],[`read`,`Read ${J(r.get(`read`)??0,`file`)}`],[`edit`,`Edited ${J(r.get(`edit`)??0,`file`)}`],[`web`,`Used ${J(r.get(`web`)??0,`browser/web tool`)}`],[`graph`,`Searched ${J(r.get(`graph`)??0,`graph tool`)}`],[`screenshot`,`Captured ${J(r.get(`screenshot`)??0,`screenshot`)}`],[`image`,`Reviewed ${J(r.get(`image`)??0,`image tool`)}`],[`mc`,`Ran ${J(r.get(`mc`)??0,`Axis action`)}`],[`other`,`Used ${J(r.get(`other`)??0,`tool`)}`]].filter(([e])=>(r.get(e)??0)>0).map(([,e])=>e).slice(0,4).join(` · `)||`Tool activity`}function ar(e){let t=e.arguments??{};if(Z(e)===`apply_patch`){let e=F(t,`patch`)||F(t,`input`)||``,n=[],r,i=[],a=[],o=()=>{(i.length>0||a.length>0)&&n.push({oldText:i.join(`
`),newText:a.join(`
`),label:r}),i=[],a=[]};for(let t of e.split(`
`)){let e=t.match(/^\*\*\* (?:Add|Update|Delete) File:\s*(.+)$/);if(e){o(),r=e[1].trim();continue}if(t.startsWith(`@@`)){o();continue}t.startsWith(`-`)&&!t.startsWith(`---`)&&i.push(t.slice(1)),t.startsWith(`+`)&&!t.startsWith(`+++`)&&a.push(t.slice(1))}return o(),n}let n=Array.isArray(t.edits)?t.edits:[],r=[],i=F(t,`path`)||void 0;for(let e of n){if(!e||typeof e!=`object`)continue;let t=e,n=typeof t.oldText==`string`?t.oldText:typeof t.old_text==`string`?t.old_text:``,a=typeof t.newText==`string`?t.newText:typeof t.new_text==`string`?t.new_text:``;(n||a)&&r.push({oldText:n,newText:a,label:i})}return r}function or({oldText:e,newText:t,label:n}){let r=e.split(`
`).slice(0,18),i=t.split(`
`).slice(0,18),a=e.split(`
`).length>18||t.split(`
`).length>18;return(0,O.jsxs)(`div`,{className:`mt-2 overflow-hidden rounded-md border border-terminal-border/50 bg-terminal-bg/65 font-mono text-[10px] leading-snug`,children:[n&&(0,O.jsx)(`div`,{className:`truncate border-b border-terminal-border/30 px-2 py-1 text-[9px] text-terminal-muted/55`,title:n,children:n}),r.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex min-w-0 gap-2 border-l-2 border-terminal-red/70 bg-terminal-red/[0.08] px-2 py-0.5 text-terminal-red/80`,children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 select-none text-terminal-red/70`,children:`−`}),(0,O.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e||` `})]},`old-${t}`)),i.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex min-w-0 gap-2 border-l-2 border-terminal-green/70 bg-terminal-green/[0.08] px-2 py-0.5 text-terminal-green/85`,children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 select-none text-terminal-green/70`,children:`+`}),(0,O.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e||` `})]},`new-${t}`)),a&&(0,O.jsx)(`div`,{className:`px-2 py-1 text-terminal-muted/60`,children:`Diff preview truncated — raw arguments still available below.`})]})}function Z(e){return e.name.toLowerCase().split(`.`).pop()??e.name.toLowerCase()}function sr(e){let t=(e??``).split(`/`).pop()??``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n+1).toLowerCase():``}function cr(e){let t=sr(e);return{ts:`ts`,tsx:`tsx`,js:`js`,jsx:`jsx`,json:`json`,css:`css`,html:`html`,md:`md`,markdown:`md`,py:`py`,mjs:`js`,cjs:`js`,sh:`sh`,sql:`sql`,yaml:`yaml`,yml:`yaml`,svg:`xml`,xml:`xml`}[t]??(t||`text`)}function lr(e){let t=sr(e);return t===`md`||t===`markdown`}function ur(e,t){if(!/^(?:ts|tsx|js|jsx|json|css|html|xml|py|sh|sql|yaml)$/i.test(t)||!e)return e||` `;let n=t===`json`?/\b(?:true|false|null)\b/g:/\b(?:const|let|var|function|return|if|else|for|while|class|interface|type|import|export|from|async|await|try|catch|new|true|false|null|undefined|case|switch|break|continue|extends|implements)\b/g,r=/(\/\/.*$|#.*$|`(?:\\.|[^`])*`|'(?:\\.|[^'])*'|"(?:\\.|[^"])*"|\b\d+(?:\.\d+)?\b)/g,i=[],a=0,o=(e,t)=>{let r=0;for(let a of e.matchAll(n)){let n=a.index??0;n>r&&i.push(e.slice(r,n)),i.push((0,O.jsx)(`span`,{className:`text-terminal-purple/90`,children:a[0]},`${t}-kw-${n}`)),r=n+a[0].length}r<e.length&&i.push(e.slice(r))};for(let t of e.matchAll(r)){let n=t.index??0;n>a&&o(e.slice(a,n),`p-${a}`);let r=t[0],s=r.startsWith(`//`)||r.startsWith(`#`)?`text-terminal-muted/65 italic`:/^['"`]/.test(r)?`text-terminal-green/85`:`text-terminal-yellow/85`;i.push((0,O.jsx)(`span`,{className:s,children:r},`tok-${n}`)),a=n+r.length}return a<e.length&&o(e.slice(a),`p-${a}`),i.length>0?i:e||` `}function Q({value:e,path:t,label:n,startLine:r=1}){let i=cr(t),a=e.split(`
`),o=a.slice(0,120),s=a.length>120;return(0,O.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-terminal-border/45 bg-terminal-bg/75`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 border-b border-terminal-border/35 px-2.5 py-1.5 font-mono text-[9px] uppercase tracking-[0.12em] text-terminal-muted/70`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:n??t??`content`}),(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-current/20 px-1.5 py-0.5`,children:i})]}),(0,O.jsx)(`div`,{className:`language-${i} max-h-80 overflow-y-auto overflow-x-hidden p-2.5 font-mono text-[10px] leading-relaxed text-terminal-text/85`,children:o.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:[(0,O.jsx)(`span`,{className:`w-6 shrink-0 select-none text-right text-terminal-muted/35`,children:r+t}),(0,O.jsx)(`code`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:ur(e,i)})]},t))}),s&&(0,O.jsx)(`div`,{className:`border-t border-terminal-border/25 px-2.5 py-1 font-mono text-[9px] text-terminal-muted/60`,children:`Preview truncated at 120 lines.`})]})}function dr({rows:e}){let t=e.filter(e=>e.value!==void 0&&e.value!==null&&String(e.value).trim());return t.length===0?null:(0,O.jsx)(`dl`,{className:`grid min-w-0 gap-1.5 rounded-lg border border-terminal-border/35 bg-terminal-bg/45 px-2.5 py-2 font-mono text-[10px] sm:grid-cols-2`,children:t.map(e=>(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`dt`,{className:`text-[8px] font-bold uppercase tracking-[0.14em] text-terminal-muted/55`,children:e.label}),(0,O.jsx)(`dd`,{className:`whitespace-pre-wrap break-words text-terminal-text/80 [overflow-wrap:anywhere]`,title:String(e.value),children:String(e.value)})]},e.label))})}function fr(e){if(typeof e==`string`)return e;let t=G(e);if(!t)return JSON.stringify(e);for(let e of[`title`,`session_title`,`name`,`id`,`session_id`,`path`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}return JSON.stringify(e)}function pr(e){let t=G(e);if(!t)return null;let n=[];for(let e of[`score`,`date`,`timestamp`,`project_path`,`topic`,`kind`]){let r=t[e];typeof r==`number`&&Number.isFinite(r)&&n.push(`${e}: ${r.toFixed(e===`score`?3:0)}`),typeof r==`string`&&r.trim()&&n.push(r.trim())}return n.length>0?n.slice(0,3).join(` · `):null}function mr(e){if(typeof e==`string`)return null;let t=G(e);if(!t)return null;for(let e of[`snippet`,`summary`,`text`,`content`,`body`,`reason`,`answer`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}return null}function hr(e){return e.replace(/^[-•]\s*/,``).replace(/\*\*/g,``).trim()}function gr(e){let t=[],n=null,r=()=>{n&&(n.summary||n.lines.length>0)&&t.push(n)};for(let t of e.split(`
`)){let e=t.trim();if(!e)continue;let i=e.match(/^\*\*(.+?):\*\*\s*(.*)$/);if(i){r(),n={key:i[1].toLowerCase().replace(/[^a-z0-9]+/g,`-`),title:i[1],summary:hr(i[2]??``),lines:[]};continue}n||={key:`workspace`,title:`Workspace`,lines:[]},n.lines.push(hr(e))}return r(),t}function _r(e){let t=e.toLowerCase();return t.includes(`session`)?{icon:`●`,accent:`text-terminal-purple/85`,label:`Current context`}:t.includes(`modal`)||t.includes(`tab`)?{icon:`▤`,accent:`text-terminal-cyan/85`,label:`Open workspace`}:t.includes(`window`)||t.includes(`pane`)?{icon:`◫`,accent:`text-terminal-yellow/85`,label:`Attached panes`}:t.includes(`project`)?{icon:`◆`,accent:`text-terminal-green/85`,label:`Projects`}:t.includes(`service`)||t.includes(`preview`)?{icon:`⚡`,accent:`text-terminal-cyan/85`,label:`Runtime`}:t.includes(`browser`)?{icon:`🌐`,accent:`text-terminal-cyan/85`,label:`Browsers`}:t.includes(`child`)?{icon:`↳`,accent:`text-terminal-purple/85`,label:`Agents`}:t.includes(`artifact`)?{icon:`◈`,accent:`text-terminal-yellow/85`,label:`Artifacts`}:{icon:`•`,accent:`text-terminal-muted/80`,label:`Details`}}function vr({resultText:e}){let t=gr(e);if(t.length===0)return null;let n=[`This session`,`Live modal`,`Open tabs`,`Active tabs`],r=t.filter(e=>n.includes(e.title)),i=t.filter(e=>!n.includes(e.title));return(0,O.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-terminal-purple/25 bg-terminal-purple/[0.04] px-2.5 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-terminal-purple/75`,children:[(0,O.jsx)(`span`,{children:`Workspace inspection`}),(0,O.jsxs)(`span`,{className:`text-terminal-muted/55`,children:[i.length,` groups`]})]}),r.length>0&&(0,O.jsx)(`div`,{className:`grid gap-1.5 sm:grid-cols-2`,children:r.map(e=>(0,O.jsxs)(`div`,{className:`min-w-0 rounded-md border border-terminal-border/35 bg-terminal-bg/45 px-2 py-1.5`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[8px] font-bold uppercase tracking-[0.13em] text-terminal-muted/55`,children:e.title}),(0,O.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-[10px] leading-relaxed text-terminal-text/85 [overflow-wrap:anywhere]`,children:e.summary||e.lines.slice(0,2).join(`
`)||`none`})]},e.key))}),(0,O.jsx)(`div`,{className:`grid gap-2 lg:grid-cols-2`,children:i.slice(0,10).map(e=>{let t=_r(e.title),n=e.lines.slice(0,e.title===`Preview services`?8:6),r=Math.max(0,e.lines.length-n.length);return(0,O.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-terminal-border/35 bg-terminal-bg/45 px-2.5 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 font-mono text-[9px] font-bold uppercase tracking-[0.13em] text-terminal-muted/70`,children:[(0,O.jsx)(`span`,{className:t.accent,children:t.icon}),` `,e.title]}),(0,O.jsx)(`div`,{className:`shrink-0 rounded border border-terminal-border/35 px-1.5 py-0.5 font-mono text-[8px] uppercase tracking-[0.1em] text-terminal-muted/50`,children:t.label})]}),e.summary&&(0,O.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-terminal-text/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e.summary}),n.length>0&&(0,O.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:n.map((e,t)=>(0,O.jsx)(`div`,{className:`min-w-0 rounded border border-terminal-border/25 bg-terminal-bg/45 px-2 py-1 text-[10px] leading-relaxed text-terminal-text/75 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e},t))}),r>0&&(0,O.jsxs)(`div`,{className:`mt-1.5 font-mono text-[9px] text-terminal-muted/55`,children:[`+ `,r,` more — expand raw result for the full list.`]})]},e.key)})}),i.length>10&&(0,O.jsxs)(`div`,{className:`font-mono text-[9px] text-terminal-muted/55`,children:[`+ `,i.length-10,` more groups in raw result.`]})]})}function yr(e){let t=[];if(typeof e.resultText==`string`&&t.push(e.resultText),typeof e.result==`string`)t.push(e.result);else if(e.result!==void 0&&e.result!==null)try{t.push(JSON.stringify(e.result))}catch{}let n=new Map,r=t.join(`
`);for(let e of Fe(r)){let t=ot(e,`tool-proof-image`);!t?.previewUrl||n.has(t.previewUrl)||n.set(t.previewUrl,t)}for(let e of Ne(r)){let t=e.replace(/[),.;:!?]+$/g,``),r=Me(t);!r||n.has(r)||n.set(r,{kind:`attachment`,id:`tool-proof-video-${t}`,name:A(t),size:0,path:t,mimeType:at(t),previewUrl:r,sourceUrl:r,uploadStatus:`ready`})}return[...n.values()]}function br({attachments:e}){return e.length===0?null:(0,O.jsx)(`div`,{"data-testid":`pi-rendered-tool-proof-images`,children:(0,O.jsx)(j,{attachments:e,variant:`proof`})})}function xr(e){return e?[{label:`X`,value:e.x},{label:`Y`,value:e.y},{label:`Width`,value:e.width},{label:`Height`,value:e.height},{label:`Left`,value:e.left},{label:`Top`,value:e.top},{label:`Right`,value:e.right},{label:`Bottom`,value:e.bottom}]:[]}function Sr(e){if(!e)return null;let t=e.x??e.left,n=e.y??e.top,r=e.width??(e.right!==void 0&&t!==void 0?e.right-t:void 0),i=e.height??(e.bottom!==void 0&&n!==void 0?e.bottom-n:void 0);if([t,n,r,i].some(e=>e===void 0||!Number.isFinite(e)))return null;let a={x:t,y:n,width:r,height:i};return a.x<0||a.y<0||a.width<=0||a.height<=0||a.x+a.width>100||a.y+a.height>100?null:{left:`${a.x}%`,top:`${a.y}%`,width:`${a.width}%`,height:`${a.height}%`}}function Cr({evidence:e}){let t=Sr(e.crop),n=e.attachments[0];return(0,O.jsxs)(`div`,{className:`space-y-2`,"data-testid":`pi-rendered-image-evidence`,children:[e.attachments.length>0?(0,O.jsx)(j,{attachments:e.attachments,variant:`proof`}):(0,O.jsx)(`div`,{className:`rounded-md border border-terminal-yellow/25 bg-terminal-yellow/[0.06] px-2.5 py-2 text-[10px] leading-relaxed text-terminal-yellow/85`,children:`Image evidence referenced, but no local preview is available.`}),t&&n?(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-terminal-cyan/20 bg-black/20`,"data-testid":`pi-rendered-crop-region-overlay`,children:[(0,O.jsx)(`div`,{className:`border-b border-terminal-cyan/15 px-2 py-1 font-mono text-[8px] font-bold uppercase tracking-[0.13em] text-terminal-cyan/70`,children:`Highlighted crop region`}),(0,O.jsxs)(`div`,{className:`relative aspect-video max-h-72 bg-terminal-bg`,children:[(0,O.jsx)(`img`,{src:n.previewUrl,alt:`${n.name} crop source`,className:`h-full w-full object-contain opacity-80`,loading:`lazy`,decoding:`async`}),(0,O.jsx)(`div`,{className:`absolute border-2 border-terminal-yellow bg-terminal-yellow/15 shadow-[0_0_0_9999px_rgba(0,0,0,0.32)]`,style:t})]})]}):null,e.observation?(0,O.jsx)(`div`,{className:`rounded-md border border-terminal-border/35 bg-terminal-bg/45 px-2.5 py-2 text-[11px] leading-relaxed text-terminal-text/85 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,"data-testid":`pi-rendered-image-observation`,children:e.observation}):null,(0,O.jsx)(dr,{rows:[...xr(e.crop),...e.referencedPaths.slice(0,4).map((e,t)=>({label:t===0?`Referenced image`:`Reference ${t+1}`,value:e}))]})]})}function wr(e){let t=e.toLowerCase().split(`.`).pop()??e.toLowerCase();return t===`axis_memory`||t===`axis_memory_recall`||t===`axis_memory_expand`}function Tr(e){return e===`high`?`green`:e===`low`?`yellow`:`cyan`}function Er(e){let t=[],n=F(e,`sourceType`)??F(e,`source_type`);n&&t.push(n.replace(/_/g,` `));let r=F(e,`projectPath`)??F(e,`project_path`);r&&t.push(r.split(`/`).filter(Boolean).pop()??r);let i=e.ageDays??e.age_days;typeof i==`number`&&Number.isFinite(i)&&t.push(i<1?`today`:`${Math.round(i)}d ago`),e.stale===!0&&t.push(`stale`);let a=e.score;return typeof a==`number`&&Number.isFinite(a)&&t.push(`score ${a.toFixed(2)}`),t.length>0?t.join(` · `):void 0}function Dr(e){let t=G(hn(e));if(!t)return null;let n=Array.isArray(t.warnings)?t.warnings.filter(e=>typeof e==`string`).slice(0,4):[],r=t.topFacts??t.top_facts;if(Array.isArray(r)&&r.length>0){let e=r.slice(0,12).map(e=>{if(typeof e==`string`)return{fact:e,citations:0};let t=G(e)??{};return{fact:F(t,`fact`)??``,source:F(t,`source`),confidence:F(t,`confidence`),citations:Array.isArray(t.citations)?t.citations.length:0}}).filter(e=>e.fact.trim()),i=F(t,`confidence`),a=Array.isArray(t.citations)?t.citations.length:0;return{kind:`pack`,query:F(t,`question`),chips:[...F(t,`intent`)?[{label:F(t,`intent`),tone:`purple`}]:[],...F(t,`depth`)?[{label:F(t,`depth`),tone:`purple`}]:[],...i?[{label:`${i} confidence`,tone:Tr(i)}]:[],...a>0?[{label:`${a} citation${a===1?``:`s`}`,tone:`cyan`}]:[]],facts:e,entries:[],nextAction:F(t,`suggestedNextAction`)??F(t,`suggested_next_action`),warnings:n}}let i=Array.isArray(t.hits)?t.hits:null;if(i)return{kind:`recall`,query:F(t,`query`),chips:[{label:`${i.length} memor${i.length===1?`y`:`ies`}`,tone:`purple`},...t.degraded===!0?[{label:`degraded`,tone:`yellow`}]:[]],facts:[],entries:i.slice(0,8).map(e=>{let t=G(e)??{};return{title:F(t,`title`)??F(t,`sourcePath`)?.split(`/`).pop()??`Chunk ${String(t.chunkId??``)}`,meta:Er(t),text:F(t,`text`)}}),warnings:n};let a=Array.isArray(t.chunks)?t.chunks:null;return a?{kind:`expand`,query:F(t,`title`),chips:[{label:`${a.length} chunk${a.length===1?``:`s`}`,tone:`purple`}],facts:[],entries:a.slice(0,8).map(e=>{let t=G(e)??{};return{title:t.isTarget===!0?`Chunk ${String(t.chunkId??``)} · match`:`Chunk ${String(t.chunkId??``)}`,text:F(t,`text`)}}),warnings:n}:null}var Or={purple:`border-terminal-purple/30 text-terminal-purple/85`,cyan:`border-terminal-cyan/30 text-terminal-cyan/85`,green:`border-terminal-green/30 text-terminal-green/85`,yellow:`border-terminal-yellow/35 text-terminal-yellow/85`};function kr({presentation:e}){return(0,O.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-lg border border-terminal-purple/25 bg-terminal-purple/[0.04] px-2.5 py-2`,"data-testid":`pi-rendered-memory-result`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:`font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-terminal-purple/75`,children:e.kind===`pack`?`Memory`:e.kind===`recall`?`Memory recall`:`Memory chunks`}),e.chips.map(e=>(0,O.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.1em] ${Or[e.tone]}`,children:e.label},e.label))]}),e.query&&(0,O.jsx)(`div`,{className:`min-w-0 text-[10px] leading-relaxed text-terminal-muted/75 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(e.query,240)}),e.facts.length>0&&(0,O.jsx)(`ol`,{className:`min-w-0 space-y-1.5`,children:e.facts.map((e,t)=>(0,O.jsxs)(`li`,{className:`min-w-0 rounded-md border border-terminal-border/35 bg-terminal-bg/45 px-2 py-1.5`,children:[(0,O.jsx)(`div`,{className:`text-[11px] leading-relaxed text-terminal-text/85 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(e.fact,420)}),(e.source||e.confidence||e.citations>0)&&(0,O.jsx)(`div`,{className:`mt-1 font-mono text-[9px] uppercase tracking-[0.1em] text-terminal-muted/60`,children:[e.source,e.confidence,e.citations>0?`${e.citations} citation${e.citations===1?``:`s`}`:null].filter(Boolean).join(` · `)})]},t))}),e.entries.length>0&&(0,O.jsx)(`div`,{className:`min-w-0 space-y-1.5`,children:e.entries.map((e,t)=>(0,O.jsxs)(`div`,{className:`min-w-0 rounded-md border border-terminal-border/35 bg-terminal-bg/45 px-2 py-1.5`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[10px] font-semibold text-terminal-text/90 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(e.title,180)}),e.meta&&(0,O.jsx)(`div`,{className:`mt-0.5 font-mono text-[9px] text-terminal-muted/65`,children:e.meta}),e.text&&(0,O.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-terminal-text/75 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(e.text,320)})]},t))}),e.nextAction&&(0,O.jsxs)(`div`,{className:`min-w-0 rounded-md border border-terminal-cyan/25 bg-terminal-cyan/[0.05] px-2 py-1.5 text-[10px] leading-relaxed text-terminal-text/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:[(0,O.jsx)(`span`,{className:`font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-terminal-cyan/75`,children:`Next`}),` `,I(e.nextAction,320)]}),e.warnings.map((e,t)=>(0,O.jsx)(`div`,{className:`min-w-0 rounded-md border border-terminal-yellow/25 bg-terminal-yellow/[0.05] px-2 py-1.5 text-[10px] leading-relaxed text-terminal-yellow/85 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(e,240)},t))]})}function Ar({tc:e}){let t=e.resultText??(typeof e.result==`string`?e.result:``),n=G(e.result),r=Z(e),i=e.arguments??{},a=F(i,`next_step`)||F(i,`comment`)||F(i,`title`)||F(i,`question`),o=r===`axis_capture_workspace_screenshot`||r===`axis_render_artifact`?yr(e):[];if(e.isError)return(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-red/30 bg-terminal-red/[0.06] px-2.5 py-2 text-[11px] leading-relaxed text-terminal-red/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:I(t,1200)||`Axis tool returned an error.`});if(o.length>0)return(0,O.jsx)(br,{attachments:o});if(wr(r)){let t=Dr(e);if(t)return(0,O.jsx)(kr,{presentation:t})}return t.trim()?r===`axis_get_workspace`?(0,O.jsx)(vr,{resultText:t}):(0,O.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-terminal-purple/25 bg-terminal-purple/[0.04] px-2.5 py-2`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-terminal-purple/75`,children:`Axis result`}),(0,O.jsx)(`div`,{className:`max-h-80 overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-terminal-text/80 [overflow-wrap:anywhere]`,children:I(t,1200)})]}):n?(0,O.jsx)(Q,{value:JSON.stringify(n,null,2),path:`axis-result.json`,label:`Axis result`}):a?(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-border/35 bg-terminal-bg/45 px-2.5 py-2 text-[11px] leading-relaxed text-terminal-text/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:a}):(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-purple/20 bg-terminal-purple/[0.035] px-2.5 py-2 font-mono text-[10px] text-terminal-muted/75`,children:`Axis action completed. No structured result payload was recorded.`})}function jr({tc:e}){let t=pn(hn(e)),n=I(e.resultText,1200),r=F(e.arguments,`question`)||F(e.arguments,`query`)||F(e.arguments,`search`)||F(e.arguments,`topic`);return e.isError?(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-red/30 bg-terminal-red/[0.06] px-2.5 py-2 text-[11px] leading-relaxed text-terminal-red/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n||`Graph tool returned an error.`}):mn(e)?t.length===0?(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-cyan/25 bg-terminal-cyan/[0.05] px-2.5 py-2 text-[11px] leading-relaxed text-terminal-text/80 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n||`Graph tool completed; no structured result payload was recorded.`}):(0,O.jsx)(`div`,{className:`space-y-2 rounded-lg border border-terminal-cyan/25 bg-terminal-cyan/[0.04] px-2.5 py-2`,children:t.slice(0,3).map(e=>(0,O.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-terminal-cyan/75`,children:[e.label,` · `,e.items.length]}),e.items.slice(0,5).map((e,t)=>{let n=I(fr(e),180)??`Result`,r=I(pr(e),180),i=I(mr(e),320);return(0,O.jsxs)(`div`,{className:`min-w-0 rounded-md border border-terminal-border/35 bg-terminal-bg/45 px-2 py-1.5`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[10px] font-semibold text-terminal-text/90 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n}),r&&(0,O.jsx)(`div`,{className:`mt-0.5 font-mono text-[9px] text-terminal-muted/65 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:r}),i&&(0,O.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-terminal-text/75 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:i})]},t)}),e.items.length>5&&(0,O.jsxs)(`div`,{className:`font-mono text-[9px] text-terminal-muted/60`,children:[`+`,e.items.length-5,` more in raw result`]})]},e.label))}):(0,O.jsxs)(`div`,{className:`rounded-lg border border-terminal-cyan/25 bg-terminal-cyan/[0.05] px-2.5 py-2 text-[11px] leading-relaxed text-terminal-text/80`,"data-testid":`pi-rendered-graph-searching`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 font-mono text-[10px] font-bold uppercase tracking-[0.14em] text-terminal-cyan/80`,children:[(0,O.jsx)(`span`,{className:`h-2 w-2 shrink-0 animate-pulse rounded-full bg-terminal-cyan`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:`Searching Axis graph…`})]}),(0,O.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-terminal-muted/75 [overflow-wrap:anywhere]`,children:r?`Looking for: ${r}`:`Retrieving sessions, codebase context, and reranked matches. Results will appear here when the tool finishes.`})]})}function Mr(e,t){return e?e.startsWith(`/`)||e.startsWith(`~`)||!t?e:`${t.replace(/\/+$/g,``)}/${e.replace(/^\.\//,``)}`:null}function Nr(e){return!!e&&/\.(?:png|jpe?g|gif|webp|avif)$/i.test(e.split(/[?#]/,1)[0]??e)}function Pr(e){return!!e&&/\.(?:svg|pdf|mp4|mov|webm)$/i.test(e.split(/[?#]/,1)[0]??e)}function Fr({path:e,previewUrl:t}){let n=(0,k.useMemo)(()=>({kind:`attachment`,id:`read-image-${e}`,name:A(e),size:0,path:e,mimeType:it(e),previewUrl:t,sourceUrl:t,uploadStatus:`ready`}),[e,t]);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-terminal-cyan/25 bg-terminal-cyan/[0.04] px-2.5 py-2`,"data-testid":`pi-rendered-read-image-preview`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 font-mono text-[9px] uppercase tracking-[0.12em] text-terminal-cyan/75`,children:[(0,O.jsx)(`span`,{className:`truncate`,title:e,children:`Image preview`}),(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-current/20 px-1.5 py-0.5`,children:`click to open`})]}),(0,O.jsx)(j,{attachments:[n]})]})}function Ir({path:e,offset:t,limit:n,cwd:r}){let[i,a]=(0,k.useState)({loading:!0}),o=(0,k.useMemo)(()=>Mr(e,r),[r,e]),s=(0,k.useMemo)(()=>o&&Nr(o)?nt(o):null,[o]),c=typeof t==`number`&&Number.isFinite(t)&&t>0?Math.floor(t):1,l=typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):80;if((0,k.useEffect)(()=>{if(!o){a({loading:!1,error:`No file path provided.`});return}if(s){a({loading:!1,resolvedPath:o});return}if(Nr(o)){a({loading:!1,error:`Image preview is only available for Axis uploaded images.`,resolvedPath:o});return}if(Pr(o)){a({loading:!1,error:`Binary preview skipped to avoid noisy text fetches.`,resolvedPath:o});return}let e=!1;a({loading:!0,resolvedPath:o});let t=new URLSearchParams({path:o});return fetch(`/api/read-file?${t}`,{cache:`no-store`}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||t.message||`HTTP ${e.status}`);return t}).then(t=>{e||a({loading:!1,content:t.content??``,resolvedPath:t.path??o})}).catch(t=>{e||a({loading:!1,error:t instanceof Error?t.message:String(t),resolvedPath:o})}),()=>{e=!0}},[s,o]),s&&o)return(0,O.jsx)(Fr,{path:o,previewUrl:s});if(i.loading)return(0,O.jsx)(`div`,{className:`rounded-lg border border-terminal-border/35 bg-terminal-bg/45 px-2.5 py-2 font-mono text-[10px] text-terminal-muted/70`,children:`Loading file context…`});if(i.error)return(0,O.jsxs)(`div`,{className:`rounded-lg border border-terminal-red/30 bg-terminal-red/[0.06] px-2.5 py-2 font-mono text-[10px] text-terminal-red/80`,children:[`Could not load file context: `,i.error]});let u=(i.content??``).split(`
`),d=Math.max(0,c-1),f=Math.min(u.length,d+l),p=u.slice(d,f).join(`
`),m=`${e??i.resolvedPath??`file`} · lines ${d+1}-${f}`;return(0,O.jsx)(Q,{value:p,path:i.resolvedPath??e,label:m,startLine:d+1})}function Lr({tc:e,todoTitle:t,diffs:n,cwd:r}){let i=e.arguments??{},a=Z(e),o=F(i,`path`),s=F(i,`content`),c=F(i,`command`),l=fn(e);return a===`write`&&s!==null?lr(o)?(0,O.jsxs)(`div`,{className:`rounded-lg border border-terminal-border/45 bg-terminal-bg/65 px-3 py-2`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 font-mono text-[9px] uppercase tracking-[0.12em] text-terminal-muted/65`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:o??`Markdown content`}),(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-current/20 px-1.5 py-0.5`,children:`markdown`})]}),(0,O.jsx)(`div`,{className:`markdown-body max-h-96 overflow-y-auto overflow-x-hidden break-words text-[12px] leading-relaxed text-terminal-text/90 [overflow-wrap:anywhere] [&_code]:[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:overflow-x-hidden [&_pre]:[overflow-wrap:anywhere]`,children:(0,O.jsx)(g,{remarkPlugins:[h],children:s})})]}):(0,O.jsx)(Q,{value:s,path:o,label:o??`Written file`}):a===`bash`&&c?(0,O.jsx)(Q,{value:c,path:`script.sh`,label:`Command`}):a===`todo`?(0,O.jsx)(dr,{rows:[{label:`Todo`,value:t??F(i,`text`)??(i.id?`Todo #${String(i.id)}`:null)},{label:`Action`,value:F(i,`action`)},{label:`Status`,value:F(i,`status`)}]}):a===`read`?(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(dr,{rows:[{label:`File`,value:o},{label:`Offset`,value:typeof i.offset==`number`?i.offset:null},{label:`Limit`,value:typeof i.limit==`number`?i.limit:null}]}),(0,O.jsx)(Ir,{path:o,offset:i.offset,limit:i.limit,cwd:r})]}):l?(0,O.jsx)(Cr,{evidence:l}):W(e.name)?(0,O.jsx)(jr,{tc:e}):a.startsWith(`axis_`)?(0,O.jsx)(Ar,{tc:e}):n.length>0?null:(0,O.jsx)(dr,{rows:Object.entries(i).slice(0,6).map(([e,t])=>({label:e,value:typeof t==`string`||typeof t==`number`?t:JSON.stringify(t)}))})}function Rr(e){let t=e.arguments??{},n=Z(e),r=e=>typeof t[e]==`string`?t[e].trim():``;if(n===`read`||n===`edit`||n===`write`){let e=r(`path`)||r(`file_path`);return e?[e]:[]}if(n===`apply_patch`)return[...(r(`patch`)||r(`input`)).matchAll(/^\*\*\* (?:Add|Update|Delete) File:\s*(.+)$/gm)].map(e=>e[1].trim()).filter(Boolean);if(n===`axis_render_artifact`||e.name===`axis_render_artifact`){let e=r(`file_path`)||r(`path`);return e?[e]:[]}return[]}var zr=k.memo(function({item:e,isLatest:t,isWorking:n=!1,nestedInTurn:r=!1,phaseView:i=`all`,cwd:a,onOpenFileAsArtifact:o}){let s=e.toolCalls.filter(e=>!an(e.tc)&&!sn(e.tc)),c=ir(s),l=Bn(An(e.messages,s),n&&t),u=Vn(l,e.previousTimestamp??e.timestamp),f=i===`current`?u.length>0?[{...u[u.length-1],current:n&&t}]:[]:u,[p,m]=(0,k.useState)(t),[ee,h]=(0,k.useState)(0);(0,k.useEffect)(()=>Ot(()=>h(e=>e+1)),[]);let g=(0,k.useMemo)(()=>Mt(l,{enabled:!1}),[l,ee]),_=e.previousTimestamp??e.timestamp,te=(0,O.jsx)(O.Fragment,{children:g.map((e,t)=>{let n=e.kind===`narration`?e.timestamp:e.entries[0]?.timestamp,i=_;_=(e.kind===`narration`?e.timestamp:e.entries[e.entries.length-1]?.timestamp)??n??_;let s=e.kind===`action`&&e.current;return(0,O.jsxs)(`div`,{className:r?`mc-rendered-turn-event min-w-0`:`min-w-0`,"data-rendered-turn-event":e.kind,"data-current":s?`true`:void 0,children:[r&&(0,O.jsx)(Un,{timestamp:n,previousTimestamp:i,live:s,className:`mc-rendered-turn-event-elapsed`}),e.kind===`narration`?(0,O.jsx)(Wn,{text:e.text,messageId:e.messageId,timestamp:e.timestamp,streaming:e.streaming}):(0,O.jsx)(nr,{item:e,cwd:a,onOpenFileAsArtifact:o})]},e.kind===`narration`?`narration-${e.messageId}-${t}`:`action-${t}-${e.bucket}`)})});return!r&&s.length===0?null:r?(0,O.jsx)(`div`,{className:`min-w-0 space-y-1`,"data-testid":`pi-rendered-tool-group`,"data-nested-in-turn":`true`,"data-phase-view":i,children:f.map(e=>(0,O.jsx)(rr,{phase:e,cwd:a,onOpenFileAsArtifact:o},e.id))}):g.length===0?null:(0,O.jsxs)(`details`,{open:p,onToggle:e=>m(e.currentTarget.open),className:`group/work mr-auto min-w-0 max-w-full text-terminal-text/95`,"data-testid":`pi-rendered-tool-group`,"data-rendered-tool-layout":`minimal`,"data-collapsed":p?void 0:`true`,children:[(0,O.jsxs)(`summary`,{className:`flex w-fit max-w-full min-w-0 cursor-pointer list-none items-center gap-1.5 py-1 font-mono text-[11px] leading-[1.6] marker:hidden hover:text-terminal-text focus-visible:outline-none [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate font-normal text-terminal-text`,title:c,children:c}),(0,O.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 opacity-0 transition-[opacity,transform] duration-150 group-hover/work:opacity-100 group-focus-within/work:opacity-100 group-open/work:rotate-90 group-open/work:opacity-100`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`shrink-0 text-[9px] text-terminal-muted/75`,children:[s.length,` step`,s.length===1?``:`s`]})]}),(0,O.jsx)(`div`,{className:`mt-1.5 min-w-0 space-y-1 pl-0.5`,children:te})]})});function Br(e,t){try{let n=JSON.parse(e),r=Array.isArray(n)?n:[n],i=[];for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=typeof n.type==`string`?n.type.trim():``;r&&(t?.taskLauncherOnly&&r.toLowerCase()!==`task_launcher`||i.push(n))}return i.length>0?i:null}catch{return null}}function Vr(e){let t=[],n=e.replace(/```(?:mc-ui|generative-ui)\s*\n([\s\S]*?)```/gi,(e,n)=>{let r=Br(n);return r?(t.push(...r),``):e});return n=n.replace(/```(?:json)?\s*\n([\s\S]*?)```/gi,(e,n)=>{let r=Br(n,{taskLauncherOnly:!0});return r?(t.push(...r),``):e}),{markdown:n.trim(),blocks:t}}function $(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function Hr(e){let t=(e??``).toLowerCase();return[`done`,`success`,`green`].includes(t)?{border:`border-terminal-green/25`,bg:`bg-terminal-green/[0.07]`,text:`text-terminal-green/90`,dot:`bg-terminal-green`}:[`blocked`,`danger`,`error`,`red`].includes(t)?{border:`border-terminal-red/30`,bg:`bg-terminal-red/[0.07]`,text:`text-terminal-red/90`,dot:`bg-terminal-red`}:[`warning`,`pending`,`yellow`].includes(t)?{border:`border-terminal-yellow/30`,bg:`bg-terminal-yellow/[0.07]`,text:`text-terminal-yellow/90`,dot:`bg-terminal-yellow`}:[`purple`,`idea`].includes(t)?{border:`border-terminal-purple/30`,bg:`bg-terminal-purple/[0.07]`,text:`text-terminal-purple/90`,dot:`bg-terminal-purple`}:{border:`border-terminal-cyan/25`,bg:`bg-terminal-cyan/[0.06]`,text:`text-terminal-cyan/90`,dot:`bg-terminal-cyan`}}function Ur(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(120,Math.min(720,e)):320}function Wr({className:e}){return(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,O.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,O.jsx)(`polyline`,{points:`9 21 3 21 3 15`}),(0,O.jsx)(`line`,{x1:`21`,y1:`3`,x2:`14`,y2:`10`}),(0,O.jsx)(`line`,{x1:`3`,y1:`21`,x2:`10`,y2:`14`})]})}function Gr({className:e}){return(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,O.jsx)(`polyline`,{points:`4 14 10 14 10 20`}),(0,O.jsx)(`polyline`,{points:`20 10 14 10 14 4`}),(0,O.jsx)(`line`,{x1:`14`,y1:`10`,x2:`21`,y2:`3`}),(0,O.jsx)(`line`,{x1:`3`,y1:`21`,x2:`10`,y2:`14`})]})}function Kr({children:e,title:t,onClose:n}){let r=(0,k.useRef)(null);return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[n]),(0,O.jsxs)(`div`,{ref:r,className:`fixed inset-0 z-[9999] flex flex-col bg-slate-950/95 backdrop-blur-sm`,onClick:e=>{e.target===r.current&&n()},children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-terminal-border/30 px-4 py-3 sm:px-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-terminal-purple shadow-[0_0_8px_rgba(168,85,247,0.5)]`}),(0,O.jsx)(`span`,{className:`font-mono text-xs font-bold uppercase tracking-wider text-terminal-purple/90 truncate`,children:t})]}),(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-terminal-border/40 bg-terminal-surface/30 text-terminal-muted hover:border-terminal-red/40 hover:text-terminal-red transition-colors`,"aria-label":`Close fullscreen`,children:(0,O.jsx)(Gr,{})})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-6`,children:e})]})}function qr({onClick:e}){return(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},className:`inline-flex h-6 w-6 items-center justify-center rounded-md border border-terminal-border/40 bg-terminal-bg/60 text-terminal-muted/60 opacity-0 transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 hover:border-terminal-purple/50 hover:text-terminal-purple hover:opacity-100 group-hover/gui:opacity-80`,"aria-label":`Expand to fullscreen`,title:`Expand`,children:(0,O.jsx)(Wr,{})})}function Jr(e){return Array.isArray(e)?e.map(e=>$(e)).filter(Boolean):[]}function Yr({block:e}){let t=y(e=>e.open),n=Array.isArray(e.tasks)?e.tasks:[],r=(0,k.useMemo)(()=>n.slice(0,24).map((e,t)=>({id:$(e.id)||`task-${t+1}`,title:$(e.title)||`Task ${t+1}`,sourceNodeIds:Jr(e.sourceNodeIds),summary:$(e.summary),plan:$(e.plan),suggestedFiles:Jr(e.suggestedFiles),validation:$(e.validation),prompt:$(e.prompt)})),[n]),[i,a]=(0,k.useState)(()=>Object.fromEntries(r.map(e=>[e.id,e.prompt]))),[o,s]=(0,k.useState)({}),[c,l]=(0,k.useState)({}),u=$(e.projectPath);(0,k.useEffect)(()=>{a(e=>{let t={...e};for(let e of r)t[e.id]??(t[e.id]=e.prompt);return t})},[r]);let d=(0,k.useCallback)(async e=>{let n=i[e.id]?.trim();if(!u||!n){l(t=>({...t,[e.id]:{ok:!1,message:u?`Prompt is empty.`:`Task launcher block is missing projectPath.`}}));return}s(t=>({...t,[e.id]:!0})),l(t=>({...t,[e.id]:{ok:!0,message:`Launching…`}}));try{let r=`🧭 ${e.title}`.slice(0,120),i=await fetch(`/api/terminal/launch-agent-session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:u,prompt:n,title:r,userInitiated:!0})}),a=await i.json().catch(()=>({}));if(!i.ok||!a.ok||!a.sessionId)throw Error(a.error||`Launch failed (${i.status})`);t({requestId:`task-launcher-${e.id}-${a.sessionId}`,cwd:u,title:r,existingPtyId:a.sessionId,spawnPi:!0,sessionType:`pi`,wasIdle:!0}),l(t=>({...t,[e.id]:{ok:!0,message:`Launched session ${a.sessionId}`,sessionId:a.sessionId}}))}catch(t){l(n=>({...n,[e.id]:{ok:!1,message:t instanceof Error?t.message:String(t)}}))}finally{s(t=>({...t,[e.id]:!1}))}},[t,u,i]);return r.length===0?null:(0,O.jsx)(`section`,{className:`group/gui my-3`,"data-testid":`pi-rendered-generative-ui`,"data-generative-ui-type":`task_launcher`,children:(0,O.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>{let t=i[e.id]??e.prompt,n=c[e.id],r=o[e.id]===!0;return(0,O.jsxs)(`article`,{className:`rounded-xl border border-terminal-border/45 bg-terminal-bg/55 p-3 shadow-sm`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded-full border border-terminal-cyan/25 bg-terminal-cyan/10 px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em] text-terminal-cyan`,children:e.id}),(0,O.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold leading-snug text-terminal-text`,children:e.title})]}),e.summary?(0,O.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-[12px] leading-relaxed text-terminal-muted`,children:e.summary}):null]}),(0,O.jsx)(`button`,{type:`button`,disabled:r||!u||!t.trim(),onClick:()=>void d(e),className:`rounded-lg border border-terminal-cyan/50 bg-terminal-cyan/12 px-3 py-1.5 font-mono text-[11px] font-bold uppercase tracking-[0.12em] text-terminal-cyan transition hover:bg-terminal-cyan/20 disabled:cursor-not-allowed disabled:opacity-45`,children:r?`Launching…`:`Launch session`})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-2 text-[11px] text-terminal-muted sm:grid-cols-3`,children:[e.sourceNodeIds.length?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`font-mono text-terminal-cyan/80`,children:`Source:`}),` `,e.sourceNodeIds.join(`, `)]}):null,e.suggestedFiles.length?(0,O.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`font-mono text-terminal-cyan/80`,children:`Files:`}),` `,e.suggestedFiles.join(`, `)]}):null,e.validation?(0,O.jsxs)(`div`,{className:`sm:col-span-3`,children:[(0,O.jsx)(`span`,{className:`font-mono text-terminal-cyan/80`,children:`Validate:`}),` `,e.validation]}):null]}),e.plan?(0,O.jsxs)(`details`,{className:`mt-3 rounded-lg border border-terminal-border/35 bg-terminal-surface/20 px-3 py-2`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer font-mono text-[11px] uppercase tracking-[0.12em] text-terminal-muted hover:text-terminal-cyan`,children:`Plan`}),(0,O.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-[12px] leading-relaxed text-terminal-text/82`,children:e.plan})]}):null,(0,O.jsxs)(`label`,{className:`mt-3 block`,children:[(0,O.jsx)(`span`,{className:`mb-1 block font-mono text-[10px] font-bold uppercase tracking-[0.16em] text-terminal-muted`,children:`Editable launch prompt`}),(0,O.jsx)(`textarea`,{value:t,onChange:t=>a(n=>({...n,[e.id]:t.target.value})),rows:8,className:`w-full resize-y rounded-lg border border-terminal-border/55 bg-terminal-bg px-3 py-2 font-mono text-[11px] leading-relaxed text-terminal-text outline-none focus:border-terminal-cyan/60`})]}),n?(0,O.jsx)(`div`,{className:`mt-2 rounded-md border px-2 py-1.5 font-mono text-[11px] ${n.ok?`border-terminal-green/25 bg-terminal-green/10 text-terminal-green`:`border-terminal-red/30 bg-terminal-red/10 text-terminal-red`}`,children:n.message}):null]},e.id)})})})}function Xr({block:e}){let[t,n]=(0,k.useState)(!1),r=(0,k.useCallback)(()=>n(!1),[]),i=e.type.toLowerCase(),a=$(e.title)||(i===`html`?`Generated interface`:`Generated UI`);if(e.subtitle,i===`task_launcher`)return(0,O.jsx)(Yr,{block:e});if(i===`vision_inspection`){let i=Array.isArray(e.crops)?(e.crops??[]).map(e=>({...e,title:e.title||e.label||e.crop_id,imagePath:e.imagePath||e.image_path||e.output_path||e.path,imageUrl:e.imageUrl||e.image_url||e.url})):[],o=Array.isArray(e.observations)?e.observations??[]:[],s=(Array.isArray(e.items)&&e.items.length>0?e.items:i).slice(0,12).map(e=>{if(e.observation||!e.crop_id)return e;let t=o.find(t=>t.crop_id===e.crop_id||t.label===e.label);return t?{...e,observation:t.observation,importance:e.importance||t.importance}:e});if(s.length===0)return null;let c=e=>(0,O.jsx)(`div`,{className:e?`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`:`grid gap-2 sm:grid-cols-2`,children:s.map((t,n)=>{let r=$(t.title||t.label||t.region||`Region ${n+1}`),i=$(t.observation||t.detail||t.description),a=$(t.importance||t.badge||t.status),o=$(t.region),s=$(t.imagePath||t.path),c=$(t.imageUrl||t.url)||(s?je(s):``),l=Hr(a||$(t.tone));return(0,O.jsxs)(`article`,{className:`overflow-hidden rounded-xl border ${l.border} ${l.bg}`,children:[c?(0,O.jsxs)(`div`,{className:`relative border-b border-terminal-border/30 bg-black/35`,children:[(0,O.jsx)(`img`,{src:c,alt:r,loading:`lazy`,className:e?`h-56 w-full object-contain`:`h-32 w-full object-contain`}),a?(0,O.jsx)(`span`,{className:`absolute right-2 top-2 rounded-full border ${l.border} bg-slate-950/80 px-2 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] ${l.text}`,children:a}):null]}):null,(0,O.jsxs)(`div`,{className:e?`p-4`:`p-3`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 font-mono ${e?`text-sm`:`text-[11px]`}`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${l.dot}`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-bold ${l.text}`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words leading-relaxed text-terminal-text/82 ${e?`text-sm`:`text-[11px]`}`,children:i}):null,o?(0,O.jsxs)(`div`,{className:`mt-2 rounded-md border border-terminal-border/30 bg-terminal-bg/35 px-2 py-1 font-mono text-[10px] text-terminal-muted/75`,children:[`region: `,o]}):null,s?(0,O.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] text-terminal-muted/55`,title:s,children:s}):null]})]},`${r}-${n}`)})});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`group/gui relative my-3`,"data-testid":`pi-rendered-generative-ui`,"data-generative-ui-type":`vision_inspection`,children:[(0,O.jsx)(`div`,{className:`absolute right-0 top-0 z-10`,children:(0,O.jsx)(qr,{onClick:()=>n(!0)})}),c(!1)]}),t&&(0,O.jsx)(Kr,{title:a||`Vision inspection`,onClose:r,children:(0,O.jsx)(`section`,{className:`rounded-xl border border-terminal-cyan/25 bg-gradient-to-br from-terminal-cyan/[0.07] to-terminal-purple/[0.045] p-3 sm:p-4`,children:c(!0)})})]})}if(i===`html`&&typeof e.html==`string`&&e.html.trim()){let i=`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>
*{box-sizing:border-box;margin:0;padding:0}
body{background:#020617;color:#e5e7eb;font-family:Inter,-apple-system,BlinkMacSystemFont,'SF Pro Text','Segoe UI',system-ui,sans-serif;padding:16px;overflow-x:hidden}
h1,h2,h3{font-weight:700;letter-spacing:-0.02em}
h1{font-size:clamp(1.4rem,4vw,2rem)}
h2{font-size:clamp(1.1rem,3vw,1.5rem)}
h3{font-size:clamp(0.95rem,2.5vw,1.2rem)}
@media(max-width:480px){body{padding:12px;font-size:14px}}
</style></head><body>${e.html}</body></html>`,o=Ur(e.height);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`group/gui relative my-3 overflow-hidden rounded-xl`,"data-testid":`pi-rendered-generative-ui`,"data-generative-ui-type":`html`,children:[(0,O.jsx)(`div`,{className:`absolute right-1 top-1 z-10`,children:(0,O.jsx)(qr,{onClick:()=>n(!0)})}),(0,O.jsx)(`iframe`,{title:a,sandbox:`allow-scripts`,srcDoc:i,className:`w-full bg-slate-950`,style:{height:o,minHeight:120}})]}),t&&(0,O.jsx)(Kr,{title:a,onClose:r,children:(0,O.jsx)(`iframe`,{title:a,sandbox:`allow-scripts`,srcDoc:i,className:`w-full h-full rounded-xl border border-terminal-purple/20 bg-slate-950`,style:{minHeight:`70vh`}})})]})}if(i===`table`&&Array.isArray(e.columns)&&Array.isArray(e.rows)){let i=t=>(0,O.jsx)(`div`,{className:`overflow-x-auto`,children:(0,O.jsxs)(`table`,{className:`min-w-full border-collapse font-mono ${t?`text-sm`:`text-[11px] sm:text-xs`}`,children:[(0,O.jsx)(`thead`,{children:(0,O.jsx)(`tr`,{children:e.columns.map(e=>(0,O.jsx)(`th`,{className:`border-b border-terminal-cyan/15 px-2 sm:px-3 py-2 text-left text-terminal-cyan/75 ${t?`px-4 py-3`:``}`,children:e},e))})}),(0,O.jsx)(`tbody`,{children:e.rows.slice(0,80).map((n,r)=>(0,O.jsx)(`tr`,{className:`border-b border-terminal-border/25 last:border-0`,children:e.columns.map(e=>(0,O.jsx)(`td`,{className:`max-w-[22rem] px-2 sm:px-3 py-2 text-terminal-text/85 align-top ${t?`px-4 py-3`:``}`,children:(0,O.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:$(n[e])})},e))},r))})]})});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`group/gui relative my-3 overflow-hidden rounded-xl`,"data-testid":`pi-rendered-generative-ui`,"data-generative-ui-type":`table`,children:[(0,O.jsx)(`div`,{className:`absolute right-0 top-0 z-10`,children:(0,O.jsx)(qr,{onClick:()=>n(!0)})}),i(!1)]}),t&&(0,O.jsx)(Kr,{title:a,onClose:r,children:(0,O.jsx)(`section`,{className:`rounded-xl border border-terminal-cyan/25 bg-terminal-cyan/[0.045] overflow-hidden`,children:i(!0)})})]})}let o=Array.isArray(e.items)?e.items:[];if(o.length===0)return null;let s=i===`timeline`,c=e=>(0,O.jsx)(`div`,{className:s?`space-y-2`:e?`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`:`space-y-2 sm:space-y-0 sm:grid sm:gap-2 sm:grid-cols-2`,children:o.slice(0,24).map((t,n)=>{let r=Hr($(t.tone||t.status)),i=$(t.title||t.label||t.step)||`Item ${n+1}`,a=$(t.detail||t.description||t.next||t.value),o=$(t.badge||t.status||t.kind);return(0,O.jsxs)(`div`,{className:`rounded-lg border ${r.border} ${r.bg} px-3 py-2 ${e?`px-4 py-3`:``}`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 font-mono ${e?`text-sm`:`text-[11px]`}`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${r.dot}`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-bold ${r.text}`,children:i}),o&&(0,O.jsx)(`span`,{className:`shrink-0 rounded-full border ${r.border} px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${r.text}`,children:o})]}),a&&(0,O.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words leading-relaxed text-terminal-text/78 ${e?`text-sm`:`text-[11px]`}`,children:a})]},`${i}-${n}`)})});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`group/gui relative my-3`,"data-testid":`pi-rendered-generative-ui`,"data-generative-ui-type":i,children:[(0,O.jsx)(`div`,{className:`absolute right-0 top-0 z-10`,children:(0,O.jsx)(qr,{onClick:()=>n(!0)})}),c(!1)]}),t&&(0,O.jsx)(Kr,{title:a,onClose:r,children:(0,O.jsx)(`section`,{className:`rounded-xl border border-terminal-purple/25 bg-terminal-purple/[0.035] p-3 sm:p-4`,children:c(!0)})})]})}var Zr={to:`To`,cc:`Cc`,bcc:`Bcc`,from:`From`,subject:`Subject`,title:`Title`,channel:`Channel`,recipient:`To`,platform:`Platform`};function Qr(e,t){let n=e.replace(/^\n+/,``).replace(/\s+$/,``),r=[],i=n.split(`
`),a=0;for(;a<i.length;a+=1){let e=i[a];if(!e.trim())continue;let t=/^([A-Za-z][A-Za-z ]{0,20}):\s*(.*)$/.exec(e),n=t?t[1].trim().toLowerCase():``;if(!t||!Zr[n])break;r.push({label:Zr[n],value:t[2].trim()})}return{fields:r,body:i.slice(a).join(`
`).replace(/^\s*---+\s*\n?/,``).replace(/^\n+/,``),streaming:t}}function $r(e){let t=[],n=/```mc-draft[^\n]*\n([\s\S]*?)(?:```|$)/gi,r=0,i;for(;(i=n.exec(e))!==null;){let n=e.slice(r,i.index);n.trim()&&t.push({kind:`markdown`,text:n.trim()});let a=i[0].trimEnd().endsWith("```");t.push({kind:`draft`,draft:Qr(i[1],!a)}),r=i.index+i[0].length}let a=e.slice(r);return(a.trim()||t.length===0)&&t.push({kind:`markdown`,text:a.trim()}),t}function ei(e,t){let n=e.fields.map(e=>`${e.label}: ${e.value}`).join(`
`);return n?`${n}\n\n${t}`:t}function ti(){return(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),(0,O.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function ni(){return(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`path`,{d:`M12 20h9`}),(0,O.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function ri({draft:e}){let[t,n]=(0,k.useState)(!1),[r,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(!1),s=r??e.body;(0,k.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1600);return()=>window.clearTimeout(e)},[a]);let c=(0,k.useCallback)(()=>{navigator.clipboard?.writeText(ei(e,s)).then(()=>o(!0)).catch(()=>void 0)},[s,e]),l=(0,k.useMemo)(()=>s.replace(/(\S)\n(?!\n)/g,`$1  
`),[s]);return(0,O.jsxs)(`div`,{className:`my-3 overflow-hidden rounded-2xl border border-terminal-border/45 bg-terminal-bg/40`,"data-rendered-draft":e.streaming?`streaming`:`complete`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`inline-flex items-center gap-1.5 rounded-full border border-terminal-border/50 px-2.5 py-1 text-[11px] text-terminal-muted transition-colors hover:border-terminal-border hover:text-terminal-text`,children:[(0,O.jsx)(ni,{}),t?`Done`:`Edit`]}),(0,O.jsxs)(`button`,{type:`button`,onClick:c,title:`Copy draft`,"aria-label":`Copy draft`,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-terminal-muted transition-colors hover:text-terminal-text`,children:[(0,O.jsx)(ti,{}),a?`Copied`:null]})]}),e.fields.length>0&&(0,O.jsx)(`div`,{className:`border-t border-terminal-border/35`,children:e.fields.map(e=>(0,O.jsxs)(`div`,{className:`border-b border-terminal-border/25 px-4 py-2.5 text-[13px] last:border-b-0`,children:[(0,O.jsx)(`span`,{className:`mr-2 text-terminal-muted/70`,children:e.label}),(0,O.jsx)(`span`,{className:`text-terminal-text/95`,children:e.value})]},e.label))}),(0,O.jsx)(`div`,{className:`border-t border-terminal-border/35 px-4 py-3`,children:t?(0,O.jsx)(`textarea`,{value:s,onChange:e=>i(e.target.value),rows:Math.min(24,Math.max(6,s.split(`
`).length+1)),className:`w-full resize-y rounded-lg border border-terminal-border/45 bg-transparent p-2 font-mono text-[12.5px] leading-[1.7] text-terminal-text/95 outline-none focus:border-terminal-cyan/50`}):(0,O.jsx)(`div`,{className:`markdown-body text-[13px] leading-[1.75] text-terminal-text/95 [overflow-wrap:anywhere]`,children:(0,O.jsx)(g,{remarkPlugins:[h],children:l})})})]})}var ii=/\.(?:html?|svg|png|jpe?g|gif|webp|pdf|json|txt|md|markdown)$/i;function ai(e){let t=e.trim();if(!t||t.length>4e3||/[\r\n]/.test(t)||/^https?:\/\//i.test(t)||!(t.startsWith(`/`)||t.startsWith(`./`)||t.startsWith(`../`)||t.startsWith(`~/`))&&!/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+$/.test(t))return null;let n=t.split(/[?#]/,1)[0];return ii.test(n)?t:null}function oi(e){if(!e)return[];let t=[],n=new Set;for(let r of e.matchAll(/`([^`\n]{1,4000})`/g)){let e=ai(r[1]);!e||n.has(e)||(n.add(e),t.push(e))}return t}function si(e){return e.split(/[?#]/,1)[0].split(/[\\/]/).filter(Boolean).at(-1)||`Artifact`}var ci=`[Axis ask-block answers]`;function li(e){return e.role===`user`&&e.textContent?.trimStart().startsWith(ci)===!0}function ui(e){try{let t=JSON.parse(e.sections_json);return Array.isArray(t)?t:[]}catch{return[]}}function di(e){if(!e)return{};try{let t=JSON.parse(e),n={};for(let e of t.sections??[])for(let t of e.answers??[])n[t.questionId]=t.value;return n}catch{return{}}}function fi(e){return di(e?.answers_json)}function pi(e){return di(e?.answers_json)}function mi(e){return`/api/sessions/${encodeURIComponent(e)}/ask-blocks`}function hi(e,t){return`${mi(e)}?anchorId=${encodeURIComponent(t)}`}function gi(e,t){return`${mi(e)}/${encodeURIComponent(t)}`}function _i(e,t){return`${gi(e,t)}/draft`}function vi(e,t){return`${gi(e,t)}/submit`}async function yi(e){let t=await e.json().catch(()=>null);if(!e.ok){let n=t?.error??t?.message??`HTTP ${e.status}`;throw Error(n)}return t}async function bi(e,t){let n=await yi(await fetch(mi(e),{cache:`no-store`,signal:t}));return Array.isArray(n.askBlocks)?n.askBlocks:[]}async function xi(e,t,n){let r=await yi(await fetch(hi(e,t),{cache:`no-store`,signal:n}));return r.askBlock?{askBlock:r.askBlock,draft:r.draft??null,submission:r.submission??null}:null}async function Si(e,t,n,r={}){return yi(await fetch(_i(e,t),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n,writerId:r.writerId,mutationId:r.mutationId})}))}async function Ci(e,t,n,r){return yi(await fetch(vi(e,t),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n,clientRequestId:r})}))}function wi(e){return e.role!==`user`||!(e.textContent?.trimStart()??``).startsWith(`Ralph Loop wake-up`)?null:`Woken up by Ralph Loop`}function Ti(e,t){if(e===t)return!0;let n=e??[],r=t??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e+=1){let t=n[e],i=r[e];if(t.id!==i.id||t.name!==i.name||t.path!==i.path||t.previewUrl!==i.previewUrl||t.uploadStatus!==i.uploadStatus||t.processingError!==i.processingError)return!1}return!0}function Ei(e,t){if(e===t)return!0;let n=e??[],r=t??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e+=1){let t=n[e],i=r[e];if(t.name!==i.name||JSON.stringify(t.arguments??{})!==JSON.stringify(i.arguments??{}))return!1}return!0}function Di(e,t){return e===t?!0:e.id===t.id&&e.role===t.role&&e.timestamp===t.timestamp&&e.textContent===t.textContent&&e.nativeStreaming===t.nativeStreaming&&e.thinking===t.thinking&&e.stopReason===t.stopReason&&e.errorMessage===t.errorMessage&&e.optimistic===t.optimistic&&e.optimisticAccepted===t.optimisticAccepted&&e.optimisticFailed===t.optimisticFailed&&e.optimisticIntentLedgerId===t.optimisticIntentLedgerId&&e.optimisticIntentStatus===t.optimisticIntentStatus&&e.optimisticIntentError===t.optimisticIntentError&&e.model===t.model&&Ti(e.optimisticAttachments,t.optimisticAttachments)&&Ei(e.toolCalls,t.toolCalls)}function Oi(e){let t=[],n=Pi(e.textContent??``),r=(e.role===`user`?We(C(n)):n).trim();r&&t.push(r);let i=Pi(e.thinking??``).trim();i&&t.push(`Thinking:\n${i}`);let a=e.errorMessage?.trim();return a&&t.push(`Error: ${a}`),e.optimisticAttachments?.length&&t.push(e.optimisticAttachments.map(e=>e.path||e.name).filter(Boolean).join(`
`)),e.toolCalls?.length&&t.push(e.toolCalls.map(e=>{let t=JSON.stringify(e.arguments??{},null,2);return t&&t!==`{}`?`Tool: ${e.name}\n${t}`:`Tool: ${e.name}`}).join(`

`)),t.filter(Boolean).join(`

`).trim()}function ki(e){let t=e.errorMessage?.trim()??``;return e.role!==`assistant`||!t||!/error|fail|exception/i.test(e.stopReason??``)?null:/context window|context length|too many tokens|maximum context/i.test(t)?{title:`Context limit reached`,summary:`This task exceeded the model’s available context. Run /compact or start a new task before continuing. Any queued message stays queued; press Enter in the empty composer when you are ready to steer it.`,detail:t}:{title:`Agent stopped`,summary:`The model stopped before it could finish this turn. The queued message has not been sent.`,detail:t}}async function Ai(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`true`),t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)}finally{t.remove()}}function ji(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(ji).join(``):k.isValidElement(e)?ji(e.props.children):``}function Mi({children:e,...t}){let[n,r]=(0,k.useState)(`idle`),i=(0,k.useRef)(null),a=(0,k.useMemo)(()=>ji(e).replace(/\n$/,``),[e]);(0,k.useEffect)(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);let o=(0,k.useCallback)(async()=>{if(a){i.current!==null&&window.clearTimeout(i.current);try{await Ai(a),r(`copied`)}catch{r(`error`)}i.current=window.setTimeout(()=>r(`idle`),1600)}},[a]);return(0,O.jsxs)(`div`,{className:`group/code-block relative my-[1em] min-w-0`,"data-testid":`pi-rendered-code-block`,children:[(0,O.jsx)(`pre`,{...t,className:`${t.className??``} !my-0 pr-24`,children:e}),(0,O.jsxs)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),o()},className:`absolute right-2 top-2 inline-flex min-h-11 min-w-[4.75rem] touch-manipulation items-center justify-center gap-1.5 rounded-lg border border-terminal-border/80 bg-terminal-bg/95 px-3 text-[12px] font-semibold text-terminal-text shadow-sm backdrop-blur transition-colors hover:border-terminal-accent/70 hover:bg-terminal-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-accent/55 active:scale-[0.98]`,"aria-label":n===`copied`?`Code copied`:n===`error`?`Code copy failed`:`Copy code`,title:n===`copied`?`Copied`:n===`error`?`Could not copy code`:`Copy code`,"data-copy-state":n,children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`text-[14px] leading-none`,children:n===`copied`?`✓`:`⧉`}),(0,O.jsx)(`span`,{children:n===`copied`?`Copied`:n===`error`?`Retry`:`Copy`})]})]})}var Ni=/\n\n…\[truncated \d+ chars from fast tail payload\]\s*$/;function Pi(e){return e.replace(Ni,``).trimEnd()}function Fi(e){return e.includes(`
`)||e.includes(`\r`)}function Ii(e){return We(C(e)).replace(/\r\n/g,`
`).replace(/\s+/g,` `).trim()}function Li(e,t){let n=new Date(e.timestamp).getTime();return Number.isFinite(n)?Ri(e,t)?!0:t.some(e=>{if(e.role!==`user`&&e.role!==`assistant`)return!1;let t=new Date(e.timestamp).getTime();return Number.isFinite(t)&&t>=n-1e3}):!1}function Ri(e,t){let n=new Date(e.timestamp).getTime();if(!Number.isFinite(n))return null;let r=Ii(e.textContent?.trim()),i=e.optimisticAttachments?.map(e=>e.path).filter(Boolean)??[];for(let e of t){if(e.role!==`user`)continue;let t=new Date(e.timestamp).getTime();if(!Number.isFinite(t)||t<n-5e3)continue;let a=e.textContent?.trim()??``,o=Ii(a);if(r&&(o.includes(r)||r.includes(o))||i.length>0&&i.every(e=>a.includes(e)))return e}return null}function zi(e,t,n){let r=[];for(let e of t){if(e.role!==`user`)continue;let t=new Date(e.timestamp).getTime();Number.isFinite(t)&&r.push({id:e.id,kind:`optimistic`,at:t,text:e.textContent??``,attachmentPaths:e.optimisticAttachments?.map(e=>e.path).filter(Boolean)??[]})}for(let t of e){let e=new Date(t.createdAt??``).getTime();Number.isFinite(e)&&r.push({id:t.id,kind:`queue`,at:e,text:t.text,attachmentPaths:t.attachments?.map(e=>e.path).filter(Boolean)??[]})}r.sort((e,t)=>e.at-t.at||(e.kind===`optimistic`?-1:1));let i=n.filter(e=>e.role===`user`&&Number.isFinite(new Date(e.timestamp).getTime())).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),a=new Set,o=new Set;for(let e of r){let t=Ii(e.text),n=e.at-(e.kind===`optimistic`?5e3:0),r=i.find(r=>{if(a.has(r.id)||new Date(r.timestamp).getTime()<n)return!1;let i=r.textContent?.trim()??``,o=Ii(i);return!!(t&&o&&(o.includes(t)||t.includes(o))||e.attachmentPaths.length>0&&e.attachmentPaths.every(e=>i.includes(e)))});r&&(a.add(r.id),e.kind===`queue`&&o.add(e.id))}return o}function Bi(e){if(!Fi(e))return null;let t=e.replace(/\r/g,`
`).split(`
`).map(e=>e.trim()).filter(Boolean).join(`
`).replace(/\u001b\[[0-9;]*[A-Za-z]/g,``).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,``).trim();return t.length>=2?t:null}function Vi(e,t){let n=e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[[^\]]*\]\(([^)]*)\)/g,`$1`).replace(/[`*_>#~-]+/g,` `).replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1).trim()}…`:n}function Hi(e,t=Date.now()){let n=new Date(e).getTime()-t;if(!Number.isFinite(n))return`time unknown`;if(n<=0)return`due now`;let r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;if(i<1)return`${a}s`;if(i<60)return`${i}m ${a.toString().padStart(2,`0`)}s`;let o=Math.floor(i/60),s=i%60;return o<24?`${o}h ${s}m`:`${Math.floor(o/24)}d ${o%24}h`}var Ui=k.memo(function({message:e,isLatest:t,assistantActionsEnabled:n=!0,handoffAgents:r=[],onOpenHandoffAgent:i,onForkMessage:a,cwd:o,onOpenFileAsArtifact:s}){let c=e.role===`user`,l=t?ki(e):null,[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[m,ee]=(0,k.useState)(!1),_=(0,k.useMemo)(()=>Oi(e),[e]),te=(0,k.useMemo)(()=>c?ue(e.textContent):[],[c,e.textContent]),v=(0,k.useMemo)(()=>c?ct(e):[],[c,e]),y=(0,k.useMemo)(()=>c?[]:st(e),[c,e]),ne=(0,k.useMemo)(()=>Pi(e.thinking??``),[e.thinking]),b=(0,k.useMemo)(()=>{let t=Pi(e.textContent??``),n=c?We(C(t)):t;return c?v.length===0?n:Le(n.replace(/\[video\][\s\S]*?\[\/video\]/gi,``).trim()):y.length>0?Re(n):n},[v.length,c,e.textContent,y.length]),re=!c&&!l&&!/tool[_-]?use/i.test(e.stopReason??``),{displayText:ie,revealing:x}=wt({messageId:e.id,text:b,timestamp:e.timestamp,isLatest:!!(t&&re),enabled:re}),ae=re?ie:b,S=(0,k.useMemo)(()=>Vr(ae),[ae]),oe=(0,k.useMemo)(()=>c?[{kind:`markdown`,text:S.markdown}]:$r(S.markdown),[S.markdown,c]),se=oe.some(e=>e.kind===`draft`),ce=(0,k.useRef)(s);ce.current=s;let le=(0,k.useMemo)(()=>({pre({children:e,...t}){return(0,O.jsx)(Mi,{...t,children:e})},code({children:e,className:t,node:n,...r}){let i=ce.current,a=String(e??``).replace(/\n$/,``),o=!n?.position||n.position.start.line===n.position.end.line,s=!c&&!t&&o?ai(a):null;if(!s||!i)return(0,O.jsx)(`code`,{className:t,...r,children:e});let l=si(s);return(0,O.jsxs)(`button`,{type:`button`,className:`group/artifact-path inline-flex max-w-full items-center gap-1 rounded border border-terminal-cyan/25 bg-terminal-cyan/[0.055] px-1.5 py-0.5 align-baseline font-mono text-[0.92em] text-terminal-cyan transition-colors hover:border-terminal-cyan/55 hover:bg-terminal-cyan/10`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i(s,l)},title:`Open ${s} as a session artifact`,"aria-label":`Open ${l} as an artifact`,"data-rendered-artifact-path":s,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[9px] opacity-55 transition-opacity group-hover/artifact-path:opacity-100`,children:`↗`})]})}}),[c]),de=(0,k.useMemo)(()=>wi(e),[e]),fe=c&&(b.length>700||b.split(`
`).length>10),pe=!e.optimistic&&!!e.id&&!!a,w=c||n,T=n&&e.nativeStreaming!==!0&&re&&!x&&!!_.trim(),me=(0,k.useCallback)(async()=>{if(_.trim())try{await Ai(_),d(!0),window.setTimeout(()=>d(!1),1200)}catch(e){console.warn(`[PiSessionRenderedView] failed to copy message`,e)}},[_]),E=(0,k.useCallback)(e=>{!w||!_.trim()||e.target.closest(`button, a, summary, input, textarea, select, [contenteditable]`)||window.matchMedia(`(max-width: 767px)`).matches&&window.getSelection()?.isCollapsed&&ee(!0)},[w,_]),he=!!(b.trim()||l||y.length>0||r.length>0||ne.trim()&&e.nativeStreaming!==!0&&/tool[_-]?use/i.test(e.stopReason??``));return!c&&!he||li(e)?null:de?(0,O.jsxs)(`div`,{className:`my-1 flex items-center gap-1.5 pl-1 text-[11px] text-terminal-muted/70`,"data-testid":`pi-rendered-automation-wake`,"data-rendered-message-id":e.id||void 0,title:b,children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,O.jsx)(`span`,{children:de})]}):(0,O.jsxs)(`article`,{className:`group/message relative min-w-0 select-text touch-pan-y ${c?`ml-auto max-w-[92%] overflow-visible`:`mr-auto max-w-full overflow-visible border-0 bg-transparent px-1 py-2 pr-10 text-terminal-text/95 shadow-none md:py-1`}`,"data-testid":`pi-rendered-message-card`,"data-rendered-message-id":e.id||void 0,"data-rendered-message-role":e.role,"data-rendered-message-layout":c?`user-bubble`:`assistant-plain`,"data-copied":u?`true`:void 0,onClick:E,children:[c&&v.length>0?(0,O.jsx)(j,{attachments:v,variant:`message`}):null,(0,O.jsxs)(`div`,{className:c?`overflow-hidden rounded-xl border border-transparent bg-transparent px-4 py-4 text-terminal-muted shadow-sm md:py-3`:`contents`,"data-testid":c?`pi-rendered-user-bubble`:void 0,children:[c&&te.length>0?(0,O.jsx)(qe,{references:te,compact:!0}):null,l?(0,O.jsx)(`div`,{className:`rounded-xl border border-red-500/35 bg-red-50 px-4 py-3 text-red-950 shadow-sm dark:border-red-400/35 dark:bg-red-500/[0.08] dark:text-red-100`,role:`alert`,"data-testid":`pi-rendered-provider-error`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`span`,{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full bg-red-600 shadow-[0_0_8px_rgba(220,38,38,0.3)] dark:bg-red-400 dark:shadow-[0_0_10px_rgba(248,113,113,0.55)]`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-red-950 dark:text-red-100`,children:l.title}),(0,O.jsx)(`div`,{className:`mt-1 text-[13px] leading-relaxed text-red-900 dark:text-red-100/90`,children:l.summary}),(0,O.jsx)(`div`,{className:`mt-2 break-words font-mono text-[11px] leading-relaxed text-red-800 dark:text-red-200/75`,children:l.detail})]})]})}):null,!c&&ne.trim()&&(/tool[_-]?use/i.test(e.stopReason??``)||e.nativeStreaming===!0)&&(0,O.jsx)(Wn,{text:ne,messageId:e.id,timestamp:e.timestamp,streaming:e.nativeStreaming===!0}),ae.trim()||x?(0,O.jsxs)(`div`,{className:`relative`,"data-assistant-revealing":x?`true`:void 0,"data-testid":x?`pi-rendered-assistant-revealing`:void 0,"data-rendered-writing":x?`1`:void 0,children:[x&&!se?(0,O.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-[13px] leading-[1.75] [overflow-wrap:anywhere] text-terminal-text/95`,children:[ae,(0,O.jsx)(Nt,{})]}):(0,O.jsxs)(`div`,{className:`markdown-body text-[13px] leading-[1.75] break-words [overflow-wrap:anywhere] [&_code]:[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:overflow-x-hidden [&_pre]:[overflow-wrap:anywhere] ${c?`text-terminal-muted`:`text-terminal-text/95`} ${fe&&!f?`max-h-52 overflow-hidden`:``}`,children:[oe.map((t,n)=>t.kind===`draft`&&!c?(0,O.jsx)(ri,{draft:t.draft},`${e.id}-draft-${n}`):(0,O.jsx)(g,{remarkPlugins:[h],components:le,children:t.kind===`markdown`?t.text:``},`${e.id}-md-${n}`)),!c&&S.blocks.map((t,n)=>(0,O.jsx)(Xr,{block:t},`${e.id}-gui-${n}`))]}),fe&&!f&&(0,O.jsx)(`div`,{"aria-hidden":`true`,className:`text-[13px] leading-[1.75] text-terminal-muted`,children:`…`}),fe&&(0,O.jsxs)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),p(e=>!e)},className:`mt-1 inline-flex items-center gap-1 text-[13px] text-terminal-muted/70 transition-colors hover:text-terminal-text`,"data-testid":`pi-rendered-long-message-toggle`,children:[(0,O.jsx)(`span`,{children:f?`Show less`:`Show more`}),(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`text-[10px]`,children:f?`⌃`:`⌄`})]})]}):null]}),c&&(_.trim()||pe)&&(0,O.jsxs)(`div`,{className:`mt-1 h-7 items-center justify-end gap-1 text-terminal-muted transition-opacity duration-150 md:flex md:opacity-0 md:group-hover/message:opacity-60 md:focus-within:opacity-100 ${m?`flex opacity-60`:`hidden`} ${u?`!flex !opacity-100`:``}`,"data-testid":`pi-rendered-user-actions`,children:[(0,O.jsx)(`time`,{className:`mr-1 font-mono text-[10px]`,dateTime:e.timestamp,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}),_.trim()&&(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),me()},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-terminal-border/30 hover:text-terminal-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-text/35`,"aria-label":u?`Message copied`:`Copy message`,title:u?`Copied`:`Copy message`,children:u?(0,O.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,O.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,O.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),pe&&(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a?.(e)},className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-terminal-border/30 hover:text-terminal-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-text/35 md:inline-flex`,"aria-label":`Fork from this user message`,title:`Fork from this user message`,"data-testid":`pi-rendered-fork-message`,children:(0,O.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`circle`,{cx:`6`,cy:`6`,r:`3`}),(0,O.jsx)(`circle`,{cx:`18`,cy:`18`,r:`3`}),(0,O.jsx)(`path`,{d:`M8.2 8.2 15.8 15.8`}),(0,O.jsx)(`path`,{d:`M6 9v3a6 6 0 0 0 6 6h3`})]})})]}),T&&(0,O.jsxs)(`div`,{className:`mt-2 items-center gap-1 transition-opacity duration-150 md:flex ${m?`flex opacity-60`:`hidden`} ${t?`md:opacity-60`:`md:opacity-0 md:group-hover/message:opacity-60 md:focus-within:opacity-100`}`,"data-testid":`pi-rendered-assistant-actions`,"data-actions-visible":t?`latest`:`hover`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),me()},className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-terminal-muted transition-colors hover:bg-terminal-border/30 hover:text-terminal-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-text/35`,"aria-label":u?`Message copied`:`Copy message`,title:u?`Copied`:`Copy message`,children:u?(0,O.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,O.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,O.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,O.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),pe&&(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a?.(e)},className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-terminal-muted transition-colors hover:bg-terminal-border/30 hover:text-terminal-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-terminal-text/35`,"aria-label":`Start new thread from this reply`,title:`Start new thread`,"data-testid":`pi-rendered-start-thread`,children:(0,O.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,O.jsx)(`path`,{d:`M16 3h5v5`}),(0,O.jsx)(`path`,{d:`M4 20 21 3`}),(0,O.jsx)(`path`,{d:`M21 16v5h-5`}),(0,O.jsx)(`path`,{d:`m15 15 6 6`}),(0,O.jsx)(`path`,{d:`M4 4l5 5`})]})}),(0,O.jsx)(`time`,{className:`ml-1 text-[13px] leading-none text-terminal-muted`,dateTime:e.timestamp,title:new Date(e.timestamp).toLocaleString(),children:new Date(e.timestamp).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})})]}),!c&&y.length>0?(0,O.jsx)(`div`,{className:`mt-3`,"data-testid":`pi-rendered-inline-proof-images`,children:(0,O.jsx)(j,{attachments:y,variant:`proof`})}):null,!c&&r.length>0&&(0,O.jsx)(Gi,{agents:r,onOpen:i})]})},(e,t)=>e.isLatest===t.isLatest&&e.assistantActionsEnabled===t.assistantActionsEnabled&&e.onOpenHandoffAgent===t.onOpenHandoffAgent&&e.onOpenFileAsArtifact===t.onOpenFileAsArtifact&&e.cwd===t.cwd&&Di(e.message,t.message)&&Xt(e.handoffAgents,t.handoffAgents));function Wi(e){return e.awaiting_approval?{label:`waiting on you`,dot:`bg-blue-400 animate-pulse`,text:`text-blue-300`}:e.status===`active`?{label:`active`,dot:`bg-terminal-green animate-pulse`,text:`text-terminal-green`}:e.task_status===`done`?{label:`done`,dot:`bg-terminal-green`,text:`text-terminal-green`}:e.task_status===`in_review`?{label:`in review`,dot:`bg-blue-400`,text:`text-blue-300`}:e.status===`completed`?{label:`idle`,dot:`bg-terminal-muted/60`,text:`text-terminal-muted`}:{label:e.task_status?.replace(/_/g,` `)||`connected`,dot:`bg-terminal-cyan`,text:`text-terminal-cyan`}}var Gi=k.memo(function({agents:e,onOpen:t}){return(0,O.jsxs)(`div`,{className:`mt-3 space-y-2`,"data-testid":`pi-rendered-handoff-agents`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[10px] font-bold uppercase tracking-[0.16em] text-terminal-purple/80`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-terminal-purple shadow-[0_0_8px_rgba(168,85,247,0.5)]`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{children:[`Connected child agent`,e.length>1?`s`:``]})]}),e.map(e=>{let n=Wi(e),r=e.awaiting_approval_question||e.recommended_next_step||e.lastActivitySummary||`${e.messageCount??0} messages`;return(0,O.jsxs)(`button`,{type:`button`,onClick:n=>{n.preventDefault(),n.stopPropagation(),t?.(e)},className:`group/handoff flex w-full items-start gap-3 rounded-xl border border-terminal-purple/25 bg-terminal-purple/[0.055] px-3 py-2.5 text-left shadow-sm shadow-black/10 transition-[color,background-color,border-color,box-shadow,opacity,transform] hover:border-terminal-purple/55 hover:bg-terminal-purple/[0.11] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-purple/60`,title:`Open child agent session`,"data-testid":`pi-rendered-handoff-agent-card`,"data-session-id":e.id,children:[(0,O.jsx)(`span`,{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${n.dot}`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-[12px] font-semibold text-terminal-text/90`,children:e.title}),(0,O.jsx)(`span`,{className:`shrink-0 rounded-full border border-current/20 px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase tracking-[0.12em] ${n.text}`,children:n.label})]}),r&&(0,O.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-terminal-muted/75`,children:r}),(0,O.jsxs)(`span`,{className:`block truncate font-mono text-[9px] text-terminal-muted/45`,children:[te(e.lastActivity),` · `,e.cwd]})]}),(0,O.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded-md border border-terminal-purple/25 px-2 py-1 font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-terminal-purple/80 transition-colors group-hover/handoff:bg-terminal-purple/15`,children:`Open ↗`})]},e.id)})]})},(e,t)=>e.onOpen===t.onOpen&&Xt(e.agents,t.agents));export{C as $,q as A,Ve as B,Jt as C,Ut as D,an as E,Qe as F,oe as G,Oe as H,qe as I,w as J,ue as K,He as L,dt as M,$e as N,Ft as O,Ze as P,x as Q,Ue as R,Yt as S,sn as T,ie as U,Be as V,le as W,ce as X,S as Y,ae as Z,Ci as _,Fi as a,zr as b,Li as c,bi as d,pe as et,li as f,Si as g,pi as h,Hi as i,Ct as j,Z as k,Ri as l,ui as m,Vi as n,Ii as o,fi as p,se as q,Bi as r,zi as s,Ui as t,xi as u,oi as v,Gn as w,Un as x,si as y,We as z};