@pi-outpost/embed 0.28.0 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -294,7 +294,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
294
294
|
`)){let e=Jk.exec(r);if(e===null)continue;let[,i,a,o]=e;if(i===``)continue;let s=n.get(i);s===void 0&&(s={path:i,hits:[]},n.set(i,s),t.push(s)),s.hits.push({line:Number(a),text:o})}return t}function Xk(e){return e.reduce((e,t)=>e+t.hits.length,0)}var Zk=8,Qk=5;function $k({item:e,dispatch:t}){let n=Yk(e.output??``),[r,a]=(0,i.useState)(!1);if(n.length===0)return(0,o.jsx)(jk,{item:e});let s=r?n:n.slice(0,Zk);return(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsxs)(`div`,{className:`text-xs text-zinc-500`,children:[Xk(n),` match`,Xk(n)===1?``:`es`,` in `,n.length,` file`,n.length===1?``:`s`]}),s.map(e=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t({kind:`openFile`,path:e.path}),className:`flex items-center gap-2 truncate text-left font-mono text-xs text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.path}),(0,o.jsx)(`span`,{className:`shrink-0 text-zinc-400 dark:text-zinc-600`,children:e.hits.length})]}),(0,o.jsxs)(`div`,{className:`overflow-x-auto rounded border border-zinc-200 font-mono text-xs dark:border-zinc-800`,children:[e.hits.slice(0,Qk).map((e,t)=>(0,o.jsxs)(`div`,{className:`flex gap-2 px-2`,children:[(0,o.jsx)(`span`,{className:`shrink-0 select-none text-zinc-400 dark:text-zinc-600`,children:e.line}),(0,o.jsx)(`span`,{className:`whitespace-pre text-zinc-700 dark:text-zinc-300`,children:e.text})]},t)),e.hits.length>Qk&&(0,o.jsxs)(`div`,{className:`px-2 text-zinc-400 dark:text-zinc-600`,children:[`+`,e.hits.length-Qk,` more in this file`]})]})]},e.path)),!r&&n.length>Zk&&(0,o.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`self-start text-xs text-zinc-500 hover:text-zinc-700 dark:hover:text-zinc-300`,children:[`show `,n.length-Zk,` more file`,n.length-Zk===1?``:`s`]})]})}var eA=[Nk,Fl,Fk,Lk,qk,{id:`code-search`,match:e=>e.toolName===`grep`,stable:!0,showsRawReveal:!0,Expanded:$k},Rk,zk,Mk];function tA(e){for(let t of eA){let n=!1;try{n=t.match(e)}catch{n=!1}if(n)return t}return Mk}function nA(e,t){let n=tA(e);if(t===void 0||t===n.id)return n;let r=eA.find(e=>e.id===t);if(r===void 0||r.id===Mk.id||n.extensionOwned===!0)return n;let i=!1;try{i=r.match(e)}catch{i=!1}return i?r:n}function rA(e){if(typeof e!=`object`||!e)return``;let t=e,n=[`command`,`path`,`file_path`,`pattern`,`query`].find(e=>typeof t[e]==`string`);if(n)return t[n];let r=JSON.stringify(t);return r===`{}`?``:r}function iA({item:e,dispatch:t=Tk}){let n=(0,i.useRef)(void 0),r=nA(e,n.current);n.current=r.id;let a=r.startsExpanded===!0,[s,c]=(0,i.useState)(a);(0,i.useEffect)(()=>{c(a)},[a]);let[l,u]=(0,i.useState)(!1),d=rA(e.args),f=r.Collapsed,p=!s&&f!==void 0&&(r.hasCollapsed?.(e)??!0);return(0,o.jsxs)(`div`,{className:`rounded-lg border text-sm ${e.isError?`border-red-300 bg-red-50 dark:border-red-900/60 dark:bg-red-950/20`:`border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900/60`}`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,o.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,o.jsx)(De,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),d&&(0,o.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:d})]}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:s?`▾`:`▸`})]}),e.running&&e.progress!=null&&(0,o.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-1.5 dark:border-zinc-800`,children:(0,o.jsx)(`progress`,{value:e.progress,max:1,"aria-label":`${e.toolName} progress`,className:`h-1.5 w-full appearance-none overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800 [&::-moz-progress-bar]:bg-emerald-500 [&::-webkit-progress-bar]:bg-transparent [&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:bg-emerald-500`})}),p&&f!==void 0&&(0,o.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,o.jsx)(f,{item:e,dispatch:t})}),s&&(0,o.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(r.Expanded,{item:e,dispatch:t}),r.showsRawReveal===!0&&(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(!l),className:`text-xs text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-400`,children:l?`hide raw output`:`raw output`}),l&&(0,o.jsx)(`div`,{className:`mt-1`,children:(0,o.jsx)(jk,{item:e})})]})]})]})}function aA({item:e}){let[n,r]=(0,i.useState)(!1),a=e.details!==void 0,s=!!e.contentHtml,c=e.contentHtmlCollapsed??e.contentHtml,l=a||s&&!!e.contentHtmlCollapsed;return(0,o.jsxs)(`div`,{className:`rounded-lg border border-violet-200 bg-violet-50 px-3 py-2 text-sm dark:border-violet-900/60 dark:bg-violet-950/30`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),l&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:n?`▾`:`▸`})]}),s&&c?(0,o.jsx)(De,{html:n||!e.contentHtmlCollapsed?e.contentHtml??c:c,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,o.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,o.jsx)(Tf,{remarkPlugins:[t.n,t.t],rehypePlugins:[cw],children:t.h(e.text)})}),n&&a&&(0,o.jsx)(`pre`,{className:`mt-2 max-h-96 overflow-auto border-t border-violet-200 pt-2 font-mono text-xs text-violet-600 dark:border-violet-900/60 dark:text-violet-400`,children:JSON.stringify(e.details,null,2)})]})}var oA=`pi-outpost:update-notice-dismissed`;function sA(){try{return window.localStorage.getItem(oA)}catch{return null}}function cA({notice:e}){let[t,n]=(0,i.useState)(()=>sA());return t===e.latest?null:(0,o.jsxs)(`div`,{role:`status`,"data-testid":`update-notice`,className:`flex items-center gap-2 border-b border-sky-200 bg-sky-50 px-4 py-1.5 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`pi-outpost `,e.latest,` is available (you have `,e.running,`). `,e.instruction]}),(0,o.jsx)(`code`,{className:`shrink-0 rounded bg-white/70 px-1.5 py-0.5 font-mono dark:bg-sky-900/40`,children:e.copy}),(0,o.jsx)(te,{text:e.copy}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss the update notice`,onClick:()=>{try{window.localStorage.setItem(oA,e.latest)}catch{}n(e.latest)},className:`shrink-0 rounded px-1.5 text-sky-700 hover:bg-sky-100 dark:text-sky-300 dark:hover:bg-sky-900/50`,children:`×`})]})}function lA(e){return e.id??e.root}var uA={cost:0,unpriced:0,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0};function dA(e){let t={...uA};for(let n of e){if(n.kind!==`assistant`||!n.usage)continue;let e=n.usage;t.turns+=1,t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,e.cost===void 0?t.unpriced+=1:t.cost+=e.cost}return t}function fA(e){let t=e>0&&e<.01?4:2;return`$${e.toFixed(t)}`}function pA(e){return e<1e3?String(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}var mA=80,hA=new WeakMap;function gA(e){let t=typeof e==`object`&&!!e;if(t){let t=hA.get(e);if(t!==void 0)return t}let n=0;try{n=JSON.stringify(e)?.length??0}catch{n=0}return t&&hA.set(e,n),n}function _A(e){let t=e.replace(/\s+/g,` `).trim();return t.length>mA?`${t.slice(0,79)}…`:t}function vA(e,t){return{index:e,title:t,turns:0,toolCalls:0,failedToolCalls:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,unpriced:0}}function yA(e,t){e.turns+=1,e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cost===void 0?e.unpriced+=1:e.cost=(e.cost??0)+t.cost}function bA(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function xA(e){let t=[],n=[],r=[],i=new Map,a=vA(-1,``),o=a;e.forEach((e,a)=>{if(e.kind===`user`){o=vA(a,_A(e.text)),r.push(o);return}if(e.kind===`assistant`){if(!e.usage)return;t.push({index:a,number:t.length+1,requestIndex:o.index,usage:e.usage}),yA(o,e.usage);return}if(e.kind!==`tool`)return;let s={index:a,toolCallId:e.toolCallId,name:e.toolName,inputSize:gA(e.args),outputSize:e.output.length,isError:e.isError===!0,running:e.running===!0,requestIndex:o.index};n.push(s),o.toolCalls+=1,s.isError&&(o.failedToolCalls+=1);let c=i.get(s.name)??{name:s.name,calls:0,failures:0,inputSize:0,outputSize:0};c.calls+=1,s.isError&&(c.failures+=1),c.inputSize+=s.inputSize,c.outputSize+=s.outputSize,i.set(s.name,c)}),(a.turns>0||a.toolCalls>0)&&r.unshift(a);let s=dA(e),c=t.map(e=>e.usage.cost).filter(e=>e!==void 0),l=n.filter(e=>e.isError).length;return{turns:t,requests:r,toolCalls:n,tools:[...i.values()],totals:s,pricedTurns:c.length,averageTurnCost:c.length===0?0:s.cost/c.length,medianTurnCost:bA(c),totalToolCalls:n.length,failedToolCalls:l,toolCallsPerTurn:t.length===0?0:n.length/t.length}}function SA(e,t){let n=[...e];return t===`input`?n.sort((e,t)=>t.inputSize-e.inputSize):t===`failure`?n.sort((e,t)=>Number(t.isError)-Number(e.isError)||t.outputSize-e.outputSize):n.sort((e,t)=>t.outputSize-e.outputSize)}function CA(e){return e.filter(e=>e.index>=0).sort((e,t)=>t.totalTokens-e.totalTokens||(t.cost??0)-(e.cost??0))}function wA(e){return e<1e3?`${e} B`:e<1e6?`${Math.round(e/1e3)} kB`:`${(e/1e6).toFixed(1)} MB`}var TA=768,EA=26,DA=132,OA=12,kA=96,AA=124,jA=[{key:`input`,label:`input`,className:`text-emerald-500`,value:e=>e.usage.input},{key:`output`,label:`output`,className:`text-blue-500`,value:e=>e.usage.output},{key:`cacheRead`,label:`cache read`,className:`text-violet-500`,value:e=>e.usage.cacheRead},{key:`cacheWrite`,label:`cache write`,className:`text-amber-500`,value:e=>e.usage.cacheWrite}],MA=[{key:`cost`,label:`cost`,className:`text-rose-500`,value:e=>e.usage.cost??0}];function NA({title:e,children:t}){return(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(0,o.jsx)(`h3`,{className:`mb-2 font-mono text-[11px] uppercase tracking-wide text-zinc-400 dark:text-zinc-500`,children:e}),t]})}function PA({children:e}){return(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})}function FA({label:e,value:t,hint:n}){return(0,o.jsxs)(`div`,{className:`rounded-md border border-zinc-200 px-2 py-1.5 dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{"aria-label":`${e}: ${t}`,className:`font-mono text-sm text-zinc-700 dark:text-zinc-200`,children:t}),(0,o.jsx)(`div`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:e}),n&&(0,o.jsx)(`div`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:n})]})}function IA({turns:e,series:t,format:n,onJump:r,describe:i}){let a=Math.max(1,...e.flatMap(e=>t.map(t=>t.value(e)))),s=Math.max(e.length*EA,EA),c=e=>EA/2+e*EA,l=e=>OA+kA*(1-e/a);return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-x-3 gap-y-1`,children:t.map(e=>(0,o.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-zinc-500 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{className:`inline-block h-0.5 w-3 bg-current ${e.className}`}),e.label]},e.key))}),(0,o.jsxs)(`div`,{className:`flex`,children:[(0,o.jsxs)(`div`,{"aria-hidden":!0,className:`flex w-12 shrink-0 flex-col justify-between py-2 pr-1 text-right font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,style:{height:DA},children:[(0,o.jsx)(`span`,{children:n(a)}),(0,o.jsx)(`span`,{children:`0`})]}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,o.jsxs)(`svg`,{width:s,height:DA,role:`group`,"aria-label":`Per-turn chart`,children:[(0,o.jsx)(`line`,{x1:0,x2:s,y1:108,y2:108,stroke:`currentColor`,className:`text-zinc-200 dark:text-zinc-800`}),t.map(t=>(0,o.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:t.className,points:e.map((e,n)=>`${c(n)},${l(t.value(e))}`).join(` `)},t.key)),e.map((n,a)=>(0,o.jsxs)(`g`,{children:[t.map(e=>(0,o.jsx)(`circle`,{cx:c(a),cy:l(e.value(n)),r:2,fill:`currentColor`,className:e.className},e.key)),(0,o.jsx)(`rect`,{x:c(a)-EA/2,y:0,width:EA,height:DA,fill:`transparent`,role:`button`,tabIndex:0,"aria-label":`Turn ${n.number}: ${i(n)} — jump to it`,className:`cursor-pointer outline-none focus-visible:fill-zinc-500/10`,onClick:()=>r(n.index),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(n.index))},children:(0,o.jsx)(`title`,{children:`turn ${n.number} · ${i(n)}`})}),(e.length<=12||n.number%5==0)&&(0,o.jsx)(`text`,{x:c(a),y:AA,textAnchor:`middle`,className:`fill-zinc-400 text-[9px] dark:fill-zinc-600`,children:n.number})]},n.index))]})})]})]})}function LA({onJump:e,label:t,children:n}){return(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-zinc-100 dark:hover:bg-zinc-900`,children:n})}function RA({analysis:e,onJump:t,onClose:n}){let[r,a]=(0,i.useState)(`output`),{totals:s}=e;function c(e){t(e),window.innerWidth<TA&&n()}let l=e.turns.length===0&&e.toolCalls.length===0,u=SA(e.toolCalls,r),d=CA(e.requests);return(0,o.jsxs)(`aside`,{"aria-label":`Session analysis`,className:`absolute inset-y-0 right-0 z-10 w-full overflow-y-auto border-l border-zinc-200 bg-white shadow-xl md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,o.jsxs)(`header`,{className:`sticky top-0 flex items-center gap-2 border-b border-zinc-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,o.jsx)(`h2`,{className:`font-mono text-xs text-zinc-600 dark:text-zinc-300`,children:`session analysis`}),(0,o.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close session analysis`,className:`ml-auto rounded-md px-2 py-1 text-sm text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-900`,children:`×`})]}),l?(0,o.jsx)(`div`,{className:`px-4 py-6`,children:(0,o.jsx)(PA,{children:`Nothing to analyse yet — no turn has reported figures and no tool has been called.`})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(NA,{title:`tokens`,children:(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`total`,value:pA(s.totalTokens)}),(0,o.jsx)(FA,{label:`fresh input`,value:pA(s.input)}),(0,o.jsx)(FA,{label:`output`,value:pA(s.output)}),(0,o.jsx)(FA,{label:`cache read`,value:pA(s.cacheRead)}),(0,o.jsx)(FA,{label:`cache write`,value:pA(s.cacheWrite)}),(0,o.jsx)(FA,{label:`turns`,value:String(e.turns.length)})]})}),(0,o.jsx)(NA,{title:`cost`,children:e.pricedTurns===0?(0,o.jsx)(PA,{children:`No turn was priced — this provider reports tokens only.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`total`,value:fA(s.cost)}),(0,o.jsx)(FA,{label:`average turn`,value:fA(e.averageTurnCost)}),(0,o.jsx)(FA,{label:`median turn`,value:fA(e.medianTurnCost)})]}),(0,o.jsxs)(`p`,{className:`mt-1 text-[11px] text-zinc-400 dark:text-zinc-500`,children:[`over `,e.pricedTurns,` priced turn`,e.pricedTurns===1?``:`s`,s.unpriced>0&&`, ${s.unpriced} unpriced`]})]})}),(0,o.jsx)(NA,{title:`tool calls`,children:e.totalToolCalls===0?(0,o.jsx)(PA,{children:`No tool call recorded in this session.`}):(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`calls`,value:String(e.totalToolCalls)}),(0,o.jsx)(FA,{label:`per turn`,value:e.toolCallsPerTurn.toFixed(1)}),(0,o.jsx)(FA,{label:`failed`,value:String(e.failedToolCalls)})]})}),(0,o.jsx)(NA,{title:`tokens per turn`,children:e.turns.length===0?(0,o.jsx)(PA,{children:`No turn has reported figures yet.`}):(0,o.jsx)(IA,{turns:e.turns,series:jA,format:pA,onJump:c,describe:e=>`${pA(e.usage.totalTokens)} tokens (input ${e.usage.input}, output ${e.usage.output}, cache read ${e.usage.cacheRead}, cache write ${e.usage.cacheWrite})`})}),(0,o.jsx)(NA,{title:`cost per turn`,children:e.pricedTurns===0?(0,o.jsx)(PA,{children:`No turn was priced, so there is no cost to plot.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(IA,{turns:e.turns.filter(e=>e.usage.cost!==void 0),series:MA,format:fA,onJump:c,describe:e=>fA(e.usage.cost??0)}),s.unpriced>0&&(0,o.jsxs)(`p`,{className:`mt-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[s.unpriced,` unpriced turn`,s.unpriced===1?``:`s`,` left out — they carry no price to plot`]})]})}),(0,o.jsx)(NA,{title:`costliest tool calls`,children:u.length===0?(0,o.jsx)(PA,{children:`No tool call recorded in this session.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,o.jsx)(`label`,{htmlFor:`tool-ranking`,className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`rank by`}),(0,o.jsxs)(`select`,{id:`tool-ranking`,value:r,onChange:e=>a(e.target.value),className:`rounded-md border border-zinc-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300`,children:[(0,o.jsx)(`option`,{value:`output`,children:`output size`}),(0,o.jsx)(`option`,{value:`input`,children:`input size`}),(0,o.jsx)(`option`,{value:`failure`,children:`failure`})]})]}),(0,o.jsx)(`p`,{className:`mb-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:`measured content size, not tokens — a tool call carries no price`}),u.slice(0,10).map(e=>(0,o.jsxs)(LA,{onJump:()=>c(e.index),label:`Jump to the ${e.name} call, output ${wA(e.outputSize)}`,children:[(0,o.jsx)(`span`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:e.name}),e.isError&&(0,o.jsx)(`span`,{className:`text-red-500`,children:`failed`}),e.running&&(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`running`}),(0,o.jsxs)(`span`,{className:`ml-auto font-mono text-zinc-500 dark:text-zinc-400`,children:[`in `,wA(e.inputSize),` · out `,wA(e.outputSize)]})]},e.toolCallId||`${e.index}`))]})}),(0,o.jsx)(NA,{title:`tools`,children:e.tools.length===0?(0,o.jsx)(PA,{children:`No tool has been called yet.`}):(0,o.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{className:`text-left text-[10px] uppercase text-zinc-400 dark:text-zinc-500`,children:[(0,o.jsx)(`th`,{className:`font-normal`,children:`tool`}),(0,o.jsx)(`th`,{className:`font-normal`,children:`calls`}),(0,o.jsx)(`th`,{className:`font-normal`,children:`failed`}),(0,o.jsx)(`th`,{className:`text-right font-normal`,children:`in / out`})]})}),(0,o.jsx)(`tbody`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:[...e.tools].sort((e,t)=>t.outputSize-e.outputSize).map(e=>(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`td`,{children:e.name}),(0,o.jsx)(`td`,{children:e.calls}),(0,o.jsx)(`td`,{className:e.failures>0?`text-red-500`:``,children:e.failures}),(0,o.jsxs)(`td`,{className:`text-right`,children:[wA(e.inputSize),` / `,wA(e.outputSize)]})]},e.name))})]})}),(0,o.jsx)(NA,{title:`costliest requests`,children:d.length===0?(0,o.jsx)(PA,{children:`No request has consumed anything yet.`}):d.slice(0,10).map(e=>(0,o.jsxs)(LA,{onJump:()=>c(e.index),label:`Jump to the request "${e.title}"`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-300`,children:e.title}),(0,o.jsxs)(`span`,{className:`shrink-0 font-mono text-zinc-500 dark:text-zinc-400`,children:[pA(e.totalTokens),` tok`,e.cost!==void 0&&` · ${fA(e.cost)}`]}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e.turns,`t / `,e.toolCalls,`c`,e.failedToolCalls>0&&` · ${e.failedToolCalls}✗`]})]},e.index))})]})]})}var zA=2e3;function BA({items:e,scrollerRef:t,hideTools:n,onShowTools:r,onJump:a}){let[o,s]=(0,i.useState)(null),c=(0,i.useRef)(null),[l,u]=(0,i.useState)(0),d=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,i.useCallback)(t=>{let i=e[t];i&&(i.kind===`tool`&&n&&r(),c.current=t,u(e=>e+1))},[e,n,r]);return(0,i.useEffect)(()=>{let e=c.current;if(e===null)return;c.current=null;let n=t.current?.querySelector(`[data-item-index="${e}"]`);n&&(a(n),n.scrollIntoView?.({behavior:`smooth`,block:`center`}),s(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>s(null),zA))},[l,n,t,a]),{jumpToItem:f,highlightIndex:o}}var VA={tools:`pi-outpost:hide-tools`,reasoning:`pi-outpost:hide-reasoning`},HA=[`tools`,`reasoning`],UA={tools:`Tool calls`,reasoning:`Reasoning`};function WA(e){try{return localStorage.getItem(VA[e])===`1`}catch{return!1}}function GA(){return{tools:!WA(`tools`),reasoning:!WA(`reasoning`)}}function KA(e,t){try{localStorage.setItem(VA[e],t?`0`:`1`)}catch{}}function qA(e){return HA.filter(t=>!e[t]).length}function JA(e,t){let n=null;for(let r of e)(r.repo===``||t===r.repo||t.startsWith(`${r.repo}/`))&&(n===null||r.repo.length>n.repo.length)&&(n=r);return n}var YA=/(?:^|\s)@([^\s@]+)/g,XA=new Set([`,`,`.`,`;`,`:`,`!`,`?`,`)`,`]`]);function ZA(e){let t=e.length;for(;t>0&&XA.has(e[t-1]);)t--;return e.slice(0,t)}function QA(e){return[...e.matchAll(YA)].map(([,e])=>ZA(e??``)).filter(e=>e.length>0)}var $A=`uploads`,ej=class extends Error{reason;constructor(e,t){super(e),this.name=`UploadError`,this.reason=t}};function tj(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result.split(`,`,2)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function nj(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function rj(e){return e.type.startsWith(`image/`)?`image`:e.type===`application/pdf`||n.i(e.name)||n.t(e.name)?`extraction-tool`:e.size<=524288?`inline-text`:oj(e)&&e.size<=26214400?`extraction-tool`:`unsupported`}function ij(e){let t=rj(e);return t===`extraction-tool`||t===`image`&&e.size>7340032}var aj=new Set([`application/json`,`application/xml`,`application/javascript`,`application/x-yaml`,`application/yaml`,`application/sql`]);function oj(e){return e.type.startsWith(`text/`)||aj.has(e.type)}function sj(e){return oj(e)?`${e.name}: file too large to upload (max 25 MB)`:`${e.name}: unsupported file type${e.type?` (${e.type})`:``}`}function cj(e,t){return t instanceof ej?t.reason===`denied`?`${e.name}: cannot upload — the workspace is read-only`:t.reason===`too-large`?`${e.name}: file too large to upload (max 25 MB)`:t.reason===`invalid`?`${e.name}: ${t.message}`:`${e.name}: upload failed — ${t.message}`:`${e.name}: upload failed`}async function lj(e){let t;try{t=await e.text()}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}return t.includes(`\0`)?{attachments:[],errors:[`${e.name}: unsupported binary file`]}:{attachments:[{name:e.name,kind:`text`,data:t,mimeType:e.type||`text/plain`,source:`manual`}],errors:[]}}async function uj(e){try{let t=await tj(e);return{attachments:[{name:e.name,kind:`image`,data:t,mimeType:e.type,source:`manual`}],errors:[]}}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}}async function dj(e,t){if(e.size>26214400)return{attachments:[],errors:[`${e.name}: file too large to upload (max 25 MB)`]};let n;try{n=await tj(e)}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}try{return{attachments:[yj(await t(e.name,n))],errors:[]}}catch(t){return{attachments:[],errors:[cj(e,t)]}}}async function fj(e,t){let n=await Promise.all([...e].map(e=>{let n=rj(e);return n===`unsupported`?Promise.resolve({attachments:[],errors:[sj(e)]}):n===`inline-text`?lj(e):n===`image`&&e.size<=7340032?uj(e):dj(e,t)}));return{attachments:n.flatMap(e=>e.attachments),errors:n.flatMap(e=>e.errors)}}function pj(e){return{...yj(e),source:`preview`,previewPath:e}}function mj(e){return pj(e)}function hj(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}var gj=QA;function _j(e,t){let n=e.trim(),r=e=>{n+=`${n?`
|
|
295
295
|
|
|
296
296
|
`:``}${e}`};for(let e of t)e.kind===`path`?hj(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}async function vj(e,t){try{let n=await fetch(t);if(!n.ok)return`${e}: unable to read preview image for attachment`;let r=n.headers.get(`Content-Type`)?.split(`;`,1)[0]??``;if(!r.startsWith(`image/`))return`${e}: preview is not a supported image attachment`;let i=new Uint8Array(await n.arrayBuffer());return i.byteLength>7340032?`${e}: image too large (max 7 MB)`:{name:e,kind:`image`,data:nj(i),mimeType:r,source:`preview`,previewPath:e}}catch{return`${e}: unable to read preview image for attachment`}}function yj(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function bj(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,yj(t)]}function xj(e,t){return[...e.filter(e=>e.source!==`preview`),t]}function Sj(e,t){return e.filter((e,n)=>n!==t)}function Cj(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function wj(e){let t=(0,i.useRef)(null);return(0,i.useEffect)(()=>{function n(n){t.current&&!Cj(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var Tj=100,Ej=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),Dj={extension:`ext`,prompt:`prompt`,skill:`skill`};function Oj(e){return e===`directory`||e===`symlink-directory`}function kj(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function Aj({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:a,attachments:s,pendingUploads:c=[],onAttach:l,onMentionPaths:u,onRemoveAttachment:d,onSend:f,onAbort:p,onSearchFiles:m,onClearFileSearch:h,initialDraft:g,onDraftChange:_}){let[v,y]=(0,i.useState)(g??``);(0,i.useEffect)(()=>{_?.(v)},[v,_]);let[b,x]=(0,i.useState)(0),[ee,te]=(0,i.useState)(0),[ne,re]=(0,i.useState)(!1),ie=(0,i.useRef)(null),ae=(0,i.useRef)(null),oe=(0,i.useRef)(null),se=(0,i.useRef)(null),ce=(0,i.useRef)(null);(0,i.useEffect)(()=>{a&&y(a.text)},[a?.nonce]),(0,i.useEffect)(()=>{ce.current!==null&&(oe.current?.focus(),oe.current?.setSelectionRange(ce.current,ce.current),ce.current=null)},[v]);let le=(0,i.useMemo)(()=>gj(v),[v]);(0,i.useEffect)(()=>{u(le)},[le.join(`
|
|
297
|
-
`)]);let ue=(0,i.useMemo)(()=>{let e=/^\/(\S*)$/.exec(v);return e?e[1].toLowerCase():null},[v]),de=(0,i.useMemo)(()=>ue===null?[]:n.filter(e=>e.name.toLowerCase().
|
|
297
|
+
`)]);let ue=(0,i.useMemo)(()=>{let e=/^\/(\S*)$/.exec(v);return e?e[1].toLowerCase():null},[v]),de=(0,i.useMemo)(()=>ue===null?[]:n.filter(e=>e.name.toLowerCase().includes(ue)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(ue);return n===t.name.toLowerCase().startsWith(ue)?Ej.compare(e.name,t.name):n?-1:1}).slice(0,Tj),[ue,n]),fe=ue===null?kj(v,b):null;(0,i.useEffect)(()=>{if(!fe||fe.query.length===0){h();return}let e=window.setTimeout(()=>m(fe.query),150);return()=>clearTimeout(e)},[fe?.query]);let pe=(0,i.useMemo)(()=>{if(de.length>0)return{kind:`command`,items:de};let e=fe&&r?.query===fe.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[de,fe,r]),me=pe!==null&&!ne,S=ue===null?fe?`file:${fe.query}`:null:`cmd:${ue}`;(0,i.useEffect)(()=>{te(0)},[S]),(0,i.useEffect)(()=>{re(!1)},[ue===null?fe?`file`:null:`command`]),(0,i.useEffect)(()=>{if(!me)return;let e=e=>{Cj(e,ie.current)||re(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[me]),(0,i.useEffect)(()=>{ae.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[ee]);let he=c.length>0,[ge,_e]=(0,i.useState)(!1);(0,i.useEffect)(()=>{he||_e(!1)},[he]);function ve(){if(he){_e(!0);return}let e=_j(v,s),t=s.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=s.every(e=>e.kind===`path`);!v.trim()&&(n||!e)&&t.length===0||(f(e,t.length>0?t:void 0),y(``),h())}function ye(e){let t=`/${e.name} `;y(t),ce.current=t.length,x(t.length)}function be(e){if(!fe)return;let t=v.slice(0,fe.start),n=v.slice(b),r=`@${e.path}${Oj(e.type)?`/`:` `}`,i=`${t}${r}${n}`;y(i),h();let a=t.length+r.length;ce.current=a,x(a)}function xe(){if(pe){if(pe.kind===`command`){let e=pe.items[ee];e&&ye(e)}else{let e=pe.items[ee];e&&be(e)}}}function Se(e){if(me&&pe){if(e.key===`ArrowDown`){e.preventDefault(),te(e=>(e+1)%pe.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),te(e=>(e-1+pe.items.length)%pe.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),xe();return}if(e.key===`Escape`){e.preventDefault(),re(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ve())}function Ce(e){x(e.currentTarget.selectionStart??0)}function we(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),l(t))}return(0,o.jsxs)(`div`,{ref:ie,className:`relative`,children:[(s.length>0||he)&&(0,o.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[c.map(e=>(0,o.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),ge&&(0,o.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),s.map((e,t)=>(0,o.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,o.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>d(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),me&&pe&&(0,o.jsx)(`div`,{ref:ae,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:pe.kind===`command`?pe.items.map((e,t)=>(0,o.jsxs)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>ye(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,o.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,o.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:Dj[e.source]})]},e.name)):pe.items.map((e,t)=>(0,o.jsx)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>be(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,Oj(e.type)?`/`:``]})},e.path))}),(0,o.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,o.jsx)(`textarea`,{ref:oe,value:v,onChange:e=>{y(e.target.value),x(e.target.selectionStart??e.target.value.length)},onKeyDown:Se,onClick:Ce,onKeyUp:Ce,onPaste:we,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:Math.min(6,Math.max(1,v.split(`
|
|
298
298
|
`).length)),className:`flex-1 resize-none bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,o.jsx)(`button`,{type:`button`,onClick:p,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>se.current?.click(),disabled:!t,title:`attach files`,"aria-label":`Attach files`,className:`rounded-lg p-2 text-zinc-500 hover:bg-zinc-200 hover:text-zinc-700 disabled:opacity-30 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,o.jsx)(`input`,{ref:se,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&l(Array.from(e.target.files)),e.target.value=``}}),(0,o.jsx)(`button`,{type:`button`,onClick:ve,disabled:!t||he||!v.trim()&&s.length===0,title:he?`waiting for an attachment to finish uploading`:e?`steer`:`send`,"aria-label":e?`Steer the agent`:`Send message`,className:`rounded-lg bg-zinc-900 p-2 text-zinc-100 hover:bg-zinc-800 disabled:opacity-30 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:e?(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,o.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,o.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var jj=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 dark:border-zinc-800 dark:hover:bg-zinc-800`,Mj=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,Nj=`w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`,Pj=`mb-4 ${Nj}`,Fj=`1,3`,Ij=` — `;function Lj(e){let t=e.indexOf(`
|
|
299
299
|
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function Rj(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(Ij);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function zj(e){if(e.method!==`input`||e.placeholder!==Fj)return null;let{heading:t,body:n}=Lj(e.title),r=[];for(let e of n.split(`
|
|
300
300
|
`)){let t=Rj(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function Bj({request:e,onRespond:t}){let[n,r]=(0,i.useState)(e.method===`editor`?e.prefill??``:``),[a,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!1),u=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[d,f]=(0,i.useState)(u?Math.ceil(u/1e3):null),p=zj(e),{heading:m,body:h}=Lj(e.title);function g(){t({id:e.id,cancelled:!0})}function _(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function v(){let r=n.trim();t({id:e.id,value:r.length>0?r:a.join(`,`)})}return(0,i.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),400);return()=>clearTimeout(e)},[c]),(0,i.useEffect)(()=>{if(d===null)return;if(d<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>f(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[d,e.id,t]),(0,o.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>l(!0),children:(0,o.jsxs)(`div`,{className:`w-full ${h?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${c?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,o.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),h&&!p&&(0,o.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:h}),e.method===`select`&&(0,o.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=Rj(n);return(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${jj}`,children:r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:jj,children:`No`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:Mj,children:`Yes`})]})]}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:p.options.map(e=>(0,o.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>_(e.index),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,o.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&g()},className:`mb-1 ${Nj}`}),(0,o.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:v,className:Mj,children:`OK`})]})]}),e.method===`input`&&!p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&g()},className:Pj}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),e.method===`editor`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&g()},className:`resize-none font-mono ${Pj}`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),d!==null&&(0,o.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,d,`s`]})]})})}var Vj={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},Hj=6e3;function Uj({notification:e,onDismiss:t}){let n=(0,i.useRef)(t);return(0,i.useEffect)(()=>{n.current=t}),(0,i.useEffect)(()=>{let e=setTimeout(()=>n.current(),Hj);return()=>clearTimeout(e)},[e.id]),(0,o.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${Vj[e.notifyType??`info`]}`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function Wj({notifications:e,onDismiss:t}){return e.length===0?null:(0,o.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,o.jsx)(Uj,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var Gj={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},Kj=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function qj(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(Gj[r]!==void 0)n.color=Gj[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function Jj(e){let t=[],n={},r=0;Kj.lastIndex=0;for(let i=Kj.exec(e);i!==null;i=Kj.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=qj(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function Yj(e){return e.replace(Kj,``)}function Xj({line:e}){let t=Jj(e);return(0,o.jsx)(o.Fragment,{children:t.map((e,t)=>(0,o.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function Zj({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,o.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,o.jsx)(`div`,{children:(0,o.jsx)(Xj,{line:e})},t))},e))})}function Qj({text:e,path:t,serverUrl:n,token:r}){let[a,s]=(0,i.useState)(`idle`),[c,l]=(0,i.useState)(null),u=(0,i.useRef)(!1),d=(0,i.useRef)(0);async function f(){if(!(u.current||Date.now()-d.current<750)){u.current=!0,d.current=Date.now(),s(`working`),l(null);try{let{downloadDocx:i}=await Promise.resolve().then(()=>require("./docxExport-DKx7m8Wz.cjs"));await i(e,t,{serverUrl:n,token:r}),s(`idle`)}catch(e){s(`failed`),l(e instanceof Error?e.message:String(e))}finally{u.current=!1}}}return(0,o.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:a===`working`,title:a===`failed`?`Could not export: ${c??`unknown reason`}`:`Download as a Word document`,"aria-label":`Download as a Word document`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:a===`working`?`… exporting`:a===`failed`?`⚠ export failed`:`⤓ word`})}function $j({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:a,searching:s=!1,onNext:c,onPrev:l,onClose:u,inputRef:d}){let f=(0,i.useRef)(null),p=d??f;(0,i.useEffect)(()=>{p.current?.focus(),p.current?.select()},[]);let m=n===0?s?`searching…`:`0/0`:`${a+1}/${n}${r?`+`:``}`;return(0,o.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,o.jsx)(`input`,{ref:p,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?l():c()):e.key===`Escape`&&(e.stopPropagation(),u())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,o.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:l,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,o.jsx)(`button`,{type:`button`,onClick:c,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,o.jsx)(`button`,{type:`button`,onClick:u,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var eM=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./PdfViewer-DJJoRd17.cjs"))),tM=250,nM=`(min-width: 768px)`;function rM(){let[e,t]=(0,i.useState)(()=>window.matchMedia?.(nM).matches??!0);return(0,i.useEffect)(()=>{let e=window.matchMedia?.(nM);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function iM(e,t){let[n,r]=(0,i.useState)(e);return(0,i.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function aM(e){let t=mc(e);return t.status===`valid`?t.envelope:void 0}function oM(e){return/\.(md|markdown)$/i.test(e)}function sM(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function cM({file:e,writableRoot:a,isStreaming:s,onDirtyChange:c,gitState:l,initialShowGitDiff:u=!1,gitDiff:d,onFetchGitDiff:f,onClearGitDiff:p,inRepository:m,onOpenGitHistory:h,onClose:g,onReload:v,onSave:y,serverUrl:b=``,token:x=null,onImageLoad:ee,onPdfLoad:ne,rawRevision:re=0}){let[ie,ae]=(0,i.useState)(`rendered`),[oe,ce]=(0,i.useState)(u),[le,ue]=(0,i.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[de,fe]=(0,i.useState)(`idle`),pe=(0,i.useRef)(null),me=(0,i.useRef)(null),S=e.status===`loaded`?e:null,he=S!==null&&oM(e.path),ge=n.r(e.path),_e=n.i(e.path),ve=(0,i.useMemo)(()=>S===null?void 0:mc(S.content),[S?.content]),ye=ve?.status===`valid`,be=ve?.status===`valid`||ve?.status===`invalid`,xe=be||he,Se=ie===`source`,Ce=rM(),we=sM(e.path,a)&&!_e,Ee=le!==null&&le.draft!==le.baseContent,De=S?.pendingSave!==void 0,ke=le!==null&&S!==null&&S.mtimeMs!==le.baseMtimeMs,Ae=S?.saveError?.conflict===!0||ke,je=le?.draft??S?.content??``,Me=iM(je,tM),Ne=(0,i.useMemo)(()=>S===null?void 0:mc(Me),[Me,S===null]),[Pe,Fe]=(0,i.useState)(()=>e.status===`loaded`?aM(e.content):void 0);(0,i.useEffect)(()=>{Ne?.status===`valid`&&Fe(Ne.envelope)},[Ne]);let Ie=Ne!==void 0&&Ne.status!==`valid`&&Pe!==void 0,Le=Ne?.status===`invalid`?Me===S?.content&&S.documentIssues!==void 0?S.documentIssues:Ne.issues:void 0,Re=Ne?.status===`not-a-document`?Ne.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ne?.status===`unsupported-version`?`This declares ${Ne.schema}, which this version does not render.`:void 0,ze=ie===`split`&&xe&&!oe&&S!==null&&Ce,Be=oe||ze?`none`:_e?`pdf`:le===null?S!==null&&!ge?`dom`:`none`:`edit`,[Ve,He]=(0,i.useState)(!1),[Ue,We]=(0,i.useState)(``),[Ge,Ke]=(0,i.useState)(0),qe=(0,i.useRef)(null),Je=(0,i.useRef)(null),Ye=(0,i.useRef)(null),[Xe,Ze]=(0,i.useState)({matchCount:0,currentIndex:-1,searching:!1}),[Qe,$e]=(0,i.useState)([]),[et,tt]=(0,i.useState)(!1),nt=(0,i.useRef)(null),rt=(0,i.useRef)([]),it=(0,i.useRef)(0),at=(0,i.useRef)(``);function ot(e){it.current=e;for(let[t,n]of rt.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=rt.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let st=Ve?Ue:``,ct=(0,i.useMemo)(()=>Be===`edit`?r.t(je,st):[],[Be,je,st]);(0,i.useEffect)(()=>{Ve&&Be===`none`&&He(!1)},[Ve,Be]);let[lt,ut]=(0,i.useState)(0),dt=(0,i.useCallback)(()=>ut(e=>e+1),[]);(0,i.useEffect)(()=>{function e(){nt.current?.clear(),nt.current=null,rt.current=[],$e([]),tt(!1)}let t=Je.current;if(Be!==`dom`||st===``||t===null){e();return}nt.current?.clear();let n=r.n(t,st);nt.current=n,rt.current=n.matches,$e(n.matches),tt(n.truncated);let i=st!==at.current;at.current=st;let a=i?0:Math.min(it.current,Math.max(n.matches.length-1,0));return Ke(a),ot(a),e},[Be,st,ie,Se,lt]);function ft(e,t){let n=e[t],r=pe.current;n!==void 0&&r!==null&&(r.focus(),r.setSelectionRange(n.start,n.end),qe.current?.focus())}(0,i.useEffect)(()=>{if(Be!==`edit`||!Ve)return;let e=r.t(je,st);Ke(0),e.length>0&&ft(e,0)},[st,Be,Ve]);function pt(){He(!0)}function mt(){He(!1)}function ht(){if(Be===`pdf`)Ye.current?.findNext();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge+1)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current+1)%e;Ke(t),ot(t)}}function gt(){if(Be===`pdf`)Ye.current?.findPrevious();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge-1+ct.length)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current-1+e)%e;Ke(t),ot(t)}}let _t=Be===`pdf`?{matchCount:Xe.matchCount,currentIndex:Xe.currentIndex,truncated:!1,searching:Xe.searching}:Be===`edit`?{matchCount:ct.length,currentIndex:ct.length>0?Math.min(Ge,ct.length-1):-1,truncated:!1,searching:!1}:{matchCount:Qe.length,currentIndex:Qe.length>0?Math.min(Ge,Qe.length-1):-1,truncated:et,searching:!1},vt=le===null?null:(0,o.jsx)(`textarea`,{ref:pe,value:le.draft,onChange:e=>ue({...le,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),Ee&&!De&&!Ae&&Ct())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function yt(r){return(0,o.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,o.jsx)(Tf,{remarkPlugins:[t.n,t.t],rehypePlugins:[cw],components:{pre:Te,a:({href:t,children:r,...i})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,o.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...i,children:r}):t.startsWith(`#`)?(0,o.jsx)(`a`,{href:t,...i,children:r}):(0,o.jsx)(`a`,{href:t,onClick:r=>{r.preventDefault(),v(n.o(e.path,t))},...i,children:r}),img:({src:t,alt:r,...i})=>{let a=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?n.a(b,n.o(e.path,t),x):t;return(0,o.jsx)(`img`,{...i,src:a,alt:r??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:t.h(r)})})}function bt(e){ie===`split`&&e!==`split`&&Ee&&!window.confirm(`Discard unsaved changes?`)||(ie===`split`&&e!==`split`&&ue(null),ae(e))}function xt(){Ee&&!window.confirm(`Discard unsaved changes?`)||g()}function St(){S&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})}function Ct(t=!1){!S||le===null||De||(me.current=le.draft,y(e.path,le.draft,le.baseMtimeMs,t))}function wt(){ue(null),v(e.path)}function Tt(){let t=!oe;ce(t),t?f(e.path):p()}return(0,i.useEffect)(()=>{if(le!==null&&S!==null&&me.current!==null&&S.content===me.current&&S.mtimeMs!==le.baseMtimeMs){let e=me.current;me.current=null,le.draft===e?ue(null):ue({...le,baseContent:S.content,baseMtimeMs:S.mtimeMs})}},[S?.mtimeMs]),(0,i.useEffect)(()=>{function e(e){if(e.key===`Escape`){Ve?mt():xt();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Be===`none`)return;e.preventDefault(),pt()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,i.useEffect)(()=>{ze&&we&&le===null&&S!==null&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})},[ze,we,S?.mtimeMs]),(0,i.useEffect)(()=>{fe(s?`streaming`:e=>e===`streaming`?`done`:e)},[s]),(0,i.useEffect)(()=>(c(Ee),()=>c(!1)),[Ee]),(0,i.useEffect)(()=>(u&&f(e.path),()=>p()),[]),(0,o.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[xe&&!oe&&(0,o.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,o.jsx)(`button`,{type:`button`,onClick:()=>bt(e),"aria-pressed":ie===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${ie===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),l!==void 0&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:Tt,"aria-pressed":oe,title:oe?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${oe?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),m&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Ee&&(0,o.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),S&&!ge&&!_e&&!oe&&(0,o.jsx)(Qj,{text:je,path:e.path,serverUrl:b,token:x}),S&&le===null&&(0,o.jsx)(te,{text:S.content}),S&&le===null&&!oe&&we&&(0,o.jsx)(`button`,{type:`button`,onClick:St,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),S&&le===null&&!we&&(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),le!==null&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(),disabled:!Ee||De||Ae,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:De?`saving…`:`save`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{Ee&&!window.confirm(`Discard unsaved changes?`)||ue(ze&&S!==null?{draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs}:null)},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,o.jsx)(`button`,{type:`button`,onClick:xt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Ve&&Be!==`none`&&(0,o.jsx)($j,{inputRef:qe,query:Ue,onQueryChange:We,matchCount:_t.matchCount,currentIndex:_t.currentIndex,truncated:_t.truncated,searching:_t.searching,onNext:ht,onPrev:gt,onClose:mt}),Ae&&le!==null&&(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,o.jsx)(`button`,{type:`button`,onClick:wt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(!0),disabled:De,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),le!==null&&S?.saveError&&!S.saveError.conflict&&(0,o.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:S.saveError.message}),(0,o.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[oe&&le===null&&(0,o.jsxs)(`div`,{className:`p-4`,children:[d?.path===e.path&&`error`in d&&(0,o.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:d.error}),d?.path===e.path&&`before`in d&&(0,o.jsx)(Oe,{fill:!0,lines:_(d.before,d.after)}),d?.path!==e.path&&(0,o.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),_e&&le===null&&!oe&&(0,o.jsx)(Il,{label:`This PDF`,children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,o.jsx)(eM,{ref:Ye,path:e.path,serverUrl:b,token:x,revision:re,findQuery:Be===`pdf`?st:``,onFindStateChange:Ze,...ne?{onLoaded:ne}:{}})})}),ge&&le===null&&!oe&&(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,o.jsx)(`img`,{src:n.a(b,e.path,x,re),alt:e.path,onLoad:()=>ee(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&le===null&&!oe&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),le!==null&&!ze&&vt,S&&le===null&&!ze&&!oe&&he&&!Se&&(0,o.jsx)(`div`,{ref:Je,children:yt(S.content)}),ze&&(0,o.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:vt??(0,o.jsx)(`div`,{className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path})})}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:he&&!be?(0,o.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:yt(Me)}):(0,o.jsxs)(o.Fragment,{children:[Ie&&(0,o.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,o.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Re??`The text beside it does not satisfy the schema it declares.`]})}),Le!==void 0&&(0,o.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Le.slice(0,6).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Le.length>6&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Le.length-6,` more`]})]}),Pe===void 0?(0,o.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Re??`This document does not satisfy the schema it declares.`]}):(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:Pe,source:je})})})]})})]}),S&&le===null&&!ze&&!oe&&ye&&!Se&&ve?.status===`valid`&&(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:ve.envelope,source:S.content})})}),S&&le===null&&!ze&&!oe&&ve?.status===`invalid`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,o.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,o.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(S.documentIssues??ve.issues).slice(0,8).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(S.documentIssues??ve.issues).length>8&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(S.documentIssues??ve.issues).length-8,` more`]})]})]}),S&&le===null&&!ze&&!oe&&ve?.status===`unsupported-version`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,o.jsx)(`span`,{className:`font-mono`,children:ve.schema}),`, which this version does not render. Shown as text.`]}),S&&le===null&&!ze&&!oe&&(!he||Se)&&(!ye||Se)&&(0,o.jsx)(`div`,{ref:Je,className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path,onRendered:dt})})]}),de!==`idle`&&(0,o.jsxs)(`button`,{type:`button`,onClick:xt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[de===`streaming`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,o.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,o.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function lM(e){return e.split(`
|
package/dist/pi-outpost-embed.js
CHANGED
|
@@ -42835,7 +42835,10 @@ function hM({ isStreaming: e, connected: t, commands: n, fileSearch: r, prefill:
|
|
|
42835
42835
|
let ue = _e(() => {
|
|
42836
42836
|
let e = /^\/(\S*)$/.exec(g);
|
|
42837
42837
|
return e ? e[1].toLowerCase() : null;
|
|
42838
|
-
}, [g]), de = _e(() => ue === null ? [] : n.filter((e) => e.name.toLowerCase().
|
|
42838
|
+
}, [g]), de = _e(() => ue === null ? [] : n.filter((e) => e.name.toLowerCase().includes(ue)).sort((e, t) => {
|
|
42839
|
+
let n = e.name.toLowerCase().startsWith(ue);
|
|
42840
|
+
return n === t.name.toLowerCase().startsWith(ue) ? dM.compare(e.name, t.name) : n ? -1 : 1;
|
|
42841
|
+
}).slice(0, uM), [ue, n]), fe = ue === null ? mM(g, v) : null;
|
|
42839
42842
|
x(() => {
|
|
42840
42843
|
if (!fe || fe.query.length === 0) {
|
|
42841
42844
|
p();
|