blade-code 0.10.26 → 0.10.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-s1khjfye.js → chunk-00ta2sme.js} +2 -2
- package/dist/{chunk-5mtryjjc.js → chunk-0vsaphkr.js} +1 -1
- package/dist/{chunk-zs9mwd17.js → chunk-14hspehn.js} +3 -3
- package/dist/{chunk-46yg6dfr.js → chunk-17k72zar.js} +2 -2
- package/dist/{chunk-1hzj6s0f.js → chunk-18ck4nnw.js} +2 -2
- package/dist/{chunk-jt55ct49.js → chunk-1c4j6q7j.js} +2 -2
- package/dist/{chunk-acf5v2fv.js → chunk-1pjvzcrj.js} +2 -2
- package/dist/{chunk-y2en7qvs.js → chunk-1thq2kns.js} +2 -2
- package/dist/{chunk-58yqrbey.js → chunk-1zsz19bn.js} +1 -1
- package/dist/chunk-2rdk9rzv.js +1 -0
- package/dist/{chunk-r46ws0q8.js → chunk-39yvdt2g.js} +2 -2
- package/dist/chunk-4qk4v6aw.js +1 -0
- package/dist/{chunk-a4cyec1y.js → chunk-5wemkcp3.js} +2 -2
- package/dist/{chunk-p6nhdbdw.js → chunk-600hfjag.js} +2 -2
- package/dist/{chunk-tnrrnzzv.js → chunk-76fnqb4r.js} +1 -1
- package/dist/{chunk-gn37wxwg.js → chunk-77y8cb2q.js} +1 -1
- package/dist/chunk-7kfnsts1.js +1 -0
- package/dist/{chunk-5yr2c8gz.js → chunk-7v0w3625.js} +4 -4
- package/dist/{chunk-6k74z0eb.js → chunk-99h83wjf.js} +2 -2
- package/dist/{chunk-px3t1rxa.js → chunk-9reqa9g1.js} +2 -2
- package/dist/chunk-a09g8k55.js +204 -0
- package/dist/chunk-awz9bn56.js +1 -0
- package/dist/{chunk-6axhk4r7.js → chunk-b9akah7k.js} +1 -1
- package/dist/{chunk-35d5gdgw.js → chunk-bmxzx4xg.js} +1 -1
- package/dist/chunk-cpk6vwyh.js +1 -0
- package/dist/{chunk-0q4jbbm5.js → chunk-cx5daedg.js} +1 -1
- package/dist/{chunk-6srz3q5d.js → chunk-czs2rxyr.js} +1 -1
- package/dist/{chunk-8htfb5zn.js → chunk-d893y03w.js} +2 -2
- package/dist/{chunk-4aem0m2n.js → chunk-dyf9jrds.js} +1 -1
- package/dist/{chunk-ebffhjma.js → chunk-e1r2zqv3.js} +2 -2
- package/dist/{chunk-nt6xmzk0.js → chunk-eeg6jn2c.js} +1 -1
- package/dist/{chunk-89gswfb2.js → chunk-emwawshv.js} +1 -1
- package/dist/{chunk-pja0tttq.js → chunk-erwmqhkw.js} +1 -1
- package/dist/{chunk-1g5h4zv6.js → chunk-ezarz0ye.js} +1 -1
- package/dist/chunk-fgczbyhy.js +1 -0
- package/dist/chunk-g11e47n1.js +1 -0
- package/dist/{chunk-tg1mf1tf.js → chunk-gwxwpwqk.js} +6 -6
- package/dist/{chunk-fnt1z0y8.js → chunk-h79p49hc.js} +1 -1
- package/dist/chunk-hszqdsn3.js +1 -0
- package/dist/{chunk-aa28p37g.js → chunk-hxb7wg07.js} +1 -1
- package/dist/{chunk-9ka0bdry.js → chunk-j4gvwm9w.js} +1 -1
- package/dist/{chunk-7jv8thn1.js → chunk-jvg2vnc3.js} +2 -2
- package/dist/{chunk-rth3jfdq.js → chunk-k6gsac91.js} +1 -1
- package/dist/{chunk-20kg90zt.js → chunk-kahzw9qn.js} +46 -46
- package/dist/chunk-kbpg9amg.js +100 -0
- package/dist/{chunk-xp44jtsd.js → chunk-kvgrg5p2.js} +1 -1
- package/dist/{chunk-b5fegjt7.js → chunk-m6crkryd.js} +4 -4
- package/dist/chunk-pvf84eht.js +1 -0
- package/dist/{chunk-kskg7crs.js → chunk-q24xmkqy.js} +2 -2
- package/dist/{chunk-vp50e95n.js → chunk-rtct70pm.js} +3 -3
- package/dist/chunk-rvz8yka7.js +1 -0
- package/dist/{chunk-kvd5nexw.js → chunk-sp1j3ng5.js} +1 -1
- package/dist/chunk-t3hahveb.js +1 -0
- package/dist/{chunk-edyxa2jw.js → chunk-v1kac601.js} +1 -1
- package/dist/{chunk-ct2x59pr.js → chunk-v874kevz.js} +2 -2
- package/dist/chunk-wa33kkb2.js +1 -0
- package/dist/chunk-wawmjv8r.js +10 -0
- package/dist/chunk-wzxkfpec.js +2 -0
- package/dist/chunk-xg9fzft1.js +1 -0
- package/dist/{chunk-eqa706gn.js → chunk-y0c3knp9.js} +2 -2
- package/dist/{chunk-m7x4ya6m.js → chunk-y2ra5akr.js} +1 -1
- package/dist/{chunk-rgafk34p.js → chunk-y4fj9way.js} +1 -1
- package/dist/chunk-yc8rrjsr.js +1 -0
- package/dist/{chunk-fbc5zfq7.js → chunk-yh81njxg.js} +1 -1
- package/dist/{chunk-k99rbzqw.js → chunk-ymgnh4an.js} +1 -1
- package/dist/{chunk-rtktz9v1.js → chunk-z2kfx8g0.js} +263 -263
- package/dist/{chunk-sprjrvn6.js → chunk-z3kc23wz.js} +1 -1
- package/dist/{chunk-58tpe6nx.js → chunk-z4d3t2bb.js} +2 -2
- package/dist/web/assets/{ChatView-Crna6-ID.js → ChatView-B4Le8nGL.js} +7 -7
- package/dist/web/assets/{CodeBlockHighlighter-coWjWCyT.js → CodeBlockHighlighter-B8-o1K2L.js} +1 -1
- package/dist/web/assets/{FilePreview-BKcCbpvz.js → FilePreview-BvUxzULZ.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BqV1nvf1.js → MarkdownRenderer-C-X3g9Ky.js} +3 -3
- package/dist/web/assets/{SettingsModal-BOMswk9P.js → SettingsModal-Dhjw1__j.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-BEW2DhW3.js → TaskSwitcher-BAHVGLmL.js} +1 -1
- package/dist/web/assets/{TerminalPanel-BXzypTz6.js → TerminalPanel-D3cC-lXf.js} +1 -1
- package/dist/web/assets/{index-DqXKkjcp.js → index-D88fYWls.js} +4 -4
- package/dist/web/assets/{session-events-K_9Lexp8.js → session-events-BoJrjSZ2.js} +2 -2
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-01n8k1jj.js +0 -1
- package/dist/chunk-1mh2285d.js +0 -200
- package/dist/chunk-bbjtt28z.js +0 -1
- package/dist/chunk-d9jz1edf.js +0 -100
- package/dist/chunk-dxgzyy09.js +0 -1
- package/dist/chunk-f88wkyfm.js +0 -1
- package/dist/chunk-fkwqgqsw.js +0 -1
- package/dist/chunk-gahvpbbs.js +0 -1
- package/dist/chunk-h2npwqz9.js +0 -10
- package/dist/chunk-kwe0a3xw.js +0 -1
- package/dist/chunk-mqsxghqb.js +0 -1
- package/dist/chunk-nar8qz5t.js +0 -1
- package/dist/chunk-pyfag66h.js +0 -1
- package/dist/chunk-q1papzdc.js +0 -1
- package/dist/chunk-ss449b56.js +0 -1
- package/dist/chunk-vc2c8wkx.js +0 -2
- package/dist/chunk-wg8p9g0z.js +0 -1
- package/dist/chunk-xkb48pvz.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as a}from"node:module";var c=a(import.meta.url);
|
|
2
|
-
export{c as
|
|
2
|
+
export{c as $f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{gf as En,hf as j,if as T}from"./chunk-j4gvwm9w.js";import{mf as On,nf as Zn}from"./chunk-wzxkfpec.js";import{sf as L}from"./chunk-sp1j3ng5.js";import{wf as $n}from"./chunk-d893y03w.js";import{Cf as p,zf as rt}from"./chunk-1c4j6q7j.js";import{Kf as sn,Lf as wn}from"./chunk-1pjvzcrj.js";import{Pf as $}from"./chunk-39yvdt2g.js";import{Zf as Sn}from"./chunk-00ta2sme.js";var et=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function St(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function B(n,t="MCP OAuth URL"){let M=new URL(n);if(M.username||M.password)throw Error(`${t} must not contain credentials`);if(M.protocol!=="https:"&&!(M.protocol==="http:"&&St(M.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return M}var U=async(n,t)=>{B(n,"MCP OAuth request URL");let M=await fetch(n,{...t,redirect:"manual"});if(M.status>=300&&M.status<400)throw await M.body?.cancel(),Error("MCP OAuth network requests must not follow redirects");return M};function y(n){let t=n.oauth;if(!t)return;let M=t;for(let S of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(M[S]!==void 0)throw Error(`MCP OAuth "${S}" is not supported; use standards-based discovery`);if(t.enabled!==!0)return{enabled:!1};if(n.type!=="http"&&n.type!=="sse")throw Error("MCP OAuth is supported only for HTTP and SSE transports");if(!n.url)throw Error("MCP OAuth requires an MCP server URL");if(B(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((S)=>S.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let _=t.clientId?.trim();if(_&&_.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let e=t.scopes?.map((S)=>S.trim());if(e){if(e.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(e.some((S)=>!S||S.length>128||!et.test(S)))throw Error("MCP OAuth scopes contain an invalid value");if(new Set(e).size!==e.length)throw Error("MCP OAuth scopes must not contain duplicates")}let r=t.callbackPort;if(r!==void 0&&(!Number.isInteger(r)||r<1024||r>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,..._?{clientId:_}:{},...e?.length?{scopes:e}:{},...r!==void 0?{callbackPort:r}:{}}}import{randomUUID as l}from"node:crypto";import xt from"node:http";import{auth as Tn}from"@modelcontextprotocol/sdk/client/auth.js";import $t from"open";import{createHash as Et,randomUUID as mt}from"node:crypto";import{constants as D,promises as P}from"node:fs";import W from"node:path";import{Mutex as At}from"async-mutex";import Tt from"write-file-atomic";var mn=1,bt=1048576,ct=5000,ot=50,st=/^[a-f0-9]{64}$/,wt=T.Object({client_id:T.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),Lt=T.Object({access_token:T.String({minLength:1,maxLength:65536}),token_type:T.String({minLength:1,maxLength:64}),expires_in:T.Optional(T.Number({minimum:0})),refresh_token:T.Optional(T.String({minLength:1,maxLength:65536})),scope:T.Optional(T.String({maxLength:16384})),id_token:T.Optional(T.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),ft=T.Unsafe({type:"object",properties:{authorizationServerUrl:T.String({format:"uri"}),resourceMetadataUrl:T.Optional(T.String({format:"uri"})),resourceMetadata:T.Optional(T.Unknown()),authorizationServerMetadata:T.Optional(T.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),An=T.Object({serverUrl:T.String({format:"uri"}),clientId:T.Optional(T.String({minLength:1,maxLength:4096})),clientInformation:T.Optional(wt),tokens:T.Optional(Lt),tokenExpiresAt:T.Optional(T.Number({minimum:0})),discoveryState:T.Optional(ft),updatedAt:T.String({format:"date-time"})},{additionalProperties:!1}),rn=T.Object({version:T.Literal(mn),credentials:T.Record(T.String(),An)},{additionalProperties:!1});function q(n,t){return n instanceof Error&&"code"in n&&n.code===t}function Pt(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return q(t,"EPERM")}}function k(n){return structuredClone(n)}function en(n){if(Object.keys(n.credentials).some((t)=>!st.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function G(n){let t=new URL(n);return t.hash="",t.toString()}function F(n,t,M=[]){return Et("sha256").update(JSON.stringify({serverUrl:G(n),clientId:t?.trim()||null,scopes:[...M].sort()})).digest("hex")}class I{static mutexes=new Map;stateRoot;tokenFilePath;mutex;constructor(n=Sn()){this.stateRoot=W.join(n,"mcp"),this.tokenFilePath=W.join(this.stateRoot,"oauth-credentials.json");let t=I.mutexes.get(this.tokenFilePath);if(!t)t=new At,I.mutexes.set(this.tokenFilePath,t);this.mutex=t}async getCredential(n){return this.mutex.runExclusive(async()=>{let M=(await this.readStore()).credentials[n];return M?k(M):null})}async updateCredential(n,t){return this.runMutation(async(M)=>{let u=M.credentials[n],_=await t(u?k(u):null);if(_)M.credentials[n]=j(An,_);else delete M.credentials[n];return _?k(M.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return this.mutex.runExclusive(async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return this.mutex.runExclusive(async()=>{let t=await this.acquireStoreLock();try{let M=await this.readStore(),u=await n(M);return await this.writeStore(M),u}finally{await t()}})}async ensureStateRoot(){await P.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await P.lstat(this.stateRoot);if(!n.isDirectory()||n.isSymbolicLink())throw Error("MCP OAuth credential root must be a regular directory");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential root must be owned by the current user");if((n.mode&63)!==0)throw Error("MCP OAuth credential root permissions must not allow group access")}async readStore(){try{let n=await P.lstat(this.tokenFilePath);if(!n.isFile()||n.isSymbolicLink())throw Error("MCP OAuth credential store must be a regular file");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential store must be owned by the current user");if((n.mode&511)!==384)throw Error("MCP OAuth credential store permissions must be 0600");if(n.size>bt)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await P.readFile(this.tokenFilePath,"utf8")),M=En(rn,t);if(!M.success)throw Error("MCP OAuth credential store has an invalid schema");return en(M.data),M.data}catch(n){if(q(n,"ENOENT"))return{version:mn,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=j(rn,n);en(t),await Tt(this.tokenFilePath,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,{mode:384,encoding:"utf8"}),await P.chmod(this.tokenFilePath,384)}async acquireStoreLock(){await this.ensureStateRoot();let n=W.join(this.stateRoot,".oauth-credentials.lock"),t=mt(),M=Date.now()+ct;while(Date.now()<M)try{let u=await P.open(n,D.O_CREAT|D.O_EXCL|D.O_WRONLY,384);return await u.writeFile(`${JSON.stringify({version:1,pid:process.pid,token:t,createdAt:new Date().toISOString()})}
|
|
3
3
|
`,"utf8"),await u.close(),async()=>{try{if(JSON.parse(await P.readFile(n,"utf8")).token===t)await P.unlink(n)}catch(_){if(!q(_,"ENOENT"))throw _}}}catch(u){if(!q(u,"EEXIST"))throw u;await this.removeDeadLock(n),await new Promise((_)=>setTimeout(_,ot))}throw Error("MCP OAuth credential store is busy; retry the operation")}async removeDeadLock(n){let t=await P.lstat(n);if(!t.isFile()||t.isSymbolicLink())throw Error("MCP OAuth credential lock must be a regular file");if(process.getuid&&t.uid!==process.getuid()||(t.mode&511)!==384)throw Error("MCP OAuth credential lock ownership or permissions are invalid");let M=JSON.parse(await P.readFile(n,"utf8"));if(typeof M.pid!=="number"||!Number.isInteger(M.pid)||M.pid<=0)throw Error("MCP OAuth credential lock owner is invalid");if(!Pt(M.pid))await P.unlink(n)}}var bn="127.0.0.1",cn=7777,on="/oauth/callback",dt=300000;class v extends Error{constructor(n){super(`MCP server "${n}" requires OAuth authorization; run "blade mcp login ${n}" or use the Web MCP panel`);this.name="McpOAuthAuthorizationRequiredError"}}class Ln extends Error{constructor(n){super(`MCP OAuth credentials are unavailable in this runtime for server "${n}"`);this.name="McpOAuthUnavailableError"}}function Xt(n){let t=n?"Authentication complete":"Authentication failed";return`<!doctype html>
|
|
4
4
|
<html lang="en">
|
|
@@ -41,4 +41,4 @@ ${M.map((u)=>` - ${u}`).join(`
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
`)}}function Uu(n,t={}){let M={...n};if(t.debug!==void 0)M.debug=t.debug===""?!0:t.debug;if(t.model){if(!n.models.some((_)=>_.id===t.model))throw Error(`模型配置未找到: ${t.model}`);M.currentModelId=t.model}if(t.yolo===!0)M.permissionMode="yolo";else if(t.permissionMode!==void 0)M.permissionMode=t.permissionMode;if(t.maxTurns!==void 0)M.maxTurns=t.maxTurns;if(t.maxConcurrentTasks!==void 0)M.maxConcurrentTasks=t.maxConcurrentTasks;if(t.maxQueuedTasks!==void 0)M.maxQueuedTasks=t.maxQueuedTasks;return M.systemPrompt=t.systemPrompt,M.appendSystemPrompt=t.appendSystemPrompt,M.model=t.model,M.resumeSessionId=t.sessionId,M.forkSession=t.forkSession,M.allowedTools=t.allowedTools,M.disallowedTools=t.disallowedTools,M.mcpConfigPaths=t.mcpConfig,M.strictMcpConfig=t.strictMcpConfig,M.addDirs=t.addDir,M.outputFormat=t.outputFormat,M.inputFormat=t.inputFormat,M.print=t.print,M.includePartialMessages=t.includePartialMessages,M.replayUserMessages=t.replayUserMessages,M.agentsConfig=t.agents,M.settingSources=t.settingSources,M}
|
|
44
|
-
export{U as
|
|
44
|
+
export{U as re,y as se,I as te,v as ue,Ln as ve,N as we,Nn as xe,qM as ye,V as ze,VM as Ae,OM as Be,ZM as Ce,Bn as De,Ut as Ee,JM as Fe,qt as Ge,QM as He,Jn as Ie,DM as Je,WM as Ke,jM as Le,FM as Me,lM as Ne,pn as Oe,vM as Pe,nu as Qe,tu as Re,Mu as Se,BM as Te,b as Ue,d as Ve,gt as We,i as Xe,Q as Ye,ln as Ze,vn as _e,nt as $e,tt as af,Mt as bf,ut as cf,R as df,Uu as ef};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-
|
|
2
|
-
import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as R,a as y,b as de,s as Ne,c as Ve,d as J,D as Se,e as Ce,f as Le,g as Ee,h as Te,i as Ae,j as A,k as O,B as ce,_ as Oe,S as Ue,l as He,m as Ke,C as ze,n as qe}from"./index-DqXKkjcp.js";import{Q as fe,O as Ge,G as We,Y as Je,L as F,z as Qe,T as ee,C as se,Z as Ye,v as Xe,_ as Ze,B as et,$ as Fe,y as re,m as ue,R as me,s as tt,H as st,a0 as Me,U as rt,a1 as at,a2 as nt,a3 as it,P as Re,a4 as ot,X as lt,a5 as ct,a6 as dt,f as De,a7 as ut,W as mt,a as xt}from"./vendor-icons-ICv1v-tf.js";import{k as ht,g as pt,l as ft,e as bt,t as gt,j as vt}from"./session-events-K_9Lexp8.js";import{j as kt,k as jt,l as yt,m as Ie}from"./vendor-radix-DXRuAJHH.js";function be(t){return t.split("/").filter(Boolean).at(-1)||t}function wt(){const t=R(),s=y(w=>w.sessions),r=y(w=>w.currentSessionRef),a=y(w=>w.taskDeliveryActions),o=y(w=>w.deliverTask),i=de(w=>w.openFilePreview),[m,b]=f.useState(!1),c=s.find(w=>Ne({sessionId:w.sessionId,projectPath:w.projectPath},r));if(!(c!=null&&c.taskIsolation))return null;const l=c.taskDiffStat,k=c.taskIsolation==="worktree",n=Ve(c),d=a[J(n)],p=c.taskDelivery,j=(p==null?void 0:p.status)==="conflicted",N=!!(l&&(l.changedFiles>0||l.commits>0)),h=!["queued","running"].includes(c.taskStatus),E=(p==null?void 0:p.status)==="applied"||(p==null?void 0:p.status)==="discarded",v=k&&N&&h&&!E,x=l?l.additions+l.deletions:0,u=x>0&&l?l.additions/x*100:0,C=w=>{o(n,w).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(fe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:be(c.taskSourceProjectPath||c.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k?e.jsx(Ge,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(fe,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),c.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:c.taskWorktreeBranch,children:[e.jsx(We,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:c.taskWorktreeBranch})]})]})]}),l&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Je,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:l.changedFiles})]}),x>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${u}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-u}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",l.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",l.deletions]}),l.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:l.commits})}),N&&(p==null?void 0:p.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>i({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!d,onClick:()=>C("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[d==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Qe,{className:"h-3 w-3"}),t(d==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!d,onClick:()=>b(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:d==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})]}),(p==null?void 0:p.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(se,{className:"h-3 w-3"}),t("artifact.applied")]}),(p==null?void 0:p.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(ee,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(p==null?void 0:p.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(Ye,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:p.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Se,{open:m,onOpenChange:b,children:e.jsxs(Ce,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(Le,{children:[e.jsx(Ee,{children:t("artifact.discardDialog.title")}),e.jsx(Te,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:be(c.taskSourceProjectPath||c.projectPath),count:(l==null?void 0:l.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ae,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{b(!1),C("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Nt=new Set(["completed","stale","failed","aborted","interrupted"]),St={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},Ct={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function te(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Et(t){const s=te(t),r=te(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,o=s==null?void 0:s.confidenceScore,i=r==null?void 0:r.lineStart,m=r==null?void 0:r.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||a!==0&&a!==1&&a!==2&&a!==3||typeof o!="number"||!Number.isFinite(o)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(i)||!Number.isInteger(m)))return{title:s.title,body:s.body,priority:a,confidenceScore:o,codeLocation:{path:r.path,lineStart:i,lineEnd:m}}}function Tt(t){const s=te(t),r=te(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Nt.has(s.status)||typeof(r==null?void 0:r.label)!="string"||r.kind!=="uncommitted"&&r.kind!=="base"&&r.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const a=s.findings.map(Et);if(!a.some(o=>o===void 0))return{status:s.status,target:{kind:r.kind,label:r.label,...typeof r.reference=="string"?{reference:r.reference}:{}},overallExplanation:s.overallExplanation,findings:a,...typeof s.error=="string"?{error:s.error}:{}}}function At(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Ft({report:t}){const s=R(),r=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",r]})]}),e.jsxs("span",{className:A("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ct[t.status]),children:[s("chat.review.status"),": ",s(St[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((a,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:a.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:a.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:At(a)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:a.body})]},`${a.codeLocation.path}:${a.codeLocation.lineStart}:${o}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function Mt({elicitation:t,messageId:s}){const r=R(),a=y(v=>v.currentSessionRef),o=y(v=>v.setElicitation),[i,m]=f.useState(()=>Dt(t.details.fields??[])),[b,c]=f.useState(()=>It(t.details.fields??[])),[l,k]=f.useState(!1),[n,d]=f.useState(),p=t.details.fields??[],j=f.useMemo(()=>p.every(v=>{var u;if(!v.required)return!0;if(ae(v))return!!((u=b[v.name])!=null&&u.trim()||v.defaultValue!==void 0);const x=i[v.name]??v.defaultValue;return Array.isArray(x)?x.length>0:x!==void 0}),[p,b,i]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(v,x)=>{if(!(!a||l)){k(!0),d(void 0);try{await O.respondToElicitation(a,t.toolCallId,{action:v,...x?{content:x}:{}}),o(s,{...t,status:"responded"})}catch(u){d(u instanceof Error?u.message:r("interaction.elicitation.failed"))}finally{k(!1)}}},h=async()=>{try{await N("accept",Bt(p,i,b))}catch(v){d(v instanceof Error?v.message:String(v))}},E=()=>{const v=t.details.url;if(!v){d("MCP URL is unavailable");return}if(!window.open(v,"_blank","noopener,noreferrer")){d("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{onClick:E,disabled:l,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(Ze,{className:"h-3.5 w-3.5"})}),e.jsx(K,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(K,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[p.map(v=>e.jsx(Rt,{field:v,value:i[v.name],rawValue:b[v.name]??"",onValueChange:x=>m(u=>({...u,[v.name]:x})),onRawChange:x=>c(u=>({...u,[v.name]:x}))},v.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{onClick:()=>void h(),disabled:l||!j,primary:!0,label:r("interaction.elicitation.submit"),icon:l?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(K,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(K,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}),n&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n})]})}function Rt({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:$t(t).map(i=>{const m=Array.isArray(s)?s.includes(i.value):s===i.typedValue;return e.jsx("button",{type:"button","aria-pressed":m,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];a(b.includes(i.value)?b.filter(c=>c!==i.value):[...b,i.value])}else a(i.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",m?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:i.label},i.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Pt(t),value:r,onChange:i=>o(i.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function K({onClick:t,disabled:s,primary:r=!1,label:a,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:A("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,a]})}function Dt(t){return Object.fromEntries(t.filter(s=>!ae(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function It(t){return Object.fromEntries(t.filter(s=>ae(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Bt(t,s,r){var o;const a={};for(const i of t){if(ae(i)){const b=((o=r[i.name])==null?void 0:o.trim())??"";if(!b){if(i.defaultValue!==void 0)a[i.name]=i.defaultValue;else if(i.required)throw new Error(`${i.title} is required`);continue}if(i.type==="number"||i.type==="integer"){const c=Number(b);if(!Number.isFinite(c))throw new Error(`${i.title} must be a finite number`);if(i.type==="integer"&&!Number.isSafeInteger(c))throw new Error(`${i.title} must be a safe integer`);a[i.name]=c}else a[i.name]=b;continue}const m=s[i.name]??i.defaultValue;if(m===void 0){if(i.required)throw new Error(`${i.title} is required`);continue}if(Array.isArray(m)){if(i.minItems!==void 0&&m.length<i.minItems)throw new Error(`${i.title} requires at least ${i.minItems} choices`);if(i.maxItems!==void 0&&m.length>i.maxItems)throw new Error(`${i.title} allows at most ${i.maxItems} choices`)}a[i.name]=m}return a}function $t(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function ae(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Pt(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function _t(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function Vt({report:t}){const s=R(),[r,a]=f.useState(!1),o=JSON.stringify(t.output,null,2),i=async()=>{try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(et,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:i,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(se,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Fe,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:o})]})}const Lt=f.lazy(()=>Oe(()=>import("./MarkdownRenderer-BqV1nvf1.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function ge({text:t,label:s}){const[r,a]=f.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(se,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Fe,{className:"h-3.5 w-3.5"})})}function Ot(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(ce,{size:20,pulse:!1})})}function Ut(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function ve(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function Ht(t){if(typeof t=="string")return{text:ve(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
3
|
-
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:ve(s),images:r}}function
|
|
4
|
-
`)}function Kt(t){const s=t.agentContent;return s?ht(s):xe(t.content)}function ke({content:t,syntaxHighlight:s=!0}){return e.jsx(f.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(Lt,{content:t,syntaxHighlight:s})})}function he({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:A("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function zt(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}function qt({tool:t}){const[s,r]=f.useState(!1),a=zt(t.arguments);return e.jsxs("div",{className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(o=>!o),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ue,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(he,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),t.output&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.output.length>500?t.output.slice(0,500)+"...":t.output})]})]})]})}function Be({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(qt,{tool:s},s.toolCallId))})}function Gt({toolCalls:t,toolCallIds:s}){const r=R(),[a,o]=f.useState(!1),i=f.useMemo(()=>new Map(t.map(n=>[n.toolCallId,n])),[t]),m=s.flatMap(n=>{const d=i.get(n);return d?[d]:[]});if(m.length===0)return null;const b=m.filter(n=>n.status==="running").length,c=m.filter(n=>n.status==="error").length,l=[...m].reverse().find(n=>n.status==="running"&&!!n.progressMessage),k=b>0?r(m.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:m.length}):c>0?r(m.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:m.length,errors:c}):r(m.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:m.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>o(n=>!n),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(re,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx(F,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(l==null?void 0:l.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[l.progressMessage,l.progress!==void 0&&l.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(l.progress/l.progressTotal*100)))}%`]})]}),(l==null?void 0:l.progress)!==void 0&&l.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${l.toolName} progress`,"aria-valuemin":0,"aria-valuemax":l.progressTotal,"aria-valuenow":Math.min(l.progress,l.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,l.progress/l.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Be,{toolCalls:m})})]})}function Wt({content:t}){const s=R(),[r,a]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ue,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Jt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function Qt({toolCalls:t}){const s=de(a=>a.openFilePreview),r=f.useMemo(()=>{const a=new Map,o=["Write","SearchReplace","Edit","ApplyPatch"];for(const i of t){if(i.status!=="success")continue;const m=i.metadata;if(i.toolName==="ApplyPatch"&&Array.isArray(m==null?void 0:m.changes)){for(const c of m.changes)c&&typeof c=="object"&&"path"in c&&typeof c.path=="string"&&a.set(c.path,{path:c.path,toolName:i.toolName});continue}const b=m==null?void 0:m.file_path;b&&o.includes(i.toolName)&&a.set(b,{path:b,toolName:i.toolName})}return Array.from(a.values())},[t]);return r.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:a})=>{const o=a.split("/").pop()||a;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:a}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:a,children:[e.jsx(tt,{className:"w-3 h-3"}),o]},a)})})]})}function Yt({subagent:t}){var q,H,Q,Y;const s=R(),[r,a]=f.useState(null),[o,i]=f.useState(!1),[m,b]=f.useState(null),[c,l]=f.useState(!1),[k,n]=f.useState(""),[d,p]=f.useState(!1),[j,N]=f.useState(null),[h,E]=f.useState(null),[v,x]=f.useState(null),u=y(T=>T.currentSessionRef),C=y(T=>T.isStreaming),w=y(T=>T.isTemporarySession);if(!t)return null;const $=t.status==="running",M=r!==null?r:$,L=t.toolCalls||m||[],P=t.output||t.thinking||L.length>0||t.sessionId,S=h&&h.status!=="running"?h:v,I=(S==null?void 0:S.id)??t.sessionId,U=((q=S==null?void 0:S.restartRecovery)==null?void 0:q.outcome)==="failed",ne=!$&&!C&&!w&&!U&&(h==null?void 0:h.status)!=="running"&&!!(I&&u);f.useEffect(()=>{if(!M||$||!t.sessionId||!(u!=null&&u.projectPath)||m!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return i(!0),O.getMessages({sessionId:t.sessionId,projectPath:u.projectPath}).then(_=>{var B,D;if(!T)return;const V=bt(_),g=new Map;for(const G of V)if((D=(B=G.agentContent)==null?void 0:B.toolCalls)!=null&&D.length)for(const ie of G.agentContent.toolCalls)g.has(ie.toolCallId)||g.set(ie.toolCallId,ie);b(Array.from(g.values()))}).finally(()=>{T&&i(!1)}),()=>{T=!1}},[M,$,t.sessionId,t.toolCalls,m,u==null?void 0:u.projectPath]),f.useEffect(()=>{if(!t.sessionId||!u)return;let T=!0;const _=t.rootAgentId??t.sessionId,V=t.resumeDepth??0;return O.listSubagents(u).then(g=>{if(!T)return;x(g.find(D=>D.id===t.sessionId)??null);const B=g.filter(D=>D.id!==t.sessionId&&D.rootAgentId===_&&D.resumeDepth>V).sort((D,G)=>G.resumeDepth-D.resumeDepth||G.lastActiveAt-D.lastActiveAt)[0];B&&E(B)}).catch(()=>{}),()=>{T=!1}},[u==null?void 0:u.sessionId,u==null?void 0:u.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!h||h.status!=="running"||!u)return;let T=!0;const _=async()=>{try{const B=(await O.listSubagents(u)).find(D=>D.id===h.id);T&&B&&E(B)}catch{}},V=window.setInterval(()=>{_()},1e3);return()=>{T=!1,window.clearInterval(V)}},[u,h==null?void 0:h.id,h==null?void 0:h.status]);const z=async()=>{if(!(!u||!I||!k.trim()||d)){p(!0),N(null);try{const T=await O.resumeSubagent(u,I,k.trim());E(T.session),n(""),l(!1),a(!0)}catch(T){N(T instanceof Error?T.message:s("chat.subagent.resumeFailed"))}finally{p(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>a(!M),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[$&&e.jsx(F,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(he,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:A("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),P&&e.jsx(re,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",M&&"rotate-180")})]}),M&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!o&&L.length>0&&e.jsx(Be,{toolCalls:L}),h&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:s("chat.subagent.resumedAs",{id:h.id,status:h.status,depth:h.resumeDepth??1})}),(((H=h.result)==null?void 0:H.message)||((Q=h.result)==null?void 0:Q.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:h.result.message||h.result.error})]}),U&&((Y=S==null?void 0:S.result)==null?void 0:Y.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:S.result.error}),ne&&e.jsxs("div",{className:"space-y-2",children:[c?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":s("chat.subagent.followUpAria"),value:k,onChange:T=>n(T.target.value),placeholder:s("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{l(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void z(),disabled:!k.trim()||d,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[d&&e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>l(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(me,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function Xt({confirmation:t,messageId:s}){const r=R(),[a,o]=f.useState(!1),[i,m]=f.useState(null),b=y(k=>k.currentSessionRef),c=y(k=>k.setConfirmation);if(!t)return null;const l=async(k,n)=>{if(!(!b||a)){o(!0),m(null);try{await O.respondPermission(b,t.toolCallId,{approved:k,scope:n}),c(s,{...t,status:k?"approved":"denied"})}catch(d){m(d instanceof Error?d.message:r("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),i&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void l(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void l(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function Zt({question:t,messageId:s}){const r=R(),[a,o]=f.useState({}),[i,m]=f.useState({}),[b,c]=f.useState(!1),[l,k]=f.useState(null),n=y(h=>h.currentSessionRef),d=y(h=>h.setQuestion),p=f.useMemo(()=>t?t.questions.reduce((h,E)=>{var C;const v=(C=i[E.header])==null?void 0:C.trim(),x=a[E.header];if(E.multiSelect){const w=Array.isArray(x)?[...x]:[];return v&&w.push(v),w.length>0&&(h[E.header]=w),h}const u=v||(typeof x=="string"?x:"");return u&&(h[E.header]=u),h},{}):{},[a,i,t]),j=(t==null?void 0:t.questions.every(h=>h.header in p))??!1;if(!t)return null;const N=async()=>{if(!(!n||b||!j)){c(!0),k(null);try{await O.respondToQuestion(n,t.toolCallId,p),d(s,{...t,status:"answered",answers:p})}catch(h){k(h instanceof Error?h.message:r("interaction.question.failed"))}finally{c(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((h,E)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:h.question}),e.jsxs("div",{className:"space-y-1",children:[h.options.map((v,x)=>e.jsxs("button",{type:"button",onClick:()=>{if(h.multiSelect){const u=a[h.header]||[],C=u.includes(v.label)?u.filter(w=>w!==v.label):[...u,v.label];o({...a,[h.header]:C})}else o({...a,[h.header]:v.label}),m({...i,[h.header]:""})},className:A("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(h.multiSelect?(a[h.header]||[]).includes(v.label):a[h.header]===v.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:v.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:v.description})]},x)),e.jsx("input",{"aria-label":`${h.header} other response`,value:i[h.header]??"",onChange:v=>m({...i,[h.header]:v.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},E)),l&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:l}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:b||!j,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[b&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function es({message:t}){const s=t.agentContent,r=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=xe(t.content);return j?e.jsx(ke,{content:j}):null}const{toolCalls:a,tasks:o,confirmation:i,question:m,elicitation:b}=s,c=pt(s),l=ft(s);if(!(l.length>0||o.length>0||c.length>0||i||m||b)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const d=a.length>0&&a.every(j=>j.status==="success"||j.status==="error")&&!r,p=!r;return e.jsxs("div",{className:"space-y-3",children:[l.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(Wt,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(ke,{content:j.content,syntaxHighlight:p})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Gt,{toolCalls:a,toolCallIds:j.toolCallIds})},j.id)),o.length>0&&e.jsx(Jt,{tasks:o}),c.map(j=>e.jsx(Yt,{subagent:j},j.id)),i&&e.jsx(Xt,{confirmation:i,messageId:t.id}),m&&e.jsx(Zt,{question:m,messageId:t.id}),b&&e.jsx(Mt,{elicitation:b,messageId:t.id}),d&&e.jsx(Qt,{toolCalls:a})]})}function ts({message:t,showAvatar:s=!0}){var b,c,l,k;const r=t.role==="user";if(t.role==="system"){const n=xe(t.content);return e.jsx("div",{"data-chat-message-id":t.id,className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:n})})}if(r){const n=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(c=t.metadata)!=null&&c.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(n){const j=typeof n.command=="string"?n.command:"",N=n.status==="running"?"running":n.status==="completed"?"success":"error",h=typeof n.output=="string"?n.output:[typeof n.stdout=="string"?n.stdout:"",typeof n.stderr=="string"&&n.stderr?`stderr:
|
|
5
|
-
${
|
|
6
|
-
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),j]}),e.jsx(he,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:h||"(no output)"}),typeof n.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",n.exitCode,typeof n.durationMs=="number"?` · ${(n.durationMs/1e3).toFixed(3)}s`:"",n.truncated===!0?" · truncated":""]})]})})}const{text:d,images:p}=Ht(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(ge,{text:d,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[d&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:d}),p.length>0&&e.jsx("div",{className:A("grid gap-2",p.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:p.map((j,N)=>e.jsx("img",{src:j,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${N}`))})]}),e.jsx(Ut,{})]})}const o=Kt(t),i=Tt((l=t.metadata)==null?void 0:l.codeReview),m=_t((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,className:A("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(Ot,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[i?e.jsx(Ft,{report:i}):m?e.jsx(Vt,{report:m}):e.jsx(es,{message:t}),!m&&o.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(ge,{text:o,label:"Copy response"})})]})]})}const ss=f.memo(ts);function rs(t,s,r){return Math.max(0,t+(r-s))}function as(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function je(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ns({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const o=R(),[i,m]=f.useState(null),[b,c]=f.useState(!1),l=f.useRef(null),k=f.useCallback(()=>{var h;const d=s.current,p=r.current;if(!d||!p||t.length===0)return;const j=d.getBoundingClientRect().top;let N=((h=t[0])==null?void 0:h.id)??null;for(const E of t){const v=je(p,E.id);if(v)if(v.getBoundingClientRect().top-j<=24)N=E.id;else break}m(N)},[t,s,r]);f.useEffect(()=>{const d=s.current;if(!d)return;const p=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,k()}))};return k(),d.addEventListener("scroll",p,{passive:!0}),()=>{d.removeEventListener("scroll",p),l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null)}},[k,s]);const n=f.useCallback(d=>{const p=()=>{const N=je(r.current,d.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),m(d.id))};a(d.index)?p():window.requestAnimationFrame(()=>window.requestAnimationFrame(p))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocusCapture:()=>c(!0),onBlurCapture:d=>{d.currentTarget.contains(d.relatedTarget)||c(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:A("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(d=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",d.id===i?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},d.id))}),e.jsx("div",{className:A("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((d,p)=>e.jsxs("button",{type:"button",onClick:()=>n(d),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d.id===i?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:A("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",d.id===i?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:o("chat.turns.label",{n:p+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:d.preview})]})]},d.id))})]})})}const ye=80;function is(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function os(t){const s=is(t).replace(/\s+/g," ").trim();return s?s.length>ye?`${s.slice(0,ye-1)}…`:s:""}function ls(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const o=os(a.content);o&&s.push({id:a.id,index:r,preview:o})}return s}const oe=120,le=80,cs=96;function W(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function ds({messages:t,isLoading:s}){const r=R(),a=f.useRef(null),o=f.useRef(null),i=f.useRef(!0),m=f.useRef(t.length),b=f.useRef(null),[c,l]=f.useState(oe),[k,n]=f.useState(!1);f.useEffect(()=>{const x=W(a.current);if(!x||!i.current)return;const u=window.requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight});return()=>window.cancelAnimationFrame(u)},[t]),f.useEffect(()=>{const x=W(a.current);if(!x)return;o.current=x;const u=()=>{const w=x.scrollHeight-x.scrollTop-x.clientHeight<=cs;i.current=w,n(!w)};return u(),x.addEventListener("scroll",u,{passive:!0}),()=>x.removeEventListener("scroll",u)},[]),f.useEffect(()=>{const x=m.current;m.current=t.length,l(u=>u>=x&&t.length>x?t.length:Math.min(Math.max(u,oe),t.length||oe))},[t.length]);const d=Math.max(t.length-c,0),p=d,j=f.useMemo(()=>t.slice(p),[t,p]),N=f.useMemo(()=>ls(t),[t]);if(f.useLayoutEffect(()=>{var C;const x=b.current;if(!x)return;const u=W(a.current);if(b.current=null,!!u){if((C=x.element)!=null&&C.isConnected){const w=x.element.getBoundingClientRect().top-x.viewportTop;u.scrollTop+=w;return}u.scrollTop=rs(x.scrollTop,x.scrollHeight,u.scrollHeight)}},[c]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(ce,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(st,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((x,u)=>e.jsxs("div",{className:A("flex gap-3",u%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${x}%`,animationDelay:`${u*120}ms`}})]},x))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(ce,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const h=()=>{const x=W(a.current);x&&(i.current=!0,n(!1),x.scrollTo({top:x.scrollHeight,behavior:"smooth"}))},E=()=>{var u;const x=W(a.current);if(x){const C=((u=a.current)==null?void 0:u.querySelector("[data-chat-message-id]"))??null;b.current={element:C,viewportTop:(C==null?void 0:C.getBoundingClientRect().top)??0,scrollHeight:x.scrollHeight,scrollTop:x.scrollTop}}l(C=>as(C,t.length,le))},v=x=>x>=p?!0:(l(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ue,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[d>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:E,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(d,le),remaining:d}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(d,le)})})}),j.map((x,u)=>{const C=p+u,w=C>0?t[C-1]:null,$=!w||w.role!==x.role||w.role==="user";return e.jsx(ss,{message:x,showAvatar:$},x.id||`msg-${C}`)})]})}),e.jsx(ns,{turns:N,viewportRef:o,containerRef:a,onRevealTurn:v}),k&&e.jsxs("button",{type:"button",onClick:h,className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Me,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const us=f.memo(ds),$e=kt,Pe=jt,_e=yt,pe=f.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Ie,{ref:a,sideOffset:s,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));pe.displayName=Ie.displayName;const ms={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function X(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function xs(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function hs(){var P;const t=R(),{locale:s}=He(),r=y(S=>S.goal),a=y(S=>S.pauseGoal),o=y(S=>S.resumeGoal),i=y(S=>S.editGoal),m=y(S=>S.clearGoal),[b,c]=f.useState(!1),[l,k]=f.useState(!1),[n,d]=f.useState(""),[p,j]=f.useState(null),[N,h]=f.useState(!1);if(f.useEffect(()=>{c(!1),k(!1),d((r==null?void 0:r.objective)??""),h(!1)},[r==null?void 0:r.goalId]),!r)return null;const E=ms[r.status],v=["active","verifying","paused","blocked"].includes(r.status),x=r.status==="active"||r.status==="verifying",u=r.status==="paused"||r.status==="blocked",C=p!==null,w=async(S,I)=>{j(S);try{await I()}finally{j(null)}},$=()=>{d(r.objective),k(!0),c(!0)},M=async S=>{S.preventDefault();const I=n.trim();if(!I||I===r.objective){k(!1);return}await w("edit",()=>i(I)),k(!1)},L=async()=>{await w("delete",m),h(!1)};return e.jsxs(e.Fragment,{children:[e.jsx($e,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0",children:[e.jsxs("div",{className:A("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",b&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(rt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(at,{className:A("h-3.5 w-3.5 shrink-0",E.accent)}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",E.dot)}),e.jsx("span",{className:A("shrink-0 text-[10px] font-medium leading-none",E.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(E.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>c(S=>!S),"aria-expanded":b,title:r.objective,children:r.objective}),r.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[X(r.tokensUsed),r.tokenBudget!==void 0&&`/${X(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[x&&e.jsx(Z,{label:t("goal.action.pause"),disabled:C,onClick:()=>void w("pause",a),children:p==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(nt,{})}),u&&e.jsx(Z,{label:t("goal.action.resume"),disabled:C,onClick:()=>void w("resume",o),children:p==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(it,{})}),e.jsx(Z,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!b,onClick:v?$:()=>c(S=>!S),children:v?e.jsx(Re,{}):e.jsx(ot,{})}),e.jsx(Z,{label:t("goal.action.delete"),disabled:C,destructive:!0,onClick:()=>h(!0),children:e.jsx(ee,{})})]})]}),b&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:l?e.jsxs("form",{onSubmit:M,children:[e.jsx("textarea",{id:"goal-objective",value:n,onChange:S=>d(S.target.value),onKeyDown:S=>{S.key==="Escape"&&k(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>k(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(lt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!n.trim()||p==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[p==="edit"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(se,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:r.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ct,{className:"h-3 w-3"}),X(r.tokensUsed),r.tokenBudget!==void 0&&` / ${X(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(dt,{className:"h-3 w-3"}),xs(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(me,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.completionVerification&&e.jsxs("div",{"data-goal-verification":r.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",r.completionVerification.attempt," ·"," ",r.completionVerification.status.toUpperCase()," ·"," ",((P=r.completionVerification.verifierSessionId)==null?void 0:P.slice(0,12))??"-"]}),r.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:r.completionVerification.summary}),r.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",r.completionVerification.evidenceSha256.slice(0,12)]})]}),r.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:r.statusReason})]})})]})}),e.jsx(Se,{open:N,onOpenChange:h,children:e.jsxs(Ce,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Ee,{children:t("goal.dialog.title")}),e.jsx(Te,{children:t("goal.dialog.description")}),e.jsxs(Ae,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:p==="delete",onClick:()=>void L(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[p==="delete"&&e.jsx(F,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function Z({label:t,children:s,disabled:r,destructive:a,onClick:o}){return e.jsxs(Pe,{children:[e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:o,className:A("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(pe,{side:"top",className:"text-[10px]",children:t})]})}function ps(){const t=R(),s=y(c=>c.currentSessionRef),r=y(c=>c.sessions),a=y(c=>c.messages),o=f.useMemo(()=>{var l,k,n,d,p;const c=s?(l=Ke(r,s))==null?void 0:l.pendingInteraction:void 0;if(c)return c.type;for(let j=a.length-1;j>=0;j-=1){const N=(k=a[j])==null?void 0:k.agentContent;if(((n=N==null?void 0:N.confirmation)==null?void 0:n.status)==="pending")return"permission";if(((d=N==null?void 0:N.question)==null?void 0:d.status)==="pending")return"question";if(((p=N==null?void 0:N.elicitation)==null?void 0:p.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!o)return null;const i=()=>{const c=document.querySelector(`[data-pending-interaction="${o}"]`);c==null||c.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>c==null?void 0:c.focus(),250)},m=o==="question",b=o==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(De,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(m?"interaction.bar.questionTitle":b?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(m?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:i,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Me,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const fs={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},we=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function bs(){const t=R(),s=y(d=>d.tokenUsage),r=y(d=>d.isStreaming),a=y(d=>d.agentPhase),o=y(d=>d.providerRetry),i=y(d=>d.providerStall),m=fs[a]??"",b=(o==null?void 0:o.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(o.delayMs/1e3))}s`:"",c=i?`${t("status.phase.providerStall")} · ${Math.ceil(i.durationMs/1e3)}s / ${Math.ceil(i.timeoutMs/1e3)}s`:o?`Provider · ${t("chat.error.action.retryingTask")} · ${o.attempt}/${o.maxRetries}${b}`:m?t(m):"",l=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,k=Math.min(l,100),n=l>95?"danger":l>80?"warn":"safe";return e.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-5 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:A("text-[12px] font-medium",n==="safe"&&"text-[hsl(var(--deck-ink))]",n==="warn"&&"text-amber-600 dark:text-amber-400",n==="danger"&&"text-red-600 dark:text-red-400"),children:we(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",we(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx($e,{children:e.jsxs(Pe,{children:[e.jsx(_e,{asChild:!0,children:e.jsx(ut,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(pe,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","aria-hidden":"true",children:[e.jsx("div",{className:A("absolute inset-y-0 left-0 transition-[width] duration-300",n==="safe"&&"bg-[hsl(var(--deck-accent))]",n==="warn"&&"bg-amber-500",n==="danger"&&"bg-red-500"),style:{width:`${k}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(d=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${d}%`}},d))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",n==="warn"&&"text-amber-600 dark:text-amber-400",n==="danger"&&"text-red-600 dark:text-red-400"),children:[l,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&c&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:c})]})]})}function gs(t){const s=[...t].reverse().find(o=>o.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(o=>o.type==="text").map(o=>o.text).join(`
|
|
7
|
-
`),a=s.content.filter(o=>o.type==="image_url").map((o,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-C-X3g9Ky.js","assets/index-D88fYWls.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-ICv1v-tf.js","assets/session-events-BoJrjSZ2.js","assets/index-BC7ygRH_.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as R,a as y,b as de,s as Ne,c as Le,d as J,D as Se,e as Ce,f as Ve,g as Ee,h as Te,i as Ae,j as A,k as O,B as ce,_ as Oe,S as Ue,l as He,m as Ke,C as ze,n as qe}from"./index-D88fYWls.js";import{Q as fe,O as Ge,G as We,Y as Je,L as F,z as Qe,T as ee,C as se,Z as Ye,v as Xe,_ as Ze,B as et,$ as Fe,y as re,m as ue,R as me,s as tt,H as st,a0 as Me,U as rt,a1 as at,a2 as nt,a3 as it,P as Re,a4 as ot,X as lt,a5 as ct,a6 as dt,f as De,a7 as ut,W as mt,a as ht}from"./vendor-icons-ICv1v-tf.js";import{k as xt,g as pt,l as ft,e as bt,t as gt,j as vt}from"./session-events-BoJrjSZ2.js";import{j as kt,k as jt,l as yt,m as Ie}from"./vendor-radix-DXRuAJHH.js";function be(t){return t.split("/").filter(Boolean).at(-1)||t}function wt(){const t=R(),s=y(w=>w.sessions),r=y(w=>w.currentSessionRef),a=y(w=>w.taskDeliveryActions),o=y(w=>w.deliverTask),n=de(w=>w.openFilePreview),[h,b]=f.useState(!1),d=s.find(w=>Ne({sessionId:w.sessionId,projectPath:w.projectPath},r));if(!(d!=null&&d.taskIsolation))return null;const l=d.taskDiffStat,k=d.taskIsolation==="worktree",i=Le(d),u=a[J(i)],c=d.taskDelivery,j=(c==null?void 0:c.status)==="conflicted",N=!!(l&&(l.changedFiles>0||l.commits>0)),p=!["queued","running"].includes(d.taskStatus),E=(c==null?void 0:c.status)==="applied"||(c==null?void 0:c.status)==="discarded",v=k&&N&&p&&!E,x=l?l.additions+l.deletions:0,m=x>0&&l?l.additions/x*100:0,C=w=>{o(i,w).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(fe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:be(d.taskSourceProjectPath||d.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k?e.jsx(Ge,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(fe,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),d.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:d.taskWorktreeBranch,children:[e.jsx(We,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:d.taskWorktreeBranch})]})]})]}),l&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Je,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:l.changedFiles})]}),x>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${m}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-m}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",l.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",l.deletions]}),l.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:l.commits})}),N&&(c==null?void 0:c.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!u,onClick:()=>C("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[u==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Qe,{className:"h-3 w-3"}),t(u==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!u,onClick:()=>b(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:u==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})]}),(c==null?void 0:c.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(se,{className:"h-3 w-3"}),t("artifact.applied")]}),(c==null?void 0:c.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(ee,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(c==null?void 0:c.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(Ye,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:c.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Se,{open:h,onOpenChange:b,children:e.jsxs(Ce,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(Ve,{children:[e.jsx(Ee,{children:t("artifact.discardDialog.title")}),e.jsx(Te,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:be(d.taskSourceProjectPath||d.projectPath),count:(l==null?void 0:l.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ae,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{b(!1),C("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Nt=new Set(["completed","stale","failed","aborted","interrupted"]),St={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},Ct={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function te(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Et(t){const s=te(t),r=te(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,o=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,h=r==null?void 0:r.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||a!==0&&a!==1&&a!==2&&a!==3||typeof o!="number"||!Number.isFinite(o)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(h)))return{title:s.title,body:s.body,priority:a,confidenceScore:o,codeLocation:{path:r.path,lineStart:n,lineEnd:h}}}function Tt(t){const s=te(t),r=te(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Nt.has(s.status)||typeof(r==null?void 0:r.label)!="string"||r.kind!=="uncommitted"&&r.kind!=="base"&&r.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const a=s.findings.map(Et);if(!a.some(o=>o===void 0))return{status:s.status,target:{kind:r.kind,label:r.label,...typeof r.reference=="string"?{reference:r.reference}:{}},overallExplanation:s.overallExplanation,findings:a,...typeof s.error=="string"?{error:s.error}:{}}}function At(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Ft({report:t}){const s=R(),r=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",r]})]}),e.jsxs("span",{className:A("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ct[t.status]),children:[s("chat.review.status"),": ",s(St[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((a,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:a.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:a.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:At(a)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:a.body})]},`${a.codeLocation.path}:${a.codeLocation.lineStart}:${o}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function Mt({elicitation:t,messageId:s}){const r=R(),a=y(v=>v.currentSessionRef),o=y(v=>v.setElicitation),[n,h]=f.useState(()=>Dt(t.details.fields??[])),[b,d]=f.useState(()=>It(t.details.fields??[])),[l,k]=f.useState(!1),[i,u]=f.useState(),c=t.details.fields??[],j=f.useMemo(()=>c.every(v=>{var m;if(!v.required)return!0;if(ae(v))return!!((m=b[v.name])!=null&&m.trim()||v.defaultValue!==void 0);const x=n[v.name]??v.defaultValue;return Array.isArray(x)?x.length>0:x!==void 0}),[c,b,n]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(v,x)=>{if(!(!a||l)){k(!0),u(void 0);try{await O.respondToElicitation(a,t.toolCallId,{action:v,...x?{content:x}:{}}),o(s,{...t,status:"responded"})}catch(m){u(m instanceof Error?m.message:r("interaction.elicitation.failed"))}finally{k(!1)}}},p=async()=>{try{await N("accept",$t(c,n,b))}catch(v){u(v instanceof Error?v.message:String(v))}},E=()=>{const v=t.details.url;if(!v){u("MCP URL is unavailable");return}if(!window.open(v,"_blank","noopener,noreferrer")){u("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{onClick:E,disabled:l,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(Ze,{className:"h-3.5 w-3.5"})}),e.jsx(K,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(K,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[c.map(v=>e.jsx(Rt,{field:v,value:n[v.name],rawValue:b[v.name]??"",onValueChange:x=>h(m=>({...m,[v.name]:x})),onRawChange:x=>d(m=>({...m,[v.name]:x}))},v.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{onClick:()=>void p(),disabled:l||!j,primary:!0,label:r("interaction.elicitation.submit"),icon:l?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(K,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(K,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}),i&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i})]})}function Rt({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:Bt(t).map(n=>{const h=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":h,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];a(b.includes(n.value)?b.filter(d=>d!==n.value):[...b,n.value])}else a(n.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",h?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Pt(t),value:r,onChange:n=>o(n.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function K({onClick:t,disabled:s,primary:r=!1,label:a,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:A("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,a]})}function Dt(t){return Object.fromEntries(t.filter(s=>!ae(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function It(t){return Object.fromEntries(t.filter(s=>ae(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function $t(t,s,r){var o;const a={};for(const n of t){if(ae(n)){const b=((o=r[n.name])==null?void 0:o.trim())??"";if(!b){if(n.defaultValue!==void 0)a[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const d=Number(b);if(!Number.isFinite(d))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(d))throw new Error(`${n.title} must be a safe integer`);a[n.name]=d}else a[n.name]=b;continue}const h=s[n.name]??n.defaultValue;if(h===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(h)){if(n.minItems!==void 0&&h.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&h.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=h}return a}function Bt(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function ae(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Pt(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function _t(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function Lt({report:t}){const s=R(),[r,a]=f.useState(!1),o=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(et,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(se,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Fe,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:o})]})}const Vt=f.lazy(()=>Oe(()=>import("./MarkdownRenderer-C-X3g9Ky.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function ge({text:t,label:s}){const[r,a]=f.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(se,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Fe,{className:"h-3.5 w-3.5"})})}function Ot(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(ce,{size:20,pulse:!1})})}function Ut(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function ve(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function Ht(t){if(typeof t=="string")return{text:ve(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
3
|
+
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:ve(s),images:r}}function he(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
4
|
+
`)}function Kt(t){const s=t.agentContent;return s?xt(s):he(t.content)}function ke({content:t,syntaxHighlight:s=!0}){return e.jsx(f.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(Vt,{content:t,syntaxHighlight:s})})}function xe({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:A("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function zt(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}function qt({tool:t}){const[s,r]=f.useState(!1),a=zt(t.arguments);return e.jsxs("div",{className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(o=>!o),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ue,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(xe,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),t.output&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.output.length>500?t.output.slice(0,500)+"...":t.output})]})]})]})}function $e({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(qt,{tool:s},s.toolCallId))})}function Gt({toolCalls:t,toolCallIds:s}){const r=R(),[a,o]=f.useState(!1),n=f.useMemo(()=>new Map(t.map(i=>[i.toolCallId,i])),[t]),h=s.flatMap(i=>{const u=n.get(i);return u?[u]:[]});if(h.length===0)return null;const b=h.filter(i=>i.status==="running").length,d=h.filter(i=>i.status==="error").length,l=[...h].reverse().find(i=>i.status==="running"&&!!i.progressMessage),k=b>0?r(h.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:h.length}):d>0?r(h.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:h.length,errors:d}):r(h.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:h.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>o(i=>!i),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(re,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx(F,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(l==null?void 0:l.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[l.progressMessage,l.progress!==void 0&&l.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(l.progress/l.progressTotal*100)))}%`]})]}),(l==null?void 0:l.progress)!==void 0&&l.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${l.toolName} progress`,"aria-valuemin":0,"aria-valuemax":l.progressTotal,"aria-valuenow":Math.min(l.progress,l.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,l.progress/l.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx($e,{toolCalls:h})})]})}function Wt({content:t}){const s=R(),[r,a]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ue,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Jt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function Qt({toolCalls:t}){const s=de(a=>a.openFilePreview),r=f.useMemo(()=>{const a=new Map,o=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const h=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(h==null?void 0:h.changes)){for(const d of h.changes)d&&typeof d=="object"&&"path"in d&&typeof d.path=="string"&&a.set(d.path,{path:d.path,toolName:n.toolName});continue}const b=h==null?void 0:h.file_path;b&&o.includes(n.toolName)&&a.set(b,{path:b,toolName:n.toolName})}return Array.from(a.values())},[t]);return r.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:a})=>{const o=a.split("/").pop()||a;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:a}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:a,children:[e.jsx(tt,{className:"w-3 h-3"}),o]},a)})})]})}function Yt({subagent:t}){var q,H,Q,Y;const s=R(),[r,a]=f.useState(null),[o,n]=f.useState(!1),[h,b]=f.useState(null),[d,l]=f.useState(!1),[k,i]=f.useState(""),[u,c]=f.useState(!1),[j,N]=f.useState(null),[p,E]=f.useState(null),[v,x]=f.useState(null),m=y(T=>T.currentSessionRef),C=y(T=>T.isStreaming),w=y(T=>T.isTemporarySession);if(!t)return null;const B=t.status==="running",M=r!==null?r:B,V=t.toolCalls||h||[],P=t.output||t.thinking||V.length>0||t.sessionId,S=p&&p.status!=="running"?p:v,I=(S==null?void 0:S.id)??t.sessionId,U=((q=S==null?void 0:S.restartRecovery)==null?void 0:q.outcome)==="failed",ne=!B&&!C&&!w&&!U&&(p==null?void 0:p.status)!=="running"&&!!(I&&m);f.useEffect(()=>{if(!M||B||!t.sessionId||!(m!=null&&m.projectPath)||h!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return n(!0),O.getMessages({sessionId:t.sessionId,projectPath:m.projectPath}).then(_=>{var $,D;if(!T)return;const L=bt(_),g=new Map;for(const G of L)if((D=($=G.agentContent)==null?void 0:$.toolCalls)!=null&&D.length)for(const ie of G.agentContent.toolCalls)g.has(ie.toolCallId)||g.set(ie.toolCallId,ie);b(Array.from(g.values()))}).finally(()=>{T&&n(!1)}),()=>{T=!1}},[M,B,t.sessionId,t.toolCalls,h,m==null?void 0:m.projectPath]),f.useEffect(()=>{if(!t.sessionId||!m)return;let T=!0;const _=t.rootAgentId??t.sessionId,L=t.resumeDepth??0;return O.listSubagents(m).then(g=>{if(!T)return;x(g.find(D=>D.id===t.sessionId)??null);const $=g.filter(D=>D.id!==t.sessionId&&D.rootAgentId===_&&D.resumeDepth>L).sort((D,G)=>G.resumeDepth-D.resumeDepth||G.lastActiveAt-D.lastActiveAt)[0];$&&E($)}).catch(()=>{}),()=>{T=!1}},[m==null?void 0:m.sessionId,m==null?void 0:m.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!p||p.status!=="running"||!m)return;let T=!0;const _=async()=>{try{const $=(await O.listSubagents(m)).find(D=>D.id===p.id);T&&$&&E($)}catch{}},L=window.setInterval(()=>{_()},1e3);return()=>{T=!1,window.clearInterval(L)}},[m,p==null?void 0:p.id,p==null?void 0:p.status]);const z=async()=>{if(!(!m||!I||!k.trim()||u)){c(!0),N(null);try{const T=await O.resumeSubagent(m,I,k.trim());E(T.session),i(""),l(!1),a(!0)}catch(T){N(T instanceof Error?T.message:s("chat.subagent.resumeFailed"))}finally{c(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>a(!M),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[B&&e.jsx(F,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(xe,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:A("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),P&&e.jsx(re,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",M&&"rotate-180")})]}),M&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!o&&V.length>0&&e.jsx($e,{toolCalls:V}),p&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:s("chat.subagent.resumedAs",{id:p.id,status:p.status,depth:p.resumeDepth??1})}),(((H=p.result)==null?void 0:H.message)||((Q=p.result)==null?void 0:Q.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:p.result.message||p.result.error})]}),U&&((Y=S==null?void 0:S.result)==null?void 0:Y.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:S.result.error}),ne&&e.jsxs("div",{className:"space-y-2",children:[d?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":s("chat.subagent.followUpAria"),value:k,onChange:T=>i(T.target.value),placeholder:s("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{l(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void z(),disabled:!k.trim()||u,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[u&&e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>l(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(me,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function Xt({confirmation:t,messageId:s}){const r=R(),[a,o]=f.useState(!1),[n,h]=f.useState(null),b=y(k=>k.currentSessionRef),d=y(k=>k.setConfirmation);if(!t)return null;const l=async(k,i)=>{if(!(!b||a)){o(!0),h(null);try{await O.respondPermission(b,t.toolCallId,{approved:k,scope:i}),d(s,{...t,status:k?"approved":"denied"})}catch(u){h(u instanceof Error?u.message:r("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),n&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void l(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void l(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function Zt({question:t,messageId:s}){const r=R(),[a,o]=f.useState({}),[n,h]=f.useState({}),[b,d]=f.useState(!1),[l,k]=f.useState(null),i=y(p=>p.currentSessionRef),u=y(p=>p.setQuestion),c=f.useMemo(()=>t?t.questions.reduce((p,E)=>{var C;const v=(C=n[E.header])==null?void 0:C.trim(),x=a[E.header];if(E.multiSelect){const w=Array.isArray(x)?[...x]:[];return v&&w.push(v),w.length>0&&(p[E.header]=w),p}const m=v||(typeof x=="string"?x:"");return m&&(p[E.header]=m),p},{}):{},[a,n,t]),j=(t==null?void 0:t.questions.every(p=>p.header in c))??!1;if(!t)return null;const N=async()=>{if(!(!i||b||!j)){d(!0),k(null);try{await O.respondToQuestion(i,t.toolCallId,c),u(s,{...t,status:"answered",answers:c})}catch(p){k(p instanceof Error?p.message:r("interaction.question.failed"))}finally{d(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((p,E)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:p.question}),e.jsxs("div",{className:"space-y-1",children:[p.options.map((v,x)=>e.jsxs("button",{type:"button",onClick:()=>{if(p.multiSelect){const m=a[p.header]||[],C=m.includes(v.label)?m.filter(w=>w!==v.label):[...m,v.label];o({...a,[p.header]:C})}else o({...a,[p.header]:v.label}),h({...n,[p.header]:""})},className:A("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(p.multiSelect?(a[p.header]||[]).includes(v.label):a[p.header]===v.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:v.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:v.description})]},x)),e.jsx("input",{"aria-label":`${p.header} other response`,value:n[p.header]??"",onChange:v=>h({...n,[p.header]:v.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},E)),l&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:l}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:b||!j,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[b&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function es({message:t}){const s=t.agentContent,r=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=he(t.content);return j?e.jsx(ke,{content:j}):null}const{toolCalls:a,tasks:o,confirmation:n,question:h,elicitation:b}=s,d=pt(s),l=ft(s);if(!(l.length>0||o.length>0||d.length>0||n||h||b)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const u=a.length>0&&a.every(j=>j.status==="success"||j.status==="error")&&!r,c=!r;return e.jsxs("div",{className:"space-y-3",children:[l.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(Wt,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(ke,{content:j.content,syntaxHighlight:c})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Gt,{toolCalls:a,toolCallIds:j.toolCallIds})},j.id)),o.length>0&&e.jsx(Jt,{tasks:o}),d.map(j=>e.jsx(Yt,{subagent:j},j.id)),n&&e.jsx(Xt,{confirmation:n,messageId:t.id}),h&&e.jsx(Zt,{question:h,messageId:t.id}),b&&e.jsx(Mt,{elicitation:b,messageId:t.id}),u&&e.jsx(Qt,{toolCalls:a})]})}function ts({message:t,showAvatar:s=!0}){var b,d,l,k;const r=t.role==="user";if(t.role==="system"){const i=he(t.content);return e.jsx("div",{"data-chat-message-id":t.id,className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:i})})}if(r){const i=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(d=t.metadata)!=null&&d.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(i){const j=typeof i.command=="string"?i.command:"",N=i.status==="running"?"running":i.status==="completed"?"success":"error",p=typeof i.output=="string"?i.output:[typeof i.stdout=="string"?i.stdout:"",typeof i.stderr=="string"&&i.stderr?`stderr:
|
|
5
|
+
${i.stderr}`:""].filter(Boolean).join(`
|
|
6
|
+
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),j]}),e.jsx(xe,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p||"(no output)"}),typeof i.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",i.exitCode,typeof i.durationMs=="number"?` · ${(i.durationMs/1e3).toFixed(3)}s`:"",i.truncated===!0?" · truncated":""]})]})})}const{text:u,images:c}=Ht(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(ge,{text:u,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[u&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:u}),c.length>0&&e.jsx("div",{className:A("grid gap-2",c.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:c.map((j,N)=>e.jsx("img",{src:j,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${N}`))})]}),e.jsx(Ut,{})]})}const o=Kt(t),n=Tt((l=t.metadata)==null?void 0:l.codeReview),h=_t((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,className:A("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(Ot,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Ft,{report:n}):h?e.jsx(Lt,{report:h}):e.jsx(es,{message:t}),!h&&o.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(ge,{text:o,label:"Copy response"})})]})]})}const ss=f.memo(ts);function rs(t,s,r){return Math.max(0,t+(r-s))}function as(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function je(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ns({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const o=R(),[n,h]=f.useState(null),[b,d]=f.useState(!1),l=f.useRef(null),k=f.useCallback(()=>{var p;const u=s.current,c=r.current;if(!u||!c||t.length===0)return;const j=u.getBoundingClientRect().top;let N=((p=t[0])==null?void 0:p.id)??null;for(const E of t){const v=je(c,E.id);if(v)if(v.getBoundingClientRect().top-j<=24)N=E.id;else break}h(N)},[t,s,r]);f.useEffect(()=>{const u=s.current;if(!u)return;const c=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,k()}))};return k(),u.addEventListener("scroll",c,{passive:!0}),()=>{u.removeEventListener("scroll",c),l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null)}},[k,s]);const i=f.useCallback(u=>{const c=()=>{const N=je(r.current,u.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),h(u.id))};a(u.index)?c():window.requestAnimationFrame(()=>window.requestAnimationFrame(c))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocusCapture:()=>d(!0),onBlurCapture:u=>{u.currentTarget.contains(u.relatedTarget)||d(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:A("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(u=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",u.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},u.id))}),e.jsx("div",{className:A("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((u,c)=>e.jsxs("button",{type:"button",onClick:()=>i(u),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",u.id===n?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:A("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",u.id===n?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:o("chat.turns.label",{n:c+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:u.preview})]})]},u.id))})]})})}const ye=80;function is(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function os(t){const s=is(t).replace(/\s+/g," ").trim();return s?s.length>ye?`${s.slice(0,ye-1)}…`:s:""}function ls(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const o=os(a.content);o&&s.push({id:a.id,index:r,preview:o})}return s}const oe=120,le=80,cs=96;function W(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function ds({messages:t,isLoading:s}){const r=R(),a=f.useRef(null),o=f.useRef(null),n=f.useRef(!0),h=f.useRef(t.length),b=f.useRef(null),[d,l]=f.useState(oe),[k,i]=f.useState(!1);f.useEffect(()=>{const x=W(a.current);if(!x||!n.current)return;const m=window.requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight});return()=>window.cancelAnimationFrame(m)},[t]),f.useEffect(()=>{const x=W(a.current);if(!x)return;o.current=x;const m=()=>{const w=x.scrollHeight-x.scrollTop-x.clientHeight<=cs;n.current=w,i(!w)};return m(),x.addEventListener("scroll",m,{passive:!0}),()=>x.removeEventListener("scroll",m)},[]),f.useEffect(()=>{const x=h.current;h.current=t.length,l(m=>m>=x&&t.length>x?t.length:Math.min(Math.max(m,oe),t.length||oe))},[t.length]);const u=Math.max(t.length-d,0),c=u,j=f.useMemo(()=>t.slice(c),[t,c]),N=f.useMemo(()=>ls(t),[t]);if(f.useLayoutEffect(()=>{var C;const x=b.current;if(!x)return;const m=W(a.current);if(b.current=null,!!m){if((C=x.element)!=null&&C.isConnected){const w=x.element.getBoundingClientRect().top-x.viewportTop;m.scrollTop+=w;return}m.scrollTop=rs(x.scrollTop,x.scrollHeight,m.scrollHeight)}},[d]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(ce,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(st,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((x,m)=>e.jsxs("div",{className:A("flex gap-3",m%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${x}%`,animationDelay:`${m*120}ms`}})]},x))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(ce,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const p=()=>{const x=W(a.current);x&&(n.current=!0,i(!1),x.scrollTo({top:x.scrollHeight,behavior:"smooth"}))},E=()=>{var m;const x=W(a.current);if(x){const C=((m=a.current)==null?void 0:m.querySelector("[data-chat-message-id]"))??null;b.current={element:C,viewportTop:(C==null?void 0:C.getBoundingClientRect().top)??0,scrollHeight:x.scrollHeight,scrollTop:x.scrollTop}}l(C=>as(C,t.length,le))},v=x=>x>=c?!0:(l(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ue,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[u>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:E,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(u,le),remaining:u}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(u,le)})})}),j.map((x,m)=>{const C=c+m,w=C>0?t[C-1]:null,B=!w||w.role!==x.role||w.role==="user";return e.jsx(ss,{message:x,showAvatar:B},x.id||`msg-${C}`)})]})}),e.jsx(ns,{turns:N,viewportRef:o,containerRef:a,onRevealTurn:v}),k&&e.jsxs("button",{type:"button",onClick:p,className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Me,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const us=f.memo(ds),Be=kt,Pe=jt,_e=yt,pe=f.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Ie,{ref:a,sideOffset:s,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));pe.displayName=Ie.displayName;const ms={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function X(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function hs(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function xs(){var P;const t=R(),{locale:s}=He(),r=y(S=>S.goal),a=y(S=>S.pauseGoal),o=y(S=>S.resumeGoal),n=y(S=>S.editGoal),h=y(S=>S.clearGoal),[b,d]=f.useState(!1),[l,k]=f.useState(!1),[i,u]=f.useState(""),[c,j]=f.useState(null),[N,p]=f.useState(!1);if(f.useEffect(()=>{d(!1),k(!1),u((r==null?void 0:r.objective)??""),p(!1)},[r==null?void 0:r.goalId]),!r)return null;const E=ms[r.status],v=["active","verifying","paused","blocked"].includes(r.status),x=r.status==="active"||r.status==="verifying",m=r.status==="paused"||r.status==="blocked",C=c!==null,w=async(S,I)=>{j(S);try{await I()}finally{j(null)}},B=()=>{u(r.objective),k(!0),d(!0)},M=async S=>{S.preventDefault();const I=i.trim();if(!I||I===r.objective){k(!1);return}await w("edit",()=>n(I)),k(!1)},V=async()=>{await w("delete",h),p(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Be,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0",children:[e.jsxs("div",{className:A("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",b&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(rt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(at,{className:A("h-3.5 w-3.5 shrink-0",E.accent)}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",E.dot)}),e.jsx("span",{className:A("shrink-0 text-[10px] font-medium leading-none",E.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(E.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>d(S=>!S),"aria-expanded":b,title:r.objective,children:r.objective}),r.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[X(r.tokensUsed),r.tokenBudget!==void 0&&`/${X(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[x&&e.jsx(Z,{label:t("goal.action.pause"),disabled:C,onClick:()=>void w("pause",a),children:c==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(nt,{})}),m&&e.jsx(Z,{label:t("goal.action.resume"),disabled:C,onClick:()=>void w("resume",o),children:c==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(it,{})}),e.jsx(Z,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!b,onClick:v?B:()=>d(S=>!S),children:v?e.jsx(Re,{}):e.jsx(ot,{})}),e.jsx(Z,{label:t("goal.action.delete"),disabled:C,destructive:!0,onClick:()=>p(!0),children:e.jsx(ee,{})})]})]}),b&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:l?e.jsxs("form",{onSubmit:M,children:[e.jsx("textarea",{id:"goal-objective",value:i,onChange:S=>u(S.target.value),onKeyDown:S=>{S.key==="Escape"&&k(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>k(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(lt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!i.trim()||c==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[c==="edit"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(se,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:r.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ct,{className:"h-3 w-3"}),X(r.tokensUsed),r.tokenBudget!==void 0&&` / ${X(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(dt,{className:"h-3 w-3"}),hs(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(me,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.completionVerification&&e.jsxs("div",{"data-goal-verification":r.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",r.completionVerification.attempt," ·"," ",r.completionVerification.status.toUpperCase()," ·"," ",((P=r.completionVerification.verifierSessionId)==null?void 0:P.slice(0,12))??"-"]}),r.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:r.completionVerification.summary}),r.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",r.completionVerification.evidenceSha256.slice(0,12)]})]}),r.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:r.statusReason})]})})]})}),e.jsx(Se,{open:N,onOpenChange:p,children:e.jsxs(Ce,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Ee,{children:t("goal.dialog.title")}),e.jsx(Te,{children:t("goal.dialog.description")}),e.jsxs(Ae,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>p(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:c==="delete",onClick:()=>void V(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[c==="delete"&&e.jsx(F,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function Z({label:t,children:s,disabled:r,destructive:a,onClick:o}){return e.jsxs(Pe,{children:[e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:o,className:A("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(pe,{side:"top",className:"text-[10px]",children:t})]})}function ps(){const t=R(),s=y(d=>d.currentSessionRef),r=y(d=>d.sessions),a=y(d=>d.messages),o=f.useMemo(()=>{var l,k,i,u,c;const d=s?(l=Ke(r,s))==null?void 0:l.pendingInteraction:void 0;if(d)return d.type;for(let j=a.length-1;j>=0;j-=1){const N=(k=a[j])==null?void 0:k.agentContent;if(((i=N==null?void 0:N.confirmation)==null?void 0:i.status)==="pending")return"permission";if(((u=N==null?void 0:N.question)==null?void 0:u.status)==="pending")return"question";if(((c=N==null?void 0:N.elicitation)==null?void 0:c.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!o)return null;const n=()=>{const d=document.querySelector(`[data-pending-interaction="${o}"]`);d==null||d.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>d==null?void 0:d.focus(),250)},h=o==="question",b=o==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(De,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(h?"interaction.bar.questionTitle":b?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(h?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Me,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const fs={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},we=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function bs(){const t=R(),s=y(c=>c.tokenUsage),r=y(c=>c.isStreaming),a=y(c=>c.agentPhase),o=y(c=>c.providerRetry),n=y(c=>c.providerStall),h=y(c=>c.actionStationarity),b=fs[a]??"",d=(o==null?void 0:o.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(o.delayMs/1e3))}s`:"",l=h?`${t(h.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${h.toolName} · ${h.runLength}/${h.haltThreshold}`:n?`${t("status.phase.providerStall")} · ${Math.ceil(n.durationMs/1e3)}s / ${Math.ceil(n.timeoutMs/1e3)}s`:o?`Provider · ${t("chat.error.action.retryingTask")} · ${o.attempt}/${o.maxRetries}${d}`:b?t(b):"",k=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,i=Math.min(k,100),u=k>95?"danger":k>80?"warn":"safe";return e.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-5 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:A("text-[12px] font-medium",u==="safe"&&"text-[hsl(var(--deck-ink))]",u==="warn"&&"text-amber-600 dark:text-amber-400",u==="danger"&&"text-red-600 dark:text-red-400"),children:we(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",we(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Be,{children:e.jsxs(Pe,{children:[e.jsx(_e,{asChild:!0,children:e.jsx(ut,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(pe,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","aria-hidden":"true",children:[e.jsx("div",{className:A("absolute inset-y-0 left-0 transition-[width] duration-300",u==="safe"&&"bg-[hsl(var(--deck-accent))]",u==="warn"&&"bg-amber-500",u==="danger"&&"bg-red-500"),style:{width:`${i}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(c=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${c}%`}},c))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",u==="warn"&&"text-amber-600 dark:text-amber-400",u==="danger"&&"text-red-600 dark:text-red-400"),children:[k,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&l&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:l})]})]})}function gs(t){const s=[...t].reverse().find(o=>o.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(o=>o.type==="text").map(o=>o.text).join(`
|
|
7
|
+
`),a=s.content.filter(o=>o.type==="image_url").map((o,n)=>{var b;const h=((b=o.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:h,dataUrl:o.image_url.url}});return{content:r,attachments:a}}function Ns(){var L;const t=R(),s=y(g=>g.messages),r=y(g=>g.currentSessionRef),a=y(g=>g.isStreaming),o=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),h=y(g=>g.pendingSteeringCount),b=y(g=>g.pendingInputDelivery),d=y(g=>g.recoveredSteeringCount),l=y(g=>g.isLoading),k=y(g=>g.error),i=y(g=>g.errorContext),u=y(g=>g.sessions),c=y(g=>g.sendMessage),j=y(g=>g.abortSession),N=y(g=>g.retryTask),p=y(g=>g.retryingTaskKeys),E=de(g=>g.openSettings),v=y(g=>g.reconnectSessionEvents),x=y(g=>g.clearError),[m,C]=f.useState(null),w=r?u.find(g=>g.sessionId===r.sessionId&&g.projectPath===r.projectPath):void 0,B=!!k&&((i==null?void 0:i.kind)==="navigation"||!(i!=null&&i.sessionRef)||Ne(i.sessionRef,r)),M=(i==null?void 0:i.failureCode)??((L=w==null?void 0:w.taskFailure)==null?void 0:L.code),V=(i==null?void 0:i.kind)==="execution"&&M?t(gt(M)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,P=n==="connecting"||n==="reconnecting",S=a&&n!=="connected",I=r?`session:${J(r)}`:"session:temporary",U=f.useMemo(()=>gs(s),[s]),ne=r?J(r):"temporary-session",z=!!(r&&(w!=null&&w.taskRetryAvailable)&&(!M||vt(M)))&&((i==null?void 0:i.kind)==="execution"||(i==null?void 0:i.kind)==="task_action"),q=(i==null?void 0:i.kind)==="execution"&&(M==="authentication"||M==="permission"||M==="model_unavailable"),H=r?p.includes(J(r)):!1;f.useEffect(()=>{C(null)},[ne]);const Q=async g=>c({content:g.content,modelId:g.modelId,reasoningEffort:g.reasoningEffort,serviceTier:g.serviceTier,responseVerbosity:g.responseVerbosity,communicationStyle:g.communicationStyle,...g.outputSchema?{outputSchema:g.outputSchema}:{},attachments:g.attachments.map($=>({type:"image",content:$.dataUrl,mimeType:$.mimeType,name:$.name}))}),Y=()=>j(),T=async()=>{if(q){x(),E("models");return}if(z&&r){x(),await N(r).catch(()=>{});return}if((i==null?void 0:i.kind)==="execution"&&U){C({...U,revision:Date.now()}),x();return}x(),requestAnimationFrame(()=>qe())},_=z?t(H?"chat.error.action.retryingTask":"chat.error.action.retryTask"):q?t("chat.error.action.checkModels"):(i==null?void 0:i.kind)==="execution"&&U?t("chat.error.action.editResend"):(i==null?void 0:i.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[B&&e.jsxs("div",{role:"alert",className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-red-200/60 bg-red-50/80 px-4 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300 sm:px-5",children:[e.jsx(De,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((i==null?void 0:i.kind)==="submission"?"chat.error.title.submission":(i==null?void 0:i.kind)==="execution"?"chat.error.title.execution":(i==null?void 0:i.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",V]}),_&&e.jsxs("button",{type:"button",onClick:()=>void T(),disabled:H,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[z?H?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(me,{className:"h-3 w-3"}):e.jsx(Re,{className:"h-3 w-3"}),_]}),e.jsx("button",{type:"button",onClick:x,"aria-label":t("chat.error.dismiss"),className:"p-1 text-red-500 rounded transition-colors hover:bg-red-100/60 hover:text-red-700 dark:hover:bg-red-950/60 dark:hover:text-red-100",children:"✕"})]}),(P||n==="offline")&&e.jsxs("div",{role:n==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[P?e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(mt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(P?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void v().catch(()=>{}),className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(ht,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(wt,{}),e.jsx(us,{messages:s,isLoading:l},r?J(r):"temporary-session"),e.jsx(ps,{}),e.jsx(xs,{}),e.jsx(ze,{draftKey:I,draft:m==null?void 0:m.content,draftAttachments:m==null?void 0:m.attachments,draftRevision:m==null?void 0:m.revision,onSend:Q,onAbort:Y,disabled:l||S,isStreaming:a,isStopping:o,pendingSteeringCount:h,pendingInputDelivery:b,recoveredSteeringCount:d,workspacePath:r==null?void 0:r.projectPath},I),e.jsx(bs,{})]})}export{Ns as ChatView};
|
package/dist/web/assets/{CodeBlockHighlighter-coWjWCyT.js → CodeBlockHighlighter-B8-o1K2L.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-
|
|
1
|
+
import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-C-X3g9Ky.js";import"./index-D88fYWls.js";import"./vendor-radix-DXRuAJHH.js";import"./vendor-icons-ICv1v-tf.js";import"./session-events-BoJrjSZ2.js";function Pe(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function et(e,t){if(e==null)return{};var n,a,o=Pe(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function tt(e){if(Array.isArray(e))return se(e)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e,t){if(e){if(typeof e=="string")return se(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(e,t):void 0}}function ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e){return tt(e)||nt(e)||at(e)||ot()}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rt(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Z(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function it(e){var t=rt(e,"string");return Z(t)=="symbol"?t:t+""}function Te(e,t,n){return(t=it(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ce.apply(null,arguments)}function Ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function st(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var ie={};function lt(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return ie[t]||(ie[t]=st(e)),ie[t]}function ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=e.filter(function(r){return r!=="token"}),o=lt(a);return o.reduce(function(r,s){return H(H({},r),n[s])},t)}function Fe(e){return e.join(" ")}function ut(e,t){var n=0;return function(a){return n+=1,a.map(function(o,r){return Ie({node:o,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(r)})})}}function Ie(e){var t=e.node,n=e.stylesheet,a=e.style,o=a===void 0?{}:a,r=e.useInlineStyles,s=e.key,i=t.properties,c=t.type,l=t.tagName,u=t.value;if(c==="text")return u;if(l){var g=ut(n,r),d;if(!r)d=H(H({},i),{},{className:Fe(i.className)});else{var p=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(N){b.includes(N)||b.push(N)}),b},[]),f=i.className&&i.className.includes("token")?["token"]:[],v=i.className&&f.concat(i.className.filter(function(b){return!p.includes(b)}));d=H(H({},i),{},{className:Fe(v)||void 0,style:ct(i.className,Object.assign({},i.style,o),n)})}var y=g(t.children);return I.createElement(l,ce({key:s},d),y)}}const dt=function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1};var gt=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function $e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?$e(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$e(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var pt=/\n/g;function ft(e){return e.match(pt)}function ht(e){var t=e.lines,n=e.startingLineNumber,a=e.style;return t.map(function(o,r){var s=r+n;return I.createElement("span",{key:"line-".concat(r),className:"react-syntax-highlighter-line-number",style:typeof a=="function"?a(s):a},"".concat(s,`
|
|
3
3
|
`))})}function bt(e){var t=e.codeString,n=e.codeStyle,a=e.containerStyle,o=a===void 0?{float:"left",paddingRight:"10px"}:a,r=e.numberStyle,s=r===void 0?{}:r,i=e.startingLineNumber;return I.createElement("code",{style:Object.assign({},n,o)},ht({lines:t.replace(/\n$/,"").split(`
|
|
4
4
|
`),style:s,startingLineNumber:i}))}function mt(e){return"".concat(e.toString().length,".25em")}function Re(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function De(e,t,n){var a={display:"inline-block",minWidth:mt(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},o=typeof e=="function"?e(t):e,r=R(R({},a),o);return r}function J(e){var t=e.children,n=e.lineNumber,a=e.lineNumberStyle,o=e.largestLineNumber,r=e.showInlineLineNumbers,s=e.lineProps,i=s===void 0?{}:s,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,g=e.wrapLongLines,d=e.wrapLines,p=d===void 0?!1:d,f=p?R({},typeof i=="function"?i(n):i):{};if(f.className=f.className?[].concat(le(f.className.trim().split(/\s+/)),le(l)):l,n&&r){var v=De(a,n,o);t.unshift(Re(n,v))}return g&u&&(f.style=R({display:"flex"},f.style)),{type:"element",tagName:"span",properties:f,children:t}}function ze(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var a=0;a<e.length;a++){var o=e[a];if(o.type==="text")n.push(J({children:[o],className:le(new Set(t))}));else if(o.children){var r,s=t.concat(((r=o.properties)===null||r===void 0?void 0:r.className)||[]);ze(o.children,s).forEach(function(i){return n.push(i)})}}return n}function yt(e,t,n,a,o,r,s,i,c){var l,u=ze(e.value),g=[],d=-1,p=0;function f(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return J({children:S,lineNumber:k,lineNumberStyle:i,largestLineNumber:s,showInlineLineNumbers:o,lineProps:n,className:x,showLineNumbers:a,wrapLongLines:c,wrapLines:t})}function v(S,k){if(a&&k&&o){var x=De(i,k,s);S.unshift(Re(k,x))}return S}function y(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||x.length>0?f(S,k,x):v(S,k)}for(var b=function(){var k=u[p],x=k.children[0].value,E=ft(x);if(E){var j=x.split(`
|