blade-code 0.10.136 → 0.10.137

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.
Files changed (134) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-r51afpkk.js → chunk-0c82q1sz.js} +1 -1
  3. package/dist/chunk-0ccm29qy.js +2 -0
  4. package/dist/{chunk-na3nregt.js → chunk-0k2x2ae6.js} +1 -1
  5. package/dist/{chunk-v2qxszks.js → chunk-1evc05gr.js} +1 -1
  6. package/dist/chunk-35668hyn.js +1 -0
  7. package/dist/{chunk-13sdjfks.js → chunk-39de5k03.js} +1 -1
  8. package/dist/chunk-3gmcvd0c.js +1 -0
  9. package/dist/{chunk-vvawhvea.js → chunk-4jqw75ce.js} +1 -1
  10. package/dist/chunk-5774a669.js +1 -0
  11. package/dist/{chunk-qjydadex.js → chunk-5btfnf2r.js} +5 -5
  12. package/dist/{chunk-91pb41e7.js → chunk-5dwmhsrx.js} +1 -1
  13. package/dist/{chunk-c5rfnzhf.js → chunk-5sf2rc1z.js} +3 -3
  14. package/dist/{chunk-sv5z5sna.js → chunk-69nwa6bn.js} +1 -1
  15. package/dist/{chunk-wj16pvvn.js → chunk-69rjav47.js} +1 -1
  16. package/dist/{chunk-ntd69c0k.js → chunk-6e3mh79j.js} +1 -1
  17. package/dist/{chunk-gdnyt8a7.js → chunk-6xvrrypm.js} +1 -1
  18. package/dist/{chunk-tev70rzj.js → chunk-74bswv4z.js} +2 -2
  19. package/dist/{chunk-g45camrd.js → chunk-75yy9yre.js} +1 -1
  20. package/dist/chunk-7n035mhg.js +1 -0
  21. package/dist/{chunk-hx10bph0.js → chunk-7ykqvsph.js} +1 -1
  22. package/dist/chunk-9a7bppj7.js +2 -0
  23. package/dist/{chunk-kbnxbb23.js → chunk-9frd4fpk.js} +1 -1
  24. package/dist/chunk-a26vtcv5.js +5 -0
  25. package/dist/{chunk-c85xvthj.js → chunk-affzv7f1.js} +1 -1
  26. package/dist/chunk-b08thknq.js +1 -0
  27. package/dist/{chunk-sy0vxdc3.js → chunk-bx75fd0d.js} +311 -311
  28. package/dist/chunk-bzqbmz6t.js +171 -0
  29. package/dist/{chunk-77x1rrz9.js → chunk-c2mx5zg0.js} +1 -1
  30. package/dist/chunk-chspy9f8.js +23 -0
  31. package/dist/chunk-d6tbr25k.js +1 -0
  32. package/dist/chunk-dt9n4f4e.js +1 -0
  33. package/dist/{chunk-82x77b2p.js → chunk-e76gej4y.js} +2 -2
  34. package/dist/{chunk-g4vgnxh4.js → chunk-e8pfbb6c.js} +1 -1
  35. package/dist/chunk-ermypm1x.js +2 -0
  36. package/dist/chunk-esp69w6w.js +1 -0
  37. package/dist/{chunk-5sknjz9b.js → chunk-etf3e9kt.js} +1 -1
  38. package/dist/{chunk-1cbaqh71.js → chunk-f2b9cyj5.js} +2 -2
  39. package/dist/chunk-g1y60ey9.js +1 -0
  40. package/dist/{chunk-jc28ddt0.js → chunk-g799czsy.js} +1 -1
  41. package/dist/{chunk-w2n1vwzg.js → chunk-g9vdmvk2.js} +2 -2
  42. package/dist/chunk-gf5v8aff.js +1 -0
  43. package/dist/chunk-gpj7k3er.js +6 -0
  44. package/dist/{chunk-hqwpnb0x.js → chunk-h05qhgrb.js} +1 -1
  45. package/dist/{chunk-24rsvr6e.js → chunk-h74p51hg.js} +1 -1
  46. package/dist/{chunk-f7hsagj6.js → chunk-karq4wfd.js} +1 -1
  47. package/dist/{chunk-9z9v8v4j.js → chunk-ky9br0z8.js} +1 -1
  48. package/dist/chunk-m9kh7djg.js +6 -0
  49. package/dist/{chunk-qm96k94k.js → chunk-mavranwn.js} +3 -3
  50. package/dist/{chunk-6rvrx275.js → chunk-mthf5akx.js} +2 -2
  51. package/dist/{chunk-jb8stg10.js → chunk-mzye1ah2.js} +1 -1
  52. package/dist/chunk-na4wzne8.js +1 -0
  53. package/dist/chunk-ntmkzrs8.js +1 -0
  54. package/dist/{chunk-1p9sjb8d.js → chunk-nxnmqk4s.js} +1 -1
  55. package/dist/{chunk-mq1mk3v5.js → chunk-p0gbxaqz.js} +1 -1
  56. package/dist/chunk-pj15kt5b.js +10 -0
  57. package/dist/chunk-pv1vwasz.js +1 -0
  58. package/dist/{chunk-mm1atkae.js → chunk-ramana2t.js} +2 -2
  59. package/dist/{chunk-1pmvyqed.js → chunk-rgjr7jsd.js} +1 -1
  60. package/dist/{chunk-0qq64xqm.js → chunk-v5503t2t.js} +3 -3
  61. package/dist/chunk-vda03kxj.js +1 -0
  62. package/dist/{chunk-cgkbdh2m.js → chunk-vg3zwv4g.js} +1 -1
  63. package/dist/chunk-vp6d1fqp.js +3 -0
  64. package/dist/{chunk-xtngc0th.js → chunk-w9z34f27.js} +1 -1
  65. package/dist/{chunk-nzwh9v6t.js → chunk-wa71vstt.js} +1 -1
  66. package/dist/{chunk-ffh4c30x.js → chunk-wc9wsyrc.js} +1 -1
  67. package/dist/{chunk-bdtpq7j9.js → chunk-wxtj6gqb.js} +1 -1
  68. package/dist/{chunk-zy2etr3v.js → chunk-wxypv01z.js} +2 -2
  69. package/dist/{chunk-s3a017q7.js → chunk-xg9fyvw0.js} +2 -2
  70. package/dist/{chunk-fnc97xg7.js → chunk-xt0ktytp.js} +1 -1
  71. package/dist/{chunk-46jmq302.js → chunk-y6jee9w7.js} +1 -1
  72. package/dist/{chunk-yacv7f7h.js → chunk-ybc5myz7.js} +1 -1
  73. package/dist/{chunk-mxe4pr8t.js → chunk-zk9rf1d7.js} +1 -1
  74. package/dist/web/assets/ChatView-DpvPjAh7.js +63 -0
  75. package/dist/web/assets/{CodeBlockHighlighter-41xRPXs2.js → CodeBlockHighlighter-Czp4VZIg.js} +1 -1
  76. package/dist/web/assets/{FilePreview-lcc_hL7J.js → FilePreview-BJWuYfyF.js} +7 -7
  77. package/dist/web/assets/{KanbanBoard-BHgM338V.js → KanbanBoard-DrYzt5Kh.js} +2 -2
  78. package/dist/web/assets/{MarkdownRenderer-BMAuTkc6.js → MarkdownRenderer-DxkR5r7t.js} +3 -3
  79. package/dist/web/assets/{ScrollArea-DJq2Kdpi.js → ScrollArea-D71pJjgW.js} +1 -1
  80. package/dist/web/assets/{SessionHistorySurface-DSe8ePBJ.js → SessionHistorySurface-2y9bnndm.js} +1 -1
  81. package/dist/web/assets/{SettingsModal-Cih4bWul.js → SettingsModal-BbaTL5Rk.js} +1 -1
  82. package/dist/web/assets/{Sidebar-DnWlUKmO.js → Sidebar-COZltpL9.js} +2 -2
  83. package/dist/web/assets/{TaskSwitcher-D3mrXv_i.js → TaskSwitcher-3giB7l1P.js} +1 -1
  84. package/dist/web/assets/{TerminalPanel-BNKHhBVM.js → TerminalPanel-gvTTiTgX.js} +1 -1
  85. package/dist/web/assets/{archive-Dof4YpyT.js → archive-DndqAA2q.js} +1 -1
  86. package/dist/web/assets/{arrow-left-DGFXaGox.js → arrow-left-XNYfpUAb.js} +1 -1
  87. package/dist/web/assets/{calendar-clock-BoxUNOvH.js → calendar-clock-BQOfNcCK.js} +1 -1
  88. package/dist/web/assets/{chevron-right-Brb1rhaA.js → chevron-right-Cvq3LzHK.js} +1 -1
  89. package/dist/web/assets/{chevrons-up-down-N-VshXV_.js → chevrons-up-down-Dia1U9Sz.js} +1 -1
  90. package/dist/web/assets/{clock-3-gdZEKe2U.js → clock-3-CnxLS8cv.js} +1 -1
  91. package/dist/web/assets/{copy-d9M8JUfQ.js → copy-CWCS3Lql.js} +1 -1
  92. package/dist/web/assets/{download-CQ-Pwfq0.js → download-DXdsM18t.js} +1 -1
  93. package/dist/web/assets/{external-link-GRAtjoO2.js → external-link-1IN2ZfaO.js} +1 -1
  94. package/dist/web/assets/{folder-CqLD0IBh.js → folder-Bpq602dI.js} +1 -1
  95. package/dist/web/assets/index-57UZsfTt.css +1 -0
  96. package/dist/web/assets/index-DEOQizD2.js +203 -0
  97. package/dist/web/assets/{pause-BqsFgQi0.js → pause-BYhoGDZq.js} +1 -1
  98. package/dist/web/assets/{pencil-Ca9289F-.js → pencil-pRZQVHFU.js} +1 -1
  99. package/dist/web/assets/{play-DmEPnYDS.js → play-DGZdCyPk.js} +1 -1
  100. package/dist/web/assets/{plus-kIBLgk0p.js → plus-CAQ3qlUJ.js} +1 -1
  101. package/dist/web/assets/session-events-C5_Q0kZV.js +29 -0
  102. package/dist/web/assets/{settings-BuSrJl6s.js → settings-BPfzj_Vf.js} +1 -1
  103. package/dist/web/assets/{teamService-B7Fp8Oyg.js → teamService-BScT9o9A.js} +1 -1
  104. package/dist/web/assets/{terminal-Qkr_gcNu.js → terminal-CldJbdMr.js} +1 -1
  105. package/dist/web/index.html +2 -2
  106. package/package.json +1 -1
  107. package/dist/chunk-1dscf8xj.js +0 -23
  108. package/dist/chunk-1n5d6b5k.js +0 -1
  109. package/dist/chunk-1qdemrkr.js +0 -1
  110. package/dist/chunk-83nxcfz3.js +0 -1
  111. package/dist/chunk-9y7j565j.js +0 -6
  112. package/dist/chunk-acsfh1cw.js +0 -5
  113. package/dist/chunk-as8stb2j.js +0 -10
  114. package/dist/chunk-azaqc1b6.js +0 -1
  115. package/dist/chunk-e1warjkn.js +0 -171
  116. package/dist/chunk-g13jmewd.js +0 -1
  117. package/dist/chunk-g7h0peka.js +0 -3
  118. package/dist/chunk-gq7fdc8c.js +0 -2
  119. package/dist/chunk-gwjah260.js +0 -1
  120. package/dist/chunk-n238rdz8.js +0 -1
  121. package/dist/chunk-nfzad4te.js +0 -2
  122. package/dist/chunk-pnanbvn3.js +0 -1
  123. package/dist/chunk-pz91qga3.js +0 -1
  124. package/dist/chunk-s4b1r3my.js +0 -1
  125. package/dist/chunk-t6cajkaj.js +0 -6
  126. package/dist/chunk-tah2002b.js +0 -1
  127. package/dist/chunk-tzfd2fza.js +0 -1
  128. package/dist/chunk-v3veeja5.js +0 -1
  129. package/dist/chunk-vptn8fhx.js +0 -2
  130. package/dist/chunk-wj813rcc.js +0 -1
  131. package/dist/web/assets/ChatView-Bc9twpWM.js +0 -63
  132. package/dist/web/assets/index-CPpIFWLG.css +0 -1
  133. package/dist/web/assets/index-DiRs2_w4.js +0 -203
  134. package/dist/web/assets/session-events-BqQQkbAN.js +0 -29
