/*!
 * Socket.D v2.4.7
 * (c) 2023-2024 noear.org
 * Released under the Apache-2.0 License.
 */
var e={7704:(e,t,s)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SocketD=void 0;const r=s(2911),i=s(7545),a=s(1243),o=s(8491),l=s(9165),h=s(6852),u=s(4797),c=s(8259),d=s(5008),_=s(6846);class g{static version(){return"2.4.7"}static protocolVersion(){return"1.0"}static createServer(e){let t=this.createServerOrNull(e);if(null==t)throw new Error("No socketd server providers were found: "+e);return t}static createServerOrNull(e){r.Asserts.assertNull("schema",e);let t=n.serverProviderMap.get(e);return null==t?null:t.createServer(new c.ServerConfig(e))}static createClient(e){const t=this.createClientOrNull(e);if(null==t)throw new Error("No socketd client providers were found: "+e);return t}static createClientOrNull(e){r.Asserts.assertNull("serverUrl",e);const t=e.indexOf("://");if(t<2)throw new Error("The serverUrl invalid: "+e);const s=e.substring(0,t),n=this.clientProviderMap.get(s);if(null==n)return null;{const t=new i.ClientConfig(e);return n.createClient(t)}}static createClusterClient(e){return new a.ClusterClient(e)}static newEntity(e){return e?"[object String]"===toString.call(e)?new l.StringEntity(e.toString()):e instanceof File?new l.FileEntity(e):e instanceof ArrayBuffer||e instanceof Blob?(new l.EntityDefault).dataSet(e):new l.StringEntity(e.toString()):new l.EntityDefault}static newSimpleListener(){return new h.SimpleListener}static newEventListener(e){return new h.EventListener(e)}static newPathListener(e){return new h.PathListener(e)}static newPipelineListener(){return new h.PipelineListener}static newBrokerListener(){return new d.BrokerListener}static newBrokerFragmentHandler(){return new _.BrokerFragmentHandler}}t.SocketD=g,n=g,g.EntityMetas=u.EntityMetas,g.clientProviderMap=new Map,g.serverProviderMap=new Map,(()=>{const e=new o.WsProvider;for(const t of e.schemas())n.clientProviderMap.set(t,e);for(const t of e.schemas())n.serverProviderMap.set(t,e)})()},6846:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerFragmentHandler=void 0;const n=s(5351);class r extends n.FragmentHandlerDefault{aggrEnable(){return!1}}t.BrokerFragmentHandler=r},5008:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerListener=void 0;const n=s(9857),r=s(8422);class i extends n.BrokerListenerBase{onOpen(e){let t=e.name();this.addPlayer(t,e)}onClose(e){let t=e.name();this.removePlayer(t,e)}onMessage(e,t){let s=t.atName();if(s)if("*"==s){let s=this.getNameAll();if(null!=s&&s.size>0)for(let n of s)this.forwardToName(e,t,n)}else if(s.endsWith("*"))s=s.substring(0,s.length()-1),0==this.forwardToName(e,t,s)&&e.sendAlarm(t,"Broker don't have '@"+s+"' player");else{let n=this.getPlayerAny(s,e);null!=n?this.forwardToSession(e,t,n):e.sendAlarm(t,"Broker don't have '@"+s+"' session")}else e.sendAlarm(t,"Broker message require '@' meta")}forwardToName(e,t,s){let n=this.getPlayerAll(s);if(null!=n&&n.size>0){for(let s of n)s!=e&&(s.isValid()?this.forwardToSession(e,t,s):this.onClose(s));return!0}return!1}forwardToSession(e,t,s){t.isRequest()?s.sendAndRequest(t.event(),t,-1).thenReply((s=>{e.isValid()&&e.reply(t,s)})).thenError((s=>{e.isValid()&&r.RunUtils.runAndTry((()=>e.sendAlarm(t,s.message)))})):t.isSubscribe()?s.sendAndSubscribe(t.event(),t).thenReply((s=>{e.isValid()&&(s.isEnd()?e.replyEnd(t,s):e.reply(t,s))})).thenError((s=>{e.isValid()&&r.RunUtils.runAndTry((()=>e.sendAlarm(t,s.message)))})):s.send(t.event(),t)}onError(e,t){console.warn("Broker error",t)}}t.BrokerListener=i},9857:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerListenerBase=void 0;const n=s(7644);t.BrokerListenerBase=class{constructor(){this._sessionAll=new Map,this._playerSessions=new Map}getSessionAll(){return this._sessionAll.values()}getSessionAny(){return n.LoadBalancer.getAnyByPoll(new Set(this._sessionAll.values()))}getSessionCount(){return this._sessionAll.size}getNameAll(){return new Set(this._playerSessions.keys())}getPlayerCount(e){let t=this.getPlayerAll(e);return null==t?0:t.size}getPlayerAll(e){if(e){return this._playerSessions.get(e)||null}return null}getPlayerAny(e,t){return e?e.endsWith("!")?(e=e.substring(0,e.length-1),null==t?n.LoadBalancer.getAnyByPoll(this.getPlayerAll(e)):n.LoadBalancer.getAnyByHash(this.getPlayerAll(e),t.remoteAddress().address)):n.LoadBalancer.getAnyByPoll(this.getPlayerAll(e)):null}addPlayer(e,t){if(e){let s=this._playerSessions.get(e);s||(s=new Set,this._playerSessions.set(e,s)),s.add(t)}this._sessionAll.set(t.sessionId(),t)}removePlayer(e,t){if(e){let s=this.getPlayerAll(e);null!=s&&s.delete(t)}this._sessionAll.delete(t.sessionId())}}},1243:function(e,t,s){var n=this&&this.__awaiter||function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClusterClient=void 0;const r=s(9270),i=s(7704);t.ClusterClient=class{constructor(e){this._serverUrls=e instanceof Array?e:[e]}connectHandler(e){return this._connectHandler=e,this}heartbeatHandler(e){return this._heartbeatHandler=e,this}config(e){return this._configHandler=e,this}listen(e){return this._listener=e,this}open(){return n(this,void 0,void 0,(function*(){return this.openDo(!1)}))}openOrThow(){return n(this,void 0,void 0,(function*(){return this.openDo(!0)}))}openDo(e){return n(this,void 0,void 0,(function*(){const t=new Array;for(const s of this._serverUrls)for(let n of s.split(",")){if(n=n.trim(),!n)continue;const s=i.SocketD.createClient(n);this._listener&&s.listen(this._listener),this._configHandler&&s.config(this._configHandler),this._connectHandler&&s.connectHandler(this._connectHandler),this._heartbeatHandler&&s.heartbeatHandler(this._heartbeatHandler),e?t.push(yield s.openOrThow()):t.push(yield s.open())}return new r.ClusterClientSession(t)}))}}},9270:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClusterClientSession=void 0;const n=s(8404),r=s(4970),i=s(8422),a=s(7644);t.ClusterClientSession=class{constructor(e){this._sessionSet=new Set(e),this._sessionId=n.StrUtils.guid()}getSessionAll(){return this._sessionSet}getSessionAny(e){let t=null;if(t=e?a.LoadBalancer.getAnyByHash(this._sessionSet,e):a.LoadBalancer.getAnyByPoll(this._sessionSet),null==t)throw new r.SocketDException("No session is available!");return t}getSessionOne(){return this.getSessionAny(null)}isValid(){for(const e of this._sessionSet)if(e.isValid())return!0;return!1}isClosing(){for(const e of this._sessionSet)if(e.isClosing())return!0;return!1}sessionId(){return this._sessionId}reconnect(){for(const e of this._sessionSet)0==e.isValid()&&e.reconnect()}send(e,t){return this.getSessionAny(null).send(e,t)}sendAndRequest(e,t,s){return this.getSessionAny(null).sendAndRequest(e,t,s)}sendAndSubscribe(e,t,s){return this.getSessionAny(null).sendAndSubscribe(e,t,s)}close(){for(const e of this._sessionSet)i.RunUtils.runAndTry(e.close)}}},7644:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LoadBalancer=void 0;class s{static roundCounterGet(){let e=s.roundCounter++;return e>999999&&s.roundCounter,e}static hashcode(e){var t,s,n=0;if(0===e.length)return n;for(t=0,s=e.length;t<s;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return n}static getAnyByPoll(e){return s.getAny(e,(()=>s.roundCounterGet()))}static getAnyByHash(e,t){return s.getAny(e,(()=>s.hashcode(t)))}static getAny(e,t){if(null==e||0==e.size)return null;{let s=new Array;for(let t of e)t.isValid()&&!t.isClosing()&&s.push(t);return 0==s.length?null:1==s.length?s[0]:s[Math.abs(t())%s.length]}}static getFirst(e){if(null==e||0==e.length)return null;for(let t of e)if(t.isValid()&&!t.isClosing())return t;return null}}t.LoadBalancer=s,s.roundCounter=0},4970:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SocketDTimeoutException=t.SocketDSizeLimitException=t.SocketDConnectionException=t.SocketDCodecException=t.SocketDChannelException=t.SocketDAlarmException=t.SocketDException=void 0;class s extends Error{constructor(e){super(e)}}t.SocketDException=s,t.SocketDAlarmException=class extends s{constructor(e){super(e.entity().dataAsString()),this._alarm=e}getAlarm(){return this._alarm}},t.SocketDChannelException=class extends s{constructor(e){super(e)}},t.SocketDCodecException=class extends s{constructor(e){super(e)}},t.SocketDConnectionException=class extends s{constructor(e){super(e)}},t.SocketDSizeLimitException=class extends s{constructor(e){super(e)}},t.SocketDTimeoutException=class extends s{constructor(e){super(e)}}},1421:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientBase=void 0;const n=s(4405),r=s(9213),i=s(4797);t.ClientBase=class{constructor(e,t){this._config=e,this._assistant=t,this._processor=new n.ProcessorDefault}getAssistant(){return this._assistant}getConnectHandler(){return this._connectHandler}getHeartbeatHandler(){return this._heartbeatHandler}getHeartbeatInterval(){return this.getConfig().getHeartbeatInterval()}getConfig(){return this._config}getProcessor(){return this._processor}connectHandler(e){return null!=e&&(this._connectHandler=e),this}heartbeatHandler(e){return null!=e&&(this._heartbeatHandler=e),this}config(e){return null!=e&&e(this._config),this}listen(e){return null!=e&&this._processor.setListener(e),this}open(){return this.openDo(!1)}openOrThow(){return this.openDo(!0)}openDo(e){const t=this.createConnector(),s=new r.ClientChannel(this,t);return new Promise(((t,n)=>{s.connect().then((e=>{console.info("Socket.D client successfully connected!"),t(s.getSession())}),(r=>{e?(s.close(i.Constants.CLOSE2008_OPEN_FAIL),n(r)):(console.warn("Socket.D client Connection failed!"),t(s.getSession()))}))}))}}},9213:function(e,t,s){var n=this&&this.__awaiter||function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientChannel=void 0;const r=s(2998),i=s(4797),a=s(2911),o=s(4970),l=s(8422),h=s(6039),u=s(2402),c=s(5922);class d extends r.ChannelBase{constructor(e,t){super(t.getConfig()),this._isConnecting=!1,this._client=e,this._connector=t,this._sessionShell=new h.SessionDefault(this),this._connectHandler=new c.ClientConnectHandlerDefault(e.getConnectHandler()),this._heartbeatHandler=new u.ClientHeartbeatHandlerDefault(e.getHeartbeatHandler()),this.initHeartbeat()}initHeartbeat(){this._heartbeatScheduledFuture&&clearInterval(this._heartbeatScheduledFuture),this._connector.autoReconnect()&&(this._heartbeatScheduledFuture=setInterval((()=>n(this,void 0,void 0,(function*(){try{yield this.heartbeatHandle()}catch(e){console.debug("Client channel heartbeat failed: {link="+this._connector.getConfig().getLinkUrl()+"}")}}))),this._client.getHeartbeatInterval()))}heartbeatHandle(){return n(this,void 0,void 0,(function*(){if(this._real){if(null==this._real.getHandshake())return;if(a.Asserts.isClosedAndEnd(this._real))return console.debug(`Client channel is closed (pause heartbeat), sessionId=${this.getSession().sessionId()}`),void this.close(this._real.isClosed());if(this._real.isClosing())return}try{yield this.internalCheck(),this._heartbeatHandler.clientHeartbeat(this.getSession())}catch(e){if(e instanceof o.SocketDException)throw e;throw this._connector.autoReconnect()&&this.internalCloseIfError(),e}}))}isValid(){return null!=this._real&&this._real.isValid()}isClosing(){return null!=this._real&&this._real.isClosing()}isClosed(){return null==this._real?0:this._real.isClosed()}getLiveTime(){return this._real?this._real.getLiveTime():0}getRemoteAddress(){return this._real?this._real.getRemoteAddress():null}getLocalAddress(){return this._real?this._real.getLocalAddress():null}send(e,t){a.Asserts.assertClosedAndEnd(this._real),this.internalCheck().then((s=>{if(this._real)try{this._real.send(e,t)}catch(e){t&&t.onError(e)}else{const e=new o.SocketDChannelException("Client channel is not connected");t&&t.onError(e)}}),(e=>{this._connector.autoReconnect()&&this.internalCloseIfError(),t&&t.onError(e)}))}retrieve(e,t){this._real.retrieve(e,t)}reconnect(){return n(this,void 0,void 0,(function*(){this.initHeartbeat(),yield this.internalCheck()}))}onError(e){this._real.onError(e)}close(e){l.RunUtils.runAndTry((()=>clearInterval(this._heartbeatScheduledFuture))),l.RunUtils.runAndTry((()=>this._connector.close())),this._real&&l.RunUtils.runAndTry((()=>this._real.close(e))),super.close(e)}getSession(){return this._sessionShell}connect(){return n(this,void 0,void 0,(function*(){if(!this._isConnecting){this._isConnecting=!0;try{null!=this._real&&this._real.close(i.Constants.CLOSE2002_RECONNECT),this._real=yield this._connectHandler.clientConnect(this._connector),this._real.setSession(this._sessionShell),this.setHandshake(this._real.getHandshake())}finally{this._isConnecting=!1}}}))}internalCloseIfError(){null!=this._real&&(this._real.close(i.Constants.CLOSE2001_ERROR),this._real=null)}internalCheck(){return n(this,void 0,void 0,(function*(){return(null==this._real||0==this._real.isValid())&&(yield this.connect(),!0)}))}}t.ClientChannel=d},7545:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConfig=void 0;const n=s(5628),r=s(8404);class i extends n.ConfigBase{constructor(e){super(!0),this._metaMap=new Map,e.startsWith("sd:")&&(e=e.substring(3)),this._url=e,this._linkUrl="sd:"+e;let t=r.StrUtils.parseUri(e);this._host=t.host,this._port=parseInt(t.port),this._schema=t.protocol,this._port<0&&(this._port=8602),this._connectTimeout=1e4,this._heartbeatInterval=2e4,this._autoReconnect=!0}getSchema(){return this._schema}getLinkUrl(){return this._linkUrl}getUrl(){return this._url}getHost(){return this._host}getPort(){return this._port}getMetaMap(){return this._metaMap}metaPut(e,t){return this._metaMap.set(e,t),this}getHeartbeatInterval(){return this._heartbeatInterval}heartbeatInterval(e){return this._heartbeatInterval=e,this}getConnectTimeout(){return this._connectTimeout}connectTimeout(e){return this._connectTimeout=e,this}isAutoReconnect(){return this._autoReconnect}autoReconnect(e){return this._autoReconnect=e,this}idleTimeout(e){return 0==this._autoReconnect?(this._idleTimeout=e,this):(this._idleTimeout=0,this)}toString(){return"ClientConfig{schema='"+this._schema+"', charset="+this._charset+", url='"+this._url+"', ioThreads="+this._ioThreads+", codecThreads="+this._codecThreads+", exchangeThreads="+this._exchangeThreads+", heartbeatInterval="+this._heartbeatInterval+", connectTimeout="+this._connectTimeout+", idleTimeout="+this._idleTimeout+", requestTimeout="+this._requestTimeout+", readBufferSize="+this._readBufferSize+", writeBufferSize="+this._writeBufferSize+", autoReconnect="+this._autoReconnect+", maxUdpSize="+this._maxUdpSize+"}"}}t.ClientConfig=i},5922:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConnectHandlerDefault=void 0,t.ClientConnectHandlerDefault=class{constructor(e){this._connectHandler=e}clientConnect(e){return this._connectHandler?this._connectHandler(e):e.connect()}}},8511:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConnectorBase=void 0,t.ClientConnectorBase=class{constructor(e){this._client=e}getConfig(){return this._client.getConfig()}autoReconnect(){return this._client.getConfig().isAutoReconnect()}}},9777:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientHandshakeResult=void 0,t.ClientHandshakeResult=class{constructor(e,t){this._channel=e,this._throwable=t}getChannel(){return this._channel}getThrowable(){return this._throwable}}},2402:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientHeartbeatHandlerDefault=void 0,t.ClientHeartbeatHandlerDefault=class{constructor(e){this._heartbeatHandler=e}clientHeartbeat(e){this._heartbeatHandler?this._heartbeatHandler(e):e.sendPing()}}},2911:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Asserts=void 0;const n=s(4797),r=s(4970);class i{static assertClosed(e){if(null!=e&&e.isClosed()>0)throw new r.SocketDChannelException("This channel is closed, sessionId="+e.getSession().sessionId())}static isClosedAndEnd(e){return e.isClosed()==n.Constants.CLOSE2009_USER||e.isClosed()==n.Constants.CLOSE2008_OPEN_FAIL}static assertClosedAndEnd(e){if(null!=e&&i.isClosedAndEnd(e))throw new r.SocketDChannelException("This channel is closed, sessionId="+e.getSession().sessionId())}static assertNull(e,t){if(null==t)throw new Error("The argument cannot be null: "+e)}static assertEmpty(e,t){if(!t)throw new Error("The argument cannot be empty: "+e)}static assertSize(e,t,s){if(t>s){const n=`This message ${e} size is out of limit ${s} (${t})`;throw new r.SocketDSizeLimitException(n)}}}t.Asserts=i},6560:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BlobBuffer=t.ByteBuffer=void 0,t.ByteBuffer=class{constructor(e){this._bufIdx=0,this._buf=e}remaining(){return this.size()-this.position()}position(){return this._bufIdx}size(){return this._buf.byteLength}reset(){this._bufIdx=0}getBytes(e,t){let s=this.remaining();if(s>e&&(s=e),s<=0)return!1;let n=this._bufIdx+s,r=this._buf.slice(this._bufIdx,n);return this._bufIdx=n,new Promise((e=>{e(1)})).then((()=>{t(r)})),!0}getBlob(){return null}getArray(){return this._buf}},t.BlobBuffer=class{constructor(e){this._bufIdx=0,this._buf=e}remaining(){return this._buf.size-this._bufIdx}position(){return this._bufIdx}size(){return this._buf.size}reset(){this._bufIdx=0}getBytes(e,t){let s=this.remaining();if(s>e&&(s=e),s<=0)return!1;let n=this._bufIdx+s,r=this._buf.slice(this._bufIdx,n),i=new FileReader;return i.onload=e=>{e.target&&t(e.target.result)},i.readAsArrayBuffer(r),this._bufIdx=n,!0}getBlob(){return this._buf}getArray(){return null}}},2998:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelBase=void 0;const n=s(3954),r=s(4797);t.ChannelBase=class{constructor(e){this._config=e,this._attachments=new Map}getAttachment(e){return this._attachments.get(e)}putAttachment(e,t){null==t?this._attachments.delete(e):this._attachments.set(e,t)}close(e){e>r.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&this._attachments.clear()}getConfig(){return this._config}setHandshake(e){this._handshake=e}getHandshake(){return this._handshake}sendConnect(e,t){this.send(n.Frames.connectFrame(this.getConfig().genId(),e,t),null)}sendConnack(){this.send(n.Frames.connackFrame(this.getHandshake()),null)}sendPing(){this.send(n.Frames.pingFrame(),null)}sendPong(){this.send(n.Frames.pongFrame(),null)}sendClose(e){this.send(n.Frames.closeFrame(e),null)}sendAlarm(e,t){this.send(n.Frames.alarmFrame(e,t),null)}}},1930:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelDefault=void 0;const n=s(3954),r=s(6862),i=s(4797),a=s(2998),o=s(6039);class l extends a.ChannelBase{constructor(e,t){super(t.getConfig()),this._liveTime=0,this._closeCode=0,this._source=e,this._processor=t.getProcessor(),this._assistant=t.getAssistant(),this._streamManger=t.getConfig().getStreamManger()}onOpenFuture(e){this._onOpenFuture=e}doOpenFuture(e,t){this._onOpenFuture&&this._onOpenFuture(e,t)}isValid(){return 0==this.isClosed()&&this._assistant.isValid(this._source)}isClosing(){return this._closeCode==i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING}isClosed(){return this._closeCode>i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING?this._closeCode:0}config(){return this._config}sendPing(){this.send(n.Frames.pingFrame(),null)}sendPong(){this.send(n.Frames.pongFrame(),null)}getRemoteAddress(){return this._assistant.getRemoteAddress(this._source)}getLocalAddress(){return this._assistant.getLocalAddress(this._source)}send(e,t){if(this.getConfig().clientMode()||console.debug("S-SEN:"+e),e.message()){const s=e.message();if(null!=t&&this._streamManger.addStream(s.sid(),t),null!=s.entity())return s.dataSize()>this.getConfig().getFragmentSize()&&s.putMeta(i.EntityMetas.META_DATA_LENGTH,s.dataSize().toString()),void this.getConfig().getFragmentHandler().spliFragment(this,t,s,(t=>{const i=new n.Frame(e.flag(),(new r.MessageBuilder).flag(e.flag()).sid(s.sid()).event(s.event()).entity(t).build());this._assistant.write(this._source,i)}))}this._assistant.write(this._source,e),null!=t&&t.onProgress(!0,1,1)}retrieve(e,t){t?((t.demands()<i.Constants.DEMANDS_MULTIPLE||e.flag()==i.Flags.ReplyEnd)&&this._streamManger.removeStream(e.message().sid()),t.demands(),i.Constants.DEMANDS_MULTIPLE,t.onReply(e.message())):console.debug(`${this.getConfig().getRoleName()} stream not found, sid=${e.message().sid()}, sessionId=${this.getSession().sessionId()}`)}reconnect(){}onError(e){this._processor.onError(this,e)}getLiveTime(){return this._liveTime}setLiveTimeAsNow(){this._liveTime=(new Date).getTime()}getSession(){return null==this._session&&(this._session=new o.SessionDefault(this)),this._session}getStream(e){return this._streamManger.getStream(e)}setSession(e){this._session=e}close(e){try{this._closeCode=e,super.close(e),e>i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&(setTimeout((()=>{this._assistant.close(this._source)}),100),console.debug(`${this.getConfig().getRoleName()} channel closed, sessionId=${this.getSession().sessionId()}`))}catch(e){console.warn(`${this.getConfig().getRoleName()} channel close error, sessionId=${this.getSession().sessionId()}`,e)}}}t.ChannelDefault=l},2608:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ArrayBufferCodecWriter=t.ArrayBufferCodecReader=void 0,t.ArrayBufferCodecReader=class{constructor(e){this._buf=e,this._bufView=new DataView(e),this._bufViewIdx=0}getByte(){if(this._bufViewIdx>=this._buf.byteLength)return-1;const e=this._bufView.getInt8(this._bufViewIdx);return this._bufViewIdx+=1,e}getBytes(e,t,s){const n=new DataView(e),r=t+s;for(let e=t;e<r&&!(this._bufViewIdx>=this._buf.byteLength);e++)n.setInt8(e,this._bufView.getInt8(this._bufViewIdx)),this._bufViewIdx++}getInt(){if(this._bufViewIdx>=this._buf.byteLength)return-1;const e=this._bufView.getInt32(this._bufViewIdx);return this._bufViewIdx+=4,e}peekByte(){return this.remaining()>0?this._bufView.getInt8(this._bufViewIdx):-1}skipBytes(e){this._bufViewIdx=this.position()+e}remaining(){return this._buf.byteLength-this._bufViewIdx}position(){return this._bufViewIdx}size(){return this._buf.byteLength}reset(){this._bufViewIdx=0}},t.ArrayBufferCodecWriter=class{constructor(e){this._buf=new ArrayBuffer(e),this._bufView=new DataView(this._buf),this._bufViewIdx=0}putBytes(e){const t=new DataView(e),s=t.byteLength;for(let e=0;e<s;e++)this._bufView.setInt8(this._bufViewIdx,t.getInt8(e)),this._bufViewIdx+=1}putInt(e){this._bufView.setInt32(this._bufViewIdx,e),this._bufViewIdx+=4}putChar(e){this._bufView.setInt16(this._bufViewIdx,e),this._bufViewIdx+=2}flush(){}getBuffer(){return this._buf}}},170:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CodecDefault=void 0;const n=s(3954),r=s(8404),i=s(2911),a=s(4797),o=s(6862),l=s(9165);t.CodecDefault=class{constructor(e){this._config=e}write(e,t){if(e.message()){const s=r.StrUtils.strToBuf(e.message().sid(),this._config.getCharset()),n=r.StrUtils.strToBuf(e.message().event(),this._config.getCharset()),o=r.StrUtils.strToBuf(e.message().metaString(),this._config.getCharset()),l=8+s.byteLength+n.byteLength+o.byteLength+e.message().dataSize()+6;i.Asserts.assertSize("sid",s.byteLength,a.Constants.MAX_SIZE_SID),i.Asserts.assertSize("event",n.byteLength,a.Constants.MAX_SIZE_EVENT),i.Asserts.assertSize("metaString",o.byteLength,a.Constants.MAX_SIZE_META_STRING),i.Asserts.assertSize("data",e.message().dataSize(),a.Constants.MAX_SIZE_DATA);const h=t(l);return h.putInt(l),h.putInt(e.flag()),h.putBytes(s),h.putChar("\n".charCodeAt(0)),h.putBytes(n),h.putChar("\n".charCodeAt(0)),h.putBytes(o),h.putChar("\n".charCodeAt(0)),h.putBytes(e.message().data().getArray()),h.flush(),h}{const s=8,n=t(s);return n.putInt(s),n.putInt(e.flag()),n.flush(),n}}read(e){const t=e.getInt();if(t>e.remaining()+4)return null;const s=e.getInt();if(8==t)return new n.Frame(a.Flags.of(s),null);{const r=Math.min(a.Constants.MAX_SIZE_META_STRING,e.remaining()),i=new ArrayBuffer(r),h=this.decodeString(e,i,a.Constants.MAX_SIZE_SID),u=this.decodeString(e,i,a.Constants.MAX_SIZE_EVENT),c=this.decodeString(e,i,a.Constants.MAX_SIZE_META_STRING),d=t-e.position();let _;if(d>a.Constants.MAX_SIZE_DATA){_=new ArrayBuffer(a.Constants.MAX_SIZE_DATA),e.getBytes(_,0,a.Constants.MAX_SIZE_DATA);for(let t=d-a.Constants.MAX_SIZE_DATA;t>0;t--)e.getByte()}else _=new ArrayBuffer(d),d>0&&e.getBytes(_,0,d);const g=(new o.MessageBuilder).flag(a.Flags.of(s)).sid(h).event(u).entity((new l.EntityDefault).dataSet(_).metaStringSet(c)).build();return new n.Frame(g.flag(),g)}}decodeString(e,t,s){const n=new DataView(t);let i=0;for(;;){const t=e.getByte();if(0==t&&10==e.peekByte()){e.skipBytes(1);break}s>0&&s<=i||(n.setInt8(i,t),i++)}return i<1?"":r.StrUtils.bufToStr(t,0,i,this._config.getCharset())}}},5628:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConfigBase=void 0;const n=s(3895),r=s(5067),i=s(5351),a=s(4797),o=s(2911),l=s(170);t.ConfigBase=class{constructor(e){this._clientMode=e,this._streamManger=new n.StreamMangerDefault(this),this._codec=new l.CodecDefault(this),this._charset="utf-8",this._idGenerator=new r.GuidGenerator,this._fragmentHandler=new i.FragmentHandlerDefault,this._fragmentSize=a.Constants.MAX_SIZE_DATA,this._ioThreads=1,this._codecThreads=2,this._exchangeThreads=4*this._codecThreads,this._readBufferSize=512,this._writeBufferSize=512,this._idleTimeout=0,this._requestTimeout=1e4,this._streamTimeout=72e5,this._maxUdpSize=2048}clientMode(){return this._clientMode}getStreamManger(){return this._streamManger}getRoleName(){return this.clientMode()?"Client":"Server"}getCharset(){return this._charset}charset(e){return this._charset=e,this}getCodec(){return this._codec}genId(){return this._idGenerator.generate()}idGenerator(e){return o.Asserts.assertNull("idGenerator",e),this._idGenerator=e,this}getFragmentHandler(){return this._fragmentHandler}fragmentHandler(e){return o.Asserts.assertNull("fragmentHandler",e),this._fragmentHandler=e,this}getFragmentSize(){return this._fragmentSize}fragmentSize(e){if(e>a.Constants.MAX_SIZE_DATA)throw new Error("The parameter fragmentSize cannot > 16m");if(e<a.Constants.MIN_FRAGMENT_SIZE)throw new Error("The parameter fragmentSize cannot < 1k");return this._fragmentSize=e,this}getIoThreads(){return this._ioThreads}ioThreads(e){return this._ioThreads=e,this}getCodecThreads(){return this._codecThreads}codecThreads(e){return this._codecThreads=e,this}getExchangeThreads(){return this._exchangeThreads}exchangeThreads(e){return this._exchangeThreads=e,this}getReadBufferSize(){return this._readBufferSize}readBufferSize(e){return this._readBufferSize=e,this}getWriteBufferSize(){return this._writeBufferSize}writeBufferSize(e){return this._writeBufferSize=e,this}getIdleTimeout(){return this._idleTimeout}idleTimeout(e){return this._idleTimeout=e,this}getRequestTimeout(){return this._requestTimeout}requestTimeout(e){return this._requestTimeout=e,this}getStreamTimeout(){return this._streamTimeout}streamTimeout(e){return this._streamTimeout=e,this}getMaxUdpSize(){return this._maxUdpSize}maxUdpSize(e){return this._maxUdpSize=e,this}generateId(){return this._idGenerator.generate()}}},4797:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EntityMetas=t.Flags=t.Constants=void 0;const n=s(6560);t.Constants={DEF_SID:"",DEF_EVENT:"",DEF_META_STRING:"",DEF_DATA:new n.ByteBuffer(new ArrayBuffer(0)),CLOSE1000_PROTOCOL_CLOSE_STARTING:1e3,CLOSE1001_PROTOCOL_CLOSE:1001,CLOSE1002_PROTOCOL_ILLEGAL:1002,CLOSE2001_ERROR:2001,CLOSE2002_RECONNECT:2002,CLOSE2008_OPEN_FAIL:2008,CLOSE2009_USER:2009,MAX_SIZE_SID:64,MAX_SIZE_EVENT:512,MAX_SIZE_META_STRING:4096,MAX_SIZE_DATA:16777216,MAX_SIZE_FRAME:17825792,MIN_FRAGMENT_SIZE:1024,DEMANDS_ZERO:0,DEMANDS_SIGNLE:1,DEMANDS_MULTIPLE:2},t.Flags={Unknown:0,Connect:10,Connack:11,Ping:20,Pong:21,Close:30,Alarm:31,Message:40,Request:41,Subscribe:42,Reply:48,ReplyEnd:49,of:function(e){switch(e){case 10:return this.Connect;case 11:return this.Connack;case 20:return this.Ping;case 21:return this.Pong;case 30:return this.Close;case 31:return this.Alarm;case 40:return this.Message;case 41:return this.Request;case 42:return this.Subscribe;case 48:return this.Reply;case 49:return this.ReplyEnd;default:return this.Unknown}},name:function(e){switch(e){case this.Connect:return"Connect";case this.Connack:return"Connack";case this.Ping:return"Ping";case this.Pong:return"Pong";case this.Close:return"Close";case this.Alarm:return"Alarm";case this.Message:return"Message";case this.Request:return"Request";case this.Subscribe:return"Subscribe";case this.Reply:return"Reply";case this.ReplyEnd:return"ReplyEnd";default:return"Unknown"}}},t.EntityMetas={META_SOCKETD_VERSION:"Socket.D",META_DATA_LENGTH:"Data-Length",META_DATA_TYPE:"Data-Type",META_DATA_FRAGMENT_IDX:"Data-Fragment-Idx",META_DATA_FRAGMENT_TOTAL:"Data-Fragment-Total",META_DATA_DISPOSITION_FILENAME:"Data-Disposition-Filename",META_RANGE_START:"Data-Range-Start",META_RANGE_SIZE:"Data-Range-Size"}},9165:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FileEntity=t.StringEntity=t.EntityDefault=void 0;const n=s(8404),r=s(2608),i=s(4797),a=s(6560),o=s(4970);class l{constructor(){this._metaMap=null,this._data=i.Constants.DEF_DATA,this._dataAsReader=null}at(e){return this.metaPut("@",e),this}range(e,t){return this.metaPut(i.EntityMetas.META_RANGE_START,e.toString()),this.metaPut(i.EntityMetas.META_RANGE_SIZE,t.toString()),this}metaStringSet(e){if(this._metaMap=new Map,e)for(const t of e.split("&")){const e=t.indexOf("=");e>0&&this._metaMap.set(t.substring(0,e),t.substring(e+1))}return this}metaMapPut(e){if(e)if(e instanceof Map)e.forEach(((e,t,s)=>{this.metaMap().set(t,e)}));else for(const t of e.prototype)this.metaMap().set(t,e[t]);return this}metaPut(e,t){return null==t?this.metaMap().delete(e):this.metaMap().set(e,t),this}metaDel(e){this.metaMap().delete(e)}metaString(){let e="";return this.metaMap().forEach(((t,s,n)=>{e+=`${s}=${t}&`})),e.length>0?e.substring(0,e.length-1):e}metaMap(){return null==this._metaMap&&(this._metaMap=new Map),this._metaMap}meta(e){return this.metaMap().get(e)||null}metaOrDefault(e,t){return this.meta(e)||t}metaAsInt(e){return parseInt(this.metaOrDefault(e,"0"))}metaAsLong(e){return this.metaAsInt(e)}metaAsFloat(e){return parseFloat(this.metaOrDefault(e,"0"))}metaAsDouble(e){return this.metaAsFloat(e)}putMeta(e,t){this.metaPut(e,t)}delMeta(e){this.metaDel(e)}dataSet(e){return e instanceof ArrayBuffer?this._data=new a.ByteBuffer(e):this._data=new a.BlobBuffer(e),this}data(){return this._data}dataAsReader(){if(null==this._data.getArray())throw new o.SocketDException("Blob does not support dataAsReader");return this._dataAsReader||(this._dataAsReader=new r.ArrayBufferCodecReader(this._data.getArray())),this._dataAsReader}dataAsString(){if(null==this._data.getArray())throw new o.SocketDException("Blob does not support dataAsString");return n.StrUtils.bufToStrDo(this._data.getArray(),"")}dataSize(){return this._data.size()}release(){}toString(){return"Entity{meta='"+this.metaString()+"', data=byte["+this.dataSize()+"]}"}}t.EntityDefault=l,t.StringEntity=class extends l{constructor(e){super();const t=n.StrUtils.strToBuf(e);this.dataSet(t)}},t.FileEntity=class extends l{constructor(e){super(),this.dataSet(e),this.metaPut(i.EntityMetas.META_DATA_DISPOSITION_FILENAME,e.name)}}},8187:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentAggregatorDefault=void 0;const n=s(6862),r=s(9165),i=s(3954),a=s(4072),o=s(4797),l=s(4970);t.FragmentAggregatorDefault=class{constructor(e){this._fragmentHolders=new Array,this._dataStreamSize=0,this._dataLength=0,this._main=e;const t=e.meta(o.EntityMetas.META_DATA_LENGTH);if(!t)throw new l.SocketDCodecException("Missing '"+o.EntityMetas.META_DATA_LENGTH+"' meta, event="+e.event());this._dataLength=parseInt(t)}getSid(){return this._main.sid()}getDataStreamSize(){return this._dataStreamSize}getDataLength(){return this._dataLength}add(e,t){this._fragmentHolders.push(new a.FragmentHolder(e,t)),this._dataStreamSize=this._dataStreamSize+t.dataSize()}get(){this._fragmentHolders.sort(((e,t)=>e.getIndex()==t.getIndex()?0:e.getIndex()>t.getIndex()?1:-1));const e=new ArrayBuffer(this._dataLength),t=new DataView(e);let s=0;for(const e of this._fragmentHolders){const n=new DataView(e.getMessage().data().getArray());for(let r=0;r<e.getMessage().data().size();r++)t.setInt8(s,n.getInt8(r)),s++}return new i.Frame(this._main.flag(),(new n.MessageBuilder).flag(this._main.flag()).sid(this._main.sid()).event(this._main.event()).entity((new r.EntityDefault).metaMapPut(this._main.metaMap()).dataSet(e)).build())}}},5351:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentHandlerDefault=void 0;const n=s(9165),r=s(4797),i=s(8187);t.FragmentHandlerDefault=class{spliFragment(e,t,s,r){if(s.dataSize()>e.getConfig().getFragmentSize()){let n=0,i=Math.ceil(s.dataSize()/e.getConfig().getFragmentSize());this.spliFragmentDo(n,i,e,t,s,r)}else null==s.data().getBlob()?(r(s),null!=t&&t.onProgress(!0,1,1)):s.data().getBytes(e.getConfig().getFragmentSize(),(e=>{r((new n.EntityDefault).dataSet(e).metaMapPut(s.metaMap())),null!=t&&t.onProgress(!0,1,1)}))}spliFragmentDo(e,t,s,i,a,o){e++,a.data().getBytes(s.getConfig().getFragmentSize(),(l=>{const h=(new n.EntityDefault).dataSet(l);1==e&&h.metaMapPut(a.metaMap()),h.metaPut(r.EntityMetas.META_DATA_FRAGMENT_IDX,e.toString()),h.metaPut(r.EntityMetas.META_DATA_FRAGMENT_TOTAL,t.toString()),o(h),null!=i&&i.onProgress(!0,e,t),this.spliFragmentDo(e,t,s,i,a,o)}))}aggrFragment(e,t,s){let n=e.getAttachment(s.sid());return n||(n=new i.FragmentAggregatorDefault(s),e.putAttachment(n.getSid(),n)),n.add(t,s),n.getDataLength()>n.getDataStreamSize()?null:(e.putAttachment(s.sid(),null),n.get())}aggrEnable(){return!0}}},4072:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentHolder=void 0,t.FragmentHolder=class{constructor(e,t){this._index=e,this._message=t}getIndex(){return this._index}getMessage(){return this._message}}},3954:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Frames=t.Frame=void 0;const n=s(9165),r=s(4797),i=s(6862),a=s(7704);class o{constructor(e,t){this._flag=e,this._message=t}flag(){return this._flag}message(){return this._message}toString(){return"Frame{flag="+r.Flags.name(this._flag)+", message="+this._message+"}"}}t.Frame=o,t.Frames=class{static connectFrame(e,t,s){const l=new n.StringEntity(t);return l.metaMapPut(s),l.metaPut(r.EntityMetas.META_SOCKETD_VERSION,a.SocketD.protocolVersion()),new o(r.Flags.Connect,(new i.MessageBuilder).sid(e).event(t).entity(l).build())}static connackFrame(e){const t=new n.EntityDefault;return t.metaMapPut(e.getOutMetaMap()),t.metaPut(r.EntityMetas.META_SOCKETD_VERSION,a.SocketD.protocolVersion()),t.dataSet(e.getSource().data().getArray()),new o(r.Flags.Connack,(new i.MessageBuilder).sid(e.getSource().sid()).event(e.getSource().event()).entity(t).build())}static pingFrame(){return new o(r.Flags.Ping,null)}static pongFrame(){return new o(r.Flags.Pong,null)}static closeFrame(e){const t=new i.MessageBuilder;return t.entity(new n.StringEntity("").metaPut("code",e.toString())),new o(r.Flags.Close,t.build())}static alarmFrame(e,t){const s=new i.MessageBuilder;return null!=e?(s.sid(e.sid()),s.event(e.event()),s.entity(new n.StringEntity(t).metaStringSet(e.metaString()))):s.entity(new n.StringEntity(t)),new o(r.Flags.Alarm,s.build())}}},7953:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HandshakeDefault=void 0;const n=s(4797),r=s(8404);t.HandshakeDefault=class{constructor(e){let t=e.dataAsString();null!=t&&""!=t||(t=e.event()),this._source=e,this._url=t,this._version=e.meta(n.EntityMetas.META_SOCKETD_VERSION),this._outMetaMap=new Map,this._paramMap=new Map;let s=r.StrUtils.parseUri(t);s.path?this._path=s.path:this._path="/";const i=s.query;if(i)for(const e of i.split("&")){const t=e.indexOf("=");t>0&&this._paramMap.set(e.substring(0,t),e.substring(t+1))}e.metaMap().forEach(((e,t,s)=>{this._paramMap.set(t,e)}))}getSource(){return this._source}getOutMetaMap(){return this._outMetaMap}uri(){return this._url}path(){return this._path}version(){return this._version}param(e){return this._paramMap.get(e)||null}paramMap(){return this._paramMap}paramOrDefault(e,t){return this.param(e)||t}paramPut(e,t){this._paramMap.set(e,t)}outMeta(e,t){this._outMetaMap.set(e,t)}}},5067:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GuidGenerator=void 0;const n=s(8404);t.GuidGenerator=class{generate(){return n.StrUtils.guid()}}},6852:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PipelineListener=t.PathListener=t.EventListener=t.SimpleListener=void 0;const n=s(6789);t.SimpleListener=class{onOpen(e){}onMessage(e,t){}onClose(e){}onError(e,t){}};class r{constructor(e){this._eventRouteSelector=e||new n.RouteSelectorDefault}doOn(e,t){return this._eventRouteSelector.put(e,t),this}doOnOpen(e){return this._doOnOpen=e,this}doOnMessage(e){return this._doOnMessage=e,this}doOnClose(e){return this._doOnClose=e,this}doOnError(e){return this._doOnError=e,this}onOpen(e){this._doOnOpen&&this._doOnOpen(e)}onMessage(e,t){this._doOnMessage&&this._doOnMessage(e,t);const s=this._eventRouteSelector.select(t.event());s&&s(e,t)}onClose(e){this._doOnClose&&this._doOnClose(e)}onError(e,t){this._doOnError&&this._doOnError(e,t)}}t.EventListener=r,t.PathListener=class{constructor(e){this._pathRouteSelector=e||new n.RouteSelectorDefault}doOf(e,t){return this._pathRouteSelector.put(e,t),this}of(e){const t=new r;return this._pathRouteSelector.put(e,t),t}size(){return this._pathRouteSelector.size()}onOpen(e){const t=this._pathRouteSelector.select(e.path());null!=t&&t.onOpen(e)}onMessage(e,t){const s=this._pathRouteSelector.select(e.path());null!=s&&s.onMessage(e,t)}onClose(e){const t=this._pathRouteSelector.select(e.path());null!=t&&t.onClose(e)}onError(e,t){const s=this._pathRouteSelector.select(e.path());null!=s&&s.onError(e,t)}},t.PipelineListener=class{constructor(){this._deque=new Array}prev(e){return this._deque.unshift(e),this}next(e){return this._deque.push(e),this}size(){return this._deque.length}onOpen(e){for(const t of this._deque)t.onOpen(e)}onMessage(e,t){for(const s of this._deque)s.onMessage(e,t)}onClose(e){for(const t of this._deque)t.onClose(e)}onError(e,t){for(const s of this._deque)s.onError(e,t)}}},6862:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDefault=t.MessageBuilder=void 0;const n=s(4797);t.MessageBuilder=class{constructor(){this._flag=n.Flags.Unknown,this._sid=n.Constants.DEF_SID,this._event=n.Constants.DEF_EVENT,this._entity=null}flag(e){return this._flag=e,this}sid(e){return this._sid=e,this}event(e){return this._event=e,this}entity(e){return this._entity=e,this}build(){return new r(this._flag,this._sid,this._event,this._entity)}};class r{constructor(e,t,s,n){this._flag=e,this._sid=t,this._event=s,this._entity=n}atName(){return this.meta("@")}rangeStart(){return this.metaAsInt(n.EntityMetas.META_RANGE_START)}rangeSize(){return this.metaAsInt(n.EntityMetas.META_RANGE_SIZE)}flag(){return this._flag}isRequest(){return this._flag==n.Flags.Request}isSubscribe(){return this._flag==n.Flags.Subscribe}isEnd(){return this._flag==n.Flags.ReplyEnd}sid(){return this._sid}event(){return this._event}entity(){return this._entity}toString(){return"Message{sid='"+this._sid+"', event='"+this._event+"', entity="+this._entity+"}"}metaString(){return this._entity.metaString()}metaMap(){return this._entity.metaMap()}meta(e){return this._entity.meta(e)}metaOrDefault(e,t){return this._entity.metaOrDefault(e,t)}metaAsInt(e){return this._entity.metaAsInt(e)}metaAsLong(e){return this.metaAsInt(e)}metaAsFloat(e){return this._entity.metaAsFloat(e)}metaAsDouble(e){return this.metaAsFloat(e)}putMeta(e,t){this._entity.putMeta(e,t)}delMeta(e){this._entity.delMeta(e)}data(){return this._entity.data()}dataAsReader(){return this._entity.dataAsReader()}dataAsString(){return this._entity.dataAsString()}dataSize(){return this._entity.dataSize()}release(){this._entity&&this._entity.release()}}t.MessageDefault=r},4405:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessorDefault=void 0;const n=s(6852),r=s(4797),i=s(4970),a=s(7953);t.ProcessorDefault=class{constructor(){this._listener=new n.SimpleListener}setListener(e){null!=e&&(this._listener=e)}onReceive(e,t){if(e.getConfig().clientMode()||console.debug("S-REV:"+t),t.flag()==r.Flags.Connect)e.setHandshake(new a.HandshakeDefault(t.message())),e.onOpenFuture(((t,s)=>{if(t&&e.isValid())try{e.sendConnack()}catch(s){this.onError(e,s)}})),this.onOpen(e);else if(t.flag()==r.Flags.Connack)e.setHandshake(new a.HandshakeDefault(t.message())),this.onOpen(e);else{if(null==e.getHandshake()){if(e.close(r.Constants.CLOSE1001_PROTOCOL_CLOSE),t.flag()==r.Flags.Close)throw new i.SocketDConnectionException("Connection request was rejected");return void console.warn(`${e.getConfig().getRoleName()} channel handshake is null, sessionId=${e.getSession().sessionId()}`)}e.setLiveTimeAsNow();try{switch(t.flag()){case r.Flags.Ping:e.sendPong();break;case r.Flags.Pong:break;case r.Flags.Close:{let s=0;null!=t.message()&&(s=t.message().metaAsInt("code")),0==s&&(s=r.Constants.CLOSE1001_PROTOCOL_CLOSE),e.close(s),s>r.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&this.onCloseInternal(e);break}case r.Flags.Alarm:{const s=new i.SocketDAlarmException(t.message()),n=e.getConfig().getStreamManger().getStream(t.message().sid());null==n?this.onError(e,s):(e.getConfig().getStreamManger().removeStream(t.message().sid()),n.onError(s));break}case r.Flags.Message:case r.Flags.Request:case r.Flags.Subscribe:this.onReceiveDo(e,t,!1);break;case r.Flags.Reply:case r.Flags.ReplyEnd:this.onReceiveDo(e,t,!0);break;default:e.close(r.Constants.CLOSE1002_PROTOCOL_ILLEGAL),this.onCloseInternal(e)}}catch(t){this.onError(e,t)}}}onReceiveDo(e,t,s){let n=null,i=1,a=1;if(s&&(n=e.getStream(t.message().sid())),e.getConfig().getFragmentHandler().aggrEnable()){const s=t.message().meta(r.EntityMetas.META_DATA_FRAGMENT_IDX);if(s){i=parseInt(s);const o=e.getConfig().getFragmentHandler().aggrFragment(e,i,t.message());if(n&&(a=parseInt(t.message().metaOrDefault(r.EntityMetas.META_DATA_FRAGMENT_TOTAL,"1"))),null==o)return void(n&&n.onProgress(!1,i,a));t=o}}s?(n&&n.onProgress(!1,i,a),e.retrieve(t,n)):this.onMessage(e,t.message())}onOpen(e){try{this._listener.onOpen(e.getSession()),e.doOpenFuture(!0,null)}catch(t){console.warn(`${e.getConfig().getRoleName()} channel listener onOpen error`,t),e.doOpenFuture(!1,t)}}onMessage(e,t){try{this._listener.onMessage(e.getSession(),t)}catch(t){console.warn(`${e.getConfig().getRoleName()} channel listener onMessage error`,t),this.onError(e,t)}}onClose(e){0==e.isClosed()&&this.onCloseInternal(e)}onCloseInternal(e){this._listener.onClose(e.getSession())}onError(e,t){this._listener.onError(e.getSession(),t)}}},6789:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouteSelectorDefault=void 0,t.RouteSelectorDefault=class{constructor(){this._inner=new Map}select(e){return this._inner.get(e)}put(e,t){this._inner.set(e,t)}remove(e){this._inner.delete(e)}size(){return this._inner.size}}},1305:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionBase=void 0,t.SessionBase=class{constructor(e){this._channel=e,this._attrMap=null,this._sessionId=this.generateId()}sessionId(){return this._sessionId}liveTime(){return this._channel.getLiveTime()}name(){return this.param("@")||null}attrMap(){return null==this._attrMap&&(this._attrMap=new Map),this._attrMap}attrHas(e){return null!=this._attrMap&&this._attrMap.has(e)}attr(e){return null==this._attrMap?null:this._attrMap.get(e)}attrOrDefault(e,t){return this.attr(e)||t}attrPut(e,t){this.attrMap().set(e,t)}generateId(){return this._channel.getConfig().genId()}}},6039:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionDefault=void 0;const n=s(1305),r=s(9165),i=s(6862),a=s(3954),o=s(4797),l=s(3895);class h extends n.SessionBase{constructor(e){super(e)}isValid(){return this._channel.isValid()}isClosing(){return this._channel.isClosing()}remoteAddress(){return this._channel.getRemoteAddress()}localAddress(){return this._channel.getLocalAddress()}handshake(){return this._channel.getHandshake()}param(e){return this.handshake().param(e)}paramOrDefault(e,t){return this.handshake().paramOrDefault(e,t)}path(){return null==this._pathNew?this.handshake().path():this._pathNew}pathNew(e){this._pathNew=e}reconnect(){this._channel.reconnect()}sendPing(){this._channel.sendPing()}sendAlarm(e,t){this._channel.sendAlarm(e,t)}send(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build(),n=new l.SendStreamImpl(s.sid());return this._channel.send(new a.Frame(o.Flags.Message,s),n),n}sendAndRequest(e,t,s){null==t&&(t=new r.EntityDefault);const n=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build();s||(s=0),s<0&&(s=this._channel.getConfig().getStreamTimeout()),0==s&&(s=this._channel.getConfig().getRequestTimeout());const h=new l.RequestStreamImpl(n.sid(),s);return this._channel.send(new a.Frame(o.Flags.Request,n),h),h}sendAndSubscribe(e,t,s){null==t&&(t=new r.EntityDefault);const n=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build();s||(s=0),s<=0&&(s=this._channel.getConfig().getStreamTimeout());const h=new l.SubscribeStreamImpl(n.sid(),s);return this._channel.send(new a.Frame(o.Flags.Subscribe,n),h),h}reply(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(e.sid()).event(e.event()).entity(t).build();this._channel.send(new a.Frame(o.Flags.Reply,s),null)}replyEnd(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(e.sid()).event(e.event()).entity(t).build();this._channel.send(new a.Frame(o.Flags.ReplyEnd,s),null)}closeStarting(){console.debug(`${this._channel.getConfig().getRoleName()} session close starting, sessionId=${this.sessionId()}`),this._channel.isValid()&&this._channel.sendClose(o.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING)}close(){if(console.debug(`${this._channel.getConfig().getRoleName()} session will be closed, sessionId=${this.sessionId()}`),this._channel.isValid())try{this._channel.sendClose(o.Constants.CLOSE1001_PROTOCOL_CLOSE)}catch(e){console.warn(`${this._channel.getConfig().getRoleName()} channel sendClose error`,e)}this._channel.close(o.Constants.CLOSE2009_USER)}}t.SessionDefault=h},9871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SocketAddress=void 0,t.SocketAddress=class{constructor(e,t,s){this.address=e,this.family=t,this.port=s}}},5812:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServerBase=void 0;const n=s(4405);t.ServerBase=class{constructor(e,t){this._processor=new n.ProcessorDefault,this._config=e,this._assistant=t}getAssistant(){return this._assistant}getConfig(){return this._config}config(e){return e&&e(this._config),this}getProcessor(){return this._processor}listen(e){return e&&this._processor.setListener(e),this}}},8259:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServerConfig=void 0;const n=s(5628);class r extends n.ConfigBase{constructor(e){super(!1),e.startsWith("sd:")&&(e=e.substring(3)),this._schema=e,this._host="",this._port=8602}getSchema(){return this._schema}getHost(){return this._host}getHttpServer(){return this._httpServer}httpServer(e){return this._httpServer=e,this}host(e){return this._host=e,this}getPort(){return this._port}port(e){return this._port=e,this}getLocalUrl(){return this._host?"sd:"+this._schema+"://"+this._host+":"+this._port:"sd:"+this._schema+"://127.0.0.1:"+this._port}toString(){return"ServerConfig{schema='"+this._schema+"', charset="+this._charset+", host='"+this._host+"', port="+this._port+", ioThreads="+this._ioThreads+", codecThreads="+this._codecThreads+", exchangeThreads="+this._exchangeThreads+", idleTimeout="+this._idleTimeout+", requestTimeout="+this._requestTimeout+", streamTimeout="+this._streamTimeout+", readBufferSize="+this._readBufferSize+", writeBufferSize="+this._writeBufferSize+", maxUdpSize="+this._maxUdpSize+"}"}}t.ServerConfig=r},3895:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StreamMangerDefault=t.SubscribeStreamImpl=t.RequestStreamImpl=t.SendStreamImpl=t.StreamBase=void 0;const n=s(4970),r=s(2911),i=s(4797);class a{constructor(e,t,s){this._sid=e,this._demands=t,this._timeout=s}sid(){return this._sid}demands(){return this._demands}timeout(){return this._timeout}insuranceStart(e,t){this._insuranceFuture||(this._insuranceFuture=setTimeout((()=>{e.removeStream(this.sid()),this.onError(new n.SocketDTimeoutException("The stream response timeout, sid="+this.sid()))}),t))}insuranceCancel(){this._insuranceFuture&&clearTimeout(this._insuranceFuture)}onError(e){this._doOnError&&this._doOnError(e)}onProgress(e,t,s){this._doOnProgress&&this._doOnProgress(e,t,s)}thenError(e){return this._doOnError=e,this}thenProgress(e){return this._doOnProgress=e,this}}t.StreamBase=a,t.SendStreamImpl=class extends a{constructor(e){super(e,i.Constants.DEMANDS_ZERO,0)}isDone(){return!0}onReply(e){}},t.RequestStreamImpl=class extends a{constructor(e,t){super(e,i.Constants.DEMANDS_SIGNLE,t),this._isDone=!1}isDone(){return this._isDone}onReply(e){this._isDone=!0;try{this._doOnReply&&this._doOnReply(e)}catch(e){this.onError(e)}}await(){return new Promise(((e,t)=>{this.thenReply((t=>{e(t)})).thenError((e=>{t(e)}))}))}thenReply(e){return this._doOnReply=e,this}},t.SubscribeStreamImpl=class extends a{constructor(e,t){super(e,i.Constants.DEMANDS_MULTIPLE,t),this._isDone=!1}isDone(){return this._isDone}onReply(e){this._isDone=e.isEnd();try{this._doOnReply&&this._doOnReply(e)}catch(e){this.onError(e)}}thenReply(e){return this._doOnReply=e,this}},t.StreamMangerDefault=class{constructor(e){this._config=e,this._streamMap=new Map}getStream(e){return this._streamMap.get(e)||null}addStream(e,t){if(r.Asserts.assertNull("stream",t),t.demands()==i.Constants.DEMANDS_ZERO)return;this._streamMap.set(e,t);const s=t.timeout()>0?t.timeout():this._config.getStreamTimeout();s>0&&t.insuranceStart(this,s)}removeStream(e){const t=this.getStream(e);t&&(this._streamMap.delete(e),t.insuranceCancel(),console.debug(`${this._config.getRoleName()} stream removed, sid=${e}`))}}},1174:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsChannelAssistant=void 0;const n=s(2608);t.WsChannelAssistant=class{constructor(e){this._config=e}read(e){return this._config.getCodec().read(new n.ArrayBufferCodecReader(e))}write(e,t){let s=this._config.getCodec().write(t,(e=>new n.ArrayBufferCodecWriter(e)));e.send(s.getBuffer())}isValid(e){return e.isOpen()}close(e){e.close()}getRemoteAddress(e){return e.remoteAddress()}getLocalAddress(e){return e.localAddress()}}},1976:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsClient=void 0;const n=s(1421),r=s(1174),i=s(7882);class a extends n.ClientBase{constructor(e){super(e,new r.WsChannelAssistant(e))}createConnector(){return new i.WsClientConnector(this)}}t.WsClient=a},7882:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClientImpl=t.WsClientConnector=void 0;const n=s(8511),r=s(9777),i=s(2171),a=s(1930),o=s(4797),l=s(4970);class h extends n.ClientConnectorBase{constructor(e){super(e)}connect(){this.close();let e=this._client.getConfig().getUrl();return new Promise(((t,s)=>{try{this._real=new u(e,this._client,(e=>{e.getThrowable()?s(e.getThrowable()):t(e.getChannel())}))}catch(e){s(e)}}))}close(){this._real&&this._real.close()}}t.WsClientConnector=h;class u{constructor(e,t,s){try{this._real=i.EnvBridge.createSdWebSocketClient(e,this)}catch(e){s(new r.ClientHandshakeResult(null,e))}this._client=t,this._channel=new a.ChannelDefault(this._real,t),this._handshakeFuture=s}onOpen(e){try{this._channel.sendConnect(this._client.getConfig().getUrl(),this._client.getConfig().getMetaMap())}catch(e){console.warn("Client channel sendConnect error",e)}}onMessage(e){if(e.data()instanceof String)console.warn("Client channel unsupported onMessage(String test)");else try{let t=this._client.getAssistant().read(e.data());null!=t&&(t.flag()==o.Flags.Connack&&this._channel.onOpenFuture(((e,t)=>{this.handshakeFutureDo(t)})),this._client.getProcessor().onReceive(this._channel,t))}catch(e){e instanceof l.SocketDConnectionException&&this.handshakeFutureDo(e),console.warn("WebSocket client onMessage error",e)}}onClose(e){this._client.getProcessor().onClose(this._channel)}onError(e){this.handshakeFutureDo(e.error()),this._client.getProcessor().onError(this._channel,e.error())}handshakeFutureDo(e){this._handshakeFuture?this._handshakeFuture(new r.ClientHandshakeResult(this._channel,e)):this._handshakeFuture=null}close(){this._real.close()}}t.WebSocketClientImpl=u},8491:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsProvider=void 0;const n=s(1976),r=s(7041);t.WsProvider=class{schemas(){return["ws","wss","sd:ws","sd:wss"]}createClient(e){return new n.WsClient(e)}createServer(e){return new r.WsServer(e)}}},7041:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketServerListener=t.WsServer=void 0;const r=s(5812),i=s(1174),a=s(7704),o=n(s(2241)),l=s(8642),h=s(4797);class u extends r.ServerBase{constructor(e){super(e,new i.WsChannelAssistant(e))}getTitle(){return"ws/js-websocket/v"+a.SocketD.version()}start(){if(this._isStarted)throw new Error("Socket.D server started");this._isStarted=!0,this.getConfig().getHttpServer()?this._server=new o.default.Server({server:this.getConfig().getHttpServer(),maxPayload:h.Constants.MAX_SIZE_FRAME}):this.getConfig().getHost()?this._server=new o.default.Server({port:this.getConfig().getPort(),host:this.getConfig().getHost(),maxPayload:h.Constants.MAX_SIZE_FRAME}):this._server=new o.default.Server({port:this.getConfig().getPort(),maxPayload:h.Constants.MAX_SIZE_FRAME});const e=new c(this);return this._server.on("connection",((t,s)=>{new l.SdWebSocketNodeJs(t,s,e)})),console.info("Socket.D server started: {server="+this.getConfig().getLocalUrl()+"}"),this}stop(){if(this._isStarted){this._isStarted=!1;try{null!=this._server&&this._server.close()}catch(e){console.debug("Server stop error",e)}}}}t.WsServer=u;class c{constructor(e){this._server=e}getServer(){return this._server}onOpen(e){let t=e.socket().attachment();this._server.getProcessor().onClose(t)}onMessage(e){let t=e.socket().attachment(),s=this._server.getAssistant().read(e.data());null!=s&&this._server.getProcessor().onReceive(t,s)}onClose(e){let t=e.socket().attachment();this._server.getProcessor().onClose(t)}onError(e){let t=e.socket().attachment();t&&this._server.getProcessor().onError(t,e.error())}}t.SdWebSocketServerListener=c},2171:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvBridge=t.Runtime=void 0;const n=s(9941),r=s(4967),i=s(7703),a=s(3734);var o;!function(e){e[e.Unknown=0]="Unknown",e[e.Browser=1]="Browser",e[e.NodeJs=2]="NodeJs",e[e.Uniapp=3]="Uniapp",e[e.Weixin=4]="Weixin"}(o||(t.Runtime=o={})),t.EnvBridge=class{static getRuntime(){return"undefined"!=typeof window?"undefined"!=typeof uni&&uni.connectSocket?o.Uniapp:"undefined"!=typeof wx&&wx.connectSocket&&wx.request?o.Weixin:o.Browser:"undefined"!=typeof process&&process.versions&&process.versions.node?o.NodeJs:"undefined"!=typeof uni&&uni.connectSocket?o.Uniapp:o.Unknown}static createSdWebSocketClient(e,t){let s=this.getRuntime();return s==o.Weixin?(console.info("Client channel use xeixin api!"),new a.SdWebSocketWeixinClient(e,t)):s==o.Uniapp?(console.info("Client channel use uniapp api!"),new i.SdWebSocketUniappClient(e,t)):s==o.NodeJs?(console.info("Client channel use nodejs api"),new r.SdWebSocketNodeJsClient(e,t)):(console.info("Client channel use browser api"),new n.SdWebSocketBrowserClient(e,t))}}},2874:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketErrorEventImpl=t.SdWebSocketCloseEventImpl=t.SdWebSocketMessageEventImpl=t.SdWebSocketEventImpl=t.SdWebSocketState=void 0,function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(s||(t.SdWebSocketState=s={})),t.SdWebSocketEventImpl=class{constructor(e){this._socket=e}socket(){return this._socket}},t.SdWebSocketMessageEventImpl=class{constructor(e,t){this._socket=e,this._data=t}socket(){return this._socket}data(){return this._data}},t.SdWebSocketCloseEventImpl=class{constructor(e){this._socket=e}socket(){return this._socket}},t.SdWebSocketErrorEventImpl=class{constructor(e,t){this._socket=e,this._error=t}socket(){return this._socket}error(){return this._error}}},9941:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketBrowserClient=void 0;const n=s(2874);t.SdWebSocketBrowserClient=class{constructor(e,t){this._real=new WebSocket(e),this._listener=t,this._real.binaryType="arraybuffer",this._real.onopen=this.onOpen.bind(this),this._real.onmessage=this.onMessage.bind(this),this._real.onclose=this.onClose.bind(this),this._real.onerror=this.onError.bind(this)}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._real.readyState==WebSocket.CONNECTING}isClosed(){return this._real.readyState==WebSocket.CLOSED}isClosing(){return this._real.readyState==WebSocket.CLOSING}isOpen(){return this._real.readyState==WebSocket.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},8642:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketNodeJs=void 0;const r=s(2874),i=n(s(2241)),a=s(9871),o=s(1930);t.SdWebSocketNodeJs=class{constructor(e,t,s){this._real=e,this._listener=s,this._real.binaryType="arraybuffer",t.socket.remoteAddress?this._remoteAddress=new a.SocketAddress(t.socket.remoteAddress,t.socket.remoteFamily,t.socket.remotePort):this._remoteAddress=null,t.socket.localAddress?this._localAddress=new a.SocketAddress(t.socket.localAddress,t.socket.localFamily,t.socket.localPort):this._localAddress=null;const n=new o.ChannelDefault(this,s.getServer());this.attachmentPut(n),this._real.on("open",this.onOpen.bind(this)),this._real.on("message",this.onMessage.bind(this)),this._real.on("close",this.onClose.bind(this)),this._real.on("error",this.onError.bind(this))}remoteAddress(){return this._remoteAddress}localAddress(){return this._localAddress}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isClosed(){return this._real.readyState==i.default.CLOSED}isClosing(){return this._real.readyState==i.default.CLOSING}isConnecting(){return this._real.readyState==i.default.CONNECTING}isOpen(){return this._real.readyState==i.default.OPEN}onOpen(){let e=new r.SdWebSocketEventImpl(this);this._listener.onOpen(e)}onMessage(e){let t=new r.SdWebSocketMessageEventImpl(this,e);this._listener.onMessage(t)}onClose(){let e=new r.SdWebSocketCloseEventImpl(this);this._listener.onClose(e)}onError(e){let t=new r.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},4967:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketNodeJsClient=void 0;const r=s(2874),i=n(s(2241));t.SdWebSocketNodeJsClient=class{constructor(e,t){this._real=new i.default(e),this._listener=t,this._real.binaryType="arraybuffer",this._real.on("open",this.onOpen.bind(this)),this._real.on("message",this.onMessage.bind(this)),this._real.on("close",this.onClose.bind(this)),this._real.on("error",this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isClosed(){return this._real.readyState==i.default.CLOSED}isClosing(){return this._real.readyState==i.default.CLOSING}isConnecting(){return this._real.readyState==i.default.CONNECTING}isOpen(){return this._real.readyState==i.default.OPEN}onOpen(){let e=new r.SdWebSocketEventImpl(this);this._listener.onOpen(e)}onMessage(e){let t=new r.SdWebSocketMessageEventImpl(this,e);this._listener.onMessage(t)}onClose(){let e=new r.SdWebSocketCloseEventImpl(this);this._listener.onClose(e)}onError(e){let t=new r.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},7703:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketUniappClient=void 0;const n=s(2874);t.SdWebSocketUniappClient=class{constructor(e,t){this._state=n.SdWebSocketState.CONNECTING,this._real=uni.connectSocket({url:e,success:e=>{}}),this._listener=t,this._real.onOpen(this.onOpen.bind(this)),this._real.onMessage(this.onMessage.bind(this)),this._real.onClose(this.onClose.bind(this)),this._real.onError(this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._state==n.SdWebSocketState.CONNECTING}isClosed(){return this._state==n.SdWebSocketState.CLOSED}isClosing(){return this._state==n.SdWebSocketState.CLOSING}isOpen(){return this._state==n.SdWebSocketState.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._state=n.SdWebSocketState.OPEN,this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._state=n.SdWebSocketState.CLOSED,this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._state=n.SdWebSocketState.CLOSING,this._real.close({complete:()=>{this._state=n.SdWebSocketState.CLOSED}})}send(e){this._real.send({data:e})}}},3734:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketWeixinClient=void 0;const n=s(2874);t.SdWebSocketWeixinClient=class{constructor(e,t){this._state=n.SdWebSocketState.CONNECTING,this._real=wx.connectSocket({url:e}),this._listener=t,this._real.binaryType="arraybuffer",this._real.onOpen(this.onOpen.bind(this)),this._real.onMessage(this.onMessage.bind(this)),this._real.onClose(this.onClose.bind(this)),this._real.onError(this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._state==n.SdWebSocketState.CONNECTING}isClosed(){return this._state==n.SdWebSocketState.CLOSED}isClosing(){return this._state==n.SdWebSocketState.CLOSING}isOpen(){return this._state==n.SdWebSocketState.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._state=n.SdWebSocketState.OPEN,this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._state=n.SdWebSocketState.CLOSED,this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._state=n.SdWebSocketState.CLOSING,this._real.close({complete:()=>{this._state=n.SdWebSocketState.CLOSED}})}send(e){this._real.send({data:e})}}},8422:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RunUtils=void 0,t.RunUtils=class{static runAndTry(e){try{e()}catch(e){}}}},8404:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StrUtils=void 0;class s{static guid(){let e="";for(let t=1;t<=32;t++)e+=Math.floor(16*Math.random()).toString(16);return e}static parseUri(e){if(!e)return"";let t=e.indexOf("?");if(t>0){let n=e.substring(0,t),r=e.substring(t,e.length),i=s.parseUriDo(n);return i.source=e,i.query=r.substring(1,r.length),i.relative=r,i}return s.parseUriDo(e)}static parseUriDo(e){if(!e)return"";let t=s.parseUriOptions,n=t.parser[t.strictMode?"strict":"loose"].exec(e),r={},i=14;for(;i--;)r[t.key[i]]=n[i]||"";return r[t.q.name]={},r[t.key[12]].replace(t.q.parser,(function(e,s,n){s&&(r[t.q.name][s]=n)})),r}static strToBuf(e,t){return t||(t="utf-8"),(new TextEncoder).encode(e).buffer}static bufToStr(e,t,n,r){if(e.byteLength!=n){const s=new DataView(e),r=new ArrayBuffer(n),i=new DataView(r);for(let e=0;e<n;e++)i.setInt8(e,s.getInt8(t+e));e=r}return s.bufToStrDo(e,r)}static bufToStrDo(e,t){return t||(t="utf-8"),new TextDecoder(t).decode(e)}}t.StrUtils=s,s.parseUriOptions={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},2241:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}},t={},s=function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,s),i.exports}(7704),n=window;for(var r in s)n[r]=s[r];s.__esModule&&Object.defineProperty(n,"__esModule",{value:!0});