1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[50954],{50954:(e,t,s)=>{s.d(t,{wsManager:()=>c});var n=s(53413),i=s(26549);class o{static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(){if(!this.socket&&("unavailable"!==this.connectionStatus||!this.hasLoggedUnavailable))try{this.connectionStatus="connecting",n.A.getState().websocket.setStatus("connecting");let{io:e}=await s.e(9829).then(s.bind(s,9829));this.socket=e(i.ZW,{path:"/ws/",withCredentials:!0,transports:["websocket"],reconnection:!1,timeout:2e3}),this.initListeners()}catch(e){console.error("Failed to establish WebSocket connection - ",i.ZW,e),this.connectionStatus="error",n.A.getState().websocket.setStatus("error");return}}close(){this.stopSilentRetry(),this.socket&&(this.socket.removeAllListeners(),this.socket.close(),this.socket=null),this.connectionStatus="offline",this.clearPendingData()}retry(){if("unavailable"!==this.connectionStatus)return void console.warn('WS: retry() should only be called when status is "unavailable"');console.log("WS: Manually retrying WebSocket connection..."),this.stopSilentRetry(),this.connectionStatus="offline",this.connectionAttempts=0,this.hasLoggedUnavailable=!1,this.isInitialConnection=!0,this.init()}startSilentRetry(){this.silentRetryTimer||(this.silentRetryTimer=setInterval(()=>{this.attemptSilentReconnection()},6e4))}stopSilentRetry(){this.silentRetryTimer&&(clearInterval(this.silentRetryTimer),this.silentRetryTimer=null)}async attemptSilentReconnection(){if("connected"===this.connectionStatus)return void this.stopSilentRetry();this.connectionStatus="offline",this.connectionAttempts=0,this.hasLoggedUnavailable=!1,this.isInitialConnection=!1,await this.init()}sendMessage(e,t){if(!this.socket||!this.socket.connected){this.pendingMessages.length>=100&&(console.warn("WS: Max pending messages reached, dropping oldest"),this.pendingMessages.shift());let s=[e,t,Date.now()];this.pendingMessages.push(s);let n=setTimeout(()=>{this.removePendingMessage(s)},3e4);return this.pendingMessageTimeouts.add(n),!1}return this.socket.emit(e,t),!0}registerListener(e,t){if(this.registeredGlobalListeners.has(e)&&this.unregisterListener(e),!this.socket||!this.socket.connected){this.pendingListenersAny[e]=t,this.registeredGlobalListeners.set(e,t);return}let s=function(s){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];i&&i.length&&s===e&&t(i[0])};this.socket.prependAny(s),this.registeredGlobalListeners.set(e,s)}unregisterListener(e){let t=this.registeredGlobalListeners.get(e);t&&this.socket&&this.socket.offAny(t),this.registeredGlobalListeners.delete(e),delete this.pendingListenersAny[e]}getConnectionStatus(){return this.connectionStatus}isConnected(){var e,t;return null!=(t=null==(e=this.socket)?void 0:e.connected)&&t}onConnectionChange(e,t){var s;return((null==(s=this.socket)?void 0:s.connected)&&e(),this.socket)?(this.socket.on("connect",e),this.socket.on("disconnect",t),()=>{this.socket&&(this.socket.off("connect",e),this.socket.off("disconnect",t))}):()=>{}}subscribeChannel(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2?arguments[2]:void 0;if(t&&this.sendMessage("subscribe",e),!this.socket||!this.socket.connected){delete this.pendingListenersOff[e],this.pendingListenersOn[e]=s;return}this.socket.on(e,s)}unsubscribeChannel(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2?arguments[2]:void 0;if(t&&this.sendMessage("unsubscribe",e),!this.socket||!this.socket.connected){delete this.pendingListenersOn[e],this.pendingListenersOff[e]=s;return}this.socket.off(e,s)}initListeners(){if(!this.socket)return void console.error("WS: socket not initialized");this.socket.on("connect",()=>{this.connectionStatus="connected",this.connectionAttempts=0,this.hasLoggedUnavailable=!1,n.A.getState().websocket.setStatus("connected"),this.stopSilentRetry(),this.isInitialConnection?console.log("WS: Connected successfully"):console.log("WS: Reconnected successfully"),this.isInitialConnection=!0,this.processPending()}),this.socket.on("disconnect",()=>{this.connectionStatus="offline",n.A.getState().websocket.setStatus("offline")}),this.socket.on("connect_error",e=>{this.connectionAttempts++,this.connectionStatus="unavailable",n.A.getState().websocket.setStatus("unavailable"),this.isInitialConnection&&!this.hasLoggedUnavailable&&(console.warn("WS: WebSocket service is unavailable. The application will continue to work without real-time features. Retrying in background..."),this.hasLoggedUnavailable=!0),this.startSilentRetry(),this.socket&&(this.socket.io&&(this.socket.io.opts.reconnection=!1),this.socket.close(),this.socket=null)}),this.socket.on("reconnect_attempt",()=>{if("unavailable"===this.connectionStatus){this.socket&&(this.socket.close(),this.socket=null);return}this.connectionStatus="connecting",n.A.getState().websocket.setStatus("connecting")}),this.socket.on("reconnect_failed",()=>{this.connectionStatus="unavailable",n.A.getState().websocket.setStatus("unavailable"),this.hasLoggedUnavailable||(console.warn("WS: Failed to reconnect after ".concat(1," attempts. WebSocket service is unavailable.")),this.hasLoggedUnavailable=!0)})}processPending(){if(!this.socket)return;this.pendingMessages&&this.pendingMessages.length&&(this.pendingMessages.forEac
1h(e=>{this.socket.emit(e[0],e[1])}),this.pendingMessages=[]);let e=Object.entries(this.pendingListenersAny);for(let[t,s]of(this.pendingListenersAny={},e)){if(this.registeredGlobalListeners.has(t)){let e=this.registeredGlobalListeners.get(t);e&&this.socket.offAny(e)}let e=function(e){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];i&&i.length&&e===t&&s(i[0])};this.socket.prependAny(e),this.registeredGlobalListeners.set(t,e)}for(let[e,t]of Object.entries(this.pendingListenersOn))this.socket.on(e,t),delete this.pendingListenersOn[e];for(let[e,t]of Object.entries(this.pendingListenersOff))this.socket.off(e,t),delete this.pendingListenersOff[e]}removePendingMessage(e){let t=this.pendingMessages.findIndex(t=>t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]);t>-1&&this.pendingMessages.splice(t,1)}clearPendingData(){this.pendingMessages=[],this.pendingMessageTimeouts.forEach(e=>{clearTimeout(e)}),this.pendingMessageTimeouts.clear(),Object.keys(this.pendingListenersOn).forEach(e=>delete this.pendingListenersOn[e]),Object.keys(this.pendingListenersOff).forEach(e=>delete this.pendingListenersOff[e]),Object.keys(this.pendingListenersAny).forEach(e=>delete this.pendingListenersAny[e]),this.registeredGlobalListeners.clear()}constructor(){this.socket=null,this.connectionStatus="offline",this.pendingMessages=[],this.pendingListenersOn={},this.pendingListenersOff={},this.pendingListenersAny={},this.pendingMessageTimeouts=new Set,this.registeredGlobalListeners=new Map,this.connectionAttempts=0,this.hasLoggedUnavailable=!1,this.silentRetryTimer=null,this.isInitialConnection=!0}}o.instance=null;let c=o.getInstance()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.