!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="008a38f4-f2e5-4b7c-865c-49f1a1f7abd3",e._sentryDebugIdIdentifier="sentry-dbid-008a38f4-f2e5-4b7c-865c-49f1a1f7abd3")}catch(e){}}();var _global="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};_global.SENTRY_RELEASE={id:"14f6a097859d0d8b3d6211949e2cbf557516f71e"},(window.webpackJsonp=window.webpackJsonp||[]).push([[117],{2117:function(e,t,n){"use strict";(function(e){n(7),n(8),n(6),n(5),n(9),n(10),n(0);var o=n(2);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.generateId=O,n(4),n(71),n(18),n(11),n(15),n(17),n(29),n(57),n(31),n(39);var r=o(n(74)),c=o(n(69)),l=o(n(70)),h=o(n(3)),d=o(n(772)),_=n(773),f=n(370);function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}var y=n(87),m={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),reconnectionDelayGrowFactor:1.3,connectionTimeout:1e4,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:"online"!==e.env.REACT_APP_ENV,maxHeartbeat:6,heartbeatInterval:2e4,compress:!!e.env.socketCompress};function w(){}var k=function(){function e(t,n){var o=this;(0,c.default)(this,e),(0,h.default)(this,"_url",void 0),(0,h.default)(this,"_options",void 0),(0,h.default)(this,"_ws",void 0),(0,h.default)(this,"_binaryType",void 0),(0,h.default)(this,"_protocols",void 0),(0,h.default)(this,"_retryCount",void 0),(0,h.default)(this,"_heartbeats",void 0),(0,h.default)(this,"_closeCalled",void 0),(0,h.default)(this,"_shouldReconnect",void 0),(0,h.default)(this,"_connectLock",void 0),(0,h.default)(this,"_connectTimeout",void 0),(0,h.default)(this,"_beatTimeout",void 0),(0,h.default)(this,"_messageQueue",void 0),(0,h.default)(this,"_listeners",void 0),(0,h.default)(this,"_channelMap",void 0),(0,h.default)(this,"productCode",void 0),(0,h.default)(this,"urlManager",void 0),(0,h.default)(this,"onLogin",void 0),(0,h.default)(this,"isLogin",void 0),(0,h.default)(this,"_handleOpen",(function(e){clearTimeout(o._connectTimeout),o._heartbeats=0,o._retryCount=0,o._debug("send queued message:",o._messageQueue.length),o._messageQueue.forEach((function(e){return o._ws.send(e)})),o._messageQueue=[],o._heartbeat(),o._listeners.open.forEach((function(t){return t(e)}))})),(0,h.default)(this,"_handleClose",(function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];o._clearTimeouts(),o._listeners.close.forEach((function(t){return t(e)})),t&&o._connect(),o.isLogin=!1})),(0,h.default)(this,"_handleMessage",(function(e){var t=e.data;o._heartbeats=0,window.stopDispatchMessage||(o._options.compress||t instanceof Blob?o._inflateMessage(t):o._dispatchMessage(t))})),this._url=t,this._options=n,this._init()}return(0,l.default)(e,[{key:"CONNECTING",get:function(){return e.CONNECTING}},{key:"OPEN",get:function(){return e.OPEN}},{key:"CLOSING",get:function(){return e.CLOSING}},{key:"CLOSED",get:function(){return e.CLOSED}},{key:"_init",value:function(){this._binaryType="blob",this._protocols="",this._retryCount=-1,this._heartbeats=0,this._closeCalled=!1,this._connectLock=!1,this._connectTimeout=null,this._messageQueue=[],this._shouldReconnect=!0,this._listeners={open:new Map,close:new Map,error:new Map,message:new Map},this._channelMap=new Map,this.onLogin=[],this.isLogin=!1}},{key:"_connect",value:function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,n=t.maxRetries,o=void 0===n?m.maxRetries:n,r=t.connectionTimeout,c=void 0===r?m.connectionTimeout:r;this._retryCount>=o?this._debug("max retries reached",this._retryCount,">=",o):(this._retryCount++,this._debug("connect retryCount:",this._retryCount),this._removeListeners(),this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled||(e._ws=e._protocols?new WebSocket(t,e._protocols):new WebSocket(t),e._connectLock=!1,e._initListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),c))})))}}},{key:"_disconnect",value:function(){var code=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,e=arguments.length>1?arguments[1]:void 0;if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(code,e);var t=new _.WrappedCloseEvent(null,code,e);t.target=this,this._handleClose(t)}catch(e){}}}},{key:"_initListeners",value:function(){var e=this;this._ws&&(this._ws.onopen=this._handleOpen,this._ws.onclose=function(t){var n=new _.WrappedCloseEvent(t);n.target=e,e._debug("close event:",t.code,t.reason),e._handleClose(n,"terminate"!==n.reason)},this._ws.onmessage=this._handleMessage,this._ws.onerror=function(t){e._handleError(new _.WrappedErrorEvent(t,_.CONNECTION_ERROR,e))})}},{key:"_removeListeners",value:function(){this._ws&&(this._debug("removeListeners"),this._ws.onclose=w,this._ws.onopen=w,this._ws.onerror=w,this._ws.onmessage=w)}},{key:"_wait",value:function(){return new Promise((function(e){setTimeout(e,1e3)}))}},{key:"_heartbeat",value:function(){var e=this;this._beatTimeout&&clearTimeout(this._beatTimeout);!function t(){var n=e._options,o=n.maxHeartbeat,r=void 0===o?m.maxHeartbeat:o,c=n.heartbeatInterval,l=void 0===c?m.heartbeatInterval:c;e._heartbeats>r?e.reconnect(4999,"heartbeat"):(e._ws.send(JSON.stringify({action:"ping",args:[{params:{}}]})),e._heartbeats++,e._beatTimeout=setTimeout((function(){t()}),l))}()}},{key:"_inflateMessage",value:function(e){if(e instanceof Blob){var t=new FileReader,n=this;t.addEventListener("loadend",(function(){var e=(0,f.inflate)(t.result,{to:"string"});n._dispatchMessage(e)})),t.onerror=function(e){console.log("Mixcopy decompression issue:",e)},t.readAsArrayBuffer(e)}else this._dispatchMessage(e)}},{key:"_dispatchMessage",value:function(e){if("pong"!==e){var data=JSON.parse(String(e)),t=O(data.arg);if("event"in data){if("auth"===data.event){for(;this.onLogin.length;){this.onLogin.pop()(data)}this.onLogin=[],this.isLogin=!0}}else this._listeners.message.forEach((function(e){return e(data,t)}))}}},{key:"_handleError",value:function(e){this._debug("error event",e.message),this._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),this._listeners.error.forEach((function(t){return t(e)})),this._connect()}},{key:"_handleTimeout",value:function(){this._debug("timeout event"),this._handleError(new _.WrappedErrorEvent(null,_.TIMEOUT_ERROR,this))}},{key:"reconnect",value:function(code,e){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(code,e),this._connect()):this._connect()}},{key:"registerEventListener",value:function(t,n,o){var c=t+String(Date.now()),l=this._listeners[t];function h(){var e=Array.prototype.slice.call(arguments);n.apply(void 0,(0,r.default)(e)),o&&l.delete(c)}return l.set(c,h),"open"===t&&this._ws&&this._ws.readyState===e.OPEN&&h(),c}},{key:"close",value:function(){var code=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,e=arguments.length>1?arguments[1]:void 0;this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(code,e):this._debug("close: already closed"):this._debug("close enqueued: no ws instance")}},{key:"terminate",value:function(){this.close(1e3,"terminate"),this._debug("execute termination"),e.instance=null,this._init()}},{key:"removeEventListener",value:function(e,t){this._listeners[e].delete(t)}},{key:"send",value:function(data){this._ws&&this._ws.readyState===this.OPEN?this._ws.send(data):(this._debug("enqueue",data),this._messageQueue.push(data))}},{key:"login",value:function(e,t){if(this.isLogin)t({event:"auth",code:0});else{var n=this.onLogin.length;this.onLogin.push(t),0===n&&this.send(JSON.stringify({op:"auth",args:[e]}))}}},{key:"subscribe",value:function(e,t,n){var o=function(e){for(var t=1;t"].concat(t))}}},{key:"_clearTimeouts",value:function(){clearTimeout(this._connectTimeout),clearTimeout(this._beatTimeout)}},{key:"_getNextUrl",value:function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e(this._options.compress);if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")}},{key:"selfDestruct",value:function(){this.terminate(),this.urlManager&&this.urlManager.stop()}},{key:"changeProduct",value:function(e){this.productCode=e}},{key:"begin",value:function(){this._connect()}}],[{key:"getInstance",value:function(){if(e.instance)return e.instance;var t=new d.default,n=y.otcWebSocketUrl,o=location.host.split(".").slice(1).join(".");"bitget.bike"!==o&&"online"===y.env&&(n="wss://stream.#/v1/common/websocket?terminalType=1".replace("#",o));var r=new e(n,m);return e.instance=r,r.urlManager=t,r}},{key:"CONNECTING",get:function(){return 0}},{key:"OPEN",get:function(){return 1}},{key:"CLOSING",get:function(){return 2}},{key:"CLOSED",get:function(){return 3}}]),e}();function O(data){return data?data.topic+data.instId+data.instType:""}(0,h.default)(k,"instance",void 0);t.default=k}).call(this,n(128))}}]); //# sourceMappingURL=1411a0a.js.map