const c="Socket.Close",i="Socket.Error",l="Socket.Open",p=self.location.protocol==="https"?"wss":"ws",d=`${p}://${self.location.hostname}:9090`,o=new WebSocket(d);function f(s){const e=s.map(({id:t,method:n,params:r})=>{const a={id:t??n,jsonrpc:"2.0",method:n};return r&&(a.params=r),a});o.send(JSON.stringify(e))}o.addEventListener("error",()=>{self.postMessage({id:i,jsonrpc:"2.0",result:"ERROR"})});o.addEventListener("open",()=>{self.postMessage({id:l,jsonrpc:"2.0",result:"OK"})});o.addEventListener("close",({code:s,reason:e})=>{self.postMessage({id:c,jsonrpc:"2.0",result:{code:s,reason:e}})});o.addEventListener("message",({data:s})=>{const e=JSON.parse(s);Array.isArray(e)?e.forEach(t=>self.postMessage(t)):self.postMessage(e)});self.addEventListener("message",({data:s})=>{Array.isArray(s)&&f(s)});
