import{a5 as E,H as B,r as f,E as p,_ as $,ap as V,Z as I,I as F,aa as R}from"./f1cbvne4.js";import{x as D,a as M}from"./vendor/xterm-dbpzgj7s.js";import{p as y,k as g,E as P,I as d,a2 as t,F as A,R as c,a4 as N,U as m,S as v,a9 as _,q,w as z,u as w,af as L,aa as C,Y as h,ak as S,a3 as j}from"./vendor/json-editor-vue-g7zhhq6q.js";import"./vendor/unocss-hvn0t0zz.js";import"./vendor/shiki-hjqm7vcp.js";const H={border:"t base",flex:"~ gap-2","items-center":"",p2:""},U={"text-sm":"",op50:""},Y=y({__name:"TerminalView",props:{id:{}},setup(k){const n=k,r=g(),i=E(),o=g();let a;P(async()=>{a=new D.Terminal({convertEol:!0,cols:80,screenReaderMode:!0});const u=new M.FitAddon;a.loadAddon(u),a.open(r.value),u.fit(),B(window,"resize",()=>{u.fit()}),o.value=await f.getTerminalDetail(await p(),n.id),o.value?.buffer&&a.write(o.value.buffer),i.hook("devtools:terminal:data",({id:e,data:l})=>{e===n.id&&a.write(l)})});async function s(){f.runTerminalAction(await p(),n.id,"clear"),a?.clear()}async function b(){f.runTerminalAction(await p(),n.id,"restart")}async function x(){f.runTerminalAction(await p(),n.id,"terminate")}return(u,e)=>{const l=$;return t(),d(A,null,[c("div",{ref_key:"container",ref:r,"h-full":"","w-full":"","of-auto":"","bg-black":""},null,512),c("div",H,[N(l,{title:"Clear",icon:"i-carbon-clean",border:!1,onClick:e[0]||(e[0]=T=>s())}),o.value?.restartable?(t(),m(l,{key:0,title:"Restart",icon:"carbon-renew",border:!1,onClick:e[1]||(e[1]=T=>b())})):v("",!0),o.value?.terminatable?(t(),m(l,{key:1,title:"Terminate",icon:"carbon-delete",border:!1,onClick:e[2]||(e[2]=T=>x())})):v("",!0),c("span",U,_(o.value?.description),1)])],64)}}}),Z={key:0,"h-full":"","w-full":"","of-hidden":"",grid:"~ rows-[max-content_1fr_max-content]"},G={flex:"~",border:"b base","flex-1":"","items-center":"","n-navbar-glass":""},J=["onClick"],K={key:1,p10:""},O={key:1,"h-full":"",flex:"","items-center":"","justify-center":""},Q=y({__name:"TerminalPage",setup(k){const n=V(),r=I(),i=q(()=>n.value?.find(a=>a.id===r.value));async function o(a){f.runTerminalAction(await p(),a,"remove")}return z(()=>{!r.value&&n.value?.length&&(r.value=n.value[0].id)}),(a,s)=>{const b=F,x=$,u=Y;return w(n)?.length?(t(),d("div",Z,[c("div",G,[(t(!0),d(A,null,L(w(n),e=>(t(),d("button",{key:e.id,border:"r base",flex:"~ gap-2","items-center":"",px3:"",py2:"",class:h(e.id===i.value?.id?"bg-active":""),onClick:l=>r.value=e.id},[e.icon?(t(),m(b,{key:0,icon:e.icon},null,8,["icon"])):v("",!0),c("span",{class:h(e.id===i.value?.id?"":"op50")},_(e.name)+_(e.isTerminated?" (terminated)":""),3),e.isTerminated?(t(),m(x,{key:1,icon:"carbon-close","mx--2":"",border:!1,onClick:S(l=>o(e.id),["stop"])},null,8,["onClick"])):v("",!0)],10,J))),128))]),i.value?(t(),m(u,{id:i.value.id,key:i.value.id},null,8,["id"])):(t(),d("div",K,[s[0]||(s[0]=C(" Terminal ")),c("code",null,_(w(r)),1),s[1]||(s[1]=C(" not found "))]))])):(t(),d("div",O,s[2]||(s[2]=[c("em",{op50:""},"No terminal attached",-1)])))}}}),ae=y({__name:"terminals",setup(k){return(n,r)=>{const i=Q,o=R;return t(),m(o,null,{default:j(()=>[N(i)]),_:1})}}});export{ae as default};
