import{a5 as E,G as V,r as _,E as p,_ as $,ap as B,Z as D,I as F,aa as I}from"#entry";import{x as P,a as j}from"./vendor/xterm-nmc0lagr.js";import{p as T,k as g,D as M,J as d,Y as t,F as A,a3 as c,a1 as N,X as m,a4 as v,ab as f,q as R,w as q,u as w,ah as z,a7 as C,am as L,ac as h,$ as O}from"./vendor/json-editor-vue-ikjc812x.js";import"./vendor/shiki-hpfujfi3.js";import"./vendor/unocss-hczpatch.js";const G={border:"t base",flex:"~ gap-2","items-center":"",p2:""},J={"text-sm":"",op50:""},S=T({__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 j.FitAddon;a.loadAddon(u),a.open(i.value),u.fit(),V(window,"resize",()=>{u.fit()}),o.value=await _.getTerminalDetail(await p(),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(){_.runTerminalAction(await p(),n.id,"clear"),a?.clear()}async function x(){_.runTerminalAction(await p(),n.id,"restart")}async function k(){_.runTerminalAction(await p(),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",G,[N(l,{title:"Clear",icon:"i-carbon-clean",border:!1,onClick:e[0]||(e[0]=y=>s())}),o.value?.restartable?(t(),m(l,{key:0,title:"Restart",icon:"carbon-renew",border:!1,onClick:e[1]||(e[1]=y=>x())})):v("",!0),o.value?.terminatable?(t(),m(l,{key:1,title:"Terminate",icon:"carbon-delete",border:!1,onClick:e[2]||(e[2]=y=>k())})):v("",!0),c("span",J,f(o.value?.description),1)])],64)}}}),X=Object.assign(S,{__name:"TerminalView"}),Y={key:0,"h-full":"","w-full":"","of-hidden":"",grid:"~ rows-[max-content_1fr_max-content]"},Z={flex:"~",border:"b base","n-navbar-glass":"","flex-1":"","items-center":""},H=["onClick"],K={key:1,p10:""},Q={key:1,"h-full":"",flex:"","items-center":"","justify-center":""},U=T({__name:"TerminalPage",setup(b){const n=B(),i=D(),r=R(()=>n.value?.find(a=>a.id===i.value));async function o(a){_.runTerminalAction(await p(),a,"remove")}return q(()=>{!i.value&&n.value?.length&&(i.value=n.value[0].id)}),(a,s)=>{const x=F,k=$,u=X;return w(n)?.length?(t(),d("div",Y,[c("div",Z,[(t(!0),d(A,null,z(w(n),e=>(t(),d("button",{key:e.id,border:"r base",flex:"~ gap-2","items-center":"",px3:"",py2:"",class:C(e.id===r.value?.id?"bg-active":""),onClick:l=>i.value=e.id},[e.icon?(t(),m(x,{key:0,icon:e.icon},null,8,["icon"])):v("",!0),c("span",{class:C(e.id===r.value?.id?"":"op50")},f(e.name)+f(e.isTerminated?" (terminated)":""),3),e.isTerminated?(t(),m(k,{key:1,icon:"carbon-close","mx--2":"",border:!1,onClick:L(l=>o(e.id),["stop"])},null,8,["onClick"])):v("",!0)],10,H))),128))]),r.value?(t(),m(u,{id:r.value.id,key:r.value.id},null,8,["id"])):(t(),d("div",K,[s[0]||(s[0]=h(" Terminal ",-1)),c("code",null,f(w(i)),1),s[1]||(s[1]=h(" not found ",-1))]))])):(t(),d("div",Q,[...s[2]||(s[2]=[c("em",{op50:""},"No terminal attached",-1)])]))}}}),W=Object.assign(U,{__name:"TerminalPage"}),ie=T({__name:"terminals",setup(b){return(n,i)=>{const r=W,o=I;return t(),m(o,null,{default:O(()=>[N(r)]),_:1})}}});export{ie as default};
