hive-am 1.8.0 → 1.9.0

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 (193) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +3 -2
  3. package/package.json +1 -1
  4. package/web/.next/BUILD_ID +1 -1
  5. package/web/.next/app-build-manifest.json +146 -131
  6. package/web/.next/app-path-routes-manifest.json +2 -1
  7. package/web/.next/build-manifest.json +13 -13
  8. package/web/.next/prerender-manifest.json +67 -43
  9. package/web/.next/react-loadable-manifest.json +3 -3
  10. package/web/.next/required-server-files.json +1 -1
  11. package/web/.next/routes-manifest.json +6 -0
  12. package/web/.next/server/app/_not-found/page.js +1 -1
  13. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  14. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/web/.next/server/app/_not-found.html +1 -1
  16. package/web/.next/server/app/_not-found.rsc +3 -3
  17. package/web/.next/server/app/agents/[id]/page.js +4 -4
  18. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  19. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  20. package/web/.next/server/app/agents/page.js +2 -2
  21. package/web/.next/server/app/agents/page.js.nft.json +1 -1
  22. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  23. package/web/.next/server/app/agents.html +1 -1
  24. package/web/.next/server/app/agents.rsc +5 -5
  25. package/web/.next/server/app/chat/page.js +1 -1
  26. package/web/.next/server/app/chat/page.js.nft.json +1 -1
  27. package/web/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  28. package/web/.next/server/app/chat.html +1 -1
  29. package/web/.next/server/app/chat.rsc +4 -4
  30. package/web/.next/server/app/colony/page.js +2 -0
  31. package/web/.next/server/app/colony/page.js.nft.json +1 -0
  32. package/web/.next/server/app/colony/page_client-reference-manifest.js +1 -0
  33. package/web/.next/server/app/colony.html +1 -0
  34. package/web/.next/server/app/colony.meta +15 -0
  35. package/web/.next/server/app/colony.rsc +25 -0
  36. package/web/.next/server/app/connections/page.js +2 -2
  37. package/web/.next/server/app/connections/page.js.nft.json +1 -1
  38. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  39. package/web/.next/server/app/connections.html +1 -1
  40. package/web/.next/server/app/connections.rsc +4 -4
  41. package/web/.next/server/app/index.html +1 -1
  42. package/web/.next/server/app/index.rsc +4 -4
  43. package/web/.next/server/app/page.js +2 -2
  44. package/web/.next/server/app/page.js.nft.json +1 -1
  45. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  46. package/web/.next/server/app/relations/page.js +2 -2
  47. package/web/.next/server/app/relations/page.js.nft.json +1 -1
  48. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  49. package/web/.next/server/app/relations.html +1 -1
  50. package/web/.next/server/app/relations.rsc +4 -4
  51. package/web/.next/server/app/resources/[id]/page.js +1 -1
  52. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
  53. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
  54. package/web/.next/server/app/resources/page.js +2 -2
  55. package/web/.next/server/app/resources/page.js.nft.json +1 -1
  56. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
  57. package/web/.next/server/app/resources.html +1 -1
  58. package/web/.next/server/app/resources.rsc +4 -4
  59. package/web/.next/server/app/schedules/page.js +1 -1
  60. package/web/.next/server/app/schedules/page.js.nft.json +1 -1
  61. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  62. package/web/.next/server/app/schedules.html +1 -1
  63. package/web/.next/server/app/schedules.rsc +4 -4
  64. package/web/.next/server/app/sessions/page.js +2 -2
  65. package/web/.next/server/app/sessions/page.js.nft.json +1 -1
  66. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  67. package/web/.next/server/app/sessions.html +1 -1
  68. package/web/.next/server/app/sessions.rsc +4 -4
  69. package/web/.next/server/app/skills/page.js +1 -1
  70. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  71. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  72. package/web/.next/server/app/skills.html +1 -1
  73. package/web/.next/server/app/skills.rsc +4 -4
  74. package/web/.next/server/app/types/page.js +2 -2
  75. package/web/.next/server/app/types/page.js.nft.json +1 -1
  76. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  77. package/web/.next/server/app/types.html +1 -1
  78. package/web/.next/server/app/types.rsc +4 -4
  79. package/web/.next/server/app-paths-manifest.json +2 -1
  80. package/web/.next/server/chunks/143.js +1 -1
  81. package/web/.next/server/chunks/{939.js → 272.js} +4 -4
  82. package/web/.next/server/chunks/345.js +2 -2
  83. package/web/.next/server/chunks/368.js +1 -1
  84. package/web/.next/server/chunks/403.js +1 -1
  85. package/web/.next/server/chunks/505.js +6 -0
  86. package/web/.next/server/chunks/561.js +1 -0
  87. package/web/.next/server/chunks/616.js +1 -0
  88. package/web/.next/server/chunks/802.js +1 -0
  89. package/web/.next/server/chunks/944.js +1 -1
  90. package/web/.next/server/chunks/953.js +2 -1
  91. package/web/.next/server/middleware-build-manifest.js +1 -1
  92. package/web/.next/server/middleware-react-loadable-manifest.js +1 -1
  93. package/web/.next/server/pages/404.html +1 -1
  94. package/web/.next/server/pages/500.html +1 -1
  95. package/web/.next/server/server-reference-manifest.json +1 -1
  96. package/web/.next/static/chunks/0937d497-daa99a23a4431317.js +1 -0
  97. package/web/.next/static/chunks/1517-01e286ff9d1d8ebe.js +1 -0
  98. package/web/.next/static/chunks/1606-2aa8ee5a6751f920.js +1 -0
  99. package/web/.next/static/chunks/1771-4688ad65e21bb512.js +1 -0
  100. package/web/.next/static/chunks/2547-847f3165f72a62b7.js +1 -0
  101. package/web/.next/static/chunks/2654-4aeef09c0d6bf56a.js +1 -0
  102. package/web/.next/static/chunks/{657.b4c39e676c3e20dc.js → 2657.8d96393b971ae134.js} +1 -1
  103. package/web/.next/static/chunks/2b9ff8ee-0851c7e556e3a39b.js +1 -0
  104. package/web/.next/static/chunks/3214-c9d0c933db5b0f44.js +1 -0
  105. package/web/.next/static/chunks/3757-45ea801718ec19e4.js +1 -0
  106. package/web/.next/static/chunks/3790-3d3f11a264e8ede8.js +1 -0
  107. package/web/.next/static/chunks/4030-bc2e0aa4da0d9ad8.js +1 -0
  108. package/web/.next/static/chunks/4162-c2361cb017547c37.js +1 -0
  109. package/web/.next/static/chunks/4491-49c700f509985c9e.js +1 -0
  110. package/web/.next/static/chunks/4837-8dc05d75f258f9e1.js +1 -0
  111. package/web/.next/static/chunks/5587-7e580517c4105e63.js +1 -0
  112. package/web/.next/static/chunks/5642-09dd4161ddddaf94.js +1 -0
  113. package/web/.next/static/chunks/7097.60e7ac5abf76b2cb.js +1 -0
  114. package/web/.next/static/chunks/7706-bd0d2bda0e0c8d1e.js +1 -0
  115. package/web/.next/static/chunks/8523-82e1ee6239699d8a.js +1 -0
  116. package/web/.next/static/chunks/8701.0db2914c123a180e.js +6 -0
  117. package/web/.next/static/chunks/{350-bdf6b8994a28f2b4.js → 969-ad2583a1ff30fdf0.js} +1 -1
  118. package/web/.next/static/chunks/9977-d80535fa4b24e377.js +1 -0
  119. package/web/.next/static/chunks/app/_not-found/page-d7975fab88bfe2c3.js +1 -0
  120. package/web/.next/static/chunks/app/agents/[id]/page-877114d3b3fab94d.js +1 -0
  121. package/web/.next/static/chunks/app/agents/layout-2536c0c15d09ddcf.js +1 -0
  122. package/web/.next/static/chunks/app/agents/page-0d8769f28c624f9c.js +1 -0
  123. package/web/.next/static/chunks/app/chat/page-b1569cf72e958d8b.js +1 -0
  124. package/web/.next/static/chunks/app/colony/page-ffdc123dac47ad69.js +1 -0
  125. package/web/.next/static/chunks/app/connections/page-2278b79b13b7fea8.js +1 -0
  126. package/web/.next/static/chunks/app/layout-6e9bec186b02e6d7.js +1 -0
  127. package/web/.next/static/chunks/app/page-68ae166b2f8dbf94.js +1 -0
  128. package/web/.next/static/chunks/app/relations/page-a9d991b174372f37.js +1 -0
  129. package/web/.next/static/chunks/app/resources/[id]/page-48131f750e983a07.js +1 -0
  130. package/web/.next/static/chunks/app/resources/page-706d012a4c0d57ce.js +1 -0
  131. package/web/.next/static/chunks/app/schedules/page-5821c0d26afde69f.js +1 -0
  132. package/web/.next/static/chunks/app/sessions/page-6145eb19002dd390.js +1 -0
  133. package/web/.next/static/chunks/app/skills/page-b94287c3a333870d.js +1 -0
  134. package/web/.next/static/chunks/app/types/page-a991fe9afa51bdb7.js +1 -0
  135. package/web/.next/static/chunks/{fcafe1ac.366e4950d3b0d4b7.js → fcafe1ac.47e831cc63938bfb.js} +1 -1
  136. package/web/.next/static/chunks/framework-ab1d276eb4175e96.js +1 -0
  137. package/web/.next/static/chunks/main-18f19eeb8b4d3fe4.js +1 -0
  138. package/web/.next/static/chunks/main-app-27cc7ffdb888b879.js +1 -0
  139. package/web/.next/static/chunks/pages/{_app-d1670a2c6ce392fc.js → _app-8aeadc281b5934a7.js} +1 -1
  140. package/web/.next/static/chunks/pages/_error-6bffadfc60f180a1.js +1 -0
  141. package/web/.next/static/chunks/webpack-ba68c1813987a630.js +1 -0
  142. package/web/.next/static/css/93c99ed61cbded84.css +1 -0
  143. package/web/.next/static/ompymNZ0AHG5SIqLOAsGL/_buildManifest.js +1 -0
  144. package/web/.next/trace +31 -30
  145. package/web/.next/types/app/colony/page.ts +84 -0
  146. package/web/.next/types/routes.d.ts +2 -1
  147. package/web/.next/types/validator.ts +9 -0
  148. package/web/.next/server/chunks/111.js +0 -1
  149. package/web/.next/server/chunks/148.js +0 -1
  150. package/web/.next/server/chunks/213.js +0 -6
  151. package/web/.next/server/chunks/716.js +0 -2
  152. package/web/.next/static/chunks/0937d497-114a2a3de515565e.js +0 -1
  153. package/web/.next/static/chunks/162-68ba190086f5ad39.js +0 -1
  154. package/web/.next/static/chunks/214-35b88db02113ae02.js +0 -1
  155. package/web/.next/static/chunks/281-db567801806519ca.js +0 -1
  156. package/web/.next/static/chunks/2b9ff8ee-969e65cc354b2150.js +0 -1
  157. package/web/.next/static/chunks/30-9adcbe92b15a6815.js +0 -1
  158. package/web/.next/static/chunks/491-196bcb3dd11bb460.js +0 -1
  159. package/web/.next/static/chunks/517-8f2db464d10a4624.js +0 -1
  160. package/web/.next/static/chunks/587-3c53d91a1c4f99d6.js +0 -1
  161. package/web/.next/static/chunks/606-14fb5aaa4d0ff22d.js +0 -1
  162. package/web/.next/static/chunks/642-dc874c8caf203ee1.js +0 -1
  163. package/web/.next/static/chunks/654-92a63b3c4b412666.js +0 -1
  164. package/web/.next/static/chunks/701.6abcaf5e60463eef.js +0 -6
  165. package/web/.next/static/chunks/706-fa2be0f10ffebe6a.js +0 -1
  166. package/web/.next/static/chunks/757-03361e7a97a605a2.js +0 -1
  167. package/web/.next/static/chunks/771-db19da9b1a24820c.js +0 -1
  168. package/web/.next/static/chunks/837-33c7480524f48577.js +0 -1
  169. package/web/.next/static/chunks/928-09d4a58e977641dc.js +0 -1
  170. package/web/.next/static/chunks/97.594543c2196de524.js +0 -1
  171. package/web/.next/static/chunks/app/_not-found/page-948f39e30bfc6144.js +0 -1
  172. package/web/.next/static/chunks/app/agents/[id]/page-242fd70d8584a88e.js +0 -1
  173. package/web/.next/static/chunks/app/agents/layout-a7dac2c3b4e7a20c.js +0 -1
  174. package/web/.next/static/chunks/app/agents/page-b7548bf41c9cbfb8.js +0 -1
  175. package/web/.next/static/chunks/app/chat/page-9abfde182ecb496f.js +0 -1
  176. package/web/.next/static/chunks/app/connections/page-2ac43cd57a97e9f0.js +0 -1
  177. package/web/.next/static/chunks/app/layout-ade8d9924844117b.js +0 -1
  178. package/web/.next/static/chunks/app/page-d66674626ad7d29d.js +0 -1
  179. package/web/.next/static/chunks/app/relations/page-d8ce10c8614ed991.js +0 -1
  180. package/web/.next/static/chunks/app/resources/[id]/page-8de76264ca0aa7e8.js +0 -1
  181. package/web/.next/static/chunks/app/resources/page-7d5f253bb19ada0d.js +0 -1
  182. package/web/.next/static/chunks/app/schedules/page-e51193921966b9e0.js +0 -1
  183. package/web/.next/static/chunks/app/sessions/page-9a762f441beb6386.js +0 -1
  184. package/web/.next/static/chunks/app/skills/page-d7d563d60e18fc62.js +0 -1
  185. package/web/.next/static/chunks/app/types/page-24913e4f2ab28b04.js +0 -1
  186. package/web/.next/static/chunks/framework-bbac72adbbe2d328.js +0 -1
  187. package/web/.next/static/chunks/main-app-61597cc1ea26ecc5.js +0 -1
  188. package/web/.next/static/chunks/main-c15f3fee674e0303.js +0 -1
  189. package/web/.next/static/chunks/pages/_error-95aac014d202fa7a.js +0 -1
  190. package/web/.next/static/chunks/webpack-ef515e41a83a16ac.js +0 -1
  191. package/web/.next/static/css/cba3f895460f46bd.css +0 -1
  192. package/web/.next/static/fLC3_wYBAX3oEgsl9XX0Q/_buildManifest.js +0 -1
  193. /package/web/.next/static/{fLC3_wYBAX3oEgsl9XX0Q → ompymNZ0AHG5SIqLOAsGL}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (()=>{var a={};a.id=969,a.ids=[969],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1708:a=>{"use strict";a.exports=require("node:process")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},23124:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(51537).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},27769:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(85972).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx","default")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33438:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>bv});var d=c(55322),e=c(97984),f=c(93674),g=c(17027),h=c(91705),i=c.n(h),j=c(66252),k=c(61222),l=c(38550),m=c(89667),n=c(93351),o=c(60570),p=c(7371),q=c(61162);c(62705);var r=c(73269),s=c(90634),t=c(33944),u=c(51537);let v=(0,u.A)("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var w=c(40413),x=c(33165);let y=(0,u.A)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var z=c(30257),A=c(78574),B=c(18869),C=c(30584),D=c(93884);function E({agent:a,session:b}){let{t:c}=(0,D.s9)(),{finished:e,live:f}=(0,o.o0)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1);e[a.id];let l=f[a.id];if(!h||0===h.turns&&!l)return null;let m=l?.usage,n=(0,C.RP)(h.usage)+(m?(0,C.RP)({input:m.input??0,output:m.output??0,cacheRead:m.cacheRead??0,cacheWrite:m.cacheWrite??0}):0),p=(h.cost??0)+(l?.cost??0),q=(h.usage.credits??0)+(m?.credits??0),r=m?.contextPct??h.contextPct,s=null!==h.cost||l?.cost!==void 0,t=h.usage,u=Math.max(1,t.input+t.output+t.cacheRead+t.cacheWrite),E=Math.max(1,...h.tools.map(a=>a.count)),F=Math.max(1,...h.timeline.map(a=>a.tokens));return(0,d.jsxs)("div",{className:"stats-wrap",children:[(0,d.jsxs)("button",{className:"statsbar",onClick:()=>k(a=>!a),"aria-expanded":j,children:[(0,d.jsxs)("span",{className:"sb",title:`${c("stats.contextTitle")} \xb7 ${(0,C.yj)(h.lastContext)}${h.contextWindow?` / ${(0,C.yj)(h.contextWindow)}`:""}`,children:[(0,d.jsx)(v,{size:14}),(0,d.jsx)("b",{children:null!==r?`${r.toFixed(+(r<10))}%`:(0,C.yj)(h.lastContext)}),c("stats.context")]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(w.A,{size:14}),(0,d.jsx)("b",{children:(0,C.yj)(n)}),c("stats.tokens")]}),q>0&&(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(x.A,{size:14}),(0,d.jsx)("b",{children:q.toFixed(2)}),c("stats.credits")]}),s&&(0,d.jsxs)("span",{className:"sb",title:h.costEstimated?c("stats.costEstimated"):c("stats.costReported"),children:[(0,d.jsx)(x.A,{size:14}),(0,d.jsxs)("b",{children:[h.costEstimated?"≈ ":"",(0,C.F0)(p)]})]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(y,{size:14}),(0,d.jsx)("b",{children:h.turns}),c("stats.turns",{count:h.turns})]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(z.A,{size:14}),(0,d.jsx)("b",{children:h.toolCalls}),c("stats.toolCalls",{count:h.toolCalls}),h.toolErrors>0&&(0,d.jsxs)("em",{className:"tbad",children:[" \xb7 ",c("stats.failed",{count:h.toolErrors})]})]}),h.durationMs>0&&(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(A.A,{size:14}),(0,d.jsx)("b",{children:(0,C.nc)(h.durationMs)}),c("stats.working")]}),(0,d.jsx)(B.A,{size:15,className:`chev2 ${j?"open":""}`})]}),j&&(0,d.jsxs)("div",{className:"statspanel",children:[(0,d.jsxs)("section",{children:[(0,d.jsx)("div",{className:"eyebrow",children:c("stats.mix")}),(0,d.jsxs)("div",{className:"mixbar",role:"img","aria-label":c("stats.mix"),children:[(0,d.jsx)("i",{className:"fa-c-cr",style:{width:`${t.cacheRead/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-cw",style:{width:`${t.cacheWrite/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-in",style:{width:`${t.input/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-out",style:{width:`${t.output/u*100}%`}})]}),(0,d.jsxs)("dl",{className:"legend",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-cr"}),(0,d.jsx)("dt",{children:c("stats.cacheRead")}),(0,d.jsx)("dd",{children:(0,C.yj)(t.cacheRead)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-cw"}),(0,d.jsx)("dt",{children:c("stats.cacheWrite")}),(0,d.jsx)("dd",{children:(0,C.yj)(t.cacheWrite)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-in"}),(0,d.jsx)("dt",{children:c("stats.input")}),(0,d.jsx)("dd",{children:(0,C.yj)(t.input)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-out"}),(0,d.jsx)("dt",{children:c("stats.output")}),(0,d.jsxs)("dd",{children:[(0,C.yj)(t.output),t.reasoning>0&&(0,d.jsxs)("span",{className:"muted",children:[" (",c("stats.thinking",{tokens:(0,C.yj)(t.reasoning)}),")"]})]})]})]}),h.models.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"eyebrow mt-m",children:c("stats.models")}),h.models.map(a=>(0,d.jsxs)("div",{className:"row small between",children:[(0,d.jsx)("span",{className:"mono",children:a.model}),(0,d.jsx)("span",{className:"muted",children:c("stats.modelLine",{count:a.messages,out:(0,C.yj)(a.output)})})]},a.model))]})]}),(0,d.jsxs)("section",{children:[(0,d.jsxs)("div",{className:"eyebrow",children:[c("stats.toolsUsed")," ",h.toolTimeMs>0&&(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",c("stats.totalTime",{time:(0,C.nc)(h.toolTimeMs)})]})]}),0===h.tools.length?(0,d.jsx)("p",{className:"muted small m0 mt-s",children:c("stats.noTools")}):h.tools.slice(0,9).map(a=>(0,d.jsxs)("div",{className:"toolrow",title:c("stats.toolTitle",{count:a.count,time:(0,C.nc)(a.totalMs)}),children:[(0,d.jsx)("span",{className:"mono tn",children:a.name.replace(/^mcp__/,"").replace("__"," \xb7 ")}),(0,d.jsx)("span",{className:"tbar",children:(0,d.jsx)("i",{style:{width:`${a.count/E*100}%`}})}),(0,d.jsxs)("span",{className:"tc",children:[a.count,a.errors>0&&(0,d.jsxs)("em",{className:"tbad",children:[" (",a.errors,"✗)"]})]}),(0,d.jsx)("span",{className:"td muted",children:a.totalMs?(0,C.nc)(a.totalMs/a.count):""})]},a.name))]}),(0,d.jsxs)("section",{className:"fa-span",children:[(0,d.jsx)("div",{className:"eyebrow",children:c("stats.perTurn")}),(0,d.jsx)("div",{className:"tbars",role:"list",children:h.timeline.slice(-40).map((a,b)=>(0,d.jsx)("div",{className:"sbar",role:"listitem",title:`${a.prompt||c("stats.promptFallback")}
2
- ${c("stats.turnLine",{tokens:(0,C.yj)(a.tokens),tools:a.tools,time:(0,C.nc)(a.durationMs)})}${null!==a.cost?` \xb7 ${(0,C.F0)(a.cost)}`:""}`,children:(0,d.jsx)("i",{style:{height:`${Math.max(4,a.tokens/F*100)}%`}})},b))})]})]})]})}var F=c(87456),G=c(58437),H=c(84300),I=c(32309),J=c(37811),K=c(96489),L=c(36368),M=c(93717),N=c(70226),O=c(81963);let P=["error","starting","running","ready","stopped","unknown"];function Q({agent:a}){let{t:b}=(0,D.s9)(),{objects:c}=(0,o.o0)(),e=(0,O.dj)(),[f,h]=(0,r.ud)("hive-am.chat.resources",!1),[j,k]=(0,r.ud)("hive-am.chat.resources.scope","mine"),[l,m]=(0,g.useState)(null);if(0===c.length)return null;let n=c.filter(b=>b.manager_id===a.id||(b.colony_id??null)===(a.colony_id??null)),q="all"===j||0===n.length,s=q?c:n,t=a=>s.filter(b=>b.state.status===a).length,u=async(a,c)=>{m(`${a.id}:${c}`);try{await p.FH.post(`/objects/${a.id}/action`,{action:c})}catch(a){e(`${b("obj.act.failed",{action:b(`obj.act.${c}`)})}: ${a instanceof Error?a.message:""}`,"err")}finally{m(null)}};return(0,d.jsxs)("div",{className:"cres",children:[(0,d.jsxs)("button",{type:"button",className:"cres-head","aria-expanded":f,onClick:()=>h(!f),children:[(0,d.jsx)(F.A,{size:15,"aria-hidden":!0}),(0,d.jsx)("b",{children:b("cres.title")}),(0,d.jsx)("span",{className:"cres-sum",children:P.filter(a=>t(a)>0).map(a=>(0,d.jsxs)("span",{className:`cres-n ${M.Wy[a]}`,children:[(0,d.jsx)(L.md,{status:a}),t(a)," ",(0,d.jsx)("em",{children:b(`cres.n.${a}`)})]},a))}),(0,d.jsx)(B.A,{size:15,className:`chev2 ${f?"open":""}`,"aria-hidden":!0})]}),f&&(0,d.jsxs)("div",{className:"cres-body",children:[n.length>0&&n.length<c.length&&(0,d.jsxs)("div",{className:"seg cres-scope",role:"group","aria-label":b("cres.scope"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":!q,onClick:()=>k("mine"),children:b("cres.mine",{a1:String(n.length)})}),(0,d.jsx)("button",{type:"button","aria-pressed":q,onClick:()=>k("all"),children:b("cres.all",{a1:String(c.length)})})]}),0===n.length&&(0,d.jsx)("p",{className:"muted small cres-note",children:b("cres.none")}),(0,d.jsx)("ul",{className:"cres-grid",children:s.map(a=>{let c=M.Nd[a.kind].icon,e=a.state.status,f="running"===e||"starting"===e,g=N.no.includes(a.kind),h=l?.startsWith(`${a.id}:`)??!1,j=(0,M.HS)(b,a.state.detail);return(0,d.jsxs)("li",{className:`cres-card ${M.Wy[e]}`,children:[(0,d.jsx)("span",{className:"cres-ico",style:{"--c":M.Nd[a.kind].color},children:(0,d.jsx)(c,{size:16,"aria-hidden":!0})}),(0,d.jsxs)("div",{className:"cres-info",children:[(0,d.jsx)(i(),{className:"cres-name",href:`/resources/${a.id}`,title:b("obj.open"),children:a.name}),(0,d.jsxs)("span",{className:`cres-st ${M.Wy[e]}`,title:j||void 0,children:[(0,d.jsx)(L.md,{status:e}),b(`obj.status.${e}`),j&&"error"===e?(0,d.jsx)("em",{children:j}):null]})]}),(0,d.jsxs)("div",{className:"cres-act",children:[h&&(0,d.jsx)(G.A,{size:14,className:"spin muted","aria-hidden":!0}),g&&(f?(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"stop"),"aria-label":b("obj.act.stop"),title:b("obj.act.stop"),children:(0,d.jsx)(H.A,{size:14})}):(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"start"),"aria-label":b("obj.act.start"),title:b("obj.act.start"),children:(0,d.jsx)(I.A,{size:14})})),g&&(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"restart"),"aria-label":b("obj.act.restart"),title:b("obj.act.restart"),children:(0,d.jsx)(J.A,{size:14})}),(0,d.jsx)(i(),{className:"btn ghost icon sm",href:`/resources/${a.id}`,"aria-label":b("obj.open"),title:b("obj.open"),children:(0,d.jsx)(K.A,{size:14})})]})]},a.id)})})]})]})}var R=c(2335),S=c(4111),T=c(77671);let U=(0,u.A)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);var V=c(29083);let W=(0,u.A)("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);var X=c(16487),Y=c(19993);let Z=(0,u.A)("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),$=(0,u.A)("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);function _(a,b,c=[],d={}){let e=new Map(b.map(a=>[a.path,a])),f=new Set(a);for(let a of b)f.add(a.path);let g={name:"",path:"",type:"dir",children:[],changed:0,additions:0,deletions:0},h=new Map([["",g]]),i=a=>{let b=h.get(a);if(b)return b;let c=a.lastIndexOf("/"),d=i(c<0?"":a.slice(0,c)),e={name:a.slice(c+1),path:a,type:"dir",children:[],changed:0,additions:0,deletions:0};return d.children.push(e),h.set(a,e),e};for(let a of f){let b=a.lastIndexOf("/");i(b<0?"":a.slice(0,b)).children.push({name:a.slice(b+1),path:a,type:"file",children:[],change:e.get(a),changed:+!!e.has(a),additions:e.get(a)?.additions??0,deletions:e.get(a)?.deletions??0})}let j=(a,b,c)=>{if(a.children.some(a=>a.path===b))return;let e={name:b.slice(b.lastIndexOf("/")+1),path:b,type:c?"dir":"file",children:[],ignored:!0,lazy:c&&!(b in d),changed:0,additions:0,deletions:0};if(a.children.push(e),c&&h.set(b,e),c)for(let a of d[b]??[])j(e,`${b}/${a.name}`,a.dir)};for(let a of c){let b=a.endsWith("/"),c=b?a.slice(0,-1):a,d=c.lastIndexOf("/");j(i(d<0?"":c.slice(0,d)),c,b)}let k=a=>{for(let b of(a.children.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"dir"===a.type?-1:1),a.children))"dir"===b.type&&k(b),a.changed+=(b.type,b.changed),a.additions+=b.additions,a.deletions+=b.deletions;a.children=a.children.map(a=>{let b=a;for(;"dir"===b.type&&1===b.children.length&&"dir"===b.children[0].type;){let a=b.children[0];b={...a,name:`${b.name}/${a.name}`}}return b})};return k(g),g}function aa(a,b,c){let d=c.query.trim().toLowerCase(),e=a=>(!c.onlyChanged||0!==a.changed)&&(!d||("file"===a.type?a.path.toLowerCase().includes(d):a.children.some(e))),f=[],g=(a,h)=>{for(let i of a.children)e(i)&&(f.push({node:i,depth:h}),"dir"===i.type&&(d||c.onlyChanged||b.has(i.path))&&g(i,h+1))};return g(a,0),f}var ab=c(8776),ac=c(48838);let ad=(0,u.A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);var ae=c(94788),af=c(37070),ag=c(31826);let ah=/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif)$/i,ai=/\.(md|markdown|mdx)$/i;var aj=c(23124),ak=c(31251);function al(a){let b={meta:[],hunks:[],binary:!1},c=null,d=0,e=0;for(let f of a.split("\n")){let a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/.exec(f);if(a){d=Number(a[1]),e=Number(a[2]),c={header:f,section:a[3]??"",lines:[]},b.hunks.push(c);continue}if(!c){/^Binary files .* differ$/.test(f)||f.startsWith("GIT binary patch")?b.binary=!0:(/^(rename|copy) (from|to) /.test(f)||/^(new|deleted) file mode/.test(f)||/^similarity index/.test(f))&&b.meta.push(f);continue}let g=f[0];if("+"===g)c.lines.push({kind:"add",newNo:e++,text:f.slice(1)});else if("-"===g)c.lines.push({kind:"del",oldNo:d++,text:f.slice(1)});else if(" "===g)c.lines.push({kind:"ctx",oldNo:d++,newNo:e++,text:f.slice(1)});else if("\\"===g){let a=c.lines[c.lines.length-1];a&&(a.noEol=!0)}}return b}let am=a=>/^(@@ [^@]+@@)/.exec(a)?.[1]??a;var an=c(74854),ao=c(70014),ap=c(61593),aq=c(26596),ar=c(21975);let as=(0,g.memo)(function({row:a,path:b,ws:c,actions:e,picking:f,onPick:g}){let{t:h}=(0,D.s9)();if("hunk"===a.t)return(0,d.jsxs)("div",{className:"vl-row hunk",children:[(0,d.jsx)("div",{className:"vl-ln",style:{left:0},children:"⋯"}),(0,d.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:"⋯"}),(0,d.jsxs)("div",{className:"vl-hl",children:[(0,d.jsx)("span",{className:"rng mono",children:a.header}),a.section&&(0,d.jsx)("span",{className:"hs",title:a.section,children:a.section}),e&&f?.hunk===a.idx?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",className:"hk-btn on",onClick:()=>e.pickAll(a.idx,a.changed),children:h("git.discard.lines.all")}),(0,d.jsxs)("button",{type:"button",className:"hk-btn danger on",disabled:!f.picked.size,onClick:()=>e.discardPicked(a.idx,a.header),children:[(0,d.jsx)(W,{size:12}),h("git.discard.lines.go",{count:f.picked.size})]}),(0,d.jsx)("button",{type:"button",className:"hk-btn on",onClick:e.stopPicking,children:h("common.cancel")})]}):e&&(0,d.jsxs)(d.Fragment,{children:[a.changed>0&&e.canPick&&(0,d.jsxs)("button",{type:"button",className:"hk-btn",title:h("git.discard.lines.hint"),onClick:()=>e.startPicking(a.idx),children:[(0,d.jsx)(ap.A,{size:12}),h("git.discard.lines")]}),(0,d.jsxs)("button",{type:"button",className:"hk-btn",title:h("git.discard.hunk.hint"),onClick:()=>e.discardHunk(a.idx,a.header),children:[(0,d.jsx)(W,{size:12}),h("git.discard.hunk")]})]})]})]});if("line"===a.t){let e=a.l;return(0,d.jsxs)("div",{className:`vl-row ${e.kind} ${g&&void 0!==a.k&&f?.picked.has(a.k)?"picked":""}`,onClick:g&&void 0!==a.k?()=>g(a.k):void 0,children:[(0,d.jsx)("div",{className:"vl-ln",style:{left:0},children:e.oldNo??""}),(0,d.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:e.newNo??""}),(0,d.jsx)("div",{className:"vl-sg",children:g&&void 0!==a.k?(0,d.jsx)("input",{type:"checkbox",checked:!!f?.picked.has(a.k),onChange:()=>void 0,"aria-label":h("git.discard.lines.pick")}):"add"===e.kind?"+":"del"===e.kind?"−":""}),(0,d.jsx)("div",{className:"vl-cd",children:(0,d.jsx)(ao.SH,{text:e.text,path:b,ws:c})})]})}let{left:i,right:j}=a.r;return(0,d.jsxs)("div",{className:"vl-row split",children:[(0,d.jsx)("div",{className:`vl-ln ${i?.kind??"void"}`,style:{left:0},children:i?.oldNo??""}),(0,d.jsx)("div",{className:`vl-cd ${i?.kind??"void"}`,title:i&&i.text.length>60?i.text:void 0,children:i?(0,d.jsx)(ao.SH,{text:i.text,path:b,ws:c}):null}),(0,d.jsx)("div",{className:`vl-ln ${j?.kind??"void"}`,children:j?.newNo??""}),(0,d.jsx)("div",{className:`vl-cd ${j?.kind??"void"}`,title:j&&j.text.length>60?j.text:void 0,children:j?(0,d.jsx)(ao.SH,{text:j.text,path:b,ws:c}):null})]})});function at({parsed:a,layout:b,path:c,cutOff:e=!1,firstIndex:f=0,onDiscardHunk:h,onDiscardLines:i}){let{whitespace:j}=(0,ab.Wx)(),k=(0,g.useMemo)(()=>(function(a,b,c,d=0){let e=[],f=(0,aq.KJ)(c);return a.hunks.forEach((a,c)=>{e.push({t:"hunk",idx:c+d,header:am(a.header),section:f?a.section:"",changed:a.lines.filter(a=>"ctx"!==a.kind).length});let g=0;if("unified"===b)for(let b of a.lines)e.push({t:"line",l:b,hunk:c+d,k:"ctx"===b.kind?void 0:g++});else for(let b of function(a){let b=[];for(let c=0;c<a.length;){let d=a[c];if("ctx"===d.kind){b.push({left:d,right:d}),c++;continue}let e=[],f=[];for(;c<a.length&&"del"===a[c].kind;)e.push(a[c++]);for(;c<a.length&&"add"===a[c].kind;)f.push(a[c++]);for(let a=0;a<Math.max(e.length,f.length);a++)b.push({left:e[a],right:f[a]})}return b}(a.lines))e.push({t:"pair",r:b})}),e})(a,b,c,f),[a,b,c,f]),l=(0,g.useMemo)(()=>a.hunks.reduce((a,b)=>b.lines.reduce((a,b)=>Math.max(a,b.text.length),a),0),[a]),m="unified"===b?`calc(12ch + 32px + 18px + ${l}ch + 24px)`:void 0,n=(0,g.useRef)(null),o=(0,g.useRef)(null),[p,q]=(0,g.useState)({max:0,track:0}),[r,s]=(0,g.useState)(null),t=a=>s(b=>{if(!b)return b;let c=new Set(b.picked);return c.has(a)?c.delete(a):c.add(a),{...b,picked:c}}),u=h?{canPick:"unified"===b&&!!i,discardHunk:h,startPicking:a=>s({hunk:a,picked:new Set}),stopPicking:()=>s(null),pickAll:(a,b)=>s({hunk:a,picked:new Set(Array.from({length:b},(a,b)=>b))}),discardPicked:(a,b)=>{if(r&&i){let c=[...r.picked].sort((a,b)=>a-b);s(null),i(a,b,c)}}}:void 0;return(0,d.jsxs)("div",{className:`vf is-${b}`,ref:n,style:{"--vl-left":"0px","--hx":"0px"},children:[a.meta.length>0&&(0,d.jsx)("div",{className:"gx-meta",children:a.meta.join(" \xb7 ")}),(0,d.jsx)("div",{className:"vf-main",children:(0,d.jsx)(ar.T,{count:k.length,width:m,render:b=>{let f=k[b],g="line"===f.t&&r?.hunk===f.hunk;return(0,d.jsx)(as,{row:f,path:c,ws:j,actions:"hunk"!==f.t||e&&f.idx===a.hunks.length-1?void 0:u,picking:"hunk"===f.t||g?r:void 0,onPick:g?t:void 0},b)}})}),"split"===b&&p.max>0&&(0,d.jsx)("div",{className:"hbar",ref:o,onScroll:a=>n.current?.style.setProperty("--hx",`${a.currentTarget.scrollLeft}px`),"aria-label":"Scroll sideways",children:(0,d.jsx)("div",{style:{width:p.track+p.max,height:1}})})]})}function au({path:a,hunk:b,index:c,total:e,extent:f,onClose:h,onGo:i}){let{t:j}=(0,D.s9)(),k=(0,g.useMemo)(()=>({meta:[],hunks:[b],binary:!1}),[b]),l=b.lines.length+1;return(0,d.jsxs)("div",{className:"vl-peek",role:"dialog","aria-label":j("git.peek.title"),onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"vl-peek-head",children:[(0,d.jsx)("b",{children:f?f.from===f.to?j("git.peek.line",{n:f.from}):j("git.peek.lines",{from:f.from,to:f.to}):j("git.peek.title")}),(0,d.jsx)("span",{className:"muted mono small grow",children:am(b.header)}),(0,d.jsx)("span",{className:"small muted",children:j("git.peek.count",{n:c+1,total:e})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:c<=0,onClick:()=>i(c-1),"aria-label":j("git.peek.prev"),title:`${j("git.peek.prev")} (Alt+↑)`,children:(0,d.jsx)(aj.A,{size:15})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:c>=e-1,onClick:()=>i(c+1),"aria-label":j("git.peek.next"),title:`${j("git.peek.next")} (Alt+↓)`,children:(0,d.jsx)(B.A,{size:15})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:h,"aria-label":j("common.close"),children:(0,d.jsx)(ak.A,{size:14})})]}),(0,d.jsx)("div",{className:"vl-peek-body",style:{height:Math.min(l*ar.U+4,260)},children:(0,d.jsx)(at,{parsed:k,layout:"unified",path:a,firstIndex:c})})]})}function av({f:a,agent:b,blame:c,onOpenCommit:e,marks:f,allNew:h,focusLine:i}){let j=f?.groups??[],[k,l]=(0,g.useState)(null),m=(0,g.useMemo)(()=>{let b=a.content.split("\n").length;return j.map(a=>({from:Math.min(a.from,b),to:Math.min(a.to,b)}))},[j,a.content]),n=k?m[k.block]??null:null,[o,p]=(0,g.useState)(),r=(b,c)=>{let d={from:b.from,to:Math.min(b.to,a.content.split("\n").length)};return(d.to-(c+1)<=25?Math.max(d.to,c+1):c+1)*ar.U},s=a=>34+Math.min((a.view.lines.length+1)*ar.U+4,260)+14,{t}=(0,D.s9)(),{whitespace:u}=(0,ab.Wx)(),[v,w]=(0,g.useState)(null),[x,y]=(0,g.useState)(null),z=(0,an.Z)(a.content,a.path),A=(0,g.useMemo)(()=>z.length&&""===z[z.length-1]?z.slice(0,-1):z,[z]),B=(0,g.useMemo)(()=>a.content.split("\n").reduce((a,b)=>Math.max(a,b.length),0),[a.content]),E=(0,g.useMemo)(()=>{if(!v)return null;let a=-1;return v.lines.map((b,c)=>{let d=b!==v.lines[c-1];return d&&a++,{first:d,g:a%2}})},[v]);if(a.binary)return(0,d.jsx)("p",{className:"gx-note",children:t("git.file.binary")});if(0===A.length)return(0,d.jsx)("p",{className:"gx-note",children:t("git.file.empty")});let F=210*!!v;return(0,d.jsxs)("div",{className:"vf",children:["head"===a.source&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.file.deleted")}),a.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.file.truncated")}),x&&(0,d.jsx)("div",{className:"gx-banner",children:x}),v?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.blame.truncated",{count:v.lines.length})}),(0,d.jsx)("div",{className:"vf-main",style:{"--vl-left":`${F}px`},children:(0,d.jsx)(ar.T,{count:A.length,width:`calc(${F}px + 6ch + ${B}ch + 40px)`,overlay:k&&j[k.block]?{top:r(j[k.block],k.row),node:(0,d.jsx)(au,{path:a.path,hunk:j[k.block].view,index:k.block,extent:n,onClose:()=>l(null),total:j.length,onGo:a=>{let b=m[a];if(!b)return;let c=Math.max(0,b.from-1);l({row:c,block:a}),p({top:c*ar.U,bottom:r(j[a],c)+s(j[a]),key:Date.now()})}})}:void 0,reveal:i?{top:Math.max(0,i.line-4)*ar.U,bottom:(i.line+2)*ar.U,key:i.key}:o,render:b=>{let c=v?.lines[b],g=c?v.commits[c]:void 0,m=E?.[b],o="worktree"===a.source?h?"add":f?.lines.get(b+1):void 0,w=!!f&&f.removedBefore.has(b+1),x=!!f&&b===A.length-1&&f.removedBefore.has(A.length+1),y=f&&"worktree"===a.source?f.blockOfLine.get(b+1)??(w?f.blockOfRemoval.get(b+1):x?f.blockOfRemoval.get(A.length+1):void 0):void 0;return(0,d.jsxs)("div",{className:`vl-row ${i&&b+1===i.line?"m-hit":""} ${m?`bl-g${m.g}`:""} ${o?`m-${o}`:""} ${w?"m-delb":x?"m-dela":""} ${void 0!==y?"has-peek":""} ${n&&b+1>=n.from&&b+1<=n.to?"in-peek":""}`,onClick:void 0!==y?a=>{if(!a.target.closest(".bl-btn")&&(a.target.closest(".vl-ln")||window.getSelection()?.isCollapsed)){if(k?.row===b)return void l(null);l({row:b,block:y}),p({top:b*ar.U,bottom:r(j[y],b)+s(j[y]),key:Date.now()})}}:void 0,title:void 0!==y?t("git.peek.hint"):void 0,children:[v&&(0,d.jsx)("div",{className:`vl-bl ${m?.first?"first":""}`,children:m?.first&&g&&(g.uncommitted?(0,d.jsx)("span",{className:"muted",children:t("git.blame.uncommitted")}):(0,d.jsxs)("button",{type:"button",className:"bl-btn",title:`${g.summary}
3
- ${g.author} \xb7 ${(0,C.v7)(g.time)}`,onClick:()=>e(c),children:[(0,d.jsx)("span",{className:"mono sha",children:g.short}),(0,d.jsx)("span",{className:"who",children:g.author}),(0,d.jsx)("span",{className:"when",children:(0,q.KN)(g.time)})]}))}),(0,d.jsx)("div",{className:"vl-ln",children:b+1}),(0,d.jsx)("div",{className:"vl-cd",children:(0,d.jsx)(ao.Yr,{html:A[b],ws:u})})]},b)}})})]})}function aw({agent:a,gitRef:b,path:c,toolbar:e=!0}){let{t:f}=(0,D.s9)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(""),[l,m]=(0,g.useState)("preview"),n=ah.test(c),o=ai.test(c);return(0,d.jsxs)(d.Fragment,{children:[e&&(0,d.jsxs)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:[(0,d.jsx)("span",{className:"mono small grow",title:c,style:{overflow:"hidden",textOverflow:"ellipsis"},children:c}),h&&(0,d.jsx)("span",{className:"muted small",children:(0,C.zi)(h.size)}),o&&h&&!h.binary&&(0,d.jsx)(O.$q,{value:l,onChange:m,options:[{id:"preview",label:f("git.view.preview")},{id:"source",label:f("git.view.source")}]}),(0,d.jsx)(R.WQ,{text:c,label:f("git.copyPath")})]}),(0,d.jsx)("div",{className:"gx-body",children:j?(0,d.jsx)("p",{className:"gx-note",children:j}):n?(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw-at?ref=${encodeURIComponent(b)}&path=${encodeURIComponent(c)}`,alt:c,onError:()=>k(f("git.file.missingAt",{ref:b}))})}):h?h.binary?(0,d.jsx)("p",{className:"gx-note",children:f("git.file.binary")}):o&&"preview"===l?(0,d.jsxs)("div",{className:"gx-md md",children:[h.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,d.jsx)(af.oz,{remarkPlugins:[ag.A],components:{a:a=>(0,d.jsx)("a",{...a,target:"_blank",rel:"noreferrer"})},children:h.content})]}):(0,d.jsx)(av,{f:h,agent:a,blame:!1,onOpenCommit:()=>void 0,marks:null,allNew:!1}):(0,d.jsx)("p",{className:"gx-note",children:f("git.loading")})})]})}let ax={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflict:"!",typechange:"T"};function ay({status:a,titled:b=!1}){let{t:c}=(0,D.s9)();return(0,d.jsx)("span",{className:`stl st-${a}`,title:b?c(`git.status.${a}`):void 0,children:ax[a]})}function az({agent:a,gitRef:b,path:c,label:e}){let[f,h]=(0,g.useState)(!0);return f?(0,d.jsxs)("figure",{className:"gx-pic",children:[(0,d.jsx)("figcaption",{className:"muted small",children:e}),(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw-at?ref=${encodeURIComponent(b)}&path=${encodeURIComponent(c)}`,alt:c,onError:()=>h(!1)})})]}):null}function aA({agent:a,detailUrl:b,diffUrl:c,header:e,focus:f,embedded:h=!1,before:i,after:j,label:k}){let{t:l}=(0,D.s9)(),[m,n]=(0,g.useState)(null),[o,p]=(0,g.useState)(null),[q,r]=(0,g.useState)(null),[s,t]=(0,g.useState)("unified"),[u,v]=(0,g.useState)(null),w=m?.files.find(a=>a.path===o),x=(0,g.useMemo)(()=>q&&w&&q.path===w.path?al(q.diff):null,[q,w]);if(u)return(0,d.jsx)("section",{className:"gx-preview",children:(0,d.jsx)("p",{className:"gx-note err",children:u})});if(!m)return(0,d.jsx)("section",{className:"gx-preview",children:(0,d.jsx)("p",{className:"gx-note",children:l("git.loading")})});let y=!!w&&ah.test(w.path);return(0,d.jsxs)("section",{className:`gx-preview gx-commitview ${h?"embedded":""}`,"aria-label":k,children:[(0,d.jsx)("header",{className:"gx-chead",children:e(m)}),0===m.files.length?(0,d.jsx)("p",{className:"gx-note",children:l("git.cmp.nofiles")}):(0,d.jsx)("div",{className:"gx-cfilelist",role:"listbox",children:m.files.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":o===a.path,className:`gx-cfile ${o===a.path?"sel":""}`,onClick:()=>p(a.path),title:a.oldPath?`${a.oldPath} → ${a.path}`:a.path,children:[(0,d.jsx)(ay,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},a.path))}),w&&(0,d.jsxs)(d.Fragment,{children:[!y&&(0,d.jsx)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:(0,d.jsx)(O.$q,{value:s,onChange:t,options:[{id:"unified",label:l("git.layout.unified")},{id:"split",label:l("git.layout.split")}]})}),(0,d.jsx)("div",{className:"gx-body",children:y?(0,d.jsxs)("div",{className:"gx-picpair",children:["added"!==w.status&&(0,d.jsx)(az,{agent:a,gitRef:i,path:w.oldPath??w.path,label:l("git.img.before")}),"deleted"!==w.status&&(0,d.jsx)(az,{agent:a,gitRef:j,path:w.path,label:l("git.img.after")})]}):x?x.binary?(0,d.jsx)("p",{className:"gx-note",children:l("git.diff.binary")}):0===x.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:l("git.diff.empty")}):(0,d.jsxs)(d.Fragment,{children:[q?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:l("git.diff.truncated")}),(0,d.jsx)(at,{parsed:x,layout:s,path:w.path})]}):(0,d.jsx)("p",{className:"gx-note",children:l("git.loading")})})]})]})}function aB({agent:a,sha:b,embedded:c=!1,focus:e}){let{t:f}=(0,D.s9)();return(0,d.jsx)(aA,{agent:a,detailUrl:`/agents/${a.id}/git/commit?sha=${b}`,embedded:c,focus:e,before:`${b}^`,after:b,label:b,diffUrl:c=>`/agents/${a.id}/git/commit-diff?sha=${b}&path=${encodeURIComponent(c.path)}${c.oldPath?`&old=${encodeURIComponent(c.oldPath)}`:""}`,header:a=>{let[b,...c]=a.message.split("\n"),e=c.join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h3",{children:b}),e&&(0,d.jsx)("pre",{className:"gx-cbody",children:e}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{className:"mono",children:a.sha.slice(0,10)}),(0,d.jsx)(R.WQ,{text:a.sha,label:f("git.info.copySha"),compact:!0}),(0,d.jsxs)("span",{children:["\xb7 ",a.author," \xb7 ",(0,C.v7)(a.date)]}),(0,d.jsxs)("span",{children:["\xb7 ",f("git.hist.files",{count:a.files.length})]})]})]})}})}function aC({agent:a,sel:b,onSelect:c,onLoaded:e}){let{t:f}=(0,D.s9)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(""),p=(0,g.useMemo)(()=>(h??[]).filter(a=>!l||`${a.name} ${a.subject}`.toLowerCase().includes(l.toLowerCase())),[h,l]);return n?(0,d.jsx)("p",{className:"gx-note err",children:n}):h?h.length?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"gx-filter",children:(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:f("git.tags.search"),value:l,onChange:a=>m(a.target.value),"aria-label":f("git.tags.search")})]})}),(0,d.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":f("git.tab.tags"),children:[p.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":b===a.name,className:`gx-commit ${b===a.name?"sel":""}`,onClick:()=>c(a),children:[(0,d.jsxs)("span",{className:"subj",children:[(0,d.jsx)(ad,{size:13,style:{verticalAlign:"-2px",marginRight:5}}),a.name]}),(0,d.jsx)("span",{className:"meta",children:a.subject||"—"}),(0,d.jsxs)("span",{className:"meta",children:[(0,d.jsx)("span",{className:"mono sha",children:a.sha.slice(0,8)})," \xb7 ",(0,q.KN)(Date.parse(a.date))]})]},a.name)),!p.length&&(0,d.jsx)("p",{className:"gx-note",children:f("git.noMatch",{query:l})}),j&&(0,d.jsx)("p",{className:"gx-note",children:f("git.tags.truncated",{count:h.length})})]})]}):(0,d.jsx)("p",{className:"gx-note",children:f("git.tags.empty")}):(0,d.jsx)("p",{className:"gx-note",children:f("git.loading")})}function aD({agent:a,tag:b,onChanged:c}){let{t:e}=(0,D.s9)(),f=(0,O.dj)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(""),l=!!h&&/^[\w./-]+$/.test(h)&&!h.startsWith("-")&&!h.endsWith("/")&&!h.includes(".."),m=async()=>{if(h&&l)try{await p.FH.post(`/agents/${a.id}/git/branch-create`,{branch:h,from:b.name}),f(e("git.tags.branchCreated",{branch:h})),i(null),k(""),c?.()}catch(a){k(a instanceof Error?a.message:"error")}},[n,o]=(0,g.useState)("files"),[q,r]=(0,g.useState)(null),[s,t]=(0,g.useState)(!1),[u,v]=(0,g.useState)(new Set),[w,x]=(0,g.useState)(""),[y,z]=(0,g.useState)(null),[A,E]=(0,g.useState)(""),F=(0,g.useMemo)(()=>q?_(q,[]):null,[q]),G=(0,g.useMemo)(()=>F?aa(F,u,{query:w,onlyChanged:!1}).slice(0,3e3):[],[F,u,w]);return(0,d.jsxs)("section",{className:"gx-preview gx-tagview","aria-label":b.name,children:[(0,d.jsxs)("header",{className:"gx-chead",children:[(0,d.jsxs)("h3",{children:[(0,d.jsx)(ad,{size:16,style:{verticalAlign:"-2px",marginRight:6}}),b.name]}),b.subject&&(0,d.jsx)("div",{children:b.subject}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{className:"gx-chip soft",children:b.annotated?e("git.tags.annotated"):e("git.tags.lightweight")}),(0,d.jsx)("span",{className:"mono",children:b.sha.slice(0,10)}),(0,d.jsx)(R.WQ,{text:b.sha,label:e("git.info.copySha"),compact:!0}),(0,d.jsxs)("span",{children:["\xb7 ",(0,C.v7)(b.date)]}),q&&(0,d.jsxs)("span",{children:["\xb7 ",e("git.tags.nfiles",{count:q.length})]})]}),(0,d.jsx)("div",{className:"row gap-s wrap",style:{marginTop:8},children:null===h?(0,d.jsxs)("button",{className:"btn sm",onClick:()=>i(""),children:[(0,d.jsx)(U,{size:14}),e("git.tags.newBranch")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{className:"input mono",style:{maxWidth:240},autoFocus:!0,placeholder:e("git.tags.branchName"),value:h,onChange:a=>{i(a.target.value.trim()),k("")},"aria-label":e("git.tags.branchName"),onKeyDown:a=>{"Enter"===a.key&&m(),"Escape"===a.key&&i(null)}}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!l,onClick:()=>void m(),children:e("git.tags.createBranch")}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>{i(null),k("")},children:e("common.cancel")})]})}),j&&(0,d.jsx)("p",{className:"gx-note err",style:{margin:0},children:j}),(0,d.jsx)("div",{style:{marginTop:4},children:(0,d.jsx)(O.$q,{value:n,onChange:o,options:[{id:"files",label:e("git.tags.files")},{id:"changes",label:e("git.tags.changes")}]})})]}),"changes"===n?(0,d.jsx)(aB,{agent:a,sha:b.sha,embedded:!0},b.sha):A?(0,d.jsx)("p",{className:"gx-note err",children:A}):F?(0,d.jsxs)("div",{className:"gx-tagfiles",children:[(0,d.jsxs)("div",{className:"gx-tagtree",children:[(0,d.jsx)("div",{className:"gx-filter",children:(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:e("git.filterPlaceholder"),value:w,onChange:a=>x(a.target.value),"aria-label":e("git.filterPlaceholder")})]})}),(0,d.jsxs)("div",{className:"gx-list",role:"tree",children:[0===G.length?(0,d.jsx)("p",{className:"gx-note",children:w?e("git.noMatch",{query:w}):e("git.noFiles")}):G.map(({node:a,depth:b})=>{let c="dir"===a.type,e=c&&(!!w||u.has(a.path));return(0,d.jsxs)("button",{type:"button",role:"treeitem","aria-level":b+1,"aria-expanded":c?e:void 0,"aria-selected":!c&&y===a.path,className:`gx-row ${c?"dir":"file"} ${!c&&y===a.path?"sel":""}`,style:{paddingLeft:8+14*b},title:a.path,onClick:()=>{let b;return c?(b=a.path,v(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})):z(a.path)},children:[(0,d.jsx)("span",{className:"chev",children:c?e?(0,d.jsx)(B.A,{size:14}):(0,d.jsx)(V.A,{size:14}):null}),(0,d.jsx)("span",{className:"ico",children:c?e?(0,d.jsx)(ae.A,{size:15}):(0,d.jsx)(S.A,{size:15}):(0,d.jsx)(Y.A,{size:15})}),(0,d.jsx)("span",{className:"nm",children:a.name})]},a.path)}),s&&(0,d.jsx)("p",{className:"gx-note",children:e("git.treeTruncated",{count:q?.length??0})})]})]}),(0,d.jsx)("div",{className:"gx-tagfile",children:y?(0,d.jsx)(aw,{agent:a,gitRef:b.name,path:y}):(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.tags.pick")})})})]}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")})]})}let aE=(0,u.A)("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var aF=c(28923),aG=c(2838);function aH({refs:a,value:b,onChange:c,label:e,extra:f,icon:h=!0,compact:i=!1}){let{t:j}=(0,D.s9)(),[k,l]=(0,g.useState)(!1),[m,n]=(0,g.useState)(""),o=(0,g.useRef)(null);(0,aG.s)(k,o,()=>l(!1));let p=a=>!m||`${a.name} ${a.subject}`.toLowerCase().includes(m.toLowerCase()),r=(0,g.useMemo)(()=>(a?.branches??[]).filter(p),[a,m]),s=(0,g.useMemo)(()=>(a?.remotes??[]).filter(p),[a,m]),t=(0,g.useMemo)(()=>(a?.tags??[]).filter(p),[a,m]),u=m.trim(),v=/^([0-9a-f]{7,40}|HEAD([~^]\d*)*)$/i.test(u)&&![...a?.branches??[],...a?.tags??[]].some(a=>a.name===u),w=a=>{c(a),l(!1)},x=(a,c)=>(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":b===a.name,className:`gx-refrow ${b===a.name?"sel":""}`,onClick:()=>w(a.name),title:a.subject,children:[(0,d.jsxs)("span",{className:"nm",children:[b===a.name?(0,d.jsx)(aF.A,{size:13}):"tag"===c?(0,d.jsx)(ad,{size:13}):(0,d.jsx)(U,{size:13}),a.name]}),(0,d.jsxs)("span",{className:"sub",children:[a.subject||"—"," \xb7 ",(0,q.KN)(Date.parse(a.date))]})]},`${c}:${a.name}`);return(0,d.jsxs)("div",{className:"gx-brmenu gx-refpick",ref:o,children:[i?(0,d.jsxs)("button",{type:"button",className:`btn sm ${b?"primary gx-refbtn":"ghost icon"}`,"aria-expanded":k,"aria-haspopup":"listbox","aria-label":e,title:e,onClick:()=>l(a=>!a),children:[(0,d.jsx)(U,{size:14}),b&&(0,d.jsx)("span",{className:"nm mono",children:b})]}):(0,d.jsxs)("button",{type:"button",className:"btn sm gx-refbtn","aria-expanded":k,"aria-haspopup":"listbox",title:e,onClick:()=>l(a=>!a),children:[h&&(0,d.jsx)(U,{size:14}),(0,d.jsx)("span",{className:"nm mono",children:f?.find(a=>a.value===b)?.label??(b||j("git.ref.pick"))}),(0,d.jsx)(B.A,{size:13})]}),k&&(0,d.jsxs)("div",{className:"gx-pop",role:"listbox",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{className:"input",autoFocus:!0,placeholder:j("git.ref.search"),value:m,onChange:a=>n(a.target.value),"aria-label":j("git.ref.search"),onKeyDown:a=>{"Enter"===a.key&&v&&w(u)}})]}),(0,d.jsxs)("div",{className:"gx-brlist",children:[!m&&f?.map(a=>(0,d.jsx)("button",{type:"button",role:"option","aria-selected":b===a.value,className:`gx-refrow ${b===a.value?"sel":""}`,onClick:()=>w(a.value),children:(0,d.jsxs)("span",{className:"nm",children:[b===a.value&&(0,d.jsx)(aF.A,{size:13}),a.label]})},a.value)),v&&(0,d.jsx)("button",{type:"button",className:"gx-refrow",onClick:()=>w(u),children:(0,d.jsx)("span",{className:"nm mono",children:j("git.ref.useCommit",{ref:u.slice(0,12)})})}),r.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.branches")}),r.map(a=>x(a,"branch")),t.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.tags")}),t.slice(0,200).map(a=>x(a,"tag")),s.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.remotes")}),s.slice(0,200).map(a=>x(a,"branch")),a&&!r.length&&!t.length&&!s.length&&!v&&(0,d.jsx)("p",{className:"gx-note",children:j("git.ref.none")})]})]})]})}function aI({refs:a,sel:b,onChange:c}){let{t:e}=(0,D.s9)();return(0,d.jsxs)("div",{className:"gx-cmpside",children:[(0,d.jsx)("label",{className:"label",children:e("git.cmp.base")}),(0,d.jsx)(aH,{refs:a,value:b.base,onChange:a=>c({...b,base:a})}),(0,d.jsx)("div",{className:"row",style:{justifyContent:"center"},children:(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>c({base:b.head,head:b.base}),disabled:!b.base&&!b.head,"aria-label":e("git.cmp.swap"),title:e("git.cmp.swap"),children:(0,d.jsx)(aE,{size:15,style:{transform:"rotate(90deg)"}})})}),(0,d.jsx)("label",{className:"label",children:e("git.cmp.head")}),(0,d.jsx)(aH,{refs:a,value:b.head,onChange:a=>c({...b,head:a})}),(!b.base||!b.head)&&(0,d.jsx)("p",{className:"muted small",children:e("git.cmp.pick")})]})}function aJ({agent:a,sel:b}){let{t:c}=(0,D.s9)();if(!(b.base&&b.head))return(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.cmp.pick")})})});let e=`base=${encodeURIComponent(b.base)}&head=${encodeURIComponent(b.head)}`;return(0,d.jsx)(aA,{agent:a,detailUrl:`/agents/${a.id}/git/compare?${e}`,before:b.base,after:b.head,label:`${b.base} → ${b.head}`,diffUrl:b=>`/agents/${a.id}/git/compare-diff?${e}&path=${encodeURIComponent(b.path)}${b.oldPath?`&old=${encodeURIComponent(b.oldPath)}`:""}`,header:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("h3",{children:[(0,d.jsx)("span",{className:"mono",children:b.base})," → ",(0,d.jsx)("span",{className:"mono",children:b.head})]}),a.base.sha===a.head.sha?(0,d.jsx)("p",{className:"muted small",style:{margin:0},children:c("git.cmp.same")}):(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{children:c("git.cmp.summary",{ahead:a.ahead,behind:a.behind})}),(0,d.jsxs)("span",{children:["\xb7 ",c("git.hist.files",{count:a.files.length})]})]}),a.commits.length>0&&(0,d.jsxs)("details",{className:"gx-cmpcommits",children:[(0,d.jsx)("summary",{children:c("git.cmp.commits",{count:a.ahead})}),(0,d.jsx)("ul",{children:a.commits.map(a=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"mono sha",children:a.short})," ",a.subject," ",(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",a.author," \xb7 ",(0,q.KN)(Date.parse(a.date))]})]},a.sha))}),a.commitsTruncated&&(0,d.jsx)("p",{className:"muted small",children:c("git.cmp.more",{count:a.commits.length})})]})]})})}function aK(a){let b=a.split("\n"),c=[];for(let a=0;a<b.length;a++){if(!/^<{7}( |$)/.test(b[a]))continue;let d=-1,e=-1,f=-1;for(let c=a+1;c<b.length&&!/^<{7}( |$)/.test(b[c]);c++)if(/^\|{7}( |$)/.test(b[c])&&d<0)e=c;else if("======="===b[c]&&d<0)d=c;else if(/^>{7}( |$)/.test(b[c])&&d>=0){f=c;break}d<0||f<0||(c.push({start:a,end:f,ours:b.slice(a+1,e>=0?e:d),base:e>=0?b.slice(e+1,d):void 0,theirs:b.slice(d+1,f),oursLabel:b[a].slice(8).trim(),theirsLabel:b[f].slice(8).trim()}),a=f)}return c}function aL(a,b,c){let d=aK(a)[b];if(!d)return a;let e={ours:d.ours,theirs:d.theirs,"ours-theirs":[...d.ours,...d.theirs],"theirs-ours":[...d.theirs,...d.ours]}[c],f=a.split("\n");return f.splice(d.start,d.end-d.start+1,...e),f.join("\n")}var aM=c(28521);function aN({agent:a,path:b,state:c,a:e,onResolved:f}){let{t:h}=(0,D.s9)(),[i,j]=(0,g.useState)(null),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(null),[p,q]=(0,g.useState)(0),r=(0,g.useMemo)(()=>aK(l),[l]),s="rebase"!==c&&"stash"!==c,t=a=>"mine"===a===s?"ours":"theirs",u=a=>"both-mine"===a?s?"ours-theirs":"theirs-ours":"both-remote"===a?s?"theirs-ours":"ours-theirs":t(a),v=/^(<{7}|>{7})( |$)/m.test(l),w=!!i&&!i.binary&&!i.truncated,x=!!e.busy,y=async a=>{await e.run("resolve",h("git.res.done"),"resolve-side",{path:b,side:t(a)})&&f()},z=async()=>{await e.run("resolve",h("git.res.done"),"resolve",{path:b,content:l})&&f()},A=async()=>{await e.run("unresolve",h("git.res.restored"),"unresolve",{path:b})&&q(a=>a+1)},B=b.lastIndexOf("/"),C=B>=0?b.slice(0,B+1):"",E=b.slice(B+1);return(0,d.jsxs)("section",{className:"gx-preview gx-resolver","aria-label":b,children:[(0,d.jsxs)("header",{className:"gx-phead",children:[(0,d.jsxs)("div",{className:"gx-ptitle",children:[(0,d.jsxs)("span",{className:"gx-path mono",title:b,children:[(0,d.jsx)("span",{className:"dir",children:C}),(0,d.jsx)("b",{children:E})]}),(0,d.jsx)("span",{className:"gx-chip st-conflict",children:h("git.status.conflict")}),w&&(0,d.jsx)("span",{className:"muted small",children:r.length>0?h("git.res.left",{count:r.length}):h("git.res.none")})]}),(0,d.jsxs)("div",{className:"gx-ptools",children:[(0,d.jsx)("button",{className:"btn sm",disabled:x,title:h("git.res.allMine.hint"),onClick:()=>void y("mine"),children:h("git.res.allMine")}),(0,d.jsx)("button",{className:"btn sm",disabled:x,title:h("git.res.allRemote.hint"),onClick:()=>void y("remote"),children:h("git.res.allRemote")}),(0,d.jsx)(R.WQ,{text:b,label:h("git.copyPath")})]})]}),n?(0,d.jsx)("p",{className:"gx-note err",children:n}):i?w?(0,d.jsxs)("div",{className:"gx-rbody",children:[r.length>0&&(0,d.jsx)("div",{className:"gx-rblocks",children:r.map((a,e)=>(0,d.jsxs)("div",{className:"gx-rcard",children:[(0,d.jsxs)("div",{className:"gx-rtitle",children:[(0,d.jsx)("b",{children:h("git.res.block",{n:e+1,total:r.length})}),(0,d.jsx)("span",{className:"muted small",children:h("git.res.line",{n:a.start+1})})]}),(0,d.jsx)("div",{className:"gx-rsides",children:["mine","remote"].map(f=>{let g,i="ours"===t(f)?a.ours:a.theirs,j=!(g="ours"===t(f)?a.oursLabel:a.theirsLabel)||["HEAD","ours","theirs","Updated upstream","Stashed changes"].includes(g)?"":g;return(0,d.jsxs)("div",{className:`gx-rside ${f}`,children:[(0,d.jsxs)("div",{className:"gx-rhead",children:[(0,d.jsx)("span",{children:"mine"===f?"stash"===c?h("git.res.mine.stash"):h("git.res.mine"):"stash"===c?h("git.res.remote.stash"):h("git.res.remote")}),j&&(0,d.jsx)("i",{className:"ref",children:j})]}),(0,d.jsx)("pre",{children:i.length?(0,d.jsx)(ao.Cy,{text:i.join("\n"),path:b}):(0,d.jsx)("span",{className:"muted",children:h("git.res.empty")})}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>aL(a,e,u(f))),children:"mine"===f?h("git.res.keepMine"):h("git.res.keepRemote")})]},f)})}),(0,d.jsxs)("div",{className:"gx-rboth",children:[(0,d.jsxs)("span",{className:"small muted",children:[h("git.res.both"),":"]}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>aL(a,e,u("both-mine"))),children:h("git.res.bothMine")}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>aL(a,e,u("both-remote"))),children:h("git.res.bothRemote")})]})]},`${e}-${a.start}`))}),(0,d.jsxs)("div",{className:"gx-rresult",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("label",{className:"label grow",htmlFor:"gx-result",children:h("git.res.result")}),(0,d.jsx)("span",{className:"small muted",children:h("git.res.editHint")})]}),(0,d.jsx)(aM.B,{id:"gx-result",label:h("git.res.result"),value:l,path:b,onChange:m})]}),(0,d.jsxs)("footer",{className:"gx-rfoot",children:[(0,d.jsxs)("button",{className:"btn ghost sm",disabled:x,onClick:()=>void A(),title:h("git.res.restore.hint"),children:[(0,d.jsx)(k.A,{size:14}),h("git.res.restore")]}),(0,d.jsx)("span",{className:"grow"}),(0,d.jsx)("button",{className:"btn primary",disabled:x||v,onClick:()=>void z(),children:h("git.res.markResolved")})]})]}):(0,d.jsx)("p",{className:"gx-note",children:h("git.res.noEdit")}):(0,d.jsx)("p",{className:"gx-note",children:h("git.loading")})]})}function aO({agent:a,plan:b,a:c,onClose:e,onGo:f}){let{t:g}=(0,D.s9)();return(0,d.jsxs)(O.TM,{title:g("git.sw.title",{branch:b.to}),confirmLabel:g("git.sw.anyway"),onConfirm:()=>{c.busy||f()},onClose:e,children:[b.carried>0&&(0,d.jsx)("p",{className:"confirm-body",children:g("git.sw.carried",{count:b.carried,from:b.from})}),(0,d.jsxs)("div",{className:"gx-sw-warn",role:"alert",children:[b.selfRunning&&(0,d.jsx)("div",{children:g("git.warn.running",{name:a.name})}),b.others.length>0&&(0,d.jsx)("div",{children:g("git.sw.others",{count:b.others.length,names:b.others.map(a=>a.name).join(", ")})})]})]})}let aP=(0,u.A)("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),aQ=(0,u.A)("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);var aR=c(34410);function aS({stashes:a,sel:b,onSelect:c,onSave:e,canSave:f}){let{t:g}=(0,D.s9)();return(0,d.jsxs)("div",{className:"gx-stashes",children:[(0,d.jsx)("div",{className:"gx-stash-head",children:(0,d.jsxs)("button",{className:"btn sm",disabled:!f,title:f?void 0:g("git.stash.nothing"),onClick:e,children:[(0,d.jsx)(aP,{size:14}),g("git.stash.save")]})}),a?0===a.length?(0,d.jsx)("p",{className:"gx-note",children:g("git.stash.empty")}):(0,d.jsx)("div",{className:"gx-hist",role:"listbox","aria-label":g("git.tab.stashes"),children:a.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":b===a.sha,className:`gx-commit ${b===a.sha?"sel":""}`,onClick:()=>c(a.sha),children:[(0,d.jsx)("span",{className:"subj",children:a.message||"—"}),(0,d.jsxs)("span",{className:"meta",children:[a.branch&&(0,d.jsxs)(d.Fragment,{children:[a.branch," \xb7 "]}),(0,q.KN)(Date.parse(a.date))]}),a.smart&&(0,d.jsx)("span",{className:"refs",children:(0,d.jsx)("i",{className:"ref",children:g("git.stash.smart")})})]},a.sha))}):(0,d.jsx)("p",{className:"gx-note",children:g("git.loading")})]})}function aT({a,onClose:b}){let{t:c}=(0,D.s9)(),[e,f]=(0,g.useState)(""),h=async()=>{b(),await a.run("stash",c("git.stash.saved"),"stash-save",{message:e})};return(0,d.jsxs)(O.aF,{title:c("git.stash.save"),onClose:b,children:[(0,d.jsx)("p",{className:"confirm-body",children:c("git.stash.save.body")}),(0,d.jsx)("input",{className:"input",autoFocus:!0,value:e,maxLength:200,placeholder:c("git.stash.save.placeholder"),onChange:a=>f(a.target.value),onKeyDown:a=>{"Enter"===a.key&&h()},"aria-label":c("git.stash.save.placeholder")}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:b,children:c("common.cancel")}),(0,d.jsx)("button",{className:"btn primary",disabled:!!a.busy,onClick:()=>void h(),children:c("git.stash.save")})]})]})}function aU({agent:a,stash:b,a:c}){let{t:e}=(0,D.s9)(),[f,h]=(0,g.useState)(null),[i,j]=(0,g.useState)(null),[k,l]=(0,g.useState)(null),[m,n]=(0,g.useState)(null),[o,p]=(0,g.useState)(!1),[r,s]=(0,g.useState)(null),t=(0,g.useMemo)(()=>m?al(m.diff):null,[m]),u=!!c.busy,v=a=>void c.run("stash",a?e("git.stash.popped"):e("git.stash.applied"),"stash-apply",{sha:b.sha,pop:a}),w=(i?.files.length??0)+(f?.untracked.length??0);return(0,d.jsxs)("section",{className:"gx-preview gx-commitview","aria-label":b.message,children:[(0,d.jsxs)("header",{className:"gx-chead",children:[(0,d.jsx)("h3",{children:b.message||"—"}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsxs)("span",{children:[b.branch&&`${b.branch} \xb7 `,(0,q.KN)(Date.parse(b.date))]}),f&&(0,d.jsxs)("span",{children:["\xb7 ",e("git.hist.files",{count:w})]})]}),(0,d.jsxs)("div",{className:"row gap-s wrap",children:[(0,d.jsxs)("button",{className:"btn sm",disabled:u,title:e("git.stash.apply.hint"),onClick:()=>v(!1),children:[(0,d.jsx)(aQ,{size:14}),e("git.stash.apply")]}),(0,d.jsx)("button",{className:"btn sm primary",disabled:u,title:e("git.stash.pop.hint"),onClick:()=>v(!0),children:e("git.stash.pop")}),(0,d.jsxs)("button",{className:"btn sm danger",disabled:u,onClick:()=>p(!0),children:[(0,d.jsx)(aR.A,{size:14}),e("git.stash.drop")]})]})]}),r?(0,d.jsx)("p",{className:"gx-note err",children:r}):i&&f?0===w?(0,d.jsx)("p",{className:"gx-note",children:e("git.hist.noFiles")}):(0,d.jsxs)("div",{className:"gx-cfilelist",role:"listbox",children:[i.files.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":k?.path===a.path&&!k.untracked,className:`gx-cfile ${k?.path===a.path&&!k.untracked?"sel":""}`,onClick:()=>l({path:a.path,untracked:!1,oldPath:a.oldPath}),children:[(0,d.jsx)(ay,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},`t-${a.path}`)),f.untracked.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":k?.path===a&&k.untracked,className:`gx-cfile ${k?.path===a&&k.untracked?"sel":""}`,onClick:()=>l({path:a,untracked:!0}),children:[(0,d.jsx)(ay,{status:"untracked"}),(0,d.jsx)("span",{className:"mono nm",children:a})]},`u-${a}`))]}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")}),k&&(0,d.jsx)("div",{className:"gx-body",children:t?t.binary?(0,d.jsx)("p",{className:"gx-note",children:e("git.diff.binary")}):0===t.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:e("git.diff.empty")}):(0,d.jsx)(at,{parsed:t,layout:"unified",path:k.path,cutOff:!!m?.truncated}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")})}),o&&(0,d.jsx)(O.TM,{danger:!0,title:e("git.stash.drop.title"),body:e("git.stash.drop.body",{name:b.message||"—"}),confirmLabel:e("git.stash.drop"),onClose:()=>p(!1),onConfirm:()=>{u||c.run("stash",e("git.stash.dropped"),"stash-drop",{sha:b.sha})},children:(0,d.jsx)("p",{className:"gx-lost",children:e("git.discard.all.warn")})})]})}let aV=(0,u.A)("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var aW=c(12675),aX=c(36414);let aY=(0,u.A)("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);function aZ({a}){let{t:b}=(0,D.s9)(),c=a.notice;return c?(0,d.jsxs)("div",{className:"gx-notice err",role:"alert",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("b",{className:"grow",children:c.title}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>a.setNotice(null),"aria-label":b("common.close"),children:(0,d.jsx)(ak.A,{size:14})})]}),(0,d.jsx)("pre",{children:c.text}),c.diverged&&(0,d.jsxs)("div",{className:"row gap-s wrap",children:[(0,d.jsx)("span",{className:"small muted",children:b("git.notice.diverged")}),(0,d.jsx)("button",{className:"btn sm",disabled:!!a.busy,onClick:()=>void a.run("pull",b("git.done.pull"),"pull",{mode:"merge"}),children:b("git.pull.merge")}),(0,d.jsx)("button",{className:"btn sm",disabled:!!a.busy,onClick:()=>void a.run("pull",b("git.done.pull"),"pull",{mode:"rebase"}),children:b("git.pull.rebase")})]})]}):null}function a$({a,ahead:b,behind:c,detached:e,changeCount:f,onCommit:g}){let{t:h}=(0,D.s9)(),i=!!a.busy;return(0,d.jsxs)("div",{className:"gx-acts",role:"group","aria-label":h("git.act.group"),children:[(0,d.jsx)("button",{className:"btn sm",disabled:i,title:`${h("git.act.fetch")}: ${h("git.act.fetch.hint")}`,"aria-label":h("git.act.fetch"),onClick:()=>void a.run("fetch",h("git.done.fetch"),"fetch"),children:"fetch"===a.busy?(0,d.jsx)(G.A,{size:14,className:"spin"}):(0,d.jsx)(aV,{size:14})}),(0,d.jsxs)("button",{className:"btn sm",disabled:i,title:`${h("git.act.pull")}: ${h("git.act.pull.hint")}`,"aria-label":h("git.act.pull"),onClick:()=>void a.run("pull",h("git.done.pull"),"pull"),children:["pull"===a.busy?(0,d.jsx)(G.A,{size:14,className:"spin"}):(0,d.jsx)(aW.A,{size:14}),c>0&&(0,d.jsx)("span",{className:"ct",children:c})]}),(0,d.jsxs)("button",{className:"btn sm",disabled:i||e,title:`${h("git.act.push")}: ${h("git.act.push.hint")}`,"aria-label":h("git.act.push"),onClick:()=>void a.run("push",h("git.done.push"),"push"),children:["push"===a.busy?(0,d.jsx)(G.A,{size:14,className:"spin"}):(0,d.jsx)(aX.A,{size:14}),b>0&&(0,d.jsx)("span",{className:"ct",children:b})]}),(0,d.jsxs)("button",{className:"btn sm primary",disabled:i||0===f,title:0===f?h("git.commit.nothing"):void 0,onClick:g,children:["commit"===a.busy?(0,d.jsx)(G.A,{size:14,className:"spin"}):(0,d.jsx)(aY,{size:14}),h("git.act.commit"),f>0&&(0,d.jsx)("span",{className:"ct",children:f})]})]})}var a_=c(71267);let a0=(0,u.A)("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function a1({agent:a,a:b,current:c,onSwitch:e}){let{t:f}=(0,D.s9)(),[h,i]=(0,g.useState)(!1),[j,k]=(0,g.useState)(null),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(""),[p,r]=(0,g.useState)(null),[s,t]=(0,g.useState)(null),[u,v]=(0,g.useState)(""),w=(0,g.useRef)(null);(0,aG.s)(h,w,()=>i(!1));let x=(0,g.useMemo)(()=>(j?.local??[]).filter(a=>a.name.toLowerCase().includes(l.toLowerCase())),[j,l]),y=(0,g.useMemo)(()=>{let a=new Set((j?.local??[]).map(a=>a.name));return(j?.remote??[]).filter(b=>!a.has(b.name.split("/").slice(1).join("/"))&&b.name.toLowerCase().includes(l.toLowerCase()))},[j,l]),z=async(a,c,d,e)=>{i(!1),await b.run(a,c,d,e)},A=/^[\w./-]+$/.test(n)&&!n.startsWith("-")&&!n.endsWith("/")&&!n.includes("..");return(0,d.jsxs)("div",{className:"gx-brmenu",ref:w,children:[(0,d.jsxs)("button",{type:"button",className:"btn sm","aria-expanded":h,"aria-haspopup":"dialog",onClick:()=>i(a=>!a),children:[(0,d.jsx)(U,{size:14}),f("git.act.branches"),(0,d.jsx)(B.A,{size:13})]}),h&&(0,d.jsxs)("div",{className:"gx-pop",role:"dialog","aria-label":f("git.act.branches"),children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{className:"input",autoFocus:!0,placeholder:f("git.br.search"),value:l,onChange:a=>m(a.target.value),"aria-label":f("git.br.search")})]}),(0,d.jsxs)("div",{className:"gx-newbr",children:[(0,d.jsx)("input",{className:"input mono",placeholder:f("git.br.newPlaceholder"),value:n,onChange:a=>o(a.target.value.trim()),"aria-label":f("git.br.new",{branch:c??""}),onKeyDown:a=>{"Enter"===a.key&&A&&z("switch",f("git.done.switch",{branch:n}),"switch",{branch:n,create:!0})}}),(0,d.jsxs)("button",{className:"btn sm",disabled:!A||!!b.busy,title:f("git.br.new",{branch:c??"…"}),onClick:()=>void z("switch",f("git.done.switch",{branch:n}),"switch",{branch:n,create:!0}),children:[(0,d.jsx)(a_.A,{size:14}),f("git.br.create")]})]}),u&&(0,d.jsx)("p",{className:"gx-note err",children:u}),(0,d.jsxs)("div",{className:"gx-brlist",children:[x.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:f("git.br.local")}),x.map(a=>(0,d.jsxs)("div",{className:`gx-br ${a.name===c?"cur":""}`,children:[(0,d.jsxs)("button",{className:"grow",disabled:a.name===c||!!b.busy,onClick:()=>{i(!1),e(a.name)},title:f("git.br.switchTo",{branch:a.name}),children:[(0,d.jsxs)("span",{className:"nm",children:[a.name===c&&(0,d.jsx)(aF.A,{size:13}),a.name]}),(0,d.jsxs)("span",{className:"sub",children:[a.subject," \xb7 ",(0,q.KN)(Date.parse(a.date))]})]}),a.name!==c&&(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>r(a.name),"aria-label":f("git.br.merge",{branch:c??""}),title:f("git.br.merge",{branch:c??""}),children:(0,d.jsx)(a0,{size:14})}),a.name!==c&&(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>{b.setNotice(null),t(a.name),i(!1)},"aria-label":f("git.br.delete",{branch:a.name}),title:f("git.br.delete",{branch:a.name}),children:(0,d.jsx)(aR.A,{size:14})})]},a.name)),y.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:f("git.br.remote")}),y.map(a=>(0,d.jsxs)("div",{className:"gx-br",children:[(0,d.jsxs)("button",{className:"grow",disabled:!!b.busy,onClick:()=>{let b=a.name.split("/").slice(1).join("/");i(!1),e(b)},title:f("git.br.switchTo",{branch:a.name}),children:[(0,d.jsx)("span",{className:"nm",children:a.name}),(0,d.jsxs)("span",{className:"sub",children:[a.subject," \xb7 ",(0,q.KN)(Date.parse(a.date))]})]}),(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>r(a.name),"aria-label":f("git.br.merge",{branch:c??""}),title:f("git.br.merge",{branch:c??""}),children:(0,d.jsx)(a0,{size:14})})]},a.name)),j&&!x.length&&!y.length&&(0,d.jsx)("p",{className:"gx-note",children:f("git.br.none")})]}),p&&(0,d.jsxs)("div",{className:"gx-mergeask",children:[(0,d.jsx)("span",{children:f("git.br.mergeAsk",{from:p,into:c??""})}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>r(null),children:f("common.cancel")}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!!b.busy,onClick:()=>void z("merge",f("git.done.merge",{branch:p}),"merge",{branch:p}),children:f("git.br.mergeGo")})]})]})]}),s&&(0,d.jsxs)(O.aF,{title:f("git.br.delete",{branch:s}),onClose:()=>t(null),children:[(0,d.jsx)("p",{className:"confirm-body",children:f("git.br.deleteAsk",{branch:s})}),b.notice&&(0,d.jsx)("pre",{className:"gx-notice err gx-prewrap",children:b.notice.text}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>t(null),children:f("common.cancel")}),b.notice&&/not fully merged/i.test(b.notice.text)?(0,d.jsx)("button",{className:"btn danger",disabled:!!b.busy,onClick:async()=>{await b.run("branch-delete",f("git.done.branchDelete"),"branch-delete",{branch:s,force:!0})&&t(null)},children:f("git.br.deleteForce")}):(0,d.jsx)("button",{className:"btn danger",disabled:!!b.busy,onClick:async()=>{await b.run("branch-delete",f("git.done.branchDelete"),"branch-delete",{branch:s})&&t(null)},children:f("git.br.deleteGo")})]})]})]})}function a2({changes:a,a:b,onClose:c,initialMessage:e=""}){let{t:f}=(0,D.s9)(),[h,i]=(0,g.useState)(()=>new Set(a.map(a=>a.path))),[j,k]=(0,g.useState)(e),l=a.filter(a=>h.has(a.path)),m=l.flatMap(a=>a.oldPath?[a.path,a.oldPath]:[a.path]),n=!!j.trim()&&l.length>0&&!b.busy,o=async a=>{if(!await b.run("commit",f("git.done.commit"),"commit",{message:j,paths:m}))return void c();c(),a&&await b.run("push",f("git.done.push"),"push")};return(0,d.jsxs)(O.aF,{title:f("git.commit.title"),onClose:c,children:[(0,d.jsxs)("div",{className:"gx-cfiles",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("span",{className:"small muted grow",children:f("git.commit.selected",{n:l.length,total:a.length})}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>i(new Set(a.map(a=>a.path))),children:f("git.commit.all")}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>i(new Set),children:f("git.commit.none")})]}),(0,d.jsx)("div",{className:"gx-clist",children:a.map(a=>(0,d.jsxs)("label",{className:"gx-crow",title:a.path,children:[(0,d.jsx)("input",{type:"checkbox",checked:h.has(a.path),onChange:()=>{let b;return b=a.path,i(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})}}),(0,d.jsx)(ay,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},a.path))})]}),(0,d.jsxs)("div",{className:"field",children:[(0,d.jsx)("label",{children:f("git.commit.message")}),(0,d.jsx)("textarea",{className:"textarea",rows:4,autoFocus:!0,value:j,onChange:a=>k(a.target.value),placeholder:f("git.commit.placeholder"),onKeyDown:a=>{(a.ctrlKey||a.metaKey)&&"Enter"===a.key&&n&&o(!1)}}),(0,d.jsx)("span",{className:"hint",children:f("git.commit.hint")})]}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:c,children:f("common.cancel")}),(0,d.jsx)("button",{className:"btn",disabled:!n,onClick:()=>void o(!1),children:"commit"===b.busy?f("git.commit.committing"):f("git.commit.go")}),(0,d.jsx)("button",{className:"btn primary",disabled:!n,onClick:()=>void o(!0),children:f("git.commit.goPush")})]})]})}function a3({agent:a,head:b,sel:c,onSelect:e,refs:f,path:h,onClearPath:i}){let{t:j}=(0,D.s9)(),[k,l]=(0,g.useState)(null),[m,n]=(0,g.useState)(!1),[o,r]=(0,g.useState)(!1),[s,t]=(0,g.useState)(""),[u,v]=(0,g.useState)(""),[w,x]=(0,g.useState)("message"),[y,z]=(0,g.useState)(""),[A,B]=(0,g.useState)(""),C=!!(A||h||y),E=async b=>{r(!0);try{let c=`skip=${b}${A?`&q=${encodeURIComponent(A)}&by=${w}`:""}${h?`&path=${encodeURIComponent(h)}`:""}${y?`&ref=${encodeURIComponent(y)}`:""}`,d=await p.FH.get(`/agents/${a.id}/git/log?${c}`);return l(a=>0===b?d.commits:[...a??[],...d.commits]),n(d.hasMore),t(""),d.commits}catch(a){return t(a instanceof Error?a.message:"error"),null}finally{r(!1)}};return(0,g.useRef)(""),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"gx-hfilter",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:j("git.hist.search"),value:u,onChange:a=>v(a.target.value),"aria-label":j("git.hist.search"),title:"content"===w?j("git.hist.by.hint"):void 0})]}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsxs)("select",{className:"input",value:w,onChange:a=>x(a.target.value),"aria-label":j("git.hist.search"),title:j("git.hist.by.hint"),children:[(0,d.jsx)("option",{value:"message",children:j("git.hist.by.message")}),(0,d.jsx)("option",{value:"author",children:j("git.hist.by.author")}),(0,d.jsx)("option",{value:"content",children:j("git.hist.by.content")})]}),(0,d.jsx)(aH,{refs:f,value:y,onChange:z,extra:[{value:"",label:j("git.hist.branchCurrent")},{value:"all",label:j("git.hist.branchAll")}]})]}),h&&(0,d.jsxs)("div",{className:"gx-chip soft gx-pathchip",children:[(0,d.jsx)("span",{className:"mono nm",title:h,children:j("git.hist.file",{path:h})}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:i,"aria-label":j("git.hist.clearFile"),title:j("git.hist.clearFile"),children:(0,d.jsx)(ak.A,{size:13})})]})]}),s?(0,d.jsx)("p",{className:"gx-note err",children:s}):k?k.length?(0,d.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":j("git.tab.history"),children:[k.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":c===a.sha,className:`gx-commit ${c===a.sha?"sel":""}`,onClick:()=>e(a.sha),children:[(0,d.jsx)("span",{className:"subj",children:a.subject||"—"}),(0,d.jsxs)("span",{className:"meta",children:[(0,d.jsx)("span",{className:"mono sha",children:a.short})," \xb7 ",a.author," \xb7 ",(0,q.KN)(Date.parse(a.date))]}),(a.refs.length>0||a.merge)&&(0,d.jsxs)("span",{className:"refs",children:[a.merge&&(0,d.jsx)("i",{className:"ref",children:j("git.hist.merge")}),a.refs.slice(0,3).map(a=>(0,d.jsx)("i",{className:"ref",children:a},a))]})]},a.sha)),m&&(0,d.jsx)("button",{className:"btn sm gx-more",disabled:o,onClick:()=>void E(k.length),children:o?j("git.loading"):j("git.hist.more")})]}):(0,d.jsx)("p",{className:"gx-note",children:C?j("git.hist.noMatch"):j("git.hist.empty")}):(0,d.jsx)("p",{className:"gx-note",children:j("git.loading")})]})}function a4({files:a,all:b,summary:c,file:e,onConfirm:f,onClose:g}){let{t:h}=(0,D.s9)(),i=(0,d.jsxs)("ul",{className:"gx-dlist",children:[a.slice(0,8).map(a=>(0,d.jsx)("li",{className:"mono",children:a},a)),a.length>8&&(0,d.jsx)("li",{className:"muted",children:h("hover.more",{count:a.length-8})})]});if(!b&&e&&!a.length){let a=e.add||e.del?` (+${e.add} −${e.del})`:"";return(0,d.jsxs)(O.TM,{danger:!0,title:h("git.discard.file.title"),confirmLabel:h("git.discard.file.go"),onConfirm:f,onClose:g,children:[(0,d.jsx)("p",{className:"gx-file-eff mono",children:e.path}),(0,d.jsx)("p",{className:"confirm-body",children:"deleted"===e.status?h("git.discard.file.deleted"):"renamed"===e.status?h("git.discard.file.renamed",{from:e.oldPath??""}):h("git.discard.file.modified",{lines:a})}),(0,d.jsx)("p",{className:"gx-lost",children:h("git.discard.all.warn")})]})}return b?(0,d.jsxs)(O.TM,{danger:!0,title:h("git.discard.all.title"),confirmLabel:h("git.discard.all.go"),onConfirm:f,onClose:g,children:[(0,d.jsxs)("ul",{className:"gx-effects",children:[c&&c.restore>0&&(0,d.jsx)("li",{children:h("git.discard.all.restore",{count:c.restore})}),a.length>0&&(0,d.jsxs)("li",{className:"bad",children:[(0,d.jsx)("b",{children:h("git.discard.all.delete",{count:a.length})}),i]})]}),c&&(0,d.jsx)("p",{className:"muted small confirm-body",children:h("git.discard.all.lines",{add:c.add,del:c.del})}),(0,d.jsx)("p",{className:"gx-lost",children:h("git.discard.all.warn")})]}):(0,d.jsx)(O.TM,{danger:!0,title:h("git.discard.confirm.title"),body:h("git.discard.confirm.body",{count:a.length}),confirmLabel:h("git.discard.confirm.go"),onConfirm:f,onClose:g,children:i})}let a5=(0,u.A)("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);function a6({agent:a,path:b,ignored:c=!1,change:e,stamp:f,refs:h,focusLine:i,onHistory:j,onOpenCommit:k,onDiscard:l,onDiscardHunk:n,onDiscardLines:o}){let{t:p}=(0,D.s9)(),[q,r]=(0,g.useState)(!1),s=!!e&&!ah.test(b),t=ai.test(b),[u,v]=(0,g.useState)(i?"file":s?"diff":t?"preview":"file"),[w,x]=(0,g.useState)("unified"),[y,z]=(0,g.useState)(null),[A,B]=(0,g.useState)(null),[E,F]=(0,g.useState)(null),[G,H]=(0,g.useState)(!1),[I,J]=(0,g.useState)(!1),K=ah.test(b),[L,M]=(0,g.useState)(null),N=(0,g.useMemo)(()=>y&&y.path===b?al(y.diff):null,[y,b]),[P,Q]=(0,g.useState)(null),S=e?.status==="untracked"||e?.status==="added"&&!e.oldPath,T=(0,g.useMemo)(()=>P&&P.path===b?al(P.diff):null,[P,b]),U=(0,g.useMemo)(()=>T?function(a){let b=new Map,c=new Set,d=new Map,e=new Map,f=[];for(let g of a.hunks){let a=g.lines,h=[],i=Number(/\+(\d+)/.exec(g.header)?.[1]??1);for(let b=0;b<a.length;b++)h[b]=i,"del"!==a[b].kind&&(i=(a[b].newNo??i)+1);let j=[];for(let b=0;b<a.length;){if("ctx"===a[b].kind){b++;continue}let c=b;for(;b<a.length&&"ctx"!==a[b].kind;)b++;j.push([c,b-1])}for(let[g,k]of j){let j=f.length,l=1/0,m=-1/0;for(let f=g;f<=k;){if("ctx"===a[f].kind){f++;continue}let g=[],n=[];for(;f<=k&&"del"===a[f].kind;)g.push(a[f++]);for(;f<=k&&"add"===a[f].kind;)n.push(a[f++]);n.forEach((a,c)=>{let e=a.newNo;b.set(e,c<g.length?"mod":"add"),d.set(e,j),l=Math.min(l,e),m=Math.max(m,e)});let o=n.length?n[n.length-1].newNo+1:f<a.length?h[f]:i;g.length>n.length&&(c.add(o),e.set(o,j),l=Math.min(l,o),m=Math.max(m,o))}let n=g;for(let b=0;b<3&&n>0&&"ctx"===a[n-1].kind;b++)n--;let o=k;for(let b=0;b<3&&o<a.length-1&&"ctx"===a[o+1].kind;b++)o++;let p=a.slice(n,o+1),q=p.filter(a=>void 0!==a.oldNo),r=p.filter(a=>void 0!==a.newNo);f.push({from:l,to:m,view:{header:`@@ -${q[0]?.oldNo??0},${q.length} +${r[0]?.newNo??0},${r.length} @@`,section:"",lines:p}})}}return{lines:b,removedBefore:c,blockOfLine:d,blockOfRemoval:e,groups:f}}(T):null,[T]),V=b.lastIndexOf("/"),X=V>=0?b.slice(0,V+1):"",Y=b.slice(V+1);return(0,d.jsxs)("section",{className:"gx-preview","aria-label":b,children:[(0,d.jsxs)("header",{className:"gx-phead",children:[(0,d.jsxs)("div",{className:"gx-ptitle",children:[(0,d.jsxs)("span",{className:"gx-path mono",title:b,children:[(0,d.jsx)("span",{className:"dir",children:X}),(0,d.jsx)("b",{children:Y})]}),c&&(0,d.jsx)("span",{className:"gx-chip soft",title:p("git.ignored.hint"),children:p("git.ignored.chip")}),e&&(0,d.jsx)("span",{className:`gx-chip st-${e.status}`,children:p(`git.status.${e.status}`)}),e?.staged&&(0,d.jsx)("span",{className:"gx-chip soft",children:p("git.staged")}),e?.unstaged&&"untracked"!==e.status&&(0,d.jsx)("span",{className:"gx-chip soft",children:p("git.unstaged")}),e&&(null!==e.additions||null!==e.deletions)&&(0,d.jsxs)("span",{className:"gx-counts",children:[(0,d.jsxs)("i",{className:"add",children:["+",e.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",e.deletions??0]})]}),A&&!e&&(0,d.jsx)("span",{className:"muted small",children:(0,C.zi)(A.size)})]}),(0,d.jsxs)("div",{className:"gx-ptr",children:[e?.status!=="untracked"&&!c&&(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",title:p("git.file.history"),"aria-label":p("git.file.history"),onClick:()=>j(b),children:(0,d.jsx)(m.A,{size:15})}),e?.status!=="untracked"&&!c&&(0,d.jsx)(aH,{refs:h,value:L??"",onChange:M,compact:!0,label:p("git.file.viewAt"),extra:[{value:"",label:p("git.file.viewAt")}]}),!K&&!c&&!L&&e?.status!=="deleted"&&e?.status!=="untracked"&&e?.status!=="conflict"&&(()=>{let a=q&&"file"===u;return(0,d.jsx)("button",{type:"button",className:`btn ghost icon sm ${a?"on":""}`,"aria-pressed":a,"aria-label":p("git.blame"),title:`${p("git.blame")}: ${p("git.blame.hint")}`,onClick:()=>{"file"!==u?(v("file"),r(!0)):r(a=>!a)},children:(0,d.jsx)(a5,{size:15})})})(),(0,d.jsx)(R.WQ,{text:b,label:p("git.copyPath"),compact:!0}),e&&"conflict"!==e.status&&(0,d.jsxs)("button",{type:"button",className:"btn sm",title:p("git.discard.hint"),onClick:()=>l(e),children:[(0,d.jsx)(W,{size:14}),p("git.discard")]})]}),(0,d.jsx)("div",{className:"gx-ptools",children:(0,d.jsxs)("div",{className:"gx-ptl",children:[(e||t)&&(0,d.jsx)(O.$q,{value:u,onChange:v,options:[...e?[{id:"diff",label:p("git.view.diff")}]:[],...t?[{id:"preview",label:p("git.view.preview")}]:[],{id:"file",label:p(t?"git.view.source":"git.view.file")}]}),"diff"===u&&e&&(0,d.jsx)(O.$q,{value:w,onChange:x,options:[{id:"unified",label:p("git.layout.unified")},{id:"split",label:p("git.layout.split")}]})]})})]}),e?.oldPath&&(0,d.jsx)("div",{className:"gx-banner",children:p("git.renamedFrom",{path:e.oldPath})}),L&&(0,d.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,d.jsx)("span",{className:"grow",children:p("git.file.atRef",{ref:L})}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>M(null),children:p("git.file.backToCurrent")})]}),L?(0,d.jsx)(aw,{agent:a,gitRef:L,path:e?.oldPath&&L?e.oldPath:b,toolbar:!1}):(0,d.jsx)("div",{className:"gx-body",children:E?(0,d.jsx)("p",{className:"gx-note err",children:E}):!G||N||A?"diff"===u&&e?N?N.binary?(0,d.jsx)("p",{className:"gx-note",children:p("git.diff.binary")}):0===N.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:p("git.diff.empty")}):(0,d.jsxs)(d.Fragment,{children:[y?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:p("git.diff.truncated")}),(0,d.jsx)(at,{parsed:N,layout:w,path:b,cutOff:!!y?.truncated,onDiscardHunk:e?.status==="modified"?(a,c)=>n(b,a,c):void 0,onDiscardLines:e?.status==="modified"?(a,c,d)=>o(b,a,c,d):void 0})]}):null:K&&!I&&e?.status!=="deleted"?(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw?path=${encodeURIComponent(b)}&v=${f}`,alt:Y,onError:()=>J(!0)})}):"preview"===u&&A&&A.path===b?(0,d.jsxs)("div",{className:"gx-md md",children:[A.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:p("git.diff.truncated")}),(0,d.jsx)(af.oz,{remarkPlugins:[ag.A],components:{a:a=>(0,d.jsx)("a",{...a,target:"_blank",rel:"noreferrer"})},children:A.content})]}):A&&A.path===b?(0,d.jsx)(av,{f:A,agent:a,blame:q,onOpenCommit:k,marks:U,allNew:S,focusLine:i}):K&&I?(0,d.jsx)("p",{className:"gx-note",children:p("git.file.binary")}):null:(0,d.jsx)("p",{className:"gx-note",children:p("git.loading")})})]})}let a7=(0,u.A)("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);var a8=c(78381);let a9=(0,u.A)("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);function ba({name:a}){return ah.test(a)?(0,d.jsx)(a7,{size:15}):/\.(md|mdx|txt|rst)$/i.test(a)?(0,d.jsx)(a8.A,{size:15}):(0,aq.eX)(a)?(0,d.jsx)(a9,{size:15}):(0,d.jsx)(Y.A,{size:15})}let bb=(0,g.memo)(function({rows:a,expanded:b,forceOpen:c,sel:e,onToggle:f,onSelect:h,label:i}){let{t:j}=(0,D.s9)(),k=(0,g.useRef)(null),[l,m]=(0,g.useState)(null),n=a=>`${a.ignored?"i:":""}${a.path}`,o=a.some(a=>n(a.node)===l)?l:a.find(a=>a.node.path===e&&!a.node.ignored)?.node.path??(a[0]?n(a[0].node):null),p=(0,g.useCallback)(a=>{let b=[...k.current?.querySelectorAll("[data-row]")??[]],c=b.indexOf(document.activeElement),d=c=>{a.preventDefault(),b[Math.max(0,Math.min(b.length-1,c))]?.focus()};if("ArrowDown"===a.key)d(c+1);else if("ArrowUp"===a.key)d(c-1);else if("Home"===a.key)d(0);else if("End"===a.key)d(b.length-1);else if(c>=0&&("ArrowRight"===a.key||"ArrowLeft"===a.key)){let e=b[c],f="1"===e.dataset.dir,g="true"===e.getAttribute("aria-expanded");if("ArrowRight"===a.key)f&&!g?(a.preventDefault(),e.click()):f&&g&&d(c+1);else if(f&&g)a.preventDefault(),e.click();else{let a=Number(e.getAttribute("aria-level"));for(let e=c-1;e>=0;e--)if(Number(b[e].getAttribute("aria-level"))<a){d(e);break}}}},[]);return(0,d.jsx)("div",{className:"gx-tree-rows",ref:k,onKeyDown:p,role:"tree","aria-label":i,children:a.map(({node:a,depth:g})=>{let i="dir"===a.type,k=i&&(c||b.has(a.path)),l=a.change,p=n(a);return(0,d.jsxs)("button",{"data-row":!0,"data-dir":i?"1":"0","data-path":a.path,type:"button",role:"treeitem","aria-level":g+1,"aria-expanded":i?!!k:void 0,"aria-selected":!i&&e===a.path,tabIndex:o===p?0:-1,onFocus:()=>m(p),className:`gx-row ${i?"dir":"file"} ${a.ignored?"ignored":""} ${l?`changed st-${l.status}`:""} ${!i&&e===a.path?"sel":""} ${i&&a.changed?"has-changes":""}`,style:{paddingLeft:8+14*g},title:a.ignored?`${a.path}: ${j("git.ignored.hint")}`:a.path,onClick:()=>i?f(a):h(a.path),children:[(0,d.jsx)("span",{className:"chev",children:i?k?(0,d.jsx)(B.A,{size:14}):(0,d.jsx)(V.A,{size:14}):null}),(0,d.jsx)("span",{className:"ico",children:i?k?(0,d.jsx)(ae.A,{size:15}):(0,d.jsx)(S.A,{size:15}):(0,d.jsx)(ba,{name:a.name})}),(0,d.jsx)("span",{className:"nm",children:a.name}),i&&a.changed>0&&(0,d.jsx)("span",{className:"dirdot",title:j("git.dirChanged",{count:a.changed}),children:a.changed}),l&&(0,d.jsxs)("span",{className:"meta",children:[(null!==l.additions||null!==l.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",l.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",l.deletions??0]})]}),(0,d.jsx)(ay,{status:l.status,titled:!0})]})]},p)})})}),bc=(0,u.A)("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),bd=(0,u.A)("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]),be=(0,u.A)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),bf=["files","history","tags","compare","stashes"],bg={files:bc,history:m.A,tags:ad,compare:bd,stashes:be},bh=a=>`gx-tab-${a}`,bi="gx-side-panel";function bj({mode:a,onChange:b,stashCount:c,label:e}){let{t:f}=(0,D.s9)(),g=a=>`${f(`git.tab.${a}`)}${"stashes"===a&&c?` \xb7 ${c}`:""}`;return(0,d.jsx)("div",{className:"gx-tabs",role:"tablist","aria-label":e,onKeyDown:c=>{let d=bf.indexOf(a),e=null;"ArrowRight"===c.key||"ArrowDown"===c.key?e=(d+1)%bf.length:"ArrowLeft"===c.key||"ArrowUp"===c.key?e=(d-1+bf.length)%bf.length:"Home"===c.key?e=0:"End"===c.key&&(e=bf.length-1),null!==e&&(c.preventDefault(),b(bf[e]),requestAnimationFrame(()=>document.getElementById(bh(bf[e]))?.focus()))},children:bf.map((c,e)=>{let f=bg[c];return(0,d.jsxs)("button",{id:bh(c),type:"button",role:"tab","aria-selected":a===c,"aria-controls":bi,tabIndex:a===c?0:-1,"aria-label":g(c),title:`${g(c)} (Alt+${e+1})`,className:`gx-tab ${a===c?"on":""}`,onClick:()=>b(c),children:[(0,d.jsx)(f,{size:15}),a===c&&(0,d.jsx)("span",{children:g(c)})]},c)})})}function bk({agent:a,git:b}){let{t:c}=(0,D.s9)(),{status:e,tree:f,loading:h,error:i,refresh:j}=b,[k,l]=(0,g.useState)(null),[m,n]=(0,g.useState)(new Set),[o,r]=(0,g.useState)(""),[s,t]=(0,g.useState)(!1),[u,v]=(0,g.useState)(!1),[w,x]=(0,g.useState)("files"),[y,z]=(0,g.useState)(null),[A,E]=(0,g.useState)({base:"",head:""}),[F,G]=(0,g.useState)(!1),[H,I]=(0,g.useState)(null),[J,K]=(0,g.useState)(),L=(0,g.useRef)(null),[M,N]=(0,g.useState)(null),[P,Q]=(0,g.useState)(null),[ad,ae]=(0,g.useState)(null),[af,ag]=(0,g.useState)(!1),[ah,ai]=(0,g.useState)(null),[aj,ak]=(0,g.useState)(!1),[al,am]=(0,g.useState)(null),[an,ao]=(0,g.useState)(!1),ap=function(a,b){let{t:c}=(0,D.s9)(),d=(0,O.dj)(),[e,f]=(0,g.useState)(null),[h,i]=(0,g.useState)(null),j=async(e,g,h,j={})=>{f(e),i(null);try{let e=await p.FH.post(`/agents/${a.id}/git/${h}`,j),f=(e.output??"").split("\n").filter(Boolean).pop()??"",i=["conflicts"===e.pending?c("git.pending.conflicts"):"",e.kept?.length?c("git.sw.kept",{count:e.kept.length,names:e.kept.slice(0,3).join(", ")}):""].filter(Boolean).join(", ");return d(i?`${g}: ${i}`:f&&f.length<90?`${g}: ${f}`:g),await b(),!0}catch(d){let a=d instanceof Error?d.message:"error";return i({title:c("git.notice.failed",{action:g}),text:a,diverged:/fast-forward|divergent/i.test(a)}),await b(),!1}finally{f(null)}};return{busy:e,notice:h,setNotice:i,run:j}}(a,()=>j()),[aq,ar]=(0,g.useState)(null),as=(0,ab.Wx)();(0,g.useRef)(new Set);let at=e&&e.isRepo?e:null,au=function(a,b){let[c,d]=(0,g.useState)(null);return c}(0,at?.head?.sha),av=f&&f.isRepo?f.files:null,aw=f&&f.isRepo?f.ignored:null,[ax,ay]=(0,g.useState)({}),az=(0,g.useMemo)(()=>at&&av?_(av,at.changes,as.showIgnored?aw??[]:[],ax):null,[at,av,aw,ax,as.showIgnored]),aA=(0,g.useMemo)(()=>{let a=(aw??[]).map(a=>a.replace(/\/$/,""));return b=>a.some(a=>b===a||b.startsWith(`${a}/`))},[aw]),aE=(0,g.useMemo)(()=>new Map((at?.changes??[]).map(a=>[a.path,a])),[at]),aF=(0,g.useMemo)(()=>(at?.changes??[]).reduce((a,b)=>({add:a.add+(b.additions??0),del:a.del+(b.deletions??0)}),{add:0,del:0}),[at]);a.id;let[aG,aH]=(0,g.useState)(!1),aK=(0,g.useRef)(null),aL=(0,g.useMemo)(()=>az?aa(az,m,{query:o,onlyChanged:s}):[],[az,m,o,s]),aM=(0,g.useMemo)(()=>aL.slice(0,2e3),[aL]),aP=(0,g.useRef)(ax);aP.current=ax;let aQ=(0,g.useCallback)(b=>{let c;c=b.path,n(a=>{let b=new Set(a);return b.has(c)?b.delete(c):b.add(c),b}),!b.ignored||!b.lazy||b.path in aP.current||p.FH.get(`/agents/${a.id}/git/ls?path=${encodeURIComponent(b.path)}`).then(a=>ay(c=>({...c,[b.path]:a.entries}))).catch(()=>ay(a=>({...a,[b.path]:[]})))},[a.id]),aR=(0,g.useCallback)(a=>{K(void 0),l(a)},[]);if(i&&!e)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsxs)("div",{className:"gx-empty",children:[(0,d.jsx)("h3",{children:c("git.error.title")}),(0,d.jsx)("p",{children:i}),(0,d.jsx)("button",{className:"btn",onClick:()=>void j(),children:c("git.refresh")})]})});if(!e)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.loading")})})});if(!e.isRepo)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsxs)("div",{className:"gx-empty",children:[(0,d.jsx)(S.A,{size:26,className:"muted"}),(0,d.jsx)("h3",{children:"not-repo"===e.reason?c("git.notRepo.title"):"no-git"===e.reason?c("git.noGit.title"):c("git.error.title")}),(0,d.jsx)("p",{children:"not-repo"===e.reason?c("git.notRepo.body",{path:e.cwd.replace(/^\/home\/[^/]+/,"~")}):"no-git"===e.reason?c("git.noGit.body"):e.message}),(0,d.jsxs)("button",{className:"btn",onClick:()=>void j(),children:[(0,d.jsx)(T.A,{size:14}),c("git.refresh")]})]})});let aV=k?aE.get(k):void 0,aW=a=>ap.run("switch",a.carried?c("git.done.switchCarried",{branch:a.to,count:a.carried}):c("git.done.switch",{branch:a.to}),a.overlap.length||a.collisions.length?"switch-smart":"switch",{branch:a.to}),aX=async b=>{try{let c=await p.FH.get(`/agents/${a.id}/git/switch-plan?branch=${encodeURIComponent(b)}`);c.others.length||c.selfRunning?ai(c):await aW(c)}catch(a){ap.setNotice({title:c("git.notice.failed",{action:c("git.done.switch",{branch:b})}),text:a instanceof Error?a.message:"error",diverged:!1})}},aY=a=>a.filter(a=>"untracked"===a.status||"added"===a.status&&!a.oldPath).map(a=>a.path),a_=(0,C.Xd)(e.generatedAt);return(0,d.jsxs)("div",{className:"gx","data-gx-theme":as.theme,style:{"--g-tab":as.tabSize},children:[(0,d.jsxs)("div",{className:"gx-bar",children:[(0,d.jsxs)("button",{type:"button",className:"gx-branch","aria-expanded":u,"aria-controls":"gx-info",title:c("git.info.toggle"),onClick:()=>v(a=>!a),children:[(0,d.jsx)(U,{size:14}),(0,d.jsx)("span",{className:"bn",children:e.branch??(e.head?`${c("git.detached")} ${e.head.sha}`:c("git.noCommitsBranch"))}),e.head&&(0,d.jsx)("span",{className:"sha",children:e.head.sha}),e.upstream&&(e.upstream.ahead>0||e.upstream.behind>0)&&(0,d.jsxs)("span",{className:"ab",title:c("git.upstream"),children:[e.upstream.ahead>0&&`↑${e.upstream.ahead}`,e.upstream.ahead>0&&e.upstream.behind>0&&" ",e.upstream.behind>0&&`↓${e.upstream.behind}`]}),u?(0,d.jsx)(B.A,{size:14}):(0,d.jsx)(V.A,{size:14})]}),(0,d.jsx)("span",{className:"grow"}),(0,d.jsx)("span",{className:"gx-sum",children:0===e.changes.length?(0,d.jsx)("span",{className:"muted",children:c("git.clean")}):(0,d.jsx)(d.Fragment,{children:(0,d.jsxs)("span",{title:c("git.summary",{count:e.changes.length}),"aria-label":c("git.summary",{count:e.changes.length}),children:[(0,d.jsx)("b",{children:e.changes.length})," ",(0,d.jsx)("span",{className:"muted",children:c("git.files.short")})," ",(0,d.jsxs)("i",{className:"add",children:["+",(0,C._E)(aF.add)]})," ",(0,d.jsxs)("i",{className:"del",children:["−",(0,C._E)(aF.del)]})]})})}),(0,d.jsx)(a1,{agent:a,a:ap,current:e.branch,onSwitch:a=>void aX(a)}),(0,d.jsx)(a$,{a:ap,ahead:e.upstream?.ahead??0,behind:e.upstream?.behind??0,detached:!e.branch,changeCount:e.changes.length,onCommit:()=>ao(!0)}),(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!ap.busy||0===e.changes.length||!!e.state,onClick:()=>{let a=aY(e.changes);ar({files:a,all:!0,summary:{restore:e.changes.length-a.length,add:aF.add,del:aF.del},go:async()=>{let a=await ap.run("discard-all",c("git.done.discard"),"discard-all");return a&&l(null),a}})},"aria-label":c("git.discard.all"),title:e.state?c("git.discard.all.blocked"):c("git.discard.all"),children:(0,d.jsx)(W,{size:15})}),(0,d.jsx)(ac.i,{}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void j(),"aria-label":c("git.refresh"),title:`${c("git.refresh")} \xb7 ${c("git.updated",{time:a_})}`,children:(0,d.jsx)(T.A,{size:15,className:h?"spin":""})})]}),u&&(0,d.jsxs)("dl",{id:"gx-info",className:"gx-info",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.branch")}),(0,d.jsxs)("dd",{className:"mono",children:[e.branch??(e.head?`${c("git.detached")} ${e.head.sha}`:c("git.noCommitsBranch")),e.branch&&(0,d.jsx)(R.WQ,{text:e.branch,label:c("git.info.copyBranch")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.upstreamLabel")}),(0,d.jsx)("dd",{children:e.upstream?0===e.upstream.ahead&&0===e.upstream.behind?c("git.info.inSync"):c("git.info.upstreamStatus",{ahead:e.upstream.ahead,behind:e.upstream.behind}):(0,d.jsx)("span",{className:"muted",children:c("git.info.noUpstream")})})]}),e.head?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.commit")}),(0,d.jsxs)("dd",{className:"mono",children:[e.head.sha,(0,d.jsx)(R.WQ,{text:e.head.sha,label:c("git.info.copySha")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.message")}),(0,d.jsx)("dd",{className:"msg",children:e.head.subject||(0,d.jsx)("span",{className:"muted",children:"—"})})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.author")}),(0,d.jsx)("dd",{children:e.head.author})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.when")}),(0,d.jsxs)("dd",{children:[(0,C.v7)(e.head.when)," ",(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",(0,q.KN)(Date.parse(e.head.when))]})]})]})]}):(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:c("git.info.commit")}),(0,d.jsx)("dd",{className:"muted",children:c("git.noCommits")})]})]}),"running"===a.status&&(0,d.jsx)("div",{className:"gx-warn",children:c("git.warn.running",{name:a.name})}),e.state&&(()=>{let a=e.changes.filter(a=>"conflict"===a.status),b="merge"===e.state?c("git.state.merge"):"rebase"===e.state?c("git.state.rebase"):c("git.state.stash");return(0,d.jsxs)("div",{className:"gx-state",role:"status",children:[(0,d.jsx)("b",{children:b}),(0,d.jsxs)("span",{className:"grow",children:["stash"===e.state&&e.stash&&(0,d.jsxs)(d.Fragment,{children:[c("git.state.stash.hint",{from:e.stash.from,to:e.stash.to})," \xb7 "]}),a.length>0?c("git.state.conflicts",{count:a.length}):c("git.state.ready")]}),0===a.length&&("merge"===e.state?(0,d.jsx)("button",{className:"btn primary sm",disabled:!!ap.busy,onClick:()=>ao(!0),children:c("git.state.finishMerge")}):"rebase"===e.state?(0,d.jsx)("button",{className:"btn primary sm",disabled:!!ap.busy,onClick:()=>void ap.run("continue",c("git.done.rebaseContinue"),"rebase-continue"),children:c("git.state.continueRebase")}):(0,d.jsx)("button",{className:"btn primary sm",disabled:!!ap.busy,onClick:()=>void ap.run("smart",c("git.done.smartFinish"),"smart-finish"),children:c("git.state.finishStash")})),"stash"===e.state?(0,d.jsx)("button",{className:"btn sm danger",disabled:!!ap.busy,onClick:()=>ak(!0),children:c("git.state.cancelStash")}):(0,d.jsx)("button",{className:"btn sm danger",disabled:!!ap.busy,onClick:()=>void ap.run("abort",c("git.done.mergeAbort"),"merge-abort"),children:"merge"===e.state?c("git.state.abortMerge"):c("git.state.abortRebase")})]})})(),(0,d.jsx)(aZ,{a:ap}),e.scope&&(0,d.jsx)("div",{className:"gx-scope",children:c("git.scope",{path:e.scope})}),(0,d.jsxs)("div",{className:"gx-main",children:[(0,d.jsxs)("aside",{className:"gx-tree","aria-label":c("git.filesLabel"),children:[(0,d.jsx)(bj,{mode:w,onChange:x,stashCount:P?.length??0,label:c("git.filesLabel")}),(0,d.jsx)("div",{className:"gx-sidepanel",id:bi,role:"tabpanel","aria-labelledby":bh(w),children:"stashes"===w?(0,d.jsx)(aS,{stashes:P,sel:ad,onSelect:ae,onSave:()=>ag(!0),canSave:e.changes.length>0&&!e.state}):"tags"===w?(0,d.jsx)(aC,{agent:a,sel:M?.name??null,onSelect:N,onLoaded:a=>{let b=aK.current;aK.current=null,b&&!M&&N(a.find(a=>a.name===b)??null)}}):"compare"===w?(0,d.jsx)(aI,{refs:au,sel:A,onChange:E}):"history"===w?(0,d.jsx)(a3,{agent:a,head:e.head?.sha,sel:al,onSelect:am,refs:au,path:y,onClearPath:()=>z(null)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"gx-filter",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(X.A,{size:14}),(0,d.jsx)("input",{ref:L,className:"input",placeholder:F?c("git.search.placeholder"):c("git.filterPlaceholder"),value:o,onChange:a=>r(a.target.value),"aria-label":c("git.filterPlaceholder")})]}),(0,d.jsxs)("div",{className:"seg icons",role:"group","aria-label":c("git.search.name"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":!F,title:c("git.search.name"),"aria-label":c("git.search.name"),onClick:()=>G(!1),children:(0,d.jsx)(Y.A,{size:14})}),(0,d.jsx)("button",{type:"button","aria-pressed":F,title:c("git.search.content"),"aria-label":c("git.search.content"),onClick:()=>G(!0),children:(0,d.jsx)(Z,{size:14})})]}),!F&&(0,d.jsxs)("button",{type:"button",className:`btn sm gx-onlych ${s?"primary":""}`,"aria-pressed":s,title:c("git.filter.changed"),onClick:()=>t(a=>!a),children:[(0,d.jsx)($,{size:14}),e.changes.length>0&&(0,d.jsx)("span",{className:"ct",children:e.changes.length})]})]}),F?(0,d.jsx)("div",{className:"gx-list gx-hits",children:o.trim().length<2?(0,d.jsx)("p",{className:"gx-note",children:c("git.search.min")}):H&&H.q===o.trim()?0===H.hits.length?(0,d.jsx)("p",{className:"gx-note",children:c("git.search.none",{query:H.q})}):(0,d.jsxs)(d.Fragment,{children:[H.hits.map((a,b)=>(0,d.jsxs)("button",{type:"button",className:`gx-hit ${k===a.path&&J?.line===a.line?"sel":""}`,onClick:()=>{l(a.path),K({line:a.line,key:Date.now()})},title:`${a.path}:${a.line}`,children:[(0,d.jsxs)("span",{className:"mono nm",children:[a.path,(0,d.jsxs)("i",{children:[":",a.line]})]}),(0,d.jsx)("span",{className:"mono tx",children:a.text.trim()})]},`${a.path}:${a.line}:${b}`)),H.truncated&&(0,d.jsx)("p",{className:"gx-note",children:c("git.search.capped",{count:H.hits.length})})]}):(0,d.jsx)("p",{className:"gx-note",children:c("git.search.searching")})}):(0,d.jsxs)("div",{className:"gx-list",children:[az?0===aM.length?(0,d.jsx)("p",{className:"gx-note",children:o?c("git.noMatch",{query:o}):s?c("git.clean"):c("git.noFiles")}):(0,d.jsx)(bb,{rows:aM,expanded:m,forceOpen:!!(o||s),sel:k,onToggle:aQ,onSelect:aR,label:c("git.filesLabel")}):(0,d.jsx)("p",{className:"gx-note",children:c("git.loading")}),aL.length>aM.length&&(0,d.jsx)("p",{className:"gx-note",children:c("git.rowsCapped",{count:aM.length})}),f?.isRepo&&f.truncated&&(0,d.jsx)("p",{className:"gx-note",children:c("git.treeTruncated",{count:f.files.length})})]})]})})]}),"stashes"===w?P?.find(a=>a.sha===ad)?(0,d.jsx)(aU,{agent:a,stash:P.find(a=>a.sha===ad),a:ap},ad):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.stash.empty")})})}):"compare"===w?(0,d.jsx)(aJ,{agent:a,sel:A}):"tags"===w?M?(0,d.jsx)(aD,{agent:a,tag:M,onChanged:()=>void j()},M.name):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.tags.select")})})}):"history"===w?al?(0,d.jsx)(aB,{agent:a,sha:al,focus:y??void 0},`${al}|${y??""}`):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.hist.select")})})}):k&&aV?.status==="conflict"?(0,d.jsx)(aN,{agent:a,path:k,state:e.state,a:ap,onResolved:()=>{j()}},k):k?(0,d.jsx)(a6,{agent:a,path:k,ignored:aA(k),change:aV,stamp:e.generatedAt,refs:au,focusLine:J,onHistory:a=>{z(a),am(null),x("history")},onOpenCommit:a=>{am(a),x("history")},onDiscard:a=>ar({files:aY([a]),all:!1,file:{path:a.path,status:a.status,oldPath:a.oldPath,add:a.additions??0,del:a.deletions??0},go:async()=>{let b=await ap.run("discard",c("git.done.discard"),"discard",{path:a.path,oldPath:a.oldPath});return b&&aY([a]).length&&l(null),b}}),onDiscardHunk:(a,b,d)=>void ap.run("discard-hunk",c("git.done.discard"),"discard-hunk",{path:a,index:b,header:d}),onDiscardLines:(a,b,d,e)=>void ap.run("discard-lines",c("git.done.discard"),"discard-lines",{path:a,index:b,header:d,lines:e})},k):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.select")})})})]}),ah&&(0,d.jsx)(aO,{agent:a,plan:ah,a:ap,onClose:()=>ai(null),onGo:()=>{ai(null),aW(ah)}}),af&&(0,d.jsx)(aT,{a:ap,onClose:()=>ag(!1)}),aj&&e.stash&&(0,d.jsx)(O.TM,{danger:!0,title:c("git.state.cancelStash.title"),body:c("git.state.cancelStash.body",{from:e.stash.from}),confirmLabel:c("git.state.cancelStash.go"),onClose:()=>ak(!1),onConfirm:()=>{ap.busy||ap.run("smart",c("git.done.smartCancel"),"smart-cancel")}}),aq&&(0,d.jsx)(a4,{files:aq.files,all:aq.all,summary:aq.summary,file:aq.file,onClose:()=>ar(null),onConfirm:()=>{aq.go()}}),an&&(0,d.jsx)(a2,{changes:e.changes,a:ap,initialMessage:e.mergeMsg,onClose:()=>ao(!1)})]})}var bl=c(58664),bm=c(15964),bn=c(8811);let bo=(0,u.A)("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);var bp=c(71556),bq=c(40123),br=c(59686);function bs({agent:a}){let{t:b}=(0,D.s9)(),{refresh:c}=(0,o.o0)(),e=(0,O.dj)(),[f,h]=(0,g.useState)(null),[i,j]=(0,g.useState)(""),[k,l]=(0,g.useState)(""),[m,n]=(0,g.useState)(!1),[r,s]=(0,g.useState)(!1),[t,u]=(0,g.useState)(!1),v=(0,g.useRef)(""),w=!!f&&i!==v.current,x=(0,g.useRef)(!1);x.current=w;let y=(0,g.useCallback)(async(b=!1)=>{try{let c=await p.FH.get(`/agents/${a.id}/notebook`);h(a=>a&&a.version===c.version&&a.enabled===c.enabled&&JSON.stringify(a.shared_with)===JSON.stringify(c.shared_with)?a:c),(b||!x.current)&&(v.current=c.content,j(c.content))}catch(a){l(a instanceof Error?a.message:String(a))}},[a.id]),z=async(c=i)=>{if(f){n(!0),l("");try{let d=await p.FH.put(`/agents/${a.id}/notebook`,{content:c,version:f.version});h({...f,...d}),v.current=d.content,j(d.content),e(b("notebook.saved"))}catch(a){l(a instanceof Error?a.message:String(a))}n(!1)}},A=async()=>{u(!1),l("");try{await p.FH.post(`/agents/${a.id}/notebook/separate`),e(b("notebook.separated")),await y(!0),await c(["agents"])}catch(a){l(a instanceof Error?a.message:String(a))}},B=async()=>{try{await p.FH.patch(`/agents/${a.id}`,{skill_ids:[...new Set([...a.skill_ids,f.skill_id])]}),await c(["agents"]),await y(!0)}catch(a){l(a instanceof Error?a.message:String(a))}};if(!f)return(0,d.jsx)("div",{className:"pane",children:(0,d.jsx)("p",{className:"hint",children:k||b("git.loading")})});let C=i.length,E=C>f.max,F=C>.8*f.max,G=f.shared_with??[];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"pane",children:[(0,d.jsx)("p",{className:"hint",style:{margin:0},children:b("notebook.intro")}),G.length>0&&(0,d.jsxs)("div",{className:"banner",children:[(0,d.jsx)(bn.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:b("notebook.sharedWith",{names:G.map(a=>a.name).join(", ")})}),(0,d.jsxs)("button",{className:"btn sm",onClick:()=>u(!0),children:[(0,d.jsx)(bo,{size:13}),b("notebook.separate")]})]}),!f.enabled&&(0,d.jsxs)("div",{className:"banner honey",children:[(0,d.jsx)(bp.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:b("notebook.off")}),(0,d.jsx)("button",{className:"btn sm",onClick:B,children:b("notebook.on")})]}),k&&(0,d.jsxs)("div",{className:"banner err",children:[(0,d.jsx)(bp.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:k}),(0,d.jsxs)("button",{className:"btn sm",onClick:()=>{l(""),y(!0)},children:[(0,d.jsx)(T.A,{size:13}),b("notebook.reload")]})]}),(0,d.jsxs)("div",{className:"row small muted",style:{justifyContent:"space-between"},children:[(0,d.jsxs)("span",{children:[(0,d.jsx)(bq.A,{size:12,style:{verticalAlign:"-1px"}})," ",f.updated_at?b("notebook.updated",{who:b("user"===f.updated_by?"notebook.by.you":"notebook.by.agent"),when:(0,q.KN)(f.updated_at)}):b("notebook.never")]}),(0,d.jsxs)("span",{style:{color:E?"var(--danger, #c0392b)":F?"var(--honey)":void 0},children:[C.toLocaleString()," / ",f.max.toLocaleString()]})]}),(0,d.jsx)(br.n,{value:i,onChange:j,placeholder:b("notebook.placeholder"),defaultView:"write",minHeight:320})]}),(0,d.jsxs)("div",{className:"savebar col",children:[(0,d.jsx)("span",{className:"muted small",children:w?b("agent.unsavedChanges"):b("agent.allSaved")}),(0,d.jsxs)("div",{className:"row",children:[(0,d.jsxs)("button",{className:"btn danger sm",style:{marginRight:"auto"},disabled:!i.trim()||m,onClick:()=>s(!0),children:[(0,d.jsx)(aR.A,{size:14}),b("notebook.clear")]}),w&&(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>j(v.current),children:b("common.discard")}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!w||m||E,onClick:()=>void z(),children:b("notebook.save")})]})]}),r&&(0,d.jsxs)(O.aF,{title:b("notebook.clear.title"),onClose:()=>s(!1),children:[(0,d.jsx)("p",{style:{margin:0},className:"muted",children:G.length?b("notebook.clear.shared",{names:G.map(a=>a.name).join(", ")}):b("notebook.clear.confirm")}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>s(!1),children:b("common.cancel")}),(0,d.jsx)("button",{className:"btn danger",onClick:()=>{s(!1),z("")},children:b("notebook.clear")})]})]}),t&&(0,d.jsxs)(O.aF,{title:b("notebook.separate.title"),onClose:()=>u(!1),children:[(0,d.jsx)("p",{style:{margin:0},className:"muted",children:b("notebook.separate.confirm",{name:a.name,names:G.map(a=>a.name).join(", ")})}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>u(!1),children:b("common.cancel")}),(0,d.jsx)("button",{className:"btn primary",onClick:()=>void A(),children:b("notebook.separate")})]})]})]})}var bt=c(4460);let bu=["config","notebook","sessions"];function bv({params:a}){let{id:b}=(0,g.use)(a);return(0,d.jsx)(bw,{id:b},b)}function bw({id:a}){let{t:b}=(0,D.s9)(),{ready:c,error:h,retry:r,refresh:u}=(0,o.q5)(),v=(0,o.fJ)(a),w=(0,j.useRouter)(),x=(0,O.dj)(),[y,z]=(0,s.Z)("tab",""),[A,B]=(0,g.useState)("config"),C=bu.includes(y)?y:A,F=""!==y,[G,H]=(0,g.useState)(!1),[I,J]=(0,g.useState)([]),[K,L]=(0,g.useState)(void 0),[M,N]=(0,g.useState)(null),[P,S]=(0,g.useState)("chat"),T=function(a,b){let{finished:c}=(0,o.o0)(),d=a?.id??"";c[d];let[e,f]=(0,g.useState)(null),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(null),n=(0,g.useRef)(0);a?.effective.cwd;let q=a?.status==="running",r=(0,g.useCallback)(async a=>{if(!d)return;let b=++n.current;k(!0);try{let[c,e]=await Promise.all([p.FH.get(`/agents/${d}/git/status`),a?p.FH.get(`/agents/${d}/git/tree`):Promise.resolve(null)]);if(b!==n.current)return;f(c),e&&i(e),m(null)}catch(a){b===n.current&&m(a instanceof Error?a.message:"error")}finally{b===n.current&&k(!1)}},[d]);return(0,bl.n)(()=>r(!0),5e3,{enabled:b&&q,immediate:!1}),{status:e,tree:h,loading:j,error:l,refresh:(0,g.useCallback)(()=>r(!0),[r])}}(v,"changes"===P),U=T.status&&T.status.isRepo?T.status.changes.length:0,V=(a,b)=>{let c=b??C;B(c),z(a?c:"")},W=(0,f.A)(v,{onDeleted:()=>w.push("/agents"),onCloned:a=>w.push(`/agents/${a.id}`)}),{draft:X,setDraft:Y,errors:Z,dirty:$}=W,_=()=>{$?H(!0):V(!1)};if(!v)return(0,d.jsx)("div",{className:"page",children:!c&&h?(0,d.jsxs)(O.lZ,{kind:"err",children:[(0,d.jsx)("span",{children:h})," ",(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void r(),children:b("fa.retry")})]}):c?(0,d.jsx)(O.pp,{title:b("agent.missing.title"),body:b("agent.missing.body"),action:(0,d.jsx)(i(),{className:"btn",href:"/agents",children:b("agent.missing.back")})}):null});let aa=async c=>{await p.FH.post(`/agents/${a}/resume-session`,{session_id:c}),L(void 0),x(b("agent.resumed"))},ab=I.filter(a=>"delegation"!==a.kind),ac=I.filter(a=>"delegation"===a.kind),ad=I.find(a=>a.session_id===K)?.kind==="delegation",ae=[...K?[{id:"make-current",label:b("agent.makeCurrent"),onClick:()=>void aa(K).catch(a=>x(a instanceof Error?a.message:String(a),"err")),disabled:ad},{id:"back-current",label:b("agent.backToCurrent"),onClick:()=>L(void 0)}]:[],{id:"new-conv",label:b("agent.newConversation"),icon:(0,d.jsx)(k.A,{size:14}),onClick:()=>N("new"),disabled:!v.session_id||"running"===v.status}];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("section",{className:"ws-chat",children:[(0,d.jsx)(O.DS,{back:{href:"/",label:b("agent.backToColony")},avatar:(0,d.jsx)(O._h,{agent:v}),title:v.name,meta:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(O.PW,{role:v.role}),(0,d.jsx)(O.dJ,{provider:v.provider}),(0,d.jsx)("span",{className:"small",children:v.model||b("model.cliDefault")}),(0,d.jsx)(O.P5,{status:v.status}),(0,d.jsx)(bt.IX,{agent:v,link:!0}),(0,d.jsx)(bt.R4,{agent:v})]}),actions:ae,primary:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"seg",role:"group","aria-label":b("git.tab.label"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":"chat"===P,onClick:()=>S("chat"),children:b("git.tab.chat")}),(0,d.jsxs)("button",{type:"button","aria-pressed":"changes"===P,onClick:()=>S("changes"),children:[b("git.tab.changes"),U>0&&(0,d.jsx)("span",{className:"tabcount",children:U})]})]}),(0,d.jsx)(e.N,{spec:{agentId:a},title:b("dock.agent")}),(0,d.jsxs)("button",{type:"button",className:`btn sm ${F?"primary":""}`,onClick:()=>F?_():V(!0),"aria-expanded":F,"aria-label":b("colony.agentSettings"),children:[(0,d.jsx)(l.A,{size:14}),b("agent.settings"),$&&(0,d.jsx)("i",{className:"dot run",title:b("agent.unsaved")})]})]})}),(0,d.jsxs)("div",{className:"chat-pane",hidden:"chat"!==P,children:[v.permission_stale&&!K&&(0,d.jsxs)(O.lZ,{kind:"warn",action:(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>N("new"),children:b("agent.permStale.action")}),children:[(0,d.jsx)("b",{children:b("agent.permStale.title")})," ",b("agent.permStale.body",{a1:(0,q.Ck)(v.effective.permission)})]}),(0,d.jsx)(Q,{agent:v}),(0,d.jsx)(E,{agent:v,session:K}),(0,d.jsx)(t.ry,{agent:v,sessionOverride:K})]}),"changes"===P&&(0,d.jsx)(bk,{agent:v,git:T})]}),F&&(0,d.jsx)(O._s,{title:v.name,subtitle:`${b(`role.${v.role}`)} \xb7 ${q.xq[v.provider].label}`,onClose:_,footer:"config"===C&&X?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"muted small grow",children:[$?b("agent.unsavedChanges"):b("agent.allSaved"),$&&"running"===v.status?` ${b("agent.appliesNextTurn")}`:""]}),W.actions({size:"sm"})]}):void 0,children:(0,d.jsxs)("div",{className:"agent-config",children:[(0,d.jsx)(O.tU,{idPrefix:"cfg",label:b("fa.cfg.tabs"),value:C,onChange:a=>V(!0,a),tabs:[{id:"config",label:b("agent.tab.config")},{id:"notebook",label:b("agent.tab.notebook")},{id:"sessions",label:b("nav.sessions")}]}),(0,d.jsx)(O.Kp,{id:"config",value:C,idPrefix:"cfg",children:X&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)("div",{className:"pane",children:(0,d.jsx)(bm.SU,{draft:X,onChange:Y,errors:Z,selfId:a})})})}),(0,d.jsx)(O.Kp,{id:"notebook",value:C,idPrefix:"cfg",children:(0,d.jsx)(bs,{agent:v})}),(0,d.jsx)(O.Kp,{id:"sessions",value:C,idPrefix:"cfg",children:(0,d.jsxs)("div",{className:"pane",children:[(0,d.jsx)("p",{className:"hint m0",children:b("agent.sessions.intro",{path:(0,q._1)(v.effective.cwd)})}),(0,d.jsx)("div",{className:"eyebrow",children:b("agent.sessions.conversations")}),0===ab.length?(0,d.jsx)(O.pp,{compact:!0,icon:(0,d.jsx)(m.A,{size:22}),title:b("agent.sessions.empty")}):ab.map(a=>{let c=a.session_id===v.session_id;return(0,d.jsxs)("div",{className:`card card-pad col fa-sess ${K===a.session_id?"on":""}`,children:[(0,d.jsxs)("div",{className:"row gap-xs",children:[(0,d.jsx)("span",{className:"mono grow sess-id",children:a.session_id}),(0,d.jsx)(R.WQ,{compact:!0,text:a.session_id,label:b("agent.sessions.copyId")}),c&&(0,d.jsx)("span",{className:"chip honey",children:b("sessions.current")})]}),(0,d.jsx)("span",{className:"muted small",children:b("agent.sessions.started",{started:(0,q.KN)(a.first_seen),last:(0,q.KN)(a.last_seen)})}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)("button",{className:"btn sm",onClick:()=>{L(c?void 0:a.session_id),V(!1)},children:K===a.session_id?b("agent.sessions.viewing"):b("agent.sessions.read")}),!c&&(0,d.jsx)("button",{className:"btn sm",onClick:()=>aa(a.session_id).then(()=>V(!1)).catch(a=>x(a instanceof Error?a.message:String(a),"err")),children:b("agent.sessions.resume")})]})]},a.session_id)}),ac.length>0&&(0,d.jsx)("div",{className:"eyebrow mt-s",children:b("agent.sessions.delegated")}),ac.map(a=>(0,d.jsxs)("div",{className:`card card-pad col fa-sess ${K===a.session_id?"on":""}`,children:[(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)(n.A,{size:14,className:"muted"}),(0,d.jsx)("b",{className:"grow",children:b("agent.sessions.from",{name:a.from_name??b("chat.anOrchestrator")})}),(0,d.jsx)("span",{className:"muted small",children:(0,q.KN)(a.last_seen)})]}),a.task&&(0,d.jsx)("span",{className:"small fa-clamp3",children:a.task}),(0,d.jsxs)("div",{className:"row gap-xs",children:[(0,d.jsx)("span",{className:"mono muted small grow sess-id",children:a.session_id}),(0,d.jsx)(R.WQ,{compact:!0,text:a.session_id,label:b("agent.sessions.copyId")})]}),(0,d.jsx)("div",{className:"row gap-s",children:(0,d.jsx)("button",{className:"btn sm",onClick:()=>{L(K===a.session_id?void 0:a.session_id),V(!1)},children:K===a.session_id?b("agent.sessions.viewing"):b("agent.sessions.read")})})]},a.session_id))]})})]})}),W.deleteModal,W.cloneModal,G&&(0,d.jsx)(O.TM,{danger:!0,title:b("fa.unsaved.title"),body:b("fa.unsaved.body"),confirmLabel:b("fa.unsaved.discard"),cancelLabel:b("fa.unsaved.keep"),onClose:()=>H(!1),onConfirm:()=>{W.discard(),V(!1)}}),"new"===M&&(0,d.jsx)(O.TM,{title:b("agent.newConvTitle"),body:b("agent.newConvBody"),confirmLabel:b("agent.newConvStart"),onClose:()=>N(null),onConfirm:async()=>{await p.FH.post(`/agents/${a}/new-session`),await u(["agents"]),x(b("agent.newConvStarted"))}})]})}},33873:a=>{"use strict";a.exports=require("path")},34105:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>F.a,__next_app__:()=>L,handler:()=>N,pages:()=>K,routeModule:()=>M,tree:()=>J});var d=c(62009),e=c(51640),f=c(52679),g=c(69985),h=c(91790),i=c(81200),j=c(54530),k=c(35977),l=c(234),m=c(43472),n=c(12698),o=c(28976),p=c(54084),q=c(16307),r=c(53063),s=c(72428),t=c(261),u=c(48291),v=c(56032),w=c(26713),x=c(83370),y=c(10143),z=c(27155),A=c(77620),B=c(13428),C=c(50164),D=c(86439),E=c(2972),F=c.n(E),G=c(94672),H=c(18313),I={};for(let a in G)0>["default","tree","pages","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>G[a]);c.d(b,I);let J={children:["",{children:["agents",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,27769)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx"]}]},{}]},{layout:[()=>Promise.resolve().then(c.bind(c,71900)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/layout.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,84507))).default(a),async a=>(await Promise.resolve().then(c.bind(c,23575))).default(a)],apple:[async a=>(await Promise.resolve().then(c.bind(c,54287))).default(a)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,20987)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,2972,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,96298,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,60075,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,79678,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,84507))).default(a),async a=>(await Promise.resolve().then(c.bind(c,23575))).default(a)],apple:[async a=>(await Promise.resolve().then(c.bind(c,54287))).default(a)],openGraph:[],twitter:[],manifest:void 0}}]}.children,K=["/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx"],L={require:c,loadChunk:()=>Promise.resolve()},M=new e.AppPageRouteModule({definition:{kind:f.RouteKind.APP_PAGE,page:"/agents/[id]/page",pathname:"/agents/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next",relativeProjectDir:""});async function N(a,b,e){var E;let I="/agents/[id]/page";"/index"===I&&(I="/");let O=(0,i.getRequestMeta)(a,"postponed"),P=(0,i.getRequestMeta)(a,"minimalMode"),Q=await M.prepare(a,b,{srcPage:I,multiZoneDraftMode:!1});if(!Q)return b.statusCode=400,b.end("Bad Request"),null==e.waitUntil||e.waitUntil.call(e,Promise.resolve()),null;let{buildId:R,query:S,params:T,parsedUrl:U,pageIsDynamic:V,buildManifest:W,nextFontManifest:X,reactLoadableManifest:Y,serverActionsManifest:Z,clientReferenceManifest:$,subresourceIntegrityManifest:_,prerenderManifest:aa,isDraftMode:ab,resolvedPathname:ac,revalidateOnlyGenerated:ad,routerServerContext:ae,nextConfig:af,interceptionRoutePatterns:ag}=Q,ah=U.pathname||"/",ai=(0,t.normalizeAppPath)(I),{isOnDemandRevalidate:aj}=Q,ak=M.match(ah,aa),al=!!aa.routes[ac]&&(M.isDev||(0,d.isRouteCacheOwner)(ac,M.cacheOwner,aa.routes[ac])),am=!!(ak||al||aa.routes[ai]),an=a.headers["user-agent"]||"",ao=(0,w.getBotType)(an),ap=(0,r.isHtmlBotRequest)(a),aq=(0,i.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[v.NEXT_ROUTER_PREFETCH_HEADER],ar=(0,i.getRequestMeta)(a,"isRSCRequest")??(0,o.f)(a.headers[v.RSC_HEADER]),as=(0,u.getIsPossibleServerAction)(a),at=(0,n.checkIsAppPPREnabled)(af.experimental.ppr)&&(null==(E=aa.routes[ai]??aa.dynamicRoutes[ai])?void 0:E.renderingMode)==="PARTIALLY_STATIC",au=!1,av=!1,aw=at?O:void 0,ax=at&&ar&&!aq,ay=(0,i.getRequestMeta)(a,"segmentPrefetchRSCRequest"),az=!an||(0,r.shouldServeStreamingMetadata)(an,af.htmlLimitedBots);ap&&at&&(am=!1,az=!1);let aA=!0===M.isDev||!am||"string"==typeof O||ax,aB=ap&&at,aC=null;ab||!am||aA||as||aw||ax||(aC=ac);let aD=aC;!aD&&M.isDev&&(aD=ac),M.isDev||ab||!am||!ar||ax||(0,l.d)(a.headers);let aE={...G,tree:J,pages:K,GlobalError:F(),handler:N,routeModule:M,__next_app__:L};Z&&$&&(0,q.setReferenceManifestsSingleton)({page:I,clientReferenceManifest:$,serverActionsManifest:Z,serverModuleMap:(0,s.createServerModuleMap)({serverActionsManifest:Z})});let aF=a.method||"GET",aG=(0,h.getTracer)(),aH=aG.getActiveScopeSpan();try{let d=M.getVaryHeader(ac,ag);b.setHeader("Vary",d);let g=async(c,d)=>{let e=new m.NodeNextRequest(a),f=new m.NodeNextResponse(b);return M.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=aG.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==j.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${aF} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aF} ${a.url}`)})},l=async({span:d,postponed:f,fallbackRouteParams:h})=>{let j={query:S,params:T,page:ai,sharedContext:{buildId:R},serverComponentsHmrCache:(0,i.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:h,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aE,Component:(0,k.T)(aE),params:T,routeModule:M,page:I,postponed:f,shouldWaitOnAllReady:aB,serveStreamingMetadata:az,supportsDynamicResponse:"string"==typeof f||aA,buildManifest:W,nextFontManifest:X,reactLoadableManifest:Y,subresourceIntegrityManifest:_,serverActionsManifest:Z,clientReferenceManifest:$,setIsrStatus:null==ae?void 0:ae.setIsrStatus,dir:c(33873).join(process.cwd(),M.relativeProjectDir),isDraftMode:ab,isRevalidate:am&&!f&&!ax,botType:ao,isOnDemandRevalidate:aj,isPossibleServerAction:as,assetPrefix:af.assetPrefix,nextConfigOutput:af.output,crossOrigin:af.crossOrigin,trailingSlash:af.trailingSlash,previewProps:aa.preview,deploymentId:af.deploymentId,enableTainting:af.experimental.taint,htmlLimitedBots:af.htmlLimitedBots,devtoolSegmentExplorer:af.experimental.devtoolSegmentExplorer,reactMaxHeadersLength:af.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:(0,i.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:af.experimental.cacheLife,basePath:af.basePath,serverActions:af.experimental.serverActions,...au?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isRevalidate:!0,isDebugDynamicAccesses:au}:{},experimental:{isRoutePPREnabled:at,expireTime:af.expireTime,staleTimes:af.experimental.staleTimes,cacheComponents:!!af.experimental.cacheComponents,clientSegmentCache:!!af.experimental.clientSegmentCache,clientParamParsing:!!af.experimental.clientParamParsing,dynamicOnHover:!!af.experimental.dynamicOnHover,inlineCss:!!af.experimental.inlineCss,authInterrupts:!!af.experimental.authInterrupts,clientTraceMetadata:af.experimental.clientTraceMetadata||[]},waitUntil:e.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d)=>M.onRequestError(a,b,d,ae),err:(0,i.getRequestMeta)(a,"invokeError"),dev:M.isDev}},l=await g(d,j),{metadata:m}=l,{cacheControl:n,headers:o={},fetchTags:p}=m;if(p&&(o[A.NEXT_CACHE_TAGS_HEADER]=p),a.fetchMetrics=m.fetchMetrics,am&&(null==n?void 0:n.revalidate)===0&&!M.isDev&&!at){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ac}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
4
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:x.CachedRouteKind.APP_PAGE,html:l,headers:o,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},n=async({hasResolved:c,previousCacheEntry:d,isRevalidating:g,span:h})=>{let j,k=!1===M.isDev,m=c||b.writableEnded;if(aj&&ad&&!d&&!P)return(null==ae?void 0:ae.render404)?await ae.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ak&&(j=(0,y.parseFallbackField)(ak.fallback)),j===y.FallbackMode.PRERENDER&&(0,w.isBot)(an)&&(!at||ap)&&(j=y.FallbackMode.BLOCKING_STATIC_RENDER),(null==d?void 0:d.isStale)===-1&&(aj=!0),aj&&(j!==y.FallbackMode.NOT_FOUND||d)&&(j=y.FallbackMode.BLOCKING_STATIC_RENDER),!P&&j!==y.FallbackMode.BLOCKING_STATIC_RENDER&&aD&&!m&&!ab&&V&&(k||!al)){let b;if((k||ak)&&j===y.FallbackMode.NOT_FOUND)throw new D.NoFallbackError;if(at&&!ar){let c="string"==typeof(null==ak?void 0:ak.fallback)?ak.fallback:k?ai:null;if(b=await M.handleResponse({cacheKey:c,req:a,nextConfig:af,routeKind:f.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:aa,isRoutePPREnabled:at,responseGenerator:async()=>l({span:h,postponed:void 0,fallbackRouteParams:k||av?(0,p.u)(ai):null}),waitUntil:e.waitUntil}),null===b)return null;if(b)return delete b.cacheControl,b}}let n=aj||g||!aw?void 0:aw;if(au&&void 0!==n)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:x.CachedRouteKind.PAGES,html:z.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let o=V&&at&&((0,i.getRequestMeta)(a,"renderFallbackShell")||av)?(0,p.u)(ah):null;return l({span:h,postponed:n,fallbackRouteParams:o})},o=async c=>{var d,g,h,j,k;let m,o=await M.handleResponse({cacheKey:aC,responseGenerator:a=>n({span:c,...a}),routeKind:f.RouteKind.APP_PAGE,isOnDemandRevalidate:aj,isRoutePPREnabled:at,req:a,nextConfig:af,prerenderManifest:aa,waitUntil:e.waitUntil});if(ab&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),M.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!o){if(aC)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(d=o.value)?void 0:d.kind)!==x.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(h=o.value)?void 0:h.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let p="string"==typeof o.value.postponed;am&&!ax&&(!p||aq)&&(P||b.setHeader("x-nextjs-cache",aj?"REVALIDATED":o.isMiss?"MISS":o.isStale?"STALE":"HIT"),b.setHeader(v.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=o;if(aw)m={revalidate:0,expire:void 0};else if(P&&ar&&!aq&&at)m={revalidate:0,expire:void 0};else if(!M.isDev)if(ab)m={revalidate:0,expire:void 0};else if(am){if(o.cacheControl)if("number"==typeof o.cacheControl.revalidate){if(o.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${o.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});m={revalidate:o.cacheControl.revalidate,expire:(null==(j=o.cacheControl)?void 0:j.expire)??af.expireTime}}else m={revalidate:A.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(m={revalidate:0,expire:void 0});if(o.cacheControl=m,"string"==typeof ay&&(null==q?void 0:q.kind)===x.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(v.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[A.NEXT_CACHE_TAGS_HEADER];P&&am&&c&&"string"==typeof c&&b.setHeader(A.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ay);return void 0!==d?(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.fromStatic(d,v.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl}):(b.statusCode=204,(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.EMPTY,cacheControl:o.cacheControl}))}let r=(0,i.getRequestMeta)(a,"onCacheEntry");if(r&&await r({...o,value:{...o.value,kind:"PAGE"}},{url:(0,i.getRequestMeta)(a,"initURL")}))return null;if(p&&aw)throw Object.defineProperty(Error("Invariant: postponed state should not be present on a resume request"),"__NEXT_ERROR_CODE",{value:"E396",enumerable:!1,configurable:!0});if(q.headers){let a={...q.headers};for(let[c,d]of(P&&am||delete a[A.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let s=null==(g=q.headers)?void 0:g[A.NEXT_CACHE_TAGS_HEADER];if(P&&am&&s&&"string"==typeof s&&b.setHeader(A.NEXT_CACHE_TAGS_HEADER,s),!q.status||ar&&at||(b.statusCode=q.status),!P&&q.status&&H.RedirectStatusCode[q.status]&&ar&&(b.statusCode=200),p&&b.setHeader(v.NEXT_DID_POSTPONE_HEADER,"1"),ar&&!ab){if(void 0===q.rscData){if(q.postponed)throw Object.defineProperty(Error("Invariant: Expected postponed to be undefined"),"__NEXT_ERROR_CODE",{value:"E372",enumerable:!1,configurable:!0});return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:q.html,cacheControl:ax?{revalidate:0,expire:void 0}:o.cacheControl})}return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.fromStatic(q.rscData,v.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl})}let t=q.html;if(!p||P||ar)return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:o.cacheControl});if(au)return t.push(new ReadableStream({start(a){a.enqueue(B.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}});let u=new TransformStream;return t.push(u.readable),l({span:c,postponed:q.postponed,fallbackRouteParams:null}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==x.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(u.writable)}).catch(a=>{u.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}})};if(!aH)return await aG.withPropagatedContext(a.headers,()=>aG.trace(j.BaseServerSpan.handleRequest,{spanName:`${aF} ${a.url}`,kind:h.SpanKind.SERVER,attributes:{"http.method":aF,"http.target":a.url}},o));await o(aH)}catch(b){throw b instanceof D.NoFallbackError||await M.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"render",revalidateReason:(0,g.c)({isRevalidate:am,isOnDemandRevalidate:aj})},ae),b}}},38550:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(51537).A)("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]])},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},55511:a=>{"use strict";a.exports=require("crypto")},61222:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(51537).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},62172:(a,b,c)=>{"use strict";c.d(b,{y:()=>k});var d=c(55322),e=c(17027),f=c(35842),g=c(7371),h=c(60570),i=c(93884),j=c(81963);function k({agent:a,onClose:b,onCloned:c}){let{t:k}=(0,i.s9)(),{agents:l,colonies:m}=(0,h.q5)(),{refresh:n}=(0,h.zd)(),o=(0,j.dj)(),[p,q]=(0,e.useState)(()=>((a,b)=>{for(let c=2;;c++){let d=`${a} ${c}`;if(!b.has(d.toLowerCase()))return d}})(a.name,new Set(l.map(a=>a.name.toLowerCase())))),[r,s]=(0,e.useState)(a.colony_id??""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(""),x=l.some(a=>a.name.toLowerCase()===p.trim().toLowerCase()),y=async()=>{u(!0),w("");try{let d=await g.FH.post(`/agents/${a.id}/clone`,{name:p.trim(),colony_id:r||null});await n(["agents","colonies"]),o(k("agent.cloned",{name:d.name})),c?.(d),b()}catch(a){w(a instanceof Error?a.message:String(a)),u(!1)}};return(0,d.jsxs)(j.aF,{title:k("agent.clone.title",{name:a.name}),onClose:b,children:[(0,d.jsx)(j.D0,{label:k("agent.clone.name"),error:x?k("agent.clone.taken"):v,children:(0,d.jsx)("input",{className:"input",value:p,autoFocus:!0,onChange:a=>q(a.target.value),onKeyDown:a=>{"Enter"===a.key&&p.trim()&&!x&&!t&&y()}})}),(0,d.jsx)(j.D0,{label:k("form.colony"),children:(0,d.jsxs)("select",{className:"select",value:r,onChange:a=>s(a.target.value),children:[(0,d.jsx)("option",{value:"",children:k("common.noColony")}),m.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))]})}),(0,d.jsxs)("ul",{className:"muted small clone-facts",children:[(0,d.jsx)("li",{children:k("agent.clone.parallel",{name:a.name})}),(0,d.jsx)("li",{children:k("agent.clone.config")}),(0,d.jsx)("li",{children:k("agent.clone.notebook",{name:a.name})}),(0,d.jsx)("li",{children:k("agent.clone.notBring",{name:a.name})})]}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:b,children:k("common.cancel")}),(0,d.jsxs)("button",{className:"btn primary",disabled:!p.trim()||x||t,onClick:()=>void y(),children:[(0,d.jsx)(f.A,{size:14}),t?k("agent.clone.working"):k("agent.clone")]})]})]})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66390:(a,b,c)=>{"use strict";c.d(b,{G:()=>j});var d=c(55322),e=c(17027),f=c(81963),g=c(60570),h=c(7371),i=c(93884);function j({agent:a,onClose:b,onDeleted:c}){let{t:j}=(0,i.s9)(),{refresh:k}=(0,g.zd)(),l=(0,f.dj)(),[m,n]=(0,e.useState)([]);return(0,d.jsx)(f.TM,{title:j("agent.deleteTitle",{name:a.name}),body:m.length?j("agent.deleteBody.shared",{names:m.join(", ")}):j("agent.deleteBody"),danger:!0,confirmLabel:j("agent.delete"),cancelLabel:j("agent.keep"),onClose:b,onConfirm:async()=>{await h.FH.del(`/agents/${a.id}`),await k(["agents","colonies"]),l(j("agent.deleted")),c?.()}})}},73136:a=>{"use strict";a.exports=require("node:url")},76760:a=>{"use strict";a.exports=require("node:path")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},93304:(a,b,c)=>{Promise.resolve().then(c.bind(c,27769))},93674:(a,b,c)=>{"use strict";c.d(b,{A:()=>p});var d=c(55322),e=c(17027),f=c(34410),g=c(35842),h=c(81963),i=c(15964),j=c(66390),k=c(62172),l=c(60570),m=c(13520),n=c(7371),o=c(93884);function p(a,b={}){let{t:c}=(0,o.s9)(),{agents:q,colonies:r,objects:s,refresh:t}=(0,l.q5)(),u=(0,h.dj)(),v=(0,e.useMemo)(()=>a?s.filter(b=>b.manager_id===a.id).map(a=>a.id).sort():[],[s,a?.id]),w=(0,e.useMemo)(()=>a?JSON.stringify((0,i.TN)(a,v)):"",[a,v]),[x,y]=(0,e.useState)(()=>a?(0,i.TN)(a,v):null),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(!1),F=x&&a?(0,i.tf)(x,q,a.id,r):{},G=!!x&&JSON.stringify(x)!==w;(0,m.h)(G);let H=async()=>{if(x&&a){if(Object.keys(F).length)return void u(c("edit.fixFields"),"err");A(!0);try{let{type_id:d,object_ids:e,...f}=x;await n.FH.patch(`/agents/${a.id}`,f),JSON.stringify([...e].sort())!==JSON.stringify(v)&&await n.FH.put(`/agents/${a.id}/resources`,{object_ids:e}),await t(["agents","colonies","objects"]),u(c("edit.saved",{name:x.name.trim()})),b.onSaved?.()}catch(a){u(a instanceof Error?a.message:c("edit.saveFailed"),"err")}A(!1)}},I=()=>{a&&y((0,i.TN)(a,v))};return{draft:x,setDraft:y,errors:F,dirty:G,saving:z,save:H,discard:I,actions:(a={})=>(0,d.jsxs)("span",{className:"foot-actions push-r",children:[(0,d.jsxs)("span",{className:"row gap-s",children:[(0,d.jsxs)("button",{className:`btn danger ${a.size??""}`,onClick:()=>C(!0),children:[(0,d.jsx)(f.A,{size:a.size?14:15}),c("agent.delete")]}),(0,d.jsx)("button",{className:`btn icon ${a.size??""}`,onClick:()=>E(!0),title:c("agent.clone.hint"),"aria-label":c("agent.clone"),children:(0,d.jsx)(g.A,{size:a.size?14:15})})]}),a.onCancel?(0,d.jsx)("button",{className:`btn ghost ${a.size??""}`,onClick:a.onCancel,children:c("common.cancel")}):(0,d.jsx)("button",{className:`btn ghost ${a.size??""}`,disabled:!G,onClick:I,children:c("common.discard")}),(0,d.jsx)("button",{className:`btn primary ${a.size??""}`,disabled:!G||z,onClick:H,children:z?c("common.saving"):c("common.saveChanges")})]}),deleteModal:B&&a?(0,d.jsx)(j.G,{agent:a,onClose:()=>C(!1),onDeleted:b.onDeleted}):null,cloneModal:D&&a?(0,d.jsx)(k.y,{agent:a,onClose:()=>E(!1),onCloned:b.onCloned}):null}}},93976:(a,b,c)=>{Promise.resolve().then(c.bind(c,33438))}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[691,939,335,593,148,953,143,716,368,111,944,345],()=>b(b.s=34105));module.exports=c})();
1
+ (()=>{var a={};a.id=969,a.ids=[969],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1708:a=>{"use strict";a.exports=require("node:process")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},23124:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(51537).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},27769:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(85972).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx","default")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},34105:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>F.a,__next_app__:()=>L,handler:()=>N,pages:()=>K,routeModule:()=>M,tree:()=>J});var d=c(62009),e=c(51640),f=c(52679),g=c(69985),h=c(91790),i=c(81200),j=c(54530),k=c(35977),l=c(234),m=c(43472),n=c(12698),o=c(28976),p=c(54084),q=c(16307),r=c(53063),s=c(72428),t=c(261),u=c(48291),v=c(56032),w=c(26713),x=c(83370),y=c(10143),z=c(27155),A=c(77620),B=c(13428),C=c(50164),D=c(86439),E=c(2972),F=c.n(E),G=c(94672),H=c(18313),I={};for(let a in G)0>["default","tree","pages","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>G[a]);c.d(b,I);let J={children:["",{children:["agents",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,27769)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx"]}]},{}]},{layout:[()=>Promise.resolve().then(c.bind(c,71900)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/layout.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,84507))).default(a),async a=>(await Promise.resolve().then(c.bind(c,23575))).default(a)],apple:[async a=>(await Promise.resolve().then(c.bind(c,54287))).default(a)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,20987)),"/home/runner/work/hive-am/hive-am/dist/stage/web/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,2972,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,96298,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,60075,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,79678,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,84507))).default(a),async a=>(await Promise.resolve().then(c.bind(c,23575))).default(a)],apple:[async a=>(await Promise.resolve().then(c.bind(c,54287))).default(a)],openGraph:[],twitter:[],manifest:void 0}}]}.children,K=["/home/runner/work/hive-am/hive-am/dist/stage/web/app/agents/[id]/page.tsx"],L={require:c,loadChunk:()=>Promise.resolve()},M=new e.AppPageRouteModule({definition:{kind:f.RouteKind.APP_PAGE,page:"/agents/[id]/page",pathname:"/agents/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next",relativeProjectDir:""});async function N(a,b,e){var E;let I="/agents/[id]/page";"/index"===I&&(I="/");let O=(0,i.getRequestMeta)(a,"postponed"),P=(0,i.getRequestMeta)(a,"minimalMode"),Q=await M.prepare(a,b,{srcPage:I,multiZoneDraftMode:!1});if(!Q)return b.statusCode=400,b.end("Bad Request"),null==e.waitUntil||e.waitUntil.call(e,Promise.resolve()),null;let{buildId:R,query:S,params:T,parsedUrl:U,pageIsDynamic:V,buildManifest:W,nextFontManifest:X,reactLoadableManifest:Y,serverActionsManifest:Z,clientReferenceManifest:$,subresourceIntegrityManifest:_,prerenderManifest:aa,isDraftMode:ab,resolvedPathname:ac,revalidateOnlyGenerated:ad,routerServerContext:ae,nextConfig:af,interceptionRoutePatterns:ag}=Q,ah=U.pathname||"/",ai=(0,t.normalizeAppPath)(I),{isOnDemandRevalidate:aj}=Q,ak=M.match(ah,aa),al=!!aa.routes[ac]&&(M.isDev||(0,d.isRouteCacheOwner)(ac,M.cacheOwner,aa.routes[ac])),am=!!(ak||al||aa.routes[ai]),an=a.headers["user-agent"]||"",ao=(0,w.getBotType)(an),ap=(0,r.isHtmlBotRequest)(a),aq=(0,i.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[v.NEXT_ROUTER_PREFETCH_HEADER],ar=(0,i.getRequestMeta)(a,"isRSCRequest")??(0,o.f)(a.headers[v.RSC_HEADER]),as=(0,u.getIsPossibleServerAction)(a),at=(0,n.checkIsAppPPREnabled)(af.experimental.ppr)&&(null==(E=aa.routes[ai]??aa.dynamicRoutes[ai])?void 0:E.renderingMode)==="PARTIALLY_STATIC",au=!1,av=!1,aw=at?O:void 0,ax=at&&ar&&!aq,ay=(0,i.getRequestMeta)(a,"segmentPrefetchRSCRequest"),az=!an||(0,r.shouldServeStreamingMetadata)(an,af.htmlLimitedBots);ap&&at&&(am=!1,az=!1);let aA=!0===M.isDev||!am||"string"==typeof O||ax,aB=ap&&at,aC=null;ab||!am||aA||as||aw||ax||(aC=ac);let aD=aC;!aD&&M.isDev&&(aD=ac),M.isDev||ab||!am||!ar||ax||(0,l.d)(a.headers);let aE={...G,tree:J,pages:K,GlobalError:F(),handler:N,routeModule:M,__next_app__:L};Z&&$&&(0,q.setReferenceManifestsSingleton)({page:I,clientReferenceManifest:$,serverActionsManifest:Z,serverModuleMap:(0,s.createServerModuleMap)({serverActionsManifest:Z})});let aF=a.method||"GET",aG=(0,h.getTracer)(),aH=aG.getActiveScopeSpan();try{let d=M.getVaryHeader(ac,ag);b.setHeader("Vary",d);let g=async(c,d)=>{let e=new m.NodeNextRequest(a),f=new m.NodeNextResponse(b);return M.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=aG.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==j.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${aF} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aF} ${a.url}`)})},l=async({span:d,postponed:f,fallbackRouteParams:h})=>{let j={query:S,params:T,page:ai,sharedContext:{buildId:R},serverComponentsHmrCache:(0,i.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:h,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aE,Component:(0,k.T)(aE),params:T,routeModule:M,page:I,postponed:f,shouldWaitOnAllReady:aB,serveStreamingMetadata:az,supportsDynamicResponse:"string"==typeof f||aA,buildManifest:W,nextFontManifest:X,reactLoadableManifest:Y,subresourceIntegrityManifest:_,serverActionsManifest:Z,clientReferenceManifest:$,setIsrStatus:null==ae?void 0:ae.setIsrStatus,dir:c(33873).join(process.cwd(),M.relativeProjectDir),isDraftMode:ab,isRevalidate:am&&!f&&!ax,botType:ao,isOnDemandRevalidate:aj,isPossibleServerAction:as,assetPrefix:af.assetPrefix,nextConfigOutput:af.output,crossOrigin:af.crossOrigin,trailingSlash:af.trailingSlash,previewProps:aa.preview,deploymentId:af.deploymentId,enableTainting:af.experimental.taint,htmlLimitedBots:af.htmlLimitedBots,devtoolSegmentExplorer:af.experimental.devtoolSegmentExplorer,reactMaxHeadersLength:af.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:(0,i.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:af.experimental.cacheLife,basePath:af.basePath,serverActions:af.experimental.serverActions,...au?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isRevalidate:!0,isDebugDynamicAccesses:au}:{},experimental:{isRoutePPREnabled:at,expireTime:af.expireTime,staleTimes:af.experimental.staleTimes,cacheComponents:!!af.experimental.cacheComponents,clientSegmentCache:!!af.experimental.clientSegmentCache,clientParamParsing:!!af.experimental.clientParamParsing,dynamicOnHover:!!af.experimental.dynamicOnHover,inlineCss:!!af.experimental.inlineCss,authInterrupts:!!af.experimental.authInterrupts,clientTraceMetadata:af.experimental.clientTraceMetadata||[]},waitUntil:e.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d)=>M.onRequestError(a,b,d,ae),err:(0,i.getRequestMeta)(a,"invokeError"),dev:M.isDev}},l=await g(d,j),{metadata:m}=l,{cacheControl:n,headers:o={},fetchTags:p}=m;if(p&&(o[A.NEXT_CACHE_TAGS_HEADER]=p),a.fetchMetrics=m.fetchMetrics,am&&(null==n?void 0:n.revalidate)===0&&!M.isDev&&!at){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ac}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:x.CachedRouteKind.APP_PAGE,html:l,headers:o,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},n=async({hasResolved:c,previousCacheEntry:d,isRevalidating:g,span:h})=>{let j,k=!1===M.isDev,m=c||b.writableEnded;if(aj&&ad&&!d&&!P)return(null==ae?void 0:ae.render404)?await ae.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ak&&(j=(0,y.parseFallbackField)(ak.fallback)),j===y.FallbackMode.PRERENDER&&(0,w.isBot)(an)&&(!at||ap)&&(j=y.FallbackMode.BLOCKING_STATIC_RENDER),(null==d?void 0:d.isStale)===-1&&(aj=!0),aj&&(j!==y.FallbackMode.NOT_FOUND||d)&&(j=y.FallbackMode.BLOCKING_STATIC_RENDER),!P&&j!==y.FallbackMode.BLOCKING_STATIC_RENDER&&aD&&!m&&!ab&&V&&(k||!al)){let b;if((k||ak)&&j===y.FallbackMode.NOT_FOUND)throw new D.NoFallbackError;if(at&&!ar){let c="string"==typeof(null==ak?void 0:ak.fallback)?ak.fallback:k?ai:null;if(b=await M.handleResponse({cacheKey:c,req:a,nextConfig:af,routeKind:f.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:aa,isRoutePPREnabled:at,responseGenerator:async()=>l({span:h,postponed:void 0,fallbackRouteParams:k||av?(0,p.u)(ai):null}),waitUntil:e.waitUntil}),null===b)return null;if(b)return delete b.cacheControl,b}}let n=aj||g||!aw?void 0:aw;if(au&&void 0!==n)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:x.CachedRouteKind.PAGES,html:z.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let o=V&&at&&((0,i.getRequestMeta)(a,"renderFallbackShell")||av)?(0,p.u)(ah):null;return l({span:h,postponed:n,fallbackRouteParams:o})},o=async c=>{var d,g,h,j,k;let m,o=await M.handleResponse({cacheKey:aC,responseGenerator:a=>n({span:c,...a}),routeKind:f.RouteKind.APP_PAGE,isOnDemandRevalidate:aj,isRoutePPREnabled:at,req:a,nextConfig:af,prerenderManifest:aa,waitUntil:e.waitUntil});if(ab&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),M.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!o){if(aC)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(d=o.value)?void 0:d.kind)!==x.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(h=o.value)?void 0:h.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let p="string"==typeof o.value.postponed;am&&!ax&&(!p||aq)&&(P||b.setHeader("x-nextjs-cache",aj?"REVALIDATED":o.isMiss?"MISS":o.isStale?"STALE":"HIT"),b.setHeader(v.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=o;if(aw)m={revalidate:0,expire:void 0};else if(P&&ar&&!aq&&at)m={revalidate:0,expire:void 0};else if(!M.isDev)if(ab)m={revalidate:0,expire:void 0};else if(am){if(o.cacheControl)if("number"==typeof o.cacheControl.revalidate){if(o.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${o.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});m={revalidate:o.cacheControl.revalidate,expire:(null==(j=o.cacheControl)?void 0:j.expire)??af.expireTime}}else m={revalidate:A.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(m={revalidate:0,expire:void 0});if(o.cacheControl=m,"string"==typeof ay&&(null==q?void 0:q.kind)===x.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(v.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[A.NEXT_CACHE_TAGS_HEADER];P&&am&&c&&"string"==typeof c&&b.setHeader(A.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ay);return void 0!==d?(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.fromStatic(d,v.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl}):(b.statusCode=204,(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.EMPTY,cacheControl:o.cacheControl}))}let r=(0,i.getRequestMeta)(a,"onCacheEntry");if(r&&await r({...o,value:{...o.value,kind:"PAGE"}},{url:(0,i.getRequestMeta)(a,"initURL")}))return null;if(p&&aw)throw Object.defineProperty(Error("Invariant: postponed state should not be present on a resume request"),"__NEXT_ERROR_CODE",{value:"E396",enumerable:!1,configurable:!0});if(q.headers){let a={...q.headers};for(let[c,d]of(P&&am||delete a[A.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let s=null==(g=q.headers)?void 0:g[A.NEXT_CACHE_TAGS_HEADER];if(P&&am&&s&&"string"==typeof s&&b.setHeader(A.NEXT_CACHE_TAGS_HEADER,s),!q.status||ar&&at||(b.statusCode=q.status),!P&&q.status&&H.RedirectStatusCode[q.status]&&ar&&(b.statusCode=200),p&&b.setHeader(v.NEXT_DID_POSTPONE_HEADER,"1"),ar&&!ab){if(void 0===q.rscData){if(q.postponed)throw Object.defineProperty(Error("Invariant: Expected postponed to be undefined"),"__NEXT_ERROR_CODE",{value:"E372",enumerable:!1,configurable:!0});return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:q.html,cacheControl:ax?{revalidate:0,expire:void 0}:o.cacheControl})}return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:z.default.fromStatic(q.rscData,v.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl})}let t=q.html;if(!p||P||ar)return(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:o.cacheControl});if(au)return t.push(new ReadableStream({start(a){a.enqueue(B.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}});let u=new TransformStream;return t.push(u.readable),l({span:c,postponed:q.postponed,fallbackRouteParams:null}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==x.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(u.writable)}).catch(a=>{u.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,C.sendRenderResult)({req:a,res:b,generateEtags:af.generateEtags,poweredByHeader:af.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}})};if(!aH)return await aG.withPropagatedContext(a.headers,()=>aG.trace(j.BaseServerSpan.handleRequest,{spanName:`${aF} ${a.url}`,kind:h.SpanKind.SERVER,attributes:{"http.method":aF,"http.target":a.url}},o));await o(aH)}catch(b){throw b instanceof D.NoFallbackError||await M.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"render",revalidateReason:(0,g.c)({isRevalidate:am,isOnDemandRevalidate:aj})},ae),b}}},40448:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>bN});var d=c(55322),e=c(97984),f=c(93674),g=c(17027),h=c(91705),i=c.n(h),j=c(66252),k=c(61222),l=c(54514),m=c(38550),n=c(89667),o=c(93351),p=c(60570),q=c(7371),r=c(61162);c(62705);var s=c(73269),t=c(90634),u=c(33944);function v(a){let b=0x811c9dc5;for(let c=0;c<a.length;c++)b^=a.charCodeAt(c),b=Math.imul(b,0x1000193);return(b>>>0).toString(16).padStart(8,"0")}let w=a=>v(`${a.kind}\u0000${a.text}`),x=a=>v(a.map(a=>`${a.kind}\u0000${a.text}`).join("\n"));function y(a){let b=b=>a.map(b).filter(a=>void 0!==a),c=b(a=>a.newNo),d=b(a=>a.oldNo),e=a=>a.length?{from:Math.min(...a),to:Math.max(...a)}:null,f=e(c),g=e(d);return{newFrom:f?.from,newTo:f?.to,oldFrom:g?.from,oldTo:g?.to,removed:!f}}function z(a,b){let c=(a.removed?a.oldFrom:a.newFrom)??0,d=(a.removed?a.oldTo:a.newTo)??c;return a.removed?c===d?b("diffc.range.removedOne",{n:c}):b("diffc.range.removedMany",{from:c,to:d}):c===d?b("diffc.range.one",{n:c}):b("diffc.range.many",{from:c,to:d})}let A=a=>a.newFrom??a.oldFrom??0;function B(a){if(a.length<=1e3)return a;let b=a.slice(0,1e3),c=b.charCodeAt(b.length-1);return c>=55296&&c<=56319?b.slice(0,-1):b}function C(a,b){let c=A(b),d=null,e=1/0;for(let f=0;f<a.hunks.length;f++){let g=a.hunks[f].lines;for(let a=0;a+b.count<=g.length;a++){if(w(g[a])!==b.first)continue;let h=g.slice(a,a+b.count);if(x(h)!==b.sig)continue;let i=Math.abs(A(y(h))-c);i<e&&(d={hunk:f,start:a},e=i)}}return d}let D={add:"+",del:"-",ctx:" "};function E(a,b){let c=[...a].sort((a,b)=>a.path<b.path?-1:a.path>b.path?1:A(a)-A(b)),d=[b("diffc.msg.head",{count:c.length})];return c.some(a=>a.removed)&&d.push(b("diffc.msg.legendLines")),c.some(a=>a.outdated)&&d.push(b("diffc.msg.legendOutdated")),d.push(""),c.forEach((a,c)=>{let e=[a.removed&&b("diffc.msg.removed"),a.outdated&&b("diffc.msg.outdated")].filter(Boolean).join(", "),[f,...g]=a.text.replace(/\r\n?/g,"\n").trim().split("\n");for(let b of(d.push(`${c+1}. ${a.path}:${function(a){let b=a.removed?a.oldFrom:a.newFrom,c=a.removed?a.oldTo:a.newTo;return b===c?`${b}`:`${b}-${c}`}(a)}${e?` (${e})`:""}: ${f}`),g))d.push(b.trim()?" "+b:"");for(let c of(d.push(" "+b("diffc.msg.code")),a.quote))d.push(` > ${D[c.kind]} ${c.text}`.trimEnd());a.count>3&&d.push(` > ${b("diffc.msg.more",{count:a.count-3})}`)}),d.join("\n")}var F=c(51537);let G=(0,F.A)("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var H=c(40413),I=c(33165);let J=(0,F.A)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var K=c(30257),L=c(78574),M=c(18869),N=c(30584),O=c(93884);function P({agent:a,session:b}){let{t:c}=(0,O.s9)(),{finished:e,live:f}=(0,p.o0)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1);e[a.id];let l=f[a.id];if(!h||0===h.turns&&!l)return null;let m=l?.usage,n=(0,N.RP)(h.usage)+(m?(0,N.RP)({input:m.input??0,output:m.output??0,cacheRead:m.cacheRead??0,cacheWrite:m.cacheWrite??0}):0),o=(h.cost??0)+(l?.cost??0),q=(h.usage.credits??0)+(m?.credits??0),r=m?.contextPct??h.contextPct,s=null!==h.cost||l?.cost!==void 0,t=h.usage,u=Math.max(1,t.input+t.output+t.cacheRead+t.cacheWrite),v=Math.max(1,...h.tools.map(a=>a.count)),w=Math.max(1,...h.timeline.map(a=>a.tokens));return(0,d.jsxs)("div",{className:"stats-wrap",children:[(0,d.jsxs)("button",{className:"statsbar",onClick:()=>k(a=>!a),"aria-expanded":j,children:[(0,d.jsxs)("span",{className:"sb",title:`${c("stats.contextTitle")} \xb7 ${(0,N.yj)(h.lastContext)}${h.contextWindow?` / ${(0,N.yj)(h.contextWindow)}`:""}`,children:[(0,d.jsx)(G,{size:14}),(0,d.jsx)("b",{children:null!==r?`${r.toFixed(+(r<10))}%`:(0,N.yj)(h.lastContext)}),c("stats.context")]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(H.A,{size:14}),(0,d.jsx)("b",{children:(0,N.yj)(n)}),c("stats.tokens")]}),q>0&&(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(I.A,{size:14}),(0,d.jsx)("b",{children:q.toFixed(2)}),c("stats.credits")]}),s&&(0,d.jsxs)("span",{className:"sb",title:h.costEstimated?c("stats.costEstimated"):c("stats.costReported"),children:[(0,d.jsx)(I.A,{size:14}),(0,d.jsxs)("b",{children:[h.costEstimated?"≈ ":"",(0,N.F0)(o)]})]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(J,{size:14}),(0,d.jsx)("b",{children:h.turns}),c("stats.turns",{count:h.turns})]}),(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(K.A,{size:14}),(0,d.jsx)("b",{children:h.toolCalls}),c("stats.toolCalls",{count:h.toolCalls}),h.toolErrors>0&&(0,d.jsxs)("em",{className:"tbad",children:[" \xb7 ",c("stats.failed",{count:h.toolErrors})]})]}),h.durationMs>0&&(0,d.jsxs)("span",{className:"sb",children:[(0,d.jsx)(L.A,{size:14}),(0,d.jsx)("b",{children:(0,N.nc)(h.durationMs)}),c("stats.working")]}),(0,d.jsx)(M.A,{size:15,className:`chev2 ${j?"open":""}`})]}),j&&(0,d.jsxs)("div",{className:"statspanel",children:[(0,d.jsxs)("section",{children:[(0,d.jsx)("div",{className:"eyebrow",children:c("stats.mix")}),(0,d.jsxs)("div",{className:"mixbar",role:"img","aria-label":c("stats.mix"),children:[(0,d.jsx)("i",{className:"fa-c-cr",style:{width:`${t.cacheRead/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-cw",style:{width:`${t.cacheWrite/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-in",style:{width:`${t.input/u*100}%`}}),(0,d.jsx)("i",{className:"fa-c-out",style:{width:`${t.output/u*100}%`}})]}),(0,d.jsxs)("dl",{className:"legend",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-cr"}),(0,d.jsx)("dt",{children:c("stats.cacheRead")}),(0,d.jsx)("dd",{children:(0,N.yj)(t.cacheRead)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-cw"}),(0,d.jsx)("dt",{children:c("stats.cacheWrite")}),(0,d.jsx)("dd",{children:(0,N.yj)(t.cacheWrite)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-in"}),(0,d.jsx)("dt",{children:c("stats.input")}),(0,d.jsx)("dd",{children:(0,N.yj)(t.input)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("i",{className:"fa-c-out"}),(0,d.jsx)("dt",{children:c("stats.output")}),(0,d.jsxs)("dd",{children:[(0,N.yj)(t.output),t.reasoning>0&&(0,d.jsxs)("span",{className:"muted",children:[" (",c("stats.thinking",{tokens:(0,N.yj)(t.reasoning)}),")"]})]})]})]}),h.models.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"eyebrow mt-m",children:c("stats.models")}),h.models.map(a=>(0,d.jsxs)("div",{className:"row small between",children:[(0,d.jsx)("span",{className:"mono",children:a.model}),(0,d.jsx)("span",{className:"muted",children:c("stats.modelLine",{count:a.messages,out:(0,N.yj)(a.output)})})]},a.model))]})]}),(0,d.jsxs)("section",{children:[(0,d.jsxs)("div",{className:"eyebrow",children:[c("stats.toolsUsed")," ",h.toolTimeMs>0&&(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",c("stats.totalTime",{time:(0,N.nc)(h.toolTimeMs)})]})]}),0===h.tools.length?(0,d.jsx)("p",{className:"muted small m0 mt-s",children:c("stats.noTools")}):h.tools.slice(0,9).map(a=>(0,d.jsxs)("div",{className:"toolrow",title:c("stats.toolTitle",{count:a.count,time:(0,N.nc)(a.totalMs)}),children:[(0,d.jsx)("span",{className:"mono tn",children:a.name.replace(/^mcp__/,"").replace("__"," \xb7 ")}),(0,d.jsx)("span",{className:"tbar",children:(0,d.jsx)("i",{style:{width:`${a.count/v*100}%`}})}),(0,d.jsxs)("span",{className:"tc",children:[a.count,a.errors>0&&(0,d.jsxs)("em",{className:"tbad",children:[" (",a.errors,"✗)"]})]}),(0,d.jsx)("span",{className:"td muted",children:a.totalMs?(0,N.nc)(a.totalMs/a.count):""})]},a.name))]}),(0,d.jsxs)("section",{className:"fa-span",children:[(0,d.jsx)("div",{className:"eyebrow",children:c("stats.perTurn")}),(0,d.jsx)("div",{className:"tbars",role:"list",children:h.timeline.slice(-40).map((a,b)=>(0,d.jsx)("div",{className:"sbar",role:"listitem",title:`${a.prompt||c("stats.promptFallback")}
3
+ ${c("stats.turnLine",{tokens:(0,N.yj)(a.tokens),tools:a.tools,time:(0,N.nc)(a.durationMs)})}${null!==a.cost?` \xb7 ${(0,N.F0)(a.cost)}`:""}`,children:(0,d.jsx)("i",{style:{height:`${Math.max(4,a.tokens/w*100)}%`}})},b))})]})]})]})}var Q=c(87456),R=c(58437),S=c(84300),T=c(32309),U=c(37811),V=c(96489),W=c(36368),X=c(93717),Y=c(70226),Z=c(95361);let $=["error","starting","running","ready","stopped","unknown"];function _({agent:a}){let{t:b}=(0,O.s9)(),{objects:c}=(0,p.o0)(),e=(0,Z.dj)(),[f,h]=(0,s.ud)("hive-am.chat.resources",!1),[j,k]=(0,s.ud)("hive-am.chat.resources.scope","mine"),[l,m]=(0,g.useState)(null);if(0===c.length)return null;let n=c.filter(b=>b.manager_id===a.id||(b.colony_id??null)===(a.colony_id??null)),o="all"===j||0===n.length,r=o?c:n,t=a=>r.filter(b=>b.state.status===a).length,u=async(a,c)=>{m(`${a.id}:${c}`);try{await q.FH.post(`/objects/${a.id}/action`,{action:c})}catch(a){e(`${b("obj.act.failed",{action:b(`obj.act.${c}`)})}: ${a instanceof Error?a.message:""}`,"err")}finally{m(null)}};return(0,d.jsxs)("div",{className:"cres",children:[(0,d.jsxs)("button",{type:"button",className:"cres-head","aria-expanded":f,onClick:()=>h(!f),children:[(0,d.jsx)(Q.A,{size:15,"aria-hidden":!0}),(0,d.jsx)("b",{children:b("cres.title")}),(0,d.jsx)("span",{className:"cres-sum",children:$.filter(a=>t(a)>0).map(a=>(0,d.jsxs)("span",{className:`cres-n ${X.Wy[a]}`,children:[(0,d.jsx)(W.md,{status:a}),t(a)," ",(0,d.jsx)("em",{children:b(`cres.n.${a}`)})]},a))}),(0,d.jsx)(M.A,{size:15,className:`chev2 ${f?"open":""}`,"aria-hidden":!0})]}),f&&(0,d.jsxs)("div",{className:"cres-body",children:[n.length>0&&n.length<c.length&&(0,d.jsxs)("div",{className:"seg cres-scope",role:"group","aria-label":b("cres.scope"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":!o,onClick:()=>k("mine"),children:b("cres.mine",{a1:String(n.length)})}),(0,d.jsx)("button",{type:"button","aria-pressed":o,onClick:()=>k("all"),children:b("cres.all",{a1:String(c.length)})})]}),0===n.length&&(0,d.jsx)("p",{className:"muted small cres-note",children:b("cres.none")}),(0,d.jsx)("ul",{className:"cres-grid",children:r.map(a=>{let c=X.Nd[a.kind].icon,e=a.state.status,f="running"===e||"starting"===e,g=Y.no.includes(a.kind),h=l?.startsWith(`${a.id}:`)??!1,j=(0,X.HS)(b,a.state.detail);return(0,d.jsxs)("li",{className:`cres-card ${X.Wy[e]}`,children:[(0,d.jsx)("span",{className:"cres-ico",style:{"--c":X.Nd[a.kind].color},children:(0,d.jsx)(c,{size:16,"aria-hidden":!0})}),(0,d.jsxs)("div",{className:"cres-info",children:[(0,d.jsx)(i(),{className:"cres-name",href:`/resources/${a.id}`,title:b("obj.open"),children:a.name}),(0,d.jsxs)("span",{className:`cres-st ${X.Wy[e]}`,title:j||void 0,children:[(0,d.jsx)(W.md,{status:e}),b(`obj.status.${e}`),j&&"error"===e?(0,d.jsx)("em",{children:j}):null]})]}),(0,d.jsxs)("div",{className:"cres-act",children:[h&&(0,d.jsx)(R.A,{size:14,className:"spin muted","aria-hidden":!0}),g&&(f?(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"stop"),"aria-label":b("obj.act.stop"),title:b("obj.act.stop"),children:(0,d.jsx)(S.A,{size:14})}):(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"start"),"aria-label":b("obj.act.start"),title:b("obj.act.start"),children:(0,d.jsx)(T.A,{size:14})})),g&&(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!l,onClick:()=>void u(a,"restart"),"aria-label":b("obj.act.restart"),title:b("obj.act.restart"),children:(0,d.jsx)(U.A,{size:14})}),(0,d.jsx)(i(),{className:"btn ghost icon sm",href:`/resources/${a.id}`,"aria-label":b("obj.open"),title:b("obj.open"),children:(0,d.jsx)(V.A,{size:14})})]})]},a.id)})})]})]})}var aa=c(2335),ab=c(4111),ac=c(77671);let ad=(0,F.A)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);var ae=c(29083);let af=(0,F.A)("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);var ag=c(16487),ah=c(19993);let ai=(0,F.A)("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),aj=(0,F.A)("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);function ak(a,b,c=[],d={}){let e=new Map(b.map(a=>[a.path,a])),f=new Set(a);for(let a of b)f.add(a.path);let g={name:"",path:"",type:"dir",children:[],changed:0,additions:0,deletions:0},h=new Map([["",g]]),i=a=>{let b=h.get(a);if(b)return b;let c=a.lastIndexOf("/"),d=i(c<0?"":a.slice(0,c)),e={name:a.slice(c+1),path:a,type:"dir",children:[],changed:0,additions:0,deletions:0};return d.children.push(e),h.set(a,e),e};for(let a of f){let b=a.lastIndexOf("/");i(b<0?"":a.slice(0,b)).children.push({name:a.slice(b+1),path:a,type:"file",children:[],change:e.get(a),changed:+!!e.has(a),additions:e.get(a)?.additions??0,deletions:e.get(a)?.deletions??0})}let j=(a,b,c)=>{if(a.children.some(a=>a.path===b))return;let e={name:b.slice(b.lastIndexOf("/")+1),path:b,type:c?"dir":"file",children:[],ignored:!0,lazy:c&&!(b in d),changed:0,additions:0,deletions:0};if(a.children.push(e),c&&h.set(b,e),c)for(let a of d[b]??[])j(e,`${b}/${a.name}`,a.dir)};for(let a of c){let b=a.endsWith("/"),c=b?a.slice(0,-1):a,d=c.lastIndexOf("/");j(i(d<0?"":c.slice(0,d)),c,b)}let k=a=>{for(let b of(a.children.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"dir"===a.type?-1:1),a.children))"dir"===b.type&&k(b),a.changed+=(b.type,b.changed),a.additions+=b.additions,a.deletions+=b.deletions;a.children=a.children.map(a=>{let b=a;for(;"dir"===b.type&&1===b.children.length&&"dir"===b.children[0].type;){let a=b.children[0];b={...a,name:`${b.name}/${a.name}`}}return b})};return k(g),g}function al(a,b,c){let d=c.query.trim().toLowerCase(),e=a=>(!c.onlyChanged||0!==a.changed)&&(!d||("file"===a.type?a.path.toLowerCase().includes(d):a.children.some(e))),f=[],g=(a,h)=>{for(let i of a.children)e(i)&&(f.push({node:i,depth:h}),"dir"===i.type&&(d||c.onlyChanged||b.has(i.path))&&g(i,h+1))};return g(a,0),f}var am=c(8776),an=c(48838);let ao=(0,F.A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);var ap=c(94788),aq=c(37070),ar=c(31826);let as=/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif)$/i,at=/\.(md|markdown|mdx)$/i;var au=c(23124),av=c(31251);function aw(a){let b={meta:[],hunks:[],binary:!1},c=null,d=0,e=0;for(let f of a.split("\n")){let a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/.exec(f);if(a){d=Number(a[1]),e=Number(a[2]),c={header:f,section:a[3]??"",lines:[]},b.hunks.push(c);continue}if(!c){/^Binary files .* differ$/.test(f)||f.startsWith("GIT binary patch")?b.binary=!0:(/^(rename|copy) (from|to) /.test(f)||/^(new|deleted) file mode/.test(f)||/^similarity index/.test(f))&&b.meta.push(f);continue}let g=f[0];if("+"===g)c.lines.push({kind:"add",newNo:e++,text:f.slice(1)});else if("-"===g)c.lines.push({kind:"del",oldNo:d++,text:f.slice(1)});else if(" "===g)c.lines.push({kind:"ctx",oldNo:d++,newNo:e++,text:f.slice(1)});else if("\\"===g){let a=c.lines[c.lines.length-1];a&&(a.noEol=!0)}}return b}let ax=a=>/^(@@ [^@]+@@)/.exec(a)?.[1]??a;var ay=c(74854),az=c(70014),aA=c(61593),aB=c(26596),aC=c(54812),aD=c(34410),aE=c(46378),aF=c(91313);function aG(){let[a,b]=(0,g.useState)(""),c=(0,g.useRef)(void 0),d=(0,g.useRef)(0);return[a,(0,g.useCallback)(a=>{clearTimeout(c.current),b(""),c.current=setTimeout(()=>{d.current=Date.now(),b(a)},Math.max(0,d.current+500-Date.now()))},[])]}let aH=a=>a.slice(a.lastIndexOf("/")+1);function aI({path:a,range:b,initial:c,saved:e,editing:f,locked:h,mac:i,onChange:j,onSave:k,onCancel:m,onDelete:n}){let{t:o}=(0,O.s9)(),[p,q]=(0,g.useState)(c),[r,s]=(0,g.useState)(!1),t=(0,g.useRef)(null),u=(0,g.useRef)(null),v=(0,g.useRef)(null),w=(0,g.useId)(),x=p!==e&&!(""===e&&!p.trim()),y=()=>{x?s(!0):m()},z=()=>{p.trim()&&k(p)},A=1e3-p.length;return(0,d.jsxs)("div",{ref:v,className:"vl-peek dc-editor",role:"group","aria-label":o("diffc.editor.title",{file:aH(a),range:b}),onKeyDown:a=>{"Escape"===a.key?(a.preventDefault(),a.stopPropagation(),r?(s(!1),t.current?.focus()):y()):"Enter"===a.key&&(a.ctrlKey||a.metaKey)&&!r&&(a.preventDefault(),z())},inert:h,children:[(0,d.jsxs)("div",{className:"vl-peek-head",children:[(0,d.jsx)(l.A,{size:13,"aria-hidden":!0}),(0,d.jsx)("b",{title:a,children:aH(a)}),(0,d.jsx)("span",{className:"muted",children:b})]}),(0,d.jsxs)("div",{className:"dc-ed-body",children:[(0,d.jsx)("label",{htmlFor:w,className:"sr-only",children:o("diffc.editor.label")}),(0,d.jsx)("textarea",{ref:t,id:w,className:"input dc-text",rows:3,maxLength:1e3,value:p,onChange:a=>{var b;q(b=a.target.value),j(b)},placeholder:o("diffc.editor.placeholder"),"aria-describedby":`${w}-hint`}),A<=200&&(0,d.jsx)("p",{className:"dc-left","aria-live":"polite",children:o("diffc.editor.left",{count:A})}),r?(0,d.jsxs)("div",{className:"dc-ask",role:"group","aria-label":o("diffc.editor.discard"),children:[(0,d.jsx)("span",{className:"grow",children:o("diffc.editor.discard")}),(0,d.jsx)("button",{ref:u,type:"button",className:"btn sm",onClick:()=>{s(!1),t.current?.focus()},children:o("diffc.editor.keep")}),(0,d.jsx)("button",{type:"button",className:"btn sm danger",onClick:m,children:o("diffc.editor.drop")})]}):(0,d.jsxs)("div",{className:"dc-ed-foot",children:[f&&n&&(0,d.jsxs)("button",{type:"button",className:"btn ghost sm danger",onClick:n,children:[(0,d.jsx)(aD.A,{size:13}),o("diffc.delete")]}),(0,d.jsx)("span",{className:"grow dc-ed-hint",id:`${w}-hint`,children:o("diffc.editor.hint",{keys:i?"⌘ Enter":"Ctrl+Enter"})}),(0,d.jsx)("button",{type:"button",className:"btn ghost sm",onClick:y,children:o("common.cancel")}),(0,d.jsx)("button",{type:"button",className:"btn primary sm",disabled:!p.trim(),onClick:z,children:o(f?"diffc.editor.save":"diffc.editor.add")})]})]})]})}function aJ({ctl:a,sending:b,setSending:c,onGoTo:e}){let{t:f}=(0,O.s9)(),{items:h}=a,[i,j]=(0,g.useState)(!1),[k,m]=(0,g.useState)(!1),[n,o]=(0,g.useState)(!1),[p,q]=(0,g.useState)(null),[r,s]=(0,g.useState)(null),[t,u]=aG(),v=(0,g.useRef)(null),w=(0,g.useRef)(null),x=(0,g.useId)(),[y,B]=function(){let[a,b]=(0,g.useState)(null),[c,d]=(0,g.useState)();return[b,c?{"--dc-vw":`${c}px`}:void 0]}(),C=async()=>{if(b||a.readOnly||!h.length)return;let d=a.busy,e=a.agentName;c(!0),q(null);let g=await a.send(E(h,f));c(!1),g.ok?(a.clear(),s({queued:d,name:e})):q(g.error)},D=(0,d.jsx)("div",{className:"sr-only","aria-live":"polite",children:t});if(!h.length)return r?(0,d.jsxs)("div",{ref:y,style:B,className:"dc-bar done",role:"region","aria-label":f("diffc.bar.label"),children:[D,(0,d.jsxs)("div",{className:"dc-sent",role:"status",children:[(0,d.jsx)("span",{className:"grow",children:f(r.queued?"diffc.sentQueued":"diffc.sent",{name:r.name})}),(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>{s(null),a.onViewChat()},children:f("diffc.viewChat")}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>s(null),"aria-label":f("common.close"),title:f("common.close"),children:(0,d.jsx)(av.A,{size:14})})]})]}):D;let F=new Set(h.map(a=>a.path)),G=h.filter(a=>a.outdated).length,H=[...F].sort().map(a=>({path:a,list:h.filter(b=>b.path===a).sort((a,b)=>A(a)-A(b))})),I=()=>{j(!1),v.current?.focus()};return(0,d.jsxs)("div",{ref:y,style:B,className:"dc-bar",role:"region","aria-label":f("diffc.bar.label"),children:[D,i&&(0,d.jsxs)("div",{id:x,className:"dc-list",role:"group","aria-label":f("diffc.review.title"),inert:b,onKeyDown:a=>{"Escape"===a.key&&(a.stopPropagation(),I())},children:[(0,d.jsxs)("div",{className:"dc-list-head",children:[(0,d.jsx)("b",{className:"grow",children:f("diffc.review.title")}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:I,"aria-label":f("common.close"),title:f("common.close"),children:(0,d.jsx)(av.A,{size:15})})]}),(0,d.jsx)("div",{className:"dc-list-body",children:H.map(b=>(0,d.jsxs)("section",{className:"dc-file",children:[(0,d.jsxs)("h4",{title:b.path,children:[(0,d.jsx)("b",{children:aH(b.path)})," ",(0,d.jsx)("span",{className:"muted mono",children:b.path})]}),(0,d.jsx)("ul",{children:b.list.map(b=>{let c=z(b,f),g=f("diffc.itemAria",{file:aH(b.path),range:c});return(0,d.jsxs)("li",{className:"dc-item",children:[(0,d.jsxs)("button",{type:"button",className:"dc-item-go",onClick:()=>e(b,!1),"aria-label":`${g}: ${b.text}`,children:[(0,d.jsxs)("span",{className:"dc-item-top",children:[(0,d.jsx)("span",{className:"dc-range",children:c}),b.outdated&&(0,d.jsx)("span",{className:"chip dc-chip",title:b.gone?f("diffc.outdated.gone"):f("diffc.outdated.hint"),children:f("diffc.outdated")})]}),(0,d.jsx)("span",{className:"dc-item-text",children:b.text}),b.outdated&&(0,d.jsx)("span",{className:"dc-item-why",children:b.gone?f("diffc.outdated.gone"):f("diffc.outdated.hint")})]}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>e(b,!0),"aria-label":`${f("diffc.edit")}: ${g}`,title:f("diffc.edit"),children:(0,d.jsx)(aE.A,{size:14})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm danger",onClick:()=>{a.remove(b.id),u(f("diffc.announce.deleted",{count:h.length-1}))},"aria-label":`${f("diffc.delete")}: ${g}`,title:f("diffc.delete"),children:(0,d.jsx)(aD.A,{size:14})})]},b.id)})})]},b.path))}),(0,d.jsxs)("div",{className:"dc-list-foot",children:[(0,d.jsx)("button",{type:"button",className:"btn ghost sm","aria-expanded":k,onClick:()=>m(a=>!a),children:k?f("diffc.preview.hide"):f("diffc.preview")}),(0,d.jsx)(aa.WQ,{text:E(h,f),label:f("diffc.copy")})]}),k&&(0,d.jsx)("pre",{className:"mono dc-msg",tabIndex:0,children:E(h,f)})]}),p&&(0,d.jsx)("div",{ref:w,tabIndex:-1,className:"dc-err",children:(0,d.jsxs)(Z.lZ,{kind:"err",action:(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void C(),children:f("diffc.retry")}),children:[f("diffc.sendError"),p?` ${p}`:""]})}),a.busy&&!a.readOnly&&(0,d.jsx)("p",{className:"dc-note",children:f("diffc.busy",{name:a.agentName})}),a.readOnly&&(0,d.jsx)("p",{className:"dc-note",children:f("diffc.readOnly")}),h.length>=25&&(0,d.jsx)("p",{className:"dc-note",children:f("diffc.limit",{max:25})}),(0,d.jsxs)("div",{className:"dc-row",inert:b,children:[(0,d.jsxs)("div",{className:"dc-sum",children:[(0,d.jsx)(l.A,{size:15,"aria-hidden":!0}),(0,d.jsxs)("span",{children:[f("diffc.bar.count",{count:h.length})," \xb7 ",f("diffc.bar.files",{count:F.size})]}),G>0&&(0,d.jsx)("span",{className:"chip dc-chip",children:f("diffc.outdated.count",{count:G})}),(0,d.jsx)("button",{ref:v,type:"button",className:"btn ghost sm","aria-expanded":i,"aria-controls":i?x:void 0,onClick:()=>j(a=>!a),children:f("diffc.review")})]}),(0,d.jsxs)("div",{className:"dc-acts",children:[h.length>=2&&(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>o(!0),"aria-label":f("diffc.clear"),title:f("diffc.clear"),children:(0,d.jsx)(aD.A,{size:15})}),(0,d.jsxs)("button",{type:"button",className:"btn primary sm dc-send",disabled:b||a.readOnly,"aria-busy":b,onClick:()=>void C(),"aria-label":b?f("diffc.sending"):f("diffc.sendAria",{count:h.length,name:a.agentName}),children:[(0,d.jsx)(aF.A,{size:14,"aria-hidden":!0}),b?f("diffc.sending"):f("diffc.send",{count:h.length})]})]})]}),n&&(0,d.jsx)(Z.TM,{danger:!0,title:f("diffc.clear.title",{count:h.length}),body:f("diffc.clear.body"),confirmLabel:f("diffc.clear.go"),onClose:()=>o(!1),onConfirm:()=>a.clear()})]})}var aK=c(21975);let aL=(0,g.memo)(function({row:a,path:b,ws:c,actions:e,picking:f,onPick:g,index:h=-1,mark:i="",zone:j=!1,title:k,bubble:m,bubbleId:n,onDown:o,onEnter:p,onTap:q,onBubble:r}){let{t:s}=(0,O.s9)();if("hunk"===a.t)return(0,d.jsxs)("div",{className:"vl-row hunk",children:[(0,d.jsx)("div",{className:"vl-ln",style:{left:0},children:"⋯"}),(0,d.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:"⋯"}),(0,d.jsxs)("div",{className:"vl-hl",children:[(0,d.jsx)("span",{className:"rng mono",children:a.header}),a.section&&(0,d.jsx)("span",{className:"hs",title:a.section,children:a.section}),e&&f?.hunk===a.idx?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",className:"hk-btn on",onClick:()=>e.pickAll(a.idx,a.changed),children:s("git.discard.lines.all")}),(0,d.jsxs)("button",{type:"button",className:"hk-btn danger on",disabled:!f.picked.size,onClick:()=>e.discardPicked(a.idx,a.header),children:[(0,d.jsx)(af,{size:12}),s("git.discard.lines.go",{count:f.picked.size})]}),(0,d.jsx)("button",{type:"button",className:"hk-btn on",onClick:e.stopPicking,children:s("common.cancel")})]}):e&&(0,d.jsxs)(d.Fragment,{children:[a.changed>0&&e.canPick&&(0,d.jsxs)("button",{type:"button",className:"hk-btn",disabled:e.blocked,title:s(e.blocked?"diffc.busyPicking":"git.discard.lines.hint"),onClick:()=>e.startPicking(a.idx),children:[(0,d.jsx)(aA.A,{size:12}),s("git.discard.lines")]}),(0,d.jsxs)("button",{type:"button",className:"hk-btn",title:s("git.discard.hunk.hint"),onClick:()=>e.discardHunk(a.idx,a.header),children:[(0,d.jsx)(af,{size:12}),s("git.discard.hunk")]})]})]})]});if("line"===a.t){let e=a.l;return(0,d.jsxs)("div",{className:`vl-row ${e.kind} ${g&&void 0!==a.k&&f?.picked.has(a.k)?"picked":""} ${j?"dc-zone":""} ${i}`,onClick:g&&void 0!==a.k?()=>g(a.k):q&&j?()=>q(h):void 0,onPointerDown:o&&j?a=>o(h,a):void 0,onPointerEnter:p&&j?()=>p(h):void 0,children:[(0,d.jsxs)("div",{className:"vl-ln",style:{left:0},title:k,children:[e.oldNo??"",n&&r&&(0,d.jsx)("button",{type:"button",className:"dc-bubble",title:m,"aria-label":m,onPointerDown:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),r(n)},children:(0,d.jsx)(l.A,{size:12,"aria-hidden":!0})})]}),(0,d.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},title:k,children:e.newNo??""}),(0,d.jsx)("div",{className:"vl-sg",children:g&&void 0!==a.k?(0,d.jsx)("input",{type:"checkbox",checked:!!f?.picked.has(a.k),onChange:()=>void 0,"aria-label":s("git.discard.lines.pick")}):"add"===e.kind?"+":"del"===e.kind?"−":""}),(0,d.jsx)("div",{className:"vl-cd",children:(0,d.jsx)(az.SH,{text:e.text,path:b,ws:c})})]})}let{left:t,right:u}=a.r;return(0,d.jsxs)("div",{className:"vl-row split",children:[(0,d.jsx)("div",{className:`vl-ln ${t?.kind??"void"}`,style:{left:0},children:t?.oldNo??""}),(0,d.jsx)("div",{className:`vl-cd ${t?.kind??"void"}`,title:t&&t.text.length>60?t.text:void 0,children:t?(0,d.jsx)(az.SH,{text:t.text,path:b,ws:c}):null}),(0,d.jsx)("div",{className:`vl-ln ${u?.kind??"void"}`,children:u?.newNo??""}),(0,d.jsx)("div",{className:`vl-cd ${u?.kind??"void"}`,title:u&&u.text.length>60?u.text:void 0,children:u?(0,d.jsx)(az.SH,{text:u.text,path:b,ws:c}):null})]})});function aM({parsed:a,layout:b,path:c,cutOff:e=!1,firstIndex:f=0,onDiscardHunk:h,onDiscardLines:i,comments:j}){let{t:k}=(0,O.s9)(),{whitespace:l}=(0,am.Wx)(),m=(0,aC.O)(),n=(0,g.useMemo)(()=>(function(a,b,c,d=0){let e=[],f=(0,aB.KJ)(c);return a.hunks.forEach((a,c)=>{e.push({t:"hunk",idx:c+d,header:ax(a.header),section:f?a.section:"",changed:a.lines.filter(a=>"ctx"!==a.kind).length});let g=0;if("unified"===b)for(let b of a.lines)e.push({t:"line",l:b,hunk:c+d,k:"ctx"===b.kind?void 0:g++});else for(let b of function(a){let b=[];for(let c=0;c<a.length;){let d=a[c];if("ctx"===d.kind){b.push({left:d,right:d}),c++;continue}let e=[],f=[];for(;c<a.length&&"del"===a[c].kind;)e.push(a[c++]);for(;c<a.length&&"add"===a[c].kind;)f.push(a[c++]);for(let a=0;a<Math.max(e.length,f.length);a++)b.push({left:e[a],right:f[a]})}return b}(a.lines))e.push({t:"pair",r:b})}),e})(a,b,c,f),[a,b,c,f]),o=(0,g.useMemo)(()=>a.hunks.reduce((a,b)=>b.lines.reduce((a,b)=>Math.max(a,b.text.length),a),0),[a]),p="unified"===b?`calc(12ch + 32px + 18px + ${o}ch + 24px)`:void 0,q=(0,g.useRef)(null),r=(0,g.useRef)(null),[s,t]=(0,g.useState)({max:0,track:0}),[u,v]=(0,g.useState)(null),w=a=>v(b=>{if(!b)return b;let c=new Set(b.picked);return c.has(a)?c.delete(a):c.add(a),{...b,picked:c}}),x="unified"===b?j:void 0,[B,D]=(0,g.useState)(null),[E,F]=(0,g.useState)(null),[G,H]=(0,g.useState)(!1),[I,J]=(0,g.useState)(null),[K,L]=(0,g.useState)(!1),[M,N]=(0,g.useState)(),[P,Q]=(0,g.useState)(null),[R,S]=aG(),T=(0,g.useRef)(""),[U,V]=(0,g.useState)(null),W=(0,g.useRef)(0),X=(0,g.useCallback)((a,b,c=0)=>N({top:a*aK.U,bottom:(b+1)*aK.U+c,key:++W.current}),[]),Y=a.hunks.length-1,Z=(0,g.useMemo)(()=>{let b=new Map;if(!x)return b;let c=new Map;for(let d of(n.forEach((a,b)=>{"hunk"===a.t&&c.set(a.idx-f,b)}),x.items)){let e=d.outdated?null:C(a,d);if(e){let a=c.get(e.hunk)+1+e.start;for(let c=0;c<d.count;c++)b.has(a+c)||b.set(a+c,{id:d.id,first:0===c,outdated:!1});continue}let f=A(d),g=n.findIndex(a=>"line"===a.t&&(d.removed?"del"===a.l.kind&&a.l.oldNo===f:a.l.newNo===f));g>=0&&!b.has(g)&&b.set(g,{id:d.id,first:!0,outdated:!0})}return b},[x?.items,a,n,f]),$=(0,g.useCallback)(a=>{let b=n[a];return!!x&&!u&&b?.t==="line"&&!(e&&b.hunk-f===Y)},[x,u,n,e,f,Y]),_=(0,g.useMemo)(()=>n.flatMap((a,b)=>"line"===a.t?[b]:[]),[n]),aa=(a,b)=>n.slice(a,b+1).flatMap(a=>"line"===a.t?[a.l]:[]),ab=a=>x?.items.find(b=>b.id===a),ac=(0,g.useCallback)((a,b)=>{let c=b>=a?1:-1,d=a;for(let e=a+c;c>0?e<=b:e>=b;e+=c){let a=n[e];if(a?.t!=="line"||Z.has(e)){Z.has(e)&&S(k("diffc.announce.clamped"));break}d=e}return d},[n,Z,S,k]),ad=!!x&&x.total<25,ae=a=>{let b=ab(a),c=(a=>{let b=[...Z].filter(([,b])=>b.id===a).map(([a])=>a);return b.length?{from:Math.min(...b),to:Math.max(...b)}:null})(a);!b||!c||x?.locked||(T.current=b.text,D(null),V(null),J({from:c.from,to:c.to,lines:aa(c.from,c.to),initial:b.text,editingId:a}),X(c.from,c.to,200))},af=(a,b)=>{if(!x||x.locked)return;let d=Math.min(a,b),e=Math.max(a,b);if(d===e&&Z.has(d))return ae(Z.get(d).id);if(!ad)return void S(k("diffc.limit",{max:25}));let f=aa(d,e);T.current="",V(null),J({from:d,to:e,lines:f,initial:""}),x.store.setDraft({path:c,lines:f,text:""}),X(d,e,200)},ag=()=>{J(null),D(null),x?.store.setDraft(null),T.current="",q.current?.querySelector(".vf-main")?.focus({preventScroll:!0})},ah=()=>!!I&&T.current!==(I.editingId?I.initial:"")&&!(!I.editingId&&!T.current.trim()),ai=()=>x?.store.setDraft(null),aj=(0,g.useRef)({sel:B,editor:I,placed:Z,zoneOk:$,extend:ac,openNew:af,openEdit:ae,dirty:ah,clearDraft:ai,dragging:!1,touchTap:!1});aj.current={...aj.current,sel:B,editor:I,placed:Z,zoneOk:$,extend:ac,openNew:af,openEdit:ae,dirty:ah,clearDraft:ai};let ak=()=>q.current?.querySelector(".dc-editor textarea")?.focus(),al=(0,g.useCallback)((a,b)=>{let c=aj.current;if(c.touchTap="touch"===b.pointerType,"touch"===b.pointerType||0!==b.button||!c.zoneOk(a)||!b.target.closest(".vl-ln, .vl-sg"))return;if(b.preventDefault(),L(!1),q.current?.querySelector(".vf-main")?.focus({preventScroll:!0}),F(a),c.editor&&c.dirty()){if(b.shiftKey){let b=c.editor.from,d=c.extend(b,a),e=Math.min(b,d),f=Math.max(b,d);J({...c.editor,from:e,to:f,lines:aa(e,f)})}else ak();return}if(c.placed.has(a)&&!b.shiftKey)return void c.openEdit(c.placed.get(a).id);c.editor&&(J(null),c.clearDraft());let d=b.shiftKey&&c.sel?c.sel.a:a;D({a:d,b:c.extend(d,a)}),aj.current.dragging=!0;let e=()=>{window.removeEventListener("pointerup",e),aj.current.dragging=!1;let a=aj.current.sel;a&&aj.current.openNew(a.a,a.b)};window.addEventListener("pointerup",e)},[]),an=(0,g.useCallback)(a=>{let b=aj.current;b.dragging&&b.sel&&D({a:b.sel.a,b:b.extend(b.sel.a,a)})},[]),ao=(0,g.useCallback)(a=>{let b=aj.current;if(!b.touchTap||!b.zoneOk(a)||b.editor)return;if(L(!0),b.placed.has(a))return void b.openEdit(b.placed.get(a).id);let c=n[a];b.sel&&b.sel.a===b.sel.b&&b.sel.a!==a&&n[b.sel.a].hunk===c.hunk?D({a:b.sel.a,b:b.extend(b.sel.a,a)}):D({a:a,b:a})},[n]),ap=(0,g.useCallback)(a=>{let b=aj.current;if(b.editor&&b.dirty())return void ak();b.openEdit(a)},[]);(0,g.useRef)(!1);let aq=h?{canPick:"unified"===b&&!!i,blocked:!!I,discardHunk:h,startPicking:a=>{D(null),v({hunk:a,picked:new Set})},stopPicking:()=>v(null),pickAll:(a,b)=>v({hunk:a,picked:new Set(Array.from({length:b},(a,b)=>b))}),discardPicked:(a,b)=>{if(u&&i){let c=[...u.picked].sort((a,b)=>a-b);v(null),i(a,b,c)}}}:void 0,ar=B?Math.min(B.a,B.b):-1,as=B?Math.max(B.a,B.b):-1,at=I&&x?(0,d.jsx)(aI,{path:c,range:z(I.editingId&&ab(I.editingId)?ab(I.editingId):y(I.lines),k),initial:U??I.initial,saved:I.initial,editing:!!I.editingId,locked:x.locked,mac:m,onChange:a=>{T.current=a,x.store.setDraft({path:c,lines:I.lines,text:a,editingId:I.editingId})},onSave:a=>{let b=I.editingId?x.total:x.total+1;I.editingId?x.store.update(I.editingId,a):x.store.add(c,I.lines,a),S(k("diffc.announce.added",{range:z(I.editingId&&ab(I.editingId)?ab(I.editingId):y(I.lines),k),count:b})),V(null),ag()},onCancel:()=>{V(null),ag()},onDelete:I.editingId?()=>{x.store.remove(I.editingId),S(k("diffc.announce.deleted",{count:x.total-1})),V(null),ag()}:void 0},I.editingId??"new"):null;return(0,d.jsxs)("div",{className:`vf is-${b}`,ref:q,style:{"--vl-left":"0px","--hx":"0px"},children:[a.meta.length>0&&(0,d.jsx)("div",{className:"gx-meta",children:a.meta.join(" \xb7 ")}),(0,d.jsx)("div",{className:`vf-main ${x?"dc-on":""}`,...x?{tabIndex:0,role:"group","aria-label":k("diffc.region",{file:c.slice(c.lastIndexOf("/")+1)}),onKeyDown:a=>{if(!x||a.target!==a.currentTarget||a.ctrlKey||a.metaKey||a.altKey||!_.length)return;let b=null===E?-1:_.indexOf(E),c=Math.max(1,Math.floor((a.currentTarget.clientHeight||400)/aK.U)-1),d=null;if("ArrowDown"===a.key)d=_[Math.min(_.length-1,b+1)];else if("ArrowUp"===a.key)d=_[Math.max(0,b<0?0:b-1)];else if("Home"===a.key)d=_[0];else if("End"===a.key)d=_[_.length-1];else if("PageDown"===a.key)d=_[Math.min(_.length-1,Math.max(0,b)+c)];else if("PageUp"===a.key)d=_[Math.max(0,b-c)];else if("c"!==a.key&&"C"!==a.key&&("Enter"!==a.key||a.shiftKey)){if("Escape"===a.key){B&&(a.preventDefault(),D(null));return}}else{let b=B??(null!==E?{a:E,b:E}:null);return b&&$(b.a)?(a.preventDefault(),I&&ah())?void ak():void af(b.a,b.b):void 0}if(null!=d){if(a.preventDefault(),a.shiftKey&&null!==E&&("ArrowDown"===a.key||"ArrowUp"===a.key)){let a=B?B.a:E,b=n[a],c=n[d];if(!$(a)||b.hunk!==c.hunk)return;let e=ac(a,d);D({a,b:e}),F(e),X(e,e),S(k("diffc.announce.selected",{range:z(y(aa(Math.min(a,e),Math.max(a,e))),k)}));return}F(d),X(d,d),(a=>{let b=n[a];if(b?.t!=="line")return;let c=b.l,d="del"===c.kind?c.oldNo:c.newNo;S(`${k(`diffc.row.${c.kind}`,{n:d??"",text:c.text.trim()})}. ${k("diffc.row.pos",{i:_.indexOf(a)+1,total:_.length})}${Z.has(a)?`, ${k("diffc.row.hasComment")}`:""}.`)})(d)}},onFocus:a=>{a.target===a.currentTarget&&(H(!0),null===E&&_.length&&F(_[0]))},onBlur:a=>{a.target===a.currentTarget&&H(!1)}}:{},children:(0,d.jsx)(aK.T,{count:n.length,width:p,reveal:M,overlay:at&&I?{top:(I.to+1)*aK.U,node:at}:void 0,render:b=>{let g=n[b],h="line"===g.t&&u?.hunk===g.hunk;return(0,d.jsx)(aL,{row:g,path:c,ws:l,actions:"hunk"!==g.t||e&&g.idx===a.hunks.length-1?void 0:aq,picking:"hunk"===g.t||h?u:void 0,onPick:h?w:void 0,...(a=>{if(!x||"line"!==n[a].t)return{};let b=Z.get(a),c=$(a),d=b?.first?ab(b.id):void 0,g=!!I&&a>=I.from&&a<=I.to,h=[b&&"dc-has",b?.first&&"dc-first",b?.outdated&&"dc-outdated",(a>=ar&&a<=as||g)&&"dc-sel",G&&E===a&&"dc-cur",P&&a>=P.from&&a<=P.to&&"dc-flash"].filter(Boolean).join(" "),i=n[a],j=e&&i.hunk-f===Y?k("diffc.cutoff"):!c||b||ad?void 0:k("diffc.limit",{max:25});return{index:a,mark:h,zone:c,title:j,bubble:d?`${d.outdated?`${k("diffc.outdated")}: `:""}${k("diffc.marker",{range:z(d,k),text:Array.from(d.text).length>120?`${Array.from(d.text).slice(0,119).join("")}…`:d.text})}`:void 0,bubbleId:d?.id,onDown:al,onEnter:an,onTap:ao,onBubble:ap}})(b)},b)}})}),x&&K&&B&&!I&&(0,d.jsxs)("div",{className:"dc-selbar",role:"group","aria-label":z(y(aa(ar,as)),k),children:[(0,d.jsx)("span",{className:"grow",children:z(y(aa(ar,as)),k)}),(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>D(null),children:k("diffc.select.cancel")}),(0,d.jsx)("button",{type:"button",className:"btn primary sm",disabled:!ad||x.locked,onClick:()=>af(ar,as),children:k("diffc.select.add")})]}),x&&(0,d.jsx)("div",{className:"sr-only","aria-live":"polite",children:R}),"split"===b&&s.max>0&&(0,d.jsx)("div",{className:"hbar",ref:r,onScroll:a=>q.current?.style.setProperty("--hx",`${a.currentTarget.scrollLeft}px`),"aria-label":"Scroll sideways",children:(0,d.jsx)("div",{style:{width:s.track+s.max,height:1}})})]})}function aN({path:a,hunk:b,index:c,total:e,extent:f,onClose:h,onGo:i}){let{t:j}=(0,O.s9)(),k=(0,g.useMemo)(()=>({meta:[],hunks:[b],binary:!1}),[b]),l=b.lines.length+1;return(0,d.jsxs)("div",{className:"vl-peek",role:"dialog","aria-label":j("git.peek.title"),onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"vl-peek-head",children:[(0,d.jsx)("b",{children:f?f.from===f.to?j("git.peek.line",{n:f.from}):j("git.peek.lines",{from:f.from,to:f.to}):j("git.peek.title")}),(0,d.jsx)("span",{className:"muted mono small grow",children:ax(b.header)}),(0,d.jsx)("span",{className:"small muted",children:j("git.peek.count",{n:c+1,total:e})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:c<=0,onClick:()=>i(c-1),"aria-label":j("git.peek.prev"),title:`${j("git.peek.prev")} (Alt+↑)`,children:(0,d.jsx)(au.A,{size:15})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:c>=e-1,onClick:()=>i(c+1),"aria-label":j("git.peek.next"),title:`${j("git.peek.next")} (Alt+↓)`,children:(0,d.jsx)(M.A,{size:15})}),(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:h,"aria-label":j("common.close"),children:(0,d.jsx)(av.A,{size:14})})]}),(0,d.jsx)("div",{className:"vl-peek-body",style:{height:Math.min(l*aK.U+4,260)},children:(0,d.jsx)(aM,{parsed:k,layout:"unified",path:a,firstIndex:c})})]})}function aO({f:a,agent:b,blame:c,onOpenCommit:e,marks:f,allNew:h,focusLine:i}){let j=f?.groups??[],[k,l]=(0,g.useState)(null),m=(0,g.useMemo)(()=>{let b=a.content.split("\n").length;return j.map(a=>({from:Math.min(a.from,b),to:Math.min(a.to,b)}))},[j,a.content]),n=k?m[k.block]??null:null,[o,p]=(0,g.useState)(),q=(b,c)=>{let d={from:b.from,to:Math.min(b.to,a.content.split("\n").length)};return(d.to-(c+1)<=25?Math.max(d.to,c+1):c+1)*aK.U},s=a=>34+Math.min((a.view.lines.length+1)*aK.U+4,260)+14,{t}=(0,O.s9)(),{whitespace:u}=(0,am.Wx)(),[v,w]=(0,g.useState)(null),[x,y]=(0,g.useState)(null),z=(0,ay.Z)(a.content,a.path),A=(0,g.useMemo)(()=>z.length&&""===z[z.length-1]?z.slice(0,-1):z,[z]),B=(0,g.useMemo)(()=>a.content.split("\n").reduce((a,b)=>Math.max(a,b.length),0),[a.content]),C=(0,g.useMemo)(()=>{if(!v)return null;let a=-1;return v.lines.map((b,c)=>{let d=b!==v.lines[c-1];return d&&a++,{first:d,g:a%2}})},[v]);if(a.binary)return(0,d.jsx)("p",{className:"gx-note",children:t("git.file.binary")});if(0===A.length)return(0,d.jsx)("p",{className:"gx-note",children:t("git.file.empty")});let D=210*!!v;return(0,d.jsxs)("div",{className:"vf",children:["head"===a.source&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.file.deleted")}),a.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.file.truncated")}),x&&(0,d.jsx)("div",{className:"gx-banner",children:x}),v?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.blame.truncated",{count:v.lines.length})}),(0,d.jsx)("div",{className:"vf-main",style:{"--vl-left":`${D}px`},children:(0,d.jsx)(aK.T,{count:A.length,width:`calc(${D}px + 6ch + ${B}ch + 40px)`,overlay:k&&j[k.block]?{top:q(j[k.block],k.row),node:(0,d.jsx)(aN,{path:a.path,hunk:j[k.block].view,index:k.block,extent:n,onClose:()=>l(null),total:j.length,onGo:a=>{let b=m[a];if(!b)return;let c=Math.max(0,b.from-1);l({row:c,block:a}),p({top:c*aK.U,bottom:q(j[a],c)+s(j[a]),key:Date.now()})}})}:void 0,reveal:i?{top:Math.max(0,i.line-4)*aK.U,bottom:(i.line+2)*aK.U,key:i.key}:o,render:b=>{let c=v?.lines[b],g=c?v.commits[c]:void 0,m=C?.[b],o="worktree"===a.source?h?"add":f?.lines.get(b+1):void 0,w=!!f&&f.removedBefore.has(b+1),x=!!f&&b===A.length-1&&f.removedBefore.has(A.length+1),y=f&&"worktree"===a.source?f.blockOfLine.get(b+1)??(w?f.blockOfRemoval.get(b+1):x?f.blockOfRemoval.get(A.length+1):void 0):void 0;return(0,d.jsxs)("div",{className:`vl-row ${i&&b+1===i.line?"m-hit":""} ${m?`bl-g${m.g}`:""} ${o?`m-${o}`:""} ${w?"m-delb":x?"m-dela":""} ${void 0!==y?"has-peek":""} ${n&&b+1>=n.from&&b+1<=n.to?"in-peek":""}`,onClick:void 0!==y?a=>{if(!a.target.closest(".bl-btn")&&(a.target.closest(".vl-ln")||window.getSelection()?.isCollapsed)){if(k?.row===b)return void l(null);l({row:b,block:y}),p({top:b*aK.U,bottom:q(j[y],b)+s(j[y]),key:Date.now()})}}:void 0,title:void 0!==y?t("git.peek.hint"):void 0,children:[v&&(0,d.jsx)("div",{className:`vl-bl ${m?.first?"first":""}`,children:m?.first&&g&&(g.uncommitted?(0,d.jsx)("span",{className:"muted",children:t("git.blame.uncommitted")}):(0,d.jsxs)("button",{type:"button",className:"bl-btn",title:`${g.summary}
4
+ ${g.author} \xb7 ${(0,N.v7)(g.time)}`,onClick:()=>e(c),children:[(0,d.jsx)("span",{className:"mono sha",children:g.short}),(0,d.jsx)("span",{className:"who",children:g.author}),(0,d.jsx)("span",{className:"when",children:(0,r.KN)(g.time)})]}))}),(0,d.jsx)("div",{className:"vl-ln",children:b+1}),(0,d.jsx)("div",{className:"vl-cd",children:(0,d.jsx)(az.Yr,{html:A[b],ws:u})})]},b)}})})]})}function aP({agent:a,gitRef:b,path:c,toolbar:e=!0}){let{t:f}=(0,O.s9)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(""),[l,m]=(0,g.useState)("preview"),n=as.test(c),o=at.test(c);return(0,d.jsxs)(d.Fragment,{children:[e&&(0,d.jsxs)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:[(0,d.jsx)("span",{className:"mono small grow",title:c,style:{overflow:"hidden",textOverflow:"ellipsis"},children:c}),h&&(0,d.jsx)("span",{className:"muted small",children:(0,N.zi)(h.size)}),o&&h&&!h.binary&&(0,d.jsx)(Z.$q,{value:l,onChange:m,options:[{id:"preview",label:f("git.view.preview")},{id:"source",label:f("git.view.source")}]}),(0,d.jsx)(aa.WQ,{text:c,label:f("git.copyPath")})]}),(0,d.jsx)("div",{className:"gx-body",children:j?(0,d.jsx)("p",{className:"gx-note",children:j}):n?(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw-at?ref=${encodeURIComponent(b)}&path=${encodeURIComponent(c)}`,alt:c,onError:()=>k(f("git.file.missingAt",{ref:b}))})}):h?h.binary?(0,d.jsx)("p",{className:"gx-note",children:f("git.file.binary")}):o&&"preview"===l?(0,d.jsxs)("div",{className:"gx-md md",children:[h.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,d.jsx)(aq.oz,{remarkPlugins:[ar.A],components:{a:a=>(0,d.jsx)("a",{...a,target:"_blank",rel:"noreferrer"})},children:h.content})]}):(0,d.jsx)(aO,{f:h,agent:a,blame:!1,onOpenCommit:()=>void 0,marks:null,allNew:!1}):(0,d.jsx)("p",{className:"gx-note",children:f("git.loading")})})]})}let aQ={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflict:"!",typechange:"T"};function aR({status:a,titled:b=!1}){let{t:c}=(0,O.s9)();return(0,d.jsx)("span",{className:`stl st-${a}`,title:b?c(`git.status.${a}`):void 0,children:aQ[a]})}function aS({agent:a,gitRef:b,path:c,label:e}){let[f,h]=(0,g.useState)(!0);return f?(0,d.jsxs)("figure",{className:"gx-pic",children:[(0,d.jsx)("figcaption",{className:"muted small",children:e}),(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw-at?ref=${encodeURIComponent(b)}&path=${encodeURIComponent(c)}`,alt:c,onError:()=>h(!1)})})]}):null}function aT({agent:a,detailUrl:b,diffUrl:c,header:e,focus:f,embedded:h=!1,before:i,after:j,label:k}){let{t:l}=(0,O.s9)(),[m,n]=(0,g.useState)(null),[o,p]=(0,g.useState)(null),[q,r]=(0,g.useState)(null),[s,t]=(0,g.useState)("unified"),[u,v]=(0,g.useState)(null),w=m?.files.find(a=>a.path===o),x=(0,g.useMemo)(()=>q&&w&&q.path===w.path?aw(q.diff):null,[q,w]);if(u)return(0,d.jsx)("section",{className:"gx-preview",children:(0,d.jsx)("p",{className:"gx-note err",children:u})});if(!m)return(0,d.jsx)("section",{className:"gx-preview",children:(0,d.jsx)("p",{className:"gx-note",children:l("git.loading")})});let y=!!w&&as.test(w.path);return(0,d.jsxs)("section",{className:`gx-preview gx-commitview ${h?"embedded":""}`,"aria-label":k,children:[(0,d.jsx)("header",{className:"gx-chead",children:e(m)}),0===m.files.length?(0,d.jsx)("p",{className:"gx-note",children:l("git.cmp.nofiles")}):(0,d.jsx)("div",{className:"gx-cfilelist",role:"listbox",children:m.files.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":o===a.path,className:`gx-cfile ${o===a.path?"sel":""}`,onClick:()=>p(a.path),title:a.oldPath?`${a.oldPath} → ${a.path}`:a.path,children:[(0,d.jsx)(aR,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},a.path))}),w&&(0,d.jsxs)(d.Fragment,{children:[!y&&(0,d.jsx)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:(0,d.jsx)(Z.$q,{value:s,onChange:t,options:[{id:"unified",label:l("git.layout.unified")},{id:"split",label:l("git.layout.split")}]})}),(0,d.jsx)("div",{className:"gx-body",children:y?(0,d.jsxs)("div",{className:"gx-picpair",children:["added"!==w.status&&(0,d.jsx)(aS,{agent:a,gitRef:i,path:w.oldPath??w.path,label:l("git.img.before")}),"deleted"!==w.status&&(0,d.jsx)(aS,{agent:a,gitRef:j,path:w.path,label:l("git.img.after")})]}):x?x.binary?(0,d.jsx)("p",{className:"gx-note",children:l("git.diff.binary")}):0===x.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:l("git.diff.empty")}):(0,d.jsxs)(d.Fragment,{children:[q?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:l("git.diff.truncated")}),(0,d.jsx)(aM,{parsed:x,layout:s,path:w.path})]}):(0,d.jsx)("p",{className:"gx-note",children:l("git.loading")})})]})]})}function aU({agent:a,sha:b,embedded:c=!1,focus:e}){let{t:f}=(0,O.s9)();return(0,d.jsx)(aT,{agent:a,detailUrl:`/agents/${a.id}/git/commit?sha=${b}`,embedded:c,focus:e,before:`${b}^`,after:b,label:b,diffUrl:c=>`/agents/${a.id}/git/commit-diff?sha=${b}&path=${encodeURIComponent(c.path)}${c.oldPath?`&old=${encodeURIComponent(c.oldPath)}`:""}`,header:a=>{let[b,...c]=a.message.split("\n"),e=c.join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h3",{children:b}),e&&(0,d.jsx)("pre",{className:"gx-cbody",children:e}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{className:"mono",children:a.sha.slice(0,10)}),(0,d.jsx)(aa.WQ,{text:a.sha,label:f("git.info.copySha"),compact:!0}),(0,d.jsxs)("span",{children:["\xb7 ",a.author," \xb7 ",(0,N.v7)(a.date)]}),(0,d.jsxs)("span",{children:["\xb7 ",f("git.hist.files",{count:a.files.length})]})]})]})}})}function aV({agent:a,sel:b,onSelect:c,onLoaded:e}){let{t:f}=(0,O.s9)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(""),p=(0,g.useMemo)(()=>(h??[]).filter(a=>!l||`${a.name} ${a.subject}`.toLowerCase().includes(l.toLowerCase())),[h,l]);return n?(0,d.jsx)("p",{className:"gx-note err",children:n}):h?h.length?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"gx-filter",children:(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:f("git.tags.search"),value:l,onChange:a=>m(a.target.value),"aria-label":f("git.tags.search")})]})}),(0,d.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":f("git.tab.tags"),children:[p.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":b===a.name,className:`gx-commit ${b===a.name?"sel":""}`,onClick:()=>c(a),children:[(0,d.jsxs)("span",{className:"subj",children:[(0,d.jsx)(ao,{size:13,style:{verticalAlign:"-2px",marginRight:5}}),a.name]}),(0,d.jsx)("span",{className:"meta",children:a.subject||"—"}),(0,d.jsxs)("span",{className:"meta",children:[(0,d.jsx)("span",{className:"mono sha",children:a.sha.slice(0,8)})," \xb7 ",(0,r.KN)(Date.parse(a.date))]})]},a.name)),!p.length&&(0,d.jsx)("p",{className:"gx-note",children:f("git.noMatch",{query:l})}),j&&(0,d.jsx)("p",{className:"gx-note",children:f("git.tags.truncated",{count:h.length})})]})]}):(0,d.jsx)("p",{className:"gx-note",children:f("git.tags.empty")}):(0,d.jsx)("p",{className:"gx-note",children:f("git.loading")})}function aW({agent:a,tag:b,onChanged:c}){let{t:e}=(0,O.s9)(),f=(0,Z.dj)(),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(""),l=!!h&&/^[\w./-]+$/.test(h)&&!h.startsWith("-")&&!h.endsWith("/")&&!h.includes(".."),m=async()=>{if(h&&l)try{await q.FH.post(`/agents/${a.id}/git/branch-create`,{branch:h,from:b.name}),f(e("git.tags.branchCreated",{branch:h})),i(null),k(""),c?.()}catch(a){k(a instanceof Error?a.message:"error")}},[n,o]=(0,g.useState)("files"),[p,r]=(0,g.useState)(null),[s,t]=(0,g.useState)(!1),[u,v]=(0,g.useState)(new Set),[w,x]=(0,g.useState)(""),[y,z]=(0,g.useState)(null),[A,B]=(0,g.useState)(""),C=(0,g.useMemo)(()=>p?ak(p,[]):null,[p]),D=(0,g.useMemo)(()=>C?al(C,u,{query:w,onlyChanged:!1}).slice(0,3e3):[],[C,u,w]);return(0,d.jsxs)("section",{className:"gx-preview gx-tagview","aria-label":b.name,children:[(0,d.jsxs)("header",{className:"gx-chead",children:[(0,d.jsxs)("h3",{children:[(0,d.jsx)(ao,{size:16,style:{verticalAlign:"-2px",marginRight:6}}),b.name]}),b.subject&&(0,d.jsx)("div",{children:b.subject}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{className:"gx-chip soft",children:b.annotated?e("git.tags.annotated"):e("git.tags.lightweight")}),(0,d.jsx)("span",{className:"mono",children:b.sha.slice(0,10)}),(0,d.jsx)(aa.WQ,{text:b.sha,label:e("git.info.copySha"),compact:!0}),(0,d.jsxs)("span",{children:["\xb7 ",(0,N.v7)(b.date)]}),p&&(0,d.jsxs)("span",{children:["\xb7 ",e("git.tags.nfiles",{count:p.length})]})]}),(0,d.jsx)("div",{className:"row gap-s wrap",style:{marginTop:8},children:null===h?(0,d.jsxs)("button",{className:"btn sm",onClick:()=>i(""),children:[(0,d.jsx)(ad,{size:14}),e("git.tags.newBranch")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{className:"input mono",style:{maxWidth:240},autoFocus:!0,placeholder:e("git.tags.branchName"),value:h,onChange:a=>{i(a.target.value.trim()),k("")},"aria-label":e("git.tags.branchName"),onKeyDown:a=>{"Enter"===a.key&&m(),"Escape"===a.key&&i(null)}}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!l,onClick:()=>void m(),children:e("git.tags.createBranch")}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>{i(null),k("")},children:e("common.cancel")})]})}),j&&(0,d.jsx)("p",{className:"gx-note err",style:{margin:0},children:j}),(0,d.jsx)("div",{style:{marginTop:4},children:(0,d.jsx)(Z.$q,{value:n,onChange:o,options:[{id:"files",label:e("git.tags.files")},{id:"changes",label:e("git.tags.changes")}]})})]}),"changes"===n?(0,d.jsx)(aU,{agent:a,sha:b.sha,embedded:!0},b.sha):A?(0,d.jsx)("p",{className:"gx-note err",children:A}):C?(0,d.jsxs)("div",{className:"gx-tagfiles",children:[(0,d.jsxs)("div",{className:"gx-tagtree",children:[(0,d.jsx)("div",{className:"gx-filter",children:(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:e("git.filterPlaceholder"),value:w,onChange:a=>x(a.target.value),"aria-label":e("git.filterPlaceholder")})]})}),(0,d.jsxs)("div",{className:"gx-list",role:"tree",children:[0===D.length?(0,d.jsx)("p",{className:"gx-note",children:w?e("git.noMatch",{query:w}):e("git.noFiles")}):D.map(({node:a,depth:b})=>{let c="dir"===a.type,e=c&&(!!w||u.has(a.path));return(0,d.jsxs)("button",{type:"button",role:"treeitem","aria-level":b+1,"aria-expanded":c?e:void 0,"aria-selected":!c&&y===a.path,className:`gx-row ${c?"dir":"file"} ${!c&&y===a.path?"sel":""}`,style:{paddingLeft:8+14*b},title:a.path,onClick:()=>{let b;return c?(b=a.path,v(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})):z(a.path)},children:[(0,d.jsx)("span",{className:"chev",children:c?e?(0,d.jsx)(M.A,{size:14}):(0,d.jsx)(ae.A,{size:14}):null}),(0,d.jsx)("span",{className:"ico",children:c?e?(0,d.jsx)(ap.A,{size:15}):(0,d.jsx)(ab.A,{size:15}):(0,d.jsx)(ah.A,{size:15})}),(0,d.jsx)("span",{className:"nm",children:a.name})]},a.path)}),s&&(0,d.jsx)("p",{className:"gx-note",children:e("git.treeTruncated",{count:p?.length??0})})]})]}),(0,d.jsx)("div",{className:"gx-tagfile",children:y?(0,d.jsx)(aP,{agent:a,gitRef:b.name,path:y}):(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.tags.pick")})})})]}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")})]})}let aX=(0,F.A)("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var aY=c(28923),aZ=c(2838);function a$({refs:a,value:b,onChange:c,label:e,extra:f,icon:h=!0,compact:i=!1}){let{t:j}=(0,O.s9)(),[k,l]=(0,g.useState)(!1),[m,n]=(0,g.useState)(""),o=(0,g.useRef)(null);(0,aZ.s)(k,o,()=>l(!1));let p=a=>!m||`${a.name} ${a.subject}`.toLowerCase().includes(m.toLowerCase()),q=(0,g.useMemo)(()=>(a?.branches??[]).filter(p),[a,m]),s=(0,g.useMemo)(()=>(a?.remotes??[]).filter(p),[a,m]),t=(0,g.useMemo)(()=>(a?.tags??[]).filter(p),[a,m]),u=m.trim(),v=/^([0-9a-f]{7,40}|HEAD([~^]\d*)*)$/i.test(u)&&![...a?.branches??[],...a?.tags??[]].some(a=>a.name===u),w=a=>{c(a),l(!1)},x=(a,c)=>(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":b===a.name,className:`gx-refrow ${b===a.name?"sel":""}`,onClick:()=>w(a.name),title:a.subject,children:[(0,d.jsxs)("span",{className:"nm",children:[b===a.name?(0,d.jsx)(aY.A,{size:13}):"tag"===c?(0,d.jsx)(ao,{size:13}):(0,d.jsx)(ad,{size:13}),a.name]}),(0,d.jsxs)("span",{className:"sub",children:[a.subject||"—"," \xb7 ",(0,r.KN)(Date.parse(a.date))]})]},`${c}:${a.name}`);return(0,d.jsxs)("div",{className:"gx-brmenu gx-refpick",ref:o,children:[i?(0,d.jsxs)("button",{type:"button",className:`btn sm ${b?"primary gx-refbtn":"ghost icon"}`,"aria-expanded":k,"aria-haspopup":"listbox","aria-label":e,title:e,onClick:()=>l(a=>!a),children:[(0,d.jsx)(ad,{size:14}),b&&(0,d.jsx)("span",{className:"nm mono",children:b})]}):(0,d.jsxs)("button",{type:"button",className:"btn sm gx-refbtn","aria-expanded":k,"aria-haspopup":"listbox",title:e,onClick:()=>l(a=>!a),children:[h&&(0,d.jsx)(ad,{size:14}),(0,d.jsx)("span",{className:"nm mono",children:f?.find(a=>a.value===b)?.label??(b||j("git.ref.pick"))}),(0,d.jsx)(M.A,{size:13})]}),k&&(0,d.jsxs)("div",{className:"gx-pop",role:"listbox",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{className:"input",autoFocus:!0,placeholder:j("git.ref.search"),value:m,onChange:a=>n(a.target.value),"aria-label":j("git.ref.search"),onKeyDown:a=>{"Enter"===a.key&&v&&w(u)}})]}),(0,d.jsxs)("div",{className:"gx-brlist",children:[!m&&f?.map(a=>(0,d.jsx)("button",{type:"button",role:"option","aria-selected":b===a.value,className:`gx-refrow ${b===a.value?"sel":""}`,onClick:()=>w(a.value),children:(0,d.jsxs)("span",{className:"nm",children:[b===a.value&&(0,d.jsx)(aY.A,{size:13}),a.label]})},a.value)),v&&(0,d.jsx)("button",{type:"button",className:"gx-refrow",onClick:()=>w(u),children:(0,d.jsx)("span",{className:"nm mono",children:j("git.ref.useCommit",{ref:u.slice(0,12)})})}),q.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.branches")}),q.map(a=>x(a,"branch")),t.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.tags")}),t.slice(0,200).map(a=>x(a,"tag")),s.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:j("git.ref.remotes")}),s.slice(0,200).map(a=>x(a,"branch")),a&&!q.length&&!t.length&&!s.length&&!v&&(0,d.jsx)("p",{className:"gx-note",children:j("git.ref.none")})]})]})]})}function a_({refs:a,sel:b,onChange:c}){let{t:e}=(0,O.s9)();return(0,d.jsxs)("div",{className:"gx-cmpside",children:[(0,d.jsx)("label",{className:"label",children:e("git.cmp.base")}),(0,d.jsx)(a$,{refs:a,value:b.base,onChange:a=>c({...b,base:a})}),(0,d.jsx)("div",{className:"row",style:{justifyContent:"center"},children:(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>c({base:b.head,head:b.base}),disabled:!b.base&&!b.head,"aria-label":e("git.cmp.swap"),title:e("git.cmp.swap"),children:(0,d.jsx)(aX,{size:15,style:{transform:"rotate(90deg)"}})})}),(0,d.jsx)("label",{className:"label",children:e("git.cmp.head")}),(0,d.jsx)(a$,{refs:a,value:b.head,onChange:a=>c({...b,head:a})}),(!b.base||!b.head)&&(0,d.jsx)("p",{className:"muted small",children:e("git.cmp.pick")})]})}function a0({agent:a,sel:b}){let{t:c}=(0,O.s9)();if(!(b.base&&b.head))return(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:c("git.cmp.pick")})})});let e=`base=${encodeURIComponent(b.base)}&head=${encodeURIComponent(b.head)}`;return(0,d.jsx)(aT,{agent:a,detailUrl:`/agents/${a.id}/git/compare?${e}`,before:b.base,after:b.head,label:`${b.base} → ${b.head}`,diffUrl:b=>`/agents/${a.id}/git/compare-diff?${e}&path=${encodeURIComponent(b.path)}${b.oldPath?`&old=${encodeURIComponent(b.oldPath)}`:""}`,header:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("h3",{children:[(0,d.jsx)("span",{className:"mono",children:b.base})," → ",(0,d.jsx)("span",{className:"mono",children:b.head})]}),a.base.sha===a.head.sha?(0,d.jsx)("p",{className:"muted small",style:{margin:0},children:c("git.cmp.same")}):(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsx)("span",{children:c("git.cmp.summary",{ahead:a.ahead,behind:a.behind})}),(0,d.jsxs)("span",{children:["\xb7 ",c("git.hist.files",{count:a.files.length})]})]}),a.commits.length>0&&(0,d.jsxs)("details",{className:"gx-cmpcommits",children:[(0,d.jsx)("summary",{children:c("git.cmp.commits",{count:a.ahead})}),(0,d.jsx)("ul",{children:a.commits.map(a=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"mono sha",children:a.short})," ",a.subject," ",(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",a.author," \xb7 ",(0,r.KN)(Date.parse(a.date))]})]},a.sha))}),a.commitsTruncated&&(0,d.jsx)("p",{className:"muted small",children:c("git.cmp.more",{count:a.commits.length})})]})]})})}function a1(a){let b=a.split("\n"),c=[];for(let a=0;a<b.length;a++){if(!/^<{7}( |$)/.test(b[a]))continue;let d=-1,e=-1,f=-1;for(let c=a+1;c<b.length&&!/^<{7}( |$)/.test(b[c]);c++)if(/^\|{7}( |$)/.test(b[c])&&d<0)e=c;else if("======="===b[c]&&d<0)d=c;else if(/^>{7}( |$)/.test(b[c])&&d>=0){f=c;break}d<0||f<0||(c.push({start:a,end:f,ours:b.slice(a+1,e>=0?e:d),base:e>=0?b.slice(e+1,d):void 0,theirs:b.slice(d+1,f),oursLabel:b[a].slice(8).trim(),theirsLabel:b[f].slice(8).trim()}),a=f)}return c}function a2(a,b,c){let d=a1(a)[b];if(!d)return a;let e={ours:d.ours,theirs:d.theirs,"ours-theirs":[...d.ours,...d.theirs],"theirs-ours":[...d.theirs,...d.ours]}[c],f=a.split("\n");return f.splice(d.start,d.end-d.start+1,...e),f.join("\n")}var a3=c(28521);function a4({agent:a,path:b,state:c,a:e,onResolved:f}){let{t:h}=(0,O.s9)(),[i,j]=(0,g.useState)(null),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(null),[p,q]=(0,g.useState)(0),r=(0,g.useMemo)(()=>a1(l),[l]),s="rebase"!==c&&"stash"!==c,t=a=>"mine"===a===s?"ours":"theirs",u=a=>"both-mine"===a?s?"ours-theirs":"theirs-ours":"both-remote"===a?s?"theirs-ours":"ours-theirs":t(a),v=/^(<{7}|>{7})( |$)/m.test(l),w=!!i&&!i.binary&&!i.truncated,x=!!e.busy,y=async a=>{await e.run("resolve",h("git.res.done"),"resolve-side",{path:b,side:t(a)})&&f()},z=async()=>{await e.run("resolve",h("git.res.done"),"resolve",{path:b,content:l})&&f()},A=async()=>{await e.run("unresolve",h("git.res.restored"),"unresolve",{path:b})&&q(a=>a+1)},B=b.lastIndexOf("/"),C=B>=0?b.slice(0,B+1):"",D=b.slice(B+1);return(0,d.jsxs)("section",{className:"gx-preview gx-resolver","aria-label":b,children:[(0,d.jsxs)("header",{className:"gx-phead",children:[(0,d.jsxs)("div",{className:"gx-ptitle",children:[(0,d.jsxs)("span",{className:"gx-path mono",title:b,children:[(0,d.jsx)("span",{className:"dir",children:C}),(0,d.jsx)("b",{children:D})]}),(0,d.jsx)("span",{className:"gx-chip st-conflict",children:h("git.status.conflict")}),w&&(0,d.jsx)("span",{className:"muted small",children:r.length>0?h("git.res.left",{count:r.length}):h("git.res.none")})]}),(0,d.jsxs)("div",{className:"gx-ptools",children:[(0,d.jsx)("button",{className:"btn sm",disabled:x,title:h("git.res.allMine.hint"),onClick:()=>void y("mine"),children:h("git.res.allMine")}),(0,d.jsx)("button",{className:"btn sm",disabled:x,title:h("git.res.allRemote.hint"),onClick:()=>void y("remote"),children:h("git.res.allRemote")}),(0,d.jsx)(aa.WQ,{text:b,label:h("git.copyPath")})]})]}),n?(0,d.jsx)("p",{className:"gx-note err",children:n}):i?w?(0,d.jsxs)("div",{className:"gx-rbody",children:[r.length>0&&(0,d.jsx)("div",{className:"gx-rblocks",children:r.map((a,e)=>(0,d.jsxs)("div",{className:"gx-rcard",children:[(0,d.jsxs)("div",{className:"gx-rtitle",children:[(0,d.jsx)("b",{children:h("git.res.block",{n:e+1,total:r.length})}),(0,d.jsx)("span",{className:"muted small",children:h("git.res.line",{n:a.start+1})})]}),(0,d.jsx)("div",{className:"gx-rsides",children:["mine","remote"].map(f=>{let g,i="ours"===t(f)?a.ours:a.theirs,j=!(g="ours"===t(f)?a.oursLabel:a.theirsLabel)||["HEAD","ours","theirs","Updated upstream","Stashed changes"].includes(g)?"":g;return(0,d.jsxs)("div",{className:`gx-rside ${f}`,children:[(0,d.jsxs)("div",{className:"gx-rhead",children:[(0,d.jsx)("span",{children:"mine"===f?"stash"===c?h("git.res.mine.stash"):h("git.res.mine"):"stash"===c?h("git.res.remote.stash"):h("git.res.remote")}),j&&(0,d.jsx)("i",{className:"ref",children:j})]}),(0,d.jsx)("pre",{children:i.length?(0,d.jsx)(az.Cy,{text:i.join("\n"),path:b}):(0,d.jsx)("span",{className:"muted",children:h("git.res.empty")})}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>a2(a,e,u(f))),children:"mine"===f?h("git.res.keepMine"):h("git.res.keepRemote")})]},f)})}),(0,d.jsxs)("div",{className:"gx-rboth",children:[(0,d.jsxs)("span",{className:"small muted",children:[h("git.res.both"),":"]}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>a2(a,e,u("both-mine"))),children:h("git.res.bothMine")}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>m(a=>a2(a,e,u("both-remote"))),children:h("git.res.bothRemote")})]})]},`${e}-${a.start}`))}),(0,d.jsxs)("div",{className:"gx-rresult",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("label",{className:"label grow",htmlFor:"gx-result",children:h("git.res.result")}),(0,d.jsx)("span",{className:"small muted",children:h("git.res.editHint")})]}),(0,d.jsx)(a3.B,{id:"gx-result",label:h("git.res.result"),value:l,path:b,onChange:m})]}),(0,d.jsxs)("footer",{className:"gx-rfoot",children:[(0,d.jsxs)("button",{className:"btn ghost sm",disabled:x,onClick:()=>void A(),title:h("git.res.restore.hint"),children:[(0,d.jsx)(k.A,{size:14}),h("git.res.restore")]}),(0,d.jsx)("span",{className:"grow"}),(0,d.jsx)("button",{className:"btn primary",disabled:x||v,onClick:()=>void z(),children:h("git.res.markResolved")})]})]}):(0,d.jsx)("p",{className:"gx-note",children:h("git.res.noEdit")}):(0,d.jsx)("p",{className:"gx-note",children:h("git.loading")})]})}function a5({agent:a,plan:b,a:c,onClose:e,onGo:f}){let{t:g}=(0,O.s9)();return(0,d.jsxs)(Z.TM,{title:g("git.sw.title",{branch:b.to}),confirmLabel:g("git.sw.anyway"),onConfirm:()=>{c.busy||f()},onClose:e,children:[b.carried>0&&(0,d.jsx)("p",{className:"confirm-body",children:g("git.sw.carried",{count:b.carried,from:b.from})}),(0,d.jsxs)("div",{className:"gx-sw-warn",role:"alert",children:[b.selfRunning&&(0,d.jsx)("div",{children:g("git.warn.running",{name:a.name})}),b.others.length>0&&(0,d.jsx)("div",{children:g("git.sw.others",{count:b.others.length,names:b.others.map(a=>a.name).join(", ")})})]})]})}let a6=(0,F.A)("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),a7=(0,F.A)("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);function a8({stashes:a,sel:b,onSelect:c,onSave:e,canSave:f}){let{t:g}=(0,O.s9)();return(0,d.jsxs)("div",{className:"gx-stashes",children:[(0,d.jsx)("div",{className:"gx-stash-head",children:(0,d.jsxs)("button",{className:"btn sm",disabled:!f,title:f?void 0:g("git.stash.nothing"),onClick:e,children:[(0,d.jsx)(a6,{size:14}),g("git.stash.save")]})}),a?0===a.length?(0,d.jsx)("p",{className:"gx-note",children:g("git.stash.empty")}):(0,d.jsx)("div",{className:"gx-hist",role:"listbox","aria-label":g("git.tab.stashes"),children:a.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":b===a.sha,className:`gx-commit ${b===a.sha?"sel":""}`,onClick:()=>c(a.sha),children:[(0,d.jsx)("span",{className:"subj",children:a.message||"—"}),(0,d.jsxs)("span",{className:"meta",children:[a.branch&&(0,d.jsxs)(d.Fragment,{children:[a.branch," \xb7 "]}),(0,r.KN)(Date.parse(a.date))]}),a.smart&&(0,d.jsx)("span",{className:"refs",children:(0,d.jsx)("i",{className:"ref",children:g("git.stash.smart")})})]},a.sha))}):(0,d.jsx)("p",{className:"gx-note",children:g("git.loading")})]})}function a9({a,onClose:b}){let{t:c}=(0,O.s9)(),[e,f]=(0,g.useState)(""),h=async()=>{b(),await a.run("stash",c("git.stash.saved"),"stash-save",{message:e})};return(0,d.jsxs)(Z.aF,{title:c("git.stash.save"),onClose:b,children:[(0,d.jsx)("p",{className:"confirm-body",children:c("git.stash.save.body")}),(0,d.jsx)("input",{className:"input",autoFocus:!0,value:e,maxLength:200,placeholder:c("git.stash.save.placeholder"),onChange:a=>f(a.target.value),onKeyDown:a=>{"Enter"===a.key&&h()},"aria-label":c("git.stash.save.placeholder")}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:b,children:c("common.cancel")}),(0,d.jsx)("button",{className:"btn primary",disabled:!!a.busy,onClick:()=>void h(),children:c("git.stash.save")})]})]})}function ba({agent:a,stash:b,a:c}){let{t:e}=(0,O.s9)(),[f,h]=(0,g.useState)(null),[i,j]=(0,g.useState)(null),[k,l]=(0,g.useState)(null),[m,n]=(0,g.useState)(null),[o,p]=(0,g.useState)(!1),[q,s]=(0,g.useState)(null),t=(0,g.useMemo)(()=>m?aw(m.diff):null,[m]),u=!!c.busy,v=a=>void c.run("stash",a?e("git.stash.popped"):e("git.stash.applied"),"stash-apply",{sha:b.sha,pop:a}),w=(i?.files.length??0)+(f?.untracked.length??0);return(0,d.jsxs)("section",{className:"gx-preview gx-commitview","aria-label":b.message,children:[(0,d.jsxs)("header",{className:"gx-chead",children:[(0,d.jsx)("h3",{children:b.message||"—"}),(0,d.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,d.jsxs)("span",{children:[b.branch&&`${b.branch} \xb7 `,(0,r.KN)(Date.parse(b.date))]}),f&&(0,d.jsxs)("span",{children:["\xb7 ",e("git.hist.files",{count:w})]})]}),(0,d.jsxs)("div",{className:"row gap-s wrap",children:[(0,d.jsxs)("button",{className:"btn sm",disabled:u,title:e("git.stash.apply.hint"),onClick:()=>v(!1),children:[(0,d.jsx)(a7,{size:14}),e("git.stash.apply")]}),(0,d.jsx)("button",{className:"btn sm primary",disabled:u,title:e("git.stash.pop.hint"),onClick:()=>v(!0),children:e("git.stash.pop")}),(0,d.jsxs)("button",{className:"btn sm danger",disabled:u,onClick:()=>p(!0),children:[(0,d.jsx)(aD.A,{size:14}),e("git.stash.drop")]})]})]}),q?(0,d.jsx)("p",{className:"gx-note err",children:q}):i&&f?0===w?(0,d.jsx)("p",{className:"gx-note",children:e("git.hist.noFiles")}):(0,d.jsxs)("div",{className:"gx-cfilelist",role:"listbox",children:[i.files.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":k?.path===a.path&&!k.untracked,className:`gx-cfile ${k?.path===a.path&&!k.untracked?"sel":""}`,onClick:()=>l({path:a.path,untracked:!1,oldPath:a.oldPath}),children:[(0,d.jsx)(aR,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},`t-${a.path}`)),f.untracked.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":k?.path===a&&k.untracked,className:`gx-cfile ${k?.path===a&&k.untracked?"sel":""}`,onClick:()=>l({path:a,untracked:!0}),children:[(0,d.jsx)(aR,{status:"untracked"}),(0,d.jsx)("span",{className:"mono nm",children:a})]},`u-${a}`))]}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")}),k&&(0,d.jsx)("div",{className:"gx-body",children:t?t.binary?(0,d.jsx)("p",{className:"gx-note",children:e("git.diff.binary")}):0===t.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:e("git.diff.empty")}):(0,d.jsx)(aM,{parsed:t,layout:"unified",path:k.path,cutOff:!!m?.truncated}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")})}),o&&(0,d.jsx)(Z.TM,{danger:!0,title:e("git.stash.drop.title"),body:e("git.stash.drop.body",{name:b.message||"—"}),confirmLabel:e("git.stash.drop"),onClose:()=>p(!1),onConfirm:()=>{u||c.run("stash",e("git.stash.dropped"),"stash-drop",{sha:b.sha})},children:(0,d.jsx)("p",{className:"gx-lost",children:e("git.discard.all.warn")})})]})}let bb=(0,F.A)("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var bc=c(12675),bd=c(36414);let be=(0,F.A)("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);function bf({a}){let{t:b}=(0,O.s9)(),c=a.notice;return c?(0,d.jsxs)("div",{className:"gx-notice err",role:"alert",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("b",{className:"grow",children:c.title}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>a.setNotice(null),"aria-label":b("common.close"),children:(0,d.jsx)(av.A,{size:14})})]}),(0,d.jsx)("pre",{children:c.text}),c.diverged&&(0,d.jsxs)("div",{className:"row gap-s wrap",children:[(0,d.jsx)("span",{className:"small muted",children:b("git.notice.diverged")}),(0,d.jsx)("button",{className:"btn sm",disabled:!!a.busy,onClick:()=>void a.run("pull",b("git.done.pull"),"pull",{mode:"merge"}),children:b("git.pull.merge")}),(0,d.jsx)("button",{className:"btn sm",disabled:!!a.busy,onClick:()=>void a.run("pull",b("git.done.pull"),"pull",{mode:"rebase"}),children:b("git.pull.rebase")})]})]}):null}function bg({a,ahead:b,behind:c,detached:e,changeCount:f,onCommit:g}){let{t:h}=(0,O.s9)(),i=!!a.busy;return(0,d.jsxs)("div",{className:"gx-acts",role:"group","aria-label":h("git.act.group"),children:[(0,d.jsx)("button",{className:"btn sm",disabled:i,title:`${h("git.act.fetch")}: ${h("git.act.fetch.hint")}`,"aria-label":h("git.act.fetch"),onClick:()=>void a.run("fetch",h("git.done.fetch"),"fetch"),children:"fetch"===a.busy?(0,d.jsx)(R.A,{size:14,className:"spin"}):(0,d.jsx)(bb,{size:14})}),(0,d.jsxs)("button",{className:"btn sm",disabled:i,title:`${h("git.act.pull")}: ${h("git.act.pull.hint")}`,"aria-label":h("git.act.pull"),onClick:()=>void a.run("pull",h("git.done.pull"),"pull"),children:["pull"===a.busy?(0,d.jsx)(R.A,{size:14,className:"spin"}):(0,d.jsx)(bc.A,{size:14}),c>0&&(0,d.jsx)("span",{className:"ct",children:c})]}),(0,d.jsxs)("button",{className:"btn sm",disabled:i||e,title:`${h("git.act.push")}: ${h("git.act.push.hint")}`,"aria-label":h("git.act.push"),onClick:()=>void a.run("push",h("git.done.push"),"push"),children:["push"===a.busy?(0,d.jsx)(R.A,{size:14,className:"spin"}):(0,d.jsx)(bd.A,{size:14}),b>0&&(0,d.jsx)("span",{className:"ct",children:b})]}),(0,d.jsxs)("button",{className:"btn sm primary",disabled:i||0===f,title:0===f?h("git.commit.nothing"):void 0,onClick:g,children:["commit"===a.busy?(0,d.jsx)(R.A,{size:14,className:"spin"}):(0,d.jsx)(be,{size:14}),h("git.act.commit"),f>0&&(0,d.jsx)("span",{className:"ct",children:f})]})]})}var bh=c(71267);let bi=(0,F.A)("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function bj({agent:a,a:b,current:c,onSwitch:e}){let{t:f}=(0,O.s9)(),[h,i]=(0,g.useState)(!1),[j,k]=(0,g.useState)(null),[l,m]=(0,g.useState)(""),[n,o]=(0,g.useState)(""),[p,q]=(0,g.useState)(null),[s,t]=(0,g.useState)(null),[u,v]=(0,g.useState)(""),w=(0,g.useRef)(null);(0,aZ.s)(h,w,()=>i(!1));let x=(0,g.useMemo)(()=>(j?.local??[]).filter(a=>a.name.toLowerCase().includes(l.toLowerCase())),[j,l]),y=(0,g.useMemo)(()=>{let a=new Set((j?.local??[]).map(a=>a.name));return(j?.remote??[]).filter(b=>!a.has(b.name.split("/").slice(1).join("/"))&&b.name.toLowerCase().includes(l.toLowerCase()))},[j,l]),z=async(a,c,d,e)=>{i(!1),await b.run(a,c,d,e)},A=/^[\w./-]+$/.test(n)&&!n.startsWith("-")&&!n.endsWith("/")&&!n.includes("..");return(0,d.jsxs)("div",{className:"gx-brmenu",ref:w,children:[(0,d.jsxs)("button",{type:"button",className:"btn sm","aria-expanded":h,"aria-haspopup":"dialog",onClick:()=>i(a=>!a),children:[(0,d.jsx)(ad,{size:14}),f("git.act.branches"),(0,d.jsx)(M.A,{size:13})]}),h&&(0,d.jsxs)("div",{className:"gx-pop",role:"dialog","aria-label":f("git.act.branches"),children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{className:"input",autoFocus:!0,placeholder:f("git.br.search"),value:l,onChange:a=>m(a.target.value),"aria-label":f("git.br.search")})]}),(0,d.jsxs)("div",{className:"gx-newbr",children:[(0,d.jsx)("input",{className:"input mono",placeholder:f("git.br.newPlaceholder"),value:n,onChange:a=>o(a.target.value.trim()),"aria-label":f("git.br.new",{branch:c??""}),onKeyDown:a=>{"Enter"===a.key&&A&&z("switch",f("git.done.switch",{branch:n}),"switch",{branch:n,create:!0})}}),(0,d.jsxs)("button",{className:"btn sm",disabled:!A||!!b.busy,title:f("git.br.new",{branch:c??"…"}),onClick:()=>void z("switch",f("git.done.switch",{branch:n}),"switch",{branch:n,create:!0}),children:[(0,d.jsx)(bh.A,{size:14}),f("git.br.create")]})]}),u&&(0,d.jsx)("p",{className:"gx-note err",children:u}),(0,d.jsxs)("div",{className:"gx-brlist",children:[x.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:f("git.br.local")}),x.map(a=>(0,d.jsxs)("div",{className:`gx-br ${a.name===c?"cur":""}`,children:[(0,d.jsxs)("button",{className:"grow",disabled:a.name===c||!!b.busy,onClick:()=>{i(!1),e(a.name)},title:f("git.br.switchTo",{branch:a.name}),children:[(0,d.jsxs)("span",{className:"nm",children:[a.name===c&&(0,d.jsx)(aY.A,{size:13}),a.name]}),(0,d.jsxs)("span",{className:"sub",children:[a.subject," \xb7 ",(0,r.KN)(Date.parse(a.date))]})]}),a.name!==c&&(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>q(a.name),"aria-label":f("git.br.merge",{branch:c??""}),title:f("git.br.merge",{branch:c??""}),children:(0,d.jsx)(bi,{size:14})}),a.name!==c&&(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>{b.setNotice(null),t(a.name),i(!1)},"aria-label":f("git.br.delete",{branch:a.name}),title:f("git.br.delete",{branch:a.name}),children:(0,d.jsx)(aD.A,{size:14})})]},a.name)),y.length>0&&(0,d.jsx)("div",{className:"gx-brhead",children:f("git.br.remote")}),y.map(a=>(0,d.jsxs)("div",{className:"gx-br",children:[(0,d.jsxs)("button",{className:"grow",disabled:!!b.busy,onClick:()=>{let b=a.name.split("/").slice(1).join("/");i(!1),e(b)},title:f("git.br.switchTo",{branch:a.name}),children:[(0,d.jsx)("span",{className:"nm",children:a.name}),(0,d.jsxs)("span",{className:"sub",children:[a.subject," \xb7 ",(0,r.KN)(Date.parse(a.date))]})]}),(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!b.busy,onClick:()=>q(a.name),"aria-label":f("git.br.merge",{branch:c??""}),title:f("git.br.merge",{branch:c??""}),children:(0,d.jsx)(bi,{size:14})})]},a.name)),j&&!x.length&&!y.length&&(0,d.jsx)("p",{className:"gx-note",children:f("git.br.none")})]}),p&&(0,d.jsxs)("div",{className:"gx-mergeask",children:[(0,d.jsx)("span",{children:f("git.br.mergeAsk",{from:p,into:c??""})}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>q(null),children:f("common.cancel")}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!!b.busy,onClick:()=>void z("merge",f("git.done.merge",{branch:p}),"merge",{branch:p}),children:f("git.br.mergeGo")})]})]})]}),s&&(0,d.jsxs)(Z.aF,{title:f("git.br.delete",{branch:s}),onClose:()=>t(null),children:[(0,d.jsx)("p",{className:"confirm-body",children:f("git.br.deleteAsk",{branch:s})}),b.notice&&(0,d.jsx)("pre",{className:"gx-notice err gx-prewrap",children:b.notice.text}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>t(null),children:f("common.cancel")}),b.notice&&/not fully merged/i.test(b.notice.text)?(0,d.jsx)("button",{className:"btn danger",disabled:!!b.busy,onClick:async()=>{await b.run("branch-delete",f("git.done.branchDelete"),"branch-delete",{branch:s,force:!0})&&t(null)},children:f("git.br.deleteForce")}):(0,d.jsx)("button",{className:"btn danger",disabled:!!b.busy,onClick:async()=>{await b.run("branch-delete",f("git.done.branchDelete"),"branch-delete",{branch:s})&&t(null)},children:f("git.br.deleteGo")})]})]})]})}function bk({changes:a,a:b,onClose:c,initialMessage:e=""}){let{t:f}=(0,O.s9)(),[h,i]=(0,g.useState)(()=>new Set(a.map(a=>a.path))),[j,k]=(0,g.useState)(e),l=a.filter(a=>h.has(a.path)),m=l.flatMap(a=>a.oldPath?[a.path,a.oldPath]:[a.path]),n=!!j.trim()&&l.length>0&&!b.busy,o=async a=>{if(!await b.run("commit",f("git.done.commit"),"commit",{message:j,paths:m}))return void c();c(),a&&await b.run("push",f("git.done.push"),"push")};return(0,d.jsxs)(Z.aF,{title:f("git.commit.title"),onClose:c,children:[(0,d.jsxs)("div",{className:"gx-cfiles",children:[(0,d.jsxs)("div",{className:"row",children:[(0,d.jsx)("span",{className:"small muted grow",children:f("git.commit.selected",{n:l.length,total:a.length})}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>i(new Set(a.map(a=>a.path))),children:f("git.commit.all")}),(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>i(new Set),children:f("git.commit.none")})]}),(0,d.jsx)("div",{className:"gx-clist",children:a.map(a=>(0,d.jsxs)("label",{className:"gx-crow",title:a.path,children:[(0,d.jsx)("input",{type:"checkbox",checked:h.has(a.path),onChange:()=>{let b;return b=a.path,i(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})}}),(0,d.jsx)(aR,{status:a.status}),(0,d.jsx)("span",{className:"mono nm",children:a.path}),(null!==a.additions||null!==a.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",a.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",a.deletions??0]})]})]},a.path))})]}),(0,d.jsxs)("div",{className:"field",children:[(0,d.jsx)("label",{children:f("git.commit.message")}),(0,d.jsx)("textarea",{className:"textarea",rows:4,autoFocus:!0,value:j,onChange:a=>k(a.target.value),placeholder:f("git.commit.placeholder"),onKeyDown:a=>{(a.ctrlKey||a.metaKey)&&"Enter"===a.key&&n&&o(!1)}}),(0,d.jsx)("span",{className:"hint",children:f("git.commit.hint")})]}),(0,d.jsxs)("div",{className:"row confirm-actions",children:[(0,d.jsx)("button",{className:"btn ghost",onClick:c,children:f("common.cancel")}),(0,d.jsx)("button",{className:"btn",disabled:!n,onClick:()=>void o(!1),children:"commit"===b.busy?f("git.commit.committing"):f("git.commit.go")}),(0,d.jsx)("button",{className:"btn primary",disabled:!n,onClick:()=>void o(!0),children:f("git.commit.goPush")})]})]})}function bl({agent:a,head:b,sel:c,onSelect:e,refs:f,path:h,onClearPath:i}){let{t:j}=(0,O.s9)(),[k,l]=(0,g.useState)(null),[m,n]=(0,g.useState)(!1),[o,p]=(0,g.useState)(!1),[s,t]=(0,g.useState)(""),[u,v]=(0,g.useState)(""),[w,x]=(0,g.useState)("message"),[y,z]=(0,g.useState)(""),[A,B]=(0,g.useState)(""),C=!!(A||h||y),D=async b=>{p(!0);try{let c=`skip=${b}${A?`&q=${encodeURIComponent(A)}&by=${w}`:""}${h?`&path=${encodeURIComponent(h)}`:""}${y?`&ref=${encodeURIComponent(y)}`:""}`,d=await q.FH.get(`/agents/${a.id}/git/log?${c}`);return l(a=>0===b?d.commits:[...a??[],...d.commits]),n(d.hasMore),t(""),d.commits}catch(a){return t(a instanceof Error?a.message:"error"),null}finally{p(!1)}};return(0,g.useRef)(""),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"gx-hfilter",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{className:"input",placeholder:j("git.hist.search"),value:u,onChange:a=>v(a.target.value),"aria-label":j("git.hist.search"),title:"content"===w?j("git.hist.by.hint"):void 0})]}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsxs)("select",{className:"input",value:w,onChange:a=>x(a.target.value),"aria-label":j("git.hist.search"),title:j("git.hist.by.hint"),children:[(0,d.jsx)("option",{value:"message",children:j("git.hist.by.message")}),(0,d.jsx)("option",{value:"author",children:j("git.hist.by.author")}),(0,d.jsx)("option",{value:"content",children:j("git.hist.by.content")})]}),(0,d.jsx)(a$,{refs:f,value:y,onChange:z,extra:[{value:"",label:j("git.hist.branchCurrent")},{value:"all",label:j("git.hist.branchAll")}]})]}),h&&(0,d.jsxs)("div",{className:"gx-chip soft gx-pathchip",children:[(0,d.jsx)("span",{className:"mono nm",title:h,children:j("git.hist.file",{path:h})}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:i,"aria-label":j("git.hist.clearFile"),title:j("git.hist.clearFile"),children:(0,d.jsx)(av.A,{size:13})})]})]}),s?(0,d.jsx)("p",{className:"gx-note err",children:s}):k?k.length?(0,d.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":j("git.tab.history"),children:[k.map(a=>(0,d.jsxs)("button",{role:"option","aria-selected":c===a.sha,className:`gx-commit ${c===a.sha?"sel":""}`,onClick:()=>e(a.sha),children:[(0,d.jsx)("span",{className:"subj",children:a.subject||"—"}),(0,d.jsxs)("span",{className:"meta",children:[(0,d.jsx)("span",{className:"mono sha",children:a.short})," \xb7 ",a.author," \xb7 ",(0,r.KN)(Date.parse(a.date))]}),(a.refs.length>0||a.merge)&&(0,d.jsxs)("span",{className:"refs",children:[a.merge&&(0,d.jsx)("i",{className:"ref",children:j("git.hist.merge")}),a.refs.slice(0,3).map(a=>(0,d.jsx)("i",{className:"ref",children:a},a))]})]},a.sha)),m&&(0,d.jsx)("button",{className:"btn sm gx-more",disabled:o,onClick:()=>void D(k.length),children:o?j("git.loading"):j("git.hist.more")})]}):(0,d.jsx)("p",{className:"gx-note",children:C?j("git.hist.noMatch"):j("git.hist.empty")}):(0,d.jsx)("p",{className:"gx-note",children:j("git.loading")})]})}function bm({files:a,all:b,summary:c,file:e,onConfirm:f,onClose:g}){let{t:h}=(0,O.s9)(),i=(0,d.jsxs)("ul",{className:"gx-dlist",children:[a.slice(0,8).map(a=>(0,d.jsx)("li",{className:"mono",children:a},a)),a.length>8&&(0,d.jsx)("li",{className:"muted",children:h("hover.more",{count:a.length-8})})]});if(!b&&e&&!a.length){let a=e.add||e.del?` (+${e.add} −${e.del})`:"";return(0,d.jsxs)(Z.TM,{danger:!0,title:h("git.discard.file.title"),confirmLabel:h("git.discard.file.go"),onConfirm:f,onClose:g,children:[(0,d.jsx)("p",{className:"gx-file-eff mono",children:e.path}),(0,d.jsx)("p",{className:"confirm-body",children:"deleted"===e.status?h("git.discard.file.deleted"):"renamed"===e.status?h("git.discard.file.renamed",{from:e.oldPath??""}):h("git.discard.file.modified",{lines:a})}),(0,d.jsx)("p",{className:"gx-lost",children:h("git.discard.all.warn")})]})}return b?(0,d.jsxs)(Z.TM,{danger:!0,title:h("git.discard.all.title"),confirmLabel:h("git.discard.all.go"),onConfirm:f,onClose:g,children:[(0,d.jsxs)("ul",{className:"gx-effects",children:[c&&c.restore>0&&(0,d.jsx)("li",{children:h("git.discard.all.restore",{count:c.restore})}),a.length>0&&(0,d.jsxs)("li",{className:"bad",children:[(0,d.jsx)("b",{children:h("git.discard.all.delete",{count:a.length})}),i]})]}),c&&(0,d.jsx)("p",{className:"muted small confirm-body",children:h("git.discard.all.lines",{add:c.add,del:c.del})}),(0,d.jsx)("p",{className:"gx-lost",children:h("git.discard.all.warn")})]}):(0,d.jsx)(Z.TM,{danger:!0,title:h("git.discard.confirm.title"),body:h("git.discard.confirm.body",{count:a.length}),confirmLabel:h("git.discard.confirm.go"),onConfirm:f,onClose:g,children:i})}let bn=(0,F.A)("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);function bo({agent:a,path:b,ignored:c=!1,change:e,stamp:f,refs:h,focusLine:i,onHistory:j,onOpenCommit:k,onDiscard:l,onDiscardHunk:m,onDiscardLines:o,comments:p,commentsLocked:q=!1,commentFocus:r}){let s,{t}=(0,O.s9)(),[u,v]=(0,g.useState)(!1),w=!!e&&!as.test(b),x=at.test(b),[y,z]=(0,g.useState)(i?"file":w?"diff":x?"preview":"file"),[A,B]=(0,g.useState)("unified"),[C,D]=(0,g.useState)(null),[E,F]=(0,g.useState)(null),[G,H]=(0,g.useState)(null),[I,J]=(0,g.useState)(!1),[K,L]=(0,g.useState)(!1),M=as.test(b),[P,Q]=(0,g.useState)(null),R=(0,g.useMemo)(()=>C&&C.path===b?aw(C.diff):null,[C,b]),S=!!p&&"diff"===y&&!!e&&!!R&&!R.binary&&R.hunks.length>0,T=S&&!!R&&!P&&(s=!!C?.truncated,R.hunks.length>+!!s),U=(0,g.useMemo)(()=>p?p.items.filter(a=>a.path===b):[],[p?.items,b]),[V,W]=(0,g.useState)(null),X=e?.status==="untracked"||e?.status==="added"&&!e.oldPath,Y=(0,g.useMemo)(()=>V&&V.path===b?aw(V.diff):null,[V,b]),$=(0,g.useMemo)(()=>Y?function(a){let b=new Map,c=new Set,d=new Map,e=new Map,f=[];for(let g of a.hunks){let a=g.lines,h=[],i=Number(/\+(\d+)/.exec(g.header)?.[1]??1);for(let b=0;b<a.length;b++)h[b]=i,"del"!==a[b].kind&&(i=(a[b].newNo??i)+1);let j=[];for(let b=0;b<a.length;){if("ctx"===a[b].kind){b++;continue}let c=b;for(;b<a.length&&"ctx"!==a[b].kind;)b++;j.push([c,b-1])}for(let[g,k]of j){let j=f.length,l=1/0,m=-1/0;for(let f=g;f<=k;){if("ctx"===a[f].kind){f++;continue}let g=[],n=[];for(;f<=k&&"del"===a[f].kind;)g.push(a[f++]);for(;f<=k&&"add"===a[f].kind;)n.push(a[f++]);n.forEach((a,c)=>{let e=a.newNo;b.set(e,c<g.length?"mod":"add"),d.set(e,j),l=Math.min(l,e),m=Math.max(m,e)});let o=n.length?n[n.length-1].newNo+1:f<a.length?h[f]:i;g.length>n.length&&(c.add(o),e.set(o,j),l=Math.min(l,o),m=Math.max(m,o))}let n=g;for(let b=0;b<3&&n>0&&"ctx"===a[n-1].kind;b++)n--;let o=k;for(let b=0;b<3&&o<a.length-1&&"ctx"===a[o+1].kind;b++)o++;let p=a.slice(n,o+1),q=p.filter(a=>void 0!==a.oldNo),r=p.filter(a=>void 0!==a.newNo);f.push({from:l,to:m,view:{header:`@@ -${q[0]?.oldNo??0},${q.length} +${r[0]?.newNo??0},${r.length} @@`,section:"",lines:p}})}}return{lines:b,removedBefore:c,blockOfLine:d,blockOfRemoval:e,groups:f}}(Y):null,[Y]),_=b.lastIndexOf("/"),ab=_>=0?b.slice(0,_+1):"",ac=b.slice(_+1);return(0,d.jsxs)("section",{className:"gx-preview","aria-label":b,children:[(0,d.jsxs)("header",{className:"gx-phead",children:[(0,d.jsxs)("div",{className:"gx-ptitle",children:[(0,d.jsxs)("span",{className:"gx-path mono",title:b,children:[(0,d.jsx)("span",{className:"dir",children:ab}),(0,d.jsx)("b",{children:ac})]}),c&&(0,d.jsx)("span",{className:"gx-chip soft",title:t("git.ignored.hint"),children:t("git.ignored.chip")}),e&&(0,d.jsx)("span",{className:`gx-chip st-${e.status}`,children:t(`git.status.${e.status}`)}),e?.staged&&(0,d.jsx)("span",{className:"gx-chip soft",children:t("git.staged")}),e?.unstaged&&"untracked"!==e.status&&(0,d.jsx)("span",{className:"gx-chip soft",children:t("git.unstaged")}),e&&(null!==e.additions||null!==e.deletions)&&(0,d.jsxs)("span",{className:"gx-counts",children:[(0,d.jsxs)("i",{className:"add",children:["+",e.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",e.deletions??0]})]}),E&&!e&&(0,d.jsx)("span",{className:"muted small",children:(0,N.zi)(E.size)})]}),(0,d.jsxs)("div",{className:"gx-ptr",children:[e?.status!=="untracked"&&!c&&(0,d.jsx)("button",{type:"button",className:"btn ghost icon sm",title:t("git.file.history"),"aria-label":t("git.file.history"),onClick:()=>j(b),children:(0,d.jsx)(n.A,{size:15})}),e?.status!=="untracked"&&!c&&(0,d.jsx)(a$,{refs:h,value:P??"",onChange:Q,compact:!0,label:t("git.file.viewAt"),extra:[{value:"",label:t("git.file.viewAt")}]}),!M&&!c&&!P&&e?.status!=="deleted"&&e?.status!=="untracked"&&e?.status!=="conflict"&&(()=>{let a=u&&"file"===y;return(0,d.jsx)("button",{type:"button",className:`btn ghost icon sm ${a?"on":""}`,"aria-pressed":a,"aria-label":t("git.blame"),title:`${t("git.blame")}: ${t("git.blame.hint")}`,onClick:()=>{"file"!==y?(z("file"),v(!0)):v(a=>!a)},children:(0,d.jsx)(bn,{size:15})})})(),(0,d.jsx)(aa.WQ,{text:b,label:t("git.copyPath"),compact:!0}),e&&"conflict"!==e.status&&(0,d.jsxs)("button",{type:"button",className:"btn sm",title:t("git.discard.hint"),onClick:()=>l(e),children:[(0,d.jsx)(af,{size:14}),t("git.discard")]})]}),(0,d.jsx)("div",{className:"gx-ptools",children:(0,d.jsxs)("div",{className:"gx-ptl",children:[(e||x)&&(0,d.jsx)(Z.$q,{value:y,onChange:z,options:[...e?[{id:"diff",label:t("git.view.diff")}]:[],...x?[{id:"preview",label:t("git.view.preview")}]:[],{id:"file",label:t(x?"git.view.source":"git.view.file")}]}),"diff"===y&&e&&(0,d.jsx)(Z.$q,{value:A,onChange:B,options:[{id:"unified",label:t("git.layout.unified")},{id:"split",label:t("git.layout.split")}]}),T&&"unified"===A&&(0,d.jsxs)("span",{className:"dc-hint",children:[(0,d.jsx)("span",{className:"fine",children:t("diffc.hint")}),(0,d.jsx)("span",{className:"coarse",children:t("diffc.hint.touch")})]})]})})]}),e?.oldPath&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.renamedFrom",{path:e.oldPath})}),T&&"split"===A&&(0,d.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,d.jsx)("span",{className:"grow",children:t("diffc.splitHint")}),(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>B("unified"),children:t("diffc.splitHint.go")})]}),P&&(0,d.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,d.jsx)("span",{className:"grow",children:t("git.file.atRef",{ref:P})}),(0,d.jsx)("button",{className:"btn sm",onClick:()=>Q(null),children:t("git.file.backToCurrent")})]}),P?(0,d.jsx)(aP,{agent:a,gitRef:P,path:e?.oldPath&&P?e.oldPath:b,toolbar:!1}):(0,d.jsx)("div",{className:"gx-body",children:G?(0,d.jsx)("p",{className:"gx-note err",children:G}):!I||R||E?"diff"===y&&e?R?R.binary?(0,d.jsx)("p",{className:"gx-note",children:t("git.diff.binary")}):0===R.hunks.length?(0,d.jsx)("p",{className:"gx-note",children:t("git.diff.empty")}):(0,d.jsxs)(d.Fragment,{children:[C?.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.diff.truncated")}),(0,d.jsx)(aM,{parsed:R,layout:A,path:b,cutOff:!!C?.truncated,onDiscardHunk:e?.status==="modified"?(a,c)=>m(b,a,c):void 0,onDiscardLines:e?.status==="modified"?(a,c,d)=>o(b,a,c,d):void 0,comments:S&&p&&"unified"===A?{items:U,store:p,total:p.items.length,focus:r&&U.some(a=>a.id===r.id)?r:void 0,locked:q}:void 0})]}):null:M&&!K&&e?.status!=="deleted"?(0,d.jsx)("div",{className:"gx-image",children:(0,d.jsx)("img",{src:`/api/agents/${a.id}/git/raw?path=${encodeURIComponent(b)}&v=${f}`,alt:ac,onError:()=>L(!0)})}):"preview"===y&&E&&E.path===b?(0,d.jsxs)("div",{className:"gx-md md",children:[E.truncated&&(0,d.jsx)("div",{className:"gx-banner",children:t("git.diff.truncated")}),(0,d.jsx)(aq.oz,{remarkPlugins:[ar.A],components:{a:a=>(0,d.jsx)("a",{...a,target:"_blank",rel:"noreferrer"})},children:E.content})]}):E&&E.path===b?(0,d.jsx)(aO,{f:E,agent:a,blame:u,onOpenCommit:k,marks:$,allNew:X,focusLine:i}):M&&K?(0,d.jsx)("p",{className:"gx-note",children:t("git.file.binary")}):null:(0,d.jsx)("p",{className:"gx-note",children:t("git.loading")})})]})}let bp=(0,F.A)("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);var bq=c(78381);let br=(0,F.A)("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);function bs({name:a}){return as.test(a)?(0,d.jsx)(bp,{size:15}):/\.(md|mdx|txt|rst)$/i.test(a)?(0,d.jsx)(bq.A,{size:15}):(0,aB.eX)(a)?(0,d.jsx)(br,{size:15}):(0,d.jsx)(ah.A,{size:15})}let bt=(0,g.memo)(function({rows:a,expanded:b,forceOpen:c,sel:e,onToggle:f,onSelect:h,label:i}){let{t:j}=(0,O.s9)(),k=(0,g.useRef)(null),[l,m]=(0,g.useState)(null),n=a=>`${a.ignored?"i:":""}${a.path}`,o=a.some(a=>n(a.node)===l)?l:a.find(a=>a.node.path===e&&!a.node.ignored)?.node.path??(a[0]?n(a[0].node):null),p=(0,g.useCallback)(a=>{let b=[...k.current?.querySelectorAll("[data-row]")??[]],c=b.indexOf(document.activeElement),d=c=>{a.preventDefault(),b[Math.max(0,Math.min(b.length-1,c))]?.focus()};if("ArrowDown"===a.key)d(c+1);else if("ArrowUp"===a.key)d(c-1);else if("Home"===a.key)d(0);else if("End"===a.key)d(b.length-1);else if(c>=0&&("ArrowRight"===a.key||"ArrowLeft"===a.key)){let e=b[c],f="1"===e.dataset.dir,g="true"===e.getAttribute("aria-expanded");if("ArrowRight"===a.key)f&&!g?(a.preventDefault(),e.click()):f&&g&&d(c+1);else if(f&&g)a.preventDefault(),e.click();else{let a=Number(e.getAttribute("aria-level"));for(let e=c-1;e>=0;e--)if(Number(b[e].getAttribute("aria-level"))<a){d(e);break}}}},[]);return(0,d.jsx)("div",{className:"gx-tree-rows",ref:k,onKeyDown:p,role:"tree","aria-label":i,children:a.map(({node:a,depth:g})=>{let i="dir"===a.type,k=i&&(c||b.has(a.path)),l=a.change,p=n(a);return(0,d.jsxs)("button",{"data-row":!0,"data-dir":i?"1":"0","data-path":a.path,type:"button",role:"treeitem","aria-level":g+1,"aria-expanded":i?!!k:void 0,"aria-selected":!i&&e===a.path,tabIndex:o===p?0:-1,onFocus:()=>m(p),className:`gx-row ${i?"dir":"file"} ${a.ignored?"ignored":""} ${l?`changed st-${l.status}`:""} ${!i&&e===a.path?"sel":""} ${i&&a.changed?"has-changes":""}`,style:{paddingLeft:8+14*g},title:a.ignored?`${a.path}: ${j("git.ignored.hint")}`:a.path,onClick:()=>i?f(a):h(a.path),children:[(0,d.jsx)("span",{className:"chev",children:i?k?(0,d.jsx)(M.A,{size:14}):(0,d.jsx)(ae.A,{size:14}):null}),(0,d.jsx)("span",{className:"ico",children:i?k?(0,d.jsx)(ap.A,{size:15}):(0,d.jsx)(ab.A,{size:15}):(0,d.jsx)(bs,{name:a.name})}),(0,d.jsx)("span",{className:"nm",children:a.name}),i&&a.changed>0&&(0,d.jsx)("span",{className:"dirdot",title:j("git.dirChanged",{count:a.changed}),children:a.changed}),l&&(0,d.jsxs)("span",{className:"meta",children:[(null!==l.additions||null!==l.deletions)&&(0,d.jsxs)("span",{className:"gx-counts sm",children:[(0,d.jsxs)("i",{className:"add",children:["+",l.additions??0]}),(0,d.jsxs)("i",{className:"del",children:["−",l.deletions??0]})]}),(0,d.jsx)(aR,{status:l.status,titled:!0})]})]},p)})})}),bu=(0,F.A)("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),bv=(0,F.A)("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]),bw=(0,F.A)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),bx=["files","history","tags","compare","stashes"],by={files:bu,history:n.A,tags:ao,compare:bv,stashes:bw},bz=a=>`gx-tab-${a}`,bA="gx-side-panel";function bB({mode:a,onChange:b,stashCount:c,label:e}){let{t:f}=(0,O.s9)(),g=a=>`${f(`git.tab.${a}`)}${"stashes"===a&&c?` \xb7 ${c}`:""}`;return(0,d.jsx)("div",{className:"gx-tabs",role:"tablist","aria-label":e,onKeyDown:c=>{let d=bx.indexOf(a),e=null;"ArrowRight"===c.key||"ArrowDown"===c.key?e=(d+1)%bx.length:"ArrowLeft"===c.key||"ArrowUp"===c.key?e=(d-1+bx.length)%bx.length:"Home"===c.key?e=0:"End"===c.key&&(e=bx.length-1),null!==e&&(c.preventDefault(),b(bx[e]),requestAnimationFrame(()=>document.getElementById(bz(bx[e]))?.focus()))},children:bx.map((c,e)=>{let f=by[c];return(0,d.jsxs)("button",{id:bz(c),type:"button",role:"tab","aria-selected":a===c,"aria-controls":bA,tabIndex:a===c?0:-1,"aria-label":g(c),title:`${g(c)} (Alt+${e+1})`,className:`gx-tab ${a===c?"on":""}`,onClick:()=>b(c),children:[(0,d.jsx)(f,{size:15}),a===c&&(0,d.jsx)("span",{children:g(c)})]},c)})})}function bC({agent:a,git:b,comments:c}){let{t:e}=(0,O.s9)(),{status:f,tree:h,loading:i,error:j,refresh:k}=b,[l,m]=(0,g.useState)(null),[n,o]=(0,g.useState)(new Set),[p,s]=(0,g.useState)(""),[t,u]=(0,g.useState)(!1),[v,w]=(0,g.useState)(!1),[x,y]=(0,g.useState)("files"),[z,A]=(0,g.useState)(null),[B,C]=(0,g.useState)({base:"",head:""}),[D,E]=(0,g.useState)(!1),[F,G]=(0,g.useState)(null),[H,I]=(0,g.useState)(),J=(0,g.useRef)(null),[K,L]=(0,g.useState)(null),[P,Q]=(0,g.useState)(null),[R,S]=(0,g.useState)(null),[T,U]=(0,g.useState)(!1),[V,W]=(0,g.useState)(null),[X,Y]=(0,g.useState)(!1),[$,_]=(0,g.useState)(null),[ao,ap]=(0,g.useState)(!1),aq=function(a,b){let{t:c}=(0,O.s9)(),d=(0,Z.dj)(),[e,f]=(0,g.useState)(null),[h,i]=(0,g.useState)(null),j=async(e,g,h,j={})=>{f(e),i(null);try{let e=await q.FH.post(`/agents/${a.id}/git/${h}`,j),f=(e.output??"").split("\n").filter(Boolean).pop()??"",i=["conflicts"===e.pending?c("git.pending.conflicts"):"",e.kept?.length?c("git.sw.kept",{count:e.kept.length,names:e.kept.slice(0,3).join(", ")}):""].filter(Boolean).join(", ");return d(i?`${g}: ${i}`:f&&f.length<90?`${g}: ${f}`:g),await b(),!0}catch(d){let a=d instanceof Error?d.message:"error";return i({title:c("git.notice.failed",{action:g}),text:a,diverged:/fast-forward|divergent/i.test(a)}),await b(),!1}finally{f(null)}};return{busy:e,notice:h,setNotice:i,run:j}}(a,()=>k()),[ar,as]=(0,g.useState)(null),at=(0,am.Wx)();(0,g.useRef)(new Set);let au=f&&f.isRepo?f:null,av=function(a,b){let[c,d]=(0,g.useState)(null);return c}(0,au?.head?.sha),aw=h&&h.isRepo?h.files:null,ax=h&&h.isRepo?h.ignored:null,[ay,az]=(0,g.useState)({}),aA=(0,g.useMemo)(()=>au&&aw?ak(aw,au.changes,at.showIgnored?ax??[]:[],ay):null,[au,aw,ax,ay,at.showIgnored]),aB=(0,g.useMemo)(()=>{let a=(ax??[]).map(a=>a.replace(/\/$/,""));return b=>a.some(a=>b===a||b.startsWith(`${a}/`))},[ax]),aC=(0,g.useMemo)(()=>new Map((au?.changes??[]).map(a=>[a.path,a])),[au]),aD=(0,g.useMemo)(()=>(au?.changes??[]).reduce((a,b)=>({add:a.add+(b.additions??0),del:a.del+(b.deletions??0)}),{add:0,del:0}),[au]);a.id;let[aE,aF]=(0,g.useState)(!1),aG=(0,g.useRef)(null),aH=(0,g.useMemo)(()=>aA?al(aA,n,{query:p,onlyChanged:t}):[],[aA,n,p,t]),aI=(0,g.useMemo)(()=>aH.slice(0,2e3),[aH]),aK=(0,g.useRef)(ay);aK.current=ay;let aL=(0,g.useCallback)(b=>{let c;c=b.path,o(a=>{let b=new Set(a);return b.has(c)?b.delete(c):b.add(c),b}),!b.ignored||!b.lazy||b.path in aK.current||q.FH.get(`/agents/${a.id}/git/ls?path=${encodeURIComponent(b.path)}`).then(a=>az(c=>({...c,[b.path]:a.entries}))).catch(()=>az(a=>({...a,[b.path]:[]})))},[a.id]),aM=(0,g.useCallback)(a=>{I(void 0),m(a)},[]),[aN,aO]=(0,g.useState)(!1),[aP,aQ]=(0,g.useState)(),aR=(0,g.useCallback)((a,b)=>{y("files"),aM(a.path),aQ({id:a.id,key:Date.now(),edit:b})},[aM]);if(j&&!f)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsxs)("div",{className:"gx-empty",children:[(0,d.jsx)("h3",{children:e("git.error.title")}),(0,d.jsx)("p",{children:j}),(0,d.jsx)("button",{className:"btn",onClick:()=>void k(),children:e("git.refresh")})]})});if(!f)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.loading")})})});if(!f.isRepo)return(0,d.jsx)("div",{className:"gx",children:(0,d.jsxs)("div",{className:"gx-empty",children:[(0,d.jsx)(ab.A,{size:26,className:"muted"}),(0,d.jsx)("h3",{children:"not-repo"===f.reason?e("git.notRepo.title"):"no-git"===f.reason?e("git.noGit.title"):e("git.error.title")}),(0,d.jsx)("p",{children:"not-repo"===f.reason?e("git.notRepo.body",{path:f.cwd.replace(/^\/home\/[^/]+/,"~")}):"no-git"===f.reason?e("git.noGit.body"):f.message}),(0,d.jsxs)("button",{className:"btn",onClick:()=>void k(),children:[(0,d.jsx)(ac.A,{size:14}),e("git.refresh")]})]})});let aS=l?aC.get(l):void 0,aT=a=>aq.run("switch",a.carried?e("git.done.switchCarried",{branch:a.to,count:a.carried}):e("git.done.switch",{branch:a.to}),a.overlap.length||a.collisions.length?"switch-smart":"switch",{branch:a.to}),aX=async b=>{try{let c=await q.FH.get(`/agents/${a.id}/git/switch-plan?branch=${encodeURIComponent(b)}`);c.others.length||c.selfRunning?W(c):await aT(c)}catch(a){aq.setNotice({title:e("git.notice.failed",{action:e("git.done.switch",{branch:b})}),text:a instanceof Error?a.message:"error",diverged:!1})}},aY=a=>a.filter(a=>"untracked"===a.status||"added"===a.status&&!a.oldPath).map(a=>a.path),aZ=(0,N.Xd)(f.generatedAt);return(0,d.jsxs)("div",{className:"gx","data-gx-theme":at.theme,style:{"--g-tab":at.tabSize},children:[(0,d.jsxs)("div",{className:"gx-bar",children:[(0,d.jsxs)("button",{type:"button",className:"gx-branch","aria-expanded":v,"aria-controls":"gx-info",title:e("git.info.toggle"),onClick:()=>w(a=>!a),children:[(0,d.jsx)(ad,{size:14}),(0,d.jsx)("span",{className:"bn",children:f.branch??(f.head?`${e("git.detached")} ${f.head.sha}`:e("git.noCommitsBranch"))}),f.head&&(0,d.jsx)("span",{className:"sha",children:f.head.sha}),f.upstream&&(f.upstream.ahead>0||f.upstream.behind>0)&&(0,d.jsxs)("span",{className:"ab",title:e("git.upstream"),children:[f.upstream.ahead>0&&`↑${f.upstream.ahead}`,f.upstream.ahead>0&&f.upstream.behind>0&&" ",f.upstream.behind>0&&`↓${f.upstream.behind}`]}),v?(0,d.jsx)(M.A,{size:14}):(0,d.jsx)(ae.A,{size:14})]}),(0,d.jsx)("span",{className:"grow"}),(0,d.jsx)("span",{className:"gx-sum",children:0===f.changes.length?(0,d.jsx)("span",{className:"muted",children:e("git.clean")}):(0,d.jsx)(d.Fragment,{children:(0,d.jsxs)("span",{title:e("git.summary",{count:f.changes.length}),"aria-label":e("git.summary",{count:f.changes.length}),children:[(0,d.jsx)("b",{children:f.changes.length})," ",(0,d.jsx)("span",{className:"muted",children:e("git.files.short")})," ",(0,d.jsxs)("i",{className:"add",children:["+",(0,N._E)(aD.add)]})," ",(0,d.jsxs)("i",{className:"del",children:["−",(0,N._E)(aD.del)]})]})})}),(0,d.jsx)(bj,{agent:a,a:aq,current:f.branch,onSwitch:a=>void aX(a)}),(0,d.jsx)(bg,{a:aq,ahead:f.upstream?.ahead??0,behind:f.upstream?.behind??0,detached:!f.branch,changeCount:f.changes.length,onCommit:()=>ap(!0)}),(0,d.jsx)("button",{className:"btn ghost icon sm",disabled:!!aq.busy||0===f.changes.length||!!f.state,onClick:()=>{let a=aY(f.changes);as({files:a,all:!0,summary:{restore:f.changes.length-a.length,add:aD.add,del:aD.del},go:async()=>{let a=await aq.run("discard-all",e("git.done.discard"),"discard-all");return a&&m(null),a}})},"aria-label":e("git.discard.all"),title:f.state?e("git.discard.all.blocked"):e("git.discard.all"),children:(0,d.jsx)(af,{size:15})}),(0,d.jsx)(an.i,{}),(0,d.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void k(),"aria-label":e("git.refresh"),title:`${e("git.refresh")} \xb7 ${e("git.updated",{time:aZ})}`,children:(0,d.jsx)(ac.A,{size:15,className:i?"spin":""})})]}),v&&(0,d.jsxs)("dl",{id:"gx-info",className:"gx-info",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.branch")}),(0,d.jsxs)("dd",{className:"mono",children:[f.branch??(f.head?`${e("git.detached")} ${f.head.sha}`:e("git.noCommitsBranch")),f.branch&&(0,d.jsx)(aa.WQ,{text:f.branch,label:e("git.info.copyBranch")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.upstreamLabel")}),(0,d.jsx)("dd",{children:f.upstream?0===f.upstream.ahead&&0===f.upstream.behind?e("git.info.inSync"):e("git.info.upstreamStatus",{ahead:f.upstream.ahead,behind:f.upstream.behind}):(0,d.jsx)("span",{className:"muted",children:e("git.info.noUpstream")})})]}),f.head?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.commit")}),(0,d.jsxs)("dd",{className:"mono",children:[f.head.sha,(0,d.jsx)(aa.WQ,{text:f.head.sha,label:e("git.info.copySha")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.message")}),(0,d.jsx)("dd",{className:"msg",children:f.head.subject||(0,d.jsx)("span",{className:"muted",children:"—"})})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.author")}),(0,d.jsx)("dd",{children:f.head.author})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.when")}),(0,d.jsxs)("dd",{children:[(0,N.v7)(f.head.when)," ",(0,d.jsxs)("span",{className:"muted",children:["\xb7 ",(0,r.KN)(Date.parse(f.head.when))]})]})]})]}):(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{children:e("git.info.commit")}),(0,d.jsx)("dd",{className:"muted",children:e("git.noCommits")})]})]}),"running"===a.status&&(0,d.jsx)("div",{className:"gx-warn",children:e("git.warn.running",{name:a.name})}),f.state&&(()=>{let a=f.changes.filter(a=>"conflict"===a.status),b="merge"===f.state?e("git.state.merge"):"rebase"===f.state?e("git.state.rebase"):e("git.state.stash");return(0,d.jsxs)("div",{className:"gx-state",role:"status",children:[(0,d.jsx)("b",{children:b}),(0,d.jsxs)("span",{className:"grow",children:["stash"===f.state&&f.stash&&(0,d.jsxs)(d.Fragment,{children:[e("git.state.stash.hint",{from:f.stash.from,to:f.stash.to})," \xb7 "]}),a.length>0?e("git.state.conflicts",{count:a.length}):e("git.state.ready")]}),0===a.length&&("merge"===f.state?(0,d.jsx)("button",{className:"btn primary sm",disabled:!!aq.busy,onClick:()=>ap(!0),children:e("git.state.finishMerge")}):"rebase"===f.state?(0,d.jsx)("button",{className:"btn primary sm",disabled:!!aq.busy,onClick:()=>void aq.run("continue",e("git.done.rebaseContinue"),"rebase-continue"),children:e("git.state.continueRebase")}):(0,d.jsx)("button",{className:"btn primary sm",disabled:!!aq.busy,onClick:()=>void aq.run("smart",e("git.done.smartFinish"),"smart-finish"),children:e("git.state.finishStash")})),"stash"===f.state?(0,d.jsx)("button",{className:"btn sm danger",disabled:!!aq.busy,onClick:()=>Y(!0),children:e("git.state.cancelStash")}):(0,d.jsx)("button",{className:"btn sm danger",disabled:!!aq.busy,onClick:()=>void aq.run("abort",e("git.done.mergeAbort"),"merge-abort"),children:"merge"===f.state?e("git.state.abortMerge"):e("git.state.abortRebase")})]})})(),(0,d.jsx)(bf,{a:aq}),f.scope&&(0,d.jsx)("div",{className:"gx-scope",children:e("git.scope",{path:f.scope})}),(0,d.jsxs)("div",{className:"gx-main",children:[(0,d.jsxs)("aside",{className:"gx-tree","aria-label":e("git.filesLabel"),children:[(0,d.jsx)(bB,{mode:x,onChange:y,stashCount:P?.length??0,label:e("git.filesLabel")}),(0,d.jsx)("div",{className:"gx-sidepanel",id:bA,role:"tabpanel","aria-labelledby":bz(x),children:"stashes"===x?(0,d.jsx)(a8,{stashes:P,sel:R,onSelect:S,onSave:()=>U(!0),canSave:f.changes.length>0&&!f.state}):"tags"===x?(0,d.jsx)(aV,{agent:a,sel:K?.name??null,onSelect:L,onLoaded:a=>{let b=aG.current;aG.current=null,b&&!K&&L(a.find(a=>a.name===b)??null)}}):"compare"===x?(0,d.jsx)(a_,{refs:av,sel:B,onChange:C}):"history"===x?(0,d.jsx)(bl,{agent:a,head:f.head?.sha,sel:$,onSelect:_,refs:av,path:z,onClearPath:()=>A(null)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"gx-filter",children:[(0,d.jsxs)("div",{className:"search",children:[(0,d.jsx)(ag.A,{size:14}),(0,d.jsx)("input",{ref:J,className:"input",placeholder:D?e("git.search.placeholder"):e("git.filterPlaceholder"),value:p,onChange:a=>s(a.target.value),"aria-label":e("git.filterPlaceholder")})]}),(0,d.jsxs)("div",{className:"seg icons",role:"group","aria-label":e("git.search.name"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":!D,title:e("git.search.name"),"aria-label":e("git.search.name"),onClick:()=>E(!1),children:(0,d.jsx)(ah.A,{size:14})}),(0,d.jsx)("button",{type:"button","aria-pressed":D,title:e("git.search.content"),"aria-label":e("git.search.content"),onClick:()=>E(!0),children:(0,d.jsx)(ai,{size:14})})]}),!D&&(0,d.jsxs)("button",{type:"button",className:`btn sm gx-onlych ${t?"primary":""}`,"aria-pressed":t,title:e("git.filter.changed"),onClick:()=>u(a=>!a),children:[(0,d.jsx)(aj,{size:14}),f.changes.length>0&&(0,d.jsx)("span",{className:"ct",children:f.changes.length})]})]}),D?(0,d.jsx)("div",{className:"gx-list gx-hits",children:p.trim().length<2?(0,d.jsx)("p",{className:"gx-note",children:e("git.search.min")}):F&&F.q===p.trim()?0===F.hits.length?(0,d.jsx)("p",{className:"gx-note",children:e("git.search.none",{query:F.q})}):(0,d.jsxs)(d.Fragment,{children:[F.hits.map((a,b)=>(0,d.jsxs)("button",{type:"button",className:`gx-hit ${l===a.path&&H?.line===a.line?"sel":""}`,onClick:()=>{m(a.path),I({line:a.line,key:Date.now()})},title:`${a.path}:${a.line}`,children:[(0,d.jsxs)("span",{className:"mono nm",children:[a.path,(0,d.jsxs)("i",{children:[":",a.line]})]}),(0,d.jsx)("span",{className:"mono tx",children:a.text.trim()})]},`${a.path}:${a.line}:${b}`)),F.truncated&&(0,d.jsx)("p",{className:"gx-note",children:e("git.search.capped",{count:F.hits.length})})]}):(0,d.jsx)("p",{className:"gx-note",children:e("git.search.searching")})}):(0,d.jsxs)("div",{className:"gx-list",children:[aA?0===aI.length?(0,d.jsx)("p",{className:"gx-note",children:p?e("git.noMatch",{query:p}):t?e("git.clean"):e("git.noFiles")}):(0,d.jsx)(bt,{rows:aI,expanded:n,forceOpen:!!(p||t),sel:l,onToggle:aL,onSelect:aM,label:e("git.filesLabel")}):(0,d.jsx)("p",{className:"gx-note",children:e("git.loading")}),aH.length>aI.length&&(0,d.jsx)("p",{className:"gx-note",children:e("git.rowsCapped",{count:aI.length})}),h?.isRepo&&h.truncated&&(0,d.jsx)("p",{className:"gx-note",children:e("git.treeTruncated",{count:h.files.length})})]})]})})]}),"stashes"===x?P?.find(a=>a.sha===R)?(0,d.jsx)(ba,{agent:a,stash:P.find(a=>a.sha===R),a:aq},R):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.stash.empty")})})}):"compare"===x?(0,d.jsx)(a0,{agent:a,sel:B}):"tags"===x?K?(0,d.jsx)(aW,{agent:a,tag:K,onChanged:()=>void k()},K.name):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.tags.select")})})}):"history"===x?$?(0,d.jsx)(aU,{agent:a,sha:$,focus:z??void 0},`${$}|${z??""}`):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.hist.select")})})}):l&&aS?.status==="conflict"?(0,d.jsx)(a4,{agent:a,path:l,state:f.state,a:aq,onResolved:()=>{k()}},l):l?(0,d.jsx)(bo,{agent:a,path:l,ignored:aB(l),change:aS,stamp:f.generatedAt,refs:av,focusLine:H,onHistory:a=>{A(a),_(null),y("history")},onOpenCommit:a=>{_(a),y("history")},onDiscard:a=>as({files:aY([a]),all:!1,file:{path:a.path,status:a.status,oldPath:a.oldPath,add:a.additions??0,del:a.deletions??0},go:async()=>{let b=await aq.run("discard",e("git.done.discard"),"discard",{path:a.path,oldPath:a.oldPath});return b&&aY([a]).length&&m(null),b}}),onDiscardHunk:(a,b,c)=>void aq.run("discard-hunk",e("git.done.discard"),"discard-hunk",{path:a,index:b,header:c}),onDiscardLines:(a,b,c,d)=>void aq.run("discard-lines",e("git.done.discard"),"discard-lines",{path:a,index:b,header:c,lines:d}),comments:c,commentsLocked:aN,commentFocus:aP},l):(0,d.jsx)("div",{className:"gx-preview",children:(0,d.jsx)("div",{className:"gx-empty",children:(0,d.jsx)("p",{children:e("git.select")})})})]}),c&&(0,d.jsx)(aJ,{ctl:c,sending:aN,setSending:aO,onGoTo:aR}),V&&(0,d.jsx)(a5,{agent:a,plan:V,a:aq,onClose:()=>W(null),onGo:()=>{W(null),aT(V)}}),T&&(0,d.jsx)(a9,{a:aq,onClose:()=>U(!1)}),X&&f.stash&&(0,d.jsx)(Z.TM,{danger:!0,title:e("git.state.cancelStash.title"),body:e("git.state.cancelStash.body",{from:f.stash.from}),confirmLabel:e("git.state.cancelStash.go"),onClose:()=>Y(!1),onConfirm:()=>{aq.busy||aq.run("smart",e("git.done.smartCancel"),"smart-cancel")}}),ar&&(0,d.jsx)(bm,{files:ar.files,all:ar.all,summary:ar.summary,file:ar.file,onClose:()=>as(null),onConfirm:()=>{ar.go()}}),ao&&(0,d.jsx)(bk,{changes:f.changes,a:aq,initialMessage:f.mergeMsg,onClose:()=>ap(!1)})]})}var bD=c(58664),bE=c(15964),bF=c(8811);let bG=(0,F.A)("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);var bH=c(71556),bI=c(40123),bJ=c(59686);function bK({agent:a}){let{t:b}=(0,O.s9)(),{refresh:c}=(0,p.o0)(),e=(0,Z.dj)(),[f,h]=(0,g.useState)(null),[i,j]=(0,g.useState)(""),[k,l]=(0,g.useState)(""),[m,n]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),[t,u]=(0,g.useState)(!1),v=(0,g.useRef)(""),w=!!f&&i!==v.current,x=(0,g.useRef)(!1);x.current=w;let y=(0,g.useCallback)(async(b=!1)=>{try{let c=await q.FH.get(`/agents/${a.id}/notebook`);h(a=>a&&a.version===c.version&&a.enabled===c.enabled&&JSON.stringify(a.shared_with)===JSON.stringify(c.shared_with)?a:c),(b||!x.current)&&(v.current=c.content,j(c.content))}catch(a){l(a instanceof Error?a.message:String(a))}},[a.id]),z=async(c=i)=>{if(f){n(!0),l("");try{let d=await q.FH.put(`/agents/${a.id}/notebook`,{content:c,version:f.version});h({...f,...d}),v.current=d.content,j(d.content),e(b("notebook.saved"))}catch(a){l(a instanceof Error?a.message:String(a))}n(!1)}},A=async()=>{u(!1),l("");try{await q.FH.post(`/agents/${a.id}/notebook/separate`),e(b("notebook.separated")),await y(!0),await c(["agents"])}catch(a){l(a instanceof Error?a.message:String(a))}},B=async()=>{try{await q.FH.patch(`/agents/${a.id}`,{skill_ids:[...new Set([...a.skill_ids,f.skill_id])]}),await c(["agents"]),await y(!0)}catch(a){l(a instanceof Error?a.message:String(a))}};if(!f)return(0,d.jsx)("div",{className:"pane",children:(0,d.jsx)("p",{className:"hint",children:k||b("git.loading")})});let C=i.length,D=C>f.max,E=C>.8*f.max,F=f.shared_with??[];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"pane",children:[(0,d.jsx)("p",{className:"hint",style:{margin:0},children:b("notebook.intro")}),F.length>0&&(0,d.jsxs)("div",{className:"banner",children:[(0,d.jsx)(bF.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:b("notebook.sharedWith",{names:F.map(a=>a.name).join(", ")})}),(0,d.jsxs)("button",{className:"btn sm",onClick:()=>u(!0),children:[(0,d.jsx)(bG,{size:13}),b("notebook.separate")]})]}),!f.enabled&&(0,d.jsxs)("div",{className:"banner honey",children:[(0,d.jsx)(bH.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:b("notebook.off")}),(0,d.jsx)("button",{className:"btn sm",onClick:B,children:b("notebook.on")})]}),k&&(0,d.jsxs)("div",{className:"banner err",children:[(0,d.jsx)(bH.A,{size:16}),(0,d.jsx)("div",{className:"grow",children:k}),(0,d.jsxs)("button",{className:"btn sm",onClick:()=>{l(""),y(!0)},children:[(0,d.jsx)(ac.A,{size:13}),b("notebook.reload")]})]}),(0,d.jsxs)("div",{className:"row small muted",style:{justifyContent:"space-between"},children:[(0,d.jsxs)("span",{children:[(0,d.jsx)(bI.A,{size:12,style:{verticalAlign:"-1px"}})," ",f.updated_at?b("notebook.updated",{who:b("user"===f.updated_by?"notebook.by.you":"notebook.by.agent"),when:(0,r.KN)(f.updated_at)}):b("notebook.never")]}),(0,d.jsxs)("span",{style:{color:D?"var(--danger, #c0392b)":E?"var(--honey)":void 0},children:[C.toLocaleString()," / ",f.max.toLocaleString()]})]}),(0,d.jsx)(bJ.n,{value:i,onChange:j,placeholder:b("notebook.placeholder"),defaultView:"write",minHeight:320})]}),(0,d.jsxs)("div",{className:"savebar col",children:[(0,d.jsx)("span",{className:"muted small",children:w?b("agent.unsavedChanges"):b("agent.allSaved")}),(0,d.jsxs)("div",{className:"row",children:[(0,d.jsxs)("button",{className:"btn danger sm",style:{marginRight:"auto"},disabled:!i.trim()||m,onClick:()=>s(!0),children:[(0,d.jsx)(aD.A,{size:14}),b("notebook.clear")]}),w&&(0,d.jsx)("button",{className:"btn ghost sm",onClick:()=>j(v.current),children:b("common.discard")}),(0,d.jsx)("button",{className:"btn primary sm",disabled:!w||m||D,onClick:()=>void z(),children:b("notebook.save")})]})]}),o&&(0,d.jsxs)(Z.aF,{title:b("notebook.clear.title"),onClose:()=>s(!1),children:[(0,d.jsx)("p",{style:{margin:0},className:"muted",children:F.length?b("notebook.clear.shared",{names:F.map(a=>a.name).join(", ")}):b("notebook.clear.confirm")}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>s(!1),children:b("common.cancel")}),(0,d.jsx)("button",{className:"btn danger",onClick:()=>{s(!1),z("")},children:b("notebook.clear")})]})]}),t&&(0,d.jsxs)(Z.aF,{title:b("notebook.separate.title"),onClose:()=>u(!1),children:[(0,d.jsx)("p",{style:{margin:0},className:"muted",children:b("notebook.separate.confirm",{name:a.name,names:F.map(a=>a.name).join(", ")})}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:()=>u(!1),children:b("common.cancel")}),(0,d.jsx)("button",{className:"btn primary",onClick:()=>void A(),children:b("notebook.separate")})]})]})]})}var bL=c(4460);let bM=["config","notebook","sessions"];function bN({params:a}){let{id:b}=(0,g.use)(a);return(0,d.jsx)(bO,{id:b},b)}function bO({id:a}){let{t:b}=(0,O.s9)(),{ready:c,error:h,retry:v,refresh:z}=(0,p.q5)(),A=(0,p.fJ)(a),D=(0,j.useRouter)(),E=(0,Z.dj)(),[F,G]=(0,t.Z)("tab",""),[H,I]=(0,g.useState)("config"),J=bM.includes(F)?F:H,K=""!==F,[L,M]=(0,g.useState)(!1),[N,Q]=(0,g.useState)([]),[R,S]=(0,g.useState)(void 0),[T,U]=(0,g.useState)(null),[V,W]=(0,g.useState)("chat"),X=function(a,b){let{finished:c}=(0,p.o0)(),d=a?.id??"";c[d];let[e,f]=(0,g.useState)(null),[h,i]=(0,g.useState)(null),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(null),n=(0,g.useRef)(0);a?.effective.cwd;let o=a?.status==="running",r=(0,g.useCallback)(async a=>{if(!d)return;let b=++n.current;k(!0);try{let[c,e]=await Promise.all([q.FH.get(`/agents/${d}/git/status`),a?q.FH.get(`/agents/${d}/git/tree`):Promise.resolve(null)]);if(b!==n.current)return;f(c),e&&i(e),m(null)}catch(a){b===n.current&&m(a instanceof Error?a.message:"error")}finally{b===n.current&&k(!1)}},[d]);return(0,bD.n)(()=>r(!0),5e3,{enabled:b&&o,immediate:!1}),{status:e,tree:h,loading:j,error:l,refresh:(0,g.useCallback)(()=>r(!0),[r])}}(A,"changes"===V),Y=X.status&&X.status.isRepo?X.status.changes.length:0,$=function(a){let[b,c]=(0,g.useState)([]),d=(0,g.useRef)([]),e=`hive-am.diffc.${a}`,f=(0,g.useCallback)(a=>{if(a!==d.current)if(d.current=a,c(a),a.length)(0,s.zS)(e,a);else try{localStorage.removeItem(e)}catch{}},[e]);(0,p.Tu)(a=>a.agents),(0,p.Tu)(a=>a.ready);let h=(0,g.useRef)(null);return(0,g.useMemo)(()=>({items:b,add:(a,b,c)=>{var e;let g=(e=Date.now(),{id:"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`,path:a,text:B(c),at:e,...y(b),quote:b.slice(0,3).map(a=>({kind:a.kind,text:((a,b)=>{let c=Array.from(a);return c.length>120?c.slice(0,119).join("")+"…":a})(a.text.trimEnd(),120)})),count:b.length,first:w(b[0]),sig:x(b),outdated:!1,gone:!1});return f([...d.current,g]),g},update:(a,b)=>f(d.current.map(c=>c.id===a?{...c,text:B(b)}:c)),remove:a=>f(d.current.filter(b=>b.id!==a)),clear:()=>f([]),relocate:(a,b)=>f(function(a,b,c){let d=!1,e=c.map(c=>{if(c.path!==b)return c;let e=C(a,c),f=e?{...c,...y(a.hunks[e.hunk].lines.slice(e.start,e.start+c.count)),outdated:!1,gone:!1}:{...c,outdated:!0};return f.outdated===c.outdated&&f.gone===c.gone&&f.newFrom===c.newFrom&&f.newTo===c.newTo&&f.oldFrom===c.oldFrom&&f.oldTo===c.oldTo&&f.removed===c.removed?c:(d=!0,f)});return d?e:c}(b,a,d.current)),syncChanges:(a,b)=>f(function(a,b,c){if(c)return a;let d=!1,e=a.map(a=>{let c=b.has(a.path);return c||a.gone?c&&a.gone?(d=!0,{...a,gone:!1}):a:(d=!0,{...a,outdated:!0,gone:!0})});return d?e:a}(d.current,a,b)),getDraft:()=>h.current,setDraft:a=>{h.current=a}}),[b,f])}(a),ab=(0,g.useRef)(null),ac=void 0!==R&&R!==A?.session_id,ad=(0,g.useMemo)(()=>({...$,readOnly:ac,busy:A?.status==="running",agentName:A?.name??"",onViewChat:()=>W("chat"),send:a=>ab.current?ab.current.send(a,{quiet:!0}):Promise.resolve({ok:!1,error:b("chat.sendFailed")})}),[$,ac,A?.status,A?.name,b]),ae=(a,b)=>{let c=b??J;I(c),G(a?c:"")},af=(0,f.A)(A,{onDeleted:()=>D.push("/agents"),onCloned:a=>D.push(`/agents/${a.id}`)}),{draft:ag,setDraft:ah,errors:ai,dirty:aj}=af,ak=()=>{aj?M(!0):ae(!1)};if(!A)return(0,d.jsx)("div",{className:"page",children:!c&&h?(0,d.jsxs)(Z.lZ,{kind:"err",children:[(0,d.jsx)("span",{children:h})," ",(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void v(),children:b("fa.retry")})]}):c?(0,d.jsx)(Z.pp,{title:b("agent.missing.title"),body:b("agent.missing.body"),action:(0,d.jsx)(i(),{className:"btn",href:"/agents",children:b("agent.missing.back")})}):null});let al=async c=>{await q.FH.post(`/agents/${a}/resume-session`,{session_id:c}),S(void 0),E(b("agent.resumed"))},am=N.filter(a=>"delegation"!==a.kind),an=N.filter(a=>"delegation"===a.kind),ao=N.find(a=>a.session_id===R)?.kind==="delegation",ap=[...R?[{id:"make-current",label:b("agent.makeCurrent"),onClick:()=>void al(R).catch(a=>E(a instanceof Error?a.message:String(a),"err")),disabled:ao},{id:"back-current",label:b("agent.backToCurrent"),onClick:()=>S(void 0)}]:[],{id:"new-conv",label:b("agent.newConversation"),icon:(0,d.jsx)(k.A,{size:14}),onClick:()=>U("new"),disabled:!A.session_id||"running"===A.status}];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("section",{className:"ws-chat",children:[(0,d.jsx)(Z.DS,{back:{href:"/colony",label:b("agent.backToColony")},avatar:(0,d.jsx)(Z._h,{agent:A}),title:A.name,meta:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Z.PW,{role:A.role}),(0,d.jsx)(Z.dJ,{provider:A.provider}),(0,d.jsx)("span",{className:"small",children:A.model||b("model.cliDefault")}),(0,d.jsx)(Z.P5,{status:A.status}),(0,d.jsx)(bL.IX,{agent:A,link:!0}),(0,d.jsx)(bL.R4,{agent:A})]}),actions:ap,primary:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"seg",role:"group","aria-label":b("git.tab.label"),children:[(0,d.jsx)("button",{type:"button","aria-pressed":"chat"===V,onClick:()=>W("chat"),children:b("git.tab.chat")}),(0,d.jsxs)("button",{type:"button","aria-pressed":"changes"===V,onClick:()=>W("changes"),children:[b("git.tab.changes"),Y>0&&(0,d.jsx)("span",{className:"tabcount",children:Y}),$.items.length>0&&(0,d.jsxs)("span",{className:"tabcount dc-tabcount",role:"img","aria-label":b("diffc.tab",{count:$.items.length}),title:b("diffc.tab",{count:$.items.length}),children:[(0,d.jsx)(l.A,{size:10,"aria-hidden":!0}),$.items.length]})]})]}),(0,d.jsx)(e.N,{spec:{agentId:a},title:b("dock.agent")}),(0,d.jsxs)("button",{type:"button",className:`btn sm ${K?"primary":""}`,onClick:()=>K?ak():ae(!0),"aria-expanded":K,"aria-label":b("colony.agentSettings"),children:[(0,d.jsx)(m.A,{size:14}),b("agent.settings"),aj&&(0,d.jsx)("i",{className:"dot run",title:b("agent.unsaved")})]})]})}),(0,d.jsxs)("div",{className:"chat-pane",hidden:"chat"!==V,children:[A.permission_stale&&!R&&(0,d.jsxs)(Z.lZ,{kind:"warn",action:(0,d.jsx)("button",{type:"button",className:"btn sm",onClick:()=>U("new"),children:b("agent.permStale.action")}),children:[(0,d.jsx)("b",{children:b("agent.permStale.title")})," ",b("agent.permStale.body",{a1:(0,r.Ck)(A.effective.permission)})]}),(0,d.jsx)(_,{agent:A}),(0,d.jsx)(P,{agent:A,session:R}),(0,d.jsx)(u.ry,{agent:A,sessionOverride:R,apiRef:ab})]}),"changes"===V&&(0,d.jsx)(bC,{agent:A,git:X,comments:ad})]}),K&&(0,d.jsx)(Z._s,{title:A.name,subtitle:`${b(`role.${A.role}`)} \xb7 ${r.xq[A.provider].label}`,onClose:ak,footer:"config"===J&&ag?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"muted small grow",children:[aj?b("agent.unsavedChanges"):b("agent.allSaved"),aj&&"running"===A.status?` ${b("agent.appliesNextTurn")}`:""]}),af.actions({size:"sm"})]}):void 0,children:(0,d.jsxs)("div",{className:"agent-config",children:[(0,d.jsx)(Z.tU,{idPrefix:"cfg",label:b("fa.cfg.tabs"),value:J,onChange:a=>ae(!0,a),tabs:[{id:"config",label:b("agent.tab.config")},{id:"notebook",label:b("agent.tab.notebook")},{id:"sessions",label:b("nav.sessions")}]}),(0,d.jsx)(Z.Kp,{id:"config",value:J,idPrefix:"cfg",children:ag&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)("div",{className:"pane",children:(0,d.jsx)(bE.SU,{draft:ag,onChange:ah,errors:ai,selfId:a})})})}),(0,d.jsx)(Z.Kp,{id:"notebook",value:J,idPrefix:"cfg",children:(0,d.jsx)(bK,{agent:A})}),(0,d.jsx)(Z.Kp,{id:"sessions",value:J,idPrefix:"cfg",children:(0,d.jsxs)("div",{className:"pane",children:[(0,d.jsx)("p",{className:"hint m0",children:b("agent.sessions.intro",{path:(0,r._1)(A.effective.cwd)})}),(0,d.jsx)("div",{className:"eyebrow",children:b("agent.sessions.conversations")}),0===am.length?(0,d.jsx)(Z.pp,{compact:!0,icon:(0,d.jsx)(n.A,{size:22}),title:b("agent.sessions.empty")}):am.map(a=>{let c=a.session_id===A.session_id;return(0,d.jsxs)("div",{className:`card card-pad col fa-sess ${R===a.session_id?"on":""}`,children:[(0,d.jsxs)("div",{className:"row gap-xs",children:[(0,d.jsx)("span",{className:"mono grow sess-id",children:a.session_id}),(0,d.jsx)(aa.WQ,{compact:!0,text:a.session_id,label:b("agent.sessions.copyId")}),c&&(0,d.jsx)("span",{className:"chip honey",children:b("sessions.current")})]}),(0,d.jsx)("span",{className:"muted small",children:b("agent.sessions.started",{started:(0,r.KN)(a.first_seen),last:(0,r.KN)(a.last_seen)})}),(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)("button",{className:"btn sm",onClick:()=>{S(c?void 0:a.session_id),ae(!1)},children:R===a.session_id?b("agent.sessions.viewing"):b("agent.sessions.read")}),!c&&(0,d.jsx)("button",{className:"btn sm",onClick:()=>al(a.session_id).then(()=>ae(!1)).catch(a=>E(a instanceof Error?a.message:String(a),"err")),children:b("agent.sessions.resume")})]})]},a.session_id)}),an.length>0&&(0,d.jsx)("div",{className:"eyebrow mt-s",children:b("agent.sessions.delegated")}),an.map(a=>(0,d.jsxs)("div",{className:`card card-pad col fa-sess ${R===a.session_id?"on":""}`,children:[(0,d.jsxs)("div",{className:"row gap-s",children:[(0,d.jsx)(o.A,{size:14,className:"muted"}),(0,d.jsx)("b",{className:"grow",children:b("agent.sessions.from",{name:a.from_name??b("chat.anOrchestrator")})}),(0,d.jsx)("span",{className:"muted small",children:(0,r.KN)(a.last_seen)})]}),a.task&&(0,d.jsx)("span",{className:"small fa-clamp3",children:a.task}),(0,d.jsxs)("div",{className:"row gap-xs",children:[(0,d.jsx)("span",{className:"mono muted small grow sess-id",children:a.session_id}),(0,d.jsx)(aa.WQ,{compact:!0,text:a.session_id,label:b("agent.sessions.copyId")})]}),(0,d.jsx)("div",{className:"row gap-s",children:(0,d.jsx)("button",{className:"btn sm",onClick:()=>{S(R===a.session_id?void 0:a.session_id),ae(!1)},children:R===a.session_id?b("agent.sessions.viewing"):b("agent.sessions.read")})})]},a.session_id))]})})]})}),af.deleteModal,af.cloneModal,L&&(0,d.jsx)(Z.TM,{danger:!0,title:b("fa.unsaved.title"),body:b("fa.unsaved.body"),confirmLabel:b("fa.unsaved.discard"),cancelLabel:b("fa.unsaved.keep"),onClose:()=>M(!1),onConfirm:()=>{af.discard(),ae(!1)}}),"new"===T&&(0,d.jsx)(Z.TM,{title:b("agent.newConvTitle"),body:b("agent.newConvBody"),confirmLabel:b("agent.newConvStart"),onClose:()=>U(null),onConfirm:async()=>{await q.FH.post(`/agents/${a}/new-session`),await z(["agents"]),E(b("agent.newConvStarted"))}})]})}},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},55511:a=>{"use strict";a.exports=require("crypto")},62172:(a,b,c)=>{"use strict";c.d(b,{y:()=>k});var d=c(55322),e=c(17027),f=c(35842),g=c(7371),h=c(60570),i=c(93884),j=c(95361);function k({agent:a,onClose:b,onCloned:c}){let{t:k}=(0,i.s9)(),{agents:l,colonies:m}=(0,h.q5)(),{refresh:n}=(0,h.zd)(),o=(0,j.dj)(),[p,q]=(0,e.useState)(()=>((a,b)=>{for(let c=2;;c++){let d=`${a} ${c}`;if(!b.has(d.toLowerCase()))return d}})(a.name,new Set(l.map(a=>a.name.toLowerCase())))),[r,s]=(0,e.useState)(a.colony_id??""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(""),x=l.some(a=>a.name.toLowerCase()===p.trim().toLowerCase()),y=async()=>{u(!0),w("");try{let d=await g.FH.post(`/agents/${a.id}/clone`,{name:p.trim(),colony_id:r||null});await n(["agents","colonies"]),o(k("agent.cloned",{name:d.name})),c?.(d),b()}catch(a){w(a instanceof Error?a.message:String(a)),u(!1)}};return(0,d.jsxs)(j.aF,{title:k("agent.clone.title",{name:a.name}),onClose:b,children:[(0,d.jsx)(j.D0,{label:k("agent.clone.name"),error:x?k("agent.clone.taken"):v,children:(0,d.jsx)("input",{className:"input",value:p,autoFocus:!0,onChange:a=>q(a.target.value),onKeyDown:a=>{"Enter"===a.key&&p.trim()&&!x&&!t&&y()}})}),(0,d.jsx)(j.D0,{label:k("form.colony"),children:(0,d.jsxs)("select",{className:"select",value:r,onChange:a=>s(a.target.value),children:[(0,d.jsx)("option",{value:"",children:k("common.noColony")}),m.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))]})}),(0,d.jsxs)("ul",{className:"muted small clone-facts",children:[(0,d.jsx)("li",{children:k("agent.clone.parallel",{name:a.name})}),(0,d.jsx)("li",{children:k("agent.clone.config")}),(0,d.jsx)("li",{children:k("agent.clone.notebook",{name:a.name})}),(0,d.jsx)("li",{children:k("agent.clone.notBring",{name:a.name})})]}),(0,d.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,d.jsx)("button",{className:"btn ghost",onClick:b,children:k("common.cancel")}),(0,d.jsxs)("button",{className:"btn primary",disabled:!p.trim()||x||t,onClick:()=>void y(),children:[(0,d.jsx)(f.A,{size:14}),t?k("agent.clone.working"):k("agent.clone")]})]})]})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66390:(a,b,c)=>{"use strict";c.d(b,{G:()=>j});var d=c(55322),e=c(17027),f=c(95361),g=c(60570),h=c(7371),i=c(93884);function j({agent:a,onClose:b,onDeleted:c}){let{t:j}=(0,i.s9)(),{refresh:k}=(0,g.zd)(),l=(0,f.dj)(),[m,n]=(0,e.useState)([]);return(0,d.jsx)(f.TM,{title:j("agent.deleteTitle",{name:a.name}),body:m.length?j("agent.deleteBody.shared",{names:m.join(", ")}):j("agent.deleteBody"),danger:!0,confirmLabel:j("agent.delete"),cancelLabel:j("agent.keep"),onClose:b,onConfirm:async()=>{await h.FH.del(`/agents/${a.id}`),await k(["agents","colonies"]),l(j("agent.deleted")),c?.()}})}},73136:a=>{"use strict";a.exports=require("node:url")},76760:a=>{"use strict";a.exports=require("node:path")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},93304:(a,b,c)=>{Promise.resolve().then(c.bind(c,27769))},93674:(a,b,c)=>{"use strict";c.d(b,{A:()=>p});var d=c(55322),e=c(17027),f=c(34410),g=c(35842),h=c(95361),i=c(15964),j=c(66390),k=c(62172),l=c(60570),m=c(13520),n=c(7371),o=c(93884);function p(a,b={}){let{t:c}=(0,o.s9)(),{agents:q,colonies:r,objects:s,refresh:t}=(0,l.q5)(),u=(0,h.dj)(),v=(0,e.useMemo)(()=>a?s.filter(b=>b.manager_id===a.id).map(a=>a.id).sort():[],[s,a?.id]),w=(0,e.useMemo)(()=>a?JSON.stringify((0,i.TN)(a,v)):"",[a,v]),[x,y]=(0,e.useState)(()=>a?(0,i.TN)(a,v):null),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(!1),F=x&&a?(0,i.tf)(x,q,a.id,r):{},G=!!x&&JSON.stringify(x)!==w;(0,m.h)(G);let H=async()=>{if(x&&a){if(Object.keys(F).length)return void u(c("edit.fixFields"),"err");A(!0);try{let{type_id:d,object_ids:e,...f}=x;await n.FH.patch(`/agents/${a.id}`,f),JSON.stringify([...e].sort())!==JSON.stringify(v)&&await n.FH.put(`/agents/${a.id}/resources`,{object_ids:e}),await t(["agents","colonies","objects"]),u(c("edit.saved",{name:x.name.trim()})),b.onSaved?.()}catch(a){u(a instanceof Error?a.message:c("edit.saveFailed"),"err")}A(!1)}},I=()=>{a&&y((0,i.TN)(a,v))};return{draft:x,setDraft:y,errors:F,dirty:G,saving:z,save:H,discard:I,actions:(a={})=>(0,d.jsxs)("span",{className:"foot-actions push-r",children:[(0,d.jsxs)("span",{className:"row gap-s",children:[(0,d.jsxs)("button",{className:`btn danger ${a.size??""}`,onClick:()=>C(!0),children:[(0,d.jsx)(f.A,{size:a.size?14:15}),c("agent.delete")]}),(0,d.jsx)("button",{className:`btn icon ${a.size??""}`,onClick:()=>E(!0),title:c("agent.clone.hint"),"aria-label":c("agent.clone"),children:(0,d.jsx)(g.A,{size:a.size?14:15})})]}),a.onCancel?(0,d.jsx)("button",{className:`btn ghost ${a.size??""}`,onClick:a.onCancel,children:c("common.cancel")}):(0,d.jsx)("button",{className:`btn ghost ${a.size??""}`,disabled:!G,onClick:I,children:c("common.discard")}),(0,d.jsx)("button",{className:`btn primary ${a.size??""}`,disabled:!G||z,onClick:H,children:z?c("common.saving"):c("common.saveChanges")})]}),deleteModal:B&&a?(0,d.jsx)(j.G,{agent:a,onClose:()=>C(!1),onDeleted:b.onDeleted}):null,cloneModal:D&&a?(0,d.jsx)(k.y,{agent:a,onClose:()=>E(!1),onCloned:b.onCloned}):null}}},93976:(a,b,c)=>{Promise.resolve().then(c.bind(c,40448))}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[691,272,335,593,616,953,143,368,802,944,345],()=>b(b.s=34105));module.exports=c})();