@@ -1,2 +1,2 @@
1
- import{Ti as b,Ui as k,Wi as w}from"./chunk-nfzad4te.js";function g(j){return b.Object(j,{additionalProperties:!1})}var W=b.String({pattern:"^acp-remote-workspace:[A-Za-z0-9_-]{43}$"}),I=b.Optional(b.Integer({minimum:1,maximum:100})),x=b.String({minLength:1,maxLength:200,pattern:"^[A-Za-z0-9_-][A-Za-z0-9._-]{0,199}$"}),A=k(b.Union([g({version:b.Literal(2),sessionId:x,workspace:g({kind:b.Literal("local"),projectPath:b.String({minLength:1})})}),g({version:b.Literal(2),sessionId:x,workspace:g({kind:b.Literal("acp-remote"),workspaceRef:W})})])),C=k(w(["history-only","owner-offline","owner-mismatch","archived","surface-not-supported","capability-not-advertised"])),X=k(g({connection:w(["local","online","offline"]),history:g({read:b.Boolean(),fork:b.Boolean()}),turn:g({start:b.Boolean(),reason:b.Optional(C)}),files:g({readText:b.Boolean(),writeText:b.Boolean(),browse:w(["none","known-files","tree"]),reason:b.Optional(C)}),terminal:g({mode:w(["none","command","interactive"]),owner:w(["none","local","acp-remote"]),reason:b.Optional(C)})})),Y=k(g({id:b.String({pattern:"^surface-message:[0-9]+:.+$"}),role:w(["user","assistant"]),content:b.String(),timestamp:b.String({minLength:1}),truncated:b.Optional(b.Boolean())})),Z=w(["queued","running","completed","failed","cancelled","interrupted"]),_=w(["posix","win32"]),$=w(["subagent","fork"]),D=b.String({minLength:1}),J=b.String({minLength:1}),z=40,H=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-](\d{2}):(\d{2}))$/,M="^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}Z$";function T(j){return j%4===0&&(j%100!==0||j%400===0)}function R(j,q){if(q===2)return T(j)?29:28;return[4,6,9,11].includes(q)?30:31}function d(j){if(j===void 0||j.length<20||j.length>z)return;let q=H.exec(j);if(!q)return;let L=Number(q[1]),B=Number(q[2]),E=Number(q[3]),N=Number(q[4]),O=Number(q[5]),P=Number(q[6]),Q=q[8],U=Number(q[9]),V=Number(q[10]);if(B<1||B>12||E<1||E>R(L,B)||N>23||O>59||P>59||Q!=="Z"&&(U>23||V>59))return;let F=Date.parse(j);if(!Number.isFinite(F))return;let G=new Date(F).toISOString();return G.length===24?G:void 0}var S=b.Refine(b.String({minLength:24,maxLength:24,pattern:M}),(j)=>d(j)===j,()=>"must be a canonical ISO instant"),K=k(g({locator:A,displayCwd:b.String({minLength:1}),pathStyle:b.Optional(_),title:b.Optional(b.String()),rootId:x,parentId:b.Optional(x),relationType:b.Optional($),taskStatus:Z,taskCompletedAt:b.Optional(S),messageCount:b.Integer({minimum:0}),firstMessageTime:b.String({minLength:1}),lastMessageTime:b.String({minLength:1}),hasErrors:b.Boolean(),archivedAt:b.Optional(b.String({minLength:1})),selectedModelId:b.Optional(b.String({minLength:1})),capabilities:X})),p=k(w(["invalid_session_surface_request","invalid_session_locator","session_surface_not_found","workspace_binding_mismatch","session_surface_cursor_invalid","session_surface_snapshot_changed","session_surface_read_only","session_surface_capability_unavailable","session_surface_capacity","session_surface_unavailable","session_surface_state_invalid"])),i=k(g({error:g({code:p,message:b.String({minLength:1}),retryable:b.Boolean()})})),s=k(g({sessions:b.Array(K),nextCursor:b.Optional(D)})),f=k(g({messages:b.Array(Y),olderCursor:b.Optional(D),snapshot:J,truncated:b.Boolean()})),v=k(g({locator:A,limit:I})),l=k(g({session:K,history:f})),r=k(g({locator:A,cursor:D,expectedSnapshot:J,limit:I})),n=k(g({locator:A}));
1
+ import{wj as b,xj as k,zj as w}from"./chunk-vp6d1fqp.js";function g(j){return b.Object(j,{additionalProperties:!1})}var W=b.String({pattern:"^acp-remote-workspace:[A-Za-z0-9_-]{43}$"}),I=b.Optional(b.Integer({minimum:1,maximum:100})),x=b.String({minLength:1,maxLength:200,pattern:"^[A-Za-z0-9_-][A-Za-z0-9._-]{0,199}$"}),A=k(b.Union([g({version:b.Literal(2),sessionId:x,workspace:g({kind:b.Literal("local"),projectPath:b.String({minLength:1})})}),g({version:b.Literal(2),sessionId:x,workspace:g({kind:b.Literal("acp-remote"),workspaceRef:W})})])),C=k(w(["history-only","owner-offline","owner-mismatch","archived","surface-not-supported","capability-not-advertised"])),X=k(g({connection:w(["local","online","offline"]),history:g({read:b.Boolean(),fork:b.Boolean()}),turn:g({start:b.Boolean(),reason:b.Optional(C)}),files:g({readText:b.Boolean(),writeText:b.Boolean(),browse:w(["none","known-files","tree"]),reason:b.Optional(C)}),terminal:g({mode:w(["none","command","interactive"]),owner:w(["none","local","acp-remote"]),reason:b.Optional(C)})})),Y=k(g({id:b.String({pattern:"^surface-message:[0-9]+:.+$"}),role:w(["user","assistant"]),content:b.String(),timestamp:b.String({minLength:1}),truncated:b.Optional(b.Boolean())})),Z=w(["queued","running","completed","failed","cancelled","interrupted"]),_=w(["posix","win32"]),$=w(["subagent","fork"]),D=b.String({minLength:1}),J=b.String({minLength:1}),z=40,H=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-](\d{2}):(\d{2}))$/,M="^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}Z$";function T(j){return j%4===0&&(j%100!==0||j%400===0)}function R(j,q){if(q===2)return T(j)?29:28;return[4,6,9,11].includes(q)?30:31}function d(j){if(j===void 0||j.length<20||j.length>z)return;let q=H.exec(j);if(!q)return;let L=Number(q[1]),B=Number(q[2]),E=Number(q[3]),N=Number(q[4]),O=Number(q[5]),P=Number(q[6]),Q=q[8],U=Number(q[9]),V=Number(q[10]);if(B<1||B>12||E<1||E>R(L,B)||N>23||O>59||P>59||Q!=="Z"&&(U>23||V>59))return;let F=Date.parse(j);if(!Number.isFinite(F))return;let G=new Date(F).toISOString();return G.length===24?G:void 0}var S=b.Refine(b.String({minLength:24,maxLength:24,pattern:M}),(j)=>d(j)===j,()=>"must be a canonical ISO instant"),K=k(g({locator:A,displayCwd:b.String({minLength:1}),pathStyle:b.Optional(_),title:b.Optional(b.String()),rootId:x,parentId:b.Optional(x),relationType:b.Optional($),taskStatus:Z,taskCompletedAt:b.Optional(S),messageCount:b.Integer({minimum:0}),firstMessageTime:b.String({minLength:1}),lastMessageTime:b.String({minLength:1}),hasErrors:b.Boolean(),archivedAt:b.Optional(b.String({minLength:1})),selectedModelId:b.Optional(b.String({minLength:1})),capabilities:X})),p=k(w(["invalid_session_surface_request","invalid_session_locator","session_surface_not_found","workspace_binding_mismatch","session_surface_cursor_invalid","session_surface_snapshot_changed","session_surface_read_only","session_surface_capability_unavailable","session_surface_capacity","session_surface_unavailable","session_surface_state_invalid"])),i=k(g({error:g({code:p,message:b.String({minLength:1}),retryable:b.Boolean()})})),s=k(g({sessions:b.Array(K),nextCursor:b.Optional(D)})),f=k(g({messages:b.Array(Y),olderCursor:b.Optional(D),snapshot:J,truncated:b.Boolean()})),v=k(g({locator:A,limit:I})),l=k(g({session:K,history:f})),r=k(g({locator:A,cursor:D,expectedSnapshot:J,limit:I})),n=k(g({locator:A}));
2
2
  export{A as Ze,Y as _e,d as $e,K as af,i as bf,s as cf,f as df,v as ef,l as ff,r as gf,n as hf};
