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