import{x as e}from"./xterm-addon-canvas.js?v=1764233927359";import{x as o,a as n,b as a,c as s}from"./xterm.js?v=1764233927359";import{C as t}from"./public.js?v=1764233927359";import{k as l,P as r,r as d,ap as i,o as u,b as c,R as m,V as f,n as v}from"./vue.js?v=1764233927359";const w=l({__name:"index",props:{url:{default:"/ws_model"},data:{default:()=>[]}},emits:["message"],setup(l,{emit:w}){const p=l,A=w,{t:x}=r(),{ws:g,status:h,send:b,close:C}=t(p.url,{onMessage:(e,o)=>{const n=o.data;return A("message",n),n.indexOf("Authentication timeout.")>-1&&(k.value=!0),-1==n.indexOf("@127.0.0.1:")&&-1==n.indexOf("@localhost:")||-1==n.indexOf("Authentication failed")?"\\r\\nlogout\\r\\n"==n||"logout\\r\\n"==n||"\r\nlogout\r\n"==n||"logout\r\n"==n||n.search(/logout[\r\n]+$/)>-1?(_.write("\r"+x("Component.Terminal.index_1")+"\r"),T(),void C()):void 0:(C(),void T())}});let _,O;const k=d(!1),j=d(null),z=()=>{const o=g.value;o&&(_.loadAddon(O),_.loadAddon(new e.CanvasAddon),_.loadAddon(new a.WebLinksAddon),_.loadAddon(new s.AttachAddon(o)))},M=()=>{j.value&&_.open(j.value)};let R=!1;const T=()=>{R=!1},y=()=>{(()=>{const{data:e}=p;e.forEach(e=>{b(e)})})(),_.focus(),_.onData(e=>{const o=g.value;"\r"===e&&k.value&&(k.value=!1,_.write("\r\n"),D()),null!==o||"\r"!==e||R||(R=!0,_.write("\r\n"+x("Component.Terminal.index_2")+"\r\n"),D())})},D=()=>{y();const e=g.value;e&&_.loadAddon(new s.AttachAddon(e))},E=()=>{v(()=>{if(O.fit(),"CLOSED"!==h.value){const{cols:e,rows:o}=_;b({cols:e,rows:o,resize:1})}})};let F=!0;const L=new ResizeObserver(()=>{i(()=>{F?F=!1:E()},200)()});return u(()=>{_=new o.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#333",foreground:"#ececec"}}),O=new n.FitAddon,z(),M(),y(),E(),(()=>{const e=j.value;e&&L.observe(e)})()}),c(()=>{C(),null==L||L.disconnect(),null==_||_.dispose()}),(e,o)=>(f(),m("div",{ref_key:"terminalRef",ref:j,class:"w-full h-full"},null,512))}});export{w as _};
