'use strict';
'use client';
import { io } from 'socket.io-client';
import { webSocketMethods } from '../constants/web-socket-methods.js';
import { isWebSocketDisabled } from '../../../fd-toolbox/lib/environments.js';

var __defProp=Object['defineProperty'],__name=(_0x1699d5,_0x4079a6)=>__defProp(_0x1699d5,'name',{'value':_0x4079a6,'configurable':!![]});async function webSocketEnsureConnected(_0x991ad3){if(socket?.['connected'])return void(0x1066+0xdf2+-0x1e58);return socket?.['connect'](),new Promise(_0x54c08f=>{function _0x408461(){socket?.['emit'](webSocketMethods['authorize'],_0x991ad3),_0x54c08f(()=>{socket?.['off'](webSocketMethods['clientConnect'],_0x408461);});}__name(_0x408461,'onConnect'),socket?.['on'](webSocketMethods['clientConnect'],_0x408461);});}__name(webSocketEnsureConnected,'webSocketEnsureConnected');function webSocketGetId(){return socket?.['id'];}__name(webSocketGetId,'webSocketGetId');function webSocketSubscribe(_0x429697,_0x12138f){socket?.['on'](_0x429697,_0x12138f);}__name(webSocketSubscribe,'webSocketSubscribe');function webSocketUnsubscribe(_0x30c01a,_0x5bda8c){socket?.['off'](_0x30c01a,_0x5bda8c);}__name(webSocketUnsubscribe,'webSocketUnsubscribe');const socketIoTransports=['websocket'],socket=((()=>{if(!isWebSocketDisabled())return io({'transports':socketIoTransports,'autoConnect':![]});return void(0x16c0+-0x2517+0xe57*0x1);})());

export { webSocketEnsureConnected, webSocketGetId, webSocketSubscribe, webSocketUnsubscribe };
