import{e as w}from"./chunk-SZAW6ZBW.js";var n,i,l=w(()=>{n=class{constructor(s){this.initConfig=s,this.startTime=0,this.websocket=null}start(){let{wsUrl:s,cols:t,rows:e,env:h,terminal:r}=this.initConfig;s.searchParams.set("fileType","asciicast"),this.websocket=new i(s.toString()),this.startTime=Date.now(),this.send({version:2,timestamp:this.startTime,width:t,height:e,env:h}),r.onServerOutput(a=>{let c=a.replace(/\r?\n/g,`\r
`);this.onEvent("o",c)})}stop(){this.websocket?.close()}onEvent(s,t){let e=(Date.now()-this.startTime)/1e3;this.send([e,s,t])}send(s){this.websocket?.send(JSON.stringify(s)+`
`)}},i=class{constructor(s){this.queue=[],this.ready=!1,this.ws=new WebSocket(s),this.ws.onopen=()=>{this.ready=!0;for(let t of this.queue)this.ws.send(t);this.queue=[]}}send(s){this.ready?this.ws.send(s):this.queue.push(s)}close(){this.ws.close()}}});export{n as a,l as b};
