@rongcloud/electron 5.9.1 → 5.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/electron-darwin-arm64.node +0 -0
- package/binding/electron-darwin-x64.node +0 -0
- package/binding/electron-linux-arm64.node +0 -0
- package/binding/electron-linux-x64.node +0 -0
- package/binding/electron-win32-ia32.node +0 -0
- package/binding/electron-win32-x64.node +0 -0
- package/cppServiceProcess.js +1 -1
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cppServiceProcess.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@rongcloud/engine"),t=require("os"),o=require("child_process"),r=require("path"),n=require("http"),s=require("https"),i=require("url"),a=require("net"),c=require("events"),u=require("tls"),p=require("fs"),d=require("crypto");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var C=l(t),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},h(e,t)};function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var g,v=function(){return v=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},v.apply(this,arguments)};function S(e,t,o,r){return new(o||(o=Promise))((function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function y(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function _(e,t,o){if(o||2===arguments.length)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_PARSE_JSON_MSGS_R="P-parse_json_messsages-R",e.P_RECEIVE_MESSAGE_E="P-receive_message-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R",e.P_PARSE_JSON_E="P-parse_json-E"}(g||(g={}));var E,m={flushTimestamp:Date.now(),queue:[],locked:!1};function P(){E&&clearInterval(E)}function T(e,t){P(),E=setInterval((function(){return O(e,t)}),1e4)}function I(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=m.queue).push.apply(e,t)}var R=200;function O(e,t){var o=m.queue,r=m.flushTimestamp;if(!(m.locked||0===o.length||Date.now()-r<3e4&&o.length<R)){m.locked=!0;var n=t.createTraceId(),s=o.splice(0,R).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:r,type:n,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(g.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),n);var i=JSON.stringify(s);e.writeLog(i),t.debug(g.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),n),m.flushTimestamp=Date.now(),m.locked=!1,setTimeout((function(){return O(e,t)}))}}var N=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.flush=function(e){I(e)},t}(e.BasicLogger),M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.flush=function(e){I(e)},t}(e.BasicStatistic),U=function(e,t){var o,r=Buffer.from(e),n=r.length;for(t.push(n),o=0;o<n;o++)t.push(r[o])},x=function(e){return"string"==typeof e},b=function(e){return x(e)?e.toUpperCase():""},w=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},L=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},A=function(e){var t=b(e.method)||"GET",o=e.pathname||"/",r=e.headers||{},n=e.search||"";r.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(o+n," HTTP/1.1\n"),r)if(Object.hasOwnProperty.call(r,i)){var a=r[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},D=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,s=w(r,o);if(!s)return 2===r[1]?(e.socket.once("data",(function(o){var r=L(o);r?e.emit("error",new Error("SOCKS authentication failed. ".concat(r))):t()})),n=[1],U(e.socksUsername,n),U(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),o=[0],e.socksUsername&&o.push(2),(r=Buffer.alloc(2+o.length))[0]=5,r[1]=o.length,o.forEach((function(e,t){r[2+t]=e})),e.write(r)}))},k=function(e,t,o){return new Promise((function(r){var n,s;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):r()})),(n=[]).push(5),n.push(1),n.push(0),a.isIP(t)){case 0:n.push(3),U(t,n);break;case 4:n.push(1),function(e,t){var o,r,n=e.split(".");for(o=0;o<4;o++)r=parseInt(n[o],10),t.push(r)}(t,n);break;case 6:e.emit("error",new Error("Does not support IPV6"))}n.length+=2,(s=Buffer.from(n)).writeUInt16BE(o,s.length-2),e.write(s)}))},J=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new a.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return f(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return S(o,void 0,void 0,(function(){var o;return y(this,(function(r){switch(r.label){case 0:return[4,D(this)];case 1:return r.sent(),[4,k(this,t,e)];case 2:return r.sent(),this.onProxied(),o=A(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(c.EventEmitter),B=function(e){var t,o=e.hostname,r=e.port;return!e.host||o&&r||(t=e.host.split(":")),!r&&t&&(r=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new J(e).connect(r,o)},j=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=B,o}return f(t,e),t}(n.Agent),F=function(e,t,o){return(t=v(v({},t),i.parse(e))).port||(t.port=80),t.agent=new j(t),n.request(t,o)},V=function(e){var t,o;return t=B(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=u.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},H=function(e){function t(t,o){var r=e.call(this,o)||this;return r.url=t,r.socksHost=o.socksHost||"localhost",r.socksPort=o.socksPort||1080,r.createConnection=V,r}return f(t,e),t}(s.Agent),G=function(e,t,o,r){var n,i;return t.protocol="https:",!t.port&&t.host&&(n=t.host.split(":"),t.port=n[0],t.port=n[1]),t.port||(t.port=443),i=new H(e,t),t.agent=i,s.request(e,t,o)},q=null;function K(t,o,r){void 0===r&&(r=!1);var i=o.url,a=o.headers,c=o.body,u=o.method,p=o.query,d=o.timeout,l=void 0===d?e.HTTP_TIMEOUT:d;return new Promise((function(o){var d=/^https/.test(i),C={headers:a,method:u};d&&(C.rejectUnauthorized=r);var h=null;q?((C=v(v({},C),q)).body=c,h=d?G:F):(h=n.request,d&&(C.agent=new s.Agent(C),h=s.request));var f=h(e.appendUrl(i,p),C,(function(e){var t=e.statusCode,r="";e.setEncoding("utf8"),e.on("data",(function(e){r+=e})),e.once("end",(function(){o({status:t||0,data:r})}))}));f.once("timeout",(function(){t.warn(g.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:i,method:u,query:p,timeout:l})),o({status:0})})),f.setTimeout(l),f.once("error",(function(e){t.warn(g.P_HTTP_REQ_E,JSON.stringify({msg:e.stack,url:i,method:u,query:p,timeout:l})),o({status:0})})),f.write(c),f.end()}))}function W(t,o){return t?(q=v(v({},q),t),o.info(e.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:q})),{code:e.ErrorCode.SUCCESS}):(q=null,o.info(e.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:e.ErrorCode.SUCCESS})}function Y(){var t=q||void 0;return{code:e.ErrorCode.SUCCESS,data:t}}var Q,X=[],z=function(e){return S(void 0,void 0,void 0,(function(){return y(this,(function(t){return[2,new Promise((function(t){X.push({resolve:t,args:e}),$()}))]}))}))},Z=!1,$=function(){return S(void 0,void 0,void 0,(function(){var t,o,r,n,s,i,a,c,u,p,d;return y(this,(function(l){return Z||0===X.length||(Z=!0,t=X.shift(),o=t.args,r=t.resolve,n=o.addon,s=o.startTime,i=o.endTime,a=o.level,c=o.realtimeReport,u=0,p=0,d=[],n.setLogEventListener((function(t){u+=t.length;var o=t.split(","),n=o[0],s=o[1],i=o[2],l=o[3],C=o[4],h=o.slice(5);if(u>e.REAT_TIME_LOG_SIZE&&parseInt(s,10)!==p)r(d);else{p=parseInt(s,10);try{var f=JSON.parse(decodeURIComponent(h.join(","))),g=f.loggerId,v=f.sessionId,S=f.content,y=f.traceId;if(!c&&a<0)return;var _={time:parseInt(s,10),level:parseInt(l,10),sessionId:"".concat(n,":").concat(v),type:i,tag:C,loggerId:g,content:S,traceId:y};d.push(_)}catch(e){console.error(e)}}}),(function(e){r(d),Z=!1,$()}),(function(e,t,o){})),n.pullFullLog(a,s,i,!1)),[2]}))}))},ee=function(t){function o(o,r,n,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=t.call(this,r,n,u,{getLogs:function(e,t,r,n){return S(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,z({startTime:e,endTime:t,level:r,realtimeReport:n,addon:o})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var t=o.getStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(t,10)||0},setTimestamp4RealtimeLog:function(t){o.setStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP,t.toString())}},s)||this).subProcess=i,a}return f(o,t),o.prototype.send=function(e){return K(this.logger,e)},o.prototype.compressLogs=function(e){return S(this,void 0,void 0,(function(){var t,o,r;return y(this,(function(n){switch(n.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=n.sent(),o=t.success,r=t.data,o?[2,{success:o,data:r.data}]:[2,{success:o,data:""}]}}))}))},o}(e.BasicReporter),te=[e.EConnectProtocol.RMTP,e.EConnectProtocol.TLS,e.EConnectProtocol.QUIC],oe={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},re=null,ne=function(){var e,o=Date.now(),r=[t.arch(),t.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,d.createHash("md5").update(e).digest("hex")},se=function(e){if(re)return re;var t=r.resolve(e,oe.DEVICE_ID);return p.existsSync(t)?re=p.readFileSync(t).toString():(re=ne(),p.writeFileSync(t,re),re)},ie=function(){function e(e){this._callCppProxy=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,s){var i=JSON.stringify(n);"{}"!==i&&e.info(g.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._callCppProxy("setMessageExtension",t,o,r,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,r,n,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._callCppProxy("getMessage",a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var C=d[l];C&&C.ts<i-this._setTime?(C.v=c[l],C.ts=i-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,r,n,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}();!function(e){e[e.ERROR=-1]="ERROR",e[e.RESPONSE=0]="RESPONSE",e[e.EVENT=1]="EVENT",e[e.CALLBACK=2]="CALLBACK"}(Q||(Q={}));var ae,ce=function(){function t(t,o,r,n){var s=this;this.p=t,this.emit=o,this.callback=r,this.errorHandle=n,this.count=0,this.maps={},this.p.on("message",(function(e){var t=e.type,i=e.data;switch(t){case Q.EVENT:var a=i,c=a.eventName,u=a.data;null==o||o.apply(void 0,_([c],u,!1));break;case Q.RESPONSE:var p=i,d=p.reqId,l=p.success,C=p.data,h=s.maps[d];if(!h)return;h({success:l,data:C}),delete s.maps[d];break;case Q.CALLBACK:var f=i,g=(d=f.reqId,f.data);null==r||r(d,g);break;case Q.ERROR:var v=i.msg;null==n||n(v)}})),this.p.on("error",(function(e){null==n||n("SubProcessProxy error ".concat(e))})),this.p.on("exit",(function(t,o){if(0!==t){for(var r in s.maps){if(Object.prototype.hasOwnProperty.call(s.maps,r))(0,s.maps[r])({success:!0,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})}null==n||n("SubProcessProxy exit ".concat(t," ").concat(o),!0)}})),this.p.on("close",(function(e,t){console.log("SubProcessProxy close",e,t)}))}return t.prototype.call=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return S(this,void 0,void 0,(function(){var r=this;return y(this,(function(n){return this.p.killed||this.p.exitCode?[2,Promise.resolve({success:!1,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})]:[2,new Promise((function(e){var n=++r.count;r.maps[n]=e;var s={reqId:n,method:t,args:o,hasResponse:!0};r.p.send(s)}))]}))}))},t.prototype.send=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return S(this,void 0,void 0,(function(){var r;return y(this,(function(n){return(this.p.killed||this.p.exitCode)&&(null===(t=this.errorHandle)||void 0===t||t.call(this,"sub process exit")),r={reqId:-1,method:e,args:o},this.p.send(r),[2]}))}))},t.prototype.destroy=function(){this.send("destroy")},t}(),ue=function(e,t,o){return S(void 0,void 0,void 0,(function(){var r,n;return y(this,(function(s){return r=d.createDecipheriv("aes-256-cbc",t,o),n=r.update(e,"base64","utf-8"),[2,n+=r.final("utf8")]}))}))},pe=function(e){if(!p.existsSync(e)){var t=r.resolve(e,"..");p.existsSync(t)||pe(t),p.mkdirSync(e)}},de=function(t){function o(e,o,n,s,i){var a=t.call(this,e,o,n,i)||this;a.naviPath="",a._caches={},a.naviPath="".concat(s,"/").concat(oe.NAVI(e));var c=r.dirname(a.naviPath);return p.existsSync(c)||pe(c),a}return f(o,t),o.prototype.httpRequest=function(t,o,r,n){return S(this,void 0,void 0,(function(){var s,i,a,c,u;return y(this,(function(p){switch(p.label){case 0:return s="token=".concat(encodeURIComponent(r),"&v=").concat(e.FORMATED_VERSION,"&p=PC&ev=").concat("5.9.1"),i="".concat(t,"/navi.json?r=").concat(Date.now()),this.logger.debug(e.LogTagId.L_REQUEST_T,JSON.stringify({url:i,body:s}),n),[4,K(this.logger,{method:"POST",headers:{appId:o},body:s,url:i,timeout:e.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=p.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i,code:a.status}),n),[2,{code:this.transHttpCode(a.status)}];try{return c=JSON.parse(a.data),u=/^https/.test(i)?"https":"http",c.protocol=u,[2,{code:e.ErrorCode.SUCCESS,data:c}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,a.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.httpRequestV2=function(t,o,r,n){return S(this,void 0,void 0,(function(){var s,i,a,c;return y(this,(function(u){switch(u.label){case 0:return s=this.getNaviV2RequestOption({appkey:o,token:r,uri:t,platform:"electron",protocol:te.join(",")}),this.logger.debug(e.LogTagId.L_REQUEST_T,JSON.stringify({url:s.url,body:s.body,headers:s.headers}),n),[4,K(this.logger,s)];case 1:if(200!==(i=u.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s.url,code:i.status}),n),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s.url)?"https":"http",a.protocol=c,[2,{code:e.ErrorCode.SUCCESS,data:a}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,i.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.getNaviCache=function(t){var o=this._caches[t];if(o)return o;if(!p.existsSync(this.naviPath))return null;var r=p.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(r),this._caches[t]}catch(t){this.logger.error(e.LogTagId.L_PARSE_NAVI_E,r)}return null},o.prototype.setNaviCache=function(t,o){var r=Date.now();if(e.notEmptyObject(this._caches))for(var n in this._caches){var s=this._caches[n];(r-s.timestamp>e.NAVI_CACHE_DURATION||t===s.token)&&delete this._caches[n]}this._caches[t]={token:t,naviInfo:o,timestamp:Date.now()},p.writeFileSync(this.naviPath,JSON.stringify(this._caches))},o}(e.BasicNavi);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}(ae||(ae={}));var le=function(t){function o(o,r,n,s,i,a){var c=t.call(this,o,n,s,i,a)||this;return c.callCppProxy=r,c._connectedTime=0,c._naviInfo=null,c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.callCppProxy("setConnectionStatusListener",c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(g.P_DB_OPEN_O,e)}),(function(){return c.recvPong(e.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c)),c}return f(o,t),o.prototype.getConnectedTime=function(){return this._connectedTime},o.prototype.connectWithToken=function(t,o,r,n){var s=this;return new Promise((function(i){s._naviInfo=o,s.connectResolve={resolve:i,traceId:n,userId:o.userId};var a={},c=Y().data;c&&(a={proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0});var u=JSON.stringify(v(v({},a),{call_plus:s._openCallPlus})),p=s.getCmpList(o,!0).filter((function(e){return te.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),d=[];p.forEach((function(t){var o=d.find((function(e){return e.addr===t.addr}));o?o.protocol!==e.EConnectProtocol.QUIC&&t.protocol!==e.EConnectProtocol.QUIC||(o.race=!0,o.protocol=e.EConnectProtocol.QUIC):(t.race=!1,d.push(t))})),s.logger.info(g.P_CONNECT_O,JSON.stringify({use:d,catche:s.cmpWeightCache,proxy:a,FORMATED_VERSION:e.FORMATED_VERSION,reconnectKickEnable:r}),n),s._startTime=Date.now();try{s.callCppProxy("connectWithToken",t,e.FORMATED_VERSION,JSON.stringify(v(v({},o),{serverAddr:d})),r,u)}catch(t){s.logger.error(g.P_CALL_ADDON_E,null==t?void 0:t.stack,n),s.recvConnectRes(e.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},o.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.callCppProxy("disconnect",t)},o.prototype.sendPing=function(t){var o=this;return new Promise((function(r){o.pingResolve=r,o.callCppProxy("sendHeartbeat"),setTimeout((function(){return o.recvPong(e.ErrorCode.TIMEOUT)}),t)}))},o.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},o.prototype._onConnectionStatusChange=function(t,o){switch(this.logger.info(g.P_CONNECT_S,JSON.stringify({status:t,delay:o})),t){case e.ErrorCode.SUCCESS:this.recvConnectRes(e.ErrorCode.SUCCESS);break;case e.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(e.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case e.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(t,!1);break;case e.ErrorCode.RC_SOCKET_NOT_CREATED:case e.ErrorCode.RC_CONN_ACK_TIMEOUT:case e.ErrorCode.RC_TCP_RESET:this.recvConnectRes(t);break;case e.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(t,!0,o);break;default:this.recvConnectRes(t,!0)}},o.prototype.recvConnectRes=function(t,o,r){if(this.connectResolve){var n=this.connectResolve,s=n.resolve,i=n.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:e.getbundleId(),cod:t,net:this.getNetwork().type,dur:a,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:e.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.record(e.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),t===e.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.callCppProxy("getDeltaTime")),s({code:t,data:i}),void(this.connectResolve=null)}if(o)this.onDisconnectByServer(t,r);else{if(t===e.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(t)}},o.prototype._onTcpConnectResponse=function(t,o,r,n,s,i,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(o,":").concat(r)})),p={bid:e.getbundleId(),ptc:e.ProtocalType.TCP,cod:t,net:this.getNetwork().type,dur:n,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:"".concat(o,":").concat(r),idx:u,rct:this.retryCount?e.ConnectType.RECONNECT:e.ConnectType.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:e.StatisticsVersion.CURRENT,rsn:this.reason,ddu:s,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};this.statisticLog.record(e.StatisticsTag.IM_CMP,JSON.stringify(p)),this.logger.info(g.P_CONNECT_ENTRY_S,JSON.stringify({code:t,host:o,port:r,duration:n,dnsDuration:s,index:i,isQuic:a})),t===ae.SUCCESS&&(this.curCmpUrl="".concat(o,":").concat(r),this.updateCmpWeight("".concat(o,":").concat(r),!0,a))},o}(e.AConnectionMgr),Ce=function(t){function o(e,o,n){var s=t.call(this,e,o)||this;s.appkey=e,s.logger=o,s.dbpath=n,s._cachePath="",s._cachePath="".concat(n,"/").concat(oe.STATIC_CONFIG(e));var i=r.dirname(s._cachePath);return p.existsSync(i)||pe(i),s}return f(o,t),o.prototype.getCache=function(){return p.existsSync(this._cachePath)&&p.readFileSync(this._cachePath,{encoding:"utf8"})||null},o.prototype.setCache=function(e){p.writeFileSync(this._cachePath,e)},o.prototype.clearCache=function(){p.writeFileSync(this._cachePath,"")},o.prototype.sendRequest=function(e){return S(this,void 0,void 0,(function(){var t,o,r;return y(this,(function(n){switch(n.label){case 0:return[4,K(this.logger,{url:e,body:""})];case 1:return t=n.sent(),o=t.status,r=t.data,[2,{code:o,data:r}]}}))}))},o.prototype.decryptData=function(t){return S(this,void 0,void 0,(function(){var o,r;return y(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,ue(t,e.STATIC_CONFIG_KEY,e.STATIC_CONFIG_IV)];case 1:return o=n.sent(),[2,JSON.parse(o)];case 2:return r=n.sent(),this.logger.error(e.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==r?void 0:r.stack})),[3,3];case 3:return[2]}}))}))},o}(e.BasicStaticConfigManager),he=function(t){function o(e,o,n,s,i,a){var c=t.call(this,o,e,n,a)||this;c.deviceId=s,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(i,"/").concat(oe.CLOUD_CONTROL(e));var u=r.dirname(c.catchFilePath);return p.existsSync(u)||pe(u),c.init(),c}return f(o,t),o.prototype.httpRequest=function(t,o,r,n){return S(this,void 0,void 0,(function(){var s,i,a,c,u,p,d,l;return y(this,(function(C){switch(C.label){case 0:return(s=n).deviceId=this.deviceId,s.model=this.model,i={url:t,method:o,headers:r,body:JSON.stringify(s)},this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify(i)),[4,K(this.logger,i)];case 1:a=C.sent(),c=a.status,u=a.data,p=void 0===u?"":u,this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:p}));try{return d=JSON.parse(p),l=d.data,[2,{code:c,data:l}]}catch(t){return this.logger.warn(e.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:p,error:t})),[2,{code:c,msg:t}]}return[2]}}))}))},o.prototype.setCloudControllerCache=function(t){p.writeFileSync(this.catchFilePath,JSON.stringify(t)),this.logger.info(e.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(t))},o.prototype.getLocalCloudControllerCache=function(){if(!p.existsSync(this.catchFilePath))return null;var t=p.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(e.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:t})),t},o}(e.BaseCloudController),fe=function(){function t(t,n,s,i,a){this._appkey=t,this._cppProtocol=n,this._dbpath=s,this._dispatchEvent=i,this._logOutputLevel=a,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._chatroomCache=[],this.rtcHeartbeatResolves={};var c=this._dbpath,u=se(c);this._cppProtocol.initWithAppkey(t,c,e.FORMATED_VERSION);var p=o.fork(r.resolve(__dirname,"sub-process.js"));this.subProxy=new ce(p);var d=r.resolve(c,"RongCloud/rclogs",t);pe(d),function(t,o,r){r.initLogModule(o,t,e.getUUID())}(t,d,this._cppProtocol),this.logger=new N(this._appkey,"RC-M","IM"),this.statisticLog=new M(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),T(this._cppProtocol,this.logger),this.reporter=new ee(this._cppProtocol,t,u,this.logger,this.subProxy),this.logger.info(g.P_INIT_O,JSON.stringify({appkey:t,dbpath:c,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:u,commit:"100c5cfb3dcc519c5c367b0e33dc43f95c2da29c"})),this._callCppProxy("setDeviceId",u),this._staticConfigManager=new Ce(t,this.logger,c),this.navi=new de(t,this.logger,this.statisticLog,c,this._staticConfigManager),this.tcpMgr=new le(t,this._callCppProxy.bind(this),this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(u,c),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),this._msgExpansionHandler=new ie(this._callCppProxy.bind(this))}return t.prototype._initCloudController=function(t,o){var r=e.urlCenter.getCloudControllerUrl();this.cloudControllerUri=r[0],this.cloudController=new he(this._appkey,this.logger,this.reporter,t,o,this.statisticLog),e.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,e.InvokerType.init)},t.prototype.callProxy=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return S(this,void 0,void 0,(function(){var r,n,s;return y(this,(function(i){switch(i.label){case 0:if(!(r=this[t]))return this.logger.warn(g.P_CALL_MAIN_E,JSON.stringify({method:t,error:"not found"})),[2,Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})];n="",i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.call.apply(r,_([this],o,!1))];case 2:return[2,i.sent()];case 3:return s=i.sent(),n=JSON.stringify({error:null==s?void 0:s.stack,method:t}),this.logger.error(g.P_CALL_MAIN_E,n),[3,4];case 4:return[2,{code:e.ErrorCode.MAIN_PROCESS_ERROR,msg:n}]}}))}))},t.prototype.sendProxy=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return S(this,void 0,void 0,(function(){var o;return y(this,(function(r){if(!(o=this[e]))return this.logger.warn(g.P_CALL_MAIN_E,JSON.stringify({method:e,error:"not found"})),[2];try{o.call.apply(o,_([this],t,!1))}catch(t){this.logger.error(g.P_CALL_MAIN_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return[2]}))}))},t.prototype.registerRenderers=function(t){var o=t.navigators,r=t.areaCode,n=t.logServerUrl;e.urlCenter.init({areaCode:r,navigators:o,logServerUrl:n})},t.prototype.onConnected=function(){return S(this,void 0,void 0,(function(){var e,t,o;return y(this,(function(r){switch(r.label){case 0:return e=this.getNaviInfoFromCache(),this.reporter.checkStart(e),this._try2RejoinChatroom(),t=this._dispatchEvent,o=["onConnected"],[4,this.getMainProcessCache()];case 1:return t.apply(this,o.concat([r.sent()])),[2]}}))}))},t.prototype.onConnecting=function(){this._dispatchEvent("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._dispatchEvent("onSuspend",e)},t.prototype.onDisconnected=function(e){this._dispatchEvent("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this.logger.createTraceId();try{return this.logger.debug(g.P_CALL_ADDON_O,JSON.stringify({method:e,content:o}),n),(t=this._cppProtocol)[e].apply(t,o)}catch(t){throw this.logger.error(g.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n),t}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return K(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){I.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(t,o){if(this.tcpMgr.setNetwork(t,o),t.status&&e.isStartCloudController()&&this.cloudController){var r=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,e.InvokerType.newWorkChange,r)}},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){P(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy(),process.exit(0)},t.prototype.callExtra=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this[t];if(!n)return this.logger.warn(g.P_CALL_EXTRA_E,JSON.stringify({method:t,error:"not found"})),Promise.resolve({code:e.ErrorCode.NOT_SUPPORT});try{return n.call.apply(n,_([this],o,!1))}catch(e){this.logger.error(g.P_CALL_EXTRA_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(t,o,r,n){var s,i=this,a=this._callCppProxy("getConversationListByPage",t,o,r,n||"");try{s=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:s})},t.prototype.getUnreadConversationList=function(t){var o,r=this,n=this._callCppProxy("getUnreadConversationList",t);try{o=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.getConversationListWithAllChannel=function(){var t,o=this,r=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],n=this._callCppProxy("getConversationListWithAllChannel",r);try{t=JSON.parse(n).list.map((function(e){return o._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannelByPage=function(t,o){var r,n=this,s=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,t,o);try{r=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},t.prototype.getHistoryMessagesByObjectNames=function(t,o,r,n,s,i,a){var c=0===i,u=n+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",t,o,r,u,s,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var C=0;C<l.length;C++){var h=this._buildMessage(l[C].obj);d[C]=h}}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:n<d.length}})},t.prototype.updateMessageReceiptStatus=function(t,o,r,n){void 0===n&&(n="");var s=this._callCppProxy("updateMessageReceiptStatus",t,o,r,n);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:s})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new N(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId(),n=this.getDeviceId(),s=this._cppProtocol.getDeltaTime();return Promise.resolve({connectedTime:e,deviceId:n,crtUserId:r,naviInfo:o,connectionStatus:t,deltaTime:s})},t.prototype._registerMsgTypes=function(){for(var t in e.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},e.SEND_MESSAGE_TYPE_OPTION){var o=e.SEND_MESSAGE_TYPE_OPTION[t],r=o.isCounted,n=o.isPersited,s=o.searchProps,i=0;n&&(i|=1),r&&(i|=2),"RC:TypSts"===t&&(i=16),this._callCppProxy("registerMessageType",t,i,s||[])}},t.prototype._buildIsMentioned=function(t,o){var r,n=!1;if(e.isObject(t))r=t;else try{r=t?JSON.parse(t):t}catch(e){r=t,this.logger.error(g.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:o}))}return e.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},t.prototype._buildMsgOption=function(t){var o={isCounted:!1,isPersited:!1};return t in e.SEND_MESSAGE_TYPE_OPTION?o=e.SEND_MESSAGE_TYPE_OPTION[t]:t in this._customMessageType&&(o=this._customMessageType[t]),o},t.prototype._buildSupportExt=function(e,t,o){var r=null;return e&&(r=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(r=this._msgExpansionHandler.parseConverOrHisExpansion(o))),r},t.prototype._buildMessage=function(t,o){void 0===o&&(o={});var r=o.isOffLineMessage,n=o.buildFrom,s=JSON.parse(t),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,p=s.content,d=s.objectName,l=s.messageUid,C=s.direction,h=s.status,f=s.messageId,g=s.sentTime,S=s.readReceiptRequest,y=s.supportExt,_=s.pushContent,E=s.pushTitle,m=s.pushId,P=s.pushConfig,T=s.templateId,I=s.disableTitle,R=s.forcePushDetail,O=s.hasMore,N=this._buildIsMentioned(p,f),M=N.isMentioned,U=N.msgContent,x=this._buildMsgOption(d),b=this._buildSupportExt(y,n,s),w=e.isUndefined(r)?g<this.tcpMgr.getConnectedTime():r,L={};P&&(L=e.pushJSONToConfigs(this.logger,P,m));var A=v(v({},L),{pushTitle:E,pushContent:_,pushData:_,disablePushTitle:I,forceShowDetailContent:R,templateId:T}),D={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:U||{},messageType:d,messageUId:l||"",messageDirection:C,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:x.isPersited,isCounted:x.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?b:null,receivedStatus:h,messageId:f,pushConfig:A,hasMore:O};if(C===e.MessageDirection.RECEIVE?D.receivedStatus=h:C===e.MessageDirection.SEND&&(D.sentStatus=h),S){var k=JSON.parse(S),J=k.hasRespond,B=k.readerInfo,j=void 0===B?{}:B,F=k.readCount,V=k.totalCount,H=k.readerList,G=void 0===H?[]:H,q={readCount:F,totalCount:V},K=this.getNaviInfoFromCache();if(1===(null==K?void 0:K.grpRRVer)){var W=[];for(var Y in j)W.push({userId:Y,readTime:j[Y]});q.readerList=W,q.hasRespond=J}3===(null==K?void 0:K.grpRRVer)&&(q.readerList=G),D.readReceiptInfo=q}return D},t.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},s=v(v({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},t.prototype._processRSMsg=function(t){var o=t.conversationType,r=t.targetId,n=t.content,s=t.channelId,i=n.msgId,a=n.rrn,c=n.tmn,u=n.endMsgTime;o===e.ConversationType.PRIVATE?this.updateMessageReceiptStatus(o,r,u,s||""):this._updateReadReceiptInfo(i,{readCount:a,totalCount:c});var p={conversationType:o,targetId:r,channelId:s};this._sendMessageReadReceipt(o===e.ConversationType.PRIVATE?{privateReadReceipt:v(v({},p),{endMsgTime:n.endMsgTime})}:{groupReadReceipt:v(v({},p),{totalCount:n.tmn,readedCount:n.rrn,messageUId:n.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,r=e.targetId,n=e.content,s=e.channelId,i=e.senderUserId,a=e.sentTime;return i===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,r,n.lastMessageSendTime,s||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:r,channelId:s,timestamp:n.lastMessageSendTime}),!1))},t.prototype._buildConversation=function(t){var o=JSON.parse(t),r=o.channelId,n=o.conversationType,s=o.targetId,i=o.unreadCount,a=o.lastestMsg,c=o.isTop,u=o.blockStatus,p=o.matchCount,d=o.hasUnreadMention,l=o.conversationTime,C=o.draft,h=u>0?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:p,operationTime:l,notificationLevel:u,draft:C}},t.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},t.prototype._setOnReceiveMessageListener=function(){var t=this;this._cppProtocol.setOnReceiveMessageListener((function(o,r,n,s){var i;try{var a=t._buildMessage(o,{isOffLineMessage:n}),c=a.messageType,u=a.channelId,p=void 0===u?"":u,d=a.senderUserId,l=a.content,C=(a.canIncludeExpansion,a.messageUId,a.conversationType),h=a.targetId;t.getNaviInfoFromCache();if(c===e.MessageType.LOG_COMMAND&&a.senderUserId===e.RC_DEFAULT_USER){var f=a.content,v=f.startTime,S=f.endTime,y=f.platform,_=f.logId,E=f.uri;return void t.reporter.report(parseInt(v,10),parseInt(S,10),y,E,_,a.messageUId)}if(c===e.MessageType.CLOUD_CONTROL&&d===e.RC_DEFAULT_USER)return t.cloudControllerMsgs.push(a),void t._ccMsgHandler();if(c===e.MessageType.GROUP_READ_RECEIPT_REQUEST){var m=l.msgId,P=l.rrn,T=l.tmn;t._updateReadReceiptInfo(m,{readCount:P,totalCount:T})}if(c===e.MessageType.READ_STATE)return void t._processRSMsg(a);if("RC:MsgExMsg"===c)return t._msgExpansionHandler.setLocalFromExtMsg(t.logger,a),void t._sendMessageExpansion(a);if(a.canIncludeExpansion&&t._msgExpansionHandler.setLocalFromReceiveMsg(t.logger,a),c===e.MessageType.READ_RECEIPT&&d===t.tcpMgr.getCurrentUserId()&&t._callCppProxy("clearUnreadCountByTimestamp",C,h,l.lastMessageSendTime,p),c===e.MessageType.SYNC_READ_STATUS&&!t._processSRSMsg(a))return;var I=!0;if(0!==r||s||(I=!1),c===e.MessageType.DELIVERED)return t._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void t._sendMessageDelivered(a.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c===e.MessageType.DELIVERED_MSG){var R={totalCount:a.content.tmn,list:null===(i=a.content.dl)||void 0===i?void 0:i.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};return void t._sendGroupMessageDeliveredStatus(R)}if(c===e.MessageType.RECALL){if(!t.handleRecalledMessage(a))return;var O=t._fixRecallContentInfo(a);C=O.conversationType,h=O.targetId}t._sendMessageNotification(Object.assign(a,{hasMoreMsg:I,conversationType:C,targetId:h}))}catch(e){t.logger.error(g.P_RECEIVE_MESSAGE_E,JSON.stringify({error:null==e?void 0:e.stack,message:o}))}}),(function(){t._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var t;return S(this,void 0,void 0,(function(){var o,r;return y(this,(function(n){switch(n.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(o=this.tcpMgr.getToken(),[4,null===(t=this.cloudController)||void 0===t?void 0:t.request(this.cloudControllerUri,e.InvokerType.other,o)]):[3,2]):[2];case 1:r=n.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>r})),this.cloudControllerLock=!0,this._ccMsgHandler(),n.label=2;case 2:return[2]}}))}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},t.prototype.handleRecalledMessage=function(t){var o=t.content,r=o.messageUId,n=o.sentTime;if(!r)return!0;var s=this._callCppProxy("getMessage",r),i=this._buildMessage(s,{isOffLineMessage:!1});if(t.content.isDelete)return-1===i.messageId||this._callCppProxy("deleteMessages",[i.messageId]),!0;if(i.messageType===e.MessageType.RECALL_NOTIFICATION_MESSAGE)return!1;var a={recallTime:Date.now(),admin:!!t.content.isAdmin,originalObjectName:i.messageType,originalMessageContent:i.content,recallActionTime:t.sentTime,operatorId:t.senderUserId};if(t.content.user&&(a.user=t.content.user),t.content.extra&&(a.extra=t.content.extra),i.messageType===e.MessageType.TextMessage&&(a.recallContent=i.content.content),-1===i.messageId){var c=t.conversationType,u=t.targetId,p=t.senderUserId,d=t.channelId,l=t.messageDirection;return this._callCppProxy("insertMessage",c,u,p,e.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,10,n,"",0,r,!1,!0,JSON.stringify({}),d||""),!0}return i.receivedStatus||this.setMessageReceivedStatus(i.messageId,1),this._callCppProxy("setMessageContent",i.messageId,JSON.stringify(a),e.MessageType.RECALL_NOTIFICATION_MESSAGE),!0},t.prototype._sendMessageExpansion=function(e){var t=e.channelId,o=void 0===t?"":t,r=e.content,n=e.conversationType,s=e.targetId,i=r,a=i.put,c=i.del,u=i.mid,p={};a&&(p.updatedExpansion={channelId:o,messageUId:u,expansion:a,conversationType:n,targetId:s}),c&&(p.deletedExpansion={channelId:o,messageUId:u,deletedKeys:c,conversationType:n,targetId:s}),this._dispatchEvent("expansion",p)},t.prototype._sendMessageNotification=function(e){this._dispatchEvent("batchMessage",e)},t.prototype._sendPullOfflineFinished=function(){this._dispatchEvent("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._dispatchEvent("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._dispatchEvent("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._dispatchEvent("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._dispatchEvent("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._dispatchEvent("syncReadStatus",e)},t.prototype._setConversationStatusListener=function(){var t=this;this._cppProtocol.setConversationStatusListener((function(o){var r=JSON.parse(o).list,n=[];r.forEach((function(t){var o=JSON.parse(t.obj),r=o.conversationType,s=o.targetId,i=o.status,a=o.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(t){var o=JSON.parse(t.item);1===o.type?c.notificationStatus=1===Number(o.value)?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE:c.isTop=1===Number(o.value)})),n.push({channelId:a,conversationType:r,targetId:s,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),t._dispatchEvent("conversation",n)}),(function(e){t._dispatchEvent("conversationTag",e)}),(function(e,o,r,n){t._callCppProxy("clearUnreadCountByTimestamp",e,o,n,r||""),t._sendsyncReadStatus({conversationType:e,targetId:o,channelId:r,timestamp:n})}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._dispatchEvent("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._dispatchEvent("onNaviDataChange",o)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._dispatchEvent("onRTCDataChange",o)}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._dispatchEvent("callInfo",t)}))},t.prototype._updateMentionedInfo=function(t,o,r){var n,s,i;return{userIdList:(null===(n=t.mentionedInfo)||void 0===n?void 0:n.userIdList)||o,type:(null===(s=t.mentionedInfo)||void 0===s?void 0:s.type)||r||e.MentionedType.ALL,mentionedContent:(null===(i=t.mentionedInfo)||void 0===i?void 0:i.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,o,r){void 0===r&&(r=[]);var n=0;t&&(n|=1),o&&(n|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(g.P_REGTYP_O,JSON.stringify({type:e,opt:n,search:r})),this._callCppProxy("registerMessageType",e,n,r)},t.prototype.connect=function(e,t,o,r){return this.tcpMgr.connect(e,t,o,r)},t.prototype.reportSDKInfo=function(e){var t=JSON.stringify(v(v({},e),{"electron-main":"5.9.1"}));this.logger.info(g.P_REPORT_VER_O,t),this._callCppProxy("uploadSDKVersion",t,"")},t.prototype.disconnect=function(e){e=e||!0,this._chatroomCache.length=0,this.reporter.stop(),W(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},t.prototype.subscribeUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("subscribeUserStatus",t,(function(){r(e.ErrorCode.SUCCESS)}),r)}))},t.prototype.setUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("setUserStatus",t,(function(){r(e.ErrorCode.SUCCESS)}),r)}))},t.prototype.getUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getUserStatus",t,(function(t){r({code:e.ErrorCode.SUCCESS,data:{status:t}})}),(function(e){r({code:e})}))}))},t.prototype.sendMessage=function(t,o,r,n,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,p=r.pushConfig,d=r.isMentioned,l=r.mentionedType,C=r.mentionedUserIdList,h=void 0===C?[]:C,f=r.pushContent,v=void 0===f?"":f,S=r.pushData,y=void 0===S?"":S,_=r.directionalUserIdList,E=void 0===_?[]:_,m=r.disableNotification,P=void 0!==m&&m,T=r.canIncludeExpansion,I=void 0!==T&&T,R=r.isVoipPush,O=void 0!==R&&R,N=r.channelId,M=void 0===N?"":N,U=r.messageId,x=void 0===U?0:U,b=p||{},w=b.iOSConfig,L=b.androidConfig,A=b.templateId,D=void 0===A?"":A,k=b.pushTitle,J=void 0===k?"":k,B=b.pushContent,j=void 0===B?v:B,F=b.pushData,V=void 0===F?y:F,H=b.disablePushTitle,G=void 0!==H&&H,q=b.forceShowDetailContent,K=void 0!==q&&q,W=e.pushConfigsToJSON(w,L);return new Promise((function(r){v=j,y=V;var p=(null==L?void 0:L.notificationId)||"";t===e.ConversationType.GROUP&&d&&c&&(c.mentionedInfo=i._updateMentionedInfo(c,h,l));var C=t===e.ConversationType.GROUP;if(C&&a===e.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)E.push(f);C&&a===e.MessageType.SYNC_READ_STATUS&&(E=[i.getCurrentUserId()]);var S={};for(var f in u)S[f]={v:""},S[f].v=u[f];var _=D;i.logger.info(g.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:t,targetId:o,channelId:M}),s);var m=i._callCppProxy("sendMessage",(function(t,o){var n=i._buildMessage(t,{isOffLineMessage:!1});return i.logger.info(g.P_SEND_MSG_R,JSON.stringify({code:o,messageUId:n.messageUId}),s),o===e.ErrorCode.SENSITIVE_REPLACE?r({code:o}):("RC:MsgExMsg"===n.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,n),n.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,n),r({code:e.ErrorCode.SUCCESS,data:n}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(g.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),r({code:t,data:o})}),t,o,a,JSON.stringify(c),E,P,G,K,v,y,p,J,W,_,I,JSON.stringify(S),O,M,x),T=JSON.parse(m);null==n||n(T.messageId)}))},t.prototype.recallMsg=function(t,o,r,n,s){var i=this;return new Promise((function(a){var c,u=s.user,p=s.pushContent,d=s.channelId,l=s.extra,C=s.pushConfig,h=s.disableNotification,f=s.isDelete,g={conversationType:t,targetId:o,messageUId:r,sentTime:n,user:u,extra:l,channelId:d,isDelete:f||!1};u&&(g.user=u),l&&(g.extra=l);var v={conversationType:t,targetId:o,senderUserId:i.tcpMgr.getCurrentUserId(),content:g,objectName:e.MessageType.RECALL,messageUid:r,direction:e.MessageDirection.SEND,status:e.ReceivedStatus.UNREAD,sentTime:n,channelId:d},S=i._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){i.handleRecalledMessage(S),a({code:e.ErrorCode.SUCCESS,data:S})}),(function(e){a({code:e})}),e.MessageType.RECALL,JSON.stringify(g),h||!1,(null==C?void 0:C.disablePushTitle)||!1,(null==C?void 0:C.forceShowDetailContent)||!1,p||"",(null==C?void 0:C.pushData)||"",(null===(c=null==C?void 0:C.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==C?void 0:C.pushTitle)||"",e.pushConfigsToJSON(null==C?void 0:C.iOSConfig,null==C?void 0:C.androidConfig),(null==C?void 0:C.templateId)||"",d)}))},t.prototype.getHistoryMessage=function(t,o,r,n,s,i,a){var c=this;return new Promise((function(u){r=r||0;var p=0===s,d=n+1,l=c._callCppProxy("getHistoryMessages",t,o,r,d,a,p,i),C=JSON.parse(l).list,h=[];C.reverse();for(var f=0;f<C.length;f++){var g=c._buildMessage(C[f].obj);h[f]=g}u({code:e.ErrorCode.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:n<h.length}})}))},t.prototype.getMessages=function(t,o,r,n,s,i){var a=this;return void 0===r&&(r=0),new Promise((function(c){var u=0===s,p=r,d=0!==r,l=n+1;d&&(p+=u?1:-1,l++);for(var C=a._callCppProxy("getMessages",t,o,p,l,u,i),h=JSON.parse(C).list,f=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);f[g]=v}var S=a._computeRepairInfo(f,u,r,p,l),y=S.isNeedRepair,_=void 0!==y&&y,E=S.repairTime,m=void 0===E?0:E;if(!_)return d&&(f.shift(),l--),f.reverse(),void c({code:e.ErrorCode.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:n<f.length}});a._processRepairHisMsg(t,o,r,n,s,i,m,c)}))},t.prototype._computeRepairInfo=function(e,t,o,r,n){var s=!1,i=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:s,repairTime:i};var d=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&d>=0?(s=!0,i=e[d].hasMore?e[d].sentTime:e[d].sentTime+1):!t&&d>=1?(s=!0,i=e[d-1].sentTime):0===o?(s=!0,i=0):e.length<n?(s=!0,i=o):e.length>0&&e[0].sentTime!==o&&(s=!0,i=r),{isNeedRepair:s,repairTime:i}},t.prototype._processRepairHisMsg=function(e,t,o,r,n,s,i,a){var c=this,u=function(i){for(var u=0===n,p=r+1,d=c._callCppProxy("getMessages",e,t,o,p,u,s),l=JSON.parse(d).list,C=[],h=0;h<l.length;h++){var f=c._buildMessage(l[h].obj);C[h]=f}C.reverse(),a({code:i,data:{list:p<=C.length?C.slice(1,p):C,hasMore:r<C.length}})},p=r+10>100?100:r+10;this._callCppProxy("getRemoteHistoryMessages",e,t,i,p,(function(){return u(0)}),(function(e){u(e)}),n,!0,s,!1)},t.prototype.getRemoteHistoryMessages=function(t,o,r,n,s,i){var a=this;return new Promise((function(c){r=r||0;a._callCppProxy("getRemoteHistoryMessages",t,o,r,n,(function(t,o){var r=JSON.parse(t).list,n=[];r.reverse();for(var s=0;s<r.length;s++){var i=a._buildMessage(r[s].obj);n[s]=i}c({code:e.ErrorCode.SUCCESS,data:{list:n,hasMore:!!o}})}),(function(e){c({code:e})}),s,!0,i,!0)}))},t.prototype.deleteRemoteMessage=function(t,o,r,n){var s=this;return new Promise((function(i){var a=JSON.stringify(r);s._callCppProxy("deleteRemoteHistoryMessages",t,o,a,!1,n,(function(){i(e.ErrorCode.SUCCESS)}),i)}))},t.prototype.deleteRemoteMessageByTimestamp=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearRemoteHistoryMessages",t,o,r,(function(){i(e.ErrorCode.SUCCESS)}),(function(e){i(e)}),n)}))},t.prototype.clearMessages=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("clearMessages",t,o,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.getConversationList=function(t,o,r,n,s){var i=this;return void 0===s&&(s=""),new Promise((function(t){for(var o=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(o).list,n=[],a=0;a<r.length;a++)n.push(i._buildConversation(r[a].obj));t({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.getConversation=function(t,o,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversation",t,o,r);if(i)s({code:e.ErrorCode.SUCCESS,data:n._buildConversation(i)});else{var a=n._callCppProxy("getHistoryMessages",t,o,0,1,"",!0,r),c=void 0;try{c=JSON.parse(a).list}catch(e){n.logger.error(g.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),c=[]}var u=null;c.length>0&&(u=n._buildMessage(c[0].obj));var p=n._callCppProxy("getConversationNotificationStatus",t,o,r),d=n._callCppProxy("getConversationTopStatus",t,o,r);s({code:e.ErrorCode.SUCCESS,data:{conversationType:t,targetId:o,channelId:r,unreadMessageCount:0,latestMessage:u,notificationStatus:p?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(t,o,r){var n=this._callCppProxy("removeConversation",t,o,r);return Promise.resolve(n?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.batchRemoveConversation=function(t){var o=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId}})),r=this._callCppProxy("removeConversationInBatches",JSON.stringify(o));return Promise.resolve(r?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(t,o){var r=this;return new Promise((function(n){var s=[];s=e.isArray(t)?t:[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",s,o||""),n(e.ErrorCode.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(t,o,r){var n=this._callCppProxy("getTotalUnreadCount",o,r,t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.getConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){var i=n._callCppProxy("getUnreadCount",t,o,r);s({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.clearConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){n._callCppProxy("clearUnreadCount",t,o,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearUnreadCountByTimestamp",t,o,r,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(t,o,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),a=n._buildMessage(i);s({code:e.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},t.prototype.getFirstUnreadMessageInfo=function(t,o,r){var n=this;return new Promise((function(s,i){var a=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),c=n._buildMessage(a);s({code:e.ErrorCode.SUCCESS,data:-1!==c.messageId?{messageUId:c.messageUId,sentTime:c.sentTime}:null})}))},t.prototype.setConversationToTop=function(t,o,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setConversationToTop",t,o,r,n,!0),i(e.ErrorCode.SUCCESS)}))},t.prototype.batchSetConversationToTop=function(t,o,r){var n=this;return new Promise((function(s,i){var a=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,is_top:o}}));n._callCppProxy("setIsTopInBatches",JSON.stringify(a),r||!1),s(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationHidden=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationHidden",t,o,r,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationNotificationStatus",t,o,r,(function(){i(e.ErrorCode.SUCCESS)}),i,n)}))},t.prototype.setConversationStatus=function(t,o,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("setConversationStatus",t,o,r,n,(function(){a(e.ErrorCode.SUCCESS)}),a,s,!0)}))},t.prototype.getConversationNotificationStatus=function(t,o,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversationNotificationStatus",t,o,r);s({code:e.ErrorCode.SUCCESS,data:i?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE})}))},t.prototype.searchConversationByContent=function(t,o,r,n){var s=this;return new Promise((function(i){n=n||[1,3,6,7];for(var a=s._callCppProxy("searchConversationByContent",n,t,o,r),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=s._buildConversation(c[p].obj);i({code:e.ErrorCode.SUCCESS,data:u})}))},t.prototype.searchConversationByContentWithAllChannel=function(t,o,r){var n=this;return new Promise((function(s){r=r||[1,3,6,7];for(var i=n._callCppProxy("searchConversationByContentWithAllChannel",r,t,o),a=JSON.parse(i).list,c=[],u=0;u<a.length;u++)c[u]=n._buildConversation(a[u].obj);s({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.searchMessageByContent=function(t,o,r,n,s,i,a){var c=this;return new Promise((function(i){c._callCppProxy("searchMessageByContent",t,o,r,n,s,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],s=0;s<r.length;s++)n[s]=c._buildMessage(r[s].obj);i({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),a)}))},t.prototype.searchMessagesByUser=function(t,o,r,n,s,i){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",t,o,r,n,s,i,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=a._buildMessage(o[n].obj);c({code:e.ErrorCode.SUCCESS,data:{messages:r}})}))}))},t.prototype.searchMessageByContentWithAllChannel=function(t,o,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("searchMessageByContentWithAllChannel",t,o,r,n,s,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],s=0;s<r.length;s++)n[s]=i._buildMessage(r[s].obj);a({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(t,o,r,n,s,i,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",t,o,r,n,s,i,a,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=c._buildMessage(o[n].obj);u({code:e.ErrorCode.SUCCESS,data:{messages:r}})}))}))},t.prototype.getUnreadMentionedMessages=function(e,t,o){for(var r=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,n=0;n<r.length;n++)r[n]=this._buildMessage(r[n].obj);return r},t.prototype.addToBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addToBlacklist",t,(function(){r(e.ErrorCode.SUCCESS)}),r)}))},t.prototype.removeFromBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("removeFromBlacklist",t,(function(){r(e.ErrorCode.SUCCESS)}),r)}))},t.prototype.getBlacklist=function(){var t=this;return new Promise((function(o){t._callCppProxy("getBlacklist",(function(t){o({code:e.ErrorCode.SUCCESS,data:t})}),(function(e){o({code:e})}))}))},t.prototype.getBlacklistStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getBlacklistStatus",t,(function(t){r({code:e.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}))},t.prototype.insertMessage=function(t,o,r){var n=this,s=r.content,i=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,p=r.sentStatus,d=r.sentTime,l=r.searchContent,C=r.isUnread,h=r.messageUId,f=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,S=r.channelId;s=JSON.stringify(s);var y={};if(d=d||0,v){var _=JSON.parse(v);for(var E in _)y[E]={v:"",ts:0},y[E].v=_[E],y[E].ts=d}return new Promise((function(r){var v=C?0:1,_=n._callCppProxy("insertMessage",t,o,i,a,s,(function(){}),(function(e){r({code:e})}),c,u||0,p||10,d,l||"",v,h||"",!!f,!!g,JSON.stringify(y),S||""),E=n._buildMessage(_,{isOffLineMessage:!1});E.messageUId=h,E.sentTime=d,r({code:-1===E.messageId?e.ErrorCode.MSG_INSERT_ERROR:e.ErrorCode.SUCCESS,data:E})}))},t.prototype.batchInsertMessage=function(t,o){var r=this;return void 0===o&&(o=!1),new Promise((function(n){var s=t.map((function(e){var t=e.content,o=e.senderUserId,r=e.messageType,n=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,d=e.disableNotification,l=e.canIncludeExpansion,C=e.expansion,h=e.channelId,f=e.conversationType,g=e.targetId,v=e.source,S=e.isMentioned,y={};if(a=a||0,C)for(var _ in C)y[_]={v:"",ts:0},y[_].v=C[_],y[_].ts=a;return{conversationType:f,targetId:g,channelId:h||"",direction:n,senderUserId:o,status:i||10,sentTime:a,objectName:r,content:JSON.stringify(t),messageUid:p||"",noNotification:!!d,supportExt:!!l,extMsg:JSON.stringify(y),readStatus:s||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:S}})),i=r._callCppProxy("insertMessages",JSON.stringify(s),o);n({code:i?e.ErrorCode.SUCCESS:e.ErrorCode.MSG_INSERT_ERROR,data:i||!1})}))},t.prototype.getMessageCount=function(t,o,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getMessageCount",t,o,r);s({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.deleteMessages=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteMessages",t),r(e.ErrorCode.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(t,o,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("deleteMessagesByTimestamp",t,o,r,n,s),a(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearMessagesByTimestamp=function(t){var o=this;return new Promise((function(r,n){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));o._callCppProxy("deleteMessageBySendTimeInBatches",JSON.stringify(s)),r(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearRemoteHistoryMessages=function(t,o){var r=this;return new Promise((function(n,s){var i=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));r._callCppProxy("deleteRemoteMessageBySendTimeInBatches",JSON.stringify(i),o||!1,(function(){n(e.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getMessage",t),s=o._buildMessage(n,{isOffLineMessage:!1});r({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.setMessageContent=function(t,o,r){var n=this;return new Promise((function(s){o=JSON.stringify(o),n._callCppProxy("setMessageContent",t,o,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSearchField=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("setMessageSearchField",t,o,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSentStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageSentStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageReceivedStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("saveTextMessageDraft",t,o,r,n||"")&&i(e.ErrorCode.SUCCESS),i(e.ErrorCode.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTextMessageDraft",t,o,r||"");s({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.clearConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("clearTextMessageDraft",t,o,r||"")&&s(e.ErrorCode.SUCCESS),s(e.ErrorCode.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(t){var o=t[0],r=o.conversationType,n=o.targetId,s=o.isTop,i=o.notificationStatus,a=o.channelId,c=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),u=this._callCppProxy("getConversationTopStatus",r,n,a||""),p=e.isUndefined(i)?Boolean(c):i===e.NotificationStatus.OPEN,d=e.isUndefined(s)?Boolean(u):s;return this.setConversationStatus(r,n,p,d,a)},t.prototype.getConversationNotificationLevel=function(t,o,r){return S(this,void 0,void 0,(function(){var n;return y(this,(function(s){return n=this._callCppProxy("getBlockPushLevelForConversation",o,r,t),[2,Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})]}))}))},t.prototype.setConversationNotificationLevel=function(t,o,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setBlockPushLevelForConversation",o,n,t,r,(function(){i(e.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},t.prototype.batchSetConversationNotificationLevel=function(t,o){var r=this;return new Promise((function(n,s){var i=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,level:o}}));r._callCppProxy("setBlockPushLevelInBatches",JSON.stringify(i),(function(){n(e.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getTotalUnreadCountByLevels=function(t,o,r){if(r){var n=this._callCppProxy("getUnreadMentionedCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})}var s=this._callCppProxy("getUnreadCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:s})},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("sendReadReceipt",t,r||"",o,(function(){o.forEach((function(e){n._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(n._callCppProxy("getMessage",e)).messageId;n.setMessageReceivedStatus(t,1)}catch(t){n.logger.error(g.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),s({code:e.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},t.prototype.getMessageReader=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("getMessageReader",t,r,o,(function(t,r){var i=[],a={};(t=JSON.parse(t)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:r};n._updateReadReceiptInfo(o,c),s({code:e.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:r}})}),(function(e){s({code:e})}))}))},t.prototype.sendReadReceiptMessageV4=function(t,o,r){var n=this;return new Promise((function(s){var i=t.conversationType,a=t.targetId,c=t.channelId;n._callCppProxy("sendMessageReadReceipt",i,a,c||"",o,r,(function(){s({code:e.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},t.prototype.getMessageReadReceiptV4=function(t,o){var r=this;return new Promise((function(n){var s=t.targetId,i=t.channelId;r._callCppProxy("getMessageReadReceipt",s,i||"",o,(function(t,s,i){var a=[],c=r._callCppProxy("getMessage",o),u=JSON.parse(c);try{JSON.parse(i).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;a.push({userId:o,readTime:r})}))}catch(e){r.logger.error(g.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(i,", error: ").concat(e))}var p=JSON.parse(u.readReceiptRequest||"{}"),d=p.readerList,l=void 0===d?[]:d,C=p.readCount,h=void 0===C?0:C,f=!1;l.length<a.length&&(l=a,f=!0),h<s&&(h=s,f=!0),f&&r._callCppProxy("updateReadReceiptRequestInfo",o,JSON.stringify({readerList:l,readCount:h,totalCount:t})),n({code:e.ErrorCode.SUCCESS,data:{list:a,totalCount:t,readCount:h}})}),(function(e){n({code:e})}))}))},t.prototype.updateConversationReadTime=function(t,o){var r=this;return new Promise((function(n){var s=t.conversationType,i=t.targetId,a=t.channelId;r._callCppProxy("updateConversationReadTime",s,i,a||"",o,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var t=this;if(0!==this._chatroomCache.length){var o=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return S(t,void 0,void 0,(function(){var t,n,s,i,a,c;return y(this,(function(u){switch(u.label){case 0:return t=r.chatroomId,n=r.joinExist,s=r.count,this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_T,t,o),[4,this._joinChrm(t,s,n,!1)];case 1:return i=u.sent(),a=i.code,c=i.data,a===e.ErrorCode.SUCCESS?(this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_R,t,o),this._sendChatroomStatus({rejoinedRoom:v({chatroomId:t,count:s},c)}),[2]):(a===e.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:t,errorCode:a}}),this.logger.warn(e.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(t,", code: ").concat(a),o),[2])}}))}))}))}},t.prototype._joinChrm=function(t,o,r,n){var s=this,i=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){n&&s._callCppProxy("clearMessages",e.ConversationType.CHATROOM,t,""),s._callCppProxy(i,t,o,(function(n,i,c,u,p,d){s._addChatroomCache(t,o,r),a({code:e.ErrorCode.SUCCESS,data:{createTime:Number(n),memberCount:i,isAllChatroomBanned:c,isCurrentUserBanned:u,isCurrentChatroomBanned:p,isCurrentChatroomInWhitelist:d}})}),(function(e){a({code:e})}))}))},t.prototype.joinChatroom=function(e,t){return S(this,void 0,void 0,(function(){return y(this,(function(o){switch(o.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,o.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(t){var o=this;return this._rmChatroomCache(t),new Promise((function(r){o._callCppProxy("quitChatRoom",t,(function(){r(e.ErrorCode.SUCCESS)}),r)}))},t.prototype.getChatroomInfo=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("getChatroomInfo",t,o,r,(function(t,o){var r=t?JSON.parse(t).list:[],n=[];if(r.length>0)for(var i=0;i<r.length;i++)n.push(JSON.parse(r[i].obj));s({code:e.ErrorCode.SUCCESS,data:{userInfos:n,userCount:o}})}),(function(e){s({code:e})}))}))},t.prototype.getChatroomHistoryMessages=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getChatroomHistoryMessage",t,o,r,n,(function(t){var o;try{o=JSON.parse(t)}catch(e){o={list:[]}}var r=o.list;if(r&&r.length)try{o.list=r.map((function(e){return s._buildMessage(e.obj)}))}catch(e){o.list=[]}i({code:e.ErrorCode.SUCCESS,data:o})}),(function(e){i({code:e})}),"")}))},t.prototype.setChatroomEntry=function(t,o){var r=this;return new Promise((function(n){var s='[{"key":"'.concat(o.key,'", "value":"').concat(o.value,'"}]');r._callCppProxy("setChatroomKV",t,s,!!o.isAutoDelete,!!o.isOverwrite,(function(){n(e.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.setChatroomEntries=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",t,JSON.stringify(o.entries),!!o.isAutoDelete,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(t,o){var r=this,n=[o.key];return new Promise((function(s){r._callCppProxy("deleteChatroomKV",t,n,!!o.isOverwrite,(function(){s(e.ErrorCode.SUCCESS)}),(function(e){s(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(t,o){var r=this;return new Promise((function(n){var s=o.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",t,s,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getChatroomEntry=function(t,o){return S(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(t)];case 1:return(r=n.sent()).code===e.ErrorCode.SUCCESS?[2,{code:e.ErrorCode.SUCCESS,data:r.data?r.data[o]:null}]:[2,{code:r.code}]}}))}))},t.prototype.getAllChatroomEntry=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getChatroomKV",t,(function(t){var o={};try{(t?JSON.parse(t):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){o[e.key]=e.value?e.value:""}))}catch(e){}r({code:e.ErrorCode.SUCCESS,data:o})}),(function(e){r({code:e})}))}))},t.prototype.getFileToken=function(t,o,r,n,s){var i=this;return r=r||"",n=n||"",s=s||"",new Promise((function(a){var c;c=n&&"uploads"!==n?o||"":e.getUploadFileName(t,o),i._callCppProxy("getUploadToken",t,c,r,n,s,(function(t,o,r,n,s,i,u,p,d,l,C,h,f,g,v,S,y,_,E,m,P,T,I){a({code:e.ErrorCode.SUCCESS,data:{token:t,deadline:0,bosToken:o,bosDate:r,path:n,osskeyId:s,ossPolicy:i,ossSign:u,ossBucketName:p,fileName:c,s3Credential:d,s3Algorithm:l,s3Date:C,s3Policy:h,s3Signature:f,s3BucketName:g,stcAuthorization:v,stcContentSha256:S,stcDate:y,stcBucketName:_,minioAuthorization:E,minioContentSha256:m,minioDate:P,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),(function(e){a({code:e})}))}))},t.prototype.getFileUrl=function(t,o,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",t,r,n,o-1,(function(t){i({code:e.ErrorCode.SUCCESS,data:{downloadUrl:t}})}),(function(e){i({code:e})}))}))},t.prototype.clearData=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("clearData");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getDeviceId=function(){var e=this._dbpath;return se(e)},t.prototype.getVoIPKey=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("getVoIPKey",t,o,"",(function(t){n({code:e.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},t.prototype.bindRTCRoomForChatroom=function(t){var o=this;return new Promise((function(r){var n=t.chatRoomId,s=t.rtcRoomId;o._callCppProxy("bindRTCRoomForChatroom",n,s,(function(){r(e.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.getGroupMessageDeliverList=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("getGroupMessageDeliverList",t,r,o,(function(t,o){var r=JSON.parse(t).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));s({code:e.ErrorCode.SUCCESS,data:{totalCount:o,list:r}})}),(function(e){s({code:e})}))}))},t.prototype.getPrivateMessageDeliverTime=function(t,o){var r=this;return new Promise((function(n){var s=r._callCppProxy("getMessageDeliverTime",t);if(s)n({code:e.ErrorCode.SUCCESS,data:s});else{r._callCppProxy("getPrivateMessageDeliverList",o,t,(function(t){var o=0,r=JSON.parse(t).list;r.length>0&&(o=JSON.parse(r[0].obj).time);n({code:e.ErrorCode.SUCCESS,data:o})}),(function(e){n({code:e})}))}}))},t.prototype.rtcSignaling=function(t,o,r,n){var s=this,i=Array.prototype.slice.call(new Uint8Array(n));return new Promise((function(n){s._callCppProxy("rtcSignaling",t,o,r,i,(function(t){var o=new Uint8Array(t).buffer;n({code:e.ErrorCode.SUCCESS,buffer:o})}),(function(e){n({code:e})}),30)}))},t.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var r=e.rtcHeartbeatResolves[t];if(r){var n=r.find((function(e){return""===e.seqId}));n&&(n.seqId=o)}}),(function(t,o,r,n){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===r}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},t.prototype.rtcPing=function(e,t,o){var r=this;return new Promise((function(t){var o={resolve:t,seqId:""},n=r.rtcHeartbeatResolves[e];n?n.push(o):r.rtcHeartbeatResolves[e]=[o],r._callCppProxy("sendRTCHeartbeat",[e],30)}))},t.prototype.createTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addTag",t.tagId,t.tagName,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.removeTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteTag",t,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.updateTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("renameTag",t.tagId,t.tagName,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getTagList=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getTags"),n=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));o({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.addTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",t,JSON.stringify(o),(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",t,JSON.stringify(o),(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTagsForConversation=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("removeTagsForConversation",t.conversationType,t.targetId,t.channelId||"",o,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getConversationListByTag=function(t,o,r,n){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",t,o,r||20,n||""),c=s._convertResultList(a,(function(e){return v(v({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.getUnreadCountByTag=function(t,o){var r=this;return new Promise((function(n){var s=r._callCppProxy("getConversationUnreadCountForTag",t,o);n({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.setConversationStatusInTag=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("setConversationToTopForTag",t,o.conversationType,o.targetId,o.channelId||"",r.isTop||!1,(function(){s({code:e.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},t.prototype.getTagsForConversation=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getTagsForConversation",t.conversationType,t.targetId,t.channelId||""),s=o._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(t,o){var r=this;return new Promise((function(n){var s=e.isUndefined(o)?r._callCppProxy("getTopConversations",t):r._callCppProxy("getTopConversations",t,o),i=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}));n({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getUnreadAndMentionCount",[e.ConversationType.GROUP],"");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getOSInfo=function(){return S(this,void 0,void 0,(function(){var t;return y(this,(function(o){return t={arch:C.arch(),platform:C.platform(),type:C.type(),version:C.version(),release:C.release(),uptime:C.uptime(),cpus:C.cpus(),freemem:C.freemem(),totalmem:C.totalmem(),networkInterfaces:C.networkInterfaces()},[2,{code:e.ErrorCode.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return S(this,void 0,void 0,(function(){return y(this,(function(t){return[2,{code:e.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},t.prototype.setCallInfo=function(t,o,r){var n=this;return new Promise((function(s){n._callCppProxy("callInfoSignaling",t,o,r,(function(t,o){s({code:e.ErrorCode.SUCCESS,data:{key:t,value:o}})}),(function(e){s({code:e})}))}))},t.prototype.setProxy=function(t){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:e.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(W(t,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(Y())},t.prototype.testProxy=function(t,o){return function(t,o,r){return new Promise((function(n){var s=/^https/.test(o)?G:F;r.info(e.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:t,testHost:o}));var i=s(o,t,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){n({status:t||0,data:o})}))}));i.once("timeout",(function(){return n({status:0})})),i.once("error",(function(e){return n({status:0,data:e.stack})})),i.end()}))}(t,o,this.logger)},t.prototype.checkDuplicateMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("checkDuplicateMessage",t);r({code:e.ErrorCode.SUCCESS,data:n})}))},t}(),ge=function(e){return{sendError:function(t){e.send({type:Q.ERROR,data:{msg:t}})},sendEvent:function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];e.send({type:Q.EVENT,data:{eventName:t,data:o}})},sendResponse:function(t){e.send({type:Q.RESPONSE,data:t})},sendCallback:function(t){e.send({type:Q.CALLBACK,data:t})}}},ve=r.resolve(__dirname,"binding","electron-".concat(t.platform(),"-").concat(t.arch(),".node")),Se={addon:null},ye=ge(process).sendError;try{Se.addon=require(ve)}catch(e){console.error("error ->",ve,"\n",e),ye(e.toString())}Se.addon||console.error("error -> cannot find module: ",ve);var _e=Se.addon;!function(t){var o=this,r=t.argv.slice(2),n=r[0],s=r[1],i=r[2],a=ge(t),c=a.sendCallback,u=a.sendError,p=a.sendEvent,d=a.sendResponse,l=_e?new fe(n,_e,s,p,~~i):null;t.on("message",(function(t){return S(o,void 0,void 0,(function(){var o,r,n,s,i,a;return y(this,(function(u){switch(u.label){case 0:return o=t.reqId,r=t.method,n=t.args,s=t.hasResponse,l?s?("sendMessage"===r&&(i=n[3],n[3]=function(e){c({reqId:i,data:e})}),[4,l.callProxy.apply(l,_([r],n,!1))]):[3,2]:[2,d({reqId:o,success:!0,data:{code:e.ErrorCode.ADDON_NOT_EXIST,msg:"Cannot find module ".concat(ve)}})];case 1:return a=u.sent(),!0,d({reqId:o,success:true,data:a}),[3,3];case 2:l.sendProxy.apply(l,_([r],n,!1)),u.label=3;case 3:return[2]}}))}))})),t.on("beforeExit",(function(e){null==l||l.destroy()})),t.on("uncaughtException",(function(e){u("uncaughtException ".concat(e.stack||e.toString()))})),t.on("unhandledRejection",(function(e){u("unhandledRejection ".concat(e.stack))}))}(process);
|
|
1
|
+
"use strict";var e=require("@rongcloud/engine"),t=require("os"),o=require("child_process"),n=require("path"),r=require("http"),i=require("https"),s=require("url"),a=require("net"),c=require("events"),u=require("tls"),p=require("fs"),d=require("crypto");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var f=l(t),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},h(e,t)};function C(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var g,v=function(){return v=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},v.apply(this,arguments)};function S(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function y(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function m(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_PARSE_JSON_MSGS_R="P-parse_json_messsages-R",e.P_RECEIVE_MESSAGE_E="P-receive_message-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R",e.P_PARSE_JSON_E="P-parse_json-E"}(g||(g={}));var _,E={flushTimestamp:Date.now(),queue:[],locked:!1};function T(){_&&clearInterval(_)}function P(e,t){T(),_=setInterval((function(){return O(e,t)}),1e4)}function I(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=E.queue).push.apply(e,t)}var R=200;function O(e,t){var o=E.queue,n=E.flushTimestamp;if(!(E.locked||0===o.length||Date.now()-n<3e4&&o.length<R)){E.locked=!0;var r=t.createTraceId(),i=o.splice(0,R).map((function(e){var t=e.sessionId,o=e.level,n=e.time,r=e.type,i=e.tag,s=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:n,type:r,tag:i,content:encodeURIComponent(JSON.stringify({loggerId:s,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(g.P_WRITE_LOG_T,"writingLen: ".concat(i.length,", queueLen: ").concat(o.length),r);var s=JSON.stringify(i);e.writeLog(s),t.debug(g.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),r),E.flushTimestamp=Date.now(),E.locked=!1,setTimeout((function(){return O(e,t)}))}}var N=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return C(t,e),t.prototype.flush=function(e){I(e)},t}(e.BasicLogger),M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return C(t,e),t.prototype.flush=function(e){I(e)},t}(e.BasicStatistic),U=function(e,t){var o,n=Buffer.from(e),r=n.length;for(t.push(r),o=0;o<r;o++)t.push(n[o])},x=function(e){return"string"==typeof e},b=function(e){return x(e)?e.toUpperCase():""},w=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},L=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},A=function(e){var t=b(e.method)||"GET",o=e.pathname||"/",n=e.headers||{},r=e.search||"";n.Host=e.host||"loclahost";var i="";for(var s in i="".concat(t," ").concat(o+r," HTTP/1.1\n"),n)if(Object.hasOwnProperty.call(n,s)){var a=n[s];i+="".concat(s,": ").concat(a,"\n")}return e.body&&(i+="Content-Length: ".concat(e.body.length,"\n")),i+="\n","POST"===t&&e.body&&(i+="".concat(e.body)),i},D=function(e){return new Promise((function(t){var o,n;e.socket.once("data",(function(n){var r,i=w(n,o);if(!i)return 2===n[1]?(e.socket.once("data",(function(o){var n=L(o);n?e.emit("error",new Error("SOCKS authentication failed. ".concat(n))):t()})),r=[1],U(e.socksUsername,r),U(e.socksPassword,r),void e.write(Buffer.from(r))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(i)))})),o=[0],e.socksUsername&&o.push(2),(n=Buffer.alloc(2+o.length))[0]=5,n[1]=o.length,o.forEach((function(e,t){n[2+t]=e})),e.write(n)}))},k=function(e,t,o){return new Promise((function(n){var r,i;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):n()})),(r=[]).push(5),r.push(1),r.push(0),a.isIP(t)){case 0:r.push(3),U(t,r);break;case 4:r.push(1),function(e,t){var o,n,r=e.split(".");for(o=0;o<4;o++)n=parseInt(r[o],10),t.push(n)}(t,r);break;case 6:e.emit("error",new Error("Does not support IPV6"))}r.length+=2,(i=Buffer.from(r)).writeUInt16BE(o,i.length-2),e.write(i)}))},J=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new a.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return C(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return S(o,void 0,void 0,(function(){var o;return y(this,(function(n){switch(n.label){case 0:return[4,D(this)];case 1:return n.sent(),[4,k(this,t,e)];case 2:return n.sent(),this.onProxied(),o=A(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(c.EventEmitter),B=function(e){var t,o=e.hostname,n=e.port;return!e.host||o&&n||(t=e.host.split(":")),!n&&t&&(n=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new J(e).connect(n,o)},j=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=B,o}return C(t,e),t}(r.Agent),F=function(e,t,o){return(t=v(v({},t),s.parse(e))).port||(t.port=80),t.agent=new j(t),r.request(t,o)},V=function(e){var t,o;return t=B(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=u.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},H=function(e){function t(t,o){var n=e.call(this,o)||this;return n.url=t,n.socksHost=o.socksHost||"localhost",n.socksPort=o.socksPort||1080,n.createConnection=V,n}return C(t,e),t}(i.Agent),G=function(e,t,o,n){var r,s;return t.protocol="https:",!t.port&&t.host&&(r=t.host.split(":"),t.port=r[0],t.port=r[1]),t.port||(t.port=443),s=new H(e,t),t.agent=s,i.request(e,t,o)},q=null;function K(t,o,n){void 0===n&&(n=!1);var s=o.url,a=o.headers,c=o.body,u=o.method,p=o.query,d=o.timeout,l=void 0===d?e.HTTP_TIMEOUT:d;return new Promise((function(o){var d=/^https/.test(s),f={headers:a,method:u};d&&(f.rejectUnauthorized=n);var h=null;q?((f=v(v({},f),q)).body=c,h=d?G:F):(h=r.request,d&&(f.agent=new i.Agent(f),h=i.request));var C=h(e.appendUrl(s,p),f,(function(e){var t=e.statusCode,n="";e.setEncoding("utf8"),e.on("data",(function(e){n+=e})),e.once("end",(function(){o({status:t||0,data:n})}))}));C.once("timeout",(function(){t.warn(g.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:s,method:u,query:p,timeout:l})),o({status:0})})),C.setTimeout(l),C.once("error",(function(e){t.warn(g.P_HTTP_REQ_E,JSON.stringify({msg:e.stack,url:s,method:u,query:p,timeout:l})),o({status:0})})),C.write(c),C.end()}))}function W(t,o){return t?(q=v(v({},q),t),o.info(e.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:q})),{code:e.ErrorCode.SUCCESS}):(q=null,o.info(e.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:e.ErrorCode.SUCCESS})}function Y(){var t=q||void 0;return{code:e.ErrorCode.SUCCESS,data:t}}var Q,X=[],z=function(e){return S(void 0,void 0,void 0,(function(){return y(this,(function(t){return[2,new Promise((function(t){X.push({resolve:t,args:e}),$()}))]}))}))},Z=!1,$=function(){return S(void 0,void 0,void 0,(function(){var t,o,n,r,i,s,a,c,u,p,d;return y(this,(function(l){return Z||0===X.length||(Z=!0,t=X.shift(),o=t.args,n=t.resolve,r=o.addon,i=o.startTime,s=o.endTime,a=o.level,c=o.realtimeReport,u=0,p=0,d=[],r.setLogEventListener((function(t){u+=t.length;var o=t.split(","),r=o[0],i=o[1],s=o[2],l=o[3],f=o[4],h=o.slice(5);if(u>e.REAT_TIME_LOG_SIZE&&parseInt(i,10)!==p)n(d);else{p=parseInt(i,10);try{var C=JSON.parse(decodeURIComponent(h.join(","))),g=C.loggerId,v=C.sessionId,S=C.content,y=C.traceId;if(!c&&a<0)return;var m={time:parseInt(i,10),level:parseInt(l,10),sessionId:"".concat(r,":").concat(v),type:s,tag:f,loggerId:g,content:S,traceId:y};d.push(m)}catch(e){console.error(e)}}}),(function(e){n(d),Z=!1,$()}),(function(e,t,o){})),r.pullFullLog(a,i,s,!1)),[2]}))}))},ee=function(t){function o(o,n,r,i,s){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=t.call(this,n,r,u,{getLogs:function(e,t,n,r){return S(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return[4,z({startTime:e,endTime:t,level:n,realtimeReport:r,addon:o})];case 1:return[2,{logs:i.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var t=o.getStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(t,10)||0},setTimestamp4RealtimeLog:function(t){o.setStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP,t.toString())}},i)||this).subProcess=s,a}return C(o,t),o.prototype.send=function(e){return K(this.logger,e)},o.prototype.compressLogs=function(e){return S(this,void 0,void 0,(function(){var t,o,n;return y(this,(function(r){switch(r.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=r.sent(),o=t.success,n=t.data,o?[2,{success:o,data:n.data}]:[2,{success:o,data:""}]}}))}))},o}(e.BasicReporter),te=[e.EConnectProtocol.RMTP,e.EConnectProtocol.TLS,e.EConnectProtocol.QUIC],oe={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},ne=null,re=function(){var e,o=Date.now(),n=[t.arch(),t.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=n,d.createHash("md5").update(e).digest("hex")},ie=function(e){if(ne)return ne;var t=n.resolve(e,oe.DEVICE_ID);return p.existsSync(t)?ne=p.readFileSync(t).toString():(ne=re(),p.writeFileSync(t,ne),ne)},se=function(){function e(e){this._callCppProxy=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,n,r,i){var s=JSON.stringify(r);"{}"!==s&&e.info(g.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:n,ext:r})),this._callCppProxy("setMessageExtension",t,o,n,s,i)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,n=t.conversationType,r=t.targetId,i=t.messageUId,s=t.expansion,a=t.sentTime,c={};for(var u in s)c[u]={v:"",ts:0},c[u].v=s[u],c[u].ts=a;this._setToProtocol(e,n,r,i,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,n=t.conversationType,r=t.targetId,i=t.content,s=t.sentTime,a=i,c=a.put,u=this._callCppProxy("getMessage",a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var f=d[l];f&&f.ts<s-this._setTime?(f.v=c[l],f.ts=s-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=s-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,n,r,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}();!function(e){e[e.ERROR=-1]="ERROR",e[e.RESPONSE=0]="RESPONSE",e[e.EVENT=1]="EVENT",e[e.CALLBACK=2]="CALLBACK"}(Q||(Q={}));var ae,ce=function(){function t(t,o,n,r){var i=this;this.p=t,this.emit=o,this.callback=n,this.errorHandle=r,this.count=0,this.maps={},this.p.on("message",(function(e){var t=e.type,s=e.data;switch(t){case Q.EVENT:var a=s,c=a.eventName,u=a.data;null==o||o.apply(void 0,m([c],u,!1));break;case Q.RESPONSE:var p=s,d=p.reqId,l=p.success,f=p.data,h=i.maps[d];if(!h)return;h({success:l,data:f}),delete i.maps[d];break;case Q.CALLBACK:var C=s,g=(d=C.reqId,C.data);null==n||n(d,g);break;case Q.ERROR:var v=s.msg;null==r||r(v)}})),this.p.on("error",(function(e){null==r||r("SubProcessProxy error ".concat(e))})),this.p.on("exit",(function(t,o){if(0!==t){for(var n in i.maps){if(Object.prototype.hasOwnProperty.call(i.maps,n))(0,i.maps[n])({success:!0,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})}null==r||r("SubProcessProxy exit ".concat(t," ").concat(o),!0)}})),this.p.on("close",(function(e,t){console.log("SubProcessProxy close",e,t)}))}return t.prototype.call=function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return S(this,void 0,void 0,(function(){var n=this;return y(this,(function(r){return this.p.killed||this.p.exitCode?[2,Promise.resolve({success:!1,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})]:[2,new Promise((function(e){var r=++n.count;n.maps[r]=e;var i={reqId:r,method:t,args:o,hasResponse:!0};n.p.send(i)}))]}))}))},t.prototype.send=function(e){for(var t,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return S(this,void 0,void 0,(function(){var n;return y(this,(function(r){return(this.p.killed||this.p.exitCode)&&(null===(t=this.errorHandle)||void 0===t||t.call(this,"sub process exit")),n={reqId:-1,method:e,args:o},this.p.send(n),[2]}))}))},t.prototype.destroy=function(){this.send("destroy")},t}(),ue=function(e,t,o){return S(void 0,void 0,void 0,(function(){var n,r;return y(this,(function(i){return n=d.createDecipheriv("aes-256-cbc",t,o),r=n.update(e,"base64","utf-8"),[2,r+=n.final("utf8")]}))}))},pe=function(e){if(!p.existsSync(e)){var t=n.resolve(e,"..");p.existsSync(t)||pe(t),p.mkdirSync(e)}},de=function(t){function o(e,o,r,i,s){var a=t.call(this,e,o,r,s)||this;a.naviPath="",a._caches={},a.naviPath="".concat(i,"/").concat(oe.NAVI(e));var c=n.dirname(a.naviPath);return p.existsSync(c)||pe(c),a}return C(o,t),o.prototype.httpRequest=function(t,o,n,r){return S(this,void 0,void 0,(function(){var i,s,a,c,u;return y(this,(function(p){switch(p.label){case 0:return i="token=".concat(encodeURIComponent(n),"&v=").concat(e.FORMATED_VERSION,"&p=PC&ev=").concat("5.9.2"),s="".concat(t,"/navi.json?r=").concat(Date.now()),this.logger.debug(e.LogTagId.L_REQUEST_T,JSON.stringify({url:s,body:i}),r),[4,K(this.logger,{method:"POST",headers:{appId:o},body:i,url:s,timeout:e.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=p.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s,code:a.status}),r),[2,{code:this.transHttpCode(a.status)}];try{return c=JSON.parse(a.data),u=/^https/.test(s)?"https":"http",c.protocol=u,[2,{code:e.ErrorCode.SUCCESS,data:c}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,a.data,r),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.httpRequestV2=function(t,o,n,r){return S(this,void 0,void 0,(function(){var i,s,a,c;return y(this,(function(u){switch(u.label){case 0:return i=this.getNaviV2RequestOption({appkey:o,token:n,uri:t,platform:"electron",protocol:te.join(",")}),this.logger.debug(e.LogTagId.L_REQUEST_T,JSON.stringify({url:i.url,body:i.body,headers:i.headers}),r),[4,K(this.logger,i)];case 1:if(200!==(s=u.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i.url,code:s.status}),r),[2,{code:this.transHttpCode(s.status)}];try{return a=JSON.parse(s.data),c=/^https/.test(i.url)?"https":"http",a.protocol=c,[2,{code:e.ErrorCode.SUCCESS,data:a}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,s.data,r),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.getNaviCache=function(t){var o=this._caches[t];if(o)return o;if(!p.existsSync(this.naviPath))return null;var n=p.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[t]}catch(t){this.logger.error(e.LogTagId.L_PARSE_NAVI_E,n)}return null},o.prototype.setNaviCache=function(t,o){var n=Date.now();if(e.notEmptyObject(this._caches))for(var r in this._caches){var i=this._caches[r];(n-i.timestamp>e.NAVI_CACHE_DURATION||t===i.token)&&delete this._caches[r]}this._caches[t]={token:t,naviInfo:o,timestamp:Date.now()},p.writeFileSync(this.naviPath,JSON.stringify(this._caches))},o}(e.BasicNavi);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}(ae||(ae={}));var le=function(t){function o(o,n,r,i,s,a){var c=t.call(this,o,r,i,s,a)||this;return c.callCppProxy=n,c._connectedTime=0,c._naviInfo=null,c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.callCppProxy("setConnectionStatusListener",c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(g.P_DB_OPEN_O,e)}),(function(){return c.recvPong(e.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c)),c}return C(o,t),o.prototype.getConnectedTime=function(){return this._connectedTime},o.prototype.connectWithToken=function(t,o,n,r){var i=this;return new Promise((function(s){i._naviInfo=o,i.connectResolve={resolve:s,traceId:r,userId:o.userId};var a={},c=Y().data;c&&(a={proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0});var u=JSON.stringify(v(v({},a),{call_plus:i._openCallPlus})),p=i.getCmpList(o,!0).filter((function(e){return te.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),d=[];p.forEach((function(t){var o=d.find((function(e){return e.addr===t.addr}));o?o.protocol!==e.EConnectProtocol.QUIC&&t.protocol!==e.EConnectProtocol.QUIC||(o.race=!0,o.protocol=e.EConnectProtocol.QUIC):(t.race=!1,d.push(t))})),i.logger.info(g.P_CONNECT_O,JSON.stringify({use:d,catche:i.cmpWeightCache,proxy:a,FORMATED_VERSION:e.FORMATED_VERSION,reconnectKickEnable:n}),r),i._startTime=Date.now();try{i.callCppProxy("connectWithToken",t,e.FORMATED_VERSION,JSON.stringify(v(v({},o),{serverAddr:d})),n,u)}catch(t){i.logger.error(g.P_CALL_ADDON_E,null==t?void 0:t.stack,r),i.recvConnectRes(e.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},o.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.callCppProxy("disconnect",t)},o.prototype.sendPing=function(t){var o=this;return new Promise((function(n){o.pingResolve=n,o.callCppProxy("sendHeartbeat"),setTimeout((function(){return o.recvPong(e.ErrorCode.TIMEOUT)}),t)}))},o.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},o.prototype._onConnectionStatusChange=function(t,o){switch(this.logger.info(g.P_CONNECT_S,JSON.stringify({status:t,delay:o})),t){case e.ErrorCode.SUCCESS:this.recvConnectRes(e.ErrorCode.SUCCESS);break;case e.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(e.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case e.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(t,!1);break;case e.ErrorCode.RC_SOCKET_NOT_CREATED:case e.ErrorCode.RC_CONN_ACK_TIMEOUT:case e.ErrorCode.RC_TCP_RESET:this.recvConnectRes(t);break;case e.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(t,!0,o);break;default:this.recvConnectRes(t,!0)}},o.prototype.recvConnectRes=function(t,o,n){if(this.connectResolve){var r=this.connectResolve,i=r.resolve,s=r.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:e.getbundleId(),cod:t,net:this.getNetwork().type,dur:a,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:e.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.record(e.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),t===e.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.callCppProxy("getDeltaTime")),i({code:t,data:s}),void(this.connectResolve=null)}if(o)this.onDisconnectByServer(t,n);else{if(t===e.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(t)}},o.prototype._onTcpConnectResponse=function(t,o,n,r,i,s,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(o,":").concat(n)})),p={bid:e.getbundleId(),ptc:e.ProtocalType.TCP,cod:t,net:this.getNetwork().type,dur:r,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:"".concat(o,":").concat(n),idx:u,rct:this.retryCount?e.ConnectType.RECONNECT:e.ConnectType.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:e.StatisticsVersion.CURRENT,rsn:this.reason,ddu:i,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};this.statisticLog.record(e.StatisticsTag.IM_CMP,JSON.stringify(p)),this.logger.info(g.P_CONNECT_ENTRY_S,JSON.stringify({code:t,host:o,port:n,duration:r,dnsDuration:i,index:s,isQuic:a})),t===ae.SUCCESS&&(this.curCmpUrl="".concat(o,":").concat(n),this.updateCmpWeight("".concat(o,":").concat(n),!0,a))},o}(e.AConnectionMgr),fe=function(t){function o(e,o,r){var i=t.call(this,e,o)||this;i.appkey=e,i.logger=o,i.dbpath=r,i._cachePath="",i._cachePath="".concat(r,"/").concat(oe.STATIC_CONFIG(e));var s=n.dirname(i._cachePath);return p.existsSync(s)||pe(s),i}return C(o,t),o.prototype.getCache=function(){return p.existsSync(this._cachePath)&&p.readFileSync(this._cachePath,{encoding:"utf8"})||null},o.prototype.setCache=function(e){p.writeFileSync(this._cachePath,e)},o.prototype.clearCache=function(){p.writeFileSync(this._cachePath,"")},o.prototype.sendRequest=function(e){return S(this,void 0,void 0,(function(){var t,o,n;return y(this,(function(r){switch(r.label){case 0:return[4,K(this.logger,{url:e,body:""})];case 1:return t=r.sent(),o=t.status,n=t.data,[2,{code:o,data:n}]}}))}))},o.prototype.decryptData=function(t){return S(this,void 0,void 0,(function(){var o,n;return y(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ue(t,e.STATIC_CONFIG_KEY,e.STATIC_CONFIG_IV)];case 1:return o=r.sent(),[2,JSON.parse(o)];case 2:return n=r.sent(),this.logger.error(e.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==n?void 0:n.stack})),[3,3];case 3:return[2]}}))}))},o}(e.BasicStaticConfigManager),he=function(t){function o(e,o,r,i,s,a){var c=t.call(this,o,e,r,a)||this;c.deviceId=i,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(s,"/").concat(oe.CLOUD_CONTROL(e));var u=n.dirname(c.catchFilePath);return p.existsSync(u)||pe(u),c.init(),c}return C(o,t),o.prototype.httpRequest=function(t,o,n,r){return S(this,void 0,void 0,(function(){var i,s,a,c,u,p,d,l;return y(this,(function(f){switch(f.label){case 0:return(i=r).deviceId=this.deviceId,i.model=this.model,s={url:t,method:o,headers:n,body:JSON.stringify(i)},this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify(s)),[4,K(this.logger,s)];case 1:a=f.sent(),c=a.status,u=a.data,p=void 0===u?"":u,this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:p}));try{return d=JSON.parse(p),l=d.data,[2,{code:c,data:l}]}catch(t){return this.logger.warn(e.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:p,error:t})),[2,{code:c,msg:t}]}return[2]}}))}))},o.prototype.setCloudControllerCache=function(t){p.writeFileSync(this.catchFilePath,JSON.stringify(t)),this.logger.info(e.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(t))},o.prototype.getLocalCloudControllerCache=function(){if(!p.existsSync(this.catchFilePath))return null;var t=p.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(e.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:t})),t},o}(e.BaseCloudController),Ce=function(){function t(t,r,i,s,a){this._appkey=t,this._cppProtocol=r,this._dbpath=i,this._dispatchEvent=s,this._logOutputLevel=a,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._chatroomCache=[],this.rtcHeartbeatResolves={};var c=this._dbpath,u=ie(c);this._cppProtocol.initWithAppkey(t,c,e.FORMATED_VERSION);var p=o.fork(n.resolve(__dirname,"sub-process.js"));this.subProxy=new ce(p);var d=n.resolve(c,"RongCloud/rclogs",t);pe(d),function(t,o,n){n.initLogModule(o,t,e.getUUID())}(t,d,this._cppProtocol),this.logger=new N(this._appkey,"RC-M","IM"),this.statisticLog=new M(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),P(this._cppProtocol,this.logger),this.reporter=new ee(this._cppProtocol,t,u,this.logger,this.subProxy),this.logger.info(g.P_INIT_O,JSON.stringify({appkey:t,dbpath:c,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:u,commit:"3642406a95558c12f7bc383b69fdc713927f4100"})),this._callCppProxy("setDeviceId",u),this._staticConfigManager=new fe(t,this.logger,c),this.navi=new de(t,this.logger,this.statisticLog,c,this._staticConfigManager),this.tcpMgr=new le(t,this._callCppProxy.bind(this),this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(u,c),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),this._msgExpansionHandler=new se(this._callCppProxy.bind(this))}return t.prototype._initCloudController=function(t,o){var n=e.urlCenter.getCloudControllerUrl();this.cloudControllerUri=n[0],this.cloudController=new he(this._appkey,this.logger,this.reporter,t,o,this.statisticLog),e.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,e.InvokerType.init)},t.prototype.callProxy=function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return S(this,void 0,void 0,(function(){var n,r,i;return y(this,(function(s){switch(s.label){case 0:if(!(n=this[t]))return this.logger.warn(g.P_CALL_MAIN_E,JSON.stringify({method:t,error:"not found"})),[2,Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})];r="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,n.call.apply(n,m([this],o,!1))];case 2:return[2,s.sent()];case 3:return i=s.sent(),r=JSON.stringify({error:null==i?void 0:i.stack,method:t}),this.logger.error(g.P_CALL_MAIN_E,r),[3,4];case 4:return[2,{code:e.ErrorCode.MAIN_PROCESS_ERROR,msg:r}]}}))}))},t.prototype.sendProxy=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return S(this,void 0,void 0,(function(){var o;return y(this,(function(n){if(!(o=this[e]))return this.logger.warn(g.P_CALL_MAIN_E,JSON.stringify({method:e,error:"not found"})),[2];try{o.call.apply(o,m([this],t,!1))}catch(t){this.logger.error(g.P_CALL_MAIN_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return[2]}))}))},t.prototype.registerRenderers=function(t){var o=t.navigators,n=t.areaCode,r=t.logServerUrl;e.urlCenter.init({areaCode:n,navigators:o,logServerUrl:r})},t.prototype.onConnected=function(){return S(this,void 0,void 0,(function(){var e,t,o;return y(this,(function(n){switch(n.label){case 0:return e=this.getNaviInfoFromCache(),this.reporter.checkStart(e),this._try2RejoinChatroom(),t=this._dispatchEvent,o=["onConnected"],[4,this.getMainProcessCache()];case 1:return t.apply(this,o.concat([n.sent()])),[2]}}))}))},t.prototype.onConnecting=function(){this._dispatchEvent("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._dispatchEvent("onSuspend",e)},t.prototype.onDisconnected=function(e){this._dispatchEvent("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var r=this.logger.createTraceId();try{return this.logger.debug(g.P_CALL_ADDON_O,JSON.stringify({method:e,content:o}),r),(t=this._cppProtocol)[e].apply(t,o)}catch(t){throw this.logger.error(g.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r),t}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return K(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){I.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(t,o){if(this.tcpMgr.setNetwork(t,o),t.status&&e.isStartCloudController()&&this.cloudController){var n=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,e.InvokerType.newWorkChange,n)}},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){T(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy(),process.exit(0)},t.prototype.callExtra=function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var r=this[t];if(!r)return this.logger.warn(g.P_CALL_EXTRA_E,JSON.stringify({method:t,error:"not found"})),Promise.resolve({code:e.ErrorCode.NOT_SUPPORT});try{return r.call.apply(r,m([this],o,!1))}catch(e){this.logger.error(g.P_CALL_EXTRA_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(t,o,n,r){var i,s=this,a=this._callCppProxy("getConversationListByPage",t,o,n,r||"");try{i=JSON.parse(a).list.map((function(e){return s._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.getUnreadConversationList=function(t){var o,n=this,r=this._callCppProxy("getUnreadConversationList",t);try{o=JSON.parse(r).list.map((function(e){return n._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.getConversationListWithAllChannel=function(){var t,o=this,n=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],r=this._callCppProxy("getConversationListWithAllChannel",n);try{t=JSON.parse(r).list.map((function(e){return o._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannelByPage=function(t,o){var n,r=this,i=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,t,o);try{n=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.getHistoryMessagesByObjectNames=function(t,o,n,r,i,s,a){var c=0===s,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",t,o,n,u,i,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);d[f]=h}}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:r<d.length}})},t.prototype.updateMessageReceiptStatus=function(t,o,n,r){void 0===r&&(r="");var i=this._callCppProxy("updateMessageReceiptStatus",t,o,n,r);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new N(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),n=this.tcpMgr.getCurrentUserId(),r=this.getDeviceId(),i=this._cppProtocol.getDeltaTime();return Promise.resolve({connectedTime:e,deviceId:r,crtUserId:n,naviInfo:o,connectionStatus:t,deltaTime:i})},t.prototype._registerMsgTypes=function(){for(var t in e.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},e.SEND_MESSAGE_TYPE_OPTION){var o=e.SEND_MESSAGE_TYPE_OPTION[t],n=o.isCounted,r=o.isPersited,i=o.searchProps,s=0;r&&(s|=1),n&&(s|=2),"RC:TypSts"===t&&(s=16),this._callCppProxy("registerMessageType",t,s,i||[])}},t.prototype._buildIsMentioned=function(t,o){var n,r=!1;if(e.isObject(t))n=t;else try{n=t?JSON.parse(t):t}catch(e){n=t,this.logger.error(g.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:o}))}return e.isObject(n)&&(r=!!n.mentionedInfo),{isMentioned:r,msgContent:n}},t.prototype._buildMsgOption=function(t){var o={isCounted:!1,isPersited:!1};return t in e.SEND_MESSAGE_TYPE_OPTION?o=e.SEND_MESSAGE_TYPE_OPTION[t]:t in this._customMessageType&&(o=this._customMessageType[t]),o},t.prototype._buildSupportExt=function(e,t,o){var n=null;return e&&(n=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(n=this._msgExpansionHandler.parseConverOrHisExpansion(o))),n},t.prototype._buildMessage=function(t,o){void 0===o&&(o={});var n=o.isOffLineMessage,r=o.buildFrom,i=JSON.parse(t),s=i.channelId,a=i.conversationType,c=i.targetId,u=i.senderUserId,p=i.content,d=i.objectName,l=i.messageUid,f=i.direction,h=i.status,C=i.messageId,g=i.sentTime,S=i.readReceiptRequest,y=i.supportExt,m=i.pushContent,_=i.pushTitle,E=i.pushId,T=i.pushConfig,P=i.templateId,I=i.disableTitle,R=i.forcePushDetail,O=i.hasMore,N=this._buildIsMentioned(p,C),M=N.isMentioned,U=N.msgContent,x=this._buildMsgOption(d),b=this._buildSupportExt(y,r,i),w=e.isUndefined(n)?g<this.tcpMgr.getConnectedTime():n,L={};T&&(L=e.pushJSONToConfigs(this.logger,T,E));var A=v(v({},L),{pushTitle:_,pushContent:m,pushData:m,disablePushTitle:I,forceShowDetailContent:R,templateId:P}),D={channelId:s,conversationType:a,targetId:c,senderUserId:u,content:U||{},messageType:d,messageUId:l||"",messageDirection:f,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:x.isPersited,isCounted:x.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?b:null,receivedStatus:h,messageId:C,pushConfig:A,hasMore:O};if(f===e.MessageDirection.RECEIVE?D.receivedStatus=h:f===e.MessageDirection.SEND&&(D.sentStatus=h),S){var k=JSON.parse(S),J=k.hasRespond,B=k.readerInfo,j=void 0===B?{}:B,F=k.readCount,V=k.totalCount,H=k.readerList,G=void 0===H?[]:H,q={readCount:F,totalCount:V},K=this.getNaviInfoFromCache();if(1===(null==K?void 0:K.grpRRVer)){var W=[];for(var Y in j)W.push({userId:Y,readTime:j[Y]});q.readerList=W,q.hasRespond=J}3===(null==K?void 0:K.grpRRVer)&&(q.readerList=G),D.readReceiptInfo=q}return D},t.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},i=v(v({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},t.prototype._processRSMsg=function(t){var o=t.conversationType,n=t.targetId,r=t.content,i=t.channelId,s=r.msgId,a=r.rrn,c=r.tmn,u=r.endMsgTime;o===e.ConversationType.PRIVATE?this.updateMessageReceiptStatus(o,n,u,i||""):this._updateReadReceiptInfo(s,{readCount:a,totalCount:c});var p={conversationType:o,targetId:n,channelId:i};this._sendMessageReadReceipt(o===e.ConversationType.PRIVATE?{privateReadReceipt:v(v({},p),{endMsgTime:r.endMsgTime})}:{groupReadReceipt:v(v({},p),{totalCount:r.tmn,readedCount:r.rrn,messageUId:r.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,n=e.targetId,r=e.content,i=e.channelId,s=e.senderUserId,a=e.sentTime;return s===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,n,r.lastMessageSendTime,i||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:n,channelId:i,timestamp:r.lastMessageSendTime}),!1))},t.prototype._buildConversation=function(t){var o=JSON.parse(t),n=o.channelId,r=o.conversationType,i=o.targetId,s=o.unreadCount,a=o.lastestMsg,c=o.isTop,u=o.blockStatus,p=o.matchCount,d=o.hasUnreadMention,l=o.conversationTime,f=o.draft,h=u>0?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:p,operationTime:l,notificationLevel:u,draft:f}},t.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},t.prototype._setOnReceiveMessageListener=function(){var t=this;this._cppProtocol.setOnReceiveMessageListener((function(o,n,r,i){var s;try{var a=t._buildMessage(o,{isOffLineMessage:r}),c=a.messageType,u=a.channelId,p=void 0===u?"":u,d=a.senderUserId,l=a.content,f=(a.canIncludeExpansion,a.messageUId,a.conversationType),h=a.targetId;t.getNaviInfoFromCache();if(c===e.MessageType.LOG_COMMAND&&a.senderUserId===e.RC_DEFAULT_USER){var C=a.content,v=C.startTime,S=C.endTime,y=C.platform,m=C.logId,_=C.uri;return void t.reporter.report(parseInt(v,10),parseInt(S,10),y,_,m,a.messageUId)}if(c===e.MessageType.CLOUD_CONTROL&&d===e.RC_DEFAULT_USER)return t.cloudControllerMsgs.push(a),void t._ccMsgHandler();if(c===e.MessageType.GROUP_READ_RECEIPT_REQUEST){var E=l.msgId,T=l.rrn,P=l.tmn;t._updateReadReceiptInfo(E,{readCount:T,totalCount:P})}if(c===e.MessageType.READ_STATE)return void t._processRSMsg(a);if("RC:MsgExMsg"===c)return t._msgExpansionHandler.setLocalFromExtMsg(t.logger,a),void t._sendMessageExpansion(a);if(a.canIncludeExpansion&&t._msgExpansionHandler.setLocalFromReceiveMsg(t.logger,a),c===e.MessageType.READ_RECEIPT&&d===t.tcpMgr.getCurrentUserId()&&t._callCppProxy("clearUnreadCountByTimestamp",f,h,l.lastMessageSendTime,p),c===e.MessageType.SYNC_READ_STATUS&&!t._processSRSMsg(a))return;var I=!0;if(0!==n||i||(I=!1),c===e.MessageType.DELIVERED)return t._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void t._sendMessageDelivered(a.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c===e.MessageType.DELIVERED_MSG){var R={totalCount:a.content.tmn,list:null===(s=a.content.dl)||void 0===s?void 0:s.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};return void t._sendGroupMessageDeliveredStatus(R)}if(c===e.MessageType.RECALL){if(!t.handleRecalledMessage(a))return;var O=t._fixRecallContentInfo(a);f=O.conversationType,h=O.targetId}t._sendMessageNotification(Object.assign(a,{hasMoreMsg:I,conversationType:f,targetId:h}))}catch(e){t.logger.error(g.P_RECEIVE_MESSAGE_E,JSON.stringify({error:null==e?void 0:e.stack,message:o}))}}),(function(){t._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var t;return S(this,void 0,void 0,(function(){var o,n;return y(this,(function(r){switch(r.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(o=this.tcpMgr.getToken(),[4,null===(t=this.cloudController)||void 0===t?void 0:t.request(this.cloudControllerUri,e.InvokerType.other,o)]):[3,2]):[2];case 1:n=r.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>n})),this.cloudControllerLock=!0,this._ccMsgHandler(),r.label=2;case 2:return[2]}}))}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},t.prototype.handleRecalledMessage=function(t){var o=t.content,n=o.messageUId,r=o.sentTime;if(!n)return!0;var i=this._callCppProxy("getMessage",n),s=this._buildMessage(i,{isOffLineMessage:!1});if(t.content.isDelete)return-1===s.messageId||this._callCppProxy("deleteMessages",[s.messageId]),!0;if(s.messageType===e.MessageType.RECALL_NOTIFICATION_MESSAGE)return!1;var a={recallTime:Date.now(),admin:!!t.content.isAdmin,originalObjectName:s.messageType,originalMessageContent:s.content,recallActionTime:t.sentTime,operatorId:t.senderUserId};if(t.content.user&&(a.user=t.content.user),t.content.extra&&(a.extra=t.content.extra),s.messageType===e.MessageType.TextMessage&&(a.recallContent=s.content.content),-1===s.messageId){var c=t.conversationType,u=t.targetId,p=t.senderUserId,d=t.channelId,l=t.messageDirection;return this._callCppProxy("insertMessage",c,u,p,e.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,10,r,"",0,n,!1,!0,JSON.stringify({}),d||""),!0}return s.receivedStatus||this.setMessageReceivedStatus(s.messageId,1),this._callCppProxy("setMessageContent",s.messageId,JSON.stringify(a),e.MessageType.RECALL_NOTIFICATION_MESSAGE),!0},t.prototype._sendMessageExpansion=function(e){var t=e.channelId,o=void 0===t?"":t,n=e.content,r=e.conversationType,i=e.targetId,s=n,a=s.put,c=s.del,u=s.mid,p={};a&&(p.updatedExpansion={channelId:o,messageUId:u,expansion:a,conversationType:r,targetId:i}),c&&(p.deletedExpansion={channelId:o,messageUId:u,deletedKeys:c,conversationType:r,targetId:i}),this._dispatchEvent("expansion",p)},t.prototype._sendMessageNotification=function(e){this._dispatchEvent("batchMessage",e)},t.prototype._sendPullOfflineFinished=function(){this._dispatchEvent("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._dispatchEvent("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._dispatchEvent("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._dispatchEvent("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._dispatchEvent("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._dispatchEvent("syncReadStatus",e)},t.prototype._setConversationStatusListener=function(){var t=this;this._cppProtocol.setConversationStatusListener((function(o){var n=JSON.parse(o).list,r=[];n.forEach((function(t){var o=JSON.parse(t.obj),n=o.conversationType,i=o.targetId,s=o.status,a=o.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(t){var o=JSON.parse(t.item);1===o.type?c.notificationStatus=1===Number(o.value)?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE:c.isTop=1===Number(o.value)})),r.push({channelId:a,conversationType:n,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),t._dispatchEvent("conversation",r)}),(function(e){t._dispatchEvent("conversationTag",e)}),(function(e,o,n,r){t._callCppProxy("clearUnreadCountByTimestamp",e,o,r,n||""),t._sendsyncReadStatus({conversationType:e,targetId:o,channelId:n,timestamp:r})}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._dispatchEvent("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._dispatchEvent("onNaviDataChange",o)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._dispatchEvent("onRTCDataChange",o)}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._dispatchEvent("callInfo",t)}))},t.prototype._updateMentionedInfo=function(t,o,n){var r,i,s;return{userIdList:(null===(r=t.mentionedInfo)||void 0===r?void 0:r.userIdList)||o,type:(null===(i=t.mentionedInfo)||void 0===i?void 0:i.type)||n||e.MentionedType.ALL,mentionedContent:(null===(s=t.mentionedInfo)||void 0===s?void 0:s.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,o,n){void 0===n&&(n=[]);var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(g.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:n})),this._callCppProxy("registerMessageType",e,r,n)},t.prototype.connect=function(e,t,o,n){return this.tcpMgr.connect(e,t,o,n)},t.prototype.reportSDKInfo=function(e){var t=JSON.stringify(v(v({},e),{"electron-main":"5.9.2"}));this.logger.info(g.P_REPORT_VER_O,t),this._callCppProxy("uploadSDKVersion",t,"")},t.prototype.disconnect=function(e){e=e||!0,this._chatroomCache.length=0,this.reporter.stop(),W(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},t.prototype.subscribeUserStatus=function(t){var o=this;return new Promise((function(n){o._callCppProxy("subscribeUserStatus",t,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.setUserStatus=function(t){var o=this;return new Promise((function(n){o._callCppProxy("setUserStatus",t,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getUserStatus=function(t){var o=this;return new Promise((function(n){o._callCppProxy("getUserStatus",t,(function(t){setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:{status:t}})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.sendMessage=function(t,o,n,r,i){var s=this;void 0===i&&(i=this.logger.createTraceId());var a=n.messageType,c=n.content,u=n.expansion,p=n.pushConfig,d=n.isMentioned,l=n.mentionedType,f=n.mentionedUserIdList,h=void 0===f?[]:f,C=n.pushContent,v=void 0===C?"":C,S=n.pushData,y=void 0===S?"":S,m=n.directionalUserIdList,_=void 0===m?[]:m,E=n.disableNotification,T=void 0!==E&&E,P=n.canIncludeExpansion,I=void 0!==P&&P,R=n.isVoipPush,O=void 0!==R&&R,N=n.channelId,M=void 0===N?"":N,U=n.messageId,x=void 0===U?0:U,b=p||{},w=b.iOSConfig,L=b.androidConfig,A=b.templateId,D=void 0===A?"":A,k=b.pushTitle,J=void 0===k?"":k,B=b.pushContent,j=void 0===B?v:B,F=b.pushData,V=void 0===F?y:F,H=b.disablePushTitle,G=void 0!==H&&H,q=b.forceShowDetailContent,K=void 0!==q&&q,W=e.pushConfigsToJSON(w,L);return new Promise((function(n){v=j,y=V;var p=(null==L?void 0:L.notificationId)||"";t===e.ConversationType.GROUP&&d&&c&&(c.mentionedInfo=s._updateMentionedInfo(c,h,l));var f=t===e.ConversationType.GROUP;if(f&&a===e.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var C in c.receiptMessageDic)_.push(C);f&&a===e.MessageType.SYNC_READ_STATUS&&(_=[s.getCurrentUserId()]);var S={};for(var C in u)S[C]={v:""},S[C].v=u[C];var m=D;s.logger.info(g.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:t,targetId:o,channelId:M}),i);var E=s._callCppProxy("sendMessage",(function(t,o){var r=s._buildMessage(t,{isOffLineMessage:!1});if(s.logger.info(g.P_SEND_MSG_R,JSON.stringify({code:o,messageUId:r.messageUId}),i),o===e.ErrorCode.SENSITIVE_REPLACE)return setTimeout((function(){n({code:o})}),0);"RC:MsgExMsg"===r.messageType&&s._msgExpansionHandler.setLocalFromExtMsg(s.logger,r),r.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(s.logger,r),setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:r})}),0)}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});s.logger.warn(g.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),i),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),setTimeout((function(){n({code:t,data:o})}),0)}),t,o,a,JSON.stringify(c),_,T,G,K,v,y,p,J,W,m,I,JSON.stringify(S),O,M,x),P=JSON.parse(E);null==r||r(P.messageId)}))},t.prototype.recallMsg=function(t,o,n,r,i){var s=this;return new Promise((function(a){var c,u=i.user,p=i.pushContent,d=i.channelId,l=i.extra,f=i.pushConfig,h=i.disableNotification,C=i.isDelete,g={conversationType:t,targetId:o,messageUId:n,sentTime:r,user:u,extra:l,channelId:d,isDelete:C||!1};u&&(g.user=u),l&&(g.extra=l);var v={conversationType:t,targetId:o,senderUserId:s.tcpMgr.getCurrentUserId(),content:g,objectName:e.MessageType.RECALL,messageUid:n,direction:e.MessageDirection.SEND,status:e.ReceivedStatus.UNREAD,sentTime:r,channelId:d},S=s._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(S),setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:S})}),0)}),(function(e){setTimeout((function(){a({code:e})}),0)}),e.MessageType.RECALL,JSON.stringify(g),h||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,p||"",(null==f?void 0:f.pushData)||"",(null===(c=null==f?void 0:f.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==f?void 0:f.pushTitle)||"",e.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig),(null==f?void 0:f.templateId)||"",d)}))},t.prototype.getHistoryMessage=function(t,o,n,r,i,s,a){var c=this;return new Promise((function(u){n=n||0;var p=0===i,d=r+1,l=c._callCppProxy("getHistoryMessages",t,o,n,d,a,p,s),f=JSON.parse(l).list,h=[];f.reverse();for(var C=0;C<f.length;C++){var g=c._buildMessage(f[C].obj);h[C]=g}u({code:e.ErrorCode.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:r<h.length}})}))},t.prototype.getMessages=function(t,o,n,r,i,s){var a=this;return void 0===n&&(n=0),new Promise((function(c){var u=0===i,p=n,d=0!==n,l=r+1;d&&(p+=u?1:-1,l++);for(var f=a._callCppProxy("getMessages",t,o,p,l,u,s),h=JSON.parse(f).list,C=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);C[g]=v}var S=a._computeRepairInfo(C,u,n,p,l),y=S.isNeedRepair,m=void 0!==y&&y,_=S.repairTime,E=void 0===_?0:_;if(!m)return d&&(C.shift(),l--),C.reverse(),void c({code:e.ErrorCode.SUCCESS,data:{list:l===C.length?C.slice(1,l):C,hasMore:r<C.length}});a._processRepairHisMsg(t,o,n,r,i,s,E,c)}))},t.prototype._computeRepairInfo=function(e,t,o,n,r){var i=!1,s=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:i,repairTime:s};var d=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&d>=0?(i=!0,s=e[d].hasMore?e[d].sentTime:e[d].sentTime+1):!t&&d>=1?(i=!0,s=e[d-1].sentTime):0===o?(i=!0,s=0):e.length<r?(i=!0,s=o):e.length>0&&e[0].sentTime!==o&&(i=!0,s=n),{isNeedRepair:i,repairTime:s}},t.prototype._processRepairHisMsg=function(e,t,o,n,r,i,s,a){var c=this,u=function(s){for(var u=0===r,p=n+1,d=c._callCppProxy("getMessages",e,t,o,p,u,i),l=JSON.parse(d).list,f=[],h=0;h<l.length;h++){var C=c._buildMessage(l[h].obj);f[h]=C}f.reverse(),a({code:s,data:{list:p<=f.length?f.slice(1,p):f,hasMore:n<f.length}})},p=n+10>100?100:n+10;this._callCppProxy("getRemoteHistoryMessages",e,t,s,p,(function(){return u(0)}),(function(e){u(e)}),r,!0,i,!1)},t.prototype.getRemoteHistoryMessages=function(t,o,n,r,i,s){var a=this;return new Promise((function(c){n=n||0;a._callCppProxy("getRemoteHistoryMessages",t,o,n,r,(function(t,o){var n=JSON.parse(t).list,r=[];n.reverse();for(var i=0;i<n.length;i++){var s=a._buildMessage(n[i].obj);r[i]=s}setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{list:r,hasMore:!!o}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}),i,!0,s,!0)}))},t.prototype.deleteRemoteMessage=function(t,o,n,r){var i=this;return new Promise((function(s){var a=JSON.stringify(n);i._callCppProxy("deleteRemoteHistoryMessages",t,o,a,!1,r,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("clearRemoteHistoryMessages",t,o,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),r)}))},t.prototype.clearMessages=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("clearMessages",t,o,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.getConversationList=function(t,o,n,r,i){var s=this;return void 0===i&&(i=""),new Promise((function(t){for(var o=s._callCppProxy("getConversationList",[1,3,6,7],i),n=JSON.parse(o).list,r=[],a=0;a<n.length;a++)r.push(s._buildConversation(n[a].obj));t({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getConversation=function(t,o,n){var r=this;return new Promise((function(i){var s=r._callCppProxy("getConversation",t,o,n);if(s)i({code:e.ErrorCode.SUCCESS,data:r._buildConversation(s)});else{var a=r._callCppProxy("getHistoryMessages",t,o,0,1,"",!0,n),c=void 0;try{c=JSON.parse(a).list}catch(e){r.logger.error(g.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),c=[]}var u=null;c.length>0&&(u=r._buildMessage(c[0].obj));var p=r._callCppProxy("getConversationNotificationStatus",t,o,n),d=r._callCppProxy("getConversationTopStatus",t,o,n);i({code:e.ErrorCode.SUCCESS,data:{conversationType:t,targetId:o,channelId:n,unreadMessageCount:0,latestMessage:u,notificationStatus:p?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(t,o,n){var r=this._callCppProxy("removeConversation",t,o,n);return Promise.resolve(r?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.batchRemoveConversation=function(t){var o=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId}})),n=this._callCppProxy("removeConversationInBatches",JSON.stringify(o));return Promise.resolve(n?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(t,o){var n=this;return new Promise((function(r){var i=[];i=e.isArray(t)?t:[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,o||""),r(e.ErrorCode.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(t,o,n){var r=this._callCppProxy("getTotalUnreadCount",o,n,t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},t.prototype.getConversationUnreadCount=function(t,o,n){var r=this;return void 0===n&&(n=""),new Promise((function(i){var s=r._callCppProxy("getUnreadCount",t,o,n);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(t,o,n){var r=this;return void 0===n&&(n=""),new Promise((function(i){r._callCppProxy("clearUnreadCount",t,o,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("clearUnreadCountByTimestamp",t,o,n,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(t,o,n){var r=this;return new Promise((function(i){var s=r._callCppProxy("getTheFirstUnreadMessage",t,o,n),a=r._buildMessage(s);i({code:e.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},t.prototype.getFirstUnreadMessageInfo=function(t,o,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getTheFirstUnreadMessage",t,o,n),c=r._buildMessage(a);i({code:e.ErrorCode.SUCCESS,data:-1!==c.messageId?{messageUId:c.messageUId,sentTime:c.sentTime}:null})}))},t.prototype.setConversationToTop=function(t,o,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(s){i._callCppProxy("setConversationToTop",t,o,n,r,!0),s(e.ErrorCode.SUCCESS)}))},t.prototype.batchSetConversationToTop=function(t,o,n){var r=this;return new Promise((function(i,s){var a=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,is_top:o}}));r._callCppProxy("setIsTopInBatches",JSON.stringify(a),n||!1),i(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationHidden=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("setConversationHidden",t,o,n,r),s(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("setConversationNotificationStatus",t,o,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),r)}))},t.prototype.setConversationStatus=function(t,o,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy("setConversationStatus",t,o,n,r,(function(){setTimeout((function(){a(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){a(e)}),0)}),i,!0)}))},t.prototype.getConversationNotificationStatus=function(t,o,n){var r=this;return new Promise((function(i){var s=r._callCppProxy("getConversationNotificationStatus",t,o,n);i({code:e.ErrorCode.SUCCESS,data:s?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE})}))},t.prototype.searchConversationByContent=function(t,o,n,r){var i=this;return new Promise((function(s){r=r||[1,3,6,7];for(var a=i._callCppProxy("searchConversationByContent",r,t,o,n),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=i._buildConversation(c[p].obj);s({code:e.ErrorCode.SUCCESS,data:u})}))},t.prototype.searchConversationByContentWithAllChannel=function(t,o,n){var r=this;return new Promise((function(i){n=n||[1,3,6,7];for(var s=r._callCppProxy("searchConversationByContentWithAllChannel",n,t,o),a=JSON.parse(s).list,c=[],u=0;u<a.length;u++)c[u]=r._buildConversation(a[u].obj);i({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.searchMessageByContent=function(t,o,n,r,i,s,a){var c=this;return new Promise((function(s){c._callCppProxy("searchMessageByContent",t,o,n,r,i,1,(function(t,o){for(var n=t?JSON.parse(t).list:[],r=[],i=0;i<n.length;i++)r[i]=c._buildMessage(n[i].obj);setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{messages:r,count:o}})}),0)}),a)}))},t.prototype.searchMessagesByUser=function(t,o,n,r,i,s){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",t,o,n,r,i,s,(function(t){for(var o=t?JSON.parse(t).list:[],n=[],r=0;r<o.length;r++)n[r]=a._buildMessage(o[r].obj);setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{messages:n}})}),0)}))}))},t.prototype.searchMessageByContentWithAllChannel=function(t,o,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy("searchMessageByContentWithAllChannel",t,o,n,r,i,1,(function(t,o){for(var n=t?JSON.parse(t).list:[],r=[],i=0;i<n.length;i++)r[i]=s._buildMessage(n[i].obj);setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:{messages:r,count:o}})}),0)}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(t,o,n,r,i,s,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",t,o,n,r,i,s,a,(function(t){for(var o=t?JSON.parse(t).list:[],n=[],r=0;r<o.length;r++)n[r]=c._buildMessage(o[r].obj);setTimeout((function(){u({code:e.ErrorCode.SUCCESS,data:{messages:n}})}),0)}))}))},t.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},t.prototype.addToBlacklist=function(t){var o=this;return new Promise((function(n){o._callCppProxy("addToBlacklist",t,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.removeFromBlacklist=function(t){var o=this;return new Promise((function(n){o._callCppProxy("removeFromBlacklist",t,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getBlacklist=function(){var t=this;return new Promise((function(o){t._callCppProxy("getBlacklist",(function(t){setTimeout((function(){o({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){o({code:e})}),0)}))}))},t.prototype.getBlacklistStatus=function(t){var o=this;return new Promise((function(n){o._callCppProxy("getBlacklistStatus",t,(function(t){setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.insertMessage=function(t,o,n){var r=this,i=n.content,s=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,d=n.sentTime,l=n.searchContent,f=n.isUnread,h=n.messageUId,C=n.disableNotification,g=n.canIncludeExpansion,v=n.expansionMsg,S=n.channelId;i=JSON.stringify(i);var y={};if(d=d||0,v){var m=JSON.parse(v);for(var _ in m)y[_]={v:"",ts:0},y[_].v=m[_],y[_].ts=d}return new Promise((function(n){var v=f?0:1,m=r._callCppProxy("insertMessage",t,o,s,a,i,(function(){}),(function(e){setTimeout((function(){n({code:e})}),0)}),c,u||0,p||10,d,l||"",v,h||"",!!C,!!g,JSON.stringify(y),S||""),_=r._buildMessage(m,{isOffLineMessage:!1});_.messageUId=h,_.sentTime=d,n({code:-1===_.messageId?e.ErrorCode.MSG_INSERT_ERROR:e.ErrorCode.SUCCESS,data:_})}))},t.prototype.batchInsertMessage=function(t,o){var n=this;return void 0===o&&(o=!1),new Promise((function(r){var i=t.map((function(e){var t=e.content,o=e.senderUserId,n=e.messageType,r=e.messageDirection,i=e.receivedStatus,s=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,d=e.disableNotification,l=e.canIncludeExpansion,f=e.expansion,h=e.channelId,C=e.conversationType,g=e.targetId,v=e.source,S=e.isMentioned,y={};if(a=a||0,f)for(var m in f)y[m]={v:"",ts:0},y[m].v=f[m],y[m].ts=a;return{conversationType:C,targetId:g,channelId:h||"",direction:r,senderUserId:o,status:s||10,sentTime:a,objectName:n,content:JSON.stringify(t),messageUid:p||"",noNotification:!!d,supportExt:!!l,extMsg:JSON.stringify(y),readStatus:i||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:S}})),s=n._callCppProxy("insertMessages",JSON.stringify(i),o);r({code:s?e.ErrorCode.SUCCESS:e.ErrorCode.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(t,o,n){var r=this;return new Promise((function(i){var s=r._callCppProxy("getMessageCount",t,o,n);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(t){var o=this;return new Promise((function(n){o._callCppProxy("deleteMessages",t),n(e.ErrorCode.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(t,o,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy("deleteMessagesByTimestamp",t,o,n,r,i),a(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearMessagesByTimestamp=function(t){var o=this;return new Promise((function(n,r){var i=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));o._callCppProxy("deleteMessageBySendTimeInBatches",JSON.stringify(i)),n(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearRemoteHistoryMessages=function(t,o){var n=this;return new Promise((function(r,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));n._callCppProxy("deleteRemoteMessageBySendTimeInBatches",JSON.stringify(s),o||!1,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getMessage=function(t){var o=this;return new Promise((function(n){var r=o._callCppProxy("getMessage",t),i=o._buildMessage(r,{isOffLineMessage:!1});n({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setMessageContent=function(t,o,n){var r=this;return new Promise((function(i){o=JSON.stringify(o),r._callCppProxy("setMessageContent",t,o,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSearchField=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("setMessageSearchField",t,o,n),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSentStatus=function(t,o){var n=this;return new Promise((function(r){n._callCppProxy("setMessageSentStatus",t,o),r(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(t,o){var n=this;return new Promise((function(r){n._callCppProxy("setMessageReceivedStatus",t,o),r(e.ErrorCode.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("saveTextMessageDraft",t,o,n,r||"")&&s(e.ErrorCode.SUCCESS),s(e.ErrorCode.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(t,o,n){var r=this;return new Promise((function(i){var s=r._callCppProxy("getTextMessageDraft",t,o,n||"");i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationMessageDraft=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("clearTextMessageDraft",t,o,n||"")&&i(e.ErrorCode.SUCCESS),i(e.ErrorCode.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(t){var o=t[0],n=o.conversationType,r=o.targetId,i=o.isTop,s=o.notificationStatus,a=o.channelId,c=this._callCppProxy("getConversationNotificationStatus",n,r,a||""),u=this._callCppProxy("getConversationTopStatus",n,r,a||""),p=e.isUndefined(s)?Boolean(c):s===e.NotificationStatus.OPEN,d=e.isUndefined(i)?Boolean(u):i;return this.setConversationStatus(n,r,p,d,a)},t.prototype.getConversationNotificationLevel=function(t,o,n){return S(this,void 0,void 0,(function(){var r;return y(this,(function(i){return r=this._callCppProxy("getBlockPushLevelForConversation",o,n,t),[2,Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})]}))}))},t.prototype.setConversationNotificationLevel=function(t,o,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(s){i._callCppProxy("setBlockPushLevelForConversation",o,r,t,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}))}))},t.prototype.batchSetConversationNotificationLevel=function(t,o){var n=this;return new Promise((function(r,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,level:o}}));n._callCppProxy("setBlockPushLevelInBatches",JSON.stringify(s),(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getTotalUnreadCountByLevels=function(t,o,n){if(n){var r=this._callCppProxy("getUnreadMentionedCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})}var i=this._callCppProxy("getUnreadCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("sendReadReceipt",t,n||"",o,(function(){o.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r.logger.error(g.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReader=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("getMessageReader",t,n,o,(function(t,n){var s=[],a={};(t=JSON.parse(t)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;s.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:s.length,totalCount:n};r._updateReadReceiptInfo(o,c),setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:n}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.sendReadReceiptMessageV4=function(t,o,n){var r=this;return new Promise((function(i){var s=t.conversationType,a=t.targetId,c=t.channelId;r._callCppProxy("sendMessageReadReceipt",s,a,c||"",o,n,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReadReceiptV4=function(t,o){var n=this;return new Promise((function(r){var i=t.targetId,s=t.channelId;n._callCppProxy("getMessageReadReceipt",i,s||"",o,(function(t,i,s){var a=[],c=n._callCppProxy("getMessage",o),u=JSON.parse(c);try{JSON.parse(s).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;a.push({userId:o,readTime:n})}))}catch(e){n.logger.error(g.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(s,", error: ").concat(e))}var p=JSON.parse(u.readReceiptRequest||"{}"),d=p.readerList,l=void 0===d?[]:d,f=p.readCount,h=void 0===f?0:f,C=!1;l.length<a.length&&(l=a,C=!0),h<i&&(h=i,C=!0),C&&n._callCppProxy("updateReadReceiptRequestInfo",o,JSON.stringify({readerList:l,readCount:h,totalCount:t})),setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:{list:a,totalCount:t,readCount:h}})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.updateConversationReadTime=function(t,o){var n=this;return new Promise((function(r){var i=t.conversationType,s=t.targetId,a=t.channelId;n._callCppProxy("updateConversationReadTime",i,s,a||"",o,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var t=this;if(0!==this._chatroomCache.length){var o=this.logger.createTraceId();this._chatroomCache.forEach((function(n){return S(t,void 0,void 0,(function(){var t,r,i,s,a,c;return y(this,(function(u){switch(u.label){case 0:return t=n.chatroomId,r=n.joinExist,i=n.count,this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_T,t,o),[4,this._joinChrm(t,i,r,!1)];case 1:return s=u.sent(),a=s.code,c=s.data,a===e.ErrorCode.SUCCESS?(this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_R,t,o),this._sendChatroomStatus({rejoinedRoom:v({chatroomId:t,count:i},c)}),[2]):(a===e.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:t,errorCode:a}}),this.logger.warn(e.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(t,", code: ").concat(a),o),[2])}}))}))}))}},t.prototype._joinChrm=function(t,o,n,r){var i=this,s=n?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){r&&i._callCppProxy("clearMessages",e.ConversationType.CHATROOM,t,""),i._callCppProxy(s,t,o,(function(r,s,c,u,p,d){i._addChatroomCache(t,o,n),setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:{createTime:Number(r),memberCount:s,isAllChatroomBanned:c,isCurrentUserBanned:u,isCurrentChatroomBanned:p,isCurrentChatroomInWhitelist:d}})}),0)}),(function(e){setTimeout((function(){a({code:e})}),0)}))}))},t.prototype.joinChatroom=function(e,t){return S(this,void 0,void 0,(function(){return y(this,(function(o){switch(o.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,o.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(t){var o=this;return this._rmChatroomCache(t),new Promise((function(n){o._callCppProxy("quitChatRoom",t,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getChatroomInfo=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("getChatroomInfo",t,o,n,(function(t,o){var n=t?JSON.parse(t).list:[],r=[];if(n.length>0)for(var s=0;s<n.length;s++)r.push(JSON.parse(n[s].obj));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{userInfos:r,userCount:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getChatroomHistoryMessages=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("getChatroomHistoryMessage",t,o,n,r,(function(t){var o;try{o=JSON.parse(t)}catch(e){o={list:[],hasMore:!1}}var n=o.list;if(n&&n.length)try{o.list=n.map((function(e){return i._buildMessage(e.obj)}))}catch(e){o.list=[]}setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}),"")}))},t.prototype.setChatroomEntry=function(t,o){var n=this;return new Promise((function(r){var i='[{"key":"'.concat(o.key,'", "value":"').concat(o.value,'"}]');n._callCppProxy("setChatroomKV",t,i,!!o.isAutoDelete,!!o.isOverwrite,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.setChatroomEntries=function(t,o){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",t,JSON.stringify(o.entries),!!o.isAutoDelete,!!o.isOverwrite,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(t,o){var n=this,r=[o.key];return new Promise((function(i){n._callCppProxy("deleteChatroomKV",t,r,!!o.isOverwrite,(function(){i(e.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(t,o){var n=this;return new Promise((function(r){var i=o.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",t,i,!!o.isOverwrite,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getChatroomEntry=function(t,o){return S(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(t)];case 1:return(n=r.sent()).code===e.ErrorCode.SUCCESS?[2,{code:e.ErrorCode.SUCCESS,data:n.data?n.data[o]:null}]:[2,{code:n.code}]}}))}))},t.prototype.getAllChatroomEntry=function(t){var o=this;return new Promise((function(n){o._callCppProxy("getChatroomKV",t,(function(t){var o={};try{(t?JSON.parse(t):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){o[e.key]=e.value?e.value:""}))}catch(e){}setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.getFileToken=function(t,o,n,r,i){var s=this;return n=n||"",r=r||"",i=i||"",new Promise((function(a){var c;c=r&&"uploads"!==r?o||"":e.getUploadFileName(t,o),s._callCppProxy("getUploadToken",t,c,n,r,i,(function(t,o,n,r,i,s,u,p,d,l,f,h,C,g,v,S,y,m,_,E,T,P,I){setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:{token:t,deadline:0,bosToken:o,bosDate:n,path:r,osskeyId:i,ossPolicy:s,ossSign:u,ossBucketName:p,fileName:c,s3Credential:d,s3Algorithm:l,s3Date:f,s3Policy:h,s3Signature:C,s3BucketName:g,stcAuthorization:v,stcContentSha256:S,stcDate:y,stcBucketName:m,minioAuthorization:_,minioContentSha256:E,minioDate:T,minioBucketName:P,downloadAuthInfo:I?JSON.parse(I):null}})}),0)}),(function(e){setTimeout((function(){a({code:e})}),0)}))}))},t.prototype.getFileUrl=function(t,o,n,r){var i=this;return new Promise((function(s){i._callCppProxy("getDownloadUrl",t,n,r,o-1,(function(t){setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{downloadUrl:t}})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}))}))},t.prototype.clearData=function(){var t=this;return new Promise((function(o){var n=t._callCppProxy("clearData");o({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.getDeviceId=function(){var e=this._dbpath;return ie(e)},t.prototype.getVoIPKey=function(t,o){var n=this;return new Promise((function(r){n._callCppProxy("getVoIPKey",t,o,"",(function(t){setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.bindRTCRoomForChatroom=function(t){var o=this;return new Promise((function(n){var r=t.chatRoomId,i=t.rtcRoomId;o._callCppProxy("bindRTCRoomForChatroom",r,i,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getGroupMessageDeliverList=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("getGroupMessageDeliverList",t,n,o,(function(t,o){var n=JSON.parse(t).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{totalCount:o,list:n}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getPrivateMessageDeliverTime=function(t,o){var n=this;return new Promise((function(r){var i=n._callCppProxy("getMessageDeliverTime",t);if(i)r({code:e.ErrorCode.SUCCESS,data:i});else{n._callCppProxy("getPrivateMessageDeliverList",o,t,(function(t){var o=0,n=JSON.parse(t).list;if(n.length>0){var i=JSON.parse(n[0].obj).time;o=i}setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}}))},t.prototype.rtcSignaling=function(t,o,n,r){var i=this,s=Array.prototype.slice.call(new Uint8Array(r));return new Promise((function(r){i._callCppProxy("rtcSignaling",t,o,n,s,(function(t){var o=new Uint8Array(t).buffer;r({code:e.ErrorCode.SUCCESS,buffer:o})}),(function(e){r({code:e})}),30)}))},t.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var n=e.rtcHeartbeatResolves[t];if(n){var r=n.find((function(e){return""===e.seqId}));r&&(r.seqId=o)}}),(function(t,o,n,r){var i=e.rtcHeartbeatResolves[t];if(i){var s=i.findIndex((function(e){return e.seqId===n}));-1!==s&&i.splice(s,1)[0].resolve({code:o,data:{version:Number(r)}})}}))},t.prototype.rtcPing=function(e,t,o){var n=this;return new Promise((function(t){var o={resolve:t,seqId:""},r=n.rtcHeartbeatResolves[e];r?r.push(o):n.rtcHeartbeatResolves[e]=[o],n._callCppProxy("sendRTCHeartbeat",[e],30)}))},t.prototype.createTag=function(t){var o=this;return new Promise((function(n){o._callCppProxy("addTag",t.tagId,t.tagName,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.removeTag=function(t){var o=this;return new Promise((function(n){o._callCppProxy("deleteTag",t,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.updateTag=function(t){var o=this;return new Promise((function(n){o._callCppProxy("renameTag",t.tagId,t.tagName,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.getTagList=function(){var t=this;return new Promise((function(o){var n=t._callCppProxy("getTags"),r=t._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.addTagForConversations=function(t,o){var n=this;return new Promise((function(r){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeTagForConversations=function(t,o){var n=this;return new Promise((function(r){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeTagsForConversation=function(t,o){var n=this;return new Promise((function(r){n._callCppProxy("removeTagsForConversation",t.conversationType,t.targetId,t.channelId||"",o,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.getConversationListByTag=function(t,o,n,r){var i=this;return new Promise((function(s){var a=i._callCppProxy("getConversationsForTagByPage",t,o,n||20,r||""),c=i._convertResultList(a,(function(e){return v(v({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.getUnreadCountByTag=function(t,o){var n=this;return new Promise((function(r){var i=n._callCppProxy("getConversationUnreadCountForTag",t,o);r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setConversationStatusInTag=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("setConversationToTopForTag",t,o.conversationType,o.targetId,o.channelId||"",n.isTop||!1,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getTagsForConversation=function(t){var o=this;return new Promise((function(n){var r=o._callCppProxy("getTagsForConversation",t.conversationType,t.targetId,t.channelId||""),i=o._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(t,o){var n=this;return new Promise((function(r){var i=e.isUndefined(o)?n._callCppProxy("getTopConversations",t):n._callCppProxy("getTopConversations",t,o),s=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}));r({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){var t=this;return new Promise((function(o){var n=t._callCppProxy("getUnreadAndMentionCount",[e.ConversationType.GROUP],"");o({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.getOSInfo=function(){return S(this,void 0,void 0,(function(){var t;return y(this,(function(o){return t={arch:f.arch(),platform:f.platform(),type:f.type(),version:f.version(),release:f.release(),uptime:f.uptime(),cpus:f.cpus(),freemem:f.freemem(),totalmem:f.totalmem(),networkInterfaces:f.networkInterfaces()},[2,{code:e.ErrorCode.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return S(this,void 0,void 0,(function(){return y(this,(function(t){return[2,{code:e.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},t.prototype.setCallInfo=function(t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("callInfoSignaling",t,o,n,(function(t,o){setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{key:t,value:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.setProxy=function(t){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:e.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(W(t,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(Y())},t.prototype.testProxy=function(t,o){return function(t,o,n){return new Promise((function(r){var i=/^https/.test(o)?G:F;n.info(e.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:t,testHost:o}));var s=i(o,t,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){r({status:t||0,data:o})}))}));s.once("timeout",(function(){return r({status:0})})),s.once("error",(function(e){return r({status:0,data:e.stack})})),s.end()}))}(t,o,this.logger)},t.prototype.checkDuplicateMessage=function(t){var o=this;return new Promise((function(n){var r=o._callCppProxy("checkDuplicateMessage",t);n({code:e.ErrorCode.SUCCESS,data:r})}))},t}(),ge=function(e){return{sendError:function(t){e.send({type:Q.ERROR,data:{msg:t}})},sendEvent:function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];e.send({type:Q.EVENT,data:{eventName:t,data:o}})},sendResponse:function(t){e.send({type:Q.RESPONSE,data:t})},sendCallback:function(t){e.send({type:Q.CALLBACK,data:t})}}},ve=n.resolve(__dirname,"binding","electron-".concat(t.platform(),"-").concat(t.arch(),".node")),Se={addon:null},ye=ge(process).sendError;try{Se.addon=require(ve)}catch(e){console.error("error ->",ve,"\n",e),ye(e.toString())}Se.addon||console.error("error -> cannot find module: ",ve);var me=Se.addon;!function(t){var o=this,n=t.argv.slice(2),r=n[0],i=n[1],s=n[2],a=ge(t),c=a.sendCallback,u=a.sendError,p=a.sendEvent,d=a.sendResponse,l=me?new Ce(r,me,i,p,~~s):null;t.on("message",(function(t){return S(o,void 0,void 0,(function(){var o,n,r,i,s,a;return y(this,(function(u){switch(u.label){case 0:return o=t.reqId,n=t.method,r=t.args,i=t.hasResponse,l?i?("sendMessage"===n&&(s=r[3],r[3]=function(e){c({reqId:s,data:e})}),[4,l.callProxy.apply(l,m([n],r,!1))]):[3,2]:[2,d({reqId:o,success:!0,data:{code:e.ErrorCode.ADDON_NOT_EXIST,msg:"Cannot find module ".concat(ve)}})];case 1:return a=u.sent(),!0,d({reqId:o,success:true,data:a}),[3,3];case 2:l.sendProxy.apply(l,m([n],r,!1)),u.label=3;case 3:return[2]}}))}))})),t.on("beforeExit",(function(e){null==l||l.destroy()})),t.on("uncaughtException",(function(e){u("uncaughtException ".concat(e.stack||e.toString()))})),t.on("unhandledRejection",(function(e){u("unhandledRejection ".concat(e.stack))}))}(process);
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"types": "index.d.ts",
|
|
16
16
|
"module": "index.esm.js",
|
|
17
|
-
"version": "5.9.
|
|
17
|
+
"version": "5.9.2",
|
|
18
18
|
"author": "pass-web@rongcloud.cn",
|
|
19
19
|
"license": "LGPL 2.1",
|
|
20
20
|
"homepage": "https://www.rongcloud.cn",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"globals": "RCMain"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@rongcloud/engine": "=5.9.
|
|
28
|
+
"@rongcloud/engine": "=5.9.2"
|
|
29
29
|
}
|
|
30
30
|
}
|