@@ -1,4 +1,4 @@
1
- import{da as p}from"./chunk-sy0vxdc3.js";import{Hb as _}from"./chunk-c5rfnzhf.js";import{Fd as q,_d as O,qd as N,rd as U,sd as I,td as A,ud as z}from"./chunk-mxe4pr8t.js";import{ke as o}from"./chunk-mq1mk3v5.js";import{Wf as P}from"./chunk-q0s3gcjm.js";import{tg as e}from"./chunk-1cbaqh71.js";import{pk as j}from"./chunk-na3nregt.js";import{createHash as ff}from"node:crypto";var af=4,cf=1000,E=4000,wf=120000,M=0.2;function $f(a){try{return q(a)&&a.retryable}catch{return!1}}function gf(a,c){let f=Number.isSafeInteger(c)&&c>0?c:1,w=f-1,h=Math.min(cf*2**w,E),$=ff("sha256").update(`${a}\x00${f}`).digest().readUInt32BE(0)/4294967295,k=1-M+2*M*$;return Math.min(E,Math.max(0,Math.round(h*k)))}function Tf(a){let c=gf(a.sessionIdentity,a.failedAttempt),f=a.evidence,w=a.workStillPending===!0&&f!==void 0&&$f(f.taskFailure)&&f.outputStarted===!1&&f.toolExecutionStarted===!1&&Number.isInteger(f.toolCallsCount)&&f.toolCallsCount===0,h=Number.isSafeInteger(a.failedAttempt)&&a.failedAttempt>0&&a.failedAttempt<af,g=a.now??Date.now(),$=g-a.recoveryStartedAt,k=Number.isFinite(g)&&Number.isFinite(a.recoveryStartedAt)&&Number.isFinite($)&&$>=0&&$+c<=wf;return{phase:w?h&&k?"retry_scheduled":"exhausted":"failed",delayMs:c,retryable:w,withinAttemptBudget:h,withinTimeBudget:k}}import R from"node:path";import{nanoid as Lf}from"nanoid";import{execFile as hf}from"node:child_process";import{createHash as xf}from"node:crypto";import{lstat as bf,readFile as mf,realpath as i}from"node:fs/promises";import n from"node:path";import{promisify as kf}from"node:util";var lf=kf(hf),T=8388608,s=500,u=200;async function C(a,c){try{return(await lf("git",["-c","core.pager=cat",...c],{cwd:a,encoding:"utf8",timeout:30000,maxBuffer:T+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let w=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${T} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${w}`)}}function d(a,c){let f=a?.trim();if(!f||f.length>u||f.includes("\x00")||f.includes(`
1
+ import{da as p}from"./chunk-bx75fd0d.js";import{Hb as _}from"./chunk-5sf2rc1z.js";import{Fd as q,_d as O,qd as N,rd as U,sd as I,td as A,ud as z}from"./chunk-zk9rf1d7.js";import{ke as o}from"./chunk-p0gbxaqz.js";import{Wf as P}from"./chunk-q0s3gcjm.js";import{vg as e}from"./chunk-f2b9cyj5.js";import{rk as j}from"./chunk-0k2x2ae6.js";import{createHash as ff}from"node:crypto";var af=4,cf=1000,E=4000,wf=120000,M=0.2;function $f(a){try{return q(a)&&a.retryable}catch{return!1}}function gf(a,c){let f=Number.isSafeInteger(c)&&c>0?c:1,w=f-1,h=Math.min(cf*2**w,E),$=ff("sha256").update(`${a}\x00${f}`).digest().readUInt32BE(0)/4294967295,k=1-M+2*M*$;return Math.min(E,Math.max(0,Math.round(h*k)))}function Tf(a){let c=gf(a.sessionIdentity,a.failedAttempt),f=a.evidence,w=a.workStillPending===!0&&f!==void 0&&$f(f.taskFailure)&&f.outputStarted===!1&&f.toolExecutionStarted===!1&&Number.isInteger(f.toolCallsCount)&&f.toolCallsCount===0,h=Number.isSafeInteger(a.failedAttempt)&&a.failedAttempt>0&&a.failedAttempt<af,g=a.now??Date.now(),$=g-a.recoveryStartedAt,k=Number.isFinite(g)&&Number.isFinite(a.recoveryStartedAt)&&Number.isFinite($)&&$>=0&&$+c<=wf;return{phase:w?h&&k?"retry_scheduled":"exhausted":"failed",delayMs:c,retryable:w,withinAttemptBudget:h,withinTimeBudget:k}}import R from"node:path";import{nanoid as Lf}from"nanoid";import{execFile as hf}from"node:child_process";import{createHash as xf}from"node:crypto";import{lstat as bf,readFile as mf,realpath as i}from"node:fs/promises";import n from"node:path";import{promisify as kf}from"node:util";var lf=kf(hf),T=8388608,s=500,u=200;async function C(a,c){try{return(await lf("git",["-c","core.pager=cat",...c],{cwd:a,encoding:"utf8",timeout:30000,maxBuffer:T+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let w=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${T} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${w}`)}}function d(a,c){let f=a?.trim();if(!f||f.length>u||f.includes("\x00")||f.includes(`
2
2
  `)||f.includes("\r"))throw Error(`${c} must contain 1-${u} characters`);return f}function Q(a){return a.split("\x00").filter(Boolean)}async function X(a,c){return(await C(a,["rev-parse","--verify",`${c}^{commit}`])).trim()}async function Ff(a,c,f,w,h){let g=h,$=await i(a);for(let k of c){let l=n.resolve($,k),x=n.relative($,l);if(!x||x.startsWith("..")||n.isAbsolute(x))throw Error(`Untracked review path escapes the workspace: ${k}`);let b=await bf(l);if(!b.isFile()||b.isSymbolicLink())throw Error(`Untracked review target must be a regular file: ${k}`);if(g+=b.size,g>T)throw Error(`Review target exceeds ${T} bytes`);f.update("\x00untracked\x00"),f.update(x.replaceAll(n.sep,"/")),f.update("\x00");let F=await mf(l);f.update(F);let m=Math.max(1,F.toString("utf8").split(`
3
3
  `).length);w.set(x.replaceAll(n.sep,"/"),[{start:1,end:m}])}}function Y(a,c){let f=new Map,w,h,g,$,k=!1,l=(x,b)=>{let F=f.get(x)??[],m=F.at(-1);if(m&&b<=m.end+1)m.end=Math.max(m.end,b);else F.push({start:b,end:b});f.set(x,F)};for(let x of a.split(`
4
4
  `)){if(x.startsWith("--- ")){let b=x.slice(4).split("\t")[0]?.trim();w=b&&b!=="/dev/null"?b.replace(/^a\//,"").replaceAll("\\","/"):void 0;continue}if(x.startsWith("+++ ")){let b=x.slice(4).split("\t")[0]?.trim();k=b==="/dev/null",h=k?w:b?b.replace(/^b\//,"").replaceAll("\\","/"):void 0,g=void 0,$=void 0;continue}if(x.startsWith("@@ ")){let b=/-(\d+)(?:,\d+)? \+(\d+)(?:,\d+)?/.exec(x);g=b?Math.max(1,Number(b[1])):void 0,$=b?Math.max(1,Number(b[2])):void 0;continue}if(!h||g===void 0||$===void 0)continue;if(x.startsWith("+")&&!x.startsWith("+++"))l(h,$),$++;else if(x.startsWith("-")&&!x.startsWith("---"))l(h,k?g:$),g++;else if(!x.startsWith("\\"))g++,$++}for(let x of c)if(!f.has(x))f.set(x,[{start:1,end:1}]);return f}function D(a){if(a.length>s)throw Error(`Review target exceeds the ${s} file limit`)}class K{static async resolve(a,c){let f=await i(a);await C(f,["rev-parse","--is-inside-work-tree"]);let w=await X(f,"HEAD"),h=xf("sha256");h.update(`kind\x00${c.kind}\x00head\x00${w}\x00`);let g="",$=[],k,l,x,b,F=new Map;switch(c.kind){case"uncommitted":{g=await C(f,["diff","--binary","--no-ext-diff","--relative","HEAD","--","."]);let m=Q(await C(f,["diff","--name-only","-z","--relative","HEAD","--","."])),L=Q(await C(f,["ls-files","--others","--exclude-standard","-z","--","."]));if($=[...new Set([...m,...L])].sort(),D($),$.length===0)throw Error("No uncommitted changes to review");h.update(g),F=Y(g,m),await Ff(f,L,h,F,Buffer.byteLength(g)),x="uncommitted changes",b=["Review the uncommitted working tree against HEAD.","Use git status --short, git diff --cached, and git diff, then inspect","every relevant untracked file listed by git status."].join(" ");break}case"base":{let m=d(c.ref,"Base ref");k=await X(f,m);let L=(await C(f,["merge-base",k,w])).trim();if(g=await C(f,["diff","--binary","--no-ext-diff","--relative",`${L}..${w}`,"--","."]),$=Q(await C(f,["diff","--name-only","-z","--relative",`${L}..${w}`,"--","."])),D($),$.length===0)throw Error(`No changes between ${m} and HEAD`);h.update(g),h.update(`\x00merge-base\x00${L}`),F=Y(g,$),x=`changes against ${m}`,b=`Review changes introduced by ${L}..${w}.`;break}case"commit":{let m=d(c.ref,"Commit ref");if(l=await X(f,m),g=await C(f,["show","--format=","--binary","--no-ext-diff","--relative",l,"--","."]),$=Q(await C(f,["diff-tree","--root","--no-commit-id","--name-only","-r","-z",l,"--","."])),D($),$.length===0)throw Error(`Commit has no changes in this workspace: ${m}`);h.update(g),h.update(`\x00commit\x00${l}`),F=Y(g,$),x=`commit ${m}`,b=`Review only the changes introduced by commit ${l}.`;break}}if(Buffer.byteLength(g)>T)throw Error(`Review diff exceeds ${T} bytes`);return{info:{kind:c.kind,label:x,headSha:w,...k?{baseSha:k}:{},...l?{commitSha:l}:{},digest:h.digest("hex"),fileCount:$.length},instruction:b,changedLines:F}}}var Wf=131072,t=50,Z=new Set;function v(a,c){return`${R.resolve(a)}\x00${c}`}function S(a){return`/review ${a.kind}${a.kind==="uncommitted"?"":` ${a.ref?.trim()??""}`}`}function V(a,c,f,w=!1){if(typeof a!=="string")throw Error(`${c} must be a string`);let h=a.trim();if(!w&&!h||h.length>f)throw Error(`${c} exceeds its allowed length`);return h}function Hf(a,c,f){if(!a||typeof a!=="object"||Array.isArray(a))throw Error("Review finding must be an object");let w=a,h=typeof w.line==="number"&&Number.isInteger(w.line)?w.line:void 0,g=w.code_location??(typeof w.file==="string"&&h!==void 0?{path:w.file,line_start:h,line_end:h}:void 0);if(!g||typeof g!=="object"||Array.isArray(g))throw Error("Review finding has no code_location");let $=g,k=V($.path,"Finding path",1000),l=R.posix.normalize(k.replaceAll("\\","/"));if(R.posix.isAbsolute(l)||l===".."||l.startsWith("../"))throw Error("Review finding path must be workspace-relative");let x=R.resolve(c,l),b=R.relative(R.resolve(c),x);if(b.startsWith("..")||R.isAbsolute(b))throw Error("Review finding path escapes the workspace");let F=typeof w.severity==="string"?w.severity.toLowerCase():"",m=F==="critical"?0:F==="high"?1:F==="medium"?2:F==="low"?3:void 0,L=w.priority??m;if(L!==0&&L!==1&&L!==2&&L!==3)throw Error("Review finding priority must be 0-3");let W=w.confidence_score??w.confidence??0.8;if(typeof W!=="number"||!Number.isFinite(W)||W<0||W>1)throw Error("Review finding confidence_score must be between 0 and 1");let{line_start:H,line_end:r}=$;if(!Number.isInteger(H)||!Number.isInteger(r)||H<1||r<H||r-H>=10)throw Error("Review finding line range is invalid");let G=f.changedLines.get(l);if(!G)throw Error("Review finding path is outside the review target");if(!G.some((y)=>H<=y.end&&r>=y.start))throw Error("Review finding line range does not overlap the changed lines");let B=V(w.title??`[P${L}] ${String(w.type??"Review finding").replaceAll("-"," ").replace(/\b\w/g,(y)=>y.toUpperCase())}`,"Finding title",120);if(!B.startsWith(`[P${L}] `))throw Error("Review finding title priority does not match priority");return{title:B,body:V(w.body??w.description,"Finding body",4000),priority:L,confidenceScore:W,codeLocation:{path:l,lineStart:H,lineEnd:r}}}function Rf(a,c,f){if(Buffer.byteLength(a)>Wf)throw Error("Review output exceeds the 128 KiB limit");let w=a.indexOf("{"),h=a.lastIndexOf("}");if(w<0||h<=w)throw Error("Reviewer did not return a JSON object");let g;try{g=JSON.parse(a.slice(w,h+1))}catch{throw Error("Reviewer returned invalid JSON")}if(!g||typeof g!=="object"||Array.isArray(g))throw Error("Reviewer output must be an object");let $=g;if(!Array.isArray($.findings))throw Error("Reviewer output must contain findings");if($.findings.length>t)throw Error(`Reviewer returned more than ${t} findings`);return{overallExplanation:V($.overall_explanation??$.summary,"Review explanation",1e4,!0),findings:$.findings.map((k)=>Hf(k,c,f))}}async function J(a,c){return new o(j(a,c)).readAll()}class rf{static async start(a){let{sessionId:c,projectPath:f,runtime:w,request:h,onEvent:g}=a;if(w.sessionId!==c||R.resolve(w.workspaceRoot)!==R.resolve(f))throw Error("Review runtime does not own the requested Session");if(w.hasTurnOwner())throw Error("Cannot start a review during an active turn");await O.assertSessionWritable(c,f);let $=v(f,c);if(Z.has($))throw Error("Session already has an active review");let k=await J(f,c);if(U(k))throw Error("Session has an interrupted review that must be recovered");let l=h.instructions?.trim();if(l&&l.length>4000)throw Error("Review instructions exceed 4,000 characters");let x=await K.resolve(f,h),b=Lf(16),F=P("review"),m=new Date().toISOString(),L={reviewId:b,reviewerSessionId:F,target:x.info,startedAt:m},W=new _(f);await W.saveReviewStart(c,L),await W.saveMessage(c,"user",S(h),null,{codeReview:{reviewId:b,phase:"started",targetKind:x.info.kind,targetDigest:x.info.digest}}),await O.updateSessionMetadata(c,f,{taskStatus:"running",taskStatusReason:`Reviewing ${x.info.label}`,taskPromptSummary:S(h),taskStartedAt:m,taskCompletedAt:null,taskFailure:null}),Z.add($);let H=this.execute({...a,target:x,reviewId:b,reviewerSessionId:F,instructions:l,store:W,onEvent:g}).finally(()=>{Z.delete($)});return{reviewId:b,completion:H}}static async execute(a){let{sessionId:c,projectPath:f,runtime:w,request:h,signal:g,onEvent:$,target:k,reviewId:l,reviewerSessionId:x,instructions:b,store:F}=a,m;try{let W=[k.instruction,"Bash already starts in the review workspace. Never prefix a command with cd.",`Authoritative target digest: ${k.info.digest}`,`Changed file count: ${k.info.fileCount}`,b?`Additional review instructions:
@@ -1 +1 @@
1
- import"./chunk-ntd69c0k.js";var d={command:"install [target]",describe:"Install Blade native build. Use [target] to specify version (stable, latest, or specific version)",builder:(b)=>{return b.positional("target",{describe:"Version to install",type:"string",default:"stable",choices:["stable","latest"]}).option("force",{type:"boolean",describe:"Force reinstall",default:!1}).example([["$0 install","Install stable version"],["$0 install latest","Install latest version"],["$0 install --force","Force reinstall stable version"]])},handler:async(b)=>{console.log(`Installing Blade ${b.target}...`);try{if(b.force)console.log("Force reinstall enabled");console.log("Downloading..."),console.log("Installing..."),console.log("Installation completed successfully")}catch(c){console.error(`Error: Installation failed: ${c instanceof Error?c.message:"未知错误"}`),process.exit(1)}}};export{d as installCommands};
1
+ import"./chunk-6e3mh79j.js";var d={command:"install [target]",describe:"Install Blade native build. Use [target] to specify version (stable, latest, or specific version)",builder:(b)=>{return b.positional("target",{describe:"Version to install",type:"string",default:"stable",choices:["stable","latest"]}).option("force",{type:"boolean",describe:"Force reinstall",default:!1}).example([["$0 install","Install stable version"],["$0 install latest","Install latest version"],["$0 install --force","Force reinstall stable version"]])},handler:async(b)=>{console.log(`Installing Blade ${b.target}...`);try{if(b.force)console.log("Force reinstall enabled");console.log("Downloading..."),console.log("Installing..."),console.log("Installation completed successfully")}catch(c){console.error(`Error: Installation failed: ${c instanceof Error?c.message:"未知错误"}`),process.exit(1)}}};export{d as installCommands};
@@ -1,4 +1,4 @@
1
- import{De as r2,Ee as C0,Le as l_,Ne as N1,Pe as o2,Qe as a2,Re as q1,Se as t2,fe as h2,ge as e,he as l2,ie as Z1,je as c2,ke as m,le as G1,me as p2,ne as n2,oe as V1,pe as L1,qe as d2,re as H1,se as A0,te as U1,ue as B1,we as i2}from"./chunk-mq1mk3v5.js";import{kg as i_}from"./chunk-vvawhvea.js";import{eh as r_}from"./chunk-f7hsagj6.js";import{Ii as P2,Ji as u2,Ki as w_,Li as Q0,Mi as R_}from"./chunk-vptn8fhx.js";import{Qi as f1}from"./chunk-jc28ddt0.js";import{wj as B0}from"./chunk-g7h0peka.js";import{Dj as n_,Gj as d_}from"./chunk-bdtpq7j9.js";import{Kj as __}from"./chunk-w2n1vwzg.js";import{Uj as h,ck as o,dk as p,ek as I2,fk as n,gk as d,hk as m2,ik as K0,jk as Y1,kk as v2,lk as K_,mk as M0,nk as h_,ok as A,pk as P,qk as S,rk as E1,sk as F1,tk as M_,uk as z1,vk as b1,wk as q_}from"./chunk-na3nregt.js";import{readdir as k_,readFile as G_,rm as b_,stat as E0}from"node:fs/promises";import*as N from"node:path";import{nanoid as I}from"nanoid";import{createHash as z4,randomUUID as D4}from"node:crypto";import*as $_ from"node:fs/promises";import*as W0 from"node:path";function cX(_){return Object.freeze({kind:"local",root:_})}function pX(_,X){let $=o(X);if(p($.collisionIdentity)!==_)throw Error("ACP remote workspace durable state is invalid");return Object.freeze({kind:"acp-remote",root:_,descriptor:$})}function nX(_,X){return _.kind==="acp-remote"?`${_.kind}\x00${_.root}\x00${_.descriptor.exactIdentity}\x00${X}`:`${_.kind}\x00${_.root}\x00${X}`}async function U_(_,X){if(_.kind==="local")return X(K_(_.root));return n(_.root,($)=>X(String($),$))}async function dX(_,X,$){return U_(_,(W,J)=>$(J?{storageRoot:W,transcriptPath:S(J,X),inboxPath:F1(J,X),goalPath:z1(J,X),remoteScope:J}:{storageRoot:W,transcriptPath:P(_.root,X),inboxPath:E1(_.root,X),goalPath:M_(_.root,X)}))}import{execFileSync as C4}from"node:child_process";import{createHash as K4}from"node:crypto";import{readFileSync as M4}from"node:fs";var A4=/^[a-f0-9]{64}$/;function D1(_){if(!_||typeof _!=="object")return!1;let X=_;return(X.platform==="linux"||X.platform==="darwin"||X.platform==="win32")&&typeof X.fingerprint==="string"&&A4.test(X.fingerprint)}var R1={readFile:(_)=>M4(_,"utf8"),execFile:(_,X)=>C4(_,X,{encoding:"utf8",timeout:_==="powershell.exe"?3000:2000,windowsHide:!0})},E4=(_)=>{try{return process.kill(_,0),!0}catch(X){return X instanceof Error&&"code"in X&&X.code==="EPERM"}};function x0(_,X){return{platform:_,fingerprint:K4("sha256").update(`${_}\x00${X}`).digest("hex")}}function F4(_,X){let $=X.readFile(`/proc/${_}/stat`).trim(),W=$.lastIndexOf(")");if(W<0)throw Error("Invalid /proc process stat");let O=$.slice(W+2).split(/\s+/)[19];if(!O||!/^\d+$/.test(O))throw Error("Missing process start ticks");return O}function X0(_,X=process.platform,$=R1){if(!Number.isInteger(_)||_<=1)return;try{if(X==="linux")return x0(X,F4(_,$));if(X==="darwin"){let W=$.execFile("ps",["-o","lstart=","-p",String(_)]).trim();return W?x0(X,W):void 0}if(X==="win32"){let W=`(Get-CimInstance Win32_Process -Filter "ProcessId = ${_}").CreationDate.ToUniversalTime().ToString('O')`,J=$.execFile("powershell.exe",["-NoProfile","-NonInteractive","-Command",W]).trim();return J?x0(X,J):void 0}}catch{return}return}function w1(_,X){return X0(_,X.platform)?.fingerprint===X.fingerprint}function tX(_,X,$=R1,W=E4){if(!Number.isInteger(_)||_<=1)return!1;let J=X0(_,X.platform,$);if(J)return J.fingerprint===X.fingerprint;return!W(_)}var j1=1;function R4(_,X){let $=z4("sha256").update(X).digest("hex");return W0.join(K_(_),".locks",`${$}.lock`)}function $0(_,X){return _ instanceof Error&&"code"in _&&_.code===X}async function k0(_){try{let X=JSON.parse(await $_.readFile(_,"utf8"));if(X.version!==j1||typeof X.sessionId!=="string"||typeof X.ownerId!=="string"||!Number.isInteger(X.pid)||(X.pid??0)<=0||X.processIdentity!==void 0&&!D1(X.processIdentity)||typeof X.acquiredAt!=="string")return;return X}catch{return}}async function x1(_){let X=await k0(_);if(X)return X;return await new Promise(($)=>setTimeout($,10)),k0(_)}function w4(_){try{return process.kill(_,0),!0}catch(X){return $0(X,"EPERM")}}async function k1(_,X){let $;try{return $=await $_.open(_,"wx",384),await $.writeFile(`${JSON.stringify(X)}
1
+ import{De as r2,Ee as C0,Le as l_,Ne as N1,Pe as o2,Qe as a2,Re as q1,Se as t2,fe as h2,ge as e,he as l2,ie as Z1,je as c2,ke as m,le as G1,me as p2,ne as n2,oe as V1,pe as L1,qe as d2,re as H1,se as A0,te as U1,ue as B1,we as i2}from"./chunk-p0gbxaqz.js";import{mg as i_}from"./chunk-4jqw75ce.js";import{gh as r_}from"./chunk-karq4wfd.js";import{Ki as P2,Li as u2,Mi as w_,Ni as Q0,Oi as R_}from"./chunk-9a7bppj7.js";import{Si as f1}from"./chunk-g799czsy.js";import{sj as B0}from"./chunk-vp6d1fqp.js";import{Fj as n_,Ij as d_}from"./chunk-wxtj6gqb.js";import{Mj as __}from"./chunk-g9vdmvk2.js";import{Wj as h,ek as o,fk as p,gk as I2,hk as n,ik as d,jk as m2,kk as K0,lk as Y1,mk as v2,nk as K_,ok as M0,pk as h_,qk as A,rk as P,sk as S,tk as E1,uk as F1,vk as M_,wk as z1,xk as b1,yk as q_}from"./chunk-0k2x2ae6.js";import{readdir as k_,readFile as G_,rm as b_,stat as E0}from"node:fs/promises";import*as N from"node:path";import{nanoid as I}from"nanoid";import{createHash as z4,randomUUID as D4}from"node:crypto";import*as $_ from"node:fs/promises";import*as W0 from"node:path";function cX(_){return Object.freeze({kind:"local",root:_})}function pX(_,X){let $=o(X);if(p($.collisionIdentity)!==_)throw Error("ACP remote workspace durable state is invalid");return Object.freeze({kind:"acp-remote",root:_,descriptor:$})}function nX(_,X){return _.kind==="acp-remote"?`${_.kind}\x00${_.root}\x00${_.descriptor.exactIdentity}\x00${X}`:`${_.kind}\x00${_.root}\x00${X}`}async function U_(_,X){if(_.kind==="local")return X(K_(_.root));return n(_.root,($)=>X(String($),$))}async function dX(_,X,$){return U_(_,(W,J)=>$(J?{storageRoot:W,transcriptPath:S(J,X),inboxPath:F1(J,X),goalPath:z1(J,X),remoteScope:J}:{storageRoot:W,transcriptPath:P(_.root,X),inboxPath:E1(_.root,X),goalPath:M_(_.root,X)}))}import{execFileSync as C4}from"node:child_process";import{createHash as K4}from"node:crypto";import{readFileSync as M4}from"node:fs";var A4=/^[a-f0-9]{64}$/;function D1(_){if(!_||typeof _!=="object")return!1;let X=_;return(X.platform==="linux"||X.platform==="darwin"||X.platform==="win32")&&typeof X.fingerprint==="string"&&A4.test(X.fingerprint)}var R1={readFile:(_)=>M4(_,"utf8"),execFile:(_,X)=>C4(_,X,{encoding:"utf8",timeout:_==="powershell.exe"?3000:2000,windowsHide:!0})},E4=(_)=>{try{return process.kill(_,0),!0}catch(X){return X instanceof Error&&"code"in X&&X.code==="EPERM"}};function x0(_,X){return{platform:_,fingerprint:K4("sha256").update(`${_}\x00${X}`).digest("hex")}}function F4(_,X){let $=X.readFile(`/proc/${_}/stat`).trim(),W=$.lastIndexOf(")");if(W<0)throw Error("Invalid /proc process stat");let O=$.slice(W+2).split(/\s+/)[19];if(!O||!/^\d+$/.test(O))throw Error("Missing process start ticks");return O}function X0(_,X=process.platform,$=R1){if(!Number.isInteger(_)||_<=1)return;try{if(X==="linux")return x0(X,F4(_,$));if(X==="darwin"){let W=$.execFile("ps",["-o","lstart=","-p",String(_)]).trim();return W?x0(X,W):void 0}if(X==="win32"){let W=`(Get-CimInstance Win32_Process -Filter "ProcessId = ${_}").CreationDate.ToUniversalTime().ToString('O')`,J=$.execFile("powershell.exe",["-NoProfile","-NonInteractive","-Command",W]).trim();return J?x0(X,J):void 0}}catch{return}return}function w1(_,X){return X0(_,X.platform)?.fingerprint===X.fingerprint}function tX(_,X,$=R1,W=E4){if(!Number.isInteger(_)||_<=1)return!1;let J=X0(_,X.platform,$);if(J)return J.fingerprint===X.fingerprint;return!W(_)}var j1=1;function R4(_,X){let $=z4("sha256").update(X).digest("hex");return W0.join(K_(_),".locks",`${$}.lock`)}function $0(_,X){return _ instanceof Error&&"code"in _&&_.code===X}async function k0(_){try{let X=JSON.parse(await $_.readFile(_,"utf8"));if(X.version!==j1||typeof X.sessionId!=="string"||typeof X.ownerId!=="string"||!Number.isInteger(X.pid)||(X.pid??0)<=0||X.processIdentity!==void 0&&!D1(X.processIdentity)||typeof X.acquiredAt!=="string")return;return X}catch{return}}async function x1(_){let X=await k0(_);if(X)return X;return await new Promise(($)=>setTimeout($,10)),k0(_)}function w4(_){try{return process.kill(_,0),!0}catch(X){return $0(X,"EPERM")}}async function k1(_,X){let $;try{return $=await $_.open(_,"wx",384),await $.writeFile(`${JSON.stringify(X)}
2
2
  `,"utf8"),!0}catch(W){if($0(W,"EEXIST"))return!1;if($)await $_.unlink(_).catch(()=>{return});throw W}finally{await $?.close().catch(()=>{return})}}class B_ extends Error{code="BLADE_SESSION_IN_USE";constructor(_){super(_?`Session is already active in another Blade process (PID ${_}). Stop that process or choose a different session.`:"Session is already active in another Blade process. Stop that process or choose a different session.");this.name="SessionInUseError"}}class u{filePath;record;stateStorage;released=!1;constructor(_,X,$){this.filePath=_;this.record=X;this.stateStorage=$}static async acquireForStorage(_,X){if(X.kind==="local")return u.acquire(_,X.root);return U_(X,($,W)=>{if(!W||$!==X.root)throw Error("ACP remote session lease scope is invalid");return u.acquireRemote(_,W,X)})}static async acquire(_,X=f1()){return u.acquireAtPath(_,R4(X,_))}static async acquireRemote(_,X,$){let W=b1(X,_);try{await d(X,W)}catch(O){if(O.code!=="ENOENT")throw O}let J=await u.acquireAtPath(_,W);try{return await d(X,W),new u(W,J.record,$)}catch(O){throw await J.release(),O}}static async acquireAtPath(_,X){let $={version:j1,sessionId:_,ownerId:D4(),pid:process.pid,processIdentity:X0(process.pid),acquiredAt:new Date().toISOString()};if(await $_.mkdir(W0.dirname(X),{recursive:!0,mode:448}),await k1(X,$))return new u(X,$);let W=await x1(X);if(W&&w4(W.pid)&&(!W.processIdentity||w1(W.pid,W.processIdentity)))throw new B_(W.pid);if(await $_.unlink(X).catch((J)=>{if(!$0(J,"ENOENT"))throw J}),await k1(X,$))return new u(X,$);throw new B_((await x1(X))?.pid)}async release(){if(this.released)return;let _=async()=>{if((await k0(this.filePath))?.ownerId!==this.record.ownerId)return;await $_.unlink(this.filePath).catch(($)=>{if(!$0($,"ENOENT"))throw $})};if(this.stateStorage?.kind==="acp-remote")await U_(this.stateStorage,_);else await _();this.released=!0}}import{createHash as O0}from"node:crypto";import{constants as A_,promises as W_}from"node:fs";import Z_ from"node:path";import{Mutex as x4}from"async-mutex";var y1=128,g1=67108864,k4=24576,S1=65536,f0=1,h1=/^[a-f0-9]{64}$/,b4=/^[a-f0-9]{64}\.txt$/,l1=64,f4=new Set(["EBUSY","EAGAIN","EMFILE","ENFILE"]),Y0=`
3
3
 
4
4
  ...[middle omitted; read the private prompt artifact for the complete request]...
@@ -0,0 +1,63 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-DxkR5r7t.js","assets/index-DEOQizD2.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-D6QrtXqd.js","assets/session-events-C5_Q0kZV.js","assets/index-57UZsfTt.css","assets/copy-CWCS3Lql.js"])))=>i.map(i=>d[i]);
2
+ import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as W,u as P,a as v,s as Ve,b as ct,d as ce,H as Fe,P as lt,G as Ke,L as $,S as He,T as ae,C as fe,D as Qe,e as ze,f as dt,g as qe,h as Ge,i as We,j as D,k as ut,l as te,B as mt,m as we,n as de,R as he,F as ht,_ as Je,o as xt,p as Ye,q as pt,r as Xe,t as ft,X as Ze,v as bt,A as Ee,w as vt,x as gt,W as kt,y as yt,z as jt}from"./index-DEOQizD2.js";import{_ as Te,M as ne,Z as O,a2 as wt,A as Nt,a3 as St,Q as Ct,X as Et,Y as Tt}from"./session-events-C5_Q0kZV.js";import{A as Mt,E as Rt}from"./external-link-1IN2ZfaO.js";import{S as At}from"./ScrollArea-D71pJjgW.js";import{C as et}from"./copy-CWCS3Lql.js";import{C as ie}from"./chevron-right-Cvq3LzHK.js";import{A as Me,a as Ft,C as Dt}from"./chevrons-up-down-Dia1U9Sz.js";import{f as It,g as Bt,h as _t,i as tt}from"./vendor-radix-D6QrtXqd.js";import{P as $t}from"./pause-BYhoGDZq.js";import{P as Pt}from"./play-DGZdCyPk.js";import{P as st}from"./pencil-pRZQVHFU.js";import{C as Ut}from"./clock-3-CnxLS8cv.js";import{t as L}from"./team-QZ9byb3E.js";import{teamService as De}from"./teamService-BScT9o9A.js";/**
3
+ * @license lucide-react v0.300.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const Lt=W("Files",[["path",{d:"M15.5 2H8.6c-.4 0-.8.2-1.1.5-.3.3-.5.7-.5 1.1v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8c.4 0 .8-.2 1.1-.5.3-.3.5-.7.5-1.1V6.5L15.5 2z",key:"cennsq"}],["path",{d:"M3 7.6v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8",key:"ms809a"}],["path",{d:"M15 2v5h5",key:"qq6kwv"}]]);/**
8
+ * @license lucide-react v0.300.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Ot=W("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
13
+ * @license lucide-react v0.300.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const Vt=W("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
18
+ * @license lucide-react v0.300.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Kt=W("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
23
+ * @license lucide-react v0.300.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Ht=W("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
28
+ * @license lucide-react v0.300.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Qt=W("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
33
+ * @license lucide-react v0.300.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const zt=W("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
38
+ * @license lucide-react v0.300.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const qt=W("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
43
+ * @license lucide-react v0.300.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const Gt=W("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Ie(t){return t.split("/").filter(Boolean).at(-1)||t}function Wt(){const t=P(),s=v(j=>j.sessions),r=v(j=>j.currentSessionRef),a=v(j=>j.historySurfaceSelection),i=v(j=>j.taskDeliveryActions),n=v(j=>j.deliverTask),c=Te(j=>j.openFilePreview),[u,f]=h.useState(!1),o=s.find(j=>Ve({sessionId:j.sessionId,projectPath:j.projectPath},r));if(ne(a)||!(o!=null&&o.taskIsolation))return null;const g=o.taskDiffStat,b=o.taskIsolation==="worktree",l=ct(o),y=i[ce(l)],x=o.taskDelivery,S=(x==null?void 0:x.status)==="conflicted",m=!!(g&&(g.changedFiles>0||g.commits>0)),p=!["queued","running"].includes(o.taskStatus),k=(x==null?void 0:x.status)==="applied"||(x==null?void 0:x.status)==="discarded",N=b&&m&&p&&!k,d=g?g.additions+g.deletions:0,M=d>0&&g?g.additions/d*100:0,F=j=>{O(v.getState())||n(l,j).catch(()=>{})},A=()=>{O(v.getState())||c({tab:"diff"})};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:Ie(o.taskSourceProjectPath||o.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:[b?e.jsx(lt,{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:b?"text-[hsl(var(--deck-accent))]":void 0,children:t(b?"artifact.env.isolated":"artifact.env.local")})]}),o.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:o.taskWorktreeBranch,children:[e.jsx(Ke,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:o.taskWorktreeBranch})]})]})]}),g&&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(Lt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:g.changedFiles})]}),d>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:["+",g.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",g.deletions]}),g.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:g.commits})}),m&&(x==null?void 0:x.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:A,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")}),N&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!y,onClick:()=>F("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:[y==="apply"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(He,{className:"h-3 w-3"}),t(y==="apply"?"artifact.applying":S?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!y,onClick:()=>f(!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:y==="discard"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(ae,{className:"h-3 w-3"})})]}),(x==null?void 0:x.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(fe,{className:"h-3 w-3"}),t("artifact.applied")]}),(x==null?void 0:x.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(ae,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(x==null?void 0:x.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(Mt,{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:x.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Qe,{open:u,onOpenChange:f,children:e.jsxs(ze,{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(dt,{children:[e.jsx(qe,{children:t("artifact.discardDialog.title")}),e.jsx(Ge,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Ie(o.taskSourceProjectPath||o.projectPath),count:(g==null?void 0:g.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(We,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>f(!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:()=>{f(!1),F("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(ae,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Jt=new Set(["completed","stale","failed","aborted","interrupted"]),Yt={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"},Xt={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 xe(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Zt(t){const s=xe(t),r=xe(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,i=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,c=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 i!="number"||!Number.isFinite(i)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(c)))return{title:s.title,body:s.body,priority:a,confidenceScore:i,codeLocation:{path:r.path,lineStart:n,lineEnd:c}}}function es(t){const s=xe(t),r=xe(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Jt.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(Zt);if(!a.some(i=>i===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 ts(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function ss({report:t}){const s=P(),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:D("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Xt[t.status]),children:[s("chat.review.status"),": ",s(Yt[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,i)=>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:ts(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}:${i}`))})]}),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 rs({elicitation:t,messageId:s}){const r=P(),a=v(k=>k.currentSessionRef),i=v(k=>k.setElicitation),[n,c]=h.useState(()=>ns(t.details.fields??[])),[u,f]=h.useState(()=>is(t.details.fields??[])),[o,g]=h.useState(!1),[b,l]=h.useState(),y=t.details.fields??[],x=h.useMemo(()=>y.every(k=>{var d;if(!k.required)return!0;if(be(k))return!!((d=u[k.name])!=null&&d.trim()||k.defaultValue!==void 0);const N=n[k.name]??k.defaultValue;return Array.isArray(N)?N.length>0:N!==void 0}),[y,u,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 S=async(k,N)=>{if(!O(v.getState())&&!(!a||o)){g(!0),l(void 0);try{await te.respondToElicitation(a,t.toolCallId,{action:k,...N?{content:N}:{}}),i(s,{...t,status:"responded"})}catch(d){l(d instanceof Error?d.message:r("interaction.elicitation.failed"))}finally{g(!1)}}},m=async()=>{try{await S("accept",os(y,n,u))}catch(k){l(k instanceof Error?k.message:String(k))}},p=()=>{if(O(v.getState()))return;const k=t.details.url;if(!k){l("MCP URL is unavailable");return}if(!window.open(k,"_blank","noopener,noreferrer")){l("The browser blocked the external window");return}S("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(ut,{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(re,{onClick:p,disabled:o,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(Rt,{className:"h-3.5 w-3.5"})}),e.jsx(re,{onClick:()=>void S("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void S("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[y.map(k=>e.jsx(as,{field:k,value:n[k.name],rawValue:u[k.name]??"",onValueChange:N=>c(d=>({...d,[k.name]:N})),onRawChange:N=>f(d=>({...d,[k.name]:N}))},k.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{onClick:()=>void m(),disabled:o||!x,primary:!0,label:r("interaction.elicitation.submit"),icon:o?e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(re,{onClick:()=>void S("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void S("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}),b&&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:b})]})}function as({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:i}){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:cs(t).map(n=>{const c=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":c,onClick:()=>{if(t.type==="multi-select"){const u=Array.isArray(s)?s:[];a(u.includes(n.value)?u.filter(f=>f!==n.value):[...u,n.value])}else a(n.typedValue)},className:D("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",c?"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:ls(t),value:r,onChange:n=>i(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 re({onClick:t,disabled:s,primary:r=!1,label:a,icon:i}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:D("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:[i,a]})}function ns(t){return Object.fromEntries(t.filter(s=>!be(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function is(t){return Object.fromEntries(t.filter(s=>be(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function os(t,s,r){var i;const a={};for(const n of t){if(be(n)){const u=((i=r[n.name])==null?void 0:i.trim())??"";if(!u){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 f=Number(u);if(!Number.isFinite(f))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(f))throw new Error(`${n.title} must be a safe integer`);a[n.name]=f}else a[n.name]=u;continue}const c=s[n.name]??n.defaultValue;if(c===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(c)){if(n.minItems!==void 0&&c.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&c.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=c}return a}function cs(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 be(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function ls(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 ds(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 us({report:t}){const s=P(),[r,a]=h.useState(!1),i=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(i),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(mt,{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(fe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(et,{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:i})]})}const ms=h.lazy(()=>Je(()=>import("./MarkdownRenderer-DxkR5r7t.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Be({text:t,label:s}){const[r,a]=h.useState(!1);if(!t.trim())return null;const i=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:i,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(fe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(et,{className:"h-3.5 w-3.5"})})}function hs(){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(we,{size:20,pulse:!1})})}function xs(){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 _e(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 ps(t){if(typeof t=="string")return{text:_e(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
48
+ `),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:_e(s),images:r}}function Re(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
49
+ `)}function fs(t){const s=t.agentContent;return s?wt(s):Re(t.content)}function $e({content:t,syntaxHighlight:s=!0}){return e.jsx(h.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(ms,{content:t,syntaxHighlight:s})})}function Ae({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:D("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function bs(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)}const Pe=500;function rt(t,s){if(t.length<=s)return t;let r=Math.max(0,s);return r>0&&/[\uD800-\uDBFF]/.test(t.charAt(r-1))&&(r-=1),t.slice(0,r)}function Ue(t,s){if(t.length<=s)return t;let r=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(r))&&(r+=1),t.slice(r)}function ge(t,s){if(t.length<=s)return t;if(s<=0)return"";const r=`
50
+ ... (display clipped) ...
51
+ `,a=s-r.length;if(a<=0)return Ue(t,s);const i=Math.floor(a/3);return`${rt(t,i)}${r}${Ue(t,a-i)}`}function vs(t){const s=t.split(`
52
+ `),r=s.at(-1),a=r!=null&&r.startsWith("Output truncated")?r:void 0,i=a?s.slice(0,-1).join(`
53
+ `):t,n=a?`
54
+ ${a}`:"",c=Math.max(0,Pe-n.length),f=i.indexOf(`
55
+ stderr:
56
+ `);let o;if(f>=0&&i.includes(`
57
+ stdout:
58
+ `)){const g=i.slice(0,f),b=i.slice(f+1),l=Math.max(0,c-1),y=Math.floor(l/2);o=`${ge(g,y)}
59
+ ${ge(b,l-y)}`}else o=ge(i,c);return{body:rt(o,c),...a?{notice:a}:{},truncated:!!a||t.length>Pe}}function gs({tool:t}){const[s,r]=h.useState(!1),a=bs(t.arguments),i=t.output?vs(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":i!=null&&i.truncated?"true":"false",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(n=>!n),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(de,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ie,{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(Ae,{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})]}),i&&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.jsxs("pre",{"data-tool-output":!0,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:[i.body,i.notice&&e.jsxs(e.Fragment,{children:[`
60
+ `,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function at({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(gs,{tool:s},s.toolCallId))})}function ks({toolCalls:t,toolCallIds:s}){const r=P(),[a,i]=h.useState(!1),n=h.useMemo(()=>new Map(t.map(b=>[b.toolCallId,b])),[t]),c=s.flatMap(b=>{const l=n.get(b);return l?[l]:[]});if(c.length===0)return null;const u=c.filter(b=>b.status==="running").length,f=c.filter(b=>b.status==="error").length,o=[...c].reverse().find(b=>b.status==="running"&&!!b.progressMessage),g=u>0?r(c.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:c.length}):f>0?r(c.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:c.length,errors:f}):r(c.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:c.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>i(b=>!b),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(de,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ie,{className:"h-3.5 w-3.5 shrink-0"}),u>0&&e.jsx($,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:g}),(o==null?void 0:o.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[o.progressMessage,o.progress!==void 0&&o.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(o.progress/o.progressTotal*100)))}%`]})]}),(o==null?void 0:o.progress)!==void 0&&o.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${o.toolName} progress`,"aria-valuemin":0,"aria-valuemax":o.progressTotal,"aria-valuenow":Math.min(o.progress,o.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,o.progress/o.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(at,{toolCalls:c})})]})}function ys({content:t}){const s=P(),[r,a]=h.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(i=>!i),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(de,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ie,{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 js({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 ws({toolCalls:t}){const s=Te(n=>n.openFilePreview),r=v(n=>ne(n.historySurfaceSelection)),a=h.useMemo(()=>{const n=new Map,c=["Write","SearchReplace","Edit","ApplyPatch"];for(const u of t){if(u.status!=="success")continue;const f=u.metadata;if(u.toolName==="ApplyPatch"&&Array.isArray(f==null?void 0:f.changes)){for(const g of f.changes)g&&typeof g=="object"&&"path"in g&&typeof g.path=="string"&&n.set(g.path,{path:g.path,toolName:u.toolName});continue}const o=f==null?void 0:f.file_path;o&&c.includes(u.toolName)&&n.set(o,{path:o,toolName:u.toolName})}return Array.from(n.values())},[t]);if(r||a.length===0)return null;const i=n=>{O(v.getState())||s({tab:"diff",targetPath:n})};return 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 (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:n})=>{const c=n.split("/").pop()||n;return e.jsxs("button",{onClick:()=>i(n),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:n,children:[e.jsx(ht,{className:"w-3 h-3"}),c]},n)})})]})}function Ns({subagent:t}){var Z,Y,G,X;const s=P(),[r,a]=h.useState(null),[i,n]=h.useState(!1),[c,u]=h.useState(null),[f,o]=h.useState(!1),[g,b]=h.useState(""),[l,y]=h.useState(!1),[x,S]=h.useState(null),[m,p]=h.useState(null),[k,N]=h.useState(null),d=v(R=>R.currentSessionRef),M=v(R=>R.isStreaming),F=v(R=>R.isTemporarySession),A=v(R=>ne(R.historySurfaceSelection));if(!t)return null;const j=t.status==="running",_=r!==null?r:j,U=t.toolCalls||c||[],C=t.output||t.thinking||U.length>0||t.sessionId,E=m&&m.status!=="running"?m:k,I=(E==null?void 0:E.id)??t.sessionId,B=((Z=E==null?void 0:E.restartRecovery)==null?void 0:Z.outcome)==="failed",z=!j&&!M&&!F&&!A&&!B&&(m==null?void 0:m.status)!=="running"&&!!(I&&d);h.useEffect(()=>{if(A||!_||j||!t.sessionId||!(d!=null&&d.projectPath)||c!==null||t.toolCalls&&t.toolCalls.length>0)return;let R=!0;return n(!0),te.getMessages({sessionId:t.sessionId,projectPath:d.projectPath}).then(q=>{var V,T;if(!R)return;const H=Ct(q),Q=new Map;for(const K of H)if((T=(V=K.agentContent)==null?void 0:V.toolCalls)!=null&&T.length)for(const se of K.agentContent.toolCalls)Q.has(se.toolCallId)||Q.set(se.toolCallId,se);u(Array.from(Q.values()))}).finally(()=>{R&&n(!1)}),()=>{R=!1}},[_,A,j,t.sessionId,t.toolCalls,c,d==null?void 0:d.projectPath]),h.useEffect(()=>{if(A||!t.sessionId||!d)return;let R=!0;const q=t.rootAgentId??t.sessionId,H=t.resumeDepth??0;return te.listSubagents(d).then(Q=>{if(!R)return;N(Q.find(T=>T.id===t.sessionId)??null);const V=Q.filter(T=>T.id!==t.sessionId&&T.rootAgentId===q&&T.resumeDepth>H).sort((T,K)=>K.resumeDepth-T.resumeDepth||K.lastActiveAt-T.lastActiveAt)[0];V&&p(V)}).catch(()=>{}),()=>{R=!1}},[d==null?void 0:d.sessionId,d==null?void 0:d.projectPath,A,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(A||!m||m.status!=="running"||!d)return;let R=!0;const q=async()=>{try{const V=(await te.listSubagents(d)).find(T=>T.id===m.id);R&&V&&p(V)}catch{}},H=window.setInterval(()=>{q()},1e3);return()=>{R=!1,window.clearInterval(H)}},[d,A,m==null?void 0:m.id,m==null?void 0:m.status]);const J=async()=>{if(!O(v.getState())&&!(!d||!I||!g.trim()||l)){y(!0),S(null);try{const R=await te.resumeSubagent(d,I,g.trim());p(R.session),b(""),o(!1),a(!0)}catch(R){S(R instanceof Error?R.message:s("chat.subagent.resumeFailed"))}finally{y(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,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(!_),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:[j&&e.jsx($,{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(Ae,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:D("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})})]}),C&&e.jsx(de,{className:D("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",_&&"rotate-180")})]}),!_&&!j&&t.output&&e.jsx("div",{"data-subagent-output-summary":!0,className:"mt-2 max-h-10 overflow-hidden whitespace-pre-wrap break-words font-mono text-[11px] text-[hsl(var(--deck-ink))]",children:t.output}),_&&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})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx($,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!i&&U.length>0&&e.jsx(at,{toolCalls:U}),m&&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:m.id,status:m.status,depth:m.resumeDepth??1})}),(((Y=m.result)==null?void 0:Y.message)||((G=m.result)==null?void 0:G.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:m.result.message||m.result.error})]}),B&&((X=E==null?void 0:E.result)==null?void 0:X.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:E.result.error}),z&&e.jsxs("div",{className:"space-y-2",children:[f?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:g,onChange:R=>b(R.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:()=>{o(!1),S(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 J(),disabled:!g.trim()||l,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[l&&e.jsx($,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>o(!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(he,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),x&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:x})]})]})]})}function Ss({confirmation:t,messageId:s}){const r=P(),[a,i]=h.useState(!1),[n,c]=h.useState(null),u=v(g=>g.currentSessionRef),f=v(g=>g.setConfirmation);if(!t)return null;const o=async(g,b)=>{if(!O(v.getState())&&!(!u||a)){i(!0),c(null);try{await te.respondPermission(u,t.toolCallId,{approved:g,scope:b}),f(s,{...t,status:g?"approved":"denied"})}catch(l){c(l instanceof Error?l.message:r("interaction.permission.failed"))}finally{i(!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 o(!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($,{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 o(!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 o(!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 o(!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 Cs({question:t,messageId:s}){const r=P(),[a,i]=h.useState({}),[n,c]=h.useState({}),[u,f]=h.useState(!1),[o,g]=h.useState(null),b=v(m=>m.currentSessionRef),l=v(m=>m.setQuestion),y=h.useMemo(()=>t?t.questions.reduce((m,p)=>{var M;const k=(M=n[p.header])==null?void 0:M.trim(),N=a[p.header];if(p.multiSelect){const F=Array.isArray(N)?[...N]:[];return k&&F.push(k),F.length>0&&(m[p.header]=F),m}const d=k||(typeof N=="string"?N:"");return d&&(m[p.header]=d),m},{}):{},[a,n,t]),x=(t==null?void 0:t.questions.every(m=>m.header in y))??!1;if(!t)return null;const S=async()=>{if(!O(v.getState())&&!(!b||u||!x)){f(!0),g(null);try{await te.respondToQuestion(b,t.toolCallId,y),l(s,{...t,status:"answered",answers:y})}catch(m){g(m instanceof Error?m.message:r("interaction.question.failed"))}finally{f(!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((m,p)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:m.question}),e.jsxs("div",{className:"space-y-1",children:[m.options.map((k,N)=>e.jsxs("button",{type:"button",onClick:()=>{if(m.multiSelect){const d=a[m.header]||[],M=d.includes(k.label)?d.filter(F=>F!==k.label):[...d,k.label];i({...a,[m.header]:M})}else i({...a,[m.header]:k.label}),c({...n,[m.header]:""})},className:D("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(m.multiSelect?(a[m.header]||[]).includes(k.label):a[m.header]===k.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:k.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:k.description})]},N)),e.jsx("input",{"aria-label":`${m.header} other response`,value:n[m.header]??"",onChange:k=>c({...n,[m.header]:k.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]"})]})]},p)),o&&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:o}),e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:u||!x,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:[u&&e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function Es({message:t}){const s=t.agentContent,r=v(x=>x.isStreaming&&x.currentAssistantMessageId===t.id);if(!s){const x=Re(t.content);return x?e.jsx($e,{content:x}):null}const{toolCalls:a,tasks:i,confirmation:n,question:c,elicitation:u}=s,f=Nt(s),o=St(s);if(!(o.length>0||i.length>0||f.length>0||n||c||u)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const l=a.length>0&&a.every(x=>x.status==="success"||x.status==="error")&&!r,y=!r;return e.jsxs("div",{className:"space-y-3",children:[o.map(x=>x.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(ys,{content:x.content})},x.id):x.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx($e,{content:x.content,syntaxHighlight:y})},x.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(ks,{toolCalls:a,toolCallIds:x.toolCallIds})},x.id)),i.length>0&&e.jsx(js,{tasks:i}),f.map(x=>e.jsx(Ns,{subagent:x},x.id)),n&&e.jsx(Ss,{confirmation:n,messageId:t.id}),c&&e.jsx(Cs,{question:c,messageId:t.id}),u&&e.jsx(rs,{elicitation:u,messageId:t.id}),l&&e.jsx(ws,{toolCalls:a})]})}function Ts({message:t,showAvatar:s=!0}){var u,f,o,g;const r=t.role==="user";if(t.role==="system"){const b=Re(t.content);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"system",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:b})})}if(r){const b=(u=t.metadata)!=null&&u.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(f=t.metadata)!=null&&f.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(b){const x=typeof b.command=="string"?b.command:"",S=b.status==="running"?"running":b.status==="completed"?"success":"error",m=typeof b.output=="string"?b.output:[typeof b.stdout=="string"?b.stdout:"",typeof b.stderr=="string"&&b.stderr?`stderr:
61
+ ${b.stderr}`:""].filter(Boolean).join(`
62
+ `);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","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:"$"}),x]}),e.jsx(Ae,{status:S})]}),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:m||"(no output)"}),typeof b.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 ",b.exitCode,typeof b.durationMs=="number"?` · ${(b.durationMs/1e3).toFixed(3)}s`:"",b.truncated===!0?" · truncated":""]})]})})}const{text:l,images:y}=ps(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(Be,{text:l,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[l&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:l}),y.length>0&&e.jsx("div",{className:D("grid gap-2",y.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:y.map((x,S)=>e.jsx("img",{src:x,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${x}-${S}`))})]}),e.jsx(xs,{})]})}const i=fs(t),n=es((o=t.metadata)==null?void 0:o.codeReview),c=ds((g=t.metadata)==null?void 0:g.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:D("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(hs,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(ss,{report:n}):c?e.jsx(us,{report:c}):e.jsx(Es,{message:t}),!c&&i.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(Be,{text:i,label:"Copy response"})})]})]})}const Ms=h.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 Fs(t,s,r,a){const i=new Map(t.filter(c=>!!c.id).map(c=>[c.id,c])),n=new Set(r);for(const c of s){if(!c.id)continue;const u=i.get(c.id);u!==c&&(!u||!a||a(u)!==a(c))&&n.add(c.id)}return n}function Le(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function Ds({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const i=P(),[n,c]=h.useState(null),[u,f]=h.useState(!1),o=h.useRef(null),g=h.useCallback(()=>{var m;const l=s.current,y=r.current;if(!l||!y||t.length===0)return;const x=l.getBoundingClientRect().top;let S=((m=t[0])==null?void 0:m.id)??null;for(const p of t){const k=Le(y,p.id);if(k)if(k.getBoundingClientRect().top-x<=24)S=p.id;else break}c(S)},[t,s,r]);h.useEffect(()=>{const l=s.current;if(!l)return;const y=()=>{o.current===null&&(o.current=window.requestAnimationFrame(()=>{o.current=null,g()}))};return g(),l.addEventListener("scroll",y,{passive:!0}),()=>{l.removeEventListener("scroll",y),o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)}},[g,s]);const b=h.useCallback(l=>{const y=()=>{const S=Le(r.current,l.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),c(l.id))};a(l.index)?y():window.requestAnimationFrame(()=>window.requestAnimationFrame(y))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":i("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocusCapture:()=>f(!0),onBlurCapture:l=>{l.currentTarget.contains(l.relatedTarget)||f(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:D("flex flex-col items-center gap-2 py-2 transition-opacity",u?"opacity-0":"opacity-100"),"aria-hidden":u,children:t.map(l=>e.jsx("li",{children:e.jsx("span",{className:D("block rounded-full transition-all",l.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},l.id))}),e.jsx("div",{className:D("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",u?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((l,y)=>e.jsxs("button",{type:"button",onClick:()=>b(l),className:D("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",l.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:D("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",l.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:i("chat.turns.label",{n:y+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:l.preview})]})]},l.id))})]})})}const Oe=80;function Is(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function Bs(t){const s=Is(t).replace(/\s+/g," ").trim();return s?s.length>Oe?`${s.slice(0,Oe-1)}…`:s:""}function _s(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const i=Bs(a.content);i&&s.push({id:a.id,index:r,preview:i})}return s}const ke=120,ye=80,$s=96;function oe(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Ps(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Us({messages:t,isLoading:s}){const r=P(),a=h.useRef(null),i=h.useRef(null),n=h.useRef(!0),c=h.useRef(!1),u=h.useRef(t),f=h.useRef(t),o=h.useRef(new Set),g=h.useRef(t.length),b=h.useRef(null),[l,y]=h.useState(ke),[x,S]=h.useState(!1),[m,p]=h.useState(0),k=t.length>0;u.current=t,h.useEffect(()=>{const C=oe(a.current);if(!C||c.current&&!n.current)return;const E=window.requestAnimationFrame(()=>{C.scrollTop=C.scrollHeight,c.current=!0,n.current=!0,o.current=new Set,p(0),S(!1)});return()=>window.cancelAnimationFrame(E)},[t]),h.useEffect(()=>{const C=oe(a.current);if(!C)return;i.current=C;const E=()=>{if(!c.current)return;const B=C.scrollHeight-C.scrollTop-C.clientHeight<=$s,z=n.current;n.current=B,S(!B),B?(o.current=new Set,p(0)):z&&(f.current=u.current,o.current=new Set,p(0))};return E(),C.addEventListener("scroll",E,{passive:!0}),()=>C.removeEventListener("scroll",E)},[k,s]),h.useEffect(()=>{const C=f.current;if(f.current=t,n.current){o.current.size>0&&(o.current=new Set,p(0));return}const E=Fs(C,t,o.current,Ps);o.current=E,p(E.size)},[t]),h.useEffect(()=>{const C=g.current;g.current=t.length,y(E=>E>=C&&t.length>C?t.length:Math.min(Math.max(E,ke),t.length||ke))},[t.length]);const N=Math.max(t.length-l,0),d=N,M=h.useMemo(()=>t.slice(d),[t,d]),F=h.useMemo(()=>_s(t),[t]);if(h.useLayoutEffect(()=>{var I;const C=b.current;if(!C)return;const E=oe(a.current);if(b.current=null,!!E){if((I=C.element)!=null&&I.isConnected){const B=C.element.getBoundingClientRect().top-C.viewportTop;E.scrollTop+=B;return}E.scrollTop=Rs(C.scrollTop,C.scrollHeight,E.scrollHeight)}},[l]),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(we,{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(xt,{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((C,E)=>e.jsxs("div",{className:D("flex gap-3",E%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:`${C}%`,animationDelay:`${E*120}ms`}})]},C))})]})});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(we,{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 A=()=>{const C=oe(a.current);C&&(C.scrollTop=C.scrollHeight,n.current=!0,c.current=!0,o.current=new Set,p(0),S(!1))},j=()=>{var E;const C=oe(a.current);if(C){const I=((E=a.current)==null?void 0:E.querySelector("[data-chat-message-id]"))??null;b.current={element:I,viewportTop:(I==null?void 0:I.getBoundingClientRect().top)??0,scrollHeight:C.scrollHeight,scrollTop:C.scrollTop}}y(I=>As(I,t.length,ye))},_=C=>C>=d?!0:(y(t.length),!1),U=m===1?r("chat.list.unreadMessage"):r("chat.list.unreadMessages",{count:m});return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(At,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[N>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:j,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(N,ye),remaining:N}),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(N,ye)})})}),M.map((C,E)=>{const I=d+E,B=I>0?t[I-1]:null,z=!B||B.role!==C.role||B.role==="user";return e.jsx(Ms,{message:C,showAvatar:z},C.id||`msg-${I}`)})]})}),e.jsx(Ds,{turns:F,viewportRef:i,containerRef:a,onRevealTurn:_}),x&&e.jsxs("button",{type:"button",onClick:A,"aria-live":"polite","aria-label":m>0?U:r("chat.list.jumpLatest"),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))]"}),m>0?U:r("chat.list.jumpLatest")]})]})}const nt=h.memo(Us);function Ls({queue:t,mutation:s,onMutate:r,onRefresh:a}){const i=P(),[n,c]=h.useState(!1),u=h.useRef(null),f=h.useRef(null),o=h.useRef(null);h.useLayoutEffect(()=>{var x,S,m;if(s.pending||!u.current)return;const l=u.current;u.current=null,(m=Array.from(((x=f.current)==null?void 0:x.querySelectorAll("[data-follow-up-focus-id]"))??[]).find(p=>p.dataset.followUpFocusId===l)??((S=f.current)==null?void 0:S.querySelector("button")))==null||m.focus()},[s.pending,t==null?void 0:t.version]);const g=h.useCallback(async l=>{u.current=l.messageId,await r(l)},[r]),b=h.useCallback((l,y)=>{g({type:"move",messageId:l,toPosition:y})},[g]);return!t||t.pending===0&&!s.errorMessage?null:e.jsxs("section",{ref:f,"data-blade-follow-up-queue":!0,className:"mx-4 mb-2 overflow-hidden rounded-lg border border-amber-300/70 bg-amber-50/70 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/25 md:mx-6","aria-label":i("chat.followUpQueue.title"),children:[e.jsxs("button",{type:"button","aria-label":i(n?"chat.followUpQueue.hide":"chat.followUpQueue.show"),"aria-expanded":n,onClick:()=>c(l=>!l),className:"flex min-h-10 w-full items-center gap-2 px-3 text-left font-mono text-[11px] text-amber-950 transition-colors hover:bg-amber-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-amber-500 dark:text-amber-100 dark:hover:bg-amber-900/35",children:[e.jsx(Kt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-semibold",children:i("chat.followUpQueue.count",{count:t.pending})}),t.locked>0&&e.jsx("span",{className:"text-amber-700/80 dark:text-amber-300/75",children:i("chat.followUpQueue.lockedCount",{count:t.locked})}),e.jsx(ie,{className:`ml-auto h-3.5 w-3.5 transition-transform ${n?"rotate-90":""}`,"aria-hidden":!0})]}),n&&e.jsxs("div",{className:"border-t border-amber-300/60 px-2 py-2 dark:border-amber-900/50",children:[s.errorMessage&&e.jsxs("div",{role:"alert",className:"mb-2 flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/35 dark:text-red-300",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.errorCode==="revision_conflict"?i("chat.followUpQueue.stale"):s.errorMessage}),a&&e.jsx("button",{type:"button","aria-label":i("chat.followUpQueue.refresh"),onClick:()=>void a(),className:"rounded p-1 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 dark:hover:bg-red-900/60",children:e.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("ol",{className:"space-y-1.5",children:t.items.map((l,y)=>{const x=t.items[y-1],S=t.items[y+1],m=l.mutable&&(x==null?void 0:x.mutable)===!0,p=l.mutable&&(S==null?void 0:S.mutable)===!0,k=s.pending;return e.jsxs("li",{"data-follow-up-id":l.id,"data-follow-up-state":l.state,"data-follow-up-focus-id":l.id,tabIndex:-1,draggable:l.mutable&&!s.pending,onDragStart:()=>{o.current=l.mutable?l.id:null},onDragOver:N=>{const d=o.current,M=t.items.find(F=>F.id===d);M!=null&&M.mutable&&l.mutable&&N.preventDefault()},onDrop:N=>{N.preventDefault();const d=o.current;o.current=null;const M=t.items.find(j=>j.id===d);if(!(M!=null&&M.mutable)||!l.mutable||M.id===l.id)return;const F=Math.min(M.position,l.position),A=Math.max(M.position,l.position);t.items.slice(F,A+1).some(j=>!j.mutable)||b(M.id,l.position)},onDragEnd:()=>{o.current=null},className:"flex min-w-0 items-center gap-2 rounded-md border border-amber-200/70 bg-white/75 px-2.5 py-2 dark:border-amber-900/50 dark:bg-zinc-950/45",children:[e.jsx("span",{className:"w-5 shrink-0 text-center font-mono text-[10px] text-amber-700 dark:text-amber-400",children:y+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-xs text-[hsl(var(--deck-ink))]",children:l.kind==="internal"?i("chat.followUpQueue.internal"):l.preview||i("chat.followUpQueue.attachmentOnly")}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] uppercase tracking-[0.08em] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx("span",{children:i(`chat.followUpQueue.delivery.${l.delivery}`)}),!l.mutable&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Ht,{className:"h-2.5 w-2.5","aria-hidden":!0}),i("chat.followUpQueue.locked")]}),l.attachmentCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(pt,{className:"h-2.5 w-2.5","aria-hidden":!0}),l.attachmentCount]})]})]}),k&&s.messageId===l.id?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-amber-600"}):e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{type:"button","aria-label":i("chat.followUpQueue.moveUp",{id:l.id}),disabled:k||!m,onClick:()=>b(l.id,y-1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Ft,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":i("chat.followUpQueue.moveDown",{id:l.id}),disabled:k||!p,onClick:()=>b(l.id,y+1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":i("chat.followUpQueue.remove",{id:l.id}),disabled:k||!l.mutable,onClick:()=>void g({type:"remove",messageId:l.id}),className:"rounded p-1 text-red-600 transition-colors hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:opacity-30 dark:text-red-400 dark:hover:bg-red-950/60",children:e.jsx(ae,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]},l.id)})})]})]})}const Ne=It,Se=Bt,Ce=_t,pe=h.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(tt,{ref:a,sideOffset:s,className:D("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=tt.displayName;const Os={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 ue(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Vs(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 Ks(){var C,E,I,B,z,J,Z,Y,G,X,R,q,H,Q,V;const t=P(),{locale:s}=Xe(),r=v(T=>T.goal),a=v(T=>T.pauseGoal),i=v(T=>T.resumeGoal),n=v(T=>T.editGoal),c=v(T=>T.clearGoal),u=v(T=>ne(T.historySurfaceSelection)),[f,o]=h.useState(!1),[g,b]=h.useState(!1),[l,y]=h.useState(""),[x,S]=h.useState(null),[m,p]=h.useState(!1);if(h.useEffect(()=>{o(!1),b(!1),y((r==null?void 0:r.objective)??""),p(!1)},[r==null?void 0:r.goalId]),u||!r)return null;const k=Os[r.status],N=["active","verifying","paused","blocked"].includes(r.status),d=r.status==="active"||r.status==="verifying",M=r.status==="paused"||r.status==="blocked",F=x!==null,A=async(T,K)=>{if(!O(v.getState())){S(T);try{await K()}finally{S(null)}}},j=()=>{y(r.objective),b(!0),o(!0)},_=async T=>{T.preventDefault();const K=l.trim();if(!K||K===r.objective){b(!1);return}await A("edit",()=>n(K)),b(!1)},U=async()=>{await A("delete",c),p(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":r.status,"data-blade-goal-recovery":(C=r.prematureStop)==null?void 0:C.consecutiveCount,"data-blade-goal-recovery-pattern":(E=r.prematureStop)==null?void 0:E.pattern,"data-blade-goal-verification-stall":(I=r.verificationStall)==null?void 0:I.consecutiveCount,"data-blade-goal-frontier-task-list":(B=r.executionFrontier)==null?void 0:B.taskListId,"data-blade-goal-frontier-total":(z=r.executionFrontier)==null?void 0:z.total,"data-blade-goal-frontier-completed":(J=r.executionFrontier)==null?void 0:J.completed,"data-blade-goal-frontier-in-progress":(Z=r.executionFrontier)==null?void 0:Z.inProgress,"data-blade-goal-frontier-pending":(Y=r.executionFrontier)==null?void 0:Y.pending,"data-blade-goal-frontier-blocked":(G=r.executionFrontier)==null?void 0:G.blocked,"data-blade-goal-frontier-next-task":(R=(X=r.executionFrontier)==null?void 0:X.nextTask)==null?void 0:R.id,"data-blade-goal-frontier-digest":(q=r.executionFrontier)==null?void 0:q.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(H=r.frontierStall)==null?void 0:H.category,"data-blade-goal-frontier-stall-count":(Q=r.frontierStall)==null?void 0:Q.consecutiveCount,children:[e.jsxs("div",{className:D("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",f&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(zt,{className:D("h-3.5 w-3.5 shrink-0",k.accent)}),e.jsx("span",{className:D("h-1.5 w-1.5 shrink-0 rounded-full",k.dot)}),e.jsx("span",{className:D("shrink-0 text-[10px] font-medium leading-none",k.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(k.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(f?"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:()=>o(T=>!T),"aria-expanded":f,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:[ue(r.tokensUsed),r.tokenBudget!==void 0&&`/${ue(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[d&&e.jsx(me,{label:t("goal.action.pause"),disabled:F,onClick:()=>void A("pause",a),children:x==="pause"?e.jsx($,{className:"animate-spin"}):e.jsx($t,{})}),M&&e.jsx(me,{label:t("goal.action.resume"),disabled:F,onClick:()=>void A("resume",i),children:x==="resume"?e.jsx($,{className:"animate-spin"}):e.jsx(Pt,{})}),e.jsx(me,{label:t(N?"goal.action.edit":"goal.action.expand"),disabled:!N&&!f,onClick:N?j:()=>o(T=>!T),children:N?e.jsx(st,{}):e.jsx(Dt,{})}),e.jsx(me,{label:t("goal.action.delete"),disabled:F,destructive:!0,onClick:()=>p(!0),children:e.jsx(ae,{})})]})]}),f&&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:g?e.jsxs("form",{onSubmit:_,children:[e.jsx("textarea",{id:"goal-objective",value:l,onChange:T=>y(T.target.value),onKeyDown:T=>{T.key==="Escape"&&b(!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:()=>b(!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(Ze,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!l.trim()||x==="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:[x==="edit"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(fe,{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(Ot,{className:"h-3 w-3"}),ue(r.tokensUsed),r.tokenBudget!==void 0&&` / ${ue(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(qt,{className:"h-3 w-3"}),Vs(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(he,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(he,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",r.prematureStop.consecutiveCount," ·"," ",r.prematureStop.pattern.replaceAll("_"," ")]}),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()," ·"," ",((V=r.completionVerification.verifierSessionId)==null?void 0:V.slice(0,12))??"-",r.verificationStall?s==="zh"?` · 重复 ${r.verificationStall.consecutiveCount}/3`:` · repeat ${r.verificationStall.consecutiveCount}/3`:""]}),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(Qe,{open:m,onOpenChange:p,children:e.jsxs(ze,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(qe,{children:t("goal.dialog.title")}),e.jsx(Ge,{children:t("goal.dialog.description")}),e.jsxs(We,{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:x==="delete",onClick:()=>void U(),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:[x==="delete"&&e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function me({label:t,children:s,disabled:r,destructive:a,onClick:i}){return e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:i,className:D("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 Hs(){const t=P(),s=v(o=>o.currentSessionRef),r=v(o=>o.sessions),a=v(o=>o.messages),i=v(o=>ne(o.historySurfaceSelection)),n=h.useMemo(()=>{var g,b,l,y,x;const o=s?(g=bt(r,s))==null?void 0:g.pendingInteraction:void 0;if(o)return o.type;for(let S=a.length-1;S>=0;S-=1){const m=(b=a[S])==null?void 0:b.agentContent;if(((l=m==null?void 0:m.confirmation)==null?void 0:l.status)==="pending")return"permission";if(((y=m==null?void 0:m.question)==null?void 0:y.status)==="pending")return"question";if(((x=m==null?void 0:m.elicitation)==null?void 0:x.status)==="pending")return"elicitation"}return null},[s,a,r]);if(i||!n)return null;const c=()=>{const o=document.querySelector(`[data-pending-interaction="${n}"]`);o==null||o.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>o==null?void 0:o.focus(),250)},u=n==="question",f=n==="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(Ee,{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(u?"interaction.bar.questionTitle":f?"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(u?"interaction.bar.questionHint":f?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:c,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")]})]})}function le(t){return Math.max(0,Math.ceil((t??0)/1e3))}function Qs(t,s=Date.now()){var a;const r=(a=t.snapshot)==null?void 0:a.nextActionAt;return r===void 0?void 0:le(r-s)}function it(t,s=Date.now()){const r=t==null?void 0:t.snapshot;if(!r)return null;const a=Qs(t,s)??0,i=r.retry,n=r.admission,c=r.stall,u=r.fallback,f={seconds:a,attempt:(i==null?void 0:i.attempt)??0,maxRetries:(i==null?void 0:i.maxRetries)??0,budgetSeconds:le(i==null?void 0:i.recoveryRemainingMs),position:(n==null?void 0:n.queuePosition)??0,depth:n?Math.max(n.queueDepth,n.queuePosition):0,scope:(n==null?void 0:n.scope)??"",waitSeconds:le(n==null?void 0:n.waitMs),stallSeconds:le(c==null?void 0:c.durationMs),timeoutSeconds:le(c==null?void 0:c.timeoutMs),from:(u==null?void 0:u.from.model)??"",to:(u==null?void 0:u.to.model)??"",candidate:(u==null?void 0:u.candidate)??0,candidateCount:(u==null?void 0:u.candidateCount)??0};switch(r.activity){case"admission_wait":return{titleKey:"chat.providerRecovery.admission",detailKey:"chat.providerRecovery.admissionDetail",compactKey:"chat.providerRecovery.admissionCompact",params:f};case"retry_wait":return{titleKey:r.reason==="rate_limit"?"chat.providerRecovery.rateLimit":"chat.providerRecovery.retryWait",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:f};case"retry_attempt":return{titleKey:"chat.providerRecovery.retryAttempt",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:f};case"circuit_open":return{titleKey:"chat.providerRecovery.circuit",detailKey:"chat.providerRecovery.circuitDetail",compactKey:"chat.providerRecovery.circuitCompact",params:f};case"circuit_probe":return{titleKey:"chat.providerRecovery.probe",detailKey:"chat.providerRecovery.probeDetail",compactKey:"chat.providerRecovery.probeCompact",params:f};case"stream_stall":return{titleKey:c!=null&&c.outputStarted?"chat.providerRecovery.stallAfterOutput":"chat.providerRecovery.stall",detailKey:"chat.providerRecovery.stallDetail",compactKey:"chat.providerRecovery.stallCompact",params:f};case"fallback":return{titleKey:"chat.providerRecovery.fallback",detailKey:"chat.providerRecovery.fallbackDetail",compactKey:"chat.providerRecovery.fallbackCompact",params:f}}}function zs({recovery:t,stopping:s,onStop:r}){var f;const a=P(),[i,n]=h.useState(Date.now()),c=(f=t==null?void 0:t.snapshot)==null?void 0:f.nextActionAt;h.useEffect(()=>{if(c===void 0)return;n(Date.now());const o=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(o)},[c]);const u=it(t,i);return u?e.jsxs("section",{role:"status","aria-live":"polite","data-provider-recovery-banner":!0,className:"mx-4 mb-2 flex min-h-12 items-center gap-3 rounded-lg border border-amber-300/70 bg-amber-50/80 px-3 py-2 text-amber-950 shadow-sm dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-100 md:mx-6",children:[e.jsx($,{className:"h-4 w-4 shrink-0 animate-spin","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold",children:a(u.titleKey,u.params)}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] opacity-80",children:a(u.detailKey,u.params)})]}),e.jsxs("button",{type:"button","data-provider-recovery-stop":!0,onClick:r,disabled:s,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/70 px-2.5 text-xs font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 disabled:cursor-wait disabled:opacity-60 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[s?e.jsx($,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(vt,{className:"h-3 w-3 fill-current","aria-hidden":!0}),a(s?"chat.input.action.stopping":"chat.providerRecovery.stop")]})]}):null}const qs=h.lazy(()=>Je(()=>import("./MarkdownRenderer-DxkR5r7t.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Gs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Ws(){const t=P(),s=v(a=>a.sideConversation),r=v(a=>a.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(Qt,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-accent))]",children:t("chat.side.title")}),s.durationMs!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Ut,{"aria-hidden":!0,className:"h-3 w-3"}),Gs(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 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:e.jsx(Ze,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[s.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx($,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),s.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Ee,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(qs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function je(t){return Number.isFinite(t)?Math.max(0,t):0}function Js(t){const s=je(t.totalInputTokens),r=je(t.cacheReadTokens),a=je(t.cacheWriteTokens),i=Math.min(r,s),n=Math.min(a,Math.max(0,s-i)),c=Math.max(0,s-i-n),u=s>0&&(r>0||a>0);return{totalInputTokens:s,cacheReadTokens:i,cacheWriteTokens:n,uncachedInputTokens:c,...u?{hitRate:i/s}:{}}}function Ys(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Xs={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:""},Zs={model_changed:"status.cacheBreak.model",system_prompt_changed:"status.cacheBreak.system",tools_changed:"status.cacheBreak.tools",request_policy_changed:"status.cacheBreak.policy",ttl_expired:"status.cacheBreak.ttl",server_side:"status.cacheBreak.server"},ee=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),er=t=>{const s=Math.max(0,Math.ceil(t/1e3)),r=Math.floor(s/60),a=s%60;return r>0?`${r}m ${a}s`:`${a}s`};function ot(){const t=P(),s=v(N=>N.tokenUsage),r=v(N=>N.isStreaming),a=v(N=>N.agentPhase),i=v(N=>N.providerRecovery),n=v(N=>N.pendingResume),c=v(N=>N.actionStationarity),u=v(N=>N.turnRecovery),f=Xs[a]??"",o=it(i),g=(n==null?void 0:n.delayMs)!==void 0?` · retry in ${er(n.delayMs)}`:"",b=(u==null?void 0:u.state)==="requires_attention"?t("status.recovery.review"):"",l=(u==null?void 0:u.state)==="requires_attention"?t(u.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",y=b||(c?`${t(c.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${c.toolName} · ${c.runLength}/${c.haltThreshold}`:o?t(o.compactKey,o.params):n?`Recovery attempt ${n.attempt}/${n.maxAttempts}${g}`:f?t(f):""),x=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,S=Js(s),m=Ys(S.hitRate),p=Math.min(x,100),k=x>95?"danger":x>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",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:D("text-[12px] font-medium",k==="safe"&&"text-[hsl(var(--deck-ink))]",k==="warn"&&"text-amber-600 dark:text-amber-400",k==="danger"&&"text-red-600 dark:text-red-400"),children:ee(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",ee(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Ne,{children:e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsx(Vt,{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 hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:D("absolute inset-y-0 left-0 transition-[width] duration-300",k==="safe"&&"bg-[hsl(var(--deck-accent))]",k==="warn"&&"bg-amber-500",k==="danger"&&"bg-red-500"),style:{width:`${p}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(N=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${N}%`}},N))})]}),e.jsxs("span",{className:D("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",k==="warn"&&"text-amber-600 dark:text-amber-400",k==="danger"&&"text-red-600 dark:text-red-400"),children:[x,"%"]})]}),e.jsx(Ne,{children:e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 cursor-help items-baseline gap-2 border-l border-[hsl(var(--deck-hairline))] pl-2 sm:pl-4","data-testid":"prompt-cache-hit-rate","aria-label":`${t("status.cache")} ${m}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:D("tabular-nums",S.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:m})]})}),e.jsx(pe,{side:"top",className:"max-w-[280px]",children:S.hitRate===void 0?e.jsx("p",{className:"text-xs",children:t("status.cacheUnavailable")}):e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:t("status.cacheTooltip")}),e.jsx("p",{className:"font-mono tabular-nums",children:t("status.cacheDetails",{read:ee(S.cacheReadTokens),write:ee(S.cacheWriteTokens),uncached:ee(S.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Zs[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:ee(s.cacheBreak.previousCacheReadTokens),current:ee(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(b||r&&y)&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:D("shrink-0",b?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:D("truncate",b?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[y,l?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",l]}):null]})]})]})}function tr(){const{locale:t}=Xe(),s=gt(d=>d.agentTeamsEnabled),r=v(d=>d.teams),a=v(d=>d.currentSessionRef),i=v(d=>ne(d.historySurfaceSelection)),n=v(d=>d.loadTeams),[c,u]=h.useState({}),[f,o]=h.useState({}),[g,b]=h.useState({}),[l,y]=h.useState(null),[x,S]=h.useState(null),[m,p]=h.useState(null);if(h.useEffect(()=>{i||n(a??void 0)},[s,a,i,n]),i||!s||!a||r.length===0)return null;const k=async d=>{var F;if(O(v.getState()))return;const M=(F=g[d])==null?void 0:F.trim();if(!(!M||l)){y(d),p(null);try{await De.sendMessage(a,d,f[d]??"*",M),b(A=>({...A,[d]:""})),await n(a)}catch(A){p(A instanceof Error?A.message:L(t,"actionFailed"))}finally{y(null)}}},N=async d=>{if(!O(v.getState())&&!x){S(d),p(null);try{await De.delete(a,d),await n(a)}catch(M){p(M instanceof Error?M.message:L(t,"actionFailed"))}finally{S(null)}}};return e.jsxs("section",{"aria-label":L(t,"title"),"data-blade-team-panel":!0,className:"shrink-0 border-y border-emerald-300/50 bg-emerald-50/55 dark:border-emerald-800/55 dark:bg-emerald-950/20",children:[m&&e.jsx("div",{role:"alert",className:"border-b border-red-200 bg-red-50 px-4 py-2 font-mono text-[10px] text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300 md:px-6",children:m}),r.filter(d=>d.status!=="deleted").map(d=>{var A;const M=c[d.name]??d.status==="running",F=d.tasks.filter(j=>j.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>u(j=>({...j,[d.name]:!M})),"aria-label":M?L(t,"collapse"):L(t,"expand"),className:"flex h-7 w-7 items-center justify-center rounded-md text-emerald-700 hover:bg-emerald-100 dark:text-emerald-300 dark:hover:bg-emerald-900/50",children:M?e.jsx(de,{className:"h-4 w-4"}):e.jsx(ie,{className:"h-4 w-4"})}),e.jsx(Gt,{className:"h-4 w-4 shrink-0 text-emerald-700 dark:text-emerald-300"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{className:"truncate font-mono text-[11px] font-semibold uppercase text-emerald-800 dark:text-emerald-200",children:d.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[d.status," · ",d.members.length-1," ",L(t,"members")," · ",F,"/",d.tasks.length," ",L(t,"tasks")]})]}),d.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:d.description})]}),e.jsx("button",{type:"button",onClick:()=>void N(d.name),disabled:x===d.name,"aria-label":L(t,"delete"),title:L(t,"delete"),className:"flex h-7 w-7 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-red-50 hover:text-red-600 disabled:opacity-40 dark:hover:bg-red-950/40",children:e.jsx(ae,{className:"h-3.5 w-3.5"})})]}),M&&e.jsxs("div",{className:"max-h-[min(40vh,360px)] overflow-y-auto border-t border-emerald-200/40 px-4 py-3 md:px-6 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:L(t,"members")}),d.members.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":j.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${j.status==="running"?"bg-emerald-500":j.status==="completed"||j.status==="leader"?"bg-sky-500":j.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.subagentType}),j.worktreePath&&e.jsx(Ke,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":L(t,"worktree")})]},j.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:L(t,"tasks")}),d.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:L(t,"noTasks")}):d.tasks.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",j.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.status})]},j.id))]})]}),d.peerMessagingEnabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-emerald-200/40 pt-3 dark:border-emerald-900/40",children:[e.jsxs("select",{"aria-label":L(t,"recipient"),value:f[d.name]??"*",onChange:j=>o(_=>({..._,[d.name]:j.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:L(t,"broadcast")}),d.members.filter(j=>j.status!=="leader").map(j=>e.jsx("option",{value:j.name,children:j.name},j.id))]}),e.jsx("input",{value:g[d.name]??"",onChange:j=>b(_=>({..._,[d.name]:j.target.value})),onKeyDown:j=>{j.key==="Enter"&&k(d.name)},placeholder:L(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void k(d.name),disabled:!((A=g[d.name])!=null&&A.trim())||l===d.name,"aria-label":L(t,"send"),title:L(t,"send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-emerald-700 text-white hover:bg-emerald-800 disabled:opacity-40 dark:bg-emerald-600",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]})]})]},d.name)})]})}function sr(t){const s=[...t].reverse().find(i=>i.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(i=>i.type==="text").map(i=>i.text).join(`
63
+ `),a=s.content.filter(i=>i.type==="image_url").map((i,n)=>{var u;const c=((u=i.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:u[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:c,dataUrl:i.image_url.url}});return{content:r,attachments:a}}function rr({messages:t,isLoading:s,isStreaming:r,isStopping:a,errorMessage:i}){const n=P(),[c,u]=h.useState(!1),f=n(i?"status.phase.error":a?"chat.input.action.stopping":r?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:c,onToggle:o=>u(o.currentTarget.open),className:"group hidden",children:[e.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 px-3 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[r&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e.jsx(ie,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),c&&e.jsxs("div",{"data-preview-activity-details":!0,className:"flex h-[min(44vh,420px)] min-h-0 flex-col border-t border-[hsl(var(--deck-hairline))]",children:[i&&e.jsx("div",{role:"alert",className:"border-b border-red-200/60 bg-red-50/80 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300",children:i}),e.jsx(nt,{messages:t,isLoading:s}),e.jsx(ot,{})]})]})}function gr(){var se;const t=P(),s=v(w=>w.messages),r=v(w=>w.currentSessionRef),a=v(w=>w.isStreaming),i=v(w=>w.isStopping),n=v(w=>w.providerRecovery),c=v(w=>w.sessionEventConnectionState),u=v(w=>w.pendingSteeringCount),f=v(w=>w.pendingInputDelivery),o=v(w=>w.recoveredSteeringCount),g=v(w=>w.followUpQueue),b=v(w=>w.followUpQueueMutation),l=v(w=>w.mutateFollowUpQueue),y=v(w=>w.refreshFollowUpQueue),x=v(w=>!!w.historySurfaceSelection),S=v(w=>w.isLoading),m=v(w=>w.error),p=v(w=>w.errorContext),k=v(w=>w.sessions),N=v(w=>w.sendMessage),d=v(w=>w.abortSession),M=v(w=>w.retryTask),F=v(w=>w.retryingTaskKeys),A=Te(w=>w.openSettings),j=v(w=>w.reconnectSessionEvents),_=v(w=>w.clearError),[U,C]=h.useState(null),E=r?k.find(w=>w.sessionId===r.sessionId&&w.projectPath===r.projectPath):void 0,I=!!m&&((p==null?void 0:p.kind)==="navigation"||!(p!=null&&p.sessionRef)||Ve(p.sessionRef,r)),B=(p==null?void 0:p.failureCode)??((se=E==null?void 0:E.taskFailure)==null?void 0:se.code),z=((p==null?void 0:p.kind)==="execution"||p!=null&&p.failureCode)&&B?t(Et(B)):m==="queue_full"?t("chat.error.queueFull"):m==="turn_unavailable"||m==="turn_active"?t("chat.error.turnChanged"):m,J=c==="connecting"||c==="reconnecting",Z=a&&c!=="connected",Y=r?`session:${ce(r)}`:"session:temporary",G=h.useMemo(()=>sr(s),[s]),X=r?ce(r):"temporary-session",R=!!(r&&(E!=null&&E.taskRetryAvailable)&&(!B||Tt(B)))&&((p==null?void 0:p.kind)==="execution"||(p==null?void 0:p.kind)==="task_action"),q=(p==null?void 0:p.kind)==="execution"&&(B==="authentication"||B==="permission"||B==="model_unavailable"),H=r?F.includes(ce(r)):!1;h.useEffect(()=>{C(null)},[X]);const Q=async w=>O(v.getState())?!1:N({content:w.content,modelId:w.modelId,reasoningEffort:w.reasoningEffort,serviceTier:w.serviceTier,responseVerbosity:w.responseVerbosity,communicationStyle:w.communicationStyle,...w.outputSchema?{outputSchema:w.outputSchema}:{},attachments:w.attachments.map(ve=>({type:"image",content:ve.dataUrl,mimeType:ve.mimeType,name:ve.name}))}),V=()=>{if(!O(v.getState()))return d()},T=async()=>{if(!O(v.getState())){if(q){_(),A("models");return}if(R&&r){_(),await M(r).catch(()=>{});return}if((p==null?void 0:p.kind)==="execution"&&G){C({...G,revision:Date.now()}),_();return}_(),requestAnimationFrame(()=>jt())}},K=R?t(H?"chat.error.action.retryingTask":"chat.error.action.retryTask"):q?t("chat.error.action.checkModels"):(p==null?void 0:p.kind)==="execution"&&G?t("chat.error.action.editResend"):(p==null?void 0:p.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{"data-chat-view":!0,className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsxs("div",{"data-chat-history":!0,className:"contents",children:[I&&e.jsxs("div",{role:"alert","data-blade-session-error":!0,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(Ee,{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((p==null?void 0:p.kind)==="submission"?"chat.error.title.submission":(p==null?void 0:p.kind)==="execution"?"chat.error.title.execution":(p==null?void 0:p.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",z]}),K&&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:[R?H?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(he,{className:"h-3 w-3"}):e.jsx(st,{className:"h-3 w-3"}),K]}),e.jsx("button",{type:"button",onClick:_,"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:"✕"})]}),(J||c==="offline")&&e.jsxs("div",{role:c==="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:[J?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(kt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(J?"chat.connection.reconnecting":"chat.connection.offline")}),c==="offline"&&e.jsxs("button",{type:"button",onClick:()=>{O(v.getState())||j().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(Ye,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(Wt,{}),e.jsx(nt,{messages:s,isLoading:S},r?ce(r):"temporary-session"),e.jsx(tr,{}),e.jsx(Ws,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(rr,{messages:s,isLoading:S,isStreaming:a,isStopping:i,errorMessage:I?z:null},X),e.jsx(Hs,{}),e.jsx(Ks,{}),e.jsx(Ls,{queue:x?null:g,mutation:b,onMutate:l,onRefresh:y}),e.jsx(zs,{recovery:x?null:n,stopping:i,onStop:V}),e.jsx(yt,{draftKey:Y,draft:U==null?void 0:U.content,draftAttachments:U==null?void 0:U.attachments,draftRevision:U==null?void 0:U.revision,onSend:Q,onAbort:V,disabled:S||Z,isStreaming:a,isStopping:i,pendingSteeringCount:u,pendingInputDelivery:f,recoveredSteeringCount:o,workspacePath:r==null?void 0:r.projectPath},Y),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(ot,{})})]})]})}export{gr as ChatView};
@@ -1,4 +1,4 @@
1
- import{R as I,j as Ke}from"./vendor-react-DofNRwfy.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-BMAuTkc6.js";import"./index-DiRs2_w4.js";import"./vendor-radix-D6QrtXqd.js";import"./session-events-BqQQkbAN.js";import"./copy-d9M8JUfQ.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.
1
+ import{R as I,j as Ke}from"./vendor-react-DofNRwfy.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-DxkR5r7t.js";import"./index-DEOQizD2.js";import"./vendor-radix-D6QrtXqd.js";import"./session-events-C5_Q0kZV.js";import"./copy-CWCS3Lql.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(`