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