import{x as e}from"./xterm-addon-canvas.js?v=1753954525509";import{x as o,a as n,b as a,c as s}from"./xterm.js?v=1753954525509";import{z as t}from"./public.js?v=1753954525509";import{k as l,P as r,r as d,an as i,o as u,b as c,U as m,V as f,n as v}from"./vue.js?v=1753954525509";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:_}=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?(C.write("\r"+x("Component.Terminal.index_1")+"\r"),y(),void _()):void 0:(_(),void y())}});let C,O;const k=d(!1),j=d(null),z=()=>{const o=g.value;o&&(C.loadAddon(O),C.loadAddon(new e.CanvasAddon),C.loadAddon(new a.WebLinksAddon),C.loadAddon(new s.AttachAddon(o)))},M=()=>{j.value&&C.open(j.value)};let T=!1;const y=()=>{T=!1},D=()=>{(()=>{const{data:e}=p;e.forEach((e=>{b(e)}))})(),C.focus(),C.onData((e=>{const o=g.value;"\r"===e&&k.value&&(k.value=!1,C.write("\r\n"),E()),null!==o||"\r"!==e||T||(T=!0,C.write("\r\n"+x("Component.Terminal.index_2")+"\r\n"),E())}))},E=()=>{D();const e=g.value;e&&C.loadAddon(new s.AttachAddon(e))},F=()=>{v((()=>{if(O.fit(),"CLOSED"!==h.value){const{cols:e,rows:o}=C;b({cols:e,rows:o,resize:1})}}))};let L=!0;const R=new ResizeObserver((()=>{i((()=>{L?L=!1:F()}),200)()}));return u((()=>{C=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(),D(),F(),(()=>{const e=j.value;e&&R.observe(e)})()})),c((()=>{_(),null==R||R.disconnect(),null==C||C.dispose()})),(e,o)=>(m(),f("div",{ref_key:"terminalRef",ref:j,class:"w-full h-full"},null,512))}});export{w as _};
