import{ay as a}from"./utils-lib.js?v=1761009159";import{r as e}from"./base-lib.js?v=1761009159";const s=(s,l=!0)=>{const c=e(null);let t={};const o=(a,e)=>{try{const s=JSON.parse(e.data),l=s.callback||s.ws_callback||s.def_name;l&&t[l]&&t[l].callback(a,e)}catch(s){}},r=(a,e)=>{var s;t[a.ws_callback]&&(t[a.ws_callback]=void 0),t[a.ws_callback]={data:a,callback:e,request:!0},null==(s=c.value)||s.send(a)};return c.value=a({route:s,onMessage:o,autoReconnect:l}),{socketRequest:({params:a,onMessage:e=!1})=>e?r(a,(a,s)=>{const l=JSON.parse(s.data);e(l)}):new Promise(e=>{r(a,(s,l)=>{const c=JSON.parse(l.data),o=c.callback||c.ws_callback||c.def_name;delete t[o],a.ws_callback===o&&e(c)})}),socketDestroy:()=>{c.value&&c.value.close(),t={}}}};export{s as u};
