!function(){var e=["MESSAGES"];function t(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(u){return void n(u)}a.done?t(c):Promise.resolve(c).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise((function(i,o){var s=e.apply(n,r);function a(e){t(s,i,o,a,c,"next",e)}function c(e){t(s,i,o,a,c,"throw",e)}a(void 0)}))}}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(c){a=!0,i=c}finally{try{s||null==n.return||n.return()}finally{if(a)throw i}}return o}(e,t)||E(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||E(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=u(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},c.apply(this,arguments)}function u(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=m(e)););return e}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function h(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=m(e);if(t){var i=m(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return f(this,n)}}function f(e,t){if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var n=0;n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function E(e,t){if(e){if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n._title_22t18_9{font-size:18px;font-weight:400}.el-message-box{border-color:transparent;background-color:var(--live-main-color)}.el-message-box__header{background-color:var(--live-backound-color);color:var(--live-color)}.el-message-box__title,.el-message-box__container,.el-message-box__headerbtn .el-message-box__close{color:var(--live-color)}._action-bar_1akc3_1{box-sizing:border-box;height:var(--action-bar-height);padding:14px 22px;display:flex;align-items:center;justify-content:space-between}._action-bar_1akc3_1 button{overflow:hidden}._bar-btn_1akc3_12{display:flex;flex-direction:column;align-items:center;color:var(--live-color);font-size:14px}._bar-btn_1akc3_12 ._bar-btn-text_1akc3_19{padding-top:6px;line-height:20px}._bar-btn_1akc3_12+._bar-btn_1akc3_12{margin-left:25px}.el-dialog{margin-bottom:10vh}.el-dialog .el-dialog__header{background:var(--live-main-color);padding:15px 20px}.el-dialog .el-dialog__header .el-dialog__title,.el-dialog .el-dialog__header .el-dialog__headerbtn .el-dialog__close{color:#fff}.el-dropdown__popper.el-popper{border-color:var(--live-main-color)!important}.el-dropdown__popper.el-popper[role=tooltip] .el-popper__arrow:before{border-color:var(--live-main-color);background-color:var(--live-main-color)}.el-slider{--el-slider-height: 2px;--el-slider-button-size: 14px;--el-slider-button-wrapper-offset: -17px;--el-slider-main-bg-color: var(--live-text-color)}.el-slider__button{border-color:var(--live-color);background-color:var(--live-text-color)}.el-dropdown-menu{background-color:var(--live-main-color);color:var(--live-color);border-radius:2px}.el-dropdown-menu .el-dropdown-menu__item{color:inherit}.el-dropdown-menu .is-disabled{opacity:.5}.el-dropdown-menu .el-dropdown-menu__item:not(.is-disabled):focus{background-color:var(--live-main-color);color:var(--live-color)}._volumeSlider_1akc3_71{display:flex;align-items:center;padding:0 12px;width:195px;height:55px;background-color:var(--live-main-color);border-color:var(--live-main-color)}._volumeSlider_1akc3_71 ._volumeIcon_1akc3_80{width:14px;height:15px;padding-right:8px}._btnInner_1akc3_85{display:flex;align-items:center;justify-content:center;width:60px;height:32px;background:rgba(94,98,109,.33);border-radius:16px}._shareWrap_d61fv_1{background:#f9f9f9;padding:16px}._shareWrap_d61fv_1 h2{font-size:18px;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#333;line-height:25px;margin-bottom:18px}._shareWrap_d61fv_1 h4{font-size:16px;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#333;line-height:28px}._shareWrap_d61fv_1 p{font-size:16px;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#333;line-height:30px}._shareBtn_d61fv_27{height:48px;background:var(--el-color-primary);border-radius:32px;width:192px;color:#fff;margin:24px auto 0;text-align:center;line-height:48px;font-size:20px;cursor:pointer}._shareWrap_ap100_1{background-color:#f9f9f9;padding:15px}._chioseBox_ap100_5 .el-checkbox__inner{width:20px;height:20px;border-radius:50%}._chioseBox_ap100_5 .el-checkbox__inner:after{height:8px;left:6px;position:absolute;top:3px;width:4px}._cell_ap100_17{height:63px;background:#ffffff;padding:10px 18px;display:flex;flex-direction:row;align-items:center;cursor:pointer;margin-bottom:10px}._dotle_ap100_27{width:42px;height:43px;background:var(--el-color-primary);border-radius:4px;line-height:42px;text-align:center;color:#fff;margin-left:17px;font-size:14px}._teamInfo_ap100_38{font-size:14px;margin-left:8px}._teamInfo_ap100_38 ._title_ap100_42{font-weight:500;color:#1a1a1a;line-height:22px}._teamInfo_ap100_38 ._subInfo_ap100_47{color:#666;line-height:22px}._tableWrap_ap100_51{max-height:500px;overflow-y:scroll}._third_z0wkr_1{position:relative;background:linear-gradient(135deg,#8d8cff 0%,#9664ec 100%);padding:43px 20px 54px}._third_z0wkr_1 h2{width:254px;font-size:30px;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:40px;text-shadow:0px 2px 4px #9366ee}._third_z0wkr_1 ._preCore_z0wkr_15 ._title_z0wkr_15{background:#fa912c}._second_z0wkr_18{position:relative;background:linear-gradient(135deg,#ff9d9d 0%,#ff6d6d 100%);padding:43px 20px 54px}._second_z0wkr_18 h2{width:254px;font-size:30px;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:40px;text-shadow:0px 2px 4px #ff5f5f}._second_z0wkr_18 ._preCore_z0wkr_15 ._title_z0wkr_15{background:#fa502c}._first_z0wkr_35{position:relative;background:linear-gradient(135deg,#4f8dff 0%,#0055ee 100%);padding:43px 20px 54px}._first_z0wkr_35 h2{width:254px;font-size:30px;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:40px;text-shadow:0px 2px 4px #1054f1}._icon_z0wkr_49{width:231px;height:223px;position:absolute;right:3px;top:8px}._teacher_z0wkr_56{font-size:16px!important;font-family:PingFangSC-Medium,PingFang SC!important;font-weight:500!important;color:#fff!important;line-height:20px!important;margin-top:15px!important;margin-bottom:67px!important}._preCore_z0wkr_15{position:relative;z-index:100;padding:12px;background:#ffffff;border-radius:11px;border-image:linear-gradient(180deg,#ffffff,#ffffff) 1 1}._preCore_z0wkr_15 ._start_z0wkr_73{width:50px;height:59px;position:absolute;top:24px;right:-11px}._preCore_z0wkr_15 ._title_z0wkr_15{width:85px;background:#faab2c;border-radius:7px;padding:2px;font-size:18px;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:25px;text-align:center}._preCore_z0wkr_15 ._time_z0wkr_92{font-size:18px;font-family:PingFangSC-Medium,PingFang SC;font-weight:600;color:#000;line-height:25px;margin:15px 0 15px 4px}._preCore_z0wkr_15 ._content_z0wkr_101{margin-top:20px;position:relative;background:linear-gradient(49deg,#fff8e2 0%,#fff1d5 100%);border-radius:8px;padding:20px;font-size:14px;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#000;line-height:25px;margin-bottom:12px}._preCore_z0wkr_15 ._content_z0wkr_101 ._pre_z0wkr_15{width:20px;height:20px;position:absolute;left:-3px;top:-4px}._preCore_z0wkr_15 ._content_z0wkr_101 ._end_z0wkr_121{width:20px;height:20px;position:absolute;bottom:-4px;right:10px}._bottom_z0wkr_128{display:flex;flex-direction:row;justify-content:space-between;margin:30px 8px 0}._bottom_z0wkr_128 ._logo_z0wkr_134{width:202px;height:84px}._bottom_z0wkr_128 ._code_z0wkr_138{padding:2px;width:80px;height:80px;background-color:#fff}._container_19awp_1{position:absolute;top:50%;left:50%;display:flex;background-color:var(--tips-backound-color);color:var(--live-color);border-radius:8px;transform:translate(-50%,-50%)}._container_19awp_1>div{padding:32px 100px;text-align:center;width:360px;box-sizing:border-box}._container_19awp_1>div svg{width:74px;height:68px}._container_19awp_1>div ._title_19awp_21{font-size:20px;margin-top:15px}._container_19awp_1>div ._tips_19awp_25{font-size:14px;color:var(--tips-color);margin-top:5px}._main_1b4ip_1{--header-height: 68px;--action-bar-height: 88px;width:calc(100% - 385px);background-color:var(--live-backound-color);color:var(--live-color);display:flex;flex-direction:column;height:calc(100vh - var(--header-bar-height));overflow:hidden}._main_1b4ip_1 ._video_1b4ip_12{width:100%;max-height:calc(100vh - var(--header-bar-height) - var(--header-height) - var(--action-bar-height));flex:1;background-color:var(--video-backound-color);position:relative}._main_1b4ip_1 ._video_1b4ip_12 video{width:100%;height:100%}._container_jmhhf_1{width:385px!important;height:calc(100vh - var(--header-bar-height));background-color:var(--live-main-color)}._dataCount_jmhhf_6{text-align:center;margin:16px 16px 0;border-radius:2px;background-color:var(--message-color);display:flex;justify-content:space-around;align-items:center;height:120px;color:var(--live-color)}._dataCount_jmhhf_6 ._num_jmhhf_17{font-size:24px;font-weight:700;padding-bottom:16px}._dataCount_jmhhf_6 ._text_jmhhf_22{display:flex;font-size:14px}._dataCount_jmhhf_6 ._dataIcon_jmhhf_26{padding-right:5px;width:20px;height:20px}._tabContainer_jmhhf_31 ._tabIcon_jmhhf_31{margin-right:6px;width:20px;height:20px}._tabContainer_jmhhf_31 .el-tabs__header{margin-bottom:0}._tabContainer_jmhhf_31 .el-tabs__nav-wrap:after{background-color:var(--message-color)}._tabContainer_jmhhf_31 .el-tabs__nav{padding:12px 0;width:100%;text-align:center}._tabContainer_jmhhf_31 .el-tabs__item{color:var(--live-color);font-size:16px;padding:0 31px}._tabContainer_jmhhf_31 .el-tabs__item.is-active{color:#00fff0}._tabContainer_jmhhf_31 .el-tabs__active-bar{background-color:#00fff0}._tabContent_jmhhf_58{--message-bar-height: 88px;position:relative;height:calc(100vh - var(--header-bar-height) - var(--message-bar-height) - 216px);padding-bottom:var(--message-bar-height)}._tabContent_jmhhf_58 ._tabList_jmhhf_64{height:calc(100vh - var(--header-bar-height) - var(--message-bar-height) - 276px);overflow:auto}._message_4zab7_1 ._buttonGroup_4zab7_1{display:flex;align-items:center;background:rgba(99,108,132,.1);padding:15px 16px}._message_4zab7_1 .el-button--info{--el-button-text-color: var(--live-color);--el-button-hover-text-color: var(--live-light-color);--el-button-disabled-text-color: var(--el-text-color-placeholder);background-color:var(--message-color);border-color:var(--message-color)}._sendMessage_p2cnx_1{position:fixed;bottom:0;height:88px;width:353px;display:flex;align-items:center;padding:0 16px}._sendMessage_p2cnx_1 ._form_p2cnx_10{display:flex;align-items:center;width:100%;background-color:var(--message-color);border-radius:60px}._sendMessage_p2cnx_1 .el-input{border-radius:60px;overflow:hidden;font-size:16px}._sendMessage_p2cnx_1 .el-input__inner{height:46px;line-height:46px;padding-left:20px;background-color:transparent;border:0;color:var(--live-color)}._sendMessage_p2cnx_1 .el-button{border:0;background-color:#00a79d;height:46px;line-height:46px;border-radius:46px;color:var(--live-color);font-weight:600;padding:0 23px;font-size:16px}._sendMessage_p2cnx_1 .el-button.is-disabled{background-color:var(--el-button-disabled-bg-color);border-color:var(--el-button-disabled-border-color)}._itemContent_1wo39_1{padding:16px 16px 5px;display:flex;color:var(--live-color)}._itemContent_1wo39_1>img{width:28px;height:28px;margin-right:8px}._itemInfo_1wo39_11{width:100%}._itemName_1wo39_14{display:flex;justify-content:space-between;align-items:center;padding-top:3px}._itemName_1wo39_14 ._userName_1wo39_20{font-size:14px;line-height:22px;align-items:center;font-weight:500}._itemName_1wo39_14 ._name-style_1wo39_26{line-height:24px;color:var(--live-text-color)}._itemName_1wo39_14 ._rightTime_1wo39_30{font-size:12px}._itemName_1wo39_14 .el-tag--default{border-radius:20px;margin-right:8px;height:20px}._itemText_1wo39_38{font-size:15px;line-height:20px}._itemText_1wo39_38._active_1wo39_42{color:var(--live-text-color)}._joinText_1wo39_45{display:flex;justify-content:space-between;align-items:center}._joinText_1wo39_45 ._join_1wo39_45{display:flex;align-items:center}._btn_1wo39_54{font-size:13px;line-height:20px;background-color:var(--live-light-color);border-color:var(--live-light-color);text-align:center;padding:3px 15px 1px;border-radius:2px;cursor:pointer;color:var(--live-color);text-decoration:none}._btn_1wo39_54._downBtn_1wo39_66{background-color:transparent;border-color:var(--live-light-color);color:var(--live-light-color)}._loadingStyle_1wo39_71{position:absolute;left:0;right:0;top:0;bottom:0}._empty-container_1svqd_1{height:100%;width:100%;text-align:center;color:#a4a6a9;font-size:14px;padding:20px 0}._empty-container_1svqd_1 ._icon_1svqd_9{width:126px;height:89px;margin-bottom:8px}._container_13n1h_1{display:flex}._home_13n1h_4{--header-bar-height: 76px}\n",document.head.appendChild(I),System.register(["./index-legacy.02b4b6c8.js","./vendor-legacy.a1955742.js"],(function(t){"use strict";var r,u,l,f,y,E,T,I,b,w,k,N,O,A,x,P,M,L,U,D,V,B,F,H,j,K,q,G,Y,J;return{setters:[function(e){r=e.s,u=e.r,l=e.a},function(e){f=e.j,y=e.n,E=e.d,T=e.i,I=e.f,b=e.l,w=e.p,k=e.t,N=e.u,O=e.v,A=e.x,x=e.y,P=e.z,M=e.A,L=e.B,U=e.C,D=e.D,V=e.F,B=e.r,F=e.G,H=e.H,j=e.I,K=e.J,q=e.K,G=e.L,Y=e.M,J=e.N}],execute:function(){var z,W,Q="_liveHeader_8nata_1",X="_liveLogo_8nata_12",Z="_liveHeaderLeft_8nata_17",$="_liveHeaderLeftIcon_8nata_23",ee="_liveHeaderLeftText_8nata_27",te="_avatarWrapper_8nata_30",ne="_userAvatar_8nata_37";!function(e){e[e.READ=1]="READ",e[e.LISTENED=2]="LISTENED",e[e.DOWNLOADED=4]="DOWNLOADED",e[e.RETRIEVED=8]="RETRIEVED",e[e.UNREAD=0]="UNREAD"}(W||(W={}));var re,ie,oe=W,se=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],ae=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],ce=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],ue={"RC:TxtMsg":{isCounted:!0,isPersited:!0},"RC:ImgMsg":{isCounted:!0,isPersited:!0},"RC:VcMsg":{isCounted:!0,isPersited:!0},"RC:ImgTextMsg":{isCounted:!0,isPersited:!0},"RC:FileMsg":{isCounted:!0,isPersited:!0},"RC:HQVCMsg":{isCounted:!0,isPersited:!0},"RC:LBSMsg":{isCounted:!0,isPersited:!0},"RC:PSImgTxtMsg":{isCounted:!0,isPersited:!0},"RC:PSMultiImgTxtMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpOpendMsg":{isCounted:!0,isPersited:!0},"RC:CombineMsg":{isCounted:!0,isPersited:!0},"RC:ReferenceMsg":{isCounted:!0,isPersited:!0},"RC:SightMsg":{isCounted:!0,isPersited:!0},"RC:GIFMsg":{isCounted:!0,isPersited:!0},"RC:InfoNtf":{isCounted:!1,isPersited:!0},"RC:ContactNtf":{isCounted:!1,isPersited:!0},"RC:ProfileNtf":{isCounted:!1,isPersited:!0},"RC:CmdNtf":{isCounted:!1,isPersited:!0},"RC:GrpNtf":{isCounted:!1,isPersited:!0},"RC:RcCmd":{isCounted:!1,isPersited:!0},"RC:CmdMsg":{isCounted:!1,isPersited:!1},"RC:TypSts":{isCounted:!1,isPersited:!1},"RC:PSCmd":{isCounted:!1,isPersited:!1},"RC:SRSMsg":{isCounted:!1,isPersited:!1},"RC:RRReqMsg":{isCounted:!1,isPersited:!1},"RC:RRRspMsg":{isCounted:!1,isPersited:!1},"RC:CsChaR":{isCounted:!1,isPersited:!1},"RC:CSCha":{isCounted:!1,isPersited:!1},"RC:CsEva":{isCounted:!1,isPersited:!1},"RC:CsContact":{isCounted:!1,isPersited:!1},"RC:CsHs":{isCounted:!1,isPersited:!1},"RC:CsHsR":{isCounted:!1,isPersited:!1},"RC:CsSp":{isCounted:!1,isPersited:!1},"RC:CsEnd":{isCounted:!1,isPersited:!1},"RC:CsUpdate":{isCounted:!1,isPersited:!1},"RC:ReadNtf":{isCounted:!1,isPersited:!1},"RC:chrmKVNotiMsg":{isCounted:!1,isPersited:!1},"RC:VCAccept":{isCounted:!1,isPersited:!1},"RC:VCRinging":{isCounted:!1,isPersited:!1},"RC:VCSummary":{isCounted:!1,isPersited:!1},"RC:VCHangup":{isCounted:!1,isPersited:!1},"RC:VCInvite":{isCounted:!1,isPersited:!1},"RC:VCModifyMedia":{isCounted:!1,isPersited:!1},"RC:VCModifyMem":{isCounted:!1,isPersited:!1},"RC:MsgExMsg":{isCounted:!1,isPersited:!1},"RC:RRMsg":{isCounted:!1,isPersited:!1},"RC:LogCmdMsg":{isCounted:!1,isPersited:!1},"RC:InterceptMsg":{isCounted:!1,isPersited:!1}},de=["RC:TypSts","RC:InterceptMsg"];!function(e){e.WEBSOCKET="websocket",e.COMET="comet"}(re||(re={}));var le=function(e){return ie||(ie={set:function(t,n){e.localStorage.setItem(t,JSON.stringify(n))},get:function(t){var n;try{n=JSON.parse(e.localStorage.getItem(t))}catch(e){n=null}return n},remove:function(t){return e.localStorage.removeItem(t)},getKeys:function(){var t=[];for(var n in e.localStorage)t.push(n);return t}}),ie},he=function(){function e(e){this._caches={},e&&(this._caches=e)}return e.prototype.set=function(e,t){this._caches[e]=t},e.prototype.remove=function(e){var t=this.get(e);return delete this._caches[e],t},e.prototype.get=function(e){return this._caches[e]},e.prototype.getKeys=function(){var e=[];for(var t in this._caches)e.push(t);return e},e}(),fe=function(){function e(e,t){var n,r=t?"RCV4-"+t:"RCV4-";this._rootStorage=le(e);var i=this._rootStorage.get(r)||{};this._cache=new he(((n={})[r]=i,n)),this._storageKey=r}return e.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},e.prototype._set=function(e){var t=this._storageKey;e=e||{},this._cache.set(t,e),this._rootStorage.set(t,e)},e.prototype.set=function(e,t){var n=this._get();n[e]=t,this._set(n)},e.prototype.remove=function(e){var t=this._get();delete t[e],this._set(t)},e.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},e.prototype.get=function(e){return this._get()[e]},e.prototype.getKeys=function(){var e=this._get(),t=[];for(var n in e)t.push(n);return t},e.prototype.getValues=function(){return this._get()||{}},e}(),pe=function(e,t){return(pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function ge(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}pe(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var me,ve,_e=function(){return(_e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1] "+t)||this}ge(t,e)}(Error);var Ee=function(e,t,n){if(void 0===t||void 0===n)return e.toUpperCase();var r=e.slice(t,n);return e.replace(r,(function(e){return e.toUpperCase()}))},Te=function(e,t){void 0===t&&(t="utf-8");var n,r=0;if("utf-16"===t)for(var i=0,o=e.length;i0&&n.indexs.forEach((function(e){r.createIndex(e.indexName,e.key,{unique:e.unique})}))}}(t,be,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}(t)}}else console.debug("IndexDB is not currently supported in the environment!")},e.getInstance=function(){return e._instance},e.prototype.addList=function(t,n){return new Promise((function(r){if(e._db){var i=e._db.transaction([t],"readwrite"),o=i.objectStore(t);n.forEach((function(e){null==o||o.add(e)})),i.oncomplete=function(e){r(!0)},i.onerror=function(e){r(!1)}}else r(!1)}))},e.prototype.getRangeData=function(t,n,r,i){return new Promise((function(o){if(e._db){var s=e._db.transaction([t],"readwrite").objectStore(t),a=IDBKeyRange.bound(r,i),c=s.index(n),u=[],d=c.openCursor(a);d.onsuccess=function(e){var t=e.target.result;t?(u.push(t.value),t.continue()):o(u)},d.onerror=function(e){console.error(e),o([])}}else o([])}))},e.prototype.getCount=function(t,n){return new Promise((function(n){if(e._db){var r=e._db.transaction([t],"readonly").objectStore(t).count();r.onsuccess=function(){n(r.result)},r.onerror=function(e){console.error(e),n(0)}}else n(0)}))},e.prototype.removeFirstData=function(t,n,r){return new Promise((function(n){if(e._db){var i=e._db.transaction([t],"readwrite").objectStore(t),o=i.getAllKeys(IDBKeyRange.lowerBound(0),r);o.onsuccess=function(){var e=o.result;e.length>0&&(i.delete(IDBKeyRange.bound(e[0],e[e.length-1])).onsuccess=function(){n(!0)})}}else n(!1)}))},e._db=null,e}(),Ne=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},Oe=function(){var e=Ne();if(e=e.replace(/-/g,"")+"a",(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),n=t.length+1,r=+e,i=[];do{var o=r%n;r=(r-o)/n,i.unshift(t[o])}while(r);return i.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e.length<22)for(var t=22-e.length,n=0;n0},je=function(e){return"[object Object]"===Object.prototype.toString.call(e)},Ke=function(e){return"[object Function]"===Object.prototype.toString.call(e)},qe=function(e){return void 0===e||"[object Undefined]"===Object.prototype.toString.call(e)},Ge=function(e){return"[object Null]"===Object.prototype.toString.call(e)},Ye=function(e){return Ue(e)&&/https?:\/\//.test(e)},Je=function(e){for(var t in e)return!0;return!1},ze=function(e){return Ve(e)&&Object.prototype.hasOwnProperty.call(Le,e)},We=((Pe={})[me.DEBUG]=console.debug.bind(console),Pe[me.INFO]=console.info.bind(console),Pe[me.WARN]=console.warn.bind(console),Pe[me.ERROR]=console.error.bind(console),Pe[me.FATAL]=console.log.bind(console),Pe),Qe=function(e){return Ue(e)||Ve(e)||qe(e)||De(e)?e:e instanceof Error?JSON.stringify({name:e.name,message:e.message,stack:e.stack}):JSON.stringify(e)},Xe=function(){function e(e,t,n){this.tag=e,this.type=t,this.initiator=n,this._outLevel=me.WARN,this.debug=this.log.bind(this,me.DEBUG),this.info=this.log.bind(this,me.INFO),this.warn=this.log.bind(this,me.WARN),this.error=this.log.bind(this,me.ERROR),this.fatal=this.log.bind(this,me.FATAL)}return e.init=function(t){e.userId=t},e.reset=function(){e.userId=""},e.prototype._defaultStdout=function(e,t){for(var n=[],r=2;r=1e3&&(n=function(e,t,n){if(void 0===n&&(n="utf-8"),!e)return"";var r="utf-8"===n?3:2,i=0,o=0,s="";for(o=0;o255?i+=r:i++,i>1e3)return s;s+=e.charAt(o)}return e}(n));var s=JSON.stringify({message:n,userId:e.userId}).replace(/"/g,'""'),a=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",c={sessionId:e.sessionId,time:o,level:4-t,content:e.sessionId+","+Date.now()+","+i+","+(4-t)+","+a+',"'+s+'"\n',userId:e.userId};e.databaseLogList.push(c),(e.databaseLogList.length>=100||t===me.FATAL)&&this.__insertLogIntoDatabase()},e.prototype.__insertLogIntoDatabase=function(){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return t=Ce([],e.databaseLogList),e.databaseLogList=[],(n=ke.getInstance())?[4,n.addList(be,t)]:[3,3];case 1:return r=i.sent(),[4,n.getCount(be,"time")];case 2:return i.sent()>1e5&&n.removeFirstData(be,"time",2e3),[2,r];case 3:return[2,!1]}}))}))},e.prototype.setLogLevel=function(e){this._outLevel="number"!=typeof e?me.WARN:e},e.prototype.setLogStdout=function(e){this._logStdout=e},e.prototype.log=function(e){for(var t=[],n=1;nme.DEBUG&&this.__pushLocalLog(e,t.map(Qe).join(" "),this.tag),!(e=600&&(e.realTimeLogList=e.realTimeLogList.slice(-500))},e.prototype.set=function(e,t){this.warn("logger.set has being deprecated!")},e.prototype.setStdout=function(e){this._stdout=e},e.prototype.__clearRealTimeLog=function(){e.realTimeLogList=[]},e.databaseLogList=[],e.realTimeLogList=[],e.sessionId=Oe(),e.userId="",e}(),Ze=new Xe("RCLog"),$e=function(){function e(){this._map={}}return e.prototype.on=function(e,t,n){var r=this._map[e]||(this._map[e]=[]);r.some((function(e){return e.listener===t&&e.target===n}))||r.push({listener:t,target:n})},e.prototype.once=function(e,t,n){var r=this._map[e]||(this._map[e]=[]);r.some((function(e){return e.listener===t&&e.target===n}))||r.push({listener:t,target:n,once:!0})},e.prototype.off=function(e,t,n){var r=this._map[e];r&&((r=r.filter((function(e){return e.listener!==t||e.target!==n}))).length?this._map[e]=r:delete this._map[e])},e.prototype.emit=function(e){for(var t=[],n=1;n=0;i-=1){var o=r[i],s=o.target,a=o.once,c=o.listener;a&&r.splice(i,1);try{c.call.apply(c,Ce([s],t))}catch(e){Ze.error(e)}}},e.prototype.removeAll=function(e){delete this._map[e]},e.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},e}();!function(e){e[e.SEND=1]="SEND",e[e.RECEIVE=2]="RECEIVE"}(Me||(Me={}));var et,nt=Me;!function(e){e[e.TIMEOUT=-1]="TIMEOUT",e[e.UNKNOWN=-2]="UNKNOWN",e[e.PARAMETER_ERROR=-3]="PARAMETER_ERROR",e[e.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",e[e.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",e[e.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",e[e.SUCCESS=0]="SUCCESS",e[e.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",e[e.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",e[e.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",e[e.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",e[e.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",e[e.RECALL_MESSAGE=25101]="RECALL_MESSAGE",e[e.NOT_IN_GROUP=22406]="NOT_IN_GROUP",e[e.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",e[e.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",e[e.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",e[e.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",e[e.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",e[e.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",e[e.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",e[e.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",e[e.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",e[e.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",e[e.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",e[e.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",e[e.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",e[e.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",e[e.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",e[e.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",e[e.INVITE_DICUSSION=21409]="INVITE_DICUSSION",e[e.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",e[e.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",e[e.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",e[e.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",e[e.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",e[e.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",e[e.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",e[e.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",e[e.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",e[e.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",e[e.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",e[e.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",e[e.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",e[e.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",e[e.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",e[e.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",e[e.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",e[e.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",e[e.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",e[e.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",e[e.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",e[e.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",e[e.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",e[e.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",e[e.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",e[e.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",e[e.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",e[e.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",e[e.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",e[e.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",e[e.RC_OTP_USED=31027]="RC_OTP_USED",e[e.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",e[e.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",e[e.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",e[e.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",e[e.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",e[e.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",e[e.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",e[e.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",e[e.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",e[e.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",e[e.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",e[e.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",e[e.TAG_EXISTS=33101]="TAG_EXISTS",e[e.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",e[e.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",e[e.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",e[e.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",e[e.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",e[e.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",e[e.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",e[e.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",e[e.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",e[e.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",e[e.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",e[e.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",e[e.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",e[e.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",e[e.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",e[e.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",e[e.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",e[e.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",e[e.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",e[e.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",e[e.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",e[e.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",e[e.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",e[e.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",e[e.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",e[e.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",e[e.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",e[e.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",e[e.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",e[e.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",e[e.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",e[e.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",e[e.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",e[e.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",e[e.NOT_SUPPORT=39002]="NOT_SUPPORT",e[e.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",e[e.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",e[e.COOKIE_ENABLE=51001]="COOKIE_ENABLE",e[e.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",e[e.HAVNODEVICEID=24001]="HAVNODEVICEID",e[e.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",e[e.FEILD=24009]="FEILD",e[e.VOIPISNULL=24013]="VOIPISNULL",e[e.NOENGINETYPE=24010]="NOENGINETYPE",e[e.NULLCHANNELNAME=24011]="NULLCHANNELNAME",e[e.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",e[e.NOVOIP=24014]="NOVOIP",e[e.INTERNALERRROR=24015]="INTERNALERRROR",e[e.VOIPCLOSE=24016]="VOIPCLOSE",e[e.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",e[e.ALREADY_IN_USE=51002]="ALREADY_IN_USE",e[e.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",e[e.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",e[e.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",e[e.CANCEL=1]="CANCEL",e[e.REJECT=2]="REJECT",e[e.HANGUP=3]="HANGUP",e[e.BUSYLINE=4]="BUSYLINE",e[e.NO_RESPONSE=5]="NO_RESPONSE",e[e.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",e[e.NETWORK_ERROR=7]="NETWORK_ERROR",e[e.REMOTE_CANCEL=11]="REMOTE_CANCEL",e[e.REMOTE_REJECT=12]="REMOTE_REJECT",e[e.REMOTE_HANGUP=13]="REMOTE_HANGUP",e[e.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",e[e.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",e[e.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",e[e.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",e[e.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",e[e.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",e[e.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"}(et||(et={}));var rt,it=et;!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED",e[e.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",e[e.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",e[e.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",e[e.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",e[e.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",e[e.BLOCKED=9]="BLOCKED",e[e.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",e[e.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",e[e.REDIRECT=14]="REDIRECT",e[e.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",e[e.ULTRALIMIT=1101]="ULTRALIMIT",e[e.REQUEST_NAVI=201]="REQUEST_NAVI",e[e.RESPONSE_NAVI=202]="RESPONSE_NAVI",e[e.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",e[e.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"}(rt||(rt={}));var ot,st=rt,at=0,ct=3,ut=4,dt=6,lt=8,ht=9,ft=10,pt=12,gt=13,mt=16,vt=17,_t=18;!function(e){e.TextMessage="RC:TxtMsg",e.VOICE="RC:VcMsg",e.HQ_VOICE="RC:HQVCMsg",e.IMAGE="RC:ImgMsg",e.GIF="RC:GIFMsg",e.RICH_CONTENT="RC:ImgTextMsg",e.LOCATION="RC:LBSMsg",e.FILE="RC:FileMsg",e.SIGHT="RC:SightMsg",e.COMBINE="RC:CombineMsg",e.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",e.LOG_COMMAND="RC:LogCmdMsg",e.EXPANSION_NOTIFY="RC:MsgExMsg",e.REFERENCE="RC:ReferenceMsg",e.RECALL="RC:RcCmd",e.READ_RECEIPT="RC:ReadNtf",e.READ_RECEIPT_REQUEST="RC:RRReqMsg",e.READ_RECEIPT_RESPONSE="RC:RRRspMsg",e.SYNC_READ_STATUS="RC:SRSMsg",e.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",e.CHATROOM_JOIN="RC:ChrmJoinNtf",e.CHATROOM_LEFT="RC:ChrmQuitNtf",e.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",e.TYPING_STATUS="RC:TypSts",e.INTERCEPT="RC:InterceptMsg"}(ot||(ot={}));var yt,Rt=ot;!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=2]="CLOSE"}(yt||(yt={}));var Ct,Et=yt;!function(e){e[e.ALL=1]="ALL",e[e.SINGAL=2]="SINGAL"}(Ct||(Ct={}));var Tt,St=Ct;!function(e){e[e.QINIU=1]="QINIU",e[e.ALI=2]="ALI",e[e.AWS=3]="AWS",e[e.STC=4]="STC"}(Tt||(Tt={}));var It,bt=Tt;!function(e){e[e.UPDATE=1]="UPDATE",e[e.DELETE=2]="DELETE"}(It||(It={}));var wt,kt=It;!function(e){e[e.QUIT=0]="QUIT",e[e.JOIN=1]="JOIN"}(wt||(wt={}));var Nt,Ot,At,xt,Pt=wt;!function(e){ /*! 全局敏感词:命中了融云内置的全局敏感词 */ e[e.GLOBAL=1]="GLOBAL", /*! 自定义敏感词拦截:命中了客户在融云自定义的敏感词 */ e[e.CUSTOM=2]="CUSTOM", /*! 第三方审核拦截:命中了第三方(数美)或模板路由决定不下发的状态 */ e[e.THIRD_PARTY=3]="THIRD_PARTY"}(Nt||(Nt={})),function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE"}(Ot||(Ot={})),function(e){e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO=1]="AUDIO"}(At||(At={})),function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(xt||(xt={}));var Mt,Lt,Ut,Dt={"RC:VCAccept":"RC:VCAccept","RC:VCRinging":"RC:VCRinging","RC:VCSummary":"RC:VCSummary","RC:VCHangup":"RC:VCHangup","RC:VCInvite":"RC:VCInvite","RC:VCModifyMedia":"RC:VCModifyMedia","RC:VCModifyMem":"RC:VCModifyMem"};!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Mt||(Mt={})),function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(Lt||(Lt={})),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE",e[e.COEXIST=2]="COEXIST"}(Ut||(Ut={}));var Vt,Bt,Ft={engine:"5.1.1"},Ht=function(){function e(){}return e.add=function(e,t){Ft[e]=t},e.validEngine=function(e){var t=e.match(/\d+\.\d+\.\d+/);if(!t)return Ze.warn("The validation engine version '"+e+"' is invalid!"),!1;var n=t[0].split(".").map((function(e){return e.padStart(3,"0")})).join("");return Ft.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map((function(e){return e.padStart(3,"0")})).join("")>=n},e.getInfo=function(){return Ft},e}();!function(e){e[e.STRING=0]="STRING",e[e.ONLY_STRING=1]="ONLY_STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.OBJECT=4]="OBJECT",e[e.ARRAY=5]="ARRAY",e[e.CALLBACK=6]="CALLBACK",e[e.CHANNEL_ID=7]="CHANNEL_ID"}(Bt||(Bt={}));var jt,Kt,qt,Gt,Yt,Jt=((Vt={})[Bt.STRING]=He,Vt[Bt.ONLY_STRING]=Ue,Vt[Bt.NUMBER]=Ve,Vt[Bt.BOOLEAN]=function(e){return"boolean"==typeof e},Vt[Bt.OBJECT]=je,Vt[Bt.ARRAY]=Be,Vt[Bt.CALLBACK]=function(e){var t=!0;return je(e)||(t=!1),(e=e||{}).onSuccess&&!Ke(e.onSuccess)&&(t=!1),e.onError&&!Ke(e.onError)&&(t=!1),t},Vt[Bt.CHANNEL_ID]=function(e){var t=!1;return Ue(e)&&!/_/g.test(e)&&e.length<=20&&(t=!0),t},Vt),zt=function(e){function t(t){var n=e.call(this,t)||this;return n.name="RCAssertError",n}return ge(t,e),t}(Error),Wt=function(e,t,n,r){if(void 0===r&&(r=!1),!Qt(e,t,n,r))throw new zt("'"+e+"' is invalid: "+JSON.stringify(t))},Qt=function(e,t,n,r){void 0===r&&(r=!1),n=Jt[n]||n;var i=r&&!n(t)||!r&&!(qe(t)||null===t||n(t));return i&&Ze.error("'"+e+"' is invalid: "+JSON.stringify(t)),!i},Xt=function(e){if(!je(e)||void 0===e.low||void 0===e.high)return e;var t=e.low;return t<0&&(t+=4294967296),t=t.toString(16),parseInt(e.high.toString(16)+"00000000".replace(new RegExp("0{"+t.length+"}$"),t),16)},Zt=function(e,t){var n={},r={notificationId:t||""};if(!e)return{iOSConfig:n,androidConfig:r};try{var i=JSON.parse(e);null==i||i.forEach((function(e){var t,i,o,s,a=Object.keys(e);if(0!==a.length){var c=a[0];switch(c){case"HW":return void(r.channelIdHW=null===(t=e[c])||void 0===t?void 0:t.channelId);case"MI":return void(r.channelIdMi=null===(i=e[c])||void 0===i?void 0:i.channelId);case"OPPO":return void(r.channelIdOPPO=null===(o=e[c])||void 0===o?void 0:o.channelId);case"VIVO":return void(r.typeVivo=null===(s=e[c])||void 0===s?void 0:s.classification);case"APNS":return n.threadId=e[c]["thread-id"],n.apnsCollapseId=e[c]["apns-collapse-id"],n.category=e[c].category,void(n.richMediaUri=e[c].richMediaUri);case"FCM":r.googleConfig={collapseKey:e[c].collapse_key||"",imageUrl:e[c].imageUrl||"",priority:e[c].priority||""}}}}))}catch(t){Ze.error("Wrong format for pushConfigs field! content: "+e)}return{iOSConfig:n,androidConfig:r}},$t=function(e){var t=/^[A-Za-z0-9_=+-]+$/.test(e),n=e.length;return t&&n<=128&&n>=1},en=function(e){var t=e.length;return t<=4096&&t>=1},tn=function(e,t,n){t=t||function(){};var r=(n=n||{}).isReverse;je(e)&&function(){for(var n in e)t(e[n],n,e)}(),(Be(e)||Ue(e))&&function(){if(r)for(var n=e.length-1;n>=0;n--)t(e[n],n);else for(var i=0,o=e.length;i0;e&&i&&1===arguments.length?(this._retain=(1&e)>0,this.qos=(6&e)>>1,this._dup=(8&e)>0,this.type=e>>4&15,this.syncMsg=8==(8&e)):(this.type=e,this._retain=t,this.qos=n,this._dup=r)}return e.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,(e|=this.qos<<1)|(this._dup?8:0)},e}(),fn=function(){function e(){}return e.writeUTF=function(e,t){var n=[],r=0;if(Ue(e))for(var i=0,o=e.length;i=0&&s<=127?(r+=1,n.push(s)):s>=128&&s<=2047?(r+=2,n.push(192|31&s>>6),n.push(128|63&s)):s>=2048&&s<=65535&&(r+=3,n.push(224|15&s>>12),n.push(128|63&s>>6),n.push(128|63&s))}for(i=0,o=n.length;i255&&(n[i]&=255);return t?n:r<=255?[0,r].concat(n):[r>>8,255&r].concat(n)},e.readUTF=function(e){for(var t,n,r=[],i=-1,o=e,s="";++i1114111||Math.floor(a)!==a)throw RangeError("Invalid code point: "+a);a<=65535?r.push(a):(t=(a-=65536)>>10|55296,n=a%1024|56320,r.push(t,n)),(i+1===o.length||r.length>16384)&&(s+=String.fromCharCode.apply(null,r),r.length=0)}return s},e}(),pn=function(){function e(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return e.prototype.check=function(){return this._position>=this._pool.length},e.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var t="",n=0;n<2;n++){var r=e._pool[e._position++].toString(16);1===r.length&&(r="0"+r),t+=r.toString()}return parseInt(t,16)},e.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var t="",n=0;n<4;n++){var r=e._pool[e._position++].toString(16);1===r.length&&(r="0"+r),t+=r.toString()}return parseInt(t,16)},e.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var t="",n=0;n<8;n++){var r=e._pool[e._position++].toString(16);1===r.length&&(r="0"+r),t+=r}return parseInt(t,16)},e.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},e.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),t=this._pool.subarray(this._position,this._position+=e);return fn.readUTF(t)},e.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},e}(),gn=function(){function e(){this._pool=[],this._position=0,this._writen=0}return e.prototype.write=function(e){return-1!==Object.prototype.toString.call(e).indexOf("Array")?this._pool=this._pool.concat(e):e>=0&&(e>255&&(e&=255),this._pool.push(e),this._writen++),e},e.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},e.prototype.writeUTF=function(e){var t=fn.writeUTF(e);this._pool=this._pool.concat(t),this._writen+=t.length},e.prototype.getBytesArray=function(){return this._pool},e}(),mn="UpStreamMessage",vn="PushExtra",_n="DownStreamMessage",yn="DownStreamMessages",Rn="SessionsAttQryInput",Cn="SessionsAttOutput",En="SyncRequestMsg",Tn="ChrmPullMsg",Sn="NotifyMsg",In="HistoryMsgInput",bn="HistoryMsgOuput",wn="RelationQryInput",kn="RelationsOutput",Nn="DeleteSessionsInput",On="SessionInfo",An="DeleteSessionsOutput",xn="RelationsInput",Pn="DeleteMsgInput",Mn="CleanHisMsgInput",Ln="SessionMsgReadInput",Un="ChrmInput",Dn="ChrmOutput",Vn="QueryChatRoomInfoInput",Bn="QueryChatRoomInfoOutput",Fn="RtcInput",Hn="RtcUserListOutput",jn="SetUserStatusInput",Kn="RtcSetDataInput",qn="RtcUserSetDataInput",Gn="RtcDataInput",Yn="RtcSetOutDataInput",Jn="MCFollowInput",zn="RtcTokenOutput",Wn="RtcQryOutput",Qn="RtcQryUserOutDataInput",Xn="RtcUserOutDataOutput",Zn="RtcQueryListInput",$n="RtcRoomInfoOutput",er="RtcValueInfo",tr="RtcKeyDeleteInput",nr="GetQNupTokenInput",rr="GetQNupTokenOutput",ir="GetQNdownloadUrlInput",or="GetDownloadUrlInput",sr="GetQNdownloadUrlOutput",ar="GetDownloadUrlOutput",cr="SetChrmKV",ur="SetChrmKVS",dr="DeleteChrmKVS",lr="ChrmKVOutput",hr="ChrmKVSOutput",fr="ChrmKVSOutputEntity",pr="QueryChrmKV",gr="SetUserSettingInput",mr="SetUserSettingOutput",vr="PullUserSettingInput",_r="PullUserSettingOutput",yr="UserSettingNotification",Rr="SessionReq",Cr="SessionStates",Er="SessionState",Tr="SessionStateItem",Sr="SessionStateModifyReq",Ir="SessionStateModifyResp",br="GrpReadReceiptMsg",wr="GrpReadReceiptQryReq",kr="GrpReadReceiptQryResp",Nr="GrpMsgReadUser",Or="SessionTagAddInput",Ar="SessionTagItem",xr="SessionTagDelInput",Pr="SessionDisTagReq",Mr="ReportSDKInput",Lr="ReportSDKOutput",Ur="RtcNotifyMsg",Dr="RtcPullKV",Vr="RtcKVOutput",Br="RtcQueryUserJoinedInput",Fr="RtcQueryUserJoinedOutput",Hr="RtcViewerJoinedOutput",jr="RtcInviteInput",Kr="RtcCancelInviteInput",qr="RtcInviteAnswerInput",Gr="RtcEndInviteInput",Yr=((ln={})[mn]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],ln[yn]=["list","syncTime","finished"],ln[_n]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],ln[vn]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],ln[Rn]=["nothing"],ln[Cn]=["inboxTime","sendboxTime","totalUnreadCount"],ln[En]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],ln[Tn]=["syncTime","count"],ln[Sn]=["type","time","chrmId"],ln[In]=["targetId","time","count","order","busChannel"],ln[bn]=["list","syncTime","hasMsg"],ln[wn]=["type","count","startTime","order"],ln[kn]=["info"],ln[Nn]=["sessions"],ln[On]=["type","channelId","busChannel"],ln[An]=["nothing"],ln[xn]=["type","msg","count","busChannel","startTime","endTime"],ln[Pn]=["type","conversationId","msgs","busChannel"],ln[Mn]=["targetId","dataTime","conversationType","busChannel"],ln[Ln]=["type","msgTime","channelId"],ln[Un]=["nothing"],ln[Dn]=["nothing","sessionId","joinTime"],ln[Vn]=["count","order"],ln[Bn]=["userTotalNums","userInfos"],ln[nr]=["type","key","httpMethod","queryString"],ln[ir]=["type","key","fileName"],ln[or]=["type","key","fileName"],ln[rr]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],ln[sr]=["downloadUrl"],ln[ar]=["downloadUrl"],ln[cr]=["entry","bNotify","notification","type"],ln[ur]=["entry","bNotify","notification","type"],ln[dr]=["entry","bNotify","notification","type"],ln[lr]=["entries","bFullUpdate","syncTime"],ln[hr]=["timestamp","errorKeys"],ln[fr]=["key","errorCode"],ln[pr]=["timestamp"],ln[gr]=["version","value"],ln[mr]=["version","reserve"],ln[vr]=["version","reserve"],ln[_r]=["items","version"],ln.UserSettingItem=["targetId","type","key","value","version","status","tags"],ln[Rr]=["time"],ln[Cr]=["version","state"],ln[Er]=["type","channelId","time","stateItem","busChannel"],ln[Tr]=["sessionStateType","value","tags"],ln[Sr]=["version","state"],ln[Ir]=["version"],ln[br]=["msgId","busChannel"],ln[wr]=["msgId","busChannel"],ln[kr]=["totalMemberNum","list"],ln[Nr]=["readTime","userId"],ln[Or]=["version","tags"],ln[Ar]=["tagId","name","createdTime","isTop"],ln[xr]=["version","tags"],ln[Pr]=["tagId"],ln[yr]=["version","reserve"],ln[Mr]=["sdkInfo"],ln[Lr]=["nothing"],ln[Fn]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],ln[Hn]=["users","token","sessionId","roomInfo"],ln[jn]=["status"],ln[Kn]=["interior","target","key","value","objectName","content"],ln[qn]=["valueInfo","objectName","content"],ln[Gn]=["interior","target","key","objectName","content"],ln[Yn]=["target","valueInfo","objectName","content"],ln[Jn]=["state"],ln[zn]=["rtcToken"],ln[Wn]=["outInfo"],ln[Qn]=["userId"],ln[Xn]=["user"],ln[Zn]=["order"],ln[$n]=["roomId","roomData","userCount","list"],ln[er]=["key","value"],ln[tr]=["key"],ln[Ur]=["type","time","roomId"],ln[Dr]=["timestamp","roomId"],ln[Vr]=["entries","bFullUpdate","syncTime"],ln[Br]=["userId"],ln[Fr]=["info"],ln[jr]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],ln[Kr]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],ln[qr]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],ln[Gr]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],ln),Jr={},zr=function(e){var t=Yr[e];Jr[e]=function(){for(var e={},n={getArrayData:function(){return e}},r=function(r){var i=t[r],o="set"+Ee(i,0,1);n[o]=function(t){e[i]=t}},i=0;i]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.DotProto=function(e,t){function n(e,n){var r=-1,i=1;if("-"==e.charAt(0)&&(i=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))r=parseInt(e);else if(t.NUMBER_HEX.test(e))r=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(i<0?"-":"")+e);r=parseInt(e.substring(1),8)}if(r=0|i*r,!n&&r<0)throw Error("illegal id value: "+(i<0?"-":"")+e);return r}function r(e){var n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return n*parseInt(e,10);if(t.NUMBER_HEX.test(e))return n*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return n*parseInt(e.substring(1),8);if("inf"===e)return 1/0*n;if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return n*parseFloat(e);throw Error("illegal number value: "+(n<0?"-":"")+e)}function i(e,t,n){void 0===e[t]?e[t]=n:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(n))}var o,s,a={},c=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},u=c.prototype;return u._readString=function(){var e,n='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;if(n.lastIndex=this.index-1,!(e=n.exec(this.source)))throw Error("unterminated string");return this.index=n.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,e[1]},u.next=function(){var e,n,r,i,o;if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if("\n"===r&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index,++this.line,e=!0}else{if("*"!==(r=this.source.charAt(this.index)))return"/";do{if("\n"===r&&++this.line,++this.index===this.source.length)return null;n=r,r=this.source.charAt(this.index)}while("*"!==n||"/"!==r);++this.index,e=!0}}while(e);if(this.index===this.source.length)return null;if(i=this.index,t.DELIM.lastIndex=0,!t.DELIM.test(this.source.charAt(i++)))for(;i"),s=this.tn.next(),!t.NAME.test(s))throw Error("illegal message field name: "+s);o.name=s,this.tn.skip("="),o.id=n(this.tn.next()),"["===(s=this.tn.peek())&&this._parseFieldOptions(o),this.tn.skip(";")}else if("group"===(i=void 0!==i?i:this.tn.next())){if(a=this._parseMessage(e,o),!/^[A-Z]/.test(a.name))throw Error("illegal group name: "+a.name);o.type=a.name,o.name=a.name.toLowerCase(),this.tn.omit(";")}else{if(!t.TYPE.test(i)&&!t.TYPEREF.test(i))throw Error("illegal message field type: "+i);if(o.type=i,s=this.tn.next(),!t.NAME.test(s))throw Error("illegal message field name: "+s);o.name=s,this.tn.skip("="),o.id=n(this.tn.next()),"["===(s=this.tn.peek())&&this._parseFieldOptions(o),this.tn.skip(";")}return e.fields.push(o),o},s._parseMessageOneOf=function(e){var n,r,i,o=this.tn.next();if(!t.NAME.test(o))throw Error("illegal oneof name: "+o);for(r=o,i=[],this.tn.skip("{");"}"!==(o=this.tn.next());)(n=this._parseMessageField(e,"optional",o)).oneof=r,i.push(n.id);this.tn.omit(";"),e.oneofs[r]=i},s._parseFieldOptions=function(e){this.tn.skip("[");for(var t=!0;"]"!==this.tn.peek();)t||this.tn.skip(","),this._parseOption(e,!0),t=!1;this.tn.next()},s._parseEnum=function(e){var r,i={name:"",values:[],options:{}},o=this.tn.next();if(!t.NAME.test(o))throw Error("illegal name: "+o);for(i.name=o,this.tn.skip("{");"}"!==(o=this.tn.next());)if("option"===o)this._parseOption(i);else{if(!t.NAME.test(o))throw Error("illegal name: "+o);this.tn.skip("="),r={name:o,id:n(this.tn.next(),!0)},"["===(o=this.tn.peek())&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),i.values.push(r)}this.tn.omit(";"),e.enums.push(i)},s._parseExtensionRanges=function(){var t,n,i,o=[];do{for(n=[];;){switch(t=this.tn.next()){case"min":i=e.ID_MIN;break;case"max":i=e.ID_MAX;break;default:i=r(t)}if(n.push(i),2===n.length)break;if("to"!==this.tn.peek()){n.push(i);break}this.tn.next()}o.push(n)}while(this.tn.omit(","));return this.tn.skip(";"),o},s._parseExtend=function(e){var n,r=this.tn.next();if(!t.TYPEREF.test(r))throw Error("illegal extend reference: "+r);for(n={ref:r,fields:[]},this.tn.skip("{");"}"!==(r=this.tn.next());)if(t.RULE.test(r))this._parseMessageField(n,r);else{if(!t.TYPEREF.test(r))throw Error("illegal extend token: "+r);if(!this.proto3)throw Error("illegal field rule: "+r);this._parseMessageField(n,"optional",r)}return this.tn.omit(";"),e.messages.push(n),n},s.toString=function(){return"Parser at line "+this.tn.line},a.Parser=o,a}(i,i.Lang),i.Reflect=function(t){function r(e,n){if(e&&"number"==typeof e.low&&"number"==typeof e.high&&"boolean"==typeof e.unsigned&&e.low==e.low&&e.high==e.high)return new t.Long(e.low,e.high,void 0===n?e.unsigned:n);if("string"==typeof e)return t.Long.fromString(e,n||!1,10);if("number"==typeof e)return t.Long.fromNumber(e,n||!1);throw Error("not convertible to Long")}function i(e,n){var r=n.readVarint32(),o=7&r,s=r>>>3;switch(o){case t.WIRE_TYPES.VARINT:do{r=n.readUint8()}while(128==(128&r));break;case t.WIRE_TYPES.BITS64:n.offset+=8;break;case t.WIRE_TYPES.LDELIM:r=n.readVarint32(),n.offset+=r;break;case t.WIRE_TYPES.STARTGROUP:i(s,n);break;case t.WIRE_TYPES.ENDGROUP:if(s===e)return!1;throw Error("Illegal GROUPEND after unknown group: "+s+" ("+e+" expected)");case t.WIRE_TYPES.BITS32:n.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+e+": "+o)}return!0}var o,s,a,c,u,d,l,h,f,p,g,m,v,_,y,R,C={},E=function(e,t,n){this.builder=e,this.parent=t,this.name=n,this.className},T=E.prototype;return T.fqn=function(){for(var e=this.name,t=this;null!=(t=t.parent);)e=t.name+"."+e;return e},T.toString=function(e){return(e?this.className+" ":"")+this.fqn()},T.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},C.T=E,(s=(o=function(e,t,n,r,i){E.call(this,e,t,n),this.className="Namespace",this.children=[],this.options=r||{},this.syntax=i||"proto2"}).prototype=Object.create(E.prototype)).getChildren=function(e){var t,n,r;if(null==(e=e||null))return this.children.slice();for(t=[],n=0,r=this.children.length;r>n;++n)this.children[n]instanceof e&&t.push(this.children[n]);return t},s.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof u.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof u.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},s.getChild=function(e){var t,n,r="number"==typeof e?"id":"name";for(t=0,n=this.children.length;n>t;++t)if(this.children[t][r]===e)return this.children[t];return null},s.resolve=function(e,t){var n,r="string"==typeof e?e.split("."):e,i=this,o=0;if(""===r[o]){for(;null!==i.parent;)i=i.parent;o++}do{do{if(!(i instanceof C.Namespace)){i=null;break}if(!((n=i.getChild(r[o]))&&n instanceof C.T&&(!t||n instanceof C.Namespace))){i=null;break}i=n,o++}while(ot;++t)(e=i[t])instanceof o&&(r[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(r,"$options",{value:this.buildOpt()}),r},s.buildOpt=function(){var e,t,n,r,i={},o=Object.keys(this.options);for(e=0,t=o.length;t>e;++e)n=o[e],r=this.options[o[e]],i[n]=r;return i},s.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},C.Namespace=o,c=(a=function(e,n,r,i){if(this.type=e,this.resolvedType=n,this.isMapKey=r,this.syntax=i,r&&t.MAP_KEY_TYPES.indexOf(e)<0)throw Error("Invalid map key type: "+e.name)}).prototype,a.defaultFieldValue=function(e){if("string"==typeof e&&(e=t.TYPES[e]),void 0===e.defaultValue)throw Error("default value for type "+e.name+" is not supported");return e==t.TYPES.bytes?new n(0):e.defaultValue},c.verifyValue=function(n){var i,o,s,a=function(e,t){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+e+" ("+t+")")}.bind(this);switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:return("number"!=typeof n||n==n&&n%1!=0)&&a(S(n),"not an integer"),n>4294967295?0|n:n;case t.TYPES.uint32:case t.TYPES.fixed32:return("number"!=typeof n||n==n&&n%1!=0)&&a(S(n),"not an integer"),n<0?n>>>0:n;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:if(t.Long)try{return r(n,!1)}catch(e){a(S(n),e.message)}else a(S(n),"requires Long.js");case t.TYPES.uint64:case t.TYPES.fixed64:if(t.Long)try{return r(n,!0)}catch(e){a(S(n),e.message)}else a(S(n),"requires Long.js");case t.TYPES.bool:return"boolean"!=typeof n&&a(S(n),"not a boolean"),n;case t.TYPES.float:case t.TYPES.double:return"number"!=typeof n&&a(S(n),"not a number"),n;case t.TYPES.string:return"string"==typeof n||n&&n instanceof String||a(S(n),"not a string"),""+n;case t.TYPES.bytes:return e.isByteBuffer(n)?n:e.wrap(n);case t.TYPES.enum:for(i=this.resolvedType.getChildren(t.Reflect.Enum.Value),s=0;s4294967295||n<0)&&a(S(n),"not in range for uint32"),n;a(n,"not a valid enum value");case t.TYPES.group:case t.TYPES.message:if(n&&"object"==S(n)||a(S(n),"object expected"),n instanceof this.resolvedType.clazz)return n;if(n instanceof t.Builder.Message){for(s in o={},n)n.hasOwnProperty(s)&&(o[s]=n[s]);n=o}return new this.resolvedType.clazz(n)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+n+" (undefined type "+this.type+")")},c.calculateLength=function(e,r){if(null===r)return 0;var i;switch(this.type){case t.TYPES.int32:return r<0?n.calculateVarint64(r):n.calculateVarint32(r);case t.TYPES.uint32:return n.calculateVarint32(r);case t.TYPES.sint32:return n.calculateVarint32(n.zigZagEncode32(r));case t.TYPES.fixed32:case t.TYPES.sfixed32:case t.TYPES.float:return 4;case t.TYPES.int64:case t.TYPES.uint64:return n.calculateVarint64(r);case t.TYPES.sint64:return n.calculateVarint64(n.zigZagEncode64(r));case t.TYPES.fixed64:case t.TYPES.sfixed64:return 8;case t.TYPES.bool:return 1;case t.TYPES.enum:return n.calculateVarint32(r);case t.TYPES.double:return 8;case t.TYPES.string:return i=n.calculateUTF8Bytes(r),n.calculateVarint32(i)+i;case t.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return n.calculateVarint32(r.remaining())+r.remaining();case t.TYPES.message:return i=this.resolvedType.calculate(r),n.calculateVarint32(i)+i;case t.TYPES.group:return(i=this.resolvedType.calculate(r))+n.calculateVarint32(e<<3|t.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},c.encodeValue=function(e,r,i){var o,s;if(null===r)return i;switch(this.type){case t.TYPES.int32:r<0?i.writeVarint64(r):i.writeVarint32(r);break;case t.TYPES.uint32:i.writeVarint32(r);break;case t.TYPES.sint32:i.writeVarint32ZigZag(r);break;case t.TYPES.fixed32:i.writeUint32(r);break;case t.TYPES.sfixed32:i.writeInt32(r);break;case t.TYPES.int64:case t.TYPES.uint64:i.writeVarint64(r);break;case t.TYPES.sint64:i.writeVarint64ZigZag(r);break;case t.TYPES.fixed64:i.writeUint64(r);break;case t.TYPES.sfixed64:i.writeInt64(r);break;case t.TYPES.bool:"string"==typeof r?i.writeVarint32("false"===r.toLowerCase()?0:!!r):i.writeVarint32(r?1:0);break;case t.TYPES.enum:i.writeVarint32(r);break;case t.TYPES.float:i.writeFloat32(r);break;case t.TYPES.double:i.writeFloat64(r);break;case t.TYPES.string:i.writeVString(r);break;case t.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");o=r.offset,i.writeVarint32(r.remaining()),i.append(r),r.offset=o;break;case t.TYPES.message:s=(new n).LE(),this.resolvedType.encode(r,s),i.writeVarint32(s.offset),i.append(s.flip());break;case t.TYPES.group:this.resolvedType.encode(r,i),i.writeVarint32(e<<3|t.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return i},c.decode=function(e,n,r){if(n!=this.type.wireType)throw Error("Unexpected wire type for element");var i,o;switch(this.type){case t.TYPES.int32:return 0|e.readVarint32();case t.TYPES.uint32:return e.readVarint32()>>>0;case t.TYPES.sint32:return 0|e.readVarint32ZigZag();case t.TYPES.fixed32:return e.readUint32()>>>0;case t.TYPES.sfixed32:return 0|e.readInt32();case t.TYPES.int64:return e.readVarint64();case t.TYPES.uint64:return e.readVarint64().toUnsigned();case t.TYPES.sint64:return e.readVarint64ZigZag();case t.TYPES.fixed64:return e.readUint64();case t.TYPES.sfixed64:return e.readInt64();case t.TYPES.bool:return!!e.readVarint32();case t.TYPES.enum:return e.readVarint32();case t.TYPES.float:return e.readFloat();case t.TYPES.double:return e.readDouble();case t.TYPES.string:return e.readVString();case t.TYPES.bytes:if(o=e.readVarint32(),e.remaining()o;++o)this[c[o].name]=null;for(o=0,s=a.length;s>o;++o)this[(u=a[o]).name]=u.repeated?[]:u.map?new t.Map(u):null,!u.required&&"proto3"!==r.syntax||null===u.defaultValue||(this[u.name]=u.defaultValue);if(arguments.length>0)if(1!==arguments.length||null===i||"object"!=S(i)||!("function"!=typeof i.encode||i instanceof e)||Array.isArray(i)||i instanceof t.Map||n.isByteBuffer(i)||i instanceof ArrayBuffer||t.Long&&i instanceof t.Long)for(o=0,s=arguments.length;s>o;++o)void 0!==(d=arguments[o])&&this.$set(a[o].name,d);else this.$set(i)},d=u.prototype=Object.create(t.Builder.Message.prototype);for(d.add=function(e,n,i){var o=r._fieldsByName[e];if(!i){if(!o)throw Error(this+"#"+e+" is undefined");if(!(o instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+o.toString(!0));if(!o.repeated)throw Error(this+"#"+e+" is not a repeated field");n=o.verifyValue(n,!0)}return null===this[e]&&(this[e]=[]),this[e].push(n),this},d.$add=d.add,d.set=function(e,n,i){var o,s,a;if(e&&"object"==S(e)){for(o in i=n,e)e.hasOwnProperty(o)&&void 0!==(n=e[o])&&this.$set(o,n,i);return this}if(s=r._fieldsByName[e],i)this[e]=n;else{if(!s)throw Error(this+"#"+e+" is not a field: undefined");if(!(s instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+s.toString(!0));this[s.name]=n=s.verifyValue(n)}return s&&s.oneof&&(a=this[s.oneof.name],null!==n?(null!==a&&a!==s.name&&(this[a]=null),this[s.oneof.name]=s.name):a===e&&(this[s.oneof.name]=null)),this},d.$set=d.set,d.get=function(e,n){if(n)return this[e];var i=r._fieldsByName[e];if(!(i&&i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: undefined");if(!(i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+i.toString(!0));return this[i.name]},d.$get=d.get,o=0;os;s++)if((o=this.children[s])instanceof g||o instanceof u||o instanceof _){if(i.hasOwnProperty(o.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+o.toString(!0)+" cannot override static property '"+o.name+"'");i[o.name]=o.build()}else if(o instanceof u.Field)o.build(),this._fields.push(o),this._fieldsById[o.id]=o,this._fieldsByName[o.name]=o;else if(!(o instanceof u.OneOf||o instanceof v))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[s].toString(!0));return this.clazz=i},d.encode=function(e,t,n){var r,i,o,s,a,c=null;for(o=0,s=this._fields.length;s>o;++o)i=e[(r=this._fields[o]).name],r.required&&null===i?null===c&&(c=r):r.encode(n?i:r.verifyValue(i),t,e);if(null!==c)throw(a=Error("Missing at least one required field for "+this.toString(!0)+": "+c)).encoded=t,a;return t},d.calculate=function(e){for(var t,n,r=0,i=0,o=this._fields.length;o>i;++i){if(n=e[(t=this._fields[i]).name],t.required&&null===n)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(n,e)}return r},d.decode=function(e,n,r){var o,s,a,c,u,d,l,h,f,p,g,m;for(n="number"==typeof n?n:-1,u=e.offset,d=new this.clazz;e.offset0;){if(a=(o=e.readVarint32())>>>3,(s=7&o)===t.WIRE_TYPES.ENDGROUP){if(a!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+a+" ("+(r?r+" expected":"not a group")+")");break}if(c=this._fieldsById[a])c.repeated&&!c.options.packed?d[c.name].push(c.decode(s,e)):c.map?(h=c.decode(s,e),d[c.name].set(h[0],h[1])):(d[c.name]=c.decode(s,e),c.oneof&&(null!==(f=d[c.oneof.name])&&f!==c.name&&(d[f]=null),d[c.oneof.name]=c.name));else switch(s){case t.WIRE_TYPES.VARINT:e.readVarint32();break;case t.WIRE_TYPES.BITS32:e.offset+=4;break;case t.WIRE_TYPES.BITS64:e.offset+=8;break;case t.WIRE_TYPES.LDELIM:l=e.readVarint32(),e.offset+=l;break;case t.WIRE_TYPES.STARTGROUP:for(;i(a,e););break;default:throw Error("Illegal wire type for unknown field "+a+" in "+this.toString(!0)+"#decode: "+s)}}for(p=0,g=this._fields.length;g>p;++p)if(null===d[(c=this._fields[p]).name])if("proto3"===this.syntax)d[c.name]=c.defaultValue;else{if(c.required)throw(m=Error("Missing at least one required field for "+this.toString(!0)+": "+c.name)).decoded=d,m;t.populateDefaults&&null!==c.defaultValue&&(d[c.name]=c.defaultValue)}return d},C.Message=u,(h=(l=function(e,n,r,i,o,s,a,c,d,l){E.call(this,e,n,s),this.className="Message.Field",this.required="required"===r,this.repeated="repeated"===r,this.map="map"===r,this.keyType=i||null,this.type=o,this.resolvedType=null,this.id=a,this.options=c||{},this.defaultValue=null,this.oneof=d||null,this.syntax=l||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=t.Util.toCamelCase(this.name))}).prototype=Object.create(E.prototype)).build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=a.defaultFieldValue(this.type)},h.verifyValue=function(e,n){var r,i,o;if(n=n||!1,r=function(e,t){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+e+" ("+t+")")}.bind(this),null===e)return this.required&&r(S(e),"required"),"proto3"===this.syntax&&this.type!==t.TYPES.message&&r(S(e),"proto3 field without field presence cannot be null"),null;if(this.repeated&&!n){for(Array.isArray(e)||(e=[e]),o=[],i=0;i0;case t.TYPES.bytes:return e.remaining()>0;case t.TYPES.enum:return 0!==e;case t.TYPES.message:return null!==e;default:return!0}},h.encode=function(e,r,i){var o,s,a,c,u;if(null===this.type||"object"!=S(this.type))throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===e||this.repeated&&0==e.length)return r;try{if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(r.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1),s=r.offset,o=0;o1&&(u=r.slice(s,r.offset),s+=c-1,r.offset=s,r.append(u)),r.writeVarint32(a,s-c)}else for(o=0;o=0){for(i+=n.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),s=0,o=0;o=0&&!r){for(o=n.readVarint32(),o=n.offset+o,s=[];n.offset0;)if(e=7&(d=u.readVarint32()),1==(l=d>>>3))c=this.keyElement.decode(u,e,l);else{if(2!==l)throw Error("Unexpected tag in map field key/value submessage");i=this.element.decode(u,e,l)}return[c,i]}return this.element.decode(n,e,this.id)},C.Message.Field=l,(f=function(e,t,n,r,i,o,s){l.call(this,e,t,n,null,r,i,o,s),this.extension}).prototype=Object.create(l.prototype),C.Message.ExtensionField=f,p=function(e,t,n){E.call(this,e,t,n),this.fields=[]},C.Message.OneOf=p,(g=function(e,t,n,r,i){o.call(this,e,t,n,r,i),this.className="Enum",this.object=null}).getName=function(e,t){var n,r,i=Object.keys(e);for(r=0;ri;++i)n[r[i].name]=r[i].id;return Object.defineProperty&&Object.defineProperty(n,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=n},C.Enum=g,(m=function(e,t,n,r){E.call(this,e,t,n),this.className="Enum.Value",this.id=r}).prototype=Object.create(E.prototype),C.Enum.Value=m,(v=function(e,t,n,r){E.call(this,e,t,n),this.field=r}).prototype=Object.create(E.prototype),C.Extension=v,((_=function(e,t,n,r){o.call(this,e,t,n,r),this.className="Service",this.clazz=null}).prototype=Object.create(o.prototype)).build=function(e){return this.clazz&&!e?this.clazz:this.clazz=function(e,t){var r,i=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,n){setTimeout(n.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},o=i.prototype=Object.create(e.Builder.Service.prototype),s=t.getChildren(e.Reflect.Service.RPCMethod);for(r=0;r0;){if(t=r.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){if(o=t.shift(),i.isMessage(o)){if(s=new n.Message(this,this.ptr,o.name,o.options,o.isGroup,o.syntax),a={},o.oneofs&&Object.keys(o.oneofs).forEach((function(e){s.addChild(a[e]=new n.Message.OneOf(this,s,e))}),this),o.fields&&o.fields.forEach((function(e){if(null!==s.getChild(0|e.id))throw Error("duplicate or invalid field id in "+s.name+": "+e.id);if(e.options&&"object"!=S(e.options))throw Error("illegal field options in "+s.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+s.name+"#"+e.name+": "+e.oneof);e=new n.Message.Field(this,s,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,o.syntax),t&&t.fields.push(e),s.addChild(e)}),this),c=[],o.enums&&o.enums.forEach((function(e){c.push(e)})),o.messages&&o.messages.forEach((function(e){c.push(e)})),o.services&&o.services.forEach((function(e){c.push(e)})),o.extensions&&(s.extensions="number"==typeof o.extensions[0]?[o.extensions]:o.extensions),this.ptr.addChild(s),c.length>0){r.push(t),t=c,c=null,this.ptr=s,s=null;continue}c=null}else if(i.isEnum(o))s=new n.Enum(this,this.ptr,o.name,o.options,o.syntax),o.values.forEach((function(e){s.addChild(new n.Enum.Value(this,s,e.name,e.id))}),this),this.ptr.addChild(s);else if(i.isService(o))s=new n.Service(this,this.ptr,o.name,o.options),Object.keys(o.rpc).forEach((function(e){var t=o.rpc[e];s.addChild(new n.Service.RPCMethod(this,s,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))}),this),this.ptr.addChild(s);else{if(!i.isExtend(o))throw Error("not a valid definition: "+JSON.stringify(o));if(s=this.ptr.resolve(o.ref,!0))o.fields.forEach((function(t){var r,i,o,a;if(null!==s.getChild(0|t.id))throw Error("duplicate extended field id in "+s.name+": "+t.id);if(s.extensions&&(r=!1,s.extensions.forEach((function(e){t.id>=e[0]&&t.id<=e[1]&&(r=!0)})),!r))throw Error("illegal extended field id in "+s.name+": "+t.id+" (not within valid ranges)");i=t.name,this.options.convertFieldsToCamelCase&&(i=e.Util.toCamelCase(i)),o=new n.Message.ExtensionField(this,s,t.rule,t.type,this.ptr.fqn()+"."+i,t.id,t.options),a=new n.Extension(this,this.ptr,t.name,o),o.extension=a,this.ptr.addChild(a),s.addChild(o)}),this);else if(!/\.?google\.protobuf\./.test(o.ref))throw Error("extended message "+o.ref+" is not defined")}o=null,s=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},o.import=function(t,n){var i,o,s,a,c,u,d,l,h="/";if("string"==typeof n){if(e.Util.IS_NODE,!0===this.files[n])return this.reset();this.files[n]=!0}else if("object"==S(n)){if(i=n.root,e.Util.IS_NODE,(i.indexOf("\\")>=0||n.file.indexOf("\\")>=0)&&(h="\\"),o=i+h+n.file,!0===this.files[o])return this.reset();this.files[o]=!0}if(t.imports&&t.imports.length>0){for(a=!1,"object"==S(n)?(this.importRoot=n.root,a=!0,s=this.importRoot,n=n.file,(s.indexOf("\\")>=0||n.indexOf("\\")>=0)&&(h="\\")):"string"==typeof n?this.importRoot?s=this.importRoot:n.indexOf("/")>=0?""===(s=n.replace(/\/[^\/]*$/,""))&&(s="/"):n.indexOf("\\")>=0?(s=n.replace(/\\[^\\]*$/,""),h="\\"):s=".":s=null,c=0;c1024&&(t.push(a.apply(String,e)),e.length=0),void Array.prototype.push.apply(e,arguments))}}function r(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<>1,d=-7,l=n?i-1:0,h=n?-1:1,f=e[t+l];for(l+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+l],l+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+l],l+=h,d-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=u}return(f?-1:1)*s*Math.pow(2,o-r)}function i(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,d=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?h/c:h*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=d?(a=0,s=d):s+l>=1?(a=(t*c-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<0;e[n+f]=255&s,f+=p,s/=256,u-=8);e[n+f-p]|=128*g}var o,s,a,c,u,d=function e(t,n,r){if(void 0===t&&(t=e.DEFAULT_CAPACITY),void 0===n&&(n=e.DEFAULT_ENDIAN),void 0===r&&(r=e.DEFAULT_NOASSERT),!r){if((t|=0)<0)throw RangeError("Illegal capacity");n=!!n,r=!!r}this.buffer=0===t?s:new ArrayBuffer(t),this.view=0===t?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=t,this.littleEndian=n,this.noAssert=r};return d.VERSION="5.0.1",d.LITTLE_ENDIAN=!0,d.BIG_ENDIAN=!1,d.DEFAULT_CAPACITY=16,d.DEFAULT_ENDIAN=d.BIG_ENDIAN,d.DEFAULT_NOASSERT=!1,d.Long=e||null,(o=d.prototype).__isByteBuffer__,Object.defineProperty(o,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),s=new ArrayBuffer(0),a=String.fromCharCode,d.accessor=function(){return Uint8Array},d.allocate=function(e,t,n){return new d(e,t,n)},d.concat=function(e,t,n,r){var i,o,s,a,c,u;for(("boolean"==typeof t||"string"!=typeof t)&&(r=n,n=t,t=void 0),i=0,s=0,a=e.length;a>s;++s)d.isByteBuffer(e[s])||(e[s]=d.wrap(e[s],t)),(o=e[s].limit-e[s].offset)>0&&(i+=o);if(0===i)return new d(0,n,r);for(u=new d(i,n,r),s=0;a>s;)(o=(c=e[s++]).limit-c.offset)<=0||(u.view.set(c.view.subarray(c.offset,c.limit),u.offset),u.offset+=o);return u.limit=u.offset,u.offset=0,u},d.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},d.type=function(){return ArrayBuffer},d.wrap=function(e,t,n,r){var i,s;if("string"!=typeof t&&(r=n,n=t,t=void 0),"string"==typeof e)switch(void 0===t&&(t="utf8"),t){case"base64":return d.fromBase64(e,n);case"hex":return d.fromHex(e,n);case"binary":return d.fromBinary(e,n);case"utf8":return d.fromUTF8(e,n);case"debug":return d.fromDebug(e,n);default:throw Error("Unsupported encoding: "+t)}if(null===e||"object"!=S(e))throw TypeError("Illegal buffer");if(d.isByteBuffer(e))return(i=o.clone.call(e)).markedOffset=-1,i;if(e instanceof Uint8Array)i=new d(0,n,r),e.length>0&&(i.buffer=e.buffer,i.offset=e.byteOffset,i.limit=e.byteOffset+e.byteLength,i.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)i=new d(0,n,r),e.byteLength>0&&(i.buffer=e,i.offset=0,i.limit=e.byteLength,i.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");for((i=new d(e.length,n,r)).limit=e.length,s=0;s>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}for(r=t,o=(i=e.length)>>3,s=0,t+=this.writeVarint32(i,t);o--;)n=1&!!e[s++]|(1&!!e[s++])<<1|(1&!!e[s++])<<2|(1&!!e[s++])<<3|(1&!!e[s++])<<4|(1&!!e[s++])<<5|(1&!!e[s++])<<6|(1&!!e[s++])<<7,this.writeByte(n,t++);if(i>s){for(a=0,n=0;i>s;)n|=(1&!!e[s++])<>3,o=0,s=[],e+=n.length;i--;)t=this.readByte(e++),s[o++]=!!(1&t),s[o++]=!!(2&t),s[o++]=!!(4&t),s[o++]=!!(8&t),s[o++]=!!(16&t),s[o++]=!!(32&t),s[o++]=!!(64&t),s[o++]=!!(128&t);if(r>o)for(a=0,t=this.readByte(e++);r>o;)s[o++]=!!(1&t>>a++);return c&&(this.offset=e),s},o.readBytes=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}return n=this.slice(t,t+e),r&&(this.offset+=e),n},o.writeBytes=o.append,o.writeInt8=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=1)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},o.writeByte=o.writeInt8,o.readInt8=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}return 128==(128&(t=this.view[e]))&&(t=-(255-t+1)),n&&(this.offset+=1),t},o.readByte=o.readInt8,o.writeUint8=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=1)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},o.writeUInt8=o.writeUint8,o.readUint8=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}return t=this.view[e],n&&(this.offset+=1),t},o.readUInt8=o.readUint8,o.writeInt16=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=2)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},o.writeShort=o.writeInt16,o.readInt16=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}return t=0,this.littleEndian?(t=this.view[e],t|=this.view[e+1]<<8):(t=this.view[e]<<8,t|=this.view[e+1]),32768==(32768&t)&&(t=-(65535-t+1)),n&&(this.offset+=2),t},o.readShort=o.readInt16,o.writeUint16=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=2)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},o.writeUInt16=o.writeUint16,o.readUint16=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}return t=0,this.littleEndian?(t=this.view[e],t|=this.view[e+1]<<8):(t=this.view[e]<<8,t|=this.view[e+1]),n&&(this.offset+=2),t},o.readUInt16=o.readUint16,o.writeInt32=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=4)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=255&e>>>24,this.view[t+2]=255&e>>>16,this.view[t+1]=255&e>>>8,this.view[t]=255&e):(this.view[t]=255&e>>>24,this.view[t+1]=255&e>>>16,this.view[t+2]=255&e>>>8,this.view[t+3]=255&e),r&&(this.offset+=4),this},o.writeInt=o.writeInt32,o.readInt32=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}return t=0,this.littleEndian?(t=this.view[e+2]<<16,t|=this.view[e+1]<<8,t|=this.view[e],t+=this.view[e+3]<<24>>>0):(t=this.view[e+1]<<16,t|=this.view[e+2]<<8,t|=this.view[e+3],t+=this.view[e]<<24>>>0),t|=0,n&&(this.offset+=4),t},o.readInt=o.readInt32,o.writeUint32=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=4)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=255&e>>>24,this.view[t+2]=255&e>>>16,this.view[t+1]=255&e>>>8,this.view[t]=255&e):(this.view[t]=255&e>>>24,this.view[t+1]=255&e>>>16,this.view[t+2]=255&e>>>8,this.view[t+3]=255&e),r&&(this.offset+=4),this},o.writeUInt32=o.writeUint32,o.readUint32=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}return t=0,this.littleEndian?(t=this.view[e+2]<<16,t|=this.view[e+1]<<8,t|=this.view[e],t+=this.view[e+3]<<24>>>0):(t=this.view[e+1]<<16,t|=this.view[e+2]<<8,t|=this.view[e+3],t+=this.view[e]<<24>>>0),n&&(this.offset+=4),t},o.readUInt32=o.readUint32,e&&(o.writeInt64=function(t,n){var r,i,o,s=void 0===n;if(s&&(n=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),(n+=8)>(r=this.buffer.byteLength)&&this.resize((r*=2)>n?r:n),n-=8,i=t.low,o=t.high,this.littleEndian?(this.view[n+3]=255&i>>>24,this.view[n+2]=255&i>>>16,this.view[n+1]=255&i>>>8,this.view[n]=255&i,n+=4,this.view[n+3]=255&o>>>24,this.view[n+2]=255&o>>>16,this.view[n+1]=255&o>>>8,this.view[n]=255&o):(this.view[n]=255&o>>>24,this.view[n+1]=255&o>>>16,this.view[n+2]=255&o>>>8,this.view[n+3]=255&o,n+=4,this.view[n]=255&i>>>24,this.view[n+1]=255&i>>>16,this.view[n+2]=255&i>>>8,this.view[n+3]=255&i),s&&(this.offset+=8),this},o.writeLong=o.writeInt64,o.readInt64=function(t){var n,r,i,o=void 0===t;if(o&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}return n=0,r=0,this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0):(r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0),i=new e(n,r,!1),o&&(this.offset+=8),i},o.readLong=o.readInt64,o.writeUint64=function(t,n){var r,i,o,s=void 0===n;if(s&&(n=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),(n+=8)>(r=this.buffer.byteLength)&&this.resize((r*=2)>n?r:n),n-=8,i=t.low,o=t.high,this.littleEndian?(this.view[n+3]=255&i>>>24,this.view[n+2]=255&i>>>16,this.view[n+1]=255&i>>>8,this.view[n]=255&i,n+=4,this.view[n+3]=255&o>>>24,this.view[n+2]=255&o>>>16,this.view[n+1]=255&o>>>8,this.view[n]=255&o):(this.view[n]=255&o>>>24,this.view[n+1]=255&o>>>16,this.view[n+2]=255&o>>>8,this.view[n+3]=255&o,n+=4,this.view[n]=255&i>>>24,this.view[n+1]=255&i>>>16,this.view[n+2]=255&i>>>8,this.view[n+3]=255&i),s&&(this.offset+=8),this},o.writeUInt64=o.writeUint64,o.readUint64=function(t){var n,r,i,o=void 0===t;if(o&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}return n=0,r=0,this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0):(r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0),i=new e(n,r,!0),o&&(this.offset+=8),i},o.readUInt64=o.readUint64),o.writeFloat32=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=4)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=4,i(this.view,e,t,this.littleEndian,23,4),r&&(this.offset+=4),this},o.writeFloat=o.writeFloat32,o.readFloat32=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}return t=r(this.view,e,this.littleEndian,23,4),n&&(this.offset+=4),t},o.readFloat=o.readFloat32,o.writeFloat64=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}return(t+=8)>(n=this.buffer.byteLength)&&this.resize((n*=2)>t?n:t),t-=8,i(this.view,e,t,this.littleEndian,52,8),r&&(this.offset+=8),this},o.writeDouble=o.writeFloat64,o.readFloat64=function(e){var t,n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}return t=r(this.view,e,this.littleEndian,52,8),n&&(this.offset+=8),t},o.readDouble=o.readFloat64,d.MAX_VARINT32_BYTES=5,d.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:1<<21>e?3:1<<28>e?4:5},d.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},d.zigZagDecode32=function(e){return 0|e>>>1^-(1&e)},o.writeVarint32=function(e,t){var n,r,i,o=void 0===t;if(o&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}for((t+=r=d.calculateVarint32(e))>(i=this.buffer.byteLength)&&this.resize((i*=2)>t?i:t),t-=r,e>>>=0;e>=128;)n=128|127&e,this.view[t++]=n,e>>>=7;return this.view[t++]=e,o?(this.offset=t,this):r},o.writeVarint32ZigZag=function(e,t){return this.writeVarint32(d.zigZagEncode32(e),t)},o.readVarint32=function(e){var t,n,r,i,o=void 0===e;if(o&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}n=0,r=0;do{if(!this.noAssert&&e>this.limit)throw(i=Error("Truncated")).truncated=!0,i;t=this.view[e++],n<5&&(r|=(127&t)<<7*n),++n}while(0!=(128&t));return r|=0,o?(this.offset=e,r):{value:r,length:n}},o.readVarint32ZigZag=function(e){var t=this.readVarint32(e);return"object"==S(t)?t.value=d.zigZagDecode32(t.value):t=d.zigZagDecode32(t),t},e&&(d.MAX_VARINT64_BYTES=10,d.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var n=t.toInt()>>>0,r=t.shiftRightUnsigned(28).toInt()>>>0,i=t.shiftRightUnsigned(56).toInt()>>>0;return 0==i?0==r?n<16384?n<128?1:2:1<<21>n?3:4:r<16384?r<128?5:6:1<<21>r?7:8:i<128?9:10},d.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},d.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},o.writeVarint64=function(t,n){var r,i,o,s,a,c=void 0===n;if(c&&(n=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}switch("number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),r=d.calculateVarint64(t),i=t.toInt()>>>0,o=t.shiftRightUnsigned(28).toInt()>>>0,s=t.shiftRightUnsigned(56).toInt()>>>0,(n+=r)>(a=this.buffer.byteLength)&&this.resize((a*=2)>n?a:n),n-=r,r){case 10:this.view[n+9]=1&s>>>7;case 9:this.view[n+8]=9!==r?128|s:127&s;case 8:this.view[n+7]=8!==r?128|o>>>21:127&o>>>21;case 7:this.view[n+6]=7!==r?128|o>>>14:127&o>>>14;case 6:this.view[n+5]=6!==r?128|o>>>7:127&o>>>7;case 5:this.view[n+4]=5!==r?128|o:127&o;case 4:this.view[n+3]=4!==r?128|i>>>21:127&i>>>21;case 3:this.view[n+2]=3!==r?128|i>>>14:127&i>>>14;case 2:this.view[n+1]=2!==r?128|i>>>7:127&i>>>7;case 1:this.view[n]=1!==r?128|i:127&i}return c?(this.offset+=r,this):r},o.writeVarint64ZigZag=function(e,t){return this.writeVarint64(d.zigZagEncode64(e),t)},o.readVarint64=function(t){var n,r,i,o,s,a,c=void 0===t;if(c&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}if(n=t,r=0,i=0,o=0,s=0,r=127&(s=this.view[t++]),128&s&&(r|=(127&(s=this.view[t++]))<<7,(128&s||this.noAssert&&void 0===s)&&(r|=(127&(s=this.view[t++]))<<14,(128&s||this.noAssert&&void 0===s)&&(r|=(127&(s=this.view[t++]))<<21,(128&s||this.noAssert&&void 0===s)&&(i=127&(s=this.view[t++]),(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[t++]))<<7,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[t++]))<<14,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[t++]))<<21,(128&s||this.noAssert&&void 0===s)&&(o=127&(s=this.view[t++]),(128&s||this.noAssert&&void 0===s)&&(o|=(127&(s=this.view[t++]))<<7,128&s||this.noAssert&&void 0===s))))))))))throw Error("Buffer overrun");return a=e.fromBits(r|i<<28,i>>>4|o<<24,!1),c?(this.offset=t,a):{value:a,length:t-n}},o.readVarint64ZigZag=function(t){var n=this.readVarint64(t);return n&&n.value instanceof e?n.value=d.zigZagDecode64(n.value):n=d.zigZagDecode64(n),n}),o.writeCString=function(e,n){var r,i,o,s=void 0===n;if(s&&(n=this.offset),i=e.length,!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(r=0;i>r;++r)if(0===e.charCodeAt(r))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return i=u.calculateUTF16asUTF8(t(e))[1],n+=i+1,o=this.buffer.byteLength,n>o&&this.resize((o*=2)>n?o:n),n-=i+1,u.encodeUTF16toUTF8(t(e),function(e){this.view[n++]=e}.bind(this)),this.view[n++]=0,s?(this.offset=n,this):i},o.readCString=function(e){var t,r,i,o=void 0===e;if(o&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}return t=e,i=-1,u.decodeUTF8toUTF16(function(){if(0===i)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(i=this.view[e++])?null:i}.bind(this),r=n(),!0),o?(this.offset=e,r()):{string:r(),length:e-t}},o.writeIString=function(e,n){var r,i,o,s=void 0===n;if(s&&(n=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}if(i=n,r=u.calculateUTF16asUTF8(t(e),this.noAssert)[1],n+=4+r,o=this.buffer.byteLength,n>o&&this.resize((o*=2)>n?o:n),n-=4+r,this.littleEndian?(this.view[n+3]=255&r>>>24,this.view[n+2]=255&r>>>16,this.view[n+1]=255&r>>>8,this.view[n]=255&r):(this.view[n]=255&r>>>24,this.view[n+1]=255&r>>>16,this.view[n+2]=255&r>>>8,this.view[n+3]=255&r),n+=4,u.encodeUTF16toUTF8(t(e),function(e){this.view[n++]=e}.bind(this)),n!==i+4+r)throw RangeError("Illegal range: Truncated data, "+n+" == "+(n+4+r));return s?(this.offset=n,this):n-i},o.readIString=function(e){var t,n,r,i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}return t=e,n=this.readUint32(e),r=this.readUTF8String(n,d.METRICS_BYTES,e+=4),e+=r.length,i?(this.offset=e,r.string):{string:r.string,length:e-t}},d.METRICS_CHARS="c",d.METRICS_BYTES="b",o.writeUTF8String=function(e,n){var r,i,o,s=void 0===n;if(s&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return i=n,r=u.calculateUTF16asUTF8(t(e))[1],n+=r,o=this.buffer.byteLength,n>o&&this.resize((o*=2)>n?o:n),n-=r,u.encodeUTF16toUTF8(t(e),function(e){this.view[n++]=e}.bind(this)),s?(this.offset=n,this):n-i},o.writeString=o.writeUTF8String,d.calculateUTF8Chars=function(e){return u.calculateUTF16asUTF8(t(e))[0]},d.calculateString=d.calculateUTF8Bytes=function(e){return u.calculateUTF16asUTF8(t(e))[1]},o.readUTF8String=function(e,t,r){var i,o,s,a,c;if("number"==typeof t&&(r=t,t=void 0),(i=void 0===r)&&(r=this.offset),void 0===t&&(t=d.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}if(s=0,a=r,t===d.METRICS_CHARS){if(o=n(),u.decodeUTF8(function(){return e>s&&r>>=0)<0||r+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+"+e+") <= "+this.buffer.byteLength)}if(c=r+e,u.decodeUTF8toUTF16(function(){return c>r?this.view[r++]:null}.bind(this),o=n(),this.noAssert),r!==c)throw RangeError("Illegal range: Truncated data, "+r+" == "+c);return i?(this.offset=r,o()):{string:o(),length:r-a}}throw TypeError("Unsupported metrics: "+t)},o.readString=o.readUTF8String,o.writeVString=function(e,n){var r,i,o,s,a=void 0===n;if(a&&(n=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}if(o=n,r=u.calculateUTF16asUTF8(t(e),this.noAssert)[1],i=d.calculateVarint32(r),n+=i+r,s=this.buffer.byteLength,n>s&&this.resize((s*=2)>n?s:n),n-=i+r,n+=this.writeVarint32(r,n),u.encodeUTF16toUTF8(t(e),function(e){this.view[n++]=e}.bind(this)),n!==o+r+i)throw RangeError("Illegal range: Truncated data, "+n+" == "+(n+r+i));return a?(this.offset=n,this):n-o},o.readVString=function(e){var t,n,r,i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}return t=e,n=this.readVarint32(e),r=this.readUTF8String(n.value,d.METRICS_BYTES,e+=n.length),e+=r.length,i?(this.offset=e,r.string):{string:r.string,length:e-t}},o.append=function(e,t,n){var r,i,o;if(("number"==typeof t||"string"!=typeof t)&&(n=t,t=void 0),(r=void 0===n)&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return e instanceof d||(e=d.wrap(e,t)),(i=e.limit-e.offset)<=0||((n+=i)>(o=this.buffer.byteLength)&&this.resize((o*=2)>n?o:n),n-=i,this.view.set(e.view.subarray(e.offset,e.limit),n),e.offset+=i,r&&(this.offset+=i)),this},o.appendTo=function(e,t){return e.append(this,t),this},o.assert=function(e){return this.noAssert=!e,this},o.capacity=function(){return this.buffer.byteLength},o.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},o.clone=function(e){var t=new d(0,this.littleEndian,this.noAssert);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),t.view=new Uint8Array(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t},o.compact=function(e,t){var n,r,i;if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return 0===e&&t===this.buffer.byteLength?this:0==(n=t-e)?(this.buffer=s,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this):(r=new ArrayBuffer(n),(i=new Uint8Array(r)).set(this.view.subarray(e,t)),this.buffer=r,this.view=i,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=n,this)},o.copy=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(e===t)return new d(0,this.littleEndian,this.noAssert);var n=t-e,r=new d(n,this.littleEndian,this.noAssert);return r.offset=0,r.limit=n,r.markedOffset>=0&&(r.markedOffset-=e),this.copyTo(r,0,e,t),r},o.copyTo=function(e,t,n,r){var i,o,s;if(!this.noAssert&&!d.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(t=(o=void 0===t)?e.offset:0|t,n=(i=void 0===n)?this.offset:0|n,r=void 0===r?this.limit:0|r,t<0||t>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+t+" <= "+e.buffer.byteLength);if(n<0||r>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+n+" <= "+this.buffer.byteLength);return 0==(s=r-n)?e:(e.ensureCapacity(t+s),e.view.set(this.view.subarray(n,r),t),i&&(this.offset+=s),o&&(e.offset+=s),this)},o.ensureCapacity=function(e){var t=this.buffer.byteLength;return e>t?this.resize((t*=2)>e?t:e):this},o.fill=function(e,t,n){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===n&&(n=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal end: Not an integer");if(n>>>=0,t<0||t>n||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}if(t>=n)return this;for(;n>t;)this.view[t++]=e;return r&&(this.offset=t),this},o.flip=function(){return this.limit=this.offset,this.offset=0,this},o.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},o.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},o.LE=function(e){return this.littleEndian=void 0===e||!!e,this},o.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},o.prepend=function(e,t,n){var r,i,o,s,a;if(("number"==typeof t||"string"!=typeof t)&&(n=t,t=void 0),(r=void 0===n)&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}return e instanceof d||(e=d.wrap(e,t)),(i=e.limit-e.offset)<=0||((o=i-n)>0?(s=new ArrayBuffer(this.buffer.byteLength+o),(a=new Uint8Array(s)).set(this.view.subarray(n,this.buffer.byteLength),i),this.buffer=s,this.view=a,this.offset+=o,this.markedOffset>=0&&(this.markedOffset+=o),this.limit+=o,n+=o):new Uint8Array(this.buffer),this.view.set(e.view.subarray(e.offset,e.limit),n-i),e.offset=e.limit,r&&(this.offset-=i)),this},o.prependTo=function(e,t){return e.prepend(this,t),this},o.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},o.remaining=function(){return this.limit-this.offset},o.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},o.resize=function(e){var t,n;if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}return this.buffer.byteLength>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},o.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},o.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var n=this.clone();return n.offset=e,n.limit=t,n},o.toBuffer=function(e){var t,n=this.offset,r=this.limit;if(!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: Not an integer");if(n>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal limit: Not an integer");if(r>>>=0,n<0||n>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+n+" <= "+r+" <= "+this.buffer.byteLength)}return e||0!==n||r!==this.buffer.byteLength?n===r?s:(t=new ArrayBuffer(r-n),new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(n,r),0),t):this.buffer},o.toArrayBuffer=o.toBuffer,o.toString=function(e,t,n){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(n=t=e="utf8"),e){case"utf8":return this.toUTF8(t,n);case"base64":return this.toBase64(t,n);case"hex":return this.toHex(t,n);case"binary":return this.toBinary(t,n);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}},c=function(){var e,t,n={},r=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],i=[];for(e=0,t=r.length;t>e;++e)i[r[e]]=e;return n.encode=function(e,t){for(var n,i;null!==(n=e());)t(r[63&n>>2]),i=(3&n)<<4,null!==(n=e())?(t(r[63&((i|=15&n>>4)|15&n>>4)]),i=(15&n)<<2,null!==(n=e())?(t(r[63&(i|3&n>>6)]),t(r[63&n])):(t(r[63&i]),t(61))):(t(r[63&i]),t(61),t(61))},n.decode=function(e,t){function n(e){throw Error("Illegal character code: "+e)}for(var r,o,s;null!==(r=e());)if(void 0===(o=i[r])&&n(r),null!==(r=e())&&(void 0===(s=i[r])&&n(r),t(o<<2>>>0|(48&s)>>4),null!==(r=e()))){if(void 0===(o=i[r])){if(61===r)break;n(r)}if(t((15&s)<<4>>>0|(60&o)>>2),null!==(r=e())){if(void 0===(s=i[r])){if(61===r)break;n(r)}t((3&o)<<6>>>0|s)}}},n.test=function(e){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e)},n}(),o.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var r;return c.encode(function(){return t>e?this.view[e++]:null}.bind(this),r=n()),r()},d.fromBase64=function(e,n){if("string"!=typeof e)throw TypeError("str");var r=new d(e.length/4*3,n),i=0;return c.decode(t(e),(function(e){r.view[i++]=e})),r.limit=i,r},d.btoa=function(e){return d.fromBinary(e).toBase64()},d.atob=function(e){return d.fromBase64(e).toBinary()},o.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var n=[],r=[];t>e;)n.push(this.view[e++]),n.length>=1024&&(r.push(String.fromCharCode.apply(String,n)),n=[]);return r.join("")+String.fromCharCode.apply(String,n)},d.fromBinary=function(e,t){if("string"!=typeof e)throw TypeError("str");for(var n,r=0,i=e.length,o=new d(i,t);i>r;){if((n=e.charCodeAt(r))>255)throw RangeError("illegal char code: "+n);o.view[r++]=n}return o.limit=i,o},o.toDebug=function(e){for(var t,n=-1,r=this.buffer.byteLength,i="",o="",s="";r>n;){if(-1!==n&&(i+=(t=this.view[n])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(o+=t>32&&t<127?String.fromCharCode(t):".")),++n,e&&n>0&&n%16==0&&n!==r){for(;i.length<51;)i+=" ";s+=i+o+"\n",i=o=""}i+=n===this.offset&&n===this.limit?n===this.markedOffset?"!":"|":n===this.offset?n===this.markedOffset?"[":"<":n===this.limit?n===this.markedOffset?"]":">":n===this.markedOffset?"'":e||0!==n&&n!==r?" ":""}if(e&&" "!==i){for(;i.length<51;)i+=" ";s+=i+o+"\n"}return e?s:i},d.fromDebug=function(e,t,n){for(var r,i,o=e.length,s=new d(0|(o+1)/3,t,n),a=0,c=0,u=!1,l=!1,h=!1,f=!1,p=!1;o>a;){switch(r=e.charAt(a++)){case"!":if(!n){if(l||h||f){p=!0;break}l=h=f=!0}s.offset=s.markedOffset=s.limit=c,u=!1;break;case"|":if(!n){if(l||f){p=!0;break}l=f=!0}s.offset=s.limit=c,u=!1;break;case"[":if(!n){if(l||h){p=!0;break}l=h=!0}s.offset=s.markedOffset=c,u=!1;break;case"<":if(!n){if(l){p=!0;break}l=!0}s.offset=c,u=!1;break;case"]":if(!n){if(f||h){p=!0;break}f=h=!0}s.limit=s.markedOffset=c,u=!1;break;case">":if(!n){if(f){p=!0;break}f=!0}s.limit=c,u=!1;break;case"'":if(!n){if(h){p=!0;break}h=!0}s.markedOffset=c,u=!1;break;case" ":u=!1;break;default:if(!n&&u){p=!0;break}if(i=parseInt(r+e.charAt(a++),16),!n&&(isNaN(i)||i<0||i>255))throw TypeError("Illegal str: Not a debug encoded string");s.view[c++]=i,u=!0}if(p)throw TypeError("Illegal str: Invalid symbol at "+a)}if(!n){if(!l||!f)throw TypeError("Illegal str: Missing offset or limit");if(c>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var n,r=new Array(t-e);t>e;)(n=this.view[e++])<16?r.push("0",n.toString(16)):r.push(n.toString(16));return r.join("")},d.fromHex=function(e,t,n){var r,i,o,s,a;if(!n){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(i=e.length,o=new d(0|i/2,t),s=0,a=0;i>s;s+=2){if(r=parseInt(e.substring(s,s+2),16),!n&&(!isFinite(r)||r<0||r>255))throw TypeError("Illegal str: Contains non-hex characters");o.view[a++]=r}return o.limit=a,o},u=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<128?t(127&n):n<2048?(t(192|31&n>>6),t(128|63&n)):n<65536?(t(224|15&n>>12),t(128|63&n>>6),t(128|63&n)):(t(240|7&n>>18),t(128|63&n>>12),t(128|63&n>>6),t(128|63&n)),n=null},decodeUTF8:function(e,t){for(var n,r,i,o,s=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(n=e());)if(0==(128&n))t(n);else if(192==(224&n))null===(r=e())&&s([n,r]),t((31&n)<<6|63&r);else if(224==(240&n))(null===(r=e())||null===(i=e()))&&s([n,r,i]),t((15&n)<<12|(63&r)<<6|63&i);else{if(240!=(248&n))throw RangeError("Illegal starting byte: "+n);(null===(r=e())||null===(i=e())||null===(o=e()))&&s([n,r,i,o]),t((7&n)<<18|(63&r)<<12|(63&i)<<6|63&o)}},UTF16toUTF8:function(e,t){for(var n,r=null;null!==(n=null!==r?r:e());)n>=55296&&n<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(n-55296)+r-56320+65536),r=null):t(n);null!==r&&t(r)},UTF8toUTF16:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<=65535?t(n):(t(55296+((n-=65536)>>10)),t(n%1024+56320)),n=null},encodeUTF16toUTF8:function(t,n){e.UTF16toUTF8(t,(function(t){e.encodeUTF8(t,n)}))},decodeUTF8toUTF16:function(t,n){e.decodeUTF8(t,(function(t){e.UTF8toUTF16(t,n)}))},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,n=0;null!==(t=e());)n+=t<128?1:t<2048?2:t<65536?3:4;return n},calculateUTF16asUTF8:function(t){var n=0,r=0;return e.UTF16toUTF8(t,(function(e){++n,r+=e<128?1:e<2048?2:e<65536?3:4})),[n,r]}};return e}(),o.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r;try{u.decodeUTF8toUTF16(function(){return t>e?this.view[e++]:null}.bind(this),r=n())}catch(n){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return r()},d.fromUTF8=function(e,n,r){if(!r&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var i=new d(u.calculateUTF16asUTF8(t(e),!0)[1],n,r),o=0;return u.encodeUTF16toUTF8(t(e),(function(e){i.view[o++]=e})),i.limit=o,i},d}(Xr=function(){function e(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function t(e){return!0===(e&&e.__isLong__)}function n(e,t){var n,r,o;return t?(o=(e>>>=0)>=0&&e<256)&&(r=c[e])?r:(n=i(e,(0|e)<0?-1:0,!0),o&&(c[e]=n),n):(o=(e|=0)>=-128&&e<128)&&(r=a[e])?r:(n=i(e,e<0?-1:0,!1),o&&(a[e]=n),n)}function r(e,t){if(isNaN(e)||!isFinite(e))return t?g:p;if(t){if(e<0)return g;if(e>=l)return R}else{if(-h>=e)return C;if(e+1>=h)return y}return e<0?r(-e,t).neg():i(0|e%d,0|e/d,t)}function i(t,n,r){return new e(t,n,r)}function o(e,t,n){var i,s,a,c,d,l,h;if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return p;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||n>36)throw RangeError("radix");if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return o(e.substring(1),t,n).neg();for(s=r(u(n,8)),a=p,c=0;c>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},E.toString=function(e){var t,n,i,o,s,a,c,d;if((e=e||10)<2||e>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(C)?(t=r(e),i=(n=this.div(t)).mul(t).sub(this),n.toString(e)+i.toInt().toString(e)):"-"+this.neg().toString(e);for(o=r(u(e,6),this.unsigned),s=this,a="";;){if(c=s.div(o),d=(s.sub(c.mul(o)).toInt()>>>0).toString(e),(s=c).isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){var e,t;if(this.isNegative())return this.eq(C)?64:this.neg().getNumBitsAbs();for(e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},E.isOdd=function(){return 1==(1&this.low)},E.isEven=function(){return 0==(1&this.low)},E.equals=function(e){return t(e)||(e=s(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},E.eq=E.equals,E.notEquals=function(e){return!this.eq(e)},E.neq=E.notEquals,E.lessThan=function(e){return this.comp(e)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(e){return this.comp(e)<=0},E.lte=E.lessThanOrEqual,E.greaterThan=function(e){return this.comp(e)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(e){return this.comp(e)>=0},E.gte=E.greaterThanOrEqual,E.compare=function(e){if(t(e)||(e=s(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(m)},E.neg=E.negate,E.add=function(e){var n,r,o,a,c,u,d,l,h,f,p;return t(e)||(e=s(e)),n=this.high>>>16,r=65535&this.high,o=this.low>>>16,a=65535&this.low,c=e.high>>>16,u=65535&e.high,d=e.low>>>16,l=0,h=0,f=0,p=0,f+=(p+=a+(65535&e.low))>>>16,h+=(f+=o+d)>>>16,l+=(h+=r+u)>>>16,l+=n+c,i((f&=65535)<<16|(p&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},E.subtract=function(e){return t(e)||(e=s(e)),this.add(e.neg())},E.sub=E.subtract,E.multiply=function(e){var n,o,a,c,u,d,l,h,g,m,v,_;return this.isZero()?p:(t(e)||(e=s(e)),e.isZero()?p:this.eq(C)?e.isOdd()?C:p:e.eq(C)?this.isOdd()?C:p:this.isNegative()?e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg():e.isNegative()?this.mul(e.neg()).neg():this.lt(f)&&e.lt(f)?r(this.toNumber()*e.toNumber(),this.unsigned):(n=this.high>>>16,o=65535&this.high,a=this.low>>>16,c=65535&this.low,u=e.high>>>16,d=65535&e.high,l=e.low>>>16,g=0,m=0,v=0,_=0,v+=(_+=c*(h=65535&e.low))>>>16,m+=(v+=a*h)>>>16,v&=65535,m+=(v+=c*l)>>>16,g+=(m+=o*h)>>>16,m&=65535,g+=(m+=a*l)>>>16,m&=65535,g+=(m+=c*d)>>>16,g+=n*h+o*l+a*d+c*u,i((v&=65535)<<16|(_&=65535),(g&=65535)<<16|(m&=65535),this.unsigned)))},E.mul=E.multiply,E.divide=function(e){var n,i,o,a,c,d,l;if(t(e)||(e=s(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?g:p;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return g;if(e.gt(this.shru(1)))return v;o=g}else{if(this.eq(C))return e.eq(m)||e.eq(_)?C:e.eq(C)?m:(n=this.shr(1).div(e).shl(1)).eq(p)?e.isNegative()?m:_:(i=this.sub(e.mul(n)),o=n.add(i.div(e)));if(e.eq(C))return this.unsigned?g:p;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=p}for(i=this;i.gte(e);){for(n=Math.max(1,Math.floor(i.toNumber()/e.toNumber())),c=(a=Math.ceil(Math.log(n)/Math.LN2))<=48?1:u(2,a-48),l=(d=r(n)).mul(e);l.isNegative()||l.gt(i);)l=(d=r(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=m),o=o.add(d),i=i.sub(l)}return o},E.div=E.divide,E.modulo=function(e){return t(e)||(e=s(e)),this.sub(this.div(e).mul(e))},E.mod=E.modulo,E.not=function(){return i(~this.low,~this.high,this.unsigned)},E.and=function(e){return t(e)||(e=s(e)),i(this.low&e.low,this.high&e.high,this.unsigned)},E.or=function(e){return t(e)||(e=s(e)),i(this.low|e.low,this.high|e.high,this.unsigned)},E.xor=function(e){return t(e)||(e=s(e)),i(this.low^e.low,this.high^e.high,this.unsigned)},E.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?i(this.low<>>32-e,this.unsigned):i(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):i(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(e){var n;return t(e)&&(e=e.toInt()),0==(e&=63)?this:(n=this.high,e<32?i(this.low>>>e|n<<32-e,n>>>e,this.unsigned):i(32===e?n:n>>>e-32,0,this.unsigned))},E.shru=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},E.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,255&t>>>8,255&t>>>16,255&t>>>24,255&e,255&e>>>8,255&e>>>16,255&e>>>24]},E.toBytesBE=function(){var e=this.high,t=this.low;return[255&e>>>24,255&e>>>16,255&e>>>8,255&e,255&t>>>24,255&t>>>16,255&t>>>8,255&t]},e}()),Xr));ni.getModule=function(e){var t=new ni[e];return t.getArrayData=function(){var e=t.toArrayBuffer();return Fe(e)?[].slice.call(new Int8Array(e)):e},t};var ri,ii={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},oi="qryRelationR",si="cleanPMsg",ai="cleanGMsg",ci="cleanCMsg",ui="cleanSMsg",di="qryPMsg",li="qryCHMsg",hi=((Zr={}).ppMsgP=xe.PRIVATE,Zr.pgMsgP=xe.GROUP,Zr.chatMsg=xe.CHATROOM,Zr.pcMsgP=xe.CUSTOMER_SERVICE,Zr),fi=(($r={})[xe.PRIVATE]=di,$r[xe.GROUP]="qryGMsg",$r[xe.CHATROOM]=li,$r[xe.CUSTOMER_SERVICE]="qryCMsg",$r[xe.SYSTEM]="qrySMsg",$r),pi=((ei={})[xe.PRIVATE]=si,ei[xe.GROUP]=ai,ei[xe.CUSTOMER_SERVICE]=ci,ei[xe.SYSTEM]=ui,ei),gi=function(){function e(e){this._codec="websocket"===e?ni:Jr,this._connectType=e}return e.prototype.decodeByPBName=function(e,t,n){var r,i=this,o=e,s=((r={})[yn]=i._formatSyncMessages,r[_n]=i._formatReceivedMessage,r[mn]=i._formatSentMessage,r[bn]=i._formatHistoryMessages,r[kn]=i._formatConversationList,r[Bn]=i._formatChatRoomInfos,r[Hn]=i._formatRTCUserList,r[Wn]=i._formatRTCData,r[lr]=i._formatChatRoomKVList,r[_r]=i._formatUserSetting,r[Cr]=i._formatConversationStatus,r[kr]=i._formatGrpReadReceiptQryResp,r[mr]=i._formatSetUserSettingOutput,r[yr]=i._formatUserSettingNotification,r[Vr]=i._formatRTCRoomKVList,r[zn]=i._formatRTCAuidenceJoinRoomData,r[Fr]=i._formatRTCJoinedUserInfo,r)[t];try{o=e.length>0&&i._codec[t].decode(e),je(o)&&(o=function(e){for(var t in e)je(e[t])&&(e[t]=Xt(e[t]));return e}(o)),Ke(s)&&(o=s.call(this,o,n))}catch(n){Ze.error("PB parse error\n",n,e,t)}return o},e.prototype._readBytes=function(e){var t=e.offset,n=e.buffer,r=e.limit;if(t)try{var i=Fe(n)?new Uint8Array(n):n;return fn.readUTF(i.subarray(t,r))}catch(e){Ze.info("readBytes error\n",e)}return e},e.prototype._formatBytes=function(e){var t=this._readBytes(e);try{t=JSON.parse(t)}catch(e){Ze.info("formatBytes error\n",e)}return t||e},e.prototype._formatSyncMessages=function(e,t){t=t||{};var n=this,r=e.list,i=e.syncTime,o=e.finished;return(qe(o)||null===o)&&(e.finished=!0),e.syncTime=Xt(i),e.list=nn(r,(function(e){return n._formatReceivedMessage(e,t)})),e},e.prototype._formatReceivedMessage=function(e,t){var n=(t=t||{}).currentUserId,r=t.connectedTime,i=e.content,o=e.fromUserId,s=e.type,a=e.groupId,c=e.status,u=e.dataTime,d=e.classname,l=e.msgId,h=e.extraContent,f=e.pushContent,p=e.pushExt,g=e.configFlag,m=(e.direction||nt.RECEIVE)===nt.SEND,v=function(e){var t=oe.READ;return{isPersited:!!(16&e),isCounted:!!(32&e),isMentioned:!!(64&e),disableNotification:!!(512&e),receivedStatus:t=2&e?oe.RETRIEVED:t,canIncludeExpansion:!!(1024&e)}}(c),_=v.isPersited,y=v.isCounted,R=v.isMentioned,C=v.disableNotification,E=v.receivedStatus,T=v.canIncludeExpansion,S=[xe.GROUP,xe.CHATROOM,xe.RTC_ROOM].indexOf(s)>-1?a:o,I=m?n:o,b=Xt(u),w=b "+o),this.timestamp=e.readLong()}return{stream:e,length:n}},t.MESSAGE_LENGTH=2,t}(_i),Ci=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name=qt.DISCONNECT,t.status=0,t}return ge(t,e),t.prototype.readMessage=function(e,t){return e.readByte(),this.status=+e.readByte(),{stream:e,length:t}},t.MESSAGE_LENGTH=2,t}(_i),Ei=function(e){function t(){var t=e.call(this,Kt.PING_REQ)||this;return t._name=qt.PING_REQ,t}return ge(t,e),t.prototype.writeMessage=function(e){},t}(yi),Ti=function(e){function t(t){var n=e.call(this,t)||this;return n._name=qt.PING_RESP,n}return ge(t,e),t}(_i),Si=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.messageId=0,t}return ge(t,e),t.prototype.readMessage=function(e,t){var n=256*e.readByte()+e.readByte();return this.messageId=parseInt(n.toString(),10),{stream:e,length:t}},t}(_i),Ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.messageId=0,t}return ge(t,e),t.prototype.writeMessage=function(e){var t=this.messageId,n=255&t,r=(65280&t)>>8;e.write(r),e.write(n)},t}(yi),bi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name=qt.PUBLISH,t.topic="",t.targetId="",t.syncMsg=!1,t.identifier=Gt.PUB,t}return ge(t,e),t.prototype.readMessage=function(t,n){return this.date=t.readInt(),this.topic=t.readUTF(),this.targetId=t.readUTF(),e.prototype.readMessage.call(this,t,n),this.data=t.readAll(),{stream:t,length:n}},t}(Si),wi=function(e){function t(t,n,r){var i=e.call(this,Kt.PUBLISH)||this;return i._name=qt.PUBLISH,i.syncMsg=!1,i.identifier=Gt.PUB,i.topic=t,i.data=Ue(n)?fn.writeUTF(n):n,i.targetId=r,i}return ge(t,e),t.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),e.prototype.writeMessage.call(this,t),t.write(this.data)},t}(Ii),ki=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name=qt.PUB_ACK,t.status=0,t.date=0,t.millisecond=0,t.messageUId="",t.timestamp=0,t.identifier=Gt.PUB,t.topic="",t.targetId="",t}return ge(t,e),t.prototype.readMessage=function(t,n){return e.prototype.readMessage.call(this,t,n),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.millisecond=256*t.readByte()+t.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=t.readUTF(),{stream:t,length:n}},t}(Si),Ni=function(e){function t(t){var n=e.call(this,Kt.PUB_ACK)||this;return n._name=qt.PUB_ACK,n.status=0,n.date=0,n.millisecond=0,n.messageUId="",n.timestamp=0,n.messageId=t,n}return ge(t,e),t.prototype.writeMessage=function(t){e.prototype.writeMessage.call(this,t)},t}(Ii),Oi=function(e){function t(t,n,r){var i=e.call(this,Kt.QUERY)||this;return i.name=qt.QUERY,i.identifier=Gt.QUERY,i.topic=t,i.data=Ue(n)?fn.writeUTF(n):n,i.targetId=r,i}return ge(t,e),t.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),e.prototype.writeMessage.call(this,t),t.write(this.data)},t}(Ii),Ai=function(e){function t(t){var n=e.call(this,Kt.QUERY_CONFIRM)||this;return n._name=qt.QUERY_CON,n.messageId=t,n}return ge(t,e),t}(Ii),xi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name=qt.QUERY_ACK,t.status=0,t.identifier=Gt.QUERY,t.topic="",t.targetId="",t}return ge(t,e),t.prototype.readMessage=function(t,n){return e.prototype.readMessage.call(this,t,n),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.data=t.readAll(),{stream:t,length:n}},t}(Si),Pi=function(e){var t,n=e.type;switch(n){case Kt.CONN_ACK:t=new Ri(e);break;case Kt.PUBLISH:(t=new bi(e)).syncMsg=e.syncMsg;break;case Kt.PUB_ACK:t=new ki(e);break;case Kt.QUERY_ACK:t=new xi(e);break;case Kt.SUB_ACK:case Kt.UNSUB_ACK:case Kt.PING_RESP:t=new Ti(e);break;case Kt.DISCONNECT:t=new Ci(e);break;default:t=new _i(e),Ze.error("No support for deserializing "+n+" messages")}return t};!function(e){e[e.ppMsgP=1]="ppMsgP",e[e.ppMsgN=2]="ppMsgN",e[e.ppMsgS=3]="ppMsgS",e[e.pgMsgP=4]="pgMsgP",e[e.chatMsg=5]="chatMsg",e[e.pcMsgP=6]="pcMsgP",e[e.qryPMsg=7]="qryPMsg",e[e.qryGMsg=8]="qryGMsg",e[e.qryCHMsg=9]="qryCHMsg",e[e.qryCMsg=10]="qryCMsg",e[e.qrySMsg=11]="qrySMsg",e[e.recallMsg=12]="recallMsg",e[e.prMsgS=13]="prMsgS",e[e.rrMsg=14]="rrMsg",e[e.rrList=15]="rrList",e[e.s_ntf=16]="s_ntf",e[e.s_msg=17]="s_msg",e[e.s_stat=18]="s_stat",e[e.s_cmd=19]="s_cmd",e[e.s_us=20]="s_us",e[e.pullUS=21]="pullUS",e[e.pgMsgS=22]="pgMsgS",e[e.chatMsgS=23]="chatMsgS",e[e.qrySessionsAtt=24]="qrySessionsAtt",e[e.pullMsg=25]="pullMsg",e[e.qrySessions=26]="qrySessions",e[e.delSessions=27]="delSessions",e[e.delMsg=28]="delMsg",e[e.updRRTime=29]="updRRTime",e[e.chrmPull=30]="chrmPull",e[e.joinChrm=31]="joinChrm",e[e.joinChrmR=32]="joinChrmR",e[e.exitChrm=33]="exitChrm",e[e.queryChrmI=34]="queryChrmI",e[e.setKV=35]="setKV",e[e.delKV=36]="delKV",e[e.pullKV=37]="pullKV",e[e.qryRelation=38]="qryRelation",e[e.delRelation=39]="delRelation",e[e.pullSeAtts=40]="pullSeAtts",e[e.setSeAtt=41]="setSeAtt",e[e.qnTkn=42]="qnTkn",e[e.qnUrl=43]="qnUrl",e[e.aliUrl=44]="aliUrl",e[e.s3Url=45]="s3Url",e[e.stcUrl=46]="stcUrl",e[e.cleanPMsg=47]="cleanPMsg",e[e.cleanGMsg=48]="cleanGMsg",e[e.cleanCMsg=49]="cleanCMsg",e[e.cleanSMsg=50]="cleanSMsg",e[e.rtcRJoin_data=51]="rtcRJoin_data",e[e.rtcRExit=52]="rtcRExit",e[e.rtcPing=53]="rtcPing",e[e.rtcSetData=54]="rtcSetData",e[e.rtc_ntf=55]="rtc_ntf",e[e.viewerJoinR=56]="viewerJoinR",e[e.viewerExitR=57]="viewerExitR",e[e.rtcPullKv=58]="rtcPullKv",e[e.rtcIdentityChange=59]="rtcIdentityChange",e[e.userSetData=60]="userSetData",e[e.rtcQryData=61]="rtcQryData",e[e.rtcDelData=62]="rtcDelData",e[e.rtcSetOutData=63]="rtcSetOutData",e[e.rtcQryUserOutData=64]="rtcQryUserOutData",e[e.rtcToken=65]="rtcToken",e[e.rtcUserState=66]="rtcUserState",e[e.rtcRInfo=67]="rtcRInfo",e[e.rtcUData=68]="rtcUData",e[e.rtcUPut=69]="rtcUPut",e[e.rtcUDel=70]="rtcUDel",e[e.rtcUList=71]="rtcUList",e[e.rtcQueryJoined=72]="rtcQueryJoined",e[e.addSeTag=73]="addSeTag",e[e.delSeTag=74]="delSeTag",e[e.addTag=75]="addTag",e[e.delTag=76]="delTag",e[e.disTag=77]="disTag",e[e.reportsdk=78]="reportsdk",e[e.rtcInvite=79]="rtcInvite",e[e.rtcCancelInvite=80]="rtcCancelInvite",e[e.rtcInviteAnswer=81]="rtcInviteAnswer",e[e.rtcEndInvite=82]="rtcEndInvite"}(ri||(ri={}));var Mi,Li=ri,Ui=function(e,t,n,r){return ye(void 0,void 0,void 0,(function(){var i;return Re(this,(function(o){return i=0,e.forEach((function(o){return ye(void 0,void 0,void 0,(function(){var s,a;return Re(this,(function(c){switch(c.label){case 0:return s=t+"://"+o+"/ping?r="+(9999,1e3+Math.floor(8999*Math.random())),Ze.debug("start ping",s),[4,n.httpReq({url:s,timeout:5e3})];case 1:return a=c.sent(),Ze.debug("end ping",i,s,a.status),i++,r({finished:i===e.length,code:a.status,host:o}),[2]}}))}))})),[2]}))}))},Di=function(e,t,n,r,i,o,s,a){return e+"://"+t+"/websocket?appId="+n+"&token="+encodeURIComponent(r)+"&sdkVer="+o+"&pid="+s+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(a?"&protocolVer="+a:"")},Vi=function(e){return[Li.ppMsgS,Li.pgMsgS,Li.chatMsgS].map((function(e){return Li[e]})).indexOf(e)>=0};!function(e){e[e.REDIRECT=0]="REDIRECT",e[e.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",e[e.BLOCK=2]="BLOCK",e[e.REMOTE_CLOSE=3]="REMOTE_CLOSE",e[e.LOGOUT=4]="LOGOUT",e[e.BLOCK_NEW=5]="BLOCK_NEW",e[e.REDIRECT_NEW=6]="REDIRECT_NEW"}(Mi||(Mi={}));var Bi,Fi=function(e,t){Ze.info("websocket send -> messageId: "+e.messageId);var n=e.getBufferData();t.send(n.buffer)},Hi=function(e){function t(t,n){var r=e.call(this,"websocket",n)||this;return r._runtime=t,r._socket=null,r._messageIds={},r._syncMessageIds={},r._failedCount=0,r.ALLOW_FAILED_TIMES=2,r._timer=null,r._idCount=0,r._generateMessageId=function(){return r._idCount>=65535&&(r._idCount=0),++r._idCount},r}return ge(t,e),t.prototype.connect=function(e,t,n,r,i,o){return ye(this,void 0,void 0,(function(){var s=this;return Re(this,(function(a){return[2,new Promise((function(a){var c=[],u=0,d=!1,l=!1,h=function n(){return ye(s,void 0,void 0,(function(){var s;return Re(this,(function(u){switch(u.label){case 0:return 0===c.length||d?[2]:(d=!0,[4,this._connect(e,t,c.shift(),r,i,o)]);case 1:if((s=u.sent())===it.SUCCESS)this._checkAlive(),a(s);else if(s===dt)a(s);else{if(l&&0===c.length)return a(an(s)),[2];d=!1,n()}return[2]}}))}))};i=Ie(i),s._watcher.status(st.CONNECTING),Ui(n,r,s._runtime,(function(e){var t=e.code,n=e.finished,r=e.host;l=n,200===t&&(c.push(r),u++,h()),n&&0===u&&(Ze.error("No valid websocket server hosts!"),a(it.RC_SOCKET_NOT_CREATED))}))}))]}))}))},t.prototype._connect=function(e,t,n,r,i,o){return ye(this,void 0,void 0,(function(){var s,a,c,u,d,l=this;return Re(this,(function(h){switch(h.label){case 0:return s=r.replace("http","ws"),a=Di(s,n,e,t,this._runtime,i,"",o),Ze.debug("conenct start -> "+a),this.sendConnectTime=Date.now(),c=this._runtime.createWebSocket(a),u=function(e){l._timer&&(clearTimeout(l._timer),l._timer=null),l._socket===c&&(l._socket=null,l._watcher.status(e))},[4,new Promise((function(e){c.onMessage((function(t){if("[object ArrayBuffer]"===Object.prototype.toString.call(t)){var n=function(e,t){var n=new Uint8Array(e),r=new pn(n),i=r.readByte(),o=new hn(i),s=Pi(o);return s.read(r,n.length-1,t),s}(t,o);if(n instanceof Ti&&l._pingResolve)return l._pingResolve(it.SUCCESS),void(l._pingResolve=void 0);if(n instanceof Ri)return Ze.debug("recv connect ack -> "+n.status),n.status!==at?(Ze.warn("connect failed: "+n.status),void e(n.status)):(Ze.info("connect success -> "+a),l.connectedTime=n.timestamp,l.userId=n.userId||"",l._idCount=n.messageId,void e(it.SUCCESS));if(n instanceof Ci){var r=n.status;switch(Ze.warn("recv disconnect signal -> status: "+r),r){case Mi.BLOCK:l._watcher.status(st.BLOCKED);break;case Mi.OTHER_DEVICE_LOGIN:l._watcher.status(st.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case Mi.REDIRECT_NEW:case Mi.REDIRECT:l._watcher.status(st.REDIRECT);break;default:l._watcher.status(st.DISCONNECT_BY_SERVER)}}else l._onReceiveSignal(n)}else Ze.error("Socket received invalid data:",t)})),c.onClose((function(t,n){for(var r in Ze.warn("websocket closed! code:",t,"reason:",n),u(st.CONNECTION_CLOSED),l._messageIds){var i=l._messageIds[r];delete l._messageIds[r],i(it.RC_NET_CHANNEL_INVALID)}e(t)})),c.onError((function(t){var n;for(var r in Ze.error("websocket error!",null===(n=t)||void 0===n?void 0:n.stack),u(st.WEBSOCKET_ERROR),l._messageIds){var i=l._messageIds[r];delete l._messageIds[r],i(it.RC_NET_CHANNEL_INVALID)}e(it.NETWORK_ERROR)})),c.onOpen((function(){return Ze.debug("websocket open =>",a)})),setTimeout((function(){e(it.TIMEOUT)}),5e3)}))];case 1:return(d=h.sent())===it.SUCCESS?this._socket=c:(Ze.warn("connect result -> code: "+d+", url: "+a),c.close()),[2,d]}}))}))},t.prototype._checkAlive=function(){var e;return ye(this,void 0,void 0,(function(){var t,n=this;return Re(this,(function(r){switch(r.label){case 0:return this._socket?(Ze.debug("send ping ->"),this.sendOnly(new Ei),[4,new Promise((function(e){n._pingResolve=e,n._timer&&clearTimeout(n._timer),n._timer=setTimeout((function(){n._pingResolve=void 0,e(it.TIMEOUT)}),15e3)}))]):[2];case 1:return(t=r.sent())!==it.SUCCESS?(this._failedCount+=1,Ze.warn("ping failed count: "+this._failedCount+", code: "+t),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,Ze.warn("ping timeout, close current websocket to reconnect!"),null===(e=this._socket)||void 0===e||e.close(),this._watcher.status(st.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(Ze.debug("recv pong <-"),this._failedCount=0,setTimeout((function(){return n._checkAlive()}),15e3),[2])}}))}))},t.prototype._onReceiveSignal=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return Re(this,(function(c){switch(c.label){case 0:return t=e.messageId,e.header&&e.header.qos!==jt.AT_MOST_ONCE&&(e instanceof bi&&!e.syncMsg&&(Ze.debug("send pubAck -> "+t),this.sendOnly(new Ni(t))),e instanceof xi&&(Ze.debug("send queryCon -> "+t),this.sendOnly(new Ai(t)))),t>0&&(e instanceof ki||e instanceof xi)&&(Ze.debug("recv ack -> messageId: "+t),(n=this._messageIds[t])&&(n(e),delete this._messageIds[t]),(r=this._syncMessageIds[t])&&(delete this._syncMessageIds[t],r(e))),e instanceof bi?(i=e.syncMsg,(o=e.topic)===Li[Li.userSetData]?[2]:!i||Vi(o)?(this._watcher.signal(e),[2]):[4,new Promise((function(e){a._syncMessageIds[t]=e}))]):[3,2];case 1:s=c.sent(),delete this._syncMessageIds[t],this._watcher.signal(e,s),c.label=2;case 2:return[2]}}))}))},t.prototype.sendOnly=function(e){this._socket&&Fi(e,this._socket)},t.prototype.send=function(e,t,n,r){return void 0===r&&(r=3e4),ye(this,void 0,void 0,(function(){var i,o,s,a=this;return Re(this,(function(c){switch(c.label){case 0:return this._socket?(i=this._generateMessageId(),e.messageId=i,Fi(e,this._socket),[4,new Promise((function(e){a._messageIds[i]=e,setTimeout((function(){a._messageIds[i]&&delete a._messageIds[i],e()}),r)}))]):[3,2];case 1:return(o=c.sent())?o instanceof xi||o instanceof ki?(s=t&&o.data?this.codec.decodeByPBName(o.data,t,n):o,0!==o.status?(Ze.warn("send failed -> message: "+i+", respPBName: "+t+", status: "+o.status),[2,{code:o.status,data:t&&o.data?s:null}]):[2,{code:it.SUCCESS,data:s}]):[2,{code:o}]:(Ze.warn("send timeout -> message: "+i+", respPBName: "+t+", timeout: "+r),[2,{code:it.TIMEOUT}]);case 2:return[2,{code:it.RC_NET_CHANNEL_INVALID}]}}))}))},t.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(st.DISCONNECTED))},t}(mi);!function(e){e.GET="GET",e.POST="POST"}(Bi||(Bi={}));var ji=function(e){function t(t,n){var r=e.call(this,"comet",n)||this;return r._runtime=t,r._messageIds={},r._syncMessageIds={},r._idCount=0,r._generateMessageId=function(){return++r._idCount},r._pid=encodeURIComponent((new Date).getTime()+Math.random()+""),r}return ge(t,e),t.prototype.handleCometRes=function(e){var t=this;if(200!==e.status&&202!==e.status)return!1;var n=Ue(e.data)?JSON.parse(e.data):e.data;return n?!Be(n)||(tn(n,(function(e){return ye(t,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d,l,h=this;return Re(this,(function(f){switch(f.label){case 0:if((t=e.sessionid)&&(this._sessionid=t),n=function(e){var t=e.headerCode,n=new hn(t),r=Pi(n);for(var i in e)r[i]=e[i];return r}(e),r=n.messageId,i=n._header,o=n.status,n.identifier,s=i&&i.qos!==jt.AT_MOST_ONCE,r&&n.getIdentifier&&((a=this._messageIds[r])&&a(n),this._syncMessageIds[r]&&this._syncMessageIds[r](n)),s&&(n instanceof bi&&!n.syncMsg&&(c=new Ni(r),this.sendOnly(c)),n instanceof xi&&(c=new Ai(r),this.sendOnly(c))),n instanceof Ci){switch(o){case Mi.OTHER_DEVICE_LOGIN:this._watcher.status(st.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case Mi.BLOCK:this._watcher.status(st.BLOCKED);break;case Mi.REDIRECT_NEW:case Mi.REDIRECT:this._watcher.status(st.REDIRECT);break;default:this._watcher.status(st.DISCONNECT_BY_SERVER)}return[2]}return n instanceof bi?(u=n.syncMsg,d=n.topic,!u||Vi(d)?(this._watcher.signal(n),[2,!1]):[4,new Promise((function(e){h._syncMessageIds[r]=e}))]):[3,2];case 1:l=f.sent(),delete this._syncMessageIds[r],this._watcher.signal(n,l),f.label=2;case 2:return[2]}}))}))})),!0):(Ze.error("received data is not a validJson",n),!1)},t.prototype._startPullSignal=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i;return Re(this,(function(o){switch(o.label){case 0:return t=(new Date).getTime(),n=e+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"×trap="+t+"&pid="+this._pid,[4,this._runtime.httpReq({url:n,body:{pid:this._pid},timeout:45e3})];case 1:return r=o.sent(),i=this.handleCometRes(r),this._isDisconnected||(i?this._startPullSignal(e):(this._isDisconnected=!0,this._watcher.status(st.NETWORK_UNAVAILABLE))),[2]}}))}))},t.prototype.connect=function(e,t,n,r,i,o){return ye(this,void 0,void 0,(function(){var o,s,a,c,u=this;return Re(this,(function(d){return i=Ie(i),this._protocol=r,this._isDisconnected=!1,this._watcher.status(st.CONNECTING),o=[],s=0,a=!1,c=!1,[2,new Promise((function(d){var l=function n(){return ye(u,void 0,void 0,(function(){var s;return Re(this,(function(u){switch(u.label){case 0:return 0===o.length||a?[2]:(a=!0,[4,this._connect(e,t,o.shift(),r,i)]);case 1:if((s=u.sent())===it.SUCCESS)this._startPullSignal(r),d(s);else if(s===dt)d(s);else{if(c&&0===o.length)return d(an(s)),[2];a=!1,n()}return[2]}}))}))};u._watcher.status(st.CONNECTING),Ui(n,r,u._runtime,(function(e){var t=e.code,n=e.finished,r=e.host;c=n,200===t&&(o.push(r),s++,l()),n&&0===s&&(Ze.error("No valid websocket server hosts!"),d(it.RC_SOCKET_NOT_CREATED))}))}))]}))}))},t.prototype._connect=function(e,t,n,r,i){return ye(this,void 0,void 0,(function(){var o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return o=function(e){return 200!==e.status&&202!==e.status?(Ze.error("handle comet res -> res: "+JSON.stringify(e||{})),!1):!!e.data&&(function(e){if(je(e))return!0;var t=!1;try{var n=JSON.parse(e);t=JSON.stringify(n)===e}catch(e){t=!1}return t}(e.data)?je(e.data)?e.data:JSON.parse(e.data):(Ze.error("received data is not a validJson",e.data),!1))},s=Di(r,n,e,t,this._runtime,i,this._pid),this.sendConnectTime=Date.now(),Ze.debug("conenct start -> "+s),[4,this._runtime.httpReq({url:s,body:{pid:this._pid},timeout:5e3})];case 1:return a=u.sent(),c=o(a),this._domain=n,c&&0===c.status?(this._sessionid=c.sessionid,this.userId=c.userId,this.connectedTime=c.timestamp):Ze.warn("connect result -> code: "+(null==c?void 0:c.status)+", url: "+s),[2,null==c?void 0:c.status]}}))}))},t.prototype.sendCometData=function(e,t){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d;return Re(this,(function(l){switch(l.label){case 0:return n=(t=this)._domain,r=t._sessionid,i=t._pid,o=e.messageId,s=e.topic,a=e.targetId,e.identifier,c=e.getHeaderFlag(),u=s?this._protocol+"://"+n+"/websocket?messageid="+o+"&header="+c+"&sessionid="+r+"&topic="+s+"&targetid="+a+"&pid="+i:this._protocol+"://"+n+"/websocket?messageid="+o+"&header="+c+"&sessionid="+r+"&pid="+i,[4,this._runtime.httpReq({url:u,method:Bi.POST,body:e.getCometData()})];case 1:return d=l.sent(),this.handleCometRes(d),[2]}}))}))},t.prototype.sendOnly=function(e){this.sendCometData(e)},t.prototype.send=function(e,t,n,r){return void 0===r&&(r=3e4),ye(this,void 0,void 0,(function(){var i,o,s,a=this;return Re(this,(function(c){switch(c.label){case 0:return i=this._generateMessageId(),e.messageId=i,this.sendCometData(e),[4,new Promise((function(e){a._messageIds[i]=e,setTimeout((function(){delete a._messageIds[i],e()}),r)}))];case 1:return(o=c.sent())?(s=t&&o.data?this.codec.decodeByPBName(o.data,t,n):o,0!==o.status?[2,{code:o.status,data:t&&o.data?s:null}]:[2,{code:it.SUCCESS,data:s}]):[2,{code:it.TIMEOUT}]}}))}))},t.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(st.DISCONNECTED)},t}(mi),Ki=function(e){return["navi",e].join("_")},qi=function(){function e(e,t){this._runtime=e,this._options=t,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=Ie(this._options.apiVersion)}return e.prototype.getInfo=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o;return Re(this,(function(s){switch(s.label){case 0:return n&&this._clear(e),(i=function(e,t,n){var r,i,o=Ki(e);try{var s=n.getItem(o);i=s?JSON.parse(s):[]}catch(e){i=[]}var a=Date.now();return i.length>0&&(i=i.filter((function(e){return a-e.timestamp<72e5}))),0===i.length?n.removeItem(o):n.setItem(o,JSON.stringify(i)),(null===(r=i.find((function(e){return e.token===t})))||void 0===r?void 0:r.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=i,[2,i]):(o=this._options.navigators.slice(),t.length&&t.forEach((function(e){o.indexOf(e)<0&&o.unshift(e)})),[4,this._reqNavi(o,this._appkey,e,r)]);case 1:return(i=s.sent())?(this._naviInfo=i,this.setNaviInfo2Cache(e,i),[2,i]):[2,i]}}))}))},e.prototype.setNaviInfo2Cache=function(e,t){this._naviInfo=t,function(e,t,n,r){var i,o=Ki(e);try{var s=r.getItem(o);i=s?JSON.parse(s):[]}catch(e){i=[]}var a=Date.now();i.length>0&&(i=i.filter((function(e){return a-e.timestamp<72e5&&t!==e.token}))),i.push({timestamp:a,naviInfo:n,token:t}),r.setItem(o,JSON.stringify(i))}(this._appkey,e,t,this._runtime.localStorage)},e.prototype.getInfoFromCache=function(e){return this._naviInfo},e.prototype._clear=function(e){!function(e,t,n){var r,i=Ki(e);try{var o=n.getItem(i);r=o?JSON.parse(o):[]}catch(e){r=[]}var s=Date.now();r.length>0&&(r=r.filter((function(e){return s-e.timestamp<72e5&&t!==e.token}))),0===r.length?n.removeItem(i):n.setItem(i,JSON.stringify(r))}(this._appkey,e,this._runtime.localStorage)},e}(),Gi=function(e,t,n){return[e,t,n].join("_")},Yi=function(){function e(e,t){this._runtime=e,this._appkey=t,this._users={}}return e.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},e.prototype.setInboxTime=function(e,t){var n=this._getMemData(t);if(!(n.inboxTime>e)){n.inboxTime=e;var r=Gi("inbox",this._appkey,t);this._runtime.localStorage.setItem(r,e.toString())}},e.prototype.getInboxTime=function(e){var t=this._getMemData(e);if(0===t.inboxTime){var n=Gi("inbox",this._appkey,e);t.inboxTime=parseInt(this._runtime.localStorage.getItem(n))||0}return t.inboxTime},e.prototype.setOutboxTime=function(e,t){var n=this._getMemData(t);if(!(n.outboxTime>=e)){n.outboxTime=e;var r=Gi("outbox",this._appkey,t);this._runtime.localStorage.setItem(r,e.toString())}},e.prototype.getOutboxTime=function(e){var t=this._getMemData(e);if(0===t.outboxTime){var n=Gi("outbox",this._appkey,e);t.outboxTime=parseInt(this._runtime.localStorage.getItem(n))||0}return t.outboxTime},e}(),Ji={_caches:{},set:function(e,t){this._caches[e]=t},get:function(e){return this._caches[e]||0},clear:function(e){this._caches[e]=0}},zi=function(){function e(e,t){this._kvCaches={},this._chatroomId=e,this._currentUserId=t}return e.prototype._add=function(e){var t=e.key;e.isDeleted=!1,this._kvCaches[t]=e},e.prototype._remove=function(e){var t=e.key,n=this._kvCaches[t];n&&(n.isDeleted=!0,this._kvCaches[t]=n)},e.prototype._setEntry=function(e,t){var n=e.key,r=e.type,i=e.isOverwrite,o=e.userId,s=this._getSetUserId(n),a=r===kt.DELETE,c=s===o,u=!this._isExisted(n),d=a?this._remove:this._add;(t||i||c||u)&&d.call(this,e)},e.prototype.getValue=function(e){var t=this._kvCaches[e]||{};return t.isDeleted?null:t.value},e.prototype.getAllValue=function(){var e={};for(var t in this._kvCaches)this._kvCaches[t].isDeleted||(e[t]=this._kvCaches[t].value);return e},e.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},e.prototype._isExisted=function(e){var t=this._kvCaches[e]||{},n=t.value,r=t.isDeleted;return n&&!r},e.prototype.setEntries=function(e){var t=this,n=e.kvEntries,r=e.isFullUpdate;n=n||[],(r=r||!1)&&this.clear(),n.forEach((function(e){t._setEntry(e,r)})),Ze.debug("end setEntries")},e.prototype.clear=function(){this._kvCaches={}},e}(),Wi=function(){function e(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return e.prototype._startPull=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r,i,o,s;return Re(this,(function(a){switch(a.label){case 0:return this._isPulling||0===this._pullQueue.length?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],t=e.chrmId,n=e.timestamp,(r=Ji.get(t))>n?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(t,r)]);case 1:return i=a.sent(),o=i.code,s=i.data,this._isPulling=!1,o===it.SUCCESS?(Ji.set(t,s.syncTime||0),this._startPull()):this._startPull(),[2]}}))}))},e.prototype.reset=function(e){Ji.clear(e);var t=this._storeCaches[e];t&&t.clear()},e.prototype.pullEntry=function(e,t){this._pullQueue.push({chrmId:e,timestamp:t}),this._startPull()},e.prototype.setLocal=function(e,t,n){var r=this._storeCaches[e];Je(r)||(r=new zi(e,n)),r.setEntries(t),this._storeCaches[e]=r},e.prototype.getValue=function(e,t){var n=this._storeCaches[e];return n?n.getValue(t):null},e.prototype.getAll=function(e){var t=this._storeCaches[e],n={};return t&&(n=t.getAllValue()),n},e}(),Qi=function(){function e(e,t,n,r){this._runtime=e,this._appkey=t,this._userId=n,this._canJoinMulipleChrm=r,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return e.prototype.set=function(e,t){void 0===t&&(t=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=t,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},e.prototype.get=function(){var e,t;try{t=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(t||"{}")}catch(ie){Ze.error("parse rejoined chrm infos error -> "+t),e={}}return e},e.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Je(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},e.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},e}(),Xi="converStatusChanged",Zi=function(){function e(e,t,n){this._eventEmitter=new $e,this._pullQueue=[],this._isPulling=!1,this._storage=le(e.runtime),this._appkey=t,this._currentUserId=n,this._engine=e,this._storagePullTimeKey="con-s-"+t+"-"+n}return e.prototype._set=function(e){var t=this;if(!qe(e)&&Array.isArray(e)){var n=this._storage.get(this._storagePullTimeKey)||0,r=e.length;e.forEach((function(e,i){var o=e.updatedTime||0;n=o>n?o:n,e.conversationType=e.type,t._eventEmitter.emit(Xi,{statusItem:e,isLastPull:i===r-1})})),this._storage.set(this._storagePullTimeKey,n)}},e.prototype._startPull=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._isPulling||0===this._pullQueue.length?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullConversationStatus(e)]);case 1:return t=i.sent(),n=t.code,r=t.data,n===it.SUCCESS?(this._isPulling=!1,this._set(r),this._startPull()):this._startPull(),[2]}}))}))},e.prototype.pull=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||0===e)&&(this._pullQueue.push(t),this._startPull())},e.prototype.watch=function(e){this._eventEmitter.on(Xi,(function(t){e(t)}))},e.prototype.unwatch=function(){this._eventEmitter.off(Xi,(function(e){}))},e}(),$i={c:{keyName:"unreadMessageCount",defaultVal:0},hm:{keyName:"hasMentioned",defaultVal:!1},m:{keyName:"mentionedInfo",defaultVal:null},t:{keyName:"lastUnreadTime",defaultVal:0},nc:{keyName:"notificationStatus",defaultVal:2},to:{keyName:"isTop",defaultVal:!1},tg:{keyName:"tags",defaultVal:{}},mc:{keyName:"unreadMentionedCount",defaultVal:0}},eo={};for(var to in $i){var no=$i[to].keyName;eo[no]=to}var ro,io=function(){function e(e,t,n){this._appkey=t,this._currentUserId=n;var r="con-"+t+"-"+n;this.storage=new fe(e,r),this._localStore=new fe(e,"CONVER-"+t+"-"+n)}return e.prototype._getStoreKey=function(e,t,n){return n+"_"+e+"_"+t},e.prototype._getConOptionByKey=function(e){var t=(e=e||"").split("_");if(t.length>=2){var n=t.shift(),r=t.shift(),i=t.join("_");return{conversationType:Number(r),targetId:i,channelId:n}}return{conversationType:xe.PRIVATE,targetId:"",channelId:""}},e.prototype.updateMentionedData=function(e){var t=this,n=e.conversationType,r=e.targetId,i=e.messageType,o=e.isMentioned,s=e.content,a=e.senderUserId,c=e.channelId,u=this._getStoreKey(n,r,c),d=this._localStore.get(u)||{},l=eo.mentionedInfo,h=eo.hasMentioned,f=d[l]||{},p=f.userIdList||[],g=s.mentionedInfo;if(g){if(o&&n===xe.GROUP&&((g.userIdList||[]).forEach((function(e){e===t._currentUserId&&p.indexOf(a)<0&&p.push(a)})),g.type===St.ALL&&p.indexOf(a)<0&&p.push(a)),i===Rt.RECALL&&n===xe.GROUP){var m=p.indexOf(a);m>=0&&p.splice(m,1)}g={userIdList:p,type:(null==g?void 0:g.type)||f.type},0!==p.length?(d[l]=g,d[h]=!0):(delete d[l],delete d[h]),Je(d)?this._localStore.set(u,d):this._localStore.remove(u)}},e.prototype.set=function(e,t,n,r){var i=this._getStoreKey(e,t,r),o=this._localStore.get(i)||{};for(var s in n){var a=eo[s],c=n[s];if(!qe(a)&&!qe(c)&&"hasMentioned"!==s&&"MentionedInfo"!==s){if(c===$i[a].defaultVal||"tags"===s&&!Je(c))delete o[a];else if("tags"===s){var u=c;for(var d in u)u[d].isTop||delete u[d].isTop;o[a]=c}else o[a]=c;o.c||(delete o.t,delete o.hm,delete o.m,delete o.mc)}}Je(o)?this._localStore.set(i,o):this._localStore.remove(i)},e.prototype.get=function(e,t,n){void 0===n&&(n="");var r=this._getStoreKey(e,t,n),i=this._localStore.get(r)||{},o={};for(var s in $i){var a=$i[s],c=a.keyName,u=a.defaultVal;o[c]=i[s]||on(u)}return o},e.prototype.getValue=function(e){var t=this._localStore.getValues()||{},n=[];for(var r in t){var i=this._getConOptionByKey(r),o={conversationType:i.conversationType,targetId:i.targetId,channelId:i.channelId},s=t[r];for(var a in s){var c=$i[a],u=c.keyName,d=c.defaultVal;o[u]=s[a]||on(d)}o=e?e(o):o,n.push(o)}return n},e.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},t={};for(var n in e){var r=this._getConOptionByKey(n),i=r.conversationType,o=r.targetId,s={},a=e[n];for(var c in a){var u=$i[c],d=u.keyName,l=u.defaultVal;s[d]=a[c]||on(l)}for(var h in s.tags){qe(t[h])&&(t[h]=[]);var f=Object.assign({},s,{conversationType:i,targetId:o});delete f.tags,t[h].push(f)}}return t},e.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(0===Object.keys(e).length)return;for(var t in e){var n="_"+t;this._localStore.set(n,e[t])}}catch(e){Ze.error("adaptOldStore error: "+e.message)}},e}(),oo=[xe.PRIVATE,xe.GROUP,xe.SYSTEM,xe.PUBLIC_SERVICE,xe.APP_PUBLIC_SERVICE],so="conversationChanged",ao="conTagStatusChanged",co=function(){function e(e,t,n,r,i){var o=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new $e,this._draftMap={},this._appkey=t,this._loginUserId=n,this._store=new io(e.runtime,t,n),this._statusManager=new Zi(e,t,n),this._statusManager.watch((function(e){var t=e.statusItem,n=e.isLastPull;o.addStatus(t,n)})),this._eventEmitter.on(so,(function(e){r(e)})),this._eventEmitter.on(ao,(function(){i()}))}return e.prototype._calcUnreadCount=function(e,t){var n=e.content,r=e.messageType,i=e.sentTime,o=e.isCounted,s=e.messageDirection,a=e.senderUserId,c=s===nt.SEND&&a===this._loginUserId,u=r===Rt.RECALL,d=je(n),l=!1,h={},f=t.lastUnreadTime||0,p=t.unreadMessageCount||0;return f>i||c||(o&&(t.unreadMessageCount=p+1,t.lastUnreadTime=i,l=!0),u&&d&&f>=n.sentTime&&p&&(t.unreadMessageCount=p-1,l=!0),l&&(h.unreadMessageCount={val:t.unreadMessageCount,time:i})),{hasChanged:l,localConversation:t,updateItems:h}},e.prototype._calcMentionedInfo=function(e,t){var n=e.content,r=(e.messageDirection,e.isMentioned),i=e.sentTime;nt.SEND;var o=je(n),s=!1,a={};return r&&o&&n.mentionedInfo&&(t.hasMentioned=!0,s=!0,a.hasMentioned={val:!0,time:i},a.mentionedInfo={val:n.mentionedInfo,time:i}),{hasChanged:s,localConversation:t,updateItems:a}},e.prototype._calcMentionedCount=function(e,t){var n=e.content,r=e.messageDirection,i=!1;if(e.isMentioned&&r===nt.RECEIVE&&(null==n?void 0:n.mentionedInfo)){var o=n.mentionedInfo,s=o.type,a=o.userIdList;if(s===St.ALL||(a||[]).includes(this._loginUserId)){i=!0;var c=t.unreadMentionedCount||0;t.unreadMentionedCount=c+1}}return{hasChanged:i,localConversation:t}},e.prototype._setUpdatedConversation=function(e){if(je(e)){var t=e.conversationType,n=e.targetId,r=e.channelId,i=t+"_"+n,o=this._store.get(t,n,r)||{};this._updatedConversations[i]=Object.assign(o,e)}},e.prototype._setConTagStatusChanged=function(e,t,n,r){var i=(this._store.get(e,t,r)||{}).tags||{};if(Object.keys(i).length===Object.keys(n).length){for(var o in i)if(!n[o]||i[o].isTop!==n[o].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},e.prototype.addStatus=function(e,t){var n=e.conversationType,r=e.targetId,i=e.updatedTime,o=e.notificationStatus,s=e.isTop,a=e.tags,c=e.channelId,u={},d={};qe(o)||(d.notificationStatus={time:i,val:o}),qe(s)||(d.isTop={time:i,val:s}),qe(a)||(d.tags={time:i,val:a},null==a||a.forEach((function(e){u[e.tagId]={isTop:e.isTop}}))),this._setConTagStatusChanged(n,r,u,c),this._store.set(n,r,{notificationStatus:o,isTop:s,tags:u},c),this._setUpdatedConversation({conversationType:n,targetId:r,updatedItems:d,channelId:c}),t&&this._notifyConversationChanged()},e.prototype._notifyConversationChanged=function(){var e=[];for(var t in this._updatedConversations)e.push(this._updatedConversations[t]);0!==e.length&&(this._eventEmitter.emit(so,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(ao),this._conTagStatusChanged=!1))},e.prototype.setConversationCacheByMessage=function(e,t){var n=this,r=e.conversationType,i=e.isPersited,o=e.targetId,s=e.channelId;if(oo.indexOf(r)>=0){var a=!1,c=this._store.get(r,o,s),u={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach((function(t){var r=t.call(n,e,c),i=r.hasChanged,o=r.localConversation,s=r.updateItems;a=a||i,u=_e(_e({},u),s),c=on(o)})),a&&this._store.set(r,o,c,s),this._store.updateMentionedData(e),i){var d=this._store.get(r,o,s);d.updatedItems=_e({latestMessage:{time:e.sentTime,val:e}},u),d.latestMessage=e;var l=Object.assign(d,{conversationType:r,targetId:o,channelId:s});this._setUpdatedConversation(l)}(a||i)&&this._notifyConversationChanged()}},e.prototype.get=function(e,t,n){return void 0===n&&(n=""),this._store.get(e,t,n)},e.prototype.getAllUnreadCount=function(e,t,n){var r=this._store.getValue(),i=0;return r.forEach((function(e){var r=e.unreadMessageCount,o=e.notificationStatus,s=e.conversationType;r=r||0,(n||1!==o)&&(t.length>0?t.includes(Number(s))&&(i+=Number(r)):i+=Number(r))})),i},e.prototype.getUnreadCountByTag=function(e,t){var n=this._store.getValueForTag()[e]||[],r=0;return n.forEach((function(e){var n=e.unreadMessageCount,i=e.notificationStatus;(t||1!==i)&&(n=n||0,r+=Number(n))})),r},e.prototype.getUnreadCount=function(e,t,n){return this._store.get(e,t,n).unreadMessageCount||0},e.prototype.clearUnreadCount=function(e,t,n,r){void 0===r&&(r=!0);var i=this._store.get(e,t,n),o=i.unreadMessageCount,s=i.hasMentioned,a={};if(o&&(i.unreadMessageCount=0,a.unreadMessageCount={val:0,time:Date.now()}),s&&(i.hasMentioned=!1,i.unreadMentionedCount=0,i.mentionedInfo=void 0,a.hasMentioned={val:!1,time:Date.now()},a.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,t,i,n),r&&0!==Object.keys(a).length){var c=Object.assign(i,{conversationType:e,targetId:t,channelId:n,updatedItems:a});this._setUpdatedConversation(c),this._notifyConversationChanged()}},e.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach((function(t){t.unreadMessageCount&&(t.unreadMessageCount=0,e._store.set(t.conversationType,t.targetId,t,t.channelId))}))},e.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},e.prototype.setDraft=function(e,t,n,r){var i=e+"_"+t+"_"+r;this._draftMap[i]=n},e.prototype.getDraft=function(e,t,n){var r=e+"_"+t+"_"+n;return this._draftMap[r]},e.prototype.clearDraft=function(e,t,n){var r=e+"_"+t+"_"+n;delete this._draftMap[r]},e.prototype.addTagStatus=function(e,t,n,r){void 0===r&&(r="");var i=this._store.get(e,t,r).tags;i=Object.assign(i,n),this._store.set(e,t,{tags:i},r)},e.prototype.deleteTagStatus=function(e,t,n,r){void 0===r&&(r="");var i=this._store.get(e,t,r).tags;n.forEach((function(e){delete i[e]})),this._store.set(e,t,{tags:i},r)},e.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},e.prototype.getBlockConversationList=function(){return this._store.getValue().filter((function(e){return e.notificationStatus===Et.OPEN})).map((function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}}))},e.prototype.getTopConversationList=function(){return(this._store.getValue()||{}).filter((function(e){return e.isTop})).map((function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}}))},e.prototype.adaptOldStore=function(){this._store.adaptOldStore()},e.prototype.getUnreadMentionedCount=function(e,t,n){return void 0===e&&(e=""),this.get(t,n,e).unreadMentionedCount||0},e.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),t=0;return e.forEach((function(e){var n=e.unreadMentionedCount;n=n||0,t+=Number(n)})),t},e}(),uo=function(){function e(e,t,n,r){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+t+"-"+n,this._storagePullTimeKey="us-s-"+t+"-"+n,this._storage=le(e.runtime),this._engine=e,this._tagWatcherFunc=r}return e.prototype._updateTag=function(e){var t=e.tags,n={};t.forEach((function(e){n[e.tagId]={tagName:e.tagName,createdTime:e.createdTime}})),this._storage.set(this._storageTagKey,n),this._tagWatcherFunc()},e.prototype.addTag=function(e,t){var n=this._storage.get(this._storageTagKey)||{};e.forEach((function(e){var t,r=(null===(t=n[e.tagId])||void 0===t?void 0:t.createdTime)||e.createdTime||0;n[e.tagId]={tagName:e.tagName,createdTime:r}})),this._storage.set(this._storageTagKey,n),this._storage.set(this._storagePullTimeKey,t)},e.prototype.deleteTag=function(e,t){var n=this._storage.get(this._storageTagKey)||{};e.forEach((function(e){delete n[e]})),this._storage.set(this._storageTagKey,n),this._storage.set(this._storagePullTimeKey,t)},e.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},e.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},t=[];for(var n in e)t.push({tagId:n,tagName:e[n].tagName,createdTime:e[n].createdTime,conversationCount:0});return t.sort((function(e,t){return(e.createdTime||0)-(t.createdTime||0)}))},e.prototype.getTagById=function(e){var t=this._storage.get(this._storageTagKey)||{};return t[e]?{tagId:e,tagName:t[e].tagName,createdTime:t[e].createdTime,conversationCount:0}:null},e.prototype._startPull=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._isPulling||0===this._pullQueue.length?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullUserSettings(e)]);case 1:return t=c.sent(),n=t.code,r=t.data,n!==it.SUCCESS||qe(r)?(this._isPulling=!1,this._startPull()):(o=(i=r).settings,s=i.version,a=o.Tag,qe(a)||this._updateTag(a),this._storage.set(this._storagePullTimeKey,s),this._isPulling=!1,this._startPull()),[2]}}))}))},e.prototype.pullUserSettings=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||0===e)&&(this._pullQueue.push(t),this._startPull())},e.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},e}(),lo=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r._miniConnectUrl="",r._connectType=n.connectionType,r}return ge(t,e),t.prototype._formatJSONPUrl=function(e,t,n,r){return e+"/"+(this._runtime.isSupportSocket()&&"websocket"===this._connectType?"navi":"cometnavi")+".js?appId="+n+"&token="+encodeURIComponent(t)+"&callBack="+r+"&v="+this._apiVersion+"&r="+Date.now()},t.prototype.getInfo=function(t,n,r){var i;return ye(this,void 0,void 0,(function(){var o;return Re(this,(function(s){return this._runtime.useNavi||(void 0,o=this._runtime.isSupportSocket()&&"websocket"===this._connectType?ae.join(","):ce.join(","),this._miniConnectUrl=(null===(i=this._options.miniCMPProxy)||void 0===i?void 0:i.length)?this._options.miniCMPProxy.join(","):o||"",n=[]),[2,e.prototype.getInfo.call(this,t,n,r)]}))}))},t.prototype._reqNavi=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d,l;return Re(this,(function(h){switch(h.label){case 0:r="getServerEndpoint",i=0,o=e.length,h.label=1;case 1:return i "+s),[4,this._runtime.httpReq({url:s,timeout:1e4,dataType:"text"})]):[3,4];case 2:if(200!==(a=h.sent()).status)return 403===a.status?Ze.error("request navi error: "+it.RC_CONN_USER_OR_PASSWD_ERROR):401===a.status&&Ze.error("request navi error: "+it.RC_CONN_APP_BLOCKED_OR_DELETED),[3,3];try{return c=a.data.match(/{[\d\D]+}/),0===(u=c&&c[0]?c[0]:"").indexOf('{\\"code\\":')&&(u=JSON.parse('"'+u+'"')),l=JSON.parse(u),d=/^https/.test(s)?"https":"http",l.protocol=d,this._runtime.useNavi||(l.server="",l.backupServer=this._miniConnectUrl,l.logSwitch=0),[2,l]}catch(e){Ze.error("parse navi err =>",e)}h.label=3;case 3:return i+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,l={code:200,protocol:"https",server:"",voipCallInfo:"",kvStorage:0,openHttpDNS:!1,historyMsg:!1,chatroomMsg:!1,uploadServer:"https://upload.qiniup.com",bosAddr:"https://gz.bcebos.com",location:"",monitor:0,joinMChrm:!1,openMp:0,openUS:0,grpMsgLimit:0,isFormatted:0,gifSize:2048,logSwitch:0,logPolicy:"",compDays:0,msgAck:"",activeServer:"",qnAddr:"",extkitSwitch:0,alone:!1,voipServer:"",offlinelogserver:"",backupServer:this._miniConnectUrl}]}}))}))},t}(qi),ho=function(){function e(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return e.prototype._startPull=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r,i,o,s;return Re(this,(function(a){switch(a.label){case 0:return this._isPulling||0===this._pullQueue.length?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],t=e.roomId,n=e.timestamp,(r=this._pullTime)>n?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(t,r)]);case 1:return i=a.sent(),o=i.code,s=i.data,o===it.SUCCESS?(this._isPulling=!1,this._pullTime=s.syncTime||0,this._startPull()):this._startPull(),[2]}}))}))},e.prototype.pullEntry=function(e,t){this._pullQueue.push({roomId:e,timestamp:t}),this._startPull()},e.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},e}(),fo=function(e,t){return["send_msg",e,t].join("_")},po=function(){function e(e,t){this._runtime=e,this._appkey=t,this._sendMessageMap={},this._userId=""}return e.prototype.init=function(e){this._userId=e;var t=fo(this._appkey,e);this._sendMessageMap=this._getLocalInfo(t)},e.prototype._getLocalInfo=function(e){var t=this._runtime.localStorage.getItem(e);try{return t?JSON.parse(t):{}}catch(e){return{}}},e.prototype.setMessage=function(e,t){this._sendMessageMap[e]=t;var n=fo(this._appkey,this._userId),r=this._getLocalInfo(n);r[e]=t,this._runtime.localStorage.setItem(n,JSON.stringify(r))},e.prototype.getSendMessageMap=function(){return this._sendMessageMap},e.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},e.prototype.removeByTimestamp=function(e){var t=fo(this._appkey,this._userId),n=this._getLocalInfo(t);Object.keys(n).forEach((function(t){n[t] signal.messageId: "+e.messageId),this._pullMsg(e);break;case Li.s_msg:this._receiveMsg(e);break;case Li.s_cmd:this._receiveStateNotify(e);break;case Li.s_us:this._receiveSettingNotify(e);break;case Li.rtc_ntf:this._receiveRtcKv(e)}else Ze.error("unknown topic:",r)}},t.prototype._receiveStateNotify=function(e){var t,n=null===(t=this._channel)||void 0===t?void 0:t.codec.decodeByPBName(e.data,Sn),r=n.time,i=n.type,o=n.chrmId;switch(i){case 2:this._chrmEntryHandler.pullEntry(o,r);break;case 3:this._conversationManager.startPullConversationStatus(r);break;case 4:this._chrmEntryHandler.reset(o),this._watcher.chatroom({chatroomDestroyed:e.targetId})}},t.prototype._receiveSettingNotify=function(e){var t,n=(null===(t=this._channel)||void 0===t?void 0:t.codec.decodeByPBName(e.data,yr)).version;this._userSettingManager.pullUserSettings(n)},t.prototype._receiveRtcKv=function(e){var t,n=null===(t=this._channel)||void 0===t?void 0:t.codec.decodeByPBName(e.data,Ur),r=n.time,i=n.type,o=n.roomId;if(1===i)this._rtcKVManager.pullEntry(o,r)},t.prototype._receiveMessageExpansion=function(e){var t=e.content,n=t.put,r=t.del,i=t.mid;n&&this._watcher.expansion({updatedExpansion:{messageUId:i,expansion:n}}),r&&this._watcher.expansion({deletedExpansion:{messageUId:i,deletedKeys:r}})},t.prototype._receiveSyncMsg=function(e,t){var n;if(mo.includes(e.topic)){var r=null===(n=this._channel)||void 0===n?void 0:n.codec.decodeByPBName(e.data,mn,{currentUserId:this.currentUserId,signal:e});r=this._handleMsgProperties(r),t&&(r.sentTime=t.timestamp,r.messageUId=t.messageUId),this._pullingMsg?this._pullQueue.push((null==t?void 0:t.timestamp)||r.sentTime):(t&&this._sendMessageStore.setMessage(t.messageUId,t.timestamp),r.messageType!==Rt.EXPANSION_NOTIFY?(r.messageType===Rt.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(r.conversationType,r.targetId,r.channelId),this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r))}},t.prototype._pullMsg=function(e){if(this._channel){var t=this._channel.codec.decodeByPBName(e.data,Sn),n=t.type,r=t.chrmId,i=t.time;if(Ze.info("s_ntf -> type: "+n+", chrmId: "+r+", time: "+i),2===n){var o=this._chrmsQueue[r];if(!o)return;o.queue.push(i),this._pullChrmMsg(r)}else this._pullQueue.push(i),this._syncMsg()}},t.prototype._startSyncInterval=function(){var e=this;this._stopSyncInterval(),this._intervalTimer=setInterval((function(){Date.now()-e._latestSyncTimestamp>=18e4&&e._syncMsg()}),3e4),this._latestSyncTimestamp=Date.now(),this._syncMsg()},t.prototype._stopSyncInterval=function(){-1!==this._intervalTimer&&(clearInterval(this._intervalTimer),this._intervalTimer=-1)},t.prototype._syncMsg=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,a,c,u,d,l,h,f,p=this;return Re(this,(function(g){switch(g.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,e=this._letterbox.getOutboxTime(this.currentUserId),t=this._letterbox.getInboxTime(this.currentUserId),Ze.info("pullMsg -> sendboxTime: "+e+", inboxTime: "+t),n=this._channel.codec.encodeSyncMsg({sendboxTime:e,inboxTime:t}),r=new Oi(Li[Li.pullMsg],n,this.currentUserId),[4,this._channel.send(r,yn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return i=g.sent(),o=i.code,s=i.data,this._latestSyncTimestamp=Date.now(),o===it.SUCCESS&&s?(a=s.list,c=s.finished,u=s.syncTime,Ze.info("pullMsg success -> syncTime: "+u+", finished: "+c),d=0,l=[],a.forEach((function(e){if(e.messageDirection===nt.SEND&&(d=Math.max(e.sentTime,d),p._sendMessageStore.getSendMessageMap()[e.messageUId]))p._sendMessageStore.removeByUID(e.messageUId);else if(e.messageType!==Rt.EXPANSION_NOTIFY){if(e.messageType===Rt.SYNC_READ_STATUS){if(e.senderUserId!==p.currentUserId)return;p._conversationManager.clearUnreadCount(e.conversationType,e.targetId,e.channelId)}var t=p._handleMsgProperties(e);p._conversationManager.setConversationCacheByMessage(t,!0),l.push(t)}else p._receiveMessageExpansion(e)})),this._watcher.batchMessage(l),this._letterbox.setInboxTime(u,this.currentUserId),this._letterbox.setOutboxTime(d,this.currentUserId),this._sendMessageStore.removeByTimestamp(d),this._pullingMsg=!1,h=this._pullQueue.filter((function(e){return e>u})),this._pullQueue.length=0,(f=this._pullQueue).push.apply(f,h),c&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!c||h.length>0)&&this._syncMsg(),[2]):(Ze.warn("pullMsg failed -> code:",o,", data: ",s),this._pullingMsg=!1,[2])}}))}))},t.prototype._receiveMsg=function(e){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var t=this._channel.codec.decodeByPBName(e.data,_n,{currentUserId:this.currentUserId,connectedTime:this._channel.connectedTime});(t=this._handleMsgProperties(t)).senderUserId===this.currentUserId&&this._sendMessageStore.setMessage(t.messageUId,t.sentTime),t.isStatusMessage||t.senderUserId===this.currentUserId||this._letterbox.setInboxTime(t.sentTime,this.currentUserId),t.messageType!==Rt.EXPANSION_NOTIFY?t.messageType===Rt.SYNC_READ_STATUS&&t.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(t,!0),this._watcher.batchMessage([t])):this._receiveMessageExpansion(t)}},t.prototype._handleMsgProperties=function(e,t){void 0===t&&(t=!1);var n,r=e.messageType,i=e.isCounted,o=e.isPersited,s=e.isStatusMessage,a=r in ue,c=r in this._customMessageType;if(n=a?ue[r]:c?this._customMessageType[r]:{isCounted:!Ge(i)&&i,isPersited:!Ge(o)&&o},Object.assign(e,{isCounted:n.isCounted,isPersited:n.isPersited,isStatusMessage:de.includes(r)}),t&&(e.isStatusMessage=s),!t){var u=e.content.user;if(u){var d=u.portrait,l=u.portraitUri,h=d||l;h&&(u.portrait=u.portraitUri=h)}}return e},t.prototype.getHistoryMessage=function(e,t,n,r,i,o){return void 0===o&&(o=""),ye(this,void 0,void 0,(function(){var s,a,c,u,d,l,h,f,p;return Re(this,(function(g){switch(g.label){case 0:return a=(s=this).currentUserId,c=s._channel,u=fi[e]||di,d=1===r&&0===n,c?(l=c.codec.encodeGetHistoryMsg(t,{timestamp:n,count:d?2:r,order:i,channelId:o}),[4,c.send(new Oi(u,l,a),bn,{currentUserId:a,connectedTime:c.connectedTime,conversation:{targetId:t}})]):[3,2];case 1:return h=g.sent(),(f=h.code)!==it.SUCCESS?[2,{code:f}]:(p=h.data,d&&2===p.list.length&&(p.hasMore=!0,0===i?p.list.shift():p.list.pop()),[2,{code:f,data:{list:p.list,hasMore:p.hasMore}}]);case 2:return[2,{code:it.RC_NET_CHANNEL_INVALID}]}}))}))},t.prototype.reportSDKInfo=function(e){var t=this.currentUserId,n=this._channel;if(n){Ze.debug("reportSDKInfo ->",e);var r=n.codec.encodeReportSDKInfo(JSON.stringify(e)),i=new Oi(Li[Li.reportsdk],r,t);n.send(i).then((function(e){var t=e.code;t!==it.SUCCESS&&Ze.warn("reportSDKInfo failed -> code: "+t)}))}},t.prototype.deleteRemoteMessage=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o,s,a,c,u,d;return Re(this,(function(l){switch(l.label){case 0:return o=(i=this).currentUserId,(s=i._channel)?(a=s.codec.encodeDeleteMessages(e,t,n,r),c=new Oi("delMsg",a,o),[4,s.send(c)]):[3,2];case 1:return u=l.sent(),d=u.code,it.SUCCESS,[2,d];case 2:return[2,it.RC_NET_CHANNEL_INVALID]}}))}))},t.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o,s,a,c,u,d,l;return Re(this,(function(h){switch(h.label){case 0:return o=(i=this).currentUserId,(s=i._channel)?(a=s.codec.encodeClearMessages(t,n,r),c=pi[e],u=new Oi(c,a,o),[4,s.send(u)]):[3,2];case 1:return d=h.sent(),l=d.code,it.SUCCESS,[2,l];case 2:return[2,it.RC_NET_CHANNEL_INVALID]}}))}))},t.prototype.getConversationList=function(e,t,n,r,i){return void 0===e&&(e=300),ye(this,void 0,void 0,(function(){var i,o,s,a,c,u,d,l,h=this;return Re(this,(function(f){switch(f.label){case 0:return o=(i=this).currentUserId,s=i._channel,t=t||xe.PRIVATE,s?(a=s.codec.encodeOldConversationList({count:e,type:t,startTime:n,order:r}),c=new Oi(oi,a,o),[4,s.send(c,kn,{currentUserId:o,connectedTime:s.connectedTime,afterDecode:function(e){var t=e.conversationType,n=e.targetId,r=e.channelId,i=h._conversationManager.get(t,n,r);return Object.assign(e,i),e}})]):[3,2];case 1:return u=f.sent(),d=u.code,l=u.data,d!==it.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}];case 2:return[2,{code:it.RC_NET_CHANNEL_INVALID}]}}))}))},t.prototype.removeConversation=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return(r=this._channel)?(i=r.codec.encodeRemoveOldConversationList({conversationType:e,channelId:n,targetId:t}),o=new Oi("delRelation",i,t),[4,r.send(o)]):[3,2];case 1:return s=c.sent(),Ze.info("RemoveConversation =>",s),a=s.code,it.SUCCESS,[2,a];case 2:return[2,it.RC_NET_CHANNEL_INVALID]}}))}))},t.prototype.getConversation=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return(r=this._conversationManager.get(e,t,n))?[4,this.getHistoryMessage(e,t,0,1,0)]:[2,{code:it.CONVER_GET_ERROR}];case 1:return i=u.sent(),o=i.code,s=i.data,o!==it.SUCCESS?[2,{code:it.CONVER_GET_ERROR}]:(a=(null==s?void 0:s.list[0])||null,c={conversationType:e,targetId:t,channelId:n,unreadMessageCount:r.unreadMessageCount||0,latestMessage:a,notificationStatus:r.notificationStatus||Et.CLOSE,isTop:r.isTop||!1,lastUnreadTime:r.lastUnreadTime||0,unreadMentionedCount:r.unreadMentionedCount||0},[2,{code:it.SUCCESS,data:c}])}}))}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._conversationManager.getAllUnreadCount(e,t,n);return Promise.resolve({code:it.SUCCESS,data:r})},t.prototype.getConversationUnreadCount=function(e,t,n){var r=this._conversationManager.getUnreadCount(e,t,n);return Promise.resolve({code:it.SUCCESS,data:r})},t.prototype.clearConversationUnreadCount=function(e,t,n){return this._conversationManager.clearUnreadCount(e,t,n,!1),Promise.resolve(it.SUCCESS)},t.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(it.SUCCESS)},t.prototype.getFirstUnreadMessage=function(e,t){throw new Error("Method not implemented.")},t.prototype.saveConversationMessageDraft=function(e,t,n,r){return this._conversationManager.setDraft(e,t,n,r),Promise.resolve(it.SUCCESS)},t.prototype.getConversationMessageDraft=function(e,t,n){var r=this._conversationManager.getDraft(e,t,n);return Promise.resolve({code:it.SUCCESS,data:r})},t.prototype.clearConversationMessageDraft=function(e,t,n){return this._conversationManager.clearDraft(e,t,n),Promise.resolve(it.SUCCESS)},t.prototype.pullConversationStatus=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return n=(t=this)._channel,r=t.currentUserId,n?(i=n.codec.encodeGetConversationStatus(e),o=new Oi(Li[Li.pullSeAtts],i,r),[4,n.send(o,Cr)]):[3,2];case 1:return s=u.sent(),a=s.code,c=s.data,a!==it.SUCCESS?[2,{code:a}]:[2,{code:a,data:c}];case 2:return[2,{code:it.RC_NET_CHANNEL_INVALID}]}}))}))},t.prototype.batchSetConversationStatus=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d=this;return Re(this,(function(l){switch(l.label){case 0:return n=(t=this).currentUserId,(r=t._channel)?(i=r.codec.encodeSetConversationStatus(e),o=new Oi("setSeAtt",i,n),[4,r.send(o,Ir)]):[3,2];case 1:return s=l.sent(),a=s.code,c=s.data,a===it.SUCCESS?(u=c,e.forEach((function(e){d._conversationManager.addStatus(_e(_e({},e),{updatedTime:u.version}),!0)})),[2,a]):[2,a];case 2:return[2,it.RC_NET_CHANNEL_INVALID]}}))}))},t.prototype._joinChrm=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u;return Re(this,(function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),o=new Oi(n?"joinChrmR":"joinChrm",i,e),[4,r.send(o,Dn)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return s=d.sent(),a=s.code,c=s.data,a===it.SUCCESS&&(u=c.joinTime,this._chrmsQueue[e]||(this._chrmsQueue[e]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(e,t,u),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(e,0),this._joinedChrmManager.set(e,t)),[2,a]}}))}))},t.prototype._rejoinChrm=function(){return ye(this,void 0,void 0,(function(){var e,t,n,r,i,o;return Re(this,(function(s){switch(s.label){case 0:for(n in e=this._joinedChrmManager.get(),t=[],e)t.push(n);r=0,s.label=1;case 1:return rh})),p=[],l.forEach((function(e){e.sentTime0)&&this._pullChrmMsg(e),[2]):(Ze.warn("pull chatroom msg failed, code:",u,", data:",d),[2])}}))}))},t.prototype.joinChatroom=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,this._joinChrm(e,t,!1)]}))}))},t.prototype.joinExistChatroom=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,this._joinChrm(e,t,!0)]}))}))},t.prototype.quitChatroom=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o;return Re(this,(function(s){switch(s.label){case 0:return(t=this._channel)?(n=t.codec.encodeJoinOrQuitChatRoom(),r=new Oi("exitChrm",n,e),[4,t.send(r)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return i=s.sent(),(o=i.code)===it.SUCCESS&&(delete this._chrmsQueue[e],this._chrmEntryHandler.reset(e),this._joinedChrmManager.remove(e)),[2,o]}}))}))},t.prototype.getChatroomInfo=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return(r=this._channel)?(i=r.codec.encodeGetChatRoomInfo(t,n),o=new Oi(Li[Li.queryChrmI],i,e),[4,r.send(o,Bn)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return s=u.sent(),a=s.code,c=s.data,a!==it.SUCCESS?[2,{code:a}]:[2,{code:a,data:c}]}}))}))},t.prototype.getChatroomHistoryMessages=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o,s,a,c,u;return Re(this,(function(d){switch(d.label){case 0:return(i=this._channel)?(o=i.codec.encodeGetHistoryMsg(e,{timestamp:t,count:n,order:r}),s=new Oi(li,o,e),[4,i.send(s,bn,{conversation:{targetId:e}})]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return a=d.sent(),c=a.code,u=a.data,c!==it.SUCCESS?[2,{code:c}]:[2,{code:c,data:{list:u.list,hasMore:u.hasMore}}]}}))}))},t.prototype._modifyChatroomKV=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,u;return Re(this,(function(d){switch(d.label){case 0:return r=(n=this)._channel,i=n.currentUserId,r?(o=r.codec.encodeModifyChatRoomKV(e,t,i),s=t.type===kt.UPDATE?"setKV":"delKV",a=new Oi(s,o,e),[4,r.send(a)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return c=d.sent(),(u=c.code)===it.SUCCESS?(this._chrmEntryHandler.setLocal(e,{kvEntries:[t],syncTime:(new Date).getTime()},i),[2,u]):[2,u]}}))}))},t.prototype._modifyChatroomKVS=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,u,d,l,h,f;return Re(this,(function(p){switch(p.label){case 0:return r=(n=this)._channel,i=n.currentUserId,r?(o=r.codec.encodeModifyChatRoomKVS(e,t,i),s=t.type===kt.UPDATE?"setKVS":"delKVS",a=new Oi(s,o,e),[4,r.send(a,hr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return c=p.sent(),u=c.code,-1!==[it.SUCCESS,it.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(u)&&(l=[],delete(h=Object.assign({},t)).entries,t.entries.forEach((function(e){l.push(Object.assign({},e,h))})),u===it.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(f=c.data,Ze.warn("设置失败的属性:",f.errorKeys),d=f.errorKeys,f&&Array.isArray(f.errorKeys)&&f.errorKeys.forEach((function(e){var t=l.findIndex((function(t){return e.key===t.key}));-1!==t&&l.splice(t,1)}))),Ze.warn("设置成功的属性:",l),this._chrmEntryHandler.setLocal(e,{kvEntries:l,syncTime:(new Date).getTime()},i)),[2,{code:u,data:d}]}}))}))},t.prototype.setChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.UPDATE,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKV(e,t)]}))}))},t.prototype.setChatroomEntries=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.UPDATE,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKVS(e,t)]}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.UPDATE,t.isOverwrite=!0,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKV(e,t)]}))}))},t.prototype.removeChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.DELETE,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKV(e,t)]}))}))},t.prototype.removeChatroomEntries=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.DELETE,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKVS(e,t)]}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return t.type=kt.DELETE,t.isOverwrite=!0,t.userId=t.userId||this.currentUserId,[2,this._modifyChatroomKV(e,t)]}))}))},t.prototype.getChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return(n=this._chrmEntryHandler.getValue(e,t))?[2,Promise.resolve({code:it.SUCCESS,data:n})]:[3,1];case 1:return(r=this._channel)?(i=r.codec.encodePullChatRoomKV(0),o=new Oi(Li[Li.pullKV],i,e),[4,r.send(o,lr)]):[2,Promise.reject({code:it.RC_NET_CHANNEL_INVALID})];case 2:return s=u.sent(),(a=s.data||{})&&a.kvEntries&&a.kvEntries.length&&void 0!==(c=a.kvEntries.find((function(e){return e.key===t})))?[2,Promise.resolve({code:it.SUCCESS,data:null==c?void 0:c.value})]:[2,Promise.resolve({code:it.CHATROOM_KEY_NOT_EXIST})]}}))}))},t.prototype.getAllChatroomEntry=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return(t=this._chrmEntryHandler.getAll(e))&&Object.keys(t).length?[2,Promise.resolve({code:it.SUCCESS,data:t})]:[3,1];case 1:return(n=this._channel)?(r={},i=n.codec.encodePullChatRoomKV(0),o=new Oi(Li[Li.pullKV],i,e),[4,n.send(o,lr)]):[2,Promise.reject({code:it.RC_NET_CHANNEL_INVALID})];case 2:return s=c.sent(),(a=s.data||{})&&a.kvEntries&&a.kvEntries.length&&a.kvEntries.forEach((function(e){e.key&&(r[e.key]=e.value||"")})),[2,Promise.resolve({code:it.SUCCESS,data:r})]}}))}))},t.prototype.pullChatroomEntry=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,u,d,l;return Re(this,(function(h){switch(h.label){case 0:return r=(n=this)._channel,i=n.currentUserId,r?(o=r.codec.encodePullChatRoomKV(t),s=new Oi(Li[Li.pullKV],o,e),[4,r.send(s,lr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return a=h.sent(),c=a.code,u=a.data,c===it.SUCCESS?(Ze.info("Pull success ChrmKV, "+JSON.stringify(a)),this._chrmEntryHandler.setLocal(e,u,i),Ze.info("Save into cache success!"),d=u.kvEntries,l=[],d.length>0&&(d.forEach((function(t){var n=t.key,r=t.value,i=t.type,o=t.timestamp;l.push({key:n,value:r,type:i,timestamp:o,chatroomId:e})})),this._watcher.chatroom({updatedEntries:l})),[2,{code:c,data:u}]):[2,{code:c}]}}))}))},t.prototype.sendMessage=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d,l,h;return Re(this,(function(f){switch(f.label){case 0:return this._channel?(n=function(e,t){return"RC:SRSMsg"===e.messageType&&Object.assign(e,{directionalUserIdList:[t]}),e}(n,this.currentUserId),n=this._handleMsgProperties(n,!0),r=!![xe.PRIVATE,xe.GROUP].includes(e)&&n.isStatusMessage,i=r?function(e){var t;return(t={},t[xe.PRIVATE]=Li.ppMsgS,t[xe.GROUP]=Li.pgMsgS,t)[e]}(e):function(e){var t;return(t={},t[xe.PRIVATE]=Li.ppMsgP,t[xe.GROUP]=Li.pgMsgP,t[xe.CHATROOM]=Li.chatMsg,t[xe.CUSTOMER_SERVICE]=Li.pcMsgP,t[xe.RTC_ROOM]=Li.prMsgS,t)[e]}(e)||Li.ppMsgP,r&&(n.isPersited=!1,n.isCounted=!1),o=this._channel.codec.encodeUpMsg({conversationType:e,targetId:t},n),(s=new wi(Li[i],o,t)).setHeaderQos(jt.AT_LEAST_ONCE),r?(this._channel.sendOnly(s),[2,{code:it.SUCCESS,data:vo(e,t,_e({},n),"",0,this.currentUserId)}]):(a=Date.now()-this._localConnectedTime+this._connectedTime,c=vo(e,t,_e({},n),"",a,this.currentUserId),[4,this._channel.send(s)])):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return u=f.sent(),d=u.code,l=u.data,d!==it.SUCCESS?[2,{code:d,data:c}]:(h=l,this._sendMessageStore.setMessage(h.messageUId,h.timestamp),c.sentTime=h.timestamp,c.messageUId=h.messageUId,this._conversationManager.setConversationCacheByMessage(c,!0),[2,{code:it.SUCCESS,data:c}])}}))}))},t.prototype.recallMsg=function(e,t,n,r,i){var o;return ye(this,void 0,void 0,(function(){var s,a,c,u,d,l,h,f,p,g;return Re(this,(function(m){switch(m.label){case 0:return this._channel?(s=i.user,a={content:{conversationType:e,targetId:t,messageUId:n,sentTime:r,user:s},messageType:"RC:RcCmd",disableNotification:null==i?void 0:i.disableNotification,pushConfig:null==i?void 0:i.pushConfig,pushContent:(null===(o=i.pushConfig)||void 0===o?void 0:o.pushContent)||i.pushContent||"",channelId:i.channelId},c=Li[Li.recallMsg],u=this._channel.codec.encodeUpMsg({conversationType:e,targetId:t},a),(d=new wi(c,u,this.currentUserId)).setHeaderQos(jt.AT_LEAST_ONCE),[4,this._channel.send(d)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return l=m.sent(),h=l.code,f=l.data,h!==it.SUCCESS?[2,{code:h}]:(p=f,this._sendMessageStore.setMessage(p.messageUId,p.timestamp),g=vo(e,t,_e(_e({},a),{isPersited:!0}),p.messageUId,p.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(g,!0),[2,{code:it.SUCCESS,data:g}])}}))}))},t.prototype.sendReadReceiptMessage=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeReadReceipt(t,n),i=new Oi(Li[Li.rrMsg],r,e),[4,this._channel.send(i)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return[2,o.sent()]}}))}))},t.prototype.getMessageReader=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeMessageReader(t,n),i=new Oi(Li[Li.rrList],r,e),[4,this._channel.send(i,kr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return[2,o.sent()]}}))}))},t.prototype.pullUserSettings=function(e){return ye(this,void 0,void 0,(function(){var t,n;return Re(this,(function(r){return this._channel?(t=this._channel.codec.encodePullUserSetting(e),n=new Oi(Li[Li.pullUS],t,this.currentUserId),[2,this._channel.send(n,_r)]):[2,{code:it.RC_NET_CHANNEL_INVALID}]}))}))},t.prototype.getFileToken=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o,s,a,c,u;return Re(this,(function(d){switch(d.label){case 0:return this._channel?(i=r&&"uploads"!==r?t||"":function(e,t){var n=Math.floor(1e3*Math.random()%1e4),r=Ne(),i=function(e){e=e||"-";var t=new Date;return""+t.getFullYear()+e+(t.getMonth()+1)+e+t.getDate()}(),o=(new Date).getTime(),s="";if(t){var a=t.split(".");s="."+a[a.length-1]}return e+"__RC-"+i+"_"+n+"_"+o+r+s}(e,t),o=this._channel.codec.encodeGetFileToken(e,i,n||"",r||""),s=new Oi(Li[Li.qnTkn],o,this.currentUserId),[4,this._channel.send(s,rr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return a=d.sent(),c=a.code,u=a.data,u=Object.assign(u,{fileName:i}),c===it.SUCCESS?[2,{code:c,data:u}]:[2,{code:c}]}}))}))},t.prototype.getFileUrl=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o,s,a,c,u,d,l,h;return Re(this,(function(f){switch(f.label){case 0:return this._channel?("",o="",s="",t===bt.QINIU?(o=ir,s=sr):(o=or,s=ar),i=t===bt.QINIU?Li[Li.qnUrl]:t===bt.AWS?Li[Li.s3Url]:t===bt.STC?Li[Li.stcUrl]:Li[Li.aliUrl],a=this._channel.codec.encodeGetFileUrl(o,e,n,r),c=new Oi(i,a,this.currentUserId),[4,this._channel.send(c,s)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return u=f.sent(),d=u.code,l=u.data,h=l,d===it.SUCCESS?[2,{code:d,data:h}]:[2,{code:d}]}}))}))},t.prototype.disconnect=function(){-1!==this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=-1),this._channel&&(this._channel.close(),this._channel=void 0),this._pullQueue.length=0,this._stopSyncInterval()},t.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},t.prototype.registerMessageType=function(e,t,n,r){this._customMessageType[e]={isPersited:t,isCounted:n}},t.prototype.getServerTime=function(){return Date.now()-this._localConnectedTime+this._connectedTime},t.prototype.getCurrentUserId=function(){return this.currentUserId},t.prototype.createTag=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._channel?(t=this._userSettingManager.getVersion(),n=this._channel.codec.encodeCreateTag([e],t),r=new Oi(Li[Li.addSeTag],n,this.currentUserId),[4,this._channel.send(r,mr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return i=c.sent(),o=i.code,s=i.data,o!==it.SUCCESS?[2,{code:o}]:(a=s.version,this._userSettingManager.addTag([_e(_e({},e),{createdTime:a})],a),[2,{code:it.SUCCESS,data:s}])}}))}))},t.prototype.removeTag=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._channel?(t=this._userSettingManager.getVersion(),n=this._channel.codec.encodeRemoveTag([e],t),r=new Oi(Li[Li.delSeTag],n,this.currentUserId),[4,this._channel.send(r,mr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return i=c.sent(),o=i.code,s=i.data,o!==it.SUCCESS?[2,{code:o}]:(a=s.version,this._userSettingManager.deleteTag([e],a),[2,{code:it.SUCCESS}])}}))}))},t.prototype.updateTag=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._channel?(t=this._userSettingManager.getVersion(),n=this._channel.codec.encodeCreateTag([e],t),r=new Oi(Li[Li.addSeTag],n,this.currentUserId),[4,this._channel.send(r,mr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return i=c.sent(),o=i.code,s=i.data,o!==it.SUCCESS?[2,{code:o}]:(a=s.version,this._userSettingManager.addTag([e],a),[2,{code:it.SUCCESS,data:s}])}}))}))},t.prototype.getTagList=function(){return ye(this,void 0,void 0,(function(){var e,t;return Re(this,(function(n){return e=this._userSettingManager.getTags(),t=this._conversationManager.getConversationListForTag(),e.forEach((function(e){e.conversationCount=t[e.tagId]?t[e.tagId].length:0})),[2,{code:it.SUCCESS,data:e}]}))}))},t.prototype.addTagForConversations=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s=this;return Re(this,(function(a){switch(a.label){case 0:return this._channel?this._userSettingManager.getTagById(e)?(n=this._channel.codec.encodeUpdateConversationTag([{tagId:e}],t),r=new Oi(Li[Li.addTag],n,this.currentUserId),[4,this._channel.send(r)]):[2,{code:it.TAG_NOT_EXIST}]:[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return(i=a.sent().code)!==it.SUCCESS?[2,{code:i}]:((o={})[e]={},t.forEach((function(e){s._conversationManager.addTagStatus(e.conversationType,e.targetId,o,e.channelId)})),[2,{code:it.SUCCESS}])}}))}))},t.prototype.removeTagForConversations=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o=this;return Re(this,(function(s){switch(s.label){case 0:return this._channel?(n=this._channel.codec.encodeUpdateConversationTag([{tagId:e}],t),r=new Oi(Li[Li.delTag],n,this.currentUserId),[4,this._channel.send(r)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return(i=s.sent().code)!==it.SUCCESS?[2,{code:i}]:(t.forEach((function(t){o._conversationManager.deleteTagStatus(t.conversationType,t.targetId,[e],t.channelId)})),[2,{code:it.SUCCESS}])}}))}))},t.prototype.removeTagsForConversation=function(e,t){return ye(this,void 0,void 0,(function(){var n,r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return this._channel?(n=e.conversationType,r=e.targetId,i=e.channelId,o=t.map((function(e){return{tagId:e}})),s=this._channel.codec.encodeUpdateConversationTag(o,[e]),a=new Oi(Li[Li.delTag],s,this.currentUserId),[4,this._channel.send(a)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return(c=u.sent().code)!==it.SUCCESS?[2,{code:c}]:(this._conversationManager.deleteTagStatus(n,r,t,i),[2,{code:it.SUCCESS}])}}))}))},t.prototype.getConversationListByTag=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d,l;return Re(this,(function(h){switch(h.label){case 0:return i=(r=this).currentUserId,(o=r._channel)?(s=o.codec.encodeOldConversationList({count:n,type:xe.PRIVATE,startTime:t}),a=new Oi(oi,s,i),[4,o.send(a,kn,{currentUserId:i,connectedTime:o.connectedTime})]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),u=c.code,d=c.data,l=this._conversationHasTagFilter(e,d),Ze.info("GetConversationListByTag",l),u!==it.SUCCESS?[2,{code:u}]:[2,{code:u,data:l}]}}))}))},t.prototype._conversationHasTagFilter=function(e,t){var n=this,r=[],i=[];function o(e,t){return e.latestMessage&&t.latestMessage?e.latestMessage.sentTime-t.latestMessage.sentTime:0}return t.forEach((function(t){var o=t.conversationType,s=t.targetId,a=t.channelId,c=n._conversationManager.get(o,s,a),u=c.hasMentioned,d=c.mentionedInfo,l=c.lastUnreadTime,h=c.notificationStatus,f=c.isTop,p=c.tags,g=c.unreadMessageCount,m=p&&p[e];if(m){var v=_e(_e({},t),{hasMentioned:u,mentionedInfo:d,lastUnreadTime:l,notificationStatus:h,isTop:f,unreadMessageCount:g});m.isTop?r.push(_e(_e({},v),{isTopInTag:!0})):i.push(_e(_e({},v),{isTopInTag:!1}))}})),Ce(Ce([],r.sort(o)),i.sort(o))},t.prototype.getUnreadCountByTag=function(e,t){return ye(this,void 0,void 0,(function(){var n;return Re(this,(function(r){return this._channel?(n=this._conversationManager.getUnreadCountByTag(e,t),[2,{code:it.SUCCESS,data:n}]):[2,{code:it.RC_NET_CHANNEL_INVALID}]}))}))},t.prototype.setConversationStatusInTag=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d,l,h;return Re(this,(function(f){switch(f.label){case 0:return this._channel?(r=t.targetId,i=t.conversationType,o=t.channelId,s=n.isTop,a=[{tagId:e,isTop:s}],(c=this._conversationManager.get(i,r,o)).tags&&Object.hasOwnProperty.call(c.tags,e)?(u=this._channel.codec.encodeUpdateConversationTag(a,[t]),d=new Oi(Li[Li.addTag],u,this.currentUserId),[4,this._channel.send(d)]):[2,{code:it.NO_TAG_IN_CONVER}]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return(l=f.sent().code)!==it.SUCCESS?[2,{code:l}]:((h={})[e]={},s&&(h[e].isTop=!0),this._conversationManager.addTagStatus(i,r,h,o),[2,{code:it.SUCCESS}])}}))}))},t.prototype.getTagsForConversation=function(e){var t;return ye(this,void 0,void 0,(function(){var n,r,i,o;return Re(this,(function(s){if(!this._channel)return[2,{code:it.RC_NET_CHANNEL_INVALID}];if(n=this._conversationManager.get(e.conversationType,e.targetId,e.channelId),r=this._userSettingManager.getTagsInfo(),i=[],n.tags)for(o in n.tags)i.push({tagId:o,tagName:null===(t=r[o])||void 0===t?void 0:t.tagName});return[2,{code:it.SUCCESS,data:i}]}))}))},t.prototype.getBlockConversationList=function(){var e=this._conversationManager.getBlockConversationList();return Promise.resolve({code:it.SUCCESS,data:e})},t.prototype.getTopConversationList=function(){var e=this._conversationManager.getTopConversationList();return Promise.resolve({code:it.SUCCESS,data:e})},t.prototype.getUnreadMentionedCount=function(e){var t=this._conversationManager.getUnreadMentionedCount(e.channelId,e.conversationType,e.targetId);return Promise.resolve({code:it.SUCCESS,data:t})},t.prototype.getAllUnreadMentionedCount=function(){var e=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:it.SUCCESS,data:e})},t.prototype.joinRTCRoom=function(e,t,n,r){return ye(this,void 0,void 0,(function(){var i,o;return Re(this,(function(s){return this._channel?(i=this._channel.codec.encodeJoinRTCRoom(t,n,r),o=new Oi(Li[Li.rtcRJoin_data],i,e),[2,this._channel.send(o,Hn)]):[2,{code:it.RC_NET_CHANNEL_INVALID}]}))}))},t.prototype.quitRTCRoom=function(e){return ye(this,void 0,void 0,(function(){var t,n;return Re(this,(function(r){switch(r.label){case 0:return this._channel?(t=this._channel.codec.encodeQuitRTCRoom(),n=new Oi(Li[Li.rtcRExit],t,e),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,r.sent().code]}}))}))},t.prototype.rtcPing=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeJoinRTCRoom(t,n),i=new Oi(Li[Li.rtcPing],r,e),[4,this._channel.send(i)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}}))}))},t.prototype.getRTCRoomInfo=function(e){return ye(this,void 0,void 0,(function(){var t,n;return Re(this,(function(r){return this._channel?(t=this._channel.codec.encodeGetRTCRoomInfo(),n=new Oi(Li[Li.rtcRInfo],t,e),[2,this._channel.send(n,$n)]):[2,{code:it.RC_NET_CHANNEL_INVALID}]}))}))},t.prototype.getRTCUserInfoList=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o;return Re(this,(function(s){switch(s.label){case 0:return this._channel?(t=this._channel.codec.encodeGetRTCRoomInfo(),n=new Oi(Li[Li.rtcUData],t,e),[4,this._channel.send(n,Hn)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return r=s.sent(),i=r.code,o=r.data,[2,{code:i,data:o?{users:o.users}:o}]}}))}))},t.prototype.setRTCUserInfo=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeSetRTCUserInfo(t,n),i=new Oi(Li[Li.rtcUPut],r,e),[4,this._channel.send(i)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}}))}))},t.prototype.removeRTCUserInfo=function(e,t){return ye(this,void 0,void 0,(function(){var n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(n=this._channel.codec.encodeRemoveRTCUserInfo(t),r=new wi(Li[Li.rtcUDel],n,e),[4,this._channel.send(r)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,i.sent().code]}}))}))},t.prototype.setRTCData=function(e,t,n,r,i,o){return ye(this,void 0,void 0,(function(){var s,a;return Re(this,(function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeSetRTCData(t,n,r,i,o),a=new wi(Li[Li.rtcSetData],s,e),[4,this._channel.send(a)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}}))}))},t.prototype.setRTCTotalRes=function(e,t,n,r,i){return ye(this,void 0,void 0,(function(){var o,s;return Re(this,(function(a){switch(a.label){case 0:return this._channel?(o=this._channel.codec.encodeUserSetRTCData(t,n,r,i),s=new Oi(Li[Li.userSetData],o,e),[4,this._channel.send(s)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,a.sent().code]}}))}))},t.prototype.setRTCCDNUris=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeUserSetRTCCDNUris(t,n),i=new Oi(Li[Li.userSetData],r,e),[4,this._channel.send(i)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}}))}))},t.prototype.getRTCData=function(e,t,n,r){if(!this._channel)return Promise.resolve({code:it.RC_NET_CHANNEL_INVALID});var i=this._channel.codec.encodeGetRTCData(t,n,r),o=new Oi(Li[Li.rtcQryData],i,e);return this._channel.send(o,Wn)},t.prototype.removeRTCData=function(e,t,n,r,i){return ye(this,void 0,void 0,(function(){var o,s;return Re(this,(function(a){switch(a.label){case 0:return this._channel?(o=this._channel.codec.encodeRemoveRTCData(t,n,r,i),s=new wi(Li[Li.rtcDelData],o,e),[4,this._channel.send(s)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,a.sent().code]}}))}))},t.prototype.setRTCOutData=function(e,t,n,r){throw new Error("JSEngine's method not implemented.")},t.prototype.getRTCOutData=function(e,t){throw new Error("JSEngine's method not implemented.")},t.prototype.getRTCToken=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i;return Re(this,(function(o){return this._channel?(r=this._channel.codec.encodeJoinRTCRoom(t,n),i=new Oi(Li[Li.rtcToken],r,e),[2,this._channel.send(i,zn)]):[2,{code:it.RC_NET_CHANNEL_INVALID}]}))}))},t.prototype.setRTCState=function(e,t){return ye(this,void 0,void 0,(function(){var n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(n=this._channel.codec.encodeSetRTCState(t),r=new Oi(Li[Li.rtcUserState],n,e),[4,this._channel.send(r)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return[2,i.sent().code]}}))}))},t.prototype.getRTCUserInfo=function(e){return ye(this,void 0,void 0,(function(){return Re(this,(function(e){throw new Error("Method not implemented.")}))}))},t.prototype.getRTCUserList=function(e){if(!this._channel)return Promise.resolve({code:it.RC_NET_CHANNEL_INVALID});var t=this._channel.codec.encodeGetRTCRoomInfo(),n=new Oi(Li[Li.rtcUList],t,e);return this._channel.send(n,Hn)},t.prototype.joinLivingRoomAsAudience=function(e,t,n){return void 0===t&&(t=Ot.LIVE),ye(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d;return Re(this,(function(l){switch(l.label){case 0:return this._channel?(r=this._channel.codec.encodeJoinRTCRoom(t,n),i=new Oi(Li[Li.viewerJoinR],r,e),[4,this._channel.send(i,Hr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return o=l.sent(),s=o.code,a=o.data,s!==it.SUCCESS?[2,{code:s}]:(u=(c=a).rtcToken,d=c.entries,[2,{code:s,data:{token:u,kvEntries:d}}])}}))}))},t.prototype.quitLivingRoomAsAudience=function(e){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(t=this._channel.codec.encodeQuitRTCRoom(),n=new Oi(Li[Li.viewerExitR],t,e),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return r=i.sent().code,this._rtcKVManager.reset(),[2,r]}}))}))},t.prototype.rtcIdentityChange=function(e,t,n){return ye(this,void 0,void 0,(function(){var r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._channel?(r=this._channel.codec.encodeIdentityChangeInfo(t,n),i=new Oi(Li[Li.rtcIdentityChange],r,e),[4,this._channel.send(i,Hn)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return o=c.sent(),s=o.code,a=o.data,s!==it.SUCCESS?[2,{code:s}]:[2,{code:s,data:a}]}}))}))},t.prototype.pullRTCRoomEntry=function(e,t){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u;return Re(this,(function(d){switch(d.label){case 0:return n=(t=this)._channel,r=t.currentUserId,n?(Ze.info("audience in room start pull KV"),i=n.codec.encodePullRTCRoomKV(e,0),o=new Oi(Li[Li.rtcPullKv],i,r),[4,n.send(o,Vr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return s=d.sent(),a=s.code,c=s.data,Ze.info("audience in room end pull KV, code: "+a+", data: "+JSON.stringify(c||{})),a===it.SUCCESS?(u=c.kvEntries,this._watcher.onRTCDataChange(u,e),[2,{code:a,data:c}]):[2,{code:a}]}}))}))},t.prototype.getRTCJoinedUserInfo=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c;return Re(this,(function(u){switch(u.label){case 0:return n=(t=this)._channel,r=t.currentUserId,n?(i=n.codec.encodeQueryUserJoinedInfo(e),o=new Oi(Li[Li.rtcQueryJoined],i,r),[4,n.send(o,Fr)]):[2,{code:it.RC_NET_CHANNEL_INVALID}];case 1:return s=u.sent(),a=s.code,c=s.data,a===it.SUCCESS?[2,{code:a,data:c}]:[2,{code:a}]}}))}))},t.prototype.getDeviceId=function(){return go(this.runtime)},t.prototype.requestRoomPK=function(e){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(t=this._channel.codec.encodeRequestRoomPK(e),n=new Oi(Li[Li.rtcInvite],t,e.roomId),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return r=i.sent().code,this._rtcKVManager.reset(),[2,r]}}))}))},t.prototype.cancelRoomPK=function(e){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(t=this._channel.codec.encodeCancelRoomPK(e),n=new Oi(Li[Li.rtcCancelInvite],t,e.roomId),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return r=i.sent().code,this._rtcKVManager.reset(),[2,r]}}))}))},t.prototype.responseRoomPK=function(e){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(t=this._channel.codec.encodeResponseRoomPK(e),n=new Oi(Li[Li.rtcInviteAnswer],t,e.roomId),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return r=i.sent().code,this._rtcKVManager.reset(),[2,r]}}))}))},t.prototype.endRoomPK=function(e){return ye(this,void 0,void 0,(function(){var t,n,r;return Re(this,(function(i){switch(i.label){case 0:return this._channel?(t=this._channel.codec.encodeEndRoomPK(e),n=new Oi(Li[Li.rtcEndInvite],t,e.roomId),[4,this._channel.send(n)]):[2,it.RC_NET_CHANNEL_INVALID];case 1:return r=i.sent().code,this._rtcKVManager.reset(),[2,r]}}))}))},t.prototype.callExtra=function(e){for(var t=[],n=1;n0){var e=s.join("");if(s=[],e.length>26){var n=t.numberEncode(e.length),r=String.fromCharCode(t.dataType.NormalExt|n.length);o.push(r+n)}else{var i=String.fromCharCode(t.dataType.Normal|e.length);o.push(i)}o.push(e)}},c=0;c=u.length)s.push(e.substr(c,u.length)),c+=u.length;else{a();var h=String.fromCharCode(t.dataType.Compressed|d.length<<2|l.length);o.push(h+d+l),c+=u.length}}}a();var f=t.numberEncode(e.length),p=String.fromCharCode(t.dataType.Tail|f.length);return o.push(p+f),o.join("")},e.uncompress=function(e){var t=this,n=0,r="";e:do{var i=e.charCodeAt(n++),o=i&t.dataType.Mark,s=15&i,a=void 0;switch(o){case t.dataType.Compressed:var c=s>>2,u=3&s;if(0===c||0===u)throw new Error("Data parsing error,at "+n);var d=t.numberDecode(e.substr(n,c)),l=t.numberDecode(e.substr(n+=c,u));if((d=r.length-d)+l>r.length)throw new Error("Data parsing error,at "+n);n+=u,r+=r.substr(d,l);break;case t.dataType.Tail:if((a=t.numberDecode(e.substr(n,s)))!==r.length)throw console.log(r.length),console.log(a),new Error("Data parsing error,at "+n);n+=s;break e;case t.dataType.NormalExt:a=t.numberDecode(e.substr(n,s)),r+=e.substr(n+=s,a),n+=a;break;case t.dataType.Normal:r+=e.substr(n,s),n+=s;break;case t.dataType.Mark:if(s>10)throw new Error("Data parsing error,at "+n);r+=e.substr(n,16+s),n+=16+s;break;default:throw new Error("Data parsing error,at "+n+" header:"+o)}}while(n=t.length-1)return r;var i=e[t.charAt(n)+t.charAt(n+1)];if(i[0]===n)return r;for(var o=t.length-n,s=0,a=i.length;sthis.max)){var d=Math.min(o,u);if(d<=r.length)break;if(!(r.length>2&&t.charAt(c+r.length-1)!==t.charAt(n+r.length-1))){for(var l=2,h=l;h=r.length&&(r.length=l,r.offset=c)}}}return r},e.numberEncode=function(e){var t=this,n=[],r=0;do{r=e%t.scale,n.push(t.chars.charAt(r)),e=(e-r)/t.scale}while(e>0);return n.join("")},e.numberDecode=function(e){for(var t=0,n=0,r=e.length-1;r>=0;r--){if(-1===(n=this.chars.indexOf(e.charAt(r))))throw new Error('decode number error, data is "'+e+'"');t=t*this.scale+n}return t},e.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},e.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",e.scale=e.chars.length,e.max=238327,e}(),Eo=1,To=!1,So="undefined"!=typeof location&&"https://"===location.protocol?"https://":"http://",Io=function(){function e(e){this.info=e,this.logUrl="logcollection.ronghub.com",this.level=1,this.itv=30,this.times=5,this.deviceId="",this.deviceInfo="",this.logSwitch=0,this.logUrl=e.logPolicy.url||this.logUrl,this.level=e.logPolicy.level||this.level,this.itv=e.logPolicy.itv||this.itv,this.times=e.logPolicy.times||this.times,this.deviceId=go(e.runtime),this.logSwitch=e.logSwitch;var t=function(e){if("browser"!==e.tag)return{type:e.tag,version:"UnKonw"};var t,n,r=navigator.userAgent,i={IE:/rv:([\d.]+)\) like Gecko|MSIE ([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/Firefox\/([\d.]+)/,Opera:/(?:OPERA|OPR).([\d.]+)/,WeChat:/MicroMessenger\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,Chrome:/Chrome\/([\d.]+)/,Safari:/Version\/([\d.]+).*Safari/,iOSChrome:/Mobile\/([\d.]+).*Safari/};for(var o in i)if(i.hasOwnProperty(o)){var s=r.match(i[o]);if(s){n=o,t=s[1]||s[2];break}}return{type:n||"UnKonw",version:t||"UnKonw"}}(e.runtime);this.deviceInfo=t.type+"|"+t.version+"|"+Xe.sessionId,this.startReport()}return e.init=function(t){return To=!0,e._instance||(e._instance=new e(t)),e._instance},e.getInstance=function(){return e._instance},e.prototype.startReport=function(){var e=this;if(this.logSwitch&&To){var t=this.itv*Math.pow(2,Eo-1);Eo "+t),e.startReport()}))}else this.startReport()},e.prototype.reportFullLog=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d,l=this;return Re(this,(function(h){switch(h.label){case 0:return t=e.startTime,n=e.endTime,r=e.platform,i=e.logId,o=e.uri,s=ke.getInstance(),Ze.debug("received report log msg, "+r.toLowerCase(),s),"web"===r.toLowerCase()&&s?t>n?(Ze.warn("report error: The start time("+t+") cannot be greater than the end time("+t+")"),[2]):[4,Ze.__insertLogIntoDatabase()]:[2];case 1:return h.sent(),[4,s.getRangeData(be,"time",t,n)];case 2:return a=(a=h.sent()).filter((function(e){return!e.userId||e.userId===l.info.userId})),c=Co.compress(a.map((function(e){return e.content})).join("")||"no data"),u=1,(d=function(){if(!(u>3)&&To){var e=o||l.logUrl,t=""+So+e+"?version="+l.info.version+"&appkey="+l.info.appkey+"&userId="+l.info.userId+"&logId="+i+"&deviceId="+l.deviceId+"&deviceInfo="+l.deviceInfo+"&platform=Web",n=5e3*(u-1);u++,setTimeout((function(){To&&l.info.runtime.httpReq({url:t,method:"POST",body:c}).then((function(){Ze.debug("report full log success!")})).catch((function(e){d(),Ze.warn("report full log error -> "+e)}))}),n)}})(),[2]}}))}))},e.prototype.distroy=function(){Eo=1,To=!1},e}();function bo(e){return Object.assign({},e)}var wo,ko=function(){function e(e,t){var n;this._runtime=e,this._token="",this._pluginContextQueue=[],this._pluginInstanseMap={},this.coreVersion="5.1.1",this._versionInfo={},this._typingInfo={},this._isInternalConnected=!1,this._connectionStatus=st.DISCONNECTED,this._canRedirectConnect=!1,this._watcher={message:void 0,batchMessage:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,readReceiptReceived:void 0,messageReceiptRequest:void 0,messageReceiptResponse:void 0,typingState:void 0,messageBlocked:void 0},this._typingInternalTimer=-1,this._typingExpireTime=2e3,this._typingChangedList=[],this.getChatRoomHistoryMessages=this.getChatroomHistoryMessages,this._options=Object.assign({},t),this.appkey=this._options.appkey,this.apiVersion=this._options.apiVersion,this._options.typingExpireTime&&(this._options.typingExpireTime<2e3?this._typingExpireTime=2e3:this._options.typingExpireTime>6e3?this._typingExpireTime=6e3:this._typingExpireTime=this._options.typingExpireTime),this._options.navigators=this._options.navigators.filter((function(e){return/^https?:\/\//.test(e)})),this._options.navigators=this._options.navigators.map((function(e){return e.replace(/\/$/g,"")})),0===this._options.navigators.length&&(n=this._options.navigators).push.apply(n,se);var r={status:this._connectionStatusListener.bind(this),batchMessage:this._batchMessageReceiver.bind(this),chatroom:this._chatroomInfoListener.bind(this),conversation:this._conversationInfoListener.bind(this),expansion:this._expansionInfoListener.bind(this),tag:this._tagListener.bind(this),conversationTag:this._conversationTagListener.bind(this),onRTCDataChange:this._rtcDataChange.bind(this),pullFinished:this._pullFinishedListener.bind(this)};this._engine=sn()?new RCCppEngine(e,r,this._options):new _o(e,r,this._options)}return e.init=function(t,n){return Ze.setLogLevel(n.logLevel),Ze.setLogStdout(n.logStdout),(n.indexDBSwitch||qe(n.indexDBSwitch))&&ke.init(),Ze.debug("APIContext.init =>",n.appkey,n.navigators),this._context?(Ze.error("Repeat initialize!"),this._context):(Ze.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new e(t,n),Ze.__insertLogIntoDatabase(),this._context)},e.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},e.prototype.install=function(e,t){if(this._pluginInstanseMap[e.tag])return Ze.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var n="RCRTC"===e.tag?new Ro(this):new yo(this),r=null;try{if(!e.verify(this._runtime))return null;r=e.setup(n,this._runtime,t)}catch(e){Ze.error("install plugin error!\n",e)}return["RCRTC","RCCall"].includes(e.tag)&&e.version&&e.name&&(this._versionInfo[e.name]=e.version),r&&this._pluginContextQueue.push(n),r&&(this._pluginInstanseMap[e.tag]=r),r},e.prototype._handleRedirect=function(){return ye(this,void 0,void 0,(function(){var e=this;return Re(this,(function(t){switch(t.label){case 0:return Ze.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return t.sent().code!==it.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout((function(){e._handleRedirect()}),5e3)),[2]}}))}))},e.prototype._connectionStatusListener=function(e){var t;return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return e===st.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===st.BLOCKED||e===st.KICKED_OFFLINE_BY_OTHER_CLIENT||e===st.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===st.CONNECTING?this._handleConnecting():e===st.CONNECTED?this._handleConnected():e===st.DISCONNECTED?this._handleDisconnect():e===st.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,(null===(t=this._watcher.rtcInnerWatcher)||void 0===t?void 0:t.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach((function(t){t.onconnectionstatechange&&t.onconnectionstatechange(e)})),this._watcher.connectionState&&this._watcher.connectionState(e),[2]}))}))},e.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},e.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},e.prototype._handleDisconnect=function(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},e.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},e.prototype._messageReceiver=function(e,t,n){var r,i,o;if((e.conversationType===xe.RTC_ROOM||Object.prototype.hasOwnProperty.call(Dt,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(bo(e));else if(-1===["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)||"function"!=typeof this._watcher.chatroomState){if("RC:ChrmMemChange"!==e.messageType){if(e.messageType!==Rt.TYPING_STATUS||(this._addTypingInfo(bo(e)),!this._watcher.typingState))if(e.messageType!==Rt.LOG_COMMAND||"rongcloudsystem"!==e.senderUserId)if(e.messageType!==Rt.INTERCEPT){if(!this._pluginContextQueue.some((function(t){if(!t.onmessage)return!1;try{return t.onmessage(bo(e))}catch(e){return Ze.error("plugin error =>",e),!1}})))if("RC:ReadNtf"!==e.messageType)if("RC:RRReqMsg"!==e.messageType){if("RC:RRRspMsg"!==e.messageType)return this._watcher.message&&this._watcher.message(bo(e),t,n),e;var s=null===(o=e.content)||void 0===o?void 0:o.receiptMessageDic;s&&Array.isArray(s[this._engine.currentUserId])&&"function"==typeof this._watcher.messageReceiptResponse&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,s[this._engine.currentUserId])}else"function"==typeof this._watcher.messageReceiptRequest&&this._watcher.messageReceiptRequest({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.senderUserId);else"function"==typeof this._watcher.readReceiptReceived&&this._watcher.readReceiptReceived({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId||"",blockType:e.content.interceptType,blockedMessageUId:e.content.msgUId});else{var a=e.content,c=a.startTime,u=a.endTime,d=a.platform,l=a.logId,h=a.uri,f=a.packageName,p={startTime:parseInt(c),endTime:parseInt(u),platform:d,logId:l,uri:h,packageName:f};null===(i=Io.getInstance())||void 0===i||i.reportFullLog(p)}}else if("function"==typeof this._watcher.chatroomState){var g={};Array.isArray(e.content.userList)&&e.content.userList.forEach((function(e){g[e.userId]=e.status})),this._watcher.chatroomState({userChange:{users:g,chatroomId:e.targetId}})}}else this._watcher.chatroomState({userChange:{users:(r={},r[e.senderUserId]="RC:ChrmQuitNtf"===e.messageType?Pt.QUIT:Pt.JOIN,r),chatroomId:e.targetId}})},e.prototype._batchMessageReceiver=function(e,t,n){var r=this,i=[];e.forEach((function(e){var o=r._messageReceiver(e,t,n);o&&i.push(o)})),i.length&&this._watcher.batchMessage&&this._watcher.batchMessage(i)},e.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},e.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},e.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},e.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},e.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},e.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},e.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},e.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},e.prototype._rtcDataChange=function(e,t){this._pluginContextQueue.forEach((function(n){n.onrtcdatachange&&n.onrtcdatachange(e,t)}))},e.prototype.assignWatcher=function(e){var t=this;Object.keys(this._watcher).forEach((function(n){if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];t._watcher[n]=Ke(r)||je(r)?r:void 0}}))},e.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach((function(t){e._watcher[t]=void 0}))},e.prototype._addTypingInfo=function(e){var t=e.senderUserId,n=e.conversationType,r=e.targetId,i=e.content,o=e.channelId,s=i.typingContentType,a=n+"#"+r+"#"+(o||"");this._typingInfo[a]||(this._typingInfo[a]=[]);var c=this._typingInfo[a].findIndex((function(e){return e.userId===t}));c>=0&&this._typingInfo[a][c].messageType===s?this._typingInfo[a][c].timestamp=Date.now():(c>=0&&this._typingInfo[a].splice(c,1),this._typingInfo[a].push({userId:t,messageType:s,timestamp:Date.now()}),this._typingChangedList.includes(a)||this._typingChangedList.push(a),this._startCheckTypingInfo())},e.prototype._startCheckTypingInfo=function(){var e=this;-1===this._typingInternalTimer&&0!==Object.keys(this._typingInfo).length&&(this._typingInternalTimer=setInterval((function(){for(var t in e._typingInfo){var n=e._typingInfo[t].length;e._typingInfo[t]=e._typingInfo[t].filter((function(t){return Date.now()-t.timestamp0){var r=e._typingChangedList.map((function(t){return{conversationType:Number(t.split("#")[0]),targetId:t.split("#")[1],channelId:t.split("#")[2],list:e._typingInfo[t]||[]}}));e._typingStatusListener(r),e._typingChangedList=[]}0===Object.keys(e._typingInfo).length&&(clearInterval(e._typingInternalTimer),e._typingInternalTimer=-1)}),500))},e.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},e.prototype.getServerTime=function(){return this._engine.getServerTime()},e.prototype.getDeviceId=function(){return this._engine.getDeviceId()},e.prototype.getCurrentUserId=function(){return this._engine.currentUserId},e.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(e.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),e.prototype.connect=function(e,t){return void 0===t&&(t=!1),ye(this,void 0,void 0,(function(){var n,r,i,o,s,a;return Re(this,(function(c){switch(c.label){case 0:return this._connectionStatus===st.CONNECTED?[2,{code:it.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===st.CONNECTING?[2,{code:it.BIZ_ERROR_CONNECTING}]:"string"!=typeof e||0===e.length?[2,{code:it.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,n=e.split("@"),r=n[1],i=r?r.split(";").map((function(e){return/^https?:/.test(e)?e:"https://"+e})):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),i,t,this._options.checkCA)]);case 1:return(o=c.sent())?1===(null==o?void 0:o.type)?[2,{code:it.PACKAGE_ENVIRONMENT_ERROR}]:(s=Ht.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),o)]):[2,{code:it.RC_NAVI_RESOURCE_ERROR}];case 2:return a=c.sent(),Ze.__insertLogIntoDatabase(),a!==dt?[3,4]:(this._connectionStatus=st.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,c.sent()];case 4:return a===it.SUCCESS&&(Ze.info("connect success, userId: "+this._engine.currentUserId),1!==(null==o?void 0:o.type)&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(s),Io.init({runtime:this._runtime,logSwitch:(null==o?void 0:o.logSwitch)||0,logPolicy:JSON.parse((null==o?void 0:o.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),Xe.init(this._engine.currentUserId),this._isInternalConnected=!0),a!==it.SUCCESS||sn()||1===o.openUS&&this._pullUserSettings(),a!==it.SUCCESS&&(this._connectionStatus=st.CONNECTION_CLOSED),[2,{code:a,userId:this._engine.currentUserId}]}}))}))},e.prototype._pullUserSettings=function(){return ye(this,void 0,void 0,(function(){return Re(this,(function(e){return[2]}))}))},e.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,null===(e=Io.getInstance())||void 0===e||e.distroy(),Ze.__insertLogIntoDatabase(),Xe.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach((function(e){if(e.ondisconnect)try{e.ondisconnect()}catch(e){Ze.error("plugin error =>",e)}})),Promise.resolve()},e.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:it.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},e.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},e.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},e.prototype.registerMessageType=function(e,t,n,r){void 0===r&&(r=[]),this._engine.registerMessageType(e,t,n,r)},e.prototype.sendMessage=function(e,t,n,r){var i=this.getInfoFromCache();if(1===((null==i?void 0:i.grpRRVer)||0)&&n.messageType===Rt.READ_RECEIPT_RESPONSE)return Promise.resolve({code:it.READ_RECEIPT_ERROR});var o=JSON.stringify(n.content);return Te(o)>131072?Promise.resolve({code:it.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,t,n,r)},e.prototype.sendExpansionMessage=function(e){return ye(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d,l,h,f,p;return Re(this,(function(g){switch(g.label){case 0:if(t=e.channelId,n=e.conversationType,r=e.targetId,i=e.messageUId,o=e.keys,s=e.expansion,a=e.removeAll,!e.canIncludeExpansion)return[2,{code:it.MESSAGE_KV_NOT_SUPPORT}];if(c=!1,u=!1,d=!1,je(s))for(h in l=Object.keys(s).length,c=l>20,s)if(f=s[h],u=Ue(h)&&!/^[A-Za-z0-9_=+-]+$/.test(h),(d=h.length>32||f.length>64)||u)break;return c||d?[2,{code:it.EXPANSION_LIMIT_EXCEET}]:u?[2,{code:it.BIZ_ERROR_INVALID_PARAMETER}]:(p={mid:i},s&&(p.put=s),o&&(p.del=o),a&&(p.removeAll=1),[4,this._engine.sendMessage(n,r,{content:p,messageType:Rt.EXPANSION_NOTIFY,channelId:t})]);case 1:return[2,{code:g.sent().code}]}}))}))},e.prototype.sendReadReceiptMessage=function(e,t,n){return ye(this,void 0,void 0,(function(){var r;return Re(this,(function(i){return 0===((null==(r=this.getInfoFromCache())?void 0:r.grpRRVer)||0)?[2,{code:it.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,t,n)]}))}))},e.prototype.getMessageReader=function(e,t,n){return ye(this,void 0,void 0,(function(){var r;return Re(this,(function(i){return 0===((null==(r=this.getInfoFromCache())?void 0:r.grpRRVer)||0)?[2,{code:it.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,t,n)]}))}))},e.prototype._destroy=function(){var e;this._isInternalConnected=!1,this._watcher={batchMessage:void 0,message:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,typingState:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0},this._engine.disconnect(),this._pluginContextQueue.forEach((function(e){if(e.ondestroy)try{e.ondestroy()}catch(e){Ze.error("plugin error =>",e)}})),this._pluginContextQueue.length=0,this._pluginInstanseMap={},null===(e=Io.getInstance())||void 0===e||e.distroy(),Xe.reset()},e.prototype.getHistoryMessage=function(e,t,n,r,i,o,s){return void 0===n&&(n=0),void 0===r&&(r=20),void 0===i&&(i=0),void 0===o&&(o=""),void 0===s&&(s=""),this._engine.getHistoryMessage(e,t,n,r,i,o,s||"")},e.prototype.getConversationList=function(e,t,n,r,i){return void 0===e&&(e=300),void 0===i&&(i=""),this._engine.getConversationList(e,t,n,r,i)},e.prototype.getConversation=function(e,t,n){return this._engine.getConversation(e,t,n)},e.prototype.removeConversation=function(e,t,n){return void 0===n&&(n=""),this._engine.removeConversation(e,t,n)},e.prototype.clearUnreadCount=function(e,t,n){return void 0===n&&(n=""),this._engine.clearConversationUnreadCount(e,t,n)},e.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},e.prototype.getUnreadCount=function(e,t,n){return void 0===n&&(n=""),this._engine.getConversationUnreadCount(e,t,n)},e.prototype.getTotalUnreadCount=function(e,t,n){return this._engine.getAllConversationUnreadCount(e,t&&t.length>0?t:[xe.PRIVATE,xe.GROUP,xe.SYSTEM,xe.PUBLIC_SERVICE],!!n)},e.prototype.getFirstUnreadMessage=function(e,t,n){return void 0===n&&(n=""),this._engine.getFirstUnreadMessage(e,t,n)},e.prototype.setConversationStatus=function(e,t,n,r,i){void 0===i&&(i="");var o=[{conversationType:e,targetId:t,isTop:n,notificationStatus:r,channelId:i}];return this._engine.batchSetConversationStatus(o)},e.prototype.saveConversationMessageDraft=function(e,t,n,r){return void 0===r&&(r=""),this._engine.saveConversationMessageDraft(e,t,n,r)},e.prototype.getConversationMessageDraft=function(e,t,n){return void 0===n&&(n=""),this._engine.getConversationMessageDraft(e,t,n)},e.prototype.clearConversationMessageDraft=function(e,t,n){return void 0===n&&(n=""),this._engine.clearConversationMessageDraft(e,t,n)},e.prototype.recallMessage=function(e,t,n,r,i){return this._engine.recallMsg(e,t,n,r,i)},e.prototype.deleteRemoteMessage=function(e,t,n,r){return void 0===r&&(r=""),this._engine.deleteRemoteMessage(e,t,n,r)},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){return void 0===r&&(r=""),this._engine.deleteRemoteMessageByTimestamp(e,t,n,r)},e.prototype.joinChatroom=function(e,t){return void 0===t&&(t=10),this._engine.joinChatroom(e,t)},e.prototype.joinExistChatroom=function(e,t){return void 0===t&&(t=10),this._engine.joinExistChatroom(e,t)},e.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},e.prototype.getChatroomInfo=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),this._engine.getChatroomInfo(e,t,n)},e.prototype.setChatroomEntry=function(e,t){var n=t.key,r=t.value;return $t(n)&&en(r)?this._engine.setChatroomEntry(e,t):Promise.resolve(it.BIZ_ERROR_INVALID_PARAMETER)},e.prototype.setChatroomEntries=function(e,t){for(var n=0;n1e3?[2,Promise.reject(it.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,t)]}))}))},e.prototype.removeTagForConversations=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,this._engine.removeTagForConversations(e,t)]}))}))},e.prototype.removeTagsForConversation=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,this._engine.removeTagsForConversation(e,t)]}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){return ye(this,void 0,void 0,(function(){return Re(this,(function(i){return[2,this._engine.getConversationListByTag(e,t,n,r)]}))}))},e.prototype.getUnreadCountByTag=function(e,t){return ye(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,this._engine.getUnreadCountByTag(e,t)]}))}))},e.prototype.setConversationStatusInTag=function(e,t,n){return ye(this,void 0,void 0,(function(){return Re(this,(function(r){return[2,this._engine.setConversationStatusInTag(e,t,n)]}))}))},e.prototype.getTagsForConversation=function(e){return ye(this,void 0,void 0,(function(){return Re(this,(function(t){return[2,this._engine.getTagsForConversation(e)]}))}))},e.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},e.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},e.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},e.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},e.prototype.callExtra=function(e){for(var t,n=[],r=1;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]"+n),[4,as.imClient.context.joinChatroom(e,t.count)];case 1:return(r=i.sent())!==it.SUCCESS?(Mo.warn("join chatroom fail ->code+:"+us[r]+","+n),[2,{code:r,msg:us[r]}]):[2,{code:r}]}}))}))}var _s=function(e,t,n,r){void 0===n&&(n=!0),void 0===r&&(r=!0),this.messageType=e,this.content=t,this.isPersited=n,this.isCounted=r};function ys(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=!0),function(r){return new _s(e,r,t,n)}}var Rs,Cs,Es=ys("RC:ImgMsg"),Ts=ys("RC:HQVCMsg"),Ss=ys("RC:SightMsg"),Is=ys("RC:TxtMsg"),bs=ys("RC:CombineMsg"),ws=ys("RC:FileMsg");ys("RC:GIFMsg"),ys("RC:VcMsg"),ys("RC:LBSMsg"),ys("RC:ReferenceMsg"),ys("RC:ImgTextMsg");var ks={qiniu:function(e,t,n,r){var i,o="https://"+t.uploadHost.qiniu;i=xs()+Ns[0][1]||o,Ns.shift();var s=new XMLHttpRequest;s.upload&&t.support_options&&(s.upload.onprogress=function(e){n.onProgress(e.loaded,e.total)}),s.onreadystatechange=function(){if(4===s.readyState){var i=s.responseText||"{}";(i=JSON.parse(i)).filename=t.uniqueValue,i.uploadMethod=bt?bt.QINIU:"",200===s.status?n.onCompleted(i):Ns.length?ks[Ns[0][0]](e,t,n,r):n.onError("upload fail")}},t.isChunk&&(i=function(e,t){var n="";return As(t,(function(e,t){"token"!==e&&(n+=(n?"&":"")+encodeURIComponent(e)+"="+encodeURIComponent(t))})),n&&(e+=(e.indexOf("?")>0?"&":"?")+n),e}(i+="/mkblk/"+e.size,t.multi_parmas)),s.open(t.method,i,!0),n.onOpen(s),t.stream&&s.setRequestHeader("authorization","UpToken "+t.multi_parmas.token),As(t.headers,(function(e,t){s.setRequestHeader(e,t)})),s.send(e)},baidu:function(e,t,n,r){if(console.log(r,t),r.size>Os)throw new Error("the file size is over 5GB!");var i=t||{};t=t||Cs;var o=new XMLHttpRequest,s=xs();if(i.uploadHost.bos||i.bosUploadPath){var a=s+Ns[0][1]+i.bosUploadPath;Ns.shift();var c=i.bosHeader||{},u={filename:t.uniqueValue||r.uniqueName,name:r.name,downloadUrl:a,isBosRes:!0};o.upload&&t.support_options&&(o.upload.onprogress=function(e){n.onProgress(e.loaded,e.total,!0)}),o.onreadystatechange=function(){if(4===o.readyState){var i=o.responseText||"{}";(i=JSON.parse(i)).filename=t.uniqueValue,200===o.status?n.onCompleted(u,!0):Ns.length?ks[Ns[0][0]](e,t,n,r):n.onError("upload fail")}},o.open(t.method,a,!0),o.setRequestHeader("authorization",c.bosToken),o.setRequestHeader("x-bce-date",c.bosDate),o.send(r)}},aliyun:function(e,t,n,r){if(r.size>Os)throw new Error("the file size is over 5GB!");var i=new FormData;i.set("file",e.get("file")),i.set("key",e.get("key")),i.set("token",e.get("token"));var o=Ns[0][1];Ns.shift(),e=e||Rs,t=(t=t||{})||Cs;var s=new XMLHttpRequest,a=xs()+t.ossBucketName+"."+o;s.upload&&t.support_options&&(s.upload.onprogress=function(e){n.onProgress(e.loaded,e.total)}),s.onreadystatechange=function(){if(4===s.readyState){var e=s.responseText||"{}";(e=JSON.parse(e)).name=t.uniqueValue,e.filename=t.uploadFileName,e.uploadMethod=bt?bt.ALI:"",200===s.status?n.onCompleted(e):Ns.length?ks[Ns[0][0]](i,t,n,r):n.onError("upload fail")}},s.open(t.method,a,!0),console.log("ali:url",a);var c=t.aliHeader||{};e.set("OSSAccessKeyId",c.osskeyId),e.set("policy",c.ossPolicy),e.set("Signature",c.ossSign),e.set("success_action_status",200),e.delete("key"),e.append("key",t.uploadFileName),e.delete("file"),e.append("file",r),s.send(e)},s3:function(e,t,n,r){var i=new FormData,o=new XMLHttpRequest,s=xs(),a=Ns[0][1],c=s+t.s3BucketName+"."+a;console.log("uploadS3:url",c),Ns.shift(),o.upload&&t.support_options&&(o.upload.onprogress=function(e){n.onProgress(e.loaded,e.total)}),o.onreadystatechange=function(){if(4===o.readyState){var i=o.responseText||"{}";if((i=JSON.parse(i)).name=t.uniqueValue,i.filename=t.uploadFileName,i.uploadMethod=bt.AWS,console.log("UploadMethod:",bt),200===o.status||204===o.status)n.onCompleted(i);else if(Ns.length){var s=new FormData;s.set("file",e.get("file")),s.set("key",e.get("key")),s.set("token",e.get("token")),ks[Ns[0][0]](s,t,n,r)}else n.onError("upload fail")}},o.open(t.method,c,!0);var u=t?t.s3Header:{},d=r&&r.type;"text/html"===d?i.set("Content-Disposition","inline;"):i.set("Content-Disposition","attachment;"),i.set("Content-Type",d),i.set("x-amz-credential",u.s3Credential),i.set("x-amz-algorithm",u.s3Algorithm),i.set("x-amz-date",u.s3Date),i.set("policy",u.s3Policy),i.set("x-amz-signature",u.s3Signature),i.set("key",t.uploadFileName),i.set("file",r),o.send(i)},stc:function(e,t,n,r){new FormData;var i=new XMLHttpRequest;xs();var o="https://"+Ns[0][1]+"/"+t.stcBucketName+"/"+t.uploadFileName;Ns.shift(),i.upload&&t.support_options&&(i.upload.onprogress=function(e){n.onProgress(e.loaded,e.total)}),i.onreadystatechange=function(){if(4===i.readyState){var o=i.responseText||"{}";if((o=JSON.parse(o)).name=t.uniqueValue,o.filename=t.uploadFileName,o.uploadMethod=bt?bt.STC:"",200===i.status||204===i.status)n.onCompleted(o);else if(Ns.length){var s=new FormData;s.set("file",e.get("file")),s.set("key",e.get("key")),s.set("token",e.get("token")),ks[Ns[0][0]](s,t,n,r)}else n.onError("upload fail")}},i.open("PUT",o,!0);var s=t?t.stcHeader:{};i.setRequestHeader("Content-Type",r.type),"text/html"===r.type?i.setRequestHeader("Content-Disposition","inline;"):i.setRequestHeader("Content-Disposition","attachment;"),i.setRequestHeader("Authorization",s.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",s.stcContentSha256),i.setRequestHeader("x-amz-date",s.stcDate),i.send(r)}},Ns=[],Os=5368709120;function As(e,t){for(var n in e)t(n,e[n])}function xs(){var e="https://";return"http:"!==location.protocol&&"file:"!==location.protocol||(e="http://"),e}var Ps={form:function(e,t){var n=new FormData;if(t.unique_key){var r=e.name.substr(e.name.lastIndexOf(".")),i=Ms()+r;n.append(t.unique_key,i),t.uniqueValue=i}return n.append(t.file_data_name,e),Ls(t.multi_parmas,(function(e,t){n.append(e,t)})),n},json:function(e,t){var n={};if(t.unique_key){var r=e.name.substr(e.name.lastIndexOf(".")),i=Ms()+r;n[t.unique_key]=i,t.uniqueValue=i}return n[t.file_data_name]=e,Ls(t.multi_parmas,(function(e,t){n[e]=t})),JSON.stringify(n)},data:function(e,t){return e}};function Ms(){var e=(new Date).getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))}function Ls(e,t){for(var n in e)t(n,e[n])}var Us,Ds=0;function Vs(e){this.options=function(e){var t={domain:"",method:"POST",file_data_name:"file",unique_key:"key",base64_size:4194304,chunk_size:4194304,bos_chunk_size:4294967296,stc_chunk_size:10485760,headers:{},multi_parmas:{},query:{},support_options:!0,data:Ps.form,genUId:Ms};if(!e||!e.domain)throw new Error("domain is null");for(var n in e)t[n]=e[n];return t}(e),this.setOptions=function(e){var t=this;Ls(e,(function(e,n){t.options[e]=n}))},console.log("options",e),this.upload=function(e,t){if(e){var n=this;!function(e,t,n){if(Rs=e,Cs=t,Ns=[],t.ossConfig){var r,i,o=JSON.parse(t.ossConfig),s="",a=[];o.forEach((function(e){var t=Number(e.p)-1;for(var n in e)"aliyun"===n&&(s=e[n]),"s3"===n&&(r=e[n]),"stc"===n&&(i=e[n]),"p"!==n&&(a[t]=[n,e[n]])})),a.forEach((function(e){e&&Ns.push(e)})),o.length!==Ns.length&&(Ns=[["qiniu",t.domain],["baidu",t.uploadHost.bos],["aliyun",s],["s3",r],["stc",i]])}else Ns=[["qiniu",t.domain],["baidu",t.uploadHost.bos]];var c;if(t.ossConfig){var u=t&&JSON.parse(t.ossConfig);Array.isArray(u)||(u=[]),c=u.find((function(e){return Object.keys(e).includes("stc")}))}if(c&&1===parseInt(c.p)&&e.size>=4194304)!function(e,t,n){var r,i,o=e&&e.type||"text/plain",s=o.indexOf("image")>-1?1:4,a=Math.ceil(e.size/t.stc_chunk_size),c=t&&JSON.parse(t.ossConfig?t.ossConfig:"");Array.isArray(c)||(c=[]);var u=c.find((function(e){return Object.keys(e).includes("stc")})),d="uploads";as.imClient.getFileToken(s,r,"POST",d).then((function(e){r=e.fileName,i="https://"+u.stc+"/"+t.stcBucketName+"/"+r,console.log("uploadStcMultipart:url",i);var s=new XMLHttpRequest;s.open("POST",i+"?"+d,!0),"text/html"===o?s.setRequestHeader("Content-Disposition","inline;"):s.setRequestHeader("Content-Disposition","attacshment;"),s.setRequestHeader("Authorization",e&&e.stcAuthorization),s.setRequestHeader("x-amz-content-sha256",e&&e.stcContentSha256),s.setRequestHeader("x-amz-date",e&&e.stcDate),s.setRequestHeader("Content-Type",o),s.send(),s.onreadystatechange=function(e){if(4===s.readyState){var t=s.response.match(/(?:)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",t),200===s.status||204===s.status?function(e){for(var t=[],n=1;n<=a;n++)t.push(p(e,n));f(e,t)}(Array.isArray(t)&&t[1]):n.onError("uploadStcMultipart:did not get uploadId")}}}),(function(e){n.onError("uploadStcMultipart:"+e)}));var l=[],h=new Map;function f(c,u){u&&Array.isArray(u)&&0!==u.length&&Promise.all(u).then((function(){var u="uploadId="+c;if(h.size===a)as.imClient.context.getFileToken(s,r,"POST",u).then((function(r){console.log("onSuccess",r),console.log("onSuccess:uploadId",c);var s=new XMLHttpRequest;s.open("POST",i+"?"+u,!0),s.setRequestHeader("Authorization",r&&r.stcAuthorization),s.setRequestHeader("x-amz-content-sha256",r&&r.stcContentSha256),s.setRequestHeader("x-amz-date",r&&r.stcDate),s.setRequestHeader("Content-Type",o);var a="",d=Array.from(h.keys()||[]).sort((function(e,t){return e-t}));console.log("keys",d),d.map((function(e){a+="".concat(h.get(e),"").concat(e,"")})),a+="",s.send(a),console.log("xml",a),s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status||204===s.status){var r={};r.name=e.name,r.filename=t.uploadFileName,r.uploadMethod=bt.STC,n.onCompleted(r)}else n.onError("uploadStcMultipart:upload does not end")}}),(function(e){n.onError("uploadStcMultipart:"+e)}));else{var d,g=[],m=C(l);try{for(m.s();!(d=m.n()).done;){var v=d.value;g.push(p(c,v))}}catch(_){m.e(_)}finally{m.f()}f(c,g)}}),(function(e){console.error(e),n.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var t,r=[],i=C(l);try{for(i.s();!(t=i.n()).done;){var o=t.value;r.push(p(c,o))}}catch(s){i.e(s)}finally{i.f()}f(c,r)}))}function p(n,a){return new Promise((function(c,u){var d="partNumber="+a+"&uploadId="+n;as.imClient.context.getFileToken(s,r,"PUT",d).then((function(n){console.log("signature "+a+" onSuccess",n);var r=e&&e.slice((a-1)*t.stc_chunk_size,a*t.stc_chunk_size);console.log("fileChunk:size",r.size);var s=new XMLHttpRequest;s.open("PUT",i+"?"+d,!0),s.setRequestHeader("Authorization",n&&n.stcAuthorization),s.setRequestHeader("x-amz-content-sha256",n&&n.stcContentSha256),s.setRequestHeader("x-amz-date",n&&n.stcDate),s.setRequestHeader("Content-Type",o),s.send(r),s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status||204===s.status){var e=s.getResponseHeader("etag");console.log("etag:"+a,e),h.set(a,e),c(e)}else l.includes(a)||l.push(a),u(a)}}),(function(e){console.log("getETags:签名验证失败"),l.includes(a)||l.push(a),u(a)}))}))}}(e,t,n);else{var d=t.data(e,t);ks[Ns[0][0]](d,t,n,e)}}(e,this.options,{onProgress:function(e,n,r){Us=e,r?Us=Ds+e/n*(n-Ds):Ds=Us,t.onProgress(Us,n)},onCompleted:function(e){t.onCompleted(e)},onError:function(e){t.onError(e)},onOpen:function(e){n.xhr=e}})}else t.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var Bs,Fs,Hs=function(e){return new Vs(e)},js=function(e,t){!function(e,t,n){var r=document.createElement("canvas"),i=r.getContext("2d"),o=new Image;o.onload=function(){var s=function(e,t,n){var r,i,o,s=en.scale?(s?(i=100,c=((o=t/(r=e/100))-n.maxHeight)/2):(o=100,a=((i=e/(r=t/100))-n.maxWidth)/2),{w:i,h:o,x:-a,y:-c}):(s?(r=t/n.maxHeight,o=n.maxHeight,i=e/r):(r=e/n.maxWidth,i=n.maxWidth,o=t/r),{w:i,h:o,x:-a,y:-c})}(o.width,o.height,t);r.width=s.w>t.maxWidth?t.maxWidth:s.w,r.height=s.h>t.maxHeight?t.maxHeight:s.h,i.drawImage(o,s.x,s.y,s.w,s.h);try{var a=r.toDataURL(e.type,t.quality),c=new RegExp("^data:image/[^;]+;base64,");a=a.replace(c,""),n(a)}catch(e){throw new Error(e)}},o.src="string"==typeof e?"data:image/jpg;base64,"+e:function(e){var t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""}(e)}(e.file,e.compress,t)},Ks=function(e,t){if(e.getToken)e.getToken((function(n,r){r=r||{},e.multi_parmas||(e.multi_parmas={}),e.multi_parmas.token=n,e.uploadHost||(e.uploadHost={}),e.uploadHost.bos=r.bos,e.ossConfig=r.ossConfig,e.bosHeader||(e.bosHeader={}),e.bosHeader.bosDate=r.bosDate,e.bosHeader.bosToken=r.bosToken,e.bosUploadPath=r.path,e.aliHeader={},e.aliHeader.osskeyId=r.osskeyId,e.aliHeader.ossPolicy=r.ossPolicy,e.aliHeader.ossSign=r.ossSign,e.ossBucketName=r.ossBucketName,e.uploadFileName=r.fileName,e.s3Header={},e.s3Header.s3Credential=r.s3Credential,e.s3Header.s3Algorithm=r.s3Algorithm,e.s3Header.s3Date=r.s3Date,e.s3Header.s3Policy=r.s3Policy,e.s3Header.s3Signature=r.s3Signature,e.s3BucketName=r.s3BucketName,e.stcHeader={},e.stcHeader.stcAuthorization=r.stcAuthorization,e.stcHeader.stcContentSha256=r.stcContentSha256,e.stcHeader.stcDate=r.stcDate,e.stcBucketName=r.stcBucketName,e.headers||(e.headers={}),e.base64&&(e.headers["Content-type"]="application/octet-stream",e.headers.Authorization="UpToken "+n),console.log("data",r);var i=Hs(e);t(i)}));else{e.headers||(e.headers={}),e.base64&&(e.headers["Content-type"]="application/octet-stream");var n=Hs(e);t(n)}},qs=function(e,t,n){t.upload(e.file,{onError:function(e){n.onError(e)},onProgress:function(e,t){n.onProgress(e,t)},onCompleted:function(t){t.filename||(t.filename=t.hash);var r=e.compressThumbnail||js;e.compress?r(e,(function(e){t.thumbnail=e,n.onCompleted(t)})):n.onCompleted(t)}})},Gs=function(e){var t=this;this.instance=e,this.upload=function(e,n){qs({file:e},t.instance,n)},this.cancel=function(){t.instance.cancel()}},Ys=function(e,t){var n=this;this.cfg=t,this.instance=e,this.upload=function(e,t){var r={file:e,compress:n.cfg};qs(r,n.instance,t)},this.cancel=function(){n.instance.cancel()}},Js=function(e,t){Ks(e,(function(e){var n=new Gs(e);t(n)}))},zs=function(e,t){Ks(e,(function(n){var r={maxHeight:e.maxHeight||160,maxWidth:e.maxWidth||160,quality:e.quality||.5,scale:e.scale||2.4},i=new Ys(n,r);t(i)}))};function Ws(e){return Bs=Bs||new AudioContext,new Promise((function(t,n){Bs.decodeAudioData(e,(function(e){t({duration:e.duration,length:e.length})}),n)}))}function Qs(e,t,n){return Ao(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,d,l;return xo(this,(function(h){switch(h.label){case 0:return n=n||{},t instanceof _s==0?(Mo.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,cs.ILLGAL_PARAMS]):(Wt("conversation.channelId",null==e?void 0:e.channelId,Bt.CHANNEL_ID),r=e.conversationType,i=e.targetId,o=e.channelId,s="conversationType:"+r+",targetId:"+i,Mo.debug("send message ->"+s),(a=Object.assign(n,t)).channelId=o||"",[4,as.imClient.context.sendMessage(r,i,a)]);case 1:return c=h.sent(),u=c.code,d=c.data,u===it.SUCCESS?(l=os(d),[2,{code:u,data:l}]):(Mo.warn("send message fail ->"+u+":"+us[u]+","+s),[2,{code:u,msg:us[u],data:os({isMentioned:!!n.isMentioned,content:t.content,messageType:t.messageType,isPersited:t.isPersited||!1,isCounted:t.isCounted||!1,disableNotification:!!(null==n?void 0:n.disableNotification),canIncludeExpansion:!!(null==n?void 0:n.canIncludeExpansion),expansion:(null==n?void 0:n.expansion)||null,conversationType:r,targetId:i,channelId:o||"",senderUserId:as.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:nt.SEND,isOffLineMessage:!1,sentTime:(null==d?void 0:d.sentTime)||0,receivedTime:0,isStatusMessage:n.isStatusMessage||!1,receivedStatus:oe.UNREAD})}])}}))}))}function Xs(e,t){return function(n,r,i,o){return new Promise((function(s){var a;!function(e,t,n,r){var i,o=this;if(void 0===t&&(t=Le.FILE),i=t===Le.IMAGE?Le.IMAGE:Le.FILE,!Fs){Fs="upload.qiniup.com";var s=as.imClient.context.getInfoFromCache();if(s&&s.ossConfig)try{var a=JSON.parse(s.ossConfig).find((function(e){return void 0!==e.qiniu}));a&&(Fs=a.qiniu)}catch(e){}}var c=Oo({domain:Fs,getToken:function(e){as.imClient.context.getFileToken(i).then((function(t){e(t.token,t)})).catch((function(e){n.onFail(e)}))}},r);(i===Le.IMAGE?zs:Js)(c,(function(r){r.upload(e,{onProgress:function(e,t){var r,i=Math.floor(e/t*100);null===(r=n.onProgress)||void 0===r||r.call(n,i)},onCompleted:function(r){return Ao(o,void 0,void 0,(function(){var o=this;return xo(this,(function(s){return function(e,t,n,r,i){return Wt("fileType",e,ze,!0),Wt("filename",t,Bt.STRING),Wt("saveName",n,Bt.STRING),Wt("serverType",i,Bt.NUMBER),new Promise((function(o){as.imClient.context.getFileUrl(e,t,n,r,i).then((function(e){o({code:it.SUCCESS,data:e})})).catch((function(e){o({code:e})}))}))}(i,r.filename,r.name,r,r.uploadMethod).then((function(s){return Ao(o,void 0,void 0,(function(){var o,a;return xo(this,(function(c){return 0!==s.code?(n.onFail(s),[2]):((o=s.data).type=e.type,o.name=r.name||r.filename,t===Le.AUDIO?("function"==typeof e.arrayBuffer?e.arrayBuffer().then(Ws).then((function(e){Object.assign(o,e),n.onSuccess(o)}),(function(){n.onSuccess(o)})):((a=new FileReader).onload=function(){a.result?Ws(a.result).then((function(e){Object.assign(o,e),n.onSuccess(o)}),(function(){n.onSuccess(o)})):n.onSuccess(o)},a.onerror=function(){o.duration=0,n.onSuccess(o)},a.readAsArrayBuffer(e)),[2]):(i===Le.IMAGE&&(o.thumbnail=r.thumbnail),n.onSuccess(o),[2]))}))}))})).catch((function(e){n.onFail(e)})),[2]}))}))},onError:function(e){n.onFail(e)}})}))}(r.file,e,{onProgress:null==i?void 0:i.onProgress,onSuccess:function(e){var a,c=(null===(a=null==i?void 0:i.onComplete)||void 0===a?void 0:a.call(i,{url:e.downloadUrl}))||t(e,r);Qs(n,c,o).then(s)},onFail:function(e){s({code:it.UPLOAD_FILE_FAILED,msg:e||it[it.UPLOAD_FILE_FAILED]})}},(null===(a=o)||void 0===a?void 0:a.thumbnailConfig)||{})}))}}function Zs(e,t,n,r){return Wt("messageType",e,Bt.STRING,!0),Wt("isPersited",t,Bt.BOOLEAN,!0),Wt("isCounted",n,Bt.BOOLEAN,!0),as.imClient.context.registerMessageType(e,t,n,r),ys(e,t,n)} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function $s(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}Xs(Le.FILE,(function(e,t){return new ws({name:e.name,size:t.file.size,type:t.file.type,fileUrl:e.downloadUrl,user:t.user,extra:t.extra})})),Xs(Le.IMAGE,(function(e,t){return new Es({content:e.thumbnail,imageUri:e.downloadUrl,user:t.user,extra:t.extra})})),Xs(Le.AUDIO,(function(e,t){return new Ts({remoteUrl:e.downloadUrl,duration:e.duration,type:e.type,user:t.user,extra:t.extra})})),Xs(Le.SIGHT,(function(e,t){return new Ss({sightUrl:e.downloadUrl,content:t.thumbnail,duration:t.duration,size:t.file.size||e.size,name:t.name||e.name,user:t.user,extra:t.extra})})),Xs(Le.COMBINE_HTML,(function(e,t){return new bs({remoteUrl:e.downloadUrl,nameList:t.nameList,summaryList:t.summaryList,conversationType:t.conversationType,user:t.user,extra:t.extra})})),Ht.add("imlib","5.1.1"),Ht.validEngine("~5.1.1")||Mo.error("The current engine version '"+Ht.getInfo().engine+"' error,imlib required engine version at least '~5.1.1'.");var ea,ta,na=new Xe("RCRTC");!function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.PERMISSION_DENIED=53012]="PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"}(ea||(ea={})),function(e){e[e.JOIN_REFUSED=40032]="JOIN_REFUSED"}(ta||(ta={}));var ra=function(){function e(){_(this,e),this.queue=[],this.locked=!1}return R(e,[{key:"checkToStart",value:function(){return $s(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.queue.length&&!this.locked){e.next=2;break}return e.abrupt("return");case 2:return this.locked=!0,t=this.queue.shift(),n=t.resolve,r=t.task,i=t.reject,e.prev=4,e.next=7,r();case 7:o=e.sent,n(o),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(4),i(e.t0);case 14:this.locked=!1,this.checkToStart();case 15:case"end":return e.stop()}}),e,this,[[4,11]])})))}},{key:"push",value:function(e){var t=this,n=new Promise((function(n,r){t.queue.push({resolve:n,task:e,reject:r})}));return this.checkToStart(),n}}]),e}(),ia=new ra,oa=function(e){return ia.push(e)},sa=!0,aa=!0;function ca(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function ua(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};var o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);var r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function da(e){return"boolean"!=typeof e?new Error("Argument type: "+S(e)+". Please use a boolean."):(sa=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function la(e){return"boolean"!=typeof e?new Error("Argument type: "+S(e)+". Please use a boolean."):(aa=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function ha(){if("object"==("undefined"==typeof window?"undefined":S(window))){if(sa)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function fa(e,t){aa&&console.warn(e+" is deprecated, please use "+t+" instead.")}function pa(e){return"[object Object]"===Object.prototype.toString.call(e)}function ga(e){return pa(e)?Object.keys(e).reduce((function(t,n){var r=pa(e[n]),i=r?ga(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,v({},n,i))}),{}):e}function ma(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((function(r){r.endsWith("Id")?ma(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((function(t){ma(e,e.get(t),n)}))})))}function va(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(n){n.type===r&&n.trackId===t.id&&ma(e,n,i)}))})),i}var _a=ha;function ya(e,t){var n=e&&e.navigator;if(n.mediaDevices){var r=function(e){if("object"!=S(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==S(e[n])?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var o={};"number"==typeof r.ideal?(o[i("min",n)]=r.ideal,t.optional.push(o),(o={})[i("max",n)]=r.ideal,t.optional.push(o)):(o[i("",n)]=r.ideal,t.optional.push(o))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==S(e.audio)){var o=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==S(e.video)){var s=e.video.facingMode;s=s&&("object"==S(s)?s:{ideal:s});var a,c=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?a=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(a=["front"]),a)return n.mediaDevices.enumerateDevices().then((function(t){var n=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return a.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!n&&t.length&&a.includes("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=s.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=r(e.video),_a("chrome: "+JSON.stringify(e)),i(e)}));e.video=r(e.video)}return _a("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(function(e){n.webkitGetUserMedia(e,t,(function(e){r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){var s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return s(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function Ra(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ca(e){if("object"==S(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.track.id})):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)})),t.stream.getTracks().forEach((function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.id})):{track:r};var o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else ua(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Ea(e){if("object"==S(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){n._senders.push(t(n,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var n=t._senders.find((function(t){return t.track===e}));n&&t._senders.splice(t._senders.indexOf(n),1)}))}}else if("object"==S(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Ta(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,n=Array.prototype.slice.call(arguments),r=n[0],i=n[1],o=n[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var s=function(e){var t={};return e.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t},a=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(a(s(e)))};return t.apply(this,[c,r])}return new Promise((function(n,r){t.apply(e,[function(e){n(a(s(e)))},r])})).then(i,o)}}}function Sa(e){if("object"==S(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return va(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=r.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),ua(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return va(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,n,r,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?r=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(n?r=!0:n=e),e.track===o})),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ia(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var r=this.getSenders();n.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===r.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]})),i.apply(this,arguments)}}function ba(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ia(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(n.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var s=this._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then((function(){r.dispatchEvent(new Event("negotiationneeded"))}));else{var a=new e.MediaStream([t]);this._streams[n.id]=a,this._reverseStreams[a.id]=n,this.addStream(a)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=v({},t,(function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[function(n){var r=a(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(this,arguments).then((function(t){return a(e,t)}))}));e.RTCPeerConnection.prototype[t]=r[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=s.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(r){n._streams[r].getTracks().find((function(t){return e.track===t}))&&(t=n._streams[r])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function a(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}function c(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}}function wa(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=v({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}))}function ka(e,t){ua(e,"negotiationneeded",(function(e){var n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var Na,Oa,Aa=Object.freeze({__proto__:null,shimMediaStream:Ra,shimOnTrack:Ca,shimGetSendersWithDtmf:Ea,shimGetStats:Ta,shimSenderReceiverGetStats:Sa,shimAddTrackRemoveTrackWithNative:Ia,shimAddTrackRemoveTrack:ba,shimPeerConnection:wa,fixNegotiationNeeded:ka,shimGetUserMedia:ya,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((function(t){var r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),xa=(Na=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==S(e.keyParams)?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=a.length>0&&a[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var s=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var o=t.writeRtpDescription(e.kind,n);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var o=n.iceCandidatePoolSize;o>0;o--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=xa.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},i.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},i.prototype.addTrack=function(t,n){if(this._isClosed)throw Da("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find((function(e){return e.track===t})))throw Da("InvalidAccessError","Track already exists.");for(var i=0;i=15025)e.getTracks().forEach((function(t){n.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",(function(e){n.enabled=e.enabled}))})),r.getTracks().forEach((function(e){n.addTrack(e,r)}))}},i.prototype.removeTrack=function(t){if(this._isClosed)throw Da("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find((function(e){return e.rtpSender===t}));if(!n)throw Da("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var n=t.getSenders().find((function(t){return t.track===e}));n&&t.removeTrack(n)}))},i.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},i.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},i.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},i.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var o=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:n};var s=e.candidate,a=!s||0===Object.keys(s).length;if(a)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),s.component=1,s.ufrag=i.getLocalParameters().usernameFragment;var c=xa.writeCandidate(s);o.candidate=Object.assign(o.candidate,xa.parseCandidate(c)),o.candidate.candidate=c,o.candidate.toJSON=function(){return{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex,usernameFragment:o.candidate.usernameFragment}}}var u=xa.getMediaSections(r._localDescription.sdp);u[o.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",r._localDescription.sdp=xa.getDescription(r._localDescription.sdp)+u.join("");var d=r.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),a||r._dispatchEvent("icecandidate",o),d&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout((function(){o.forEach((function(e){i.onlocalcandidate(e)}))}),0)}},i.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},i.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},i.prototype._transceive=function(e,n,r){var i=Ma(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:xa.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?i.encodings=e.recvEncodingParameters:i.encodings=[{}],i.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(i.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},i.prototype.setLocalDescription=function(e){var t,n,r=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(Da("TypeError",'Unsupported type "'+e.type+'"'));if(!La("setLocalDescription",e.type,r.signalingState)||r._isClosed)return Promise.reject(Da("InvalidStateError","Can not set local "+e.type+" in state "+r.signalingState));if("offer"===e.type)t=xa.splitSections(e.sdp),n=t.shift(),t.forEach((function(e,t){var n=xa.parseRtpParameters(e);r.transceivers[t].localCapabilities=n})),r.transceivers.forEach((function(e,t){r._gather(e.mid,t)}));else if("answer"===e.type){t=xa.splitSections(r._remoteDescription.sdp),n=t.shift();var i=xa.matchPrefix(n,"a=ice-lite").length>0;t.forEach((function(e,t){var o=r.transceivers[t],s=o.iceGatherer,a=o.iceTransport,c=o.dtlsTransport,u=o.localCapabilities,d=o.remoteCapabilities;if(!(xa.isRejected(e)&&0===xa.matchPrefix(e,"a=bundle-only").length||o.rejected)){var l=xa.getIceParameters(e,n),h=xa.getDtlsParameters(e,n);i&&(h.role="server"),r.usingBundle&&0!==t||(r._gather(o.mid,t),"new"===a.state&&a.start(s,l,i?"controlling":"controlled"),"new"===c.state&&c.start(h));var f=Ma(u,d);r._transceive(o,f.codecs.length>0,!1)}}))}return r._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?r._updateSignalingState("have-local-offer"):r._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(i){var o=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(Da("TypeError",'Unsupported type "'+i.type+'"'));if(!La("setRemoteDescription",i.type,o.signalingState)||o._isClosed)return Promise.reject(Da("InvalidStateError","Can not set remote "+i.type+" in state "+o.signalingState));var s={};o.remoteStreams.forEach((function(e){s[e.id]=e}));var a=[],c=xa.splitSections(i.sdp),u=c.shift(),d=xa.matchPrefix(u,"a=ice-lite").length>0,l=xa.matchPrefix(u,"a=group:BUNDLE ").length>0;o.usingBundle=l;var h=xa.matchPrefix(u,"a=ice-options:")[0];return o.canTrickleIceCandidates=!!h&&h.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(r,c){var h=xa.splitLines(r),f=xa.getKind(r),p=xa.isRejected(r)&&0===xa.matchPrefix(r,"a=bundle-only").length,g=h[0].substr(2).split(" ")[2],m=xa.getDirection(r,u),v=xa.parseMsid(r),_=xa.getMid(r)||xa.generateIdentifier();if(p||"application"===f&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))o.transceivers[c]={mid:_,kind:f,protocol:g,rejected:!0};else{var y,R,C,E,T,S,I,b,w;!p&&o.transceivers[c]&&o.transceivers[c].rejected&&(o.transceivers[c]=o._createTransceiver(f,!0));var k,N,O=xa.parseRtpParameters(r);p||(k=xa.getIceParameters(r,u),(N=xa.getDtlsParameters(r,u)).role="client"),I=xa.parseRtpEncodingParameters(r);var A=xa.parseRtcpParameters(r),x=xa.matchPrefix(r,"a=end-of-candidates",u).length>0,P=xa.matchPrefix(r,"a=candidate:").map((function(e){return xa.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!p&&l&&c>0&&o.transceivers[c]&&(o._disposeIceAndDtlsTransports(c),o.transceivers[c].iceGatherer=o.transceivers[0].iceGatherer,o.transceivers[c].iceTransport=o.transceivers[0].iceTransport,o.transceivers[c].dtlsTransport=o.transceivers[0].dtlsTransport,o.transceivers[c].rtpSender&&o.transceivers[c].rtpSender.setTransport(o.transceivers[0].dtlsTransport),o.transceivers[c].rtpReceiver&&o.transceivers[c].rtpReceiver.setTransport(o.transceivers[0].dtlsTransport)),"offer"!==i.type||p)"answer"!==i.type||p||(R=(y=o.transceivers[c]).iceGatherer,C=y.iceTransport,E=y.dtlsTransport,T=y.rtpReceiver,S=y.sendEncodingParameters,b=y.localCapabilities,o.transceivers[c].recvEncodingParameters=I,o.transceivers[c].remoteCapabilities=O,o.transceivers[c].rtcpParameters=A,P.length&&"new"===C.state&&(!d&&!x||l&&0!==c?P.forEach((function(e){Ua(y.iceTransport,e)})):C.setRemoteCandidates(P)),l&&0!==c||("new"===C.state&&C.start(R,k,"controlling"),"new"===E.state&&E.start(N)),!Ma(y.localCapabilities,y.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&y.sendEncodingParameters[0].rtx&&delete y.sendEncodingParameters[0].rtx,o._transceive(y,"sendrecv"===m||"recvonly"===m,"sendrecv"===m||"sendonly"===m),!T||"sendrecv"!==m&&"sendonly"!==m?delete y.rtpReceiver:(w=T.track,v?(s[v.stream]||(s[v.stream]=new e.MediaStream),n(w,s[v.stream]),a.push([w,T,s[v.stream]])):(s.default||(s.default=new e.MediaStream),n(w,s.default),a.push([w,T,s.default]))));else{(y=o.transceivers[c]||o._createTransceiver(f)).mid=_,y.iceGatherer||(y.iceGatherer=o._createIceGatherer(c,l)),P.length&&"new"===y.iceTransport.state&&(!x||l&&0!==c?P.forEach((function(e){Ua(y.iceTransport,e)})):y.iceTransport.setRemoteCandidates(P)),b=e.RTCRtpReceiver.getCapabilities(f),t<15019&&(b.codecs=b.codecs.filter((function(e){return"rtx"!==e.name}))),S=y.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var M,L=!1;"sendrecv"===m||"sendonly"===m?(L=!y.rtpReceiver,T=y.rtpReceiver||new e.RTCRtpReceiver(y.dtlsTransport,f),L&&(w=T.track,v&&"-"===v.stream||(v?(s[v.stream]||(s[v.stream]=new e.MediaStream,Object.defineProperty(s[v.stream],"id",{get:function(){return v.stream}})),Object.defineProperty(w,"id",{get:function(){return v.track}}),M=s[v.stream]):(s.default||(s.default=new e.MediaStream),M=s.default)),M&&(n(w,M),y.associatedRemoteMediaStreams.push(M)),a.push([w,T,M]))):y.rtpReceiver&&y.rtpReceiver.track&&(y.associatedRemoteMediaStreams.forEach((function(t){var n=t.getTracks().find((function(e){return e.id===y.rtpReceiver.track.id}));n&&function(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(n,t)})),y.associatedRemoteMediaStreams=[]),y.localCapabilities=b,y.remoteCapabilities=O,y.rtpReceiver=T,y.rtcpParameters=A,y.sendEncodingParameters=S,y.recvEncodingParameters=I,o._transceive(o.transceivers[c],!1,L)}}})),void 0===o._dtlsRole&&(o._dtlsRole="offer"===i.type?"active":"passive"),o._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?o._updateSignalingState("have-remote-offer"):o._updateSignalingState("stable"),Object.keys(s).forEach((function(t){var n=s[t];if(n.getTracks().length){if(-1===o.remoteStreams.indexOf(n)){o.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,e.setTimeout((function(){o._dispatchEvent("addstream",i)}))}a.forEach((function(e){var t=e[0],i=e[1];n.id===e[2].id&&r(o,t,i,[n])}))}})),a.forEach((function(e){e[2]||r(o,e[0],e[1],[])})),e.setTimeout((function(){o&&o.transceivers&&o.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},i.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},i.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},i.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},i.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(Da("InvalidStateError","Can not call createOffer after close"));var r=n.transceivers.filter((function(e){return"audio"===e.kind})).length,i=n.transceivers.filter((function(e){return"video"===e.kind})).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(r=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(i=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(n.transceivers.forEach((function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--i<0&&(e.wantReceive=!1)}));r>0||i>0;)r>0&&(n._createTransceiver("audio"),r--),i>0&&(n._createTransceiver("video"),i--);var s=xa.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach((function(r,i){var o=r.track,s=r.kind,a=r.mid||xa.generateIdentifier();r.mid=a,r.iceGatherer||(r.iceGatherer=n._createIceGatherer(i,n.usingBundle));var c=e.RTCRtpSender.getCapabilities(s);t<15019&&(c.codecs=c.codecs.filter((function(e){return"rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),c.headerExtensions.forEach((function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var u=r.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];o&&t>=15019&&"video"===s&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,s)),r.localCapabilities=c,r.sendEncodingParameters=u})),"max-compat"!==n._config.bundlePolicy&&(s+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n",n.transceivers.forEach((function(e,t){s+=Pa(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),s+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,s+="a="+xa.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(s+="a=end-of-candidates\r\n"))}));var a=new e.RTCSessionDescription({type:"offer",sdp:s});return Promise.resolve(a)},i.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(Da("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(Da("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var r=xa.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(r+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var i=xa.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach((function(e,o){if(!(o+1>i)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var s;e.stream&&("audio"===e.kind?s=e.stream.getAudioTracks()[0]:"video"===e.kind&&(s=e.stream.getVideoTracks()[0]),s&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}));var a=Ma(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=Pa(e,a,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}}));var o=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(o)},i.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(r,i){if(!n._remoteDescription)return i(Da("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var o=e.sdpMLineIndex;if(e.sdpMid)for(var s=0;s0?xa.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return r();if(c.component&&1!==c.component)return r();if((0===o||o>0&&a.iceTransport!==n.transceivers[0].iceTransport)&&!Ua(a.iceTransport,c))return i(Da("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=xa.getMediaSections(n._remoteDescription.sdp))[o]+="a="+(c.type?u:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=xa.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var d=0;d55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var i=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==S(e)&&"object"==S(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},r&&r.prototype.getSettings){var s=r.prototype.getSettings;r.prototype.getSettings=function(){var e=s.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(r&&r.prototype.applyConstraints){var a=r.prototype.applyConstraints;r.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==S(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[e])}}}}function qa(e){"object"==S(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function Ga(e,t){if("object"==S(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=v({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}));var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),i=e[0],o=e[1],s=e[2];return r.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach((function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(o,s)}}}function Ya(e){if("object"==S(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function Ja(e){if("object"==S(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n}),ua(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function za(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;fa("removeStream","removeTrack"),this.getSenders().forEach((function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)}))})}function Wa(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Qa(e){if("object"==S(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach((function(e){if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var r=t.apply(this,arguments);if(n){var i=r.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return r})}}function Xa(e){if("object"==S(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function Za(e){if("object"==S(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}function $a(e){if("object"==S(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}var ec=Object.freeze({__proto__:null,shimOnTrack:qa,shimPeerConnection:Ga,shimSenderGetStats:Ya,shimReceiverGetStats:Ja,shimRemoveStream:za,shimRTCDataChannel:Wa,shimAddTransceiver:Qa,shimGetParameters:Xa,shimCreateOffer:Za,shimCreateAnswer:$a,shimGetUserMedia:Ka,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function tc(e){if("object"==S(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=this,r=arguments.length,i=new Array(r>1?r-1:0),o=1;o=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function rc(e){if("object"==S(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var a=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=a}}function ic(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=function(e){return r(oc(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function oc(e){return e&&void 0!==e.video?Object.assign({},e,{video:ga(e.video)}):e}function sc(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var r=[],i=0;i0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),a=e.sdpSemantics;"plan-b"===a&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){var c,u=r(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};Object.defineProperty(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return s.apply(this,arguments)}}}function fc(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return n(e,this),e},ua(e,"datachannel",(function(e){return n(e.channel,e.target),e}))}function n(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}}function pc(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}}function gc(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=t.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return n.apply(this,arguments)}}}function mc(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}var vc,_c,yc,Rc=Object.freeze({__proto__:null,shimRTCIceCandidate:lc,shimMaxMessageSize:hc,shimSendThrowTypeError:fc,shimConnectionState:pc,removeExtmapAllowMixed:gc,shimAddIceCandidateNullOrEmpty:mc}),Cc=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},r=ha,i=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var n=e.navigator;if(n.mozGetUserMedia)t.browser="firefox",t.version=ca(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=ca(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=ca(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=ca(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(t),o={browserDetails:i,commonShim:Rc,extractVersion:ca,disableLog:da,disableWarnings:la};switch(i.browser){case"chrome":if(!Aa||!wa||!n.shimChrome)return r("Chrome shim is not included in this adapter release."),o;if(null===i.version)return r("Chrome shim can not determine version, not shimming."),o;r("adapter.js shimming chrome."),o.browserShim=Aa,mc(t,i),ya(t,i),Ra(t),wa(t,i),Ca(t),ba(t,i),Ea(t),Ta(t),Sa(t),ka(t,i),lc(t),pc(t),hc(t,i),fc(t),gc(t,i);break;case"firefox":if(!ec||!Ga||!n.shimFirefox)return r("Firefox shim is not included in this adapter release."),o;r("adapter.js shimming firefox."),o.browserShim=ec,mc(t,i),Ka(t,i),Ga(t,i),qa(t),za(t),Ya(t),Ja(t),Wa(t),Qa(t),Xa(t),Za(t),$a(t),lc(t),pc(t),hc(t,i),fc(t);break;case"edge":if(!ja||!Fa||!n.shimEdge)return r("MS edge shim is not included in this adapter release."),o;r("adapter.js shimming edge."),o.browserShim=ja,Va(t),Ba(t),Fa(t,i),Ha(t),hc(t,i),fc(t);break;case"safari":if(!dc||!n.shimSafari)return r("Safari shim is not included in this adapter release."),o;r("adapter.js shimming safari."),o.browserShim=dc,mc(t,i),sc(t),cc(t),rc(t),tc(t),nc(t),ac(t),ic(t),uc(t),lc(t),hc(t,i),fc(t),gc(t,i);break;default:r("Unsupported browser!")}return o}({window:"undefined"==typeof window?void 0:window});!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(vc||(vc={})),function(e){e.W176_H132="W176_H132",e.W176_H144="W176_H144",e.W256_H144="W256_H144",e.W320_H180="W320_H180",e.W240_H240="W240_H240",e.W320_H240="W320_H240",e.W480_H360="W480_H360",e.W640_H360="W640_H360",e.W480_H480="W480_H480",e.W640_H480="W640_H480",e.W720_H480="W720_H480",e.W1280_H720="W1280_H720",e.W1920_H1080="W1920_H1080"}(_c||(_c={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(yc||(yc={}));var Ec=(v(z={},_c.W176_H132,{width:176,height:132,maxBitrate:150,minBitrate:80}),v(z,_c.W176_H144,{width:176,height:144,maxBitrate:160,minBitrate:80}),v(z,_c.W256_H144,{width:256,height:144,maxBitrate:240,minBitrate:120}),v(z,_c.W320_H180,{width:320,height:180,maxBitrate:280,minBitrate:120}),v(z,_c.W240_H240,{width:240,height:240,maxBitrate:280,minBitrate:120}),v(z,_c.W320_H240,{width:320,height:240,maxBitrate:400,minBitrate:120}),v(z,_c.W480_H360,{width:480,height:360,maxBitrate:650,minBitrate:150}),v(z,_c.W640_H360,{width:640,height:360,maxBitrate:800,minBitrate:180}),v(z,_c.W480_H480,{width:480,height:480,maxBitrate:800,minBitrate:180}),v(z,_c.W640_H480,{width:640,height:480,maxBitrate:900,minBitrate:200}),v(z,_c.W720_H480,{width:720,height:480,maxBitrate:1e3,minBitrate:200}),v(z,_c.W1280_H720,{width:1280,height:720,maxBitrate:2200,minBitrate:250}),v(z,_c.W1920_H1080,{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}),z),Tc=function(e,t){var n=e*t,r=Number.MAX_VALUE,i=null;for(var o in Ec){var s=Ec[o],a=Math.abs(s.width*s.height-n);a id: ".concat(this._id)),{code:ea.TRACK_NOT_READY}));case 2:if("ended"===this._msTrack.readyState&&na.warn("the track's readyState is 'ended' -> id: ".concat(this._id)),!(null==t?void 0:t.volume)){n.next=6;break}if(Ve(null==t?void 0:t.volume)){n.next=5;break}return n.abrupt("return",(na.error("".concat(null==t?void 0:t.volume," is not a number, the valid range of options.volume is 0-100")),{code:ea.PARAMS_ERROR}));case 5:(null==t?void 0:t.volume)<0&&(t.volume=0,na.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(null==t?void 0:t.volume)>100&&(t.volume=100,na.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"));case 6:if(!(null==t?void 0:t.audioDeviceId)){n.next=13;break}return n.next=9,kc();case 9:if(n.t0=function(e){return e.deviceId},n.t1=t.audioDeviceId,n.sent.map(n.t0).includes(n.t1)){n.next=13;break}return n.abrupt("return",(na.error("the options.audioDeviceId is invalid --\x3e ".concat(t.audioDeviceId)),{code:ea.PARAMS_ERROR}));case 13:if(!(r=this.isVideoTrack())||e&&e instanceof HTMLVideoElement){n.next=16;break}return n.abrupt("return",(na.error("the video track need an