!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.imsdk=e():t.imsdk=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=1e4){r=Date.now();var s=e.imClient.buildMessagePack(y.SystemCommand.PING,{});t.send(s.pack(!1))}setTimeout(i,500)}else a.default.error("heartbeatLoop exited")};setTimeout(i,500)},t.prototype.createP2PTextMessage=function(t,e){var n=new g.MessagePack(this.appId);return n.buildTextMessagePack(this.userId,t,e),n},t.prototype.sendP2PMessage=function(t){var n=e.imClient.buildMessagePack(y.MessageCommand.MSG_P2P,t);this.conn&&this.conn.send(n.pack(!1))},t.prototype.sendP2PMessageReciveAck=function(t){console.log("=============== sendP2PMessageReciveAck"),console.log(t),t.toId=t.fromId,t.fromId=this.userId,console.log(t);var n=e.imClient.buildMessagePack(y.MessageCommand.MSG_RECIVE_ACK,t);t.conversationType=0;var r=e.imClient.buildMessagePack(y.MessageCommand.MSG_READED,t),i=e.imClient.buildMessagePack(y.MessageCommand.MSG_READED_RECEIPT,t);this.conn&&(this.conn.send(n.pack(!1)),this.conn.send(r.pack(!1)),this.conn.send(i.pack(!1)))},t.prototype.sendP2PMessageReadedReceipt=function(t){console.log("=============== sendP2PMessageReadedRECEIPT"),console.log(t),t.toId=t.fromId,t.fromId=this.userId,console.log(t);var n=e.imClient.buildMessagePack(y.MessageCommand.MSG_READED_RECEIPT,t);this.conn&&(console.log("=============== sendP2PMessageReadedRECEIPT 正式开始发送已读回执"),this.conn.send(n.pack(!1)))},t.prototype.getUserId=function(){return this.userId},t.prototype.loadOfflineMessage=function(){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return a.default.info("loadOfflineMessage start"),[4,new p.default(this.httpUrl).call("/message/syncOfflineMessage",this.getRequestParams(),{clientType:this.clientType,operater:this.userId,appId:this.appId,lastSequence:this.lastOfflineMessageSequence,maxLimit:100})];case 1:return(t=r.sent()).isSucceed()?(this.lastOfflineMessageSequence=t.data.maxSequence,n=t.data.dataList,this.offlineMessageList.push(n),n.length>0&&"function"==typeof e.imClient.listeners.onOfflineMessage&&e.imClient.listeners.onOfflineMessage(n),console.log(t.data.completed),t.data.completed||this.loadOfflineMessage()):a.default.error("loadOfflineMessage - error"),[2]}}))}))},t}();e.ImClient=E,e.limLogin=function(t,e,n){return r(void 0,void 0,void 0,(function(){return i(this,(function(r){return[2,new Promise((function(r,i){var o=new c.w3cwebsocket(t);o.binaryType="arraybuffer",a.default.info("limLogin");var s=setTimeout((function(){clearTimeout(s),r({success:!1,err:new Error("timeout"),conn:o})}),1e4);o.onopen=function(){if(o.readyState==c.w3cwebsocket.OPEN){"function"==typeof n.listeners.onSocketConnectEvent&&n.listeners.onSocketConnectEvent(t,e),a.default.info("开启连接");var r={userId:e.userId},i=n.buildMessagePack(9e3,r);o.send(i.pack(!1))}},o.onerror=function(t){clearTimeout(s),a.default.error(t),r({success:!1,err:t,conn:o})},o.onmessage=function(t){if("string"!=typeof t.data){clearTimeout(s);var e=new u.default(t.data).int32().int32().unpack(),n=e[0];e[1];9001==n&&r({success:!0,conn:o})}else a.default.info("Received: '"+t.data+"'")}}))]}))}))},e.getLen=function(t){for(var e=0,n=0;n=1&&r<=126||65376<=r&&r<=65439?e++:e+=3}return e},e.imClient=new E},function(t,e,n){"use strict";(function(t){e.__esModule=!0;var r=function(){function e(){}return e.getFetchToolkit=function(){var e;if(void 0!==t.fetch&&"function"==typeof t.fetch)e=t.fetch;else if("function"==typeof fetch)e=fetch;else{e=n(9).fetch}return e},e}();e.default=r}).call(this,n(8))},function(t,e,n){"use strict";e.__esModule=!0,e.im=void 0;var r=n(2);e.im=r.imClient,"undefined"!=typeof uni&&(uni.im=r.imClient)},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t,e){this.Type_Byte=1,this.Type_Short=2,this.Type_UShort=3,this.Type_Int32=4,this.Type_UInt32=5,this.Type_String=6,this.Type_VString=7,this.Type_Int64=8,this.Type_Float=9,this.Type_Double=10,this.Type_ByteArray=11,this._offset=0,this._list=[],this._littleEndian=!1,this._org_buf=t?t.constructor==DataView?t:t.constructor==Uint8Array?new DataView(t.buffer,e):new DataView(t,e):new DataView(new Uint8Array([]).buffer),this.arrayBuf=t,this.offset=e}return t.prototype.bigEndian=function(){return this._littleEndian=!1,this},t.prototype.littleEndianfunction=function(){return this._littleEndian=!0,this},t.prototype.utf8Write=function(t,e,n){for(var r=0,i=0,o=n.length;i>6),t.setUint8(e++,128|63&r)):r<55296||r>=57344?(t.setUint8(e++,224|r>>12),t.setUint8(e++,128|r>>6&63),t.setUint8(e++,128|63&r)):(i++,r=65536+((1023&r)<<10|1023&n.charCodeAt(i)),t.setUint8(e++,240|r>>18),t.setUint8(e++,128|r>>12&63),t.setUint8(e++,128|r>>6&63),t.setUint8(e++,128|63&r))},t.prototype.int32=function(t,e){return 0==arguments.length?(this._list.push(this._org_buf.getInt32(this._offset,this._littleEndian)),this._offset+=4):(this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_Int32,d:t,l:4}),this._offset+=4),this},t.prototype.uint32=function(t,e){return 0==arguments.length?(this._list.push(this._org_buf.getUint32(this._offset,this._littleEndian)),this._offset+=4):(this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_UInt32,d:t,l:4}),this._offset+=4),this},t.prototype.blength=function(){return this._offset},t.prototype.string=function(t,e){if(0==arguments.length){var n=this._org_buf.getInt32(this._offset,this._littleEndian);this._offset+=4,this._list.push(this.utf8Read(this._org_buf,this._offset,n)),this._offset+=n}else{n=0;t&&(n=this.utf8Length(t)),this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_String,d:t,l:n}),this._offset+=n+4}return this},t.prototype.utf8Length=function(t){for(var e=0,n=0,r=0,i=t.length;r=57344?n+=3:(r++,n+=4);return n},t.prototype.utf8Read=function(t,e,n){for(var r="",i=0,o=e,s=e+n;o=65536?(i-=65536,r+=String.fromCharCode(55296+(i>>>10),56320+(1023&i))):r+=String.fromCharCode(i)}else r+=String.fromCharCode((15&a)<<12|(63&t.getUint8(++o))<<6|(63&t.getUint8(++o))<<0);else r+=String.fromCharCode((15&a)<<6|63&t.getUint8(++o));else r+=String.fromCharCode(a)}return r},t.prototype.vstring=function(t,e,n){if(!e)throw new Error("vstring must got len argument");if(null==t||null==t){for(var r=0,i=this._offset;i0&&r++;this._list.push(this.utf8Read(this._org_buf,this._offset,r)),this._offset+=e}else this._list.splice(null!=n?n:this._list.length,0,{t:this.Type_VString,d:t,l:e}),this._offset+=e;return this},t.prototype.int64=function(t,e){return 0==arguments.length?(this._list.push(this._org_buf.getFloat64(this._offset,this._littleEndian)),this._offset+=8):(this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_Int64,d:t,l:8}),this._offset+=8),this},t.prototype.float=function(t,e){return 0==arguments.length?(this._list.push(this._org_buf.getFloat32(this._offset,this._littleEndian)),this._offset+=4):(this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_Float,d:t,l:4}),this._offset+=4),this},t.prototype.double=function(t,e){return 0==arguments.length?(this._list.push(this._org_buf.getFloat64(this._offset,this._littleEndian)),this._offset+=8):(this._list.splice(null!=e?e:this._list.length,0,{t:this.Type_Double,d:t,l:8}),this._offset+=8),this},t.prototype.byteArray=function(t,e,n){if(!e)throw new Error("byteArray must got len argument");if(null==t||null==t){var r=new Uint8Array(this._org_buf.buffer.slice(this._offset,this._offset+e));this._list.push(r),this._offset+=e}else this._list.splice(null!=n?n:this._list.length,0,{t:this.Type_ByteArray,d:t,l:e}),this._offset+=e;return this},t.prototype.unpack=function(){return this._list},t.prototype.packWithHead=function(){return this.pack(!0)},t.prototype.pack=function(t){this._org_buf=new DataView(new ArrayBuffer(t?this._offset+4:this._offset));var e=0;t&&(this._org_buf.setUint32(e,this._offset,this._littleEndian),e+=4);for(var n=0;n>2,o=(3&e)<<4|(n=t.charCodeAt(l++))>>4,s=(15&n)<<2|(r=t.charCodeAt(l++))>>6,a=63&r,isNaN(n)?s=a=64:isNaN(r)&&(a=64),u=u+this._keyStr.charAt(i)+this._keyStr.charAt(o)+this._keyStr.charAt(s)+this._keyStr.charAt(a);return u},decode:function(t){var e,n,r,i,o,s,a="",u=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");u>4,n=(15&i)<<4|(o=this._keyStr.indexOf(t.charAt(u++)))>>2,r=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(u++))),a+=String.fromCharCode(e),64!=o&&(a+=String.fromCharCode(n)),64!=s&&(a+=String.fromCharCode(r));return a=Base64._utf8_decode(a)},_utf8_encode:function(t){t=t.replace(/rn/g,"n");for(var e="",n=0;n127&&r<2048?(e+=String.fromCharCode(r>>6|192),e+=String.fromCharCode(63&r|128)):(e+=String.fromCharCode(r>>12|224),e+=String.fromCharCode(r>>6&63|128),e+=String.fromCharCode(63&r|128))}return e},_utf8_decode:function(t){for(var e="",n=0,r=0,i=0;n191&&r<224)i=t.charCodeAt(n+1),e+=String.fromCharCode((31&r)<<6|63&i),n+=2;else{i=t.charCodeAt(n+1);var o=t.charCodeAt(n+2);e+=String.fromCharCode((15&r)<<12|(63&i)<<6|63&o),n+=3}return e}},WebToolkit=function(){function WebToolkit(){}return WebToolkit.getBrowserInfo=function(){var t=navigator.userAgent.toLowerCase(),e=/edge\/[\d.]+/gi,n=/trident\/[\d.]+/gi,r=/msie\s[\d.]+/gi,i=/firefox\/[\d.]+/gi,o=/chrome\/[\d.]+/gi,s=/safari\/[\d.]+/gi,a=/opr\/[\d.]+/gi,u={code:0,system:t.split(" ")[1].split(" ")[0].split("(")[1],browser:"",browserVersion:""};return t.indexOf("trident")>0?(u.browser=t.match(n)[0].split("/")[0],u.browserVersion=t.match(n)[0].split("/")[1],u):t.indexOf("msie")>0?(u.browser=t.match(r)[0].split(" ")[0],u.browserVersion=t.match(r)[0].split(" ")[1],u):t.indexOf("edge")>0?(u.browser=t.match(e)[0].split("/")[0],u.browserVersion=t.match(e)[0].split("/")[1],u):t.indexOf("firefox")>0?(u.browser=t.match(i)[0].split("/")[0],u.browserVersion=t.match(i)[0].split("/")[1],u):t.indexOf("opr")>0?(u.browser=t.match(a)[0].split("/")[0],u.browserVersion=t.match(a)[0].split("/")[1],u):t.indexOf("safari")>0&&t.indexOf("chrome")<0?(u.browser=t.match(s)[0].split("/")[0],u.browserVersion=t.match(s)[0].split("/")[1],u):t.indexOf("chrome")>0?(u.browser=t.match(o)[0].split("/")[0],u.browserVersion=t.match(o)[0].split("/")[1],u):(u.code=-1,u)},WebToolkit.getWxappInfo=function(){return{system:"WXAPP",browser:"WXAPP",browserVersion:"1.0"}},WebToolkit.getReactNativeInfo=function(){return{system:"RNNative",browser:"RNNative",browserVersion:"1.0"}},WebToolkit.getUniAppInfo=function(){return{system:"UNIAPP",browser:"UNIAPP",browserVersion:"1.0"}},WebToolkit.loadJS=function(t,e){var n=document.createElement("script"),r=e||function(){};n.type="text/javascript";var i=!1;for(var o in document.getElementsByTagName("head")[0].children){var s=document.getElementsByTagName("head")[0].children[o];void 0!==s.outerHTML&&s.outerHTML.indexOf(t)>=0&&(i=!0)}i?r():(n.readyState?n.onreadystatechange=function(){"loaded"!=n.readyState&&"complete"!=n.readyState||(n.onreadystatechange=null,r())}:n.onload=function(){r()},n.src=t,document.getElementsByTagName("head")[0].appendChild(n))},WebToolkit.getIpInfoByFetch=function(callback){var url="http://pv.sohu.com/cityjson?ie=utf-8",fetch=Fetch_1.default.getFetchToolkit(),request={method:"GET",mode:"cors",headers:{"Content-Type":"application/json"}};return fetch(url,request).then((function(t){return t.text()})).then((function(res){if("function"==typeof callback){var currentCity=eval("_current_city="+res.replace("var returnCitySN = ",""));callback(currentCity)}})).catch((function(t){Logger_1.default.trace(t)}))},WebToolkit.getIpInfoByInsertScript=function(t){WebToolkit.loadJS("http://pv.sohu.com/cityjson?ie=utf-8",(function(){t(window.returnCitySN)}))},WebToolkit.getIpInfo=function(t){WebToolkit.getIpInfoByFetch(t)},WebToolkit.getDeviceInfo=function(){return WebToolkit.getUniAppInfo()},WebToolkit.base64Encode=function(t){return Base64.encode(t)},WebToolkit.base64Decode=function(t){return Base64.decode(t)},WebToolkit}();exports.default=WebToolkit},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"Headers",(function(){return p})),n.d(e,"Request",(function(){return v})),n.d(e,"Response",(function(){return C})),n.d(e,"DOMException",(function(){return w})),n.d(e,"fetch",(function(){return R}));var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==r&&r,i="URLSearchParams"in r,o="Symbol"in r&&"iterator"in Symbol,s="FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch(t){return!1}}(),a="FormData"in r,u="ArrayBuffer"in r;if(u)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(t){return t&&l.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function _(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function y(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function g(t){var e=new FileReader,n=y(e);return e.readAsArrayBuffer(t),n}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function E(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:a&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:i&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():u&&s&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(t)||f(t))?this._bodyArrayBuffer=m(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("Content-Type")||("string"==typeof t?this.headers.set("Content-Type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("Content-Type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var t=_(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=_(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(g)}),this.text=function(){var t,e,n,r=_(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=y(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function S(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function T(t){var e=new p;for(var n in t)e.append(n,t[n]);return e}function C(t,e){if(!(this instanceof C))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},E.call(v.prototype),E.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},C.error=function(){var t=new C(null,{status:0,statusText:""});return t.type="error",t};var I=[301,302,303,307,308];C.redirect=function(t,e){if(-1===I.indexOf(e))throw new RangeError("Invalid status code");return new C(null,{status:e,headers:{location:t}})};var w=r.DOMException;try{new w}catch(t){(w=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function R(t,e){return new Promise((function(n,i){var o=new v(t,e);if(o.signal&&o.signal.aborted)return i(new w("Aborted","AbortError"));function s(t){try{if("object"==typeof t)return JSON.stringify(t);if("string"==typeof t)return t}catch(t){}return t.toString()}let a=void 0===o._bodyInit?null:o._bodyInit;o.headers.hasOwnProperty("Content-Type")&&o.headers["Content-Type"].indexOf("application/json")>=0&&"POST"===o.method.toUpperCase()&&(a=JSON.parse(a));const u=uni.request({url:function(t){try{return""===t&&r.location.href?r.location.href:t}catch(e){return t}}(o.url),method:o.method,data:a,header:o.headers.map,complete:t=>{if(o.signal&&o.signal.removeEventListener("abort",l),t.errMsg.indexOf("fail")>=0)setTimeout((function(){i(new TypeError("Network request failed"))}),0);else{var e={status:t.statusCode,statusText:t.data?s(t.data):"",headers:T(t.header||{})};e.url=e.headers.get("X-Request-URL");var r=e.statusText;setTimeout((function(){n(new C(r,e))}),0)}}});function l(){u.abort()}o.signal&&o.signal.addEventListener("abort",l)}))}R.polyfill=!0,r.fetch||(r.fetch=R,r.Headers=p,r.Request=v,r.Response=C)},function(t,e,n){var r;if("object"==typeof globalThis)r=globalThis;else try{r=n(11)}catch(t){}finally{if(r||"undefined"==typeof window||(r=window),!r)throw new Error("Could not determine global this")}var i=r.WebSocket||r.MozWebSocket,o=n(12);function s(t,e){return e?new i(t,e):new i(t)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(t){Object.defineProperty(s,t,{get:function(){return i[t]}})})),t.exports={w3cwebsocket:i?s:null,version:o}},function(t,e){var n=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(t){return n()}try{return __global__||n()}finally{delete Object.prototype.__global__}}()},function(t,e,n){t.exports=n(13).version},function(t){t.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo (http://dev.sipdoc.net)"],"version":"1.0.34","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=4.0.0"},"dependencies":{"bufferutil":"^4.0.1","debug":"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"test":"tape test/unit/*.js","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0"}')},function(t,e,n){"use strict";e.__esModule=!0,e.RequestBase=void 0;var r=function(t,e,n){this.appId=t,this.clientType=e,this.imei=n};e.RequestBase=r},function(t,e,n){"use strict";e.__esModule=!0,e.RequestParams=void 0;var r=function(t,e,n){this.appId=t,this.identifier=e,this.userSign=n};e.RequestParams=r},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0),i=n(2),o=n(17),s=n(1),a=n(3),u=function(){function t(t){this.url="",this.url=t}return t.prototype.call=function(t,e,n){var o=i.imClient.userId;r.default.info(o);var a=this.url+t;null!=e&&(a+=this.setQueryConfig(e));n=this.setQueryToBody(e,n);var u={method:"POST",headers:{"Content-Type":"application/json"},body:s.default.json(n)};return this.httpFetch(a,u)},t.prototype.setQueryToBody=function(t,e){for(var n in t)e[n]=t[n];return e},t.prototype.setQueryConfig=function(t){var e="?";for(var n in t)e+=n+"="+t[n]+"&";return e=e.substring(0,e.length-1)},t.prototype.httpFetch=function(t,e){var n=this;return console.log("httpFetch"),a.default.getFetchToolkit()(t,e).then((function(t){return t.json()})).then((function(i){r.default.info("==> ["+e.method+"] "+t+" back:"+s.default.json(i));var o=n.response2ApiResponse(i);return o.isFailed()?Promise.reject(o):Promise.resolve(o)}))},t.prototype.response2ApiResponse=function(t){var e=new o.default(!0);return e.data=t.data,e.msg=t.msg,e.code=t.code,e},t}();e.default=u},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t){void 0===t&&(t=!1),this.msg="",this.data=null,t&&(this.code=200)}return t.prototype.isSucceed=function(){return 200===this.code},t.prototype.isFailed=function(){return!this.isSucceed()},t}();e.default=r},function(t,e,n){"use strict";var r,i,o,s,a,u;e.__esModule=!0,e.ConversationEventCommand=e.UserEventCommand=e.SystemCommand=e.GroupCommand=e.FriendShipCommand=e.MessageCommand=void 0,function(t){t[t.MSG_P2P=1103]="MSG_P2P",t[t.MSG_P2P_SYNC=1108]="MSG_P2P_SYNC",t[t.MSG_READED=1106]="MSG_READED",t[t.MSG_RECIVE_ACK=1107]="MSG_RECIVE_ACK",t[t.MSG_ACK=1046]="MSG_ACK",t[t.MSG_RECALL=1050]="MSG_RECALL",t[t.MSG_RECALL_NOTIFY=1052]="MSG_RECALL_NOTIFY",t[t.MSG_RECALL_ACK=1051]="MSG_RECALL_ACK",t[t.MSG_READED_NOTIFY=1053]="MSG_READED_NOTIFY",t[t.MSG_READED_RECEIPT=1054]="MSG_READED_RECEIPT"}(r||(r={})),e.MessageCommand=r,function(t){t[t.FRIEND_ADD=3e3]="FRIEND_ADD",t[t.FRIEND_UPDATE=3001]="FRIEND_UPDATE",t[t.FRIEND_DELETE=3002]="FRIEND_DELETE",t[t.FRIEND_REQUEST=3003]="FRIEND_REQUEST",t[t.FRIEND_REQUEST_READ=3004]="FRIEND_REQUEST_READ",t[t.FRIEND_REQUEST_APPROVER=3005]="FRIEND_REQUEST_APPROVER",t[t.FRIEND_BLACK_ADD=3010]="FRIEND_BLACK_ADD",t[t.FRIEND_BLACK_DELETE=3011]="FRIEND_BLACK_DELETE",t[t.FRIEND_GROUP_ADD=3012]="FRIEND_GROUP_ADD",t[t.FRIEND_GROUP_DELETE=3013]="FRIEND_GROUP_DELETE",t[t.FRIEND_GROUP_MEMBER_ADD=3014]="FRIEND_GROUP_MEMBER_ADD",t[t.FRIEND_GROUP_MEMBER_DELETE=3015]="FRIEND_GROUP_MEMBER_DELETE"}(i||(i={})),e.FriendShipCommand=i,function(t){t[t.JOIN_GROUP=2e3]="JOIN_GROUP",t[t.ADDED_MEMBER=2001]="ADDED_MEMBER",t[t.CREATED_GROUP=2002]="CREATED_GROUP",t[t.UPDATED_GROUP=2003]="UPDATED_GROUP",t[t.EXIT_GROUP=2004]="EXIT_GROUP",t[t.UPDATED_MEMBER=2005]="UPDATED_MEMBER",t[t.DELETED_MEMBER=2006]="DELETED_MEMBER",t[t.DESTROY_GROUP=2007]="DESTROY_GROUP",t[t.TRANSFER_GROUP=2008]="TRANSFER_GROUP",t[t.MUTE_GROUP=2009]="MUTE_GROUP",t[t.SPEAK_GOUP_MEMBER=2010]="SPEAK_GOUP_MEMBER",t[t.MSG_GROUP=2104]="MSG_GROUP",t[t.MSG_GROUP_SYNC=2105]="MSG_GROUP_SYNC",t[t.GROUP_MSG_ACK=2047]="GROUP_MSG_ACK"}(o||(o={})),e.GroupCommand=o,function(t){t[t.PING=9999]="PING",t[t.LOGIN=9e3]="LOGIN",t[t.LOGINACK=9001]="LOGINACK",t[t.MUTUALLOGIN=9002]="MUTUALLOGIN",t[t.LOGOUT=9003]="LOGOUT"}(s||(s={})),e.SystemCommand=s,function(t){t[t.USER_MODIFY=4e3]="USER_MODIFY",t[t.USER_ONLINE_STATUS_CHANGE=4001]="USER_ONLINE_STATUS_CHANGE",t[t.USER_ONLINE_STATUS_SUBSCRIBE=4002]="USER_ONLINE_STATUS_SUBSCRIBE",t[t.PULL_USER_ONLINE_STATUS=4003]="PULL_USER_ONLINE_STATUS",t[t.USER_ONLINE_STATUS_CHANGE_NOTIFY=4004]="USER_ONLINE_STATUS_CHANGE_NOTIFY"}(a||(a={})),e.UserEventCommand=a,function(t){t[t.CONVERSATION_DELETE=5e3]="CONVERSATION_DELETE",t[t.CONVERSATION_UPDATE=5001]="CONVERSATION_UPDATE"}(u||(u={})),e.ConversationEventCommand=u},function(t,e,n){"use strict";e.__esModule=!0,e.MessagePack=void 0;var r=n(1),i=function(){function t(t){this.messageId=r.default.uuid(),this.appId=t,this.messageRandom=this.RangeInteger(0,1e4),this.messageTime=Date.parse((new Date).toString())}return t.prototype.RangeInteger=function(t,e){var n=e-t;return Math.floor(Math.random()*n)+t},t.prototype.buildTextMessagePack=function(t,e,n){this.fromId=t,this.toId=e,console.warn(typeof n),console.log(n);var i=n;this.messageBody=r.default.json(i)},t.prototype.buildCustomerMessagePack=function(t,e,n,i){this.fromId=t,this.toId=e;var o={type:n,content:i};this.messageBody=r.default.json(o)},t}();e.MessagePack=i}])})); //# sourceMappingURL=lim-sdk.js.map