hive-am 1.2.2 → 1.4.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 (148) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/README.md +19 -0
  3. package/package.json +1 -1
  4. package/server/dist/context.js +62 -0
  5. package/server/dist/db/migrations.js +7 -0
  6. package/server/dist/db.js +4 -4
  7. package/server/dist/history/claude.js +8 -2
  8. package/server/dist/http/routes/agents.js +1 -1
  9. package/server/dist/http/validate.js +2 -0
  10. package/server/dist/instructions.js +4 -0
  11. package/server/dist/models.js +2 -0
  12. package/server/dist/objects/index.js +4 -6
  13. package/server/dist/objects/runner.js +20 -0
  14. package/server/dist/objects/supervisor.js +2 -2
  15. package/server/dist/providers/claude.js +13 -1
  16. package/server/dist/providers/opencode-server.js +59 -0
  17. package/server/dist/providers/opencode.js +4 -1
  18. package/server/dist/stats.js +15 -3
  19. package/web/.next/BUILD_ID +1 -1
  20. package/web/.next/app-build-manifest.json +80 -71
  21. package/web/.next/app-path-routes-manifest.json +6 -5
  22. package/web/.next/build-manifest.json +2 -2
  23. package/web/.next/prerender-manifest.json +73 -49
  24. package/web/.next/routes-manifest.json +6 -0
  25. package/web/.next/server/app/_not-found/page.js +1 -1
  26. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  27. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  28. package/web/.next/server/app/_not-found.html +1 -1
  29. package/web/.next/server/app/_not-found.rsc +3 -3
  30. package/web/.next/server/app/agents/[id]/page.js +4 -4
  31. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  32. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  33. package/web/.next/server/app/agents/page.js +1 -1
  34. package/web/.next/server/app/agents/page.js.nft.json +1 -1
  35. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  36. package/web/.next/server/app/agents.html +1 -1
  37. package/web/.next/server/app/agents.rsc +4 -4
  38. package/web/.next/server/app/chat/page.js +2 -0
  39. package/web/.next/server/app/chat/page.js.nft.json +1 -0
  40. package/web/.next/server/app/chat/page_client-reference-manifest.js +1 -0
  41. package/web/.next/server/app/chat.html +1 -0
  42. package/web/.next/server/app/chat.meta +15 -0
  43. package/web/.next/server/app/chat.rsc +25 -0
  44. package/web/.next/server/app/connections/page.js +1 -1
  45. package/web/.next/server/app/connections/page.js.nft.json +1 -1
  46. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  47. package/web/.next/server/app/connections.html +1 -1
  48. package/web/.next/server/app/connections.rsc +4 -4
  49. package/web/.next/server/app/index.html +1 -1
  50. package/web/.next/server/app/index.rsc +4 -4
  51. package/web/.next/server/app/page.js +1 -1
  52. package/web/.next/server/app/page.js.nft.json +1 -1
  53. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  54. package/web/.next/server/app/relations/page.js +2 -2
  55. package/web/.next/server/app/relations/page.js.nft.json +1 -1
  56. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  57. package/web/.next/server/app/relations.html +1 -1
  58. package/web/.next/server/app/relations.rsc +4 -4
  59. package/web/.next/server/app/resources/[id]/page.js +2 -2
  60. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
  61. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
  62. package/web/.next/server/app/resources/page.js +2 -2
  63. package/web/.next/server/app/resources/page.js.nft.json +1 -1
  64. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
  65. package/web/.next/server/app/resources.html +1 -1
  66. package/web/.next/server/app/resources.rsc +4 -4
  67. package/web/.next/server/app/schedules/page.js +1 -1
  68. package/web/.next/server/app/schedules/page.js.nft.json +1 -1
  69. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  70. package/web/.next/server/app/schedules.html +1 -1
  71. package/web/.next/server/app/schedules.rsc +4 -4
  72. package/web/.next/server/app/sessions/page.js +2 -2
  73. package/web/.next/server/app/sessions/page.js.nft.json +1 -1
  74. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  75. package/web/.next/server/app/sessions.html +1 -1
  76. package/web/.next/server/app/sessions.rsc +4 -4
  77. package/web/.next/server/app/skills/page.js +1 -1
  78. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  79. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  80. package/web/.next/server/app/skills.html +1 -1
  81. package/web/.next/server/app/skills.rsc +4 -4
  82. package/web/.next/server/app/types/page.js +1 -1
  83. package/web/.next/server/app/types/page.js.nft.json +1 -1
  84. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  85. package/web/.next/server/app/types.html +1 -1
  86. package/web/.next/server/app/types.rsc +4 -4
  87. package/web/.next/server/app-paths-manifest.json +6 -5
  88. package/web/.next/server/chunks/143.js +1 -1
  89. package/web/.next/server/chunks/148.js +1 -0
  90. package/web/.next/server/chunks/213.js +6 -0
  91. package/web/.next/server/chunks/274.js +1 -1
  92. package/web/.next/server/chunks/368.js +1 -0
  93. package/web/.next/server/chunks/403.js +1 -0
  94. package/web/.next/server/chunks/{790.js → 435.js} +2 -2
  95. package/web/.next/server/chunks/505.js +1 -6
  96. package/web/.next/server/chunks/612.js +1 -1
  97. package/web/.next/server/chunks/716.js +2 -2
  98. package/web/.next/server/pages/404.html +1 -1
  99. package/web/.next/server/pages/500.html +1 -1
  100. package/web/.next/server/server-reference-manifest.json +1 -1
  101. package/web/.next/static/YT6HM6qmegMJaBMX5QvuP/_buildManifest.js +1 -0
  102. package/web/.next/static/chunks/281-113274e705940a55.js +1 -0
  103. package/web/.next/static/chunks/350-0fe82e622e7a670f.js +1 -0
  104. package/web/.next/static/chunks/391-18768499e741112e.js +1 -0
  105. package/web/.next/static/chunks/517-373a80c8ba432bdc.js +1 -0
  106. package/web/.next/static/chunks/587-8e4d2be01ba7d48f.js +1 -0
  107. package/web/.next/static/chunks/606-c9a19918b02a98d0.js +1 -0
  108. package/web/.next/static/chunks/654-92a63b3c4b412666.js +1 -0
  109. package/web/.next/static/chunks/656-f537149fe28f79aa.js +1 -0
  110. package/web/.next/static/chunks/705-f81face97b1bb1af.js +1 -0
  111. package/web/.next/static/chunks/app/agents/[id]/page-6ed6edb3e74b0ebe.js +1 -0
  112. package/web/.next/static/chunks/app/agents/{page-f4c4c80f955f3967.js → page-9bb8cba69776c719.js} +1 -1
  113. package/web/.next/static/chunks/app/chat/page-5261b12b7d50f5d1.js +1 -0
  114. package/web/.next/static/chunks/app/connections/{page-0936beaf02d863c6.js → page-eb11cfb1ffeab3ca.js} +1 -1
  115. package/web/.next/static/chunks/app/layout-fad968a635f9a4b3.js +1 -0
  116. package/web/.next/static/chunks/app/page-99e0351e6ccaa384.js +1 -0
  117. package/web/.next/static/chunks/app/relations/{page-fba25393c8688714.js → page-a44fd515a3b0525e.js} +1 -1
  118. package/web/.next/static/chunks/app/resources/[id]/{page-d110d89bb8b5fca7.js → page-fc494e85b01e8cb7.js} +1 -1
  119. package/web/.next/static/chunks/app/resources/{page-bbd0b450d3f3131d.js → page-61cccd8fdcc2f6c8.js} +1 -1
  120. package/web/.next/static/chunks/app/schedules/{page-a1124397fc760413.js → page-96976fff4ee23538.js} +1 -1
  121. package/web/.next/static/chunks/app/sessions/{page-0e322811b0cde724.js → page-a7534ebd90e982d6.js} +1 -1
  122. package/web/.next/static/chunks/app/skills/{page-22ea0ef89d9f7a13.js → page-bc1acd0663f36129.js} +1 -1
  123. package/web/.next/static/chunks/app/types/{page-18c4e1db2724d41d.js → page-ebd37e220f77c1f3.js} +1 -1
  124. package/web/.next/static/css/582723fcea1f9887.css +1 -0
  125. package/web/.next/trace +30 -29
  126. package/web/.next/types/app/chat/page.ts +84 -0
  127. package/web/.next/types/routes.d.ts +2 -1
  128. package/web/.next/types/validator.ts +9 -0
  129. package/web/.next/server/chunks/306.js +0 -1
  130. package/web/.next/server/chunks/555.js +0 -1
  131. package/web/.next/server/chunks/638.js +0 -1
  132. package/web/.next/server/chunks/802.js +0 -1
  133. package/web/.next/static/7BI__-ayGDTlOrSboD_bT/_buildManifest.js +0 -1
  134. package/web/.next/static/chunks/176-aeaf907a6ea5627d.js +0 -1
  135. package/web/.next/static/chunks/291-efae53ea5f7ee92d.js +0 -1
  136. package/web/.next/static/chunks/350-56599dc3bf06066d.js +0 -1
  137. package/web/.next/static/chunks/486-13e08542f3a1cbac.js +0 -1
  138. package/web/.next/static/chunks/491-6b4e6201f5110dff.js +0 -1
  139. package/web/.next/static/chunks/517-ccaf8cc5c733cbd8.js +0 -1
  140. package/web/.next/static/chunks/581-3ad5c4343dad3f50.js +0 -1
  141. package/web/.next/static/chunks/705-c7e75806f77b880c.js +0 -1
  142. package/web/.next/static/chunks/839-4aefe6e71be6e1ef.js +0 -1
  143. package/web/.next/static/chunks/844-fe55292e0701f436.js +0 -1
  144. package/web/.next/static/chunks/app/agents/[id]/page-3faf40800981a736.js +0 -1
  145. package/web/.next/static/chunks/app/layout-99620746d028dda8.js +0 -1
  146. package/web/.next/static/chunks/app/page-a7f292117b7d76bf.js +0 -1
  147. package/web/.next/static/css/b7a03c62468f4263.css +0 -1
  148. /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → YT6HM6qmegMJaBMX5QvuP}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[844],{9217:(e,s,t)=>{t.d(s,{Zp:()=>y,Bh:()=>w,Mr:()=>k,QJ:()=>x,qP:()=>f,Te:()=>C});var l=t(94799),a=t(52974),n=t(34023),r=t(89075),o=t(86606),i=t(3749),d=t(84561),c=t(69654);let m=null;function u(e){let{template:s,values:t,onPick:a,onValue:r}=e,{t:d}=(0,c.s9)(),u=function(){let[e,s]=(0,n.useState)(m);return(0,n.useEffect)(()=>{m||i.FH.get("/object-templates").then(e=>{m=e,s(e)}).catch(()=>s([]))},[]),e}(),h=null==u?void 0:u.find(e=>e.id===s);return u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"tpls",children:u.map(e=>(0,l.jsxs)("button",{type:"button",className:"tpl","aria-pressed":s===e.id,onClick:()=>a(e),children:[(0,l.jsx)("b",{children:e.name}),(0,l.jsx)("small",{children:e.description})]},e.id))}),h&&h.fields.map(e=>{var s;return(0,l.jsx)(o.D0,{label:e.label,children:(0,l.jsx)("input",{className:"input ".concat("text"===e.kind&&"version"!==e.key?"":"mono"),value:null!=(s=t[e.key])?s:"",onChange:s=>r(e.key,s.target.value),placeholder:e.default,inputMode:"port"===e.kind?"numeric":void 0})},"".concat(h.id,"-").concat(e.key))}),h&&(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:d("tpl.note")})]}):(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:d("git.loading")})}var h=t(48538),p=t(74988),b=t(13460),j=t(67056);let v=e=>void 0===e?"":String(e),x=(e,s,t)=>{var l,a,n,r,o,i,d,c,m,u,h,b,j,x,g,f,k,y,N,w,C,S,T,D,R,q,z,A,F,E,M,P,$,_,O,H,I,L,U;let K=(null==e?void 0:e.kind)==="server"?e.config:{},Q=(null==e?void 0:e.kind)==="docker"?e.config:{},B=(null==e?void 0:e.kind)==="http"?e.config:{},W=(null==e?void 0:e.kind)==="cluster"?e.config:{},V=(null==e?void 0:e.kind)==="database"?e.config:{};return{manager:null!=(i=null==e?void 0:e.manager_id)?i:"",name:null!=(d=null==e?void 0:e.name)?d:"",colony_id:null!=(m=null!=(c=null==e?void 0:e.colony_id)?c:s)?m:"",kind:null!=(h=null!=(u=null==e?void 0:e.kind)?u:t)?h:"server",cwd:null!=(b=K.cwd)?b:"",start:null!=(j=K.start)?j:"",stop:null!=(x=K.stop)?x:"",port:v(K.port),env:(0,p.M6)((null==e?void 0:e.kind)==="server"?K.env:Q.env),restart:null!=(g=K.restart)?g:"no",maxRestarts:v(K.maxRestarts),healthKind:null!=(f=null==(l=K.health)?void 0:l.kind)?f:"",healthTarget:null!=(k=null==(a=K.health)?void 0:a.target)?k:"",healthInterval:v(null==(n=K.health)?void 0:n.intervalSec),healthRetries:v(null==(r=K.health)?void 0:r.retries),healthRestart:!!(null==(o=K.health)?void 0:o.restartWhenUnhealthy),stopTimeout:v((null==e?void 0:e.kind)==="server"?K.stopTimeoutSec:Q.stopTimeoutSec),logMax:v((null==e?void 0:e.kind)==="server"?K.logMaxMb:Q.logMaxMb),folder:null!=(y=B.folder)?y:"",defEnv:null!=(N=B.env)?N:"",variables:null!=(w=B.variables)?w:{},members:null!=(C=W.members)?C:[],template:"",tplValues:{},mode:null!=(S=Q.mode)?S:e?"container":"template",image:null!=(T=Q.image)?T:"",ports:(null!=(D=Q.ports)?D:[]).join("\n"),volumes:(null!=(R=Q.volumes)?R:[]).join("\n"),dockerRestart:null!=(q=Q.restart)?q:"no",command:null!=(z=Q.command)?z:"",file:null!=(A=Q.file)?A:"",project:null!=(F=Q.project)?F:"",services:(null!=(E=Q.services)?E:[]).join(", "),container:null!=(M=Q.container)?M:"",memory:null!=(P=Q.memory)?P:"",cpus:v(Q.cpus),network:null!=($=Q.network)?$:"",engine:null!=(_=V.engine)?_:"postgresql",dbHost:null!=(O=V.host)?O:"",dbPort:v(V.port),dbUser:null!=(H=V.user)?H:"",dbPassword:"",dbPasswordSet:!!V.passwordSet,dbName:null!=(I=V.database)?I:"",dbFile:null!=(L=V.file)?L:"",dbSsl:!!V.ssl,dbTrust:!!V.trustCert,dbReadOnly:!1!==V.readOnly,dbTimeout:v(V.timeoutSec),dbMaxRows:v(V.maxRows),dbProps:{...null!=(U=V.props)?U:{}}}},g=e=>""===e.trim()?void 0:Number(e);function f(e){return"database"===e.kind?k(e):"http"===e.kind?{folder:e.folder.trim(),env:e.defEnv.trim()||void 0,variables:Object.keys(e.variables).length?e.variables:void 0}:"cluster"===e.kind?{members:e.members}:"server"===e.kind?{cwd:e.cwd.trim(),start:e.start.trim(),stop:e.stop.trim()||void 0,port:g(e.port),env:(0,p.y$)(e.env),restart:"no"===e.restart?void 0:e.restart,maxRestarts:g(e.maxRestarts),stopTimeoutSec:g(e.stopTimeout),logMaxMb:g(e.logMax),health:e.healthKind&&e.healthTarget.trim()?{kind:e.healthKind,target:e.healthTarget.trim(),intervalSec:g(e.healthInterval),retries:g(e.healthRetries),restartWhenUnhealthy:e.healthRestart||void 0}:void 0}:"template"===e.mode?{mode:"compose"}:"existing"===e.mode?{mode:"existing",container:e.container.trim(),stopTimeoutSec:g(e.stopTimeout)}:"compose"===e.mode?{mode:"compose",file:e.file.trim(),project:e.project.trim()||void 0,services:e.services.split(",").map(e=>e.trim()).filter(Boolean),stopTimeoutSec:g(e.stopTimeout)}:{mode:"container",image:e.image.trim(),ports:(0,p.Mn)(e.ports),volumes:(0,p.Mn)(e.volumes),env:(0,p.y$)(e.env),restart:e.dockerRestart||"no",command:e.command.trim()||void 0,memory:e.memory.trim()||void 0,cpus:g(e.cpus),network:e.network.trim()||void 0,stopTimeoutSec:g(e.stopTimeout),logMaxMb:g(e.logMax)}}let k=e=>{let s=Object.entries(e.dbProps).filter(s=>{let[t,l]=s;return""!==l.trim()&&(e.dbSsl||!t.startsWith("ssl."))}),t=s.length?Object.fromEntries(s):void 0;return"sqlite"===e.engine?{engine:"sqlite",file:e.dbFile.trim(),props:t,readOnly:e.dbReadOnly,timeoutSec:g(e.dbTimeout),maxRows:g(e.dbMaxRows)}:{engine:e.engine,host:e.dbHost.trim()||void 0,port:g(e.dbPort),user:e.dbUser.trim()||void 0,password:e.dbPassword,database:e.dbName.trim()||void 0,ssl:e.dbSsl||void 0,trustCert:!!e.dbSsl&&!!e.dbTrust||void 0,props:t,readOnly:e.dbReadOnly,timeoutSec:g(e.dbTimeout),maxRows:g(e.dbMaxRows)}},y=e=>{let{title:s,hint:t,wide:a=!1,children:n}=e;return(0,l.jsxs)("section",{className:"of-card ".concat(a?"wide":""),id:"of-".concat(s.toLowerCase().normalize("NFD").replace(/[^a-z0-9]+/g,"-")),"data-title":s,children:[(0,l.jsxs)("header",{children:[(0,l.jsx)("h4",{children:s}),t&&(0,l.jsx)("p",{className:"muted small",children:t})]}),n]})};function N(e){let{file:s,project:t,services:a,onServices:r,onProject:d}=e,{t:m}=(0,c.s9)(),{info:u,err:h,loading:p}=function(e){let[s,t]=(0,n.useState)(null),[l,a]=(0,n.useState)(""),[r,o]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(a(""),!/^\/.+\.ya?ml$/i.test(e))return void t(null);let s=!1;o(!0);let l=setTimeout(()=>i.FH.get("/docker/compose-services?file=".concat(encodeURIComponent(e))).then(e=>!s&&t(e)).catch(e=>{s||(t(null),a(e instanceof Error?e.message:""))}).finally(()=>!s&&o(!1)),300);return()=>{s=!0,clearTimeout(l)}},[e]),{info:s,err:l,loading:r}}(s),b=new Set(a.split(",").map(e=>e.trim()).filter(Boolean));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.D0,{label:m("obj.f.services"),hint:m("dk.services.hint"),children:s?p?(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.loading")}):h?(0,l.jsx)("p",{className:"gx-note err res-m0",children:h}):u&&0===u.services.length?(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.none")}):u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"chips",children:u.services.map(e=>(0,l.jsx)("button",{type:"button",className:"chip-pick ".concat(b.has(e)?"on":""),"aria-pressed":b.has(e),onClick:()=>(e=>{let s=new Set(b);s.has(e)?s.delete(e):s.add(e),r([...s].join(", "))})(e),children:e},e))}),"file"===u.source&&(0,l.jsx)("p",{className:"muted small res-mt6",children:m("dk.services.file")})]}):null:(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.pickFile")})}),(0,l.jsx)(o.D0,{label:m("obj.f.project"),hint:m("dk.project.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("input",{className:"input mono",value:t,onChange:e=>d(e.target.value),placeholder:null==u?void 0:u.project}),u&&!t&&(0,l.jsx)("button",{type:"button",className:"btn sm",onClick:()=>d(u.project),children:m("dk.project.use",{name:u.project})})]})})]})}function w(e){var s,t,m;let{d:v,set:x,setD:g,scan:f,showKind:k=!1,error:w,objectId:C}=e,{t:S}=(0,c.s9)(),{colonies:T,objects:D}=(0,h.o0)(),R=function(e){let[s,t]=(0,n.useState)(null),[l,a]=(0,n.useState)(null),[r,o]=(0,n.useState)(""),[d,c]=(0,n.useState)(0);return(0,n.useEffect)(()=>{if(!e)return;let s=!1;return i.FH.get("/docker/containers").then(e=>{var l;s||(t(e.containers),o(e.available?"":null!=(l=e.error)?l:"unavailable"))}).catch(()=>!s&&o("unavailable")),i.FH.get("/docker/images").then(e=>!s&&a(e.images)).catch(()=>void 0),()=>{s=!0}},[e,d]),{containers:s,images:l,error:r,reload:(0,n.useCallback)(()=>c(e=>e+1),[])}}("docker"===v.kind&&("existing"===v.mode||"container"===v.mode)),q=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,l.jsx)("input",{className:"input ".concat(s.mono?"mono":""),type:s.type,value:v[e],placeholder:s.placeholder,onChange:s=>x(e,s.target.value)})},z=R.error?(0,l.jsx)("p",{className:"muted small res-mt4",children:S("dk.unavailable",{error:R.error})}):null,A=(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:R.reload,"aria-label":S("dk.refresh"),title:S("dk.refresh"),children:(0,l.jsx)(r.A,{size:14})}),F=f?Object.keys(f.fileVars).filter(e=>"$shared"!==e):void 0,E=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.dR,{value:v.folder,onChange:e=>x("folder",e),label:S("obj.f.httpFolder"),hint:S("obj.f.httpFolder.hint")}),(0,l.jsx)(o.D0,{label:S("obj.f.defaultEnv"),hint:S("obj.f.defaultEnv.hint"),children:(0,l.jsx)(d.b,{value:v.defEnv,onChange:e=>x("defEnv",e),mono:!0,placeholder:"dev",options:[...new Set([...null!=(s=null==f?void 0:f.environments)?s:[],...Object.keys(v.variables).filter(e=>"$shared"!==e)])].map(e=>({value:e}))})})]});return(0,l.jsxs)("div",{className:"of",children:[k&&(0,l.jsx)(y,{title:S("obj.kind.pick"),wide:!0,children:(0,l.jsx)("div",{className:"okinds",children:["server","docker","http","database","cluster"].map(e=>{let{icon:s,color:t}=p.Nd[e];return(0,l.jsxs)("button",{type:"button",className:"okind","aria-pressed":v.kind===e,style:{"--c":t},onClick:()=>x("kind",e),children:[(0,l.jsx)(s,{size:20}),(0,l.jsx)("b",{children:S("obj.kind.".concat(e))}),(0,l.jsx)("small",{children:S("obj.kind.".concat(e,".hint"))})]},e)})})}),(0,l.jsxs)(y,{title:S("of.general"),children:[(0,l.jsx)(o.D0,{label:S("obj.f.name"),error:w,children:q("name",{placeholder:"database"===v.kind?(0,j.I5)(v):void 0})}),(0,l.jsx)(o.D0,{label:S("obj.colony"),children:(0,l.jsxs)("select",{className:"select",value:v.colony_id,onChange:e=>g(s=>({...s,colony_id:e.target.value,members:[]})),children:[(0,l.jsx)("option",{value:"",children:S("obj.noColony")}),T.map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]})}),a.G.includes(v.kind)&&(0,l.jsx)(a.I,{value:v.manager,onChange:e=>x("manager",e)}),"http"===v.kind&&!k&&E]}),"http"===v.kind?(0,l.jsxs)(l.Fragment,{children:[k&&(0,l.jsx)(y,{title:S("of.files"),children:E}),k&&(0,l.jsx)(y,{title:S("of.vars"),wide:!0,children:(0,l.jsx)(b.W,{value:v.variables,onChange:e=>x("variables",e),fileEnvs:F,fileVars:null==f?void 0:f.fileVars,used:null==f?void 0:f.used,fileDefined:null==f?void 0:f.fileDefined,setBy:null==f?void 0:f.setBy})})]}):"database"===v.kind?(0,l.jsx)(j.dN,{d:v,set:x,setD:g,objectId:C,creating:k}):"cluster"===v.kind?(0,l.jsx)(y,{title:S("of.members"),hint:S("obj.f.members.hint"),children:(()=>{let e=D.filter(e=>{var s;return("server"===e.kind||"docker"===e.kind)&&(null!=(s=e.colony_id)?s:"")===v.colony_id});return e.length?(0,l.jsx)("div",{className:"omembers",children:e.map(e=>{let{icon:s,color:t}=p.Nd[e.kind],a=v.members.indexOf(e.id);return(0,l.jsxs)("label",{className:"omember",children:[(0,l.jsx)("input",{type:"checkbox",checked:a>=0,onChange:()=>{let s;return s=e.id,x("members",v.members.includes(s)?v.members.filter(e=>e!==s):[...v.members,s])}}),(0,l.jsx)(s,{size:15,style:{color:t}}),(0,l.jsx)("span",{className:"nm",children:e.name}),a>=0&&(0,l.jsx)("span",{className:"ord",children:a+1})]},e.id)})}):(0,l.jsx)("p",{className:"muted small res-m0",children:S("obj.f.members.none")})})()}):"server"===v.kind?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(y,{title:S("of.run"),children:[(0,l.jsx)(o.dR,{value:v.cwd,onChange:e=>x("cwd",e),label:S("obj.f.folder"),hint:S("obj.f.folder.hint")}),(0,l.jsx)(o.D0,{label:S("obj.f.start"),hint:S("obj.f.start.hint"),children:q("start",{placeholder:"npm run dev",mono:!0})}),(0,l.jsx)(o.D0,{label:S("obj.f.stop"),hint:S("obj.f.stop.hint"),children:q("stop",{mono:!0})}),(0,l.jsx)(o.D0,{label:S("obj.f.port"),hint:S("obj.f.port.hint"),children:q("port",{placeholder:"3000"})})]}),(0,l.jsx)(y,{title:S("of.env"),children:(0,l.jsx)(o.D0,{label:S("obj.f.env"),hint:S("obj.f.env.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:5,value:v.env,onChange:e=>x("env",e.target.value)})})}),(0,l.jsxs)(y,{title:S("obj.sup.title"),hint:S("obj.sup.note"),children:[(0,l.jsx)(o.D0,{label:S("obj.sup.restart"),hint:S("obj.sup.restart.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("select",{className:"select",value:v.restart,onChange:e=>x("restart",e.target.value),children:[(0,l.jsx)("option",{value:"no",children:S("obj.sup.restart.no")}),(0,l.jsx)("option",{value:"on-failure",children:S("obj.sup.restart.fail")}),(0,l.jsx)("option",{value:"always",children:S("obj.sup.restart.always")})]}),"no"!==v.restart&&(0,l.jsx)("input",{className:"input res-mw130",value:v.maxRestarts,placeholder:S("obj.sup.max"),onChange:e=>x("maxRestarts",e.target.value),title:S("obj.sup.max.hint"),"aria-label":S("obj.sup.max")})]})}),(0,l.jsxs)(o.D0,{label:S("obj.sup.health"),hint:S("obj.sup.health.hint"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("select",{className:"select res-mw170",value:v.healthKind,onChange:e=>x("healthKind",e.target.value),children:[(0,l.jsx)("option",{value:"",children:S("obj.sup.health.none")}),(0,l.jsx)("option",{value:"http",children:"HTTP"}),(0,l.jsx)("option",{value:"tcp",children:S("obj.sup.health.tcp")}),(0,l.jsx)("option",{value:"command",children:S("obj.sup.health.command")})]}),v.healthKind&&(0,l.jsx)("input",{className:"input mono grow",value:v.healthTarget,onChange:e=>x("healthTarget",e.target.value),placeholder:"http"===v.healthKind?"http://127.0.0.1:3000/health":"tcp"===v.healthKind?"3000":"curl -fs localhost:3000","aria-label":S("obj.sup.health")})]}),v.healthKind&&(0,l.jsxs)("div",{className:"row gap-s wrap res-mt8",children:[(0,l.jsx)("input",{className:"input res-mw150",value:v.healthInterval,onChange:e=>x("healthInterval",e.target.value),placeholder:S("obj.sup.interval"),"aria-label":S("obj.sup.interval")}),(0,l.jsx)("input",{className:"input res-mw130",value:v.healthRetries,onChange:e=>x("healthRetries",e.target.value),placeholder:S("obj.sup.retries"),"aria-label":S("obj.sup.retries")}),(0,l.jsx)(o.Tl,{checked:v.healthRestart,onChange:e=>x("healthRestart",e),label:S("obj.sup.healthRestart")})]})]}),(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"8"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.logMax"),hint:S("obj.sup.logMax.hint"),children:q("logMax",{placeholder:"5"})})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(y,{title:S("obj.f.mode"),children:(0,l.jsx)(o.$q,{value:v.mode,onChange:e=>x("mode",e),options:[...k?[{id:"template",label:S("obj.mode.template")}]:[],{id:"container",label:S("obj.mode.container")},{id:"compose",label:S("obj.mode.compose")},{id:"existing",label:S("obj.mode.existing")}]})}),"template"===v.mode&&(0,l.jsx)(y,{title:S("obj.mode.template"),hint:S("tpl.hint"),children:(0,l.jsx)(u,{template:v.template,values:v.tplValues,onPick:e=>g(s=>({...s,template:e.id,tplValues:Object.fromEntries(e.fields.map(e=>[e.key,e.default])),name:s.name.trim()?s.name:e.name})),onValue:(e,s)=>g(t=>({...t,tplValues:{...t.tplValues,[e]:s}}))})}),"container"===v.mode&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(y,{title:S("of.image"),children:[(0,l.jsxs)(o.D0,{label:S("obj.f.image"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(d.b,{value:v.image,onChange:e=>x("image",e),mono:!0,placeholder:S("dk.pickImage"),ariaLabel:S("obj.f.image"),options:(null!=(t=R.images)?t:[]).map(e=>({value:e.ref,hint:"".concat(e.size).concat(e.created?" \xb7 ".concat(e.created):"")}))})}),A]}),z]}),(0,l.jsx)(o.D0,{label:S("obj.f.ports"),hint:S("obj.f.ports.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:2,value:v.ports,onChange:e=>x("ports",e.target.value),placeholder:"8080:80"})}),(0,l.jsxs)(o.D0,{label:S("obj.f.volumes"),hint:S("obj.f.volumes.hint"),children:[(0,l.jsx)("textarea",{className:"textarea mono",rows:2,value:v.volumes,onChange:e=>x("volumes",e.target.value)}),(0,l.jsx)(o.yQ,{bare:!0,value:"",buttonLabel:S("obj.f.volumes.add"),onChange:e=>x("volumes","".concat(v.volumes.trimEnd()).concat(v.volumes.trim()?"\n":"").concat(e,":/data"))})]})]}),(0,l.jsxs)(y,{title:S("of.env"),children:[(0,l.jsx)(o.D0,{label:S("obj.f.env"),hint:S("obj.f.env.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:4,value:v.env,onChange:e=>x("env",e.target.value)})}),(0,l.jsx)(o.D0,{label:S("obj.f.restart"),children:(0,l.jsx)("select",{className:"select",value:v.dockerRestart,onChange:e=>x("dockerRestart",e.target.value),children:["no","always","unless-stopped","on-failure"].map(e=>(0,l.jsx)("option",{value:e,children:e},e))})}),(0,l.jsx)(o.D0,{label:S("obj.f.command"),children:q("command",{mono:!0})})]}),(0,l.jsx)(y,{title:S("of.limits"),hint:S("obj.dk.limits.hint"),children:(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(o.D0,{label:S("obj.dk.memory"),children:q("memory",{placeholder:"512m"})}),(0,l.jsx)(o.D0,{label:S("obj.dk.cpus"),children:q("cpus",{placeholder:"1.5"})}),(0,l.jsx)(o.D0,{label:S("obj.dk.network"),children:q("network",{placeholder:"bridge"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),children:q("stopTimeout",{placeholder:"10"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.logMax"),children:q("logMax",{placeholder:"10"})})]})})]}),"compose"===v.mode&&(0,l.jsxs)(y,{title:S("obj.mode.compose"),children:[(0,l.jsx)(o.yQ,{mode:"file",exts:["yml","yaml"],value:v.file,onChange:e=>x("file",e),label:S("obj.f.file"),hint:S("obj.f.file.hint"),placeholder:"/home/you/app/docker-compose.yml"}),(0,l.jsx)(N,{file:v.file,project:v.project,services:v.services,onServices:e=>x("services",e),onProject:e=>x("project",e)}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"10"})})]}),"existing"===v.mode&&(0,l.jsxs)(y,{title:S("obj.mode.existing"),children:[(0,l.jsxs)(o.D0,{label:S("obj.f.container"),hint:S("obj.f.container.hint"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(d.b,{value:v.container,onChange:e=>x("container",e),mono:!0,placeholder:S("dk.pickContainer"),ariaLabel:S("obj.f.container"),options:(null!=(m=R.containers)?m:[]).map(e=>({value:e.name,hint:"".concat(e.image," \xb7 ").concat(e.state).concat(e.managed?" \xb7 ".concat(S("dk.managed")):"")}))})}),A]}),z]}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"10"})})]})]})]})}function C(e){let[s,t]=(0,n.useState)(e);return{d:s,setD:t,set:(e,s)=>t(t=>({...t,[e]:s}))}}},13460:(e,s,t)=>{t.d(s,{W:()=>b});var l=t(94799),a=t(34023),n=t(92947),r=t(2432),o=t(58960),i=t(7168),d=t(97356),c=t(70665),m=t(42366),u=t(69654),h=t(84561);let p="$shared";function b(e){var s,t,b;let{value:j,onChange:v,fileEnvs:x=[],fileVars:g={},used:f=[],fileDefined:k=[],setBy:y={}}=e,{t:N}=(0,u.s9)(),w=[p,...[...new Set([...Object.keys(j),...x])].filter(e=>e!==p).sort()],[C,S]=(0,a.useState)(()=>{var e;return null!=(e=w.find(e=>{var s;return e!==p&&Object.keys(null!=(s=j[e])?s:{}).length>0}))?e:w[0]}),[T,D]=(0,a.useState)(""),[R,q]=(0,a.useState)({}),z=null!=(s=j[C])?s:{},A=new Set([...C!==p&&null!=(t=g[p])?t:[],...null!=(b=g[C])?b:[]]),F=f.filter(e=>!(e.name in z)).map(e=>({value:e.name,hint:N("vars.used.count",{count:e.count})})),E=(e,s,t)=>{if(void 0!==t&&t!==e&&t in z)return;let l=Object.entries(z).map(l=>{let[a,n]=l;return a===e?[null!=t?t:a,{...n,...s}]:[a,n]});v({...j,[C]:Object.fromEntries(l)})},M=()=>{let e=T.trim();!/^[\w.$-]{1,60}$/.test(e)||e in j||e===p||(v({...j,[e]:{}}),S(e),D(""))};return(0,l.jsxs)("div",{className:"vars",children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("b",{children:N("ow.tab.vars")}),(0,l.jsxs)(m.B,{size:"sm",label:N("common.help"),title:N("vars.how.title"),children:[(0,l.jsx)("p",{children:N("vars.hint")}),(0,l.jsx)("p",{children:N("vars.how.1")}),(0,l.jsx)("p",{children:N("vars.how.2")}),(0,l.jsx)("p",{children:N("vars.note")})]})]}),(0,l.jsxs)("div",{className:"vars-envs",role:"tablist",children:[w.map(e=>(0,l.jsxs)("button",{type:"button",role:"tab","aria-selected":C===e,className:"vars-env ".concat(C===e?"on":""),onClick:()=>S(e),title:e===p?N("vars.all.hint"):void 0,children:[e===p?N("vars.all"):e,x.includes(e)&&(0,l.jsx)("i",{className:"vars-file",title:N("vars.fromFile"),children:"\xb7"})]},e)),(0,l.jsxs)("span",{className:"vars-add",children:[(0,l.jsx)("input",{className:"input",placeholder:N("vars.newEnv"),value:T,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),M())},"aria-label":N("vars.newEnv")}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:M,disabled:!T.trim(),"aria-label":N("vars.newEnv"),children:(0,l.jsx)(n.A,{size:14})})]})]}),(0,l.jsx)("p",{className:"muted small vars-scope",children:C===p?N("vars.scope.all"):N("vars.scope.env",{env:C})}),(0,l.jsxs)("div",{className:"vars-table",children:[0===Object.keys(z).length&&(0,l.jsx)("p",{className:"muted small",style:{margin:"4px 2px"},children:N("vars.empty")}),Object.entries(z).map((e,s)=>{let[t,a]=e,n="".concat(C,"/").concat(s),c=a.secret&&!R[n];return(0,l.jsxs)("div",{className:"vars-row",children:[(0,l.jsx)(h.b,{value:t,onChange:e=>E(t,{},e.trim()),options:F,mono:!0,placeholder:N("vars.name"),ariaLabel:N("vars.name")}),(0,l.jsx)("input",{className:"input mono",type:c?"password":"text",value:a.value,onChange:e=>E(t,{value:e.target.value}),"aria-label":N("vars.value"),placeholder:a.secret&&a.set&&!a.value?N("vars.saved"):N("vars.value"),autoComplete:"off"}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm ".concat(a.secret?"on":""),"aria-pressed":!!a.secret,onClick:()=>E(t,{secret:!a.secret}),"aria-label":N("vars.secret"),title:N("vars.secret.hint"),children:(0,l.jsx)(r.A,{size:14})}),a.secret?(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>q(e=>({...e,[n]:!e[n]})),"aria-label":N("vars.show"),title:N("vars.show"),children:R[n]?(0,l.jsx)(o.A,{size:14}):(0,l.jsx)(i.A,{size:14})}):(0,l.jsx)("span",{}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>(e=>{let s={...z};delete s[e],v({...j,[C]:s})})(t),"aria-label":N("common.delete"),children:(0,l.jsx)(d.A,{size:14})}),A.has(t)&&(0,l.jsx)("span",{className:"vars-note",children:N("vars.overridden")})]},"".concat(C,":").concat(s))})]}),(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("button",{type:"button",className:"btn sm",onClick:()=>(e=>{let s=null!=e?e:"name",t=1;for(;s in z;)s="".concat(null!=e?e:"name").concat(++t);v({...j,[C]:{...z,[s]:{value:""}}})})(),children:[(0,l.jsx)(n.A,{size:14}),N("vars.add")]}),C!==p&&!x.includes(C)&&(0,l.jsxs)("button",{type:"button",className:"btn ghost sm",onClick:()=>{let e={...j};delete e[C],v(e),S(p)},children:[(0,l.jsx)(c.A,{size:14}),N("vars.delEnv")]})]})]})}},31606:(e,s,t)=>{t.d(s,{md:()=>E,wl:()=>P});var l=t(94799),a=t(20422),n=t(34023),r=t(41463),o=t.n(r),i=t(66654),d=t(70665),c=t(7991),m=t(66826),u=t(2432),h=t(32335),p=t(59959),b=t(73885),j=t(47405),v=t(83372),x=t(6673),g=t(19431),f=t(33691),k=t(26701),y=t(5372),N=t(3749),w=t(69654),C=t(47890),S=t(86606),T=t(28941),D=t(48538),R=t(42162),q=t(1517),z=t(74988),A=t(75010);let F={mysql:"MySQL / MariaDB",postgresql:"PostgreSQL",sqlite:"SQLite",mssql:"SQL Server"};function E(e){let{status:s,className:t=""}=e;return(0,l.jsx)("i",{className:"odot ".concat(z.Wy[s]," ").concat(t),"aria-hidden":!0})}function M(e){var s,t,l,a;if("server"===e.kind)return e.config.start;if("http"===e.kind)return(0,C._1)(e.config.folder);if("database"===e.kind){let t=e.config;return"sqlite"===t.engine?(0,C._1)(null!=(s=t.file)?s:""):"".concat(t.host||"127.0.0.1").concat(t.port?":".concat(t.port):"").concat(t.database?"/".concat(t.database):"")}if("cluster"===e.kind)return"".concat(e.config.members.length);let n=e.config;return"container"===n.mode?null!=(t=n.image)?t:"":"compose"===n.mode?(0,C._1)(null!=(l=n.file)?l:""):null!=(a=n.container)?a:""}function P(e){let{object:s,target:t,onClose:r,onCreateManager:P}=e,{t:$}=(0,w.s9)(),{agents:_,objects:O,colonies:H}=(0,D.o0)(),I=(0,R.n)(),L="server"===s.kind||"docker"===s.kind&&"compose"!==s.config.mode,U=s.manager_id?_.filter(e=>e.id===s.manager_id):_.filter(e=>{var t,l;return e.skill_ids.includes(q.t)&&(null!=(t=e.colony_id)?t:null)===(null!=(l=s.colony_id)?l:null)}),[K,Q]=(0,n.useState)(!1),{refresh:B}=(0,D.o0)(),W=async e=>{try{await N.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:e}),await B(["objects","agents"]),Q(!1)}catch(e){V(e instanceof Error?e.message:"","err")}},V=(0,S.dj)(),[Z,G]=(0,n.useState)(null),{icon:J,color:X}=z.Nd[s.kind],Y=s.state.status,ee=async e=>{G(e);try{await N.FH.post("/objects/".concat(s.id,"/action"),{action:e})}catch(s){V("".concat($("obj.act.failed",{action:$("obj.act.".concat(e))}),": ").concat(s instanceof Error?s.message:""),"err")}finally{G(null)}},es="running"===Y||"starting"===Y,et=async()=>{G("test");try{let e=await N.FH.post("/object-db/test",{id:s.id,config:s.config});V("".concat($("db.test.ok")," \xb7 ").concat(e.version," \xb7 ").concat(e.ms," ms"))}catch(e){V(e instanceof Error?e.message:"","err")}finally{G(null)}},el="cluster"===s.kind?s.config.members.map(e=>O.find(s=>s.id===e)).filter(e=>!!e):[];return(0,l.jsx)(y.rs,{target:t,pinned:!0,width:380,label:s.name,onClose:r,children:(0,l.jsxs)("div",{className:"col obj-panel res-gap12",children:[(0,l.jsxs)("div",{className:"ap-corner row gap-s",children:[(0,l.jsx)(o(),{className:"btn ghost icon sm",href:"/resources/".concat(s.id,"?tab=config"),"aria-label":$("obj.act.edit"),title:$("obj.act.edit"),children:(0,l.jsx)(i.A,{size:15})}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:r,"aria-label":$("common.close"),title:"".concat($("common.close")," (Esc)"),children:(0,l.jsx)(d.A,{size:16})})]}),(0,l.jsxs)("div",{className:"row gap-l res-pr70",children:[(0,l.jsx)("span",{className:"obj-ico",style:{"--c":X},children:(0,l.jsx)(J,{size:22})}),(0,l.jsxs)("div",{className:"grow res-minw0",children:[(0,l.jsx)("h2",{className:"res-h2",children:s.name}),(0,l.jsxs)("div",{className:"row gap-s wrap res-mt4",children:[(0,l.jsxs)("span",{className:"ostatus ".concat(z.Wy[Y]),children:[(0,l.jsx)(E,{status:Y}),$("obj.status.".concat(Y))]}),(0,l.jsx)("span",{className:"muted small",children:$("obj.kind.".concat(s.kind))})]})]})]}),(s.state.detail||s.state.since)&&(0,l.jsx)("p",{className:"muted small res-m0",children:[(0,z.HS)($,s.state.detail),s.state.since&&es?$("obj.since",{time:(0,C.KN)(s.state.since)}):"",s.state.pid?$("obj.pid",{pid:s.state.pid}):""].filter(Boolean).join(" \xb7 ")}),(0,l.jsxs)(o(),{className:"btn primary",href:"/resources/".concat(s.id),children:[(0,l.jsx)(c.A,{size:15}),$("obj.open")]}),"cluster"!==s.kind&&(0,l.jsx)("div",{className:"mono small obj-cmd",title:M(s),children:M(s)}),"database"===s.kind&&(0,l.jsxs)("div",{className:"row gap-s wrap",children:[(0,l.jsxs)("span",{className:"db-badge",children:[(0,l.jsx)(m.A,{size:12}),F[s.config.engine]]}),!1!==s.config.readOnly?(0,l.jsxs)("span",{className:"db-badge ro",children:[(0,l.jsx)(u.A,{size:12}),$("db.readonly.badge")]}):(0,l.jsxs)("span",{className:"db-badge rw",children:[(0,l.jsx)(h.A,{size:12}),$("db.write.badge")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z,onClick:()=>void et(),children:["test"===Z?(0,l.jsx)(p.A,{size:14,className:"spin"}):(0,l.jsx)(b.A,{size:14}),$("db.test")]})]}),"http"===s.kind||"database"===s.kind?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row gap-s wrap",children:[(0,l.jsxs)("button",{className:"btn primary sm",disabled:!!Z||("cluster"===s.kind?"running"===Y:es),onClick:()=>void ee("start"),children:[(0,l.jsx)(j.A,{size:14}),$("cluster"===s.kind?"obj.act.startAll":"obj.act.start")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z||!es&&"error"!==Y&&!("cluster"===s.kind&&el.some(e=>"running"===e.state.status)),onClick:()=>void ee("stop"),children:[(0,l.jsx)(v.A,{size:14}),$("cluster"===s.kind?"obj.act.stopAll":"obj.act.stop")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z,onClick:()=>void ee("restart"),children:[(0,l.jsx)(x.A,{size:14}),$("cluster"===s.kind?"obj.act.restartAll":"obj.act.restart")]})]}),"cluster"===s.kind&&(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.members")}),el.length?(0,l.jsx)("div",{className:"col res-gap4",children:el.map((e,s)=>(0,l.jsxs)("div",{className:"row gap-s small",children:[(0,l.jsx)("span",{className:"ord",children:s+1}),(0,l.jsx)(E,{status:e.state.status}),(0,l.jsx)("b",{className:"grow ellipsis",children:e.name}),(0,l.jsx)("span",{className:"muted",children:$("obj.status.".concat(e.state.status))})]},e.id))}):(0,l.jsx)("p",{className:"muted small res-m0",children:$("obj.members.empty")})]}),(0,l.jsxs)("div",{className:"row gap-s wrap",children:[L&&(0,l.jsx)(a.N,{spec:{objectId:s.id},label:"server"===s.kind?$("dock.here"):$("dock.shell")}),(0,l.jsxs)("button",{className:"btn sm",onClick:()=>I.openLogs(s.id,s.name),children:[(0,l.jsx)(g.A,{size:14}),$("dock.logs")]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.logs")}),(0,l.jsx)(A.I,{id:s.id})]})]}),"http"!==s.kind&&"database"!==s.kind&&(0,l.jsxs)("div",{className:"obj-managers",children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.managers")}),U.length?(0,l.jsx)("div",{className:"row gap-s wrap",children:U.map(e=>(0,l.jsxs)("span",{className:"chip ps-chip",children:[(0,l.jsxs)(o(),{href:"/agents/".concat(e.id),title:"plan"===e.permission?$("obj.managers.readonly"):void 0,children:[e.name,"plan"===e.permission?" \xb7 ".concat($("obj.managers.ro")):""]}),s.manager_id===e.id&&(0,l.jsx)("button",{type:"button",onClick:()=>void W(null),"aria-label":$("obj.managers.remove"),title:$("obj.managers.remove"),children:(0,l.jsx)(d.A,{size:12})})]},e.id))}):(0,l.jsx)("p",{className:"muted small res-m0",children:$("obj.managers.none")}),s.manager_id&&(0,l.jsx)("p",{className:"muted small res-mt6",children:$("obj.managers.only")}),(0,l.jsxs)("div",{className:"row gap-s wrap res-mt8",children:[(0,l.jsxs)("button",{className:"btn sm",onClick:P,children:[(0,l.jsx)(f.A,{size:14}),$("obj.managers.create")]}),(0,l.jsxs)("button",{className:"btn sm","aria-pressed":K,onClick:()=>Q(e=>!e),children:[(0,l.jsx)(k.A,{size:14}),$("obj.managers.add")]})]}),K&&(0,l.jsx)("div",{className:"res-mt8",children:(0,l.jsx)(T.c,{inline:!0,autoFocus:!0,options:_.filter(e=>e.id!==s.manager_id).map(e=>{var s,t;return{id:e.id,label:e.name,hint:null!=(t=null==(s=H.find(s=>s.id===e.colony_id))?void 0:s.name)?t:$("common.noColony")}}),value:[],onChange:e=>e[0]&&void W(e[0]),placeholder:$("obj.manager.placeholder"),empty:$("obj.manager.empty"),ariaLabel:$("obj.managers.add")})})]})]})})}},42366:(e,s,t)=>{t.d(s,{B:()=>o});var l=t(94799),a=t(34023),n=t(34265),r=t(21018);function o(e){let{label:s,title:t,children:o,size:i="md",align:d="start"}=e,[c,m]=(0,a.useState)(!1),u=(0,a.useRef)(null),h=(0,a.useRef)(null),p=(0,a.useId)();return(0,r.s)(c,u,()=>m(!1),()=>{var e;return null==(e=h.current)?void 0:e.focus()}),(0,l.jsxs)("span",{className:"help ".concat("sm"===i?"sm":""," ").concat("end"===d?"end":""),ref:u,children:[(0,l.jsx)("button",{ref:h,type:"button",className:"help-btn","aria-label":s,title:s,"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":c?p:void 0,onClick:()=>m(e=>!e),children:(0,l.jsx)(n.A,{size:"sm"===i?15:18})}),c&&(0,l.jsxs)("div",{id:p,role:"dialog","aria-label":t,className:"help-pop",children:[(0,l.jsx)("div",{className:"eyebrow",children:t}),(0,l.jsx)("div",{className:"muted small help-body",children:o})]})]})}},67056:(e,s,t)=>{t.d(s,{dN:()=>z,I5:()=>q});var l=t(94799),a=t(66843),n=t(34023),r=t(59959),o=t(73885),i=t(3414),d=t(94726),c=t(66826),m=t(55712),u=t(79141),h=t(3749),p=t(86606),b=t(69654);let j=null;function v(){let[e,s]=(0,n.useState)(null);return(0,n.useEffect)(()=>{let e=!0;return null!=j||(j=h.FH.get("/object-db/props").catch(e=>{throw j=null,e})),j.then(t=>{e&&s(t)}).catch(()=>void 0),()=>{e=!1}},[]),e}var x=t(9217),g=t(70665),f=t(92947);let k=["session","network","ssl","advanced"];function y(e){let{def:s,value:t,onChange:a}=e;return"boolean"===s.type?(0,l.jsxs)("select",{className:"select",value:t,onChange:e=>a(e.target.value),"aria-label":s.name,children:[(0,l.jsx)("option",{value:"true",children:"true"}),(0,l.jsx)("option",{value:"false",children:"false"})]}):"choice"===s.type?(0,l.jsxs)("select",{className:"select",value:t,onChange:e=>a(e.target.value),"aria-label":s.name,children:[!t&&(0,l.jsx)("option",{value:""}),s.choices.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]}):(0,l.jsx)("input",{className:"input mono",type:"number"===s.type?"number":"text",min:s.min,max:s.max,value:t,placeholder:s.placeholder,autoComplete:"off",onChange:e=>a(e.target.value),"aria-label":s.name})}function N(e){let{engine:s,value:t,onChange:a,groups:n=k,exclude:r=[],quiet:o=!1}=e,{t:i,locale:d}=(0,b.s9)(),c=v();if(!c)return(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:i("dp.loading")});let m=c[s].filter(e=>n.includes(e.group)&&!r.includes(e.name)),u=m.filter(e=>e.name in t),h=m.filter(e=>!(e.name in t));return(0,l.jsxs)("div",{className:"dprops",children:[0===u.length&&!o&&(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:i("dp.none")}),u.map(e=>(0,l.jsxs)("div",{className:"dprop",children:[(0,l.jsxs)("div",{className:"dprop-row",children:[(0,l.jsx)("code",{className:"dprop-name",children:e.name}),(0,l.jsx)("div",{className:"dprop-val",children:(0,l.jsx)(y,{def:e,value:t[e.name],onChange:s=>a({...t,[e.name]:s})})}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>{let{[e.name]:s,...l}=t;a(l)},"aria-label":i("dp.remove",{name:e.name}),title:i("dp.remove",{name:e.name}),children:(0,l.jsx)(g.A,{size:14})})]}),(0,l.jsx)("p",{className:"muted small dprop-desc",children:"es"===d?e.es:e.desc})]},e.name)),h.length>0&&(0,l.jsxs)("div",{className:"dprop-add",children:[(0,l.jsx)(f.A,{size:14,className:"muted"}),(0,l.jsxs)("select",{className:"select",value:"","aria-label":i("dp.add"),onChange:e=>{let s=m.find(s=>s.name===e.target.value);s&&a({...t,[s.name]:"boolean"===s.type?"true":"choice"===s.type?s.choices[0]:""})},children:[(0,l.jsx)("option",{value:"",children:i("dp.add")}),k.filter(e=>h.some(s=>s.group===e)).map(e=>(0,l.jsx)("optgroup",{label:i("dp.group.".concat(e)),children:h.filter(s=>s.group===e).map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.name))},e))]})]})]})}let w={postgres:"postgresql",postgresql:"postgresql",mysql:"mysql",mariadb:"mysql",mssql:"mssql",sqlserver:"mssql",sqlite:"sqlite",file:"sqlite"};function C(e){let s,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=e.trim(),a=/^(?:jdbc:)?([a-z][a-z0-9+.-]*):/i.exec(l),n=a?w[a[1].toLowerCase()]:void 0;if(!n)return null;let r={engine:n,host:"",port:"",user:"",password:"",database:"",file:"",ssl:!1,trust:!1,props:{}};if("sqlite"===n){let e=l.replace(/^(?:jdbc:)?(?:sqlite|file):(?:\/\/)?/i,"").split("?")[0],s=decodeURIComponent(e.startsWith("/")?e:"/".concat(e));return s.length>1?{...r,file:s}:null}try{s=new URL(l.replace(/^jdbc:/i,"").replace(/^[a-z][a-z0-9+.-]*:/i,"http:"))}catch(e){return null}r.host=s.hostname,r.port=s.port,r.user=decodeURIComponent(s.username),r.password=decodeURIComponent(s.password),r.database=decodeURIComponent(s.pathname.replace(/^\//,""));let o=new Map(t.map(e=>[e.name.toLowerCase(),e]));return s.searchParams.forEach((e,s)=>{let t=s.toLowerCase(),l=e.toLowerCase();if("sslmode"===t||"ssl"===t||"encrypt"===t||"tls"===t)r.ssl=!["disable","disabled","false","no","0","allow","prefer"].includes(l)&&""!==l,r.trust=r.ssl&&["require","required","preferred"].includes(l);else if("trustservercertificate"===t)r.trust="true"===l;else{let s=o.get(t);s&&!s.name.startsWith("ssl.")&&(r.props[s.name]=e)}}),r}let S={mysql:{label:"MySQL / MariaDB",port:3306,color:"#00758f",sample:"mysql://user:password@localhost:3306/app"},postgresql:{label:"PostgreSQL",port:5432,color:"#4a7fb5",sample:"postgresql://user:password@localhost:5432/app?sslmode=require"},sqlite:{label:"SQLite",port:0,color:"#0f80cc",sample:"sqlite:///home/you/app/data.db"},mssql:{label:"SQL Server",port:1433,color:"#cc2927",sample:"mssql://sa:password@localhost:1433/master"}},T=Object.keys(S),D=["ssl.ca","ssl.cert","ssl.key"],R={"ssl.ca":"db.ssl.ca","ssl.cert":"db.ssl.cert","ssl.key":"db.ssl.key"};function q(e){var s;let t="sqlite"===e.engine?null==(s=e.dbFile.split("/").pop())?void 0:s.replace(/\.[^.]+$/,""):e.dbName.trim()||e.dbHost.trim();return t?"".concat(t," \xb7 ").concat(S[e.engine].label.split(" ")[0]):""}function z(e){let{d:s,set:t,setD:j,objectId:g,creating:f=!1}=e,{t:k,locale:y}=(0,b.s9)(),w=v(),[q,z]=(0,n.useState)({state:"idle"}),[A,F]=(0,n.useState)(""),[E,M]=(0,n.useState)(""),P="sqlite"===s.engine,$=function(e){var a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,l.jsx)("input",{className:"input ".concat(n.mono?"mono":""),type:n.type,value:s[e],placeholder:n.placeholder,autoComplete:null!=(a=n.auto)?a:"off",onChange:s=>t(e,s.target.value)})},_=e=>{e!==s.engine&&(j(s=>({...s,engine:e,dbProps:{},dbSsl:!1,dbTrust:!1})),z({state:"idle"}))},O=async()=>{z({state:"busy"});try{let e=await h.FH.post("/object-db/test",{id:g,config:(0,x.Mr)(s)});z({state:"ok",text:"".concat(e.version," \xb7 ").concat(e.ms," ms")})}catch(e){z({state:"err",text:e instanceof Error?e.message:""})}},H=()=>{var e,t;let l=C(A,null==w?void 0:w[null!=(t=null==(e=C(A))?void 0:e.engine)?t:s.engine]);if(!l)return void M(k("db.url.bad"));M(""),z({state:"idle"}),j(e=>({...e,engine:l.engine,dbHost:l.host,dbPort:l.port,dbUser:l.user,dbPassword:l.password,dbName:l.database,dbFile:l.file,dbSsl:l.ssl,dbTrust:l.trust,dbProps:l.props})),F("")},I=(0,l.jsxs)(l.Fragment,{children:[P?(0,l.jsx)(p.yQ,{mode:"file",exts:["db","sqlite","sqlite3","db3"],value:s.dbFile,onChange:e=>t("dbFile",e),label:k("db.file"),hint:k("db.file.hint"),placeholder:"/home/you/app/data.db"}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(p.D0,{label:k("db.host"),children:$("dbHost",{placeholder:"127.0.0.1",mono:!0})}),(0,l.jsx)(p.D0,{label:k("db.port"),children:$("dbPort",{placeholder:String(S[s.engine].port)})}),(0,l.jsx)(p.D0,{label:k("db.user"),children:$("dbUser",{mono:!0})}),(0,l.jsx)(p.D0,{label:k("db.password"),hint:s.dbPasswordSet&&!s.dbPassword?k("db.password.saved"):void 0,children:(0,l.jsx)(a.y,{value:s.dbPassword,autoComplete:"new-password",placeholder:s.dbPasswordSet?"••••••••":"",onChange:e=>t("dbPassword",e.target.value)})})]}),(0,l.jsx)(p.D0,{label:k("db.database"),hint:k("db.database.hint"),children:$("dbName",{mono:!0})})]}),(0,l.jsxs)("div",{className:"row gap-s wrap db-test",children:[(0,l.jsxs)("button",{type:"button",className:"btn sm",onClick:()=>void O(),disabled:"busy"===q.state||!!P&&!s.dbFile.trim(),children:["busy"===q.state?(0,l.jsx)(r.A,{size:14,className:"spin"}):(0,l.jsx)(o.A,{size:14}),k("db.test")]}),"ok"===q.state&&(0,l.jsxs)("span",{className:"db-ok small",children:[(0,l.jsx)(i.A,{size:14}),k("db.test.ok")," \xb7 ",q.text]}),"err"===q.state&&(0,l.jsxs)("span",{className:"db-bad small",children:[(0,l.jsx)(d.A,{size:14}),q.text]})]})]}),L=P?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbSsl,onChange:e=>t("dbSsl",e),label:k("db.ssl")}),s.dbSsl&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbTrust,onChange:e=>t("dbTrust",e),label:k("db.trust"),hint:s.dbTrust?k("db.trust.on"):k("db.trust.off")}),D.filter(e=>null==w?void 0:w[s.engine].some(s=>s.name===e)).map(e=>{var a;let n=w[s.engine].find(s=>s.name===e);return(0,l.jsx)(p.yQ,{mode:"file",exts:["pem","crt","cer","key"],value:null!=(a=s.dbProps[e])?a:"",onChange:l=>t("dbProps",{...s.dbProps,[e]:l}),label:k(R[e]),hint:"es"===y?n.es:n.desc,placeholder:n.placeholder},e)}),(0,l.jsx)(N,{engine:s.engine,value:s.dbProps,onChange:e=>t("dbProps",e),groups:["ssl"],exclude:[...D],quiet:!0})]})]}),U=(0,l.jsx)(N,{engine:s.engine,value:s.dbProps,onChange:e=>t("dbProps",e),groups:["session","network","advanced"]}),K=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbReadOnly,onChange:e=>t("dbReadOnly",e),label:k("db.readonly"),hint:s.dbReadOnly?k("db.readonly.on"):k("db.readonly.off")}),(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(p.D0,{label:k("db.timeout"),hint:k("db.timeout.hint"),children:$("dbTimeout",{placeholder:"30"})}),(0,l.jsx)(p.D0,{label:k("db.maxRows"),hint:k("db.maxRows.hint"),children:$("dbMaxRows",{placeholder:"1000"})})]})]}),Q=(0,l.jsx)("div",{className:"dbengines",role:"group","aria-label":k("db.engine"),children:T.map(e=>(0,l.jsxs)("button",{type:"button",className:"dbengine","aria-pressed":s.engine===e,style:{"--c":S[e].color},onClick:()=>_(e),children:[(0,l.jsx)(c.A,{size:18}),(0,l.jsx)("b",{children:S[e].label}),(0,l.jsx)("small",{children:"sqlite"===e?k("db.engine.file"):k("db.engine.port",{port:S[e].port})})]},e))});return f?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.Zp,{title:k("db.engine"),hint:k("db.engine.hint"),children:Q}),(0,l.jsxs)(x.Zp,{title:k("db.conn"),hint:k("db.conn.hint"),children:[(0,l.jsx)(p.D0,{label:k("db.url"),error:E,hint:E?void 0:k("db.url.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("input",{className:"input mono grow",value:A,placeholder:S[s.engine].sample,autoComplete:"off",spellCheck:!1,onChange:e=>{F(e.target.value),M("")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),H())}}),(0,l.jsxs)("button",{type:"button",className:"btn sm",disabled:!A.trim(),onClick:H,children:[(0,l.jsx)(m.A,{size:14}),k("db.url.use")]})]})}),I]}),(0,l.jsx)(x.Zp,{title:k("db.safety"),hint:k("db.safety.hint"),children:K}),(0,l.jsxs)("details",{className:"of-adv",children:[(0,l.jsxs)("summary",{children:[(0,l.jsx)(u.A,{size:15}),k("db.advanced"),(0,l.jsx)("span",{className:"muted small",children:k("db.advanced.hint")})]}),!P&&(0,l.jsx)(x.Zp,{title:k("db.sslTitle"),hint:k("db.sslTitle.hint"),children:L}),(0,l.jsx)(x.Zp,{title:k("dp.title"),hint:k("dp.hint"),children:U})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(x.Zp,{title:k("db.conn"),hint:k("db.conn.hint"),children:[(0,l.jsx)(p.D0,{label:k("db.engine"),children:(0,l.jsx)(p.$q,{value:s.engine,onChange:_,options:T.map(e=>({id:e,label:S[e].label}))})}),I]}),!P&&(0,l.jsx)(x.Zp,{title:k("db.sslTitle"),hint:k("db.sslTitle.hint"),children:L}),(0,l.jsx)(x.Zp,{title:k("dp.title"),hint:k("dp.hint"),children:U}),(0,l.jsx)(x.Zp,{title:k("db.safety"),hint:k("db.safety.hint"),children:K})]})}},74988:(e,s,t)=>{t.d(s,{HS:()=>b,M6:()=>m,Mn:()=>h,Nd:()=>d,Wy:()=>c,y$:()=>u});var l=t(29416),a=t(34978),n=t(84616),r=t(66826),o=t(73784),i=t(47890);let d={server:{color:"#0f8f9e",icon:l.A},docker:{color:"#2496ed",icon:a.A},http:{color:"#7a4de0",icon:n.A},database:{color:"#d9822b",icon:r.A},cluster:{color:i.Ng,icon:o.A}},c={running:"ok",ready:"ok",starting:"warn",error:"err",stopped:"off",unknown:"off"},m=e=>Object.entries(null!=e?e:{}).map(e=>{let[s,t]=e;return"".concat(s,"=").concat(t)}).join("\n");function u(e){let s={};for(let t of e.split("\n")){let e=t.trim();if(!e||e.startsWith("#"))continue;let l=e.indexOf("=");if(l<=0)throw Error('"'.concat(e,'" is not NAME=value'));s[e.slice(0,l).trim()]=e.slice(l+1)}return s}let h=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),p=[[/^(\d+) requests in (\d+) files$/,"d.requests"],[/^(\d+)\/(\d+) running$/,"d.running"],[/^no members$/,"d.noMembers"],[/^only (\d+)\/(\d+) running · stopped: (.+)$/,"d.onlySome"],[/^(.+) failed · (\d+)\/(\d+) running$/,"d.failed"],[/^waiting for port (\d+)$/,"d.waitPort"],[/^running, but nothing listens on port (\d+)$/,"d.noPort"],[/^exited with code (\d+)$/,"d.exited"],[/^ended by (\w+)$/,"d.signal"],[/^restarted \((\d+)\/(\d+)\)$/,"d.restarted"],[/^was unhealthy: restarting \((\d+)\/(\d+)\)$/,"d.unhealthyRestart"],[/^health check pending$/,"d.healthPending"],[/^restarting$/,"d.restarting"],[/^container not found$/,"d.noContainer"],[/^the compose file is missing$/,"d.noCompose"],[/^(\d+) of (\d+) running$/,"d.running2"],[/^(\d+) services?$/,"d.services"],[/^a service exited with an error$/,"d.serviceFailed"],[/^checking…$/,"d.checking"],[/^unhealthy$/,"d.unhealthy"]];function b(e,s){return s?s.split(" \xb7 ").map(s=>{for(let[t,l]of p){let a=t.exec(s);if(a)return e(l,Object.fromEntries(a.slice(1).map((e,s)=>["a".concat(s+1),e])))}let t=/^(.*)restarting in (\d+) s \((\d+)\/(\d+)\)$/.exec(s);if(t)return e("d.restartIn",{a1:t[2],a2:t[3],a3:t[4]});let l=/^gave up after (\d+) restarts$/.exec(s);if(l)return e("d.gaveUp",{a1:l[1]});let a=/^unhealthy: (.+)$/.exec(s);return a?"".concat(e("d.unhealthy"),": ").concat(a[1]):s}).join(" \xb7 "):""}},75010:(e,s,t)=>{t.d(s,{I:()=>c});var l=t(94799),a=t(34023),n=t(98392),r=t(64883),o=t(3749),i=t(69654);let d=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function c(e){let{id:s,height:t=220}=e,{t:c}=(0,i.s9)(),[m,u]=(0,a.useState)(null),h=(0,a.useRef)(""),p=(0,a.useRef)(null),b=(0,a.useRef)(!0),[j,v]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,t;u(null),h.current="",b.current=!0,v(!1);let l=async()=>{try{let t=h.current?"after=".concat(encodeURIComponent(h.current)):"tail=300",l=await o.FH.get("/objects/".concat(s,"/logs?").concat(t));if(e)return;h.current=l.cursor||h.current;let a=l.text.replace(d,"");u(e=>{let s=l.reset?"":null!=e?e:"";if(!a)return null!=e?e:"";let t=!s||s.endsWith("\n")||a.startsWith("\n")?s+a:"".concat(s,"\n").concat(a);return t.length>2e5?t.slice(t.length-2e5):t})}catch(e){}e||(t=setTimeout(l,1200))};return l(),()=>{e=!0,clearTimeout(t)}},[s]),(0,a.useEffect)(()=>{let e=p.current;e&&b.current&&(e.scrollTop=e.scrollHeight)},[m]),(0,l.jsxs)("div",{className:"logv",children:[(0,l.jsx)("pre",{ref:p,className:"logv-body mono",style:{height:t},onScroll:()=>{let e=p.current;if(!e)return;let s=e.scrollHeight-e.scrollTop-e.clientHeight<24;b.current=s,v(!s)},tabIndex:0,children:null===m?c("git.loading"):m.trim()?m:c("obj.logs.empty")}),(0,l.jsxs)("div",{className:"logv-tools",children:[j&&(0,l.jsxs)("button",{className:"btn sm",onClick:()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,b.current=!0,v(!1))},children:[(0,l.jsx)(n.A,{size:14}),c("obj.logs.bottom")]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>u(""),"aria-label":c("obj.logs.clear"),title:c("obj.logs.clear"),children:(0,l.jsx)(r.A,{size:14})})]})]})}},84561:(e,s,t)=>{t.d(s,{b:()=>o});var l=t(94799),a=t(34023),n=t(21018),r=t(86606);function o(e){let{value:s,onChange:t,options:o,placeholder:i,mono:d=!1,ariaLabel:c,onOpen:m,empty:u}=e,[h,p]=(0,a.useState)(!1),[b,j]=(0,a.useState)(0),v=(0,a.useRef)(null);(0,n.s)(h,v,()=>p(!1));let x=(0,a.useMemo)(()=>{let e=s.trim().toLowerCase();return(e?o.filter(s=>{var t,l;return"".concat(s.value," ").concat(null!=(t=s.label)?t:""," ").concat(null!=(l=s.hint)?l:"").toLowerCase().includes(e)}):o).slice(0,60)},[o,s]);(0,a.useEffect)(()=>{j(0)},[s,h]);let g=(0,r.Bp)(h&&(x.length>0||!!u),b,x.length),f=e=>{t(e.value),p(!1)};return(0,l.jsxs)("div",{className:"sg",ref:v,children:[(0,l.jsx)("input",{className:"input ".concat(d?"mono":""),value:s,placeholder:i,"aria-label":c,autoComplete:"off",spellCheck:!1,...g.input,onFocus:()=>{h||(p(!0),null==m||m())},onClick:()=>p(!0),onChange:e=>{t(e.target.value),p(!0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),p(!0),j(e=>Math.min(x.length-1,e+1))):"ArrowUp"===e.key?(e.preventDefault(),j(e=>Math.max(0,e-1))):"Enter"===e.key&&h&&x[b]?(e.preventDefault(),f(x[b])):"Escape"===e.key&&h&&(e.stopPropagation(),p(!1))}}),h&&(x.length>0||u)&&(0,l.jsxs)("ul",{className:"sg-list",...g.listProps,children:[0===x.length&&(0,l.jsx)("li",{className:"sg-empty",role:"presentation",children:u}),x.map((e,s)=>{var t;return(0,l.jsx)("li",{...g.optionProps(s),children:(0,l.jsxs)("button",{type:"button",tabIndex:-1,className:"sg-opt ".concat(s===b?"hi":""),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>j(s),onClick:()=>f(e),children:[(0,l.jsx)("span",{className:"nm ".concat(d?"mono":""),children:null!=(t=e.label)?t:e.value}),e.hint&&(0,l.jsx)("span",{className:"hint",children:e.hint})]})},e.value)})]})]})}},95587:(e,s,t)=>{t.d(s,{X:()=>u});var l=t(94799),a=t(34023),n=t(3749),r=t(69654),o=t(48538),i=t(86606),d=t(9217),c=t(52974),m=t(67056);function u(e){let{presetColonyId:s,presetKind:t,onClose:u,onSaved:h}=e,{t:p}=(0,r.s9)(),{refresh:b}=(0,o.o0)(),j=(0,i.dj)(),{d:v,set:x,setD:g}=(0,d.Te)(()=>(0,d.QJ)(void 0,s,t)),[f,k]=(0,a.useState)(""),[y,N]=(0,a.useState)(!1),w=async()=>{let e=v.name.trim()||("database"===v.kind?(0,m.I5)(v):"");if(!e)return void k(p("obj.err.name"));N(!0),k("");try{if("docker"===v.kind&&"template"===v.mode&&!v.template){k(p("tpl.pick")),N(!1);return}let s="docker"===v.kind&&"template"===v.mode?await n.FH.post("/objects/from-template",{name:e,colony_id:v.colony_id||null,template:v.template,values:v.tplValues}):await n.FH.post("/objects",{name:e,colony_id:v.colony_id||null,kind:v.kind,config:(0,d.qP)(v)});v.manager&&c.G.includes(v.kind)&&await n.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:v.manager}).catch(e=>j(e instanceof Error?e.message:"","err")),await b(["objects","agents"]),j(p("obj.created")),null==h||h(s.id),u()}catch(e){k(e instanceof Error?e.message:p("edit.saveFailed")),N(!1)}};return(0,l.jsx)(i._s,{title:p("obj.newTitle"),subtitle:p("obj.subtitle"),onClose:u,footer:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{className:"btn ghost",onClick:u,children:p("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",disabled:y,onClick:()=>void w(),children:p("obj.create")})]}),children:(0,l.jsx)(d.Bh,{d:v,set:x,setD:g,showKind:!0,error:f})})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[969],{16054:(e,s,t)=>{Promise.resolve().then(t.bind(t,42860))},42860:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>sm});var a=t(94799),n=t(20422),l=t(89128),i=t(34023),c=t(41463),r=t.n(c),o=t(43624),d=t(75406),h=t(32098),u=t(68449),m=t(97541),g=t(48538),x=t(3749),p=t(47890),j=t(77021),b=t(61748),f=t(51705),v=t(44738),N=t(14214),y=t(84611),k=t(29718),w=t(8089),C=t(50352),S=t(12349),A=t(56072),z=t(69654);function E(e){var s,t,n,l,c,r,o,d,h,u,m;let{agent:p,session:j}=e,{t:b}=(0,z.s9)(),{finished:f,live:E}=(0,g.o0)(),[M,F]=(0,i.useState)(null),[R,P]=(0,i.useState)(!1),L=null!=(s=f[p.id])?s:0,_=E[p.id];if((0,i.useEffect)(()=>{if(!p.session_id&&!j)return void F(null);x.FH.get("/agents/".concat(p.id,"/stats").concat(j?"?session=".concat(encodeURIComponent(j)):"")).then(F).catch(()=>void 0)},[p.id,p.session_id,j,L]),!M||0===M.turns&&!_)return null;let I=null==_?void 0:_.usage,T=(0,A.RP)(M.usage)+(I?(0,A.RP)({input:null!=(t=I.input)?t:0,output:null!=(n=I.output)?n:0,cacheRead:null!=(l=I.cacheRead)?l:0,cacheWrite:null!=(c=I.cacheWrite)?c:0}):0),U=(null!=(r=M.cost)?r:0)+(null!=(o=null==_?void 0:_.cost)?o:0),H=(null!=(d=M.usage.credits)?d:0)+(null!=(h=null==I?void 0:I.credits)?h:0),D=null!=(m=null!=(u=null==I?void 0:I.contextPct)?u:M.contextPct)?m:M.lastContext?Math.min(100,M.lastContext/2e5*100):null,K=null!==M.cost||(null==_?void 0:_.cost)!==void 0,O=M.usage,W=Math.max(1,O.input+O.output+O.cacheRead+O.cacheWrite),q=Math.max(1,...M.tools.map(e=>e.count)),$=Math.max(1,...M.timeline.map(e=>e.tokens));return(0,a.jsxs)("div",{className:"stats-wrap",children:[(0,a.jsxs)("button",{className:"statsbar",onClick:()=>P(e=>!e),"aria-expanded":R,children:[(0,a.jsxs)("span",{className:"sb",title:b("stats.contextTitle"),children:[(0,a.jsx)(v.A,{size:14}),(0,a.jsx)("b",{children:null!==D?"".concat(D.toFixed(+(D<10)),"%"):(0,A.yj)(M.lastContext)}),b("stats.context")]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(N.A,{size:14}),(0,a.jsx)("b",{children:(0,A.yj)(T)}),b("stats.tokens")]}),H>0&&(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(y.A,{size:14}),(0,a.jsx)("b",{children:H.toFixed(2)}),b("stats.credits")]}),K&&(0,a.jsxs)("span",{className:"sb",title:M.costEstimated?b("stats.costEstimated"):b("stats.costReported"),children:[(0,a.jsx)(y.A,{size:14}),(0,a.jsxs)("b",{children:[M.costEstimated?"≈ ":"",(0,A.F0)(U)]})]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(k.A,{size:14}),(0,a.jsx)("b",{children:M.turns}),b("stats.turns",{count:M.turns})]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(w.A,{size:14}),(0,a.jsx)("b",{children:M.toolCalls}),b("stats.toolCalls",{count:M.toolCalls}),M.toolErrors>0&&(0,a.jsxs)("em",{className:"tbad",children:[" \xb7 ",b("stats.failed",{count:M.toolErrors})]})]}),M.durationMs>0&&(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(C.A,{size:14}),(0,a.jsx)("b",{children:(0,A.nc)(M.durationMs)}),b("stats.working")]}),(0,a.jsx)(S.A,{size:15,className:"chev2 ".concat(R?"open":"")})]}),R&&(0,a.jsxs)("div",{className:"statspanel",children:[(0,a.jsxs)("section",{children:[(0,a.jsx)("div",{className:"eyebrow",children:b("stats.mix")}),(0,a.jsxs)("div",{className:"mixbar",role:"img","aria-label":b("stats.mix"),children:[(0,a.jsx)("i",{className:"fa-c-cr",style:{width:"".concat(O.cacheRead/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-cw",style:{width:"".concat(O.cacheWrite/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-in",style:{width:"".concat(O.input/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-out",style:{width:"".concat(O.output/W*100,"%")}})]}),(0,a.jsxs)("dl",{className:"legend",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-cr"}),(0,a.jsx)("dt",{children:b("stats.cacheRead")}),(0,a.jsx)("dd",{children:(0,A.yj)(O.cacheRead)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-cw"}),(0,a.jsx)("dt",{children:b("stats.cacheWrite")}),(0,a.jsx)("dd",{children:(0,A.yj)(O.cacheWrite)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-in"}),(0,a.jsx)("dt",{children:b("stats.input")}),(0,a.jsx)("dd",{children:(0,A.yj)(O.input)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-out"}),(0,a.jsx)("dt",{children:b("stats.output")}),(0,a.jsxs)("dd",{children:[(0,A.yj)(O.output),O.reasoning>0&&(0,a.jsxs)("span",{className:"muted",children:[" (",b("stats.thinking",{tokens:(0,A.yj)(O.reasoning)}),")"]})]})]})]}),M.models.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"eyebrow mt-m",children:b("stats.models")}),M.models.map(e=>(0,a.jsxs)("div",{className:"row small between",children:[(0,a.jsx)("span",{className:"mono",children:e.model}),(0,a.jsx)("span",{className:"muted",children:b("stats.modelLine",{count:e.messages,out:(0,A.yj)(e.output)})})]},e.model))]})]}),(0,a.jsxs)("section",{children:[(0,a.jsxs)("div",{className:"eyebrow",children:[b("stats.toolsUsed")," ",M.toolTimeMs>0&&(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",b("stats.totalTime",{time:(0,A.nc)(M.toolTimeMs)})]})]}),0===M.tools.length?(0,a.jsx)("p",{className:"muted small m0 mt-s",children:b("stats.noTools")}):M.tools.slice(0,9).map(e=>(0,a.jsxs)("div",{className:"toolrow",title:b("stats.toolTitle",{count:e.count,time:(0,A.nc)(e.totalMs)}),children:[(0,a.jsx)("span",{className:"mono tn",children:e.name.replace(/^mcp__/,"").replace("__"," \xb7 ")}),(0,a.jsx)("span",{className:"tbar",children:(0,a.jsx)("i",{style:{width:"".concat(e.count/q*100,"%")}})}),(0,a.jsxs)("span",{className:"tc",children:[e.count,e.errors>0&&(0,a.jsxs)("em",{className:"tbad",children:[" (",e.errors,"✗)"]})]}),(0,a.jsx)("span",{className:"td muted",children:e.totalMs?(0,A.nc)(e.totalMs/e.count):""})]},e.name))]}),(0,a.jsxs)("section",{className:"fa-span",children:[(0,a.jsx)("div",{className:"eyebrow",children:b("stats.perTurn")}),(0,a.jsx)("div",{className:"tbars",role:"list",children:M.timeline.slice(-40).map((e,s)=>(0,a.jsx)("div",{className:"sbar",role:"listitem",title:"".concat(e.prompt||b("stats.promptFallback"),"\n").concat(b("stats.turnLine",{tokens:(0,A.yj)(e.tokens),tools:e.tools,time:(0,A.nc)(e.durationMs)})).concat(null!==e.cost?" \xb7 ".concat((0,A.F0)(e.cost)):""),children:(0,a.jsx)("i",{style:{height:"".concat(Math.max(4,e.tokens/$*100),"%")}})},s))})]})]})]})}var M=t(33974),F=t(78330),R=t(92947),P=t(58311),L=t(72942),_=t(5372),I=t(86606),T=t(1517);function U(e){let{activeId:s,collapsed:t=!1,onToggle:n}=e,{t:l}=(0,z.s9)(),{agents:c,colonies:o,live:d}=(0,g.o0)(),h=(0,_.z6)(),[u,m]=(0,i.useState)(""),[x,j]=(0,i.useState)(!1),b=(0,i.useMemo)(()=>{let e=e=>!u||"".concat(e.name," ").concat(e.description," ").concat(e.provider," ").concat(e.model).toLowerCase().includes(u.toLowerCase()),s=o.map(s=>({key:s.id,name:s.name,color:s.color||"var(--honey)",items:c.filter(t=>t.colony_id===s.id&&e(t))}));return s.push({key:"free",name:l("common.noColony"),color:null,items:c.filter(s=>(!s.colony_id||!o.some(e=>e.id===s.colony_id))&&e(s))}),s.filter(e=>e.items.length)},[c,o,u,l]),f=n&&(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:n,"aria-label":t?l("switcher.expand"):l("switcher.collapse"),title:t?l("switcher.expand"):l("switcher.collapse"),"aria-expanded":!t,children:t?(0,a.jsx)(M.A,{size:17}):(0,a.jsx)(F.A,{size:17})});return t?(0,a.jsxs)("aside",{className:"switcher mini","aria-label":l("nav.agents"),children:[(0,a.jsxs)("div",{className:"switcher-head",children:[f,(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(!0),"aria-label":l("newAgent.title"),title:l("newAgent.title"),children:(0,a.jsx)(R.A,{size:16})})]}),(0,a.jsx)("div",{className:"switcher-list",children:b.map(e=>(0,a.jsxs)("div",{className:"mini-group",children:[(0,a.jsx)("div",{className:"mini-sep",title:"".concat(e.name," \xb7 ").concat(e.items.length),style:e.color?{"--c":e.color}:void 0}),e.items.map(e=>(0,a.jsx)(r(),{href:"/agents/".concat(e.id),className:"sw-item mini","aria-current":e.id===s?"page":void 0,"aria-label":e.name,...h.bind(e.id),children:(0,a.jsxs)("span",{className:"sw-av",children:[(0,a.jsx)(I._h,{agent:e}),"idle"!==e.status&&(0,a.jsx)("i",{className:"pip ".concat("error"===e.status?"err":"")})]})},e.id))]},e.key))}),x&&(0,a.jsx)(T.b,{onClose:()=>j(!1)}),h.node]}):(0,a.jsxs)("aside",{className:"switcher","aria-label":l("nav.agents"),children:[(0,a.jsxs)("div",{className:"switcher-head",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("b",{style:{fontFamily:"var(--font-display)",fontSize:16},className:"grow",children:l("nav.agents")}),f,(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(!0),"aria-label":l("newAgent.title"),children:(0,a.jsx)(R.A,{size:16})})]}),(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:15}),(0,a.jsx)("input",{className:"input",placeholder:l("switcher.find"),value:u,onChange:e=>m(e.target.value),"aria-label":l("switcher.find")})]})]}),(0,a.jsxs)("div",{className:"switcher-list",children:[0===b.length&&(0,a.jsx)("p",{className:"muted small",style:{padding:16},children:l("switcher.noMatch",{query:u})}),b.map(e=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"switcher-group",children:[e.color&&(0,a.jsx)("i",{className:"cdot",style:{background:e.color}}),e.name,(0,a.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{let t=(0,L.E)(d[e.id]);return(0,a.jsxs)(r(),{href:"/agents/".concat(e.id),className:"sw-item","aria-current":e.id===s?"page":void 0,...h.bind(e.id),children:[(0,a.jsxs)("span",{className:"sw-av",children:[(0,a.jsx)(I._h,{agent:e}),"idle"!==e.status&&(0,a.jsx)("i",{className:"pip ".concat("error"===e.status?"err":"")})]}),(0,a.jsxs)("span",{className:"sw-body",children:[(0,a.jsxs)("span",{className:"sw-top",children:[(0,a.jsx)("b",{children:e.name}),"orchestrator"===e.role&&(0,a.jsx)("em",{children:l("role.orchestrator")})]}),(0,a.jsx)("span",{className:"sw-sub ".concat(t?"live":e.description?"":"blank"),children:null!=t?t:"error"===e.status?l("status.error"):e.description||l("switcher.noDescription")}),(0,a.jsxs)("span",{className:"sw-meta",children:[(0,a.jsx)("i",{style:{background:p.xq[e.provider].color}}),p.xq[e.provider].short,e.model?" \xb7 ".concat(e.model):"",(0,a.jsx)("span",{className:"sw-ago",children:e.queued&&e.queued>0?l("queue.count",{count:e.queued}):(0,p.KN)(e.updated_at)})]})]})]},e.id)})]},e.key))]}),x&&(0,a.jsx)(T.b,{onClose:()=>j(!1)}),h.node]})}var H=t(94227),D=t(89075),K=t(10776),O=t(79141),W=t(12582),q=t(25661),$=t(68979),B=t(76844);function G(e,s){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=new Map(s.map(e=>[e.path,e])),l=new Set(e);for(let e of s)l.add(e.path);let i={name:"",path:"",type:"dir",children:[],changed:0,additions:0,deletions:0},c=new Map([["",i]]),r=e=>{let s=c.get(e);if(s)return s;let t=e.lastIndexOf("/"),a=r(t<0?"":e.slice(0,t)),n={name:e.slice(t+1),path:e,type:"dir",children:[],changed:0,additions:0,deletions:0};return a.children.push(n),c.set(e,n),n};for(let e of l){var o,d,h,u;let s=e.lastIndexOf("/");r(s<0?"":e.slice(0,s)).children.push({name:e.slice(s+1),path:e,type:"file",children:[],change:n.get(e),changed:+!!n.has(e),additions:null!=(h=null==(o=n.get(e))?void 0:o.additions)?h:0,deletions:null!=(u=null==(d=n.get(e))?void 0:d.deletions)?u:0})}let m=(e,s,t)=>{var n;if(e.children.some(e=>e.path===s))return;let l={name:s.slice(s.lastIndexOf("/")+1),path:s,type:t?"dir":"file",children:[],ignored:!0,lazy:t&&!(s in a),changed:0,additions:0,deletions:0};if(e.children.push(l),t&&c.set(s,l),t)for(let e of null!=(n=a[s])?n:[])m(l,"".concat(s,"/").concat(e.name),e.dir)};for(let e of t){let s=e.endsWith("/"),t=s?e.slice(0,-1):e,a=t.lastIndexOf("/");m(r(a<0?"":t.slice(0,a)),t,s)}let g=e=>{for(let s of(e.children.sort((e,s)=>e.type===s.type?e.name.localeCompare(s.name):"dir"===e.type?-1:1),e.children))"dir"===s.type&&g(s),e.changed+=(s.type,s.changed),e.additions+=s.additions,e.deletions+=s.deletions;e.children=e.children.map(e=>{let s=e;for(;"dir"===s.type&&1===s.children.length&&"dir"===s.children[0].type;){let e=s.children[0];s={...e,name:"".concat(s.name,"/").concat(e.name)}}return s})};return g(i),i}function J(e,s,t){let a=t.query.trim().toLowerCase(),n=e=>(!t.onlyChanged||0!==e.changed)&&(!a||("file"===e.type?e.path.toLowerCase().includes(a):e.children.some(n))),l=[],i=(e,c)=>{for(let r of e.children)n(r)&&(l.push({node:r,depth:c}),"dir"===r.type&&(a||t.onlyChanged||s.has(r.path))&&i(r,c+1))};return i(e,0),l}var Q=t(10969),X=t(39696),Y=t(78060),Z=t(61),V=t(80306),ee=t(6458),es=t(53983);let et=/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif)$/i,ea=/\.(md|markdown|mdx)$/i;var en=t(32480),el=t(70665);function ei(e){let s={meta:[],hunks:[],binary:!1},t=null,a=0,n=0;for(let i of e.split("\n")){let e=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/.exec(i);if(e){var l;a=Number(e[1]),n=Number(e[2]),t={header:i,section:null!=(l=e[3])?l:"",lines:[]},s.hunks.push(t);continue}if(!t){/^Binary files .* differ$/.test(i)||i.startsWith("GIT binary patch")?s.binary=!0:(/^(rename|copy) (from|to) /.test(i)||/^(new|deleted) file mode/.test(i)||/^similarity index/.test(i))&&s.meta.push(i);continue}let c=i[0];if("+"===c)t.lines.push({kind:"add",newNo:n++,text:i.slice(1)});else if("-"===c)t.lines.push({kind:"del",oldNo:a++,text:i.slice(1)});else if(" "===c)t.lines.push({kind:"ctx",oldNo:a++,newNo:n++,text:i.slice(1)});else if("\\"===c){let e=t.lines[t.lines.length-1];e&&(e.noEol=!0)}}return s}let ec=e=>{var s,t;return null!=(t=null==(s=/^(@@ [^@]+@@)/.exec(e))?void 0:s[1])?t:e};var er=t(3218),eo=t(97254),ed=t(55267),eh=t(69962),eu=t(58099);let em=(0,i.memo)(function(e){var s,t,n,l,i,c,r,o;let{row:d,path:h,ws:u,actions:m,picking:g,onPick:x}=e,{t:p}=(0,z.s9)();if("hunk"===d.t)return(0,a.jsxs)("div",{className:"vl-row hunk",children:[(0,a.jsx)("div",{className:"vl-ln",style:{left:0},children:"⋯"}),(0,a.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:"⋯"}),(0,a.jsxs)("div",{className:"vl-hl",children:[(0,a.jsx)("span",{className:"rng mono",children:d.header}),d.section&&(0,a.jsx)("span",{className:"hs",title:d.section,children:d.section}),m&&(null==g?void 0:g.hunk)===d.idx?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"hk-btn on",onClick:()=>m.pickAll(d.idx,d.changed),children:p("git.discard.lines.all")}),(0,a.jsxs)("button",{type:"button",className:"hk-btn danger on",disabled:!g.picked.size,onClick:()=>m.discardPicked(d.idx,d.header),children:[(0,a.jsx)(W.A,{size:12}),p("git.discard.lines.go",{count:g.picked.size})]}),(0,a.jsx)("button",{type:"button",className:"hk-btn on",onClick:m.stopPicking,children:p("common.cancel")})]}):m&&(0,a.jsxs)(a.Fragment,{children:[d.changed>0&&m.canPick&&(0,a.jsxs)("button",{type:"button",className:"hk-btn",title:p("git.discard.lines.hint"),onClick:()=>m.startPicking(d.idx),children:[(0,a.jsx)(ed.A,{size:12}),p("git.discard.lines")]}),(0,a.jsxs)("button",{type:"button",className:"hk-btn",title:p("git.discard.hunk.hint"),onClick:()=>m.discardHunk(d.idx,d.header),children:[(0,a.jsx)(W.A,{size:12}),p("git.discard.hunk")]})]})]})]});if("line"===d.t){let e=d.l;return(0,a.jsxs)("div",{className:"vl-row ".concat(e.kind," ").concat(x&&void 0!==d.k&&(null==g?void 0:g.picked.has(d.k))?"picked":""),onClick:x&&void 0!==d.k?()=>x(d.k):void 0,children:[(0,a.jsx)("div",{className:"vl-ln",style:{left:0},children:null!=(s=e.oldNo)?s:""}),(0,a.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:null!=(t=e.newNo)?t:""}),(0,a.jsx)("div",{className:"vl-sg",children:x&&void 0!==d.k?(0,a.jsx)("input",{type:"checkbox",checked:!!(null==g?void 0:g.picked.has(d.k)),onChange:()=>void 0,"aria-label":p("git.discard.lines.pick")}):"add"===e.kind?"+":"del"===e.kind?"−":""}),(0,a.jsx)("div",{className:"vl-cd",children:(0,a.jsx)(eo.SH,{text:e.text,path:h,ws:u})})]})}let{left:j,right:b}=d.r;return(0,a.jsxs)("div",{className:"vl-row split",children:[(0,a.jsx)("div",{className:"vl-ln ".concat(null!=(n=null==j?void 0:j.kind)?n:"void"),style:{left:0},children:null!=(l=null==j?void 0:j.oldNo)?l:""}),(0,a.jsx)("div",{className:"vl-cd ".concat(null!=(i=null==j?void 0:j.kind)?i:"void"),title:j&&j.text.length>60?j.text:void 0,children:j?(0,a.jsx)(eo.SH,{text:j.text,path:h,ws:u}):null}),(0,a.jsx)("div",{className:"vl-ln ".concat(null!=(c=null==b?void 0:b.kind)?c:"void"),children:null!=(r=null==b?void 0:b.newNo)?r:""}),(0,a.jsx)("div",{className:"vl-cd ".concat(null!=(o=null==b?void 0:b.kind)?o:"void"),title:b&&b.text.length>60?b.text:void 0,children:b?(0,a.jsx)(eo.SH,{text:b.text,path:h,ws:u}):null})]})});function eg(e){let{parsed:s,layout:t,path:n,cutOff:l=!1,firstIndex:c=0,onDiscardHunk:r,onDiscardLines:o}=e,{whitespace:d}=(0,X.Wx)(),h=(0,i.useMemo)(()=>(function(e,s,t){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=[],l=(0,eh.KJ)(t);return e.hunks.forEach((e,t)=>{n.push({t:"hunk",idx:t+a,header:ec(e.header),section:l?e.section:"",changed:e.lines.filter(e=>"ctx"!==e.kind).length});let i=0;if("unified"===s)for(let s of e.lines)n.push({t:"line",l:s,hunk:t+a,k:"ctx"===s.kind?void 0:i++});else for(let s of function(e){let s=[];for(let t=0;t<e.length;){let a=e[t];if("ctx"===a.kind){s.push({left:a,right:a}),t++;continue}let n=[],l=[];for(;t<e.length&&"del"===e[t].kind;)n.push(e[t++]);for(;t<e.length&&"add"===e[t].kind;)l.push(e[t++]);for(let e=0;e<Math.max(n.length,l.length);e++)s.push({left:n[e],right:l[e]})}return s}(e.lines))n.push({t:"pair",r:s})}),n})(s,t,n,c),[s,t,n,c]),u=(0,i.useMemo)(()=>s.hunks.reduce((e,s)=>s.lines.reduce((e,s)=>Math.max(e,s.text.length),e),0),[s]),m="unified"===t?"calc(12ch + 32px + 18px + ".concat(u,"ch + 24px)"):void 0,g=(0,i.useRef)(null),x=(0,i.useRef)(null),[p,j]=(0,i.useState)({max:0,track:0});(0,i.useEffect)(()=>{let e=g.current;if(!e||"split"!==t)return void j({max:0,track:0});let s=()=>{let s=e.querySelector(".vl");if(!s)return;let t=document.createElement("canvas").getContext("2d");if(!t)return;t.font=getComputedStyle(s).font;let a=t.measureText("0").width,n=(e.clientWidth-2*(6*a+16))/2;j({max:Math.max(0,Math.ceil(u*a+24-n)),track:e.clientWidth})};s();let a=new ResizeObserver(s);return a.observe(e),()=>a.disconnect()},[t,u,h.length]),(0,i.useEffect)(()=>{var e;x.current&&(x.current.scrollLeft=0),null==(e=g.current)||e.style.setProperty("--hx","0px")},[s,t]),(0,i.useEffect)(()=>{let e=g.current;if(!e||"split"!==t)return;let s=e=>{let s=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;s&&x.current&&(e.preventDefault(),x.current.scrollLeft+=s)};return e.addEventListener("wheel",s,{passive:!1}),()=>e.removeEventListener("wheel",s)},[t]);let[b,f]=(0,i.useState)(null);(0,i.useEffect)(()=>{f(null)},[s,t]);let v=e=>f(s=>{if(!s)return s;let t=new Set(s.picked);return t.has(e)?t.delete(e):t.add(e),{...s,picked:t}}),N=r?{canPick:"unified"===t&&!!o,discardHunk:r,startPicking:e=>f({hunk:e,picked:new Set}),stopPicking:()=>f(null),pickAll:(e,s)=>f({hunk:e,picked:new Set(Array.from({length:s},(e,s)=>s))}),discardPicked:(e,s)=>{if(b&&o){let t=[...b.picked].sort((e,s)=>e-s);f(null),o(e,s,t)}}}:void 0;return(0,a.jsxs)("div",{className:"vf is-".concat(t),ref:g,style:{"--vl-left":"0px","--hx":"0px"},children:[s.meta.length>0&&(0,a.jsx)("div",{className:"gx-meta",children:s.meta.join(" \xb7 ")}),(0,a.jsx)("div",{className:"vf-main",children:(0,a.jsx)(eu.T,{count:h.length,width:m,render:e=>{let t=h[e],i="line"===t.t&&(null==b?void 0:b.hunk)===t.hunk;return(0,a.jsx)(em,{row:t,path:n,ws:d,actions:"hunk"!==t.t||l&&t.idx===s.hunks.length-1?void 0:N,picking:"hunk"===t.t||i?b:void 0,onPick:i?v:void 0},e)}})}),"split"===t&&p.max>0&&(0,a.jsx)("div",{className:"hbar",ref:x,onScroll:e=>{var s;return null==(s=g.current)?void 0:s.style.setProperty("--hx","".concat(e.currentTarget.scrollLeft,"px"))},"aria-label":"Scroll sideways",children:(0,a.jsx)("div",{style:{width:p.track+p.max,height:1}})})]})}function ex(e){let{path:s,hunk:t,index:n,total:l,extent:c,onClose:r,onGo:o}=e,{t:d}=(0,z.s9)(),h=(0,i.useMemo)(()=>({meta:[],hunks:[t],binary:!1}),[t]),u=t.lines.length+1;return(0,a.jsxs)("div",{className:"vl-peek",role:"dialog","aria-label":d("git.peek.title"),onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"vl-peek-head",children:[(0,a.jsx)("b",{children:c?c.from===c.to?d("git.peek.line",{n:c.from}):d("git.peek.lines",{from:c.from,to:c.to}):d("git.peek.title")}),(0,a.jsx)("span",{className:"muted mono small grow",children:ec(t.header)}),(0,a.jsx)("span",{className:"small muted",children:d("git.peek.count",{n:n+1,total:l})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:n<=0,onClick:()=>o(n-1),"aria-label":d("git.peek.prev"),title:"".concat(d("git.peek.prev")," (Alt+↑)"),children:(0,a.jsx)(en.A,{size:15})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:n>=l-1,onClick:()=>o(n+1),"aria-label":d("git.peek.next"),title:"".concat(d("git.peek.next")," (Alt+↓)"),children:(0,a.jsx)(S.A,{size:15})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:r,"aria-label":d("common.close"),children:(0,a.jsx)(el.A,{size:14})})]}),(0,a.jsx)("div",{className:"vl-peek-body",style:{height:Math.min(u*eu.U+4,260)},children:(0,a.jsx)(eg,{parsed:h,layout:"unified",path:s,firstIndex:n})})]})}function ep(e){var s,t;let{f:n,agent:l,blame:c,onOpenCommit:r,marks:o,allNew:d,focusLine:h}=e,u=null!=(s=null==o?void 0:o.groups)?s:[],[m,g]=(0,i.useState)(null),j=(0,i.useMemo)(()=>{let e=n.content.split("\n").length;return u.map(s=>({from:Math.min(s.from,e),to:Math.min(s.to,e)}))},[u,n.content]),b=m&&null!=(t=j[m.block])?t:null,[f,v]=(0,i.useState)(),N=(e,s)=>{let t={from:e.from,to:Math.min(e.to,n.content.split("\n").length)};return(t.to-(s+1)<=25?Math.max(t.to,s+1):s+1)*eu.U},y=e=>34+Math.min((e.view.lines.length+1)*eu.U+4,260)+14,k=e=>{let s=j[e];if(!s)return;let t=Math.max(0,s.from-1);g({row:t,block:e}),v({top:t*eu.U,bottom:N(u[e],t)+y(u[e]),key:Date.now()})};(0,i.useEffect)(()=>{g(null)},[n.path,o]),(0,i.useEffect)(()=>{if(!m)return;let e=e=>{if("Escape"===e.key)g(null);else if(e.altKey&&("ArrowDown"===e.key||"ArrowUp"===e.key)){e.preventDefault();let s=m.block+("ArrowDown"===e.key?1:-1);s>=0&&s<u.length&&k(s)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]);let{t:w}=(0,z.s9)(),{whitespace:C}=(0,X.Wx)(),[S,E]=(0,i.useState)(null),[M,F]=(0,i.useState)(null),R=(0,er.Z)(n.content,n.path),P=(0,i.useMemo)(()=>R.length&&""===R[R.length-1]?R.slice(0,-1):R,[R]),L=(0,i.useMemo)(()=>n.content.split("\n").reduce((e,s)=>Math.max(e,s.length),0),[n.content]);(0,i.useEffect)(()=>{if(!c||"worktree"!==n.source){E(null),F(null);return}let e=!1;return x.FH.get("/agents/".concat(l.id,"/git/blame?path=").concat(encodeURIComponent(n.path))).then(s=>{e||(E(s),F(null))}).catch(s=>!e&&F(s instanceof Error?s.message:w("git.loadError"))),()=>{e=!0}},[c,l.id,n.path,n.source]);let _=(0,i.useMemo)(()=>{if(!S)return null;let e=-1;return S.lines.map((s,t)=>{let a=s!==S.lines[t-1];return a&&e++,{first:a,g:e%2}})},[S]);if(n.binary)return(0,a.jsx)("p",{className:"gx-note",children:w("git.file.binary")});if(0===P.length)return(0,a.jsx)("p",{className:"gx-note",children:w("git.file.empty")});let I=210*!!S;return(0,a.jsxs)("div",{className:"vf",children:["head"===n.source&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.file.deleted")}),n.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.file.truncated")}),M&&(0,a.jsx)("div",{className:"gx-banner",children:M}),(null==S?void 0:S.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.blame.truncated",{count:S.lines.length})}),(0,a.jsx)("div",{className:"vf-main",style:{"--vl-left":"".concat(I,"px")},children:(0,a.jsx)(eu.T,{count:P.length,width:"calc(".concat(I,"px + ").concat(6,"ch + ").concat(L,"ch + 40px)"),overlay:m&&u[m.block]?{top:N(u[m.block],m.row),node:(0,a.jsx)(ex,{path:n.path,hunk:u[m.block].view,index:m.block,extent:b,onClose:()=>g(null),total:u.length,onGo:k})}:void 0,reveal:h?{top:Math.max(0,h.line-4)*eu.U,bottom:(h.line+2)*eu.U,key:h.key}:f,render:e=>{var s;let t=null==S?void 0:S.lines[e],l=t?S.commits[t]:void 0,i=null==_?void 0:_[e],c="worktree"===n.source?d?"add":null==o?void 0:o.lines.get(e+1):void 0,x=!!o&&o.removedBefore.has(e+1),j=!!o&&e===P.length-1&&o.removedBefore.has(P.length+1),f=o&&"worktree"===n.source?null!=(s=o.blockOfLine.get(e+1))?s:x?o.blockOfRemoval.get(e+1):j?o.blockOfRemoval.get(P.length+1):void 0:void 0;return(0,a.jsxs)("div",{className:"vl-row ".concat(h&&e+1===h.line?"m-hit":""," ").concat(i?"bl-g".concat(i.g):""," ").concat(c?"m-".concat(c):""," ").concat(x?"m-delb":j?"m-dela":""," ").concat(void 0!==f?"has-peek":""," ").concat(b&&e+1>=b.from&&e+1<=b.to?"in-peek":""),onClick:void 0!==f?s=>{var t;if(!s.target.closest(".bl-btn")&&(s.target.closest(".vl-ln")||(null==(t=window.getSelection())?void 0:t.isCollapsed))){if((null==m?void 0:m.row)===e)return void g(null);g({row:e,block:f}),v({top:e*eu.U,bottom:N(u[f],e)+y(u[f]),key:Date.now()})}}:void 0,title:void 0!==f?w("git.peek.hint"):void 0,children:[S&&(0,a.jsx)("div",{className:"vl-bl ".concat((null==i?void 0:i.first)?"first":""),children:(null==i?void 0:i.first)&&l&&(l.uncommitted?(0,a.jsx)("span",{className:"muted",children:w("git.blame.uncommitted")}):(0,a.jsxs)("button",{type:"button",className:"bl-btn",title:"".concat(l.summary,"\n").concat(l.author," \xb7 ").concat((0,A.v7)(l.time)),onClick:()=>r(t),children:[(0,a.jsx)("span",{className:"mono sha",children:l.short}),(0,a.jsx)("span",{className:"who",children:l.author}),(0,a.jsx)("span",{className:"when",children:(0,p.KN)(l.time)})]}))}),(0,a.jsx)("div",{className:"vl-ln",children:e+1}),(0,a.jsx)("div",{className:"vl-cd",children:(0,a.jsx)(eo.Yr,{html:P[e],ws:C})})]},e)}})})]})}function ej(e){let{agent:s,gitRef:t,path:n,toolbar:l=!0}=e,{t:c}=(0,z.s9)(),[r,o]=(0,i.useState)(null),[d,h]=(0,i.useState)(""),[u,m]=(0,i.useState)("preview"),g=et.test(n),p=ea.test(n);return(0,i.useEffect)(()=>{let e=!1;if(o(null),h(""),m("preview"),!g)return x.FH.get("/agents/".concat(s.id,"/git/ref-file?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n))).then(s=>!e&&o(s)).catch(s=>!e&&h(s instanceof Error&&/not found/i.test(s.message)?c("git.file.missingAt",{ref:t}):s instanceof Error?s.message:c("git.loadError"))),()=>{e=!0}},[s.id,t,n]),(0,a.jsxs)(a.Fragment,{children:[l&&(0,a.jsxs)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:[(0,a.jsx)("span",{className:"mono small grow",title:n,style:{overflow:"hidden",textOverflow:"ellipsis"},children:n}),r&&(0,a.jsx)("span",{className:"muted small",children:(0,A.zi)(r.size)}),p&&r&&!r.binary&&(0,a.jsx)(I.$q,{value:u,onChange:m,options:[{id:"preview",label:c("git.view.preview")},{id:"source",label:c("git.view.source")}]}),(0,a.jsx)(Q.WQ,{text:n,label:c("git.copyPath")})]}),(0,a.jsx)("div",{className:"gx-body",children:d?(0,a.jsx)("p",{className:"gx-note",children:d}):g?(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(s.id,"/git/raw-at?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n)),alt:n,onError:()=>h(c("git.file.missingAt",{ref:t}))})}):r?r.binary?(0,a.jsx)("p",{className:"gx-note",children:c("git.file.binary")}):p&&"preview"===u?(0,a.jsxs)("div",{className:"gx-md md",children:[r.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:c("git.diff.truncated")}),(0,a.jsx)(ee.oz,{remarkPlugins:[es.A],components:{a:e=>(0,a.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:r.content})]}):(0,a.jsx)(ep,{f:r,agent:s,blame:!1,onOpenCommit:()=>void 0,marks:null,allNew:!1}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})})]})}let eb={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflict:"!",typechange:"T"};function ef(e){let{status:s,titled:t=!1}=e,{t:n}=(0,z.s9)();return(0,a.jsx)("span",{className:"stl st-".concat(s),title:t?n("git.status.".concat(s)):void 0,children:eb[s]})}function ev(e){let{agent:s,gitRef:t,path:n,label:l}=e,[c,r]=(0,i.useState)(!0);return((0,i.useEffect)(()=>{r(!0)},[t,n]),c)?(0,a.jsxs)("figure",{className:"gx-pic",children:[(0,a.jsx)("figcaption",{className:"muted small",children:l}),(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(s.id,"/git/raw-at?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n)),alt:n,onError:()=>r(!1)})})]}):null}function eN(e){var s;let{agent:t,detailUrl:n,diffUrl:l,header:c,focus:r,embedded:o=!1,before:d,after:h,label:u}=e,{t:m}=(0,z.s9)(),[g,p]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[f,v]=(0,i.useState)(null),[N,y]=(0,i.useState)("unified"),[k,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return p(null),b(null),v(null),w(null),x.FH.get(n).then(s=>{var t,a;e||(p(s),b(null!=(a=r&&s.files.some(e=>e.path===r)?r:null==(t=s.files[0])?void 0:t.path)?a:null))}).catch(s=>!e&&w(s instanceof Error?s.message:m("git.loadError"))),()=>{e=!0}},[t.id,n,r]);let C=null==g?void 0:g.files.find(e=>e.path===j);(0,i.useEffect)(()=>{if(!C)return void v(null);let e=!1;return v(null),x.FH.get(l(C)).then(s=>!e&&v(s)).catch(s=>!e&&w(s instanceof Error?s.message:m("git.loadError"))),()=>{e=!0}},[t.id,n,null==C?void 0:C.path,null==C?void 0:C.oldPath]);let S=(0,i.useMemo)(()=>f&&C&&f.path===C.path?ei(f.diff):null,[f,C]);if(k)return(0,a.jsx)("section",{className:"gx-preview",children:(0,a.jsx)("p",{className:"gx-note err",children:k})});if(!g)return(0,a.jsx)("section",{className:"gx-preview",children:(0,a.jsx)("p",{className:"gx-note",children:m("git.loading")})});let A=!!C&&et.test(C.path);return(0,a.jsxs)("section",{className:"gx-preview gx-commitview ".concat(o?"embedded":""),"aria-label":u,children:[(0,a.jsx)("header",{className:"gx-chead",children:c(g)}),0===g.files.length?(0,a.jsx)("p",{className:"gx-note",children:m("git.cmp.nofiles")}):(0,a.jsx)("div",{className:"gx-cfilelist",role:"listbox",children:g.files.map(e=>{var s,t;return(0,a.jsxs)("button",{role:"option","aria-selected":j===e.path,className:"gx-cfile ".concat(j===e.path?"sel":""),onClick:()=>b(e.path),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,a.jsx)(ef,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},e.path)})}),C&&(0,a.jsxs)(a.Fragment,{children:[!A&&(0,a.jsx)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:(0,a.jsx)(I.$q,{value:N,onChange:y,options:[{id:"unified",label:m("git.layout.unified")},{id:"split",label:m("git.layout.split")}]})}),(0,a.jsx)("div",{className:"gx-body",children:A?(0,a.jsxs)("div",{className:"gx-picpair",children:["added"!==C.status&&(0,a.jsx)(ev,{agent:t,gitRef:d,path:null!=(s=C.oldPath)?s:C.path,label:m("git.img.before")}),"deleted"!==C.status&&(0,a.jsx)(ev,{agent:t,gitRef:h,path:C.path,label:m("git.img.after")})]}):S?S.binary?(0,a.jsx)("p",{className:"gx-note",children:m("git.diff.binary")}):0===S.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:m("git.diff.empty")}):(0,a.jsxs)(a.Fragment,{children:[(null==f?void 0:f.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:m("git.diff.truncated")}),(0,a.jsx)(eg,{parsed:S,layout:N,path:C.path})]}):(0,a.jsx)("p",{className:"gx-note",children:m("git.loading")})})]})]})}function ey(e){let{agent:s,sha:t,embedded:n=!1,focus:l}=e,{t:i}=(0,z.s9)();return(0,a.jsx)(eN,{agent:s,detailUrl:"/agents/".concat(s.id,"/git/commit?sha=").concat(t),embedded:n,focus:l,before:"".concat(t,"^"),after:t,label:t,diffUrl:e=>"/agents/".concat(s.id,"/git/commit-diff?sha=").concat(t,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>{let[s,...t]=e.message.split("\n"),n=t.join("\n").trim();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:s}),n&&(0,a.jsx)("pre",{className:"gx-cbody",children:n}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{className:"mono",children:e.sha.slice(0,10)}),(0,a.jsx)(Q.WQ,{text:e.sha,label:i("git.info.copySha"),compact:!0}),(0,a.jsxs)("span",{children:["\xb7 ",e.author," \xb7 ",(0,A.v7)(e.date)]}),(0,a.jsxs)("span",{children:["\xb7 ",i("git.hist.files",{count:e.files.length})]})]})]})}})}function ek(e){let{agent:s,sel:t,onSelect:n,onLoaded:l}=e,{t:c}=(0,z.s9)(),[r,o]=(0,i.useState)(null),[d,h]=(0,i.useState)(!1),[u,m]=(0,i.useState)(""),[g,j]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=!1;return o(null),j(""),x.FH.get("/agents/".concat(s.id,"/git/tags")).then(s=>{e||(o(s.tags),h(s.truncated),null==l||l(s.tags))}).catch(s=>!e&&j(s instanceof Error?s.message:"error")),()=>{e=!0}},[s.id]);let b=(0,i.useMemo)(()=>(null!=r?r:[]).filter(e=>!u||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(u.toLowerCase())),[r,u]);return g?(0,a.jsx)("p",{className:"gx-note err",children:g}):r?r.length?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"gx-filter",children:(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:c("git.tags.search"),value:u,onChange:e=>m(e.target.value),"aria-label":c("git.tags.search")})]})}),(0,a.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.tags"),children:[b.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":t===e.name,className:"gx-commit ".concat(t===e.name?"sel":""),onClick:()=>n(e),children:[(0,a.jsxs)("span",{className:"subj",children:[(0,a.jsx)(Z.A,{size:13,style:{verticalAlign:"-2px",marginRight:5}}),e.name]}),(0,a.jsx)("span",{className:"meta",children:e.subject||"—"}),(0,a.jsxs)("span",{className:"meta",children:[(0,a.jsx)("span",{className:"mono sha",children:e.sha.slice(0,8)})," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},e.name)),!b.length&&(0,a.jsx)("p",{className:"gx-note",children:c("git.noMatch",{query:u})}),d&&(0,a.jsx)("p",{className:"gx-note",children:c("git.tags.truncated",{count:r.length})})]})]}):(0,a.jsx)("p",{className:"gx-note",children:c("git.tags.empty")}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})}function ew(e){var s;let{agent:t,tag:n,onChanged:l}=e,{t:c}=(0,z.s9)(),r=(0,I.dj)(),[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(""),m=!!o&&/^[\w./-]+$/.test(o)&&!o.startsWith("-")&&!o.endsWith("/")&&!o.includes(".."),g=async()=>{if(o&&m)try{await x.FH.post("/agents/".concat(t.id,"/git/branch-create"),{branch:o,from:n.name}),r(c("git.tags.branchCreated",{branch:o})),d(null),u(""),null==l||l()}catch(e){u(e instanceof Error?e.message:"error")}},[p,j]=(0,i.useState)("files"),[b,f]=(0,i.useState)(null),[v,N]=(0,i.useState)(!1),[y,k]=(0,i.useState)(new Set),[w,C]=(0,i.useState)(""),[E,M]=(0,i.useState)(null),[F,R]=(0,i.useState)("");(0,i.useEffect)(()=>{j("files"),M(null),C(""),k(new Set)},[n.name]),(0,i.useEffect)(()=>{let e=!1;return f(null),R(""),x.FH.get("/agents/".concat(t.id,"/git/tag-tree?tag=").concat(encodeURIComponent(n.name))).then(s=>{e||(f(s.files),N(s.truncated),k(new Set(s.files.length<=40?s.files.flatMap(e=>e.split("/").slice(0,-1).map((e,s,t)=>t.slice(0,s+1).join("/"))):[])))}).catch(s=>!e&&R(s instanceof Error?s.message:c("git.loadError"))),()=>{e=!0}},[t.id,n.name]);let L=(0,i.useMemo)(()=>b?G(b,[]):null,[b]),_=(0,i.useMemo)(()=>L?J(L,y,{query:w,onlyChanged:!1}).slice(0,3e3):[],[L,y,w]);return(0,a.jsxs)("section",{className:"gx-preview gx-tagview","aria-label":n.name,children:[(0,a.jsxs)("header",{className:"gx-chead",children:[(0,a.jsxs)("h3",{children:[(0,a.jsx)(Z.A,{size:16,style:{verticalAlign:"-2px",marginRight:6}}),n.name]}),n.subject&&(0,a.jsx)("div",{children:n.subject}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{className:"gx-chip soft",children:n.annotated?c("git.tags.annotated"):c("git.tags.lightweight")}),(0,a.jsx)("span",{className:"mono",children:n.sha.slice(0,10)}),(0,a.jsx)(Q.WQ,{text:n.sha,label:c("git.info.copySha"),compact:!0}),(0,a.jsxs)("span",{children:["\xb7 ",(0,A.v7)(n.date)]}),b&&(0,a.jsxs)("span",{children:["\xb7 ",c("git.tags.nfiles",{count:b.length})]})]}),(0,a.jsx)("div",{className:"row gap-s wrap",style:{marginTop:8},children:null===o?(0,a.jsxs)("button",{className:"btn sm",onClick:()=>d(""),children:[(0,a.jsx)(K.A,{size:14}),c("git.tags.newBranch")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{className:"input mono",style:{maxWidth:240},autoFocus:!0,placeholder:c("git.tags.branchName"),value:o,onChange:e=>{d(e.target.value.trim()),u("")},"aria-label":c("git.tags.branchName"),onKeyDown:e=>{"Enter"===e.key&&g(),"Escape"===e.key&&d(null)}}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!m,onClick:()=>void g(),children:c("git.tags.createBranch")}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>{d(null),u("")},children:c("common.cancel")})]})}),h&&(0,a.jsx)("p",{className:"gx-note err",style:{margin:0},children:h}),(0,a.jsx)("div",{style:{marginTop:4},children:(0,a.jsx)(I.$q,{value:p,onChange:j,options:[{id:"files",label:c("git.tags.files")},{id:"changes",label:c("git.tags.changes")}]})})]}),"changes"===p?(0,a.jsx)(ey,{agent:t,sha:n.sha,embedded:!0},n.sha):F?(0,a.jsx)("p",{className:"gx-note err",children:F}):L?(0,a.jsxs)("div",{className:"gx-tagfiles",children:[(0,a.jsxs)("div",{className:"gx-tagtree",children:[(0,a.jsx)("div",{className:"gx-filter",children:(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:c("git.filterPlaceholder"),value:w,onChange:e=>C(e.target.value),"aria-label":c("git.filterPlaceholder")})]})}),(0,a.jsxs)("div",{className:"gx-list",role:"tree",children:[0===_.length?(0,a.jsx)("p",{className:"gx-note",children:w?c("git.noMatch",{query:w}):c("git.noFiles")}):_.map(e=>{let{node:s,depth:t}=e,n="dir"===s.type,l=n&&(!!w||y.has(s.path));return(0,a.jsxs)("button",{type:"button",role:"treeitem","aria-level":t+1,"aria-expanded":n?l:void 0,"aria-selected":!n&&E===s.path,className:"gx-row ".concat(n?"dir":"file"," ").concat(n||E!==s.path?"":"sel"),style:{paddingLeft:8+14*t},title:s.path,onClick:()=>{let e;return n?(e=s.path,k(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})):M(s.path)},children:[(0,a.jsx)("span",{className:"chev",children:n?l?(0,a.jsx)(S.A,{size:14}):(0,a.jsx)(O.A,{size:14}):null}),(0,a.jsx)("span",{className:"ico",children:n?l?(0,a.jsx)(V.A,{size:15}):(0,a.jsx)(H.A,{size:15}):(0,a.jsx)(q.A,{size:15})}),(0,a.jsx)("span",{className:"nm",children:s.name})]},s.path)}),v&&(0,a.jsx)("p",{className:"gx-note",children:c("git.treeTruncated",{count:null!=(s=null==b?void 0:b.length)?s:0})})]})]}),(0,a.jsx)("div",{className:"gx-tagfile",children:E?(0,a.jsx)(ej,{agent:t,gitRef:n.name,path:E}):(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:c("git.tags.pick")})})})]}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}var eC=t(71857),eS=t(72705),eA=t(21018);function ez(e){var s,t,n,l;let{refs:c,value:r,onChange:o,label:d,extra:h,icon:u=!0,compact:m=!1}=e,{t:g}=(0,z.s9)(),[x,j]=(0,i.useState)(!1),[b,f]=(0,i.useState)(""),v=(0,i.useRef)(null);(0,eA.s)(x,v,()=>j(!1)),(0,i.useEffect)(()=>{x&&f("")},[x]);let N=e=>!b||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(b.toLowerCase()),y=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.branches)?e:[]).filter(N)},[c,b]),k=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.remotes)?e:[]).filter(N)},[c,b]),w=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.tags)?e:[]).filter(N)},[c,b]),C=b.trim(),A=/^([0-9a-f]{7,40}|HEAD([~^]\d*)*)$/i.test(C)&&![...null!=(t=null==c?void 0:c.branches)?t:[],...null!=(n=null==c?void 0:c.tags)?n:[]].some(e=>e.name===C),E=e=>{o(e),j(!1)},M=(e,s)=>(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":r===e.name,className:"gx-refrow ".concat(r===e.name?"sel":""),onClick:()=>E(e.name),title:e.subject,children:[(0,a.jsxs)("span",{className:"nm",children:[r===e.name?(0,a.jsx)(eS.A,{size:13}):"tag"===s?(0,a.jsx)(Z.A,{size:13}):(0,a.jsx)(K.A,{size:13}),e.name]}),(0,a.jsxs)("span",{className:"sub",children:[e.subject||"—"," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},"".concat(s,":").concat(e.name));return(0,a.jsxs)("div",{className:"gx-brmenu gx-refpick",ref:v,children:[m?(0,a.jsxs)("button",{type:"button",className:"btn sm ".concat(r?"primary gx-refbtn":"ghost icon"),"aria-expanded":x,"aria-haspopup":"listbox","aria-label":d,title:d,onClick:()=>j(e=>!e),children:[(0,a.jsx)(K.A,{size:14}),r&&(0,a.jsx)("span",{className:"nm mono",children:r})]}):(0,a.jsxs)("button",{type:"button",className:"btn sm gx-refbtn","aria-expanded":x,"aria-haspopup":"listbox",title:d,onClick:()=>j(e=>!e),children:[u&&(0,a.jsx)(K.A,{size:14}),(0,a.jsx)("span",{className:"nm mono",children:null!=(l=null==h||null==(s=h.find(e=>e.value===r))?void 0:s.label)?l:r||g("git.ref.pick")}),(0,a.jsx)(S.A,{size:13})]}),x&&(0,a.jsxs)("div",{className:"gx-pop",role:"listbox",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{className:"input",autoFocus:!0,placeholder:g("git.ref.search"),value:b,onChange:e=>f(e.target.value),"aria-label":g("git.ref.search"),onKeyDown:e=>{"Enter"===e.key&&A&&E(C)}})]}),(0,a.jsxs)("div",{className:"gx-brlist",children:[!b&&(null==h?void 0:h.map(e=>(0,a.jsx)("button",{type:"button",role:"option","aria-selected":r===e.value,className:"gx-refrow ".concat(r===e.value?"sel":""),onClick:()=>E(e.value),children:(0,a.jsxs)("span",{className:"nm",children:[r===e.value&&(0,a.jsx)(eS.A,{size:13}),e.label]})},e.value))),A&&(0,a.jsx)("button",{type:"button",className:"gx-refrow",onClick:()=>E(C),children:(0,a.jsx)("span",{className:"nm mono",children:g("git.ref.useCommit",{ref:C.slice(0,12)})})}),y.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.branches")}),y.map(e=>M(e,"branch")),w.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.tags")}),w.slice(0,200).map(e=>M(e,"tag")),k.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.remotes")}),k.slice(0,200).map(e=>M(e,"branch")),c&&!y.length&&!w.length&&!k.length&&!A&&(0,a.jsx)("p",{className:"gx-note",children:g("git.ref.none")})]})]})]})}function eE(e){let{refs:s,sel:t,onChange:n}=e,{t:l}=(0,z.s9)();return(0,a.jsxs)("div",{className:"gx-cmpside",children:[(0,a.jsx)("label",{className:"label",children:l("git.cmp.base")}),(0,a.jsx)(ez,{refs:s,value:t.base,onChange:e=>n({...t,base:e})}),(0,a.jsx)("div",{className:"row",style:{justifyContent:"center"},children:(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>n({base:t.head,head:t.base}),disabled:!t.base&&!t.head,"aria-label":l("git.cmp.swap"),title:l("git.cmp.swap"),children:(0,a.jsx)(eC.A,{size:15,style:{transform:"rotate(90deg)"}})})}),(0,a.jsx)("label",{className:"label",children:l("git.cmp.head")}),(0,a.jsx)(ez,{refs:s,value:t.head,onChange:e=>n({...t,head:e})}),(!t.base||!t.head)&&(0,a.jsx)("p",{className:"muted small",children:l("git.cmp.pick")})]})}function eM(e){let{agent:s,sel:t}=e,{t:n}=(0,z.s9)();if(!(t.base&&t.head))return(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:n("git.cmp.pick")})})});let l="base=".concat(encodeURIComponent(t.base),"&head=").concat(encodeURIComponent(t.head));return(0,a.jsx)(eN,{agent:s,detailUrl:"/agents/".concat(s.id,"/git/compare?").concat(l),before:t.base,after:t.head,label:"".concat(t.base," → ").concat(t.head),diffUrl:e=>"/agents/".concat(s.id,"/git/compare-diff?").concat(l,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h3",{children:[(0,a.jsx)("span",{className:"mono",children:t.base})," → ",(0,a.jsx)("span",{className:"mono",children:t.head})]}),e.base.sha===e.head.sha?(0,a.jsx)("p",{className:"muted small",style:{margin:0},children:n("git.cmp.same")}):(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{children:n("git.cmp.summary",{ahead:e.ahead,behind:e.behind})}),(0,a.jsxs)("span",{children:["\xb7 ",n("git.hist.files",{count:e.files.length})]})]}),e.commits.length>0&&(0,a.jsxs)("details",{className:"gx-cmpcommits",children:[(0,a.jsx)("summary",{children:n("git.cmp.commits",{count:e.ahead})}),(0,a.jsx)("ul",{children:e.commits.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("span",{className:"mono sha",children:e.short})," ",e.subject," ",(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",e.author," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},e.sha))}),e.commitsTruncated&&(0,a.jsx)("p",{className:"muted small",children:n("git.cmp.more",{count:e.commits.length})})]})]})})}function eF(e){let s=e.split("\n"),t=[];for(let e=0;e<s.length;e++){if(!/^<{7}( |$)/.test(s[e]))continue;let a=-1,n=-1,l=-1;for(let t=e+1;t<s.length&&!/^<{7}( |$)/.test(s[t]);t++)if(/^\|{7}( |$)/.test(s[t])&&a<0)n=t;else if("======="===s[t]&&a<0)a=t;else if(/^>{7}( |$)/.test(s[t])&&a>=0){l=t;break}a<0||l<0||(t.push({start:e,end:l,ours:s.slice(e+1,n>=0?n:a),base:n>=0?s.slice(n+1,a):void 0,theirs:s.slice(a+1,l),oursLabel:s[e].slice(8).trim(),theirsLabel:s[l].slice(8).trim()}),e=l)}return t}function eR(e,s,t){let a=eF(e)[s];if(!a)return e;let n={ours:a.ours,theirs:a.theirs,"ours-theirs":[...a.ours,...a.theirs],"theirs-ours":[...a.theirs,...a.ours]}[t],l=e.split("\n");return l.splice(a.start,a.end-a.start+1,...n),l.join("\n")}var eP=t(96213);function eL(e){let{agent:s,path:t,state:n,a:l,onResolved:c}=e,{t:r}=(0,z.s9)(),[o,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(""),[g,p]=(0,i.useState)(null),[j,b]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=!1;return h(null),p(null),x.FH.get("/agents/".concat(s.id,"/git/file?path=").concat(encodeURIComponent(t))).then(s=>{e||(h(s),m(s.content))}).catch(s=>!e&&p(s instanceof Error?s.message:r("git.loadError"))),()=>{e=!0}},[s.id,t,j]);let f=(0,i.useMemo)(()=>eF(u),[u]),v="rebase"!==n&&"stash"!==n,N=e=>"mine"===e===v?"ours":"theirs",y=e=>"both-mine"===e?v?"ours-theirs":"theirs-ours":"both-remote"===e?v?"theirs-ours":"ours-theirs":N(e),k=/^(<{7}|>{7})( |$)/m.test(u),w=!!o&&!o.binary&&!o.truncated,C=!!l.busy,S=async e=>{await l.run("resolve",r("git.res.done"),"resolve-side",{path:t,side:N(e)})&&c()},A=async()=>{await l.run("resolve",r("git.res.done"),"resolve",{path:t,content:u})&&c()},E=async()=>{await l.run("unresolve",r("git.res.restored"),"unresolve",{path:t})&&b(e=>e+1)},M=t.lastIndexOf("/"),F=M>=0?t.slice(0,M+1):"",R=t.slice(M+1);return(0,a.jsxs)("section",{className:"gx-preview gx-resolver","aria-label":t,children:[(0,a.jsxs)("header",{className:"gx-phead",children:[(0,a.jsxs)("div",{className:"gx-ptitle",children:[(0,a.jsxs)("span",{className:"gx-path mono",title:t,children:[(0,a.jsx)("span",{className:"dir",children:F}),(0,a.jsx)("b",{children:R})]}),(0,a.jsx)("span",{className:"gx-chip st-conflict",children:r("git.status.conflict")}),w&&(0,a.jsx)("span",{className:"muted small",children:f.length>0?r("git.res.left",{count:f.length}):r("git.res.none")})]}),(0,a.jsxs)("div",{className:"gx-ptools",children:[(0,a.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allMine.hint"),onClick:()=>void S("mine"),children:r("git.res.allMine")}),(0,a.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allRemote.hint"),onClick:()=>void S("remote"),children:r("git.res.allRemote")}),(0,a.jsx)(Q.WQ,{text:t,label:r("git.copyPath")})]})]}),g?(0,a.jsx)("p",{className:"gx-note err",children:g}):o?w?(0,a.jsxs)("div",{className:"gx-rbody",children:[f.length>0&&(0,a.jsx)("div",{className:"gx-rblocks",children:f.map((e,s)=>(0,a.jsxs)("div",{className:"gx-rcard",children:[(0,a.jsxs)("div",{className:"gx-rtitle",children:[(0,a.jsx)("b",{children:r("git.res.block",{n:s+1,total:f.length})}),(0,a.jsx)("span",{className:"muted small",children:r("git.res.line",{n:e.start+1})})]}),(0,a.jsx)("div",{className:"gx-rsides",children:["mine","remote"].map(l=>{let i,c="ours"===N(l)?e.ours:e.theirs,o=!(i="ours"===N(l)?e.oursLabel:e.theirsLabel)||["HEAD","ours","theirs","Updated upstream","Stashed changes"].includes(i)?"":i;return(0,a.jsxs)("div",{className:"gx-rside ".concat(l),children:[(0,a.jsxs)("div",{className:"gx-rhead",children:[(0,a.jsx)("span",{children:"mine"===l?"stash"===n?r("git.res.mine.stash"):r("git.res.mine"):"stash"===n?r("git.res.remote.stash"):r("git.res.remote")}),o&&(0,a.jsx)("i",{className:"ref",children:o})]}),(0,a.jsx)("pre",{children:c.length?(0,a.jsx)(eo.Cy,{text:c.join("\n"),path:t}):(0,a.jsx)("span",{className:"muted",children:r("git.res.empty")})}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eR(e,s,y(l))),children:"mine"===l?r("git.res.keepMine"):r("git.res.keepRemote")})]},l)})}),(0,a.jsxs)("div",{className:"gx-rboth",children:[(0,a.jsxs)("span",{className:"small muted",children:[r("git.res.both"),":"]}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eR(e,s,y("both-mine"))),children:r("git.res.bothMine")}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eR(e,s,y("both-remote"))),children:r("git.res.bothRemote")})]})]},"".concat(s,"-").concat(e.start)))}),(0,a.jsxs)("div",{className:"gx-rresult",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"label grow",htmlFor:"gx-result",children:r("git.res.result")}),(0,a.jsx)("span",{className:"small muted",children:r("git.res.editHint")})]}),(0,a.jsx)(eP.B,{id:"gx-result",label:r("git.res.result"),value:u,path:t,onChange:m})]}),(0,a.jsxs)("footer",{className:"gx-rfoot",children:[(0,a.jsxs)("button",{className:"btn ghost sm",disabled:C,onClick:()=>void E(),title:r("git.res.restore.hint"),children:[(0,a.jsx)(d.A,{size:14}),r("git.res.restore")]}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"btn primary",disabled:C||k,onClick:()=>void A(),children:r("git.res.markResolved")})]})]}):(0,a.jsx)("p",{className:"gx-note",children:r("git.res.noEdit")}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")})]})}function e_(e){let{agent:s,plan:t,a:n,onClose:l,onGo:i}=e,{t:c}=(0,z.s9)();return(0,a.jsxs)(I.TM,{title:c("git.sw.title",{branch:t.to}),confirmLabel:c("git.sw.anyway"),onConfirm:()=>{n.busy||i()},onClose:l,children:[t.carried>0&&(0,a.jsx)("p",{className:"confirm-body",children:c("git.sw.carried",{count:t.carried,from:t.from})}),(0,a.jsxs)("div",{className:"gx-sw-warn",role:"alert",children:[t.selfRunning&&(0,a.jsx)("div",{children:c("git.warn.running",{name:s.name})}),t.others.length>0&&(0,a.jsx)("div",{children:c("git.sw.others",{count:t.others.length,names:t.others.map(e=>e.name).join(", ")})})]})]})}var eI=t(43380),eT=t(24328),eU=t(97356);function eH(e){let{stashes:s,sel:t,onSelect:n,onSave:l,canSave:i}=e,{t:c}=(0,z.s9)();return(0,a.jsxs)("div",{className:"gx-stashes",children:[(0,a.jsx)("div",{className:"gx-stash-head",children:(0,a.jsxs)("button",{className:"btn sm",disabled:!i,title:i?void 0:c("git.stash.nothing"),onClick:l,children:[(0,a.jsx)(eI.A,{size:14}),c("git.stash.save")]})}),s?0===s.length?(0,a.jsx)("p",{className:"gx-note",children:c("git.stash.empty")}):(0,a.jsx)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.stashes"),children:s.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":t===e.sha,className:"gx-commit ".concat(t===e.sha?"sel":""),onClick:()=>n(e.sha),children:[(0,a.jsx)("span",{className:"subj",children:e.message||"—"}),(0,a.jsxs)("span",{className:"meta",children:[e.branch&&(0,a.jsxs)(a.Fragment,{children:[e.branch," \xb7 "]}),(0,p.KN)(Date.parse(e.date))]}),e.smart&&(0,a.jsx)("span",{className:"refs",children:(0,a.jsx)("i",{className:"ref",children:c("git.stash.smart")})})]},e.sha))}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}function eD(e){let{a:s,onClose:t}=e,{t:n}=(0,z.s9)(),[l,c]=(0,i.useState)(""),r=async()=>{t(),await s.run("stash",n("git.stash.saved"),"stash-save",{message:l})};return(0,a.jsxs)(I.aF,{title:n("git.stash.save"),onClose:t,children:[(0,a.jsx)("p",{className:"confirm-body",children:n("git.stash.save.body")}),(0,a.jsx)("input",{className:"input",autoFocus:!0,value:l,maxLength:200,placeholder:n("git.stash.save.placeholder"),onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&r()},"aria-label":n("git.stash.save.placeholder")}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:t,children:n("common.cancel")}),(0,a.jsx)("button",{className:"btn primary",disabled:!!s.busy,onClick:()=>void r(),children:n("git.stash.save")})]})]})}function eK(e){var s,t;let{agent:n,stash:l,a:c}=e,{t:r}=(0,z.s9)(),[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(null),[m,g]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[f,v]=(0,i.useState)(!1),[N,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return d(null),u(null),g(null),b(null),y(null),Promise.all([x.FH.get("/agents/".concat(n.id,"/git/stash?sha=").concat(l.sha)),x.FH.get("/agents/".concat(n.id,"/git/commit?sha=").concat(l.sha))]).then(s=>{let[t,a]=s;if(e)return;d(t),u(a);let n=a.files[0];g(n?{path:n.path,untracked:!1,oldPath:n.oldPath}:t.untracked[0]?{path:t.untracked[0],untracked:!0}:null)}).catch(s=>!e&&y(s instanceof Error?s.message:r("git.loadError"))),()=>{e=!0}},[n.id,l.sha]),(0,i.useEffect)(()=>{if(!m||!o)return void b(null);let e=m.untracked?o.untrackedSha:l.sha;if(!e)return;let s=!1;return b(null),x.FH.get("/agents/".concat(n.id,"/git/commit-diff?sha=").concat(e,"&path=").concat(encodeURIComponent(m.path)).concat(m.oldPath?"&old=".concat(encodeURIComponent(m.oldPath)):"")).then(e=>!s&&b(e)).catch(e=>!s&&y(e instanceof Error?e.message:r("git.loadError"))),()=>{s=!0}},[n.id,l.sha,o,null==m?void 0:m.path,null==m?void 0:m.untracked]);let k=(0,i.useMemo)(()=>j?ei(j.diff):null,[j]),w=!!c.busy,C=e=>void c.run("stash",e?r("git.stash.popped"):r("git.stash.applied"),"stash-apply",{sha:l.sha,pop:e}),S=(null!=(s=null==h?void 0:h.files.length)?s:0)+(null!=(t=null==o?void 0:o.untracked.length)?t:0);return(0,a.jsxs)("section",{className:"gx-preview gx-commitview","aria-label":l.message,children:[(0,a.jsxs)("header",{className:"gx-chead",children:[(0,a.jsx)("h3",{children:l.message||"—"}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsxs)("span",{children:[l.branch&&"".concat(l.branch," \xb7 "),(0,p.KN)(Date.parse(l.date))]}),o&&(0,a.jsxs)("span",{children:["\xb7 ",r("git.hist.files",{count:S})]})]}),(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsxs)("button",{className:"btn sm",disabled:w,title:r("git.stash.apply.hint"),onClick:()=>C(!1),children:[(0,a.jsx)(eT.A,{size:14}),r("git.stash.apply")]}),(0,a.jsx)("button",{className:"btn sm primary",disabled:w,title:r("git.stash.pop.hint"),onClick:()=>C(!0),children:r("git.stash.pop")}),(0,a.jsxs)("button",{className:"btn sm danger",disabled:w,onClick:()=>v(!0),children:[(0,a.jsx)(eU.A,{size:14}),r("git.stash.drop")]})]})]}),N?(0,a.jsx)("p",{className:"gx-note err",children:N}):h&&o?0===S?(0,a.jsx)("p",{className:"gx-note",children:r("git.hist.noFiles")}):(0,a.jsxs)("div",{className:"gx-cfilelist",role:"listbox",children:[h.files.map(e=>{var s,t;return(0,a.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e.path&&!m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)!==e.path||m.untracked?"":"sel"),onClick:()=>g({path:e.path,untracked:!1,oldPath:e.oldPath}),children:[(0,a.jsx)(ef,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},"t-".concat(e.path))}),o.untracked.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e&&m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)===e&&m.untracked?"sel":""),onClick:()=>g({path:e,untracked:!0}),children:[(0,a.jsx)(ef,{status:"untracked"}),(0,a.jsx)("span",{className:"mono nm",children:e})]},"u-".concat(e)))]}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")}),m&&(0,a.jsx)("div",{className:"gx-body",children:k?k.binary?(0,a.jsx)("p",{className:"gx-note",children:r("git.diff.binary")}):0===k.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:r("git.diff.empty")}):(0,a.jsx)(eg,{parsed:k,layout:"unified",path:m.path,cutOff:!!(null==j?void 0:j.truncated)}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")})}),f&&(0,a.jsx)(I.TM,{danger:!0,title:r("git.stash.drop.title"),body:r("git.stash.drop.body",{name:l.message||"—"}),confirmLabel:r("git.stash.drop"),onClose:()=>v(!1),onConfirm:()=>{w||c.run("stash",r("git.stash.dropped"),"stash-drop",{sha:l.sha})},children:(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})})]})}var eO=t(59959),eW=t(6819),eq=t(50703),e$=t(75014),eB=t(10216);function eG(e){let{a:s}=e,{t}=(0,z.s9)(),n=s.notice;return n?(0,a.jsxs)("div",{className:"gx-notice err",role:"alert",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("b",{className:"grow",children:n.title}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>s.setNotice(null),"aria-label":t("common.close"),children:(0,a.jsx)(el.A,{size:14})})]}),(0,a.jsx)("pre",{children:n.text}),n.diverged&&(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsx)("span",{className:"small muted",children:t("git.notice.diverged")}),(0,a.jsx)("button",{className:"btn sm",disabled:!!s.busy,onClick:()=>void s.run("pull",t("git.done.pull"),"pull",{mode:"merge"}),children:t("git.pull.merge")}),(0,a.jsx)("button",{className:"btn sm",disabled:!!s.busy,onClick:()=>void s.run("pull",t("git.done.pull"),"pull",{mode:"rebase"}),children:t("git.pull.rebase")})]})]}):null}function eJ(e){let{a:s,ahead:t,behind:n,detached:l,changeCount:i,onCommit:c}=e,{t:r}=(0,z.s9)(),o=!!s.busy;return(0,a.jsxs)("div",{className:"gx-acts",role:"group","aria-label":r("git.act.group"),children:[(0,a.jsx)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.fetch"),": ").concat(r("git.act.fetch.hint")),"aria-label":r("git.act.fetch"),onClick:()=>void s.run("fetch",r("git.done.fetch"),"fetch"),children:"fetch"===s.busy?(0,a.jsx)(eO.A,{size:14,className:"spin"}):(0,a.jsx)(eW.A,{size:14})}),(0,a.jsxs)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.pull"),": ").concat(r("git.act.pull.hint")),"aria-label":r("git.act.pull"),onClick:()=>void s.run("pull",r("git.done.pull"),"pull"),children:["pull"===s.busy?(0,a.jsx)(eO.A,{size:14,className:"spin"}):(0,a.jsx)(eq.A,{size:14}),n>0&&(0,a.jsx)("span",{className:"ct",children:n})]}),(0,a.jsxs)("button",{className:"btn sm",disabled:o||l,title:"".concat(r("git.act.push"),": ").concat(r("git.act.push.hint")),"aria-label":r("git.act.push"),onClick:()=>void s.run("push",r("git.done.push"),"push"),children:["push"===s.busy?(0,a.jsx)(eO.A,{size:14,className:"spin"}):(0,a.jsx)(e$.A,{size:14}),t>0&&(0,a.jsx)("span",{className:"ct",children:t})]}),(0,a.jsxs)("button",{className:"btn sm primary",disabled:o||0===i,title:0===i?r("git.commit.nothing"):void 0,onClick:c,children:["commit"===s.busy?(0,a.jsx)(eO.A,{size:14,className:"spin"}):(0,a.jsx)(eB.A,{size:14}),r("git.act.commit"),i>0&&(0,a.jsx)("span",{className:"ct",children:i})]})]})}var eQ=t(67384);function eX(e){let{agent:s,a:t,current:n,onSwitch:l}=e,{t:c}=(0,z.s9)(),[r,o]=(0,i.useState)(!1),[d,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(""),[g,j]=(0,i.useState)(""),[b,f]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),[y,k]=(0,i.useState)(""),w=(0,i.useRef)(null);(0,eA.s)(r,w,()=>o(!1)),(0,i.useEffect)(()=>{r&&(k(""),f(null),x.FH.get("/agents/".concat(s.id,"/git/branches")).then(h).catch(e=>k(e instanceof Error?e.message:"error")))},[r,s.id]);let C=(0,i.useMemo)(()=>{var e;return(null!=(e=null==d?void 0:d.local)?e:[]).filter(e=>e.name.toLowerCase().includes(u.toLowerCase()))},[d,u]),A=(0,i.useMemo)(()=>{var e,s;let t=new Set((null!=(e=null==d?void 0:d.local)?e:[]).map(e=>e.name));return(null!=(s=null==d?void 0:d.remote)?s:[]).filter(e=>!t.has(e.name.split("/").slice(1).join("/"))&&e.name.toLowerCase().includes(u.toLowerCase()))},[d,u]),E=async(e,s,a,n)=>{o(!1),await t.run(e,s,a,n)},M=/^[\w./-]+$/.test(g)&&!g.startsWith("-")&&!g.endsWith("/")&&!g.includes("..");return(0,a.jsxs)("div",{className:"gx-brmenu",ref:w,children:[(0,a.jsxs)("button",{type:"button",className:"btn sm","aria-expanded":r,"aria-haspopup":"dialog",onClick:()=>o(e=>!e),children:[(0,a.jsx)(K.A,{size:14}),c("git.act.branches"),(0,a.jsx)(S.A,{size:13})]}),r&&(0,a.jsxs)("div",{className:"gx-pop",role:"dialog","aria-label":c("git.act.branches"),children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{className:"input",autoFocus:!0,placeholder:c("git.br.search"),value:u,onChange:e=>m(e.target.value),"aria-label":c("git.br.search")})]}),(0,a.jsxs)("div",{className:"gx-newbr",children:[(0,a.jsx)("input",{className:"input mono",placeholder:c("git.br.newPlaceholder"),value:g,onChange:e=>j(e.target.value.trim()),"aria-label":c("git.br.new",{branch:null!=n?n:""}),onKeyDown:e=>{"Enter"===e.key&&M&&E("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0})}}),(0,a.jsxs)("button",{className:"btn sm",disabled:!M||!!t.busy,title:c("git.br.new",{branch:null!=n?n:"…"}),onClick:()=>void E("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0}),children:[(0,a.jsx)(R.A,{size:14}),c("git.br.create")]})]}),y&&(0,a.jsx)("p",{className:"gx-note err",children:y}),(0,a.jsxs)("div",{className:"gx-brlist",children:[C.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:c("git.br.local")}),C.map(e=>(0,a.jsxs)("div",{className:"gx-br ".concat(e.name===n?"cur":""),children:[(0,a.jsxs)("button",{className:"grow",disabled:e.name===n||!!t.busy,onClick:()=>{o(!1),l(e.name)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,a.jsxs)("span",{className:"nm",children:[e.name===n&&(0,a.jsx)(eS.A,{size:13}),e.name]}),(0,a.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]}),e.name!==n&&(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>f(e.name),"aria-label":c("git.br.merge",{branch:null!=n?n:""}),title:c("git.br.merge",{branch:null!=n?n:""}),children:(0,a.jsx)(eQ.A,{size:14})}),e.name!==n&&(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>{t.setNotice(null),N(e.name),o(!1)},"aria-label":c("git.br.delete",{branch:e.name}),title:c("git.br.delete",{branch:e.name}),children:(0,a.jsx)(eU.A,{size:14})})]},e.name)),A.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:c("git.br.remote")}),A.map(e=>(0,a.jsxs)("div",{className:"gx-br",children:[(0,a.jsxs)("button",{className:"grow",disabled:!!t.busy,onClick:()=>{let s=e.name.split("/").slice(1).join("/");o(!1),l(s)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,a.jsx)("span",{className:"nm",children:e.name}),(0,a.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]}),(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>f(e.name),"aria-label":c("git.br.merge",{branch:null!=n?n:""}),title:c("git.br.merge",{branch:null!=n?n:""}),children:(0,a.jsx)(eQ.A,{size:14})})]},e.name)),d&&!C.length&&!A.length&&(0,a.jsx)("p",{className:"gx-note",children:c("git.br.none")})]}),b&&(0,a.jsxs)("div",{className:"gx-mergeask",children:[(0,a.jsx)("span",{children:c("git.br.mergeAsk",{from:b,into:null!=n?n:""})}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>f(null),children:c("common.cancel")}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!!t.busy,onClick:()=>void E("merge",c("git.done.merge",{branch:b}),"merge",{branch:b}),children:c("git.br.mergeGo")})]})]})]}),v&&(0,a.jsxs)(I.aF,{title:c("git.br.delete",{branch:v}),onClose:()=>N(null),children:[(0,a.jsx)("p",{className:"confirm-body",children:c("git.br.deleteAsk",{branch:v})}),t.notice&&(0,a.jsx)("pre",{className:"gx-notice err gx-prewrap",children:t.notice.text}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:()=>N(null),children:c("common.cancel")}),t.notice&&/not fully merged/i.test(t.notice.text)?(0,a.jsx)("button",{className:"btn danger",disabled:!!t.busy,onClick:async()=>{await t.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v,force:!0})&&N(null)},children:c("git.br.deleteForce")}):(0,a.jsx)("button",{className:"btn danger",disabled:!!t.busy,onClick:async()=>{await t.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v})&&N(null)},children:c("git.br.deleteGo")})]})]})]})}function eY(e){let{changes:s,a:t,onClose:n,initialMessage:l=""}=e,{t:c}=(0,z.s9)(),[r,o]=(0,i.useState)(()=>new Set(s.map(e=>e.path))),[d,h]=(0,i.useState)(l),u=s.filter(e=>r.has(e.path)),m=u.flatMap(e=>e.oldPath?[e.path,e.oldPath]:[e.path]),g=!!d.trim()&&u.length>0&&!t.busy,x=async e=>{if(!await t.run("commit",c("git.done.commit"),"commit",{message:d,paths:m}))return void n();n(),e&&await t.run("push",c("git.done.push"),"push")};return(0,a.jsxs)(I.aF,{title:c("git.commit.title"),onClose:n,children:[(0,a.jsxs)("div",{className:"gx-cfiles",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"small muted grow",children:c("git.commit.selected",{n:u.length,total:s.length})}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set(s.map(e=>e.path))),children:c("git.commit.all")}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set),children:c("git.commit.none")})]}),(0,a.jsx)("div",{className:"gx-clist",children:s.map(e=>{var s,t;return(0,a.jsxs)("label",{className:"gx-crow",title:e.path,children:[(0,a.jsx)("input",{type:"checkbox",checked:r.has(e.path),onChange:()=>{let s;return s=e.path,o(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})}}),(0,a.jsx)(ef,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},e.path)})})]}),(0,a.jsxs)("div",{className:"field",children:[(0,a.jsx)("label",{children:c("git.commit.message")}),(0,a.jsx)("textarea",{className:"textarea",rows:4,autoFocus:!0,value:d,onChange:e=>h(e.target.value),placeholder:c("git.commit.placeholder"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&g&&x(!1)}}),(0,a.jsx)("span",{className:"hint",children:c("git.commit.hint")})]}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:n,children:c("common.cancel")}),(0,a.jsx)("button",{className:"btn",disabled:!g,onClick:()=>void x(!1),children:"commit"===t.busy?c("git.commit.committing"):c("git.commit.go")}),(0,a.jsx)("button",{className:"btn primary",disabled:!g,onClick:()=>void x(!0),children:c("git.commit.goPush")})]})]})}function eZ(e){let{agent:s,head:t,sel:n,onSelect:l,refs:c,path:r,onClearPath:o}=e,{t:d}=(0,z.s9)(),[h,u]=(0,i.useState)(null),[m,g]=(0,i.useState)(!1),[j,b]=(0,i.useState)(!1),[f,v]=(0,i.useState)(""),[N,y]=(0,i.useState)(""),[k,w]=(0,i.useState)("message"),[C,S]=(0,i.useState)(""),[A,E]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=setTimeout(()=>E(N.trim()),350);return()=>clearTimeout(e)},[N]);let M=!!(A||r||C),F=async e=>{b(!0);try{let t="skip=".concat(e).concat(A?"&q=".concat(encodeURIComponent(A),"&by=").concat(k):"").concat(r?"&path=".concat(encodeURIComponent(r)):"").concat(C?"&ref=".concat(encodeURIComponent(C)):""),a=await x.FH.get("/agents/".concat(s.id,"/git/log?").concat(t));return u(s=>0===e?a.commits:[...null!=s?s:[],...a.commits]),g(a.hasMore),v(""),a.commits}catch(e){return v(e instanceof Error?e.message:"error"),null}finally{b(!1)}},R=(0,i.useRef)("");return(0,i.useEffect)(()=>{let e="".concat(A,"|").concat(k,"|").concat(null!=r?r:"","|").concat(C),s=e!==R.current;R.current=e,F(0).then(e=>{e&&e.length&&(s||!n)&&l(e[0].sha)})},[s.id,t,A,k,r,C]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"gx-hfilter",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:d("git.hist.search"),value:N,onChange:e=>y(e.target.value),"aria-label":d("git.hist.search"),title:"content"===k?d("git.hist.by.hint"):void 0})]}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsxs)("select",{className:"input",value:k,onChange:e=>w(e.target.value),"aria-label":d("git.hist.search"),title:d("git.hist.by.hint"),children:[(0,a.jsx)("option",{value:"message",children:d("git.hist.by.message")}),(0,a.jsx)("option",{value:"author",children:d("git.hist.by.author")}),(0,a.jsx)("option",{value:"content",children:d("git.hist.by.content")})]}),(0,a.jsx)(ez,{refs:c,value:C,onChange:S,extra:[{value:"",label:d("git.hist.branchCurrent")},{value:"all",label:d("git.hist.branchAll")}]})]}),r&&(0,a.jsxs)("div",{className:"gx-chip soft gx-pathchip",children:[(0,a.jsx)("span",{className:"mono nm",title:r,children:d("git.hist.file",{path:r})}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:o,"aria-label":d("git.hist.clearFile"),title:d("git.hist.clearFile"),children:(0,a.jsx)(el.A,{size:13})})]})]}),f?(0,a.jsx)("p",{className:"gx-note err",children:f}):h?h.length?(0,a.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":d("git.tab.history"),children:[h.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":n===e.sha,className:"gx-commit ".concat(n===e.sha?"sel":""),onClick:()=>l(e.sha),children:[(0,a.jsx)("span",{className:"subj",children:e.subject||"—"}),(0,a.jsxs)("span",{className:"meta",children:[(0,a.jsx)("span",{className:"mono sha",children:e.short})," \xb7 ",e.author," \xb7 ",(0,p.KN)(Date.parse(e.date))]}),(e.refs.length>0||e.merge)&&(0,a.jsxs)("span",{className:"refs",children:[e.merge&&(0,a.jsx)("i",{className:"ref",children:d("git.hist.merge")}),e.refs.slice(0,3).map(e=>(0,a.jsx)("i",{className:"ref",children:e},e))]})]},e.sha)),m&&(0,a.jsx)("button",{className:"btn sm gx-more",disabled:j,onClick:()=>void F(h.length),children:j?d("git.loading"):d("git.hist.more")})]}):(0,a.jsx)("p",{className:"gx-note",children:M?d("git.hist.noMatch"):d("git.hist.empty")}):(0,a.jsx)("p",{className:"gx-note",children:d("git.loading")})]})}function eV(e){let{files:s,all:t,summary:n,file:l,onConfirm:i,onClose:c}=e,{t:r}=(0,z.s9)(),o=(0,a.jsxs)("ul",{className:"gx-dlist",children:[s.slice(0,8).map(e=>(0,a.jsx)("li",{className:"mono",children:e},e)),s.length>8&&(0,a.jsx)("li",{className:"muted",children:r("hover.more",{count:s.length-8})})]});if(!t&&l&&!s.length){var d;let e=l.add||l.del?" (+".concat(l.add," −").concat(l.del,")"):"";return(0,a.jsxs)(I.TM,{danger:!0,title:r("git.discard.file.title"),confirmLabel:r("git.discard.file.go"),onConfirm:i,onClose:c,children:[(0,a.jsx)("p",{className:"gx-file-eff mono",children:l.path}),(0,a.jsx)("p",{className:"confirm-body",children:"deleted"===l.status?r("git.discard.file.deleted"):"renamed"===l.status?r("git.discard.file.renamed",{from:null!=(d=l.oldPath)?d:""}):r("git.discard.file.modified",{lines:e})}),(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]})}return t?(0,a.jsxs)(I.TM,{danger:!0,title:r("git.discard.all.title"),confirmLabel:r("git.discard.all.go"),onConfirm:i,onClose:c,children:[(0,a.jsxs)("ul",{className:"gx-effects",children:[n&&n.restore>0&&(0,a.jsx)("li",{children:r("git.discard.all.restore",{count:n.restore})}),s.length>0&&(0,a.jsxs)("li",{className:"bad",children:[(0,a.jsx)("b",{children:r("git.discard.all.delete",{count:s.length})}),o]})]}),n&&(0,a.jsx)("p",{className:"muted small confirm-body",children:r("git.discard.all.lines",{add:n.add,del:n.del})}),(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]}):(0,a.jsx)(I.TM,{danger:!0,title:r("git.discard.confirm.title"),body:r("git.discard.confirm.body",{count:s.length}),confirmLabel:r("git.discard.confirm.go"),onConfirm:i,onClose:c,children:o})}var e0=t(8591);function e1(e){var s,t;let{agent:n,path:l,ignored:c=!1,change:r,stamp:o,refs:d,focusLine:h,onHistory:m,onOpenCommit:g,onDiscard:p,onDiscardHunk:j,onDiscardLines:b}=e,{t:f}=(0,z.s9)(),[v,N]=(0,i.useState)(!1),y=!!r&&!et.test(l),k=ea.test(l),w=h?"file":y?"diff":k?"preview":"file",[C,S]=(0,i.useState)(w),[E,M]=(0,i.useState)("unified"),[F,R]=(0,i.useState)(null),[P,L]=(0,i.useState)(null),[_,T]=(0,i.useState)(null),[U,H]=(0,i.useState)(!1),[D,K]=(0,i.useState)(!1),O=et.test(l),[q,$]=(0,i.useState)(null);(0,i.useEffect)(()=>{$(null)},[l]),(0,i.useEffect)(()=>{S(w),K(!1)},[l,y]),(0,i.useEffect)(()=>{let e=!1;T(null);let s="path=".concat(encodeURIComponent(l));return H(!0),("diff"===C&&r?x.FH.get("/agents/".concat(n.id,"/git/diff?").concat(s).concat(r.oldPath?"&old=".concat(encodeURIComponent(r.oldPath)):"")).then(s=>!e&&R(s)):O?Promise.resolve():x.FH.get("/agents/".concat(n.id,"/git/file?").concat(s)).then(s=>!e&&L(s))).catch(s=>!e&&T(s instanceof Error?s.message:f("git.loadError"))).finally(()=>!e&&H(!1)),()=>{e=!0}},[n.id,l,C,null==r?void 0:r.status,null==r?void 0:r.oldPath,o]);let B=(0,i.useMemo)(()=>F&&F.path===l?ei(F.diff):null,[F,l]),[G,J]=(0,i.useState)(null),X=(null==r?void 0:r.status)==="untracked"||(null==r?void 0:r.status)==="added"&&!r.oldPath;(0,i.useEffect)(()=>{if(J(null),"file"!==C||!r||O||X||"deleted"===r.status||"conflict"===r.status)return;let e=!1;return x.FH.get("/agents/".concat(n.id,"/git/diff?path=").concat(encodeURIComponent(l)).concat(r.oldPath?"&old=".concat(encodeURIComponent(r.oldPath)):"")).then(s=>!e&&J(s)).catch(()=>void 0),()=>{e=!0}},[n.id,l,C,null==r?void 0:r.status,null==r?void 0:r.oldPath,o]);let Y=(0,i.useMemo)(()=>G&&G.path===l?ei(G.diff):null,[G,l]),Z=(0,i.useMemo)(()=>Y?function(e){let s=new Map,t=new Set,a=new Map,n=new Map,l=[];for(let m of e.hunks){var i,c,r,o,d,h,u;let e=m.lines,g=[],x=Number(null!=(c=null==(i=/\+(\d+)/.exec(m.header))?void 0:i[1])?c:1);for(let s=0;s<e.length;s++)g[s]=x,"del"!==e[s].kind&&(x=(null!=(r=e[s].newNo)?r:x)+1);let p=[];for(let s=0;s<e.length;){if("ctx"===e[s].kind){s++;continue}let t=s;for(;s<e.length&&"ctx"!==e[s].kind;)s++;p.push([t,s-1])}for(let[i,c]of p){let r=l.length,m=1/0,p=-1/0;for(let l=i;l<=c;){if("ctx"===e[l].kind){l++;continue}let i=[],o=[];for(;l<=c&&"del"===e[l].kind;)i.push(e[l++]);for(;l<=c&&"add"===e[l].kind;)o.push(e[l++]);o.forEach((e,t)=>{let n=e.newNo;s.set(n,t<i.length?"mod":"add"),a.set(n,r),m=Math.min(m,n),p=Math.max(p,n)});let d=o.length?o[o.length-1].newNo+1:l<e.length?g[l]:x;i.length>o.length&&(t.add(d),n.set(d,r),m=Math.min(m,d),p=Math.max(p,d))}let j=i;for(let s=0;s<3&&j>0&&"ctx"===e[j-1].kind;s++)j--;let b=c;for(let s=0;s<3&&b<e.length-1&&"ctx"===e[b+1].kind;s++)b++;let f=e.slice(j,b+1),v=f.filter(e=>void 0!==e.oldNo),N=f.filter(e=>void 0!==e.newNo);l.push({from:m,to:p,view:{header:"@@ -".concat(null!=(h=null==(o=v[0])?void 0:o.oldNo)?h:0,",").concat(v.length," +").concat(null!=(u=null==(d=N[0])?void 0:d.newNo)?u:0,",").concat(N.length," @@"),section:"",lines:f}})}}return{lines:s,removedBefore:t,blockOfLine:a,blockOfRemoval:n,groups:l}}(Y):null,[Y]),V=l.lastIndexOf("/"),en=V>=0?l.slice(0,V+1):"",el=l.slice(V+1);return(0,a.jsxs)("section",{className:"gx-preview","aria-label":l,children:[(0,a.jsxs)("header",{className:"gx-phead",children:[(0,a.jsxs)("div",{className:"gx-ptitle",children:[(0,a.jsxs)("span",{className:"gx-path mono",title:l,children:[(0,a.jsx)("span",{className:"dir",children:en}),(0,a.jsx)("b",{children:el})]}),c&&(0,a.jsx)("span",{className:"gx-chip soft",title:f("git.ignored.hint"),children:f("git.ignored.chip")}),r&&(0,a.jsx)("span",{className:"gx-chip st-".concat(r.status),children:f("git.status.".concat(r.status))}),(null==r?void 0:r.staged)&&(0,a.jsx)("span",{className:"gx-chip soft",children:f("git.staged")}),(null==r?void 0:r.unstaged)&&"untracked"!==r.status&&(0,a.jsx)("span",{className:"gx-chip soft",children:f("git.unstaged")}),r&&(null!==r.additions||null!==r.deletions)&&(0,a.jsxs)("span",{className:"gx-counts",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=r.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=r.deletions)?t:0]})]}),P&&!r&&(0,a.jsx)("span",{className:"muted small",children:(0,A.zi)(P.size)})]}),(0,a.jsxs)("div",{className:"gx-ptr",children:[(null==r?void 0:r.status)!=="untracked"&&!c&&(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",title:f("git.file.history"),"aria-label":f("git.file.history"),onClick:()=>m(l),children:(0,a.jsx)(u.A,{size:15})}),(null==r?void 0:r.status)!=="untracked"&&!c&&(0,a.jsx)(ez,{refs:d,value:null!=q?q:"",onChange:$,compact:!0,label:f("git.file.viewAt"),extra:[{value:"",label:f("git.file.viewAt")}]}),!O&&!c&&!q&&(null==r?void 0:r.status)!=="deleted"&&(null==r?void 0:r.status)!=="untracked"&&(null==r?void 0:r.status)!=="conflict"&&(()=>{let e=v&&"file"===C;return(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm ".concat(e?"on":""),"aria-pressed":e,"aria-label":f("git.blame"),title:"".concat(f("git.blame"),": ").concat(f("git.blame.hint")),onClick:()=>{"file"!==C?(S("file"),N(!0)):N(e=>!e)},children:(0,a.jsx)(e0.A,{size:15})})})(),(0,a.jsx)(Q.WQ,{text:l,label:f("git.copyPath"),compact:!0}),r&&"conflict"!==r.status&&(0,a.jsxs)("button",{type:"button",className:"btn sm",title:f("git.discard.hint"),onClick:()=>p(r),children:[(0,a.jsx)(W.A,{size:14}),f("git.discard")]})]}),(0,a.jsx)("div",{className:"gx-ptools",children:(0,a.jsxs)("div",{className:"gx-ptl",children:[(r||k)&&(0,a.jsx)(I.$q,{value:C,onChange:S,options:[...r?[{id:"diff",label:f("git.view.diff")}]:[],...k?[{id:"preview",label:f("git.view.preview")}]:[],{id:"file",label:f(k?"git.view.source":"git.view.file")}]}),"diff"===C&&r&&(0,a.jsx)(I.$q,{value:E,onChange:M,options:[{id:"unified",label:f("git.layout.unified")},{id:"split",label:f("git.layout.split")}]})]})})]}),(null==r?void 0:r.oldPath)&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.renamedFrom",{path:r.oldPath})}),q&&(0,a.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,a.jsx)("span",{className:"grow",children:f("git.file.atRef",{ref:q})}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>$(null),children:f("git.file.backToCurrent")})]}),q?(0,a.jsx)(ej,{agent:n,gitRef:q,path:(null==r?void 0:r.oldPath)&&q?r.oldPath:l,toolbar:!1}):(0,a.jsx)("div",{className:"gx-body",children:_?(0,a.jsx)("p",{className:"gx-note err",children:_}):!U||B||P?"diff"===C&&r?B?B.binary?(0,a.jsx)("p",{className:"gx-note",children:f("git.diff.binary")}):0===B.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:f("git.diff.empty")}):(0,a.jsxs)(a.Fragment,{children:[(null==F?void 0:F.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,a.jsx)(eg,{parsed:B,layout:E,path:l,cutOff:!!(null==F?void 0:F.truncated),onDiscardHunk:(null==r?void 0:r.status)==="modified"?(e,s)=>j(l,e,s):void 0,onDiscardLines:(null==r?void 0:r.status)==="modified"?(e,s,t)=>b(l,e,s,t):void 0})]}):null:O&&!D&&(null==r?void 0:r.status)!=="deleted"?(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(n.id,"/git/raw?path=").concat(encodeURIComponent(l),"&v=").concat(o),alt:el,onError:()=>K(!0)})}):"preview"===C&&P&&P.path===l?(0,a.jsxs)("div",{className:"gx-md md",children:[P.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,a.jsx)(ee.oz,{remarkPlugins:[es.A],components:{a:e=>(0,a.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:P.content})]}):P&&P.path===l?(0,a.jsx)(ep,{f:P,agent:n,blame:v,onOpenCommit:g,marks:Z,allNew:X,focusLine:h}):O&&D?(0,a.jsx)("p",{className:"gx-note",children:f("git.file.binary")}):null:(0,a.jsx)("p",{className:"gx-note",children:f("git.loading")})})]})}var e4=t(43249),e9=t(19431),e3=t(63745);function e6(e){let{name:s}=e;return et.test(s)?(0,a.jsx)(e4.A,{size:15}):/\.(md|mdx|txt|rst)$/i.test(s)?(0,a.jsx)(e9.A,{size:15}):(0,eh.eX)(s)?(0,a.jsx)(e3.A,{size:15}):(0,a.jsx)(q.A,{size:15})}let e2=(0,i.memo)(function(e){var s,t;let{rows:n,expanded:l,forceOpen:c,sel:r,onToggle:o,onSelect:d,label:h}=e,{t:u}=(0,z.s9)(),m=(0,i.useRef)(null),[g,x]=(0,i.useState)(null),p=e=>"".concat(e.ignored?"i:":"").concat(e.path),j=n.some(e=>p(e.node)===g)?g:null!=(t=null==(s=n.find(e=>e.node.path===r&&!e.node.ignored))?void 0:s.node.path)?t:n[0]?p(n[0].node):null,b=(0,i.useCallback)(e=>{var s,t;let a=[...null!=(t=null==(s=m.current)?void 0:s.querySelectorAll("[data-row]"))?t:[]],n=a.indexOf(document.activeElement),l=s=>{var t;e.preventDefault(),null==(t=a[Math.max(0,Math.min(a.length-1,s))])||t.focus()};if("ArrowDown"===e.key)l(n+1);else if("ArrowUp"===e.key)l(n-1);else if("Home"===e.key)l(0);else if("End"===e.key)l(a.length-1);else if(n>=0&&("ArrowRight"===e.key||"ArrowLeft"===e.key)){let s=a[n],t="1"===s.dataset.dir,i="true"===s.getAttribute("aria-expanded");if("ArrowRight"===e.key)t&&!i?(e.preventDefault(),s.click()):t&&i&&l(n+1);else if(t&&i)e.preventDefault(),s.click();else{let e=Number(s.getAttribute("aria-level"));for(let s=n-1;s>=0;s--)if(Number(a[s].getAttribute("aria-level"))<e){l(s);break}}}},[]);return(0,a.jsx)("div",{className:"gx-tree-rows",ref:m,onKeyDown:b,role:"tree","aria-label":h,children:n.map(e=>{var s,t;let{node:n,depth:i}=e,h="dir"===n.type,m=h&&(c||l.has(n.path)),g=n.change,b=p(n);return(0,a.jsxs)("button",{"data-row":!0,"data-dir":h?"1":"0","data-path":n.path,type:"button",role:"treeitem","aria-level":i+1,"aria-expanded":h?!!m:void 0,"aria-selected":!h&&r===n.path,tabIndex:j===b?0:-1,onFocus:()=>x(b),className:"gx-row ".concat(h?"dir":"file"," ").concat(n.ignored?"ignored":""," ").concat(g?"changed st-".concat(g.status):""," ").concat(!h&&r===n.path?"sel":""," ").concat(h&&n.changed?"has-changes":""),style:{paddingLeft:8+14*i},title:n.ignored?"".concat(n.path,": ").concat(u("git.ignored.hint")):n.path,onClick:()=>h?o(n):d(n.path),children:[(0,a.jsx)("span",{className:"chev",children:h?m?(0,a.jsx)(S.A,{size:14}):(0,a.jsx)(O.A,{size:14}):null}),(0,a.jsx)("span",{className:"ico",children:h?m?(0,a.jsx)(V.A,{size:15}):(0,a.jsx)(H.A,{size:15}):(0,a.jsx)(e6,{name:n.name})}),(0,a.jsx)("span",{className:"nm",children:n.name}),h&&n.changed>0&&(0,a.jsx)("span",{className:"dirdot",title:u("git.dirChanged",{count:n.changed}),children:n.changed}),g&&(0,a.jsxs)("span",{className:"meta",children:[(null!==g.additions||null!==g.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=g.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=g.deletions)?t:0]})]}),(0,a.jsx)(ef,{status:g.status,titled:!0})]})]},b)})})});var e5=t(32898),e7=t(61904),e8=t(2507);let se=["files","history","tags","compare","stashes"],ss={files:e5.A,history:u.A,tags:Z.A,compare:e7.A,stashes:e8.A},st=e=>"gx-tab-".concat(e),sa="gx-side-panel";function sn(e){let{mode:s,onChange:t,stashCount:n,label:l}=e,{t:i}=(0,z.s9)(),c=e=>"".concat(i("git.tab.".concat(e))).concat("stashes"===e&&n?" \xb7 ".concat(n):"");return(0,a.jsx)("div",{className:"gx-tabs",role:"tablist","aria-label":l,onKeyDown:e=>{let a=se.indexOf(s),n=null;"ArrowRight"===e.key||"ArrowDown"===e.key?n=(a+1)%se.length:"ArrowLeft"===e.key||"ArrowUp"===e.key?n=(a-1+se.length)%se.length:"Home"===e.key?n=0:"End"===e.key&&(n=se.length-1),null!==n&&(e.preventDefault(),t(se[n]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(st(se[n])))?void 0:e.focus()}))},children:se.map((e,n)=>{let l=ss[e];return(0,a.jsxs)("button",{id:st(e),type:"button",role:"tab","aria-selected":s===e,"aria-controls":sa,tabIndex:s===e?0:-1,"aria-label":c(e),title:"".concat(c(e)," (Alt+").concat(n+1,")"),className:"gx-tab ".concat(s===e?"on":""),onClick:()=>t(e),children:[(0,a.jsx)(l,{size:15}),s===e&&(0,a.jsx)("span",{children:c(e)})]},e)})})}function sl(e){var s,t,n,l,c,r,o,d,h,u;let{agent:m,git:g}=e,{t:j}=(0,z.s9)(),{status:b,tree:f,loading:v,error:N,refresh:y}=g,[k,w]=(0,i.useState)(null),[C,E]=(0,i.useState)(new Set),[M,F]=(0,i.useState)(""),[R,L]=(0,i.useState)(!1),[_,T]=(0,i.useState)(!1),[U,Z]=(0,i.useState)("files"),[V,ee]=(0,i.useState)(null),[es,et]=(0,i.useState)({base:"",head:""}),[ea,en]=(0,i.useState)(!1),[el,ei]=(0,i.useState)(null),[ec,er]=(0,i.useState)(),eo=(0,i.useRef)(null),[ed,eh]=(0,i.useState)(null),[eu,em]=(0,i.useState)(null),[eg,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(!1),[eb,ef]=(0,i.useState)(null),[ev,eN]=(0,i.useState)(!1),[eC,eS]=(0,i.useState)(null),[eA,ez]=(0,i.useState)(!1),eF=function(e,s){let{t}=(0,z.s9)(),a=(0,I.dj)(),[n,l]=(0,i.useState)(null),[c,r]=(0,i.useState)(null),o=async function(n,i,c){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};l(n),r(null);try{var d,h,u;let n=await x.FH.post("/agents/".concat(e.id,"/git/").concat(c),o),l=null!=(u=(null!=(h=n.output)?h:"").split("\n").filter(Boolean).pop())?u:"",r=["conflicts"===n.pending?t("git.pending.conflicts"):"",(null==(d=n.kept)?void 0:d.length)?t("git.sw.kept",{count:n.kept.length,names:n.kept.slice(0,3).join(", ")}):""].filter(Boolean).join(", ");return a(r?"".concat(i,": ").concat(r):l&&l.length<90?"".concat(i,": ").concat(l):i),await s(),!0}catch(a){let e=a instanceof Error?a.message:"error";return r({title:t("git.notice.failed",{action:i}),text:e,diverged:/fast-forward|divergent/i.test(e)}),await s(),!1}finally{l(null)}};return{busy:n,notice:c,setNotice:r,run:o}}(m,()=>y()),[eR,eP]=(0,i.useState)(null),eI=(0,X.Wx)(),eT=(0,i.useRef)(new Set),eU=b&&b.isRepo?b:null,eO=function(e,s){let[t,a]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let s=!1;return x.FH.get("/agents/".concat(e.id,"/git/refs")).then(e=>!s&&a(e)).catch(()=>!s&&a({current:null,branches:[],remotes:[],tags:[]})),()=>{s=!0}},[e.id,s]),t}(m,null==eU||null==(s=eU.head)?void 0:s.sha),eW=f&&f.isRepo?f.files:null,eq=f&&f.isRepo?f.ignored:null,[e$,eB]=(0,i.useState)({});(0,i.useEffect)(()=>{eB({})},[m.id,m.effective.cwd]);let eQ=(0,i.useMemo)(()=>eU&&eW?G(eW,eU.changes,eI.showIgnored&&null!=eq?eq:[],e$):null,[eU,eW,eq,e$,eI.showIgnored]),e0=(0,i.useMemo)(()=>{let e=(null!=eq?eq:[]).map(e=>e.replace(/\/$/,""));return s=>e.some(e=>s===e||s.startsWith("".concat(e,"/")))},[eq]),e4=(0,i.useMemo)(()=>{var e;return new Map((null!=(e=null==eU?void 0:eU.changes)?e:[]).map(e=>[e.path,e]))},[eU]),e9=(0,i.useMemo)(()=>{var e;return(null!=(e=null==eU?void 0:eU.changes)?e:[]).reduce((e,s)=>{var t,a;return{add:e.add+(null!=(t=s.additions)?t:0),del:e.del+(null!=(a=s.deletions)?a:0)}},{add:0,del:0})},[eU]);(0,i.useEffect)(()=>{if(!eQ)return;let e=new Set,s=t=>{for(let n of t.children)if("dir"===n.type){var a;!eT.current.has(n.path)&&(n.changed>0||0===eT.current.size&&(null!=(a=null==eW?void 0:eW.length)?a:0)<=40)&&e.add(n.path),s(n)}};s(eQ);let t=e=>{for(let s of e.children)"dir"===s.type&&(eT.current.add(s.path),t(s))};t(eQ),e.size&&E(s=>new Set([...s,...e]))},[eQ]),(0,i.useEffect)(()=>{var e;eQ&&null===k&&(null==eU?void 0:eU.changes.length)&&w((null!=(e=eU.changes.find(e=>"conflict"===e.status))?e:eU.changes[0]).path)},[eQ]),(0,i.useEffect)(()=>{let e=!1;return x.FH.get("/agents/".concat(m.id,"/git/stashes")).then(s=>{e||(em(s),ex(e=>{var t,a;return e&&s.some(s=>s.sha===e)?e:null!=(a=null==(t=s[0])?void 0:t.sha)?a:null}))}).catch(()=>void 0),()=>{e=!0}},[m.id,null==eU?void 0:eU.generatedAt]);let e3="hive-am.git.last.".concat(m.id);(0,i.useEffect)(()=>{if(k)try{localStorage.setItem(e3,k)}catch(e){}},[k,e3]),(0,i.useEffect)(()=>{if(eQ&&null===k&&(null==eU||!eU.changes.length))try{let e=localStorage.getItem(e3);e&&(null==eW?void 0:eW.includes(e))&&w(e)}catch(e){}},[eQ]),(0,i.useEffect)(()=>{let e=M.trim();if(!ea||e.length<2)return void ei(null);let s=!1,t=setTimeout(()=>x.FH.get("/agents/".concat(m.id,"/git/grep?q=").concat(encodeURIComponent(e))).then(t=>!s&&ei({q:e,...t})).catch(()=>!s&&ei({q:e,hits:[],truncated:!1})),350);return()=>{s=!0,clearTimeout(t)}},[m.id,ea,M,null==eU?void 0:eU.generatedAt]),(0,i.useEffect)(()=>{let e=e=>{let s=e.target,t=!!s&&("INPUT"===s.tagName||"TEXTAREA"===s.tagName||"SELECT"===s.tagName||s.isContentEditable);"/"!==e.key||t||e.ctrlKey||e.metaKey||e.altKey?e.altKey&&!e.ctrlKey&&!e.metaKey&&/^[1-5]$/.test(e.key)&&(e.preventDefault(),Z(se[Number(e.key)-1])):(e.preventDefault(),Z("files"),setTimeout(()=>{var e;return null==(e=eo.current)?void 0:e.focus()},0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let e6=(0,i.useMemo)(()=>eQ?J(eQ,C,{query:M,onlyChanged:R}):[],[eQ,C,M,R]),e5=(0,i.useMemo)(()=>e6.slice(0,2e3),[e6]),e7=(0,i.useRef)(e$);e7.current=e$;let e8=(0,i.useCallback)(e=>{let s;s=e.path,E(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t}),!e.ignored||!e.lazy||e.path in e7.current||x.FH.get("/agents/".concat(m.id,"/git/ls?path=").concat(encodeURIComponent(e.path))).then(s=>eB(t=>({...t,[e.path]:s.entries}))).catch(()=>eB(s=>({...s,[e.path]:[]})))},[m.id]),ss=(0,i.useCallback)(e=>{er(void 0),w(e)},[]);if(N&&!b)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsxs)("div",{className:"gx-empty",children:[(0,a.jsx)("h3",{children:j("git.error.title")}),(0,a.jsx)("p",{children:N}),(0,a.jsx)("button",{className:"btn",onClick:()=>void y(),children:j("git.refresh")})]})});if(!b)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.loading")})})});if(!b.isRepo)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsxs)("div",{className:"gx-empty",children:[(0,a.jsx)(H.A,{size:26,className:"muted"}),(0,a.jsx)("h3",{children:"not-repo"===b.reason?j("git.notRepo.title"):"no-git"===b.reason?j("git.noGit.title"):j("git.error.title")}),(0,a.jsx)("p",{children:"not-repo"===b.reason?j("git.notRepo.body",{path:b.cwd.replace(/^\/home\/[^/]+/,"~")}):"no-git"===b.reason?j("git.noGit.body"):b.message}),(0,a.jsxs)("button",{className:"btn",onClick:()=>void y(),children:[(0,a.jsx)(D.A,{size:14}),j("git.refresh")]})]})});let sl=k?e4.get(k):void 0,si=e=>eF.run("switch",e.carried?j("git.done.switchCarried",{branch:e.to,count:e.carried}):j("git.done.switch",{branch:e.to}),e.overlap.length||e.collisions.length?"switch-smart":"switch",{branch:e.to}),sc=async e=>{try{let s=await x.FH.get("/agents/".concat(m.id,"/git/switch-plan?branch=").concat(encodeURIComponent(e)));s.others.length||s.selfRunning?ef(s):await si(s)}catch(s){eF.setNotice({title:j("git.notice.failed",{action:j("git.done.switch",{branch:e})}),text:s instanceof Error?s.message:"error",diverged:!1})}},sr=e=>e.filter(e=>"untracked"===e.status||"added"===e.status&&!e.oldPath).map(e=>e.path),so=(0,A.Xd)(b.generatedAt);return(0,a.jsxs)("div",{className:"gx","data-gx-theme":eI.theme,style:{"--g-tab":eI.tabSize},children:[(0,a.jsxs)("div",{className:"gx-bar",children:[(0,a.jsxs)("button",{type:"button",className:"gx-branch","aria-expanded":_,"aria-controls":"gx-info",title:j("git.info.toggle"),onClick:()=>T(e=>!e),children:[(0,a.jsx)(K.A,{size:14}),(0,a.jsx)("span",{className:"bn",children:null!=(c=b.branch)?c:b.head?"".concat(j("git.detached")," ").concat(b.head.sha):j("git.noCommitsBranch")}),b.head&&(0,a.jsx)("span",{className:"sha",children:b.head.sha}),b.upstream&&(b.upstream.ahead>0||b.upstream.behind>0)&&(0,a.jsxs)("span",{className:"ab",title:j("git.upstream"),children:[b.upstream.ahead>0&&"↑".concat(b.upstream.ahead),b.upstream.ahead>0&&b.upstream.behind>0&&" ",b.upstream.behind>0&&"↓".concat(b.upstream.behind)]}),_?(0,a.jsx)(S.A,{size:14}):(0,a.jsx)(O.A,{size:14})]}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("span",{className:"gx-sum",children:0===b.changes.length?(0,a.jsx)("span",{className:"muted",children:j("git.clean")}):(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("span",{title:j("git.summary",{count:b.changes.length}),"aria-label":j("git.summary",{count:b.changes.length}),children:[(0,a.jsx)("b",{children:b.changes.length})," ",(0,a.jsx)("span",{className:"muted",children:j("git.files.short")})," ",(0,a.jsxs)("i",{className:"add",children:["+",(0,A._E)(e9.add)]})," ",(0,a.jsxs)("i",{className:"del",children:["−",(0,A._E)(e9.del)]})]})})}),(0,a.jsx)(eX,{agent:m,a:eF,current:b.branch,onSwitch:e=>void sc(e)}),(0,a.jsx)(eJ,{a:eF,ahead:null!=(r=null==(t=b.upstream)?void 0:t.ahead)?r:0,behind:null!=(o=null==(n=b.upstream)?void 0:n.behind)?o:0,detached:!b.branch,changeCount:b.changes.length,onCommit:()=>ez(!0)}),(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!eF.busy||0===b.changes.length||!!b.state,onClick:()=>{let e=sr(b.changes);eP({files:e,all:!0,summary:{restore:b.changes.length-e.length,add:e9.add,del:e9.del},go:async()=>{let e=await eF.run("discard-all",j("git.done.discard"),"discard-all");return e&&w(null),e}})},"aria-label":j("git.discard.all"),title:b.state?j("git.discard.all.blocked"):j("git.discard.all"),children:(0,a.jsx)(W.A,{size:15})}),(0,a.jsx)(Y.i,{}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void y(),"aria-label":j("git.refresh"),title:"".concat(j("git.refresh")," \xb7 ").concat(j("git.updated",{time:so})),children:(0,a.jsx)(D.A,{size:15,className:v?"spin":""})})]}),_&&(0,a.jsxs)("dl",{id:"gx-info",className:"gx-info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.branch")}),(0,a.jsxs)("dd",{className:"mono",children:[null!=(d=b.branch)?d:b.head?"".concat(j("git.detached")," ").concat(b.head.sha):j("git.noCommitsBranch"),b.branch&&(0,a.jsx)(Q.WQ,{text:b.branch,label:j("git.info.copyBranch")})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.upstreamLabel")}),(0,a.jsx)("dd",{children:b.upstream?0===b.upstream.ahead&&0===b.upstream.behind?j("git.info.inSync"):j("git.info.upstreamStatus",{ahead:b.upstream.ahead,behind:b.upstream.behind}):(0,a.jsx)("span",{className:"muted",children:j("git.info.noUpstream")})})]}),b.head?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.commit")}),(0,a.jsxs)("dd",{className:"mono",children:[b.head.sha,(0,a.jsx)(Q.WQ,{text:b.head.sha,label:j("git.info.copySha")})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.message")}),(0,a.jsx)("dd",{className:"msg",children:b.head.subject||(0,a.jsx)("span",{className:"muted",children:"—"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.author")}),(0,a.jsx)("dd",{children:b.head.author})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.when")}),(0,a.jsxs)("dd",{children:[(0,A.v7)(b.head.when)," ",(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",(0,p.KN)(Date.parse(b.head.when))]})]})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.commit")}),(0,a.jsx)("dd",{className:"muted",children:j("git.noCommits")})]})]}),"running"===m.status&&(0,a.jsx)("div",{className:"gx-warn",children:j("git.warn.running",{name:m.name})}),b.state&&(()=>{let e=b.changes.filter(e=>"conflict"===e.status),s="merge"===b.state?j("git.state.merge"):"rebase"===b.state?j("git.state.rebase"):j("git.state.stash");return(0,a.jsxs)("div",{className:"gx-state",role:"status",children:[(0,a.jsx)("b",{children:s}),(0,a.jsxs)("span",{className:"grow",children:["stash"===b.state&&b.stash&&(0,a.jsxs)(a.Fragment,{children:[j("git.state.stash.hint",{from:b.stash.from,to:b.stash.to})," \xb7 "]}),e.length>0?j("git.state.conflicts",{count:e.length}):j("git.state.ready")]}),0===e.length&&("merge"===b.state?(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eF.busy,onClick:()=>ez(!0),children:j("git.state.finishMerge")}):"rebase"===b.state?(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eF.busy,onClick:()=>void eF.run("continue",j("git.done.rebaseContinue"),"rebase-continue"),children:j("git.state.continueRebase")}):(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eF.busy,onClick:()=>void eF.run("smart",j("git.done.smartFinish"),"smart-finish"),children:j("git.state.finishStash")})),"stash"===b.state?(0,a.jsx)("button",{className:"btn sm danger",disabled:!!eF.busy,onClick:()=>eN(!0),children:j("git.state.cancelStash")}):(0,a.jsx)("button",{className:"btn sm danger",disabled:!!eF.busy,onClick:()=>void eF.run("abort",j("git.done.mergeAbort"),"merge-abort"),children:"merge"===b.state?j("git.state.abortMerge"):j("git.state.abortRebase")})]})})(),(0,a.jsx)(eG,{a:eF}),b.scope&&(0,a.jsx)("div",{className:"gx-scope",children:j("git.scope",{path:b.scope})}),(0,a.jsxs)("div",{className:"gx-main",children:[(0,a.jsxs)("aside",{className:"gx-tree","aria-label":j("git.filesLabel"),children:[(0,a.jsx)(sn,{mode:U,onChange:Z,stashCount:null!=(h=null==eu?void 0:eu.length)?h:0,label:j("git.filesLabel")}),(0,a.jsx)("div",{className:"gx-sidepanel",id:sa,role:"tabpanel","aria-labelledby":st(U),children:"stashes"===U?(0,a.jsx)(eH,{stashes:eu,sel:eg,onSelect:ex,onSave:()=>ej(!0),canSave:b.changes.length>0&&!b.state}):"tags"===U?(0,a.jsx)(ek,{agent:m,sel:null!=(u=null==ed?void 0:ed.name)?u:null,onSelect:eh}):"compare"===U?(0,a.jsx)(eE,{refs:eO,sel:es,onChange:et}):"history"===U?(0,a.jsx)(eZ,{agent:m,head:null==(l=b.head)?void 0:l.sha,sel:eC,onSelect:eS,refs:eO,path:V,onClearPath:()=>ee(null)}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"gx-filter",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(P.A,{size:14}),(0,a.jsx)("input",{ref:eo,className:"input",placeholder:ea?j("git.search.placeholder"):j("git.filterPlaceholder"),value:M,onChange:e=>F(e.target.value),"aria-label":j("git.filterPlaceholder")})]}),(0,a.jsxs)("div",{className:"seg icons",role:"group","aria-label":j("git.search.name"),children:[(0,a.jsx)("button",{type:"button","aria-pressed":!ea,title:j("git.search.name"),"aria-label":j("git.search.name"),onClick:()=>en(!1),children:(0,a.jsx)(q.A,{size:14})}),(0,a.jsx)("button",{type:"button","aria-pressed":ea,title:j("git.search.content"),"aria-label":j("git.search.content"),onClick:()=>en(!0),children:(0,a.jsx)($.A,{size:14})})]}),!ea&&(0,a.jsxs)("button",{type:"button",className:"btn sm gx-onlych ".concat(R?"primary":""),"aria-pressed":R,title:j("git.filter.changed"),onClick:()=>L(e=>!e),children:[(0,a.jsx)(B.A,{size:14}),b.changes.length>0&&(0,a.jsx)("span",{className:"ct",children:b.changes.length})]})]}),ea?(0,a.jsx)("div",{className:"gx-list gx-hits",children:M.trim().length<2?(0,a.jsx)("p",{className:"gx-note",children:j("git.search.min")}):el&&el.q===M.trim()?0===el.hits.length?(0,a.jsx)("p",{className:"gx-note",children:j("git.search.none",{query:el.q})}):(0,a.jsxs)(a.Fragment,{children:[el.hits.map((e,s)=>(0,a.jsxs)("button",{type:"button",className:"gx-hit ".concat(k===e.path&&(null==ec?void 0:ec.line)===e.line?"sel":""),onClick:()=>{w(e.path),er({line:e.line,key:Date.now()})},title:"".concat(e.path,":").concat(e.line),children:[(0,a.jsxs)("span",{className:"mono nm",children:[e.path,(0,a.jsxs)("i",{children:[":",e.line]})]}),(0,a.jsx)("span",{className:"mono tx",children:e.text.trim()})]},"".concat(e.path,":").concat(e.line,":").concat(s))),el.truncated&&(0,a.jsx)("p",{className:"gx-note",children:j("git.search.capped",{count:el.hits.length})})]}):(0,a.jsx)("p",{className:"gx-note",children:j("git.search.searching")})}):(0,a.jsxs)("div",{className:"gx-list",children:[eQ?0===e5.length?(0,a.jsx)("p",{className:"gx-note",children:M?j("git.noMatch",{query:M}):R?j("git.clean"):j("git.noFiles")}):(0,a.jsx)(e2,{rows:e5,expanded:C,forceOpen:!!(M||R),sel:k,onToggle:e8,onSelect:ss,label:j("git.filesLabel")}):(0,a.jsx)("p",{className:"gx-note",children:j("git.loading")}),e6.length>e5.length&&(0,a.jsx)("p",{className:"gx-note",children:j("git.rowsCapped",{count:e5.length})}),(null==f?void 0:f.isRepo)&&f.truncated&&(0,a.jsx)("p",{className:"gx-note",children:j("git.treeTruncated",{count:f.files.length})})]})]})})]}),"stashes"===U?(null==eu?void 0:eu.find(e=>e.sha===eg))?(0,a.jsx)(eK,{agent:m,stash:eu.find(e=>e.sha===eg),a:eF},eg):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.stash.empty")})})}):"compare"===U?(0,a.jsx)(eM,{agent:m,sel:es}):"tags"===U?ed?(0,a.jsx)(ew,{agent:m,tag:ed,onChanged:()=>void y()},ed.name):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.tags.select")})})}):"history"===U?eC?(0,a.jsx)(ey,{agent:m,sha:eC,focus:null!=V?V:void 0},"".concat(eC,"|").concat(null!=V?V:"")):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.hist.select")})})}):k&&(null==sl?void 0:sl.status)==="conflict"?(0,a.jsx)(eL,{agent:m,path:k,state:b.state,a:eF,onResolved:()=>{y()}},k):k?(0,a.jsx)(e1,{agent:m,path:k,ignored:e0(k),change:sl,stamp:b.generatedAt,refs:eO,focusLine:ec,onHistory:e=>{ee(e),eS(null),Z("history")},onOpenCommit:e=>{eS(e),Z("history")},onDiscard:e=>{var s,t;return eP({files:sr([e]),all:!1,file:{path:e.path,status:e.status,oldPath:e.oldPath,add:null!=(s=e.additions)?s:0,del:null!=(t=e.deletions)?t:0},go:async()=>{let s=await eF.run("discard",j("git.done.discard"),"discard",{path:e.path,oldPath:e.oldPath});return s&&sr([e]).length&&w(null),s}})},onDiscardHunk:(e,s,t)=>void eF.run("discard-hunk",j("git.done.discard"),"discard-hunk",{path:e,index:s,header:t}),onDiscardLines:(e,s,t,a)=>void eF.run("discard-lines",j("git.done.discard"),"discard-lines",{path:e,index:s,header:t,lines:a})},k):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.select")})})})]}),eb&&(0,a.jsx)(e_,{agent:m,plan:eb,a:eF,onClose:()=>ef(null),onGo:()=>{ef(null),si(eb)}}),ep&&(0,a.jsx)(eD,{a:eF,onClose:()=>ej(!1)}),ev&&b.stash&&(0,a.jsx)(I.TM,{danger:!0,title:j("git.state.cancelStash.title"),body:j("git.state.cancelStash.body",{from:b.stash.from}),confirmLabel:j("git.state.cancelStash.go"),onClose:()=>eN(!1),onConfirm:()=>{eF.busy||eF.run("smart",j("git.done.smartCancel"),"smart-cancel")}}),eR&&(0,a.jsx)(eV,{files:eR.files,all:eR.all,summary:eR.summary,file:eR.file,onClose:()=>eP(null),onConfirm:()=>{eR.go()}}),eA&&(0,a.jsx)(eY,{changes:b.changes,a:eF,initialMessage:b.mergeMsg,onClose:()=>ez(!1)})]})}var si=t(37064),sc=t(5300),sr=t(48180),so=t(66477),sd=t(12646);function sh(e){let{agent:s}=e,{t}=(0,z.s9)(),{refresh:n}=(0,g.o0)(),l=(0,I.dj)(),[c,r]=(0,i.useState)(null),[o,d]=(0,i.useState)(""),[h,u]=(0,i.useState)(""),[m,j]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),v=(0,i.useRef)(""),N=!!c&&o!==v.current,y=(0,i.useRef)(!1);y.current=N;let k=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let t=await x.FH.get("/agents/".concat(s.id,"/notebook"));r(e=>e&&e.version===t.version&&e.enabled===t.enabled?e:t),(e||!y.current)&&(v.current=t.content,d(t.content))}catch(e){u(e instanceof Error?e.message:String(e))}},[s.id]);(0,i.useEffect)(()=>{r(null),u(""),k(!0)},[s.id,k]),(0,i.useEffect)(()=>{let e=setInterval(()=>{"visible"===document.visibilityState&&k()},4e3);return()=>clearInterval(e)},[k]);let w=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;if(c){j(!0),u("");try{let a=await x.FH.put("/agents/".concat(s.id,"/notebook"),{content:e,version:c.version});r({...c,...a}),v.current=a.content,d(a.content),l(t("notebook.saved"))}catch(e){u(e instanceof Error?e.message:String(e))}j(!1)}},C=async()=>{try{await x.FH.patch("/agents/".concat(s.id),{skill_ids:[...new Set([...s.skill_ids,c.skill_id])]}),await n(["agents"]),await k(!0)}catch(e){u(e instanceof Error?e.message:String(e))}};if(!c)return(0,a.jsx)("div",{className:"pane",children:(0,a.jsx)("p",{className:"hint",children:h||t("git.loading")})});let S=o.length,A=S>c.max,E=S>.8*c.max;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"pane",children:[(0,a.jsx)("p",{className:"hint",style:{margin:0},children:t("notebook.intro")}),!c.enabled&&(0,a.jsxs)("div",{className:"banner honey",children:[(0,a.jsx)(sr.A,{size:16}),(0,a.jsx)("div",{className:"grow",children:t("notebook.off")}),(0,a.jsx)("button",{className:"btn sm",onClick:C,children:t("notebook.on")})]}),h&&(0,a.jsxs)("div",{className:"banner err",children:[(0,a.jsx)(sr.A,{size:16}),(0,a.jsx)("div",{className:"grow",children:h}),(0,a.jsxs)("button",{className:"btn sm",onClick:()=>{u(""),k(!0)},children:[(0,a.jsx)(D.A,{size:13}),t("notebook.reload")]})]}),(0,a.jsxs)("div",{className:"row small muted",style:{justifyContent:"space-between"},children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(so.A,{size:12,style:{verticalAlign:"-1px"}})," ",c.updated_at?t("notebook.updated",{who:t("user"===c.updated_by?"notebook.by.you":"notebook.by.agent"),when:(0,p.KN)(c.updated_at)}):t("notebook.never")]}),(0,a.jsxs)("span",{style:{color:A?"var(--danger, #c0392b)":E?"var(--honey)":void 0},children:[S.toLocaleString()," / ",c.max.toLocaleString()]})]}),(0,a.jsx)(sd.n,{value:o,onChange:d,placeholder:t("notebook.placeholder"),defaultView:"write",minHeight:320})]}),(0,a.jsxs)("div",{className:"savebar col",children:[(0,a.jsx)("span",{className:"muted small",children:N?t("agent.unsavedChanges"):t("agent.allSaved")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("button",{className:"btn danger sm",style:{marginRight:"auto"},disabled:!o.trim()||m,onClick:()=>f(!0),children:[(0,a.jsx)(eU.A,{size:14}),t("notebook.clear")]}),N&&(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>d(v.current),children:t("common.discard")}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!N||m||A,onClick:()=>void w(),children:t("notebook.save")})]})]}),b&&(0,a.jsxs)(I.aF,{title:t("notebook.clear.title"),onClose:()=>f(!1),children:[(0,a.jsx)("p",{style:{margin:0},className:"muted",children:t("notebook.clear.confirm")}),(0,a.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,a.jsx)("button",{className:"btn ghost",onClick:()=>f(!1),children:t("common.cancel")}),(0,a.jsx)("button",{className:"btn danger",onClick:()=>{f(!1),w("")},children:t("notebook.clear")})]})]})]})}let su=["config","notebook","sessions"];function sm(e){let{params:s}=e,{id:t}=(0,i.use)(s);return(0,a.jsx)(sg,{id:t},t)}function sg(e){var s;let{id:t}=e,{t:c}=(0,z.s9)(),{ready:v,error:N,retry:y,refresh:k}=(0,g.q5)(),w=(0,g.fJ)(t),C=(0,o.useRouter)(),S=(0,I.dj)(),[A,M]=(0,b.Z)("tab",""),[F,R]=(0,i.useState)("config"),P=su.includes(A)?A:F,L=""!==A,[_,T]=(0,i.useState)(!1),[H,D]=(0,i.useState)([]),[K,O]=(0,i.useState)(void 0),[W,q]=(0,i.useState)(null),[$,B]=(0,i.useState)("chat"),[G,J]=(0,j.ud)("hive-switcher-collapsed",0),Q=1===G,X=()=>J(+!Q),Y=function(e,s){var t,a,n;let{finished:l}=(0,g.o0)(),c=null!=(t=null==e?void 0:e.id)?t:"",r=null!=(a=l[c])?a:0,[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(null),[m,p]=(0,i.useState)(!1),[j,b]=(0,i.useState)(null),f=(0,i.useRef)(0),v=null!=(n=null==e?void 0:e.effective.cwd)?n:"",N=(null==e?void 0:e.status)==="running",y=(0,i.useCallback)(async e=>{if(!c)return;let s=++f.current;p(!0);try{let[t,a]=await Promise.all([x.FH.get("/agents/".concat(c,"/git/status")),e?x.FH.get("/agents/".concat(c,"/git/tree")):Promise.resolve(null)]);if(s!==f.current)return;d(t),a&&u(a),b(null)}catch(e){s===f.current&&b(e instanceof Error?e.message:"error")}finally{s===f.current&&p(!1)}},[c]);return(0,i.useEffect)(()=>{u(null),d(null)},[v]),(0,i.useEffect)(()=>{y(s)},[y,s,r,v]),(0,si.n)(()=>y(!0),5e3,{enabled:s&&N,immediate:!1}),{status:o,tree:h,loading:m,error:j,refresh:(0,i.useCallback)(()=>y(!0),[y])}}(w,"changes"===$),Z=Y.status&&Y.status.isRepo?Y.status.changes.length:0,V=(e,s)=>{let t=null!=s?s:P;R(t),M(e?t:"")},ee=(0,l.A)(w,{onDeleted:()=>C.push("/agents")}),{draft:es,setDraft:et,errors:ea,dirty:en}=ee,el=()=>{en?T(!0):V(!1)};if((0,i.useEffect)(()=>{L&&"sessions"===P&&x.FH.get("/agents/".concat(t,"/sessions")).then(D).catch(()=>void 0)},[L,P,t,null==w?void 0:w.session_id]),!w)return(0,a.jsxs)("div",{className:"ws ".concat(Q?"sw-collapsed":""),children:[(0,a.jsx)(U,{activeId:t,collapsed:Q,onToggle:X}),(0,a.jsx)("div",{className:"page",children:!v&&N?(0,a.jsxs)(I.lZ,{kind:"err",children:[(0,a.jsx)("span",{children:N})," ",(0,a.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void y(),children:c("fa.retry")})]}):v?(0,a.jsx)(I.pp,{title:c("agent.missing.title"),body:c("agent.missing.body"),action:(0,a.jsx)(r(),{className:"btn",href:"/agents",children:c("agent.missing.back")})}):null})]});let ei=async e=>{await x.FH.post("/agents/".concat(t,"/resume-session"),{session_id:e}),O(void 0),S(c("agent.resumed"))},ec=H.filter(e=>"delegation"!==e.kind),er=H.filter(e=>"delegation"===e.kind),eo=(null==(s=H.find(e=>e.session_id===K))?void 0:s.kind)==="delegation",ed=[...K?[{id:"make-current",label:c("agent.makeCurrent"),onClick:()=>void ei(K).catch(e=>S(e instanceof Error?e.message:String(e),"err")),disabled:eo},{id:"back-current",label:c("agent.backToCurrent"),onClick:()=>O(void 0)}]:[],{id:"new-conv",label:c("agent.newConversation"),icon:(0,a.jsx)(d.A,{size:14}),onClick:()=>q("new"),disabled:!w.session_id||"running"===w.status}];return(0,a.jsxs)("div",{className:"ws ".concat(Q?"sw-collapsed":""),children:[(0,a.jsx)(U,{activeId:t,collapsed:Q,onToggle:X}),(0,a.jsxs)("section",{className:"ws-chat",children:[(0,a.jsx)(I.DS,{back:{href:"/",label:c("agent.backToColony")},avatar:(0,a.jsx)(I._h,{agent:w}),title:w.name,meta:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.PW,{role:w.role}),(0,a.jsx)(I.dJ,{provider:w.provider}),(0,a.jsx)("span",{className:"small",children:w.model||c("model.cliDefault")}),(0,a.jsx)(I.P5,{status:w.status})]}),actions:ed,primary:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"seg",role:"group","aria-label":c("git.tab.label"),children:[(0,a.jsx)("button",{type:"button","aria-pressed":"chat"===$,onClick:()=>B("chat"),children:c("git.tab.chat")}),(0,a.jsxs)("button",{type:"button","aria-pressed":"changes"===$,onClick:()=>B("changes"),children:[c("git.tab.changes"),Z>0&&(0,a.jsx)("span",{className:"tabcount",children:Z})]})]}),(0,a.jsx)(n.N,{spec:{agentId:t},title:c("dock.agent")}),(0,a.jsxs)("button",{type:"button",className:"btn sm ".concat(L?"primary":""),onClick:()=>L?el():V(!0),"aria-expanded":L,"aria-label":c("colony.agentSettings"),children:[(0,a.jsx)(h.A,{size:14}),c("agent.settings"),en&&(0,a.jsx)("i",{className:"dot run",title:c("agent.unsaved")})]})]})}),(0,a.jsxs)("div",{className:"chat-pane",hidden:"chat"!==$,children:[(0,a.jsx)(E,{agent:w,session:K}),(0,a.jsx)(f.ry,{agent:w,sessionOverride:K})]}),"changes"===$&&(0,a.jsx)(sl,{agent:w,git:Y})]}),L&&(0,a.jsx)(I._s,{title:w.name,subtitle:"".concat(c("role.".concat(w.role))," \xb7 ").concat(p.xq[w.provider].label),onClose:el,footer:"config"===P&&es?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"muted small grow",children:[en?c("agent.unsavedChanges"):c("agent.allSaved"),en&&"running"===w.status?" ".concat(c("agent.appliesNextTurn")):""]}),ee.actions({size:"sm"})]}):void 0,children:(0,a.jsxs)("div",{className:"agent-config",children:[(0,a.jsx)(I.tU,{idPrefix:"cfg",label:c("fa.cfg.tabs"),value:P,onChange:e=>V(!0,e),tabs:[{id:"config",label:c("agent.tab.config")},{id:"notebook",label:c("agent.tab.notebook")},{id:"sessions",label:c("nav.sessions")}]}),(0,a.jsx)(I.Kp,{id:"config",value:P,idPrefix:"cfg",children:es&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"pane",children:(0,a.jsx)(sc.SU,{draft:es,onChange:et,errors:ea,selfId:t})})})}),(0,a.jsx)(I.Kp,{id:"notebook",value:P,idPrefix:"cfg",children:(0,a.jsx)(sh,{agent:w})}),(0,a.jsx)(I.Kp,{id:"sessions",value:P,idPrefix:"cfg",children:(0,a.jsxs)("div",{className:"pane",children:[(0,a.jsx)("p",{className:"hint m0",children:c("agent.sessions.intro",{path:(0,p._1)(w.effective.cwd)})}),(0,a.jsx)("div",{className:"eyebrow",children:c("agent.sessions.conversations")}),0===ec.length?(0,a.jsx)(I.pp,{compact:!0,icon:(0,a.jsx)(u.A,{size:22}),title:c("agent.sessions.empty")}):ec.map(e=>{let s=e.session_id===w.session_id;return(0,a.jsxs)("div",{className:"card card-pad col fa-sess ".concat(K===e.session_id?"on":""),children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("span",{className:"mono grow",children:[e.session_id.slice(0,18),"…"]}),s&&(0,a.jsx)("span",{className:"chip honey",children:c("sessions.current")})]}),(0,a.jsx)("span",{className:"muted small",children:c("agent.sessions.started",{started:(0,p.KN)(e.first_seen),last:(0,p.KN)(e.last_seen)})}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)("button",{className:"btn sm",onClick:()=>{O(s?void 0:e.session_id),V(!1)},children:K===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")}),!s&&(0,a.jsx)("button",{className:"btn sm",onClick:()=>ei(e.session_id).then(()=>V(!1)).catch(e=>S(e instanceof Error?e.message:String(e),"err")),children:c("agent.sessions.resume")})]})]},e.session_id)}),er.length>0&&(0,a.jsx)("div",{className:"eyebrow mt-s",children:c("agent.sessions.delegated")}),er.map(e=>{var s;return(0,a.jsxs)("div",{className:"card card-pad col fa-sess ".concat(K===e.session_id?"on":""),children:[(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)(m.A,{size:14,className:"muted"}),(0,a.jsx)("b",{className:"grow",children:c("agent.sessions.from",{name:null!=(s=e.from_name)?s:c("chat.anOrchestrator")})}),(0,a.jsx)("span",{className:"muted small",children:(0,p.KN)(e.last_seen)})]}),e.task&&(0,a.jsx)("span",{className:"small fa-clamp3",children:e.task}),(0,a.jsx)("div",{className:"row gap-s",children:(0,a.jsx)("button",{className:"btn sm",onClick:()=>{O(K===e.session_id?void 0:e.session_id),V(!1)},children:K===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")})})]},e.session_id)})]})})]})}),ee.deleteModal,_&&(0,a.jsx)(I.TM,{danger:!0,title:c("fa.unsaved.title"),body:c("fa.unsaved.body"),confirmLabel:c("fa.unsaved.discard"),cancelLabel:c("fa.unsaved.keep"),onClose:()=>T(!1),onConfirm:()=>{ee.discard(),V(!1)}}),"new"===W&&(0,a.jsx)(I.TM,{title:c("agent.newConvTitle"),body:c("agent.newConvBody"),confirmLabel:c("agent.newConvStart"),onClose:()=>q(null),onConfirm:async()=>{await x.FH.post("/agents/".concat(t,"/new-session")),await k(["agents"]),S(c("agent.newConvStarted"))}})]})}},48776:(e,s,t)=>{"use strict";t.d(s,{G:()=>r});var a=t(94799),n=t(86606),l=t(48538),i=t(3749),c=t(69654);function r(e){let{agent:s,onClose:t,onDeleted:r}=e,{t:o}=(0,c.s9)(),{refresh:d}=(0,l.zd)(),h=(0,n.dj)();return(0,a.jsx)(n.TM,{title:o("agent.deleteTitle",{name:s.name}),body:o("agent.deleteBody"),danger:!0,confirmLabel:o("agent.delete"),cancelLabel:o("agent.keep"),onClose:t,onConfirm:async()=>{await i.FH.del("/agents/".concat(s.id)),await d(["agents","colonies"]),h(o("agent.deleted")),null==r||r()}})}},89128:(e,s,t)=>{"use strict";t.d(s,{A:()=>m});var a=t(94799),n=t(34023),l=t(97356),i=t(86606),c=t(5300),r=t(48776),o=t(48538),d=t(73506),h=t(3749),u=t(69654);function m(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t}=(0,u.s9)(),{agents:m,colonies:g,objects:x,refresh:p}=(0,o.q5)(),j=(0,i.dj)(),b=(0,n.useMemo)(()=>e?x.filter(s=>s.manager_id===e.id).map(e=>e.id).sort():[],[x,null==e?void 0:e.id]),f=(0,n.useMemo)(()=>e?JSON.stringify((0,c.TN)(e,b)):"",[e,b]),[v,N]=(0,n.useState)(()=>e?(0,c.TN)(e,b):null),[y,k]=(0,n.useState)(!1),[w,C]=(0,n.useState)(!1);(0,n.useEffect)(()=>{N(e?(0,c.TN)(e,b):null)},[f]);let S=v&&e?(0,c.tf)(v,m,e.id,g):{},A=!!v&&JSON.stringify(v)!==f;(0,d.h)(A);let z=async()=>{if(v&&e){if(Object.keys(S).length)return void j(t("edit.fixFields"),"err");k(!0);try{var a;let{type_id:n,object_ids:l,...i}=v;await h.FH.patch("/agents/".concat(e.id),i),JSON.stringify([...l].sort())!==JSON.stringify(b)&&await h.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:l}),await p(["agents","colonies","objects"]),j(t("edit.saved",{name:v.name.trim()})),null==(a=s.onSaved)||a.call(s)}catch(e){j(e instanceof Error?e.message:t("edit.saveFailed"),"err")}k(!1)}},E=()=>{e&&N((0,c.TN)(e,b))};return{draft:v,setDraft:N,errors:S,dirty:A,saving:y,save:z,discard:E,actions:function(){var e,s,n,i;let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{className:"btn danger push-r ".concat(null!=(e=c.size)?e:""),onClick:()=>C(!0),children:[(0,a.jsx)(l.A,{size:c.size?14:15}),t("agent.delete")]}),c.onCancel?(0,a.jsx)("button",{className:"btn ghost ".concat(null!=(s=c.size)?s:""),onClick:c.onCancel,children:t("common.cancel")}):(0,a.jsx)("button",{className:"btn ghost ".concat(null!=(n=c.size)?n:""),disabled:!A,onClick:E,children:t("common.discard")}),(0,a.jsx)("button",{className:"btn primary ".concat(null!=(i=c.size)?i:""),disabled:!A||y,onClick:z,children:y?t("common.saving"):t("common.saveChanges")})]})},deleteModal:w&&e?(0,a.jsx)(r.G,{agent:e,onClose:()=>C(!1),onDeleted:s.onDeleted}):null}}}},e=>{e.O(0,[586,706,837,486,316,839,517,350,291,30,705,408,89,358],()=>e(e.s=16054)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{5506:(e,t,n)=>{"use strict";n.d(t,{Shell:()=>B});var l=n(94799),a=n(41463),s=n.n(a),r=n(43624),i=n(34023),o=n(84616),c=n(6261),d=n(29416),u=n(26701),h=n(74955);let m=(0,h.A)("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);var v=n(15223),k=n(54234),y=n(73784);let p=(0,h.A)("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);var b=n(68449),x=n(70283);let g=(0,h.A)("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),f=(0,h.A)("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);var j=n(48538),w=n(69654),A=n(86606);function N(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(null),s=(0,i.useRef)(null);return((0,i.useEffect)(()=>{let e,n=null,l=()=>{clearTimeout(e),n=null,t(null),a(null)},s=e=>e instanceof Element?e.closest("[title],[data-tip]"):null,r=function(a){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!a||a===n)return;l();let r=(e=>{var t,n;let l=e.getAttribute("title");return null!==l&&(e.removeAttribute("title"),l.trim()&&(e.dataset.tip=l,e.getAttribute("aria-label")||(null==(t=e.textContent)?void 0:t.trim())||e.setAttribute("aria-label",l))),null!=(n=e.dataset.tip)?n:""})(a);if(!r)return;n=a;let i=()=>{n===a&&a.isConnected&&t({text:r,rect:a.getBoundingClientRect()})};s?i():e=setTimeout(i,350)},i=e=>r(s(e.target)),o=e=>{n&&!(e.relatedTarget instanceof Node&&n.contains(e.relatedTarget))&&l()},c=e=>{let t=s(e.target);t&&t.matches(":focus-visible")&&r(t,!0)},d=e=>{"Escape"===e.key&&l()};return document.addEventListener("mouseover",i),document.addEventListener("mouseout",o),document.addEventListener("focusin",c),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",d),window.addEventListener("scroll",l,!0),window.addEventListener("blur",l),()=>{l(),document.removeEventListener("mouseover",i),document.removeEventListener("mouseout",o),document.removeEventListener("focusin",c),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",d),window.removeEventListener("scroll",l,!0),window.removeEventListener("blur",l)}},[]),(0,i.useLayoutEffect)(()=>{if(!e||!s.current)return;let{width:t,height:n}=s.current.getBoundingClientRect(),l=e.rect.top-n-8<8;a({left:Math.min(Math.max(8,e.rect.left+e.rect.width/2-t/2),window.innerWidth-t-8),top:l?e.rect.bottom+8:e.rect.top-n-8,below:l})},[e]),e)?(0,l.jsx)("div",{ref:s,className:"tooltip",role:"tooltip","data-live":!0,"data-below":(null==n?void 0:n.below)?"1":void 0,style:n?{left:n.left,top:n.top}:{left:0,top:0,visibility:"hidden"},children:e.text}):null}var M=n(42162),E=n(19431),z=n(70665),C=n(92947),S=n(80306),L=n(12349),H=n(75010);n(21169);var _=n(69538);let T=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,F=()=>({background:T("--bg-deep","#0c1411"),foreground:T("--ink","#e7eee9"),cursor:T("--honey","#e8a317"),cursorAccent:T("--bg-deep","#0c1411"),selectionBackground:"rgba(232,163,23,.35)"});function P(e){let{id:t,visible:a,onEnded:s}=e,{t:r}=(0,w.s9)(),o=(0,i.useRef)(null),c=(0,i.useRef)(null),d=(0,i.useRef)(a);return d.current=a,(0,i.useEffect)(()=>{let e=!1,l=null,a,i=!1,u=0,h=null,m=null,v=null,k=null,y=e=>{(null==l?void 0:l.readyState)===WebSocket.OPEN&&l.send(JSON.stringify(e))},p=()=>{var e;if(h&&m&&(null==(e=o.current)?void 0:e.offsetParent))try{m.fit(),y({t:"resize",cols:h.cols,rows:h.rows})}catch(e){}};return(async()=>{let[{Terminal:b},{FitAddon:x},{WebLinksAddon:g}]=await Promise.all([n.e(209).then(n.bind(n,75657)),n.e(97).then(n.bind(n,57097)),n.e(545).then(n.bind(n,90545))]);if(e||!o.current)return;h=new b({fontFamily:T("--font-mono","ui-monospace, monospace"),fontSize:13,lineHeight:1.15,cursorBlink:!0,scrollback:5e3,theme:F(),allowProposedApi:!1}),m=new x,h.loadAddon(m),h.loadAddon(new g),h.open(o.current),c.current={fit:p,focus:()=>null==h?void 0:h.focus()},d.current&&(p(),h.focus()),h.onData(e=>y({t:"in",d:e}));let f=()=>{var e;let t=null==h?void 0:h.getSelection();return t&&(null==(e=navigator.clipboard)||e.writeText(t).catch(()=>{})),!!t};h.onSelectionChange(()=>{f()}),h.attachCustomKeyEventHandler(e=>"keydown"!==e.type||!e.ctrlKey||!!e.altKey||!!e.metaKey||!("c"===e.key.toLowerCase()&&(e.shiftKey||(null==h?void 0:h.hasSelection())))||(f(),!1)),(v=new ResizeObserver(p)).observe(o.current),(k=new MutationObserver(()=>{h&&(h.options.theme=F())})).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let j=()=>{var n;(l=new WebSocket("".concat("ws://".concat(location.hostname,":").concat(null!=(n=_.env.NEXT_PUBLIC_HIVE_WS_PORT)?n:4400,"/ws/terminal"),"?id=").concat(encodeURIComponent(t)))).onopen=()=>{u=0},l.onmessage=e=>{let t=JSON.parse(e.data);"init"===t.t?(h.reset(),p()):"out"===t.t?h.write(t.d):"exit"===t.t?(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.ended",{code:t.code}),"]\x1b[0m\r\n")),s(t.code)):"gone"===t.t&&(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.gone"),"]\x1b[0m\r\n")),s(null))},l.onclose=()=>{e||i||(a=setTimeout(j,Math.min(5e3,600*2**u++)))}};j()})(),()=>{e=!0,clearTimeout(a),null==v||v.disconnect(),null==k||k.disconnect(),null==l||l.close(),null==h||h.dispose(),c.current=null}},[t]),(0,i.useEffect)(()=>{if(a){let e=setTimeout(()=>{var e,t;null==(e=c.current)||e.fit(),null==(t=c.current)||t.focus()},30);return()=>clearTimeout(e)}},[a]),(0,l.jsx)("div",{className:"xterm-box",ref:o})}let R=e=>"dock-tab-".concat(e);function q(){var e;let{t}=(0,w.s9)(),n=(0,M.n)(),[a,s]=(0,i.useState)(null),r=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{r.current&&n.setHeight(r.current.h+(r.current.y-e.clientY))},t=()=>{r.current=null,document.body.style.userSelect=""};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[n]);let o=n.tabs.some(e=>e.key===n.active),c=null==(e=[...n.tabs].reverse().find(e=>"term"===e.kind))?void 0:e.cwd;return(0,l.jsxs)("section",{className:"dock",style:{height:n.height,display:n.open?void 0:"none"},"aria-hidden":!n.open,"aria-label":t("dock.title"),children:[(0,l.jsx)("div",{className:"dock-grip",onPointerDown:e=>{r.current={y:e.clientY,h:n.height},document.body.style.userSelect="none",e.preventDefault()},role:"separator","aria-orientation":"horizontal"}),(0,l.jsxs)("div",{className:"dock-bar",children:[(0,l.jsx)("div",{className:"dock-tabs",role:"tablist","aria-label":t("dock.title"),onKeyDown:e=>{var t;let l=n.tabs.map(e=>e.key),a=l.indexOf(null!=(t=n.active)?t:""),s=null;if("ArrowRight"===e.key)s=(a+1)%l.length;else if("ArrowLeft"===e.key)s=(a-1+l.length)%l.length;else if("Home"===e.key)s=0;else if("End"===e.key)s=l.length-1;else if("Delete"===e.key&&a>=0){e.preventDefault(),n.closeTab(l[a]);return}null!==s&&l.length&&(e.preventDefault(),n.setActive(l[s]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(R(l[s])))?void 0:e.focus()}))},children:n.tabs.map(e=>{var a;let s=n.active===e.key,r=R(e.key);return(0,l.jsxs)("div",{className:"dock-tabwrap ".concat(s?"on":""),children:[(0,l.jsxs)("button",{id:r,type:"button",role:"tab","aria-selected":s,"aria-controls":"".concat(r,"-panel"),tabIndex:s||!o&&e===n.tabs[0]?0:-1,className:"dock-tab-btn",onClick:()=>n.setActive(e.key),title:"term"===e.kind?e.cwd:t("obj.logs"),children:["term"===e.kind?(0,l.jsx)(x.A,{size:14}):(0,l.jsx)(E.A,{size:14}),(0,l.jsx)("span",{className:"nm",children:e.title}),"term"===e.kind&&void 0!==e.ended&&(0,l.jsx)("i",{className:"odot off",title:t("dock.ended",{code:null!=(a=e.ended)?a:""})})]}),(0,l.jsx)("button",{type:"button",className:"dock-x",tabIndex:-1,onClick:()=>n.closeTab(e.key),"aria-label":"".concat(t("common.close"),": ").concat(e.title),children:(0,l.jsx)(z.A,{size:12})})]},e.key)})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void n.openTerminal(c?{cwd:c}:{}),"aria-label":t("dock.new"),title:t("dock.new"),children:(0,l.jsx)(C.A,{size:15})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>s(null!=c?c:""),"aria-label":t("dock.inFolder"),title:t("dock.inFolder"),children:(0,l.jsx)(S.A,{size:15})}),(0,l.jsx)("span",{className:"grow"}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>n.setOpen(!1),"aria-label":t("dock.hide"),title:"".concat(t("dock.hide")," (Ctrl+`)"),children:(0,l.jsx)(L.A,{size:15})})]}),(0,l.jsxs)("div",{className:"dock-body",children:[n.error&&(0,l.jsx)("p",{className:"gx-note err gx-hint-row",role:"alert",children:n.error}),!n.enabled&&!n.tabs.length&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.disabled")}),n.enabled&&!n.tabs.length&&!n.error&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.empty")}),n.tabs.map(e=>(0,l.jsx)("div",{id:"".concat(R(e.key),"-panel"),role:"tabpanel","aria-labelledby":R(e.key),className:"dock-pane",hidden:n.active!==e.key,children:"term"===e.kind?(0,l.jsx)(P,{id:e.id,visible:n.open&&n.active===e.key,onEnded:t=>n.markEnded(e.key,t)}):n.open&&(0,l.jsx)("div",{className:"dock-logpane",children:(0,l.jsx)(H.I,{id:e.objectId,height:"100%"})})},e.key))]}),null!==a&&(0,l.jsxs)(A.aF,{title:t("dock.inFolder"),onClose:()=>s(null),children:[(0,l.jsx)(A.dR,{value:a,onChange:s,label:t("obj.f.folder"),hint:t("dock.folder.hint")}),(0,l.jsxs)("div",{className:"row confirm-actions",children:[(0,l.jsx)("button",{className:"btn ghost",onClick:()=>s(null),children:t("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",disabled:!a.startsWith("/"),onClick:()=>{s(null),n.openTerminal({cwd:a})},children:t("dock.open")})]})]})]})}function O(){return(0,l.jsx)("img",{src:"/icon.png",width:34,height:34,alt:"","aria-hidden":!0,className:"brand-mark"})}function V(){let{locale:e,setLocale:t,t:n}=(0,w.s9)();return(0,l.jsxs)("div",{className:"lang-row",role:"group","aria-label":n("lang.label"),children:[(0,l.jsx)(o.A,{size:15,"aria-hidden":!0}),(0,l.jsx)("div",{className:"seg",children:w.YZ.map(n=>(0,l.jsx)("button",{type:"button","aria-pressed":e===n.id,lang:n.id,title:n.name,"aria-label":n.name,onClick:()=>t(n.id),children:n.short},n.id))})]})}function I(){let e=(0,r.usePathname)(),{t}=(0,w.s9)(),{agents:n,types:a,skills:o,connections:h,objects:A,connected:N}=(0,j.o0)(),E=(0,M.n)(),[z,C]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=document.documentElement,t=()=>C("dark"===e.dataset.theme);t();let n=new MutationObserver(t);return n.observe(e,{attributes:!0,attributeFilter:["data-theme"]}),()=>n.disconnect()},[]);let S=n.filter(e=>"running"===e.status).length,L=(t,n,a,r)=>{let i="/"===t?"/"===e:e.startsWith(t);return(0,l.jsxs)(s(),{href:t,className:"nav","aria-current":i?"page":void 0,children:[a,(0,l.jsx)("span",{className:"t",children:n}),void 0!==r&&(0,l.jsx)("span",{className:"count",children:r})]},t)};return(0,l.jsxs)("nav",{className:"rail","aria-label":t("nav.main"),children:[(0,l.jsxs)("div",{className:"brand",children:[(0,l.jsx)(O,{}),(0,l.jsxs)("div",{children:["hive-am",(0,l.jsx)("small",{children:t("app.tagline")})]})]}),(0,l.jsx)(V,{}),L("/",t("nav.colony"),(0,l.jsx)(c.A,{size:18}),S||void 0),L("/resources",t("nav.objects"),(0,l.jsx)(d.A,{size:18}),A.length||void 0),L("/agents",t("nav.agents"),(0,l.jsx)(u.A,{size:18}),n.length),L("/relations",t("nav.relations"),(0,l.jsx)(m,{size:18})),L("/connections",t("nav.connections"),(0,l.jsx)(v.A,{size:18}),h.length||void 0),L("/schedules",t("nav.schedules"),(0,l.jsx)(k.A,{size:18})),(0,l.jsx)("div",{className:"nav-label",children:t("nav.library")}),L("/types",t("nav.types"),(0,l.jsx)(y.A,{size:18}),a.length),L("/skills",t("nav.skills"),(0,l.jsx)(p,{size:18}),o.length),(0,l.jsx)("div",{className:"nav-label",children:t("nav.history")}),L("/sessions",t("nav.sessions"),(0,l.jsx)(b.A,{size:18})),(0,l.jsxs)("div",{className:"rail-foot",children:[(0,l.jsxs)("button",{type:"button",className:"nav",onClick:E.toggle,"aria-pressed":E.open,title:"".concat(t("dock.nav")," (Ctrl+`)"),children:[(0,l.jsx)(x.A,{size:18}),(0,l.jsx)("span",{className:"t",children:t("dock.nav")}),E.tabs.length>0&&(0,l.jsx)("span",{className:"count",children:E.tabs.length})]}),(0,l.jsxs)("div",{className:"conn",children:[(0,l.jsx)("i",{className:"dot ".concat(N?"ok":"err")}),t(N?"nav.connected":"nav.offline")]}),(0,l.jsxs)("button",{type:"button",className:"nav",onClick:()=>{let e=z?"light":"dark";document.documentElement.dataset.theme=e;try{localStorage.setItem("hive-theme",e)}catch(e){}},"aria-pressed":z,children:[z?(0,l.jsx)(g,{size:18}):(0,l.jsx)(f,{size:18}),(0,l.jsx)("span",{className:"t",children:t("nav.switchTheme")})]})]})]})}function B(e){let{children:t}=e;return(0,l.jsx)(w.CY,{children:(0,l.jsx)(j.Of,{children:(0,l.jsx)(M.$,{children:(0,l.jsxs)(A.l$,{children:[(0,l.jsx)(N,{}),(0,l.jsxs)("div",{className:"shell",children:[(0,l.jsx)(I,{}),(0,l.jsx)("main",{className:"main",children:t})]}),(0,l.jsx)(q,{})]})})})})}},6261:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 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 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},15151:e=>{e.exports={style:{fontFamily:"'JetBrains Mono', 'JetBrains Mono Fallback'",fontStyle:"normal"},className:"__className_4dc837",variable:"__variable_4dc837"}},15223:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]])},19431:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FileText",[["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"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},21169:()=>{},26701:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},29416:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},39856:e=>{e.exports={style:{fontFamily:"'Bricolage Grotesque', 'Bricolage Grotesque Fallback'",fontStyle:"normal"},className:"__className_23d1a5",variable:"__variable_23d1a5"}},42162:(e,t,n)=>{"use strict";n.d(t,{$:()=>u,n:()=>o});var l=n(94799),a=n(34023),s=n(3749),r=n(69654);let i=(0,a.createContext)(null),o=()=>{let e=(0,a.useContext)(i);if(!e)throw Error("DockProvider missing");return e},c="hive-am.dock",d=e=>Math.max(140,Math.min(e,Math.round(.8*window.innerHeight)));function u(e){let{children:t}=e,{t:n}=(0,r.s9)(),[o,u]=(0,a.useState)(!1),[h,m]=(0,a.useState)(320),[v,k]=(0,a.useState)([]),[y,p]=(0,a.useState)(null),[b,x]=(0,a.useState)(!0),[g,f]=(0,a.useState)(""),j=(0,a.useRef)(!1);(0,a.useEffect)(()=>{try{var e;let t=JSON.parse(null!=(e=localStorage.getItem(c))?e:"{}");"number"==typeof t.height&&m(d(t.height)),t.open&&u(!0),"string"==typeof t.active&&p(t.active)}catch(e){}s.FH.get("/terminals").then(e=>{x(e.enabled),k(t=>[...e.terminals.map(e=>({key:"t:".concat(e.id),kind:"term",id:e.id,title:e.title,cwd:e.cwd,ended:e.alive?void 0:e.exitCode})),...t.filter(e=>"logs"===e.kind)]),p(t=>t&&e.terminals.some(e=>"t:".concat(e.id)===t)?t:e.terminals[0]?"t:".concat(e.terminals[0].id):t)}).catch(()=>void 0).finally(()=>{j.current=!0})},[]),(0,a.useEffect)(()=>{if(j.current)try{localStorage.setItem(c,JSON.stringify({open:o,height:h,active:y}))}catch(e){}},[o,h,y]),(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--app-h",o?"calc(100vh - ".concat(h,"px)"):"100vh")},[o,h]);let w=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};f("");try{let t=await s.FH.post("/terminals",e),n={key:"t:".concat(t.id),kind:"term",id:t.id,title:t.title,cwd:t.cwd};k(e=>[...e,n]),p(n.key),u(!0)}catch(e){f(e instanceof Error?e.message:n("dock.failed")),u(!0)}},[n]),A=(0,a.useCallback)((e,t)=>{let n="l:".concat(e);k(l=>l.some(e=>e.key===n)?l:[...l,{key:n,kind:"logs",objectId:e,title:t}]),p(n),u(!0)},[]),N=(0,a.useCallback)(e=>{k(t=>{let n=t.find(t=>t.key===e);(null==n?void 0:n.kind)==="term"&&s.FH.del("/terminals/".concat(n.id)).catch(()=>void 0);let l=t.filter(t=>t.key!==e);return p(t=>{var n,a;return t===e?null!=(a=null==(n=l[l.length-1])?void 0:n.key)?a:null:t}),l})},[]),M=(0,a.useCallback)((e,t)=>k(n=>n.map(n=>n.key===e&&"term"===n.kind?{...n,ended:null!=t?t:0}:n)),[]),E=(0,a.useCallback)(()=>{if(o)return void u(!1);u(!0),!v.length&&b&&w()},[o,v.length,b,w]);(0,a.useEffect)(()=>{let e=e=>{!e.ctrlKey||e.altKey||e.metaKey||"`"!==e.key&&"Backquote"!==e.code||(e.preventDefault(),e.stopPropagation(),E())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[E]);let z=(0,a.useMemo)(()=>({open:o,height:h,tabs:v,active:y,enabled:b,error:g,toggle:E,setOpen:u,setHeight:e=>m(d(e)),setActive:p,openTerminal:w,openLogs:A,closeTab:N,markEnded:M}),[o,h,v,y,b,g,E,w,A,N,M]);return(0,l.jsx)(i.Provider,{value:z,children:t})}},54234:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},64883:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]])},68449:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("History",[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},70283:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]])},73784:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]])},75010:(e,t,n)=>{"use strict";n.d(t,{I:()=>d});var l=n(94799),a=n(34023),s=n(98392),r=n(64883),i=n(3749),o=n(69654);let c=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function d(e){let{id:t,height:n=220}=e,{t:d}=(0,o.s9)(),[u,h]=(0,a.useState)(null),m=(0,a.useRef)(""),v=(0,a.useRef)(null),k=(0,a.useRef)(!0),[y,p]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,n;h(null),m.current="",k.current=!0,p(!1);let l=async()=>{try{let n=m.current?"after=".concat(encodeURIComponent(m.current)):"tail=300",l=await i.FH.get("/objects/".concat(t,"/logs?").concat(n));if(e)return;m.current=l.cursor||m.current;let a=l.text.replace(c,"");h(e=>{let t=l.reset?"":null!=e?e:"";if(!a)return null!=e?e:"";let n=!t||t.endsWith("\n")||a.startsWith("\n")?t+a:"".concat(t,"\n").concat(a);return n.length>2e5?n.slice(n.length-2e5):n})}catch(e){}e||(n=setTimeout(l,1200))};return l(),()=>{e=!0,clearTimeout(n)}},[t]),(0,a.useEffect)(()=>{let e=v.current;e&&k.current&&(e.scrollTop=e.scrollHeight)},[u]),(0,l.jsxs)("div",{className:"logv",children:[(0,l.jsx)("pre",{ref:v,className:"logv-body mono",style:{height:n},onScroll:()=>{let e=v.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;k.current=t,p(!t)},tabIndex:0,children:null===u?d("git.loading"):u.trim()?u:d("obj.logs.empty")}),(0,l.jsxs)("div",{className:"logv-tools",children:[y&&(0,l.jsxs)("button",{className:"btn sm",onClick:()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight,k.current=!0,p(!1))},children:[(0,l.jsx)(s.A,{size:14}),d("obj.logs.bottom")]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>h(""),"aria-label":d("obj.logs.clear"),title:d("obj.logs.clear"),children:(0,l.jsx)(r.A,{size:14})})]})]})}},80306:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]])},84616:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},87968:()=>{},92605:(e,t,n)=>{Promise.resolve().then(n.bind(n,5506)),Promise.resolve().then(n.t.bind(n,39856,23)),Promise.resolve().then(n.t.bind(n,98682,23)),Promise.resolve().then(n.t.bind(n,15151,23)),Promise.resolve().then(n.t.bind(n,87968,23))},92947:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98392:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]])},98682:e=>{e.exports={style:{fontFamily:"'Hanken Grotesk', 'Hanken Grotesk Fallback'",fontStyle:"normal"},className:"__className_67a390",variable:"__variable_67a390"}}},e=>{e.O(0,[584,597,586,839,408,89,358],()=>e(e.s=92605)),_N_E=e.O()}]);