function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = ["assets/TUIKit-components-TUIConversation-index.BszPXyYX.js","assets/TUIKit-components-TUISearch-index.Cp_ZmtC_.js","assets/Icon.D1Z3K5c-.js","assets/_plugin-vue_export-helper.BCo6x5W8.js","assets/star-light.wZqPaCFn.js","assets/right-icon.-uAfiCH7.js","assets/index.DDTlzfEU.js","assets/add-circle.Cuok7LbY.js","assets/index.D_s0sZWW.js","assets/pages-index-index.CPHuv6KV.js","assets/index-MkNlm2Ac.css","assets/pages-login-login.BEiUK2v9.js","assets/agreement-checkbox.DUrK4kZ2.js","assets/check-to-confirm.waajYe9C.js","assets/agreement-checkbox-ayjyhx8Z.css","assets/cb-button.BGoweT37.js","assets/login-rjRX0ilO.css","assets/TUIKit-components-TUIChat-index.Cj26Cu3T.js","assets/index.EPwmt-Vu.js","assets/utils.C_15QP-2.js","assets/tui-kit.DbB44lt3.js","assets/uu-pwdModal.CN6ycXtM.js","assets/uni-icons.CInJK_LV.js","assets/uni-popup.1gidbmHq.js","assets/TUIKit-components-TUIContact-index.CgQjlOy-.js","assets/cb-empty.PJJFX43l.js","assets/index.D2yezGMR.js","assets/TUIKit-components-TUIChat-video-play.DUkcS_xe.js","assets/video-play-D2pkoIg3.css","assets/TUIKit-components-TUIGroup-index.BRKduKr7.js","assets/bottom-view.7Jv-fjme.js","assets/media.C7HffoTH.js","assets/uploadFile.DQ-stcMT.js","assets/validate.TrIJ_KHd.js","assets/pages-login-protocol.Bs-wFh3A.js","assets/app-article-detail.BxRtBYto.js","assets/mp-html.CIiZeyC1.js","assets/mp-html-CsPoo5Bx.css","assets/app-article-detail--FkLLCPW.css","assets/pages-login-regime.CZSj_SSM.js","assets/pages-login-phone-register-phone-register.BJYIh-2W.js","assets/register-app.CBJHOzzO.js","assets/register-app-CDptpIpR.css","assets/pages-login-email-register-email-register.DTGXQvI-.js","assets/pages-login-forgot-password-forgot-password.iEKGXf-P.js","assets/nav-bar.BBPaJA1x.js","assets/nav-bar-DSgdWNiE.css","assets/forgot-password-CyjFOfEA.css","assets/pages-news-list-news-list.D49CpDuO.js","assets/news-list-DCAq7RKF.css","assets/pages-contacts-contacts.QOLJfbpO.js","assets/pages-discover-discover.c6wbTgZH.js","assets/right-arrow.DFaGKQbT.js","assets/discover-CJFH2sCg.css","assets/pages-my-index-my-index.DOYn2rp7.js","assets/index.C8j8y52R.js","assets/my-index-DstQYZmu.css","assets/pages-my-index-withdraw.CapE4pOy.js","assets/withdraw-uiPrwk_J.css","assets/pages-my-index-personal-center-index.B02LHm_D.js","assets/popup-box.ZzXGw4LW.js","assets/uni-data-checkbox.pGMB-8Xv.js","assets/uni-cloud.es.D8sVMAJa.js","assets/uni-load-more.RyMgzTbz.js","assets/uni-load-more-DIGyw_ft.css","assets/uni-data-checkbox-CXS7A27e.css","assets/popup-box-CMBldQTj.css","assets/index-WN9txbcC.css","assets/pages-my-index-qr-code-index.DRou2cTk.js","assets/l-qrcode.rUC9Cfbx.js","assets/l-qrcode-CavPSo9L.css","assets/index-Cvciy40O.css","assets/pages-my-index-wallet-index.BNWBEX42.js","assets/index-jUw1MUmw.css","assets/pages-my-index-wallet-edit-password.-UUZYFNq.js","assets/card-input.DmavkC9c.js","assets/card-input-DbvowD0v.css","assets/edit-password-BftDhtEr.css","assets/pages-my-index-wallet-bank-card-index.PFhmLgX-.js","assets/uni-swipe-action.Dxn7q199.js","assets/uni-swipe-action-BJ6J0mNv.css","assets/index-DrhlTO41.css","assets/pages-my-index-wallet-record.D_lL5Nwj.js","assets/z-paging.DKRQNsMm.js","assets/z-paging-Br_BU8oi.css","assets/record-CzlcmozQ.css","assets/pages-my-index-wallet-withdrawal-record.DuDcBPvX.js","assets/pages-my-index-wallet-real-id.BFaxXf6n.js","assets/cb-file-picker.BFBYivfP.js","assets/cb-file-picker-D-b3c8c9.css","assets/date-icon.a8wwGpJt.js","assets/real-id-mof8mWje.css","assets/pages-my-index-wallet-invite.43_63nes.js","assets/invite-By1sq6q0.css","assets/pages-my-index-my-team.B_8YBLDl.js","assets/my-team-D4rtLr5z.css","assets/pages-my-index-collection-index.BarD2mgC.js","assets/cb-search.DlkuLv6C.js","assets/cb-search-36jjbJp5.css","assets/index-BCO-NnOD.css","assets/pages-my-index-meeting-record-index.D2RST8Fq.js","assets/index-CN7a8IHK.css","assets/pages-my-index-meeting-record-details.BQke5n7a.js","assets/details-tOLwBNGU.css","assets/pages-my-index-customer-service-index.Bk6n0xIk.js","assets/index-B3S8RlHQ.css","assets/pages-my-index-customer-service-third-party._NAOEpxm.js","assets/third-party-DSiLp9Fp.css","assets/pages-my-index-set-up-index.UbHnzgRh.js","assets/index-IAXrwAe8.css","assets/pages-my-index-set-up-feedback.xX9KgCfY.js","assets/feedback-CJLGHESL.css","assets/pages-my-index-set-up-message-index.BBKyTkW6.js","assets/index-KYYm2jrg.css","assets/pages-my-index-set-up-message-details.BTWbrRMX.js","assets/details-CZfVZpck.css","assets/pages-my-index-set-up-font-settings.DobbslTk.js","assets/font-settings-CLbtua4Q.css","assets/pages-my-index-wallet-bank-card-card-details.Bm01r185.js","assets/card-details-DoWjtwb-.css","assets/pages-mall-list.Zn1WXIRv.js","assets/mall.CmObYVhp.js","assets/list-C7IsTBti.css","assets/pages-mall-detail.CblNjsth.js","assets/return-icon.C_Tm7uSC.js","assets/dateUtils.CjCYplP3.js","assets/detail-Df-0KSAt.css","assets/pages-mall-comment.BQjKcHti.js","assets/uni-rate.DS976532.js","assets/uni-rate-DR8DaIUk.css","assets/comment-Cdq2zDwr.css","assets/pages-mall-add-comment.vAYbyeKS.js","assets/add-comment-C1Zf0UId.css","assets/pages-mall-confirm-order.UGvFmQVy.js","assets/confirm-order-PeYWzWUZ.css","assets/pages-address-index._M3e2_64.js","assets/index-D9zOQXQI.css","assets/pages-address-add.dms2Ecga.js","assets/add-B-sg7hK3.css","assets/pages-address-edit.DLXKbCuF.js","assets/pages-shop-together-index.Dx0FPcJD.js","assets/mall-data.DIwWIX27.js","assets/index-BIUgXOsb.css","assets/pages-shop-together-detail.Ct4MfSi8.js","assets/detail-Da8wrVdE.css","assets/pages-shop-together-share.Axv3RveS.js","assets/share-uZ8K3qNq.css","assets/pages-discover-ranking-list.C2kuznWx.js","assets/ranking-list-Ck63hDC1.css","assets/pages-discover-punch.Ch-zxBXH.js","assets/punch-Cj2OOo5-.css","assets/pages-discover-dynamic-dynamic.BodfEZND.js","assets/dynamic-CoV8as1w.css","assets/pages-discover-dynamic-release.Bw945Ce1.js","assets/release-D-DrFPKD.css","assets/pages-discover-company.AOV1WuNg.js","assets/company-CIIVAOzj.css","assets/TUIKit-components-TUIChat-message-input-toolbar-live-stream-apply.7tHisfN7.js","assets/apply-D3BG1hcH.css","assets/pages-adduser-index.DHRZRLuI.js","assets/index-BnCOuQCR.css","assets/pages-adduser-details.ChC6QT93.js","assets/details-8H9pbBOp.css","assets/pages-red-packet-details.DrAaMcdz.js","assets/details-KtW1v6kL.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } var A,e,t,i;!function(){const A=document.createElement("link").relList;if(!(A&&A.supports&&A.supports("modulepreload"))){for(const A of document.querySelectorAll('link[rel="modulepreload"]'))e(A);new MutationObserver(A=>{for(const t of A)if("childList"===t.type)for(const A of t.addedNodes)"LINK"===A.tagName&&"modulepreload"===A.rel&&e(A)}).observe(document,{childList:!0,subtree:!0})}function e(A){if(A.ep)return;A.ep=!0;const e=function(A){const e={};return A.integrity&&(e.integrity=A.integrity),A.referrerPolicy&&(e.referrerPolicy=A.referrerPolicy),"use-credentials"===A.crossOrigin?e.credentials="include":"anonymous"===A.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(A);fetch(A.href,e)}}();const o={},n=function(A,e,t){let i=Promise.resolve();if(e&&e.length>0){const A=document.getElementsByTagName("link"),n=document.querySelector("meta[property=csp-nonce]"),r=(null==n?void 0:n.nonce)||(null==n?void 0:n.getAttribute("nonce"));i=Promise.all(e.map(e=>{if((e=function(A){return"/"+A}(e))in o)return;o[e]=!0;const i=e.endsWith(".css"),n=i?'[rel="stylesheet"]':"";if(!!t)for(let t=A.length-1;t>=0;t--){const o=A[t];if(o.href===e&&(!i||"stylesheet"===o.rel))return}else if(document.querySelector(`link[href="${e}"]${n}`))return;const s=document.createElement("link");return s.rel=i?"stylesheet":"modulepreload",i||(s.as="script",s.crossOrigin=""),s.href=e,r&&s.setAttribute("nonce",r),document.head.appendChild(s),i?new Promise((A,t)=>{s.addEventListener("load",A),s.addEventListener("error",()=>t(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}return i.then(()=>A()).catch(A=>{const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=A,window.dispatchEvent(e),!e.defaultPrevented)throw A})}; /** * @vue/shared v3.4.21 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ function r(A,e){const t=new Set(A.split(","));return e?A=>t.has(A.toLowerCase()):A=>t.has(A)}const s={},a=[],g=()=>{},c=()=>!1,l=A=>111===A.charCodeAt(0)&&110===A.charCodeAt(1)&&(A.charCodeAt(2)>122||A.charCodeAt(2)<97),I=A=>A.startsWith("onUpdate:"),u=Object.assign,E=(A,e)=>{const t=A.indexOf(e);t>-1&&A.splice(t,1)},d=Object.prototype.hasOwnProperty,h=(A,e)=>d.call(A,e),C=Array.isArray,B=A=>"[object Map]"===w(A),Q=A=>"[object Set]"===w(A),p=A=>"function"==typeof A,f=A=>"string"==typeof A,m=A=>"symbol"==typeof A,y=A=>null!==A&&"object"==typeof A,D=A=>(y(A)||p(A))&&p(A.then)&&p(A.catch),v=Object.prototype.toString,w=A=>v.call(A),S=A=>"[object Object]"===w(A),M=A=>f(A)&&"NaN"!==A&&"-"!==A[0]&&""+parseInt(A,10)===A,R=r(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),_=A=>{const e=Object.create(null);return t=>e[t]||(e[t]=A(t))},T=/-(\w)/g,N=_(A=>A.replace(T,(A,e)=>e?e.toUpperCase():"")),b=/\B([A-Z])/g,G=_(A=>A.replace(b,"-$1").toLowerCase()),k=_(A=>A.charAt(0).toUpperCase()+A.slice(1)),L=_(A=>A?`on${k(A)}`:""),U=(A,e)=>!Object.is(A,e),F=(A,e)=>{for(let t=0;t{Object.defineProperty(A,e,{configurable:!0,enumerable:!1,value:t})},x=A=>{const e=parseFloat(A);return isNaN(e)?A:e};let P;const Y=()=>P||(P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{});function J(A){if(C(A)){const e={};for(let t=0;t{if(A){const t=A.split(q);t.length>1&&(e[t[0].trim()]=t[1].trim())}}),e}function K(A){let e="";if(f(A))e=A;else if(C(A))for(let t=0;tf(A)?A:null==A?"":C(A)||y(A)&&(A.toString===v||!p(A.toString))?JSON.stringify(A,X,2):String(A),X=(A,e)=>e&&e.__v_isRef?X(A,e.value):B(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((A,[e,t],i)=>(A[$(e,i)+" =>"]=t,A),{})}:Q(e)?{[`Set(${e.size})`]:[...e.values()].map(A=>$(A))}:m(e)?$(e):!y(e)||C(e)||S(e)?e:String(e),$=(A,e="")=>{var t;return m(A)?`Symbol(${null!=(t=A.description)?t:e})`:A},AA=["ad","ad-content-page","ad-draw","audio","button","camera","canvas","checkbox","checkbox-group","cover-image","cover-view","editor","form","functional-page-navigator","icon","image","input","label","live-player","live-pusher","map","movable-area","movable-view","navigator","official-account","open-data","picker","picker-view","picker-view-column","progress","radio","radio-group","rich-text","scroll-view","slider","swiper","swiper-item","switch","text","textarea","video","view","web-view","location-picker","location-view"].map(A=>"uni-"+A),eA=["list-view","list-item","sticky-section","sticky-header","cloud-db-element"].map(A=>"uni-"+A),tA=["list-item"].map(A=>"uni-"+A);function iA(A){if(-1!==tA.indexOf(A))return!1;const e="uni-"+A.replace("v-uni-","");return-1!==AA.indexOf(e)||-1!==eA.indexOf(e)}const oA="\n",nA="UNI_LOCALE",rA=["%","%"],sA="#007aff",aA=/^([a-z-]+:)?\/\//i,gA=/^data:.*,.*/,cA="onShow",lA="onHide",IA="onLaunch",uA="onError",EA="onThemeChange",dA="onPageNotFound",hA="onUnhandledRejection",CA="onLoad",BA="onReady",QA="onUnload",pA="onInit",fA="onSaveExitState",mA="onResize",yA="onBackPress",DA="onPageScroll",vA="onTabItemTap",wA="onReachBottom",SA="onPullDownRefresh",MA="onShareTimeline",RA="onShareChat",_A="onAddToFavorites",TA="onShareAppMessage",NA="onNavigationBarButtonTap",bA="onNavigationBarSearchInputClicked",GA="onNavigationBarSearchInputChanged",kA="onNavigationBarSearchInputConfirmed",LA="onNavigationBarSearchInputFocusChanged",UA="onAppEnterForeground",FA="onAppEnterBackground",OA="onWebInvokeAppService";function xA(A){return 0===A.indexOf("/")}function PA(A){return xA(A)?A:"/"+A}function YA(A){return xA(A)?A.slice(1):A}function JA(A,e){for(const t in e)A.style[t]=e[t]}function HA(A,e=null){let t;return(...i)=>(A&&(t=A.apply(e,i),A=null),t)}function qA(A,e){A=A||{},f(e)&&(e={errMsg:e}),/:ok$/.test(e.errMsg)?p(A.success)&&A.success(e):p(A.fail)&&A.fail(e),p(A.complete)&&A.complete(e)}let VA;function jA(){return VA||(VA=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;function A(){return this}return void 0!==A()?A():new Function("return this")()}(),VA)}function KA(A){return A&&(A.appContext?A.proxy:A)}function WA(A){if(!A)return;let e=A.type.name;for(;e&&iA(G(e));)e=(A=A.parent).type.name;return A.proxy}function zA(A){return 1===A.nodeType}function ZA(A){const e=jA();if(e&&e.UTSJSONObject&&A instanceof e.UTSJSONObject){const t={};return e.UTSJSONObject.keys(A).forEach(e=>{t[e]=A[e]}),J(t)}if(A instanceof Map){const e={};return A.forEach((A,t)=>{e[t]=A}),J(e)}if(f(A))return j(A);if(C(A)){const e={};for(let t=0;t{A[t]&&(e+=t+" ")});else if(A instanceof Map)A.forEach((A,t)=>{A&&(e+=t+" ")});else if(C(A))for(let i=0;i{A=A||(A=>A.tagName.startsWith("UNI-"));const e=HTMLElement.prototype,t=e.setAttribute;e.setAttribute=function(e,i){if(e.startsWith("data-")&&A(this)){(this.__uniDataset||(this.__uniDataset={}))[Ae(e)]=i}t.call(this,e,i)};const i=e.removeAttribute;e.removeAttribute=function(e){this.__uniDataset&&e.startsWith("data-")&&A(this)&&delete this.__uniDataset[Ae(e)],i.call(this,e)}});function te(A){return u({},A.dataset,A.__uniDataset)}const ie=new RegExp("\"[^\"]+\"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px","g");function oe(A){return{passive:A}}function ne(A){const{id:e,offsetTop:t,offsetLeft:i}=A;return{id:e,dataset:te(A),offsetTop:t,offsetLeft:i}}function re(A){try{return decodeURIComponent(""+A)}catch(e){}return""+A}function se(A={}){const e={};return Object.keys(A).forEach(t=>{try{e[t]=re(A[t])}catch(__){e[t]=A[t]}}),e}const ae=/\+/g;function ge(A){const e={};if(""===A||"?"===A)return e;const t=("?"===A[0]?A.slice(1):A).split("&");for(let i=0;iA.apply(this,arguments),e)};return n.cancel=function(){t(o)},n}class le{constructor(A,e){this.id=A,this.listener={},this.emitCache=[],e&&Object.keys(e).forEach(A=>{this.on(A,e[A])})}emit(A,...e){const t=this.listener[A];if(!t)return this.emitCache.push({eventName:A,args:e});t.forEach(A=>{A.fn.apply(A.fn,e)}),this.listener[A]=t.filter(A=>"once"!==A.type)}on(A,e){this._addListener(A,"on",e),this._clearCache(A)}once(A,e){this._addListener(A,"once",e),this._clearCache(A)}off(A,e){const t=this.listener[A];if(t)if(e)for(let i=0;ie(A)),Ce=function(){};Ce.prototype={_id:1,on:function(A,e,t){var i=this.e||(this.e={});return(i[A]||(i[A]=[])).push({fn:e,ctx:t,_id:this._id}),this._id++},once:function(A,e,t){var i=this;function o(){i.off(A,o),e.apply(t,arguments)}return o._=e,this.on(A,o,t)},emit:function(A){for(var e=[].slice.call(arguments,1),t=((this.e||(this.e={}))[A]||[]).slice(),i=0,o=t.length;i=0;n--)if(i[n].fn===e||i[n].fn._===e||i[n]._id===e){i.splice(n,1);break}o=i}return o.length?t[A]=o:delete t[A],this}};var Be=Ce;const Qe={black:"rgba(0,0,0,0.4)",white:"rgba(255,255,255,0.4)"};function pe(A,e,t){if(f(e)&&e.startsWith("@")){let o=A[e.replace("@","")]||e;switch(t){case"titleColor":o="black"===o?"#000000":"#ffffff";break;case"borderStyle":o=(i=o)&&i in Qe?Qe[i]:i}return o}var i;return e}function fe(A,e={},t="light"){const i=e[t],o={};return void 0!==i&&A?(Object.keys(A).forEach(n=>{const r=A[n];o[n]=S(r)?fe(r,e,t):C(r)?r.map(A=>S(A)?fe(A,e,t):pe(i,A)):pe(i,r,n)}),o):A} /** * @dcloudio/uni-h5-vue v3.4.21 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/let me,ye;class De{constructor(A=!1){this.detached=A,this._active=!0,this.effects=[],this.cleanups=[],this.parent=me,!A&&me&&(this.index=(me.scopes||(me.scopes=[])).push(this)-1)}get active(){return this._active}run(A){if(this._active){const e=me;try{return me=this,A()}finally{me=e}}}on(){me=this}off(){me=this.parent}stop(A){if(this._active){let e,t;for(e=0,t=this.effects.length;e=4))break}1===this._dirtyLevel&&(this._dirtyLevel=0),Le()}return this._dirtyLevel>=4}set dirty(A){this._dirtyLevel=A?4:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let A=Ne,e=ye;try{return Ne=!0,ye=this,this._runnings++,Re(this),this.fn()}finally{_e(this),this._runnings--,ye=e,Ne=A}}stop(){var A;this.active&&(Re(this),_e(this),null==(A=this.onStop)||A.call(this),this.active=!1)}}function Me(A){return A.value}function Re(A){A._trackId++,A._depsLength=0}function _e(A){if(A.deps.length>A._depsLength){for(let e=A._depsLength;e{const t=new Map;return t.cleanup=A,t.computed=e,t},Je=new WeakMap,He=Symbol(""),qe=Symbol("");function Ve(A,e,t){if(Ne&&ye){let e=Je.get(A);e||Je.set(A,e=new Map);let i=e.get(t);i||e.set(t,i=Ye(()=>e.delete(t))),Oe(ye,i)}}function je(A,e,t,i,o,n){const r=Je.get(A);if(!r)return;let s=[];if("clear"===e)s=[...r.values()];else if("length"===t&&C(A)){const A=Number(i);r.forEach((e,t)=>{("length"===t||!m(t)&&t>=A)&&s.push(e)})}else switch(void 0!==t&&s.push(r.get(t)),e){case"add":C(A)?M(t)&&s.push(r.get("length")):(s.push(r.get(He)),B(A)&&s.push(r.get(qe)));break;case"delete":C(A)||(s.push(r.get(He)),B(A)&&s.push(r.get(qe)));break;case"set":B(A)&&s.push(r.get(He))}Ue();for(const a of s)a&&Pe(a,4);Fe()}const Ke=r("__proto__,__v_isRef,__isVue"),We=new Set(Object.getOwnPropertyNames(Symbol).filter(A=>"arguments"!==A&&"caller"!==A).map(A=>Symbol[A]).filter(m)),ze=Ze();function Ze(){const A={};return["includes","indexOf","lastIndexOf"].forEach(e=>{A[e]=function(...A){const t=xt(this);for(let e=0,o=this.length;e{A[e]=function(...A){ke(),Ue();const t=xt(this)[e].apply(this,A);return Fe(),Le(),t}}),A}function Xe(A){const e=xt(this);return Ve(e,0,A),e.hasOwnProperty(A)}class $e{constructor(A=!1,e=!1){this._isReadonly=A,this._isShallow=e}get(A,e,t){const i=this._isReadonly,o=this._isShallow;if("__v_isReactive"===e)return!i;if("__v_isReadonly"===e)return i;if("__v_isShallow"===e)return o;if("__v_raw"===e)return t===(i?o?_t:Rt:o?Mt:St).get(A)||Object.getPrototypeOf(A)===Object.getPrototypeOf(t)?A:void 0;const n=C(A);if(!i){if(n&&h(ze,e))return Reflect.get(ze,e,t);if("hasOwnProperty"===e)return Xe}const r=Reflect.get(A,e,t);return(m(e)?We.has(e):Ke(e))?r:(i||Ve(A,0,e),o?r:jt(r)?n&&M(e)?r:r.value:y(r)?i?Gt(r):Nt(r):r)}}class At extends $e{constructor(A=!1){super(!1,A)}set(A,e,t,i){let o=A[e];if(!this._isShallow){const e=Ut(o);if(Ft(t)||Ut(t)||(o=xt(o),t=xt(t)),!C(A)&&jt(o)&&!jt(t))return!e&&(o.value=t,!0)}const n=C(A)&&M(e)?Number(e)A,st=A=>Reflect.getPrototypeOf(A);function at(A,e,t=!1,i=!1){const o=xt(A=A.__v_raw),n=xt(e);t||(U(e,n)&&Ve(o,0,e),Ve(o,0,n));const{has:r}=st(o),s=i?rt:t?Jt:Yt;return r.call(o,e)?s(A.get(e)):r.call(o,n)?s(A.get(n)):void(A!==o&&A.get(e))}function gt(A,e=!1){const t=this.__v_raw,i=xt(t),o=xt(A);return e||(U(A,o)&&Ve(i,0,A),Ve(i,0,o)),A===o?t.has(A):t.has(A)||t.has(o)}function ct(A,e=!1){return A=A.__v_raw,!e&&Ve(xt(A),0,He),Reflect.get(A,"size",A)}function lt(A){A=xt(A);const e=xt(this);return st(e).has.call(e,A)||(e.add(A),je(e,"add",A,A)),this}function It(A,e){e=xt(e);const t=xt(this),{has:i,get:o}=st(t);let n=i.call(t,A);n||(A=xt(A),n=i.call(t,A));const r=o.call(t,A);return t.set(A,e),n?U(e,r)&&je(t,"set",A,e):je(t,"add",A,e),this}function ut(A){const e=xt(this),{has:t,get:i}=st(e);let o=t.call(e,A);o||(A=xt(A),o=t.call(e,A)),i&&i.call(e,A);const n=e.delete(A);return o&&je(e,"delete",A,void 0),n}function Et(){const A=xt(this),e=0!==A.size,t=A.clear();return e&&je(A,"clear",void 0,void 0),t}function dt(A,e){return function(t,i){const o=this,n=o.__v_raw,r=xt(n),s=e?rt:A?Jt:Yt;return!A&&Ve(r,0,He),n.forEach((A,e)=>t.call(i,s(A),s(e),o))}}function ht(A,e,t){return function(...i){const o=this.__v_raw,n=xt(o),r=B(n),s="entries"===A||A===Symbol.iterator&&r,a="keys"===A&&r,g=o[A](...i),c=t?rt:e?Jt:Yt;return!e&&Ve(n,0,a?qe:He),{next(){const{value:A,done:e}=g.next();return e?{value:A,done:e}:{value:s?[c(A[0]),c(A[1])]:c(A),done:e}},[Symbol.iterator](){return this}}}}function Ct(A){return function(...e){return"delete"!==A&&("clear"===A?void 0:this)}}function Bt(){const A={get(A){return at(this,A)},get size(){return ct(this)},has:gt,add:lt,set:It,delete:ut,clear:Et,forEach:dt(!1,!1)},e={get(A){return at(this,A,!1,!0)},get size(){return ct(this)},has:gt,add:lt,set:It,delete:ut,clear:Et,forEach:dt(!1,!0)},t={get(A){return at(this,A,!0)},get size(){return ct(this,!0)},has(A){return gt.call(this,A,!0)},add:Ct("add"),set:Ct("set"),delete:Ct("delete"),clear:Ct("clear"),forEach:dt(!0,!1)},i={get(A){return at(this,A,!0,!0)},get size(){return ct(this,!0)},has(A){return gt.call(this,A,!0)},add:Ct("add"),set:Ct("set"),delete:Ct("delete"),clear:Ct("clear"),forEach:dt(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{A[o]=ht(o,!1,!1),t[o]=ht(o,!0,!1),e[o]=ht(o,!1,!0),i[o]=ht(o,!0,!0)}),[A,t,e,i]}const[Qt,pt,ft,mt]=Bt();function yt(A,e){const t=e?A?mt:ft:A?pt:Qt;return(e,i,o)=>"__v_isReactive"===i?!A:"__v_isReadonly"===i?A:"__v_raw"===i?e:Reflect.get(h(t,i)&&i in e?t:e,i,o)}const Dt={get:yt(!1,!1)},vt={get:yt(!1,!0)},wt={get:yt(!0,!1)},St=new WeakMap,Mt=new WeakMap,Rt=new WeakMap,_t=new WeakMap;function Tt(A){return A.__v_skip||!Object.isExtensible(A)?0:function(A){switch(A){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((A=>w(A).slice(8,-1))(A))}function Nt(A){return Ut(A)?A:kt(A,!1,it,Dt,St)}function bt(A){return kt(A,!1,nt,vt,Mt)}function Gt(A){return kt(A,!0,ot,wt,Rt)}function kt(A,e,t,i,o){if(!y(A))return A;if(A.__v_raw&&(!e||!A.__v_isReactive))return A;const n=o.get(A);if(n)return n;const r=Tt(A);if(0===r)return A;const s=new Proxy(A,2===r?i:t);return o.set(A,s),s}function Lt(A){return Ut(A)?Lt(A.__v_raw):!(!A||!A.__v_isReactive)}function Ut(A){return!(!A||!A.__v_isReadonly)}function Ft(A){return!(!A||!A.__v_isShallow)}function Ot(A){return Lt(A)||Ut(A)}function xt(A){const e=A&&A.__v_raw;return e?xt(e):A}function Pt(A){return Object.isExtensible(A)&&O(A,"__v_skip",!0),A}const Yt=A=>y(A)?Nt(A):A,Jt=A=>y(A)?Gt(A):A;class Ht{constructor(A,e,t,i){this.getter=A,this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this.effect=new Se(()=>A(this._value),()=>Vt(this,2===this.effect._dirtyLevel?2:3)),this.effect.computed=this,this.effect.active=this._cacheable=!i,this.__v_isReadonly=t}get value(){const A=xt(this);return A._cacheable&&!A.effect.dirty||!U(A._value,A._value=A.effect.run())||Vt(A,4),qt(A),A.effect._dirtyLevel>=2&&Vt(A,2),A._value}set value(A){this._setter(A)}get _dirty(){return this.effect.dirty}set _dirty(A){this.effect.dirty=A}}function qt(A){var e;Ne&&ye&&(A=xt(A),Oe(ye,null!=(e=A.dep)?e:A.dep=Ye(()=>A.dep=void 0,A instanceof Ht?A:void 0)))}function Vt(A,e=4,t){const i=(A=xt(A)).dep;i&&Pe(i,e)}function jt(A){return!(!A||!0!==A.__v_isRef)}function Kt(A){return zt(A,!1)}function Wt(A){return zt(A,!0)}function zt(A,e){return jt(A)?A:new Zt(A,e)}class Zt{constructor(A,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?A:xt(A),this._value=e?A:Yt(A)}get value(){return qt(this),this._value}set value(A){const e=this.__v_isShallow||Ft(A)||Ut(A);A=e?A:xt(A),U(A,this._rawValue)&&(this._rawValue=A,this._value=e?A:Yt(A),Vt(this,4))}}function Xt(A){return jt(A)?A.value:A}const $t={get:(A,e,t)=>Xt(Reflect.get(A,e,t)),set:(A,e,t,i)=>{const o=A[e];return jt(o)&&!jt(t)?(o.value=t,!0):Reflect.set(A,e,t,i)}};function Ai(A){return Lt(A)?A:new Proxy(A,$t)}class ei{constructor(A){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:t}=A(()=>qt(this),()=>Vt(this));this._get=e,this._set=t}get value(){return this._get()}set value(A){this._set(A)}}function ti(A){const e=C(A)?new Array(A.length):{};for(const t in A)e[t]=ri(A,t);return e}class ii{constructor(A,e,t){this._object=A,this._key=e,this._defaultValue=t,this.__v_isRef=!0}get value(){const A=this._object[this._key];return void 0===A?this._defaultValue:A}set value(A){this._object[this._key]=A}get dep(){return A=xt(this._object),e=this._key,null==(t=Je.get(A))?void 0:t.get(e);var A,e,t}}class oi{constructor(A){this._getter=A,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function ni(A,e,t){return jt(A)?A:p(A)?new oi(A):y(A)&&arguments.length>1?ri(A,e,t):Kt(A)}function ri(A,e,t){const i=A[e];return jt(i)?i:new ii(A,e,t)}function si(A,e,t,i){try{return i?A(...i):A()}catch(o){gi(o,e,t)}}function ai(A,e,t,i){if(p(A)){const o=si(A,e,t,i);return o&&D(o)&&o.catch(A=>{gi(A,e,t)}),o}const o=[];for(let n=0;n>>1,o=ui[i],n=vi(o);nvi(A)-vi(e));if(di.length=0,hi)return void hi.push(...A);for(hi=A,Ci=0;Cinull==A.id?1/0:A.id,wi=(A,e)=>{const t=vi(A)-vi(e);if(0===t){if(A.pre&&!e.pre)return-1;if(e.pre&&!A.pre)return 1}return t};function Si(A){Ii=!1,li=!0,ui.sort(wi);try{for(Ei=0;Eif(A)?A.trim():A)),e&&(o=t.map(x))}let a,g=i[a=L(e)]||i[a=L(N(e))];!g&&n&&(g=i[a=L(G(e))]),g&&ai(g,A,6,Ri(A,g,o));const c=i[a+"Once"];if(c){if(A.emitted){if(A.emitted[a])return}else A.emitted={};A.emitted[a]=!0,ai(c,A,6,Ri(A,c,o))}}function Ri(A,e,t){if(1!==t.length)return t;if(p(e)){if(e.length<2)return t}else if(!e.find(A=>A.length>=2))return t;const i=t[0];if(i&&h(i,"type")&&h(i,"timeStamp")&&h(i,"target")&&h(i,"currentTarget")&&h(i,"detail")){const e=A.proxy,i=e.$gcd(e,!0);i&&t.push(i)}return t}function _i(A,e,t=!1){const i=e.emitsCache,o=i.get(A);if(void 0!==o)return o;const n=A.emits;let r={},s=!1;if(!p(A)){const i=A=>{const t=_i(A,e,!0);t&&(s=!0,u(r,t))};!t&&e.mixins.length&&e.mixins.forEach(i),A.extends&&i(A.extends),A.mixins&&A.mixins.forEach(i)}return n||s?(C(n)?n.forEach(A=>r[A]=null):u(r,n),y(A)&&i.set(A,r),r):(y(A)&&i.set(A,null),null)}function Ti(A,e){return!(!A||!l(e))&&(e=e.slice(2).replace(/Once$/,""),h(A,e[0].toLowerCase()+e.slice(1))||h(A,G(e))||h(A,e))}let Ni=null,bi=null;function Gi(A){const e=Ni;return Ni=A,bi=A&&A.type.__scopeId||null,e}function ki(A){bi=A}function Li(){bi=null}function Ui(A,e=Ni,t){if(!e)return A;if(A._n)return A;const i=(...t)=>{i._d&&tr(-1);const o=Gi(e);let n;try{n=A(...t)}finally{Gi(o),i._d&&tr(1)}return n};return i._n=!0,i._c=!0,i._d=!0,i}function Fi(A){const{type:e,vnode:t,proxy:i,withProxy:o,props:n,propsOptions:[r],slots:s,attrs:a,emit:g,render:c,renderCache:l,data:u,setupState:E,ctx:d,inheritAttrs:h}=A;let C,B;const Q=Gi(A);try{if(4&t.shapeFlag){const A=o||i,e=A;C=hr(c.call(e,A,l,n,E,u,d)),B=a}else{const A=e;0,C=hr(A.length>1?A(n,{attrs:a,slots:s,emit:g}):A(n,null)),B=e.props?a:Oi(a)}}catch(f){Xn.length=0,gi(f,A,1),C=Ir(zn)}let p=C;if(B&&!1!==h){const A=Object.keys(B),{shapeFlag:e}=p;A.length&&7&e&&(r&&A.some(I)&&(B=xi(B,r)),p=ur(p,B))}return t.dirs&&(p=ur(p),p.dirs=p.dirs?p.dirs.concat(t.dirs):t.dirs),t.transition&&(p.transition=t.transition),C=p,Gi(Q),C}const Oi=A=>{let e;for(const t in A)("class"===t||"style"===t||l(t))&&((e||(e={}))[t]=A[t]);return e},xi=(A,e)=>{const t={};for(const i in A)I(i)&&i.slice(9)in e||(t[i]=A[i]);return t};function Pi(A,e,t){const i=Object.keys(e);if(i.length!==Object.keys(A).length)return!0;for(let o=0;oA.__isSuspense;const Wi=Symbol.for("v-scx");function zi(A,e){return $i(A,null,e)}const Zi={};function Xi(A,e,t){return $i(A,e,t)}function $i(A,e,{immediate:t,deep:i,flush:o,once:n,onTrack:r,onTrigger:a}=s){if(e&&n){const A=e;e=(...e)=>{A(...e),w()}}const c=yr,l=A=>!0===i?A:to(A,!1===i?1:void 0);let I,u,d=!1,h=!1;if(jt(A)?(I=()=>A.value,d=Ft(A)):Lt(A)?(I=()=>l(A),d=!0):C(A)?(h=!0,d=A.some(A=>Lt(A)||Ft(A)),I=()=>A.map(A=>jt(A)?A.value:Lt(A)?l(A):p(A)?si(A,c,2):void 0)):I=p(A)?e?()=>si(A,c,2):()=>(u&&u(),ai(A,c,3,[Q])):g,e&&i){const A=I;I=()=>to(A())}let B,Q=A=>{u=D.onStop=()=>{si(A,c,4),u=D.onStop=void 0}};if(Tr){if(Q=g,e?t&&ai(e,c,3,[I(),h?[]:void 0,Q]):I(),"sync"!==o)return g;{const A=pn(Wi);B=A.__watcherHandles||(A.__watcherHandles=[])}}let f=h?new Array(A.length).fill(Zi):Zi;const m=()=>{if(D.active&&D.dirty)if(e){const A=D.run();(i||d||(h?A.some((A,e)=>U(A,f[e])):U(A,f)))&&(u&&u(),ai(e,c,3,[A,f===Zi?void 0:h&&f[0]===Zi?[]:f,Q]),f=A)}else D.run()};let y;m.allowRecurse=!!e,"sync"===o?y=m:"post"===o?y=()=>kn(m,c&&c.suspense):(m.pre=!0,c&&(m.id=c.uid),y=()=>fi(m));const D=new Se(I,g,y),v=we(),w=()=>{D.stop(),v&&E(v.effects,D)};return e?t?m():f=D.run():"post"===o?kn(D.run.bind(D),c&&c.suspense):D.run(),B&&B.push(w),w}function Ao(A,e,t){const i=this.proxy,o=f(A)?A.includes(".")?eo(i,A):()=>i[A]:A.bind(i,i);let n;p(e)?n=e:(n=e.handler,t=e);const r=Sr(this),s=$i(o,n.bind(i),t);return r(),s}function eo(A,e){const t=e.split(".");return()=>{let e=A;for(let A=0;A0){if(t>=e)return A;t++}if((i=i||new Set).has(A))return A;if(i.add(A),jt(A))to(A.value,e,t,i);else if(C(A))for(let o=0;o{to(A,e,t,i)});else if(S(A))for(const o in A)to(A[o],e,t,i);return A}function io(A,e){if(null===Ni)return A;const t=kr(Ni)||Ni.proxy,i=A.dirs||(A.dirs=[]);for(let o=0;o{A.isMounted=!0}),xo(()=>{A.isUnmounting=!0}),A}();return()=>{const o=e.default&&ho(e.default(),!0);if(!o||!o.length)return;let n=o[0];if(o.length>1)for(const A of o)if(A.type!==zn){n=A;break}const r=xt(A),{mode:s}=r;if(i.isLeaving)return Io(n);const a=uo(n);if(!a)return Io(n);const g=lo(a,r,i,t);Eo(a,g);const c=t.subTree,l=c&&uo(c);if(l&&l.type!==zn&&!sr(a,l)){const A=lo(l,r,i,t);if(Eo(l,A),"out-in"===s)return i.isLeaving=!0,A.afterLeave=()=>{i.isLeaving=!1,!1!==t.update.active&&(t.effect.dirty=!0,t.update())},Io(n);"in-out"===s&&a.type!==zn&&(A.delayLeave=(A,e,t)=>{co(i,l)[String(l.key)]=l,A[no]=()=>{e(),A[no]=void 0,delete g.delayedLeave},g.delayedLeave=t})}return n}}};function co(A,e){const{leavingVNodes:t}=A;let i=t.get(e.type);return i||(i=Object.create(null),t.set(e.type,i)),i}function lo(A,e,t,i){const{appear:o,mode:n,persisted:r=!1,onBeforeEnter:s,onEnter:a,onAfterEnter:g,onEnterCancelled:c,onBeforeLeave:l,onLeave:I,onAfterLeave:u,onLeaveCancelled:E,onBeforeAppear:d,onAppear:h,onAfterAppear:B,onAppearCancelled:Q}=e,p=String(A.key),f=co(t,A),m=(A,e)=>{A&&ai(A,i,9,e)},y=(A,e)=>{const t=e[1];m(A,e),C(A)?A.every(A=>A.length<=1)&&t():A.length<=1&&t()},D={mode:n,persisted:r,beforeEnter(e){let i=s;if(!t.isMounted){if(!o)return;i=d||s}e[no]&&e[no](!0);const n=f[p];n&&sr(A,n)&&n.el[no]&&n.el[no](),m(i,[e])},enter(A){let e=a,i=g,n=c;if(!t.isMounted){if(!o)return;e=h||a,i=B||g,n=Q||c}let r=!1;const s=A[ro]=e=>{r||(r=!0,m(e?n:i,[A]),D.delayedLeave&&D.delayedLeave(),A[ro]=void 0)};e?y(e,[A,s]):s()},leave(e,i){const o=String(A.key);if(e[ro]&&e[ro](!0),t.isUnmounting)return i();m(l,[e]);let n=!1;const r=e[no]=t=>{n||(n=!0,i(),m(t?E:u,[e]),e[no]=void 0,f[o]===A&&delete f[o])};f[o]=A,I?y(I,[e,r]):r()},clone:A=>lo(A,e,t,i)};return D}function Io(A){if(fo(A))return(A=ur(A)).children=null,A}function uo(A){return fo(A)?A.children?A.children[0]:void 0:A}function Eo(A,e){6&A.shapeFlag&&A.component?Eo(A.component.subTree,e):128&A.shapeFlag?(A.ssContent.transition=e.clone(A.ssContent),A.ssFallback.transition=e.clone(A.ssFallback)):A.transition=e}function ho(A,e=!1,t){let i=[],o=0;for(let n=0;n1)for(let n=0;nu({name:A.name},e,{setup:A}))():A}const Bo=A=>!!A.type.__asyncLoader; /*! #__NO_SIDE_EFFECTS__ */function Qo(A){p(A)&&(A={loader:A});const{loader:e,loadingComponent:t,errorComponent:i,delay:o=200,timeout:n,suspensible:r=!0,onError:s}=A;let a,g=null,c=0;const l=()=>{let A;return g||(A=g=e().catch(A=>{if(A=A instanceof Error?A:new Error(String(A)),s)return new Promise((e,t)=>{s(A,()=>e((c++,g=null,l())),()=>t(A),c+1)});throw A}).then(e=>A!==g&&g?g:(e&&(e.__esModule||"Module"===e[Symbol.toStringTag])&&(e=e.default),a=e,e)))};return Co({name:"AsyncComponentWrapper",__asyncLoader:l,get __asyncResolved(){return a},setup(){const A=yr;if(a)return()=>po(a,A);const e=e=>{g=null,gi(e,A,13,!i)};if(r&&A.suspense||Tr)return l().then(e=>()=>po(e,A)).catch(A=>(e(A),()=>i?Ir(i,{error:A}):null));const s=Kt(!1),c=Kt(),I=Kt(!!o);return o&&setTimeout(()=>{I.value=!1},o),null!=n&&setTimeout(()=>{if(!s.value&&!c.value){const A=new Error(`Async component timed out after ${n}ms.`);e(A),c.value=A}},n),l().then(()=>{s.value=!0,A.parent&&fo(A.parent.vnode)&&(A.parent.effect.dirty=!0,fi(A.parent.update))}).catch(A=>{e(A),c.value=A}),()=>s.value&&a?po(a,A):c.value&&i?Ir(i,{error:c.value}):t&&!I.value?Ir(t):void 0}})}function po(A,e){const{ref:t,props:i,children:o,ce:n}=e.vnode,r=Ir(A,i,o);return r.ref=t,r.ce=n,delete e.vnode.ce,r}const fo=A=>A.type.__isKeepAlive;class mo{constructor(A){this.max=A,this._cache=new Map,this._keys=new Set,this._max=parseInt(A,10)}get(A){const{_cache:e,_keys:t,_max:i}=this,o=e.get(A);if(o)t.delete(A),t.add(A);else if(t.add(A),i&&t.size>i){const A=t.values().next().value;this.pruneCacheEntry(e.get(A)),this.delete(A)}return o}set(A,e){this._cache.set(A,e)}delete(A){this._cache.delete(A),this._keys.delete(A)}forEach(A,e){this._cache.forEach(A.bind(e))}}const yo={name:"KeepAlive",__isKeepAlive:!0,props:{include:[String,RegExp,Array],exclude:[String,RegExp,Array],max:[String,Number],matchBy:{type:String,default:"name"},cache:Object},setup(A,{slots:e}){const t=Dr(),i=t.ctx;if(!i.renderer)return()=>{const A=e.default&&e.default();return A&&1===A.length?A[0]:A};const o=A.cache||new mo(A.max);o.pruneCacheEntry=r;let n=null;function r(e){var i;!n||!sr(e,n)||"key"===A.matchBy&&e.key!==n.key?(_o(i=e),c(i,t,s,!0)):n&&_o(n)}const s=t.suspense,{renderer:{p:a,m:g,um:c,o:{createElement:l}}}=i,I=l("div");function u(e){o.forEach((t,i)=>{const n=No(t,A.matchBy);!n||e&&e(n)||(o.delete(i),r(t))})}i.activate=(A,e,t,i,o)=>{const n=A.component;if(n.ba){const A=n.isDeactivated;n.isDeactivated=!1,F(n.ba),n.isDeactivated=A}g(A,e,t,0,s),a(n.vnode,A,e,t,n,s,i,A.slotScopeIds,o),kn(()=>{n.isDeactivated=!1,n.a&&F(n.a);const e=A.props&&A.props.onVnodeMounted;e&&pr(e,n.parent,A)},s)},i.deactivate=A=>{const e=A.component;e.bda&&bo(e.bda),g(A,I,null,1,s),kn(()=>{e.bda&&e.bda.forEach(A=>A.__called=!1),e.da&&F(e.da);const t=A.props&&A.props.onVnodeUnmounted;t&&pr(t,e.parent,A),e.isDeactivated=!0},s)},Xi(()=>[A.include,A.exclude,A.matchBy],([A,e])=>{A&&u(e=>vo(A,e)),e&&u(A=>!vo(e,A))},{flush:"post",deep:!0});let E=null;const d=()=>{null!=E&&o.set(E,To(t.subTree))};return Uo(d),Oo(d),xo(()=>{o.forEach((e,i)=>{o.delete(i),r(e);const{subTree:n,suspense:s}=t,a=To(n);if(e.type===a.type&&("key"!==A.matchBy||e.key===a.key)){a.component.bda&&F(a.component.bda),_o(a);const A=a.component.da;return void(A&&kn(A,s))}})}),()=>{if(E=null,!e.default)return null;const t=e.default(),i=t[0];if(t.length>1)return n=null,t;if(!rr(i)||!(4&i.shapeFlag)&&!Ki(i.type))return n=null,i;let r=To(i);const s=r.type,a=No(r,A.matchBy),{include:g,exclude:c}=A;if(g&&(!a||!vo(g,a))||c&&a&&vo(c,a))return n=r,i;const l=null==r.key?s:r.key,I=o.get(l);return r.el&&(r=ur(r),Ki(i.type)&&(i.ssContent=r)),E=l,I&&(r.el=I.el,r.component=I.component,r.transition&&Eo(r,r.transition),r.shapeFlag|=512),r.shapeFlag|=256,n=r,Ki(i.type)?i:r}}},Do=yo;function vo(A,e){return C(A)?A.some(A=>vo(A,e)):f(A)?A.split(",").includes(e):"[object RegExp]"===w(A)&&A.test(e)}function wo(A,e){Mo(A,"a",e)}function So(A,e){Mo(A,"da",e)}function Mo(A,e,t=yr){const i=A.__wdc||(A.__wdc=()=>{let e=t;for(;e;){if(e.isDeactivated)return;e=e.parent}return A()});if(i.__called=!1,Go(e,i,t),t){let A=t.parent;for(;A&&A.parent;)fo(A.parent.vnode)&&Ro(i,e,t,A),A=A.parent}}function Ro(A,e,t,i){const o=Go(e,A,i,!0);Po(()=>{E(i[e],o)},t)}function _o(A){A.shapeFlag&=-257,A.shapeFlag&=-513}function To(A){return Ki(A.type)?A.ssContent:A}function No(A,e){if("name"===e){const e=A.type;return Lr(Bo(A)?e.__asyncResolved||{}:e)}return String(A.key)}function bo(A){for(let e=0;e-1&&t.$pageInstance){if(t.type.__reserved)return;if(t!==t.$pageInstance&&(t=t.$pageInstance,function(A){return[CA,cA].indexOf(A)>-1}(A))){const i=t.proxy;ai(e.bind(i),t,A,CA===A?[i.$page.options]:[])}}const n=t[A]||(t[A]=[]),r=e.__weh||(e.__weh=(...i)=>{if(t.isUnmounted)return;ke();const o=Sr(t),n=ai(e,t,A,i);return o(),Le(),n});return i?n.unshift(r):n.push(r),r}var o}const ko=A=>(e,t=yr)=>(!Tr||"sp"===A)&&Go(A,(...A)=>e(...A),t),Lo=ko("bm"),Uo=ko("m"),Fo=ko("bu"),Oo=ko("u"),xo=ko("bum"),Po=ko("um"),Yo=ko("sp"),Jo=ko("rtg"),Ho=ko("rtc");function qo(A,e=yr){Go("ec",A,e)}function Vo(A,e,t,i){let o;const n=t&&t[i];if(C(A)||f(A)){o=new Array(A.length);for(let t=0,i=A.length;te(A,t,void 0,n&&n[t]));else{const t=Object.keys(A);o=new Array(t.length);for(let i=0,r=t.length;i!rr(A)||A.type!==zn&&!(A.type===Kn&&!Ko(A.children)))?A:null}const Wo=A=>{if(!A)return null;if(Rr(A)){return kr(A)||A.proxy}return Wo(A.parent)},zo=u(Object.create(null),{$:A=>A,$el:A=>A.vnode.el,$data:A=>A.data,$props:A=>A.props,$attrs:A=>A.attrs,$slots:A=>A.slots,$refs:A=>A.refs,$parent:A=>Wo(A.parent),$root:A=>Wo(A.root),$emit:A=>A.emit,$options:A=>sn(A),$forceUpdate:A=>A.f||(A.f=(A=>function(){A.effect.dirty=!0,fi(A.update)})(A)),$nextTick:A=>A.n||(A.n=pi.bind(A.proxy)),$watch:A=>Ao.bind(A)}),Zo=(A,e)=>A!==s&&!A.__isScriptSetup&&h(A,e),Xo={get({_:A},e){const{ctx:t,setupState:i,data:o,props:n,accessCache:r,type:a,appContext:g}=A;let c;if("$"!==e[0]){const a=r[e];if(void 0!==a)switch(a){case 1:return i[e];case 2:return o[e];case 4:return t[e];case 3:return n[e]}else{if(Zo(i,e))return r[e]=1,i[e];if(o!==s&&h(o,e))return r[e]=2,o[e];if((c=A.propsOptions[0])&&h(c,e))return r[e]=3,n[e];if(t!==s&&h(t,e))return r[e]=4,t[e];tn&&(r[e]=0)}}const l=zo[e];let I,u;return l?("$attrs"===e&&Ve(A,0,e),l(A)):(I=a.__cssModules)&&(I=I[e])?I:t!==s&&h(t,e)?(r[e]=4,t[e]):(u=g.config.globalProperties,h(u,e)?u[e]:void 0)},set({_:A},e,t){const{data:i,setupState:o,ctx:n}=A;return Zo(o,e)?(o[e]=t,!0):i!==s&&h(i,e)?(i[e]=t,!0):!h(A.props,e)&&(("$"!==e[0]||!(e.slice(1)in A))&&(n[e]=t,!0))},has({_:{data:A,setupState:e,accessCache:t,ctx:i,appContext:o,propsOptions:n}},r){let a;return!!t[r]||A!==s&&h(A,r)||Zo(e,r)||(a=n[0])&&h(a,r)||h(i,r)||h(zo,r)||h(o.config.globalProperties,r)},defineProperty(A,e,t){return null!=t.get?A._.accessCache[e]=0:h(t,"value")&&this.set(A,e,t.value,null),Reflect.defineProperty(A,e,t)}};function $o(){return function(){const A=Dr();return A.setupContext||(A.setupContext=Gr(A))}().slots}function An(A){return C(A)?A.reduce((A,e)=>(A[e]=null,A),{}):A}function en(A,e){return A&&e?C(A)&&C(e)?A.concat(e):u({},An(A),An(e)):A||e}let tn=!0;function on(A){const e=sn(A),t=A.proxy,i=A.ctx;tn=!1,e.beforeCreate&&nn(e.beforeCreate,A,"bc");const{data:o,computed:n,methods:r,watch:s,provide:a,inject:c,created:l,beforeMount:I,mounted:u,beforeUpdate:E,updated:d,activated:h,deactivated:B,beforeDestroy:Q,beforeUnmount:f,destroyed:m,unmounted:D,render:v,renderTracked:w,renderTriggered:S,errorCaptured:M,serverPrefetch:R,expose:_,inheritAttrs:T,components:N,directives:b,filters:G}=e;if(c&&function(A,e){C(A)&&(A=ln(A));for(const t in A){const i=A[t];let o;o=y(i)?"default"in i?pn(i.from||t,i.default,!0):pn(i.from||t):pn(i),jt(o)?Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>o.value,set:A=>o.value=A}):e[t]=o}}(c,i,null),r)for(const g in r){const A=r[g];p(A)&&(i[g]=A.bind(t))}if(o){const e=o.call(t,t);y(e)&&(A.data=Nt(e))}if(tn=!0,n)for(const C in n){const A=n[C],e=p(A)?A.bind(t,t):p(A.get)?A.get.bind(t,t):g,o=!p(A)&&p(A.set)?A.set.bind(t):g,r=Ur({get:e,set:o});Object.defineProperty(i,C,{enumerable:!0,configurable:!0,get:()=>r.value,set:A=>r.value=A})}if(s)for(const g in s)rn(s[g],i,t,g);if(a){const A=p(a)?a.call(t):a;Reflect.ownKeys(A).forEach(e=>{Qn(e,A[e])})}function k(A,e){C(e)?e.forEach(e=>A(e.bind(t))):e&&A(e.bind(t))}if(l&&nn(l,A,"c"),k(Lo,I),k(Uo,u),k(Fo,E),k(Oo,d),k(wo,h),k(So,B),k(qo,M),k(Ho,w),k(Jo,S),k(xo,f),k(Po,D),k(Yo,R),C(_))if(_.length){const e=A.exposed||(A.exposed={});_.forEach(A=>{Object.defineProperty(e,A,{get:()=>t[A],set:e=>t[A]=e})})}else A.exposed||(A.exposed={});v&&A.render===g&&(A.render=v),null!=T&&(A.inheritAttrs=T),N&&(A.components=N),b&&(A.directives=b);const L=A.appContext.config.globalProperties.$applyOptions;L&&L(e,A,t)}function nn(A,e,t){ai(C(A)?A.map(A=>A.bind(e.proxy)):A.bind(e.proxy),e,t)}function rn(A,e,t,i){const o=i.includes(".")?eo(t,i):()=>t[i];if(f(A)){const t=e[A];p(t)&&Xi(o,t)}else if(p(A))Xi(o,A.bind(t));else if(y(A))if(C(A))A.forEach(A=>rn(A,e,t,i));else{const i=p(A.handler)?A.handler.bind(t):e[A.handler];p(i)&&Xi(o,i,A)}}function sn(A){const e=A.type,{mixins:t,extends:i}=e,{mixins:o,optionsCache:n,config:{optionMergeStrategies:r}}=A.appContext,s=n.get(e);let a;return s?a=s:o.length||t||i?(a={},o.length&&o.forEach(A=>an(a,A,r,!0)),an(a,e,r)):a=e,y(e)&&n.set(e,a),a}function an(A,e,t,i=!1){const{mixins:o,extends:n}=e;n&&an(A,n,t,!0),o&&o.forEach(e=>an(A,e,t,!0));for(const r in e)if(i&&"expose"===r);else{const i=gn[r]||t&&t[r];A[r]=i?i(A[r],e[r]):e[r]}return A}const gn={data:cn,props:En,emits:En,methods:un,computed:un,beforeCreate:In,created:In,beforeMount:In,mounted:In,beforeUpdate:In,updated:In,beforeDestroy:In,beforeUnmount:In,destroyed:In,unmounted:In,activated:In,deactivated:In,errorCaptured:In,serverPrefetch:In,components:un,directives:un,watch:function(A,e){if(!A)return e;if(!e)return A;const t=u(Object.create(null),A);for(const i in e)t[i]=In(A[i],e[i]);return t},provide:cn,inject:function(A,e){return un(ln(A),ln(e))}};function cn(A,e){return e?A?function(){return u(p(A)?A.call(this,this):A,p(e)?e.call(this,this):e)}:e:A}function ln(A){if(C(A)){const e={};for(let t=0;t(n.has(A)||(A&&p(A.install)?(n.add(A),A.install(s,...e)):p(A)&&(n.add(A),A(s,...e))),s),mixin:A=>(o.mixins.includes(A)||o.mixins.push(A),s),component:(A,e)=>e?(o.components[A]=e,s):o.components[A],directive:(A,e)=>e?(o.directives[A]=e,s):o.directives[A],mount(n,a,g){if(!r){const c=Ir(t,i);return c.appContext=o,!0===g?g="svg":!1===g&&(g=void 0),a&&e?e(c,n):A(c,n,g),r=!0,s._container=n,n.__vue_app__=s,s._instance=c.component,kr(c.component)||c.component.proxy}},unmount(){r&&(A(null,s._container),delete s._container.__vue_app__)},provide:(A,e)=>(o.provides[A]=e,s),runWithContext(A){const e=Bn;Bn=s;try{return A()}finally{Bn=e}}};return s}}let Bn=null;function Qn(A,e){if(yr){let t=yr.provides;const i=yr.parent&&yr.parent.provides;i===t&&(t=yr.provides=Object.create(i)),t[A]=e,"app"===yr.type.mpType&&yr.appContext.app.provide(A,e)}else;}function pn(A,e,t=!1){const i=yr||Ni;if(i||Bn){const o=i?null==i.parent?i.vnode.appContext&&i.vnode.appContext.provides:i.parent.provides:Bn._context.provides;if(o&&A in o)return o[A];if(arguments.length>1)return t&&p(e)?e.call(i&&i.proxy):e}}function fn(){return!!(yr||Ni||Bn)}function mn(A,e,t,i){const[o,n]=A.propsOptions;let r,a=!1;if(e)for(let s in e){if(R(s))continue;const g=e[s];let c;o&&h(o,c=N(s))?n&&n.includes(c)?(r||(r={}))[c]=g:t[c]=g:Ti(A.emitsOptions,s)||s in i&&g===i[s]||(i[s]=g,a=!0)}if(n){const e=xt(t),i=r||s;for(let r=0;r{c=!0;const[t,i]=Dn(A,e,!0);u(r,t),i&&g.push(...i)};!t&&e.mixins.length&&e.mixins.forEach(i),A.extends&&i(A.extends),A.mixins&&A.mixins.forEach(i)}if(!n&&!c)return y(A)&&i.set(A,a),a;if(C(n))for(let a=0;a-1,t[1]=i<0||e-1||h(t,"default"))&&g.push(A)}}}const l=[r,g];return y(A)&&i.set(A,l),l}function vn(A){return"$"!==A[0]&&!R(A)}function wn(A){if(null===A)return"null";if("function"==typeof A)return A.name||"";if("object"==typeof A){return A.constructor&&A.constructor.name||""}return""}function Sn(A,e){return wn(A)===wn(e)}function Mn(A,e){return C(e)?e.findIndex(e=>Sn(e,A)):p(e)&&Sn(e,A)?0:-1}const Rn=A=>"_"===A[0]||"$stable"===A,_n=A=>C(A)?A.map(hr):[hr(A)],Tn=(A,e,t)=>{if(e._n)return e;const i=Ui((...A)=>_n(e(...A)),t);return i._c=!1,i},Nn=(A,e,t)=>{const i=A._ctx;for(const o in A){if(Rn(o))continue;const t=A[o];if(p(t))e[o]=Tn(0,t,i);else if(null!=t){const A=_n(t);e[o]=()=>A}}},bn=(A,e)=>{const t=_n(e);A.slots.default=()=>t};function Gn(A,e,t,i,o=!1){if(C(A))return void A.forEach((A,n)=>Gn(A,e&&(C(e)?e[n]:e),t,i,o));if(Bo(i)&&!o)return;const n=4&i.shapeFlag?kr(i.component)||i.component.proxy:i.el,r=o?null:n,{i:a,r:g}=A,c=e&&e.r,l=a.refs===s?a.refs={}:a.refs,I=a.setupState;if(null!=c&&c!==g&&(f(c)?(l[c]=null,h(I,c)&&(I[c]=null)):jt(c)&&(c.value=null)),p(g))si(g,a,12,[r,l]);else{const e=f(g),i=jt(g);if(e||i){const s=()=>{if(A.f){const t=e?h(I,g)?I[g]:l[g]:g.value;o?C(t)&&E(t,n):C(t)?t.includes(n)||t.push(n):e?(l[g]=[n],h(I,g)&&(I[g]=l[g])):(g.value=[n],A.k&&(l[A.k]=g.value))}else e?(l[g]=r,h(I,g)&&(I[g]=r)):i&&(g.value=r,A.k&&(l[A.k]=r))};r?(s.id=-1,kn(s,t)):s()}}}const kn=function(A,e){var t;e&&e.pendingBranch?C(A)?e.effects.push(...A):e.effects.push(A):(C(t=A)?di.push(...t):hi&&hi.includes(t,t.allowRecurse?Ci+1:Ci)||di.push(t),mi())};function Ln(A){return function(A,e){Y().__VUE__=!0;const{insert:t,remove:i,patchProp:o,forcePatchProp:n,createElement:r,createText:c,createComment:l,setText:I,setElementText:E,parentNode:d,nextSibling:C,setScopeId:B=g,insertStaticContent:Q}=A,p=(A,e,t,i=null,o=null,n=null,r=void 0,s=null,a=!!e.dynamicChildren)=>{if(A===e)return;A&&!sr(A,e)&&(i=eA(A),z(A,o,n,!0),A=null),-2===e.patchFlag&&(a=!1,e.dynamicChildren=null);const{type:g,ref:c,shapeFlag:l}=e;switch(g){case Wn:f(A,e,t,i);break;case zn:m(A,e,t,i);break;case Zn:null==A&&y(e,t,i,r);break;case Kn:U(A,e,t,i,o,n,r,s,a);break;default:1&l?S(A,e,t,i,o,n,r,s,a):6&l?x(A,e,t,i,o,n,r,s,a):(64&l||128&l)&&g.process(A,e,t,i,o,n,r,s,a,oA)}null!=c&&o&&Gn(c,A&&A.ref,n,e||A,!e)},f=(A,e,i,o)=>{if(null==A)t(e.el=c(e.children),i,o);else{const t=e.el=A.el;e.children!==A.children&&I(t,e.children)}},m=(A,e,i,o)=>{null==A?t(e.el=l(e.children||""),i,o):e.el=A.el},y=(A,e,t,i)=>{[A.el,A.anchor]=Q(A.children,e,t,i,A.el,A.anchor)},v=({el:A,anchor:e},i,o)=>{let n;for(;A&&A!==e;)n=C(A),t(A,i,o),A=n;t(e,i,o)},w=({el:A,anchor:e})=>{let t;for(;A&&A!==e;)t=C(A),i(A),A=t;i(e)},S=(A,e,t,i,o,n,r,s,a)=>{"svg"===e.type?r="svg":"math"===e.type&&(r="mathml"),null==A?M(e,t,i,o,n,r,s,a):b(A,e,o,n,r,s,a)},M=(A,e,i,n,s,a,g,c)=>{let l,I;const{props:u,shapeFlag:d,transition:h,dirs:C}=A;if(l=A.el=r(A.type,a,u&&u.is,u),8&d?E(l,A.children):16&d&&T(A.children,l,null,n,s,Un(A,a),g,c),C&&oo(A,null,n,"created"),_(l,A,A.scopeId,g,n),u){for(const e in u)"value"===e||R(e)||o(l,e,null,u[e],a,A.children,n,s,AA);"value"in u&&o(l,"value",null,u.value,a),(I=u.onVnodeBeforeMount)&&pr(I,n,A)}Object.defineProperty(l,"__vueParentComponent",{value:n,enumerable:!1}),C&&oo(A,null,n,"beforeMount");const B=function(A,e){return(!A||A&&!A.pendingBranch)&&e&&!e.persisted}(s,h);B&&h.beforeEnter(l),t(l,e,i),((I=u&&u.onVnodeMounted)||B||C)&&kn(()=>{I&&pr(I,n,A),B&&h.enter(l),C&&oo(A,null,n,"mounted")},s)},_=(A,e,t,i,o)=>{if(t&&B(A,t),i)for(let n=0;n{for(let g=a;g{const c=e.el=A.el;let{patchFlag:l,dynamicChildren:I,dirs:u}=e;l|=16&A.patchFlag;const d=A.props||s,h=e.props||s;let C;if(t&&Fn(t,!1),(C=h.onVnodeBeforeUpdate)&&pr(C,t,e,A),u&&oo(e,A,t,"beforeUpdate"),t&&Fn(t,!0),I?k(A.dynamicChildren,I,c,t,i,Un(e,r),a):g||V(A,e,c,null,t,i,Un(e,r),a,!1),l>0){if(16&l)L(c,e,d,h,t,i,r);else if(2&l&&d.class!==h.class&&o(c,"class",null,h.class,r),4&l&&o(c,"style",d.style,h.style,r),8&l){const s=e.dynamicProps;for(let e=0;e{C&&pr(C,t,e,A),u&&oo(e,A,t,"updated")},i)},k=(A,e,t,i,o,n,r)=>{for(let s=0;s{if(t!==i){if(t!==s)for(const n in t)R(n)||n in i||o(A,n,t[n],null,g,e.children,r,a,AA);for(const s in i){if(R(s))continue;const c=i[s],l=t[s];(c!==l&&"value"!==s||n&&n(A,s))&&o(A,s,l,c,g,e.children,r,a,AA)}"value"in i&&o(A,"value",t.value,i.value,g)}},U=(A,e,i,o,n,r,s,a,g)=>{const l=e.el=A?A.el:c(""),I=e.anchor=A?A.anchor:c("");let{patchFlag:u,dynamicChildren:E,slotScopeIds:d}=e;d&&(a=a?a.concat(d):d),null==A?(t(l,i,o),t(I,i,o),T(e.children||[],i,I,n,r,s,a,g)):u>0&&64&u&&E&&A.dynamicChildren?(k(A.dynamicChildren,E,i,n,r,s,a),(null!=e.key||n&&e===n.subTree)&&On(A,e,!0)):V(A,e,i,I,n,r,s,a,g)},x=(A,e,t,i,o,n,r,s,a)=>{e.slotScopeIds=s,null==A?512&e.shapeFlag?o.ctx.activate(e,t,i,r,a):P(e,t,i,o,n,r,a):J(A,e,a)},P=(A,e,t,i,o,n,r)=>{const a=A.component=function(A,e,t){const i=A.type,o=(e?e.appContext:A.appContext)||fr,n={uid:mr++,vnode:A,type:i,parent:e,appContext:o,get renderer(){return"app"===i.mpType?"app":this.$pageInstance&&this.$pageInstance==n?"page":"component"},root:null,next:null,subTree:null,effect:null,update:null,scope:new De(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(o.provides),accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Dn(i,o),emitsOptions:_i(i,o),emit:null,emitted:null,propsDefaults:s,inheritAttrs:i.inheritAttrs,ctx:s,data:s,props:s,attrs:s,slots:s,refs:s,setupState:s,setupContext:null,attrsProxy:null,slotsProxy:null,suspense:t,suspenseId:t?t.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,bda:null,da:null,ba:null,a:null,rtg:null,rtc:null,ec:null,sp:null};n.ctx={_:n},n.root=e?e.root:n,n.emit=Mi.bind(null,n),n.$pageInstance=e&&e.$pageInstance,A.ce&&A.ce(n);return n}(A,i,o);if(fo(A)&&(a.ctx.renderer=oA),function(A,e=!1){e&&wr(e);const{props:t,children:i}=A.vnode,o=Rr(A);(function(A,e,t,i=!1){const o={},n={};O(n,ar,1),A.propsDefaults=Object.create(null),mn(A,e,o,n);for(const r in A.propsOptions[0])r in o||(o[r]=void 0);t?A.props=i?o:bt(o):A.type.props?A.props=o:A.props=n,A.attrs=n})(A,t,o,e),((A,e)=>{if(32&A.vnode.shapeFlag){const t=e._;t?(A.slots=xt(e),O(e,"_",t)):Nn(e,A.slots={})}else A.slots={},e&&bn(A,e);O(A.slots,ar,1)})(A,i);const n=o?function(A,e){const t=A.type;A.accessCache=Object.create(null),A.proxy=Pt(new Proxy(A.ctx,Xo));const{setup:i}=t;if(i){const t=A.setupContext=i.length>1?Gr(A):null,o=Sr(A);ke();const n=si(i,A,0,[A.props,t]);if(Le(),o(),D(n)){if(n.then(Mr,Mr),e)return n.then(t=>{Nr(A,t,e)}).catch(e=>{gi(e,A,0)});A.asyncDep=n}else Nr(A,n,e)}else br(A,e)}(A,e):void 0;e&&wr(!1)}(a),a.asyncDep){if(o&&o.registerDep(a,H),!A.el){const A=a.subTree=Ir(zn);m(null,A,e,t)}}else H(a,A,e,t,o,n,r)},J=(A,e,t)=>{const i=e.component=A.component;if(function(A,e,t){const{props:i,children:o,component:n}=A,{props:r,children:s,patchFlag:a}=e,g=n.emitsOptions;if(e.dirs||e.transition)return!0;if(!(t&&a>=0))return!(!o&&!s||s&&s.$stable)||i!==r&&(i?!r||Pi(i,r,g):!!r);if(1024&a)return!0;if(16&a)return i?Pi(i,r,g):!!r;if(8&a){const A=e.dynamicProps;for(let e=0;eEi&&ui.splice(e,1)}(i.update),i.effect.dirty=!0,i.update()}else e.el=A.el,i.vnode=e},H=(A,e,t,i,o,n,r)=>{const s=()=>{if(A.isMounted){let{next:e,bu:t,u:i,parent:a,vnode:g}=A;{const t=xn(A);if(t)return e&&(e.el=g.el,q(A,e,r)),void t.asyncDep.then(()=>{A.isUnmounted||s()})}let c,l=e;Fn(A,!1),e?(e.el=g.el,q(A,e,r)):e=g,t&&F(t),(c=e.props&&e.props.onVnodeBeforeUpdate)&&pr(c,a,e,g),Fn(A,!0);const I=Fi(A),u=A.subTree;A.subTree=I,p(u,I,d(u.el),eA(u),A,o,n),e.el=I.el,null===l&&function({vnode:A,parent:e},t){for(;e;){const i=e.subTree;if(i.suspense&&i.suspense.activeBranch===A&&(i.el=A.el),i!==A)break;(A=e.vnode).el=t,e=e.parent}}(A,I.el),i&&kn(i,o),(c=e.props&&e.props.onVnodeUpdated)&&kn(()=>pr(c,a,e,g),o)}else{let r;const{el:s,props:a}=e,{bm:g,m:c,parent:l}=A,I=Bo(e);if(Fn(A,!1),g&&F(g),!I&&(r=a&&a.onVnodeBeforeMount)&&pr(r,l,e),Fn(A,!0),s&&rA){const t=()=>{A.subTree=Fi(A),rA(s,A.subTree,A,o,null)};I?e.type.__asyncLoader().then(()=>!A.isUnmounted&&t()):t()}else{const r=A.subTree=Fi(A);p(null,r,t,i,A,o,n),e.el=r.el}if(c&&kn(c,o),!I&&(r=a&&a.onVnodeMounted)){const A=e;kn(()=>pr(r,l,A),o)}(256&e.shapeFlag||l&&Bo(l.vnode)&&256&l.vnode.shapeFlag)&&(A.ba&&bo(A.ba),A.a&&kn(A.a,o)),A.isMounted=!0,e=t=i=null}},a=A.effect=new Se(s,g,()=>fi(c),A.scope),c=A.update=()=>{a.dirty&&a.run()};c.id=A.uid,Fn(A,!0),c()},q=(A,e,t)=>{e.component=A;const i=A.vnode.props;A.vnode=e,A.next=null,function(A,e,t,i){const{props:o,attrs:n,vnode:{patchFlag:r}}=A,s=xt(o),[a]=A.propsOptions;let g=!1;if(!(i||r>0)||16&r){let i;mn(A,e,o,n)&&(g=!0);for(const n in s)e&&(h(e,n)||(i=G(n))!==n&&h(e,i))||(a?!t||void 0===t[n]&&void 0===t[i]||(o[n]=yn(a,s,n,void 0,A,!0)):delete o[n]);if(n!==s)for(const A in n)e&&h(e,A)||(delete n[A],g=!0)}else if(8&r){const t=A.vnode.dynamicProps;for(let i=0;i{const{vnode:i,slots:o}=A;let n=!0,r=s;if(32&i.shapeFlag){const A=e._;A?t&&1===A?n=!1:(u(o,e),t||1!==A||delete o._):(n=!e.$stable,Nn(e,o)),r=e}else e&&(bn(A,e),r={default:1});if(n)for(const s in o)Rn(s)||null!=r[s]||delete o[s]})(A,e.children,t),ke(),yi(A),Le()},V=(A,e,t,i,o,n,r,s,a=!1)=>{const g=A&&A.children,c=A?A.shapeFlag:0,l=e.children,{patchFlag:I,shapeFlag:u}=e;if(I>0){if(128&I)return void K(g,l,t,i,o,n,r,s,a);if(256&I)return void j(g,l,t,i,o,n,r,s,a)}8&u?(16&c&&AA(g,o,n),l!==g&&E(t,l)):16&c?16&u?K(g,l,t,i,o,n,r,s,a):AA(g,o,n,!0):(8&c&&E(t,""),16&u&&T(l,t,i,o,n,r,s,a))},j=(A,e,t,i,o,n,r,s,g)=>{e=e||a;const c=(A=A||a).length,l=e.length,I=Math.min(c,l);let u;for(u=0;ul?AA(A,o,n,!0,!1,I):T(e,t,i,o,n,r,s,g,I)},K=(A,e,t,i,o,n,r,s,g)=>{let c=0;const l=e.length;let I=A.length-1,u=l-1;for(;c<=I&&c<=u;){const i=A[c],a=e[c]=g?Cr(e[c]):hr(e[c]);if(!sr(i,a))break;p(i,a,t,null,o,n,r,s,g),c++}for(;c<=I&&c<=u;){const i=A[I],a=e[u]=g?Cr(e[u]):hr(e[u]);if(!sr(i,a))break;p(i,a,t,null,o,n,r,s,g),I--,u--}if(c>I){if(c<=u){const A=u+1,a=Au)for(;c<=I;)z(A[c],o,n,!0),c++;else{const E=c,d=c,h=new Map;for(c=d;c<=u;c++){const A=e[c]=g?Cr(e[c]):hr(e[c]);null!=A.key&&h.set(A.key,c)}let C,B=0;const Q=u-d+1;let f=!1,m=0;const y=new Array(Q);for(c=0;c=Q){z(i,o,n,!0);continue}let a;if(null!=i.key)a=h.get(i.key);else for(C=d;C<=u;C++)if(0===y[C-d]&&sr(i,e[C])){a=C;break}void 0===a?z(i,o,n,!0):(y[a-d]=c+1,a>=m?m=a:f=!0,p(i,e[a],t,null,o,n,r,s,g),B++)}const D=f?function(A){const e=A.slice(),t=[0];let i,o,n,r,s;const a=A.length;for(i=0;i>1,A[t[s]]0&&(e[i]=t[n-1]),t[n]=i)}}n=t.length,r=t[n-1];for(;n-- >0;)t[n]=r,r=e[r];return t}(y):a;for(C=D.length-1,c=Q-1;c>=0;c--){const A=d+c,a=e[A],I=A+1{const{el:r,type:s,transition:a,children:g,shapeFlag:c}=A;if(6&c)return void W(A.component.subTree,e,i,o);if(128&c)return void A.suspense.move(e,i,o);if(64&c)return void s.move(A,e,i,oA);if(s===Kn){t(r,e,i);for(let A=0;Aa.enter(r),n);else{const{leave:A,delayLeave:o,afterLeave:n}=a,s=()=>t(r,e,i),g=()=>{A(r,()=>{s(),n&&n()})};o?o(r,s,g):g()}else t(r,e,i)},z=(A,e,t,i=!1,o=!1)=>{const{type:n,props:r,ref:s,children:a,dynamicChildren:g,shapeFlag:c,patchFlag:l,dirs:I}=A;if(null!=s&&Gn(s,null,t,A,!0),256&c)return void e.ctx.deactivate(A);const u=1&c&&I,E=!Bo(A);let d;if(E&&(d=r&&r.onVnodeBeforeUnmount)&&pr(d,e,A),6&c)$(A.component,t,i);else{if(128&c)return void A.suspense.unmount(t,i);u&&oo(A,null,e,"beforeUnmount"),64&c?A.type.remove(A,e,t,o,oA,i):g&&(n!==Kn||l>0&&64&l)?AA(g,e,t,!1,!0):(n===Kn&&384&l||!o&&16&c)&&AA(a,e,t),i&&Z(A)}(E&&(d=r&&r.onVnodeUnmounted)||u)&&kn(()=>{d&&pr(d,e,A),u&&oo(A,null,e,"unmounted")},t)},Z=A=>{const{type:e,el:t,anchor:o,transition:n}=A;if(e===Kn)return void X(t,o);if(e===Zn)return void w(A);const r=()=>{i(t),n&&!n.persisted&&n.afterLeave&&n.afterLeave()};if(1&A.shapeFlag&&n&&!n.persisted){const{leave:e,delayLeave:i}=n,o=()=>e(t,r);i?i(A.el,r,o):o()}else r()},X=(A,e)=>{let t;for(;A!==e;)t=C(A),i(A),A=t;i(e)},$=(A,e,t)=>{const{bum:i,scope:o,update:n,subTree:r,um:s}=A;i&&F(i),o.stop(),n&&(n.active=!1,z(r,A,e,t)),s&&kn(s,e),kn(()=>{A.isUnmounted=!0},e),e&&e.pendingBranch&&!e.isUnmounted&&A.asyncDep&&!A.asyncResolved&&A.suspenseId===e.pendingId&&(e.deps--,0===e.deps&&e.resolve())},AA=(A,e,t,i=!1,o=!1,n=0)=>{for(let r=n;r6&A.shapeFlag?eA(A.component.subTree):128&A.shapeFlag?A.suspense.next():C(A.anchor||A.el);let tA=!1;const iA=(A,e,t)=>{null==A?e._vnode&&z(e._vnode,null,null,!0):p(e._vnode||null,A,e,null,null,null,t),tA||(tA=!0,yi(),Di(),tA=!1),e._vnode=A},oA={p:p,um:z,m:W,r:Z,mt:P,mc:T,pc:V,pbc:k,n:eA,o:A};let nA,rA;e&&([nA,rA]=e(oA));return{render:iA,hydrate:nA,createApp:Cn(iA,nA)}}(A)}function Un({type:A,props:e},t){return"svg"===t&&"foreignObject"===A||"mathml"===t&&"annotation-xml"===A&&e&&e.encoding&&e.encoding.includes("html")?void 0:t}function Fn({effect:A,update:e},t){A.allowRecurse=e.allowRecurse=t}function On(A,e,t=!1){const i=A.children,o=e.children;if(C(i)&&C(o))for(let n=0;nA&&(A.disabled||""===A.disabled),Yn=A=>"undefined"!=typeof SVGElement&&A instanceof SVGElement,Jn=A=>"function"==typeof MathMLElement&&A instanceof MathMLElement,Hn=(A,e)=>{const t=A&&A.to;if(f(t)){if(e){return e(t)}return null}return t};function qn(A,e,t,{o:{insert:i},m:o},n=2){0===n&&i(A.targetAnchor,e,t);const{el:r,anchor:s,shapeFlag:a,children:g,props:c}=A,l=2===n;if(l&&i(r,e,t),(!l||Pn(c))&&16&a)for(let I=0;I{16&B&&c(Q,A,e,o,n,r,s,a)};C?h(t,g):l&&h(l,I)}else{e.el=A.el;const i=e.anchor=A.anchor,c=e.target=A.target,u=e.targetAnchor=A.targetAnchor,d=Pn(A.props),h=d?t:c,B=d?i:u;if("svg"===r||Yn(c)?r="svg":("mathml"===r||Jn(c))&&(r="mathml"),p?(I(A.dynamicChildren,p,h,o,n,r,s),On(A,e,!0)):a||l(A,e,h,B,o,n,r,s,!1),C)d?e.props&&A.props&&e.props.to!==A.props.to&&(e.props.to=A.props.to):qn(e,t,i,g,1);else if((e.props&&e.props.to)!==(A.props&&A.props.to)){const A=e.target=Hn(e.props,E);A&&qn(e,A,null,g,0)}else d&&qn(e,c,u,g,1)}jn(e)},remove(A,e,t,i,{um:o,o:{remove:n}},r){const{shapeFlag:s,children:a,anchor:g,targetAnchor:c,target:l,props:I}=A;if(l&&n(c),r&&n(g),16&s){const A=r||!Pn(I);for(let i=0;i0?$n||a:null,Xn.pop(),$n=Xn[Xn.length-1]||null,er>0&&$n&&$n.push(A),A}function or(A,e,t,i,o,n){return ir(lr(A,e,t,i,o,n,!0))}function nr(A,e,t,i,o){return ir(Ir(A,e,t,i,o,!0))}function rr(A){return!!A&&!0===A.__v_isVNode}function sr(A,e){return A.type===e.type&&A.key===e.key}const ar="__vInternal",gr=({key:A})=>null!=A?A:null,cr=({ref:A,ref_key:e,ref_for:t})=>("number"==typeof A&&(A=""+A),null!=A?f(A)||jt(A)||p(A)?{i:Ni,r:A,k:e,f:!!t}:A:null);function lr(A,e=null,t=null,i=0,o=null,n=(A===Kn?0:1),r=!1,s=!1){const a={__v_isVNode:!0,__v_skip:!0,type:A,props:e,key:e&&gr(e),ref:e&&cr(e),scopeId:bi,slotScopeIds:null,children:t,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:n,patchFlag:i,dynamicProps:o,dynamicChildren:null,appContext:null,ctx:Ni};return s?(Br(a,t),128&n&&A.normalize(a)):t&&(a.shapeFlag|=f(t)?8:16),er>0&&!r&&$n&&(a.patchFlag>0||6&n)&&32!==a.patchFlag&&$n.push(a),a}const Ir=function(A,e=null,t=null,i=0,o=null,n=!1){A&&A!==Hi||(A=zn);if(rr(A)){const i=ur(A,e,!0);return t&&Br(i,t),er>0&&!n&&$n&&(6&i.shapeFlag?$n[$n.indexOf(A)]=i:$n.push(i)),i.patchFlag|=-2,i}r=A,p(r)&&"__vccOpts"in r&&(A=A.__vccOpts);var r;if(e){e=function(A){return A?Ot(A)||ar in A?u({},A):A:null}(e);let{class:A,style:t}=e;A&&!f(A)&&(e.class=XA(A)),y(t)&&(Ot(t)&&!C(t)&&(t=u({},t)),e.style=ZA(t))}const s=f(A)?1:Ki(A)?128:(A=>A.__isTeleport)(A)?64:y(A)?4:p(A)?2:0;return lr(A,e,t,i,o,s,n,!0)};function ur(A,e,t=!1){const{props:i,ref:o,patchFlag:n,children:r}=A,s=e?Qr(i||{},e):i;return{__v_isVNode:!0,__v_skip:!0,type:A.type,props:s,key:s&&gr(s),ref:e&&e.ref?t&&o?C(o)?o.concat(cr(e)):[o,cr(e)]:cr(e):o,scopeId:A.scopeId,slotScopeIds:A.slotScopeIds,children:r,target:A.target,targetAnchor:A.targetAnchor,staticCount:A.staticCount,shapeFlag:A.shapeFlag,patchFlag:e&&A.type!==Kn?-1===n?16:16|n:n,dynamicProps:A.dynamicProps,dynamicChildren:A.dynamicChildren,appContext:A.appContext,dirs:A.dirs,transition:A.transition,component:A.component,suspense:A.suspense,ssContent:A.ssContent&&ur(A.ssContent),ssFallback:A.ssFallback&&ur(A.ssFallback),el:A.el,anchor:A.anchor,ctx:A.ctx,ce:A.ce}}function Er(A=" ",e=0){return Ir(Wn,null,A,e)}function dr(A="",e=!1){return e?(Ar(),nr(zn,null,A)):Ir(zn,null,A)}function hr(A){return null==A||"boolean"==typeof A?Ir(zn):C(A)?Ir(Kn,null,A.slice()):"object"==typeof A?Cr(A):Ir(Wn,null,String(A))}function Cr(A){return null===A.el&&-1!==A.patchFlag||A.memo?A:ur(A)}function Br(A,e){let t=0;const{shapeFlag:i}=A;if(null==e)e=null;else if(C(e))t=16;else if("object"==typeof e){if(65&i){const t=e.default;return void(t&&(t._c&&(t._d=!1),Br(A,t()),t._c&&(t._d=!0)))}{t=32;const i=e._;i||ar in e?3===i&&Ni&&(1===Ni.slots._?e._=1:(e._=2,A.patchFlag|=1024)):e._ctx=Ni}}else p(e)?(e={default:e,_ctx:Ni},t=32):(e=String(e),64&i?(t=16,e=[Er(e)]):t=8);A.children=e,A.shapeFlag|=t}function Qr(...A){const e={};for(let t=0;tyr||Ni;let vr,wr;{const A=Y(),e=(e,t)=>{let i;return(i=A[e])||(i=A[e]=[]),i.push(t),A=>{i.length>1?i.forEach(e=>e(A)):i[0](A)}};vr=e("__VUE_INSTANCE_SETTERS__",A=>yr=A),wr=e("__VUE_SSR_SETTERS__",A=>Tr=A)}const Sr=A=>{const e=yr;return vr(A),A.scope.on(),()=>{A.scope.off(),vr(e)}},Mr=()=>{yr&&yr.scope.off(),vr(null)};function Rr(A){return 4&A.vnode.shapeFlag}let _r,Tr=!1;function Nr(A,e,t){p(e)?A.type.__ssrInlineRender?A.ssrRender=e:A.render=e:y(e)&&(A.setupState=Ai(e)),br(A,t)}function br(A,e,t){const i=A.type;if(!A.render){if(!e&&_r&&!i.render){const e=i.template||sn(A).template;if(e){const{isCustomElement:t,compilerOptions:o}=A.appContext.config,{delimiters:n,compilerOptions:r}=i,s=u(u({isCustomElement:t,delimiters:n},o),r);i.render=_r(e,s)}}A.render=i.render||g}{const e=Sr(A);ke();try{on(A)}finally{Le(),e()}}}function Gr(A){const e=e=>{A.exposed=e||{}};return{get attrs(){return function(A){return A.attrsProxy||(A.attrsProxy=new Proxy(A.attrs,{get:(e,t)=>(Ve(A,0,"$attrs"),e[t])}))}(A)},slots:A.slots,emit:A.emit,expose:e}}function kr(A){if(A.exposed)return A.exposeProxy||(A.exposeProxy=new Proxy(Ai(Pt(A.exposed)),{get:(e,t)=>t in e?e[t]:t in zo?zo[t](A):void 0,has:(A,e)=>e in A||e in zo}))}function Lr(A,e=!0){return p(A)?A.displayName||A.name:A.name||e&&A.__name}const Ur=(A,e)=>{const t=function(A,e,t=!1){let i,o;const n=p(A);return n?(i=A,o=g):(i=A.get,o=A.set),new Ht(i,o,n||!o,t)}(A,0,Tr);return t};function Fr(A,e,t=s){const i=Dr(),o=N(e),n=G(e),r=new ei((r,s)=>{let a;return $i(()=>{const t=A[e];U(a,t)&&(a=t,s())},null,{flush:"sync"}),{get:()=>(r(),t.get?t.get(a):a),set(A){const r=i.vnode.props;r&&(e in r||o in r||n in r)&&(`onUpdate:${e}`in r||`onUpdate:${o}`in r||`onUpdate:${n}`in r)||!U(A,a)||(a=A,s()),i.emit(`update:${e}`,t.set?t.set(A):A)}}});const a="modelValue"===e?"modelModifiers":`${e}Modifiers`;return r[Symbol.iterator]=()=>{let e=0;return{next:()=>e<2?{value:e++?A[a]||{}:r,done:!1}:{done:!0}}},r}function Or(A,e,t){const i=arguments.length;return 2===i?y(e)&&!C(e)?rr(e)?Ir(A,null,[e]):Ir(A,e):Ir(A,null,e):(i>3?t=Array.prototype.slice.call(arguments,2):3===i&&rr(t)&&(t=[t]),Ir(A,e,t))}const xr="3.4.21",Pr="undefined"!=typeof document?document:null,Yr=Pr&&Pr.createElement("template"),Jr={insert:(A,e,t)=>{e.insertBefore(A,t||null)},remove:A=>{const e=A.parentNode;e&&e.removeChild(A)},createElement:(A,e,t,i)=>{const o="svg"===e?Pr.createElementNS("http://www.w3.org/2000/svg",A):"mathml"===e?Pr.createElementNS("http://www.w3.org/1998/Math/MathML",A):t?Pr.createElement(A,{is:t}):Pr.createElement(A);return"select"===A&&i&&null!=i.multiple&&o.setAttribute("multiple",i.multiple),o},createText:A=>Pr.createTextNode(A),createComment:A=>Pr.createComment(A),setText:(A,e)=>{A.nodeValue=e},setElementText:(A,e)=>{A.textContent=e},parentNode:A=>A.parentNode,nextSibling:A=>A.nextSibling,querySelector:A=>Pr.querySelector(A),setScopeId(A,e){A.setAttribute(e,"")},insertStaticContent(A,e,t,i,o,n){const r=t?t.previousSibling:e.lastChild;if(o&&(o===n||o.nextSibling))for(;e.insertBefore(o.cloneNode(!0),t),o!==n&&(o=o.nextSibling););else{Yr.innerHTML="svg"===i?`${A}`:"mathml"===i?`${A}`:A;const o=Yr.content;if("svg"===i||"mathml"===i){const A=o.firstChild;for(;A.firstChild;)o.appendChild(A.firstChild);o.removeChild(A)}e.insertBefore(o,t)}return[r?r.nextSibling:e.firstChild,t?t.previousSibling:e.lastChild]}},Hr="transition",qr="animation",Vr=Symbol("_vtc"),jr=(A,{slots:e})=>Or(go,function(A){const e={};for(const u in A)u in Kr||(e[u]=A[u]);if(!1===A.css)return e;const{name:t="v",type:i,duration:o,enterFromClass:n=`${t}-enter-from`,enterActiveClass:r=`${t}-enter-active`,enterToClass:s=`${t}-enter-to`,appearFromClass:a=n,appearActiveClass:g=r,appearToClass:c=s,leaveFromClass:l=`${t}-leave-from`,leaveActiveClass:I=`${t}-leave-active`,leaveToClass:E=`${t}-leave-to`}=A,d=function(A){if(null==A)return null;if(y(A))return[Zr(A.enter),Zr(A.leave)];{const e=Zr(A);return[e,e]}}(o),h=d&&d[0],C=d&&d[1],{onBeforeEnter:B,onEnter:Q,onEnterCancelled:p,onLeave:f,onLeaveCancelled:m,onBeforeAppear:D=B,onAppear:v=Q,onAppearCancelled:w=p}=e,S=(A,e,t)=>{$r(A,e?c:s),$r(A,e?g:r),t&&t()},M=(A,e)=>{A._isLeaving=!1,$r(A,l),$r(A,E),$r(A,I),e&&e()},R=A=>(e,t)=>{const o=A?v:Q,r=()=>S(e,A,t);Wr(o,[e,r]),As(()=>{$r(e,A?a:n),Xr(e,A?c:s),zr(o)||ts(e,i,h,r)})};return u(e,{onBeforeEnter(A){Wr(B,[A]),Xr(A,n),Xr(A,r)},onBeforeAppear(A){Wr(D,[A]),Xr(A,a),Xr(A,g)},onEnter:R(!1),onAppear:R(!0),onLeave(A,e){A._isLeaving=!0;const t=()=>M(A,e);Xr(A,l),document.body.offsetHeight,Xr(A,I),As(()=>{A._isLeaving&&($r(A,l),Xr(A,E),zr(f)||ts(A,i,C,t))}),Wr(f,[A,t])},onEnterCancelled(A){S(A,!1),Wr(p,[A])},onAppearCancelled(A){S(A,!0),Wr(w,[A])},onLeaveCancelled(A){M(A),Wr(m,[A])}})}(A),e);jr.displayName="Transition";const Kr={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String};jr.props=u({},ao,Kr);const Wr=(A,e=[])=>{C(A)?A.forEach(A=>A(...e)):A&&A(...e)},zr=A=>!!A&&(C(A)?A.some(A=>A.length>1):A.length>1);function Zr(A){const e=(A=>{const e=f(A)?Number(A):NaN;return isNaN(e)?A:e})(A);return e}function Xr(A,e){e.split(/\s+/).forEach(e=>e&&A.classList.add(e)),(A[Vr]||(A[Vr]=new Set)).add(e)}function $r(A,e){e.split(/\s+/).forEach(e=>e&&A.classList.remove(e));const t=A[Vr];t&&(t.delete(e),t.size||(A[Vr]=void 0))}function As(A){requestAnimationFrame(()=>{requestAnimationFrame(A)})}let es=0;function ts(A,e,t,i){const o=A._endId=++es,n=()=>{o===A._endId&&i()};if(t)return setTimeout(n,t);const{type:r,timeout:s,propCount:a}=function(A,e){const t=window.getComputedStyle(A),i=A=>(t[A]||"").split(", "),o=i(`${Hr}Delay`),n=i(`${Hr}Duration`),r=is(o,n),s=i(`${qr}Delay`),a=i(`${qr}Duration`),g=is(s,a);let c=null,l=0,I=0;e===Hr?r>0&&(c=Hr,l=r,I=n.length):e===qr?g>0&&(c=qr,l=g,I=a.length):(l=Math.max(r,g),c=l>0?r>g?Hr:qr:null,I=c?c===Hr?n.length:a.length:0);const u=c===Hr&&/\b(transform|all)(,|$)/.test(i(`${Hr}Property`).toString());return{type:c,timeout:l,propCount:I,hasTransform:u}}(A,e);if(!r)return i();const g=r+"end";let c=0;const l=()=>{A.removeEventListener(g,I),n()},I=e=>{e.target===A&&++c>=a&&l()};setTimeout(()=>{cos(e)+os(A[t])))}function os(A){return"auto"===A?0:1e3*Number(A.slice(0,-1).replace(",","."))}const ns=Symbol("_vod"),rs=Symbol("_vsh"),ss={beforeMount(A,{value:e},{transition:t}){A[ns]="none"===A.style.display?"":A.style.display,t&&e?t.beforeEnter(A):as(A,e)},mounted(A,{value:e},{transition:t}){t&&e&&t.enter(A)},updated(A,{value:e,oldValue:t},{transition:i}){!e!=!t&&(i?e?(i.beforeEnter(A),as(A,!0),i.enter(A)):i.leave(A,()=>{as(A,!1)}):as(A,e))},beforeUnmount(A,{value:e}){as(A,e)}};function as(A,e){A.style.display=e?A[ns]:"none",A[rs]=!e}const gs=Symbol(""),cs=/(^|;)\s*display\s*:/;const ls=/\s*!important$/;function Is(A,e,t){if(C(t))t.forEach(t=>Is(A,e,t));else if(null==t&&(t=""),t=ms(t),e.startsWith("--"))A.setProperty(e,t);else{const i=function(A,e){const t=Es[e];if(t)return t;let i=N(e);if("filter"!==i&&i in A)return Es[e]=i;i=k(i);for(let o=0;oA.replace(ie,(A,e)=>{if(!e)return A;if(1===ps)return`${e}${Qs}`;const t=function(A,e){const t=Math.pow(10,e+1),i=Math.floor(A*t);return 10*Math.round(i/10)/t}(parseFloat(e)*ps,fs);return 0===t?"0":`${t}${Qs}`}));var Qs,ps,fs;const ms=A=>f(A)?Bs(A):A,ys="http://www.w3.org/1999/xlink";const Ds=Symbol("_vei");function vs(A,e,t,i,o=null){const n=A[Ds]||(A[Ds]={}),r=n[e];if(i&&r)r.value=i;else{const[t,s]=function(A){let e;if(ws.test(A)){let t;for(e={};t=A.match(ws);)A=A.slice(0,A.length-t[0].length),e[t[0].toLowerCase()]=!0}const t=":"===A[2]?A.slice(3):G(A.slice(2));return[t,e]}(e);if(i){const r=n[e]=function(A,e){const t=A=>{if(A._vts){if(A._vts<=t.attached)return}else A._vts=Date.now();const i=e&&e.proxy,o=i&&i.$nne,{value:n}=t;if(o&&C(n)){const t=_s(A,n);for(let i=0;iSs||(Ms.then(()=>Ss=0),Ss=Date.now());function _s(A,e){if(C(e)){const t=A.stopImmediatePropagation;return A.stopImmediatePropagation=()=>{t.call(A),A._stopped=!0},e.map(A=>{const e=e=>!e._stopped&&A&&A(e);return e.__wwe=A.__wwe,e})}return e}const Ts=A=>111===A.charCodeAt(0)&&110===A.charCodeAt(1)&&A.charCodeAt(2)>96&&A.charCodeAt(2)<123;const Ns=["ctrl","shift","alt","meta"],bs={stop:A=>A.stopPropagation(),prevent:A=>A.preventDefault(),self:A=>A.target!==A.currentTarget,ctrl:A=>!A.ctrlKey,shift:A=>!A.shiftKey,alt:A=>!A.altKey,meta:A=>!A.metaKey,left:A=>"button"in A&&0!==A.button,middle:A=>"button"in A&&1!==A.button,right:A=>"button"in A&&2!==A.button,exact:(A,e)=>Ns.some(t=>A[`${t}Key`]&&!e.includes(t))},Gs=(A,e)=>{const t=A._withMods||(A._withMods={}),i=e.join(".");return t[i]||(t[i]=(t,...i)=>{for(let A=0;A{const t=A._withKeys||(A._withKeys={}),i=e.join(".");return t[i]||(t[i]=t=>{if(!("key"in t))return;const i=G(t.key);return e.some(A=>A===i||ks[A]===i)?A(t):void 0})},Us=u({patchProp:(A,e,t,i,o,n,r,s,a)=>{if(0===e.indexOf("change:"))return function(A,e,t,i=null){if(!t||!i)return;const o=e.replace("change:",""),{attrs:n}=i,r=n[o],s=(A.__wxsProps||(A.__wxsProps={}))[o];if(s===r)return;A.__wxsProps[o]=r;const a=i.proxy;pi(()=>{t(r,s,a.$gcd(a,!0),a.$gcd(a,!1))})}(A,e,i,r);const g="svg"===o;"class"===e?function(A,e,t){const{__wxsAddClass:i,__wxsRemoveClass:o}=A;o&&o.length&&(e=(e||"").split(/\s+/).filter(A=>-1===o.indexOf(A)).join(" "),o.length=0),i&&i.length&&(e=(e||"")+" "+i.join(" "));const n=A[Vr];n&&(e=(e?[e,...n]:[...n]).join(" ")),null==e?A.removeAttribute("class"):t?A.setAttribute("class",e):A.className=e}(A,i,g):"style"===e?function(A,e,t){const i=A.style,o=f(t);let n=!1;if(t&&!o){if(e)if(f(e))for(const A of e.split(";")){const e=A.slice(0,A.indexOf(":")).trim();null==t[e]&&Is(i,e,"")}else for(const A in e)null==t[A]&&Is(i,A,"");for(const A in t)"display"===A&&(n=!0),Is(i,A,t[A])}else if(o){if(e!==t){const A=i[gs];A&&(t+=";"+A),i.cssText=t,n=cs.test(t)}}else e&&A.removeAttribute("style");ns in A&&(A[ns]=n?i.display:"",A[rs]&&(i.display="none"));const{__wxsStyle:r}=A;if(r)for(const s in r)Is(i,s,r[s])}(A,t,i):l(e)?I(e)||vs(A,e,0,i,r):("."===e[0]?(e=e.slice(1),1):"^"===e[0]?(e=e.slice(1),0):function(A,e,t,i){if(i)return"innerHTML"===e||"textContent"===e||!!(e in A&&Ts(e)&&p(t));if("spellcheck"===e||"draggable"===e||"translate"===e)return!1;if("form"===e)return!1;if("list"===e&&"INPUT"===A.tagName)return!1;if("type"===e&&"TEXTAREA"===A.tagName)return!1;if("width"===e||"height"===e){const e=A.tagName;if("IMG"===e||"VIDEO"===e||"CANVAS"===e||"SOURCE"===e)return!1}if(Ts(e)&&f(t))return!1;return e in A}(A,e,i,g))?function(A,e,t,i,o,n,r){if("innerHTML"===e||"textContent"===e)return i&&r(i,o,n),void(A[e]=null==t?"":t);const s=A.tagName;if("value"===e&&"PROGRESS"!==s&&!s.includes("-")){const i=null==t?"":t;return("OPTION"===s?A.getAttribute("value")||"":A.value)===i&&"_value"in A||(A.value=i),null==t&&A.removeAttribute(e),void(A._value=t)}let a=!1;if(""===t||null==t){const i=typeof A[e];"boolean"===i?t=z(t):null==t&&"string"===i?(t="",a=!0):"number"===i&&(t=0,a=!0)}try{A[e]=t}catch(__){}a&&A.removeAttribute(e)}(A,e,i,n,r,s,a):("true-value"===e?A._trueValue=i:"false-value"===e&&(A._falseValue=i),function(A,e,t,i){if(i&&e.startsWith("xlink:"))null==t?A.removeAttributeNS(ys,e.slice(6,e.length)):A.setAttributeNS(ys,e,t);else{const i=W(e);null==t||i&&!z(t)?A.removeAttribute(e):A.setAttribute(e,i?"":t)}}(A,e,i,g))},forcePatchProp:(A,e)=>0===e.indexOf("change:")||("class"===e&&A.__wxsClassChanged?(A.__wxsClassChanged=!1,!0):!("style"!==e||!A.__wxsStyleChanged)&&(A.__wxsStyleChanged=!1,!0))},Jr);let Fs;function Os(){return Fs||(Fs=Ln(Us))}const xs=(...A)=>{Os().render(...A)},Ps=(...A)=>{const e=Os().createApp(...A),{mount:t}=e;return e.mount=A=>{const i=function(A){if(f(A)){return document.querySelector(A)}return A} /*! * vue-router v4.4.4 * (c) 2024 Eduardo San Martin Morote * @license MIT */(A);if(!i)return;const o=e._component;p(o)||o.render||o.template||(o.template=i.innerHTML),i.innerHTML="";const n=t(i,!1,function(A){if(A instanceof SVGElement)return"svg";if("function"==typeof MathMLElement&&A instanceof MathMLElement)return"mathml"}(i));return i instanceof Element&&(i.removeAttribute("v-cloak"),i.setAttribute("data-v-app","")),n},e};const Ys="undefined"!=typeof document;function Js(A){return"object"==typeof A||"displayName"in A||"props"in A||"__vccOpts"in A}const Hs=Object.assign;function qs(A,e){const t={};for(const i in e){const o=e[i];t[i]=js(o)?o.map(A):A(o)}return t}const Vs=()=>{},js=Array.isArray,Ks=/#/g,Ws=/&/g,zs=/\//g,Zs=/=/g,Xs=/\?/g,$s=/\+/g,Aa=/%5B/g,ea=/%5D/g,ta=/%5E/g,ia=/%60/g,oa=/%7B/g,na=/%7C/g,ra=/%7D/g,sa=/%20/g;function aa(A){return encodeURI(""+A).replace(na,"|").replace(Aa,"[").replace(ea,"]")}function ga(A){return aa(A).replace($s,"%2B").replace(sa,"+").replace(Ks,"%23").replace(Ws,"%26").replace(ia,"`").replace(oa,"{").replace(ra,"}").replace(ta,"^")}function ca(A){return ga(A).replace(Zs,"%3D")}function la(A){return null==A?"":function(A){return aa(A).replace(Ks,"%23").replace(Xs,"%3F")}(A).replace(zs,"%2F")}function Ia(A){try{return decodeURIComponent(""+A)}catch(e){}return""+A}const ua=/\/$/;function Ea(A,e,t="/"){let i,o={},n="",r="";const s=e.indexOf("#");let a=e.indexOf("?");return s=0&&(a=-1),a>-1&&(i=e.slice(0,a),n=e.slice(a+1,s>-1?s:e.length),o=A(n)),s>-1&&(i=i||e.slice(0,s),r=e.slice(s,e.length)),i=function(A,e){if(A.startsWith("/"))return A;if(!A)return e;const t=e.split("/"),i=A.split("/"),o=i[i.length-1];".."!==o&&"."!==o||i.push("");let n,r,s=t.length-1;for(n=0;n1&&s--}return t.slice(0,s).join("/")+"/"+i.slice(n).join("/")}(null!=i?i:e,t),{fullPath:i+(n&&"?")+n+r,path:i,query:o,hash:Ia(r)}}function da(A,e){return e&&A.toLowerCase().startsWith(e.toLowerCase())?A.slice(e.length)||"/":A}function ha(A,e){return(A.aliasOf||A)===(e.aliasOf||e)}function Ca(A,e){if(Object.keys(A).length!==Object.keys(e).length)return!1;for(const t in A)if(!Ba(A[t],e[t]))return!1;return!0}function Ba(A,e){return js(A)?Qa(A,e):js(e)?Qa(e,A):A===e}function Qa(A,e){return js(e)?A.length===e.length&&A.every((A,t)=>A===e[t]):1===A.length&&A[0]===e}const pa={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var fa,ma,ya,Da;function va(A){if(!A)if(Ys){const e=document.querySelector("base");A=(A=e&&e.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else A="/";return"/"!==A[0]&&"#"!==A[0]&&(A="/"+A),A.replace(ua,"")}(ma=fa||(fa={})).pop="pop",ma.push="push",(Da=ya||(ya={})).back="back",Da.forward="forward",Da.unknown="";const wa=/^[^#]+#/;function Sa(A,e){return A.replace(wa,"#")+e}const Ma=()=>({left:window.scrollX,top:window.scrollY});function Ra(A){let e;if("el"in A){const t=A.el,i="string"==typeof t&&t.startsWith("#"),o="string"==typeof t?i?document.getElementById(t.slice(1)):document.querySelector(t):t;if(!o)return;e=function(A,e){const t=document.documentElement.getBoundingClientRect(),i=A.getBoundingClientRect();return{behavior:e.behavior,left:i.left-t.left-(e.left||0),top:i.top-t.top-(e.top||0)}}(o,A)}else e=A;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(null!=e.left?e.left:window.scrollX,null!=e.top?e.top:window.scrollY)}function _a(A,e){return(history.state?history.state.position-e:-1)+A}const Ta=new Map;function Na(A,e){const{pathname:t,search:i,hash:o}=e,n=A.indexOf("#");if(n>-1){let e=o.includes(A.slice(n))?A.slice(n).length:1,t=o.slice(e);return"/"!==t[0]&&(t="/"+t),da(t,"")}return da(t,A)+i+o}function ba(A,e,t,i=!1,o=!1){return{back:A,current:e,forward:t,replaced:i,position:window.history.length,scroll:o?Ma():null}}function Ga(A){const{history:e,location:t}=window,i={value:Na(A,t)},o={value:e.state};function n(i,n,r){const s=A.indexOf("#"),a=s>-1?(t.host&&document.querySelector("base")?A:A.slice(s))+i:location.protocol+"//"+location.host+A+i;try{e[r?"replaceState":"pushState"](n,"",a),o.value=n}catch(g){console.error(g),t[r?"replace":"assign"](a)}}return o.value||n(i.value,{back:null,current:i.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0),{location:i,state:o,push:function(A,t){const r=Hs({},o.value,e.state,{forward:A,scroll:Ma()});n(r.current,r,!0),n(A,Hs({},ba(i.value,A,null),{position:r.position+1},t),!1),i.value=A},replace:function(A,t){n(A,Hs({},e.state,ba(o.value.back,A,o.value.forward,!0),t,{position:o.value.position}),!0),i.value=A}}}function ka(A){const e=Ga(A=va(A)),t=function(A,e,t,i){let o=[],n=[],r=null;const s=({state:n})=>{const s=Na(A,location),a=t.value,g=e.value;let c=0;if(n){if(t.value=s,e.value=n,r&&r===a)return void(r=null);c=g?n.position-g.position:0}else i(s);o.forEach(A=>{A(t.value,a,{delta:c,type:fa.pop,direction:c?c>0?ya.forward:ya.back:ya.unknown})})};function a(){const{history:A}=window;A.state&&A.replaceState(Hs({},A.state,{scroll:Ma()}),"")}return window.addEventListener("popstate",s),window.addEventListener("beforeunload",a,{passive:!0}),{pauseListeners:function(){r=t.value},listen:function(A){o.push(A);const e=()=>{const e=o.indexOf(A);e>-1&&o.splice(e,1)};return n.push(e),e},destroy:function(){for(const A of n)A();n=[],window.removeEventListener("popstate",s),window.removeEventListener("beforeunload",a)}}}(A,e.state,e.location,e.replace);const i=Hs({location:"",base:A,go:function(A,e=!0){e||t.pauseListeners(),history.go(A)},createHref:Sa.bind(null,A)},e,t);return Object.defineProperty(i,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(i,"state",{enumerable:!0,get:()=>e.state.value}),i}function La(A){return"string"==typeof A||"symbol"==typeof A}const Ua=Symbol("");var Fa,Oa;function xa(A,e){return Hs(new Error,{type:A,[Ua]:!0},e)}function Pa(A,e){return A instanceof Error&&Ua in A&&(null==e||!!(A.type&e))}(Oa=Fa||(Fa={}))[Oa.aborted=4]="aborted",Oa[Oa.cancelled=8]="cancelled",Oa[Oa.duplicated=16]="duplicated";const Ya="[^/]+?",Ja={sensitive:!1,strict:!1,start:!0,end:!0},Ha=/[.+*?^${}()[\]/\\]/g;function qa(A,e){let t=0;for(;te.length?1===e.length&&80===e[0]?1:-1:0}function Va(A,e){let t=0;const i=A.score,o=e.score;for(;t0&&e[e.length-1]<0}const Ka={type:0,value:""},Wa=/[a-zA-Z0-9_]/;function za(A,e,t){const i=function(A,e){const t=Hs({},Ja,e),i=[];let o=t.start?"^":"";const n=[];for(const a of A){const A=a.length?[]:[90];t.strict&&!a.length&&(o+="/");for(let e=0;e1&&("*"===s||"+"===s)&&e(`A repeatable param (${g}) must be alone in its segment. eg: '/:ids+.`),n.push({type:1,value:g,regexp:c,repeatable:"*"===s||"+"===s,optional:"*"===s||"?"===s})):e("Invalid state to consume buffer"),g="")}function I(){g+=s}for(;a{n(I)}:Vs}function n(A){if(La(A)){const e=i.get(A);e&&(i.delete(A),t.splice(t.indexOf(e),1),e.children.forEach(n),e.alias.forEach(n))}else{const e=t.indexOf(A);e>-1&&(t.splice(e,1),A.record.name&&i.delete(A.record.name),A.children.forEach(n),A.alias.forEach(n))}}function r(A){const e=function(A,e){let t=0,i=e.length;for(;t!==i;){const o=t+i>>1;Va(A,e[o])<0?i=o:t=o+1}const o=function(A){let e=A;for(;e=e.parent;)if(ig(e)&&0===Va(A,e))return e;return}(A);o&&(i=e.lastIndexOf(o,i-1));return i}(A,t);t.splice(e,0,A),A.record.name&&!Ag(A)&&i.set(A.record.name,A)}return e=tg({strict:!1,end:!0,sensitive:!1},e),A.forEach(A=>o(A)),{addRoute:o,resolve:function(A,e){let o,n,r,s={};if("name"in A&&A.name){if(o=i.get(A.name),!o)throw xa(1,{location:A});r=o.record.name,s=Hs(Xa(e.params,o.keys.filter(A=>!A.optional).concat(o.parent?o.parent.keys.filter(A=>A.optional):[]).map(A=>A.name)),A.params&&Xa(A.params,o.keys.map(A=>A.name))),n=o.stringify(s)}else if(null!=A.path)n=A.path,o=t.find(A=>A.re.test(n)),o&&(s=o.parse(n),r=o.record.name);else{if(o=e.name?i.get(e.name):t.find(A=>A.re.test(e.path)),!o)throw xa(1,{location:A,currentLocation:e});r=o.record.name,s=Hs({},e.params,A.params),n=o.stringify(s)}const a=[];let g=o;for(;g;)a.unshift(g.record),g=g.parent;return{name:r,path:n,params:s,matched:a,meta:eg(a)}},removeRoute:n,clearRoutes:function(){t.length=0,i.clear()},getRoutes:function(){return t},getRecordMatcher:function(A){return i.get(A)}}}function Xa(A,e){const t={};for(const i of e)i in A&&(t[i]=A[i]);return t}function $a(A){const e={},t=A.props||!1;if("component"in A)e.default=t;else for(const i in A.components)e[i]="object"==typeof t?t[i]:t;return e}function Ag(A){for(;A;){if(A.record.aliasOf)return!0;A=A.parent}return!1}function eg(A){return A.reduce((A,e)=>Hs(A,e.meta),{})}function tg(A,e){const t={};for(const i in A)t[i]=i in e?e[i]:A[i];return t}function ig({record:A}){return!!(A.name||A.components&&Object.keys(A.components).length||A.redirect)}function og(A){const e={};if(""===A||"?"===A)return e;const t=("?"===A[0]?A.slice(1):A).split("&");for(let i=0;iA&&ga(A)):[i&&ga(i)]).forEach(A=>{void 0!==A&&(e+=(e.length?"&":"")+t,null!=A&&(e+="="+A))})}return e}function rg(A){const e={};for(const t in A){const i=A[t];void 0!==i&&(e[t]=js(i)?i.map(A=>null==A?null:""+A):null==i?i:""+i)}return e}const sg=Symbol(""),ag=Symbol(""),gg=Symbol(""),cg=Symbol(""),lg=Symbol("");function Ig(){let A=[];return{add:function(e){return A.push(e),()=>{const t=A.indexOf(e);t>-1&&A.splice(t,1)}},list:()=>A.slice(),reset:function(){A=[]}}}function ug(A,e,t,i,o,n=A=>A()){const r=i&&(i.enterCallbacks[o]=i.enterCallbacks[o]||[]);return()=>new Promise((s,a)=>{const g=A=>{var n;!1===A?a(xa(4,{from:t,to:e})):A instanceof Error?a(A):"string"==typeof(n=A)||n&&"object"==typeof n?a(xa(2,{from:e,to:A})):(r&&i.enterCallbacks[o]===r&&"function"==typeof A&&r.push(A),s())},c=n(()=>A.call(i&&i.instances[o],e,t,g));let l=Promise.resolve(c);A.length<3&&(l=l.then(g)),l.catch(A=>a(A))})}function Eg(A,e,t,i,o=A=>A()){const n=[];for(const r of A)for(const A in r.components){let s=r.components[A];if("beforeRouteEnter"===e||r.instances[A])if(Js(s)){const a=(s.__vccOpts||s)[e];a&&n.push(ug(a,t,i,r,A,o))}else{let a=s();n.push(()=>a.then(n=>{if(!n)throw new Error(`Couldn't resolve component "${A}" at "${r.path}"`);const s=(a=n).__esModule||"Module"===a[Symbol.toStringTag]||a.default&&Js(a.default)?n.default:n;var a;r.mods[A]=n,r.components[A]=s;const g=(s.__vccOpts||s)[e];return g&&ug(g,t,i,r,A,o)()}))}}return n}function dg(A){const e=pn(gg),t=pn(cg),i=Ur(()=>{const t=Xt(A.to);return e.resolve(t)}),o=Ur(()=>{const{matched:A}=i.value,{length:e}=A,o=A[e-1],n=t.matched;if(!o||!n.length)return-1;const r=n.findIndex(ha.bind(null,o));if(r>-1)return r;const s=Cg(A[e-2]);return e>1&&Cg(o)===s&&n[n.length-1].path!==s?n.findIndex(ha.bind(null,A[e-2])):r}),n=Ur(()=>o.value>-1&&function(A,e){for(const t in e){const i=e[t],o=A[t];if("string"==typeof i){if(i!==o)return!1}else if(!js(o)||o.length!==i.length||i.some((A,e)=>A!==o[e]))return!1}return!0}(t.params,i.value.params)),r=Ur(()=>o.value>-1&&o.value===t.matched.length-1&&Ca(t.params,i.value.params));return{route:i,href:Ur(()=>i.value.href),isActive:n,isExactActive:r,navigate:function(t={}){return function(A){if(A.metaKey||A.altKey||A.ctrlKey||A.shiftKey)return;if(A.defaultPrevented)return;if(void 0!==A.button&&0!==A.button)return;if(A.currentTarget&&A.currentTarget.getAttribute){const e=A.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}A.preventDefault&&A.preventDefault();return!0}(t)?e[Xt(A.replace)?"replace":"push"](Xt(A.to)).catch(Vs):Promise.resolve()}}}const hg=Co({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:dg,setup(A,{slots:e}){const t=Nt(dg(A)),{options:i}=pn(gg),o=Ur(()=>({[Bg(A.activeClass,i.linkActiveClass,"router-link-active")]:t.isActive,[Bg(A.exactActiveClass,i.linkExactActiveClass,"router-link-exact-active")]:t.isExactActive}));return()=>{const i=e.default&&e.default(t);return A.custom?i:Or("a",{"aria-current":t.isExactActive?A.ariaCurrentValue:null,href:t.href,onClick:t.navigate,class:o.value},i)}}});function Cg(A){return A?A.aliasOf?A.aliasOf.path:A.path:""}const Bg=(A,e,t)=>null!=A?A:null!=e?e:t;function Qg(A,e){if(!A)return null;const t=A(e);return 1===t.length?t[0]:t}const pg=Co({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(A,{attrs:e,slots:t}){const i=pn(lg),o=Ur(()=>A.route||i.value),n=pn(ag,0),r=Ur(()=>{let A=Xt(n);const{matched:e}=o.value;let t;for(;(t=e[A])&&!t.components;)A++;return A}),s=Ur(()=>o.value.matched[r.value]);Qn(ag,Ur(()=>r.value+1)),Qn(sg,s),Qn(lg,o);const a=Kt();return Xi(()=>[a.value,s.value,A.name],([A,e,t],[i,o,n])=>{e&&(e.instances[t]=A,o&&o!==e&&A&&A===i&&(e.leaveGuards.size||(e.leaveGuards=o.leaveGuards),e.updateGuards.size||(e.updateGuards=o.updateGuards))),!A||!e||o&&ha(e,o)&&i||(e.enterCallbacks[t]||[]).forEach(e=>e(A))},{flush:"post"}),()=>{const i=o.value,n=A.name,r=s.value,g=r&&r.components[n];if(!g)return Qg(t.default,{Component:g,route:i});const c=r.props[n],l=c?!0===c?i.params:"function"==typeof c?c(i):c:null,I=Or(g,Hs({},l,e,{onVnodeUnmounted:A=>{A.component.isUnmounted&&(r.instances[n]=null)},ref:a}));return Qg(t.default,{Component:I,route:i})||I}}});function fg(A){const e=Za(A.routes,A),t=A.parseQuery||og,i=A.stringifyQuery||ng,o=A.history,n=Ig(),r=Ig(),s=Ig(),a=Wt(pa);let g=pa;Ys&&A.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const c=qs.bind(null,A=>""+A),l=qs.bind(null,la),I=qs.bind(null,Ia);function u(A,n){if(n=Hs({},n||a.value),"string"==typeof A){const i=Ea(t,A,n.path),r=e.resolve({path:i.path},n),s=o.createHref(i.fullPath);return Hs(i,r,{params:I(r.params),hash:Ia(i.hash),redirectedFrom:void 0,href:s})}let r;if(null!=A.path)r=Hs({},A,{path:Ea(t,A.path,n.path).path});else{const e=Hs({},A.params);for(const A in e)null==e[A]&&delete e[A];r=Hs({},A,{params:l(e)}),n.params=l(n.params)}const s=e.resolve(r,n),g=A.hash||"";s.params=c(I(s.params));const u=function(A,e){const t=e.query?A(e.query):"";return e.path+(t&&"?")+t+(e.hash||"")}(i,Hs({},A,{hash:(E=g,aa(E).replace(oa,"{").replace(ra,"}").replace(ta,"^")),path:s.path}));var E;const d=o.createHref(u);return Hs({fullPath:u,hash:g,query:i===ng?rg(A.query):A.query||{}},s,{redirectedFrom:void 0,href:d})}function E(A){return"string"==typeof A?Ea(t,A,a.value.path):Hs({},A)}function d(A,e){if(g!==A)return xa(8,{from:e,to:A})}function h(A){return B(A)}function C(A){const e=A.matched[A.matched.length-1];if(e&&e.redirect){const{redirect:t}=e;let i="function"==typeof t?t(A):t;return"string"==typeof i&&(i=i.includes("?")||i.includes("#")?i=E(i):{path:i},i.params={}),Hs({query:A.query,hash:A.hash,params:null!=i.path?{}:A.params},i)}}function B(A,e){const t=g=u(A),o=a.value,n=A.state,r=A.force,s=!0===A.replace,c=C(t);if(c)return B(Hs(E(c),{state:"object"==typeof c?Hs({},n,c.state):n,force:r,replace:s}),e||t);const l=t;let I;return l.redirectedFrom=e,!r&&function(A,e,t){const i=e.matched.length-1,o=t.matched.length-1;return i>-1&&i===o&&ha(e.matched[i],t.matched[o])&&Ca(e.params,t.params)&&A(e.query)===A(t.query)&&e.hash===t.hash}(i,o,t)&&(I=xa(16,{to:l,from:o}),T(o,o,!0,!1)),(I?Promise.resolve(I):f(l,o)).catch(A=>Pa(A)?Pa(A,2)?A:_(A):R(A,l,o)).then(A=>{if(A){if(Pa(A,2))return B(Hs({replace:s},E(A.to),{state:"object"==typeof A.to?Hs({},n,A.to.state):n,force:r}),e||l)}else A=y(l,o,!0,s,n);return m(l,o,A),A})}function Q(A,e){const t=d(A,e);return t?Promise.reject(t):Promise.resolve()}function p(A){const e=G.values().next().value;return e&&"function"==typeof e.runWithContext?e.runWithContext(A):A()}function f(A,e){let t;const[i,o,s]=function(A,e){const t=[],i=[],o=[],n=Math.max(e.matched.length,A.matched.length);for(let r=0;rha(A,n))?i.push(n):t.push(n));const s=A.matched[r];s&&(e.matched.find(A=>ha(A,s))||o.push(s))}return[t,i,o]}(A,e);t=Eg(i.reverse(),"beforeRouteLeave",A,e);for(const n of i)n.leaveGuards.forEach(i=>{t.push(ug(i,A,e))});const a=Q.bind(null,A,e);return t.push(a),L(t).then(()=>{t=[];for(const i of n.list())t.push(ug(i,A,e));return t.push(a),L(t)}).then(()=>{t=Eg(o,"beforeRouteUpdate",A,e);for(const i of o)i.updateGuards.forEach(i=>{t.push(ug(i,A,e))});return t.push(a),L(t)}).then(()=>{t=[];for(const i of s)if(i.beforeEnter)if(js(i.beforeEnter))for(const o of i.beforeEnter)t.push(ug(o,A,e));else t.push(ug(i.beforeEnter,A,e));return t.push(a),L(t)}).then(()=>(A.matched.forEach(A=>A.enterCallbacks={}),t=Eg(s,"beforeRouteEnter",A,e,p),t.push(a),L(t))).then(()=>{t=[];for(const i of r.list())t.push(ug(i,A,e));return t.push(a),L(t)}).catch(A=>Pa(A,8)?A:Promise.reject(A))}function m(A,e,t){s.list().forEach(i=>p(()=>i(A,e,t)))}function y(A,e,t,i,n){const r=d(A,e);if(r)return r;const s=e===pa,g=Ys?history.state:{};t&&(i||s?o.replace(A.fullPath,Hs({scroll:s&&g&&g.scroll},n)):o.push(A.fullPath,n)),a.value=A,T(A,e,t,s),_()}let D;function v(){D||(D=o.listen((A,e,t)=>{if(!k.listening)return;const i=u(A),n=C(i);if(n)return void B(Hs(n,{replace:!0}),i).catch(Vs);g=i;const r=a.value;var s,c;Ys&&(s=_a(r.fullPath,t.delta),c=Ma(),Ta.set(s,c)),f(i,r).catch(A=>Pa(A,12)?A:Pa(A,2)?(B(A.to,i).then(A=>{Pa(A,20)&&!t.delta&&t.type===fa.pop&&o.go(-1,!1)}).catch(Vs),Promise.reject()):(t.delta&&o.go(-t.delta,!1),R(A,i,r))).then(A=>{(A=A||y(i,r,!1))&&(t.delta&&!Pa(A,8)?o.go(-t.delta,!1):t.type===fa.pop&&Pa(A,20)&&o.go(-1,!1)),m(i,r,A)}).catch(Vs)}))}let w,S=Ig(),M=Ig();function R(A,e,t){_(A);const i=M.list();return i.length?i.forEach(i=>i(A,e,t)):console.error(A),Promise.reject(A)}function _(A){return w||(w=!A,v(),S.list().forEach(([e,t])=>A?t(A):e()),S.reset()),A}function T(e,t,i,o){const{scrollBehavior:n}=A;if(!Ys||!n)return Promise.resolve();const r=!i&&function(A){const e=Ta.get(A);return Ta.delete(A),e}(_a(e.fullPath,0))||(o||!i)&&history.state&&history.state.scroll||null;return pi().then(()=>n(e,t,r)).then(A=>A&&Ra(A)).catch(A=>R(A,e,t))}const N=A=>o.go(A);let b;const G=new Set,k={currentRoute:a,listening:!0,addRoute:function(A,t){let i,o;return La(A)?(i=e.getRecordMatcher(A),o=t):o=A,e.addRoute(o,i)},removeRoute:function(A){const t=e.getRecordMatcher(A);t&&e.removeRoute(t)},clearRoutes:e.clearRoutes,hasRoute:function(A){return!!e.getRecordMatcher(A)},getRoutes:function(){return e.getRoutes().map(A=>A.record)},resolve:u,options:A,push:h,replace:function(A){return h(Hs(E(A),{replace:!0}))},go:N,back:()=>N(-1),forward:()=>N(1),beforeEach:n.add,beforeResolve:r.add,afterEach:s.add,onError:M.add,isReady:function(){return w&&a.value!==pa?Promise.resolve():new Promise((A,e)=>{S.add([A,e])})},install(A){A.component("RouterLink",hg),A.component("RouterView",pg),A.config.globalProperties.$router=this,Object.defineProperty(A.config.globalProperties,"$route",{enumerable:!0,get:()=>Xt(a)}),Ys&&!b&&a.value===pa&&(b=!0,h(o.location).catch(A=>{}));const e={};for(const i in pa)Object.defineProperty(e,i,{get:()=>a.value[i],enumerable:!0});A.provide(gg,this),A.provide(cg,bt(e)),A.provide(lg,a);const t=A.unmount;G.add(A),A.unmount=function(){G.delete(A),G.size<1&&(g=pa,D&&D(),D=null,a.value=pa,b=!1,w=!1),t()}}};function L(A){return A.reduce((A,e)=>A.then(()=>p(e)),Promise.resolve())}return k}function mg(A){return pn(cg)}const yg=["{","}"];const Dg=/^(?:\d)+/,vg=/^(?:\w)+/;const wg="zh-Hans",Sg="zh-Hant",Mg="en",Rg="fr",_g="es",Tg=Object.prototype.hasOwnProperty,Ng=(A,e)=>Tg.call(A,e),bg=new class{constructor(){this._caches=Object.create(null)}interpolate(A,e,t=yg){if(!e)return[A];let i=this._caches[A];return i||(i=function(A,[e,t]){const i=[];let o=0,n="";for(;o-1?wg:A.indexOf("-hant")>-1?Sg:(t=A,["-tw","-hk","-mo","-cht"].find(A=>-1!==t.indexOf(A))?Sg:wg);var t;let i=[Mg,Rg,_g];e&&Object.keys(e).length>0&&(i=Object.keys(e));const o=function(A,e){return e.find(e=>0===A.indexOf(e))}(A,i);return o||void 0}let kg=class{constructor({locale:A,fallbackLocale:e,messages:t,watcher:i,formater:o}){this.locale=Mg,this.fallbackLocale=Mg,this.message={},this.messages={},this.watchers=[],e&&(this.fallbackLocale=e),this.formater=o||bg,this.messages=t||{},this.setLocale(A||Mg),i&&this.watchLocale(i)}setLocale(A){const e=this.locale;this.locale=Gg(A,this.messages)||this.fallbackLocale,this.messages[this.locale]||(this.messages[this.locale]={}),this.message=this.messages[this.locale],e!==this.locale&&this.watchers.forEach(A=>{A(this.locale,e)})}getLocale(){return this.locale}watchLocale(A){const e=this.watchers.push(A)-1;return()=>{this.watchers.splice(e,1)}}add(A,e,t=!0){const i=this.messages[A];i?t?Object.assign(i,e):Object.keys(e).forEach(A=>{Ng(i,A)||(i[A]=e[A])}):this.messages[A]=e}f(A,e,t){return this.formater.interpolate(A,e,t).join("")}t(A,e,t){let i=this.message;return"string"==typeof e?(e=Gg(e,this.messages))&&(i=this.messages[e]):t=e,Ng(i,A)?this.formater.interpolate(i[A],t).join(""):(console.warn(`Cannot translate the value of keypath ${A}. Use the value of keypath as default.`),A)}};function Lg(A,e={},t,i){if("string"!=typeof A){const t=[e,A];A=t[0],e=t[1]}"string"!=typeof A&&(A="undefined"!=typeof uni&&uni.getLocale?uni.getLocale():"undefined"!=typeof global&&global.getLocale?global.getLocale():Mg),"string"!=typeof t&&(t="undefined"!=typeof __uniConfig&&__uniConfig.fallbackLocale||Mg);const o=new kg({locale:A,fallbackLocale:t,messages:e,watcher:i});let n=(A,e)=>{{let A=!1;n=function(e,t){const i=np().$vm;return i&&(i.$locale,A||(A=!0,function(A,e){A.$watchLocale?A.$watchLocale(A=>{e.setLocale(A)}):A.$watch(()=>A.$locale,A=>{e.setLocale(A)})}(i,o))),o.t(e,t)}}return n(A,e)};return{i18n:o,f:(A,e,t)=>o.f(A,e,t),t:(A,e)=>n(A,e),add:(A,e,t=!0)=>o.add(A,e,t),watch:A=>o.watchLocale(A),getLocale:()=>o.getLocale(),setLocale:A=>o.setLocale(A)}}function Ug(A,e){return A.indexOf(e[0])>-1}const Fg=HA(()=>"undefined"!=typeof __uniConfig&&__uniConfig.locales&&!!Object.keys(__uniConfig.locales).length);let Og;function xg(A){return Ug(A,rA)?Jg().f(A,function(){const A=uni.getLocale(),e=__uniConfig.locales;return e[A]||e[__uniConfig.fallbackLocale]||e.en||{}}(),rA):A}function Pg(A,e){if(1===e.length){if(A){const t=A=>f(A)&&Ug(A,rA),i=e[0];let o=[];if(C(A)&&(o=A.filter(A=>t(A[i]))).length)return o;const n=A[e[0]];if(t(n))return A}return}const t=e.shift();return Pg(A&&A[t],e)}function Yg(A,e){const t=Pg(A,e);if(!t)return!1;const i=e[e.length-1];if(C(t))t.forEach(A=>Yg(A,[i]));else{let A=t[i];Object.defineProperty(t,i,{get:()=>xg(A),set(e){A=e}})}return!0}function Jg(){if(!Og){let A;if(A=navigator.cookieEnabled&&window.localStorage&&localStorage[nA]||__uniConfig.locale||navigator.language,Og=Lg(A),Fg()){const e=Object.keys(__uniConfig.locales||{});e.length&&e.forEach(A=>Og.add(A,__uniConfig.locales[A])),Og.setLocale(A)}}return Og}function Hg(A,e,t){return e.reduce((e,i,o)=>(e[A+i]=t[o],e),{})}const qg=HA(()=>{const A="uni.async.",e=["error"];Jg().add(Mg,Hg(A,e,["The connection timed out, click the screen to try again."]),!1),Jg().add(_g,Hg(A,e,["Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo."]),!1),Jg().add(Rg,Hg(A,e,["La connexion a expiré, cliquez sur l'écran pour réessayer."]),!1),Jg().add(wg,Hg(A,e,["连接服务器超时,点击屏幕重试"]),!1),Jg().add(Sg,Hg(A,e,["連接服務器超時,點擊屏幕重試"]),!1)}),Vg=HA(()=>{const A="uni.showActionSheet.",e=["cancel"];Jg().add(Mg,Hg(A,e,["Cancel"]),!1),Jg().add(_g,Hg(A,e,["Cancelar"]),!1),Jg().add(Rg,Hg(A,e,["Annuler"]),!1),Jg().add(wg,Hg(A,e,["取消"]),!1),Jg().add(Sg,Hg(A,e,["取消"]),!1)}),jg=HA(()=>{const A="uni.showToast.",e=["unpaired"];Jg().add(Mg,Hg(A,e,["Please note showToast must be paired with hideToast"]),!1),Jg().add(_g,Hg(A,e,["Tenga en cuenta que showToast debe estar emparejado con hideToast"]),!1),Jg().add(Rg,Hg(A,e,["Veuillez noter que showToast doit être associé à hideToast"]),!1),Jg().add(wg,Hg(A,e,["请注意 showToast 与 hideToast 必须配对使用"]),!1),Jg().add(Sg,Hg(A,e,["請注意 showToast 與 hideToast 必須配對使用"]),!1)}),Kg=HA(()=>{const A="uni.showLoading.",e=["unpaired"];Jg().add(Mg,Hg(A,e,["Please note showLoading must be paired with hideLoading"]),!1),Jg().add(_g,Hg(A,e,["Tenga en cuenta que showLoading debe estar emparejado con hideLoading"]),!1),Jg().add(Rg,Hg(A,e,["Veuillez noter que showLoading doit être associé à hideLoading"]),!1),Jg().add(wg,Hg(A,e,["请注意 showLoading 与 hideLoading 必须配对使用"]),!1),Jg().add(Sg,Hg(A,e,["請注意 showLoading 與 hideLoading 必須配對使用"]),!1)}),Wg=HA(()=>{const A="uni.showModal.",e=["cancel","confirm"];Jg().add(Mg,Hg(A,e,["Cancel","OK"]),!1),Jg().add(_g,Hg(A,e,["Cancelar","OK"]),!1),Jg().add(Rg,Hg(A,e,["Annuler","OK"]),!1),Jg().add(wg,Hg(A,e,["取消","确定"]),!1),Jg().add(Sg,Hg(A,e,["取消","確定"]),!1)}),zg=HA(()=>{const A="uni.chooseFile.",e=["notUserActivation"];Jg().add(Mg,Hg(A,e,["File chooser dialog can only be shown with a user activation"]),!1),Jg().add(_g,Hg(A,e,["El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario"]),!1),Jg().add(Rg,Hg(A,e,["La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur"]),!1),Jg().add(wg,Hg(A,e,["文件选择器对话框只能在由用户激活时显示"]),!1),Jg().add(Sg,Hg(A,e,["文件選擇器對話框只能在由用戶激活時顯示"]),!1)}),Zg=HA(()=>{const A="uni.setClipboardData.",e=["success","fail"];Jg().add(Mg,Hg(A,e,["Content copied","Copy failed, please copy manually"]),!1),Jg().add(_g,Hg(A,e,["Contenido copiado","Error al copiar, copie manualmente"]),!1),Jg().add(Rg,Hg(A,e,["Contenu copié","Échec de la copie, copiez manuellement"]),!1),Jg().add(wg,Hg(A,e,["内容已复制","复制失败,请手动复制"]),!1),Jg().add(Sg,Hg(A,e,["內容已復制","復制失敗,請手動復製"]),!1)}),Xg=HA(()=>{const A="uni.getClipboardData.",e=["fail"];Jg().add(Mg,Hg(A,e,["Reading failed, please paste manually"]),!1),Jg().add(_g,Hg(A,e,["Error de lectura, pegue manualmente"]),!1),Jg().add(Rg,Hg(A,e,["Échec de la lecture, veuillez coller manuellement"]),!1),Jg().add(wg,Hg(A,e,["读取失败,请手动粘贴"]),!1),Jg().add(Sg,Hg(A,e,["讀取失敗,請手動粘貼"]),!1)}),$g=HA(()=>{const A="uni.video.",e=["danmu","volume"];Jg().add(Mg,Hg(A,e,["Danmu","Volume"]),!1),Jg().add(_g,Hg(A,e,["Danmu","Volumen"]),!1),Jg().add(Rg,Hg(A,e,["Danmu","Le Volume"]),!1),Jg().add(wg,Hg(A,e,["弹幕","音量"]),!1),Jg().add(Sg,Hg(A,e,["彈幕","音量"]),!1)}),Ac=HA(()=>{const A="uni.chooseLocation.",e=["search","cancel"];Jg().add(Mg,Hg(A,e,["Find Place","Cancel"]),!1),Jg().add(_g,Hg(A,e,["Encontrar","Cancelar"]),!1),Jg().add(Rg,Hg(A,e,["Trouve","Annuler"]),!1),Jg().add(wg,Hg(A,e,["搜索地点","取消"]),!1),Jg().add(Sg,Hg(A,e,["搜索地點","取消"]),!1)});function ec(A){const e=new Be;return{on:(A,t)=>e.on(A,t),once:(A,t)=>e.once(A,t),off:(A,t)=>e.off(A,t),emit:(A,...t)=>e.emit(A,...t),subscribe(t,i,o=!1){e[o?"once":"on"](`${A}.${t}`,i)},unsubscribe(t,i){e.off(`${A}.${t}`,i)},subscribeHandler(t,i,o){e.emit(`${A}.${t}`,i,o)}}}const tc="invokeViewApi",ic="invokeServiceApi";let oc=1;const nc=Object.create(null);function rc(A,e){return A+"."+e}function sc(A,e,t){e=rc(A,e),nc[e]||(nc[e]=t)}function ac({id:A,name:e,args:t},i){e=rc(i,e);const o=e=>{A&&Ov.publishHandler(tc+"."+A,e)},n=nc[e];n?n(t,o):o({})}const gc=u(ec("service"),{invokeServiceMethod:(A,e,t)=>{const{subscribe:i,publishHandler:o}=Ov,n=t?oc++:0;t&&i(ic+"."+n,t,!0),o(ic,{id:n,name:A,args:e})}}),cc=oe(!0);let lc;function Ic(){lc&&(clearTimeout(lc),lc=null)}let uc=0,Ec=0;function dc(A){if(Ic(),1!==A.touches.length)return;const{pageX:e,pageY:t}=A.touches[0];uc=e,Ec=t,lc=setTimeout(function(){const e=new CustomEvent("longpress",{bubbles:!0,cancelable:!0,target:A.target,currentTarget:A.currentTarget});e.touches=A.touches,e.changedTouches=A.changedTouches,A.target.dispatchEvent(e)},350)}function hc(A){if(!lc)return;if(1!==A.touches.length)return Ic();const{pageX:e,pageY:t}=A.touches[0];return Math.abs(e-uc)>10||Math.abs(t-Ec)>10?Ic():void 0}function Cc(A,e){const t=Number(A);return isNaN(t)?e:t}function Bc(){const A=__uniConfig.globalStyle||{},e=Cc(A.rpxCalcMaxDeviceWidth,960),t=Cc(A.rpxCalcBaseDeviceWidth,375);function i(){let A=function(){const A=/^Apple/.test(navigator.vendor)&&"number"==typeof window.orientation,e=A&&90===Math.abs(window.orientation);var t=A?Math[e?"max":"min"](screen.width,screen.height):screen.width;return Math.min(window.innerWidth,document.documentElement.clientWidth,t)||t}();A=A<=e?A:t,document.documentElement.style.fontSize=A/23.4375+"px"}i(),document.addEventListener("DOMContentLoaded",i),window.addEventListener("load",i),window.addEventListener("resize",i)}function Qc(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var pc,fc,mc=["top","left","right","bottom"],yc={};function Dc(){return fc="CSS"in window&&"function"==typeof CSS.supports?CSS.supports("top: env(safe-area-inset-top)")?"env":CSS.supports("top: constant(safe-area-inset-top)")?"constant":"":""}function vc(){if(fc="string"==typeof fc?fc:Dc()){var A=[],e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e={passive:!0}}});window.addEventListener("test",null,t)}catch(__){}var i=document.createElement("div");o(i,{position:"absolute",left:"0",top:"0",width:"0",height:"0",zIndex:"-1",overflow:"hidden",visibility:"hidden"}),mc.forEach(function(A){r(i,A)}),document.body.appendChild(i),n(),pc=!0}else mc.forEach(function(A){yc[A]=0});function o(A,e){var t=A.style;Object.keys(e).forEach(function(A){var i=e[A];t[A]=i})}function n(e){e?A.push(e):A.forEach(function(A){A()})}function r(A,t){var i=document.createElement("div"),r=document.createElement("div"),s=document.createElement("div"),a=document.createElement("div"),g={position:"absolute",width:"100px",height:"200px",boxSizing:"border-box",overflow:"hidden",paddingBottom:fc+"(safe-area-inset-"+t+")"};o(i,g),o(r,g),o(s,{transition:"0s",animation:"none",width:"400px",height:"400px"}),o(a,{transition:"0s",animation:"none",width:"250%",height:"250%"}),i.appendChild(s),r.appendChild(a),A.appendChild(i),A.appendChild(r),n(function(){i.scrollTop=r.scrollTop=1e4;var A=i.scrollTop,o=r.scrollTop;function n(){this.scrollTop!==(this===i?A:o)&&(i.scrollTop=r.scrollTop=1e4,A=i.scrollTop,o=r.scrollTop,function(A){Sc.length||setTimeout(function(){var A={};Sc.forEach(function(e){A[e]=yc[e]}),Sc.length=0,Mc.forEach(function(e){e(A)})},0);Sc.push(A)}(t))}i.addEventListener("scroll",n,e),r.addEventListener("scroll",n,e)});var c=getComputedStyle(i);Object.defineProperty(yc,t,{configurable:!0,get:function(){return parseFloat(c.paddingBottom)}})}}function wc(A){return pc||vc(),yc[A]}var Sc=[];var Mc=[];const Rc=Qc({get support(){return 0!=("string"==typeof fc?fc:Dc()).length},get top(){return wc("top")},get left(){return wc("left")},get right(){return wc("right")},get bottom(){return wc("bottom")},onChange:function(A){Dc()&&(pc||vc(),"function"==typeof A&&Mc.push(A))},offChange:function(A){var e=Mc.indexOf(A);e>=0&&Mc.splice(e,1)}}),_c=Gs(()=>{},["prevent"]),Tc=Gs(A=>{},["stop"]);function Nc(A,e){return parseInt((A.getPropertyValue(e).match(/\d+/)||["0"])[0])}function bc(){const A=Nc(document.documentElement.style,"--window-top");return A?A+Rc.top:0}function Gc(){const A=document.documentElement.style,e=bc(),t=Nc(A,"--window-bottom"),i=Nc(A,"--window-left"),o=Nc(A,"--window-right"),n=Nc(A,"--top-window-height");return{top:e,bottom:t?t+Rc.bottom:0,left:i?i+Rc.left:0,right:o?o+Rc.right:0,topWindowHeight:n||0}}function kc(A){const e=document.documentElement.style;Object.keys(A).forEach(t=>{e.setProperty(t,A[t])})}function Lc(A){return kc(A)}function Uc(A){return Symbol(A)}function Fc(A){return-1!==(A+="").indexOf("rpx")||-1!==A.indexOf("upx")}function Oc(A,e=!1){if(e)return function(A){if(!Fc(A))return A;return A.replace(/(\d+(\.\d+)?)[ru]px/g,(A,e)=>uni.upx2px(parseFloat(e))+"px")}(A);if(f(A)){const e=parseInt(A)||0;return Fc(A)?uni.upx2px(e):e}return A}function xc(A){return A.$page}function Pc(A){return 0===A.tagName.indexOf("UNI-")}const Yc="M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z",Jc="M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z",Hc="M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z",qc="M17.25 16.156l7.375-7.313q0.281-0.281 0.281-0.641t-0.281-0.641q-0.25-0.25-0.625-0.25t-0.625 0.25l-7.375 7.344-7.313-7.344q-0.25-0.25-0.625-0.25t-0.625 0.25q-0.281 0.25-0.281 0.625t0.281 0.625l7.313 7.344-7.375 7.344q-0.281 0.25-0.281 0.625t0.281 0.625q0.125 0.125 0.281 0.188t0.344 0.063q0.156 0 0.328-0.063t0.297-0.188l7.375-7.344 7.375 7.406q0.125 0.156 0.297 0.219t0.328 0.063q0.188 0 0.344-0.078t0.281-0.203q0.281-0.25 0.281-0.609t-0.281-0.641l-7.375-7.406z",Vc="M31.562 4.9966666659375q0.435 0.399 0.435 0.87 0.036 0.58-0.399 0.98l-18.61 19.917q-0.145 0.145-0.327 0.217-0.073 0.037-0.145 0.11-0.254 0.035-0.472 0.035-0.29 0-0.544-0.036l-0.145-0.072q-0.109-0.073-0.217-0.182l-0.11-0.072L0.363 16.2786666659375q-0.327-0.399-0.363-0.907 0-0.544 0.363-1.016 0.435-0.326 0.961-0.362 0.527-0.036 0.962 0.362l9.722 9.542L29.712 5.0326666659375q0.399-0.363 0.943-0.363 0.544-0.036 0.907 0.327z";function jc(A,e="#000",t=27){return Ir("svg",{width:t,height:t,viewBox:"0 0 32 32"},[Ir("path",{d:A,fill:e},null,8,["d","fill"])],8,["width","height"])}function Kc(){{const{$pageInstance:A}=Dr();return A&&tl(A.proxy)}}function Wc(A){const e=KA(A);if(e.$page)return tl(e);if(!e.$)return;{const{$pageInstance:A}=e.$;if(A)return tl(A.proxy)}const t=e.$.root.proxy;return t&&t.$page?tl(t):void 0}function zc(){const A=Lh(),e=A.length;if(e)return A[e-1]}function Zc(){var A;const e=null==(A=zc())?void 0:A.$page;if(e)return e.meta}function Xc(){const A=Zc();return A?A.id:-1}function $c(){const A=zc();if(A)return A.$vm}const Al=["navigationBar","pullToRefresh"];function el(A,e){const t=JSON.parse(JSON.stringify(__uniConfig.globalStyle||{})),i=u({id:e},t,A);Al.forEach(e=>{i[e]=u({},t[e],A[e])});const{navigationBar:o}=i;return o.titleText&&o.titleImage&&(o.titleText=""),i}function tl(A){var e,t;return(null==(e=A.$page)?void 0:e.id)||(null==(t=A.$basePage)?void 0:t.id)}function il(A,e,t){if(f(A))t=e,e=A,A=$c();else if("number"==typeof A){const e=Lh().find(e=>xc(e).id===A);A=e?e.$vm:$c()}if(!A)return;const i=A.$[e];return i&&((A,e)=>{let t;for(let i=0;i{function r(){if((()=>{const{scrollHeight:A}=document.documentElement,e=window.innerHeight,i=window.scrollY,n=i>0&&A>e&&i+e+t>=A,r=Math.abs(A-rl)>t;return!n||o&&!r?(!n&&o&&(o=!1),!1):(rl=A,o=!0,!0)})())return e&&e(),n=!1,setTimeout(function(){n=!0},350),!0}A&&A(window.pageYOffset),e&&n&&(r()||(nl=setTimeout(r,300))),i=!1};return function(){clearTimeout(nl),i||requestAnimationFrame(r),i=!0}}function al(A,e){if(0===e.indexOf("/"))return e;if(0===e.indexOf("./"))return al(A,e.slice(2));const t=e.split("/"),i=t.length;let o=0;for(;o0?A.split("/"):[];return n.splice(n.length-o-1,o+1),PA(n.concat(t).join("/"))}function gl(A,e=!1){return e?__uniRoutes.find(e=>e.path===A||e.alias===A):__uniRoutes.find(e=>e.path===A)}function cl(){Bc(),ee(Pc),window.addEventListener("touchstart",dc,cc),window.addEventListener("touchmove",hc,cc),window.addEventListener("touchend",Ic,cc),window.addEventListener("touchcancel",Ic,cc)}class ll{constructor(A){this.$bindClass=!1,this.$bindStyle=!1,this.$vm=A,this.$el=function(A,e=!1){const{vnode:t}=A;if(zA(t.el))return e?t.el?[t.el]:[]:t.el;const{subTree:i}=A;if(16&i.shapeFlag){const A=i.children.filter(A=>A.el&&zA(A.el));if(A.length>0)return e?A.map(A=>A.el):A[0].el}return e?t.el?[t.el]:[]:t.el}(A.$),this.$el.getAttribute&&(this.$bindClass=!!this.$el.getAttribute("class"),this.$bindStyle=!!this.$el.getAttribute("style"))}selectComponent(A){if(!this.$el||!A)return;const e=dl(this.$el.querySelector(A));return e?Il(e,!1):void 0}selectAllComponents(A){if(!this.$el||!A)return[];const e=[],t=this.$el.querySelectorAll(A);for(let i=0;i-1&&e.splice(t,1)}const t=this.$el.__wxsRemoveClass||(this.$el.__wxsRemoveClass=[]);return-1===t.indexOf(A)&&(t.push(A),this.forceUpdate("class")),this}hasClass(A){return this.$el&&this.$el.classList.contains(A)}getDataset(){return this.$el&&this.$el.dataset}callMethod(A,e={}){const t=this.$vm[A];p(t)?t(JSON.parse(JSON.stringify(e))):this.$vm.ownerId&&Ov.publishHandler("onWxsInvokeCallMethod",{nodeId:this.$el.__id,ownerId:this.$vm.ownerId,method:A,args:e})}requestAnimationFrame(A){return window.requestAnimationFrame(A)}getState(){return this.$el&&(this.$el.__wxsState||(this.$el.__wxsState={}))}triggerEvent(A,e={}){return this.$vm.$emit(A,e),this}getComputedStyle(A){if(this.$el){const e=window.getComputedStyle(this.$el);return A&&A.length?A.reduce((A,t)=>(A[t]=e[t],A),{}):e}return{}}setTimeout(A,e){return window.setTimeout(A,e)}clearTimeout(A){return window.clearTimeout(A)}getBoundingClientRect(){return this.$el.getBoundingClientRect()}}function Il(A,e=!0){if(e&&A&&(A=WA(A.$)),A&&A.$el)return A.$el.__wxsComponentDescriptor||(A.$el.__wxsComponentDescriptor=new ll(A)),A.$el.__wxsComponentDescriptor}function ul(A,e){return Il(A,e)}function El(A,e,t,i=!0){if(e){A.__instance||(A.__instance=!0,Object.defineProperty(A,"instance",{get:()=>ul(t.proxy,!1)}));const o=function(A,e,t=!0){if(!e)return!1;if(t&&A.length<2)return!1;const i=WA(e);if(!i)return!1;const o=i.$.type;return!(!o.$wxs&&!o.$renderjs)&&i}(e,t,i);if(o)return[A,ul(o,!1)]}}function dl(A){if(A)return A.__vueParentComponent&&A.__vueParentComponent.proxy}function hl(A,e=!1){const{type:t,timeStamp:i,target:o,currentTarget:n}=A;let r,s;r=ne(e?o:function(A){for(;!Pc(A);)A=A.parentElement;return A}(o)),s=ne(n);const a={type:t,timeStamp:i,target:r,detail:{},currentTarget:s};return A instanceof CustomEvent&&S(A.detail)&&(a.detail=A.detail),A._stopped&&(a._stopped=!0),A.type.startsWith("touch")&&(a.touches=A.touches,a.changedTouches=A.changedTouches),function(A,e){u(A,{preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}(a,A),a}function Cl(A,e){return{force:1,identifier:0,clientX:A.clientX,clientY:A.clientY-e,pageX:A.pageX,pageY:A.pageY-e}}function Bl(A,e){const t=[];for(let i=0;i0===A.type.indexOf("mouse")||["contextmenu"].includes(A.type))(A))!function(A,e){const t=bc();A.pageX=e.pageX,A.pageY=e.pageY-t,A.clientX=e.clientX,A.clientY=e.clientY-t,A.touches=A.changedTouches=[Cl(e,t)]}(n,A);else if((A=>"undefined"!=typeof TouchEvent&&A instanceof TouchEvent||0===A.type.indexOf("touch")||["longpress"].indexOf(A.type)>=0)(A)){const e=bc();n.touches=Bl(A.touches,e),n.changedTouches=Bl(A.changedTouches,e)}else if((A=>!A.type.indexOf("key")&&A instanceof KeyboardEvent)(A)){["key","code"].forEach(e=>{Object.defineProperty(n,e,{get:()=>A[e]})})}return El(n,e,t)||[n]},createNativeEvent:hl},Symbol.toStringTag,{value:"Module"});function pl(A){!function(A){const e=A.globalProperties;u(e,Ql),e.$gcd=ul}(A._context.config)}let fl=1;function ml(A){return(A||Xc())+"."+tc}const yl=u(ec("view"),{invokeOnCallback:(A,e)=>Pv.emit("api."+A,e),invokeViewMethod:(A,e,t,i)=>{const{subscribe:o,publishHandler:n}=Pv,r=i?fl++:0;i&&o(tc+"."+r,i,!0),n(ml(t),{id:r,name:A,args:e},t)},invokeViewMethodKeepAlive:(A,e,t,i)=>{const{subscribe:o,unsubscribe:n,publishHandler:r}=Pv,s=fl++,a=tc+"."+s;return o(a,t),r(ml(i),{id:s,name:A,args:e},i),()=>{n(a)}}});function Dl(A){il(zc(),mA,A),Pv.invokeOnCallback("onWindowResize",A)}function vl(A){const e=zc();il(np(),cA,A),il(e,cA)}function wl(){il(np(),lA),il(zc(),lA)}const Sl=[DA,wA];function Ml(){Sl.forEach(A=>Pv.subscribe(A,function(A){return(e,t)=>{il(parseInt(t),A,e)}}(A)))}function Rl(){!function(){const{on:A}=Pv;A(mA,Dl),A(UA,vl),A(FA,wl)}(),Ml()}function _l(){if(this.$route){const A=this.$route.meta;return A.eventChannel||(A.eventChannel=new le(this.$page.id)),A.eventChannel}}function Tl(A){A._context.config.globalProperties.getOpenerEventChannel=_l}function Nl(){return{path:"",query:{},scene:1001,referrerInfo:{appId:"",extraData:{}}}}function bl(A){return/^-?\d+[ur]px$/i.test(A)?A.replace(/(^-?\d+)[ur]px$/i,(A,e)=>`${uni.upx2px(parseFloat(e))}px`):/^-?[\d\.]+$/.test(A)?`${A}px`:A||""}function Gl(A){const e=A.animation;if(!e||!e.actions||!e.actions.length)return;let t=0;const i=e.actions,o=e.actions.length;function n(){const e=i[t],r=e.option.transition,s=function(A){const e=["matrix","matrix3d","scale","scale3d","rotate3d","skew","translate","translate3d"],t=["scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skewX","skewY","translateX","translateY","translateZ"],i=["opacity","background-color"],o=["width","height","left","right","top","bottom"],n=A.animates,r=A.option,s=r.transition,a={},g=[];return n.forEach(A=>{let n=A.type,r=[...A.args];if(e.concat(t).includes(n))n.startsWith("rotate")||n.startsWith("skew")?r=r.map(A=>parseFloat(A)+"deg"):n.startsWith("translate")&&(r=r.map(bl)),t.indexOf(n)>=0&&(r.length=1),g.push(`${n}(${r.join(",")})`);else if(i.concat(o).includes(r[0])){n=r[0];const A=r[1];a[n]=o.includes(n)?bl(A):A}}),a.transform=a.webkitTransform=g.join(" "),a.transition=a.webkitTransition=Object.keys(a).map(A=>`${function(A){return A.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`).replace("webkit","-webkit")}(A)} ${s.duration}ms ${s.timingFunction} ${s.delay}ms`).join(","),a.transformOrigin=a.webkitTransformOrigin=r.transformOrigin,a}(e);Object.keys(s).forEach(e=>{A.$el.style[e]=s[e]}),t+=1,t{n()},0)}const kl={props:["animation"],watch:{animation:{deep:!0,handler(){Gl(this)}}},mounted(){Gl(this)}},Ll=A=>{A.__reserved=!0;const{props:e,mixins:t}=A;return e&&e.animation||(t||(A.mixins=[])).push(kl),Ul(A)},Ul=A=>(A.__reserved=!0,A.compatConfig={MODE:3},Co(A));function Fl(A){return A.__wwe=!0,A}function Ol(A,e){return(t,i,o)=>{A.value&&e(t,function(A,e,t,i){let o;return o=ne(t),{type:e.__evName||i.type||A,timeStamp:e.timeStamp||0,target:o,currentTarget:o,detail:i}}(t,i,A.value,o||{}))}}const xl={hoverClass:{type:String,default:"none"},hoverStopPropagation:{type:Boolean,default:!1},hoverStartTime:{type:[Number,String],default:50},hoverStayTime:{type:[Number,String],default:400}};function Pl(A){const e=Kt(!1);let t,i,o=!1;function n(){requestAnimationFrame(()=>{clearTimeout(i),i=setTimeout(()=>{e.value=!1},parseInt(A.hoverStayTime))})}function r(i){i._hoverPropagationStopped||A.hoverClass&&"none"!==A.hoverClass&&!A.disabled&&(A.hoverStopPropagation&&(i._hoverPropagationStopped=!0),o=!0,t=setTimeout(()=>{e.value=!0,o||n()},parseInt(A.hoverStartTime)))}function s(){o=!1,e.value&&n()}function a(){s(),window.removeEventListener("mouseup",a)}return{hovering:e,binding:{onTouchstartPassive:Fl(function(A){A.touches.length>1||r(A)}),onMousedown:Fl(function(A){o||(r(A),window.addEventListener("mouseup",a))}),onTouchend:Fl(function(){s()}),onMouseup:Fl(function(){o&&a()}),onTouchcancel:Fl(function(){o=!1,e.value=!1,clearTimeout(t)})}}}function Yl(A,e){return f(e)&&(e=[e]),e.reduce((e,t)=>(A[t]&&(e[t]=!0),e),Object.create(null))}const Jl=Uc("uf"),Hl=Ll({name:"Form",emits:["submit","reset"],setup(A,{slots:e,emit:t}){const i=Kt(null);return function(A){const e=[];Qn(Jl,{addField(A){e.push(A)},removeField(A){e.splice(e.indexOf(A),1)},submit(t){A("submit",t,{value:e.reduce((A,e)=>{if(e.submit){const[t,i]=e.submit();t&&(A[t]=i)}return A},Object.create(null))})},reset(t){e.forEach(A=>A.reset&&A.reset()),A("reset",t)}})}(Ol(i,t)),()=>Ir("uni-form",{ref:i},[Ir("span",null,[e.default&&e.default()])],512)}});const ql={for:{type:String,default:""}},Vl=Uc("ul");const jl=Ll({name:"Label",props:ql,setup(A,{slots:e}){const t=Kt(null),i=Kc(),o=function(){const A=[];return Qn(Vl,{addHandler(e){A.push(e)},removeHandler(e){A.splice(A.indexOf(e),1)}}),A}(),n=Ur(()=>A.for||e.default&&e.default.length),r=Fl(e=>{const t=e.target;let n=/^uni-(checkbox|radio|switch)-/.test(t.className);n||(n=/^uni-(checkbox|radio|switch|button)$|^(svg|path)$/i.test(t.tagName)),n||(A.for?Ov.emit("uni-label-click-"+i+"-"+A.for,e,!0):o.length&&o[0](e,!0))});return()=>Ir("uni-label",{ref:t,class:{"uni-label-pointer":n},onClick:r},[e.default&&e.default()],10,["onClick"])}});function Kl(A,e){Wl(A.id,e),Xi(()=>A.id,(A,t)=>{zl(t,e,!0),Wl(A,e,!0)}),Po(()=>{zl(A.id,e)})}function Wl(A,e,t){const i=Kc();t&&!A||S(e)&&Object.keys(e).forEach(o=>{t?0!==o.indexOf("@")&&0!==o.indexOf("uni-")&&Ov.on(`uni-${o}-${i}-${A}`,e[o]):0===o.indexOf("uni-")?Ov.on(o,e[o]):A&&Ov.on(`uni-${o}-${i}-${A}`,e[o])})}function zl(A,e,t){const i=Kc();t&&!A||S(e)&&Object.keys(e).forEach(o=>{t?0!==o.indexOf("@")&&0!==o.indexOf("uni-")&&Ov.off(`uni-${o}-${i}-${A}`,e[o]):0===o.indexOf("uni-")?Ov.off(o,e[o]):A&&Ov.off(`uni-${o}-${i}-${A}`,e[o])})}const Zl=Ll({name:"Button",props:{id:{type:String,default:""},hoverClass:{type:String,default:"button-hover"},hoverStartTime:{type:[Number,String],default:20},hoverStayTime:{type:[Number,String],default:70},hoverStopPropagation:{type:Boolean,default:!1},disabled:{type:[Boolean,String],default:!1},formType:{type:String,default:""},openType:{type:String,default:""},loading:{type:[Boolean,String],default:!1},plain:{type:[Boolean,String],default:!1}},setup(A,{slots:e}){const t=Kt(null),i=pn(Jl,!1),{hovering:o,binding:n}=Pl(A),r=Fl((e,o)=>{if(A.disabled)return e.stopImmediatePropagation();o&&t.value.click();const n=A.formType;if(n){if(!i)return;"submit"===n?i.submit(e):"reset"===n&&i.reset(e)}else;}),s=pn(Vl,!1);return s&&(s.addHandler(r),xo(()=>{s.removeHandler(r)})),Kl(A,{"label-click":r}),()=>{const i=A.hoverClass,s=Yl(A,"disabled"),a=Yl(A,"loading"),g=Yl(A,"plain"),c=i&&"none"!==i;return Ir("uni-button",Qr({ref:t,onClick:r,id:A.id,class:c&&o.value?i:""},c&&n,s,a,g),[e.default&&e.default()],16,["onClick","id"])}}}),Xl=Uc("upm");function $l(){return pn(Xl)}function AI(A){const e=function(A){return Nt(function(A){{const{navigationBar:e}=A,{titleSize:t,titleColor:i,backgroundColor:o}=e;e.titleText=e.titleText||"",e.type=e.type||"default",e.titleSize=t||"16px",e.titleColor=i||"#000000",e.backgroundColor=o||"#F8F8F8"}if(history.state){const e=history.state.__type__;"redirectTo"!==e&&"reLaunch"!==e||0!==Lh().length||(A.isEntry=!0,A.isQuit=!0)}return A}(JSON.parse(JSON.stringify(el(mg().meta,A)))))}(A);return Qn(Xl,e),e}function eI(){return mg()}function tI(){return history.state&&history.state.__id__||1}var iI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",oI=function(){const A=new Uint8Array(256);for(var e=0;e<64;e++)A[iI.charCodeAt(e)]=e;return A}();const nI=["original","compressed"],rI=["album","camera"],sI=["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"];function aI(A,e){return A&&-1!==e.indexOf(A)?A:e[0]}function gI(A,e){return!C(A)||0===A.length||A.find(A=>-1===e.indexOf(A))?e:A}function cI(A){return function(){try{return A.apply(A,arguments)}catch(__){console.error(__)}}}let lI=1;const II={};function uI(A,e,t,i=!1){return II[A]={name:e,keepAlive:i,callback:t},A}function EI(A,e,t){if("number"==typeof A){const i=II[A];if(i)return i.keepAlive||delete II[A],i.callback(e,t)}return e}function dI(A){for(const e in II)if(II[e].name===A)return!0;return!1}const hI="success",CI="fail",BI="complete";function QI(A,e={},{beforeAll:t,beforeSuccess:i}={}){S(e)||(e={});const{success:o,fail:n,complete:r}=function(A){const e={};for(const t in A){const i=A[t];p(i)&&(e[t]=cI(i),delete A[t])}return e}(e),s=p(o),a=p(n),g=p(r),c=lI++;return uI(c,A,c=>{(c=c||{}).errMsg=function(A,e){return A&&-1!==A.indexOf(":fail")?e+A.substring(A.indexOf(":fail")):e+":ok"}(c.errMsg,A),p(t)&&t(c),c.errMsg===A+":ok"?(p(i)&&i(c,e),s&&o(c)):a&&n(c),g&&r(c)}),c}const pI="success",fI="fail",mI="complete",yI={},DI={};function vI(A,e){return function(t){return A(t,e)||t}}function wI(A,e,t){let i=!1;for(let o=0;oA(e),catch(){}}}function SI(A,e={}){return[pI,fI,mI].forEach(t=>{const i=A[t];if(!C(i))return;const o=e[t];e[t]=function(A){wI(i,A,e).then(A=>p(o)&&o(A)||A)}}),e}function MI(A,e){const t=[];C(yI.returnValue)&&t.push(...yI.returnValue);const i=DI[A];return i&&C(i.returnValue)&&t.push(...i.returnValue),t.forEach(A=>{e=A(e)||e}),e}function RI(A){const e=Object.create(null);Object.keys(yI).forEach(A=>{"returnValue"!==A&&(e[A]=yI[A].slice())});const t=DI[A];return t&&Object.keys(t).forEach(A=>{"returnValue"!==A&&(e[A]=(e[A]||[]).concat(t[A]))}),e}function _I(A,e,t,i){const o=RI(A);if(o&&Object.keys(o).length){if(C(o.invoke)){return wI(o.invoke,t).then(t=>e(SI(RI(A),t),...i))}return e(SI(o,t),...i)}return e(t,...i)}function TI(A,e){return(t={},...i)=>function(A){return!(!S(A)||![hI,CI,BI].find(e=>p(A[e])))}(t)?MI(A,_I(A,e,u({},t),i)):MI(A,new Promise((o,n)=>{_I(A,e,u({},t,{success:o,fail:n}),i)}))}function NI(A,e,t,i={}){const o=e+":fail";let n="";return n=t?0===t.indexOf(o)?t:o+" "+t:o,delete i.errCode,EI(A,u({errMsg:n},i))}function bI(A,e,t,i){if(i&&i.beforeInvoke){const A=i.beforeInvoke(e);if(f(A))return A}const o=function(A,e){const t=A[0];if(!e||!e.formatArgs||!S(e.formatArgs)&&S(t))return;const i=e.formatArgs,o=Object.keys(i);for(let n=0;n{GI(i);const o=bI(0,[i],0,t);if(o)throw new Error(o);const n=!dI(A);!function(A,e){uI(lI++,A,e,!0)}(A,i),n&&(!function(A){Pv.on("api."+A,e=>{for(const t in II){const i=II[t];i.name===A&&i.callback(e)}})}(A),e())}}function LI(A,e,t){return i=>{GI(i);const o=bI(0,[i],0,t);if(o)throw new Error(o);!function(A,e){for(const t in II){const i=II[t];i.callback===e&&i.name===A&&delete II[t]}}(A=A.replace("off","on"),i);dI(A)||(!function(A){Pv.off("api."+A)}(A),e())}}function UI(A,e,t,i){return t=>{const o=QI(A,t,i),n=bI(0,[t],0,i);return n?NI(o,A,n):e(t,{resolve:e=>function(A,e,t){return EI(A,u(t||{},{errMsg:e+":ok"}))}(o,A,e),reject:(e,t)=>NI(o,A,function(A){return!A||f(A)?A:A.stack?("undefined"!=typeof globalThis&&globalThis.harmonyChannel||console.error(A.message+"\n"+A.stack),A.message):A}(e),t)})}}function FI(A,e,t){return kI(A,e,t)}function OI(A,e,t){return LI(A,e,t)}function xI(A,e,t,i){return TI(A,UI(A,e,0,i))}function PI(A,e,t,i){return function(A,e,t,i){return(...A)=>{const t=bI(0,A,0,i);if(t)throw new Error(t);return e.apply(null,A)}}(0,e,0,i)}function YI(A,e,t,i){return TI(A,function(A,e,t,i){return UI(A,e,0,i)}(A,e,0,i))}function JI(A){return`method 'uni.${A}' not supported`}function HI(A){return()=>{console.error(JI(A))}}const qI=HI;function VI(A){return(e,{reject:t})=>t(JI(A))}const jI=PI(0,A=>function(A){var e,t,i,o,n,r=.75*A.length,s=A.length,a=0;"="===A[A.length-1]&&(r--,"="===A[A.length-2]&&r--);var g=new ArrayBuffer(r),c=new Uint8Array(g);for(e=0;e>4,c[a++]=(15&i)<<4|o>>2,c[a++]=(3&o)<<6|63&n;return g}(A)),KI=PI(0,A=>function(A){var e,t=new Uint8Array(A),i=t.length,o="";for(e=0;e>2],o+=iI[(3&t[e])<<4|t[e+1]>>4],o+=iI[(15&t[e+1])<<2|t[e+2]>>6],o+=iI[63&t[e+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(A));let WI=!1,zI=0,ZI=0,XI=960,$I=375,Au=750;function eu(){let A,e,t;{const{windowWidth:i,pixelRatio:o,platform:n}=function(){const A=aC(),e=lC(cC(A,gC(A)));return{platform:iC?"ios":"other",pixelRatio:window.devicePixelRatio,windowWidth:e}}();A=i,e=o,t=n}zI=A,ZI=e,WI="ios"===t}function tu(A,e){const t=Number(A);return isNaN(t)?e:t}const iu=PI(0,(A,e)=>{if(0===zI&&(eu(),function(){const A=__uniConfig.globalStyle||{};XI=tu(A.rpxCalcMaxDeviceWidth,960),$I=tu(A.rpxCalcBaseDeviceWidth,375),Au=tu(A.rpxCalcBaseDeviceWidth,750)}()),0===(A=Number(A)))return 0;let t=e||zI;t=A===Au||t<=XI?t:$I;let i=A/750*t;return i<0&&(i=-i),i=Math.floor(i+1e-4),0===i&&(i=1!==ZI&&WI?.5:1),A<0?-i:i});function ou(A,e){Object.keys(e).forEach(t=>{p(e[t])&&(A[t]=function(A,e){const t=e?A?A.concat(e):C(e)?e:[e]:A;return t?function(A){const e=[];for(let t=0;t{const i=A[t],o=e[t];C(i)&&p(o)&&E(i,o)})}const ru=PI(0,(A,e)=>{f(A)&&S(e)?ou(DI[A]||(DI[A]={}),e):S(A)&&ou(yI,A)}),su=PI(0,(A,e)=>{f(A)?S(e)?nu(DI[A],e):delete DI[A]:S(A)&&nu(yI,A)});const au=new class{constructor(){this.$emitter=new Be}on(A,e){return this.$emitter.on(A,e)}once(A,e){return this.$emitter.once(A,e)}off(A,e){A?this.$emitter.off(A,e):this.$emitter.e={}}emit(A,...e){this.$emitter.emit(A,...e)}},gu=PI(0,(A,e)=>(au.on(A,e),()=>au.off(A,e))),cu=PI(0,(A,e)=>(au.once(A,e),()=>au.off(A,e))),lu=PI(0,(A,e)=>{C(A)||(A=A?[A]:[]),A.forEach(A=>{au.off(A,e)})}),Iu=PI(0,(A,...e)=>{au.emit(A,...e)});const uu=[.5,.8,1,1.25,1.5,2];class Eu{constructor(A,e){this.id=A,this.pageId=e}play(){IC(this.id,this.pageId,"play")}pause(){IC(this.id,this.pageId,"pause")}stop(){IC(this.id,this.pageId,"stop")}seek(A){IC(this.id,this.pageId,"seek",{position:A})}sendDanmu(A){IC(this.id,this.pageId,"sendDanmu",A)}playbackRate(A){~uu.indexOf(A)||(A=1),IC(this.id,this.pageId,"playbackRate",{rate:A})}requestFullScreen(A={}){IC(this.id,this.pageId,"requestFullScreen",A)}exitFullScreen(){IC(this.id,this.pageId,"exitFullScreen")}showStatusBar(){IC(this.id,this.pageId,"showStatusBar")}hideStatusBar(){IC(this.id,this.pageId,"hideStatusBar")}}const du=PI(0,(A,e)=>new Eu(A,Wc(e||$c()))),hu=(A,e,t,i)=>{!function(A,e,t,i,o){Pv.invokeViewMethod("map."+A,{type:t,data:i},e,o)}(A,e,t,i,A=>{i&&((A,e)=>{const t=e.errMsg||"";new RegExp("\\:\\s*fail").test(t)?A.fail&&A.fail(e):A.success&&A.success(e),A.complete&&A.complete(e)})(i,A)})};class Cu{constructor(A,e){this.id=A,this.pageId=e}getCenterLocation(A){hu(this.id,this.pageId,"getCenterLocation",A)}moveToLocation(A){hu(this.id,this.pageId,"moveToLocation",A)}getScale(A){hu(this.id,this.pageId,"getScale",A)}getRegion(A){hu(this.id,this.pageId,"getRegion",A)}includePoints(A){hu(this.id,this.pageId,"includePoints",A)}translateMarker(A){hu(this.id,this.pageId,"translateMarker",A)}$getAppMap(){}addCustomLayer(A){hu(this.id,this.pageId,"addCustomLayer",A)}removeCustomLayer(A){hu(this.id,this.pageId,"removeCustomLayer",A)}addGroundOverlay(A){hu(this.id,this.pageId,"addGroundOverlay",A)}removeGroundOverlay(A){hu(this.id,this.pageId,"removeGroundOverlay",A)}updateGroundOverlay(A){hu(this.id,this.pageId,"updateGroundOverlay",A)}initMarkerCluster(A){hu(this.id,this.pageId,"initMarkerCluster",A)}addMarkers(A){hu(this.id,this.pageId,"addMarkers",A)}removeMarkers(A){hu(this.id,this.pageId,"removeMarkers",A)}moveAlong(A){hu(this.id,this.pageId,"moveAlong",A)}setLocMarkerIcon(A){hu(this.id,this.pageId,"setLocMarkerIcon",A)}openMapApp(A){hu(this.id,this.pageId,"openMapApp",A)}on(A,e){hu(this.id,this.pageId,"on",{name:A,callback:e})}}const Bu=PI(0,(A,e)=>new Cu(A,Wc(e||$c())));function Qu(A,e){return function(t,i){t?i[A]=Math.round(t):void 0!==e&&(i[A]=e)}}const pu=Qu("width"),fu=Qu("height"),mu={formatArgs:{x:Qu("x"),y:Qu("y"),width:pu,height:fu}},yu={canvasId:{type:String,required:!0},x:{type:Number,required:!0},y:{type:Number,required:!0},width:{type:Number,required:!0},height:{type:Number,required:!0}},Du=mu,vu=(Uint8ClampedArray,{PNG:"png",JPG:"jpg",JPEG:"jpg"}),wu={formatArgs:{x:Qu("x",0),y:Qu("y",0),width:pu,height:fu,destWidth:Qu("destWidth"),destHeight:Qu("destHeight"),fileType(A,e){A=(A||"").toUpperCase();let t=vu[A];t||(t=vu.PNG),e.fileType=t},quality(A,e){e.quality=A&&A>0&&A<1?A:1}}};function Su(A,e,t,i,o){Pv.invokeViewMethod(`canvas.${A}`,{type:t,data:i},e,A=>{o&&o(A)})}var Mu=["scale","rotate","translate","setTransform","transform"],Ru=["drawImage","fillText","fill","stroke","fillRect","strokeRect","clearRect","strokeText"],_u=["setFillStyle","setTextAlign","setStrokeStyle","setGlobalAlpha","setShadow","setFontSize","setLineCap","setLineJoin","setLineWidth","setMiterLimit","setTextBaseline","setLineDash"];const Tu={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"#00000000"};function Nu(A){let e=null;if(null!=(e=/^#([0-9|A-F|a-f]{6})$/.exec(A=A||"#000000"))){return[parseInt(e[1].slice(0,2),16),parseInt(e[1].slice(2,4),16),parseInt(e[1].slice(4),16),255]}if(null!=(e=/^#([0-9|A-F|a-f]{3})$/.exec(A))){let A=e[1].slice(0,1),t=e[1].slice(1,2),i=e[1].slice(2,3);return A=parseInt(A+A,16),t=parseInt(t+t,16),i=parseInt(i+i,16),[A,t,i,255]}if(null!=(e=/^rgb\((.+)\)$/.exec(A)))return e[1].split(",").map(function(A){return Math.min(255,parseInt(A.trim()))}).concat(255);if(null!=(e=/^rgba\((.+)\)$/.exec(A)))return e[1].split(",").map(function(A,e){return 3===e?Math.floor(255*parseFloat(A.trim())):Math.min(255,parseInt(A.trim()))});var t=A.toLowerCase();if(h(Tu,t)){e=/^#([0-9|A-F|a-f]{6,8})$/.exec(Tu[t]);const A=parseInt(e[1].slice(0,2),16),i=parseInt(e[1].slice(2,4),16),o=parseInt(e[1].slice(4,6),16);let n=parseInt(e[1].slice(6,8),16);return n=n>=0?n:255,[A,i,o,n]}return console.error("unsupported color:"+A),[0,0,0,255]}let bu=class{constructor(A,e){this.type=A,this.data=e,this.colorStop=[]}addColorStop(A,e){this.colorStop.push([A,Nu(e)])}};class Gu{constructor(A,e){this.type="pattern",this.data=A,this.colorStop=e}}class ku{constructor(A){this.width=A}}class Lu{constructor(A,e){this.id=A,this.pageId=e,this.actions=[],this.path=[],this.subpath=[],this.drawingState=[],this.state={lineDash:[0,0],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,shadowColor:[0,0,0,0],font:"10px sans-serif",fontSize:10,fontWeight:"normal",fontStyle:"normal",fontFamily:"sans-serif"}}setFillStyle(A){console.log("initCanvasContextProperty implemented.")}setStrokeStyle(A){console.log("initCanvasContextProperty implemented.")}setShadow(A,e,t,i){console.log("initCanvasContextProperty implemented.")}addColorStop(A,e){console.log("initCanvasContextProperty implemented.")}setLineWidth(A){console.log("initCanvasContextProperty implemented.")}setLineCap(A){console.log("initCanvasContextProperty implemented.")}setLineJoin(A){console.log("initCanvasContextProperty implemented.")}setLineDash(A,e){console.log("initCanvasContextProperty implemented.")}setMiterLimit(A){console.log("initCanvasContextProperty implemented.")}fillRect(A,e,t,i){console.log("initCanvasContextProperty implemented.")}strokeRect(A,e,t,i){console.log("initCanvasContextProperty implemented.")}clearRect(A,e,t,i){console.log("initCanvasContextProperty implemented.")}fill(){console.log("initCanvasContextProperty implemented.")}stroke(){console.log("initCanvasContextProperty implemented.")}scale(A,e){console.log("initCanvasContextProperty implemented.")}rotate(A){console.log("initCanvasContextProperty implemented.")}translate(A,e){console.log("initCanvasContextProperty implemented.")}setFontSize(A){console.log("initCanvasContextProperty implemented.")}fillText(A,e,t,i){console.log("initCanvasContextProperty implemented.")}setTextAlign(A){console.log("initCanvasContextProperty implemented.")}setTextBaseline(A){console.log("initCanvasContextProperty implemented.")}drawImage(A,e,t,i,o,n,r,s,a){console.log("initCanvasContextProperty implemented.")}setGlobalAlpha(A){console.log("initCanvasContextProperty implemented.")}strokeText(A,e,t,i){console.log("initCanvasContextProperty implemented.")}setTransform(A,e,t,i,o,n){console.log("initCanvasContextProperty implemented.")}draw(A=!1,e){var t=[...this.actions];this.actions=[],this.path=[],Su(this.id,this.pageId,"actionsChanged",{actions:t,reserve:A},e)}createLinearGradient(A,e,t,i){return new bu("linear",[A,e,t,i])}createCircularGradient(A,e,t){return new bu("radial",[A,e,t])}createPattern(A,e){if(void 0===e)console.error("Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present.");else{if(!(["repeat","repeat-x","repeat-y","no-repeat"].indexOf(e)<0))return new Gu(A,e);console.error("Failed to execute 'createPattern' on 'CanvasContext': The provided type ('"+e+"') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'.")}}measureText(A,e){let t=0;return t=function(A,e){const t=document.createElement("canvas").getContext("2d");return t.font=e,t.measureText(A).width||0}(A,this.state.font),new ku(t)}save(){this.actions.push({method:"save",data:[]}),this.drawingState.push(this.state)}restore(){this.actions.push({method:"restore",data:[]}),this.state=this.drawingState.pop()||{lineDash:[0,0],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,shadowColor:[0,0,0,0],font:"10px sans-serif",fontSize:10,fontWeight:"normal",fontStyle:"normal",fontFamily:"sans-serif"}}beginPath(){this.path=[],this.subpath=[],this.path.push({method:"beginPath",data:[]})}moveTo(A,e){this.path.push({method:"moveTo",data:[A,e]}),this.subpath=[[A,e]]}lineTo(A,e){0===this.path.length&&0===this.subpath.length?this.path.push({method:"moveTo",data:[A,e]}):this.path.push({method:"lineTo",data:[A,e]}),this.subpath.push([A,e])}quadraticCurveTo(A,e,t,i){this.path.push({method:"quadraticCurveTo",data:[A,e,t,i]}),this.subpath.push([t,i])}bezierCurveTo(A,e,t,i,o,n){this.path.push({method:"bezierCurveTo",data:[A,e,t,i,o,n]}),this.subpath.push([o,n])}arc(A,e,t,i,o,n=!1){this.path.push({method:"arc",data:[A,e,t,i,o,n]}),this.subpath.push([A,e])}rect(A,e,t,i){this.path.push({method:"rect",data:[A,e,t,i]}),this.subpath=[[A,e]]}arcTo(A,e,t,i,o){this.path.push({method:"arcTo",data:[A,e,t,i,o]}),this.subpath.push([t,i])}clip(){this.actions.push({method:"clip",data:[...this.path]})}closePath(){this.path.push({method:"closePath",data:[]}),this.subpath.length&&(this.subpath=[this.subpath.shift()])}clearActions(){this.actions=[],this.path=[],this.subpath=[]}getActions(){var A=[...this.actions];return this.clearActions(),A}set lineDashOffset(A){this.actions.push({method:"setLineDashOffset",data:[A]})}set globalCompositeOperation(A){this.actions.push({method:"setGlobalCompositeOperation",data:[A]})}set shadowBlur(A){this.actions.push({method:"setShadowBlur",data:[A]})}set shadowColor(A){this.actions.push({method:"setShadowColor",data:[A]})}set shadowOffsetX(A){this.actions.push({method:"setShadowOffsetX",data:[A]})}set shadowOffsetY(A){this.actions.push({method:"setShadowOffsetY",data:[A]})}set font(A){var e=this;this.state.font=A;var t=A.match(/^(([\w\-]+\s)*)(\d+\.?\d*r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/);if(t){var i=t[1].trim().split(/\s/),o=parseFloat(t[3]),n=t[7],r=[];i.forEach(function(A,t){["italic","oblique","normal"].indexOf(A)>-1?(r.push({method:"setFontStyle",data:[A]}),e.state.fontStyle=A):["bold","normal","lighter","bolder"].indexOf(A)>-1||/^\d+$/.test(A)?(r.push({method:"setFontWeight",data:[A]}),e.state.fontWeight=A):0===t?(r.push({method:"setFontStyle",data:["normal"]}),e.state.fontStyle="normal"):1===t&&s()}),1===i.length&&s(),i=r.map(function(A){return A.data[0]}).join(" "),this.state.fontSize=o,this.state.fontFamily=n,this.actions.push({method:"setFont",data:[`${i} ${o}px ${n}`]})}else console.warn("Failed to set 'font' on 'CanvasContext': invalid format.");function s(){r.push({method:"setFontWeight",data:["normal"]}),e.state.fontWeight="normal"}}get font(){return this.state.font}set fillStyle(A){this.setFillStyle(A)}set strokeStyle(A){this.setStrokeStyle(A)}set globalAlpha(A){A=Math.floor(255*parseFloat(A)),this.actions.push({method:"setGlobalAlpha",data:[A]})}set textAlign(A){this.actions.push({method:"setTextAlign",data:[A]})}set lineCap(A){this.actions.push({method:"setLineCap",data:[A]})}set lineJoin(A){this.actions.push({method:"setLineJoin",data:[A]})}set lineWidth(A){this.actions.push({method:"setLineWidth",data:[A]})}set miterLimit(A){this.actions.push({method:"setMiterLimit",data:[A]})}set textBaseline(A){this.actions.push({method:"setTextBaseline",data:[A]})}}const Uu=HA(()=>{[...Mu,...Ru].forEach(function(A){Lu.prototype[A]=function(A){switch(A){case"fill":case"stroke":return function(){this.actions.push({method:A+"Path",data:[...this.path]})};case"fillRect":return function(A,e,t,i){this.actions.push({method:"fillPath",data:[{method:"rect",data:[A,e,t,i]}]})};case"strokeRect":return function(A,e,t,i){this.actions.push({method:"strokePath",data:[{method:"rect",data:[A,e,t,i]}]})};case"fillText":case"strokeText":return function(e,t,i,o){var n=[e.toString(),t,i];"number"==typeof o&&n.push(o),this.actions.push({method:A,data:n})};case"drawImage":return function(e,t,i,o,n,r,s,a,g){var c;function l(A){return"number"==typeof A}void 0===g&&(r=t,s=i,a=o,g=n,t=void 0,i=void 0,o=void 0,n=void 0),c=l(t)&&l(i)&&l(o)&&l(n)?[e,r,s,a,g,t,i,o,n]:l(a)&&l(g)?[e,r,s,a,g]:[e,r,s],this.actions.push({method:A,data:c})};default:return function(...e){this.actions.push({method:A,data:e})}}}(A)}),_u.forEach(function(A){Lu.prototype[A]=function(A){switch(A){case"setFillStyle":case"setStrokeStyle":return function(e){"object"!=typeof e?this.actions.push({method:A,data:["normal",Nu(e)]}):this.actions.push({method:A,data:[e.type,e.data,e.colorStop]})};case"setGlobalAlpha":return function(e){e=Math.floor(255*parseFloat(e)),this.actions.push({method:A,data:[e]})};case"setShadow":return function(e,t,i,o){o=Nu(o),this.actions.push({method:A,data:[e,t,i,o]}),this.state.shadowBlur=i,this.state.shadowColor=o,this.state.shadowOffsetX=e,this.state.shadowOffsetY=t};case"setLineDash":return function(e,t){e=e||[0,0],t=t||0,this.actions.push({method:A,data:[e,t]}),this.state.lineDash=e};case"setFontSize":return function(e){this.state.font=this.state.font.replace(/\d+\.?\d*px/,e+"px"),this.state.fontSize=e,this.actions.push({method:A,data:[e]})};default:return function(...e){this.actions.push({method:A,data:e})}}}(A)})}),Fu=PI(0,(A,e)=>{if(Uu(),e)return new Lu(A,Wc(e));const t=Wc($c());if(t)return new Lu(A,t);Pv.emit(uA,"createCanvasContext:fail")}),Ou=YI("canvasGetImageData",({canvasId:A,x:e,y:t,width:i,height:o},{resolve:n,reject:r})=>{const s=Wc($c());s?Su(A,s,"getImageData",{x:e,y:t,width:i,height:o},function(A){if(A.errMsg&&-1!==A.errMsg.indexOf("fail"))return void r("",A);let e=A.data;e&&e.length&&(A.data=new Uint8ClampedArray(e)),delete A.compressed,n(A)}):r()},0,mu),xu=YI("canvasPutImageData",({canvasId:A,data:e,x:t,y:i,width:o,height:n},{resolve:r,reject:s})=>{var a=Wc($c());if(!a)return void s();e=Array.prototype.slice.call(e),Su(A,a,"putImageData",{data:e,x:t,y:i,width:o,height:n,compressed:void 0},A=>{A.errMsg&&-1!==A.errMsg.indexOf("fail")?s():r(A)})},0,Du),Pu=YI("canvasToTempFilePath",({x:A=0,y:e=0,width:t,height:i,destWidth:o,destHeight:n,canvasId:r,fileType:s,quality:a},{resolve:g,reject:c})=>{var l=Wc($c());if(!l)return void c();Su(r,l,"toTempFilePath",{x:A,y:e,width:t,height:i,destWidth:o,destHeight:n,fileType:s,quality:a,dirname:"/canvas"},A=>{A.errMsg&&-1!==A.errMsg.indexOf("fail")?c("",A):g(A)})},0,wu),Yu=["onCanplay","onPlay","onPause","onStop","onEnded","onTimeUpdate","onError","onWaiting","onSeeking","onSeeked"],Ju=["offCanplay","offPlay","offPause","offStop","offEnded","offTimeUpdate","offError","offWaiting","offSeeking","offSeeked"],Hu={thresholds:[0],initialRatio:0,observeAll:!1},qu=["top","right","bottom","left"];let Vu=1;function ju(A={}){return qu.map(e=>`${Number(A[e])||0}px`).join(" ")}class Ku{constructor(A,e){this._pageId=Wc(A),this._component=A,this._options=u({},Hu,e)}relativeTo(A,e){return this._options.relativeToSelector=A,this._options.rootMargin=ju(e),this}relativeToViewport(A){return this._options.relativeToSelector=void 0,this._options.rootMargin=ju(A),this}observe(A,e){p(e)&&(this._options.selector=A,this._reqId=Vu++,function({reqId:A,component:e,options:t,callback:i}){const o=Xh(e);(o.__io||(o.__io={}))[A]=function(A,e,t){th();const i=e.relativeToSelector?A.querySelector(e.relativeToSelector):null,o=new IntersectionObserver(A=>{A.forEach(A=>{t({intersectionRatio:oh(A),intersectionRect:ih(A.intersectionRect),boundingClientRect:ih(A.boundingClientRect),relativeRect:ih(A.rootBounds),time:Date.now(),dataset:te(A.target),id:A.target.id})})},{root:i,rootMargin:e.rootMargin,threshold:e.thresholds});if(e.observeAll){o.USE_MUTATION_OBSERVER=!0;const t=A.querySelectorAll(e.selector);for(let A=0;A((A=KA(A))&&!Wc(A)&&(e=A,A=null),new Ku(A||$c(),e)));let zu=1;class Zu{constructor(A){this._pageId=(null==A?void 0:A.$page)&&A.$page.id,this._component=A}observe(A,e){p(e)&&(this._reqId=zu++,function({reqId:A,component:e,options:t,callback:i}){const o=dC[A]=window.matchMedia(function(A){const e=[],t=["width","minWidth","maxWidth","height","minHeight","maxHeight","orientation"];for(const i of t)"orientation"!==i&&A[i]&&Number(A[i]>=0)&&e.push(`(${CC(i)}: ${Number(A[i])}px)`),"orientation"===i&&A[i]&&e.push(`(${CC(i)}: ${A[i]})`);return e.join(" and ")}(t)),n=hC[A]=A=>i(A.matches);n(o),o.addListener(n)}({reqId:this._reqId,component:this._component,options:A,callback:e},this._pageId))}disconnect(){this._reqId&&function({reqId:A,component:e}){const t=hC[A],i=dC[A];i&&(i.removeListener(t),delete hC[A],delete dC[A])}({reqId:this._reqId,component:this._component},this._pageId)}}const Xu=PI(0,A=>((A=KA(A))&&!Wc(A)&&(A=null),new Zu(A||$c())));let $u=0,AE={};const eE={canvas:Lu,map:Cu,video:Eu,editor:class{constructor(A,e){this.id=A,this.pageId=e}format(A,e){this._exec("format",{name:A,value:e})}insertDivider(){this._exec("insertDivider")}insertImage(A){this._exec("insertImage",A)}insertText(A){this._exec("insertText",A)}setContents(A){this._exec("setContents",A)}getContents(A){this._exec("getContents",A)}clear(A){this._exec("clear",A)}removeFormat(A){this._exec("removeFormat",A)}undo(A){this._exec("undo",A)}redo(A){this._exec("redo",A)}blur(A){this._exec("blur",A)}getSelectionText(A){this._exec("getSelectionText",A)}scrollIntoView(A){this._exec("scrollIntoView",A)}_exec(A,e){!function(A,e,t,i){const o={options:i},n=i&&("success"in i||"fail"in i||"complete"in i);if(n){const A=String($u++);o.callbackId=A,AE[A]=i}Pv.invokeViewMethod(`editor.${A}`,{type:t,data:o},e,({callbackId:A,data:e})=>{n&&(qA(AE[A],e),delete AE[A])})}(this.id,this.pageId,A,e)}}};function tE(A){if(A&&A.contextInfo){const{id:e,type:t,page:i}=A.contextInfo,o=eE[t];A.context=new o(e,i),delete A.contextInfo}}class iE{constructor(A,e,t,i){this._selectorQuery=A,this._component=e,this._selector=t,this._single=i}boundingClientRect(A){return this._selectorQuery._push(this._selector,this._component,this._single,{id:!0,dataset:!0,rect:!0,size:!0},A),this._selectorQuery}fields(A,e){return this._selectorQuery._push(this._selector,this._component,this._single,A,e),this._selectorQuery}scrollOffset(A){return this._selectorQuery._push(this._selector,this._component,this._single,{id:!0,dataset:!0,scrollOffset:!0},A),this._selectorQuery}context(A){return this._selectorQuery._push(this._selector,this._component,this._single,{context:!0},A),this._selectorQuery}node(A){return this._selectorQuery._push(this._selector,this._component,this._single,{node:!0},A),this._selectorQuery}}class oE{constructor(A){this._component=void 0,this._page=A,this._queue=[],this._queueCb=[]}exec(A){return function(A,e,t){const i=[];e.forEach(({component:e,selector:t,single:o,fields:n})=>{null===e?i.push(function(A){const e={};A.id&&(e.id="");A.dataset&&(e.dataset={});A.rect&&(e.left=0,e.right=0,e.top=0,e.bottom=0);A.size&&(e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight);if(A.scrollOffset){const A=document.documentElement,t=document.body;e.scrollLeft=A.scrollLeft||t.scrollLeft||0,e.scrollTop=A.scrollTop||t.scrollTop||0,e.scrollHeight=A.scrollHeight||t.scrollHeight||0,e.scrollWidth=A.scrollWidth||t.scrollWidth||0}return e}(n)):i.push(function(A,e,t,i,o){const n=function(A,e){if(!A)return e.$el;return A.$el}(e,A),r=n.parentElement;if(!r)return i?null:[];const{nodeType:s}=n,a=3===s||8===s;if(i){const A=a?r.querySelector(t):EC(n,t)?n:n.querySelector(t);return A?uC(A,o):null}{let A=[];const e=(a?r:n).querySelectorAll(t);return e&&e.length&&[].forEach.call(e,e=>{A.push(uC(e,o))}),!a&&EC(n,t)&&A.unshift(uC(n,o)),A}}(A,e,t,o,n))}),t(i)}(this._page,this._queue,e=>{const t=this._queueCb;e.forEach((A,e)=>{C(A)?A.forEach(tE):tE(A);const i=t[e];p(i)&&i.call(this,A)}),p(A)&&A.call(this,e)}),this._nodesRef}in(A){return this._component=KA(A),this}select(A){return this._nodesRef=new iE(this,this._component,A,!0)}selectAll(A){return this._nodesRef=new iE(this,this._component,A,!1)}selectViewport(){return this._nodesRef=new iE(this,null,"",!0)}_push(A,e,t,i,o){this._queue.push({component:e,selector:A,single:t,fields:i}),this._queueCb.push(o)}}const nE=PI(0,A=>((A=KA(A))&&!Wc(A)&&(A=null),new oE(A||$c()))),rE={formatArgs:{}},sE={duration:400,timingFunction:"linear",delay:0,transformOrigin:"50% 50% 0"};let aE=class{constructor(A){this.actions=[],this.currentTransform={},this.currentStepAnimates=[],this.option=u({},sE,A)}_getOption(A){const e={transition:u({},this.option,A),transformOrigin:""};return e.transformOrigin=e.transition.transformOrigin,delete e.transition.transformOrigin,e}_pushAnimates(A,e){this.currentStepAnimates.push({type:A,args:e})}_converType(A){return A.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`)}_getValue(A){return"number"==typeof A?`${A}px`:A}export(){const A=this.actions;return this.actions=[],{actions:A}}step(A){return this.currentStepAnimates.forEach(A=>{"style"!==A.type?this.currentTransform[A.type]=A:this.currentTransform[`${A.type}.${A.args[0]}`]=A}),this.actions.push({animates:Object.values(this.currentTransform),option:this._getOption(A)}),this.currentStepAnimates=[],this}};const gE=HA(()=>{const A=["opacity","backgroundColor"],e=["width","height","left","right","top","bottom"];["matrix","matrix3d","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","translate","translate3d","translateX","translateY","translateZ"].concat(A,e).forEach(t=>{aE.prototype[t]=function(...i){return A.concat(e).includes(t)?this._pushAnimates("style",[this._converType(t),e.includes(t)?this._getValue(i[0]):i[0]]):this._pushAnimates(t,i),this}})}),cE=PI(0,A=>(gE(),new aE(A)),0,rE),lE=FI("onTabBarMidButtonTap",()=>{}),IE=FI("onWindowResize",()=>{}),uE=OI("offWindowResize",()=>{}),EE="onLocaleChange",dE=PI(0,()=>{const A=np();return A&&A.$vm?A.$vm.$locale:Jg().getLocale()}),hE=FI(EE,()=>{}),CE=PI(0,A=>{const e=np();if(!e)return!1;return e.$vm.$locale!==A&&(e.$vm.$locale=A,navigator.cookieEnabled&&window.localStorage&&(localStorage[nA]=A),Pv.invokeOnCallback(EE,{locale:A}),!0)}),BE=YI("setPageMeta",(A,{resolve:e})=>{e(function(A,{pageStyle:e,rootFontSize:t}){if(e){(document.querySelector("uni-page-body")||document.body).setAttribute("style",e)}t&&document.documentElement.style.fontSize!==t&&(document.documentElement.style.fontSize=t)}($c(),A))}),QE="getSelectedTextRange",pE=YI(QE,(A,{resolve:e,reject:t})=>{Pv.invokeViewMethod(QE,{},Xc(),A=>{void 0===A.end&&void 0===A.start?t("no focused"):e(A)})}),fE={[hA]:[],[dA]:[],[uA]:[],[cA]:[],[lA]:[]};function mE(A,e){const t=np();if(t&&t.$vm)return Go(A,e,t.$vm.$);fE[A].push(e)}function yE(A,e){const t=np();if(t&&t.$vm)return function(A,e,t){const i=A.$[e];C(i)&&t.__weh&&E(i,t.__weh)}(t.$vm,A,e);E(fE[A],e)}const DE=PI(0,()=>vC()),vE=PI(0,()=>u({},yC));let wE,SE,ME;function RE(A){try{return JSON.parse(A)}catch(__){}return A}const _E=[];function TE(A,e){_E.forEach(t=>{t(A,e)}),_E.length=0}const NE=YI("getPushClientId",(A,{resolve:e,reject:t})=>{Promise.resolve().then(()=>{void 0===ME&&(ME=!1,wE="",SE="uniPush is not enabled"),_E.push((A,i)=>{A?e({cid:A}):t(i)}),void 0!==wE&&TE(wE,SE)})}),bE=[],GE={formatArgs:{showToast:!0},beforeInvoke(){Zg()},beforeSuccess(A,e){if(!e.showToast)return;const{t:t}=Jg(),i=t("uni.setClipboardData.success");i&&uni.showToast({title:i,icon:"success",mask:!1})}},kE=(Boolean,"onAccelerometer"),LE="onCompass",UE="removeStorage",FE={formatArgs:{filePath(A,e){e.filePath=AC(A)}}},OE={formatArgs:{filePath(A,e){e.filePath=AC(A)}}},xE=["wgs84","gcj02"],PE={formatArgs:{type(A,e){A=(A||"").toLowerCase(),-1===xE.indexOf(A)?e.type=xE[0]:e.type=A},altitude(A,e){e.altitude=A||!1}}},YE=(Boolean,(A,e)=>{if(void 0===e)return`${A} should not be empty.`;if("number"!=typeof e){let A=typeof e;return A=A[0].toUpperCase()+A.substring(1),`Expected Number, got ${A} with value ${JSON.stringify(e)}.`}}),JE={formatArgs:{latitude(A,e){const t=YE("latitude",A);if(t)return t;e.latitude=A},longitude(A,e){const t=YE("longitude",A);if(t)return t;e.longitude=A},scale(A,e){A=Math.floor(A),e.scale=A>=5&&A<=18?A:18}}},HE={formatArgs:{count(A,e){(!A||A<=0)&&(e.count=9)},sizeType(A,e){e.sizeType=gI(A,nI)},sourceType(A,e){e.sourceType=gI(A,rI)},extension(A,e){if(A instanceof Array&&0===A.length)return"param extension should not be empty.";A||(e.extension=["*"])}}},qE={formatArgs:{sourceType(A,e){e.sourceType=gI(A,rI)},compressed:!0,maxDuration:60,camera:"back",extension(A,e){if(A instanceof Array&&0===A.length)return"param extension should not be empty.";A||(e.extension=["*"])}}},VE=(Boolean,["all","image","video"]),jE={formatArgs:{count(A,e){(!A||A<=0)&&(e.count=100)},sourceType(A,e){e.sourceType=gI(A,rI)},type(A,e){e.type=aI(A,VE)},extension(A,e){if(A instanceof Array&&0===A.length)return"param extension should not be empty.";A||("all"!==e.type&&e.type?e.extension=["*"]:e.extension=[""])}}},KE={formatArgs:{src(A,e){e.src=AC(A)}}},WE={formatArgs:{urls(A,e){e.urls=A.map(A=>f(A)&&A?AC(A):"")},current(A,e){"number"==typeof A?e.current=A>0&&AA),r={};n.forEach(A=>{const e=A.split("=");r[e[0]]=e[1]});for(const s in e)if(h(e,s)){let A=e[s];null==A?A="":S(A)&&(A=JSON.stringify(A)),r[ed(s)]=ed(A)}return o=Object.keys(r).map(A=>`${A}=${r[A]}`).join("&"),A+(o?"?"+o:"")+(i?"#"+i:"")}(A,e.data))},header(A,e){const t=e.header=A||{};e.method!==sI[0]&&(Object.keys(t).find(A=>"content-type"===A.toLowerCase())||(t["Content-Type"]="application/json"))},dataType(A,e){e.dataType=(A||$E).toLowerCase()},responseType(A,e){e.responseType=(A||"").toLowerCase(),-1===Ad.indexOf(e.responseType)&&(e.responseType="text")}}},id={formatArgs:{header(A,e){e.header=A||{}}}},od={formatArgs:{filePath(A,e){A&&(e.filePath=AC(A))},header(A,e){e.header=A||{}},formData(A,e){e.formData=A||{}}}},nd={formatArgs:{header(A,e){e.header=A||{}},method(A,e){e.method=aI((A||"").toUpperCase(),sI)},protocols(A,e){f(A)&&(e.protocols=[A])}}},rd="onLocationChange",sd="onLocationChangeError",ad=["wgs84","gcj02"],gd={formatArgs:{type(A,e){A=(A||"").toLowerCase(),-1===ad.indexOf(A)?e.type=ad[1]:e.type=A}}};const cd={url:{type:String,required:!0}},ld="navigateTo",Id="redirectTo",ud="reLaunch",Ed="switchTab",dd="preloadPage",hd=(fd(["slide-in-right","slide-in-left","slide-in-top","slide-in-bottom","fade-in","zoom-out","zoom-fade-out","pop-in","none"]),fd(["slide-out-right","slide-out-left","slide-out-top","slide-out-bottom","fade-out","zoom-in","zoom-fade-in","pop-out","none"]),Dd(ld)),Cd=Dd(Id),Bd=Dd(ud),Qd=Dd(Ed),pd={formatArgs:{delta(A,e){A=parseInt(A+"")||1,e.delta=Math.min(Lh().length-1,A)}}};function fd(A){return{animationType:{type:String,validator(e){if(e&&-1===A.indexOf(e))return"`"+e+"` is not supported for `animationType` (supported values are: `"+A.join("`|`")+"`)"}},animationDuration:{type:Number}}}let md;function yd(){md=""}function Dd(A){return{formatArgs:{url:vd(A)},beforeAll:yd}}function vd(A){return function(e,t){if(!e)return'Missing required args: "url"';const i=(e=function(A){if(0===A.indexOf("/")||0===A.indexOf("uni:"))return A;let e="";const t=Lh();return t.length&&(e=xc(t[t.length-1]).route),al(e,A)}(e)).split("?")[0],o=gl(i,!0);if(!o)return"page `"+e+"` is not found";if(A===ld||A===Id){if(o.meta.isTabBar)return`can not ${A} a tabbar page`}else if(A===Ed&&!o.meta.isTabBar)return"can not switch to no-tabBar page";if(A!==Ed&&A!==dd||!o.meta.isTabBar||"appLaunch"===t.openType||(e=i),o.meta.isEntry&&(e=e.replace(o.alias,"/")),t.url=function(A){if(!f(A))return A;const e=A.indexOf("?");if(-1===e)return A;const t=A.slice(e+1).trim().replace(/^(\?|#|&)/,"");if(!t)return A;A=A.slice(0,e);const i=[];return t.split("&").forEach(A=>{const e=A.replace(/\+/g," ").split("="),t=e.shift(),o=e.length>0?e.join("="):"";i.push(t+"="+encodeURIComponent(o))}),i.length?A+"?"+i.join("&"):A}(e),"unPreloadPage"!==A)if(A!==dd){if(md===e&&"appLaunch"!==t.openType)return`${md} locked`;__uniConfig.ready&&(md=e)}else if(o.meta.isTabBar){const A=Lh(),e=o.path.slice(1);if(A.find(A=>A.route===e))return"tabBar page `"+e+"` already exists"}}}const wd="setNavigationBarColor",Sd={formatArgs:{animation(A,e){A||(A={duration:0,timingFunc:"linear"}),e.animation={duration:A.duration||0,timingFunc:A.timingFunc||"linear"}}}},Md="setNavigationBarTitle",Rd="showNavigationBarLoading",_d="hideNavigationBarLoading",Td={formatArgs:{duration:300}},Nd={formatArgs:{itemColor:"#000"}},bd=(Boolean,{formatArgs:{title:"",mask:!1}}),Gd=(Boolean,{beforeInvoke(){Wg()},formatArgs:{title:"",content:"",placeholderText:"",showCancel:!0,editable:!1,cancelText(A,e){if(!h(e,"cancelText")){const{t:A}=Jg();e.cancelText=A("uni.showModal.cancel")}},cancelColor:"#000",confirmText(A,e){if(!h(e,"confirmText")){const{t:A}=Jg();e.confirmText=A("uni.showModal.confirm")}},confirmColor:sA}}),kd=["success","loading","none","error"],Ld=(Boolean,{formatArgs:{title:"",icon(A,e){e.icon=aI(A,kd)},image(A,e){e.image=A?AC(A):""},duration:1500,mask:!1}}),Ud="startPullDownRefresh",Fd="stopPullDownRefresh",Od={beforeInvoke(){const A=Zc();if(A&&!A.isTabBar)return"not TabBar page"},formatArgs:{index(A){if(!__uniConfig.tabBar.list[A])return"tabbar item not found"}}},xd="setTabBarItem",Pd={beforeInvoke:Od.beforeInvoke,formatArgs:u({pagePath(A,e){A&&(e.pagePath=YA(A))}},Od.formatArgs)},Yd="setTabBarStyle",Jd=/^(linear|radial)-gradient\(.+?\);?$/,Hd={beforeInvoke:Od.beforeInvoke,formatArgs:{backgroundImage(A,e){A&&!Jd.test(A)&&(e.backgroundImage=AC(A))},borderStyle(A,e){A&&(e.borderStyle="white"===A?"white":"black")}}},qd="hideTabBar",Vd="showTabBar",Kd="hideTabBarRedDot",Wd=Od,zd="showTabBarRedDot",Zd=Od,Xd="removeTabBarBadge",$d=Od,Ah="setTabBarBadge",eh={beforeInvoke:Od.beforeInvoke,formatArgs:u({text(A,e){(function(A=""){return(""+A).replace(/[^\x00-\xff]/g,"**").length})(A)>=4&&(e.text="...")}},Od.formatArgs)},th=function(){if("object"==typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var A=function(){for(var A=window.document,e=o(A);e;)e=o(A=e.ownerDocument);return A}(),e=[],t=null,i=null;r.prototype.THROTTLE_TIMEOUT=100,r.prototype.POLL_INTERVAL=null,r.prototype.USE_MUTATION_OBSERVER=!0,r._setupCrossOriginUpdater=function(){return t||(t=function(A,t){i=A&&t?I(A,t):{top:0,bottom:0,left:0,right:0,width:0,height:0},e.forEach(function(A){A._checkForIntersections()})}),t},r._resetCrossOriginUpdater=function(){t=null,i=null},r.prototype.observe=function(A){if(!this._observationTargets.some(function(e){return e.element==A})){if(!A||1!=A.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:A,entry:null}),this._monitorIntersections(A.ownerDocument),this._checkForIntersections()}},r.prototype.unobserve=function(A){this._observationTargets=this._observationTargets.filter(function(e){return e.element!=A}),this._unmonitorIntersections(A.ownerDocument),0==this._observationTargets.length&&this._unregisterInstance()},r.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},r.prototype.takeRecords=function(){var A=this._queuedEntries.slice();return this._queuedEntries=[],A},r.prototype._initThresholds=function(A){var e=A||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(function(A,e,t){if("number"!=typeof A||isNaN(A)||A<0||A>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return A!==t[e-1]})},r.prototype._parseRootMargin=function(A){var e=(A||"0px").split(/\s+/).map(function(A){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(A);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}});return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e},r.prototype._monitorIntersections=function(e){var t=e.defaultView;if(t&&-1==this._monitoringDocuments.indexOf(e)){var i=this._checkForIntersections,n=null,r=null;this.POLL_INTERVAL?n=t.setInterval(i,this.POLL_INTERVAL):(s(t,"resize",i,!0),s(e,"scroll",i,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in t&&(r=new t.MutationObserver(i)).observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0})),this._monitoringDocuments.push(e),this._monitoringUnsubscribes.push(function(){var A=e.defaultView;A&&(n&&A.clearInterval(n),a(A,"resize",i,!0)),a(e,"scroll",i,!0),r&&r.disconnect()});var g=this.root&&(this.root.ownerDocument||this.root)||A;if(e!=g){var c=o(e);c&&this._monitorIntersections(c.ownerDocument)}}},r.prototype._unmonitorIntersections=function(e){var t=this._monitoringDocuments.indexOf(e);if(-1!=t){var i=this.root&&(this.root.ownerDocument||this.root)||A;if(!this._observationTargets.some(function(A){var t=A.element.ownerDocument;if(t==e)return!0;for(;t&&t!=i;){var n=o(t);if((t=n&&n.ownerDocument)==e)return!0}return!1})){var n=this._monitoringUnsubscribes[t];if(this._monitoringDocuments.splice(t,1),this._monitoringUnsubscribes.splice(t,1),n(),e!=i){var r=o(e);r&&this._unmonitorIntersections(r.ownerDocument)}}}},r.prototype._unmonitorAllIntersections=function(){var A=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e=0&&s>=0&&{top:t,bottom:i,left:o,right:n,width:r,height:s}||null}function c(A){var e;try{e=A.getBoundingClientRect()}catch(t){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):{top:0,bottom:0,left:0,right:0,width:0,height:0}}function l(A){return!A||"x"in A?A:{top:A.top,y:A.top,bottom:A.bottom,left:A.left,x:A.left,right:A.right,width:A.width,height:A.height}}function I(A,e){var t=e.top-A.top,i=e.left-A.left;return{top:t,left:i,height:e.height,width:e.width,bottom:t+e.height,right:i+e.width}}function u(A,e){for(var t=e;t;){if(t==A)return!0;t=E(t)}return!1}function E(e){var t=e.parentNode;return 9==e.nodeType&&e!=A?o(e):(t&&t.assignedSlot&&(t=t.assignedSlot.parentNode),t&&11==t.nodeType&&t.host?t.host:t)}function d(A){return A&&9===A.nodeType}};function ih(A){const{bottom:e,height:t,left:i,right:o,top:n,width:r}=A||{};return{bottom:e,height:t,left:i,right:o,top:n,width:r}}function oh(A){const{intersectionRatio:e,boundingClientRect:{height:t,width:i},intersectionRect:{height:o,width:n}}=A;return 0!==e?e:o===t?n/i:o/t}function nh(){const A=$c();if(!A)return;const e=kh(),t=e.keys();for(const i of t){const A=e.get(i);A.$.__isTabBar?A.$.__isActive=!1:Fh(i)}A.$.__isTabBar&&(A.$.__isVisible=!1,il(A,lA))}function rh(A,e){return A===e.fullPath||"/"===A&&e.meta.isEntry}function sh(A){const e=kh().values();for(const t of e){const e=Rh(t);if(rh(A,e))return t.$.__isActive=!0,e.id}}const ah=YI(Ed,({url:A,tabBarText:e,isAutomatedTesting:t},{resolve:i,reject:o})=>{if(_h.handledBeforeEntryPageRoutes)return nh(),uh({type:Ed,url:A,tabBarText:e,isAutomatedTesting:t},sh(A)).then(i).catch(o);Nh.push({args:{type:Ed,url:A,tabBarText:e,isAutomatedTesting:t},resolve:i,reject:o})},0,Qd);function gh(){const A=zc();if(!A)return;const e=Rh(A);Fh(Yh(e.path,e.id))}const ch=YI(Id,({url:A,isAutomatedTesting:e},{resolve:t,reject:i})=>{if(_h.handledBeforeEntryPageRoutes)return gh(),uh({type:Id,url:A,isAutomatedTesting:e}).then(t).catch(i);bh.push({args:{type:Id,url:A,isAutomatedTesting:e},resolve:t,reject:i})},0,Cd);function lh(){const A=kh().keys();for(const e of A)Fh(e)}const Ih=YI(ud,({url:A,isAutomatedTesting:e},{resolve:t,reject:i})=>{if(_h.handledBeforeEntryPageRoutes)return lh(),uh({type:ud,url:A,isAutomatedTesting:e}).then(t).catch(i);Gh.push({args:{type:ud,url:A,isAutomatedTesting:e},resolve:t,reject:i})},0,Bd);function uh({type:A,url:e,tabBarText:t,events:i,isAutomatedTesting:o},n){const r=np().$router,{path:s,query:a}=function(A){const[e,t]=A.split("?",2);return{path:e,query:ge(t||"")}}(e);return new Promise((e,g)=>{const c=function(A,e){return{__id__:e||++Oh,__type__:A}}(A,n);r["navigateTo"===A?"push":"replace"]({path:s,query:a,state:c,force:!0}).then(n=>{if(Pa(n))return g(n.message);if("switchTab"===A&&(r.currentRoute.value.meta.tabBarText=t),"navigateTo"===A){const A=r.currentRoute.value.meta;return A.eventChannel?i&&(Object.keys(i).forEach(e=>{A.eventChannel._addListener(e,"on",i[e])}),A.eventChannel._clearCache()):A.eventChannel=new le(c.__id__,i),e(o?{__id__:c.__id__}:{eventChannel:A.eventChannel})}return o?e({__id__:c.__id__}):e()})})}function Eh(){if(_h.handledBeforeEntryPageRoutes)return;_h.handledBeforeEntryPageRoutes=!0;const A=[...Th];Th.length=0,A.forEach(({args:A,resolve:e,reject:t})=>uh(A).then(e).catch(t));const e=[...Nh];Nh.length=0,e.forEach(({args:A,resolve:e,reject:t})=>(nh(),uh(A,sh(A.url)).then(e).catch(t)));const t=[...bh];bh.length=0,t.forEach(({args:A,resolve:e,reject:t})=>(gh(),uh(A).then(e).catch(t)));const i=[...Gh];Gh.length=0,i.forEach(({args:A,resolve:e,reject:t})=>(lh(),uh(A).then(e).catch(t)))}let dh;function hh(){var A;return dh||(dh=__uniConfig.tabBar&&Nt((A=__uniConfig.tabBar,Fg()&&A.list&&A.list.forEach(A=>{Yg(A,["text"])}),A))),dh}function Ch(A){const e=window.CSS&&window.CSS.supports;return e&&(e(A)||e.apply(window.CSS,A.split(":")))}const Bh=Ch("--a:0"),Qh=Ch("top:env(a)"),ph=Ch("top:constant(a)"),fh=Ch("backdrop-filter:blur(10px)"),mh={"css.var":Bh,"css.env":Qh,"css.constant":ph,"css.backdrop-filter":fh},yh=PI(0,A=>h(mh,A)?mh[A]:!!h(uni,A)),Dh=(()=>Qh?"env":ph?"constant":"")();function vh(A){let e=0,t=0;if("custom"!==A.navigationBar.style&&["default","float"].indexOf(A.navigationBar.type)>-1&&(e=44),A.isTabBar){const A=hh();A.shown&&(t=parseInt(A.height))}var i;Lc({"--window-top":(i=e,Dh?`calc(${i}px + ${Dh}(safe-area-inset-top))`:`${i}px`),"--window-bottom":wh(t)})}function wh(A){return Dh?`calc(${A}px + ${Dh}(safe-area-inset-bottom))`:`${A}px`}const Sh="$$",Mh=new Map;function Rh(A){return A.$page}const _h={handledBeforeEntryPageRoutes:!1},Th=[],Nh=[],bh=[],Gh=[];function kh(){return Mh}function Lh(){return Uh()}function Uh(){const A=[],e=Mh.values();for(const t of e)t.$.__isTabBar?t.$.__isActive&&A.push(t):A.push(t);return A}function Fh(A,e=!0){const t=Mh.get(A);t.$.__isUnload=!0,il(t,QA),Mh.delete(A),e&&function(A){const e=Jh.get(A);e&&(Jh.delete(A),Hh.pruneCacheEntry(e))}(A)}let Oh=tI();function xh(A){const e=$l();let t=A.fullPath;return A.meta.isEntry&&-1===t.indexOf(A.meta.route)&&(t="/"+A.meta.route+t.replace("/","")),function(A,e,t,i,o,n){const{id:r,route:s}=i,a=fe(i.navigationBar,__uniConfig.themeConfig,n).titleColor;return{id:r,path:PA(s),route:s,fullPath:e,options:t,meta:i,openType:A,eventChannel:o,statusBarStyle:"#ffffff"===a?"light":"dark"}}("navigateTo",t,{},e)}function Ph(A){const e=xh(A.$route);!function(A,e){A.route=e.route,A.$vm=A,A.$page=e,A.$mpType="page",A.$fontFamilySet=new Set,e.meta.isTabBar&&(A.$.__isTabBar=!0,A.$.__isActive=!0)}(A,e),Mh.set(Yh(e.path,e.id),A),1===Mh.size&&setTimeout(()=>{Eh()},0)}function Yh(A,e){return A+Sh+e}const Jh=new Map,Hh={get:A=>Jh.get(A),set(A,e){!function(A){const e=parseInt(A.split(Sh)[1]);if(!e)return;Hh.forEach((A,t)=>{const i=parseInt(t.split(Sh)[1]);if(i&&i>e){if(function(A){return"tabBar"===A.props.type}(A))return;Hh.delete(t),Hh.pruneCacheEntry(A),pi(()=>{Mh.forEach((A,e)=>{A.$.isUnmounted&&Mh.delete(e)})})}})}(A),Jh.set(A,e)},delete(A){Jh.get(A)&&Jh.delete(A)},forEach(A){Jh.forEach(A)}};function qh(A,e){!function(A){const e=jh(A),{body:t}=document;Kh&&t.removeAttribute(Kh),e&&t.setAttribute(e,""),Kh=e}(A),vh(e),function(A){{const e="nvue-dir-"+__uniConfig.nvue["flex-direction"];A.isNVue?(document.body.setAttribute("nvue",""),document.body.setAttribute(e,"")):(document.body.removeAttribute("nvue"),document.body.removeAttribute(e))}}(e),Zh(A,e)}function Vh(A){const e=jh(A);e&&function(A){const e=document.querySelector("uni-page-body");e&&e.setAttribute(A,"")}(e)}function jh(A){return A.type.__scopeId}let Kh;const Wh=!!(()=>{let A=!1;try{const e={};Object.defineProperty(e,"passive",{get(){A=!0}}),window.addEventListener("test-passive",()=>{},e)}catch(__){}return A})()&&{passive:!1};let zh;function Zh(A,e){if(document.removeEventListener("touchmove",ol),zh&&document.removeEventListener("scroll",zh),e.disableScroll)return document.addEventListener("touchmove",ol,Wh);const{onPageScroll:t,onReachBottom:i}=A,o="transparent"===e.navigationBar.type;if(!(null==t?void 0:t.length)&&!(null==i?void 0:i.length)&&!o)return;const n={},r=Rh(A.proxy).id;(t||o)&&(n.onPageScroll=function(A,e,t){return i=>{e&&Ov.publishHandler(DA,{scrollTop:i},A),t&&Ov.emit(A+"."+DA,{scrollTop:i})}}(r,t,o)),(null==i?void 0:i.length)&&(n.onReachBottomDistance=e.onReachBottomDistance||50,n.onReachBottom=()=>Ov.publishHandler(wA,{},r)),zh=sl(n),requestAnimationFrame(()=>document.addEventListener("scroll",zh))}function Xh(A){return A.$el}function $h(A){const{base:e}=__uniConfig.router;return 0===PA(A).indexOf(e)?PA(A):e+A}function AC(A){const{base:e,assets:t}=__uniConfig.router;if("./"===e&&(0!==A.indexOf("./")||!A.includes("/static/")&&0!==A.indexOf("./"+(t||"assets")+"/")||(A=A.slice(1))),0===A.indexOf("/")){if(0!==A.indexOf("//"))return $h(A.slice(1));A="https:"+A}if(aA.test(A)||gA.test(A)||0===A.indexOf("blob:"))return A;const i=Uh();return i.length?$h(al(Rh(i[i.length-1]).route,A).slice(1)):A}const eC=navigator.userAgent,tC=/android/i.test(eC),iC=/iphone|ipad|ipod/i.test(eC),oC=eC.match(/Windows NT ([\d|\d.\d]*)/i),nC=/Macintosh|Mac/i.test(eC),rC=/Linux|X11/i.test(eC),sC=nC&&navigator.maxTouchPoints>0;function aC(){return/^Apple/.test(navigator.vendor)&&"number"==typeof window.orientation}function gC(A){return A&&90===Math.abs(window.orientation)}function cC(A,e){return A?Math[e?"max":"min"](screen.width,screen.height):screen.width}function lC(A){return Math.min(window.innerWidth,document.documentElement.clientWidth,A)||A}function IC(A,e,t,i){Pv.invokeViewMethod("video."+A,{videoId:A,type:t,data:i},e)}function uC(A,e){const t={},{top:i,topWindowHeight:o}=Gc();if(e.node){const e=A.tagName.split("-")[1]||A.tagName;e&&(t.node=A.querySelector(e))}if(e.id&&(t.id=A.id),e.dataset&&(t.dataset=te(A)),e.rect||e.size){const n=A.getBoundingClientRect();e.rect&&(t.left=n.left,t.right=n.right,t.top=n.top-i-o,t.bottom=n.bottom-i-o),e.size&&(t.width=n.width,t.height=n.height)}if(C(e.properties)&&e.properties.forEach(A=>{A=A.replace(/-([a-z])/g,function(A,e){return e.toUpperCase()})}),e.scrollOffset)if("UNI-SCROLL-VIEW"===A.tagName){const e=A.children[0].children[0];t.scrollLeft=e.scrollLeft,t.scrollTop=e.scrollTop,t.scrollHeight=e.scrollHeight,t.scrollWidth=e.scrollWidth}else t.scrollLeft=0,t.scrollTop=0,t.scrollHeight=0,t.scrollWidth=0;if(C(e.computedStyle)){const i=getComputedStyle(A);e.computedStyle.forEach(A=>{t[A]=i[A]})}return e.context&&(t.contextInfo=function(A){return A.__uniContextInfo}(A)),t}function EC(A,e){return(A.matches||A.matchesSelector||A.mozMatchesSelector||A.msMatchesSelector||A.oMatchesSelector||A.webkitMatchesSelector||function(A){const e=this.parentElement.querySelectorAll(A);let t=e.length;for(;--t>=0&&e.item(t)!==this;);return t>-1}).call(A,e)}let dC={},hC={};function CC(A){return A.replace(/([A-Z])/g,"-$1").toLowerCase()}const BC={};function QC(A,e){const t=BC[A];return t?Promise.resolve(t):/^data:[a-z-]+\/[a-z-]+;base64,/.test(A)?Promise.resolve(function(A){const e=A.split(","),t=e[0].match(/:(.*?);/),i=t?t[1]:"",o=atob(e[1]);let n=o.length;const r=new Uint8Array(n);for(;n--;)r[n]=o.charCodeAt(n);return pC(r,i)}(A)):e?Promise.reject(new Error("not find")):new Promise((e,t)=>{const i=new XMLHttpRequest;i.open("GET",A,!0),i.responseType="blob",i.onload=function(){e(this.response)},i.onerror=t,i.send()})}function pC(A,e){let t;if(A instanceof File)t=A;else{e=e||A.type||"";const o=`${Date.now()}${function(A){const e=A.split("/")[1];return e?`.${e}`:""}(e)}`;try{t=new File([A],o,{type:e})}catch(i){t=A=A instanceof Blob?A:new Blob([A],{type:e}),t.name=t.name||o}}return t}function fC(A){for(const t in BC)if(h(BC,t)){if(BC[t]===A)return t}var e=(window.URL||window.webkitURL).createObjectURL(A);return BC[e]=A,e}function mC(A){(window.URL||window.webkitURL).revokeObjectURL(A),delete BC[A]}const yC=Nl(),DC=Nl();function vC(){return u({},DC)}const wC=Ll({name:"ResizeSensor",props:{initial:{type:Boolean,default:!1}},emits:["resize"],setup(A,{emit:e}){const t=Kt(null),i=function(A){return()=>{const{firstElementChild:e,lastElementChild:t}=A.value;e.scrollLeft=1e5,e.scrollTop=1e5,t.scrollLeft=1e5,t.scrollTop=1e5}}(t),o=function(A,e,t){const i=Nt({width:-1,height:-1});return Xi(()=>u({},i),A=>e("resize",A)),()=>{const e=A.value;e&&(i.width=e.offsetWidth,i.height=e.offsetHeight,t())}}(t,e,i);return function(A,e,t,i){wo(i),Uo(()=>{e.initial&&pi(t);const o=A.value;o.offsetParent!==o.parentElement&&(o.parentElement.style.position="relative"),"AnimationEvent"in window||i()})}(t,A,o,i),()=>Ir("uni-resize-sensor",{ref:t,onAnimationstartOnce:o},[Ir("div",{onScroll:o},[Ir("div",null,null)],40,["onScroll"]),Ir("div",{onScroll:o},[Ir("div",null,null)],40,["onScroll"])],40,["onAnimationstartOnce"])}});const SC=function(){if(navigator.userAgent.includes("jsdom"))return 1;const A=document.createElement("canvas");A.height=A.width=0;const e=A.getContext("2d"),t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t}();function MC(A,e=!0){const t=e?SC:1;A.width=A.offsetWidth*t,A.height=A.offsetHeight*t,A.getContext("2d").__hidpi__=e}let RC=!1;function _C(){if(RC)return;RC=!0;const A={fillRect:"all",clearRect:"all",strokeRect:"all",moveTo:"all",lineTo:"all",arc:[0,1,2],arcTo:"all",bezierCurveTo:"all",isPointinPath:"all",isPointinStroke:"all",quadraticCurveTo:"all",rect:"all",translate:"all",createRadialGradient:"all",createLinearGradient:"all",transform:[4,5],setTransform:[4,5]},e=CanvasRenderingContext2D.prototype;e.drawImageByCanvas=function(A){return function(e,t,i,o,n,r,s,a,g,c){if(!this.__hidpi__)return A.apply(this,arguments);t*=SC,i*=SC,o*=SC,n*=SC,r*=SC,s*=SC,a=c?a*SC:a,g=c?g*SC:g,A.call(this,e,t,i,o,n,r,s,a,g)}}(e.drawImage),1!==SC&&(!function(A,e){for(const t in A)h(A,t)&&e(A[t],t)}(A,function(A,t){e[t]=function(e){return function(){if(!this.__hidpi__)return e.apply(this,arguments);let t=Array.prototype.slice.call(arguments);if("all"===A)t=t.map(function(A){return A*SC});else if(Array.isArray(A))for(let e=0;e_C());function NC(A){return A?AC(A):A}function bC(A){return(A=A.slice(0))[3]=A[3]/255,"rgba("+A.join(",")+")"}function GC(A,e){Array.from(e).forEach(e=>{e.x=e.clientX-A.left,e.y=e.clientY-A.top})}let kC;function LC(A=0,e=0){return kC||(kC=document.createElement("canvas")),kC.width=A,kC.height=e,kC}const UC=Ll({inheritAttrs:!1,name:"Canvas",compatConfig:{MODE:3},props:{canvasId:{type:String,default:""},disableScroll:{type:[Boolean,String],default:!1},hidpi:{type:Boolean,default:!0}},computed:{id(){return this.canvasId}},setup(A,{emit:e,slots:t}){TC();const i=Kt(null),o=Kt(null),n=Kt(null),r=Kt(!1),s=function(A){return(e,t)=>{A(e,hl(t))}}(e),{$attrs:a,$excludeAttrs:g,$listeners:c}=MB({excludeListeners:!0}),{_listeners:l}=function(A,e,t){const i=Ur(()=>{let i=["onTouchstart","onTouchmove","onTouchend"],o=e.value,n=u({},(()=>{let A={};for(const e in o)if(h(o,e)){const t=o[e];A[e]=t}return A})());return i.forEach(e=>{let i=[];n[e]&&i.push(Fl(A=>{const i=A.currentTarget.getBoundingClientRect();GC(i,A.touches),GC(i,A.changedTouches),t(e.replace("on","").toLocaleLowerCase(),A)})),A.disableScroll&&"onTouchmove"===e&&i.push(_c),n[e]=i}),n});return{_listeners:i}}(A,c,s),{_handleSubscribe:I,_resize:E}=function(A,e,t){let i=[],o={};const n=Ur(()=>A.hidpi?SC:1);function r(t){let i=e.value;if(!t||i.width!==Math.floor(t.width*n.value)||i.height!==Math.floor(t.height*n.value))if(i.width>0&&i.height>0){let e=i.getContext("2d"),t=e.getImageData(0,0,i.width,i.height);MC(i,A.hidpi),e.putImageData(t,0,0)}else MC(i,A.hidpi)}function s({actions:A,reserve:n},r){if(!A)return;if(t.value)return void i.push([A,n]);let s=e.value,c=s.getContext("2d");n||(c.fillStyle="#000000",c.strokeStyle="#000000",c.shadowColor="#000000",c.shadowBlur=0,c.shadowOffsetX=0,c.shadowOffsetY=0,c.setTransform(1,0,0,1,0,0),c.clearRect(0,0,s.width,s.height)),a(A);for(let e=0;e{A.src=e}).catch(()=>{A.src=i})}"drawImage"===e?(i=t[0],i=NC(i),t[0]=i):"setFillStyle"===e&&"pattern"===t[0]&&(i=t[1],i=NC(i),t[1]=i),i&&!o[i]&&n()})}function g(A,e,n,r){let a=o[A];return a.ready?(r(a),!0):(i.unshift([e,!0]),t.value=!0,a.onload=function(){a.ready=!0,r(a),t.value=!1;let A=i.slice(0);i=[];for(let e=A.shift();e;)s({actions:e[0],reserve:e[1]},n),e=A.shift()},!1)}function c({x:A=0,y:t=0,width:i,height:o,destWidth:r,destHeight:s,hidpi:a=!0,dataType:g,quality:c=1,type:l="png"},I){const u=e.value;let E;const d=u.offsetWidth-A;i=i?Math.min(i,d):d;const h=u.offsetHeight-t;o=o?Math.min(o,h):h,a?(r=i,s=o):r||s?r?s||(s=Math.round(o/i*r)):(s||(s=Math.round(o*n.value)),r=Math.round(i/o*s)):(r=Math.round(i*n.value),s=Math.round(o*n.value));const C=LC(r,s),B=C.getContext("2d");let Q;"jpeg"!==l&&"jpg"!==l||(l="jpeg",B.fillStyle="#fff",B.fillRect(0,0,r,s)),B.__hidpi__=!0,B.drawImageByCanvas(u,A,t,i,o,0,0,r,s,!1);try{let A;if("base64"===g)E=C.toDataURL(`image/${l}`,c);else{const A=B.getImageData(0,0,r,s);E=Array.prototype.slice.call(A.data)}Q={data:E,compressed:A,width:r,height:s}}catch(p){Q={errMsg:`canvasGetImageData:fail ${p}`}}if(C.height=C.width=0,B.__hidpi__=!1,!I)return Q;I(Q)}function l({data:A,x:t,y:i,width:o,height:n,compressed:r},s){try{0,n||(n=Math.round(A.length/4/o));const r=LC(o,n);r.getContext("2d").putImageData(new ImageData(new Uint8ClampedArray(A),o,n),0,0),e.value.getContext("2d").drawImage(r,t,i,o,n),r.height=r.width=0}catch(a){return void s({errMsg:"canvasPutImageData:fail"})}s({errMsg:"canvasPutImageData:ok"})}function I({x:A=0,y:e=0,width:t,height:i,destWidth:o,destHeight:n,fileType:r,quality:s,dirname:a},g){const l=c({x:A,y:e,width:t,height:i,destWidth:o,destHeight:n,hidpi:!1,dataType:"base64",type:r,quality:s});var I;l.errMsg?g({errMsg:l.errMsg.replace("canvasPutImageData","toTempFilePath")}):(I=l.data,((A,e)=>{let t="toTempFilePath:"+(A?"fail":"ok");A&&(t+=` ${A.message}`),g({errMsg:t,tempFilePath:e})})(null,I))}const E={actionsChanged:s,getImageData:c,putImageData:l,toTempFilePath:I};function d(A,e,t){let i=E[A];0!==A.indexOf("_")&&p(i)&&i(e,t)}return u(E,{_resize:r,_handleSubscribe:d})}(A,o,r);return LQ(I,FQ(A.canvasId),!0),Uo(()=>{E()}),()=>{const{canvasId:e,disableScroll:r}=A;return Ir("uni-canvas",Qr({ref:i,"canvas-id":e,"disable-scroll":r},a.value,g.value,l.value),[Ir("canvas",{ref:o,class:"uni-canvas-canvas",width:"300",height:"150"},null,512),Ir("div",{style:"position: absolute;top: 0;left: 0;width: 100%;height: 100%;overflow: hidden;"},[t.default&&t.default()]),Ir(wC,{ref:n,onResize:E},null,8,["onResize"])],16,["canvas-id","disable-scroll"])}}});const FC=Uc("ucg"),OC=Ll({name:"CheckboxGroup",props:{name:{type:String,default:""}},emits:["change"],setup(A,{emit:e,slots:t}){const i=Kt(null);return function(A,e){const t=[],i=()=>t.reduce((A,e)=>(e.value.checkboxChecked&&A.push(e.value.value),A),new Array);Qn(FC,{addField(A){t.push(A)},removeField(A){t.splice(t.indexOf(A),1)},checkboxChange(A){e("change",A,{value:i()})}});const o=pn(Jl,!1);o&&o.addField({submit:()=>{let e=["",null];return""!==A.name&&(e[0]=A.name,e[1]=i()),e}})}(A,Ol(i,e)),()=>Ir("uni-checkbox-group",{ref:i},[t.default&&t.default()],512)}});const xC=Ll({name:"Checkbox",props:{checked:{type:[Boolean,String],default:!1},id:{type:String,default:""},disabled:{type:[Boolean,String],default:!1},value:{type:String,default:""},color:{type:String,default:"#007aff"},backgroundColor:{type:String,default:""},borderColor:{type:String,default:""},activeBackgroundColor:{type:String,default:""},activeBorderColor:{type:String,default:""},iconColor:{type:String,default:""},foreColor:{type:String,default:""}},setup(A,{slots:e}){const t=Kt(null),i=Kt(A.checked),o=Ur(()=>"true"===i.value||!0===i.value),n=Kt(A.value);const r=Ur(()=>function(e){if(A.disabled)return{backgroundColor:"#E1E1E1",borderColor:"#D1D1D1"};const t={};return e?(A.activeBorderColor&&(t.borderColor=A.activeBorderColor),A.activeBackgroundColor&&(t.backgroundColor=A.activeBackgroundColor)):(A.borderColor&&(t.borderColor=A.borderColor),A.backgroundColor&&(t.backgroundColor=A.backgroundColor)),t}(o.value));Xi([()=>A.checked,()=>A.value],([A,e])=>{i.value=A,n.value=e});const{uniCheckGroup:s,uniLabel:a}=function(A,e,t){const i=Ur(()=>({checkboxChecked:Boolean(A.value),value:e.value})),o={reset:t},n=pn(FC,!1);n&&n.addField(i);const r=pn(Jl,!1);r&&r.addField(o);const s=pn(Vl,!1);return xo(()=>{n&&n.removeField(i),r&&r.removeField(o)}),{uniCheckGroup:n,uniForm:r,uniLabel:s}}(i,n,()=>{i.value=!1}),g=e=>{A.disabled||(i.value=!i.value,s&&s.checkboxChange(e),e.stopPropagation())};return a&&(a.addHandler(g),xo(()=>{a.removeHandler(g)})),Kl(A,{"label-click":g}),()=>{const o=Yl(A,"disabled");let n;return n=i.value,Ir("uni-checkbox",Qr(o,{id:A.id,onClick:g,ref:t}),[Ir("div",{class:"uni-checkbox-wrapper",style:{"--HOVER-BD-COLOR":A.activeBorderColor}},[Ir("div",{class:["uni-checkbox-input",{"uni-checkbox-input-disabled":A.disabled}],style:r.value},[n?jc(Yc,A.disabled?"#ADADAD":A.foreColor||A.iconColor||A.color,22):""],6),e.default&&e.default()],4)],16,["id","onClick"])}}});function PC(){}const YC={cursorSpacing:{type:[Number,String],default:0},showConfirmBar:{type:[Boolean,String],default:"auto"},adjustPosition:{type:[Boolean,String],default:!0},autoBlur:{type:[Boolean,String],default:!1}};function JC(A,e,t){function i(A){const e=Ur(()=>0===String(navigator.vendor).indexOf("Apple"));A.addEventListener("focus",()=>{clearTimeout(undefined),document.addEventListener("click",PC,!1)});A.addEventListener("blur",()=>{e.value&&A.blur(),document.removeEventListener("click",PC,!1),e.value&&document.documentElement.scrollTo(document.documentElement.scrollLeft,document.documentElement.scrollTop)})}Xi(()=>e.value,A=>A&&i(A))}var HC=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,qC=/^<\/([-A-Za-z0-9_]+)[^>]*>/,VC=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g,jC=$C("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"),KC=$C("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),WC=$C("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),zC=$C("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),ZC=$C("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),XC=$C("script,style");function $C(A){for(var e={},t=A.split(","),i=0;iA/e],heightFix:["offsetHeight","width",(A,e)=>A*e]},tB={aspectFit:["center center","contain"],aspectFill:["center center","cover"],widthFix:[,"100% 100%"],heightFix:[,"100% 100%"],top:["center top"],bottom:["center bottom"],center:["center center"],left:["left center"],right:["right center"],"top left":["left top"],"top right":["right top"],"bottom left":["left bottom"],"bottom right":["right bottom"]},iB=Ll({name:"Image",props:AB,setup(A,{emit:e}){const t=Kt(null),i=function(A,e){const t=Kt(""),i=Ur(()=>{let A="auto",i="";const o=tB[e.mode];return o?(o[0]&&(i=o[0]),o[1]&&(A=o[1])):(i="0% 0%",A="100% 100%"),`background-image:${t.value?'url("'+t.value+'")':"none"};background-position:${i};background-size:${A};`}),o=Nt({rootEl:A,src:Ur(()=>e.src?AC(e.src):""),origWidth:0,origHeight:0,origStyle:{width:"",height:""},modeStyle:i,imgSrc:t});return Uo(()=>{const e=A.value;o.origWidth=e.clientWidth||0,o.origHeight=e.clientHeight||0}),o}(t,A),o=Ol(t,e),{fixSize:n}=function(A,e,t){const i=()=>{const{mode:i}=e,o=eB[i];if(!o)return;const{origWidth:n,origHeight:r}=t,s=n&&r?n/r:0;if(!s)return;const a=A.value,g=a[o[0]];g&&(a.style[o[1]]=function(A){oB&&A>10&&(A=2*Math.round(A/2));return A}(o[2](g,s))+"px")},o=()=>{const{style:e}=A.value,{origStyle:{width:i,height:o}}=t;e.width=i,e.height=o};return Xi(()=>e.mode,(A,e)=>{eB[e]&&o(),eB[A]&&i()}),{fixSize:i,resetSize:o}}(t,A,i);return function(A,e,t,i,o){let n,r;const s=(e=0,t=0,i="")=>{A.origWidth=e,A.origHeight=t,A.imgSrc=i},a=a=>{if(!a)return g(),void s();n=n||new Image,n.onload=A=>{const{width:c,height:l}=n;s(c,l,a),pi(()=>{i()}),n.draggable=e.draggable,r&&r.remove(),r=n,t.value.appendChild(n),g(),o("load",A,{width:c,height:l})},n.onerror=e=>{s(),g(),o("error",e,{errMsg:`GET ${A.src} 404 (Not Found)`})},n.src=a},g=()=>{n&&(n.onload=null,n.onerror=null,n=null)};Xi(()=>A.src,A=>a(A)),Xi(()=>A.imgSrc,A=>{!A&&r&&(r.remove(),r=null)}),Uo(()=>a(A.src)),xo(()=>g())}(i,A,t,n,o),()=>Ir("uni-image",{ref:t},[Ir("div",{style:i.modeStyle},null,4),eB[A.mode]?Ir(wC,{onResize:n},null,8,["onResize"]):Ir("span",null,null)],512)}});const oB="Google Inc."===navigator.vendor;const nB=oe(!0),rB=[];let sB=0,aB=!1;const gB=A=>rB.forEach(e=>e.userAction=A);function cB(A={userAction:!1}){if(!aB){["touchstart","touchmove","touchend","mousedown","mouseup"].forEach(A=>{document.addEventListener(A,function(){!sB&&gB(!0),sB++,setTimeout(()=>{! --sB&&gB(!1)},0)},nB)}),aB=!0}rB.push(A)}const lB=()=>!!sB;function IB(){const A=Nt({userAction:!1});return Uo(()=>{cB(A)}),xo(()=>{!function(A){const e=rB.indexOf(A);e>=0&&rB.splice(e,1)}(A)}),{state:A}}function uB(A,e){const t=document.activeElement;if(!t)return e({});const i={};["input","textarea"].includes(t.tagName.toLowerCase())&&(i.start=t.selectionStart,i.end=t.selectionEnd),e(i)}function EB(A,e,t){"number"===e&&isNaN(Number(A))&&(A="");return null==A?"":String(A)}const dB=["none","text","decimal","numeric","tel","search","email","url"],hB=u({},{name:{type:String,default:""},modelValue:{type:[String,Number]},value:{type:[String,Number]},disabled:{type:[Boolean,String],default:!1},autoFocus:{type:[Boolean,String],default:!1},focus:{type:[Boolean,String],default:!1},cursor:{type:[Number,String],default:-1},selectionStart:{type:[Number,String],default:-1},selectionEnd:{type:[Number,String],default:-1},type:{type:String,default:"text"},password:{type:[Boolean,String],default:!1},placeholder:{type:String,default:""},placeholderStyle:{type:String,default:""},placeholderClass:{type:String,default:""},maxlength:{type:[Number,String],default:140},confirmType:{type:String,default:"done"},confirmHold:{type:Boolean,default:!1},ignoreCompositionEvent:{type:Boolean,default:!0},step:{type:String,default:"0.000000000000000001"},inputmode:{type:String,default:void 0,validator:A=>!!~dB.indexOf(A)},cursorColor:{type:String,default:""}},YC),CB=["input","focus","blur","update:value","update:modelValue","update:focus","compositionstart","compositionupdate","compositionend","keyboardheightchange"];function BB(A,e,t,i){let o=null;o=ce(t=>{e.value=EB(t,A.type)},100,{setTimeout:setTimeout,clearTimeout:clearTimeout}),Xi(()=>A.modelValue,o),Xi(()=>A.value,o);const n=function(A,e){let t,i,o=0;const n=function(...n){const r=Date.now();clearTimeout(t),i=()=>{i=null,o=r,A.apply(this,n)},r-o{o.cancel(),t("update:modelValue",e.value),t("update:value",e.value),i("input",A,e)},100);return Lo(()=>{o.cancel(),n.cancel()}),{trigger:i,triggerInput:(A,e,t)=>{o.cancel(),n(A,e),t&&n.flush()}}}function QB(A,e){IB();const t=Ur(()=>A.autoFocus||A.focus);function i(){if(!t.value)return;const A=e.value;A?A.focus():setTimeout(i,100)}Xi(()=>A.focus,A=>{A?i():function(){const A=e.value;A&&A.blur()}()}),Uo(()=>{t.value&&pi(i)})}function pB(A,e,t,i){sc(Xc(),"getSelectedTextRange",uB);const{fieldRef:o,state:n,trigger:r}=function(A,e,t){const i=Kt(null),o=Ol(e,t),n=Ur(()=>{const e=Number(A.selectionStart);return isNaN(e)?-1:e}),r=Ur(()=>{const e=Number(A.selectionEnd);return isNaN(e)?-1:e}),s=Ur(()=>{const e=Number(A.cursor);return isNaN(e)?-1:e}),a=Ur(()=>{var e=Number(A.maxlength);return isNaN(e)?140:e});let g="";g=EB(A.modelValue,A.type)||EB(A.value,A.type);const c=Nt({value:g,valueOrigin:g,maxlength:a,focus:A.focus,composing:!1,selectionStart:n,selectionEnd:r,cursor:s});return Xi(()=>c.focus,A=>t("update:focus",A)),Xi(()=>c.maxlength,A=>c.value=c.value.slice(0,A),{immediate:!1}),{fieldRef:i,state:c,trigger:o}}(A,e,t),{triggerInput:s}=BB(A,n,t,r);QB(A,o),JC(0,o);const{state:a}=function(){const A=Nt({attrs:{}});return Uo(()=>{let e=Dr();for(;e;){const t=e.type.__scopeId;t&&(A.attrs[t]=""),e=e.proxy&&"page"===e.proxy.$mpType?null:e.parent}}),{state:A}}();!function(A,e){const t=pn(Jl,!1);if(!t)return;const i=Dr(),o={submit(){const t=i.proxy;return[t[A],f(e)?t[e]:e.value]},reset(){f(e)?i.proxy[e]="":e.value=""}};t.addField(o),xo(()=>{t.removeField(o)})}("name",n),function(A,e,t,i,o,n){function r(){const t=A.value;t&&e.focus&&e.selectionStart>-1&&e.selectionEnd>-1&&"number"!==t.type&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd)}function s(){const t=A.value;t&&e.focus&&e.selectionStart<0&&e.selectionEnd<0&&e.cursor>-1&&"number"!==t.type&&(t.selectionEnd=t.selectionStart=e.cursor)}function a(A){return"number"===A.type?null:A.selectionEnd}Xi([()=>e.selectionStart,()=>e.selectionEnd],r),Xi(()=>e.cursor,s),Xi(()=>A.value,function(){const g=A.value;if(!g)return;const c=function(A,i){A.stopPropagation(),p(n)&&!1===n(A,e)||(e.value=g.value,e.composing&&t.ignoreCompositionEvent||o(A,{value:g.value,cursor:a(g)},i))};function l(A){t.ignoreCompositionEvent||i(A.type,A,{value:A.data})}g.addEventListener("change",A=>A.stopPropagation()),g.addEventListener("focus",function(A){e.focus=!0,i("focus",A,{value:e.value}),r(),s()}),g.addEventListener("blur",function(A){e.composing&&(e.composing=!1,c(A,!0)),e.focus=!1,i("blur",A,{value:e.value,cursor:a(A.target)})}),g.addEventListener("input",c),g.addEventListener("compositionstart",A=>{A.stopPropagation(),e.composing=!0,l(A)}),g.addEventListener("compositionend",A=>{A.stopPropagation(),e.composing&&(e.composing=!1,c(A)),l(A)}),g.addEventListener("compositionupdate",l)})}(o,n,A,r,s,i);return{fieldRef:o,state:n,scopedAttrsState:a,fixDisabledColor:0===String(navigator.vendor).indexOf("Apple")&&CSS.supports("image-orientation:from-image"),trigger:r}}const fB=u({},hB,{placeholderClass:{type:String,default:"input-placeholder"},textContentType:{type:String,default:""}}),mB=HA(()=>{{const A=navigator.userAgent;let e="";const t=A.match(/OS\s([\w_]+)\slike/);if(t)e=t[1].replace(/_/g,".");else if(/Macintosh|Mac/i.test(A)&&navigator.maxTouchPoints>0){const t=A.match(/Version\/(\S*)\b/);t&&(e=t[1])}return!!e&&parseInt(e)>=16&&parseFloat(e)<17.2}});function yB(A,e,t,i,o){if(e.value)if("."===A.data){if("."===e.value.slice(-1))return t.value=i.value=e.value=e.value.slice(0,-1),!1;if(e.value&&!e.value.includes("."))return e.value+=".",o&&(o.fn=()=>{t.value=i.value=e.value=e.value.slice(0,-1),i.removeEventListener("blur",o.fn)},i.addEventListener("blur",o.fn)),!1}else if("deleteContentBackward"===A.inputType&&mB()&&"."===e.value.slice(-2,-1))return e.value=t.value=i.value=e.value.slice(0,-2),!0}function DB(A){return"insertFromPaste"===A.inputType}const vB=Ll({name:"Input",props:fB,emits:["confirm",...CB],setup(A,{emit:e,expose:t}){const i=["text","number","idcard","digit","password","tel"],o=["off","one-time-code"],n=Ur(()=>{let e="";switch(A.type){case"text":e="text","search"===A.confirmType&&(e="search");break;case"idcard":e="text";break;case"digit":e="number";break;default:e=i.includes(A.type)?A.type:"text"}return A.password?"password":e}),r=Ur(()=>{const e=o.indexOf(A.textContentType),t=o.indexOf(G(A.textContentType));return o[-1!==e?e:-1!==t?t:0]}),s=Ur(()=>{if(A.inputmode)return A.inputmode});let a=function(A,e){if("number"===e.value){const e=void 0===A.modelValue?A.value:A.modelValue,t=Kt(null!=e?e.toLocaleString():"");return Xi(()=>A.modelValue,A=>{t.value=null!=A?A.toLocaleString():""}),Xi(()=>A.value,A=>{t.value=null!=A?A.toLocaleString():""}),t}return Kt("")}(A,n),g={fn:null};const c=Kt(null),{fieldRef:l,state:I,scopedAttrsState:u,fixDisabledColor:E,trigger:d}=pB(A,c,e,(A,e)=>{const t=A.target;if("number"===n.value){if(g.fn&&(t.removeEventListener("blur",g.fn),g.fn=null),t.validity&&!t.validity.valid){if((!a.value||!t.value)&&"-"===A.data||"-"===a.value[0]&&"deleteContentBackward"===A.inputType)return a.value="-",e.value="",g.fn=()=>{a.value=t.value=""},t.addEventListener("blur",g.fn),!1;const i=yB(A,a,e,t,g);return"boolean"==typeof i?i:(a.value=e.value=t.value="-"===a.value?"":a.value,!1)}{const i=yB(A,a,e,t,g);if("boolean"==typeof i)return i;a.value=t.value}if(e.maxlength>0&&t.value.length>e.maxlength&&!DB(A))return t.value=a.value=e.value,!1}});Xi(()=>I.value,e=>{"number"!==A.type||"-"===a.value&&""===e||(a.value=e.toString())}),Xi(()=>A.maxlength,A=>{A=parseInt(A,10);const e=I.value.slice(0,A);e!==I.value&&(I.value=e)});const h=["number","digit"],C=Ur(()=>h.includes(A.type)?A.step:"");function B(e){if("Enter"!==e.key)return;const t=e.target;e.stopPropagation(),d("confirm",e,{value:t.value}),!A.confirmHold&&t.blur()}return t({$triggerInput:A=>{e("update:modelValue",A.value),e("update:value",A.value),I.value=A.value}}),()=>{let e=A.disabled&&E?Ir("input",{key:"disabled-input",ref:l,value:I.value,tabindex:"-1",readonly:!!A.disabled,type:n.value,maxlength:I.maxlength,step:C.value,class:"uni-input-input",style:A.cursorColor?{caretColor:A.cursorColor}:{},onFocus:A=>A.target.blur()},null,44,["value","readonly","type","maxlength","step","onFocus"]):Ir("input",{key:"input",ref:l,value:I.value,onInput:A=>{const e=A.target.value.toString();"number"===n.value&&I.maxlength>0&&e.length>I.maxlength?DB(A)&&(I.value=e.slice(0,I.maxlength)):I.value=e},disabled:!!A.disabled,type:n.value,maxlength:I.maxlength,step:C.value,enterkeyhint:A.confirmType,pattern:"number"===A.type?"[0-9]*":void 0,class:"uni-input-input",style:A.cursorColor?{caretColor:A.cursorColor}:{},autocomplete:r.value,onKeyup:B,inputmode:s.value},null,44,["value","onInput","disabled","type","maxlength","step","enterkeyhint","pattern","autocomplete","onKeyup","inputmode"]);return Ir("uni-input",{ref:c},[Ir("div",{class:"uni-input-wrapper"},[io(Ir("div",Qr(u.attrs,{style:A.placeholderStyle,class:["uni-input-placeholder",A.placeholderClass]}),[A.placeholder],16),[[ss,!(I.value.length||"-"===a.value||a.value.includes("."))]]),"search"===A.confirmType?Ir("form",{action:"",onSubmit:A=>A.preventDefault(),class:"uni-input-form"},[e],40,["onSubmit"]):e])],512)}}});const wB=["class","style"],SB=/^on[A-Z]+/,MB=(A={})=>{const{excludeListeners:e=!1,excludeKeys:t=[]}=A,i=Dr(),o=Wt({}),n=Wt({}),r=Wt({}),s=t.concat(wB);return i.attrs=Nt(i.attrs),zi(()=>{const A=(t=i.attrs,Object.keys(t).map(A=>[A,t[A]])).reduce((A,[t,i])=>(s.includes(t)?A.exclude[t]=i:SB.test(t)?(e||(A.attrs[t]=i),A.listeners[t]=i):A.attrs[t]=i,A),{exclude:{},attrs:{},listeners:{}});var t;o.value=A.attrs,n.value=A.listeners,r.value=A.exclude}),{$attrs:o,$listeners:n,$excludeAttrs:r}};function RB(A){const e=[];return C(A)&&A.forEach(A=>{rr(A)?A.type===Kn?e.push(...RB(A.children)):e.push(A):C(A)&&e.push(...RB(A))}),e}const _B=Ll({inheritAttrs:!1,name:"MovableArea",props:{scaleArea:{type:Boolean,default:!1}},setup(A,{slots:e}){const t=Kt(null),i=Kt(!1);let{setContexts:o,events:n}=function(A,e){const t=Kt(0),i=Kt(0),o=Nt({x:null,y:null}),n=Kt(null);let r=null,s=[];function a(e){e&&1!==e&&(A.scaleArea?s.forEach(function(A){A._setScale(e)}):r&&r._setScale(e))}function g(A,t=s){let i=e.value;function o(A){for(let e=0;e{let t=e.touches;if(t&&t.length>1){let e={x:t[1].pageX-t[0].pageX,y:t[1].pageY-t[0].pageY};if(n.value=TB(e),o.x=e.x,o.y=e.y,!A.scaleArea){let A=g(t[0].target),e=g(t[1].target);r=A&&A===e?A:null}}}),l=Fl(A=>{let e=A.touches;if(e&&e.length>1){A.preventDefault();let t={x:e[1].pageX-e[0].pageX,y:e[1].pageY-e[0].pageY};if(null!==o.x&&n.value&&n.value>0){a(TB(t)/n.value)}o.x=t.x,o.y=t.y}}),I=Fl(e=>{let t=e.touches;t&&t.length||e.changedTouches&&(o.x=0,o.y=0,n.value=null,A.scaleArea?s.forEach(function(A){A._endScale()}):r&&r._endScale())});function u(){E(),s.forEach(function(A,e){A.setParent()})}function E(){let A=window.getComputedStyle(e.value),o=e.value.getBoundingClientRect();t.value=o.width-["Left","Right"].reduce(function(e,t){const i="padding"+t;return e+parseFloat(A["border"+t+"Width"])+parseFloat(A[i])},0),i.value=o.height-["Top","Bottom"].reduce(function(e,t){const i="padding"+t;return e+parseFloat(A["border"+t+"Width"])+parseFloat(A[i])},0)}return Qn("movableAreaWidth",t),Qn("movableAreaHeight",i),{setContexts(A){s=A},events:{_onTouchstart:c,_onTouchmove:l,_onTouchend:I,_resize:u}}}(A,t);const{$listeners:r,$attrs:s,$excludeAttrs:a}=MB(),g=r.value;["onTouchstart","onTouchmove","onTouchend"].forEach(A=>{let e=g[A],t=n[`_${A}`];g[A]=e?[].concat(e,t):t}),Uo(()=>{n._resize(),i.value=!0});let c=[];const l=[];function I(){const A=[];for(let e=0;et===A.rootRef.value);i&&A.push(Pt(i))}o(A)}return Qn("_isMounted",i),Qn("movableAreaRootRef",t),Qn("addMovableViewContext",A=>{l.push(A),I()}),Qn("removeMovableViewContext",A=>{const e=l.indexOf(A);e>=0&&(l.splice(e,1),I())}),()=>{const A=e.default&&e.default();return c=RB(A),Ir("uni-movable-area",Qr({ref:t},s.value,a.value,g),[Ir(wC,{onResize:n._resize},null,8,["onResize"]),c],16)}}});function TB(A){return Math.sqrt(A.x*A.x+A.y*A.y)}const NB=function(A,e,t,i){A.addEventListener(e,A=>{p(t)&&!1===t(A)&&((void 0===A.cancelable||A.cancelable)&&A.preventDefault(),A.stopPropagation())},{passive:!1})};let bB,GB;function kB(A,e,t){xo(()=>{document.removeEventListener("mousemove",bB),document.removeEventListener("mouseup",GB)});let i=0,o=0,n=0,r=0;const s=function(A,t,s,a){if(!1===e({cancelable:A.cancelable,target:A.target,currentTarget:A.currentTarget,preventDefault:A.preventDefault.bind(A),stopPropagation:A.stopPropagation.bind(A),touches:A.touches,changedTouches:A.changedTouches,detail:{state:t,x:s,y:a,dx:s-i,dy:a-o,ddx:s-n,ddy:a-r,timeStamp:A.timeStamp}}))return!1};let a,g,c=null;NB(A,"touchstart",function(A){if(a=!0,1===A.touches.length&&!c)return c=A,i=n=A.touches[0].pageX,o=r=A.touches[0].pageY,s(A,"start",i,o)}),NB(A,"mousedown",function(A){if(g=!0,!a&&!c)return c=A,i=n=A.pageX,o=r=A.pageY,s(A,"start",i,o)}),NB(A,"touchmove",function(A){if(1===A.touches.length&&c){const e=s(A,"move",A.touches[0].pageX,A.touches[0].pageY);return n=A.touches[0].pageX,r=A.touches[0].pageY,e}});const l=bB=function(A){if(!a&&g&&c){const e=s(A,"move",A.pageX,A.pageY);return n=A.pageX,r=A.pageY,e}};document.addEventListener("mousemove",l),NB(A,"touchend",function(A){if(0===A.touches.length&&c)return a=!1,c=null,s(A,"end",A.changedTouches[0].pageX,A.changedTouches[0].pageY)});const I=GB=function(A){if(g=!1,!a&&c)return c=null,s(A,"end",A.pageX,A.pageY)};document.addEventListener("mouseup",I),NB(A,"touchcancel",function(A){if(c){a=!1;const e=c;return c=null,s(A,t?"cancel":"end",e.touches[0].pageX,e.touches[0].pageY)}})}function LB(A,e,t){return A>e-t&&Athis._t&&(A=this._t,this._lastDt=A);let e=this._x_v*A+.5*this._x_a*Math.pow(A,2)+this._x_s,t=this._y_v*A+.5*this._y_a*Math.pow(A,2)+this._y_s;return(this._x_a>0&&ethis._endPositionX)&&(e=this._endPositionX),(this._y_a>0&&tthis._endPositionY)&&(t=this._endPositionY),{x:e,y:t}},OB.prototype.ds=function(A){return void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3),A>this._t&&(A=this._t),{dx:this._x_v+this._x_a*A,dy:this._y_v+this._y_a*A}},OB.prototype.delta=function(){return{x:-1.5*Math.pow(this._x_v,2)/this._x_a||0,y:-1.5*Math.pow(this._y_v,2)/this._y_a||0}},OB.prototype.dt=function(){return-this._x_v/this._x_a},OB.prototype.done=function(){const A=LB(this.s().x,this._endPositionX)||LB(this.s().y,this._endPositionY)||this._lastDt===this._t;return this._lastDt=null,A},OB.prototype.setEnd=function(A,e){this._endPositionX=A,this._endPositionY=e},OB.prototype.reconfigure=function(A,e){this._m=A,this._f=1e3*e},xB.prototype._solve=function(A,e){const t=this._c,i=this._m,o=this._k,n=t*t-4*i*o;if(0===n){const o=-t/(2*i),n=A,r=e/(o*A);return{x:function(A){return(n+r*A)*Math.pow(Math.E,o*A)},dx:function(A){const e=Math.pow(Math.E,o*A);return o*(n+r*A)*e+r*e}}}if(n>0){const o=(-t-Math.sqrt(n))/(2*i),r=(-t+Math.sqrt(n))/(2*i),s=(e-o*A)/(r-o),a=A-s;return{x:function(A){let e,t;return A===this._t&&(e=this._powER1T,t=this._powER2T),this._t=A,e||(e=this._powER1T=Math.pow(Math.E,o*A)),t||(t=this._powER2T=Math.pow(Math.E,r*A)),a*e+s*t},dx:function(A){let e,t;return A===this._t&&(e=this._powER1T,t=this._powER2T),this._t=A,e||(e=this._powER1T=Math.pow(Math.E,o*A)),t||(t=this._powER2T=Math.pow(Math.E,r*A)),a*o*e+s*r*t}}}const r=Math.sqrt(4*i*o-t*t)/(2*i),s=-t/2*i,a=A,g=(e-s*A)/r;return{x:function(A){return Math.pow(Math.E,s*A)*(a*Math.cos(r*A)+g*Math.sin(r*A))},dx:function(A){const e=Math.pow(Math.E,s*A),t=Math.cos(r*A),i=Math.sin(r*A);return e*(g*r*t-a*r*i)+s*e*(g*i+a*t)}}},xB.prototype.x=function(A){return void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3),this._solution?this._endPosition+this._solution.x(A):0},xB.prototype.dx=function(A){return void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3),this._solution?this._solution.dx(A):0},xB.prototype.setEnd=function(A,e,t){if(t||(t=(new Date).getTime()),A!==this._endPosition||!UB(e,.1)){e=e||0;let i=this._endPosition;this._solution&&(UB(e,.1)&&(e=this._solution.dx((t-this._startTime)/1e3)),i=this._solution.x((t-this._startTime)/1e3),UB(e,.1)&&(e=0),UB(i,.1)&&(i=0),i+=this._endPosition),this._solution&&UB(i-A,.1)&&UB(e,.1)||(this._endPosition=A,this._solution=this._solve(i-this._endPosition,e),this._startTime=t)}},xB.prototype.snap=function(A){this._startTime=(new Date).getTime(),this._endPosition=A,this._solution={x:function(){return 0},dx:function(){return 0}}},xB.prototype.done=function(A){return A||(A=(new Date).getTime()),LB(this.x(),this._endPosition,.1)&&UB(this.dx(),.1)},xB.prototype.reconfigure=function(A,e,t){this._m=A,this._k=e,this._c=t,this.done()||(this._solution=this._solve(this.x()-this._endPosition,this.dx()),this._startTime=(new Date).getTime())},xB.prototype.springConstant=function(){return this._k},xB.prototype.damping=function(){return this._c},xB.prototype.configuration=function(){return[{label:"Spring Constant",read:this.springConstant.bind(this),write:function(A,e){A.reconfigure(1,e,A.damping())}.bind(this,this),min:100,max:1e3},{label:"Damping",read:this.damping.bind(this),write:function(A,e){A.reconfigure(1,A.springConstant(),e)}.bind(this,this),min:1,max:500}]},PB.prototype.setEnd=function(A,e,t,i){const o=(new Date).getTime();this._springX.setEnd(A,i,o),this._springY.setEnd(e,i,o),this._springScale.setEnd(t,i,o),this._startTime=o},PB.prototype.x=function(){const A=((new Date).getTime()-this._startTime)/1e3;return{x:this._springX.x(A),y:this._springY.x(A),scale:this._springScale.x(A)}},PB.prototype.done=function(){const A=(new Date).getTime();return this._springX.done(A)&&this._springY.done(A)&&this._springScale.done(A)},PB.prototype.reconfigure=function(A,e,t){this._springX.reconfigure(A,e,t),this._springY.reconfigure(A,e,t),this._springScale.reconfigure(A,e,t)};function YB(A,e){return+((1e3*A-1e3*e)/1e3).toFixed(1)}const JB=Ll({name:"MovableView",props:{direction:{type:String,default:"none"},inertia:{type:[Boolean,String],default:!1},outOfBounds:{type:[Boolean,String],default:!1},x:{type:[Number,String],default:0},y:{type:[Number,String],default:0},damping:{type:[Number,String],default:20},friction:{type:[Number,String],default:2},disabled:{type:[Boolean,String],default:!1},scale:{type:[Boolean,String],default:!1},scaleMin:{type:[Number,String],default:.1},scaleMax:{type:[Number,String],default:10},scaleValue:{type:[Number,String],default:1},animation:{type:[Boolean,String],default:!0}},emits:["change","scale"],setup(A,{slots:e,emit:t}){const i=Kt(null),o=Ol(i,t),{setParent:n}=function(A,e,t){const i=pn("_isMounted",Kt(!1)),o=pn("addMovableViewContext",()=>{}),n=pn("removeMovableViewContext",()=>{});let r,s,a=Kt(1),g=Kt(1),c=Kt(!1),l=Kt(0),I=Kt(0),u=null,E=null,d=!1,h=null,C=null;const B=new FB,Q=new FB,p={historyX:[0,0],historyY:[0,0],historyT:[0,0]},f=Ur(()=>{let e=Number(A.friction);return isNaN(e)||e<=0?2:e}),m=new OB(1,f.value);Xi(()=>A.disabled,()=>{q()});const{_updateOldScale:y,_endScale:D,_setScale:v,scaleValueSync:w,_updateBoundary:S,_updateOffset:M,_updateWH:R,_scaleOffset:_,minX:T,minY:N,maxX:b,maxY:G,FAandSFACancel:k,_getLimitXY:L,_setTransform:U,_revise:F,dampingNumber:O,xMove:x,yMove:P,xSync:Y,ySync:J,_STD:H}=function(A,e,t,i,o,n,r,s,a,g){const c=Ur(()=>{let e=Number(A.scaleMin);return isNaN(e)?.1:e}),l=Ur(()=>{let e=Number(A.scaleMax);return isNaN(e)?10:e}),I=Kt(Number(A.scaleValue)||1);Xi(I,A=>{U(A)}),Xi(c,()=>{L()}),Xi(l,()=>{L()}),Xi(()=>A.scaleValue,A=>{I.value=Number(A)||0});const{_updateBoundary:u,_updateOffset:E,_updateWH:d,_scaleOffset:h,minX:C,minY:B,maxX:Q,maxY:p}=function(A,e,t){const i=pn("movableAreaWidth",Kt(0)),o=pn("movableAreaHeight",Kt(0)),n=pn("movableAreaRootRef"),r={x:0,y:0},s={x:0,y:0},a=Kt(0),g=Kt(0),c=Kt(0),l=Kt(0),I=Kt(0),u=Kt(0);function E(){let A=0-r.x+s.x,e=i.value-a.value-r.x-s.x;c.value=Math.min(A,e),I.value=Math.max(A,e);let t=0-r.y+s.y,n=o.value-g.value-r.y-s.y;l.value=Math.min(t,n),u.value=Math.max(t,n)}function d(){r.x=VB(A.value,n.value),r.y=jB(A.value,n.value)}function h(i){i=i||e.value,i=t(i);let o=A.value.getBoundingClientRect();g.value=o.height/e.value,a.value=o.width/e.value;let n=g.value*i,r=a.value*i;s.x=(r-a.value)/2,s.y=(n-g.value)/2}return{_updateBoundary:E,_updateOffset:d,_updateWH:h,_scaleOffset:s,minX:c,minY:l,maxX:I,maxY:u}}(e,i,k),{FAandSFACancel:f,_getLimitXY:m,_animationTo:y,_setTransform:D,_revise:v,dampingNumber:w,xMove:S,yMove:M,xSync:R,ySync:_,_STD:T}=function(A,e,t,i,o,n,r,s,a,g,c,l,I,u){const E=Ur(()=>{let A=Number(e.damping);return isNaN(A)?20:A}),d=Ur(()=>"all"===e.direction||"horizontal"===e.direction),h=Ur(()=>"all"===e.direction||"vertical"===e.direction),C=Kt(WB(e.x)),B=Kt(WB(e.y));Xi(()=>e.x,A=>{C.value=WB(A)}),Xi(()=>e.y,A=>{B.value=WB(A)}),Xi(C,A=>{v(A)}),Xi(B,A=>{w(A)});const Q=new PB(1,9*Math.pow(E.value,2)/40,E.value);function p(A,e){let t=!1;return A>o.value?(A=o.value,t=!0):An.value?(e=n.value,t=!0):e1?"htouchmove":"vtouchmove"),x.value&&(t=e.detail.dx+r,p.historyX.shift(),p.historyX.push(t),P.value||null!==h||(h=Math.abs(e.detail.dx/e.detail.dy)<1)),P.value&&(i=e.detail.dy+s,p.historyY.shift(),p.historyY.push(i),x.value||null!==h||(h=Math.abs(e.detail.dy/e.detail.dx)<1)),p.historyT.shift(),p.historyT.push(e.detail.timeStamp),!h){e.preventDefault();let o="touch";tb.value&&(A.outOfBounds?(o="touch-out-of-bounds",t=b.value+B.x(t-b.value)):t=b.value),iG.value&&(A.outOfBounds?(o="touch-out-of-bounds",i=G.value+Q.x(i-G.value)):i=G.value),qB(function(){U(t,i,a.value,o)})}}}function j(){if(!c.value&&!A.disabled&&d&&(t.value.style.willChange="auto",d=!1,!h&&!F("out-of-bounds")&&A.inertia)){const A=1e3*(p.historyX[1]-p.historyX[0])/(p.historyT[1]-p.historyT[0]),e=1e3*(p.historyY[1]-p.historyY[0])/(p.historyT[1]-p.historyT[0]),t=l.value,i=I.value;m.setV(A,e),m.setS(t,i);const o=m.delta().x,n=m.delta().y;let r=o+t,s=n+i;rb.value&&(r=b.value,s=i+(b.value-t)*n/o),sG.value&&(s=G.value,r=t+(G.value-i)*o/n),m.setEnd(r,s),E=KB(m,function(){let A=m.s(),e=A.x,t=A.y;U(e,t,a.value,"friction")},function(){E.cancel()})}A.outOfBounds||A.inertia||k()}function K(){if(!i.value)return;k();let e=A.scale?w.value:1;M(),R(e),S();let t=L(Y.value+_.x,J.value+_.y),o=t.x,n=t.y;U(o,n,e,"",!0),y(e)}return Uo(()=>{kB(t.value,A=>{switch(A.detail.state){case"start":q();break;case"move":V(A);break;case"end":j()}}),K(),m.reconfigure(1,f.value),H.reconfigure(1,9*Math.pow(O.value,2)/40,O.value),t.value.style.transformOrigin="center";const A={rootRef:t,setParent:K,_endScale:D,_setScale:v};o(A),Po(()=>{n(A)})}),Po(()=>{k()}),{setParent:K}}(A,o,i);return()=>Ir("uni-movable-view",{ref:i},[Ir(wC,{onResize:n},null,8,["onResize"]),e.default&&e.default()],512)}});let HB=!1;function qB(A){HB||(HB=!0,requestAnimationFrame(function(){A(),HB=!1}))}function VB(A,e){if(A===e)return 0;let t=A.offsetLeft;return A.offsetParent?t+=VB(A.offsetParent,e):0}function jB(A,e){if(A===e)return 0;let t=A.offsetTop;return A.offsetParent?t+=jB(A.offsetParent,e):0}function KB(A,e,t){let i={id:0,cancelled:!1};return function A(e,t,i,o){if(!e||!e.cancelled){i(t);let n=t.done();n||e.cancelled||(e.id=requestAnimationFrame(A.bind(null,e,t,i,o))),n&&o&&o(t)}}(i,A,e,t),{cancel:function(A){A&&A.id&&cancelAnimationFrame(A.id),A&&(A.cancelled=!0)}.bind(null,i),model:A}}function WB(A){return/\d+[ur]px$/i.test(A)?uni.upx2px(parseFloat(A)):Number(A)||0}class zB{constructor(A){this._drag=A,this._dragLog=Math.log(A),this._x=0,this._v=0,this._startTime=0}set(A,e){this._x=A,this._v=e,this._startTime=(new Date).getTime()}setVelocityByEnd(A){this._v=(A-this._x)*this._dragLog/(Math.pow(this._drag,100)-1)}x(A){void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3);const e=A===this._dt&&this._powDragDt?this._powDragDt:this._powDragDt=Math.pow(this._drag,A);return this._dt=A,this._x+this._v*e/this._dragLog-this._v/this._dragLog}dx(A){void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3);const e=A===this._dt&&this._powDragDt?this._powDragDt:this._powDragDt=Math.pow(this._drag,A);return this._dt=A,this._v*e}done(){return Math.abs(this.dx())<3}reconfigure(A){const e=this.x(),t=this.dx();this._drag=A,this._dragLog=Math.log(A),this.set(e,t)}configuration(){const A=this;return[{label:"Friction",read:function(){return A._drag},write:function(e){A.reconfigure(e)},min:.001,max:.1,step:.001}]}}function ZB(A,e,t){return A>e-t&&A0){const o=(-t-Math.sqrt(n))/(2*i),r=(-t+Math.sqrt(n))/(2*i),s=(e-o*A)/(r-o),a=A-s;return{x:function(A){let e,t;return A===this._t&&(e=this._powER1T,t=this._powER2T),this._t=A,e||(e=this._powER1T=Math.pow(Math.E,o*A)),t||(t=this._powER2T=Math.pow(Math.E,r*A)),a*e+s*t},dx:function(A){let e,t;return A===this._t&&(e=this._powER1T,t=this._powER2T),this._t=A,e||(e=this._powER1T=Math.pow(Math.E,o*A)),t||(t=this._powER2T=Math.pow(Math.E,r*A)),a*o*e+s*r*t}}}const r=Math.sqrt(4*i*o-t*t)/(2*i),s=-t/2*i,a=A,g=(e-s*A)/r;return{x:function(A){return Math.pow(Math.E,s*A)*(a*Math.cos(r*A)+g*Math.sin(r*A))},dx:function(A){const e=Math.pow(Math.E,s*A),t=Math.cos(r*A),i=Math.sin(r*A);return e*(g*r*t-a*r*i)+s*e*(g*i+a*t)}}}x(A){return void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3),this._solution?this._endPosition+this._solution.x(A):0}dx(A){return void 0===A&&(A=((new Date).getTime()-this._startTime)/1e3),this._solution?this._solution.dx(A):0}setEnd(A,e,t){if(t||(t=(new Date).getTime()),A!==this._endPosition||!XB(e,.4)){e=e||0;let i=this._endPosition;this._solution&&(XB(e,.4)&&(e=this._solution.dx((t-this._startTime)/1e3)),i=this._solution.x((t-this._startTime)/1e3),XB(e,.4)&&(e=0),XB(i,.4)&&(i=0),i+=this._endPosition),this._solution&&XB(i-A,.4)&&XB(e,.4)||(this._endPosition=A,this._solution=this._solve(i-this._endPosition,e),this._startTime=t)}}snap(A){this._startTime=(new Date).getTime(),this._endPosition=A,this._solution={x:function(){return 0},dx:function(){return 0}}}done(A){return A||(A=(new Date).getTime()),ZB(this.x(),this._endPosition,.4)&&XB(this.dx(),.4)}reconfigure(A,e,t){this._m=A,this._k=e,this._c=t,this.done()||(this._solution=this._solve(this.x()-this._endPosition,this.dx()),this._startTime=(new Date).getTime())}springConstant(){return this._k}damping(){return this._c}configuration(){return[{label:"Spring Constant",read:this.springConstant.bind(this),write:function(A,e){A.reconfigure(1,e,A.damping())}.bind(this,this),min:100,max:1e3},{label:"Damping",read:this.damping.bind(this),write:function(A,e){A.reconfigure(1,A.springConstant(),e)}.bind(this,this),min:1,max:500}]}}class AQ{constructor(A,e,t){this._extent=A,this._friction=e||new zB(.01),this._spring=t||new $B(1,90,20),this._startTime=0,this._springing=!1,this._springOffset=0}snap(A,e){this._springOffset=0,this._springing=!0,this._spring.snap(A),this._spring.setEnd(e)}set(A,e){this._friction.set(A,e),A>0&&e>=0?(this._springOffset=0,this._springing=!0,this._spring.snap(A),this._spring.setEnd(0)):A<-this._extent&&e<=0?(this._springOffset=0,this._springing=!0,this._spring.snap(A),this._spring.setEnd(-this._extent)):this._springing=!1,this._startTime=(new Date).getTime()}x(A){if(!this._startTime)return 0;if(A||(A=((new Date).getTime()-this._startTime)/1e3),this._springing)return this._spring.x()+this._springOffset;let e=this._friction.x(A),t=this.dx(A);return(e>0&&t>=0||e<-this._extent&&t<=0)&&(this._springing=!0,this._spring.setEnd(0,t),e<-this._extent?this._springOffset=-this._extent:this._springOffset=0,e=this._spring.x()+this._springOffset),e}dx(A){let e;return e=this._lastTime===A?this._lastDx:this._springing?this._spring.dx(A):this._friction.dx(A),this._lastTime=A,this._lastDx=e,e}done(){return this._springing?this._spring.done():this._friction.done()}setVelocityByEnd(A){this._friction.setVelocityByEnd(A)}configuration(){const A=this._friction.configuration();return A.push.apply(A,this._spring.configuration()),A}}class eQ{constructor(A,e){e=e||{},this._element=A,this._options=e,this._enableSnap=e.enableSnap||!1,this._itemSize=e.itemSize||0,this._enableX=e.enableX||!1,this._enableY=e.enableY||!1,this._shouldDispatchScrollEvent=!!e.onScroll,this._enableX?(this._extent=(e.scrollWidth||this._element.offsetWidth)-this._element.parentElement.offsetWidth,this._scrollWidth=e.scrollWidth):(this._extent=(e.scrollHeight||this._element.offsetHeight)-this._element.parentElement.offsetHeight,this._scrollHeight=e.scrollHeight),this._position=0,this._scroll=new AQ(this._extent,e.friction,e.spring),this._onTransitionEnd=this.onTransitionEnd.bind(this),this.updatePosition()}onTouchStart(){this._startPosition=this._position,this._lastChangePos=this._startPosition,this._startPosition>0?this._startPosition/=.5:this._startPosition<-this._extent&&(this._startPosition=(this._startPosition+this._extent)/.5-this._extent),this._animation&&(this._animation.cancel(),this._scrolling=!1),this.updatePosition()}onTouchMove(A,e){let t=this._startPosition;this._enableX?t+=A:this._enableY&&(t+=e),t>0?t*=.5:t<-this._extent&&(t=.5*(t+this._extent)-this._extent),this._position=t,this.updatePosition(),this.dispatchScroll()}onTouchEnd(A,e,t){if(this._enableSnap&&this._position>-this._extent&&this._position<0){if(this._enableY&&(Math.abs(e)this._itemSize/2?A-(this._itemSize-Math.abs(e)):A-e,i<=0&&i>=-this._extent&&this._scroll.setVelocityByEnd(i)}this._lastTime=Date.now(),this._lastDelay=0,this._scrolling=!0,this._lastChangePos=this._position,this._lastIdx=Math.floor(Math.abs(this._position/this._itemSize)),this._animation=function(A,e,t){const i={id:0,cancelled:!1};return function A(e,t,i,o){if(!e||!e.cancelled){i(t);const n=t.done();n||e.cancelled||(e.id=requestAnimationFrame(A.bind(null,e,t,i,o))),n&&o&&o(t)}}(i,A,e,t),{cancel:function(A){A&&A.id&&cancelAnimationFrame(A.id),A&&(A.cancelled=!0)}.bind(null,i),model:A}}(this._scroll,()=>{const A=Date.now(),e=(A-this._scroll._startTime)/1e3,t=this._scroll.x(e);this._position=t,this.updatePosition();const i=this._scroll.dx(e);this._shouldDispatchScrollEvent&&A-this._lastTime>this._lastDelay&&(this.dispatchScroll(),this._lastDelay=Math.abs(2e3/i),this._lastTime=A)},()=>{this._enableSnap&&(i<=0&&i>=-this._extent&&(this._position=i,this.updatePosition()),p(this._options.onSnap)&&this._options.onSnap(Math.floor(Math.abs(this._position)/this._itemSize))),this._shouldDispatchScrollEvent&&this.dispatchScroll(),this._scrolling=!1})}onTransitionEnd(){this._element.style.webkitTransition="",this._element.style.transition="",this._element.removeEventListener("transitionend",this._onTransitionEnd),this._snapping&&(this._snapping=!1),this.dispatchScroll()}snap(){const A=this._itemSize,e=this._position%A,t=Math.abs(e)>this._itemSize/2?this._position-(A-Math.abs(e)):this._position-e;this._position!==t&&(this._snapping=!0,this.scrollTo(-t),p(this._options.onSnap)&&this._options.onSnap(Math.floor(Math.abs(this._position)/this._itemSize)))}scrollTo(A,e){this._animation&&(this._animation.cancel(),this._scrolling=!1),"number"==typeof A&&(this._position=-A),this._position<-this._extent?this._position=-this._extent:this._position>0&&(this._position=0);const t="transform "+(e||.2)+"s ease-out";this._element.style.webkitTransition="-webkit-"+t,this._element.style.transition=t,this.updatePosition(),this._element.addEventListener("transitionend",this._onTransitionEnd)}dispatchScroll(){if(p(this._options.onScroll)&&Math.round(Number(this._lastPos))!==Math.round(this._position)){this._lastPos=this._position;const A={target:{scrollLeft:this._enableX?-this._position:0,scrollTop:this._enableY?-this._position:0,scrollHeight:this._scrollHeight||this._element.offsetHeight,scrollWidth:this._scrollWidth||this._element.offsetWidth,offsetHeight:this._element.parentElement.offsetHeight,offsetWidth:this._element.parentElement.offsetWidth}};this._options.onScroll(A)}}update(A,e,t){let i=0;const o=this._position;this._enableX?(i=this._element.childNodes.length?(e||this._element.offsetWidth)-this._element.parentElement.offsetWidth:0,this._scrollWidth=e):(i=this._element.childNodes.length?(e||this._element.offsetHeight)-this._element.parentElement.offsetHeight:0,this._scrollHeight=e),"number"==typeof A&&(this._position=-A),this._position<-i?this._position=-i:this._position>0&&(this._position=0),this._itemSize=t||this._itemSize,this.updatePosition(),o!==this._position&&(this.dispatchScroll(),p(this._options.onSnap)&&this._options.onSnap(Math.floor(Math.abs(this._position)/this._itemSize))),this._extent=i,this._scroll._extent=i}updatePosition(){let A="";this._enableX?A="translateX("+this._position+"px) translateZ(0)":this._enableY&&(A="translateY("+this._position+"px) translateZ(0)"),this._element.style.webkitTransform=A,this._element.style.transform=A}isScrolling(){return this._scrolling||this._snapping}}const tQ=sA,iQ="backwards",oQ=Ll({name:"Progress",props:{percent:{type:[Number,String],default:0,validator:A=>!isNaN(parseFloat(A))},fontSize:{type:[String,Number],default:16},showInfo:{type:[Boolean,String],default:!1},strokeWidth:{type:[Number,String],default:6,validator:A=>!isNaN(parseFloat(A))},color:{type:String,default:tQ},activeColor:{type:String,default:tQ},backgroundColor:{type:String,default:"#EBEBEB"},active:{type:[Boolean,String],default:!1},activeMode:{type:String,default:iQ},duration:{type:[Number,String],default:30,validator:A=>!isNaN(parseFloat(A))},borderRadius:{type:[Number,String],default:0}},setup(A){const e=Kt(null),t=function(A){const e=Kt(0),t=Ur(()=>`background-color: ${A.backgroundColor}; height: ${Oc(A.strokeWidth)}px;`),i=Ur(()=>{const t=A.color!==tQ&&A.activeColor===tQ?A.color:A.activeColor;return`width: ${e.value}%;background-color: ${t}`}),o=Ur(()=>{if("string"==typeof A.percent&&!/^-?\d*\.?\d*$/.test(A.percent))return 0;let e=parseFloat(A.percent);return Number.isNaN(e)||e<0?e=0:e>100&&(e=100),e}),n=Nt({outerBarStyle:t,innerBarStyle:i,realPercent:o,currentPercent:e,strokeTimer:0,lastPercent:0});return n}(A);return nQ(t,A),Xi(()=>t.realPercent,(e,i)=>{t.strokeTimer&&clearInterval(t.strokeTimer),t.lastPercent=i||0,nQ(t,A)}),()=>{const{showInfo:i}=A,{outerBarStyle:o,innerBarStyle:n,currentPercent:r}=t;return Ir("uni-progress",{class:"uni-progress",ref:e},[Ir("div",{style:o,class:"uni-progress-bar"},[Ir("div",{style:n,class:"uni-progress-inner-bar"},null,4)],4),i?Ir("p",{class:"uni-progress-info"},[r+"%"]):""],512)}}});function nQ(A,e){e.active?(A.currentPercent=e.activeMode===iQ?0:A.lastPercent,A.strokeTimer=setInterval(()=>{A.currentPercent+1>A.realPercent?(A.currentPercent=A.realPercent,A.strokeTimer&&clearInterval(A.strokeTimer)):A.currentPercent+=1},parseFloat(e.duration))):A.currentPercent=A.realPercent}const rQ=Uc("ucg"),sQ=Ll({name:"RadioGroup",props:{name:{type:String,default:""}},setup(A,{emit:e,slots:t}){const i=Kt(null);return function(A,e){const t=[];Uo(()=>{s(t.length-1)});const i=()=>{var A;return null==(A=t.find(A=>A.value.radioChecked))?void 0:A.value.value};Qn(rQ,{addField(A){t.push(A)},removeField(A){t.splice(t.indexOf(A),1)},radioChange(A,o){s(t.indexOf(o),!0),e("change",A,{value:i()})}});const o=pn(Jl,!1),n={submit:()=>{let e=["",null];return""!==A.name&&(e[0]=A.name,e[1]=i()),e}};o&&(o.addField(n),xo(()=>{o.removeField(n)}));function r(A,e){A.value={radioChecked:e,value:A.value.value}}function s(A,e){t.forEach((i,o)=>{o!==A&&(e?r(t[o],!1):t.forEach((A,e)=>{o>=e||t[e].value.radioChecked&&r(t[o],!1)}))})}}(A,Ol(i,e)),()=>Ir("uni-radio-group",{ref:i},[t.default&&t.default()],512)}});const aQ=Ll({name:"Radio",props:{checked:{type:[Boolean,String],default:!1},id:{type:String,default:""},disabled:{type:[Boolean,String],default:!1},value:{type:String,default:""},color:{type:String,default:"#007aff"},backgroundColor:{type:String,default:""},borderColor:{type:String,default:""},activeBackgroundColor:{type:String,default:""},activeBorderColor:{type:String,default:""},iconColor:{type:String,default:"#ffffff"}},setup(A,{slots:e}){const t=Kt(null),i=Kt(A.checked),o=Kt(A.value);const n=Ur(()=>function(){if(A.disabled)return{backgroundColor:"#E1E1E1",borderColor:"#D1D1D1"};const e={};return i.value?(e.backgroundColor=A.activeBackgroundColor||A.color,e.borderColor=A.activeBorderColor||e.backgroundColor):(A.borderColor&&(e.borderColor=A.borderColor),A.backgroundColor&&(e.backgroundColor=A.backgroundColor)),e}(i.value));Xi([()=>A.checked,()=>A.value],([A,e])=>{i.value=A,o.value=e});const{uniCheckGroup:r,uniLabel:s,field:a}=function(A,e,t){const i=Ur({get:()=>({radioChecked:Boolean(A.value),value:e.value}),set:({radioChecked:e})=>{A.value=e}}),o={reset:t},n=pn(rQ,!1);n&&n.addField(i);const r=pn(Jl,!1);r&&r.addField(o);const s=pn(Vl,!1);return xo(()=>{n&&n.removeField(i),r&&r.removeField(o)}),{uniCheckGroup:n,uniForm:r,uniLabel:s,field:i}}(i,o,()=>{i.value=!1}),g=e=>{A.disabled||i.value||(i.value=!0,r&&r.radioChange(e,a),e.stopPropagation())};return s&&(s.addHandler(g),xo(()=>{s.removeHandler(g)})),Kl(A,{"label-click":g}),()=>{const o=Yl(A,"disabled");let r;return r=i.value,Ir("uni-radio",Qr(o,{id:A.id,onClick:g,ref:t}),[Ir("div",{class:"uni-radio-wrapper",style:{"--HOVER-BD-COLOR":i.value?n.value.borderColor:A.activeBorderColor}},[Ir("div",{class:["uni-radio-input",{"uni-radio-input-disabled":A.disabled}],style:n.value},[r?jc(Yc,A.disabled?"#ADADAD":A.iconColor,18):""],6),e.default&&e.default()],4)],16,["id","onClick"])}}});const gQ={a:"",abbr:"",address:"",article:"",aside:"",b:"",bdi:"",bdo:["dir"],big:"",blockquote:"",br:"",caption:"",center:"",cite:"",code:"",col:["span","width"],colgroup:["span","width"],dd:"",del:"",div:"",dl:"",dt:"",em:"",fieldset:"",font:"",footer:"",h1:"",h2:"",h3:"",h4:"",h5:"",h6:"",header:"",hr:"",i:"",img:["alt","src","height","width"],ins:"",label:"",legend:"",li:"",mark:"",nav:"",ol:["start","type"],p:"",pre:"",q:"",rt:"",ruby:"",s:"",section:"",small:"",span:"",strong:"",sub:"",sup:"",table:["width"],tbody:"",td:["colspan","height","rowspan","width"],tfoot:"",th:["colspan","height","rowspan","width"],thead:"",tr:["colspan","height","rowspan","width"],tt:"",u:"",ul:""},cQ={amp:"&",gt:">",lt:"<",nbsp:" ",quot:'"',apos:"'",ldquo:"“",rdquo:"”",yen:"¥",radic:"√",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",hellip:"…"};const lQ=(A,e,t)=>!t||C(t)&&!t.length?[]:t.map(t=>{var i;if(S(t)){if(!h(t,"type")||"node"===t.type){let o={[A]:""};const n=null==(i=t.name)?void 0:i.toLowerCase();if(!h(gQ,n))return;return function(A,e){if(S(e))for(const t in e)if(h(e,t)){const i=e[t];"img"===A&&"src"===t&&(e[t]=AC(i))}}(n,t.attrs),o=u(o,function(A,e){if(["a","img"].includes(A.name)&&e)return{onClickCapture:t=>{e(t,{node:A}),t.stopPropagation(),t.preventDefault(),t.returnValue=!1}}}(t,e),t.attrs),Or(t.name,o,lQ(A,e,t.children))}return"text"===t.type&&f(t.text)&&""!==t.text?Er((t.text||"").replace(/&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi,function(A,e){return h(cQ,e)&&cQ[e]?cQ[e]:/^#[0-9]{1,4}$/.test(e)?String.fromCharCode(e.slice(1)):/^#x[0-9a-f]{1,4}$/i.test(e)?String.fromCharCode(0+e.slice(1)):A})):void 0}});function IQ(A){A=function(A){return A.replace(/<\?xml.*\?>\n/,"").replace(/\n/,"").replace(/\n/,"")}(A);const e=[],t={node:"root",children:[]};return function(A,e){var t,i,o,n=[],r=A;for(n.last=function(){return this[this.length-1]};A;){if(i=!0,n.last()&&XC[n.last()])A=A.replace(new RegExp("([\\s\\S]*?)]*>"),function(A,t){return t=t.replace(/|/g,"$1$2"),e.chars&&e.chars(t),""}),g("",n.last());else if(0==A.indexOf("\x3c!--")?(t=A.indexOf("--\x3e"))>=0&&(e.comment&&e.comment(A.substring(4,t)),A=A.substring(t+3),i=!1):0==A.indexOf("=0&&n[i]!=t;i--);else var i=0;if(i>=0){for(var o=n.length-1;o>=i;o--)e.end&&e.end(n[o]);n.length=i}}g()}(A,{start:function(A,i,o){const n={name:A};if(0!==i.length&&(n.attrs=function(A){return A.reduce(function(A,e){let t=e.value;const i=e.name;return t.match(/ /)&&-1===["style","src"].indexOf(i)&&(t=t.split(" ")),A[i]?Array.isArray(A[i])?A[i].push(t):A[i]=[A[i],t]:A[i]=t,A},{})}(i)),o){const A=e[0]||t;A.children||(A.children=[]),A.children.push(n)}else e.unshift(n)},end:function(A){const i=e.shift();if(i.name!==A&&console.error("invalid state: mismatch end tag"),0===e.length)t.children.push(i);else{const A=e[0];A.children||(A.children=[]),A.children.push(i)}},chars:function(A){const i={type:"text",text:A};if(0===e.length)t.children.push(i);else{const A=e[0];A.children||(A.children=[]),A.children.push(i)}},comment:function(A){const t={node:"comment",text:A},i=e[0];i&&(i.children||(i.children=[]),i.children.push(t))}}),t.children}const uQ=Ll({name:"RichText",compatConfig:{MODE:3},props:{nodes:{type:[Array,String],default:function(){return[]}}},emits:["itemclick"],setup(A,{emit:e}){const t=Dr(),i=t&&t.vnode.scopeId||"",o=Kt(null),n=Kt([]),r=Ol(o,e);function s(A,e={}){r("itemclick",A,e)}return Xi(()=>A.nodes,function(){let e=A.nodes;f(e)&&(e=IQ(A.nodes)),n.value=lQ(i,s,e)},{immediate:!0,deep:!0}),()=>Or("uni-rich-text",{ref:o},Or("div",{},n.value))}}),EQ=Ll({name:"Refresher",props:{refreshState:{type:String,default:""},refresherHeight:{type:Number,default:0},refresherThreshold:{type:Number,default:45},refresherDefaultStyle:{type:String,default:"black"},refresherBackground:{type:String,default:"#fff"}},setup(A,{slots:e}){const t=Kt(null),i=Ur(()=>{const e={backgroundColor:A.refresherBackground};switch(A.refreshState){case"pulling":e.height=A.refresherHeight+"px";break;case"refreshing":e.height=A.refresherThreshold+"px",e.transition="height 0.3s";break;case"":case"refresherabort":case"restore":e.height="0px",e.transition="height 0.3s"}return e}),o=Ur(()=>{const e=A.refresherHeight/A.refresherThreshold;return 360*(e>1?1:e)});return()=>{const{refreshState:n,refresherDefaultStyle:r,refresherThreshold:s}=A;return Ir("div",{ref:t,style:i.value,class:"uni-scroll-view-refresher"},["none"!==r?Ir("div",{class:"uni-scroll-view-refresh"},[Ir("div",{class:"uni-scroll-view-refresh-inner"},["pulling"==n?Ir("svg",{key:"refresh__icon",style:{transform:"rotate("+o.value+"deg)"},fill:"#2BD009",class:"uni-scroll-view-refresh__icon",width:"24",height:"24",viewBox:"0 0 24 24"},[Ir("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"},null),Ir("path",{d:"M0 0h24v24H0z",fill:"none"},null)],4):null,"refreshing"==n?Ir("svg",{key:"refresh__spinner",class:"uni-scroll-view-refresh__spinner",width:"24",height:"24",viewBox:"25 25 50 50"},[Ir("circle",{cx:"50",cy:"50",r:"20",fill:"none",style:"color: #2bd009","stroke-width":"3"},null)]):null])]):null,"none"===r?Ir("div",{class:"uni-scroll-view-refresher-container",style:{height:`${s}px`}},[e.default&&e.default()]):null],4)}}}),dQ=oe(!0),hQ=Ll({name:"ScrollView",compatConfig:{MODE:3},props:{direction:{type:[String],default:"vertical"},scrollX:{type:[Boolean,String],default:!1},scrollY:{type:[Boolean,String],default:!1},showScrollbar:{type:[Boolean,String],default:!0},upperThreshold:{type:[Number,String],default:50},lowerThreshold:{type:[Number,String],default:50},scrollTop:{type:[Number,String],default:0},scrollLeft:{type:[Number,String],default:0},scrollIntoView:{type:String,default:""},scrollWithAnimation:{type:[Boolean,String],default:!1},enableBackToTop:{type:[Boolean,String],default:!1},refresherEnabled:{type:[Boolean,String],default:!1},refresherThreshold:{type:Number,default:45},refresherDefaultStyle:{type:String,default:"black"},refresherBackground:{type:String,default:"#fff"},refresherTriggered:{type:[Boolean,String],default:!1}},emits:["scroll","scrolltoupper","scrolltolower","refresherrefresh","refresherrestore","refresherpulling","refresherabort","update:refresherTriggered"],setup(A,{emit:e,slots:t,expose:i}){const o=Kt(null),n=Kt(null),r=Kt(null),s=Kt(null),a=Ol(o,e),{state:g,scrollTopNumber:c,scrollLeftNumber:l}=function(A){const e=Ur(()=>Number(A.scrollTop)||0),t=Ur(()=>Number(A.scrollLeft)||0),i=Nt({lastScrollTop:e.value,lastScrollLeft:t.value,lastScrollToUpperTime:0,lastScrollToLowerTime:0,refresherHeight:0,refreshState:""});return{state:i,scrollTopNumber:e,scrollLeftNumber:t}}(A),{realScrollX:I,realScrollY:u,_scrollLeftChanged:E,_scrollTopChanged:d}=function(A,e,t,i,o,n,r,s,a){let g=!1,c=0,l=!1,I=()=>{};const u=Ur(()=>A.scrollX),E=Ur(()=>A.scrollY),d=Ur(()=>{let e=Number(A.upperThreshold);return isNaN(e)?50:e}),h=Ur(()=>{let e=Number(A.lowerThreshold);return isNaN(e)?50:e});function C(A,e){const t=r.value;let i=0,o="";if(A<0?A=0:"x"===e&&A>t.scrollWidth-t.offsetWidth?A=t.scrollWidth-t.offsetWidth:"y"===e&&A>t.scrollHeight-t.offsetHeight&&(A=t.scrollHeight-t.offsetHeight),"x"===e?i=t.scrollLeft-A:"y"===e&&(i=t.scrollTop-A),0===i)return;let n=s.value;n.style.transition="transform .3s ease-out",n.style.webkitTransition="-webkit-transform .3s ease-out","x"===e?o="translateX("+i+"px) translateZ(0)":"y"===e&&(o="translateY("+i+"px) translateZ(0)"),n.removeEventListener("transitionend",I),n.removeEventListener("webkitTransitionEnd",I),I=()=>m(A,e),n.addEventListener("transitionend",I),n.addEventListener("webkitTransitionEnd",I),"x"===e?t.style.overflowX="hidden":"y"===e&&(t.style.overflowY="hidden"),n.style.transform=o,n.style.webkitTransform=o}function B(A){const t=A.target;o("scroll",A,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,scrollHeight:t.scrollHeight,scrollWidth:t.scrollWidth,deltaX:e.lastScrollLeft-t.scrollLeft,deltaY:e.lastScrollTop-t.scrollTop}),E.value&&(t.scrollTop<=d.value&&e.lastScrollTop-t.scrollTop>0&&A.timeStamp-e.lastScrollToUpperTime>200&&(o("scrolltoupper",A,{direction:"top"}),e.lastScrollToUpperTime=A.timeStamp),t.scrollTop+t.offsetHeight+h.value>=t.scrollHeight&&e.lastScrollTop-t.scrollTop<0&&A.timeStamp-e.lastScrollToLowerTime>200&&(o("scrolltolower",A,{direction:"bottom"}),e.lastScrollToLowerTime=A.timeStamp)),u.value&&(t.scrollLeft<=d.value&&e.lastScrollLeft-t.scrollLeft>0&&A.timeStamp-e.lastScrollToUpperTime>200&&(o("scrolltoupper",A,{direction:"left"}),e.lastScrollToUpperTime=A.timeStamp),t.scrollLeft+t.offsetWidth+h.value>=t.scrollWidth&&e.lastScrollLeft-t.scrollLeft<0&&A.timeStamp-e.lastScrollToLowerTime>200&&(o("scrolltolower",A,{direction:"right"}),e.lastScrollToLowerTime=A.timeStamp)),e.lastScrollTop=t.scrollTop,e.lastScrollLeft=t.scrollLeft}function Q(e){E.value&&(A.scrollWithAnimation?C(e,"y"):r.value.scrollTop=e)}function p(e){u.value&&(A.scrollWithAnimation?C(e,"x"):r.value.scrollLeft=e)}function f(e){if(e){if(!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(e))return void console.error(`id error: scroll-into-view=${e}`);let t=n.value.querySelector("#"+e);if(t){let e=r.value.getBoundingClientRect(),i=t.getBoundingClientRect();if(u.value){let t=i.left-e.left,o=r.value.scrollLeft+t;A.scrollWithAnimation?C(o,"x"):r.value.scrollLeft=o}if(E.value){let t=i.top-e.top,o=r.value.scrollTop+t;A.scrollWithAnimation?C(o,"y"):r.value.scrollTop=o}}}}function m(A,e){s.value.style.transition="",s.value.style.webkitTransition="",s.value.style.transform="",s.value.style.webkitTransform="";let t=r.value;"x"===e?(t.style.overflowX=u.value?"auto":"hidden",t.scrollLeft=A):"y"===e&&(t.style.overflowY=E.value?"auto":"hidden",t.scrollTop=A),s.value.removeEventListener("transitionend",I),s.value.removeEventListener("webkitTransitionEnd",I)}function y(t){if(A.refresherEnabled){switch(t){case"refreshing":e.refresherHeight=A.refresherThreshold,g||(g=!0,o("refresherpulling",{},{deltaY:e.refresherHeight,dy:e.refresherHeight}),o("refresherrefresh",{},{dy:v.y-D.y}),a("update:refresherTriggered",!0));break;case"restore":case"refresherabort":g=!1,e.refresherHeight=c=0,"restore"===t&&(l=!1,o("refresherrestore",{},{dy:v.y-D.y})),"refresherabort"===t&&l&&(l=!1,o("refresherabort",{},{dy:v.y-D.y}))}e.refreshState=t}}let D={x:0,y:0},v={x:0,y:A.refresherThreshold};return Uo(()=>{pi(()=>{Q(t.value),p(i.value)}),f(A.scrollIntoView);let n=function(A){A.preventDefault(),A.stopPropagation(),B(A)},s=null,a=function(t){if(null===D)return;let i=t.touches[0].pageX,n=t.touches[0].pageY,a=r.value;if(Math.abs(i-D.x)>Math.abs(n-D.y))if(u.value){if(0===a.scrollLeft&&i>D.x)return void(s=!1);if(a.scrollWidth===a.offsetWidth+a.scrollLeft&&iD.y)s=!1,A.refresherEnabled&&!1!==t.cancelable&&t.preventDefault();else{if(a.scrollHeight===a.offsetHeight+a.scrollTop&&n0&&(l=!0,o("refresherpulling",t,{deltaY:i,dy:i})))}},I=function(A){1===A.touches.length&&(D={x:A.touches[0].pageX,y:A.touches[0].pageY})},d=function(t){v={x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY},e.refresherHeight>=A.refresherThreshold?y("refreshing"):y("refresherabort"),D={x:0,y:0},v={x:0,y:A.refresherThreshold}};r.value.addEventListener("touchstart",I,dQ),r.value.addEventListener("touchmove",a,oe(!1)),r.value.addEventListener("scroll",n,oe(!1)),r.value.addEventListener("touchend",d,dQ),xo(()=>{r.value.removeEventListener("touchstart",I),r.value.removeEventListener("touchmove",a),r.value.removeEventListener("scroll",n),r.value.removeEventListener("touchend",d)})}),wo(()=>{E.value&&(r.value.scrollTop=e.lastScrollTop),u.value&&(r.value.scrollLeft=e.lastScrollLeft)}),Xi(t,A=>{Q(A)}),Xi(i,A=>{p(A)}),Xi(()=>A.scrollIntoView,A=>{f(A)}),Xi(()=>A.refresherTriggered,A=>{!0===A?y("refreshing"):!1===A&&y("restore")}),{realScrollX:u,realScrollY:E,_scrollTopChanged:Q,_scrollLeftChanged:p}}(A,g,c,l,a,o,n,s,e),h=Ur(()=>{let A="";return I.value?A+="overflow-x:auto;":A+="overflow-x:hidden;",u.value?A+="overflow-y:auto;":A+="overflow-y:hidden;",A}),C=Ur(()=>{let e="uni-scroll-view";return!1===A.showScrollbar&&(e+=" uni-scroll-view-scrollbar-hidden"),e});return i({$getMain:()=>n.value}),()=>{const{refresherEnabled:e,refresherBackground:i,refresherDefaultStyle:a,refresherThreshold:c}=A,{refresherHeight:l,refreshState:I}=g;return Ir("uni-scroll-view",{ref:o},[Ir("div",{ref:r,class:"uni-scroll-view"},[Ir("div",{ref:n,style:h.value,class:C.value},[e?Ir(EQ,{refreshState:I,refresherHeight:l,refresherThreshold:c,refresherDefaultStyle:a,refresherBackground:i},{default:()=>["none"==a?t.refresher&&t.refresher():null]},8,["refreshState","refresherHeight","refresherThreshold","refresherDefaultStyle","refresherBackground"]):null,Ir("div",{ref:s,class:"uni-scroll-view-content"},[t.default&&t.default()],512)],6)],512)],512)}}});const CQ=Ll({name:"Slider",props:{name:{type:String,default:""},min:{type:[Number,String],default:0},max:{type:[Number,String],default:100},value:{type:[Number,String],default:0},step:{type:[Number,String],default:1},disabled:{type:[Boolean,String],default:!1},color:{type:String,default:"#e9e9e9"},backgroundColor:{type:String,default:"#e9e9e9"},activeColor:{type:String,default:"#007aff"},selectedColor:{type:String,default:"#007aff"},blockColor:{type:String,default:"#ffffff"},blockSize:{type:[Number,String],default:28},showValue:{type:[Boolean,String],default:!1}},emits:["changing","change"],setup(A,{emit:e}){const t=Kt(null),i=Kt(null),o=Kt(null),n=Kt(Number(A.value));Xi(()=>A.value,A=>{n.value=Number(A)});const r=Ol(t,e),s=function(A,e){const t=()=>BQ(e.value,A.min,A.max),i=()=>"#e9e9e9"!==A.backgroundColor?A.backgroundColor:"#007aff"!==A.color?A.color:"#007aff",o=()=>"#007aff"!==A.activeColor?A.activeColor:"#e9e9e9"!==A.selectedColor?A.selectedColor:"#e9e9e9",n={setBgColor:Ur(()=>({backgroundColor:i()})),setBlockBg:Ur(()=>({left:t()})),setActiveColor:Ur(()=>({backgroundColor:o(),width:t()})),setBlockStyle:Ur(()=>({width:A.blockSize+"px",height:A.blockSize+"px",marginLeft:-A.blockSize/2+"px",marginTop:-A.blockSize/2+"px",left:t(),backgroundColor:A.blockColor}))};return n}(A,n),{_onClick:a,_onTrack:g}=function(A,e,t,i,o){const n=t=>{A.disabled||(s(t),o("change",t,{value:e.value}))},r=e=>{const t=Number(A.max),i=Number(A.min),o=Number(A.step);return et?t:QQ.mul.call(Math.round((e-i)/o),o)+i},s=o=>{const n=Number(A.max),s=Number(A.min),a=i.value,g=getComputedStyle(a,null).marginLeft;let c=a.offsetWidth;c+=parseInt(g);const l=t.value,I=l.offsetWidth-(A.showValue?c:0),u=l.getBoundingClientRect().left,E=(o.x-u)*(n-s)/I+s;e.value=r(E)},a=t=>{if(!A.disabled)return"move"===t.detail.state?(s({x:t.detail.x}),o("changing",t,{value:e.value}),!1):"end"===t.detail.state&&o("change",t,{value:e.value})},g=pn(Jl,!1);if(g){const t={reset:()=>e.value=Number(A.min),submit:()=>{const t=["",null];return""!==A.name&&(t[0]=A.name,t[1]=e.value),t}};g.addField(t),xo(()=>{g.removeField(t)})}return{_onClick:n,_onTrack:a}}(A,n,t,i,r);return Uo(()=>{kB(o.value,g)}),()=>{const{setBgColor:e,setBlockBg:r,setActiveColor:g,setBlockStyle:c}=s;return Ir("uni-slider",{ref:t,onClick:Fl(a)},[Ir("div",{class:"uni-slider-wrapper"},[Ir("div",{class:"uni-slider-tap-area"},[Ir("div",{style:e.value,class:"uni-slider-handle-wrapper"},[Ir("div",{ref:o,style:r.value,class:"uni-slider-handle"},null,4),Ir("div",{style:c.value,class:"uni-slider-thumb"},null,4),Ir("div",{style:g.value,class:"uni-slider-track"},null,4)],4)]),io(Ir("span",{ref:i,class:"uni-slider-value"},[n.value],512),[[ss,A.showValue]])])],8,["onClick"])}}}),BQ=(A,e,t)=>(t=Number(t),100*(A-(e=Number(e)))/(t-e)+"%");var QQ={mul:function(A){let e=0,t=this.toString(),i=A.toString();try{e+=t.split(".")[1].length}catch(__){}try{e+=i.split(".")[1].length}catch(__){}return Number(t.replace(".",""))*Number(i.replace(".",""))/Math.pow(10,e)}};function pQ(A,e,t,i,o,n){function r(){g&&(clearTimeout(g),g=null)}let s,a,g=null,c=!0,l=0,I=1,u=null,E=!1,d=0,h="";const C=Ur(()=>t.value.length>e.displayMultipleItems),B=Ur(()=>A.circular&&C.value);function Q(o){Math.floor(2*l)===Math.floor(2*o)&&Math.ceil(2*l)===Math.ceil(2*o)||B.value&&function(i){if(!c)for(let o=t.value,n=o.length,r=i+e.displayMultipleItems,s=0;s=g.length&&(o-=g.length),o=s%1>.5||s<0?o-1:o,n("transition",{},{dx:A.vertical?0:o*a.offsetWidth,dy:A.vertical?o*a.offsetHeight:0})}function p(A){const i=t.value.length;if(!i)return-1;const o=(Math.round(A)%i+i)%i;if(B.value){if(i<=e.displayMultipleItems)return 0}else if(o>i-e.displayMultipleItems)return i-e.displayMultipleItems;return o}function f(){u=null}function m(){if(!u)return void(E=!1);const A=u,i=A.toPos,o=A.acc,r=A.endTime,g=A.source,c=r-Date.now();if(c<=0){Q(i),u=null,E=!1,s=null;const A=t.value[e.current];if(A){const t=A.getItemId();n("animationfinish",{},{current:e.current,currentItemId:t,source:g})}return}Q(i+o*c*c/2),a=requestAnimationFrame(m)}function y(A,i,o){f();const n=e.duration,r=t.value.length;let s=l;if(B.value)if(o<0){for(;sA;)s-=r}else if(o>0){for(;s>A;)s-=r;for(;s+rA;)s-=r;s+r-AA.current,()=>A.currentItemId,()=>[...t.value]],()=>{let i=-1;if(A.currentItemId)for(let e=0,o=t.value;eA.vertical,()=>B.value,()=>e.displayMultipleItems,()=>[...t.value]],function(){r(),u&&(Q(u.toPos),u=null);const o=t.value;for(let e=0;e0&&I<1||(I=1)}const s=l;l=-2;const a=e.current;a>=0?(c=!1,e.userTracking?(Q(s+a-d),d=a):(Q(a),A.autoplay&&D())):(c=!0,Q(-e.displayMultipleItems-1))}),Xi(()=>e.interval,()=>{g&&(r(),D())}),Xi(()=>e.current,(A,i)=>{!function(A,i){const o=h;h="";const r=t.value;if(!o){const e=r.length;y(A,"",B.value&&i+(e-A)%e>e/2?1:0)}const s=r[A];if(s){const A=e.currentItemId=s.getItemId();n("change",{},{current:e.current,currentItemId:A,source:o})}}(A,i),o("update:current",A)}),Xi(()=>e.currentItemId,A=>{o("update:currentItemId",A)}),Xi(()=>A.autoplay&&!e.userTracking,v),v(A.autoplay&&!e.userTracking),Uo(()=>{let o=!1,n=0,s=0;function a(A){e.userTracking=!1;const t=n/Math.abs(n);let i=0;!A&&Math.abs(n)>.2&&(i=.5*t);const o=p(l+i);A?Q(d):(h="touch",e.current=o,y(o,"touch",0!==i?i:0===o&&B.value&&l>=1?1:0))}kB(i.value,g=>{if(!A.disableTouch&&!c){if("start"===g.detail.state)return e.userTracking=!0,o=!1,r(),d=l,n=0,s=Date.now(),void f();if("end"===g.detail.state)return a(!1);if("cancel"===g.detail.state)return a(!0);if(e.userTracking){if(!o){o=!0;const t=Math.abs(g.detail.dx),i=Math.abs(g.detail.dy);if((t>=i&&A.vertical||t<=i&&!A.vertical)&&(e.userTracking=!1),!e.userTracking)return void(A.autoplay&&D())}return function(o){const r=s;s=Date.now();const a=t.value.length-e.displayMultipleItems;function g(A){return.5-.25/(A+.5)}function c(A,e){let t=d+A;n=.6*n+.4*e,B.value||(t<0||t>a)&&(t<0?t=-g(-t):t>a&&(t=a+g(t-a)),n=0),Q(t)}const l=s-r||1,I=i.value;A.vertical?c(-o.dy/I.offsetHeight,-o.ddy/l):c(-o.dx/I.offsetWidth,-o.ddx/l)}(g.detail),!1}}})}),Po(()=>{r(),cancelAnimationFrame(a)}),{onSwiperDotClick:function(A){y(e.current=A,h="click",B.value?1:0)},circularEnabled:B,swiperEnabled:C}}const fQ=Ll({name:"Swiper",props:{indicatorDots:{type:[Boolean,String],default:!1},vertical:{type:[Boolean,String],default:!1},autoplay:{type:[Boolean,String],default:!1},circular:{type:[Boolean,String],default:!1},interval:{type:[Number,String],default:5e3},duration:{type:[Number,String],default:500},current:{type:[Number,String],default:0},indicatorColor:{type:String,default:""},indicatorActiveColor:{type:String,default:""},previousMargin:{type:String,default:""},nextMargin:{type:String,default:""},currentItemId:{type:String,default:""},skipHiddenItemLayout:{type:[Boolean,String],default:!1},displayMultipleItems:{type:[Number,String],default:1},disableTouch:{type:[Boolean,String],default:!1},navigation:{type:[Boolean,String],default:!1},navigationColor:{type:String,default:"#fff"},navigationActiveColor:{type:String,default:"rgba(53, 53, 53, 0.6)"}},emits:["change","transition","animationfinish","update:current","update:currentItemId"],setup(A,{slots:e,emit:t}){const i=Kt(null),o=Ol(i,t),n=Kt(null),r=Kt(null),s=function(A){return Nt({interval:Ur(()=>{const e=Number(A.interval);return isNaN(e)?5e3:e}),duration:Ur(()=>{const e=Number(A.duration);return isNaN(e)?500:e}),displayMultipleItems:Ur(()=>{const e=Math.round(A.displayMultipleItems);return isNaN(e)?1:e}),current:Math.round(A.current)||0,currentItemId:A.currentItemId,userTracking:!1})}(A),a=Ur(()=>{let e={};return(A.nextMargin||A.previousMargin)&&(e=A.vertical?{left:0,right:0,top:Oc(A.previousMargin,!0),bottom:Oc(A.nextMargin,!0)}:{top:0,bottom:0,left:Oc(A.previousMargin,!0),right:Oc(A.nextMargin,!0)}),e}),g=Ur(()=>{const e=Math.abs(100/s.displayMultipleItems)+"%";return{width:A.vertical?"100%":e,height:A.vertical?e:"100%"}});let c=[];const l=[],I=Kt([]);function u(){const A=[];for(let e=0;et===A.rootRef.value);i&&A.push(Pt(i))}I.value=A}Qn("addSwiperContext",function(A){l.push(A),u()});Qn("removeSwiperContext",function(A){const e=l.indexOf(A);e>=0&&(l.splice(e,1),u())});const{onSwiperDotClick:E,circularEnabled:d,swiperEnabled:h}=pQ(A,s,I,r,t,o);let C=()=>null;return C=mQ(i,A,s,E,I,d,h),()=>{const t=e.default&&e.default();return c=RB(t),Ir("uni-swiper",{ref:i},[Ir("div",{ref:n,class:"uni-swiper-wrapper"},[Ir("div",{class:"uni-swiper-slides",style:a.value},[Ir("div",{ref:r,class:"uni-swiper-slide-frame",style:g.value},[t],4)],4),A.indicatorDots&&Ir("div",{class:["uni-swiper-dots",A.vertical?"uni-swiper-dots-vertical":"uni-swiper-dots-horizontal"]},[I.value.map((e,t,i)=>Ir("div",{onClick:()=>E(t),class:{"uni-swiper-dot":!0,"uni-swiper-dot-active":t=s.current||t{let s=!1,a=!1,g=!1,c=Kt(!1);function l(A,t){const i=A.currentTarget;i&&(i.style.backgroundColor="over"===t?e.navigationActiveColor:"")}zi(()=>{s="auto"===e.navigation,c.value=!0!==e.navigation||s,Q()}),zi(()=>{const A=o.value.length,e=!n.value;a=0===t.current&&e,g=t.current===A-1&&e||e&&t.current+t.displayMultipleItems>=A,r.value||(a=!0,g=!0,s&&(c.value=!0))});const I={onMouseover:A=>l(A,"over"),onMouseout:A=>l(A,"out")};function E(A,e,r){if(A.stopPropagation(),r)return;const s=o.value.length;let a=t.current;switch(e){case"prev":a--,a<0&&n.value&&(a=s-1);break;case"next":a++,a>=s&&n.value&&(a=0)}i(a)}const d=()=>jc(Hc,e.navigationColor,26);let h;const C=t=>{clearTimeout(h);const{clientX:i,clientY:o}=t,{left:n,right:r,top:s,bottom:a,width:g,height:l}=A.value.getBoundingClientRect();let I=!1;if(I=e.vertical?!(o-s{c.value=I},300);c.value=I},B=()=>{c.value=!0};function Q(){A.value&&(A.value.removeEventListener("mousemove",C),A.value.removeEventListener("mouseleave",B),s&&(A.value.addEventListener("mousemove",C),A.value.addEventListener("mouseleave",B)))}return Uo(Q),function(){const A={"uni-swiper-navigation-hide":c.value,"uni-swiper-navigation-vertical":e.vertical};return e.navigation?Ir(Kn,null,[Ir("div",Qr({class:["uni-swiper-navigation uni-swiper-navigation-prev",u({"uni-swiper-navigation-disabled":a},A)],onClick:A=>E(A,"prev",a)},I),[d()],16,["onClick"]),Ir("div",Qr({class:["uni-swiper-navigation uni-swiper-navigation-next",u({"uni-swiper-navigation-disabled":g},A)],onClick:A=>E(A,"next",g)},I),[d()],16,["onClick"])]):null}},yQ=Ll({name:"SwiperItem",props:{itemId:{type:String,default:""}},setup(A,{slots:e}){const t=Kt(null),i={rootRef:t,getItemId:()=>A.itemId,getBoundingClientRect:()=>t.value.getBoundingClientRect(),updatePosition(A,e){const i=e?"0":100*A+"%",o=e?100*A+"%":"0",n=t.value,r=`translate(${i},${o}) translateZ(0)`;n&&(n.style.webkitTransform=r,n.style.transform=r)}};return Uo(()=>{const A=pn("addSwiperContext");A&&A(i)}),Po(()=>{const A=pn("removeSwiperContext");A&&A(i)}),()=>Ir("uni-swiper-item",{ref:t,style:{position:"absolute",width:"100%",height:"100%"}},[e.default&&e.default()],512)}}),DQ=Ll({name:"Switch",props:{name:{type:String,default:""},checked:{type:[Boolean,String],default:!1},type:{type:String,default:"switch"},id:{type:String,default:""},disabled:{type:[Boolean,String],default:!1},color:{type:String,default:""}},emits:["change"],setup(A,{emit:e}){const t=Kt(null),i=Kt(A.checked),o=function(A,e){const t=pn(Jl,!1),i=pn(Vl,!1),o={submit:()=>{const t=["",null];return A.name&&(t[0]=A.name,t[1]=e.value),t},reset:()=>{e.value=!1}};t&&(t.addField(o),Po(()=>{t.removeField(o)}));return i}(A,i),n=Ol(t,e);Xi(()=>A.checked,A=>{i.value=A});const r=e=>{A.disabled||(i.value=!i.value,n("change",e,{value:i.value}))};return o&&(o.addHandler(r),xo(()=>{o.removeHandler(r)})),Kl(A,{"label-click":r}),()=>{const{color:e,type:o}=A,n=Yl(A,"disabled"),s={};let a;return e&&i.value&&(s.backgroundColor=e,s.borderColor=e),a=i.value,Ir("uni-switch",Qr({id:A.id,ref:t},n,{onClick:r}),[Ir("div",{class:"uni-switch-wrapper"},[io(Ir("div",{class:["uni-switch-input",[i.value?"uni-switch-input-checked":""]],style:s},null,6),[[ss,"switch"===o]]),io(Ir("div",{class:"uni-checkbox-input"},[a?jc(Yc,A.color,22):""],512),[[ss,"checkbox"===o]])])],16,["id","onClick"])}}});const vQ={ensp:" ",emsp:" ",nbsp:" "};function wQ(A,e){return function(A,{space:e,decode:t}){let i="",o=!1;for(let n of A)e&&vQ[e]&&" "===n&&(n=vQ[e]),o?(i+="n"===n?oA:"\\"===n?"\\":"\\"+n,o=!1):"\\"===n?o=!0:i+=n;return t?i.replace(/ /g,vQ.nbsp).replace(/ /g,vQ.ensp).replace(/ /g,vQ.emsp).replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"):i}(A,e).split(oA)}const SQ=Ll({name:"Text",props:{selectable:{type:[Boolean,String],default:!1},space:{type:String,default:""},decode:{type:[Boolean,String],default:!1}},setup(A,{slots:e}){const t=Kt(null);return()=>{const i=[];return e.default&&e.default().forEach(e=>{if(8&e.shapeFlag&&e.type!==zn){const t=wQ(e.children,{space:A.space,decode:A.decode}),o=t.length-1;t.forEach((A,e)=>{(0!==e||A)&&i.push(Er(A)),e!==o&&i.push(Ir("br"))})}else i.push(e)}),Ir("uni-text",{ref:t,selectable:!!A.selectable||null},[Ir("span",null,i)],8,["selectable"])}}}),MQ=u({},hB,{placeholderClass:{type:String,default:"input-placeholder"},autoHeight:{type:[Boolean,String],default:!1},confirmType:{type:String,default:"return",validator:A=>_Q.concat("return").includes(A)}});let RQ=!1;const _Q=["done","go","next","search","send"];const TQ=Ll({name:"Textarea",props:MQ,emits:["confirm","change","linechange",...CB],setup(A,{emit:e,expose:t}){const i=Kt(null),o=Kt(null),{fieldRef:n,state:r,scopedAttrsState:s,fixDisabledColor:a,trigger:g}=pB(A,i,e),c=Ur(()=>r.value.split(oA)),l=Ur(()=>_Q.includes(A.confirmType)),I=Kt(0),u=Kt(null);function E({height:A}){I.value=A}function d(A){}function h(A){"Enter"===A.key&&l.value&&A.preventDefault()}function C(e){if("Enter"===e.key&&l.value){!function(A){g("confirm",A,{value:r.value})}(e);const t=e.target;!A.confirmHold&&t.blur()}}return Xi(()=>I.value,e=>{const t=i.value,n=u.value,r=o.value;let s=parseFloat(getComputedStyle(t).lineHeight);isNaN(s)&&(s=n.offsetHeight);var a=Math.round(e/s);g("linechange",{},{height:e,heightRpx:750/window.innerWidth*e,lineCount:a}),A.autoHeight&&(r.style.height=e+"px")}),function(){const A="(prefers-color-scheme: dark)";RQ=0===String(navigator.platform).indexOf("iP")&&0===String(navigator.vendor).indexOf("Apple")&&window.matchMedia(A).media!==A}(),t({$triggerInput:A=>{e("update:modelValue",A.value),e("update:value",A.value),r.value=A.value}}),()=>{let e=A.disabled&&a?Ir("textarea",{key:"disabled-textarea",ref:n,value:r.value,tabindex:"-1",readonly:!!A.disabled,maxlength:r.maxlength,class:{"uni-textarea-textarea":!0,"uni-textarea-textarea-fix-margin":RQ},style:{overflowY:A.autoHeight?"hidden":"auto",...A.cursorColor&&{caretColor:A.cursorColor}},onFocus:A=>A.target.blur()},null,46,["value","readonly","maxlength","onFocus"]):Ir("textarea",{key:"textarea",ref:n,value:r.value,disabled:!!A.disabled,maxlength:r.maxlength,enterkeyhint:A.confirmType,inputmode:A.inputmode,class:{"uni-textarea-textarea":!0,"uni-textarea-textarea-fix-margin":RQ},style:{overflowY:A.autoHeight?"hidden":"auto",...A.cursorColor&&{caretColor:A.cursorColor}},onKeydown:h,onKeyup:C,onChange:d},null,46,["value","disabled","maxlength","enterkeyhint","inputmode","onKeydown","onKeyup","onChange"]);return Ir("uni-textarea",{ref:i,"auto-height":A.autoHeight},[Ir("div",{ref:o,class:"uni-textarea-wrapper"},[io(Ir("div",Qr(s.attrs,{style:A.placeholderStyle,class:["uni-textarea-placeholder",A.placeholderClass]}),[A.placeholder],16),[[ss,!r.value.length]]),Ir("div",{ref:u,class:"uni-textarea-line"},[" "],512),Ir("div",{class:{"uni-textarea-compute":!0,"uni-textarea-compute-auto-height":A.autoHeight}},[c.value.map(A=>Ir("div",null,[A.trim()?A:"."])),Ir(wC,{initial:!0,onResize:E},null,8,["initial","onResize"])],2),"search"===A.confirmType?Ir("form",{action:"",onSubmit:()=>!1,class:"uni-input-form"},[e],40,["onSubmit"]):e],512)],8,["auto-height"])}}}),NQ=Ll({name:"View",props:u({},xl),setup(A,{slots:e}){const t=Kt(null),{hovering:i,binding:o}=Pl(A);return()=>{const n=A.hoverClass;return n&&"none"!==n?Ir("uni-view",Qr({class:i.value?n:"",ref:t},o),[jo(e,"default")],16):Ir("uni-view",{ref:t},[jo(e,"default")],512)}}});function bQ(A,e){if(e||(e=A.id),e)return A.$options.name.toLowerCase()+"."+e}function GQ(A,e,t){A&&sc(t||Xc(),A,({type:A,data:t},i)=>{e(A,t,i)})}function kQ(A,e){A&&function(A,e){e=rc(A,e),delete nc[e]}(e||Xc(),A)}function LQ(A,e,t,i){const o=Dr().proxy;i=null==i?Kc():i,Uo(()=>{GQ(e||bQ(o),A,i),!t&&e||Xi(()=>o.id,(e,t)=>{GQ(bQ(o,e),A,i),kQ(t&&bQ(o,t))})}),xo(()=>{kQ(e||bQ(o),i)})}let UQ=0;function FQ(A){const e=Kc(),t=Dr().proxy,i=t.$options.name.toLowerCase(),o=A||t.id||"context"+UQ++;return Uo(()=>{t.$el.__uniContextInfo={id:o,type:i,page:e}}),`${i}.${o}`}function OQ(A,e,t,i){p(e)&&Go(A,e.bind(t),i)}function xQ(A,e,t){const i=A.mpType||t.$mpType;if(i&&"component"!==i&&("page"!==i||"component"!==e.renderer)&&(Object.keys(A).forEach(i=>{if(function(A,e,t=!0){return!(t&&!p(e))&&(ue.indexOf(A)>-1||0===A.indexOf("on"))}(i,A[i],!1)){const o=A[i];C(o)?o.forEach(A=>OQ(i,A,t,e)):OQ(i,o,t,e)}}),"page"===i)){e.__isVisible=!0;try{let A=e.attrs.__pageQuery;0,il(t,CA,A),e.vapor||delete e.attrs.__pageQuery;const i=t.$page;"preloadPage"!==(null==i?void 0:i.openType)&&il(t,cA)}catch(__){console.error(__.message+oA+__.stack)}}}function PQ(A,e,t){xQ(A,e,t)}function YQ(A,e,t){return A[e]=t}function JQ(A,...e){const t=this[A];return t?t(...e):(console.error(`method ${A} not found`),null)}function HQ(A){const e=A.config.errorHandler;return function(t,i,o){e&&e(t,i,o);const n=A._instance;if(!n||!n.proxy)throw t;n[uA]?il(n.proxy,uA,t):ci(t,0,i&&i.$.vnode,!1)}}function qQ(A,e){return A?[...new Set([].concat(A,e))]:e}function VQ(A){const e=A.config;var t;e.errorHandler=he(A,HQ),t=e.optionMergeStrategies,ue.forEach(A=>{t[A]=qQ});const i=e.globalProperties;i.$set=YQ,i.$applyOptions=PQ,i.$callMethod=JQ,function(A){Ee=A,de.forEach(e=>e(A))}(A)}function jQ(A){const e=fg({history:zQ(),strict:!!__uniConfig.router.strict,routes:__uniRoutes,scrollBehavior:WQ});e.beforeEach((A,e)=>{var t;A&&e&&A.meta.isTabBar&&e.meta.isTabBar&&(t=e.meta.tabBarIndex,"undefined"!=typeof window&&(KQ[t]={left:window.pageXOffset,top:window.pageYOffset}))}),A.router=e,A.use(e)}let KQ=Object.create(null);const WQ=(A,e,t)=>{if(t)return t;if(A&&e&&A.meta.isTabBar&&e.meta.isTabBar){const e=(i=A.meta.tabBarIndex,KQ[i]);if(e)return e}return{left:0,top:0};var i};function zQ(){let{routerBase:A}=__uniConfig.router;"/"===A&&(A="");const e=ka(A);return e.listen((A,e,t)=>{"back"===t.direction&&function(A=1){const e=Uh(),t=e.length-1,i=t-A;for(let o=t;o>i;o--){const A=Rh(e[o]);Fh(Yh(A.path,A.id),!1)}}(Math.abs(t.delta))}),e}const ZQ={install(A){VQ(A),pl(A),Tl(A),A.config.warnHandler||(A.config.warnHandler=XQ),jQ(A)}};function XQ(A,e,t){if(e){if("PageMetaHead"===e.$.type.name)return;const A=e.$.parent;if(A&&"PageMeta"===A.type.name)return}const i=[`[Vue warn]: ${A}`];t.length&&i.push("\n",t),console.warn(...i)}const $Q={class:"uni-async-loading"},Ap=Ir("i",{class:"uni-loading"},null,-1),ep=Ul({name:"AsyncLoading",render:()=>(Ar(),nr("div",$Q,[Ap]))});function tp(){window.location.reload()}const ip=Ul({name:"AsyncError",props:["error"],setup(){qg();const{t:A}=Jg();return()=>Ir("div",{class:"uni-async-error",onClick:tp},[A("uni.async.error")],8,["onClick"])}});let op;function np(){return op}function rp(A){op=A,Object.defineProperty(op.$.ctx,"$children",{get:()=>Uh().map(A=>A.$vm)});const e=op.$.appContext.app;e.component(ep.name)||e.component(ep.name,ep),e.component(ip.name)||e.component(ip.name,ip),function(A){A.$vm=A,A.$mpType="app";const e=Kt(Jg().getLocale());Object.defineProperty(A,"$locale",{get:()=>e.value,set(A){e.value=A}})}(op),function(A,e){const t=A.$options||{};t.globalData=u(t.globalData||{},e),Object.defineProperty(A,"globalData",{get:()=>t.globalData,set(A){t.globalData=A}})}(op),Rl(),cl()}function sp(A,{clone:e,init:t,setup:i,before:o}){e&&(A=u({},A)),o&&o(A);const n=A.setup;return A.setup=(A,e)=>{const o=Dr();if(t(o.proxy),i(o),n)return n(A,e)},A}function ap(A,e){return A&&(A.__esModule||"Module"===A[Symbol.toStringTag])?sp(A.default,e):sp(A,e)}function gp(A){return ap(A,{clone:!0,init:Ph,setup(A){A.$pageInstance=A;const e=eI(),t=se(e.query);A.attrs.__pageQuery=t,Rh(A.proxy).options=t,A.proxy.options=t;const i=$l();var o;vh(i),A.onReachBottom=Nt([]),A.onPageScroll=Nt([]),Xi([A.onReachBottom,A.onPageScroll],()=>{const e=zc();A.proxy===e&&Zh(A,i)},{once:!0}),Lo(()=>{qh(A,i)}),Uo(()=>{Vh(A);const{onReady:t}=A;t&&F(t),up(e)}),Mo(()=>{if(!A.__isVisible){qh(A,i),A.__isVisible=!0;const{onShow:t}=A;t&&F(t),pi(()=>{up(e)})}},"ba",o),function(A,e){Mo(A,"bda",e)}(()=>{if(A.__isVisible&&!A.__isUnload){A.__isVisible=!1;{const{onHide:e}=A;e&&F(e)}}});const n=tl(A.proxy);return function(A){Ov.subscribe(rc(A,tc),ac)}(n),xo(()=>{!function(A){Ov.unsubscribe(rc(A,tc)),Object.keys(nc).forEach(e=>{0===e.indexOf(A+".")&&delete nc[e]})}(n)}),t}})}function cp(){const{windowWidth:A,windowHeight:e,screenWidth:t,screenHeight:i}=uni.getSystemInfoSync(),o=90===Math.abs(Number(window.orientation))?"landscape":"portrait";Pv.emit(mA,{deviceOrientation:o,size:{windowWidth:A,windowHeight:e,screenWidth:t,screenHeight:i}})}function lp(A){S(A.data)&&"WEB_INVOKE_APPSERVICE"===A.data.type&&Pv.emit(OA,A.data.data,A.data.pageId)}function Ip(){const{emit:A}=Pv;"visible"===document.visibilityState?A(UA,vC()):A(FA)}function up(A){const{tabBarText:e,tabBarIndex:t,route:i}=A.meta;e&&il("onTabItemTap",{index:t,text:e,pagePath:i})}function Ep(A){A=A>0&&A<1/0?A:0;const e=Math.floor(A/3600),t=Math.floor(A%3600/60),i=Math.floor(A%3600%60),o=(e<10?"0":"")+e;let n=(t<10?"0":"")+t+":"+((i<10?"0":"")+i);return"00"!==o&&(n=o+":"+n),n}function dp(A,e,t){const i=Nt({seeking:!1,gestureType:"none",volumeOld:0,volumeNew:0,currentTimeOld:0,currentTimeNew:0,toastThin:!1}),o={x:0,y:0};let n=null;let r;return{state:i,onTouchstart:function(A){const e=A.targetTouches[0];o.x=e.pageX,o.y=e.pageY,i.gestureType="none",i.volumeOld=0},onTouchmove:function(s){function a(){s.stopPropagation(),s.preventDefault()}t.fullscreen&&a();const g=i.gestureType;if("stop"===g)return;const c=s.targetTouches[0],l=c.pageX,I=c.pageY,u=o,E=e.value;if("progress"===g?(!function(A){const t=e.value,o=t.duration;let n=A/600*o+i.currentTimeOld;n<0?n=0:n>o&&(n=o);i.currentTimeNew=n}(l-u.x),i.seeking=!0):"volume"===g&&function(A){const t=e.value,o=i.volumeOld;let n;"number"==typeof o&&(n=o-A/200,n<0?n=0:n>1&&(n=1),clearTimeout(r),r=void 0,null==r&&(r=setTimeout(()=>{i.toastThin=!1,r=void 0},1e3)),t.volume=n,i.volumeNew=n)}(I-u.y),"none"===g)if(Math.abs(l-u.x)>Math.abs(I-u.y)){if(!A.enableProgressGesture)return void(i.gestureType="stop");i.gestureType="progress",i.currentTimeOld=i.currentTimeNew=E.currentTime,t.fullscreen||a()}else{if(!A.pageGesture&&!A.vslideGesture)return void(i.gestureType="stop");"none"!==i.gestureType&&null!=n||(n=setTimeout(()=>{i.toastThin=!0},500)),i.gestureType="volume",i.volumeOld=E.volume,t.fullscreen||a()}},onTouchend:function(A){const t=e.value;"none"!==i.gestureType&&"stop"!==i.gestureType&&(A.stopPropagation(),A.preventDefault()),"progress"===i.gestureType&&i.currentTimeOld!==i.currentTimeNew&&(t.currentTime=i.currentTimeNew),i.gestureType="none"}}}const hp={id:{type:String,default:""},src:{type:String,default:""},duration:{type:[Number,String],default:""},controls:{type:[Boolean,String],default:!0},danmuList:{type:Array,default:()=>[]},danmuBtn:{type:[Boolean,String],default:!1},enableDanmu:{type:[Boolean,String],default:!1},autoplay:{type:[Boolean,String],default:!1},loop:{type:[Boolean,String],default:!1},muted:{type:[Boolean,String],default:!1},objectFit:{type:String,default:"contain"},poster:{type:String,default:""},direction:{type:[String,Number],default:""},showProgress:{type:Boolean,default:!0},initialTime:{type:[String,Number],default:0},showFullscreenBtn:{type:[Boolean,String],default:!0},pageGesture:{type:[Boolean,String],default:!1},vslideGesture:{type:[Boolean,String],default:!1},enableProgressGesture:{type:[Boolean,String],default:!0},showPlayBtn:{type:[Boolean,String],default:!0},showCenterPlayBtn:{type:[Boolean,String],default:!0}},Cp=Ll({name:"Video",props:hp,emits:["fullscreenchange","progress","loadedmetadata","waiting","error","play","pause","ended","timeupdate"],setup(A,{emit:e,attrs:t,slots:i}){const o=Kt(null),n=Kt(null),r=Ol(o,e),{state:s}=IB(),{$attrs:a}=MB({excludeListeners:!0});Jg(),$g();const{videoRef:g,state:c,play:l,pause:I,stop:u,seek:E,playbackRate:d,toggle:h,onDurationChange:B,onLoadedMetadata:Q,onProgress:p,onWaiting:f,onVideoError:m,onPlay:y,onPause:D,onEnded:v,onTimeUpdate:w}=function(A,e,t){const i=Kt(null),o=Ur(()=>AC(A.src)),n=Ur(()=>"true"===A.muted||!0===A.muted),r=Nt({start:!1,src:o,playing:!1,currentTime:0,duration:0,progress:0,buffered:0,muted:n,pauseUpdatingCurrentTime:!1});function s(A){const e=A.target,t=e.buffered;t.length&&(r.buffered=t.end(t.length-1)/e.duration*100)}function a(){i.value.pause()}function g(A){const e=i.value;"number"!=typeof(A=Number(A))||isNaN(A)||(e.currentTime=A)}return Xi(()=>o.value,()=>{r.playing=!1,r.currentTime=0}),Xi(()=>r.buffered,A=>{t("progress",{},{buffered:A})}),Xi(()=>n.value,A=>{i.value.muted=A}),{videoRef:i,state:r,play:function(){const A=i.value;r.start=!0,A.play()},pause:a,stop:function(){g(0),a()},seek:g,playbackRate:function(A){i.value.playbackRate=A},toggle:function(){const A=i.value;r.playing?A.pause():A.play()},onDurationChange:function({target:A}){r.duration=A.duration},onLoadedMetadata:function(e){const i=Number(A.initialTime)||0,o=e.target;i>0&&(o.currentTime=i),t("loadedmetadata",e,{width:o.videoWidth,height:o.videoHeight,duration:o.duration}),s(e)},onProgress:s,onWaiting:function(A){t("waiting",A,{})},onVideoError:function(A){r.playing=!1,t("error",A,{})},onPlay:function(A){r.start=!0,r.playing=!0,t("play",A,{})},onPause:function(A){r.playing=!1,t("pause",A,{})},onEnded:function(A){r.playing=!1,t("ended",A,{})},onTimeUpdate:function(A){const e=A.target;r.pauseUpdatingCurrentTime||(r.currentTime=e.currentTime);const i=e.currentTime;t("timeupdate",A,{currentTime:i,duration:e.duration})}}}(A,0,r),{state:S,danmuRef:M,updateDanmu:R,toggleDanmu:_,sendDanmu:T}=function(A,e){const t=Kt(null),i=Nt({enable:Boolean(A.enableDanmu)});let o={time:0,index:-1};const n=C(A.danmuList)?JSON.parse(JSON.stringify(A.danmuList)):[];function r(A){const e=document.createElement("p");e.className="uni-video-danmu-item",e.innerText=A.text;let i=`bottom: ${100*Math.random()}%;color: ${A.color};`;e.setAttribute("style",i),t.value.appendChild(e),setTimeout(function(){i+="left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);",e.setAttribute("style",i),setTimeout(function(){e.remove()},4e3)},17)}return n.sort(function(A,e){return(A.time||0)-(e.time||0)}),{state:i,danmuRef:t,updateDanmu:function(A){const t=A.target.currentTime,s=o,a={time:t,index:s.index};if(t>s.time)for(let o=s.index+1;o=(A.time||0)))break;a.index=o,e.playing&&i.enable&&r(A)}else if(t-1&&t<=(n[e].time||0);e--)a.index=e-1;o=a},toggleDanmu:function(){i.enable=!i.enable},sendDanmu:function(A){n.splice(o.index+1,0,{text:String(A.text),color:A.color,time:e.currentTime||0})}}}(A,c),{state:N,onFullscreenChange:b,emitFullscreenChange:G,toggleFullscreen:k,requestFullScreen:L,exitFullScreen:U}=function(A,e,t,i,o){const n=Nt({fullscreen:!1}),r=/^Apple/.test(navigator.vendor);function s(e){n.fullscreen=e,A("fullscreenchange",{},{fullScreen:e,direction:"vertical"})}function a(A){const n=o.value,a=e.value,g=t.value;let c;A?!document.fullscreenEnabled&&!document.webkitFullscreenEnabled||r&&!i.userAction?g.webkitEnterFullScreen?g.webkitEnterFullScreen():(c=!0,a.remove(),a.classList.add("uni-video-type-fullscreen"),document.body.appendChild(a)):a[document.fullscreenEnabled?"requestFullscreen":"webkitRequestFullscreen"]():document.fullscreenEnabled||document.webkitFullscreenEnabled?document.fullscreenElement?document.exitFullscreen():document.webkitFullscreenElement&&document.webkitExitFullscreen():g.webkitExitFullScreen?g.webkitExitFullScreen():(c=!0,a.remove(),a.classList.remove("uni-video-type-fullscreen"),n.appendChild(a)),c&&s(A)}function g(){a(!1)}return xo(g),{state:n,onFullscreenChange:function(A,e){e&&document.fullscreenEnabled||s(!(!document.fullscreenElement&&!document.webkitFullscreenElement))},emitFullscreenChange:s,toggleFullscreen:a,requestFullScreen:function(){a(!0)},exitFullScreen:g}}(r,n,g,s,o),{state:F,onTouchstart:O,onTouchend:x,onTouchmove:P}=dp(A,g,N),{state:Y,progressRef:J,ballRef:H,clickProgress:q,toggleControls:V,autoHideEnd:j,autoHideStart:K}=function(A,e,t,i){const o=Kt(null),n=Kt(null),r=Ur(()=>A.showCenterPlayBtn&&!e.start),s=Kt(!0),a=Ur(()=>!r.value&&A.controls&&s.value),g=Nt({seeking:!1,touching:!1,controlsTouching:!1,centerPlayBtnShow:r,controlsShow:a,controlsVisible:s});let c;function l(){c=setTimeout(()=>{g.controlsVisible=!1},3e3)}function I(){c&&(clearTimeout(c),c=null)}return xo(()=>{c&&clearTimeout(c)}),Xi(()=>g.controlsShow&&e.playing&&!g.controlsTouching,A=>{A?l():I()}),Uo(()=>{const A=oe(!1);let r,s,a,c=!0;const l=n.value;function I(A){const t=A.targetTouches[0],n=t.pageX,l=t.pageY;if(c&&Math.abs(n-r)100&&(E=100),e.progress=E,null==i||i(e.duration*E/100),g.seeking=!0,A.preventDefault(),A.stopPropagation()}function u(i){g.controlsTouching=!1,g.touching&&(l.removeEventListener("touchmove",I,A),c||(i.preventDefault(),i.stopPropagation(),t(e.duration*e.progress/100)),g.touching=!1)}l.addEventListener("touchstart",t=>{g.controlsTouching=!0;const i=t.targetTouches[0];r=i.pageX,s=i.pageY,a=e.progress,c=!0,g.touching=!0,l.addEventListener("touchmove",I,A)}),l.addEventListener("touchend",u),l.addEventListener("touchcancel",u)}),{state:g,progressRef:o,ballRef:n,clickProgress:function(A){const i=o.value;let n=A.target,r=A.offsetX;for(;n&&n!==i;)r+=n.offsetLeft,n=n.parentNode;const s=i.offsetWidth;let a=0;r>=0&&r<=s&&(a=r/s,t(e.duration*a))},toggleControls:function(){g.controlsVisible=!g.controlsVisible},autoHideStart:l,autoHideEnd:I}}(A,c,E,A=>{F.currentTimeNew=A});!function(A,e,t,i,o,n,r,s){const a={play:A,stop:t,pause:e,seek:i,sendDanmu:o,playbackRate:n,requestFullScreen:r,exitFullScreen:s};LQ((A,e)=>{let t;switch(A){case"seek":t=e.position;break;case"sendDanmu":t=e;break;case"playbackRate":t=e.rate}A in a&&a[A](t)},FQ(),!0)}(l,I,u,E,T,d,L,U);const W=function(A,e,t){const i=Ur(()=>"progress"===e.gestureType||t.touching);return Xi(i,i=>{A.pauseUpdatingCurrentTime=i,t.controlsTouching=i,"progress"===e.gestureType&&i&&(t.controlsVisible=i)}),Xi([()=>A.currentTime,()=>{hp.duration}],()=>{A.progress=A.currentTime/A.duration*100}),Xi(()=>e.currentTimeNew,e=>{A.currentTime=e}),i}(c,F,Y);return()=>Ir("uni-video",{ref:o,id:A.id,onClick:V},[Ir("div",{ref:n,class:"uni-video-container",onTouchstart:O,onTouchend:x,onTouchmove:P,onFullscreenchange:Gs(b,["stop"]),onWebkitfullscreenchange:Gs(A=>b(A,!0),["stop"])},[Ir("video",Qr({ref:g,style:{"object-fit":A.objectFit},muted:!!A.muted,loop:!!A.loop,src:c.src,poster:A.poster,autoplay:!!A.autoplay},a.value,{class:"uni-video-video","webkit-playsinline":!0,playsinline:!0,onDurationchange:B,onLoadedmetadata:Q,onProgress:p,onWaiting:f,onError:m,onPlay:y,onPause:D,onEnded:v,onTimeupdate:A=>{w(A),R(A)},onWebkitbeginfullscreen:()=>G(!0),onX5videoenterfullscreen:()=>G(!0),onWebkitendfullscreen:()=>G(!1),onX5videoexitfullscreen:()=>G(!1)}),null,16,["muted","loop","src","poster","autoplay","webkit-playsinline","playsinline","onDurationchange","onLoadedmetadata","onProgress","onWaiting","onError","onPlay","onPause","onEnded","onTimeupdate","onWebkitbeginfullscreen","onX5videoenterfullscreen","onWebkitendfullscreen","onX5videoexitfullscreen"]),io(Ir("div",{class:"uni-video-bar uni-video-bar-full",onClick:Gs(()=>{},["stop"])},[Ir("div",{class:"uni-video-controls"},[io(Ir("div",{class:{"uni-video-icon":!0,"uni-video-control-button":!0,"uni-video-control-button-play":!c.playing,"uni-video-control-button-pause":c.playing},onClick:Gs(h,["stop"])},null,10,["onClick"]),[[ss,A.showPlayBtn]]),io(Ir("div",{class:"uni-video-current-time"},[Ep(c.currentTime)],512),[[ss,A.showProgress]]),io(Ir("div",{ref:J,class:"uni-video-progress-container",onClick:Gs(q,["stop"])},[Ir("div",{class:{"uni-video-progress":!0,"uni-video-progress-progressing":W.value}},[Ir("div",{style:{width:c.buffered-c.progress+"%",left:c.progress+"%"},class:"uni-video-progress-buffered"},null,4),Ir("div",{style:{width:c.progress+"%"},class:"uni-video-progress-played"},null,4),Ir("div",{ref:H,style:{left:c.progress+"%"},class:{"uni-video-ball":!0,"uni-video-ball-progressing":W.value}},[Ir("div",{class:"uni-video-inner"},null)],6)],2)],8,["onClick"]),[[ss,A.showProgress]]),io(Ir("div",{class:"uni-video-duration"},[Ep(Number(A.duration)||c.duration)],512),[[ss,A.showProgress]])]),io(Ir("div",{class:{"uni-video-icon":!0,"uni-video-danmu-button":!0,"uni-video-danmu-button-active":S.enable},onClick:Gs(_,["stop"])},null,10,["onClick"]),[[ss,A.danmuBtn]]),io(Ir("div",{class:{"uni-video-icon":!0,"uni-video-fullscreen":!0,"uni-video-type-fullscreen":N.fullscreen},onClick:Gs(()=>k(!N.fullscreen),["stop"])},null,10,["onClick"]),[[ss,A.showFullscreenBtn]])],8,["onClick"]),[[ss,Y.controlsShow]]),io(Ir("div",{ref:M,style:"z-index: 0;",class:"uni-video-danmu"},null,512),[[ss,c.start&&S.enable]]),Y.centerPlayBtnShow&&Ir("div",{class:"uni-video-cover",onClick:Gs(()=>{},["stop"])},[Ir("div",{class:"uni-video-cover-play-button uni-video-icon",onClick:Gs(l,["stop"])},null,8,["onClick"])],8,["onClick"]),Ir("div",{class:"uni-video-loading"},["volume"===F.gestureType?Ir("div",{class:{"uni-video-toast-container":!0,"uni-video-toast-container-thin":F.toastThin},style:{marginTop:"5px"}},[!F.toastThin&&F.volumeNew>0&&"volume"===F.gestureType?Ir("text",{class:"uni-video-icon uni-video-toast-icon"},[""]):!F.toastThin&&Ir("text",{class:"uni-video-icon uni-video-toast-icon"},[""]),Ir("div",{class:"uni-video-toast-draw",style:{width:100*F.volumeNew+"%"}},null)],2):null]),Ir("div",{class:{"uni-video-toast":!0,"uni-video-toast-progress":W.value}},[Ir("div",{class:"uni-video-toast-title"},[Ir("span",{class:"uni-video-toast-title-current-time"},[Ep(F.currentTimeNew)])," / ",Number(A.duration)||Ep(c.duration)])],2),Ir("div",{class:"uni-video-slots"},[i.default&&i.default()])],40,["onTouchstart","onTouchend","onTouchmove","onFullscreenchange","onWebkitfullscreenchange"])],8,["id","onClick"])}}),Bp=({name:A,arg:e})=>{if("postMessage"===A);else switch(A){case"navigateTo":uni.navigateTo(e);break;case"navigateBack":uni.navigateBack(e);break;case"switchTab":uni.switchTab(e);break;case"reLaunch":uni.reLaunch(e);break;case"redirectTo":uni.redirectTo(e)}},Qp=HA(()=>Pv.on(OA,Bp)),pp=Ll({inheritAttrs:!1,name:"WebView",props:{src:{type:String,default:""},fullscreen:{type:Boolean,default:!0}},emits:["load"],setup(A,{emit:e}){Qp();const t=Kt(null),i=Kt(null),{$attrs:o,$excludeAttrs:n,$listeners:r}=MB({excludeListeners:!0}),s=Ol(t,e);let a;return(()=>{const e=document.createElement("iframe");e.onload=function(e){s("load",e,{src:A.src})},zi(()=>{for(const A in o.value)if(h(o.value,A)){const t=o.value[A];e[A]=t}}),zi(()=>{e.src=AC(A.src)}),i.value=e,a=function(A,e,t){const i=()=>{var i,o;if(t){const{top:t,left:i,width:o,height:n}=A.value.getBoundingClientRect();JA(e.value,{position:"absolute",display:"block",border:"0",top:t+"px",left:i+"px",width:o+"px",height:n+"px"})}else JA(e.value,{width:(null==(i=A.value)?void 0:i.style.width)||"300px",height:(null==(o=A.value)?void 0:o.style.height)||"150px"})};return i}(t,i,A.fullscreen),A.fullscreen&&document.body.appendChild(e)})(),Uo(()=>{var e;a(),!A.fullscreen&&(null==(e=t.value)||e.appendChild(i.value))}),wo(()=>{A.fullscreen&&(i.value.style.display="block")}),So(()=>{A.fullscreen&&(i.value.style.display="none")}),xo(()=>{A.fullscreen&&document.body.removeChild(i.value)}),()=>Ir(Kn,null,[Ir("uni-web-view",Qr({class:A.fullscreen?"uni-webview--fullscreen":""},r.value,n.value,{ref:t}),[Ir(wC,{onResize:a},null,8,["onResize"])],16)])}});let fp,mp=0;function yp(A,e,t,i){var o,n=document.createElement("script"),r=e.callback||"callback",s="__uni_jsonp_callback_"+mp++,a=e.timeout||3e4;function g(){clearTimeout(o),delete window[s],n.remove()}window[s]=A=>{p(t)&&t(A),g()},n.onerror=()=>{p(i)&&i(),g()},o=setTimeout(function(){p(i)&&i(),g()},a),n.src=A+(A.indexOf("?")>=0?"&":"?")+r+"="+s,document.body.appendChild(n)}function Dp(A){function e(){const A=this.div;this.getPanes().floatPane.appendChild(A)}function t(){const A=this.div.parentNode;A&&A.removeChild(this.div)}function i(){const e=this.option;this.Text=new A.Text({text:e.content,anchor:"bottom-center",offset:new A.Pixel(0,e.offsetY-16),style:{padding:(e.padding||8)+"px","line-height":(e.fontSize||14)+"px","border-radius":(e.borderRadius||0)+"px","border-color":`${e.bgColor||"#fff"} transparent transparent`,"background-color":e.bgColor||"#fff","box-shadow":"0 2px 6px 0 rgba(114, 124, 245, .5)","text-align":"center","font-size":(e.fontSize||14)+"px",color:e.color||"#000"},position:e.position});(A.event||A.Event).addListener(this.Text,"click",()=>{this.callback()}),this.Text.setMap(e.map)}function o(){}function n(){this.Text&&this.option.map.remove(this.Text)}function r(){this.Text&&this.option.map.remove(this.Text)}class s{constructor(A={},s){this.createAMapText=i,this.removeAMapText=n,this.createBMapText=o,this.removeBMapText=r,this.onAdd=e,this.construct=e,this.onRemove=t,this.destroy=t,this.option=A||{};const a=this.visible=this.alwaysVisible="ALWAYS"===A.display;if(kp())this.callback=s,this.visible&&this.createAMapText();else if(Lp())this.visible&&this.createBMapText();else{const e=A.map;this.position=A.position,this.index=1;const t=this.div=document.createElement("div"),i=t.style;i.position="absolute",i.whiteSpace="nowrap",i.transform="translateX(-50%) translateY(-100%)",i.zIndex="1",i.boxShadow=A.boxShadow||"none",i.display=a?"block":"none";const o=this.triangle=document.createElement("div");o.setAttribute("style","position: absolute;white-space: nowrap;border-width: 4px;border-style: solid;border-color: #fff transparent transparent;border-image: initial;font-size: 12px;padding: 0px;background-color: transparent;width: 0px;height: 0px;transform: translate(-50%, 100%);left: 50%;bottom: 0;"),this.setStyle(A),t.appendChild(o),e&&this.setMap(e)}}set onclick(A){this.div.onclick=A}get onclick(){return this.div.onclick}setOption(A){this.option=A,"ALWAYS"===A.display?this.alwaysVisible=this.visible=!0:this.alwaysVisible=!1,kp()?this.visible&&this.createAMapText():Lp()?this.visible&&this.createBMapText():(this.setPosition(A.position),this.setStyle(A))}setStyle(A){const e=this.div,t=e.style;e.innerText=A.content||"",t.lineHeight=(A.fontSize||14)+"px",t.fontSize=(A.fontSize||14)+"px",t.padding=(A.padding||8)+"px",t.color=A.color||"#000",t.borderRadius=(A.borderRadius||0)+"px",t.backgroundColor=A.bgColor||"#fff",t.marginTop="-"+((A.top||0)+5)+"px",this.triangle.style.borderColor=`${A.bgColor||"#fff"} transparent transparent`}setPosition(A){this.position=A,this.draw()}draw(){const A=this.getProjection();if(!this.position||!this.div||!A)return;const e=A.fromLatLngToDivPixel(this.position),t=this.div.style;t.left=e.x+"px",t.top=e.y+"px"}changed(){this.div.style.display=this.visible?"block":"none"}}if(!kp()&&!Lp()){const e=new(A.OverlayView||A.Overlay);s.prototype.setMap=e.setMap,s.prototype.getMap=e.getMap,s.prototype.getPanes=e.getPanes,s.prototype.getProjection=e.getProjection,s.prototype.map_changed=e.map_changed,s.prototype.set=e.set,s.prototype.get=e.get,s.prototype.setOptions=e.setValues,s.prototype.bindTo=e.bindTo,s.prototype.bindsTo=e.bindsTo,s.prototype.notify=e.notify,s.prototype.setValues=e.setValues,s.prototype.unbind=e.unbind,s.prototype.unbindAll=e.unbindAll,s.prototype.addListener=e.addListener}return s}const vp={};function wp(A,e){const t=Np();if(!t.key)return void console.error("Map key not configured.");const i=vp[t.type]=vp[t.type]||[];if(fp)e(fp);else if(window[t.type]&&window[t.type].maps)fp=kp()||Lp()?window[t.type]:window[t.type].maps,fp.Callout=fp.Callout||Dp(fp),e(fp);else if(i.length)i.push(e);else{i.push(e);const o=window,n="__map_callback__"+t.type;o[n]=function(){delete o[n],fp=kp()||Lp()?window[t.type]:window[t.type].maps,fp.Callout=Dp(fp),i.forEach(A=>A(fp)),i.length=0},kp()&&function(A){window._AMapSecurityConfig={securityJsCode:A.securityJsCode||"",serviceHost:A.serviceHost||""}}(t);const r=document.createElement("script");let s=Sp(t.type);t.type===Tp.QQ&&A.push("geometry"),A.length&&(s+=`libraries=${A.join("%2C")}&`),t.type===Tp.BMAP?r.src=`${s}ak=${t.key}&callback=${n}`:r.src=`${s}key=${t.key}&callback=${n}`,r.onerror=function(){console.error("Map load failed.")},document.body.appendChild(r)}}const Sp=A=>({qq:"https://map.qq.com/api/js?v=2.exp&",google:"https://maps.googleapis.com/maps/api/js?",AMap:"https://webapi.amap.com/maps?v=2.0&",BMapGL:"https://api.map.baidu.com/api?type=webgl&v=1.0&"}[A]);const Mp="M13.3334375 16 q0.033125 1.1334375 0.783125 1.8834375 q0.75 0.75 1.8834375 0.75 q1.1334375 0 1.8834375 -0.75 q0.75 -0.75 0.75 -1.8834375 q0 -1.1334375 -0.75 -1.8834375 q-0.75 -0.75 -1.8834375 -0.75 q-1.1334375 0 -1.8834375 0.75 q-0.75 0.75 -0.783125 1.8834375 ZM30.9334375 14.9334375 l-1.1334375 0 q-0.5 -5.2 -4.0165625 -8.716875 q-3.516875 -3.5165625 -8.716875 -4.0165625 l0 -1.1334375 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 1.1334375 q-5.2 0.5 -8.716875 4.0165625 q-3.5165625 3.516875 -4.0165625 8.716875 l-1.1334375 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l1.1334375 0 q0.5 5.2 4.0165625 8.716875 q3.516875 3.5165625 8.716875 4.0165625 l0 1.1334375 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -1.1334375 q5.2 -0.5 8.716875 -4.0165625 q3.5165625 -3.516875 4.0165625 -8.716875 l1.1334375 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 ZM17.0665625 27.6665625 l0 -2.0665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 2.0665625 q-4.3 -0.4665625 -7.216875 -3.383125 q-2.916875 -2.916875 -3.3834375 -7.216875 l2.0665625 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 l-2.0665625 0 q0.4665625 -4.3 3.3834375 -7.216875 q2.9165625 -2.916875 7.216875 -3.3834375 l0 2.0665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -2.0665625 q4.3 0.4665625 7.216875 3.3834375 q2.9165625 2.9165625 3.383125 7.216875 l-2.0665625 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l2.0665625 0 q-0.4665625 4.3 -3.383125 7.216875 q-2.916875 2.9165625 -7.216875 3.383125 Z",Rp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAMAAABmmnOVAAAC01BMVEUAAAAAef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef96quGStdqStdpbnujMzMzCyM7Gyc7Ky83MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMwAef8GfP0yjfNWnOp0qOKKsdyYt9mju9aZt9mMstx1qeJYnekyjvIIfP0qivVmouaWttnMzMyat9lppOUujPQKffxhoOfNzc3Y2Njh4eHp6enu7u7y8vL19fXv7+/i4uLZ2dnOzs6auNgOf/sKff15quHR0dHx8fH9/f3////j4+N6quFdn+iywdPb29vw8PD+/v7c3NyywtLa2tr29vbS0tLd3d38/Pzf39/o6Ojc7f+q0v+HwP9rsf9dqv9Hnv9Vpv/q6urj8P+Vx/9Am/8Pgf8Iff/z8/OAvP95uf/n5+c5l//V6f+52v+y1//7+/vt7e0rkP/09PTQ0NDq9P8Whf+cy//W1tbe3t7A3v/m5ubs7OxOov/r6+vk5OQiaPjKAAAAknRSTlMACBZ9oB71/jiqywJBZATT6hBukRXv+zDCAVrkDIf4JbQsTb7eVeJLbwfa8Rh4G/OlPS/6/kxQ9/xdmZudoJxNVhng7B6wtWdzAtQOipcF1329wS44doK/BAkyP1pvgZOsrbnGXArAg34G2IsD1eMRe7bi7k5YnqFT9V0csyPedQyYD3p/Fje+hDpskq/MwpRBC6yKp2MAAAQdSURBVHja7Zn1exMxGIAPHbrhDsPdneHuNtzd3d3dIbjLh93o2o4i7TpgG1Jk0g0mMNwd/gTa5rq129reHnK5e/bk/TFNk/dJ7r5894XjGAwGg8GgTZasCpDIll1+hxw5vXLJLpEboTx5ZXbIhyzkl9fB28cqUaCgrBKFkI3CcjoUKYolihWXUSI7EihRUjaHXF52CVRKLoe8eZIdUOkyMknkRw6UlcehYAFHiXK+skgURk6Ul8OhQjFnCVRRBolKqRxQ5SzUHaqgNGSj7VCmalqJnDkoS5RF6ZCbroNvufQkUD6qEuXTdUA+3hQdqiEXVKfnUKOmK4latalJ1EEuoZZ6162HJ9x/4OChw0eOHj12/MTJU6dxG7XUu751tjNnz4ET5y9ctLZTSr0beKFLl89bpuUDrqgC1RqNWqsKuqqzNFw7e51S6u3tc+OmZUJ9kCHY6ECwOkRvab51iUrqXej2HYDQsHBjWgx3Ae7dppB6N2wEcF9jdMGDUIDGTaR2aNoM9FqjG7QmaN5CWgc/gIePjG559BigpZQOrYB/4jBfRGRUtDkmJjY6KjLCofkpD62lc2gDfMpWPIuLdwyV8XEpHgaddBZ+wBuSFcwJqSN2ovmZ/dfnOvCTxqGtwzq8SEjv4EhISn48eWgnhUP7DvDSvgzxrs6vV6+FLiro2EkCic4QKkzwJsH1KYreCp0eQhfyDl1B/w4P/xa5JVJ4U03QjbRD9x7wXlgH5IE3wmMBHXoSlugFAcI6f/AkkSi8q6HQm6xDn77wEQ8djTwSj3tqAMguRTe4ikeOQyJ4YV+KfkQl+oNW5GbY4gWOWgbwJ+kwAD6Fi90MK2ZsrIeBBCUGwRXbqJ+/iJMQliIEBhOU6AJhtlG/IpHE2bqrYQg5h6HA4yQiRqwEfkGCdTCMmMRw+IbPDCQaHCsCYAQxiZHw3TbmD/ESOHgHwShiEqPhp/gggYkSztIxxCRawy/bmEniJaJtfwiEscQkxkFgRqJESqQwwHhiEuMBp3Vm8RK/cZoHEzKXhCK2QxEPpiJe0YlKCFaKCNv/cYBNUsBRPlkJSc0U+dM7E9H0ThGJbgZT/iR7yj+VqMS06Qr4+OFm2JdCxIa8lugzkJs5K6MfxAaYPUcBpYG5khZJEkUUSb7DPCnKRfPBXj6M8FwuegoLpCgXcQszVjhbJFUJUee2hBhLoYTIcYtB57KY+opSMdVqwatSlZVj05aV//CwJLMX2DluaUcwhXm4ali2XOoLjxUrPV26zFtF4f5p0Gp310+z13BUWNvbehEXona6iAtX/zVZmtfN4WixfsNky4S6gCCVVq3RPLdfSfpv3MRRZfPoLc6Xs/5bt3EyMGzE9h07/Xft2t15z6i9+zgGg8FgMBgMBoPBYDAYDAYj8/APG67Rie8pUDsAAAAASUVORK5CYII=",_p="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAACcCAMAAAC3Fl5oAAAB3VBMVEVMaXH/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/EhL/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/Dw//AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/GRn/NTX/Dw//Fhb/AAD/AAD/AAD/GRn/GRn/Y2P/AAD/AAD/ExP/Ghr/AAD/AAD/MzP/GRn/AAD/Hh7/AAD/RUX/AAD/AAD/AAD/AAD/AAD/AAD/Dg7/AAD/HR3/Dw//FRX/SUn/AAD/////kJD/DQ3/Zmb/+/v/wMD/mJj/6en/vb3/1NT//Pz/ODj/+fn/3Nz/nJz/j4//9/f/7e3/9vb/7Oz/2Nj/x8f/Ozv/+Pj/3d3/nZ3/2dn//f3/6Oj/2tr/v7//09P/vr7/mZn/l5cdSvP3AAAAe3RSTlMAAhLiZgTb/vztB/JMRhlp6lQW86g8mQ4KFPs3UCH5U8huwlesWtTYGI7RsdVeJGfTW5rxnutLsvXWF8vQNdo6qQbuz7D4hgVIx2xtw8GC1TtZaIw0i84P98tU0/fsj7PKaAgiZZxeVfo8Z52eg1P0nESrENnjXVPUgw/uuSmDAAADsUlEQVR42u3aZ3cTRxgF4GtbYleSLdnGcsENG2ODjbExEHrvhAQCIb1Bem+QdkeuuFMNBBJIfmuOckzZI8/srHYmH3Lm+QNXK632LTvQ03Tu/IWeU/tTGTKT2n+q58L5c00wpXJd47DHEt5w47pKxLbhdLdPKb/7dBYxVLxw1GcI/2h1BcpzKNFHLX2JQ4gumaiitqpEEhEdOMJI9h5AFC3feYzI+7IF2tpSLEOqDXpObPRYFm/jCWho/4Ble7MdoT7fzhhq9yHEz28wltU1UPrJZ0wd66HwicfYvEFIfePTAP8tSLTupBHvtGJFH9bSkNrNWEHzERrT34xSH9Ogr1CijkbVAUH1KRqVqkdQAw07iIAaGlcTqI+/0LjeJJ5J0IIEnkpXMdzs4sTtW9dnZq7fuj2xOMtwVWk88RHDjBYejYvnjD8qjOpfQsUqhvj7oSjxcJIhVj3pyKqpNjYvVjQ/RrXq5YABKi3MCYm5BSrtWO5v11DlmlC4RpU1WRS9SJU7QukOVbpQ9JLu549+Dd0AUOlTbkGEuk85vxLAK5QbuytC3R2j3HoAjZSbFxrmKTcCoJdSk0LLJKV6gSaPMqNTQsvUKGW8JrxKqUWhaZFSeWyh1LTQNE2pHF6mzOy40DQ+S5mLimJcENoKlOnBWsr8KbRNUGYt5LXgd6HtD3lNQIoyN4S2G5RJIUOZm0LbTcqsBqVmhLYZSlkPsP4VWf+Rrd+m1v9o9h8Vv5p42C1R5qL1x7WRglOgVN52yfwNOBu76P+lLPoYidu23KPciIHGa07ZeIW1jvcNtI7q5vexCPGYCmf+m/Y9a3sAwQ5bI9T7ukPgPcn9GToEao+xk1OixJT+GIsvNAbx6eAgPq0xiF+KtkpYKhRXCQ8eFFcJhSWGu3rZ8jJkCM8kz9K4TUnrC6mAgzTsB9tLwQ2W15qfosQ2GrQNpZr7aczbzVjBZsvLcaC1g0bsbIVEnU8DOr6H1KDH2LwtUBi0/JII6Dxm9zUXkH+XMWzfh1Dte1i2Pe3QkC77Zel7aehpO8wyHG6Dtt0NjKxhN6I4uSli/TqJiJJDUQ4NDCURXTrXRy1XcumyD24M+AzhD1RXIIZsl/LoyZmurJHDM7s8lvB2FQ/PmPJ6PseAXP5HGMYAAC7ABbgAF+ACXIALcAEuwAW4ABfgAlyAC3ABLsAFuID/d8Cx4NEt8/byOf0wLnis8zjMq9/Kp7bWw4JOj8u8TlhRl+G/Mp2wpOX48GffvvZ1CyL4B53LAS6zb08EAAAAAElFTkSuQmCC";var Tp=(A=>(A.QQ="qq",A.GOOGLE="google",A.AMAP="AMap",A.BMAP="BMapGL",A.UNKNOWN="",A))(Tp||{});function Np(){return __uniConfig.bMapKey?{type:"BMapGL",key:__uniConfig.bMapKey}:__uniConfig.qqMapKey?{type:"qq",key:__uniConfig.qqMapKey}:__uniConfig.googleMapKey?{type:"google",key:__uniConfig.googleMapKey}:__uniConfig.aMapKey?{type:"AMap",key:__uniConfig.aMapKey,securityJsCode:__uniConfig.aMapSecurityJsCode,serviceHost:__uniConfig.aMapServiceHost}:{type:"",key:""}}let bp=!1,Gp=!1;const kp=()=>Gp?bp:(Gp=!0,bp="AMap"===Np().type),Lp=()=>"BMapGL"===Np().type;function Up(A,e,t){const i=Np();return A&&"WGS84"===A.toUpperCase()||["google"].includes(i.type)||t?Promise.resolve(e):"qq"===i.type?new Promise(A=>{yp(`https://apis.map.qq.com/ws/coord/v1/translate?type=1&locations=${e.latitude},${e.longitude}&key=${i.key}&output=jsonp`,{callback:"callback"},t=>{if("locations"in t&&t.locations.length){const{lng:i,lat:o}=t.locations[0];A({longitude:i,latitude:o,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed})}else A(e)},()=>A(e))}):"AMap"===i.type?new Promise(A=>{wp([],()=>{window.AMap.convertFrom([e.longitude,e.latitude],"gps",(t,i)=>{if("ok"===i.info&&i.locations.length){const{lat:t,lng:o}=i.locations[0];A({longitude:o,latitude:t,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed})}else A(e)})})}):Promise.reject(new Error("translate coordinate system faild, map provider not configured or not supported"))}const Fp=Ul({name:"MapMarker",props:{id:{type:[Number,String],default:""},latitude:{type:[Number,String],require:!0},longitude:{type:[Number,String],require:!0},title:{type:String,default:""},iconPath:{type:String,require:!0},rotate:{type:[Number,String],default:0},alpha:{type:[Number,String],default:1},width:{type:[Number,String],default:""},height:{type:[Number,String],default:""},callout:{type:Object,default:null},label:{type:Object,default:null},anchor:{type:Object,default:null},clusterId:{type:[Number,String],default:""},customCallout:{type:Object,default:null},ariaLabel:{type:String,default:""}},setup(A){const e=String(isNaN(Number(A.id))?"":A.id),t=pn("onMapReady"),i=function(A){const e="uni-map-marker-label-"+A,t=document.createElement("style");return t.id=e,document.head.appendChild(t),Po(()=>{t.remove()}),function(A){const i=Object.assign({},A,{position:"absolute",top:"70px",borderStyle:"solid"}),o=document.createElement("div");return Object.keys(i).forEach(A=>{o.style[A]=i[A]||""}),t.innerText=`.${e}{${o.getAttribute("style")}}`,e}}(e);let o;function n(A){kp()?A.removeAMapText():A.setMap(null)}if(t((t,r,s)=>{function a(A){const a=A.title;let g;g=kp()?new r.LngLat(A.longitude,A.latitude):Lp()?new r.Point(A.longitude,A.latitude):new r.LatLng(A.latitude,A.longitude);const c=new Image;let l=0;c.onload=()=>{const I=A.anchor||{};let u,E,d,h,C="number"==typeof I.x?I.x:.5,B="number"==typeof I.y?I.y:1;A.iconPath&&(A.width||A.height)?(E=A.width||c.width/c.height*A.height,d=A.height||c.height/c.width*A.width):(E=c.width/2,d=c.height/2),l=d,h=d-(d-B*d),u="MarkerImage"in r?new r.MarkerImage(c.src,null,null,new r.Point(C*E,B*d),new r.Size(E,d)):"Icon"in r?new r.Icon({image:c.src,size:new r.Size(E,d),imageSize:new r.Size(E,d),imageOffset:new r.Pixel(C*E,B*d)}):{url:c.src,anchor:new r.Point(C,B),size:new r.Size(E,d)},Lp()?(o=new r.Marker(new r.Point(g.lng,g.lat)),t.addOverlay(o)):(o.setPosition(g),o.setIcon(u)),"setRotation"in o&&o.setRotation(A.rotate||0);const Q=A.label||{};let p;if("label"in o&&(o.label.setMap(null),delete o.label),Q.content){const A={borderColor:Q.borderColor,borderWidth:(Number(Q.borderWidth)||0)+"px",padding:(Number(Q.padding)||0)+"px",borderRadius:(Number(Q.borderRadius)||0)+"px",backgroundColor:Q.bgColor,color:Q.color,fontSize:(Q.fontSize||14)+"px",lineHeight:(Q.fontSize||14)+"px",marginLeft:(Number(Q.anchorX||Q.x)||0)+"px",marginTop:(Number(Q.anchorY||Q.y)||0)+"px"};if("Label"in r)p=new r.Label({position:g,map:t,clickable:!1,content:Q.content,style:A}),o.label=p;else if("setLabel"in o)if(kp()){const e=`
\n ${Q.content}\n
`;o.setLabel({content:e,direction:"bottom-right"})}else{const e=i(A);o.setLabel({text:Q.content,color:A.color,fontSize:A.fontSize,className:e})}}const f=A.callout||{};let m,y=o.callout;if(f.content||a){kp()&&f.content&&(f.content=f.content.replaceAll("\n","
"));const i="0px 0px 3px 1px rgba(0,0,0,0.5)";let n=-l/2;if((A.width||A.height)&&(n+=14-l/2),m=f.content?{position:g,map:t,top:h,offsetY:n,content:f.content,color:f.color,fontSize:f.fontSize,borderRadius:f.borderRadius,bgColor:f.bgColor,padding:f.padding,boxShadow:f.boxShadow||i,display:f.display}:{position:g,map:t,top:h,offsetY:n,content:a,boxShadow:i},y)y.setOption(m);else if(kp()){const A=()=>{""!==e&&s("callouttap",{},{markerId:Number(e)})};y=o.callout=new r.Callout(m,A)}else y=o.callout=new r.Callout(m),y.div.onclick=function(A){""!==e&&s("callouttap",A,{markerId:Number(e)}),A.stopPropagation(),A.preventDefault()},Np().type===Tp.GOOGLE&&(y.div.ontouchstart=function(A){A.stopPropagation()},y.div.onpointerdown=function(A){A.stopPropagation()})}else y&&(n(y),delete o.callout)},A.iconPath?c.src=AC(A.iconPath):console.error("Marker.iconPath is required.")}!function(A){Lp()||(o=new r.Marker({map:t,flat:!0,autoRotation:!1})),a(A);const i=r.event||r.Event;Lp()||i.addListener(o,"click",()=>{const t=o.callout;if(t&&!t.alwaysVisible)if(kp())t.visible=!t.visible,t.visible?o.callout.createAMapText():o.callout.removeAMapText();else if(t.set("visible",!t.visible),t.visible){const A=t.div,e=A.parentNode;e.removeChild(A),e.appendChild(A)}e&&s("markertap",{},{markerId:Number(e),latitude:A.latitude,longitude:A.longitude})})}(A),Xi(A,a)}),e){const A=pn("addMapChidlContext"),i=pn("removeMapChidlContext"),n={id:e,translate(A){t((e,t,i)=>{const n=A.destination,r=A.duration,s=!!A.autoRotate;let a=Number(A.rotate)||0,g=0;"getRotation"in o&&(g=o.getRotation());const c=o.getPosition(),l=new t.LatLng(n.latitude,n.longitude),I=t.geometry.spherical.computeDistanceBetween(c,l)/1e3/(("number"==typeof r?r:1e3)/36e5),u=t.event||t.Event,E=u.addListener(o,"moving",A=>{const e=A.latLng,t=o.label;t&&t.setPosition(e);const i=o.callout;i&&i.setPosition(e)}),d=u.addListener(o,"moveend",()=>{d.remove(),E.remove(),o.lastPosition=c,o.setPosition(l);const e=o.label;e&&e.setPosition(l);const t=o.callout;t&&t.setPosition(l);const i=A.animationEnd;p(i)&&i()});let h=0;s&&(o.lastPosition&&(h=t.geometry.spherical.computeHeading(o.lastPosition,c)),a=t.geometry.spherical.computeHeading(c,l)-h),"setRotation"in o&&o.setRotation(g+a),"moveTo"in o?o.moveTo(l,I):(o.setPosition(l),u.trigger(o,"moveend",{}))})}};A(n),Po(()=>i(n))}return Po(function(){o&&(o.label&&"setMap"in o.label&&o.label.setMap(null),o.callout&&n(o.callout),o.setMap(null))}),()=>null}});function Op(A){if(!A)return{r:0,g:0,b:0,a:0};let e=A.slice(1);const t=e.length;if(![3,4,6,8].includes(t))return{r:0,g:0,b:0,a:0};3!==t&&4!==t||(e=e.replace(/(\w{1})/g,"$1$1"));let[i,o,n,r]=e.match(/(\w{2})/g);const s=parseInt(i,16),a=parseInt(o,16),g=parseInt(n,16);return r?{r:s,g:a,b:g,a:(`0x100${r}`-65536)/255}:{r:s,g:a,b:g,a:1}}const xp={points:{type:Array,require:!0},color:{type:String,default:"#000000"},width:{type:[Number,String],default:""},dottedLine:{type:[Boolean,String],default:!1},arrowLine:{type:[Boolean,String],default:!1},arrowIconPath:{type:String,default:""},borderColor:{type:String,default:"#000000"},borderWidth:{type:[Number,String],default:""},colorList:{type:Array,default:()=>[]},level:{type:String,default:""}},Pp=Ul({name:"MapPolyline",props:xp,setup(A){let e,t;function i(){e&&e.setMap(null),t&&t.setMap(null)}return pn("onMapReady")((o,n)=>{function r(A){const i=[];A.points.forEach(A=>{let e;e=kp()?[A.longitude,A.latitude]:Lp()?new n.Point(A.longitude,A.latitude):new n.LatLng(A.latitude,A.longitude),i.push(e)});const r=Number(A.width)||1,{r:s,g:a,b:g,a:c}=Op(A.color),{r:l,g:I,b:u,a:E}=Op(A.borderColor),d={map:o,clickable:!1,path:i,strokeWeight:r,strokeColor:A.color||void 0,strokeDashStyle:A.dottedLine?"dash":"solid"},h=Number(A.borderWidth)||0,C={map:o,clickable:!1,path:i,strokeWeight:r+2*h,strokeColor:A.borderColor||void 0,strokeDashStyle:A.dottedLine?"dash":"solid"};"Color"in n?(d.strokeColor=new n.Color(s,a,g,c),C.strokeColor=new n.Color(l,I,u,E)):(d.strokeColor=`rgb(${s}, ${a}, ${g})`,d.strokeOpacity=c,C.strokeColor=`rgb(${l}, ${I}, ${u})`,C.strokeOpacity=E),h&&(t=new n.Polyline(C)),Lp()?(e=new n.Polyline(d.path,d),o.addOverlay(e)):e=new n.Polyline(d)}r(A),Xi(A,function(A){i(),r(A)})}),Po(i),()=>null}}),Yp=Ul({name:"MapCircle",props:{latitude:{type:[Number,String],require:!0},longitude:{type:[Number,String],require:!0},color:{type:String,default:"#000000"},fillColor:{type:String,default:"#00000000"},radius:{type:[Number,String],require:!0},strokeWidth:{type:[Number,String],default:""},level:{type:String,default:""}},setup(A){let e;function t(){e&&e.setMap(null)}return pn("onMapReady")((i,o)=>{function n(A){const t=kp()||Lp()?[A.longitude,A.latitude]:new o.LatLng(A.latitude,A.longitude),n={map:i,center:t,clickable:!1,radius:A.radius,strokeWeight:Number(A.strokeWidth)||1,strokeDashStyle:"solid"};if(Lp())n.strokeColor=A.color,n.fillColor=A.fillColor||"#000",n.fillOpacity=1;else{const{r:e,g:t,b:i,a:r}=Op(A.fillColor),{r:s,g:a,b:g,a:c}=Op(A.color);"Color"in o?(n.fillColor=new o.Color(e,t,i,r),n.strokeColor=new o.Color(s,a,g,c)):(n.fillColor=`rgb(${e}, ${t}, ${i})`,n.fillOpacity=r,n.strokeColor=`rgb(${s}, ${a}, ${g})`,n.strokeOpacity=c)}if(Lp()){let A=new o.Point(n.center[0],n.center[1]);e=new o.Circle(A,n.radius,n),i.addOverlay(e)}else e=new o.Circle(n),kp()&&i.add(e)}n(A),Xi(A,function(A){t(),n(A)})}),Po(t),()=>null}}),Jp={id:{type:[Number,String],default:""},position:{type:Object,required:!0},iconPath:{type:String,required:!0},clickable:{type:[Boolean,String],default:""},trigger:{type:Function,required:!0}},Hp=Ul({name:"MapControl",props:Jp,setup(A){const e=Ur(()=>AC(A.iconPath)),t=Ur(()=>{let e=`top:${A.position.top||0}px;left:${A.position.left||0}px;`;return A.position.width&&(e+=`width:${A.position.width}px;`),A.position.height&&(e+=`height:${A.position.height}px;`),e}),i=e=>{A.clickable&&A.trigger("controltap",e,{controlId:A.id})};return()=>Ir("div",{class:"uni-map-control"},[Ir("img",{src:e.value,style:t.value,class:"uni-map-control-icon",onClick:i},null,12,["src","onClick"])])}}),qp=HA(()=>{Yu.forEach(A=>{Vp.prototype[A]=function(e){p(e)&&this._events[A].push(e)}}),Ju.forEach(A=>{Vp.prototype[A]=function(e){var t=this._events[A.replace("off","on")],i=t.indexOf(e);i>=0&&t.splice(i,1)}})});class Vp{constructor(){this._src="";var A=this._audio=new Audio;this._stoping=!1;["src","autoplay","loop","duration","currentTime","paused","volume"].forEach(e=>{Object.defineProperty(this,e,{set:"src"===e?e=>(A.src=AC(e),this._src=e,e):t=>(A[e]=t,t),get:"src"===e?()=>this._src:()=>A[e]})}),this.startTime=0,Object.defineProperty(this,"obeyMuteSwitch",{set:()=>!1,get:()=>!1}),Object.defineProperty(this,"buffered",{get(){var e=A.buffered;return e.length?e.end(e.length-1):0}}),this._events={},Yu.forEach(A=>{this._events[A]=[]}),A.addEventListener("loadedmetadata",()=>{var e=Number(this.startTime)||0;e>0&&(A.currentTime=e)});var e=["canplay","pause","seeking","seeked","timeUpdate"];e.concat(["play","ended","error","waiting"]).forEach(t=>{A.addEventListener(t.toLowerCase(),()=>{if(this._stoping&&e.indexOf(t)>=0)return;const A=`on${t.slice(0,1).toUpperCase()}${t.slice(1)}`;this._events[A].forEach(A=>{A()})},!1)}),qp()}play(){this._stoping=!1,this._audio.play()}pause(){this._audio.pause()}stop(){this._stoping=!0,this._audio.pause(),this._audio.currentTime=0,this._events.onStop.forEach(A=>{A()})}seek(A){this._stoping=!1,"number"!=typeof(A=Number(A))||isNaN(A)||(this._audio.currentTime=A)}destroy(){this.stop()}}const jp=PI(0,()=>new Vp),Kp=YI("makePhoneCall",({phoneNumber:A},{resolve:e})=>(window.location.href=`tel:${A}`,e())),Wp="__DC_STAT_UUID",zp=navigator.cookieEnabled&&(window.localStorage||window.sessionStorage)||{};let Zp;function Xp(){if(Zp=Zp||zp[Wp],!Zp){Zp=Date.now()+""+Math.floor(1e7*Math.random());try{zp[Wp]=Zp}catch(A){}}return Zp}function $p(){if(!0!==__uniConfig.darkmode)return f(__uniConfig.darkmode)?__uniConfig.darkmode:"light";try{return window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}catch(A){return"light"}}function Af(){let A,e="0",t="",i="phone";const o=navigator.language;if(iC){A="iOS";const i=eC.match(/OS\s([\w_]+)\slike/);i&&(e=i[1].replace(/_/g,"."));const o=eC.match(/\(([a-zA-Z]+);/);o&&(t=o[1])}else if(tC){A="Android";const i=eC.match(/Android[\s/]([\w\.]+)[;\s]/);i&&(e=i[1]);const o=eC.match(/\((.+?)\)/),n=o?o[1].split(";"):eC.split(" "),r=[/\bAndroid\b/i,/\bLinux\b/i,/\bU\b/i,/^\s?[a-z][a-z]$/i,/^\s?[a-z][a-z]-[a-z][a-z]$/i,/\bwv\b/i,/\/[\d\.,]+$/,/^\s?[\d\.,]+$/,/\bBrowser\b/i,/\bMobile\b/i];for(let A=0;A0){t=e.split("Build")[0].trim();break}let i;for(let A=0;A-1&&A.indexOf("MSIE")>-1,t=A.indexOf("Edge")>-1&&!e,i=A.indexOf("Trident")>-1&&A.indexOf("rv:11.0")>-1;if(e){new RegExp("MSIE (\\d+\\.\\d+);").test(A);const e=parseFloat(RegExp.$1);return e>6?e:6}return t?-1:i?11:-1}());if("-1"!==a)s="IE";else{const A=["Version","Firefox","Chrome","Edge{0,1}"],e=["Safari","Firefox","Chrome","Edge"];for(let t=0;t{const A=window.devicePixelRatio,e=aC(),t=gC(e),i=cC(e,t),o=function(A,e){return A?Math[e?"min":"max"](screen.height,screen.width):screen.height}(e,t),n=lC(i);let r=window.innerHeight;const s=Rc.top,a={left:Rc.left,right:n-Rc.right,top:Rc.top,bottom:r-Rc.bottom,width:n-Rc.left-Rc.right,height:r-Rc.top-Rc.bottom},{top:g,bottom:c}=Gc();return r-=g,r-=c,{windowTop:g,windowBottom:c,windowWidth:n,windowHeight:r,pixelRatio:A,screenWidth:i,screenHeight:o,statusBarHeight:s,safeArea:a,safeAreaInsets:{top:Rc.top,right:Rc.right,bottom:Rc.bottom,left:Rc.left},screenTop:o-r}});let tf,of=!0;function nf(){of&&(tf=Af())}const rf=PI(0,()=>{nf();const{deviceBrand:A,deviceModel:e,brand:t,model:i,platform:o,system:n,deviceOrientation:r,deviceType:s,osname:a,osversion:g}=tf;return u({brand:t,deviceBrand:A,deviceModel:e,devicePixelRatio:window.devicePixelRatio,deviceId:Xp(),deviceOrientation:r,deviceType:s,model:i,platform:o,system:n,osName:a?a.toLowerCase():void 0,osVersion:g})}),sf=PI(0,()=>{nf();const{theme:A,language:e,browserName:t,browserVersion:i}=tf;return u({appId:__uniConfig.appId,appName:__uniConfig.appName,appVersion:__uniConfig.appVersion,appVersionCode:__uniConfig.appVersionCode,appLanguage:dE?dE():e,enableDebug:!1,hostSDKVersion:void 0,hostPackageName:void 0,hostFontSizeSetting:void 0,hostName:t,hostVersion:i,hostTheme:A,hostLanguage:e,language:e,SDKVersion:"",theme:A,version:"",uniPlatform:"web",isUniAppX:!1,uniCompileVersion:__uniConfig.compilerVersion,uniCompilerVersion:__uniConfig.compilerVersion,uniRuntimeVersion:__uniConfig.compilerVersion},{})}),af=PI(0,()=>{of=!0,nf(),of=!1;const A=ef(),e=rf(),t=sf();of=!0;const{ua:i,browserName:o,browserVersion:n,osname:r,osversion:s}=tf,a=u(A,e,t,{ua:i,browserName:o,browserVersion:n,uniPlatform:"web",uniCompileVersion:__uniConfig.compilerVersion,uniRuntimeVersion:__uniConfig.compilerVersion,fontSizeSetting:void 0,osName:r.toLowerCase(),osVersion:s,osLanguage:void 0,osTheme:void 0});return delete a.screenTop,delete a.enableDebug,__uniConfig.darkmode||delete a.theme,function(A){let e={};return S(A)&&Object.keys(A).sort().forEach(t=>{const i=t;e[i]=A[i]}),Object.keys(e)?e:A}(a)}),gf=YI("getSystemInfo",(A,{resolve:e})=>e(af())),cf="onNetworkStatusChange";function lf(){df().then(({networkType:A})=>{Pv.invokeOnCallback(cf,{isConnected:"none"!==A,networkType:A})})}function If(){return navigator.connection||navigator.webkitConnection||navigator.mozConnection}const uf=FI(cf,()=>{const A=If();A?A.addEventListener("change",lf):(window.addEventListener("offline",lf),window.addEventListener("online",lf))}),Ef=OI("offNetworkStatusChange",()=>{const A=If();A?A.removeEventListener("change",lf):(window.removeEventListener("offline",lf),window.removeEventListener("online",lf))}),df=YI("getNetworkType",(A,{resolve:e})=>{const t=If();let i="unknown";return t?(i=t.type,"cellular"===i&&t.effectiveType?i=t.effectiveType.replace("slow-",""):!i&&t.effectiveType?i=t.effectiveType:["none","wifi"].includes(i)||(i="unknown")):!1===navigator.onLine&&(i="none"),e({networkType:i})});let hf=null;const Cf=FI(kE,()=>{Qf()}),Bf=OI("offAccelerometer",()=>{pf()}),Qf=YI("startAccelerometer",(A,{resolve:e,reject:t})=>{if(window.DeviceMotionEvent){if(!hf){if(DeviceMotionEvent.requestPermission)return void DeviceMotionEvent.requestPermission().then(A=>{"granted"===A?(i(),e()):t(`${A}`)}).catch(A=>{t(`${A}`)});i()}e()}else t();function i(){hf=function(A){const e=A.acceleration||A.accelerationIncludingGravity;Pv.invokeOnCallback(kE,{x:e&&e.x||0,y:e&&e.y||0,z:e&&e.z||0})},window.addEventListener("devicemotion",hf,!1)}}),pf=YI("stopAccelerometer",(A,{resolve:e})=>{hf&&(window.removeEventListener("devicemotion",hf,!1),hf=null),e()});let ff=null;const mf=FI(LE,()=>{Df()}),yf=OI("offCompass",()=>{vf()}),Df=YI("startCompass",(A,{resolve:e,reject:t})=>{if(window.DeviceOrientationEvent){if(!ff){if(DeviceOrientationEvent.requestPermission)return void DeviceOrientationEvent.requestPermission().then(A=>{"granted"===A?(i(),e()):t(`${A}`)}).catch(A=>{t(`${A}`)});i()}e()}else t();function i(){ff=function(A){const e=360-(null!==A.alpha?A.alpha:360);Pv.invokeOnCallback(LE,{direction:e})},window.addEventListener("deviceorientation",ff,!1)}}),vf=YI("stopCompass",(A,{resolve:e})=>{ff&&(window.removeEventListener("deviceorientation",ff,!1),ff=null),e()}),wf=!!window.navigator.vibrate,Sf=YI("vibrateShort",(A,{resolve:e,reject:t})=>{wf&&window.navigator.vibrate(15)?e():t("vibrateLong:fail")}),Mf=YI("vibrateLong",(A,{resolve:e,reject:t})=>{wf&&window.navigator.vibrate(400)?e():t("vibrateLong:fail")});var Rf=(A,e,t)=>new Promise((i,o)=>{var n=A=>{try{s(t.next(A))}catch(__){o(__)}},r=A=>{try{s(t.throw(A))}catch(__){o(__)}},s=A=>A.done?i(A.value):Promise.resolve(A.value).then(n,r);s((t=t.apply(A,e)).next())});const _f=YI("getClipboardData",(A,e)=>Rf(void 0,[A,e],function*(A,{resolve:e,reject:t}){Xg();const{t:i}=Jg();try{e({data:yield navigator.clipboard.readText()})}catch(o){!function(A,e){const t=document.getElementById("#clipboard"),i=t?t.value:void 0;i?A({data:i}):e()}(e,()=>{t(`${o} ${i("uni.getClipboardData.fail")}`)})}})),Tf=YI("setClipboardData",(A,e)=>Rf(void 0,[A,e],function*({data:A},{resolve:e,reject:t}){try{yield navigator.clipboard.writeText(A),e()}catch(i){!function(A,e,t){const i=document.getElementById("#clipboard");i&&i.remove();const o=document.createElement("textarea");o.setAttribute("inputmode","none"),o.id="#clipboard",o.style.position="fixed",o.style.top="-9999px",o.style.zIndex="-9999",document.body.appendChild(o),o.value=A,o.select(),o.setSelectionRange(0,o.value.length);const n=document.execCommand("Copy",!1);o.blur(),n?e():t()}(A,e,t)}}),0,GE);const Nf=A=>{Pv.invokeOnCallback(EA,A)},bf=FI(EA,()=>{Pv.on(EA,Nf)}),Gf=OI("offThemeChange",()=>{Pv.off(EA,Nf)});const kf=PI(0,(A,e)=>{const t=typeof e,i="string"===t?e:JSON.stringify({type:t,data:e});localStorage.setItem(A,i)}),Lf=YI("setStorage",({key:A,data:e},{resolve:t,reject:i})=>{try{kf(A,e),t()}catch(o){i(o.message)}});function Uf(A){const e=localStorage&&localStorage.getItem(A);if(!f(e))throw new Error("data not found");let t=e;try{const A=function(A){const e=["object","string","number","boolean","undefined"];try{const t=f(A)?JSON.parse(A):A,i=t.type;if(e.indexOf(i)>=0){const A=Object.keys(t);if(2===A.length&&"data"in t){if(typeof t.data===i)return t.data;if("object"===i&&/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(t.data))return new Date(t.data)}else if(1===A.length)return""}}catch(t){}}(JSON.parse(e));void 0!==A&&(t=A)}catch(i){}return t}const Ff=PI(0,A=>{try{return Uf(A)}catch(e){return""}}),Of=YI("getStorage",({key:A},{resolve:e,reject:t})=>{try{e({data:Uf(A)})}catch(i){t(i.message)}}),xf=PI(0,A=>{localStorage&&localStorage.removeItem(A)}),Pf=YI(UE,({key:A},{resolve:e})=>{xf(A),e()}),Yf=PI(0,()=>{localStorage&&localStorage.clear()}),Jf=YI("clearStorage",(A,{resolve:e})=>{Yf(),e()}),Hf=PI(0,()=>{const A=localStorage&&localStorage.length||0,e=[];let t=0;for(let i=0;i{e(Hf())}),Vf=YI("getFileInfo",({filePath:A},{resolve:e,reject:t})=>{QC(A).then(A=>{e({size:A.size})}).catch(A=>{t(String(A))})},0,FE),jf=YI("openDocument",({filePath:A},{resolve:e})=>(window.open(A),e()),0,OE),Kf=YI("hideKeyboard",(A,{resolve:e,reject:t})=>{const i=document.activeElement;!i||"TEXTAREA"!==i.tagName&&"INPUT"!==i.tagName||(i.blur(),e())});const Wf=YI("getImageInfo",({src:A},{resolve:e,reject:t})=>{const i=new Image;i.onload=function(){e({width:i.naturalWidth,height:i.naturalHeight,path:0===A.indexOf("/")?window.location.protocol+"//"+window.location.host+A:A})},i.onerror=function(){t()},i.src=A},0,KE),zf=YI("getVideoInfo",({src:A},{resolve:e,reject:t})=>{QC(A,!0).then(A=>A).catch(()=>null).then(i=>{const o=document.createElement("video");if(void 0!==o.onloadedmetadata){const n=setTimeout(()=>{o.onloadedmetadata=null,o.onerror=null,t()},A.startsWith("data:")||A.startsWith("blob:")?300:3e3);o.onloadedmetadata=function(){clearTimeout(n),o.onerror=null,e({size:Math.ceil((i?i.size:0)/1024),duration:o.duration||0,width:o.videoWidth||0,height:o.videoHeight||0})},o.onerror=function(){clearTimeout(n),o.onloadedmetadata=null,t()},o.src=A}else t()})},0,zE),Zf={image:{jpg:"jpeg",jpe:"jpeg",pbm:"x-portable-bitmap",pgm:"x-portable-graymap",pnm:"x-portable-anymap",ppm:"x-portable-pixmap",psd:"vnd.adobe.photoshop",pic:"x-pict",rgb:"x-rgb",svg:"svg+xml",svgz:"svg+xml",tif:"tiff",xif:"vnd.xiff",wbmp:"vnd.wap.wbmp",wdp:"vnd.ms-photo",xbm:"x-xbitmap",ico:"x-icon"},video:{"3g2":"3gpp2","3gp":"3gpp",avi:"x-msvideo",f4v:"x-f4v",flv:"x-flv",jpgm:"jpm",jpgv:"jpeg",m1v:"mpeg",m2v:"mpeg",mpe:"mpeg",mpg:"mpeg",mpg4:"mpeg",m4v:"x-m4v",mkv:"x-matroska",mov:"quicktime",qt:"quicktime",movie:"x-sgi-movie",mp4v:"mp4",ogv:"ogg",smv:"x-smv",wm:"x-ms-wm",wmv:"x-ms-wmv",wmx:"x-ms-wmx",wvx:"x-ms-wvx"}};function Xf({count:A,sourceType:e,type:t,extension:i}){cB();const o=document.createElement("input");return o.type="file",JA(o,{position:"absolute",visibility:"hidden",zIndex:"-999",width:"0",height:"0",top:"0",left:"0"}),o.accept=i.map(A=>{if("all"!==t){const e=A.replace(".","");return`${t}/${Zf[t][e]||e}`}return function(){const A=window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i);return!(!A||"micromessenger"!==A[0])}()?".":0===A.indexOf(".")?A:`.${A}`}).join(","),A&&A>1&&(o.multiple=!0),"all"!==t&&e instanceof Array&&1===e.length&&"camera"===e[0]&&o.setAttribute("capture","camera"),o}let $f=null;const Am=YI("chooseFile",({count:A,sourceType:e,type:t,extension:i},{resolve:o,reject:n})=>{zg();const{t:r}=Jg();$f&&(document.body.removeChild($f),$f=null),$f=Xf({count:A,sourceType:e,type:t,extension:i}),document.body.appendChild($f),$f.addEventListener("cancel",()=>{n("chooseFile:fail cancel")}),$f.addEventListener("change",function(e){const t=e.target,i=[];if(t&&t.files){const e=t.files.length;for(let o=0;o(n=n||fC(e),n)}),oA)},tempFiles:i})}),$f.click(),lB()||console.warn(r("uni.chooseFile.notUserActivation"))},0,jE);let em=null;const tm=YI("chooseImage",({count:A,sourceType:e,extension:t},{resolve:i,reject:o})=>{zg();const{t:n}=Jg();em&&(document.body.removeChild(em),em=null),em=Xf({count:A,sourceType:e,extension:t,type:"image"}),document.body.appendChild(em),em.addEventListener("cancel",()=>{o("chooseImage:fail cancel")}),em.addEventListener("change",function(e){const t=e.target,o=[];if(t&&t.files){const e=t.files.length;for(let i=0;i(n=n||fC(e),n)}),iA)},tempFiles:o})}),em.click(),lB()||console.warn(n("uni.chooseFile.notUserActivation"))},0,HE),im={esc:["Esc","Escape"],enter:["Enter"]},om=Object.keys(im);function nm(){const A=Kt(""),e=Kt(!1),t=t=>{if(e.value)return;const i=om.find(A=>-1!==im[A].indexOf(t.key));i&&(A.value=i),pi(()=>A.value="")};return Uo(()=>{document.addEventListener("keyup",t)}),xo(()=>{document.removeEventListener("keyup",t)}),{key:A,disable:e}}const rm=Ir("div",{class:"uni-mask"},null,-1);function sm(A,e,t){return e.onClose=(...A)=>(e.visible=!1,t.apply(null,A)),Ps(Co({setup:()=>()=>(Ar(),nr(A,e,null,16))}))}function am(A){let e=document.getElementById(A);return e||(e=document.createElement("div"),e.id=A,document.body.append(e)),e}function gm(A,{onEsc:e,onEnter:t}){const i=Kt(A.visible),{key:o,disable:n}=nm();return Xi(()=>A.visible,A=>i.value=A),Xi(()=>i.value,A=>n.value=!A),zi(()=>{const{value:A}=o;"esc"===A?e&&e():"enter"===A&&t&&t()}),i}let cm=0,lm="";function Im(A){let e=cm;cm+=A?1:-1,cm=Math.max(0,cm),cm>0?0===e&&(lm=document.body.style.overflow,document.body.style.overflow="hidden"):(document.body.style.overflow=lm,lm="")}function um(){Uo(()=>Im(!0)),Po(()=>Im(!1))}const Em=Ul({name:"ImageView",props:{src:{type:String,default:""}},setup(A){const e=Nt({direction:"none"});let t=1,i=0,o=0,n=0,r=0;function s({detail:A}){t=A.scale}function a(A){const e=A.target.getBoundingClientRect();i=e.width,o=e.height}function g(A){const e=A.target.getBoundingClientRect();n=e.width,r=e.height,l(A)}function c(A){const s=t*i>n,a=t*o>r;e.direction=s&&a?"all":s?"horizontal":a?"vertical":"none",l(A)}function l(A){"all"!==e.direction&&"horizontal"!==e.direction||A.stopPropagation()}return()=>{const t={position:"absolute",left:"0",top:"0",width:"100%",height:"100%"};return Ir(_B,{style:t,onTouchstart:Fl(g),onTouchmove:Fl(l),onTouchend:Fl(c)},{default:()=>[Ir(JB,{style:t,direction:e.direction,inertia:!0,scale:!0,"scale-min":"1","scale-max":"4",onScale:s},{default:()=>[Ir("img",{src:A.src,style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",maxHeight:"100%",maxWidth:"100%"},onLoad:a},null,40,["src","onLoad"])]},8,["style","direction","inertia","scale","onScale"])]},8,["style","onTouchstart","onTouchmove","onTouchend"])}}});function dm(A){let e="number"==typeof A.current?A.current:A.urls.indexOf(A.current);return e=e<0?0:e,e}const hm=Ul({name:"ImagePreview",props:{urls:{type:Array,default:()=>[]},current:{type:[Number,String],default:0}},emits:["close"],setup(A,{emit:e}){um();const{key:t}=nm(),i=Kt(null),o=Kt(dm(A));let n;function r(){n||pi(()=>{e("close")})}function s(A){o.value=A.detail.current}Xi(()=>A.current,()=>o.value=dm(A)),Xi(()=>t.value,A=>{"esc"===A&&r()}),Uo(()=>{const A=i.value;let e=0,t=0;A.addEventListener("mousedown",A=>{n=!1,e=A.clientX,t=A.clientY}),A.addEventListener("mouseup",A=>{(Math.abs(A.clientX-e)>20||Math.abs(A.clientY-t)>20)&&(n=!0)})});const a={position:"absolute","box-sizing":"border-box",top:"0",right:"0",width:"60px",height:"44px",padding:"6px","line-height":"32px","font-size":"26px",color:"white","text-align":"center",cursor:"pointer"};return()=>{let e;return Ir("div",{ref:i,style:{display:"block",position:"fixed",left:"0",top:"0",width:"100%",height:"100%",zIndex:999,background:"rgba(0,0,0,0.8)"},onClick:r},[Ir(fQ,{navigation:"auto",current:o.value,onChange:s,"indicator-dots":!1,autoplay:!1,style:{position:"absolute",left:"0",top:"0",width:"100%",height:"100%"}},(t=e=A.urls.map(A=>Ir(yQ,null,{default:()=>[Ir(Em,{src:A},null,8,["src"])]})),"function"==typeof t||"[object Object]"===Object.prototype.toString.call(t)&&!rr(t)?e:{default:()=>[e],_:1}),8,["current","onChange"]),Ir("div",{style:a},[jc(qc,"#ffffff",26)],4)],8,["onClick"]);var t}}});let Cm,Bm=null;const Qm=()=>{Bm=null,pi(()=>{null==Cm||Cm.unmount(),Cm=null})},pm=YI("previewImage",(A,{resolve:e})=>{Bm?u(Bm,A):(Bm=Nt(A),pi(()=>{Cm=sm(hm,Bm,Qm),Cm.mount(am("u-a-p"))})),e()},0,WE),fm=YI("closePreviewImage",(A,{resolve:e,reject:t})=>{Cm?(Qm(),e()):t()});let mm=null;const ym=YI("chooseVideo",({sourceType:A,extension:e},{resolve:t,reject:i})=>{zg();const{t:o}=Jg();mm&&(document.body.removeChild(mm),mm=null),mm=Xf({sourceType:A,extension:e,type:"video"}),document.body.appendChild(mm),mm.addEventListener("cancel",()=>{i("chooseVideo:fail cancel")}),mm.addEventListener("change",function(A){const e=A.target.files[0];let i="";const o={tempFilePath:i,tempFile:e,size:e.size,duration:0,width:0,height:0,name:e.name};Object.defineProperty(o,"tempFilePath",{get(){return i=i||fC(this.tempFile),i}});const n=document.createElement("video");if(void 0!==n.onloadedmetadata){const A=fC(e);n.onloadedmetadata=function(){mC(A),t(u(o,{duration:n.duration||0,width:n.videoWidth||0,height:n.videoHeight||0}))},setTimeout(()=>{n.onloadedmetadata=null,mC(A),t(o)},300),n.src=A}else t(o)}),mm.click(),lB()||console.warn(o("uni.chooseFile.notUserActivation"))},0,qE),Dm=xI("request",({url:A,data:e,header:t={},method:i,dataType:o,responseType:n,enableChunked:r,withCredentials:s,timeout:a=__uniConfig.networkTimeout.request},{resolve:g,reject:c})=>{let l=null;const I=function(A){const e=Object.keys(A).find(A=>"content-type"===A.toLowerCase());if(!e)return;const t=A[e];if(0===t.indexOf("application/json"))return"json";if(0===t.indexOf("application/x-www-form-urlencoded"))return"urlencoded";return"string"}(t);if("GET"!==i)if(f(e)||e instanceof ArrayBuffer)l=e;else if("json"===I)try{l=JSON.stringify(e)}catch(E){l=e.toString()}else if("urlencoded"===I){const A=[];for(const t in e)h(e,t)&&A.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));l=A.join("&")}else l=e.toString();let u;if(r){if(void 0===typeof window.fetch||void 0===typeof window.AbortController)throw new Error("fetch or AbortController is not supported in this environment");const e=new AbortController,r=e.signal;u=new wm(e);const I={method:i,headers:t,body:l,signal:r,credentials:s?"include":"same-origin"},E=setTimeout(function(){u.abort(),c("timeout",{errCode:5})},a);I.signal.addEventListener("abort",function(){clearTimeout(E),c("abort",{errCode:600003})}),window.fetch(A,I).then(A=>{const e=A.status,t=A.headers,i=A.body,r={};t.forEach((A,e)=>{r[e]=A});const s=vm(r);if(u._emitter.emit("headersReceived",{header:r,statusCode:e,cookies:s}),!i)return void g({data:"",statusCode:e,header:r,cookies:s});const a=i.getReader(),c=[],l=()=>{a.read().then(({done:A,value:t})=>{if(A){const A=function(A){const e=A.reduce((A,e)=>A+e.byteLength,0),t=new Uint8Array(e);let i=0;for(const o of A)t.set(new Uint8Array(o),i),i+=o.byteLength;return t.buffer}(c);let t="text"===n?(new TextDecoder).decode(A):A;return"text"===n&&(t=Mm(t,n,o)),void g({data:t,statusCode:e,header:r,cookies:s})}const i=t;c.push(i),u._emitter.emit("chunkReceived",{data:i}),l()})};l()},A=>{c(A,{errCode:5})})}else{const e=new XMLHttpRequest;u=new wm(e),e.open(i,A);for(const A in t)h(t,A)&&e.setRequestHeader(A,t[A]);const r=setTimeout(function(){e.onload=e.onabort=e.onerror=null,u.abort(),c("timeout",{errCode:5})},a);e.responseType=n,e.onload=function(){clearTimeout(r);const A=e.status;let t="text"===n?e.responseText:e.response;"text"===n&&(t=Mm(t,n,o)),g({data:t,statusCode:A,header:Sm(e.getAllResponseHeaders()),cookies:[]})},e.onabort=function(){clearTimeout(r),c("abort",{errCode:600003})},e.onerror=function(){clearTimeout(r),c(void 0,{errCode:5})},e.withCredentials=s,e.send(l)}return u},0,td),vm=A=>{let e=A["Set-Cookie"]||A["set-cookie"],t=[];if(!e)return[];"["===e[0]&&"]"===e[e.length-1]&&(e=e.slice(1,-1));const i=e.split(";");for(let o=0;o{e===A&&(this._requestOnHeadersReceiveCallbacks.delete(t),this._emitter.off("headersReceived",A))});const e=this._requestOnHeadersReceiveCallbacks.get(A);e&&(this._requestOnHeadersReceiveCallbacks.delete(A),this._emitter.off("headersReceived",e))}onChunkReceived(A){return this._emitter.on("chunkReceived",A),this._requestOnChunkReceiveCallbackId++,this._requestOnChunkReceiveCallbacks.set(this._requestOnChunkReceiveCallbackId,A),this._requestOnChunkReceiveCallbackId}offChunkReceived(A){if(null==A)return void this._emitter.off("chunkReceived");if("function"==typeof A)return void this._requestOnChunkReceiveCallbacks.forEach((e,t)=>{e===A&&(this._requestOnChunkReceiveCallbacks.delete(t),this._emitter.off("chunkReceived",A))});const e=this._requestOnChunkReceiveCallbacks.get(A);e&&(this._requestOnChunkReceiveCallbacks.delete(A),this._emitter.off("chunkReceived",e))}}function Sm(A){const e={};return A.split(oA).forEach(A=>{const t=A.match(/(\S+\s*):\s*(.*)/);t&&3===t.length&&(e[t[1]]=t[2])}),e}function Mm(A,e,t){let i=A;if("text"===e&&"json"===t)try{i=JSON.parse(i)}catch(o){}return i}class Rm{constructor(A){this._callbacks=[],this._xhr=A}onProgressUpdate(A){p(A)&&this._callbacks.push(A)}offProgressUpdate(A){const e=this._callbacks.indexOf(A);e>=0&&this._callbacks.splice(e,1)}abort(){this._xhr&&(this._xhr.abort(),delete this._xhr)}onHeadersReceived(A){throw new Error("Method not implemented.")}offHeadersReceived(A){throw new Error("Method not implemented.")}}const _m=xI("downloadFile",({url:A,header:e={},timeout:t=__uniConfig.networkTimeout.downloadFile},{resolve:i,reject:o})=>{var n,r=new XMLHttpRequest,s=new Rm(r);return r.open("GET",A,!0),Object.keys(e).forEach(A=>{r.setRequestHeader(A,e[A])}),r.responseType="blob",r.onload=function(){clearTimeout(n);const e=r.status,t=this.response;let o;const s=r.getResponseHeader("content-disposition");if(s){const A=s.match(/filename="?(\S+)"?\b/);A&&(o=A[1])}t.name=o||function(A){const e=(A=A.split("#")[0].split("?")[0]).split("/");return e[e.length-1]}(A),i({statusCode:e,tempFilePath:fC(t)})},r.onabort=function(){clearTimeout(n),o("abort",{errCode:600003})},r.onerror=function(){clearTimeout(n),o("",{errCode:602001})},r.onprogress=function(A){s._callbacks.forEach(e=>{var t=A.loaded,i=A.total;e({progress:Math.round(t/i*100),totalBytesWritten:t,totalBytesExpectedToWrite:i})})},r.send(),n=setTimeout(function(){r.onprogress=r.onload=r.onabort=r.onerror=null,s.abort(),o("timeout",{errCode:5})},t),s},0,id);class Tm{constructor(A){this._callbacks=[],this._xhr=A}onProgressUpdate(A){p(A)&&this._callbacks.push(A)}offProgressUpdate(A){const e=this._callbacks.indexOf(A);e>=0&&this._callbacks.splice(e,1)}abort(){this._isAbort=!0,this._xhr&&(this._xhr.abort(),delete this._xhr)}onHeadersReceived(A){throw new Error("Method not implemented.")}offHeadersReceived(A){throw new Error("Method not implemented.")}}const Nm=xI("uploadFile",({url:A,file:e,filePath:t,name:i,files:o,header:n={},formData:r={},timeout:s=__uniConfig.networkTimeout.uploadFile},{resolve:a,reject:g})=>{var c=new Tm;return C(o)&&o.length||(t||g("file error"),o=[{name:i,file:e,uri:t}]),Promise.all(o.map(({file:A,uri:e})=>A instanceof Blob?Promise.resolve(pC(A)):QC(e))).then(function(e){var t,i=new XMLHttpRequest,l=new FormData;Object.keys(r).forEach(A=>{l.append(A,r[A])}),Object.values(o).forEach(({name:A},t)=>{const i=e[t];l.append(A||"file",i,i.name||`file-${Date.now()}`)}),i.open("POST",A),Object.keys(n).forEach(A=>{i.setRequestHeader(A,n[A])}),i.upload.onprogress=function(A){c._callbacks.forEach(e=>{var t=A.loaded,i=A.total;e({progress:Math.round(t/i*100),totalBytesSent:t,totalBytesExpectedToSend:i})})},i.onerror=function(){clearTimeout(t),g("",{errCode:602001})},i.onabort=function(){clearTimeout(t),g("abort",{errCode:600003})},i.onload=function(){clearTimeout(t);const A=i.status;a({statusCode:A,data:i.responseText||i.response})},c._isAbort?g("abort",{errCode:600003}):(t=setTimeout(function(){i.upload.onprogress=i.onload=i.onabort=i.onerror=null,c.abort(),g("timeout",{errCode:5})},s),i.send(l),c._xhr=i)}).catch(()=>{setTimeout(()=>{g("file error")},0)}),c},0,od),bm=[],Gm={open:"",close:"",error:"",message:""};class km{constructor(A,e,t){let i;this._callbacks={open:[],close:[],error:[],message:[]};try{const t=this._webSocket=new WebSocket(A,e);t.binaryType="arraybuffer";["open","close","error","message"].forEach(A=>{this._callbacks[A]=[],t.addEventListener(A,e=>{const{data:t,code:i,reason:o}=e,n="message"===A?{data:t}:"close"===A?{code:i,reason:o}:{};if(this._callbacks[A].forEach(e=>{try{e(n)}catch(__){console.error(`thirdScriptError\n${__};at socketTask.on${k(A)} callback function\n`,__)}}),this===bm[0]&&Gm[A]&&Pv.invokeOnCallback(Gm[A],n),"error"===A||"close"===A){const A=bm.indexOf(this);A>=0&&bm.splice(A,1)}})});["CLOSED","CLOSING","CONNECTING","OPEN","readyState"].forEach(A=>{Object.defineProperty(this,A,{get:()=>t[A]})})}catch(__){i=__}t&&t(i,this)}send(A){const e=(A||{}).data,t=this._webSocket;try{if(t.readyState!==t.OPEN)throw qA(A,{errMsg:"sendSocketMessage:fail SocketTask.readyState is not OPEN",errCode:10002}),new Error("SocketTask.readyState is not OPEN");t.send(e),qA(A,"sendSocketMessage:ok")}catch(i){qA(A,{errMsg:`sendSocketMessage:fail ${i}`,errCode:602001})}}close(A={}){const e=this._webSocket;try{const t=A.code||1e3,i=A.reason;f(i)?e.close(t,i):e.close(t),qA(A,"closeSocket:ok")}catch(t){qA(A,`closeSocket:fail ${t}`)}}onOpen(A){this._callbacks.open.push(A)}onMessage(A){this._callbacks.message.push(A)}onError(A){this._callbacks.error.push(A)}onClose(A){this._callbacks.close.push(A)}}const Lm=xI("connectSocket",({url:A,protocols:e},{resolve:t,reject:i})=>new km(A,e,(A,e)=>{A?i(A.toString(),{errCode:600009}):(bm.push(e),t())}),0,nd);function Um(A,e,t,i,o){const n=A[e];p(n)&&n.call(A,u({},t,{success(){i()},fail({errMsg:A}){o(A.replace("sendSocketMessage:fail ",""))},complete:void 0}))}const Fm=YI("sendSocketMessage",(A,{resolve:e,reject:t})=>{const i=bm[0];i&&i.readyState===i.OPEN?Um(i,"send",A,e,t):t("WebSocket is not connected")}),Om=YI("closeSocket",(A,{resolve:e,reject:t})=>{const i=bm[0];i?Um(i,"close",A,e,t):t("WebSocket is not connected")});function xm(A){const e=`onSocket${k(A)}`;return FI(e,()=>{Gm[A]=e})}const Pm=xm("open"),Ym=xm("error"),Jm=xm("message"),Hm=xm("close"),qm=YI("getLocation",({type:A,altitude:e,highAccuracyExpireTime:t,isHighAccuracy:i},{resolve:o,reject:n})=>{const r=Np();new Promise((A,o)=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>A({coords:e.coords}),o,{enableHighAccuracy:i||e,timeout:t||1e5}):o(new Error("device nonsupport geolocation"))}).catch(A=>new Promise((e,t)=>{r.type===Tp.QQ?yp(`https://apis.map.qq.com/ws/location/v1/ip?output=jsonp&key=${r.key}`,{callback:"callback"},A=>{if("result"in A&&A.result.location){const t=A.result.location;e({coords:{latitude:t.lat,longitude:t.lng},skip:!0})}else t(new Error(A.message||JSON.stringify(A)))},()=>t(new Error("network error"))):r.type===Tp.GOOGLE?Dm({method:"POST",url:`https://www.googleapis.com/geolocation/v1/geolocate?key=${r.key}`,success(A){const i=A.data;"location"in i?e({coords:{latitude:i.location.lat,longitude:i.location.lng,accuracy:i.accuracy},skip:!0}):t(new Error(i.error&&i.error.message||JSON.stringify(A)))},fail(){t(new Error("network error"))}}):r.type===Tp.AMAP?wp([],()=>{window.AMap.plugin("AMap.Geolocation",()=>{new window.AMap.Geolocation({enableHighAccuracy:!0,timeout:1e4}).getCurrentPosition((A,i)=>{"complete"===A?e({coords:{latitude:i.position.lat,longitude:i.position.lng,accuracy:i.accuracy},skip:!0}):t(new Error(i.message))})})}):t(A)})).then(({coords:e,skip:t})=>{Up(A,e,t).then(A=>{o({latitude:A.latitude,longitude:A.longitude,accuracy:A.accuracy,speed:A.altitude||0,altitude:A.altitude||0,verticalAccuracy:A.altitudeAccuracy||0,horizontalAccuracy:A.accuracy||0})}).catch(A=>{n(A.message)})}).catch(A=>{n(A.message||JSON.stringify(A))})},0,PE);const Vm=Ul({name:"LocationView",props:{latitude:{type:Number},longitude:{type:Number},scale:{type:Number,default:18},name:{type:String,default:""},address:{type:String,default:""}},emits:["close"],setup(A,{emit:e}){const t=function(A){const e=Nt({center:{latitude:0,longitude:0},marker:{id:1,latitude:0,longitude:0,iconPath:_p,width:32,height:52},location:{id:2,latitude:0,longitude:0,iconPath:Rp,width:44,height:44}});function t(){A.latitude&&A.longitude&&(e.center.latitude=A.latitude,e.center.longitude=A.longitude,e.marker.latitude=A.latitude,e.marker.longitude=A.longitude)}return Xi([()=>A.latitude,()=>A.longitude],t),t(),e}(A);function i(A){const e=A.detail.centerLocation;e&&(t.center.latitude=e.latitude,t.center.longitude=e.longitude)}function o(){const e=Np();let i="";if(e.type===Tp.GOOGLE){i=`https://www.google.com/maps/dir/?api=1${t.location.latitude?`&origin=${t.location.latitude}%2C${t.location.longitude}`:""}&destination=${A.latitude}%2C${A.longitude}`}else if(e.type===Tp.QQ){i=`https://apis.map.qq.com/uri/v1/routeplan?type=drive${t.location.latitude?`&fromcoord=${t.location.latitude}%2C${t.location.longitude}&from=${encodeURIComponent("我的位置")}`:""}&tocoord=${A.latitude}%2C${A.longitude}&to=${encodeURIComponent(A.name||"目的地")}&ref=${e.key}`}else if(e.type===Tp.AMAP){i=`https://uri.amap.com/navigation?${t.location.latitude?`from=${t.location.longitude},${t.location.latitude},${encodeURIComponent("我的位置")}&`:""}to=${A.longitude},${A.latitude},${encodeURIComponent(A.name||"目的地")}`}window.open(i)}function n(){e("close")}function r({latitude:A,longitude:e}){t.center.latitude=A,t.center.longitude=e}return um(),qm({type:"gcj02",success:({latitude:A,longitude:e})=>{t.location.latitude=A,t.location.longitude=e}}),()=>Ir("div",{class:"uni-system-open-location"},[Ir(Fv,{latitude:t.center.latitude,longitude:t.center.longitude,class:"map",markers:[t.marker,t.location],onRegionchange:i},{default:()=>[Ir("div",{class:"map-move",onClick:()=>r(t.location)},[jc(Mp,"#000000",24)],8,["onClick"])]},8,["latitude","longitude","markers","onRegionchange"]),Ir("div",{class:"info"},[Ir("div",{class:"name",onClick:()=>r(t.marker)},[A.name],8,["onClick"]),Ir("div",{class:"address",onClick:()=>r(t.marker)},[A.address],8,["onClick"]),Ir("div",{class:"nav",onClick:o},[jc("M28 17c-6.49396875 0-12.13721875 2.57040625-15 6.34840625V5.4105l6.29859375 6.29859375c0.387875 0.387875 1.02259375 0.387875 1.4105 0 0.387875-0.387875 0.387875-1.02259375 0-1.4105L12.77853125 2.36803125a0.9978125 0.9978125 0 0 0-0.0694375-0.077125c-0.1944375-0.1944375-0.45090625-0.291375-0.70721875-0.290875l-0.00184375-0.0000625-0.00184375 0.0000625c-0.2563125-0.0005-0.51278125 0.09640625-0.70721875 0.290875a0.9978125 0.9978125 0 0 0-0.0694375 0.077125l-7.930625 7.9305625c-0.387875 0.387875-0.387875 1.02259375 0 1.4105 0.387875 0.387875 1.02259375 0.387875 1.4105 0L11 5.4105V29c0 0.55 0.45 1 1 1s1-0.45 1-1c0-5.52284375 6.71571875-10 15-10 0.55228125 0 1-0.44771875 1-1 0-0.55228125-0.44771875-1-1-1z","#ffffff",26)],8,["onClick"])]),Ir("div",{class:"nav-btn-back",onClick:n},[jc(Hc,"#ffffff",26)],8,["onClick"])])}});let jm=null;const Km=YI("openLocation",(A,{resolve:e})=>{jm?u(jm,A):(jm=Nt(A),pi(()=>{const A=sm(Vm,jm,()=>{jm=null,pi(()=>{A.unmount()})});A.mount(am("u-a-o"))})),e()},0,JE);const Wm=Ul({name:"LoctaionPicker",props:{latitude:{type:Number},longitude:{type:Number}},emits:["close"],setup(A,{emit:e}){um(),Ac();const{t:t}=Jg(),i=function(A){const e=Nt({latitude:0,longitude:0,keyword:"",searching:!1});function t(){A.latitude&&A.longitude&&(e.latitude=A.latitude,e.longitude=A.longitude)}return Xi([()=>A.latitude,()=>A.longitude],t),t(),e}(A),{list:o,listState:n,loadMore:r,reset:s,getList:a}=function(A){const e=__uniConfig.qqMapKey,t=Nt([]),i=Kt(-1),o=Ur(()=>t[i.value]),n=Nt({loading:!0,pageSize:20,pageIndex:1,hasNextPage:!0,nextPage:null,selectedIndex:i,selected:o}),r=Kt(""),s=Ur(()=>r.value?`region(${r.value},1,${A.latitude},${A.longitude})`:`nearby(${A.latitude},${A.longitude},5000)`);function a(A){A.forEach(A=>{t.push({name:A.title||A.name,address:A.address,distance:A._distance||A.distance,latitude:A.location.lat,longitude:A.location.lng})})}function g(){n.loading=!0;const i=Np();if(i.type===Tp.GOOGLE){if(n.pageIndex>1&&n.nextPage)return void n.nextPage();new google.maps.places.PlacesService(document.createElement("div"))[A.searching?"textSearch":"nearbySearch"]({location:{lat:A.latitude,lng:A.longitude},query:A.keyword,radius:5e3},(A,e,i)=>{n.loading=!1,A&&A.length&&A.forEach(A=>{t.push({name:A.name||"",address:A.vicinity||A.formatted_address||"",distance:0,latitude:A.geometry.location.lat(),longitude:A.geometry.location.lng()})}),i&&(i.hasNextPage?n.nextPage=()=>{i.nextPage()}:n.hasNextPage=!1)})}else i.type===Tp.QQ?yp(A.searching?`https://apis.map.qq.com/ws/place/v1/search?output=jsonp&key=${e}&boundary=${s.value}&keyword=${A.keyword}&page_size=${n.pageSize}&page_index=${n.pageIndex}`:`https://apis.map.qq.com/ws/geocoder/v1/?output=jsonp&key=${e}&location=${A.latitude},${A.longitude}&get_poi=1&poi_options=page_size=${n.pageSize};page_index=${n.pageIndex}`,{callback:"callback"},e=>{if(n.loading=!1,A.searching&&"data"in e&&e.data.length)a(e.data);else if("result"in e){const A=e.result;r.value=A.ad_info?A.ad_info.adcode:"",A.pois&&a(A.pois)}t.length===n.pageSize*n.pageIndex&&(n.hasNextPage=!1)},()=>{n.loading=!1}):i.type===Tp.AMAP&&window.AMap.plugin("AMap.PlaceSearch",function(){const e=new window.AMap.PlaceSearch({city:"全国",pageSize:10,pageIndex:n.pageIndex}),t=A.searching?A.keyword:"",i=A.searching?5e4:5e3;e.searchNearBy(t,[A.longitude,A.latitude],i,function(A,e){"error"===A?console.error(e):"no_data"===A?n.hasNextPage=!1:a(e.poiList.pois)}),n.loading=!1})}return{listState:n,list:t,loadMore:function(){!n.loading&&n.hasNextPage&&(n.pageIndex++,g())},reset:function(){n.selectedIndex=-1,n.pageIndex=1,n.hasNextPage=!0,n.nextPage=null,t.splice(0,t.length)},getList:g}}(i),g=ce(()=>{s(),i.keyword&&a()},1e3,{setTimeout:setTimeout,clearTimeout:clearTimeout});function c(A){i.keyword=A.detail.value,g()}function l(){e("close",u({},n.selected))}function I(){e("close")}function E(A){const e=A.detail.centerLocation;e&&h(e)}function d(){qm({type:"gcj02",success:h,fail:()=>{}})}function h({latitude:A,longitude:e}){i.latitude=A,i.longitude=e,i.searching||(s(),a())}return Xi(()=>i.searching,A=>{s(),A||a()}),i.latitude&&i.longitude||d(),()=>{const A=o.map((A,e)=>{return Ir("div",{key:e,class:{"list-item":!0,selected:n.selectedIndex===e},onClick:()=>{n.selectedIndex=e,i.latitude=A.latitude,i.longitude=A.longitude}},[jc(Vc,"#007aff",24),Ir("div",{class:"list-item-title"},[A.name]),Ir("div",{class:"list-item-detail"},[(t=A.distance,t>100?`${t>1e3?(t/1e3).toFixed(1)+"k":t.toFixed(0)}m | `:t>0?"<100m | ":""),A.address])],10,["onClick"]);var t});return n.loading&&A.unshift(Ir("div",{class:"list-loading"},[Ir("i",{class:"uni-loading"},null)])),Ir("div",{class:"uni-system-choose-location"},[Ir(Fv,{latitude:i.latitude,longitude:i.longitude,class:"map","show-location":!0,libraries:["places"],onUpdated:a,onRegionchange:E},{default:()=>[Ir("div",{class:"map-location",style:`background-image: url("${_p}")`},null),Ir("div",{class:"map-move",onClick:d},[jc(Mp,"#000000",24)],8,["onClick"])],_:1},8,["latitude","longitude","show-location","onUpdated","onRegionchange"]),Ir("div",{class:"nav"},[Ir("div",{class:"nav-btn back",onClick:I},[jc(qc,"#ffffff",26)],8,["onClick"]),Ir("div",{class:{"nav-btn":!0,confirm:!0,disable:!n.selected},onClick:l},[jc(Vc,"#ffffff",26)],10,["onClick"])]),Ir("div",{class:"menu"},[Ir("div",{class:"search"},[Ir(vB,{value:i.keyword,class:"search-input",placeholder:t("uni.chooseLocation.search"),onFocus:()=>i.searching=!0,onInput:c},null,8,["value","placeholder","onFocus","onInput"]),i.searching&&Ir("div",{class:"search-btn",onClick:()=>{i.searching=!1,i.keyword=""}},[t("uni.chooseLocation.cancel")],8,["onClick"])]),Ir(hQ,{"scroll-y":!0,class:"list",onScrolltolower:r},(e=A,"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!rr(e)?A:{default:()=>[A],_:2}),8,["scroll-y","onScrolltolower"])])]);var e}}});let zm=null;const Zm=YI("chooseLocation",(A,{resolve:e,reject:t})=>{zm?t("cancel"):(zm=Nt(A),pi(()=>{const A=sm(Wm,zm,i=>{zm=null,pi(()=>{A.unmount()}),i?e(i):t("cancel")});A.mount(am("u-a-c"))}))});let Xm=!1,$m=0;const Ay=YI("startLocationUpdate",(A,{resolve:e,reject:t})=>{navigator.geolocation?($m=$m||navigator.geolocation.watchPosition(t=>{Xm=!0,Up(null==A?void 0:A.type,t.coords).then(A=>{Pv.invokeOnCallback(rd,A),e()}).catch(A=>{Pv.invokeOnCallback(sd,{errMsg:`onLocationChange:fail ${A.message}`})})},A=>{Xm||(t(A.message),Xm=!0),Pv.invokeOnCallback(sd,{errMsg:`onLocationChange:fail ${A.message}`})}),setTimeout(e,100)):t()},0,gd),ey=YI("stopLocationUpdate",(A,{resolve:e})=>{$m&&(navigator.geolocation.clearWatch($m),Xm=!1,$m=0),e()}),ty=FI(rd,()=>{}),iy=OI("offLocationChange",()=>{}),oy=FI(sd,()=>{}),ny=OI("offLocationChangeError",()=>{}),ry=YI("navigateBack",(A,{resolve:e,reject:t})=>{let i=!0;return!0===il(yA,{from:A.from||"navigateBack"})&&(i=!1),i?(np().$router.go(-A.delta),e()):t(yA)},0,pd),sy=YI(ld,({url:A,events:e,isAutomatedTesting:t},{resolve:i,reject:o})=>{if(_h.handledBeforeEntryPageRoutes)return uh({type:ld,url:A,events:e,isAutomatedTesting:t}).then(i).catch(o);Th.push({args:{type:ld,url:A,events:e,isAutomatedTesting:t},resolve:i,reject:o})},0,hd),ay=YI(dd,({url:A},{resolve:e,reject:t})=>{const i=gl(A.split("?")[0]);i?i.loader&&i.loader().then(()=>{e({url:A,errMsg:"preloadPage:ok"})}).catch(e=>{t(`${A} ${String(e)}`)}):t(`${A}}`)});function gy(A){__uniConfig.darkmode&&Pv.on(EA,A)}function cy(A){Pv.off(EA,A)}function ly(A){let e={};return __uniConfig.darkmode&&(e=fe(A,__uniConfig.themeConfig,$p())),__uniConfig.darkmode?e:A}function Iy(A,e){const t=Lt(A),i=t?Nt(ly(A)):ly(A);return __uniConfig.darkmode&&t&&Xi(A,A=>{const e=ly(A);for(const t in e)i[t]=e[t]}),e&&gy(e),i}const uy={light:{cancelColor:"#000000"},dark:{cancelColor:"rgb(170, 170, 170)"}},Ey=Co({props:{title:{type:String,default:""},content:{type:String,default:""},showCancel:{type:Boolean,default:!0},cancelText:{type:String,default:"Cancel"},cancelColor:{type:String,default:"#000000"},confirmText:{type:String,default:"OK"},confirmColor:{type:String,default:"#007aff"},visible:{type:Boolean},editable:{type:Boolean,default:!1},placeholderText:{type:String,default:""}},setup(A,{emit:e}){const t=Kt(""),i=()=>r.value=!1,o=()=>(i(),e("close","cancel")),n=()=>(i(),e("close","confirm",t.value)),r=gm(A,{onEsc:o,onEnter:()=>{!A.editable&&n()}}),s=function(A){const e=Kt(A.cancelColor),t=({theme:A})=>{((A,e)=>{e.value=uy[A].cancelColor})(A,e)};return zi(()=>{A.visible?(e.value=A.cancelColor,"#000"===A.cancelColor&&("dark"===$p()&&t({theme:"dark"}),gy(t))):cy(t)}),e}(A);return()=>{const{title:e,content:i,showCancel:a,confirmText:g,confirmColor:c,editable:l,placeholderText:I}=A;return t.value=i,Ir(jr,{name:"uni-fade"},{default:()=>[io(Ir("uni-modal",{onTouchmove:_c},[rm,Ir("div",{class:"uni-modal"},[e?Ir("div",{class:"uni-modal__hd"},[Ir("strong",{class:"uni-modal__title",textContent:e||""},null,8,["textContent"])]):null,l?Ir("textarea",{class:"uni-modal__textarea",rows:"1",placeholder:I,value:i,onInput:A=>t.value=A.target.value},null,40,["placeholder","value","onInput"]):Ir("div",{class:"uni-modal__bd",onTouchmovePassive:Tc,textContent:i},null,40,["onTouchmovePassive","textContent"]),Ir("div",{class:"uni-modal__ft"},[a&&Ir("div",{style:{color:s.value},class:"uni-modal__btn uni-modal__btn_default",onClick:o},[A.cancelText],12,["onClick"]),Ir("div",{style:{color:c},class:"uni-modal__btn uni-modal__btn_primary",onClick:n},[g],12,["onClick"])])])],40,["onTouchmove"]),[[ss,r.value]])]})}}});let dy;const hy=HA(()=>{Pv.on("onHidePopup",()=>dy.visible=!1)});let Cy;function By(A,e){const t="confirm"===A,i={confirm:t,cancel:"cancel"===A};t&&dy.editable&&(i.content=e),Cy&&Cy(i)}const Qy=YI("showModal",(A,{resolve:e})=>{hy(),Cy=e,dy?(u(dy,A),dy.visible=!0):(dy=Nt(A),pi(()=>(sm(Ey,dy,By).mount(am("u-a-m")),pi(()=>dy.visible=!0))))},0,Gd),py={title:{type:String,default:""},icon:{default:"success",validator:A=>-1!==kd.indexOf(A)},image:{type:String,default:""},duration:{type:Number,default:1500},mask:{type:Boolean,default:!1},visible:{type:Boolean}},fy="uni-toast__icon",yy={light:"#fff",dark:"rgba(255,255,255,0.9)"},Dy=A=>yy[A],vy=Co({name:"Toast",props:py,setup(A){jg(),Kg();const{Icon:e}=function(A){const e=Kt(Dy($p())),t=({theme:A})=>e.value=Dy(A);zi(()=>{A.visible?gy(t):cy(t)});const i=Ur(()=>{switch(A.icon){case"success":return Ir(jc(Yc,e.value,38),{class:fy});case"error":return Ir(jc(Jc,e.value,38),{class:fy});case"loading":return Ir("i",{class:[fy,"uni-loading"]},null,2);default:return null}});return{Icon:i}}(A),t=gm(A,{});return()=>{const{mask:i,duration:o,title:n,image:r}=A;return Ir(jr,{name:"uni-fade"},{default:()=>[io(Ir("uni-toast",{"data-duration":o},[i?Ir("div",{class:"uni-mask",style:"background: transparent;",onTouchmove:_c},null,40,["onTouchmove"]):"",r||e.value?Ir("div",{class:"uni-toast"},[r?Ir("img",{src:r,class:fy},null,10,["src"]):e.value,Ir("p",{class:"uni-toast__content"},[n])]):Ir("div",{class:"uni-sample-toast"},[Ir("p",{class:"uni-simple-toast__text"},[n])])],8,["data-duration"]),[[ss,t.value]])]})}}});let wy,Sy,My="";const Ry=ve();function _y(A){wy?u(wy,A):(wy=Nt(u(A,{visible:!1})),pi(()=>{Ry.run(()=>{Xi([()=>wy.visible,()=>wy.duration],([A,e])=>{if(A){if(Sy&&clearTimeout(Sy),"onShowLoading"===My)return;Sy=setTimeout(()=>{Ly("onHideToast")},e)}else Sy&&clearTimeout(Sy)})}),Pv.on("onHidePopup",()=>Ly("onHidePopup")),sm(vy,wy,()=>{}).mount(am("u-a-t"))})),setTimeout(()=>{wy.visible=!0},10)}const Ty=YI("showToast",(A,{resolve:e,reject:t})=>{_y(A),My="onShowToast",e()},0,Ld),Ny={icon:"loading",duration:1e8,image:""},by=YI("showLoading",(A,{resolve:e,reject:t})=>{u(A,Ny),_y(A),My="onShowLoading",e()},0,bd),Gy=YI("hideToast",(A,{resolve:e,reject:t})=>{Ly("onHideToast"),e()}),ky=YI("hideLoading",(A,{resolve:e,reject:t})=>{Ly("onHideLoading"),e()});function Ly(A){const{t:e}=Jg();if(!My)return;let t="";if("onHideToast"===A&&"onShowToast"!==My?t=e("uni.showToast.unpaired"):"onHideLoading"===A&&"onShowLoading"!==My&&(t=e("uni.showLoading.unpaired")),t)return console.warn(t);My="",setTimeout(()=>{wy.visible=!1},10)}const Uy={light:{listItemColor:"#000000",cancelItemColor:"#000000"},dark:{listItemColor:"rgba(255, 255, 255, 0.8)",cancelItemColor:"rgba(255, 255, 255)"}};const Fy=Co({name:"ActionSheet",props:{title:{type:String,default:""},itemList:{type:Array,default:()=>[]},itemColor:{type:String,default:"#000000"},popover:{type:Object,default:null},visible:{type:Boolean,default:!1}},emits:["close"],setup(A,{emit:e}){Vg();const t=Kt(260),i=Kt(0),o=Kt(0),n=Kt(0),r=Kt(0),s=Kt(null),a=Kt(null),{t:g}=Jg(),{_close:c}=function(A,e){function t(A){e("close",A)}const{key:i,disable:o}=nm();return Xi(()=>A.visible,A=>o.value=!A),zi(()=>{const{value:A}=i;"esc"===A&&t&&t(-1)}),{_close:t}}(A,e),{popupStyle:l}=function(A){const e=Kt(0),t=Kt(0),i=Ur(()=>e.value>=500&&t.value>=500),o=Ur(()=>{const e={content:{transform:"",left:"",top:"",bottom:""},triangle:{left:"",top:"",bottom:"","border-width":"","border-color":""}},o=e.content,n=e.triangle,r=A.popover;function s(A){return Number(A)||0}if(i.value&&r){u(n,{position:"absolute",width:"0",height:"0","margin-left":"-6px","border-style":"solid"});const A=s(r.left),e=s(r.width?r.width:300),i=s(r.top),a=s(r.height),g=A+e/2;o.transform="none !important";const c=Math.max(0,g-e/2);o.left=`${c}px`,r.width&&(o.width=`${e}px`);let l=Math.max(12,g-c);l=Math.min(e-12,l),n.left=`${l}px`;const I=t.value/2;i+a-I>I-i?(o.top="auto",o.bottom=t.value-i+6+"px",n.bottom="-6px",n["border-width"]="6px 6px 0 6px",n["border-color"]="#fcfcfd transparent transparent transparent"):(o.top=`${i+a+6}px`,n.top="-6px",n["border-width"]="0 6px 6px 6px",n["border-color"]="transparent transparent #fcfcfd transparent")}return e});return Uo(()=>{const A=()=>{const{windowWidth:A,windowHeight:i,windowTop:o}=uni.getSystemInfoSync();e.value=A,t.value=i+(o||0)};window.addEventListener("resize",A),A(),Po(()=>{window.removeEventListener("resize",A)})}),{isDesktop:i,popupStyle:o}}(A);let I;function E(A){const e=n.value+A.deltaY;Math.abs(e)>10?(r.value+=e/3,r.value=r.value>=i.value?i.value:r.value<=0?0:r.value,I.scrollTo(r.value)):n.value=e,A.preventDefault()}Uo(()=>{const{scroller:A,handleTouchStart:e,handleTouchMove:t,handleTouchEnd:i}=function(A,e){const t={trackingID:-1,maxDy:0,maxDx:0},i=new eQ(A,e);function o(A){const e=A,i=A;return"move"===e.detail.state||"end"===e.detail.state?{x:e.detail.dx,y:e.detail.dy}:{x:i.screenX-t.x,y:i.screenY-t.y}}return{scroller:i,handleTouchStart:function(A){const e=A,o=A;"start"===e.detail.state?(t.trackingID="touch",t.x=e.detail.x,t.y=e.detail.y):(t.trackingID="mouse",t.x=o.screenX,t.y=o.screenY),t.maxDx=0,t.maxDy=0,t.historyX=[0],t.historyY=[0],t.historyTime=[e.detail.timeStamp||o.timeStamp],t.listener=i,i.onTouchStart&&i.onTouchStart(),("boolean"!=typeof A.cancelable||A.cancelable)&&A.preventDefault()},handleTouchMove:function(A){const e=A,i=A;if(-1!==t.trackingID){("boolean"!=typeof A.cancelable||A.cancelable)&&A.preventDefault();const n=o(A);if(n){for(t.maxDy=Math.max(t.maxDy,Math.abs(n.y)),t.maxDx=Math.max(t.maxDx,Math.abs(n.x)),t.historyX.push(n.x),t.historyY.push(n.y),t.historyTime.push(e.detail.timeStamp||i.timeStamp);t.historyTime.length>10;)t.historyTime.shift(),t.historyX.shift(),t.historyY.shift();t.listener&&t.listener.onTouchMove&&t.listener.onTouchMove(n.x,n.y)}}},handleTouchEnd:function(A){if(-1!==t.trackingID){A.preventDefault();const e=o(A);if(e){const A=t.listener;t.trackingID=-1,t.listener=null;const i={x:0,y:0};if(t.historyTime.length>2)for(let e=t.historyTime.length-1,o=t.historyTime[e],n=t.historyX[e],r=t.historyY[e];e>0;){e--;const A=o-t.historyTime[e];if(A>30&&A<50){i.x=(n-t.historyX[e])/(A/1e3),i.y=(r-t.historyY[e])/(A/1e3);break}}t.historyTime=[],t.historyX=[],t.historyY=[],A&&A.onTouchEnd&&A.onTouchEnd(e.x,e.y,i)}}}}}(s.value,{enableY:!0,friction:new zB(1e-4),spring:new $B(2,90,20),onScroll:A=>{r.value=A.target.scrollTop}});I=A,kB(s.value,o=>{if(A)switch(o.detail.state){case"start":e(o);break;case"move":t(o);break;case"end":case"cancel":i(o)}},!0)}),Xi(()=>A.visible,()=>{pi(()=>{A.title&&(o.value=document.querySelector(".uni-actionsheet__title").offsetHeight),I.update(),s.value&&(i.value=s.value.clientHeight-t.value),document.querySelectorAll(".uni-actionsheet__cell").forEach(A=>{!function(A){const e=20;let t=0,i=0;A.addEventListener("touchstart",A=>{const e=A.changedTouches[0];t=e.clientX,i=e.clientY}),A.addEventListener("touchend",A=>{const o=A.changedTouches[0];if(Math.abs(o.clientX-t){i[A]=o[A]}),A.target.dispatchEvent(i)}})}(A)})})});const d=function(A){const e=Nt({listItemColor:"#000",cancelItemColor:"#000"}),t=({theme:A})=>{!function(A,e){["listItemColor","cancelItemColor"].forEach(t=>{e[t]=Uy[A][t]})}(A,e)};return zi(()=>{A.visible?(e.listItemColor=e.cancelItemColor=A.itemColor,"#000"===A.itemColor&&(t({theme:$p()}),gy(t))):cy(t)}),e}(A);return()=>Ir("uni-actionsheet",{onTouchmove:_c},[Ir(jr,{name:"uni-fade"},{default:()=>[io(Ir("div",{class:"uni-mask uni-actionsheet__mask",onClick:()=>c(-1)},null,8,["onClick"]),[[ss,A.visible]])]}),Ir("div",{class:["uni-actionsheet",{"uni-actionsheet_toggle":A.visible}],style:l.value.content},[Ir("div",{ref:a,class:"uni-actionsheet__menu",onWheel:E},[A.title?Ir(Kn,null,[Ir("div",{class:"uni-actionsheet__cell",style:{height:`${o.value}px`}},null),Ir("div",{class:"uni-actionsheet__title"},[A.title])]):"",Ir("div",{style:{maxHeight:`${t.value}px`,overflow:"hidden"}},[Ir("div",{ref:s},[A.itemList.map((A,e)=>Ir("div",{key:e,style:{color:d.listItemColor},class:"uni-actionsheet__cell",onClick:()=>c(e)},[A],12,["onClick"]))],512)])],40,["onWheel"]),Ir("div",{class:"uni-actionsheet__action"},[Ir("div",{style:{color:d.cancelItemColor},class:"uni-actionsheet__cell",onClick:()=>c(-1)},[g("uni.showActionSheet.cancel")],12,["onClick"])]),Ir("div",{style:l.value.triangle},null,4)],6)],40,["onTouchmove"])}});let Oy,xy,Py;const Yy=HA(()=>{Pv.on("onHidePopup",()=>Py.visible=!1)});function Jy(A){-1===A?xy&&xy("cancel"):Oy&&Oy({tapIndex:A})}const Hy=YI("showActionSheet",(A,{resolve:e,reject:t})=>{Yy(),Oy=e,xy=t,Py?(u(Py,A),Py.visible=!0):(Py=Nt(A),pi(()=>(sm(Fy,Py,Jy).mount(am("u-s-a-s")),pi(()=>Py.visible=!0))))},0,Nd),qy=YI("loadFontFace",({family:A,source:e,desc:t},{resolve:i,reject:o})=>{(function(A,e,t){const i=document.fonts;if(i){const o=new FontFace(A,e,t);return o.load().then(()=>{i.add&&i.add(o)})}return new Promise(i=>{const o=document.createElement("style"),n=[];if(t){const{style:A,weight:e,stretch:i,unicodeRange:o,variant:r,featureSettings:s}=t;A&&n.push(`font-style:${A}`),e&&n.push(`font-weight:${e}`),i&&n.push(`font-stretch:${i}`),o&&n.push(`unicode-range:${o}`),r&&n.push(`font-variant:${r}`),s&&n.push(`font-feature-settings:${s}`)}o.innerText=`@font-face{font-family:"${A}";src:${e};${n.join(";")}}`,document.head.appendChild(o),i()})})(A,e=e.startsWith('url("')||e.startsWith("url('")?`url('${AC(e.substring(5,e.length-2))}')`:e.startsWith("url(")?`url('${AC(e.substring(4,e.length-1))}')`:AC(e),t).then(()=>{i()}).catch(A=>{o(`loadFontFace:fail ${A}`)})});function Vy(A){function e(){var e;e=A.navigationBar.titleText,document.title=e,Pv.emit("onNavigationBarChange",{titleText:e})}zi(e),wo(e)}function jy(A,e,t,i,o){if(!A)return o("page not found");const{navigationBar:n}=A;switch(e){case wd:const{frontColor:A,backgroundColor:e,animation:i}=t,{duration:o,timingFunc:r}=i;A&&(n.titleColor="#000000"===A?"#000000":"#ffffff"),e&&(n.backgroundColor=e),n.duration=o+"ms",n.timingFunc=r;break;case Rd:n.loading=!0;break;case _d:n.loading=!1;break;case Md:const{title:s}=t;n.titleText=s}i()}const Ky=YI(wd,(A,{resolve:e,reject:t})=>{jy(Zc(),wd,A,e,t)},0,Sd),Wy=YI(Rd,(A,{resolve:e,reject:t})=>{jy(Zc(),Rd,A||{},e,t)}),zy=YI(_d,(A,{resolve:e,reject:t})=>{jy(Zc(),_d,A||{},e,t)}),Zy=YI(Md,(A,{resolve:e,reject:t})=>{jy(Zc(),Md,A,e,t)}),Xy=YI("pageScrollTo",({scrollTop:A,selector:e,duration:t},{resolve:i})=>{!function(A,e){if(f(A)){const e=document.querySelector(A);if(e){const{top:t}=e.getBoundingClientRect();A=t+window.pageYOffset;const i=document.querySelector("uni-page-head");i&&(A-=i.offsetHeight)}}A<0&&(A=0);const t=document.documentElement,{clientHeight:i,scrollHeight:o}=t;if(A=Math.min(A,o-i),0===e)return void(t.scrollTop=document.body.scrollTop=A);if(window.scrollY===A)return;const n=e=>{if(e<=0)return void window.scrollTo(0,A);const t=A-window.scrollY;requestAnimationFrame(function(){window.scrollTo(0,window.scrollY+t/e*10),n(e-10)})};n(e)}(e||A||0,t),i()},0,Td),$y=YI(Ud,(A,{resolve:e})=>{Pv.invokeViewMethod(Ud,{},Xc()),e()}),AD=YI(Fd,(A,{resolve:e})=>{Pv.invokeViewMethod(Fd,{},Xc()),e()}),eD=["text","iconPath","iconfont","selectedIconPath","visible"],tD=["color","selectedColor","backgroundColor","borderStyle","borderColor","midButton"],iD=["badge","redDot"];function oD(A,e,t){e.forEach(function(e){h(t,e)&&(A[e]=t[e])})}function nD(A,e,t,i){var o;let n=!1;const r=Uh();if(r.length&&Rh(r[r.length-1]).meta.isTabBar&&(n=!0),!n)return i("not TabBar page");const{index:s}=e;if("number"==typeof s){const A=null==(o=null==__uniConfig?void 0:__uniConfig.tabBar)?void 0:o.list.length;if(!A||s>=A)return i("tabbar item not found")}const a=hh();switch(A){case Vd:a.shown=!0;break;case qd:a.shown=!1;break;case xd:const A=a.list[s],t=A.pagePath;oD(A,eD,e);const{pagePath:i}=e;if(i){const A=PA(i);A!==t&&function(A,e,t){const i=gl(PA(e));if(i){const{meta:A}=i;delete A.tabBarIndex,A.isQuit=A.isTabBar=!1}const o=gl(PA(t));if(o){const{meta:e}=o;e.tabBarIndex=A,e.isQuit=e.isTabBar=!0;const i=__uniConfig.tabBar;i&&i.list&&i.list[A]&&(i.list[A].pagePath=YA(t))}}(s,t,A)}break;case Yd:oD(a,tD,e);break;case zd:oD(a.list[s],iD,{badge:"",redDot:!0});break;case Ah:oD(a.list[s],iD,{badge:e.text,redDot:!0});break;case Kd:case Xd:oD(a.list[s],iD,{badge:"",redDot:!1})}t()}const rD=YI(xd,(A,{resolve:e,reject:t})=>{nD(xd,A,e,t)},0,Pd),sD=YI(Yd,(A,{resolve:e,reject:t})=>{nD(Yd,A,e,t)},0,Hd),aD=YI(qd,(A,{resolve:e,reject:t})=>{nD(qd,A||{},e,t)}),gD=YI(Vd,(A,{resolve:e,reject:t})=>{nD(Vd,A||{},e,t)}),cD=YI(Kd,(A,{resolve:e,reject:t})=>{nD(Kd,A,e,t)},0,Wd),lD=YI(zd,(A,{resolve:e,reject:t})=>{nD(zd,A,e,t)},0,Zd),ID=YI(Xd,(A,{resolve:e,reject:t})=>{nD(Xd,A,e,t)},0,$d),uD=YI(Ah,(A,{resolve:e,reject:t})=>{nD(Ah,A,e,t)},0,eh),ED=Ul({name:"TabBar",setup(){const A=Kt([]),e=hh(),t=Iy(e,()=>{const A=ly(e);t.backgroundColor=A.backgroundColor,t.borderStyle=A.borderStyle,t.color=A.color,t.selectedColor=A.selectedColor,t.blurEffect=A.blurEffect,t.midButton=A.midButton,A.list&&A.list.length&&A.list.forEach((A,e)=>{t.list[e].iconPath=A.iconPath,t.list[e].selectedIconPath=A.selectedIconPath})});!function(A,e){function t(){let t=[];t=A.list.filter(A=>!1!==A.visible),e.value=t}Kt(u({type:"midButton"},A.midButton)),zi(t)}(t,A),function(A){Xi(()=>A.shown,e=>{Lc({"--window-bottom":wh(e?parseInt(A.height):0)})})}(t);const i=function(A,e,t){return zi(()=>{const i=A.meta;if(i.isTabBar){const A=i.route,o=t.value.findIndex(e=>e.pagePath===A);e.selectedIndex=o}}),(e,t)=>()=>{const{pagePath:i,text:o}=e;let n=PA(i);n===__uniRoutes[0].alias&&(n="/"),A.path!==n?uni.switchTab({from:"tabBar",url:n,tabBarText:o}):il("onTabItemTap",{index:t,text:o,pagePath:i})}}(mg(),t,A),{style:o,borderStyle:n,placeholderStyle:r}=function(A){const e=Ur(()=>{let e=A.backgroundColor;const t=A.blurEffect;return e||fh&&t&&"none"!==t&&(e=BD[t]),{backgroundColor:e||dD,backdropFilter:"none"!==t?"blur(10px)":t}}),t=Ur(()=>{const{borderStyle:e,borderColor:t}=A;return t&&f(t)?{backgroundColor:t}:{backgroundColor:QD[e]||QD.black}}),i=Ur(()=>({height:A.height}));return{style:e,borderStyle:t,placeholderStyle:i}}(t);return Uo(()=>{t.iconfontSrc&&qy({family:"UniTabbarIconFont",source:`url("${t.iconfontSrc}")`})}),()=>{const e=function(A,e,t){const{selectedIndex:i,selectedColor:o,color:n}=A;return t.value.map((t,r)=>{const s=i===r;return function(A,e,t,i,o,n,r,s){return Ir("div",{key:r,class:"uni-tabbar__item",onClick:s(o,r)},[pD(A,e||"",t,i,o,n)],8,["onClick"])}(s?o:n,s&&t.selectedIconPath||t.iconPath||"",t.iconfont?s&&t.iconfont.selectedText||t.iconfont.text:void 0,t.iconfont?s&&t.iconfont.selectedColor||t.iconfont.color:void 0,t,A,r,e)})}(t,i,A);return Ir("uni-tabbar",{class:"uni-tabbar-"+t.position},[Ir("div",{class:"uni-tabbar",style:o.value},[Ir("div",{class:"uni-tabbar-border",style:n.value},null,4),e],4),Ir("div",{class:"uni-placeholder",style:r.value},null,4)],2)}}});const dD="#f7f7fa",hD="rgb(0, 0, 0, 0.8)",CD="rgb(250, 250, 250, 0.8)",BD={dark:hD,light:CD,extralight:CD},QD={white:"rgba(255, 255, 255, 0.33)",black:"rgba(0, 0, 0, 0.33)"};function pD(A,e,t,i,o,n){const{height:r}=n;return Ir("div",{class:"uni-tabbar__bd",style:{height:r}},[t?mD(t,i||hD,o,n):e&&fD(e,o,n),o.text&&yD(A,o,n),o.redDot&&DD(o.badge)],4)}function fD(A,e,t){const{type:i,text:o}=e,{iconWidth:n}=t;return Ir("div",{class:"uni-tabbar__icon"+(o?" uni-tabbar__icon__diff":""),style:{width:n,height:n}},["midButton"!==i&&Ir("img",{src:AC(A)},null,8,["src"])],6)}function mD(A,e,t,i){var o;const{type:n,text:r}=t,{iconWidth:s}=i,a="uni-tabbar__icon"+(r?" uni-tabbar__icon__diff":""),g={width:s,height:s},c={fontSize:(null==(o=t.iconfont)?void 0:o.fontSize)||s,color:e};return Ir("div",{class:a,style:g},["midButton"!==n&&Ir("div",{class:"uni-tabbar__iconfont",style:c},[A],4)],6)}function yD(A,e,t){const{iconPath:i,text:o}=e,{fontSize:n,spacing:r}=t;return Ir("div",{class:"uni-tabbar__label",style:{color:A,fontSize:n,lineHeight:i?"normal":1.8,marginTop:i?r:"inherit"}},[o],4)}function DD(A){return Ir("div",{class:"uni-tabbar__reddot"+(A?" uni-tabbar__badge":"")},[A],2)}const vD="0px";let wD;function SD(){return wD}const MD=Ul({name:"Layout",setup(A,{emit:e}){const t=Kt(null);kc({"--status-bar-height":vD,"--top-window-height":vD,"--window-left":vD,"--window-right":vD,"--window-margin":vD,"--tab-bar-height":vD});const i=function(){const A=mg();return{routeKey:Ur(()=>Yh("/"+A.meta.route,tI())),isTabBar:Ur(()=>A.meta.isTabBar),routeCache:Hh}}(),{layoutState:o,windowState:n}=function(){eI();{const A=Nt({marginWidth:0,leftWindowWidth:0,rightWindowWidth:0});return Xi(()=>A.marginWidth,A=>kc({"--window-margin":A+"px"})),Xi(()=>A.leftWindowWidth+A.marginWidth,A=>{kc({"--window-left":A+"px"})}),Xi(()=>A.rightWindowWidth+A.marginWidth,A=>{kc({"--window-right":A+"px"})}),{layoutState:A,windowState:Ur(()=>({}))}}}();!function(A,e){const t=eI();function i(){const i=document.body.clientWidth,o=Uh();let n={};if(o.length>0){n=Rh(o[o.length-1]).meta}else{const A=gl(t.path,!0);A&&(n=A.meta)}const r=parseInt(String((h(n,"maxWidth")?n.maxWidth:__uniConfig.globalStyle.maxWidth)||Number.MAX_SAFE_INTEGER));let s=!1;s=i>r,s&&r?(A.marginWidth=(i-r)/2,pi(()=>{const A=e.value;A&&A.setAttribute("style","max-width:"+r+"px;margin:0 auto;")})):(A.marginWidth=0,pi(()=>{const A=e.value;A&&A.removeAttribute("style")}))}Xi([()=>t.path],i),Uo(()=>{i(),window.addEventListener("resize",i)})}(o,t);const r=function(){const A=eI(),e=hh(),t=Ur(()=>A.meta.isTabBar&&e.shown);return kc({"--tab-bar-height":e.height}),t}(),s=function(A){const e=Kt(!1);return Ur(()=>({"uni-app--showtabbar":A&&A.value,"uni-app--maxwidth":e.value}))}(r);return wD=o,()=>{const A=function(A){const e=function({routeKey:A,isTabBar:e,routeCache:t}){return Ir(pg,null,{default:Ui(({Component:i})=>[(Ar(),nr(Do,{matchBy:"key",cache:t},[(Ar(),nr(qi(i),{type:e.value?"tabBar":"",key:A.value}))],1032,["cache"]))]),_:1})}(A);return e}(i),e=function(A){return io(Ir(ED,null,null,512),[[ss,A.value]])}(r);return Ir("uni-app",{ref:t,class:s.value},[A,e],2)}}});const RD=YI("showTopWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowTopWindow=!0,pi(e)):t()}),_D=YI("hideTopWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowTopWindow=!1,pi(e)):t()}),TD=YI("showLeftWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowLeftWindow=!0,pi(e)):t()}),ND=YI("hideLeftWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowLeftWindow=!1,pi(e)):t()}),bD=YI("showRightWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowRightWindow=!0,pi(e)):t()}),GD=YI("hideRightWindow",(A,{resolve:e,reject:t})=>{const i=SD();i?(i.apiShowRightWindow=!1,pi(e)):t()}),kD=PI(0,()=>{const A=SD();return u({},A&&A.topWindowStyle)}),LD=PI(0,A=>{const e=SD();e&&(e.topWindowStyle=A)}),UD=PI(0,()=>{const A=SD();return u({},A&&A.leftWindowStyle)}),FD=PI(0,A=>{const e=SD();e&&(e.leftWindowStyle=A)}),OD=PI(0,()=>{const A=SD();return u({},A&&A.rightWindowStyle)}),xD=PI(0,A=>{const e=SD();e&&(e.rightWindowStyle=A)}),PD=PI(0,A=>{const e=document.querySelector("uni-page-body");return e?e.querySelector(`#${A}`):null}),YD=PI(0,()=>Object.getPrototypeOf(window)!==Window.prototype?(console.error("getFacialRecognitionMetaInfo:fail window对象原型被篡改,可能存在劫持"),""):window.window!==window||window.self!==window?(console.error("getFacialRecognitionMetaInfo:fail window对象属性引用异常,可能被劫持"),""):"[object Window]"!==Object.prototype.toString.call(window)&&"[object DOMWindow]"!==Object.prototype.toString.call(window)?(console.error("getFacialRecognitionMetaInfo:fail window对象类型标识异常,可能被劫持"),""):p(window.getMetaInfo)?window.getMetaInfo():(console.error("getFacialRecognitionMetaInfo:fail window对象缺少getMetaInfo方法,请参考文档引用:https://doc.dcloud.net.cn/uniCloud/frv/dev.html#window-get-meta-info"),"")),JD=YI(ZE,VI(ZE)),HD="getRecorderManager",qD=PI(0,HI(HD)),VD=YI(XE,VI(XE)),jD="createCameraContext",KD=PI(0,HI(jD)),WD="createLivePlayerContext",zD=PI(0,HI(WD)),ZD="saveFile",XD=YI(ZD,VI(ZD)),$D="getSavedFileList",Av=YI($D,VI($D)),ev="getSavedFileInfo",tv=YI(ev,VI(ev)),iv="removeSavedFile",ov=YI(iv,VI(iv)),nv="onMemoryWarning",rv=FI(nv,qI(nv)),sv="onGyroscopeChange",av=FI(sv,qI(sv)),gv="startGyroscope",cv=YI(gv,VI(gv)),lv="stopGyroscope",Iv=YI(lv,VI(lv)),uv="scanCode",Ev=YI(uv,VI(uv)),dv="setScreenBrightness",hv=YI(dv,VI(dv)),Cv="getScreenBrightness",Bv=YI(Cv,VI(Cv)),Qv="setKeepScreenOn",pv=YI(Qv,VI(Qv)),fv="onUserCaptureScreen",mv=FI(fv,qI(fv)),yv="addPhoneContact",Dv=YI(yv,VI(yv)),vv="login",wv=YI(vv,VI(vv)),Sv="getProvider",Mv=YI(Sv,VI(Sv)),Rv=Object.defineProperty({__proto__:null,$emit:Iu,$off:lu,$on:gu,$once:cu,__f__:function(A,e,...t){e&&t.push(e),console[A].apply(console,t)},addInterceptor:ru,addPhoneContact:Dv,arrayBufferToBase64:KI,base64ToArrayBuffer:jI,canIUse:yh,canvasGetImageData:Ou,canvasPutImageData:xu,canvasToTempFilePath:Pu,chooseFile:Am,chooseImage:tm,chooseLocation:Zm,chooseVideo:ym,clearStorage:Jf,clearStorageSync:Yf,closePreviewImage:fm,closeSocket:Om,connectSocket:Lm,createAnimation:cE,createCameraContext:KD,createCanvasContext:Fu,createInnerAudioContext:jp,createIntersectionObserver:Wu,createLivePlayerContext:zD,createMapContext:Bu,createMediaQueryObserver:Xu,createSelectorQuery:nE,createVideoContext:du,cssBackdropFilter:fh,cssConstant:ph,cssEnv:Qh,cssVar:Bh,downloadFile:_m,getAppBaseInfo:sf,getClipboardData:_f,getDeviceInfo:rf,getElementById:PD,getEnterOptionsSync:DE,getFacialRecognitionMetaInfo:YD,getFileInfo:Vf,getImageInfo:Wf,getLaunchOptionsSync:vE,getLeftWindowStyle:UD,getLocale:dE,getLocation:qm,getNetworkType:df,getProvider:Mv,getPushClientId:NE,getRecorderManager:qD,getRightWindowStyle:OD,getSavedFileInfo:tv,getSavedFileList:Av,getScreenBrightness:Bv,getSelectedTextRange:pE,getStorage:Of,getStorageInfo:qf,getStorageInfoSync:Hf,getStorageSync:Ff,getSystemInfo:gf,getSystemInfoSync:af,getTabBarPageId:sh,getTopWindowStyle:kD,getVideoInfo:zf,getWindowInfo:ef,hideActionSheet:()=>{Py&&(Py.visible=!1)},hideKeyboard:Kf,hideLeftWindow:ND,hideLoading:ky,hideModal:()=>{dy&&(dy.visible=!1)},hideNavigationBarLoading:zy,hideRightWindow:GD,hideTabBar:aD,hideTabBarRedDot:cD,hideToast:Gy,hideTopWindow:_D,interceptors:{},invokePushCallback:function(A){if("enabled"===A.type)ME=!0;else if("clientId"===A.type)wE=A.cid,SE=A.errMsg,TE(wE,A.errMsg);else if("pushMsg"===A.type){const e={type:"receive",data:RE(A.message)};for(let A=0;A{e({type:"click",data:RE(A.message)})})},loadFontFace:qy,login:wv,makePhoneCall:Kp,navigateBack:ry,navigateTo:sy,offAccelerometerChange:Bf,offAppHide:function(A){yE(lA,A)},offAppShow:function(A){yE(cA,A)},offCompassChange:yf,offError:function(A){yE(uA,A)},offLocationChange:iy,offLocationChangeError:ny,offNetworkStatusChange:Ef,offPageNotFound:function(A){yE(dA,A)},offPushMessage:A=>{if(A){const e=bE.indexOf(A);e>-1&&bE.splice(e,1)}else bE.length=0},offThemeChange:Gf,offUnhandledRejection:function(A){yE(hA,A)},offWindowResize:uE,onAccelerometerChange:Cf,onAppHide:function(A){mE(lA,A)},onAppShow:function(A){mE(cA,A)},onCompassChange:mf,onCreateVueApp:function(A){if(Ee)return A(Ee);de.push(A)},onError:function(A){mE(uA,A)},onGyroscopeChange:av,onLocaleChange:hE,onLocationChange:ty,onLocationChangeError:oy,onMemoryWarning:rv,onNetworkStatusChange:uf,onPageNotFound:function(A){mE(dA,A)},onPushMessage:A=>{-1===bE.indexOf(A)&&bE.push(A)},onSocketClose:Hm,onSocketError:Ym,onSocketMessage:Jm,onSocketOpen:Pm,onTabBarMidButtonTap:lE,onThemeChange:bf,onUnhandledRejection:function(A){mE(hA,A)},onUserCaptureScreen:mv,onWindowResize:IE,openDocument:jf,openLocation:Km,pageScrollTo:Xy,preloadPage:ay,previewImage:pm,reLaunch:Ih,redirectTo:ch,removeAllPages:lh,removeInterceptor:su,removeLastPage:gh,removeNonTabBarPages:nh,removeSavedFile:ov,removeStorage:Pf,removeStorageSync:xf,removeTabBarBadge:ID,request:Dm,rpx2px:iu,saveFile:XD,saveImageToPhotosAlbum:JD,saveVideoToPhotosAlbum:VD,scanCode:Ev,sendSocketMessage:Fm,setClipboardData:Tf,setKeepScreenOn:pv,setLeftWindowStyle:FD,setLocale:CE,setNavigationBarColor:Ky,setNavigationBarTitle:Zy,setPageMeta:BE,setRightWindowStyle:xD,setScreenBrightness:hv,setStorage:Lf,setStorageSync:kf,setTabBarBadge:uD,setTabBarItem:rD,setTabBarStyle:sD,setTopWindowStyle:LD,showActionSheet:Hy,showLeftWindow:TD,showLoading:by,showModal:Qy,showNavigationBarLoading:Wy,showRightWindow:bD,showTabBar:gD,showTabBarRedDot:lD,showToast:Ty,showTopWindow:RD,startAccelerometer:Qf,startCompass:Df,startGyroscope:cv,startLocationUpdate:Ay,startPullDownRefresh:$y,stopAccelerometer:pf,stopCompass:vf,stopGyroscope:Iv,stopLocationUpdate:ey,stopPullDownRefresh:AD,switchTab:ah,uploadFile:Nm,upx2px:iu,vibrateLong:Mf,vibrateShort:Sf},Symbol.toStringTag,{value:"Module"}),_v="MAP_LOCATION",Tv=Ul({name:"MapLocation",setup(){const A=Nt({latitude:0,longitude:0,rotate:0});{let e=function(e){A.rotate=e.direction},t=function(){qm({type:"gcj02",success:e=>{A.latitude=e.latitude,A.longitude=e.longitude},complete:()=>{n=setTimeout(t,3e4)}})},i=function(){n&&clearTimeout(n),yf(e)};const o=pn("onMapReady");let n;mf(e),o(t),Po(i);const r=pn("addMapChidlContext"),s=pn("removeMapChidlContext"),a={id:_v,state:A};r(a),Po(()=>s(a))}return()=>A.latitude?Ir(Fp,Qr({anchor:{x:.5,y:.5},width:"44",height:"44",iconPath:Rp},A),null,16,["iconPath"]):null}}),Nv=Ul({name:"MapPolygon",props:{dashArray:{type:Array,default:()=>[0,0]},points:{type:Array,required:!0},strokeWidth:{type:Number,default:1},strokeColor:{type:String,default:"#000000"},fillColor:{type:String,default:"#00000000"},zIndex:{type:Number,default:0}},setup(A){let e;return pn("onMapReady")((t,i,o)=>{function n(){const{points:o,strokeWidth:n,strokeColor:r,dashArray:s,fillColor:a,zIndex:g}=A,c=o.map(A=>{const{latitude:e,longitude:t}=A;return kp()?[t,e]:Lp()?new i.Point(t,e):new i.LatLng(e,t)}),{r:l,g:I,b:u,a:E}=Op(a),{r:d,g:h,b:C,a:B}=Op(r),Q={clickable:!0,cursor:"crosshair",editable:!1,map:t,fillColor:"",path:c,strokeColor:"",strokeDashStyle:s.some(A=>A>0)?"dash":"solid",strokeWeight:n,visible:!0,zIndex:g};i.Color?(Q.fillColor=new i.Color(l,I,u,E),Q.strokeColor=new i.Color(d,h,C,B)):(Q.fillColor=`rgb(${l}, ${I}, ${u})`,Q.fillOpacity=E,Q.strokeColor=`rgb(${d}, ${h}, ${C})`,Q.strokeOpacity=B),e?e.setOptions(Q):Lp()?(e=new i.Polygon(Q.path,Q),t.addOverlay(e)):e=new i.Polygon(Q)}n(),Xi(A,n)}),Po(()=>{e.setMap(null)}),()=>null}});function bv(A){const e=[];return C(A)&&A.forEach(A=>{A&&A.latitude&&A.longitude&&e.push({latitude:A.latitude,longitude:A.longitude})}),e}function Gv(A,e,t){return Lp()?function(A,e,t){return new A.Point(t,e)}(A,e,t):kp()?function(A,e,t){return new A.LngLat(t,e)}(A,e,t):function(A,e,t){return new A.LatLng(e,t)}(A,e,t)}function kv(A){return"getLat"in A?A.getLat():Lp()?A.lat:A.lat()}function Lv(A){return"getLng"in A?A.getLng():Lp()?A.lng:A.lng()}function Uv(A,e,t){const i=Ol(e,t),o=Kt(null);let n,r;const s=Nt({latitude:Number(A.latitude),longitude:Number(A.longitude),includePoints:bv(A.includePoints)}),a=[];let g,c;function l(A){g?A(r,n,i):a.push(A)}const I=[];function E(A){c?A():a.push(A)}const d={};function h(){c=!0,I.forEach(A=>A()),I.length=0}function C(){const A=r.getCenter();return{scale:r.getZoom(),centerLocation:{latitude:kv(A),longitude:Lv(A)}}}function B(){if(kp()){const A=[];s.includePoints.forEach(e=>{A.push([e.longitude,e.latitude])});const e=new n.Bounds(...A);r.setBounds(e)}else if(Lp());else{const A=new n.LatLngBounds;s.includePoints.forEach(({latitude:e,longitude:t})=>{const i=new n.LatLng(e,t);A.extend(i)}),r.fitBounds(A)}}function Q(){const e=o.value,a=Gv(n,s.latitude,s.longitude),g=n.event||n.Event,c=new n.Map(e,{center:a,zoom:Number(A.scale),disableDoubleClickZoom:!0,mapTypeControl:!1,zoomControl:!1,scaleControl:!1,panControl:!1,fullscreenControl:!1,streetViewControl:!1,keyboardShortcuts:!1,minZoom:5,maxZoom:18,draggable:!0});if(Lp()&&(c.centerAndZoom(a,Number(A.scale)),c.enableScrollWheelZoom(),c._printLog&&c._printLog("uniapp")),Xi(()=>A.scale,A=>{c.setZoom(Number(A)||16)}),E(()=>{s.includePoints.length&&(B(),function(){const A=Gv(n,s.latitude,s.longitude);r.setCenter(A)}())}),Lp())c.addEventListener("click",()=>{i("tap",{},{}),i("click",{},{})}),c.addEventListener("dragstart",()=>{i("regionchange",{},{type:"begin",causedBy:"gesture"})}),c.addEventListener("dragend",()=>{i("regionchange",{},u({type:"end",causedBy:"drag"},C()))});else{const A=g.addListener(c,"bounds_changed",()=>{A.remove(),h()});g.addListener(c,"complete",()=>{h()}),g.addListener(c,"click",()=>{i("tap",{},{}),i("click",{},{})}),g.addListener(c,"dragstart",()=>{i("regionchange",{},{type:"begin",causedBy:"gesture"})}),g.addListener(c,"dragend",()=>{i("regionchange",{},u({type:"end",causedBy:"drag"},C()))});const e=()=>{t("update:scale",c.getZoom()),i("regionchange",{},u({type:"end",causedBy:"scale"},C()))};g.addListener(c,"zoom_changed",e),g.addListener(c,"zoomend",e),g.addListener(c,"center_changed",()=>{const A=c.getCenter(),e=kv(A),i=Lv(A);t("update:latitude",e),t("update:longitude",i)})}return c}Xi([()=>A.latitude,()=>A.longitude],([A,e])=>{const t=Number(A),i=Number(e);if((t!==s.latitude||i!==s.longitude)&&(s.latitude=t,s.longitude=i,r)){const A=Gv(n,s.latitude,s.longitude);r.setCenter(A)}}),Xi(()=>A.includePoints,A=>{s.includePoints=bv(A),c&&B()},{deep:!0});try{LQ((A,e={})=>{switch(A){case"getCenterLocation":l(()=>{const t=r.getCenter();qA(e,{latitude:kv(t),longitude:Lv(t),errMsg:`${A}:ok`})});break;case"moveToLocation":{let t=Number(e.latitude),i=Number(e.longitude);if(!t||!i){const A=d[_v];A&&(t=A.state.latitude,i=A.state.longitude)}if(t&&i){if(s.latitude=t,s.longitude=i,r){const A=Gv(n,t,i);r.setCenter(A)}l(()=>{qA(e,`${A}:ok`)})}else qA(e,`${A}:fail`)}break;case"translateMarker":l(()=>{const t=d[e.markerId];if(t){try{t.translate(e)}catch(i){qA(e,`${A}:fail ${i.message}`)}qA(e,`${A}:ok`)}else qA(e,`${A}:fail not found`)});break;case"includePoints":s.includePoints=bv(e.includePoints),(c||kp())&&B(),E(()=>{qA(e,`${A}:ok`)});break;case"getRegion":E(()=>{const t=r.getBounds(),i=t.getSouthWest(),o=t.getNorthEast();qA(e,{southwest:{latitude:kv(i),longitude:Lv(i)},northeast:{latitude:kv(o),longitude:Lv(o)},errMsg:`${A}:ok`})});break;case"getScale":l(()=>{qA(e,{scale:r.getZoom(),errMsg:`${A}:ok`})})}},FQ(),!0)}catch(p){}return Uo(()=>{wp(A.libraries,A=>{n=A,r=Q(),g=!0,a.forEach(A=>A(r,n,i)),a.length=0,i("updated",{},{})})}),Qn("onMapReady",l),Qn("addMapChidlContext",function(A){d[A.id]=A}),Qn("removeMapChidlContext",function(A){delete d[A.id]}),{state:s,mapRef:o,trigger:i}}const Fv=Ll({name:"Map",props:{id:{type:String,default:""},latitude:{type:[String,Number],default:0},longitude:{type:[String,Number],default:0},scale:{type:[String,Number],default:16},markers:{type:Array,default:()=>[]},includePoints:{type:Array,default:()=>[]},polyline:{type:Array,default:()=>[]},circles:{type:Array,default:()=>[]},controls:{type:Array,default:()=>[]},showLocation:{type:[Boolean,String],default:!1},libraries:{type:Array,default:()=>[]},polygons:{type:Array,default:()=>[]}},emits:["markertap","labeltap","callouttap","controltap","regionchange","tap","click","updated","update:scale","update:latitude","update:longitude"],setup(A,{emit:e,slots:t}){const i=Kt(null),{mapRef:o,trigger:n}=Uv(A,i,e);return()=>Ir("uni-map",{ref:i,id:A.id},[Ir("div",{ref:o,style:"width: 100%; height: 100%; position: relative; overflow: hidden"},null,512),A.markers.map(A=>Ir(Fp,Qr({key:A.id},A),null,16)),A.polyline.map(A=>Ir(Pp,A,null,16)),A.circles.map(A=>Ir(Yp,A,null,16)),A.controls.map(A=>Ir(Hp,Qr(A,{trigger:n}),null,16,["trigger"])),A.showLocation&&Ir(Tv,null,null),A.polygons.map(A=>Ir(Nv,A,null,16)),Ir("div",{style:"position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"},[t.default&&t.default()])],8,["id"])}}),Ov=u(gc,{publishHandler(A,e,t){Pv.subscribeHandler(A,e,t)}}),xv=Rv,Pv=u(yl,{publishHandler(A,e,t){Ov.subscribeHandler(A,e,t)}}),Yv=Ul({name:"PageHead",setup(){const A=Kt(null),e=$l(),t=Iy(e.navigationBar,()=>{const A=ly(e.navigationBar);t.backgroundColor=A.backgroundColor,t.titleColor=A.titleColor}),{clazz:i,style:o}=function(A){const e=Ur(()=>{const{type:e,titlePenetrate:t,shadowColorType:i}=A,o={"uni-page-head":!0,"uni-page-head-transparent":"transparent"===e,"uni-page-head-titlePenetrate":"YES"===t,"uni-page-head-shadow":!!i};return i&&(o[`uni-page-head-shadow-${i}`]=!0),o}),t=Ur(()=>({backgroundColor:A.backgroundColor,color:A.titleColor,transitionDuration:A.duration,transitionTimingFunction:A.timingFunc}));return{clazz:e,style:t}}(t);return()=>{const n=function(A,e){if(!e)return Ir("div",{class:"uni-page-head-btn",onClick:Hv},[jc(Hc,"transparent"===A.type?"#fff":A.titleColor,26)],8,["onClick"])}(t,e.isQuit),r=t.type||"default",s="transparent"!==r&&"float"!==r&&Ir("div",{class:{"uni-placeholder":!0,"uni-placeholder-titlePenetrate":t.titlePenetrate}},null,2);return Ir("uni-page-head",{"uni-page-head-type":r},[Ir("div",{ref:A,class:i.value,style:o.value},[Ir("div",{class:"uni-page-head-hd"},[n]),Jv(t),Ir("div",{class:"uni-page-head-ft"},[])],6),s],8,["uni-page-head-type"])}}});function Jv(A,e){return function({type:A,loading:e,titleSize:t,titleText:i,titleImage:o}){return Ir("div",{class:"uni-page-head-bd"},[Ir("div",{style:{fontSize:t,opacity:"transparent"===A?0:1},class:"uni-page-head__title"},[e?Ir("i",{class:"uni-loading"},null):o?Ir("img",{src:o,class:"uni-page-head__title_image"},null,8,["src"]):i],4)])}(A)}function Hv(){1===Lh().length?uni.reLaunch({url:"/"}):uni.navigateBack({from:"backbutton",success(){}})}const qv=Ul({name:"PageBody",setup(A,e){const t=!1,i=Kt(null),o=Kt(null);return Xi(()=>t.enablePullDownRefresh,()=>{o.value=null},{immediate:!0}),()=>Ir(Kn,null,[!1,Ir("uni-page-wrapper",Qr({ref:i},o.value),[Ir("uni-page-body",null,[jo(e.slots,"default")]),null],16)])}}),Vv=Ul({name:"Page",setup(A,e){let t=AI(tI());const i=t.navigationBar,o={};return Vy(t),()=>Ir("uni-page",{"data-page":t.route,style:o},"custom"!==i.style?[Ir(Yv),jv(e),null]:[jv(e),null])}});function jv(A){return Ar(),nr(qv,{key:0},{default:Ui(()=>[jo(A.slots,"page")]),_:3})}const Kv={loading:"AsyncLoading",error:"AsyncError",delay:200,timeout:6e4,suspensible:!0};window.getApp=np,window.getCurrentPages=Lh,window.wx=xv,window.uni=xv,window.UniViewJSBridge=Ov,window.UniServiceJSBridge=Pv,window.rpx2px=iu,window.__setupPage=A=>gp(A);const Wv=Object.assign({}),zv=Object.assign;window.__uniConfig=zv({globalStyle:{backgroundColor:"#F8F8F8",navigationBar:{backgroundColor:"#F8F8F8",titleText:"uni-app",type:"default",titleColor:"#000000"},isNVue:!1},uniIdRouter:{},tabBar:{position:"bottom",color:"#333333",selectedColor:"#00D993",borderStyle:"black",blurEffect:"none",fontSize:"10px",iconWidth:"24px",spacing:"3px",height:"50px",list:[{pagePath:"TUIKit/components/TUIConversation/index",iconPath:"/static/images/tabBar/news.png",selectedIconPath:"/static/images/tabBar/newsHL.png",text:"消息"},{pagePath:"TUIKit/components/TUIContact/index",iconPath:"/static/images/tabBar/contacts.png",selectedIconPath:"/static/images/tabBar/contactsHL.png",text:"通讯录"},{pagePath:"pages/discover/discover",iconPath:"/static/images/tabBar/discover.png",selectedIconPath:"/static/images/tabBar/discoverHL.png",text:"发现"},{pagePath:"pages/my-index/my-index",iconPath:"/static/images/tabBar/my.png",selectedIconPath:"/static/images/tabBar/myHL.png",text:"我的"}],backgroundColor:"#ffffff",selectedIndex:0,shown:!0},compilerVersion:"4.87"},{appId:"__UNI__9EFDC69",appName:"密谈IM",appVersion:"1.1.2",appVersionCode:111,async:Kv,debug:!1,networkTimeout:{request:6e4,connectSocket:6e4,uploadFile:6e4,downloadFile:6e4},sdkConfigs:{},qqMapKey:void 0,bMapKey:void 0,googleMapKey:void 0,aMapKey:void 0,aMapSecurityJsCode:void 0,aMapServiceHost:void 0,nvue:{"flex-direction":"column"},locale:"",fallbackLocale:"",locales:Object.keys(Wv).reduce((A,e)=>{const t=e.replace(/\.\/locale\/(uni-app.)?(.*).json/,"$2");return zv(A[t]||(A[t]={}),Wv[e].default),A},{}),router:{mode:"history",base:"/",assets:"assets",routerBase:"/"},darkmode:!1,themeConfig:{}}),window.__uniLayout=window.__uniLayout||{};const Zv={delay:Kv.delay,timeout:Kv.timeout,suspensible:Kv.suspensible};Kv.loading&&(Zv.loadingComponent={name:"SystemAsyncLoading",render:()=>Ir(Ji(Kv.loading))}),Kv.error&&(Zv.errorComponent={name:"SystemAsyncError",props:["error"],render(){return Ir(Ji(Kv.error),{error:this.error})}});const Xv=()=>n(()=>import("./TUIKit-components-TUIConversation-index.BszPXyYX.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(A=>gp(A.default||A)),$v=Qo(zv({loader:Xv},Zv)),Aw=()=>n(()=>import("./pages-index-index.CPHuv6KV.js"),__vite__mapDeps([9,3,10])).then(A=>gp(A.default||A)),ew=Qo(zv({loader:Aw},Zv)),tw=()=>n(()=>import("./pages-login-login.BEiUK2v9.js"),__vite__mapDeps([11,12,3,13,14,15,16])).then(A=>gp(A.default||A)),iw=Qo(zv({loader:tw},Zv)),ow=()=>n(()=>import("./TUIKit-components-TUIChat-index.Cj26Cu3T.js"),__vite__mapDeps([17,6,3,2,18,4,19,7,8,20,21,22,23])).then(A=>gp(A.default||A)),nw=Qo(zv({loader:ow},Zv)),rw=()=>n(()=>import("./TUIKit-components-TUIContact-index.CgQjlOy-.js"),__vite__mapDeps([24,6,3,2,18,19,25,26])).then(A=>gp(A.default||A)),sw=Qo(zv({loader:rw},Zv)),aw=()=>n(()=>import("./TUIKit-components-TUIChat-video-play.DUkcS_xe.js"),__vite__mapDeps([27,3,28])).then(A=>gp(A.default||A)),gw=Qo(zv({loader:aw},Zv)),cw=()=>n(()=>import("./TUIKit-components-TUIChat-web-view.DjFpSr5x.js"),[]).then(A=>gp(A.default||A)),lw=Qo(zv({loader:cw},Zv)),Iw=()=>n(()=>import("./TUIKit-components-TUIGroup-index.BRKduKr7.js"),__vite__mapDeps([29,6,3,2,18,15,30,23,31,32,33,8,5])).then(A=>gp(A.default||A)),uw=Qo(zv({loader:Iw},Zv)),Ew=()=>n(()=>import("./TUIKit-components-TUISearch-index.Cp_ZmtC_.js"),__vite__mapDeps([1,2,3,4,5])).then(A=>gp(A.default||A)),dw=Qo(zv({loader:Ew},Zv)),hw=()=>n(()=>import("./pages-login-protocol.Bs-wFh3A.js"),__vite__mapDeps([34,35,36,3,37,38])).then(A=>gp(A.default||A)),Cw=Qo(zv({loader:hw},Zv)),Bw=()=>n(()=>import("./pages-login-regime.CZSj_SSM.js"),__vite__mapDeps([39,35,36,3,37,38])).then(A=>gp(A.default||A)),Qw=Qo(zv({loader:Bw},Zv)),pw=()=>n(()=>import("./pages-login-phone-register-phone-register.BJYIh-2W.js"),__vite__mapDeps([40,41,12,3,13,14,15,33,42])).then(A=>gp(A.default||A)),fw=Qo(zv({loader:pw},Zv)),mw=()=>n(()=>import("./pages-login-email-register-email-register.DTGXQvI-.js"),__vite__mapDeps([43,41,12,3,13,14,15,33,42])).then(A=>gp(A.default||A)),yw=Qo(zv({loader:mw},Zv)),Dw=()=>n(()=>import("./pages-login-forgot-password-forgot-password.iEKGXf-P.js"),__vite__mapDeps([44,45,22,3,46,15,47])).then(A=>gp(A.default||A)),vw=Qo(zv({loader:Dw},Zv)),ww=()=>n(()=>import("./pages-news-list-news-list.D49CpDuO.js"),__vite__mapDeps([48,3,49])).then(A=>gp(A.default||A)),Sw=Qo(zv({loader:ww},Zv)),Mw=()=>n(()=>import("./pages-contacts-contacts.QOLJfbpO.js"),__vite__mapDeps([50,3])).then(A=>gp(A.default||A)),Rw=Qo(zv({loader:Mw},Zv)),_w=()=>n(()=>import("./pages-discover-discover.c6wbTgZH.js"),__vite__mapDeps([51,45,22,3,46,52,53])).then(A=>gp(A.default||A)),Tw=Qo(zv({loader:_w},Zv)),Nw=()=>n(()=>import("./pages-my-index-my-index.DOYn2rp7.js"),__vite__mapDeps([54,22,3,52,55,56])).then(A=>gp(A.default||A)),bw=Qo(zv({loader:Nw},Zv)),Gw=()=>n(()=>import("./pages-my-index-withdraw.CapE4pOy.js"),__vite__mapDeps([57,45,22,3,46,21,23,15,30,58])).then(A=>gp(A.default||A)),kw=Qo(zv({loader:Gw},Zv)),Lw=()=>n(()=>import("./pages-my-index-recharge.CEeDSxv1.js"),[]).then(A=>gp(A.default||A)),Uw=Qo(zv({loader:Lw},Zv)),Fw=()=>n(()=>import("./pages-my-index-personal-center-index.B02LHm_D.js"),__vite__mapDeps([59,45,22,3,46,60,61,62,63,64,65,23,66,31,32,67])).then(A=>gp(A.default||A)),Ow=Qo(zv({loader:Fw},Zv)),xw=()=>n(()=>import("./pages-my-index-qr-code-index.DRou2cTk.js"),__vite__mapDeps([68,22,3,69,70,71])).then(A=>gp(A.default||A)),Pw=Qo(zv({loader:xw},Zv)),Yw=()=>n(()=>import("./pages-my-index-wallet-index.BNWBEX42.js"),__vite__mapDeps([72,22,3,55,73])).then(A=>gp(A.default||A)),Jw=Qo(zv({loader:Yw},Zv)),Hw=()=>n(()=>import("./pages-my-index-wallet-edit-password.-UUZYFNq.js"),__vite__mapDeps([74,45,22,3,46,15,30,75,76,33,77])).then(A=>gp(A.default||A)),qw=Qo(zv({loader:Hw},Zv)),Vw=()=>n(()=>import("./pages-my-index-wallet-bank-card-index.PFhmLgX-.js"),__vite__mapDeps([78,22,3,79,80,15,30,81])).then(A=>gp(A.default||A)),jw=Qo(zv({loader:Vw},Zv)),Kw=()=>n(()=>import("./pages-my-index-wallet-record.D_lL5Nwj.js"),__vite__mapDeps([82,83,3,84,85])).then(A=>gp(A.default||A)),Ww=Qo(zv({loader:Kw},Zv)),zw=()=>n(()=>import("./pages-my-index-wallet-withdrawal-record.DuDcBPvX.js"),__vite__mapDeps([86,82,83,3,84,85])).then(A=>gp(A.default||A)),Zw=Qo(zv({loader:zw},Zv)),Xw=()=>n(()=>import("./pages-my-index-wallet-real-id.BFaxXf6n.js"),__vite__mapDeps([87,88,22,3,62,32,89,15,30,90,75,76,33,20,91])).then(A=>gp(A.default||A)),$w=Qo(zv({loader:Xw},Zv)),AS=()=>n(()=>import("./pages-my-index-wallet-invite.43_63nes.js"),__vite__mapDeps([92,3,93])).then(A=>gp(A.default||A)),eS=Qo(zv({loader:AS},Zv)),tS=()=>n(()=>import("./pages-my-index-my-team.B_8YBLDl.js"),__vite__mapDeps([94,3,95])).then(A=>gp(A.default||A)),iS=Qo(zv({loader:tS},Zv)),oS=()=>n(()=>import("./pages-my-index-collection-index.BarD2mgC.js"),__vite__mapDeps([96,97,3,98,99])).then(A=>gp(A.default||A)),nS=Qo(zv({loader:oS},Zv)),rS=()=>n(()=>import("./pages-my-index-meeting-record-index.D2RST8Fq.js"),__vite__mapDeps([100,83,3,84,20,101])).then(A=>gp(A.default||A)),sS=Qo(zv({loader:rS},Zv)),aS=()=>n(()=>import("./pages-my-index-meeting-record-details.BQke5n7a.js"),__vite__mapDeps([102,90,20,3,103])).then(A=>gp(A.default||A)),gS=Qo(zv({loader:aS},Zv)),cS=()=>n(()=>import("./pages-my-index-customer-service-index.Bk6n0xIk.js"),__vite__mapDeps([104,3,105])).then(A=>gp(A.default||A)),lS=Qo(zv({loader:cS},Zv)),IS=()=>n(()=>import("./pages-my-index-customer-service-third-party._NAOEpxm.js"),__vite__mapDeps([106,3,107])).then(A=>gp(A.default||A)),uS=Qo(zv({loader:IS},Zv)),ES=()=>n(()=>import("./pages-my-index-set-up-index.UbHnzgRh.js"),__vite__mapDeps([108,22,3,109])).then(A=>gp(A.default||A)),dS=Qo(zv({loader:ES},Zv)),hS=()=>n(()=>import("./pages-my-index-set-up-feedback.xX9KgCfY.js"),__vite__mapDeps([110,61,62,63,3,64,65,88,22,32,89,15,30,75,76,111])).then(A=>gp(A.default||A)),CS=Qo(zv({loader:hS},Zv)),BS=()=>n(()=>import("./pages-my-index-set-up-message-index.BBKyTkW6.js"),__vite__mapDeps([112,22,3,83,84,113])).then(A=>gp(A.default||A)),QS=Qo(zv({loader:BS},Zv)),pS=()=>n(()=>import("./pages-my-index-set-up-message-details.BTWbrRMX.js"),__vite__mapDeps([114,3,115])).then(A=>gp(A.default||A)),fS=Qo(zv({loader:pS},Zv)),mS=()=>n(()=>import("./pages-my-index-set-up-font-settings.DobbslTk.js"),__vite__mapDeps([116,3,117])).then(A=>gp(A.default||A)),yS=Qo(zv({loader:mS},Zv)),DS=()=>n(()=>import("./pages-my-index-wallet-bank-card-card-details.Bm01r185.js"),__vite__mapDeps([118,45,22,3,46,61,62,63,64,65,88,32,89,15,30,75,76,119])).then(A=>gp(A.default||A)),vS=Qo(zv({loader:DS},Zv)),wS=()=>n(()=>import("./pages-mall-list.Zn1WXIRv.js"),__vite__mapDeps([120,97,3,98,83,84,121,122])).then(A=>gp(A.default||A)),SS=Qo(zv({loader:wS},Zv)),MS=()=>n(()=>import("./pages-mall-detail.CblNjsth.js"),__vite__mapDeps([123,45,22,3,46,36,37,15,30,23,19,124,52,121,125,126])).then(A=>gp(A.default||A)),RS=Qo(zv({loader:MS},Zv)),_S=()=>n(()=>import("./pages-mall-comment.BQjKcHti.js"),__vite__mapDeps([127,22,3,128,129,15,30,83,84,121,130])).then(A=>gp(A.default||A)),TS=Qo(zv({loader:_S},Zv)),NS=()=>n(()=>import("./pages-mall-add-comment.vAYbyeKS.js"),__vite__mapDeps([131,128,22,3,129,88,62,32,89,15,30,75,76,121,132])).then(A=>gp(A.default||A)),bS=Qo(zv({loader:NS},Zv)),GS=()=>n(()=>import("./pages-mall-confirm-order.UGvFmQVy.js"),__vite__mapDeps([133,21,22,3,23,15,30,52,13,121,55,134])).then(A=>gp(A.default||A)),kS=Qo(zv({loader:GS},Zv)),LS=()=>n(()=>import("./pages-address-index._M3e2_64.js"),__vite__mapDeps([135,45,22,3,46,25,79,80,136])).then(A=>gp(A.default||A)),US=Qo(zv({loader:LS},Zv)),FS=()=>n(()=>import("./pages-address-add.dms2Ecga.js"),__vite__mapDeps([137,22,3,15,30,13,33,138])).then(A=>gp(A.default||A)),OS=Qo(zv({loader:FS},Zv)),xS=()=>n(()=>import("./pages-address-edit.DLXKbCuF.js"),__vite__mapDeps([139,137,22,3,15,30,13,33,138])).then(A=>gp(A.default||A)),PS=Qo(zv({loader:xS},Zv)),YS=()=>n(()=>import("./pages-shop-together-index.Dx0FPcJD.js"),__vite__mapDeps([140,25,3,121,141,142])).then(A=>gp(A.default||A)),JS=Qo(zv({loader:YS},Zv)),HS=()=>n(()=>import("./pages-shop-together-detail.Ct4MfSi8.js"),__vite__mapDeps([143,63,3,64,22,15,30,141,121,144])).then(A=>gp(A.default||A)),qS=Qo(zv({loader:HS},Zv)),VS=()=>n(()=>import("./pages-shop-together-share.Axv3RveS.js"),__vite__mapDeps([145,45,22,3,46,69,70,146])).then(A=>gp(A.default||A)),jS=Qo(zv({loader:VS},Zv)),KS=()=>n(()=>import("./pages-discover-ranking-list.C2kuznWx.js"),__vite__mapDeps([147,45,22,3,46,124,55,148])).then(A=>gp(A.default||A)),WS=Qo(zv({loader:KS},Zv)),zS=()=>n(()=>import("./pages-discover-punch.Ch-zxBXH.js"),__vite__mapDeps([149,45,22,3,46,124,125,55,150])).then(A=>gp(A.default||A)),ZS=Qo(zv({loader:zS},Zv)),XS=()=>n(()=>import("./pages-discover-dynamic-dynamic.BodfEZND.js"),__vite__mapDeps([151,22,3,45,46,83,84,125,152])).then(A=>gp(A.default||A)),$S=Qo(zv({loader:XS},Zv)),AM=()=>n(()=>import("./pages-discover-dynamic-release.Bw945Ce1.js"),__vite__mapDeps([153,45,22,3,46,88,62,32,89,154])).then(A=>gp(A.default||A)),eM=Qo(zv({loader:AM},Zv)),tM=()=>n(()=>import("./pages-discover-company.AOV1WuNg.js"),__vite__mapDeps([155,36,3,37,156])).then(A=>gp(A.default||A)),iM=Qo(zv({loader:tM},Zv)),oM=()=>n(()=>import("./TUIKit-components-TUIChat-message-input-toolbar-live-stream-apply.7tHisfN7.js"),__vite__mapDeps([157,45,22,3,46,87,88,62,32,89,15,30,90,75,76,33,20,91,158])).then(A=>gp(A.default||A)),nM=Qo(zv({loader:oM},Zv)),rM=()=>n(()=>import("./pages-adduser-index.DHRZRLuI.js"),__vite__mapDeps([159,22,3,25,160])).then(A=>gp(A.default||A)),sM=Qo(zv({loader:rM},Zv)),aM=()=>n(()=>import("./pages-adduser-details.ChC6QT93.js"),__vite__mapDeps([161,22,3,15,30,60,61,62,63,64,65,23,66,26,162])).then(A=>gp(A.default||A)),gM=Qo(zv({loader:aM},Zv)),cM=()=>n(()=>import("./pages-red-packet-details.DrAaMcdz.js"),__vite__mapDeps([163,22,3,45,46,63,64,20,164])).then(A=>gp(A.default||A)),lM=Qo(zv({loader:cM},Zv));function IM(A,e){return Ar(),nr(Vv,null,{page:Ui(()=>[Ir(A,zv({},e,{ref:"page"}),null,512)]),_:1})}function uM(A,e){return"string"==typeof A?e:A}window.__uniRoutes=[{path:"/",alias:"/TUIKit/components/TUIConversation/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM($v,e)}},loader:Xv,meta:{isQuit:!0,isEntry:!0,isTabBar:!0,tabBarIndex:0,navigationBar:{style:"custom",type:"default"},isNVue:!1}},{path:"/pages/index/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(ew,e)}},loader:Aw,meta:{navigationBar:{titleText:"首页",type:"default"},isNVue:!1}},{path:"/pages/login/login",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(iw,e)}},loader:tw,meta:{navigationBar:{titleText:"登录",style:"custom",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIChat/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(nw,e)}},loader:ow,meta:{softinputMode:"adjustResize",navigationBar:{style:"custom",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIContact/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(sw,e)}},loader:rw,meta:{isQuit:!0,isTabBar:!0,tabBarIndex:1,navigationBar:{style:"custom",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIChat/video-play",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(gw,e)}},loader:aw,meta:{navigationBar:{backgroundColor:"#EBF0F6",titleText:"腾讯云 IM",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIChat/web-view",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(lw,e)}},loader:cw,meta:{navigationBar:{backgroundColor:"#EBF0F6",titleText:"腾讯云 IM",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIGroup/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(uw,e)}},loader:Iw,meta:{navigationBar:{style:"custom",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUISearch/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(dw,e)}},loader:Ew,meta:{navigationBar:{backgroundColor:"#EBF0F6",titleText:"聊天记录",type:"default"},isNVue:!1}},{path:"/pages/login/protocol",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Cw,e)}},loader:hw,meta:{navigationBar:{titleText:"用户权益",type:"default"},isNVue:!1}},{path:"/pages/login/regime",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Qw,e)}},loader:Bw,meta:{navigationBar:{titleText:"隐私政策",type:"default"},isNVue:!1}},{path:"/pages/login/phone-register/phone-register",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(fw,e)}},loader:pw,meta:{navigationBar:{titleText:"手机注册",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/login/email-register/email-register",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(yw,e)}},loader:mw,meta:{navigationBar:{titleText:"邮箱注册",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/login/forgot-password/forgot-password",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(vw,e)}},loader:Dw,meta:{navigationBar:{titleText:"忘记密码",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/news-list/news-list",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Sw,e)}},loader:ww,meta:{navigationBar:{titleText:"消息",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/contacts/contacts",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Rw,e)}},loader:Mw,meta:{navigationBar:{titleText:"通讯录",type:"default"},isNVue:!1}},{path:"/pages/discover/discover",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Tw,e)}},loader:_w,meta:{isQuit:!0,isTabBar:!0,tabBarIndex:2,navigationBar:{backgroundColor:"#ffffff",titleText:"发现",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/my-index/my-index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(bw,e)}},loader:Nw,meta:{isQuit:!0,isTabBar:!0,tabBarIndex:3,backgroundColor:"#f7f7f7",navigationBar:{backgroundColor:"#ffffff",titleText:"我的",type:"default"},isNVue:!1}},{path:"/pages/my-index/withdraw",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(kw,e)}},loader:Gw,meta:{navigationBar:{titleText:"提现",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/my-index/recharge",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Uw,e)}},loader:Lw,meta:{backgroundColor:"#f7f7f7",navigationBar:{titleText:"充值",type:"default"},isNVue:!1}},{path:"/pages/my-index/personal-center/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Ow,e)}},loader:Fw,meta:{navigationBar:{titleText:"个人中心",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/my-index/qr-code/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Pw,e)}},loader:xw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Jw,e)}},loader:Yw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"钱包",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/edit-password",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(qw,e)}},loader:Hw,meta:{navigationBar:{titleText:"修改钱包密码",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/bank-card/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(jw,e)}},loader:Vw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"提现卡",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/record",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Ww,e)}},loader:Kw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"积分记录",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/withdrawal-record",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(Zw,e)}},loader:zw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"提现记录",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/real-id",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM($w,e)}},loader:Xw,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"实名认证",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/invite",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(eS,e)}},loader:AS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"邀请好友",type:"default"},isNVue:!1}},{path:"/pages/my-index/my-team",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(iS,e)}},loader:tS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"我的团队",type:"default"},isNVue:!1}},{path:"/pages/my-index/collection/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(nS,e)}},loader:oS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"收藏",type:"default"},isNVue:!1}},{path:"/pages/my-index/meeting-record/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(sS,e)}},loader:rS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"直播记录",type:"default"},isNVue:!1}},{path:"/pages/my-index/meeting-record/details",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(gS,e)}},loader:aS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"会议详情",type:"default"},isNVue:!1}},{path:"/pages/my-index/customer-service/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(lS,e)}},loader:cS,meta:{navigationBar:{titleText:"客服",type:"default"},isNVue:!1}},{path:"/pages/my-index/customer-service/third-party",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(uS,e)}},loader:IS,meta:{navigationBar:{titleText:"第三方客服",type:"default"},isNVue:!1}},{path:"/pages/my-index/set-up/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(dS,e)}},loader:ES,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"设置",type:"default"},isNVue:!1}},{path:"/pages/my-index/set-up/feedback",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(CS,e)}},loader:hS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"意见反馈",type:"default"},isNVue:!1}},{path:"/pages/my-index/set-up/message/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(QS,e)}},loader:BS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"消息通知",type:"default"},isNVue:!1}},{path:"/pages/my-index/set-up/message/details",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(fS,e)}},loader:pS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"通知详情",type:"default"},isNVue:!1}},{path:"/pages/my-index/set-up/font-settings",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(yS,e)}},loader:mS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"字体设置",type:"default"},isNVue:!1}},{path:"/pages/my-index/wallet/bank-card/card-details",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(vS,e)}},loader:DS,meta:{navigationBar:{titleText:"卡信息增删改查",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/mall/list",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(SS,e)}},loader:wS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"商城",type:"default"},isNVue:!1}},{path:"/pages/mall/detail",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(RS,e)}},loader:MS,meta:{navigationBar:{titleText:"商品详情",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/mall/comment",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(TS,e)}},loader:_S,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"评价",type:"default"},isNVue:!1}},{path:"/pages/mall/add-comment",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(bS,e)}},loader:NS,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"添加评价",type:"default"},isNVue:!1}},{path:"/pages/mall/confirm-order",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(kS,e)}},loader:GS,meta:{navigationBar:{titleText:"确认订单",type:"default"},isNVue:!1}},{path:"/pages/address/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(US,e)}},loader:LS,meta:{navigationBar:{titleText:"我的地址",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/address/add",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(OS,e)}},loader:FS,meta:{navigationBar:{titleText:"添加地址",type:"default"},isNVue:!1}},{path:"/pages/address/edit",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(PS,e)}},loader:xS,meta:{navigationBar:{titleText:"修改地址",type:"default"},isNVue:!1}},{path:"/pages/shop-together/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(JS,e)}},loader:YS,meta:{navigationBar:{titleText:"我的拼团",type:"default"},isNVue:!1}},{path:"/pages/shop-together/detail",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(qS,e)}},loader:HS,meta:{navigationBar:{titleText:"拼团记录",type:"default"},isNVue:!1}},{path:"/pages/shop-together/share",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(jS,e)}},loader:VS,meta:{navigationBar:{style:"custom",type:"default"},isNVue:!1}},{path:"/pages/discover/ranking-list",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(WS,e)}},loader:KS,meta:{navigationBar:{titleText:"排行榜",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/discover/punch",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(ZS,e)}},loader:zS,meta:{navigationBar:{titleText:"签到",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/discover/dynamic/dynamic",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM($S,e)}},loader:XS,meta:{navigationBar:{titleText:"朋友圈",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/discover/dynamic/release",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(eM,e)}},loader:AM,meta:{navigationBar:{titleText:"发布朋友圈",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/discover/company",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(iM,e)}},loader:tM,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"公司介绍",type:"default"},isNVue:!1}},{path:"/TUIKit/components/TUIChat/message-input-toolbar/live-stream/apply",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(nM,e)}},loader:oM,meta:{navigationBar:{titleText:"直播",style:"custom",type:"default"},isNVue:!1}},{path:"/pages/adduser/index",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(sM,e)}},loader:rM,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"添加朋友/群组",type:"default"},isNVue:!1}},{path:"/pages/adduser/details",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(gM,e)}},loader:aM,meta:{navigationBar:{backgroundColor:"#ffffff",titleText:"发送好友申请",type:"default"},isNVue:!1}},{path:"/pages/red-packet/details",component:{setup(){const A=np(),e=A&&A.$route&&A.$route.query||{};return()=>IM(lM,e)}},loader:cM,meta:{navigationBar:{titleText:"红包详情",style:"custom",type:"default"},isNVue:!1}}].map(A=>(A.meta.route=(A.alias||A.path).slice(1),A));const EM=(A,e=0)=>(e,t=Dr())=>{!Tr&&Go(A,e,t)},dM=EM(cA,3),hM=EM(lA,3),CM=EM(IA,1),BM=EM(CA,2),QM=EM(BA,2),pM=EM(QA,2),fM=EM(DA,2),mM=(A,e)=>{if(!e||0===Object.keys(e).length)return A;const t=Object.entries(e).map(([A,e])=>`${A}=${e="object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}`).join("&");return A.includes("?")?`${A}&${t}`:`${A}?${t}`},yM=(A,e={})=>{const t=mM(A,e);return uni.navigateTo({url:t})},DM=(A,e={})=>{const t=mM(A,e);return uni.reLaunch({url:t})},vM=(A=1)=>uni.navigateBack({delta:A}),wM=(A,e={})=>(Object.keys(e).length>0&&console.warn("switchTab 不支持携带参数,请使用全局状态或 storage 传递"),uni.switchTab({url:A})); /*! * pinia v2.1.7 * (c) 2023 Eduardo San Martin Morote * @license MIT */ let SM;const MM=A=>SM=A,RM=Symbol();function _M(A){return A&&"object"==typeof A&&"[object Object]"===Object.prototype.toString.call(A)&&"function"!=typeof A.toJSON}var TM,NM;(NM=TM||(TM={})).direct="direct",NM.patchObject="patch object",NM.patchFunction="patch function";const bM="undefined"!=typeof window;function GM(){const A=ve(!0),e=A.run(()=>Kt({}));let t=[],i=[];const o=Pt({install(A){MM(o),o._a=A,A.provide(RM,o),A.config.globalProperties.$pinia=o,i.forEach(A=>t.push(A)),i=[]},use(A){return this._a?t.push(A):i.push(A),this},_p:t,_a:null,_e:A,_s:new Map,state:e});return o}const kM=()=>{};function LM(A,e,t,i=kM){A.push(e);const o=()=>{const t=A.indexOf(e);t>-1&&(A.splice(t,1),i())};var n;return!t&&we()&&(n=o,me&&me.cleanups.push(n)),o}function UM(A,...e){A.slice().forEach(A=>{A(...e)})}const FM=A=>A();function OM(A,e){A instanceof Map&&e instanceof Map&&e.forEach((e,t)=>A.set(t,e)),A instanceof Set&&e instanceof Set&&e.forEach(A.add,A);for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t],o=A[t];_M(o)&&_M(i)&&A.hasOwnProperty(t)&&!jt(i)&&!Lt(i)?A[t]=OM(o,i):A[t]=i}return A}const xM=Symbol();function PM(A){return!_M(A)||!A.hasOwnProperty(xM)}const{assign:YM}=Object;function JM(A){return!(!jt(A)||!A.effect)}function HM(A,e,t={},i,o,n){let r;const s=YM({actions:{}},t),a={deep:!0};let g,c,l,I=[],u=[];const E=i.state.value[A];let d;function h(e){let t;g=c=!1,"function"==typeof e?(e(i.state.value[A]),t={type:TM.patchFunction,storeId:A,events:l}):(OM(i.state.value[A],e),t={type:TM.patchObject,payload:e,storeId:A,events:l});const o=d=Symbol();pi().then(()=>{d===o&&(g=!0)}),c=!0,UM(I,t,i.state.value[A])}n||E||(i.state.value[A]={}),Kt({});const C=n?function(){const{state:A}=t,e=A?A():{};this.$patch(A=>{YM(A,e)})}:kM;function B(e,t){return function(){MM(i);const o=Array.from(arguments),n=[],r=[];let s;UM(u,{args:o,name:e,store:Q,after:function(A){n.push(A)},onError:function(A){r.push(A)}});try{s=t.apply(this&&this.$id===A?this:Q,o)}catch(a){throw UM(r,a),a}return s instanceof Promise?s.then(A=>(UM(n,A),A)).catch(A=>(UM(r,A),Promise.reject(A))):(UM(n,s),s)}}const Q=Nt({_p:i,$id:A,$onAction:LM.bind(null,u),$patch:h,$reset:C,$subscribe(e,t={}){const o=LM(I,e,t.detached,()=>n()),n=r.run(()=>Xi(()=>i.state.value[A],i=>{("sync"===t.flush?c:g)&&e({storeId:A,type:TM.direct,events:l},i)},YM({},a,t)));return o},$dispose:function(){r.stop(),I=[],u=[],i._s.delete(A)}});i._s.set(A,Q);const p=(i._a&&i._a.runWithContext||FM)(()=>i._e.run(()=>(r=ve()).run(e)));for(const f in p){const e=p[f];if(jt(e)&&!JM(e)||Lt(e))n||(E&&PM(e)&&(jt(e)?e.value=E[f]:OM(e,E[f])),i.state.value[A][f]=e);else if("function"==typeof e){const A=B(f,e);p[f]=A,s.actions[f]=e}}return YM(Q,p),YM(xt(Q),p),Object.defineProperty(Q,"$state",{get:()=>i.state.value[A],set:A=>{h(e=>{YM(e,A)})}}),i._p.forEach(A=>{YM(Q,r.run(()=>A({store:Q,app:i._a,pinia:i,options:s})))}),E&&n&&t.hydrate&&t.hydrate(Q.$state,E),g=!0,c=!0,Q}function qM(A,e,t){let i,o;const n="function"==typeof e;function r(A,t){const r=fn();(A=A||(r?pn(RM,null):null))&&MM(A),(A=SM)._s.has(i)||(n?HM(i,e,o,A):function(A,e,t){const{state:i,actions:o,getters:n}=e,r=t.state.value[A];let s;s=HM(A,function(){r||(t.state.value[A]=i?i():{});const e=ti(t.state.value[A]);return YM(e,o,Object.keys(n||{}).reduce((e,i)=>(e[i]=Pt(Ur(()=>{MM(t);const e=t._s.get(A);return n[i].call(e,e)})),e),{}))},e,t,0,!0)}(i,o,A));return A._s.get(i)}return"string"==typeof A?(i=A,o=n?t:e):(o=A,i=A.id),r.$id=i,r}let VM="Store";function jM(A,e){return Array.isArray(e)?e.reduce((e,t)=>(e[t]=function(){return A(this.$pinia)[t]},e),{}):Object.keys(e).reduce((t,i)=>(t[i]=function(){const t=A(this.$pinia),o=e[i];return"function"==typeof o?o.call(this,t):t[o]},t),{})}const KM=jM;function WM(A){{A=xt(A);const e={};for(const t in A){const i=A[t];(jt(i)||Lt(i))&&(e[t]=ni(A,t))}return e}}const zM=Object.freeze(Object.defineProperty({__proto__:null,get MutationType(){return TM},PiniaVuePlugin:function(A){A.mixin({beforeCreate(){const A=this.$options;if(A.pinia){const e=A.pinia;if(!this._provided){const A={};Object.defineProperty(this,"_provided",{get:()=>A,set:e=>Object.assign(A,e)})}this._provided[RM]=e,this.$pinia||(this.$pinia=e),e._a=this,bM&&MM(e)}else!this.$pinia&&A.parent&&A.parent.$pinia&&(this.$pinia=A.parent.$pinia)},destroyed(){delete this._pStores}})},acceptHMRUpdate:function(A,e){return()=>{}},createPinia:GM,defineStore:qM,getActivePinia:()=>fn()&&pn(RM)||SM,mapActions:function(A,e){return Array.isArray(e)?e.reduce((e,t)=>(e[t]=function(...e){return A(this.$pinia)[t](...e)},e),{}):Object.keys(e).reduce((t,i)=>(t[i]=function(...t){return A(this.$pinia)[e[i]](...t)},t),{})},mapGetters:KM,mapState:jM,mapStores:function(...A){return A.reduce((A,e)=>(A[e.$id+VM]=function(){return e(this.$pinia)},A),{})},mapWritableState:function(A,e){return Array.isArray(e)?e.reduce((e,t)=>(e[t]={get(){return A(this.$pinia)[t]},set(e){return A(this.$pinia)[t]=e}},e),{}):Object.keys(e).reduce((t,i)=>(t[i]={get(){return A(this.$pinia)[e[i]]},set(t){return A(this.$pinia)[e[i]]=t}},t),{})},setActivePinia:MM,setMapStoreSuffix:function(A){VM=A},skipHydrate:function(A){return Object.defineProperty(A,xM,{})},storeToRefs:WM},Symbol.toStringTag,{value:"Module"})),ZM="token",XM="userInfo",$M="tencentUserSig",AR="fontSizeData",eR=()=>uni.getStorageSync(ZM)||"",tR=A=>uni.setStorageSync(XM,JSON.stringify(A)),iR=()=>uni.getStorageSync(XM)||"",oR=()=>uni.getStorageSync($M)||"",nR=qM(ZM,()=>{const A=Kt(eR()||null),e=Kt(!!A.value);return{token:A,isLogin:e,setToken:t=>{var i;A.value=t,e.value=!0,i=t,uni.setStorageSync(ZM,i)},clearToken:()=>{A.value=null,e.value=!1,uni.removeStorageSync(ZM)},checkToken:()=>!!A.value,isTokenExpired:()=>!1}});let rR=!1;const sR=A=>{const e={...{url:"",method:"GET",data:{},header:{deviceId:uni.getDeviceInfo().deviceId,"Content-Type":"application/json"}},...A};return eR()&&(e.header.Authorization="Bearer "+eR()),!1!==A.loading&&uni.showLoading({title:"加载中...",mask:!0}),new Promise((t,i)=>{uni.request({url:"https://dev.cqjcteach.cn/prod-api"+e.url,method:e.method,data:e.data,timeout:1e4,header:e.header,success:A=>{if(200===A.statusCode)if(200===A.data.code)t(A.data);else{const e=aR(A.data.code,A.data);i(e||A.data)}else{const e=aR(A.statusCode,A.data);i(e||A)}},fail:A=>{uni.showToast({title:"网络异常,请检查网络连接",icon:"none",duration:2e3,mask:!0}),i(A)},complete:()=>{!1!==A.loading&&uni.hideLoading()}})})},aR=(A,e)=>{if(401===A)return rR||(rR=!0,uni.showModal({title:"提示",content:"登录已过期,请重新登录",showCancel:!1,success:async()=>{await BN().clearAllUserInfo(),uni.reLaunch({url:"/pages/login/login"}),console.log("登录已过期,====")},complete:()=>{rR=!1}})),new Error("Unauthorized");switch(A){case 403:uni.showToast({title:"没有权限访问",icon:"none",duration:2e3,mask:!0});break;case 404:uni.showToast({title:"请求资源不存在",icon:"none",duration:2e3,mask:!0});break;case 500:uni.showModal({title:`${A}提示`,content:e.msg||"服务器内部错误",showCancel:!1,confirmText:"确定"});break;default:uni.showToast({title:e.msg||"请求失败,请重试",icon:"none",duration:2e3,mask:!0})}return new Error(`Request failed with code: ${A}`)},gR=A=>sR({url:"/api/register",method:"post",data:A}),cR=A=>sR({url:"/api/login",method:"post",data:A}),lR=()=>sR({url:"/api/userInfo",method:"get"}),IR=(A,e=!0)=>sR({url:"/api/service/userAddress/list",method:"get",loading:e,data:A}),uR=A=>sR({url:`/api/service/userAddress/${A}`,method:"get"}),ER=A=>sR({url:"/api/service/userAddress",method:"post",data:A}),dR=A=>sR({url:"/api/service/userAddress",method:"put",data:A}),hR=A=>sR({url:`/api/service/userAddress/${A}`,method:"delete"}),CR=A=>sR({url:"/api/system/userPoints/list",method:"get",data:A}),BR=A=>sR({url:"/api/system/signRecord/list",method:"get",data:A}),QR=()=>sR({url:"/api/system/signRecord",method:"post"}),pR=A=>sR({url:`/api/service/articleContent/type/${A}`,method:"get"}),fR=(A=!0)=>sR({url:"/api/free/black/isBlack",method:"get",loading:A}),mR=Kt(!1),yR=(A="加载中...")=>{mR.value=!0,uni.showLoading({title:A,mask:!0})},DR=()=>{mR.value=!1,uni.hideLoading()},vR=(A,e="none",t=1800)=>{let i="none";return"success"===e&&(i="success"),"error"===e&&(i="error"),"warning"===e&&(i="none"),new Promise(e=>{uni.showToast({title:A,icon:i,duration:t,mask:!0}),setTimeout(()=>e(),t)})},wR=(A,e,t=!0)=>new Promise(i=>{uni.showModal({title:A,content:e,showCancel:t,confirmText:"确定",cancelText:"取消",success:A=>i(A.confirm)})}),SR=()=>({isLoading:mR,showLoading:yR,hideLoading:DR,showToast:vR,showDialog:wR});var MR="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function RR(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}function _R(A){if(A.__esModule)return A;var e=A.default;if("function"==typeof e){var t=function A(){return this instanceof A?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(A).forEach(function(e){var i=Object.getOwnPropertyDescriptor(A,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return A[e]}})}),t}var TR={exports:{}};TR.exports=function(){const A=A=>void 0===A,e=A=>"string"==typeof A,t=A=>{var e;return null===(e=Object.prototype.toString.call(A).match(/^\[object (.*)\]$/))||void 0===e?void 0:e[1].toLowerCase()},i=A=>"function"==typeof Array.isArray?Array.isArray(A):"array"===t(A),o=A=>null!==A&&"object"==typeof A,n=A=>i(A)||o(A),r=A=>{if("string"!=typeof A)return!1;const e=A[0];return!/[^a-zA-Z0-9]/.test(e)},s=A=>{if("object"!=typeof A||null===A)return!1;const e=Object.getPrototypeOf(A);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function a(A=99999999){return Math.round(Math.random()*A)}const g=(e,t,i,o)=>{if(!n(e)||!n(t))return 0;let r=0;const s=Object.keys(t);let a;for(let c=0,l=s.length;c-1&&Y.indexOf("rv:11.0")>-1,tA=function(){const A=/MSIE\s(\d+)\.\d/.exec(Y);let e=A&&parseFloat(A[1]);return!e&&/Trident\/7.0/i.test(Y)&&/rv:11.0/.test(Y)&&(e=11),e}(),iA=/Safari/i.test(Y)&&!AA&&!z&&!$,oA=/Windows/i.test(Y),nA=/MAC OS X/i.test(Y),rA=x&&"undefined"!=typeof Worker&&!eA,sA=z||K,aA=x&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,gA=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:A}=window.navigator;return!(!K||A||iA)}();function cA(){let A="unknown";if(nA&&(A="mac"),oA&&(A="windows"),K&&(A="ios"),z&&(A="android"),L)try{const{platform:e}=P.getSystemInfoSync();void 0!==e&&(A=e)}catch(e){console.error(e)}return A}function lA(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{P.request({url:e,data:t,method:A,timeout:i,header:{"content-type":hA},success:A=>o(A.data),fail:()=>n(new Error(`{"message":"Network error","code":${uA}}`))})}:(o,n)=>{const r=new XMLHttpRequest,s=setTimeout(()=>{r.abort(),n(new Error(`{"message":"Request timeout","code":${EA}}`))},i);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(s),200===r.status||304===r.status)try{o(r.responseText?JSON.parse(r.responseText):null)}catch(A){o(r.responseText)}else n(new Error(`{"message":"Network error","code":${uA}}`))},r.open(A,e,!0),r.setRequestHeader("Content-type",hA),r.send(t||null)})})}function BA(A){if(null==A)return!0;if("boolean"==typeof A)return!1;if("number"==typeof A)return 0===A;if("string"==typeof A)return 0===A.length;if("function"==typeof A)return 0===A.length;if(Array.isArray(A))return 0===A.length;if(A instanceof Error)return""===A.message;if(s(A)){for(const e in A)if(Object.prototype.hasOwnProperty.call(A,e))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(A)||"[object Set]"===Object.prototype.toString.call(A)||"[object File]"===Object.prototype.toString.call(A))&&0===A.size}function QA(A){if(null===A||"object"!=typeof A)return A;if(A instanceof Date)return new Date(A.getTime());if(A instanceof RegExp)return new RegExp(A.source,A.flags);if(A instanceof Map){const e=new Map;return A.forEach((A,t)=>{e.set(QA(t),QA(A))}),e}if(A instanceof Set){const e=new Set;return A.forEach(A=>{e.add(QA(A))}),e}if(Array.isArray(A))return A.map(A=>QA(A));const e=Object.getPrototypeOf(A),t=Object.create(e);return[...Object.getOwnPropertyNames(A),...Object.getOwnPropertySymbols(A)].forEach(e=>{const i=Object.getOwnPropertyDescriptor(A,e);i&&(i.get||i.set?Object.defineProperty(t,e,i):t[e]=QA(A[e]))}),t}function pA(A,e,t){const i=new WeakSet,o=(A,t)=>{if(e&&(t=e(A,t)),void 0===t)return"undefined";if(null===t)return null;if(Number.isNaN(t))return"NaN";if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if("function"==typeof t)return`[Function: ${t.name||"anonymous"}]`;if("symbol"==typeof t)return t.toString();if("bigint"==typeof t)return`${t.toString()}n`;if("object"==typeof t&&null!==t){if(i.has(t))return"[Circular]";i.add(t)}return t instanceof Date?t.toISOString():t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t instanceof Map?{dataType:"Map",value:Array.from(t.entries())}:t instanceof Set?{dataType:"Set",value:Array.from(t.values())}:t};try{return JSON.stringify(A,o,t)}catch(n){return console.error("Failed to stringify:",n),""}}function fA(){let A,e;return{promise:new Promise((t,i)=>{A=t,e=i}),resolve:A,reject:e}}var mA,yA=Object.freeze({__proto__:null,ANDROID_VERSION:Z,IE_VERSION:tA,IN_ALIPAY_MINI_APP:T,IN_BAIDU_MINI_APP:_,IN_BROWSER:x,IN_DONUT_NATIVE_APP:G,IN_JD_MINI_APP:N,IN_MINI_APP:L,IN_NS_NATIVE_APP:U,IN_QQ_MINI_APP:S,IN_RN_APP:F,IN_TT_MINI_APP:M,IN_TT_MINI_GAME:R,IN_UNI_APP:k,IN_UNI_NATIVE_APP:b,IN_WX_MINI_APP:v,IN_WX_MINI_APP_DESK:D,IN_WX_MINI_GAME:w,IN_WX_MINI_PLUGIN:O,IOS_VERSION:W,IS_ANDROID:z,IS_CHROME:AA,IS_EDGE:$,IS_FIREFOX:X,IS_IE:eA,IS_IOS:K,IS_IPAD:q,IS_IPHONE:V,IS_IPOD:j,IS_MAC:nA,IS_SAFARI:iA,IS_WECHAT:J,IS_WIN:oA,IS_WORKER_AVAILABLE:rA,MINI_APP_NAMESPACE:P,USER_AGENT:Y,base16EncodeBinaryString:c,deepCopyWithMethods:QA,deepMerge:g,generatePromise:fA,getPlatformType:cA,getType:t,httpRequest:CA,isArray:i,isArrayOrObject:n,isEmpty:BA,isFlutterWeb:aA,isH5:sA,isIOSWebView:gA,isNumber:A=>null!==A&&("number"==typeof A&&!Number.isNaN(A-0)||"object"==typeof A&&A.constructor===Number),isObject:o,isPlainObject:s,isString:e,isUndefined:A,isUniIOSApp:function(){return b&&"ios"===uni.getDeviceInfo().platform.toLocaleLowerCase()},isValidRequestKey:r,platform:H,randomInt:a,randomString:function(){const A="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let e="";for(let t=32;t>0;--t)e+=A[Math.floor(62*Math.random())];return e},safeStringify:pA});class DA{constructor(){this.listeners={}}on(A,e,t){this.listeners[A]||(this.listeners[A]=[]),this.listeners[A].push({fn:e,context:t})}off(A,e,t){var i;e&&(this.listeners[A]=null===(i=this.listeners[A])||void 0===i?void 0:i.filter(A=>{const i=A.fn===e,o=!t||A.context===t;return!(i&&o)}))}emit(A,...e){const t=this.listeners[A];t&&t.forEach(t=>{const{fn:i,context:o}=t;try{i.apply(o,e)}catch(n){console.warn(`Error in event handler for ${A} error: ${pA(n)}`)}})}once(A,e,t){const i=(...o)=>{e.apply(t,o),this.off(A,i)};this.on(A,i)}}!function(A){A.BUSINESS_COMMAND="business_command",A.C2C_REALTIME_MESSAGE="c2c_realtime_message",A.C2C_MESSAGE_MODIFIED="c2c_message_modified",A.C2C_REVOKED_MESSAGE="c2c_message_revoked",A.GROUP_REALTIME_MESSAGE="group_realtime_message",A.GROUP_MESSAGE_MODIFIED="group_message_modified",A.GROUP_MESSAGE_REVOKED="group_message_revoked",A.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",A.MESSAGE_REACTION_UPDATED="message_reaction_updated",A.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",A.GROUP_AT_TIPS="group_at_tips",A.USER_STATUS_UPDATE="user_status_update",A.FRIEND_LIST_MODIFIED="friend_list_modified",A.PROFILE_MODIFIED="profile_modified",A.CONV_MODIFIED="conversation_modified",A.GROUP_TIPS_NOTIFICATION="group_tips_notification",A.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",A.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",A.GROUP_SYSTEM_NOTIFICATION="group_system_notification",A.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",A.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",A.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",A.FOLLOW_LIST_UPDATED="follow_list_updated",A.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",A.ALL_MESSAGE_READ="all_message_read",A.CONVERSATION_MARK_UPDATED="conversation_mark_updated",A.CONVERSATION_GROUP_ADD="conversation_group_add",A.CONVERSATION_GROUP_DELETED="conversation_group_deleted",A.CONVERSATION_GROUP_UPDATED="conversation_group_updated",A.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",A.TOPIC_AT_TIPS="topic_at_tips",A.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",A.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",A.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",A.TOPIC_LATEST_MESSAGE="topic_latest_message",A.GROUP_MESSAGE_PINNED="group_message_pinned"}(mA||(mA={}));const vA=[16,17];function wA(A){var e;const t=[];return null===(e=null==A?void 0:A.GroupTips)||void 0===e||e.forEach(A=>{var e;2===A.GroupInfo.MillionGroupFlag?t.push(mA.TOPIC_TIPS_NOTIFICATION):vA.includes(null===(e=null==A?void 0:A.MsgBody)||void 0===e?void 0:e.OpType)?t.push(mA.GROUP_MESSAGE_PINNED):t.push(mA.GROUP_TIPS_NOTIFICATION)}),t}const SA=[{conditions:[{type:"event",value:100}],subType:mA.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:mA.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:mA.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:mA.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:mA.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:mA.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:mA.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:mA.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:mA.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:mA.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(A){var e;const t=[];return null===(e=null==A?void 0:A.C2cNotifyMsgArray)||void 0===e||e.forEach(A=>{A.WithdrawC2cMsgNotify&&t.push(mA.C2C_REVOKED_MESSAGE),A.C2cReadedReceipt&&t.push(mA.C2C_MESSAGE_PEER_READ),A.ReadC2cMsgNotify&&t.push(mA.C2C_MESSAGE_READ_SYNC),A.MuteNotificationsSync&&t.push(mA.C2C_REMIND_TYPE_SYNC)}),t}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:wA},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(A){var e;const t=[];return null===(e=null==A?void 0:A.GroupTips)||void 0===e||e.forEach(A=>{Array.isArray(A.MsgBody.GroupWithdrawInfoArray)?t.push(mA.GROUP_MESSAGE_REVOKED):Array.isArray(A.MsgBody.GroupMsgReceiptList)?t.push(mA.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(A.MsgBody.GroupReadInfoArray)?A.MsgBody.GroupReadInfoArray[0].TopicId?t.push(mA.TOPIC_MESSAGE_READ_SYNC):t.push(mA.GROUP_MESSAGE_READ_SYNC):2===A.GroupInfo.MillionGroupFlag?t.push(mA.TOPIC_SYSTEM_NOTIFICATION):t.push(mA.GROUP_SYSTEM_NOTIFICATION)}),t}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:wA},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(A){var e;const t=[];return null===(e=null==A?void 0:A.GroupTips)||void 0===e||e.forEach(A=>{const{GroupAtTips:{TopicId:e}}=A;e?t.push(mA.TOPIC_AT_TIPS):t.push(mA.GROUP_AT_TIPS)}),t}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(A){var e;const t=[];return null===(e=null==A?void 0:A.RecentContactMod)||void 0===e||e.forEach(A=>{switch(A.PushType){case m.CONV_MARK_UPDATED:t.push(mA.CONVERSATION_MARK_UPDATED);break;case m.CONV_GROUP_ADDED:t.push(mA.CONVERSATION_GROUP_ADD);break;case m.CONV_GROUP_DELETED:t.push(mA.CONVERSATION_GROUP_DELETED);break;case m.CONV_GROUP_UPDATED:t.push(mA.CONVERSATION_GROUP_UPDATED);break;default:t.push(mA.CONV_MODIFIED)}}),t}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:mA.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:mA.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:mA.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:mA.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:mA.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:mA.ALL_MESSAGE_READ}];var MA;function RA(A){var e;const t=Array.isArray(null===(e=null==A?void 0:A.body)||void 0===e?void 0:e.EventArray)?A.body.EventArray:[],i=[];return t.forEach(e=>{e.Flag=A.body.Flag;const t=SA.find(A=>A.conditions.every(A=>{switch(A.type){case"event":return e.Event===A.value;case"hasKey":return Object.prototype.hasOwnProperty.call(e,A.value);default:return!1}}));if(!t)return null;let o=[];"function"==typeof t.subTypeParser?o=t.subTypeParser(e):t.subType&&(o=t.subType),Array.isArray(o)?o.forEach(A=>{i.push({type:`${MA.SERVER_PUSH_MESSAGE}:${A}`,data:e})}):i.push({type:`${MA.SERVER_PUSH_MESSAGE}:${o}`,data:e})}),i}!function(A){A.SERVER_PUSH_MESSAGE="im_open_push.msg_push",A.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",A.ERROR="error"}(MA||(MA={}));const _A={[MA.SERVER_PUSH_MESSAGE]:RA,[MA.SERVER_PUSH_MESSAGE_MULTIPLE]:RA,[MA.ERROR]:function(A){const{errorCode:e}=A;return[{type:`error:${e}`,data:A}]}},TA=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._filteredCallbackMap=new Map,this._outerEventEmitter=new DA,this._innerEventEmitter=new DA,this.InnerEventSubType=mA}subscribeInnerEvent(A,e,t,i,o){var n;let r,s,a,g;["string","number"].includes(typeof e)?(a=`${A}:${e}`,g=t,s=i,r=o):(a=A,g=e,s=t,r="function"==typeof i?i:void 0),r?this._subscribeWithFilter(a,g,s,r):null===(n=this._innerEventEmitter)||void 0===n||n.on(a,g,s)}emitInnerEvent(A,e){var t,i;if(null===(t=this._innerEventEmitter)||void 0===t||t.emit(A,e),Object.keys(_A).includes(A)){const t=null===(i=_A[A])||void 0===i?void 0:i.call(_A,e);null==t||t.forEach(A=>{var e;A&&(null===(e=this._innerEventEmitter)||void 0===e||e.emit(A.type,A.data))})}}subscribeOuterEvent(A,e,t){var i;null===(i=this._outerEventEmitter)||void 0===i||i.on(A,e,t)}unSubscribeOuterEvent(A,e,t){var i;null===(i=this._outerEventEmitter)||void 0===i||i.off(A,e,t)}unSubscribeInnerEvent(A,e,t,i){if(["string","number"].includes(typeof e)){const o=t,n=`${A}:${e}`;this._unsubscribeEvent(n,o,i)}else{const i=e;this._unsubscribeEvent(A,i,t)}}emitOuterEvent(A,e){var t;null===(t=this._outerEventEmitter)||void 0===t||t.emit(A,e)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}_subscribeWithFilter(A,e,t,i){var o;const n=A=>{i.call(t,A)&&e.call(t,A)};this._filteredCallbackMap.has(A)||this._filteredCallbackMap.set(A,[]),this._filteredCallbackMap.get(A).push({originalCallback:e,filteredCallback:n,filter:i,context:t}),null===(o=this._innerEventEmitter)||void 0===o||o.on(A,n,t)}_unsubscribeEvent(A,e,t){var i,o;const n=this._filteredCallbackMap.get(A);if(n){const o=n.findIndex(A=>A.originalCallback===e&&A.context===t);if(-1!==o){const{filteredCallback:e}=n[o];return null===(i=this._innerEventEmitter)||void 0===i||i.off(A,e,t),n.splice(o,1),void(0===n.length&&this._filteredCallbackMap.delete(A))}}null===(o=this._innerEventEmitter)||void 0===o||o.off(A,e,t)}};class NA{constructor(){this._socket=null}connectSocket(A){return this._socket=new WebSocket(A),this._socket}send(A){var e,t;try{null===(e=this._socket)||void 0===e||e.send(A)}catch(i){null===(t=this._onSendFail)||void 0===t||t.call(this,i)}}bindSocketHandlers(A){const{onOpen:e,onMessage:t,onClose:i,onError:o,onSendFail:n}=A;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=i,this._socket.onerror=o,this._onSendFail=n)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class bA{connectSocket(A){return this._socket=P.connectSocket({url:A,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(A){var e;null===(e=this._socket)||void 0===e||e.send({data:A,fail:this._onSendFail})}bindSocketHandlers(A){const{onOpen:e,onMessage:t,onClose:i,onError:o,onSendFail:n}=A;this._socket.onClose(i),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(o),this._onSendFail=n}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const GA="CONNECT",kA="SEND",LA="DISCONNECT",UA="OPEN",FA="MESSAGE",OA="CLOSE",xA="ERROR",PA="SEND_FAIL";class YA{constructor(){this._worker=null,this._blobUrl=null}connectSocket(A){const e=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(e)),this._worker.postMessage({type:GA,url:A})}send(A){var e,t;try{null===(e=this._worker)||void 0===e||e.postMessage({type:kA,data:A})}catch(i){null===(t=this._onSendFail)||void 0===t||t.call(this,i)}}bindSocketHandlers(A){const{onOpen:e,onMessage:t,onClose:i,onError:o,onSendFail:n}=A;if(this._worker){const A={[UA]:e,[FA]:t,[OA]:i,[xA]:o,[PA]:n};this._onSendFail=n,this._worker.onmessage=e=>{var t;const{type:i}=(null==e?void 0:e.data)||{};"function"==typeof A[i]&&(null===(t=A[i])||void 0===t||t.call(A,null==e?void 0:e.data))}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:LA}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var JA,HA=new class{constructor(){this._store=new Map}get(A){return this._store.get(A)}getStorage(A){return L?T?my.getStorageSync({key:A}).data:P.getStorageSync(A):this._canUseLocalStorage()?localStorage.getItem(A):{}}set(A,e){const t=this._store.get(A)||{};e instanceof Map?this._store.set(A,e):this._store.set(A,Object.assign(Object.assign({},t),e))}setStorage(A,e){L?T?my.setStorageSync({key:A,data:JSON.stringify(e)}):P.setStorageSync(A,JSON.stringify(e)):this._canUseLocalStorage()&&localStorage.setItem(A,JSON.stringify(e))}clear(A){"string"==typeof A?this._store.set(A,{}):this._store.clear()}clearLocalStorage(A){this._canUseLocalStorage()&&("string"==typeof A?localStorage.setItem(A,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(A){A[A.CONNECTED=0]="CONNECTED",A[A.CONNECTING=1]="CONNECTING",A[A.DISCONNECTED=2]="DISCONNECTED"}(JA||(JA={}));class qA{constructor(A){this._url="",this._readyState=JA.DISCONNECTED,this._url=A,this._id=a(),this._emitter=new DA,v||b||R?this._socket=new bA:this._canUseWebWorker()?this._socket=new YA:this._socket=new NA,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[JA.CONNECTED,JA.CONNECTING].includes(this._readyState)||(this._readyState=JA.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(A){this._readyState!==JA.CONNECTED?this.reconnect():this._socket.send(A)}reconnect(){[JA.CONNECTED,JA.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(A,e,t){this._emitter.on(A,e,t)}off(A,e,t){this._emitter.off(A,e,t)}isConnected(){return this._readyState===JA.CONNECTED}disconnect(){this._readyState=JA.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(A){this._readyState===JA.CONNECTING&&(this._readyState=JA.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:A}))}_onMessage(A){this._emitter.emit("message",A)}_onClose(A){this._readyState=JA.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:A})}_onError(A){this._readyState=JA.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:A})}_onSendFail(A){this._readyState=JA.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:A})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){const e=HA.get("cloudConfig")||{};return(A(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&rA}}const VA="CHINA",jA="OVERSEA",KA="SINGAPORE",WA="KOREA",zA="GERMANY",ZA="IND",XA="JPN",$A="USA",Ae="INDONESIA",ee={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},te={[KA]:[[2e7,3e7],[172e7,173e7]],[WA]:[[3e7,4e7],[173e7,174e7]],[zA]:[[4e7,5e7],[174e7,175e7]],[ZA]:[[5e7,6e7],[175e7,176e7]],[XA]:[[6e7,7e7],[176e7,177e7]],[$A]:[[7e7,8e7],[177e7,178e7]],[Ae]:[[8e7,9e7],[178e7,179e7]]};function ie(A){var e;if(null===(e=HA.get("instance"))||void 0===e?void 0:e.oversea)return jA;for(const t of Object.keys(te))for(const[e,i]of te[t])if(A>=e&&A`${A}=${c[A]}`).join("&"));var c;return t?`${A}/binfo?${g}&compress=gzip`:`${A}/info?${g}`}function ge(A){const e=HA.get("instance"),{sdkAppId:t,testEnv:i}=e,o=ie(t);if(i)return ae(ee.TEST[o].DEFAULT,{isBinary:A});const n=ee.PRODUCTION[o],r=x&&n.ANYCAST,s=x,a=!!n.BACKUP_CN;return ae({[oe.INITIAL]:()=>(re=oe.DEFAULT,n.DEFAULT),[oe.DEFAULT]:()=>(re=oe.IPV6,n.IPV6),[oe.IPV6]:()=>(re=oe.BACKUP,n.BACKUP),[oe.BACKUP]:()=>s?(re=oe.BACKUP_WEB_ONLY,function(A){const e=Math.floor(10001*Math.random())+1e4;return A.replace("*",String(e))}(n.BACKUP_WEB_ONLY)):a?(re=oe.BACKUP_CN,n.BACKUP_CN):r?(re=oe.ANYCAST,n.ANYCAST):n.DEFAULT,[oe.BACKUP_WEB_ONLY]:()=>a?(re=oe.BACKUP_CN,n.BACKUP_CN):r?(re=oe.ANYCAST,n.ANYCAST):n.DEFAULT,[oe.BACKUP_CN]:()=>(re=r?oe.ANYCAST:oe.DEFAULT,n[re]),[oe.ANYCAST]:()=>(re=oe.DEFAULT,n.ANYCAST="",n.DEFAULT)}[re](),{isBinary:A})}var ce=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(A,e){const t=Date.now(),i=t-A;this._timeOffsetWithServer=e+i-t}};const le=16;var Ie=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(A){const{id:e}=A;this.removeTask(e),this._tasks.push(A),this._taskMap.set(e,A),this._sort(),this._scheduleNextTask()}_createTask(A){const{id:e,callback:t,context:i,isOnce:o=!1,intervalMs:n=le}=A,r=Math.max(n,le);return{id:e,nextExecuteTime:Date.now()+r,intervalMs:n,callback:t,context:i,isOnce:o}}addTask(A){const e=this._createTask(A);this._addTaskToScheduler(e)}addOnceTask(A){const e=this._createTask(Object.assign(Object.assign({},A),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(A){const e=this._tasks.findIndex(e=>e.id===A);e>-1&&(this._tasks.splice(e,1),this._taskMap.delete(A),this._scheduleNextTask())}updateTaskInterval(A,e){const t=this._taskMap.get(A);t&&(t.intervalMs=e,t.nextExecuteTime=Date.now()+e,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((A,e)=>A.nextExecuteTime-e.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);const A=this._tasks[0];if(A){const e=Math.max(0,A.nextExecuteTime-Date.now());this._timer=setTimeout(()=>this._execute(),e)}}_execute(){const A=Date.now();for(;this._tasks.length&&this._tasks[0].nextExecuteTime<=A;){const t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=A+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function ue(A){const e=[];for(let t=0;t=55296&&i<=56319){const o=A.charCodeAt(++t)-56320+(i-55296<<10)+65536;e.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}else i<=127?e.push(i):i<=2047?e.push(192|i>>6,128|63&i):e.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(e)}function Ee(A){const e=Array.isArray(A)?[]:Object.create(null);for(const t in A)Object.prototype.hasOwnProperty.call(A,t)&&r(t)&&null!=A[t]&&(null===A[t]||"object"!=typeof A[t]?e[t]=A[t]:e[t]=Ee(A[t]));return e}function de(A,e){if(I.includes(A))return 0;const t=ue(JSON.stringify(e));let i=4294967295;const{length:o}=t;for(let n=0;n>>=1:i=i>>>1^3988292384}return(4294967295^i)>>>0}function he(A){const{servcmd:e,data:t}=A,i=function(A){const e=HA.get("login")||{},t=HA.get("instance")||{};return{servcmd:A,ver:"v4",platform:H,websdkappid:537048168,websdkversion:"1.7.3",a2:e.a2Key||void 0,tinyid:e.tinyID||void 0,status_instid:e.statusInstanceId||0,sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:e.a2Key?void 0:e.userId,usersig:e.a2Key?void 0:e.userSig,sdkability:75689843,sdkability_ext:c(""),cappid:t.applicationID||0,tjgID:"",seq:Qe(),cs:0}}(e),o=Ee(t);return i.cs=de(e,o),{head:i,body:o}}function Ce(A){const{servcmd:e,data:t}=A,i=function(A){const e=HA.get("login")||{},t=HA.get("instance")||{};return{servcmd:A,ver:"v4",platform:H,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:e.statusInstanceId||0,sdkability:75689843,sdkability_ext:c(""),cappid:t.applicationID||0,seq:Qe(),cs:0}}(e),o=Ee(t);return i.cs=de(e,o),{head:i,body:o}}let Be=a();function Qe(){return Be=Be<2415919103?Be+1:a(),Be}function pe(){var A;const e=HA.get("login")||{},t=HA.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.6.6",tiny_id:Number(e.tinyID),user_id:e.userId||(null===(A=HA.get("webPush"))||void 0===A?void 0:A.userId),platform:H,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var fe,me=Object.freeze({__proto__:null,calcBodyCRC:de,filterProtocolDataInvalidFields:Ee,generateCosSpecifiedData:function(A){const{servcmd:e,data:t}=A,i=function(A){const e=HA.get("login")||{},t=HA.get("instance")||{};return{servcmd:A,ver:"v4",platform:H,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:e.userId,usersig:e.userSig,status_instid:e.statusInstanceId||0,sdkability:75689843,sdkability_ext:c(""),cappid:t.applicationID||0,seq:Qe(),cs:0}}(e),o=Ee(t);return i.cs=de(e,o),{head:i,body:o}},generateProtocolData:he,generateSSOLogProtocolData:Ce,generateSequence:Qe,getCommonHead:pe,taskScheduler:Ie,timeManager:ce});!function(A){A[A.info=4]="info",A[A.warning=5]="warning",A[A.error=6]="error"}(fe||(fe={}));const ye={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class De{constructor(A){this.level=fe.info,this._canSendLog=!0,this._logCreatedAt=ce.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=this._getUiPlatform(),this._sdkEdition=this._getSDKEdition();const{method:e,eventType:t=0,message:i="",costTime:o=0,error:n,moreMessage:r="",code:s=0}=A||{};this.eventType=t,this.method=e,this.message=i,this.costTime=o,this.moreMessage=r,this.code=s,n&&this.setError(n)}setMoreMessage(A){this.moreMessage=`${this.moreMessage} ${A}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=ce.getTimeOffsetWithServer()}end(A=!1){this._canSendLog&&(this._canSendLog=!1,this.timestamp=ce.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()),A&&this._ssoLogModule.uploadSSOLogData())}setError(A){var e;return A instanceof Error?this._canSendLog?((null===(e=HA.get("netWorkMonitor"))||void 0===e?void 0:e.isNetworkOnline)&&(A.errorCode&&(this.code=A.errorCode),A.errorMessage&&this.setMoreMessage(A.errorMessage)),this.level=fe.error,this):this:(console.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}setLogInfo(A){return Object.keys(A).forEach(e=>{Object.keys(ye).includes(e)&&(this[e]=A[e])}),this}setSSOLogModule(A){this._ssoLogModule=A}_convertSSOLogDataKeyToServe(){const A={};return Object.keys(this).forEach(e=>{const t=e;ye[t]&&(A[ye[t]]=this[t])}),A}_getUiPlatform(){var A;const e=null===(A=HA.get("instance"))||void 0===A?void 0:A.scene;if("string"==typeof e){const A=Number(e);return isNaN(A)?void 0:A}}_getSDKEdition(){var A;return null===(A=HA.get("instance"))||void 0===A?void 0:A.sdkEdition}}var ve;!function(A){A.RECONNECTED="reconnected",A.CLOUD_CONFIG_UPDATE="cloud_config_update",A.SOCKET_DISCONNECTED="socket_disconnected"}(ve||(ve={}));var we=ve;const Se=20,Me=6e4,Re=[4,5,6],_e=[],Te=[],Ne="report-logger";var be=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=Se,this._maxThreshold=100,this._waitingTime=Me,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=u.DEBUG,this._throttleConfig={global:{throttleTime:p,maxCount:f},single:{throttleTime:B,maxCount:Q}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,TA.subscribeInnerEvent(we.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Ie.addTask({id:Ne,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(A){const{evt_rpt_threshold:e=Se,evt_rpt_waiting:t=Me,evt_rpt_level:i=Re,evt_rpt_sdkappid_bl:o=_e,evt_rpt_tinyid_wl:n=Te,evt_rpt_global_throttle_time:r=p,evt_rpt_global_throttle_count:s=f,evt_rpt_single_throttle_time:a=B,evt_rpt_single_throttle_count:g=Q}=A||{};this._sdkAppIdBlackList=o,this._waitingTime=t,this._minThreshold=e,this._reportLevel=i,this._tinyIdWhiteList=n,this._throttleConfig={global:{throttleTime:r,maxCount:s},single:{throttleTime:a,maxCount:g}}}createSSOLogData(A){const e=new De(A);return e.setSSOLogModule(this),this._ssoLogMap.set(A.method,e),e}getSSOLogData(A){return this._ssoLogMap.get(A)||{}}pushToLogQueue(A){A&&(this._logQueue.push(A),this._shouldUploadImmediately()&&this.uploadSSOLogData())}setLogLevel(A){[u.DEBUG,u.ERROR,u.INFO,u.NONE,u.WARN].includes(A)&&(this._logLevel=A)}debug(A,e="",t){this._log(u.DEBUG,A,e,t)}info(A,e="",t){this._log(u.INFO,A,e,t)}warn(A,e="",t){this._log(u.WARN,A,e,t)}error(A,e="",t){this._log(u.ERROR,A,e,t)}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&this._logQueue.length>0&&this.uploadSSOLogData()}uploadSSOLogData(){return IA(this,void 0,void 0,function*(){if(0===this._logQueue.length)return;const A=this._logQueue.slice(),e=this._filterLogs(A);if(this._logQueue=[],0===e.length)return void(this._lastReportAt=Date.now());const t={Header:pe(),Event:e};BA(t.Header.user_id)||(yield function(A){const e="imopenstat.tim_web_report_v2",t=Ce({servcmd:e,data:A}),i=`${t.head.seq}${e}`;$e.sendPacket(t,{requestId:i})}(t)),this._lastReportAt=Date.now()})}_savePlatFormInfo(){var A,e;if(v){const t=null===(e=null===(A=wx.getAccountInfoSync)||void 0===A?void 0:A.call(wx))||void 0===e?void 0:e.miniProgram;if(t){const{appId:A,envVersion:e}=t;HA.set("instance",{appId:A,envVersion:e})}}else x&&HA.set("instance",{href:window.location.href})}_filterLogs(A){const{tinyID:e}=HA.get("login")||{},{sdkAppId:t}=HA.get("instance")||{};return this._sdkAppIdBlackList.includes(t)&&!this._tinyIdWhiteList.includes(e)?[]:A.filter(A=>this._reportLevel.includes(A.level))}_checkThrottle(A){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(A)}_checkGlobalThrottle(){const A=Date.now();if(A-this._globalThrottle.startTime>=this._throttleConfig.global.throttleTime)this._globalThrottle.count=1,this._globalThrottle.startTime=A;else if(this._globalThrottle.count++,this._globalThrottle.count>this._throttleConfig.global.maxCount)return!0;return!1}_checkSingleThrottle(A){const e=Date.now(),t=this._singleThrottleMap.get(A);return t?e-t.startTime>=this._throttleConfig.single.throttleTime?(t.count=1,t.startTime=e,!1):t.count>=this._throttleConfig.single.maxCount||(t.count++,!1):(this._singleThrottleMap.set(A,{count:1,startTime:e}),!1)}_shouldLog(A){return A>=this._logLevel&&this._logLevel!==u.NONE}_shouldReport(A){return this._reportLevel.includes(C[A])}_formatLog(A,e,t){const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}:${i.getMilliseconds()}`,n=`<${u[A]}>`;return eA||L?[`${d} [${o}] ${n} [${e}] ${t}`]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",d,"",`[${o}] ${n} [${e}] ${t}`]}_log(A,e,t,i){if(!this._shouldLog(A))return;const o=this._formatLog(A,e,t);if(h[A].apply(console,o),this._shouldReport(A)){const A=this._getThrottleKey(e,t,i);this._checkThrottle(A)||this.createSSOLogData(Object.assign(Object.assign({message:t},i),{method:e})).end()}}_getThrottleKey(A,e,t){const i=`${A}${e}${pA(Object.assign(Object.assign({},t),{costTime:""}))}`,o=ue(JSON.stringify(i));let n=4294967295;const{length:r}=o;for(let s=0;s>>=1:n=n>>>1^3988292384}return""+((4294967295^n)>>>0)}reset(){console.log("SSO_LOG_MODULE.reset"),Ie.removeTask(Ne),TA.unSubscribeInnerEvent(we.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=Se,this._maxThreshold=100,this._waitingTime=Me,this._logQueue=[],this._logLevel=u.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}};const Ge=15e3,ke="Channel",Le="channel_schedule_task",Ue="channel_reconnect_task",Fe="connected",Oe="connecting",xe="disconnected",Pe=1e3,Ye="network_status_change",Je="activity_status_change",He="send_fail",qe="reconnect_failed",Ve="socket_error",je="socket_close";function Ke(A){return(Ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(A)}function We(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ze,Ze={exports:{}},Xe=(ze||(ze=1,function(A){A.exports=function A(e,t,i){function o(r,s){if(!t[r]){if(!e[r]){if(!s&&We)return We(r);if(n)return n(r,!0);var a=new Error("Cannot find module '"+r+"'");throw a.code="MODULE_NOT_FOUND",a}var g=t[r]={exports:{}};e[r][0].call(g.exports,function(A){return o(e[r][1][A]||A)},g,g.exports,A,e,t,i)}return t[r].exports}for(var n=We,r=0;r>>6:(t<65536?e[r++]=224|t>>>12:(e[r++]=240|t>>>18,e[r++]=128|t>>>12&63),e[r++]=128|t>>>6&63),e[r++]=128|63&t);return e},t.buf2binstring=function(A){return a(A,A.length)},t.binstring2buf=function(A){for(var e=new i.Buf8(A.length),t=0,o=e.length;t>10&1023,g[i++]=56320|1023&o)}return a(g,i)},t.utf8border=function(A,e){var t;for((e=e||A.length)>A.length&&(e=A.length),t=e-1;0<=t&&128==(192&A[t]);)t--;return t<0||0===t?e:t+r[A[t]]>e?t:e}},{"./common":1}],3:[function(A,e,t){e.exports=function(A,e,t,i){for(var o=65535&A,n=A>>>16&65535,r=0;0!==t;){for(t-=r=2e3>>1:A>>>1;e[t]=A}return e}();e.exports=function(A,e,t,o){var n=i,r=o+t;A^=-1;for(var s=o;s>>8^n[255&(A^e[s])];return~A}},{}],6:[function(A,e,t){e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(A,e,t){e.exports=function(A,e){var t,i,o,n,r,s,a,g,c,l,I,u,E,d,h,C,B,Q,p,f,m,y,D,v,w;t=A.state,i=A.next_in,v=A.input,o=i+(A.avail_in-5),n=A.next_out,w=A.output,r=n-(e-A.avail_out),s=n+(A.avail_out-257),a=t.dmax,g=t.wsize,c=t.whave,l=t.wnext,I=t.window,u=t.hold,E=t.bits,d=t.lencode,h=t.distcode,C=(1<>>=p=Q>>>24,E-=p,0==(p=Q>>>16&255))w[n++]=65535&Q;else{if(!(16&p)){if(!(64&p)){Q=d[(65535&Q)+(u&(1<>>=p,E-=p),E<15&&(u+=v[i++]<>>=p=Q>>>24,E-=p,!(16&(p=Q>>>16&255))){if(!(64&p)){Q=h[(65535&Q)+(u&(1<>>=p,E-=p,(p=n-r)>3,u&=(1<<(E-=f<<3))-1,A.next_in=i,A.next_out=n,A.avail_in=i>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(A){var e;return A&&A.state?(e=A.state,A.total_in=A.total_out=e.total=0,A.msg="",e.wrap&&(A.adler=1&e.wrap),e.mode=I,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new i.Buf32(u),e.distcode=e.distdyn=new i.Buf32(E),e.sane=1,e.back=-1,c):l}function B(A){var e;return A&&A.state?((e=A.state).wsize=0,e.whave=0,e.wnext=0,C(A)):l}function Q(A,e){var t,i;return A&&A.state?(i=A.state,e<0?(t=0,e=-e):(t=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=r.wsize?(i.arraySet(r.window,e,t-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(o<(n=r.wsize-r.wnext)&&(n=o),i.arraySet(r.window,e,t-o,n,r.wnext),(o-=n)?(i.arraySet(r.window,e,t-o,o,0),r.wnext=o,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave>>8&255,t.check=n(t.check,x,2,0),f=p=0,t.mode=2;break}if(t.flags=0,t.head&&(t.head.done=!1),!(1&t.wrap)||(((255&p)<<8)+(p>>8))%31){A.msg="incorrect header check",t.mode=30;break}if(8!=(15&p)){A.msg="unknown compression method",t.mode=30;break}if(f-=4,k=8+(15&(p>>>=4)),0===t.wbits)t.wbits=k;else if(k>t.wbits){A.msg="invalid window size",t.mode=30;break}t.dmax=1<>8&1),512&t.flags&&(x[0]=255&p,x[1]=p>>>8&255,t.check=n(t.check,x,2,0)),f=p=0,t.mode=3;case 3:for(;f<32;){if(0===B)break A;B--,p+=u[h++]<>>8&255,x[2]=p>>>16&255,x[3]=p>>>24&255,t.check=n(t.check,x,4,0)),f=p=0,t.mode=4;case 4:for(;f<16;){if(0===B)break A;B--,p+=u[h++]<>8),512&t.flags&&(x[0]=255&p,x[1]=p>>>8&255,t.check=n(t.check,x,2,0)),f=p=0,t.mode=5;case 5:if(1024&t.flags){for(;f<16;){if(0===B)break A;B--,p+=u[h++]<>>8&255,t.check=n(t.check,x,2,0)),f=p=0}else t.head&&(t.head.extra=null);t.mode=6;case 6:if(1024&t.flags&&(B<(w=t.length)&&(w=B),w&&(t.head&&(k=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),i.arraySet(t.head.extra,u,h,w,k)),512&t.flags&&(t.check=n(t.check,u,w,h)),B-=w,h+=w,t.length-=w),t.length))break A;t.length=0,t.mode=7;case 7:if(2048&t.flags){if(0===B)break A;for(w=0;k=u[h+w++],t.head&&k&&t.length<65536&&(t.head.name+=String.fromCharCode(k)),k&&w>9&1,t.head.done=!0),A.adler=t.check=0,t.mode=12;break;case 10:for(;f<32;){if(0===B)break A;B--,p+=u[h++]<>>=7&f,f-=7&f,t.mode=27;break}for(;f<3;){if(0===B)break A;B--,p+=u[h++]<>>=1)){case 0:t.mode=14;break;case 1:if(D(t),t.mode=20,6!==e)break;p>>>=2,f-=2;break A;case 2:t.mode=17;break;case 3:A.msg="invalid block type",t.mode=30}p>>>=2,f-=2;break;case 14:for(p>>>=7&f,f-=7&f;f<32;){if(0===B)break A;B--,p+=u[h++]<>>16^65535)){A.msg="invalid stored block lengths",t.mode=30;break}if(t.length=65535&p,f=p=0,t.mode=15,6===e)break A;case 15:t.mode=16;case 16:if(w=t.length){if(B>>=5,f-=5,t.ndist=1+(31&p),p>>>=5,f-=5,t.ncode=4+(15&p),p>>>=4,f-=4,286>>=3,f-=3}for(;t.have<19;)t.lens[P[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,U={bits:t.lenbits},L=s(0,t.lens,0,19,t.lencode,0,t.work,U),t.lenbits=U.bits,L){A.msg="invalid code lengths set",t.mode=30;break}t.have=0,t.mode=19;case 19:for(;t.have>>16&255,T=65535&O,!((R=O>>>24)<=f);){if(0===B)break A;B--,p+=u[h++]<>>=R,f-=R,t.lens[t.have++]=T;else{if(16===T){for(F=R+2;f>>=R,f-=R,0===t.have){A.msg="invalid bit length repeat",t.mode=30;break}k=t.lens[t.have-1],w=3+(3&p),p>>>=2,f-=2}else if(17===T){for(F=R+3;f>>=R)),p>>>=3,f-=3}else{for(F=R+7;f>>=R)),p>>>=7,f-=7}if(t.have+w>t.nlen+t.ndist){A.msg="invalid bit length repeat",t.mode=30;break}for(;w--;)t.lens[t.have++]=k}}if(30===t.mode)break;if(0===t.lens[256]){A.msg="invalid code -- missing end-of-block",t.mode=30;break}if(t.lenbits=9,U={bits:t.lenbits},L=s(a,t.lens,0,t.nlen,t.lencode,0,t.work,U),t.lenbits=U.bits,L){A.msg="invalid literal/lengths set",t.mode=30;break}if(t.distbits=6,t.distcode=t.distdyn,U={bits:t.distbits},L=s(g,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,U),t.distbits=U.bits,L){A.msg="invalid distances set",t.mode=30;break}if(t.mode=20,6===e)break A;case 20:t.mode=21;case 21:if(6<=B&&258<=Q){A.next_out=C,A.avail_out=Q,A.next_in=h,A.avail_in=B,t.hold=p,t.bits=f,r(A,y),C=A.next_out,E=A.output,Q=A.avail_out,h=A.next_in,u=A.input,B=A.avail_in,p=t.hold,f=t.bits,12===t.mode&&(t.back=-1);break}for(t.back=0;_=(O=t.lencode[p&(1<>>16&255,T=65535&O,!((R=O>>>24)<=f);){if(0===B)break A;B--,p+=u[h++]<>N)])>>>16&255,T=65535&O,!(N+(R=O>>>24)<=f);){if(0===B)break A;B--,p+=u[h++]<>>=N,f-=N,t.back+=N}if(p>>>=R,f-=R,t.back+=R,t.length=T,0===_){t.mode=26;break}if(32&_){t.back=-1,t.mode=12;break}if(64&_){A.msg="invalid literal/length code",t.mode=30;break}t.extra=15&_,t.mode=22;case 22:if(t.extra){for(F=t.extra;f>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=23;case 23:for(;_=(O=t.distcode[p&(1<>>16&255,T=65535&O,!((R=O>>>24)<=f);){if(0===B)break A;B--,p+=u[h++]<>N)])>>>16&255,T=65535&O,!(N+(R=O>>>24)<=f);){if(0===B)break A;B--,p+=u[h++]<>>=N,f-=N,t.back+=N}if(p>>>=R,f-=R,t.back+=R,64&_){A.msg="invalid distance code",t.mode=30;break}t.offset=T,t.extra=15&_,t.mode=24;case 24:if(t.extra){for(F=t.extra;f>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){A.msg="invalid distance too far back",t.mode=30;break}t.mode=25;case 25:if(0===Q)break A;if(w=y-Q,t.offset>w){if((w=t.offset-w)>t.whave&&t.sane){A.msg="invalid distance too far back",t.mode=30;break}w>t.wnext?(w-=t.wnext,S=t.wsize-w):S=t.wnext-w,w>t.length&&(w=t.length),M=t.window}else M=E,S=C-t.offset,w=t.length;for(QB?(p=U[F+l[D]],f=b[G+l[D]]):(p=96,f=0),u=1<>R)+(E-=u)]=Q<<24|p<<16|f,0!==E;);for(u=1<>=1;if(0!==u?(N&=u-1,N+=u):N=0,D++,0==--k[y]){if(y===w)break;y=e[t+l[D]]}if(S{const e=new Uint8Array(A).slice(4);let t;try{t=Xe.inflate(e,{to:"string"})}catch(i){console.error("inflate error",i)}return t})(A.data):function(A){const e=new Uint8Array(A);let t="",i=0;const{length:o}=e;for(;i0)for(let t=0;t{var t;const{uplinkData:i,canResend:o,resolve:n,reject:r,timeout:s}=A;if(o){this._pendingRequests.set(e,{resolve:n,reject:r,timestamp:Date.now(),uplinkData:i,timeout:s,canResend:o});const A=this._isBinarySupported?ue(i).buffer:i;null===(t=this._socketAdapter)||void 0===t||t.send(A)}else this._pendingRequests.delete(e)})}_onConnect(A){const{socketId:e,event:t={}}=A||{};this._connectionId=e,this._connectionEstablishedTime=Date.now();const i=Date.now()-this._connectionStartTime,o=`${ke}.onConnect cost:${i} ms. socketID:${e} res:${JSON.stringify(t)}`;if(this._ssoLog({method:"onConnect",message:o}),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){const A=`${ke}.reconnect success`;this._ssoLog({method:"reconnectSuccess",message:A}),TA.emitInnerEvent(we.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:Fe,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}_sendAck(A){const e=he({servcmd:"openim.ws_msg_push_ack",data:{SessionData:A}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return IA(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var A;return(null===(A=this._socketAdapter)||void 0===A?void 0:A.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return IA(this,void 0,void 0,function*(){var A;const e=he({servcmd:"heartbeat.alive",data:{}});try{const A=`${e.head.seq}${e.head.servcmd}`;yield this.sendPacket(e,{requestId:A,timeout:3e3})}catch(t){const e=null===(A=HA.get("netWorkMonitor"))||void 0===A?void 0:A.isNetWorkOnline,i=`${ke}.sendHeartbeat failed. isNetWorkOnline:${e} error: ${t}`;this._ssoLog({method:"sendHeartbeatError",message:i}),this._handleConnectStateChange({state:xe,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}_sendHeartbeatIfReady(){return IA(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=b?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(A){const e=`${ke}.networkStatusChange ${JSON.stringify(A)}`;this._ssoLog({method:"networkStatusChange",message:e});const{isNetworkOnline:t,networkType:i}=A;t&&"none"!==i?this._handleConnectStateChange({state:Fe,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Ye}):this._handleConnectStateChange({state:xe,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Ye})}isPrivateNetWork(){const A=HA.get("instance")||{};return A.proxyServer&&!A.fileDownloadProxy}_handleConnectStateChange(A){const{state:e,shouldAttemptReconnect:t,shouldEmitEvent:i,reason:o}=A,n=`${ke}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${t} shouldEmitEvent: ${i} reason: ${o}`;this._currentConnectState!==e&&(this._ssoLog({method:"handleConnectStateChange",message:n}),i&&(be.info("_handleConnectStateChange",` from ${this._currentConnectState} to ${e}`),TA.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:e}}),this._currentConnectState=e,e===xe&&TA.emitInnerEvent(we.SOCKET_DISCONNECTED)),t&&(this._resetReconnectDelay(),Ie.addTask({id:Ue,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this})))}_handleActivityStatusChange(A){var e,t;const i=null===(t=null===(e=this._socketAdapter)||void 0===e?void 0:e._ws)||void 0===t?void 0:t.readyState,o=`${ke}.activityStatusChange ${JSON.stringify(A)} readyState: ${i}`;be.debug("activityStatusChange",o),3===i&&this._handleConnectStateChange({state:xe,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Je})}_resetReconnectDelay(){var A;be.debug(`${ke}._resetReconnectDelay`),Ie.removeTask(Ue);const e=null===(A=HA.get("activityMonitor"))||void 0===A?void 0:A.isActive;this._intendedDelay=e?Pe:1e3}_scheduleReconnectWithBackoff(){var A;const e=null===(A=HA.get("activityMonitor"))||void 0===A?void 0:A.isActive;this._intendedDelay=e?Math.min(5e3,Math.max(Pe,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay));const t=(new Date).toTimeString().slice(0,8),i=`${ke}.scheduleReconnectWithBackoff timeStr: ${t} intendedDelay: ${this._intendedDelay}`;be.debug(i),this.reconnect(),Ie.updateTaskInterval(Ue,this._intendedDelay)}_ssoLog(A){const{method:e,message:t}=A;be.info(e,t)}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(A){IA(this,void 0,void 0,function*(){const e=A.split("/")[2];if(!e.startsWith("ws"))return;const t=`https://${e}/v3/netcheck/getconninfo?${A.slice(A.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield CA({method:"GET",url:t,data:{}})}catch(i){be.warn("diagnoseBySSO",`diagnoseBySSO failed. error:${i.message}`)}})}(this._url),function(A){IA(this,void 0,void 0,function*(){const e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${A.slice(A.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield CA({method:"GET",url:e,data:{}})}catch(t){be.warn(`diagnoseByCDN', 'diagnoseByCDN failed. error:${t.message}`)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(const[A,e]of this._pendingRequests.entries()){const{reject:t,timestamp:i,timeout:o}=e;Date.now()-i>=o&&(this._pendingRequests.delete(A),Date.now()-this._lastDiagnoseAt>=3e4&&this._diagnose(),t({errorCode:EA,errorInfo:"NETWORK_TIMEOUT",data:{requestId:A}}))}}_updateIsBinarySupported(){var A;if(null===(A=HA.get("instance"))||void 0===A?void 0:A.devMode)return void(this._isBinarySupported=!1);const e=cA();(T||v&&"windows"===e||b)&&(this._isBinarySupported=!1)}_isCompressedData(A){const e=new Uint8Array(A);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};const At={init:function(A){HA.set("instance",A),$e.init()},destroy:function(){$e.dispose(),HA.clear(),Ie.dispose()},notificationCenter:TA,channel:$e,store:HA,ssoLog:be,utils:yA,common:me,constants:y},et=A=>"function"==typeof A;function it(A,e,t){const i=t||[];if(!A||!e)return!1;const o=Object.keys(A).filter(A=>!i.includes(A)),n=Object.keys(e).filter(A=>!i.includes(A));return o.length===n.length&&o.every(i=>!!e.hasOwnProperty(i)&&("object"==typeof A[i]&&null!==A[i]?it(A[i],e[i],t):A[i]===e[i]))}var ot;!function(A){A.SDK_READY="sdkStateReady",A.SDK_NOT_READY="sdkStateNotReady",A.SDK_DESTROY="sdkDestroy",A.MESSAGE_RECEIVED="onMessageReceived",A.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",A.MESSAGE_MODIFIED="onMessageModified",A.MESSAGE_REVOKED="onMessageRevoked",A.MESSAGE_READ_BY_PEER="onMessageReadByPeer",A.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",A.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",A.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",A.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",A.CONVERSATION_LIST_UPDATED="onConversationListUpdated",A.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",A.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",A.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",A.GROUP_LIST_UPDATED="onGroupListUpdated",A.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",A.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",A.TOPIC_CREATED="onTopicCreated",A.TOPIC_DELETED="onTopicDeleted",A.TOPIC_UPDATED="onTopicUpdated",A.PROFILE_UPDATED="onProfileUpdated",A.USER_STATUS_UPDATED="onUserStatusUpdated",A.BLACKLIST_UPDATED="blacklistUpdated",A.FRIEND_LIST_UPDATED="onFriendListUpdated",A.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",A.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",A.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",A.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",A.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",A.KICKED_OUT="kickedOut",A.ERROR="error",A.NET_STATE_CHANGE="netStateChange",A.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated",A.SERVER_CONFIG_UPDATED="onServerConfigUpdated",A.PINNED_GROUP_MESSAGE_UPDATED="onPinnedGroupMessageUpdated"}(ot||(ot={}));var nt,rt=ot;!function(A){A.LOGOUT="logout",A.DESTROY="destroy",A.CLOUD_CONFIG_UPDATE="cloud_config_update",A.PROFILE_UPDATE="profile_updated",A.ERROR="error",A.RECONNECTED="reconnected",A.FORCE_OFFLINE="im_open_status.stat_forceoffline",A.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",A.OVERLOAD_PUSH="OverLoadPush.notify2",A.NEW_MESSAGE="new_message",A.MESSAGE_PUSH="im_open_push.msg_push",A.MESSAGE_DELETED="message_deleted",A.MESSAGE_REVOKED="message_revoked",A.MESSAGE_MODIFIED="message_modified",A.SOCKET_DISCONNECTED="socket_disconnected",A.CONVERSATION_UPDATED="conversation_updated",A.TOPIC_MESSAGE_DELETED="topic_message_deleted",A.TOPIC_MESSAGE_REVOKED="topic_message_revoked",A.TOPIC_MESSAGE_MODIFIED="topic_message_modified",A.TOPIC_NEW_MESSAGE="topic_new_message",A.QUALITY_STAT="quality_stat",A.SYNC_CONVERSATION_LIST="sync_conversation_list"}(nt||(nt={}));var st,at=nt;!function(A){A.NEW_INVITATION_RECEIVED="newInvitationReceived",A.INVITEE_ACCEPTED="ts_invitee_accepted",A.INVITEE_REJECTED="ts_invitee_rejected",A.INVITATION_CANCELLED="ts_invitation_cancelled",A.INVITATION_TIMEOUT="ts_invitation_timeout",A.INVITATION_MODIFIED="ts_invitation_modified"}(st||(st={}));var gt=st;const ct=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),lt={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"};var It;!function(A){A.UNSENT="unSend",A.SUCCESS="success",A.FAIL="fail"}(It||(It={}));const ut={modify:at.MESSAGE_MODIFIED,delete:at.MESSAGE_DELETED,revoke:at.MESSAGE_REVOKED};var Et;!function(A){A[A.FORWARD=0]="FORWARD",A[A.BACKWARD=1]="BACKWARD"}(Et||(Et={}));const dt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},lt),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:It,Direction:Et}),ht={[ut.modify]:at.TOPIC_MESSAGE_MODIFIED,[ut.delete]:at.TOPIC_MESSAGE_DELETED,[ut.revoke]:at.TOPIC_MESSAGE_REVOKED},Ct={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},Bt=Object.assign({},Ct),Qt={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},pt=Object.assign(Object.assign(Object.assign(Object.assign({},Qt),{CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3}),{CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),ft=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both"}),{SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both"}),{SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd"}),{SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),mt={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},yt={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},Dt={JOINED:1,QUITTED:2,KICKED:3,ADMIN_SET:4,ADMIN_CANCELED:5,GROUP_PROFILE_UPDATED:6,GROUP_MEMBER_PROFILE_UPDATED:7,TOPIC_PROFILE_UPDATED:8},vt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},mt),{GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom"}),{GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11}),{JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval"}),{INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess"}),{GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers"}),{GROUP_ID_PREFIX:yt,GROUP_TIPS_OPERATION_TYPE:Dt}),wt={IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"},St=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ct),dt),Bt),pt),ft),vt),wt),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),Mt={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},Rt={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},_t={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message",RECEIVE_GROUP_TIPS_NOTIFICATION:"receive-group-tips-notification"},Tt={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report",GROUP_TIPS_RECOVER:"group-tips-recover",HANDLE_GROUP_TIPS_NOTIFICATION:"handle-group-tips-notification"},Nt={[_t.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:Tt.USER_STATUS_UPDATE},{stepId:Tt.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.CONVERSATION_RECOVER},{stepId:Tt.HISTORY_MESSAGE_RECOVER,dependency:Tt.CONVERSATION_RECOVER},{stepId:Tt.BLACKLIST_RECOVER},{stepId:Tt.FRIEND_RECOVER},{stepId:Tt.GROUP_REVOKED_NOTICE_RECOVER,dependency:Tt.HISTORY_MESSAGE_RECOVER},{stepId:Tt.GROUP_TIPS_RECOVER,dependency:Tt.HISTORY_MESSAGE_RECOVER},{stepId:Tt.TOPIC_REQUEST_INFO_RESET},{stepId:Tt.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Tt.UNREAD_MESSAGE_SYNC,Tt.CONVERSATION_RECOVER]},{stepId:Tt.EMIT_C2C_MESSAGE_EVENT,dependency:[Tt.UNREAD_MESSAGE_SYNC,Tt.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[_t.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:Tt.COMMERCIAL_CONFIG_UPDATE},{stepId:Tt.CLOUD_CONFIG_SYNC},{stepId:Tt.USER_PROFILE_SYNC},{stepId:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.FRIEND_AND_BLACKLIST_SYNC},{stepId:Tt.GROUP_LIST_SYNC},{stepId:Tt.CONVERSATION_LIST_SYNC},{stepId:Tt.SIGNALING_MESSAGE_RECOVER,dependency:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[Tt.UNREAD_MESSAGE_SYNC]},{stepId:Tt.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Tt.UNREAD_MESSAGE_SYNC,Tt.CONVERSATION_LIST_SYNC]},{stepId:Tt.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[Tt.GROUP_LIST_SYNC,Tt.CONVERSATION_LIST_SYNC]},{stepId:Tt.CONVERSATION_GROUP_LIST_SYNC},{stepId:Tt.CONVERSATION_GROUP_UPDATE,dependency:[Tt.CONVERSATION_LIST_SYNC,Tt.CONVERSATION_GROUP_LIST_SYNC]},{stepId:Tt.QUALITY_REPORT}],[_t.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:Tt.HANDLE_C2C_NEW_MESSAGE},{stepId:Tt.UNREAD_MESSAGE_SYNC},{stepId:Tt.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Tt.HANDLE_C2C_NEW_MESSAGE},{stepId:Tt.EMIT_C2C_MESSAGE_EVENT,dependency:[Tt.HANDLE_C2C_NEW_MESSAGE,Tt.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:Tt.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Tt.UNREAD_MESSAGE_SYNC]}],[_t.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:Tt.HANDLE_GROUP_NEW_MESSAGE},{stepId:Tt.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Tt.HANDLE_GROUP_NEW_MESSAGE},{stepId:Tt.UPDATE_GROUP_NEXT_SEQUENCE,dependency:Tt.HANDLE_GROUP_NEW_MESSAGE},{stepId:Tt.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:Tt.HANDLE_GROUP_NEW_MESSAGE},{stepId:Tt.EMIT_GROUP_MESSAGE_EVENT,dependency:[Tt.HANDLE_GROUP_NEW_MESSAGE,Tt.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}],[_t.RECEIVE_GROUP_TIPS_NOTIFICATION]:[{stepId:Tt.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:Tt.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Tt.HANDLE_GROUP_TIPS_NOTIFICATION}]},bt={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},Gt={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"},kt=["login","getMyProfile","getUserProfile","updateMyProfile","setSelfStatus","getUserStatus","subscribeUserStatus","unsubscribeUserStatus","modifyMessage","deleteGroupMember","dismissGroup","getGroupMemberList","getGroupOnlineMemberCount","joinGroup","markGroupMemberList","quitGroup","searchCloudMessages","searchCloudGroups","searchCloudGroupMembers","searchCloudUsers","getMyFollowingList","getMyFollowersList","getMutualFollowersList","followUser","unfollowUser","getUserFollowInfo","checkFollowType","getFriendProfile","addFriend","deleteFriend","updateFriend","checkFriend","setFriendApplicationRead","createFriendGroup","deleteFriendGroup","addToFriendGroup","removeFromFriendGroup","renameFriendGroup","changeGroupOwner","createGroup","dismissGroup","getGroupList","getGroupOnlineMemberCount","getGroupProfile","searchGroupByID","updateGroupProfile","handleGroupApplication","deleteGroupAttributes","getGroupAttributes","initGroupAttributes","setGroupAttributes","addGroupMember","deleteGroupMember","getGroupMemberList","getGroupMemberProfile","setGroupMemberMuteTime","setGroupMemberNameCard","setGroupMemberRole","deleteMessage","revokeMessage","setMessageExtensions","getMessageExtensions","deleteMessageExtensions","getMessageList","addMessageReaction","removeMessageReaction","clearHistoryMessage","sendMessageReadReceipt","getMessageReadReceiptList","getGroupMessageReadMemberList","invite","accept","cancel","reject","modifyInvitation","deleteConversation","pinConversation","setMessageRead","setAllMessageRead","getConversationList","getTotalUnreadMessageCount","renameConversationGroup","deleteConversationGroup","markConversation","setConversationCustomData","deleteConversationsFromGroup","addConversationsToGroup","createConversationGroup"];var Lt,Ut,Ft,Ot=Object.freeze({__proto__:null,ERROR_CODE:Mt,InnerEvent:at,NEED_LOG_API:kt,OuterConstant:St,OuterEvent:rt,PUSH:wt,QUALITY_METRICS:bt,SDK_EDITION:Rt,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:Gt,SignalingEvent:gt,WEB_PUSH_ACCOUNT_TYPE:1,WORKFLOW_DEFINITIONS:Nt,WORKFLOW_NAME:_t,WORKFLOW_STEP:Tt});!function(A){A[A.USER_INITIATED=0]="USER_INITIATED",A[A.KICKED_OUT=1]="KICKED_OUT"}(Lt||(Lt={})),function(A){A[A.multipleAccount=1]="multipleAccount",A[A.multipleDevice=2]="multipleDevice",A[A.restApi=3]="restApi"}(Ut||(Ut={})),function(A){A[A.multipleDevice=3002]="multipleDevice",A[A.multipleAccount=3003]="multipleAccount",A[A.usersigExpired=70001]="usersigExpired",A[A.restApi=20002]="restApi"}(Ft||(Ft={}));const xt={[Ut.multipleAccount]:"multipleAccount",[Ut.multipleDevice]:"multipleDevice",[Ut.restApi]:"REST_API_Kick",[Ft.multipleAccount]:"multipleAccount",[Ft.multipleDevice]:"multipleDevice",[Ft.restApi]:"REST_API_Kick",[Ft.usersigExpired]:"userSigExpired"},Pt="login_online_presence_task",{ERROR:Yt,DESTROY:Jt,FORCE_OFFLINE:Ht}=at,{KICKED_OUT_MULT_ACCOUNT:qt,KICKED_OUT_MULT_DEVICE:Vt,KICKED_OUT_REST_API:jt,ACCOUNT_A2KEY_EXPIRED:Kt,MSG_A2KEY_EXPIRED:Wt}=Mt;class zt{init(){const{notificationCenter:A}=At;A.subscribeInnerEvent(Ht,this._handleForceOfflineFromServerPush,this),A.subscribeInnerEvent(Yt,Wt,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),A.subscribeInnerEvent(Yt,Kt,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),A.subscribeInnerEvent(Yt,qt,this._handleForceOfflineFromResponse,this),A.subscribeInnerEvent(Yt,Vt,this._handleForceOfflineFromResponse,this),A.subscribeInnerEvent(Yt,jt,this._handleForceOfflineFromResponse,this),A.subscribeInnerEvent(Jt,this._dispose,this)}_handleForceOfflineFromServerPush(A){var e;if(!0===(null===(e=At.store.get("login"))||void 0===e?void 0:e.isLoggedIn)){const{EventArray:e=[]}=(null==A?void 0:A.body)||{};this._extractKickedOutMessages(e).forEach(A=>{const{KickoutMsgNotify:{KickType:e,NewInstInfo:t}}=A;this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}}_extractKickedOutMessages(A){return A.reduce((A,e)=>[...A,...e.C2cNotifyMsgArray||[]],[]).filter(A=>{var e;return this._isKickedOut(null===(e=null==A?void 0:A.KickoutMsgNotify)||void 0===e?void 0:e.KickType)})}_handleForceOfflineFromResponse(A){const{errorCode:e}=A;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(A){return IA(this,void 0,void 0,function*(){const{kickedOutReasonCode:e}=A,{ssoLog:t,utils:{safeStringify:i}}=At;try{this._logKickedOutEvent(A),this._shouldLogoutAfterKickedOut(e)&&(yield At.login.loginAction.logout(Lt.KICKED_OUT))}catch(o){t.debug("_processKickedOutReasonInfo",` fail ${i(o)}`)}finally{At.notificationCenter.emitOuterEvent(rt.KICKED_OUT,{data:{type:xt[e]},name:rt.KICKED_OUT})}})}_logKickedOutEvent(A){const{kickedOutReasonCode:e,newInstanceInfo:t={}}=A,i=`type:${xt[e]} newInstanceInfo: ${JSON.stringify(t)}`;At.ssoLog.warn("kickedOut",i)}_isKickedOut(A){return[Ut.multipleAccount,Ut.multipleDevice,Ut.restApi].includes(A)}_isChatLoginEvent(A){const{requestHead:e}=A||{};return 1!==(null==e?void 0:e.idtype)}_shouldLogoutAfterKickedOut(A){return![Ft.usersigExpired,Ut.restApi].includes(A)}_dispose(){const{notificationCenter:A}=At;A.unSubscribeInnerEvent(Ht,this._handleForceOfflineFromServerPush,this),A.unSubscribeInnerEvent(Yt,Kt,this._handleForceOfflineFromResponse,this),A.unSubscribeInnerEvent(Yt,Wt,this._handleForceOfflineFromResponse,this),A.unSubscribeInnerEvent(Yt,qt,this._handleForceOfflineFromResponse,this),A.unSubscribeInnerEvent(Yt,Vt,this._handleForceOfflineFromResponse,this),A.unSubscribeInnerEvent(Yt,jt,this._handleForceOfflineFromResponse,this),A.unSubscribeInnerEvent(Jt,this._dispose,this)}}function Zt(A){return IA(this,void 0,void 0,function*(){const e="im_open_status.wslogin",t=At.common.generateProtocolData({servcmd:e,data:{State:"Online",is_web_uniapp:0,InstType:0,CustomInfo:A}}),i=`${t.head.seq}${e}`,o=yield At.channel.sendPacket(t,{timeout:9e4,requestId:i});if(o){const{HelloInterval:A,InstId:e,TinyId:t,TimeStamp:i,CustomStatus:n,PurchaseBits:r,A2Key:s,RichMsgAuthKey:a,ErrorCode:g,ErrorInfo:c,ActionStatus:l}=o;return{helloInterval:A,instanceID:e,tinyID:t,timeStamp:i,customStatus:n,purchaseBits:r,a2Key:s,authKey:a,errorCode:g,errorInfo:c,actionStatus:l}}})}function Xt(A){var e;try{const t=HA.getStorage("errorMessage");if(!A||!t)return"";const i=(null===(e=JSON.parse(t))||void 0===e?void 0:e.errorMessage)||{},{isIntl:o=!1,code:n,replacement1:r="",replacement2:s=""}=A;if(!n)return"";const a=o?`${n}_en`:`${n}_cn`;let g=i[i[a]?a:n]||"";return g&&(r&&(g=g.replace("$replacement1",r)),s&&(g=g.replace("$replacement2",s))),g}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class $t extends Error{constructor(A){const{functionName:e="Unknown",code:t,message:i="",data:o="",moreMessage:n=""}=A;let r=i;t&&!i&&(r=Xt(A));let s=t?`${e} failed. error: {"message": ${r}, "code": ${t}}`:`${e} failed. error: {"message": ${r}}`;s=`${s} ${n}`,super(),this.code=t,this.errorCode=t,this.errorMessage=r,this.message=s,this.data=o}}function Ai(A,e){var t;if(A&&!0!==(null===(t=At.store.get("login"))||void 0===t?void 0:t.isLoggedIn))throw new $t({code:Mt.USER_NOT_LOGGED_IN,functionName:e})}function ei(A,e,t){if(Array.isArray(A))for(let i=0;i{return A===(e=i,Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase());var e})){for(let t=0;t{const{interceptor:e,context:i}=A;e.apply(i,[t])})}function si(A,e){ii.push({interceptor:A,context:e})}function ai(A){const{params:e,auth:t}=A;e&&"object"==typeof e&&Object.assign(ni,e),t&&"object"==typeof t&&Object.assign(oi,t)}function gi(A){return At.store.get("commercialConfig").get(A)}class ci{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(A,e)=>{const t=Date.now();e?(this._stepStartTimes.set(`${A}-${e}`,t),At.ssoLog.debug("_executeWorkflowStep",`[Workflow ${A}] Step ${e} started at ${new Date(t).toISOString()}`)):(this._workflowStartTimes.set(A,t),At.ssoLog.debug("_executeWorkflowStep",`[Workflow ${A}] started at ${new Date(t).toISOString()}`))},success:(A,e)=>{const t=Date.now();if(e){const i=this._stepStartTimes.get(`${A}-${e}`),o=i?t-i:0;this._stepStartTimes.delete(`${A}-${e}`),At.ssoLog.debug("_executeWorkflowStep",`[Workflow ${A}] Step ${e} completed successfully at ${new Date(t).toISOString()} (${o}ms)`)}else{const e=this._workflowStartTimes.get(A),i=e?t-e:0;this._workflowStartTimes.delete(A),At.ssoLog.debug("_executeWorkflowStep",`[Workflow ${A}] completed successfully at ${new Date(t).toISOString()} (${i}ms)`)}},error:(A,e,t)=>{const{ssoLog:i,utils:{safeStringify:o}}=At,n=Date.now();if(e){const r=this._stepStartTimes.get(`${A}-${e}`),s=r?n-r:0;this._stepStartTimes.delete(`${A}-${e}`),i.error("_executeWorkflowStep",`[Workflow ${A}] Step ${e} failed at ${new Date(n).toISOString()} (${s}ms) ${o(t)}`,{error:t})}else{const e=this._workflowStartTimes.get(A),r=e?n-e:0;this._workflowStartTimes.delete(A),i.error("_executeWorkflowStep",`[Workflow ${A}] failed at ${new Date(n).toISOString()} (${r}ms) ${o(t)}`,{error:t})}}}}static getInstance(){return ci._instance||(ci._instance=new ci),ci._instance}static setInstance(A){ci._instance=A}init(){this._initializeWorkflows()}registerWorkflowStep(A,e,t,i){if(!this._handlers.has(A))return void At.ssoLog.debug("registerWorkflowStep",`Workflow '${A}' not defined in core`);if(!Nt[A].find(A=>A.stepId===e))return void At.ssoLog.debug("registerWorkflowStep",`Step '${e}' not defined in workflow '${A}'`);const o=this._handlers.get(A);o.has(e)||o.set(e,i?t.bind(i):t)}executeWorkflow(A,e){return IA(this,void 0,void 0,function*(){if(!this._validateWorkflow(A))return;At.ssoLog.debug("executeWorkflow",`[Workflow ${A}] Started execution at ${(new Date).toISOString()}`);const t=Nt[A],i={},o={cancelled:!1};this._activeWorkflows.set(A,{cancelToken:o});try{const n=new Map;t.forEach(A=>{n.set(A.stepId,A)});const r={workflowName:A,pendingSteps:new Set(t.map(A=>A.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:n,stepResults:i,data:e,cancelToken:o};yield new Promise((e,t)=>{const i=()=>{o.cancelled?e():this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:A}).filter(A=>!r.runningSteps.has(A)).forEach(o=>{r.completedSteps.has(o)||r.runningSteps.has(o)||this._executeWorkflowStep(o,r,{onComplete:()=>{0!==r.pendingSteps.size?0===this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:A}).filter(A=>!r.runningSteps.has(A)).length&&0===r.runningSteps.size&&(At.ssoLog.debug("executeWorkflow",`Workflow ${A} completed with some steps skipped due to dependency failures`),e()):e()},onError:t,onStepComplete:i})})};i()}),At.ssoLog.debug("executeWorkflow",`[Workflow ${A}] Completed execution at ${(new Date).toISOString()}`)}catch(n){At.ssoLog.error("executeWorkflow",`[Workflow ${A}] Failed execution at ${(new Date).toISOString()}`,{error:n})}finally{this._activeWorkflows.delete(A)}})}_executeWorkflowStep(A,t,i){return IA(this,void 0,void 0,function*(){const{workflowName:o,runningSteps:n,stepMap:r,stepResults:s,data:a}=t;n.add(A),this._logWorkflowExecution(o,A,"start");try{const i=r.get(A);let n=null;(null==i?void 0:i.dependency)&&(e(i.dependency)?n=s[i.dependency]:Array.isArray(i.dependency)&&(n={},i.dependency.forEach(A=>{n[A]=s[A]})));const g=this._handlers.get(o).get(A);if(g){const e=yield Promise.resolve(g({data:a,result:n}));s[A]=e,this._logWorkflowExecution(o,A,"success")}t.completedSteps.add(A)}catch(g){const e=`[Workflow].${o}.${A}`,{errorCode:t,errorInfo:n=`${e} failed`}=g||{},r=new $t({functionName:e,code:t,message:n});At.ssoLog.error(e,n,{error:r}),this._logWorkflowExecution(o,A,"error",g),i.onError(g)}finally{n.delete(A),t.pendingSteps.delete(A),i.onStepComplete(),i.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(Nt).forEach(A=>{this._handlers.has(A)||this._handlers.set(A,new Map)})}_cancelWorkFlow(A){const e=this._activeWorkflows.get(A);if(!e)return;const{cancelToken:t}=e;t.cancelled=!0,this._activeWorkflows.delete(A)}_cancelAllWorkflows(){Object.keys(Nt).forEach(A=>{this._cancelWorkFlow(A)})}_validateWorkflow(A){return!!Nt[A]&&!!this._handlers.get(A)}_getExecutableSteps(A){const{pendingSteps:t,completedSteps:o,stepMap:n,workflowName:r}=A;return Array.from(t).filter(A=>{const t=n.get(A)||{},{dependency:s,skipIfDependencyMissing:a=!0}=t;if(!s)return!0;if(e(s))return this._isStepRegistered({workflowName:r,stepId:s})?o.has(s):!a;if(i(s)){if(s.filter(A=>!this._isStepRegistered({workflowName:r,stepId:A})).length>0&&a)return!1;for(const A of s)if(!o.has(A))return!1;return!0}return!1})}_isStepRegistered(A){var e;const{workflowName:t,stepId:i}=A;return null===(e=this._handlers.get(t))||void 0===e?void 0:e.has(i)}_logWorkflowExecution(A,e,t,i){this._logHandlers[t](A,e)}}const li=new Map,Ii=({type:A,groupID:e})=>A===St.GRP_COMMUNITY||`${e}`.startsWith(yt.COMMUNITY)&&!`${e}`.includes(yt.TOPIC),ui=(A="")=>{const e=A.startsWith("GROUP")?A.replace("GROUP",""):A;return e.startsWith(yt.COMMUNITY)&&`${e}`.includes(yt.TOPIC)},Ei="openim",di="million_group_open_http_svc";function hi(A){return IA(this,void 0,void 0,function*(){const{servcmd:e,data:t}=function(A){const{data:e}=A;return Ci(e)||Bi(e)}(A)?function(A){let{servcmd:e,data:t}=A;return Bi(t)?function(A){const{servcmd:e,data:t}=A;let{GroupId:i=""}=t;const o=i;return[i]=o.split(yt.TOPIC),{servcmd:Qi(e),data:Object.assign(Object.assign({},t),{GroupId:i,TopicId:o})}}(A):(Ci(t)&&(e=Qi(e)),{servcmd:e,data:t})}(A):A,i=At.common.generateProtocolData({servcmd:e,data:t}),o=`${i.head.seq}${e}`;return At.channel.sendPacket(i,{requestId:o})})}function Ci(A){const{Type:e,GroupId:t,GroupIdList:i=[]}=A,o=t||i[0]||"";return Ii({type:e,groupID:o})}function Bi(A){const{GroupId:e=""}=A;return ui(e)}function Qi(A){if(A.includes(Ei))return A;const e=A.split(".")[1];return`${di}.${e}`}function pi(){var A;return null===(A=At.store.get("login"))||void 0===A?void 0:A.userId}const fi=A=>i(A)||o(A),mi=(e,t,i,o)=>{if(!fi(e)||!fi(t))return 0;let n=0;const r=Object.keys(t);let s;for(let a=0,g=r.length;a{if(A(t))return"";switch(e){case St.MSG_TEXT:return t.text||"";case St.MSG_IMAGE:return"[Image]";case St.MSG_LOCATION:return"[Location]";case St.MSG_AUDIO:return"[Voice]";case St.MSG_VIDEO:return"[Video]";case St.MSG_FILE:return"[File]";case St.MSG_CUSTOM:return"[Custom Messages]";case St.MSG_GRP_TIP:return"[Group Notification]";case St.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case St.MSG_FACE:return"[Animated Sticker]";case St.MSG_MERGER:return"[Chat Record]";default:return""}},Di=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],vi="im_sdk_config_mgr.fetch_config",wi="im_sdk_config_mgr.push_configv2",Si="cloud-config",Mi=2996,Ri=new class{init(A){this.core=A}};function _i(A){return IA(this,void 0,void 0,function*(){const{sdkAppId:e}=Ri.core.store.get("instance")||{},t=Ri.core.helper.generateProtocolData({servcmd:vi,data:{uint32_sdkappid:e,uint64_version:A}}),i=`${t.head.seq}${vi}`;return Ri.core.channel.sendPacket(t,{requestId:i})})}var Ti=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(A){this._core=A;const{notificationCenter:e,InnerEvent:t,helper:i,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:n},channel:r}=A;e.subscribeInnerEvent(wi,this._handlePushedConfig,this),i.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,n.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),i.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Di),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(A){return IA(this,void 0,void 0,function*(){var e;const t={code:0,data:""};return A?(t.data=(null===(e=this._core.store.get("cloudConfig"))||void 0===e?void 0:e[A])||"",t):t})}checkMethodCallOverLimit(A){if(!this._cmdFrequencyLimitMap.has(A))return;if(!this._methodCallFrequencyMap.has(A))return void this._methodCallFrequencyMap.set(A,{startTime:Date.now(),methodCallCounter:1});const{count:e,interval:t}=this._cmdFrequencyLimitMap.get(A);let{startTime:i,methodCallCounter:o}=this._methodCallFrequencyMap.get(A);if(Date.now()-i>1e3*t)this._methodCallFrequencyMap.set(A,{startTime:Date.now(),methodCallCounter:1});else if(o+=1,this._methodCallFrequencyMap.set(A,{startTime:i,methodCallCounter:o}),o>e)throw new this._core.helper.ChatError({code:Mi,replacement1:A})}_handlePushedConfig(A){return IA(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;e.info("_handlePushedConfig",t(A)),yield this._updateCloudConfig(A)})}_handleLoginSuccess(){return IA(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:e}}=this._core;try{if(this._canFetch()){const t=yield _i(this._version);A.info("_fetchCloudConfigIfLogin",e(t)),yield this._updateCloudConfig(t)}this._core.helper.taskScheduler.addTask({id:Si,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(t){A.error("_fetchCloudConfigIfLogin",e(t))}})}_fetchCloudConfigIfReady(){return IA(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:e}}=this._core;if(this._canFetch())try{const t=yield _i(this._version);A.info("_fetchCloudConfigIfReady",e(t)),yield this._updateCloudConfig(t)}catch(t){A.error("_fetchCloudConfigIfReady",e(t))}})}_updateCloudConfig(A){return IA(this,void 0,void 0,function*(){const e=this._parseCloudConfig(A);e&&(this._core.store.set("cloudConfig",e),yield this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e),this._core.notificationCenter.emitOuterEvent(this._core.OuterEvent.SERVER_CONFIG_UPDATED,{name:this._core.OuterEvent.SERVER_CONFIG_UPDATED,data:{config:e}}))})}_canFetch(){const{isLoggedIn:A}=this._core.store.get("login")||{};return A&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(A){const{int32_error_code:e,str_error_message:t,str_json_config:i,uint32_expired_time:o,uint32_sdkappid:n,uint64_version:r}=A;let s=null;if(0===e){if(this._version!==r)try{s=JSON.parse(i),this._version=r}catch(a){}this._expirationTime=Date.now()+1e3*o}else this._expirationTime=void 0===e?Date.now()+36e5:Date.now()+12e4;return s}_parseCmdFreqLimit(){return IA(this,void 0,void 0,function*(){var A;let e=null===(A=yield this.getServerConfig("cmd_frequency_limit"))||void 0===A?void 0:A.data;const{isEmpty:t}=this._core.utils;if(!t(e))try{e=JSON.parse(e),this._updateCmdFreqLimitMap(e)}catch(i){console.warn(i)}})}_updateCmdFreqLimitMap(A){A.forEach(A=>{this._cmdFrequencyLimitMap.set(A.cmd,{interval:A.interval,count:A.count})})}_reset(){this._core.helper.taskScheduler.removeTask(Si),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Di),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(wi,this._handlePushedConfig,this),A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this),this._reset()}};class Ni{constructor(A=0,e=0){this.high=A,this.low=e}equal(A){return null!==A&&this.low===A.low&&this.high===A.high}toString(){const A=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let A=8-e.length;for(;A;)e=`0${e}`,A--}return A+e}}const bi={SEARCH_GRP_SNS:new Ni(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new Ni(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new Ni(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new Ni(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new Ni(0,Math.pow(2,6)).toString(),USER_STATUS:new Ni(0,Math.pow(2,7)).toString(),CONV_MARK:new Ni(0,Math.pow(2,9)).toString(),CONV_GROUP:new Ni(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new Ni(0,Math.pow(2,11)).toString(),MSG_EXT:new Ni(0,Math.pow(2,13)).toString(),GRP_COUNTER:new Ni(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new Ni(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new Ni(Math.pow(2,7)).toString(),PLUGIN_CS:new Ni(Math.pow(2,8)).toString(),PLUGIN_PUSH:new Ni(Math.pow(2,9)).toString(),PLUGIN_BOT:new Ni(Math.pow(2,10)).toString(),MSG_REACTION:new Ni(Math.pow(2,16)).toString(),FOLLOW:new Ni(Math.pow(2,20)).toString()},Gi="CommercialConfig",ki="commercial-config";var Li,Ui,Fi=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map,this._purchaseBits="0"}install(A){this._core=A;const{helper:e,notificationCenter:t,constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:o,InnerEvent:n}}=A;t.subscribeInnerEvent(n.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),t.subscribeInnerEvent(n.LOGOUT,this._handleLogout,this),t.subscribeInnerEvent(n.DESTROY,this._dispose,this),e.registerWorkflowStep(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),A.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this),A.helper.registerExperimentalAPI("queryCommercialAbility",this)}isCommercialAbilityEnabled(A){return IA(this,void 0,void 0,function*(){const e=parseInt(A,10).toString(2),{length:t}=e;let i,o=!0;for(let A=t-1,n=0;A>=0;A--,n++)if("1"===e.charAt(A)&&(i=n<32?new Ni(0,2**n).toString():new Ni(2**(n-32),0).toString(),!this._featureMap.get(i))){o=!1;break}return this._core.ssoLog.debug("isFeatureEnabled",`${Gi}.isFeatureEnabled decimalNumber:${A} key:${i} ret:${o}`),{code:0,data:{enabled:o}}})}queryCommercialAbility(){return this._purchaseBits}_fetchAndParseCommercialConfig(){return IA(this,void 0,void 0,function*(){var A;const{ssoLog:e,utils:{safeStringify:t},common:{buildAndSendPacket:i}}=this._core;try{this._isFetching=!0;const e=yield i({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null===(A=this._core.store.get("instance"))||void 0===A?void 0:A.sdkAppId}});(null==e?void 0:e.body)&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(o){e.error("_fetchAndParseCommercialConfig",t(o))}finally{this._isFetching=!1}})}_syncCommercialConfig(A){return IA(this,void 0,void 0,function*(){const{purchaseBits:e}=(null==A?void 0:A.data)||{};e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:ki,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var A;const e=null===(A=this._core.store.get("login"))||void 0===A?void 0:A.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(A){(null==A?void 0:A.body)&&(this._parseCommercialConfig(A.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return IA(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(A){const{ssoLog:e}=this._core;if("object"!=typeof A)return;const{int32_error_code:t,str_error_message:i,str_purchase_bits:o,uint32_expired_time:n}=A;0===t?(this._parsePurchaseBits(o),this._expirationTime=Date.now()+1e3*n):void 0===t?(e.warn("_parseCommercialConfig",`${Gi}._parseCommercialConfig failed. Invalid message format:`,A),this._expirationTime=Date.now()+36e5):(e.warn("_parseCommercialConfig",`${Gi}._parseCommercialConfig errorCode:${t} errorMessage:${i}`),this._expirationTime=Date.now()+12e4)}_isValidPurchaseBits(A){return A&&"string"==typeof A&&A.length>=1&&A.length<=64&&/[01]{1,64}/.test(A)}_parsePurchaseBits(A){const{ssoLog:e,utils:{safeStringify:t}}=this._core;if(this._isValidPurchaseBits(A)){this._purchaseBits=A,this._featureMap.clear(),this._methodKeyMap.clear();let e=null;for(let t=A.length-1,i=0;t>=0;t--,i++)if(e=i<32?new Ni(0,2**i).toString():new Ni(2**(i-32),0).toString(),"1"===A[t]){this._featureMap.set(e,!0);const A=this._getKeyByValue(bi,e);A&&this._methodKeyMap.set(A,!0)}else{this._featureMap.set(e,!1);const A=this._getKeyByValue(bi,e);A&&this._methodKeyMap.set(A,!1)}}else e.warn("_parsePurchaseBits",`${Gi}.parsePurchaseBits invalid purchases:${t(A)}`)}_getKeyByValue(A,e){const t=Object.entries(A).find(([A,t])=>t===e);return t?t[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(ki),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear(),this._purchaseBits="0"}},Oi=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(A){this._core=A;const{notificationCenter:e,InnerEvent:t,channel:i}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),i.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(A){if(!this._serverOverloadInfoMap.has(A))return;const{overloadStartTimestamp:e,delaySeconds:t}=this._serverOverloadInfoMap.get(A);if(Date.now()-e<=1e3*t)throw new this._core.helper.ChatError({functionName:A,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(A)}_handleOverLoadPush(A){const{OverLoadServCmd:e,DelaySecs:t}=A;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.OVERLOAD_PUSH,this._handleOverLoadPush,this),A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}},xi=new class{constructor(){this.name="ConfigCenter"}install(A){Ri.init(A),Ti.install(A),Fi.install(A),Oi.install(A)}},Pi=new class{constructor(){this.name="ErrorMessage",this._core=null}install(A){return IA(this,void 0,void 0,function*(){if(this._core=A,this._canFetch()){const A=yield this._fetchErrorMessage();if(!A)return;const e=this._parseResponse(A);this._saveErrorMessage(e)}})}_canFetch(){const A=this._core.store.getStorage("errorMessage");return!A||this._isExpired(A)}_saveErrorMessage(A){this._core.store.setStorage("errorMessage",{errorMessage:A,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return IA(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(E){console.error(E)}})}_isExpired(A){if(!A)return!0;const{errorMessageSavedTime:e}=A;return e&&(new Date).getTime()-e>=6048e5}_parseResponse(A){if("string"==typeof A){const e=A.split(";\n"),t={},i=new RegExp(/'/g);for(let A=0;A{var o,n,r;const s=function(A,e){const{From_Account:t,From_AccountHeadurl:i,From_AccountNick:o,IsNeedReadReceipt:n,MsgBody:r,MsgClientTime:s,MsgRandom:a,MsgSeq:g,MsgTimeStamp:c,SendMsgControl:l,SupportMessageExtension:I,To_Account:u,TinyId:E,MsgCheckResult:d,CloudCustomData:h,IsPeerRead:C,MsgFlagBits:B,MsgVersion:Q,EventArray:p}=A;return{from:t,avatar:i,nick:o,needReadReceipt:1===n,readReceiptSentByPeer:C,clientTime:s,messageFlagBits:B,random:a,sequence:g,time:c,messageControlInfo:l,isSupportExtension:I,to:u,tinyID:E,checkResult:d,cloudCustomData:h,messageVersion:Q,eventArray:p,elements:e.message.messageHelper.parseServerPushMessageElement(r)}}(A,e);if(null===(r=null===(n=null===(o=null==A?void 0:A.EventArray)||void 0===o?void 0:o[0])||void 0===n?void 0:n.hasOwnProperty)||void 0===r?void 0:r.call(n,"C2cNotifyMsgArray"))i.push(...function(A){var e;const t=[];return null===(e=A.EventArray)||void 0===e||e.forEach(A=>{var e,i;const{C2cNotifyMsgArray:o}=A,n=null===(i=null===(e=null==o?void 0:o[0])||void 0===e?void 0:e.WithdrawC2cMsgNotify)||void 0===i?void 0:i.C2cWithdrawInfoArray;Array.isArray(n)&&t.push(...n)}),t}(A));else{const A=e.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),{elements:i}=s;A.setElement(i),t.push(A)}}),{unreadMessageList:t,revokedMessageList:i}}(A.MsgList,e);return{syncFlag:null==A?void 0:A.SyncFlag,unreadMessageList:n,revokedMessageList:a,unreadCountList:t,overflowUnreadCountList:i,cookie:null==A?void 0:A.Cookie,groupTipList:o}}catch(a){console.warn(a)}})}!function(A){A[A.START_SYNC=0]="START_SYNC",A[A.SYNCING=1]="SYNCING",A[A.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(Li||(Li={})),function(A){A[A.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",A[A.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(Ui||(Ui={}));var Ji=new class{constructor(){this.name="UnreadMessageSynchronizer",this._unreadDBMessageMap=new Map,this._cookie=""}install(A){this._core=A;const{constants:e}=A;A.helper.registerWorkflowStep(e.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,e.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),A.helper.registerWorkflowStep(e.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,e.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),A.helper.registerWorkflowStep(e.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,e.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.LOGOUT,this._reset,this),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(A){return IA(this,void 0,void 0,function*(){const{isAfterReOnline:e=!1,isAfterNewMessageReceived:t=!1,isAfterLogin:i=!1}=A||{};let o=Li.START_SYNC;const n=[],r=[],s=[],a=[];for(;this._canContinueSync({cookie:this._cookie,syncFlag:o});){const A=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:o,syncTriggerEvent:t?Ui.NEW_MESSAGE_RECEIVED:Ui.LOGIN_SUCCESS});if(!A)break;const{unreadMessageList:i=[],revokedMessageList:g=[],overflowUnreadCountList:c,unreadCountList:l,groupTipList:I}=A;if(this._cookie=(null==A?void 0:A.cookie)||"",o=null==A?void 0:A.syncFlag,this._parseAndSaveUnreadMessageList(i),s.push(...g),this._updateConversationUnreadOptions({unreadCountList:l,overflowUnreadCountList:c,conversationUpdateFieldList:n}),Array.isArray(I)&&r.push(...I),e){const{messages:A}=this._handleNewMessageList(i);a.push(...A)}}return e?{conversationUpdateFieldList:n,revokedMessageList:s,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r,messages:a}:{conversationUpdateFieldList:n,isInstantMessage:!i,isUnreadC2CMessage:!0,revokedMessageList:s,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r}})}_syncUnreadDBMessageAfterLogin(){return IA(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(A){return IA(this,void 0,void 0,function*(){if(1===A.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(A){const{unreadCountList:e,overflowUnreadCountList:t,conversationUpdateFieldList:i}=A,{constants:{OuterConstant:{CONV_C2C:o,CONV_SYSTEM:n}}}=this._core;null==e||e.forEach(A=>{const{From_Account:e,UnreadCount:t}=A;if(e!==n){const A=i.find(({conversationID:A})=>A===`${o}${e}`);A?A.unreadCount=t:i.push({conversationID:`${o}${e}`,unreadCount:t,type:o})}}),null==t||t.forEach(A=>{const{From_Account:e,LastMsgTime:t}=A;e!==n&&(i.find(({conversationID:A})=>A===`${o}${e}`)||i.push({conversationID:`${o}${e}`,type:o,lastMsgTime:t}))})}_syncUnreadDBMessageAfterReOnline(){return IA(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(A){var e;const{messageDataHandler:t}=this._core.message||{},i=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,{from:o,nick:n,avatar:r,conversationID:s=""}=A;if(o!==i){const e=t.getLatestMsgSentByPeer(s);if(e){const{nick:i,avatar:o}=e;n&&r?n===i&&r===o||t.updateNickAndAvatarOfSentMessage({conversationID:s,latestNick:n,latestAvatar:r,isSentByMe:!1}):(A.nick=i,A.avatar=o)}}else{const A=t.getLatestMsgSentByMe(s);!A||n===A.nick&&r===A.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:s,latestNick:n,latestAvatar:r,isSentByMe:!0})}}_handleNewMessageList(A){const{messageDataHandler:e}=this._core.message||{},t=new Map,i=[];return A.forEach(A=>{this._updateMessageProfile(A);let o=1===A.isModified;if(e.isMessageSentByCurrentInstance(A)?A.isModified=o:o=!1,A.isOnlineMessage())A._onlineOnlyFlag=!0,e.isMessageSentByCurrentInstance(A)||i.push(A);else if(!e.isInMessageList(A)){if(e.storeConversationMessage(A)){const{conversationID:e,conversationType:i,conversationSubType:o,flow:n,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:s}=A,a=s?"":A;t.has(e)?(t.get(e).lastMessage=a,"in"===n&&(r||t.get(e).unreadCount++)):t.set(e,{conversationID:e,type:i,subType:o,unreadCount:r||"in"!==n?0:1,lastMessage:a})}e.isMessageSentByCurrentInstance(A)&&!o||i.push(A)}}),{messages:i,conversationOptions:t}}_fetchUnreadDBMessage(A){return IA(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;try{const i="unread-message-synchronizer._fetchUnreadDBMessage";e.debug("_fetchUnreadDBMessage",`${i} options:${t(A)}`);const o=yield Yi(A,this._core);if(!o)return null;const{syncFlag:n,unreadMessageList:r,revokedMessageList:s,cookie:a,unreadCountList:g,overflowUnreadCountList:c,groupTipList:l}=o;return this._parseAndSaveUnreadMessageList(r),{syncFlag:n,cookie:a,unreadMessageList:r,revokedMessageList:s,unreadCountList:g,overflowUnreadCountList:c,groupTipList:l}}catch(i){console.log(i)}})}_canContinueSync({cookie:A,syncFlag:e}){var t;return e===Li.START_SYNC||e===Li.SYNCING&&!(null===(t=this._core)||void 0===t?void 0:t.helper.isEmpty(A))}_parseAndSaveUnreadMessageList(A){A.forEach(A=>{const{ID:e}=A;this._unreadDBMessageMap.set(e,A)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var A,e;null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Hi=new class{init(A){var e;this._core=A,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this),null===document||void 0===document||document.addEventListener("visibilitychange",this._visibilityChangeHandler),null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var A,e;const t="visible"===document.visibilityState;null===(A=this._core)||void 0===A||A.store.set("activityMonitor",{isActive:t}),null===(e=this._core)||void 0===e||e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var A;null===(A=this._core)||void 0===A||A.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this),this._reset()}},qi=new class{init(A){var e;this._core=A,this._bindAppActivityEvent(),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this),null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var A,e,t,i,o;const{MINI_APP_NAMESPACE:n,IN_TT_MINI_GAME:r,IN_WX_MINI_GAME:s}=(null===(A=this._core)||void 0===A?void 0:A.utils)||{};r||s?(null===(e=null==n?void 0:n.onShow)||void 0===e||e.call(n,()=>{var A,e;null===(A=this._core)||void 0===A||A.store.set("activityMonitor",{isActive:!0}),null===(e=this._core)||void 0===e||e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null===(t=null==n?void 0:n.onHide)||void 0===t||t.call(n,()=>{var A,e;null===(A=this._core)||void 0===A||A.store.set("activityMonitor",{isActive:!1}),null===(e=this._core)||void 0===e||e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})):(null===(i=null==n?void 0:n.onAppShow)||void 0===i||i.call(n,()=>{var A,e;null===(A=this._core)||void 0===A||A.store.set("activityMonitor",{isActive:!0}),null===(e=this._core)||void 0===e||e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null===(o=null==n?void 0:n.onAppHide)||void 0===o||o.call(n,()=>{var A,e;null===(A=this._core)||void 0===A||A.store.set("activityMonitor",{isActive:!1}),null===(e=this._core)||void 0===e||e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})}))}_reset(){var A;null===(A=this._core)||void 0===A||A.store.clear("activityMonitor")}_dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this),this._reset()}},Vi=new class{init(A){const{IN_MINI_APP:e,IN_WX_MINI_PLUGIN:t}=A.helper;t||(e?qi.init(A):Hi.init(A))}};const ji="none",Ki="online";var Wi=new class{init(A){this._core=A,this._activateNetworkMonitoring(),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return IA(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(A){var e,t;const{isConnected:i,networkType:o}=A;null===(e=this._core)||void 0===e||e.store.set("netWorkMonitor",{isNetworkOnline:i,networkType:o}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:i,networkType:o})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:Ki})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:ji})}_reset(){var A;this._deactivateNetworkMonitoring(),null===(A=this._core)||void 0===A||A.store.clear("netWorkMonitor")}_dispose(){var A,e;null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeInnerEvent(null===(e=this._core)||void 0===e?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},zi=new class{init(A){this._core=A,this._activateNetworkMonitoring(),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return IA(this,void 0,void 0,function*(){try{const{utils:{MINI_APP_NAMESPACE:A}}=this._core;this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),A.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(E){console.error(E)}})}_deactivateNetworkMonitoring(){if(null!==this._mpNetworkStatusCallback){const{utils:{MINI_APP_NAMESPACE:A}}=this._core;A.offNetworkStatusChange&&A.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null}}_onNetworkStatusChange(A){var e,t;const{isConnected:i,networkType:o}=A;null===(e=this._core)||void 0===e||e.store.set("netWorkMonitor",{isNetworkOnline:i,networkType:o}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:i,networkType:o})}_reset(){var A;this._deactivateNetworkMonitoring(),null===(A=this._core)||void 0===A||A.store.clear("netWorkMonitor")}_dispose(){var A,e;null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeInnerEvent(null===(e=this._core)||void 0===e?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Zi=new class{init(A){const{IN_MINI_APP:e}=A.utils;e?zi.init(A):Wi.init(A)}},Xi=new class{constructor(){this.name="SystemStateMonitor"}install(A){Vi.init(A),Zi.init(A)}};const $i=new Set(["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"]),Ao="tui_room_svr.*";var eo=new class{constructor(){this.name="BusinessCommandTransfer",this._transferredCommands=$i}install(A){this._core=A;const{notificationCenter:e,InnerEvent:t,helper:i}=A;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),i.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),i.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(A){return IA(this,void 0,void 0,function*(){const e="transferBusinessCommand";try{const{serviceCommand:t=Ao}=A||{};if(!this._isValidTransferredCommand(t))throw new this._core.helper.ChatError({code:2995,functionName:e});return{code:0,data:(yield function(A,e){return IA(this,void 0,void 0,function*(){const{helper:t,channel:i}=e,{serviceCommand:o=Ao,data:n}=A||{};let r={};try{r="string"==typeof n?JSON.parse(n):n}catch(g){console.warn(g)}const s=t.generateProtocolData({servcmd:o,data:r}),a=`${s.head.seq}${o}`;return i.sendPacket(s,{requestId:a})})}(A,this._core))||{}}}catch(t){throw console.warn(t),new this._core.helper.ChatError({code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo,data:{},functionName:e})}})}_onCloudConfigUpdate(A={}){try{if("string"!=typeof A.rtc_cmd)return;const e=JSON.parse(A.rtc_cmd);Array.isArray(e)&&(this._transferredCommands=new Set([...this._transferredCommands,...e]))}catch(e){console.log(e)}}_isValidTransferredCommand(A=""){const e=`${null==A?void 0:A.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(A){const{OuterEvent:e,notificationCenter:t}=this._core,{MsgContent:i}=A||{},{ROOM_CUSTOM_DATA_RECEIVED:o}=e;t.emitOuterEvent(o,{name:o,data:i})}_reset(){this._transferredCommands=$i}_dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;this._reset(),A.unSubscribeInnerEvent(e.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this),A.unSubscribeInnerEvent("im_open_push.msg_push",A.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};const to=1,io=300;var oo=new class{constructor(){this.name="OfflineMessageSynchronizer",this._lastMessageSequenceMapOnDisconnect=new Map}install(A){this._core=A;const{common:{workflowManager:e},constants:{WORKFLOW_NAME:t,WORKFLOW_STEP:i,InnerEvent:o}}=A;e.registerWorkflowStep(t.SYNC_SERVER_INFO_AFTER_RE_ONLINE,i.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),A.notificationCenter.subscribeInnerEvent(o.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(A){const{conversationList:e}=(null==A?void 0:A.result)||{},{OuterConstant:t,utils:{isArray:i}}=this._core;if(i(e)){const A=e.filter(A=>A.type===t.CONV_GROUP&&A.groupProfile.type!==t.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(A)}}_recoverGroupHistoryMessage(A){return IA(this,void 0,void 0,function*(){const{OuterConstant:e}=this._core,t=[],i=[];return yield Promise.all(null==A?void 0:A.map(A=>IA(this,void 0,void 0,function*(){const{groupProfile:{groupID:o}={},lastMessage:{lastSequence:n}={}}=A,r=`${e.CONV_GROUP}${o}`;let s=this._getLocalLastMessageSequence(r);this._shouldRecoverHistory({localLastMessageSequence:s,serverLastMessageSequence:n})&&(yield this._recoverHistoryForConversation({conversationID:r,localLastMessageSequence:s,serverLastMessageSequence:n,groupTipList:i})),t.push(r.replace(e.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:t,groupTipList:i}})}_recoverHistoryForConversation(A){return IA(this,arguments,void 0,function*({conversationID:A,localLastMessageSequence:e,serverLastMessageSequence:t,groupTipList:i}){try{const{utils:{isArray:o,isObject:n,isEmpty:r},OuterEvent:s,OuterConstant:a,notificationCenter:g,message:c,appStore:l,common:{getMessagePreviewText:I}}=this._core,u=t-e,E=Math.min(20,u),d={},h=yield c.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:A,sequence:e+E,direction:a.Direction.FORWARD,count:E}),{nextReqMessageIDFromServer:C,hasNoMoreHistoryMessage:B,messageList:Q,serverGroupTipList:p}=h;o(p)&&i.push(...p);const f=B&&C<0,m=[];if(o(Q)&&(Q.forEach(A=>{c.messageReceiver.groupMessageReceiver.updateMessageProfile(A),A.from===a.CONV_SYSTEM&&(A.isSystemMessage=!1),c.messageDataHandler.storeConversationMessage(A)&&!r(A.payload)&&(m.push(A),A._isExcludedFromLastMessage||(d.lastMessage=Object.assign({},A)))}),m.length>0&&g.emitOuterEvent(s.MESSAGE_RECEIVED,{name:s.MESSAGE_RECEIVED,data:m})),!f&&Q.length>0){const e=Q[Q.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:A,localLastMessageSequence:e,serverLastMessageSequence:t,groupTipList:i})}n(d.lastMessage)&&(d.lastMessage.messageForShow=I(d.lastMessage.type,d.lastMessage.payload),l.conversationStore.updateConversation(A,d))}catch(o){this._core.ssoLog.error("_recoverHistoryForConversation",`Recovery failed for conversation:${A}`,{error:o})}})}_updateLastMessageSequenceMapOnDisconnect(){const{message:A}=this._core,e=A.messageDataHandler.getContinuousMessagesByConversation();for(const[t,i]of e){if(t.startsWith("C2C"))continue;const A=Array.from(i.values());if((null==A?void 0:A.length)>0){const e=A[A.length-1].sequence;this._lastMessageSequenceMapOnDisconnect.set(t,e)}}}_getLocalLastMessageSequence(A){const{message:e}=this._core;if(this._lastMessageSequenceMapOnDisconnect.has(A))return this._lastMessageSequenceMapOnDisconnect.get(A);const t=e.messageDataHandler.getLocalMessageList(A),i=t[t.length-1];return null==i?void 0:i.sequence}_shouldRecoverHistory(A){const{localLastMessageSequence:e,serverLastMessageSequence:t}=A;if("number"!=typeof e||"number"!=typeof t)return!1;const i=t-e;return 0!==t&&e>0&&i>=to&&ie(A)&&A.slice(0,3)===Qt.CONV_C2C,isCommunity:Ii,isGroupConv:A=>e(A)&&A.slice(0,5)===Qt.CONV_GROUP,isTopic:ui,isUnlimitedAVChatRoom:function(){var A;return!!(null===(A=At.store.get("instance"))||void 0===A?void 0:A.unlimitedAVChatRoom)},liteChatInstanceMap:li,registerInterceptor:si,registerValidateConfig:ai,requireAuth:Ai,get sdkEdition(){return ao},updateGroupAtInfo:(A,e)=>{const{CONV_AT_ME:t,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:o}=St;if(function(A,e){const{CONV_AT_ME:t,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:o}=St,{groupID:n,sequence:r}=A;let s=!1;return Ii({groupID:n})?(e.forEach(e=>{e.messageSequence===r&&(e.atTypeArray.includes(t)&&A.groupAtType.includes(i)&&(e.atTypeArray=[o]),e.atTypeArray.includes(i)&&A.groupAtType.includes(t)&&(e.atTypeArray=[o],e.__random=A.__random,e.__sequence=A.__sequence),s=!0)}),s):s}(A,e))return;let n=[...A.groupAtType];n.includes(t)&&n.includes(i)&&(n=[o]);const r={from:A.from,groupID:A.groupID,topicID:A.topicID,messageSequence:A.sequence,atTypeArray:n,__random:A.__random,__sequence:A.__sequence};e.push(r)},validateAndExecute:ri,validateParameters:ei});class lo{constructor(){this._builtInPlugins=new Set,this._externalPlugins=new Set}static getInstance(){return lo._instance||(lo._instance=new lo),lo._instance}static setInstance(A){lo._instance=A}installBuiltInPlugin(A){A&&this._installPlugin(A,this._builtInPlugins)}installExternalPlugin(A){A&&this._installPlugin(A,this._externalPlugins)}clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}_installPlugin(A,e){let t=[];t=i(A)?A:[A];const o=t.findIndex(A=>"AVChatRoom"===(null==A?void 0:A.name)),n=o>-1?t.splice(o,1):[];t.forEach(A=>{this._isPluginInstalled(A.name)||(A&&et(A.install)?(e.add(A.name),et(A.getInstalledSubPlugins)?A.install(Bo.getInstance().exposeApiForPlugin(),n):A.install(Bo.getInstance().exposeApiForPlugin()),et(A.handleLoginSuccess)&&this._isLoggedIn()&&A.handleLoginSuccess()):et(A)?(e.add(A.name),A(Bo.getInstance().exposeApiForPlugin()),et(A.handleLoginSuccess)&&this._isLoggedIn()&&A.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isPluginInstalled(A){return this._builtInPlugins.has(A)||this._externalPlugins.has(A)}_isLoggedIn(){var A;return!0===(null===(A=At.store.get("login"))||void 0===A?void 0:A.isLoggedIn)}}var Io=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(A){return this._conversationMap.get(A)}updateConversation(A,e,t={emit:!0,needSort:!1}){const{emit:i,needSort:o}=t,n=this._conversationMap.get(A);n&&!BA(e)&&(Object.keys(e).forEach(A=>{n[A]=e[A]}),i&&At.notificationCenter.emitInnerEvent(at.CONVERSATION_UPDATED,{needSort:o}))}deleteConversation(A){this._conversationMap.has(A)&&(this._conversationMap.delete(A),At.notificationCenter.emitInnerEvent(at.CONVERSATION_UPDATED))}},uo=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(A){return this._groupMap.get(A)}updateGroup(A,e){const t=this._groupMap.get(A);t&&!BA(e)&&Object.keys(e).forEach(A=>{t[A]=e[A]})}},Eo=new class{constructor(){this._messagesByConversation=new Map}updateMessage(A,e,t){var i;const{operation:o,updateUnreadCount:n=!0}=t,r=lA(t,["operation","updateUnreadCount"]),s=[];for(const a of e){const e=null===(i=this._messagesByConversation.get(A))||void 0===i?void 0:i.get(a);if(!e)return!1;Object.keys(r).forEach(A=>{e[A]=r[A]}),s.push(e)}return this._emitMessageStoreOperationEvent(o,{conversationID:A,messageList:s,updateUnreadCount:n}),s}getMessagesByConversation(A){var e;return[...(null===(e=this._messagesByConversation.get(A))||void 0===e?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(A,e){const{conversationID:t}=e;ui(t)?At.notificationCenter.emitInnerEvent(ht[A],e):At.notificationCenter.emitInnerEvent(A,e)}},ho=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(A){return this.userProfileMap.get(A)}getFriend(A){return this.friendMap.get(A)}},Co=Object.freeze({__proto__:null,conversationStore:Io,groupStore:uo,messageStore:Eo,userStore:ho});class Bo{static getInstance(){return Bo._instance||(Bo._instance=new Bo),Bo._instance}static setInstance(A){Bo._instance=A}constructor(){this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this),setApplicationID:this.setApplicationID.bind(this)},this._apiHandlersMap={},this._apiMap={on:At.notificationCenter.subscribeOuterEvent.bind(At.notificationCenter),off:At.notificationCenter.unSubscribeOuterEvent.bind(At.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:lo.getInstance().installExternalPlugin.bind(lo.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}registerPlugin(A){At.ssoLog.debug("registerPlugin",A)}statKeyFeatureUsage(A){At.ssoLog.debug("statTUIKeyFeatures",A)}setLogLevel(A){At.ssoLog.debug("setLogLevel",A),At.ssoLog.setLogLevel(A)}setApplicationID(A){At.store.set("instance",{applicationID:A})}getApiMap(){return this._apiMap}setApiMap(A){this._apiMap=A}registerApi(A){const{common:{timeManager:e},utils:{safeStringify:t}}=At,{apiName:i,context:o,methodName:n=i,matcher:r}=A;this._apiHandlersMap[i]||(this._apiHandlersMap[i]=[]),this._apiHandlersMap[i].push({context:o,methodName:n,matcher:r}),this._apiMap[i]&&1!==this._apiHandlersMap[i].length||(this._apiMap[i]=(...A)=>{const o=e.getServerTimeMs();let r=0;"login"===i&&(r=4),kt.includes(i)&&At.ssoLog.debug(i,`${i} start params: ${t(A)}`),ri(n,A);const s=this._apiHandlersMap[i];for(const t of s)if(!t.matcher||t.matcher(A))try{const e=t.context[t.methodName].bind(t.context)(...A);return this._isPromiseLike(e)?this._handleAsyncResult(e,i,r,o):(this._reportApiSuccessLog({result:e,apiName:i,eventType:r,startTime:o}),e)}catch(a){throw At.ssoLog.error(i,`${i} fail ${(null==a?void 0:a.errorMessage)||(null==a?void 0:a.message)})`,{error:a,costTime:e.getServerTimeMs()-o,eventType:r,method:i}),a}})}registerExperimentalAPI(A,e,t){const i=t||A;this._experimentalApiMap[A]=e[i].bind(e)}destroy(){return IA(this,void 0,void 0,function*(){var A,e;try{(null===(A=At.store.get("login"))||void 0===A?void 0:A.isLogin)&&(yield this._apiMap.logout()),At.notificationCenter.emitInnerEvent(at.DESTROY)}catch(t){console.debug("destroy error: ",t)}finally{At.notificationCenter.emitOuterEvent(rt.SDK_DESTROY,{SDKAppID:null===(e=At.store.get("instance"))||void 0===e?void 0:e.sdkAppId}),li.clear(),lo.getInstance().clear(),ci.getInstance().destroy(),At.destroy()}})}exposeApiForClient(){return this._apiMap}exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:at,InnerEventSubType:At.notificationCenter.InnerEventSubType,OuterEvent:rt,OuterConstant:St,SignalingEvent:gt,helper:Object.assign(Object.assign(Object.assign({},At.utils),At.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:si,registerValidateConfig:ai,checkBusinessCapabilityBits:gi,registerWorkflowStep:ci.getInstance().registerWorkflowStep.bind(ci.getInstance()),ChatError:$t}),apiMap:this._apiMap},At),{constants:Object.assign(Object.assign({},Ot),At.constants),common:Object.assign(Object.assign(Object.assign({},co),At.common),{workflowManager:ci.getInstance()}),utils:At.utils,appStore:Co})}callExperimentalAPI(A,e){return At.ssoLog.debug(`callExperimentalAPI.${A} start params: ${At.utils.safeStringify(e)}`),this._experimentalApiMap[A]?this._experimentalApiMap[A](e):Promise.reject(new $t({code:Mt.INVALID_OPERATION}))}_isPromiseLike(A){return null!==A&&"object"==typeof A&&"function"==typeof A.then}_handleAsyncResult(A,e,t,i){return A.then(A=>(this._reportApiSuccessLog({result:A,apiName:e,eventType:t,startTime:i}),A)).catch(A=>{throw At.ssoLog.error(e,`${e} fail ${(null==A?void 0:A.errorMessage)||(null==A?void 0:A.message)})`,{error:A,costTime:At.common.timeManager.getServerTimeMs()-i,eventType:t,method:e}),A})}_reportApiSuccessLog(A){let{result:e,apiName:t,startTime:i,eventType:o}=A;const{timeManager:n}=At.common,{successLog:{message:r,moreMessage:s}={message:"",moreMessage:""}}=e||{},a=n.getServerTimeMs();"login"===t&&(i+=n.getTimeOffsetWithServer()),kt.includes(t)&&At.ssoLog.info(t,`${t} success ${r} ${s}`,{costTime:a-i,eventType:o,message:r,moreMessage:s}),(null==e?void 0:e.successLog)&&delete e.successLog}}class Qo{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120,this._customLoginInfo=""}init(){const{notificationCenter:A,store:e}=At;e.set("login",{isReady:!1}),Bo.getInstance().registerApi({apiName:"login",context:this}),Bo.getInstance().registerApi({apiName:"logout",context:this}),Bo.getInstance().registerApi({apiName:"getLoginUser",context:this}),Bo.getInstance().registerApi({apiName:"isReady",context:this}),Bo.getInstance().registerExperimentalAPI("setCustomLoginInfo",this),A.subscribeInnerEvent(at.RECONNECTED,this._reLogin,this),At.notificationCenter.subscribeInnerEvent(at.DESTROY,this._dispose,this)}login(A){return IA(this,void 0,void 0,function*(){var e;const{sdkEdition:t}=At.store.get("instance")||{};try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new $t({functionName:"login",code:Mt.REPEAT_LOGIN});const i=yield this._performLogin(A);this._validateAfterLogin(i),this._handleLoginSuccess(i),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),this._latestLoginAt=0;const o=null===(e=At.channel.getSocketAdapter())||void 0===e?void 0:e.getId(),{appId:n,href:r}=At.store.get("instance")||{},{instanceID:s,customStatus:a}=i||{};return{code:0,data:i,successLog:{message:t,moreMessage:`socketID:${o} instanceID:${s} customStatus:${a} href: ${r} appId: ${n}`}}}catch(i){const{errorCode:A}=i;A!==Mt.REPEAT_LOGIN&&(this._latestLoginAt=0);const e=new $t({functionName:"login",code:A});throw console.error(e),e}})}_reLogin(){return IA(this,void 0,void 0,function*(){var A;try{if(!this._isLoginIn())return;const e=yield Zt(this._customLoginInfo);if(e){const{instanceID:t,customStatus:i}=e;At.store.set("login",{statusInstanceId:t}),ci.getInstance().executeWorkflow(_t.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:i,statusType:Ct.USER_STATUS_ONLINE});const o=null===(A=At.channel.getSocketAdapter())||void 0===A?void 0:A.getId();At.ssoLog.info("reLogin",`socketId:${o} instanceId:${t}`)}}catch(e){console.warn(e)}})}logout(){return IA(this,arguments,void 0,function*(A=Lt.USER_INITIATED){const{ssoLog:e}=At;e.debug("logout",`logout start logoutReason: ${A}`);try{yield this._performLogout(A),e.info("logout","logout success"),At.ssoLog.uploadSSOLogData()}catch(t){const{errorCode:A}=t;throw new $t({functionName:"logout",code:A})}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?pi():""}isReady(){var A;return null===(A=At.store.get("login"))||void 0===A?void 0:A.isReady}setCustomLoginInfo(A=""){this._customLoginInfo=A}_updateAndEmitSDKReady(){At.store.set("login",{isReady:!0}),setTimeout(()=>{At.notificationCenter.emitOuterEvent(rt.SDK_READY,{name:rt.SDK_READY})},1)}_updateAndEmitSDKNotReady(){At.store.set("login",{isReady:!1}),At.notificationCenter.emitOuterEvent(rt.SDK_NOT_READY,{name:rt.SDK_NOT_READY})}_validateAfterLogin(A){const e="login";if(!A)throw new $t({functionName:e,message:"login response is empty"});const{tinyID:t,a2Key:i}=A||{};if(!t)throw new $t({functionName:e,code:Mt.NO_TINYID});if(!i)throw new $t({functionName:e,code:Mt.NO_A2KEY})}_createRepeatLoginResponse(){var A;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:Xt({code:"RepeatLogin",replacement1:null===(A=At.store.get("login"))||void 0===A?void 0:A.userId}),repeatLogin:!0}}}_performLogin(A){return IA(this,void 0,void 0,function*(){const{userID:e,userSig:t}=A;return At.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),Zt(this._customLoginInfo)})}_ensureAsyncComplete(){return IA(this,void 0,void 0,function*(){yield new Promise(A=>{setTimeout(()=>A(null),1)})})}_handleLoginSuccess(A){const{timeManager:e}=At.common,{helloInterval:t,timeStamp:i,customStatus:o,purchaseBits:n}=A,r=1e3*i;e.calculateTimeOffsetWithServer(this._latestLoginAt,r),this._helloInterval=t||120,this._updateLoginStore(A),At.user.userStatus.setCustomStatus(o),ci.getInstance().executeWorkflow(_t.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:n}),At.common.taskScheduler.addTask({id:Pt,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this})}_performLogout(A){return function(A){return IA(this,void 0,void 0,function*(){const{logoutReason:e}=A,t="im_open_status.wslogout",i=At.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),o=`${i.head.seq}${t}`;return yield At.channel.sendPacket(i,{requestId:o})})}({logoutReason:A})}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),ci.getInstance().reset(),At.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(A){const{a2Key:e,tinyID:t,instanceID:i,authKey:o}=A;At.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:i,authKey:o,isLoggedIn:!0})}_sendOnlinePresenceRequest(){return IA(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{yield function(){const A="im_open_status.wshello",e=At.common.generateProtocolData({servcmd:A,data:{isWebUniapp:0}}),t=`${e.head.seq}${A}`;return At.channel.sendPacket(e,{requestId:t})}()}catch(E){At.ssoLog.warn("_sendOnlinePresenceRequest",` error:${E.message}`)}})}_isLoginIn(){var A;return!0===(null===(A=At.store.get("login"))||void 0===A?void 0:A.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){At.common.taskScheduler.removeTask(Pt),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,this._customLoginInfo="",At.store.clear("login"),At.store.set("login",{isReady:!1}),At.store.set("instance",{applicationID:0})}_dispose(){this._reset();const{notificationCenter:A}=At;A.unSubscribeInnerEvent(at.RECONNECTED,this._reLogin,this),A.unSubscribeInnerEvent(at.DESTROY,this._dispose,this)}}const po={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},fo={logout:!0};class mo{constructor(){this.loginAction=new Qo,this.kickedOutHandler=new zt,this.loginAction.init(),this.kickedOutHandler.init(),ai({auth:fo,params:po})}}var yo,Do,vo;!function(A){A.CONV_C2C="C2C",A.CONV_GROUP="GROUP",A.CONV_TOPIC="TOPIC",A.CONV_SYSTEM="@TIM#SYSTEM"}(yo||(yo={})),function(A){A.MSG_PRIORITY_HIGH="High",A.MSG_PRIORITY_NORMAL="Normal",A.MSG_PRIORITY_LOW="Low",A.MSG_PRIORITY_LOWEST="Lowest"}(Do||(Do={})),function(A){A.MSG_TEXT="TIMTextElem",A.MSG_CUSTOM="TIMCustomElem",A.MSG_LOCATION="TIMLocationElem",A.MSG_FACE="TIMFaceElem",A.MSG_IMAGE="TIMImageElem",A.MSG_AUDIO="TIMSoundElem",A.MSG_FILE="TIMFileElem",A.MSG_VIDEO="TIMVideoFileElem",A.MSG_GRP_TIP="TIMGroupTipElem",A.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",A.MSG_MERGER="TIMRelayElem"}(vo||(vo={}));const wo={1:Do.MSG_PRIORITY_HIGH,2:Do.MSG_PRIORITY_NORMAL,3:Do.MSG_PRIORITY_LOW,4:Do.MSG_PRIORITY_LOWEST},So=0,Mo=1;var Ro;!function(A){A.IN="in",A.OUT="out"}(Ro||(Ro={}));const _o=2,To={};function No(A){if(!A)return 0;if(void 0===To[A]){const e=new Date,t=`3${e.getHours()}`.slice(-2),i=`0${e.getMinutes()}`.slice(-2),o=`0${e.getSeconds()}`.slice(-2);To[A]=parseInt([t,i,o,"0001"].join(""),10),console.log(`autoIncrementIndex start index:${To[A]}`)}else To[A]+=1;return To[A]}class bo{constructor(A){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=Do.MSG_PRIORITY_NORMAL,this._relayFlag=!1;const{clientTime:e=At.common.timeManager.getServerTimeSeconds()||0,senderTinyID:t,currentUser:i,needReadReceipt:o,isSupportExtension:n,customModerationConfigurationId:r,to:s,from:a,nick:g="",avatar:c="",time:l,messageControlInfo:I,tinyID:u,cloudCustomData:E="",messageLifeTime:d,messageVersion:h=0,conversationType:C,sequence:B,checkResult:Q=0,isPlaceMessage:p=0,messageFlagBits:f,receiverList:m,isSystemMessage:y=!1,status:D=It.SUCCESS,revokeReason:v="",conversationSubType:w,clientSequence:S,protocol:M="JSON",revokerInfo:R={userID:"",nick:"",avatar:""},readReceiptInfo:_={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:T,groupProfile:N,atUserList:b,flow:G,isRead:k=!1,priority:L=Do.MSG_PRIORITY_NORMAL}=A;var U;this.clientTime=e,this.senderTinyID=t||u,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===n||1===n,this._cmConfigID=r,this.to=s,this.nick=g,this.avatar=c,this.protocol=M,this.random=void 0===T?(U=U||99999999,Math.round(Math.random()*U)):T,this.time=l||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!!(null==I?void 0:I.excludedFromLastMessage),this._isExcludedFromUnreadCount=!!(null==I?void 0:I.excludedFromUnreadCount),this.isModified=!!h,this.cloudCustomData=E,this.messageLifeTime=d,this.from=a||null,this.sequence=B||0,this.conversationType=C||yo.CONV_C2C,this.hasRiskContent=Q>1,this.version=h,this.isPlaceMessage=p,this.isRevoked=2===p||8===f,this.isSystemMessage=y,this.readReceiptInfo=_,this.revokeReason=v,this.revokerInfo=R,this._receiverList=m,this.conversationSubType=w,this.revoker=(null==R?void 0:R.revoker)||"",this.clientSequence=S||B||0,this.status=D,this.atUserList=b||[],this.flow=G,this.isRead=k,this.priority=L,this.reInitialize(i),this._initC2CReadReceiptInfo(A),this._extractGroupInfo(N)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(A){Array.isArray(A)?this._elements=A:this._elements=[A],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(A=>A.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(A){this._relayFlag=A}validateBeforeSend(){var A,e,t;return this._relayFlag?{isValid:!0}:(null===(A=this._elements)||void 0===A?void 0:A.length)>0?null===(t=null===(e=this._elements[0])||void 0===e?void 0:e.validateBeforeSend)||void 0===t?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(A){const{readReceiptSentByPeer:e,timestamp:t=0}=A;this.conversationType===yo.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(A){if(!A)return;const{From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:i}=A,{NameCard:o}=i||{};"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof o&&(this.nameCard=o)}reInitialize(A){A===this.from&&(this.isRead=!0),this._initSequence(A),this._concatConversationID(A),this.generateMessageID()}_concatConversationID(A){let e="";const t=this.conversationType;t!==yo.CONV_SYSTEM?(e=t===yo.CONV_C2C?A===this.from?this.to:this.from:this.to,this.conversationID=e?`${t}${e}`:null):this.conversationID=yo.CONV_SYSTEM}_initSequence(A){0===this.clientSequence&&A&&(this.clientSequence=No(A)),0===this.sequence&&this.conversationType===yo.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===yo.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-${this.random}`}setIsRead(A){this.isRead=A}}class Go{static parseServerPushElement(A){const{MsgContent:e={}}=A,{Data:t,Ext:i,Desc:o}=e;return new Go({data:t,description:o,extension:i})}constructor(A){this.type=vo.MSG_CUSTOM;const{data:e="",description:t="",extension:i=""}=A;this.content={data:e,description:t,extension:i}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{data:i,description:o,extension:n}=t;return{MsgType:this.type,MsgContent:{Data:i,Ext:n,Desc:o}}}validateBeforeSend(){const{isEmpty:A}=At.utils,e=[this.content.data,this.content.description,this.content.extension].some(e=>!A(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class ko{static parseServerPushElement(A){const{MsgContent:e={Text:""}}=A,{Text:t}=e;return new ko({text:t})}constructor(A){this.type=lt.MSG_TEXT,this.content={text:A.text||""}}validateBeforeSend(){var A,e;return(null===(e=null===(A=this.content)||void 0===A?void 0:A.text)||void 0===e?void 0:e.length)>0?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{text:i}=t;return{MsgType:this.type,MsgContent:{Text:i}}}}var Lo=new class{constructor(){this._elementClassMap={[vo.MSG_CUSTOM]:Go,[vo.MSG_TEXT]:ko}}init(){Bo.getInstance().registerApi({apiName:"createCustomMessage",context:this}),Bo.getInstance().registerApi({apiName:"createTextMessage",context:this})}registerElementClass(A,e){var t;void 0!==(t=e).prototype&&"constructor"in t.prototype&&(this._elementClassMap[A]=e)}getElementClass(A){return this._elementClassMap[A]}createMessage(A){const{from:e,flow:t=Ro.OUT}=A,{userId:i}=At.store.get("login")||{};this._isSendByCurrentInstance({from:e,flow:t,currentUser:i})?this._updateWithSenderInfo(A):this._isMultiEndpointSyncMessage({from:e,flow:t,currentUser:i})&&(A.flow=Ro.OUT);const o=Object.assign(Object.assign({},A),{currentUser:i});return new bo(o)}createCustomMessage(A){const e=pi(),t=this.createMessage(Object.assign(Object.assign({},A),{from:e})),i=this._elementClassMap[vo.MSG_CUSTOM];if(!t)return null;if(i){const e=new i(A.payload);t.setElement(e)}return t}createTextMessage(A){var e;if(!A)return null;const t="string"==typeof A.payload?A.payload:(null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.text)||"",i=new ko({text:t}),o=pi(),n=At.message.messageFactory.createMessage(Object.assign(Object.assign({},A),{from:o}));return n.setElement(i),n}_updateWithSenderInfo(A){const{nick:e,avatar:t}=A,{userId:i,tinyID:o}=At.store.get("login")||{},n=ho.getUserProfile(i);return A.nick=e||(null==n?void 0:n.nick)||"",A.avatar=t||(null==n?void 0:n.avatar)||"",A.tinyID=A.tinyID||o||"",A.from=i,A.status=It.UNSENT,A.flow=Ro.OUT,A}_isMultiEndpointSyncMessage(A){const{from:e,flow:t,currentUser:i}=A;return e===i&&t===Ro.IN}_isSendByCurrentInstance(A){const{from:e,flow:t,currentUser:i}=A;return e===i&&t===Ro.OUT}};const Uo={PushFlag:0,Title:"",Desc:"",Ext:"",ApnsInfo:{Sound:"",BadgeMode:0,IsVoipPush:void 0,Image:"",InterruptionLevel:"active",ContentAvailable:0},AndroidInfo:{Sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},Fo={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Oo={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function xo(A,e){return Object.keys(e).forEach(t=>{const{range:i,defaultValue:o}=e[t];A[t]=i.includes(A[t])?A[t]:o}),A}function Po(A){const e=A.lastIndexOf(".");return-1===e?A:A.slice(0,e)}function Yo(A){const{androidInfo:e={},androidOPPOChannelID:t=""}=A,i=e.OPPOChannelID||t,o=xo(e,Fo),{sound:n="",FCMChannelID:r=""}=o,s=lA(o,["sound","FCMChannelID"]);return Object.assign(Object.assign({},s),{Sound:Po(n),OPPOChannelID:i,GoogleChannelID:r})}function Jo(e){const{apnsInfo:t={},ignoreIOSBadge:i=!1,disableVoipPush:o}=e,n=xo(t,Oo),{ignoreIOSBadge:r,disableVoipPush:s,enableIOSBackgroundNotification:a}=n,g=lA(n,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),c=!0===r||!0===i?1:0;let l;return A(o)||(l=!1===o?1:0),A(s)||(l=!1===s?1:0),Object.assign(Object.assign({},g),{BadgeMode:c,IsVoipPush:l,ContentAvailable:a?1:0})}function Ho(A){return At.utils.isPlainObject(A)?{PushFlag:!0===A.disablePush?1:0,Title:A.title||"",Desc:A.description||"",Ext:A.extension||"",ApnsInfo:Jo(A),AndroidInfo:Yo(A)}:Uo}function qo(A){const{From_AccountHeadurl:e,From_AccountNick:t,IsNeedReadReceipt:i,IsPeerRead:o,IsSyncMsg:n,MsgBody:r,MsgClientTime:s,MsgLifeTime:a,MsgRandom:g,MsgSeq:c,MsgTimeStamp:l,SendMsgControl:I,SupportMessageExtension:u,TinyId:E,MsgCheckResult:d,CloudCustomData:h,MsgVersion:C,MsgFlagBits:B,RevokerInfo:Q}=A;let p,{From_Account:f,To_Account:m}=A;if(1===n){const A=m;m=f,f=A}if(Q){const{Reason:A,Revoker_Account:e,Revoker_FromUin:t}=Q;p={reason:A,revoker:e,revokerFromUin:t,userID:e}}return{from:f,avatar:e,nick:t,needReadReceipt:1===i,isSyncMessage:n,clientTime:s,messageLifeTime:a,random:g,sequence:c,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==I?void 0:I.NoLastMsg),excludedFromUnreadCount:1===(null==I?void 0:I.NoUnread)},isSupportExtension:u,to:m,tinyID:E,checkResult:d,cloudCustomData:h,revokerInfo:p,messageVersion:C,messageFlagBits:B,readReceiptSentByPeer:o,elements:Wo(r)}}function Vo(A){const{From_Account:e,MsgBody:t,MsgClientTime:i,MsgRandom:o,MsgSeq:n,MsgTimeStamp:r,To_Account:s,MsgVersion:a,CloudCustomData:g}=A;return{from:e,clientTime:i,random:o,sequence:n,time:r,to:s,elements:Wo(t),messageVersion:a,cloudCustomData:g}}function jo(A){const{ClientSeq:e,From_Account:t,GroupInfo:i,MsgBody:o,MsgClientTime:n,MsgRandom:r,MsgSeq:s,MsgTimeStamp:a,SendMsgControl:g,SupportMessageExtension:c,TinyId:l,CloudCustomData:I,MsgVersion:u,MsgCheckResult:E,NeedReadReceipt:d,IsPlaceMsg:h,RevokerInfo:C,GroupAtInfo:B}=A;let Q,p=Do.MSG_PRIORITY_NORMAL;if(Object.keys(wo).includes(String(A.MsgPriority))&&(p=wo[A.MsgPriority]),C){const{Reason:A,Revoker_Account:e,Revoker_FromUin:t}=C;Q={reason:A,revoker:e,revokerFromUin:t,userID:e}}const f=function(A){const e=[];return Array.isArray(A)&&A.forEach(A=>{A.GroupAtAllFlag===So?e.push(A.GroupAt_Account):A.GroupAtAllFlag===Mo&&e.push(St.MSG_AT_ALL)}),e}(B);return{clientSequence:e,from:t,groupProfile:i,clientTime:n,priority:p,random:r,sequence:s,time:a,messageControlInfo:{excludedFromLastMessage:1===(null==g?void 0:g.NoLastMsg),excludedFromUnreadCount:1===(null==g?void 0:g.NoUnread)},isSupportExtension:c,tinyID:l,cloudCustomData:I,messageVersion:u,messageCheckResult:E,needReadReceipt:d,isPlaceMessage:h,revokerInfo:Q,atUserList:f,elements:Wo(o),to:Ko(A)}}function Ko(A){const{utils:{isEmpty:e},constants:{IS_TOPIC_MESSAGE:t}}=At,{ToGroupId:i,GroupInfo:{MillionGroupFlag:o=0,TopicId:n}={}}=A;return o!==t||e(n)?i:n}function Wo(A){if(!A)return null;if(Array.isArray(A))return A.map(A=>{const e=At.message.messageFactory.getElementClass(A.MsgType);return null==e?void 0:e.parseServerPushElement(A)});const e=At.message.messageFactory.getElementClass(A.MsgType);return null==e?void 0:e.parseServerPushElement(A)}function zo(A){const{From_Account:e,MsgBody:t,MsgClientTime:i,MsgRandom:o,MsgSeq:n,MsgTimeStamp:r,GroupId:s,TopicId:a,MsgVersion:g,CloudCustomData:c}=A;return{from:e,clientTime:i,random:o,sequence:n,time:r,groupID:s,topicID:a,elements:Wo(t),messageVersion:g,cloudCustomData:c}}function Zo({conversationUpdateFields:A,message:e}){const{conversationID:t,conversationType:i,conversationSubType:o,flow:n,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:s}=e,a=s?"":e,g=!r&&n===Ro.IN;A.has(t)?(A.get(t).lastMessage=a,g&&A.get(t).unreadCount++):A.set(t,{conversationID:t,type:i,subType:o,unreadCount:g?1:0,lastMessage:a})}function Xo(A){return A.filter(A=>{const e=!BA(null==A?void 0:A.getElements()),t=1===(null==A?void 0:A.isPlaceMessage);return e||At.ssoLog.error("emptyMessageBody",`from:${A.from} to:${A.to} sequence:${A.sequence}`),e&&!t})}function $o(A){const{messageDataHandler:e}=At.message;return!e.isInMessageList(A)&&!e.isMessageSentByCurrentInstance(A)}var An=Object.freeze({__proto__:null,autoIncrementIndex:No,filterValidMessages:Xo,parseServerGroupMessage:jo,parseServerPushC2CModifyMessage:Vo,parseServerPushGroupModifyMessage:zo,parseServerPushMessage:qo,parseServerPushMessageElement:Wo,shouldStoreMessage:$o,updateConversationFields:Zo});const{isPlainObject:en}=At.utils;function tn(A,e={}){const{onlineUserOnly:t,messageControlInfo:i}=e;let{offlinePushInfo:o}=e;A.conversationType===yo.CONV_C2C&&!0===t&&(o?o.disablePush=!0:o={disablePush:!0});let n="";"string"==typeof A.cloudCustomData&&A.cloudCustomData.length>0&&(n=A.cloudCustomData);const r=[];if(i&&en(i)){const{excludedFromUnreadCount:A,excludedFromLastMessage:e,excludedFromContentModeration:t}=i;!0===A&&r.push("NoUnread"),!0===e&&r.push("NoLastMsg"),!0===t&&r.push("NoMsgCheck")}return{onlineUserOnly:t,cloudCustomData:n,messageControlInfo:r,offlinePushInfo:o}}function on(A){const{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:t=!1}={}}=A||{};if(!e&&!t)return;const i=[];return e&&i.push("ForbidBeforeSendMsgCallback"),t&&i.push("ForbidAfterSendMsgCallback"),i}function nn(A,e){return IA(this,void 0,void 0,function*(){const t=A.conversationType===yo.CONV_GROUP?function(A,e){var t;const o=tn(A,e),{onlineUserOnly:n,cloudCustomData:r,messageControlInfo:s,offlinePushInfo:a}=o,g=JSON.parse(JSON.stringify(A.transformElementsToServerFormat()));let c;return i(A._receiverList)&&A._receiverList.length>0&&(c=A._receiverList,A._receiverList.length>50&&(c=A._receiverList.slice(0,50),console.warn("ReceiverListLimit"))),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null===(t=At.store.get("login"))||void 0===t?void 0:t.userId,GroupId:A.to,MsgBody:g,CloudCustomData:r,Random:A.random,MsgPriority:A.priority,ClientSeq:A.clientSequence,GroupAtInfo:A._groupAtInfoList,OnlineOnlyFlag:n?1:0,MsgClientTime:A.clientTime,OfflinePushInfo:Ho(a),SendMsgControl:n?void 0:s,NeedReadReceipt:!0===A.needReadReceipt?1:0,To_Account:c,SupportMessageExtension:!0===A.isSupportExtension?1:0,IsRelayMsg:!0===A._relayFlag?1:0,CustomModerationConfigID:A._cmConfigID,ForbidCallbackControl:on(e)}}}(A,e):function(A,e){var t;const i=tn(A,e),{onlineUserOnly:o,cloudCustomData:n,messageControlInfo:r,offlinePushInfo:s}=i,a=!0===o?0:void 0,g=JSON.parse(JSON.stringify(A.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null===(t=At.store.get("login"))||void 0===t?void 0:t.userId,To_Account:A.to,MsgBody:g,CloudCustomData:n,MsgSeq:A.sequence,MsgRandom:A.random,MsgLifeTime:a,From_AccountNick:A.nick,From_AccountHeadurl:A.avatar,SendMsgControl:0!==a?r:void 0,MsgClientTime:A.clientTime,IsNeedReadReceipt:!0===A.needReadReceipt?1:0,SupportMessageExtension:!0===A.isSupportExtension?1:0,IsRelayMsg:!0===A._relayFlag?1:0,CustomModerationConfigID:A._cmConfigID,OfflinePushInfo:Ho(s),ForbidCallbackControl:on(e)}}}(A,e),o=yield hi(t);return o?{time:o.MsgTime,messageDropReason:o.MsgDropReason,sequence:o.MsgSeq}:null})}const{isPlainObject:rn}=At.utils,{MSG_AUDIO:sn,MSG_FILE:an,MSG_IMAGE:gn,MSG_VIDEO:cn,MSG_MERGER:ln}=St;class In{init(){Bo.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:A=>![sn,an,gn,cn,ln].includes(A[0].type)})}sendMessage(A,e){return IA(this,void 0,void 0,function*(){const{TOTAL_COUNT:t,SEND_COST:i,SUCCESS_COUNT:o,FAILED_COUNT:n}=Gt;if(!(A instanceof bo))throw new $t({code:Mt.MSG_INSTANCE_REQUIRED});const r=A.validateBeforeSend();if(!r.isValid){const{code:A,message:e=""}=r.error||{};throw new $t({code:A,message:e})}this._reportMessageSendQuality({name:t,message:A});let s=!1;const{messageDataHandler:a}=At.message||{};try{const{messageControlInfo:t}=e||{};let n=null;a.addRandomOfSentMessage(A.random);const r=Date.now();if(A.conversationType===yo.CONV_C2C?(s=!0===(null==e?void 0:e.onlineUserOnly),n=yield nn(A,e)):A.conversationType===yo.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(A),n=yield nn(A,e)),n){const{messageDropReason:e,sequence:g,time:c}=n;if(this._updateNickAndAvatarOfSentMessageByMe(A),e&&this._logRateLimitInfo(A,g,e),this._reportMessageSendQuality({name:o,message:A}),this._reportMessageSendQuality({name:i,message:A,startTs:r}),!0===A.isResend){const e=a.findMessage(A.ID);e&&(At.ssoLog.debug("sendMessage",`sendMessage resend ok. ID:${e.ID}`),a.deleteConversationMessage(e))}return A.status=It.SUCCESS,A.time=c,A.conversationType===yo.CONV_GROUP&&(A.sequence=g),s?A._onlineOnlyFlag=!0:(a.storeConversationMessage(A),this._applySentMessageControlInfo(A,t),this._emitOnlineMessageSent(A)),{code:0,data:{message:A}}}}catch(g){A.status=It.FAIL,a.removeRandomOfSentMessage(A.random);let{errorCode:e}=g||{},t=(null==g?void 0:g.errorInfo)||(null==g?void 0:g.message)||"";throw this._hasRiskContent(e)&&(A.hasRiskContent=!0),s||this._isRejectedByRestApi(e)||a.storeConversationMessage(A),this._reportMessageSendQuality({name:n,message:A,error:g}),new $t({code:e,message:t,data:{message:A},moreMessage:`type:${A.type} from:${A.from} to:${A.to}`})}})}_hasRiskContent(A){return 80001===A||80004===A}_isRejectedByRestApi(A){return A>=10100&&A<=10200||A>=120001&&A<=13e4}_emitOnlineMessageSent(A){const e=A._isExcludedFromLastMessage?"":A,{conversationID:t,conversationType:i}=A,o=ui(t)?at.TOPIC_NEW_MESSAGE:at.NEW_MESSAGE;At.notificationCenter.emitInnerEvent(o,{result:{conversationUpdateFieldList:[{conversationID:t,type:i,message:A,lastMessage:e,unreadCount:0}]}})}_applySentMessageControlInfo(A,e){e&&rn(e)&&(!0===e.excludedFromLastMessage&&(A._isExcludedFromLastMessage=!0),!0===e.excludedFromUnreadCount&&(A._isExcludedFromUnreadCount=!0))}_logRateLimitInfo(A,e,t){const i=`from:${A.from} to:${A.to} sequence:${e} messageDropReason:${t}`;At.ssoLog.warn("messageDropReason",i)}_updateNickAndAvatarOfSentMessageByMe(A){const{messageDataHandler:e}=At.message||{};let t=!1;const{conversationID:i}=A,o=e.getLatestMsgSentByMe(i);if(o){const{nick:n,avatar:r}=o;n===A.nick&&r===A.avatar||(t=!0),t&&e.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:A.nick,latestAvatar:A.avatar,isSentByMe:!0})}}_validateBeforeSendGroupMessage(A){return IA(this,void 0,void 0,function*(){var e,t,i;const{to:o,from:n}=A;let r=o,s=uo.getGroup(r);if(Ii({groupID:r})&&(null==s?void 0:s.isSupportTopic))throw new $t({code:Mt.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(ui(o)&&([r]=o.split(yt.TOPIC),s=uo.getGroup(r)),!s&&"function"==typeof(null===(e=Bo.getInstance().getApiMap())||void 0===e?void 0:e.getGroupProfile)){const A=yield Bo.getInstance().getApiMap().getGroupProfile({groupID:r});if((null===(i=null===(t=null==A?void 0:A.data)||void 0===t?void 0:t.group)||void 0===i?void 0:i.type)===St.GRP_AVCHATROOM){const A=Xt({code:Mt.MSG_SEND_FAIL_NOT_IN_AV,replacement1:n,replacement2:r});throw new $t({code:Mt.MSG_SEND_FAIL_NOT_IN_AV,message:A})}}return!0})}_reportMessageSendQuality(A){At.notificationCenter.emitInnerEvent(at.QUALITY_STAT,{label:bt.MESSAGE_SEND_SUCCESS_RATE,data:A})}}var un=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Set}init(){At.notificationCenter.subscribeInnerEvent(at.LOGOUT,this._reset,this),At.notificationCenter.subscribeInnerEvent(at.DESTROY,this._dispose,this)}get _messagesByConversation(){return Eo.getMessages()}storeConversationMessage(A,e=!1){const{conversationID:t}=A;if(!t)return!1;if(this._messagesByConversation.has(t)||this._messagesByConversation.set(t,new Map),this._shouldSkipStoreMessage(A,e))return!1;const i=this._getUniqueIdOfMessage(A);return this._messagesByConversation.get(t).set(i,A),this._updateLatestMessageMap(A),!0}_updateLatestMessageMap(A){const{conversationID:e}=A;"out"===A.flow?this._setLatestMsgSentByMe(e,A):e.startsWith("C2C")&&this._setLatestMsgSentByPeer(e,A)}_shouldSkipStoreMessage(A,e){const t=this._getUniqueIdOfMessage(A),i=this._messagesByConversation.get(A.conversationID);if(null==i?void 0:i.has(t)){const A=null==i?void 0:i.get(t);if(!e||!0===(null==A?void 0:A.isModified))return!0}return!1}deleteConversationMessage(A){var e;const{conversationID:t=""}=A,i=this._getUniqueIdOfMessage(A);this._messagesByConversation.has(t)&&(null===(e=this._messagesByConversation.get(t))||void 0===e||e.delete(i))}modifyConversationMessage(A,e){var t;if(!this._messagesByConversation.has(A)&&!this._sparseMessagesByConversation.has(A))return{isUpdated:!1,message:null};const i=this._getUniqueIdOfMessage(e),o=this._getMessageFromLocalMessage(A,i);if(o){const{messageVersion:i,elements:n,cloudCustomData:r,checkResult:s=0}=e,a=s>1;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${o.version} remoteVersion:${i}`),o.versione.ID===A)||null,e)break;if(!e){const t=Array.from(this._sparseMessagesByConversation.values());for(const i of t)if(e=i.get(A)||null,e)break}return e}deleteConversationMessageList(A){this._messagesByConversation.has(A)&&(this._messagesByConversation.delete(A),this._latestMessageSentByMeMap.delete(A),this._latestMessageSentByPeerMap.delete(A)),this._sparseMessagesByConversation.has(A)&&this._sparseMessagesByConversation.delete(A)}revokeMessage({conversationID:A,sequence:e,random:t,revoker:i}){const o=this._messagesByConversation.get(A);let n=null;if(o){const r=Array.from(o.values());if(n=this._findMessageBySequenceAndRandom({messageList:r,random:t,sequence:e}),n){const e=this._getUniqueIdOfMessage(n);return Eo.updateMessage(A,[e],{isRevoked:!0,revoker:i,operation:ut.revoke}),n}}if(this._sparseMessagesByConversation.has(A)){const o=Array.from(this._sparseMessagesByConversation.get(A).values());if(n=this._findMessageBySequenceAndRandom({messageList:o,random:t,sequence:e}),n)return n.isRevoked=!0,n.revoker=i,n}}_findMessageBySequenceAndRandom({messageList:e,sequence:t,random:i}){for(let o=0;o0){const A=new Map([...o,...n.entries()]);this._messagesByConversation.set(t,A),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return i}storeSparseMessageList(A){if(0===A.length)return;const{conversationID:e}=A[0],t=A.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);const i=this._sparseMessagesByConversation.get(e);for(let o=0;o=0;i--)if("out"===t[i].flow){this._setLatestMsgSentByMe(A,t[i]);break}}_updateLatestMessageSentByPeer(A){var e;const t=Array.from((null===(e=this._messagesByConversation.get(A))||void 0===e?void 0:e.values())||[]);if(0!==t.length&&A.startsWith("C2C"))for(let i=t.length-1;i>=0;i--)if("in"===t[i].flow){this._setLatestMsgSentByPeer(A,t[i]);break}}_getUniqueIdOfMessage(A){const{from:e,to:t,random:i,sequence:o,time:n}=A;return`${e}-${t}-${i}-${o}-${n}`}_setLatestMsgSentByPeer(A,e){this._latestMessageSentByPeerMap.set(A,e)}_setLatestMsgSentByMe(A,e){this._latestMessageSentByMeMap.set(A,e)}getLatestMsgSentByPeer(A){return this._latestMessageSentByPeerMap.get(A)}getLatestMsgSentByMe(A){return this._latestMessageSentByMeMap.get(A)}addRandomOfSentMessage(A){this._randomOfSentMessageList.add(A)}removeRandomOfSentMessage(A){this._randomOfSentMessageList.delete(A)}updateNickAndAvatarOfSentMessage(A){const{conversationID:e="",latestAvatar:t,latestNick:i,isSentByMe:o=!0}=A,n=this._messagesByConversation.get(e);if(!n)return;const r=Array.from(n.values()),s=o?"out":"in";r.forEach(A=>{const{nick:e,avatar:o,flow:n}=A;n===s&&(e!==i&&(A.nick=i),o!==t&&(A.avatar=t))})}isInMessageList(A){var e;const{conversationID:t}=A;if(!t)return!1;if(!this._messagesByConversation.has(t))return!1;const i=this._getUniqueIdOfMessage(A);return null===(e=this._messagesByConversation.get(t))||void 0===e?void 0:e.has(i)}isMessageSentByCurrentInstance(A){const{random:e}=A;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(A){const e=this._messagesByConversation.get(A);return e?[...e.values()]:[]}getSparseMessageList(A){const e=this._sparseMessagesByConversation.get(A);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),At.notificationCenter.unSubscribeInnerEvent(at.LOGOUT,this._reset,this),At.notificationCenter.unSubscribeInnerEvent(at.DESTROY,this._dispose,this)}};function En(A,e){const t=Io.getConversation(A);if(null==t?void 0:t.lastMessage){const{lastMessage:i}=t,{lastTime:o,lastSequence:n,version:r}=i,{time:s,sequence:a,messageVersion:g,elements:c,cloudCustomData:l}=e;o===s&&n===a&&r!==g&&(i.type=c[0].type,i.payload=c[0].content,i.messageForShow=yi(i.type,i.payload),i.cloudCustomData=l,i.version=g,Io.updateConversation(A,{lastMessage:i}))}}class dn{init(){Bo.getInstance().registerApi({apiName:"modifyMessage",context:this})}modifyMessage(A){return IA(this,void 0,void 0,function*(){const{to:e,payload:t,sequence:i,conversationType:o,random:n,time:r,from:s,type:a}=A;if(this._canModifyMessageElement(a)){const e=A.getElements();e.length>1&&(e[0].type=a,e[0].content=t)}try{let t=null,a=null;if(o===yo.CONV_C2C?t=yield function(A){return IA(this,void 0,void 0,function*(){const{from:e,to:t,version:i=0,sequence:o,random:n,time:r,type:s,cloudCustomData:a}=A,g={From_Account:e,To_Account:t,MsgVersion:i,MsgSeq:o,MsgRandom:n,MsgTime:r,MsgType:s,MsgBody:A.transformElementsToServerFormat(),CloudCustomData:a},c=yield hi({servcmd:"openim.modify_c2c_msg",data:g});if(c){const{MsgBody:A,MsgVersion:e,CloudCustomData:t}=c;return{elements:Wo(A),messageVersion:e,cloudCustomData:t}}})}(A):o===yo.CONV_GROUP&&(t=yield function(A){return IA(this,void 0,void 0,function*(){const{to:e,version:t=0,sequence:i,cloudCustomData:o}=A,n={GroupId:e,MsgVersion:t,MsgSeq:i,MsgBody:A.transformElementsToServerFormat(),CloudCustomData:o},r=yield hi({servcmd:"openim.modify_group_msg",data:n});if(r){const{MsgBody:A,MsgVersion:e,CloudCustomData:t}=r;return{elements:Wo(A),messageVersion:e,cloudCustomData:t}}})}(A)),t){let g=`${o}${e}`;return e===pi()&&o===yo.CONV_C2C&&(g=`${o}${s}`),a={conversationType:o,from:s,to:e,time:r,random:n,sequence:i,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:g},this._handleModifyMessageSuccess(a),{code:0,data:{message:A},successLog:{message:`to:${e}`}}}}catch(g){const{errorCode:A}=g||{};throw new $t({functionName:"modifyMessage",code:A})}})}_handleModifyMessageSuccess(A){const{conversationID:e}=A,{isUpdated:t,message:i}=At.message.messageDataHandler.modifyConversationMessage(e,A);!0===t&&At.notificationCenter.emitOuterEvent(rt.MESSAGE_MODIFIED,{name:rt.MESSAGE_MODIFIED,data:[i]}),At.notificationCenter.emitInnerEvent(at.MESSAGE_MODIFIED,{conversationID:e,message:i}),En(e,A)}_canModifyMessageElement(A){return[vo.MSG_TEXT,vo.MSG_CUSTOM,vo.MSG_LOCATION,vo.MSG_FACE].includes(A)}}class hn{init(){const{notificationCenter:A}=At,{InnerEventSubType:e}=A;ci.getInstance().registerWorkflowStep(_t.RECEIVE_C2C_NEW_MESSAGE,Tt.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),ci.getInstance().registerWorkflowStep(_t.RECEIVE_C2C_NEW_MESSAGE,Tt.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),ci.getInstance().registerWorkflowStep(_t.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Tt.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),A.subscribeInnerEvent(at.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(A){ci.getInstance().executeWorkflow(_t.RECEIVE_C2C_NEW_MESSAGE,A)}_handleC2CMessagePush(A){const e=A.data||{},{messageDataHandler:t}=At.message||{},i=[],o=new Map;return e.C2cMsgArray.forEach(A=>{const e=this._generateC2CMessage(A);this._updateMessageProfile(e);let n=1===e.isModified;t.isMessageSentByCurrentInstance(e)?e.isModified=n:n=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(e)||i.push(e)):$o(e)&&(t.storeConversationMessage(e)&&Zo({conversationUpdateFields:o,message:e}),t.isMessageSentByCurrentInstance(e)&&!n||i.push(e))}),{conversationUpdateFieldList:[...o.values()],messages:i}}_emitMessageEventsAfterReceiveNewMessage(A){var e;const{messages:t=[]}=(null===(e=A.result)||void 0===e?void 0:e[Tt.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(t)}_emitMessageEventsAfterSyncUnreadMessage(A){var e;const{messages:t=[]}=(null===(e=A.result)||void 0===e?void 0:e[Tt.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(t)}_emitMessageEvents(A){const e=(null==A?void 0:A.filter(A=>!0===(null==A?void 0:A.isModified)))||[];e.length>0&&At.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:e});const t=null==A?void 0:A.filter(A=>!(null==A?void 0:A.isModified));t.length>0&&At.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(A){const e=yo.CONV_C2C,t=qo(A),i=At.message.messageFactory.createMessage(Object.assign(Object.assign({},t),{conversationType:e,flow:Ro.IN})),{elements:o}=t;return i.setElement(o),i}_updateMessageProfile(t){var i;const{messageDataHandler:o}=At.message||{},n=null===(i=At.store.get("login"))||void 0===i?void 0:i.userId,{from:r,nick:s,avatar:a,conversationID:g=""}=t;if(r!==n){const i=o.getLatestMsgSentByPeer(g);if(i){const{nick:n,avatar:r}=i;A(s)||A(a)?(t.nick=e(n)?n:t.nick,t.avatar=e(r)?r:t.avatar):s===n&&a===r||(o.updateNickAndAvatarOfSentMessage({conversationID:g,latestNick:s,latestAvatar:a,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:g,nick:s,avatar:a}))}}else{const A=o.getLatestMsgSentByMe(g);!A||s===A.nick&&a===A.avatar||o.updateNickAndAvatarOfSentMessage({conversationID:g,latestNick:s,latestAvatar:a,isSentByMe:!0})}}_updateConversationUserProfile(A){const{conversationID:e,nick:t,avatar:i}=A,o=Io.getConversation(e),{userProfile:n={}}=o||{};n.avatar===i&&n.nick===t||Io.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:i})})}_updateMessageListDueToModify(A){const{conversationID:e}=A,{isUpdated:t,message:i}=At.message.messageDataHandler.modifyConversationMessage(e,A);!0===t&&At.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[i]}),At.notificationCenter.emitInnerEvent("ModifyMessageSuccess",A),En(e,A)}_handleC2CMessageModify(A){A.C2cMsgModNotifys.forEach(A=>{var e;const t=yo.CONV_C2C;let i=Vo(A);const{to:o,from:n}=i;let r=`${t}${o}`;o===(null===(e=At.store.get("login"))||void 0===e?void 0:e.userId)&&(r=`${t}${n}`),i=Object.assign({conversationType:t,conversationID:r},i),this._updateMessageListDueToModify(i)})}_dispose(){const{notificationCenter:A}=At,{InnerEventSubType:e}=A;At.notificationCenter.unSubscribeInnerEvent(at.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),At.notificationCenter.unSubscribeInnerEvent(at.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),At.notificationCenter.unSubscribeInnerEvent(at.DESTROY,this._dispose,this)}}class Cn{init(){const{notificationCenter:A}=At,{InnerEventSubType:e}=A;ci.getInstance().registerWorkflowStep(_t.RECEIVE_GROUP_NEW_MESSAGE,Tt.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),ci.getInstance().registerWorkflowStep(_t.RECEIVE_GROUP_NEW_MESSAGE,Tt.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,e.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,e.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),A.subscribeInnerEvent(at.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(A){this._canExecuteReceiverNewMessageWorkFlow(A)&&ci.getInstance().executeWorkflow(_t.RECEIVE_GROUP_NEW_MESSAGE,A)}_handleGroupMessagePush(A){const e=A.data||{},{messageDataHandler:t}=At.message,i=[],o=new Map,n=null==e?void 0:e.GroupMsgArray;return null==n||n.forEach(A=>{if(1===A.GroupInfo.NotVisible)return;const e=this._generateGroupMessage(A);this.updateMessageProfile(e);let n=1===e.isModified;t.isMessageSentByCurrentInstance(e)?e.isModified=n:n=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(e)||i.push(e)):$o(e)&&t.storeConversationMessage(e)&&(i.push(e),Zo({conversationUpdateFields:o,message:e}))}),{conversationUpdateFieldList:[...o.values()],messages:i}}_emitMessageEvents(A){var e;const{messages:t}=(null===(e=A.result)||void 0===e?void 0:e[Tt.HANDLE_GROUP_NEW_MESSAGE])||{},i=(null==t?void 0:t.filter(A=>!0===(null==A?void 0:A.isModified)))||[];i.length>0&&At.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:i});const o=(null==t?void 0:t.filter(A=>!(null==A?void 0:A.isModified)))||[];o.length>0&&At.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:o})}_generateGroupMessage(A){const e=yo.CONV_GROUP,t=jo(A),i=At.message.messageFactory.createMessage(Object.assign(Object.assign({},t),{conversationType:e,flow:Ro.IN})),{elements:o}=t;return i.setElement(o),i}updateMessageProfile(A){var e;const{messageDataHandler:t}=At.message||{},i=null===(e=At.store.get("login"))||void 0===e?void 0:e.userId,{from:o,nick:n,avatar:r,conversationID:s="",_elements:a}=A;if(o===i){const A=t.getLatestMsgSentByMe(s);!A||n===A.nick&&r===A.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:s,latestNick:n,latestAvatar:r,isSentByMe:!0})}else if(o===St.CONV_SYSTEM){const{operationType:e,memberInfoList:t,operatorInfo:i}=a;let o={};if(BA(t)?BA(i)||(o=i):[Dt.JOINED,Dt.KICKED,Dt.ADMIN_SET,Dt.ADMIN_CANCELED].includes(e)&&(o=Object.assign({},t[0])),!BA(o)){const{nick:e="",avatar:t=""}=o;A.nick=e,A.avatar=t}}}_updateMessageListDueToModify(A){const{conversationID:e}=A,{isUpdated:t,message:i}=At.message.messageDataHandler.modifyConversationMessage(e,A);!0===t&&At.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[i]}),En(e,A)}_handleGroupMessageModify(A){A.GroupMsgModNotifys.forEach(A=>{const e=yo.CONV_GROUP;let t=zo(A);const{topicID:i,groupID:o}=t,n=i||o,r=`${e}${n}`;t=Object.assign({conversationType:e,conversationID:r,to:n},t),this._updateMessageListDueToModify(t)})}_dispose(){const{notificationCenter:A}=At,{InnerEventSubType:{GROUP_REALTIME_MESSAGE:e,GROUP_MESSAGE_MODIFIED:t}}=A;A.unSubscribeInnerEvent(at.MESSAGE_PUSH,e,this._handleGroupMessagePush,this),A.unSubscribeInnerEvent(at.MESSAGE_PUSH,t,this._handleGroupMessageModify,this),A.unSubscribeInnerEvent(at.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(A){var e,t;const{GroupId:i,GroupType:o}=(null===(t=null===(e=null==A?void 0:A.GroupMsgArray)||void 0===e?void 0:e[0])||void 0===t?void 0:t.GroupInfo)||{},n=o===mt.GRP_AVCHATROOM;return!(!uo.getGroup(i)&&n)}}var Bn=new class{constructor(){this.c2cMessageReceiver=new hn,this.groupMessageReceiver=new Cn}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};const Qn={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!(!A.startsWith("C2C")&&!A.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:A=>{return"string"==typeof(null==(e=A)?void 0:e.text)&&("string"!=typeof e.text||0!==(null===(t=null==e?void 0:e.text)||void 0===t?void 0:t.length))||"payload.text must be a string";var e,t}}}},pn={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var fn=new class{getGroupRoamingMessagesByAnchor(A){return IA(this,void 0,void 0,function*(){try{const{conversationID:e,count:t,direction:o,sequence:n,messageSequenceList:r,getType:s}=A,a=e.replace(Qt.CONV_GROUP,""),g=[];let c=n;if(o===Et.BACKWARD){if("number"!=typeof n)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};c=n+t-1}const l=yield function(A){return IA(this,void 0,void 0,function*(){const{groupID:e,count:t,messageSequence:o,messageSequenceList:n,getType:r}=A,s={GroupId:e,ReqMsgNumber:t,WithRecalledMsg:1,Version:1,GetType:r};return o&&(s.ReqMsgSeq=o),i(n)&&n.length>0&&(s.ReqMsgSeqList=n),yield hi({servcmd:"group_open_http_svc.group_msg_get",data:s})})}({groupID:a,count:t,messageSequence:c,messageSequenceList:r,getType:s});if(l){const{RspMsgList:A=[],NextReqMsgSeq:e=0,IsFinished:t,InvisibleMsgSeq:i}=l,r=`groupID:${a} sequence:${n} reqSeq:${c} direction:${o} complete:${t} nextSequence:${e} remoteMsgCount:${A.length} invisibleSequenceList:${i}`,s=[];for(let o=0;o=n);const u=Xo(s);return At.ssoLog.info("getGroupRoamingMessagesByAnchor",r),{messageList:u,invisibleSequenceList:i,nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:I,serverGroupTipList:g}}}catch(e){const{errorCode:A,errorInfo:t}=e||{};throw new $t({code:A,message:t})}})}_parseMessage(A){const e=Qt.CONV_GROUP;4===A.Event&&(A.MsgBody.MsgType=St.MSG_GRP_TIP);const t=jo(A),i=Lo.createMessage(Object.assign(Object.assign({},t),{conversationType:e,flow:"in"}));return i.setElement(t.elements),i}};class mn{constructor(){this.messageHelper=An,this.messageFactory=Lo,this.messageSender=new In,this.messageAction=new dn,this.messageReceiver=Bn,this.messageDataHandler=un,this.messageHistory=fn,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),this.messageDataHandler.init(),ai({auth:pn,params:Qn})}}const yn="Tag_Profile_IM_",Dn={NICK:`${yn}Nick`,GENDER:`${yn}Gender`,BIRTHDAY:`${yn}BirthDay`,LOCATION:`${yn}Location`,SELFSIGNATURE:`${yn}SelfSignature`,ALLOWTYPE:`${yn}AllowType`,LANGUAGE:`${yn}Language`,AVATAR:`${yn}Image`,MESSAGESETTINGS:`${yn}MsgSettings`,ADMINFORBIDTYPE:`${yn}AdminForbidType`,LEVEL:`${yn}Level`,ROLE:`${yn}Role`},vn="Tag_Profile_Custom",wn="profileCustomField",Sn="USER_STATUS",Mn=1,Rn=1e3,_n={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},Tn=new Map([[Dn.NICK,"nick"],[Dn.GENDER,"gender"],[Dn.BIRTHDAY,"birthday"],[Dn.LOCATION,"location"],[Dn.SELFSIGNATURE,"selfSignature"],[Dn.ALLOWTYPE,"allowType"],[Dn.LANGUAGE,"language"],[Dn.AVATAR,"avatar"],[Dn.MESSAGESETTINGS,"messageSettings"],[Dn.ADMINFORBIDTYPE,"adminForbidType"],[Dn.LEVEL,"level"],[Dn.ROLE,"role"]]);var Nn=new class{createProfile(A,e){const t={userID:A,profileCustomField:[]};return e.forEach(A=>{const{tag:e,value:i}=A;e&&e.indexOf(vn)>-1?t.profileCustomField.push({key:e,value:i}):Tn.has(e)&&(t[Tn.get(e)]=i)}),Object.assign(Object.assign({},_n),t)}parseProfileItem(A=[]){const e=[];return A.forEach(A=>{e.push({tag:A.Tag,value:A.Value})}),e}parseProfileList(A=[]){const e=[];return A.forEach(A=>{e.push({tag:A.Tag,value:A.ValueBytes})}),e}convertParamsToProfile(A){const e=[];return Object.keys(A).forEach(t=>{t!==wn&&e.push({tag:Dn[t.toUpperCase()],value:A[t]})}),A.profileCustomField&&i(A.profileCustomField)&&A.profileCustomField.forEach(A=>{e.push({tag:A.key,value:A.value})}),e}normalizeProfileFields(A){const e={},t=[];return A.forEach(A=>{const{tag:i,value:o}=A;if(i&&i.indexOf(vn)>-1&&t.push({key:i,value:o}),Tn.has(i)&&void 0!==o){const A=Tn.get(i);e[A]=o}}),t.length>0&&(e.profileCustomField=t),e}};const{generateProtocolData:bn}=At.common;function Gn(A){return IA(this,void 0,void 0,function*(){const e="profile.portrait_get_all",t={From_Account:pi(),UserItem:[]};A.forEach(A=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:A})});const i=bn({servcmd:e,data:t}),o=`${i.head.seq}${e}`,n=yield At.channel.sendPacket(i,{requestId:o});if(n)return function(A){const{ActionStatus:e,ErrorCode:t,ErrorDisplay:i,ErrorInfo:o,UserProfileItem:n}=A,r=[];return n.map(A=>{const{To_Account:e,CustomSequence:t,ResultCode:i,ResultInfo:o,StandardSequence:n,ProfileItem:s}=A,a=Nn.parseProfileItem(s);r.push({userId:e,customSequence:t,resultCode:i,resultInfo:o,standardSequence:n,profileItem:a})}),{actionStatus:e,errorCode:t,errorDisplay:i,errorInfo:o,userProfile:r}}(n)})}function kn(A){return ho.getFriendMap().has(A)}const{isEmpty:Ln}=At.utils;class Un{constructor(){this._strangerProfileMap=new Map}init(){Bo.getInstance().registerApi({apiName:"getMyProfile",context:this}),Bo.getInstance().registerApi({apiName:"getUserProfile",context:this}),Bo.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=Nn.createProfile.bind(Nn);const{notificationCenter:A}=At;ci.getInstance().registerWorkflowStep(_t.SYNC_SERVER_INFO_AFTER_LOGIN,Tt.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,A.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),A.subscribeInnerEvent(at.LOGOUT,this._reset,this),A.subscribeInnerEvent(at.DESTROY,this._dispose,this)}getMyProfile(){return IA(this,void 0,void 0,function*(){try{const A=pi(),e=yield Gn([A]);if(e){const t=this._handleProfileFormResponse(e)[0];return ho.getUserProfileMap().set(A,t),{code:0,data:t}}}catch(E){const{errorCode:e,errorInfo:t}=E;throw new $t({functionName:"getMyProfile",code:e,message:t})}})}getUserProfile(A){return IA(this,void 0,void 0,function*(){try{let{userIDList:e}=A;const{userIdListToRequest:t,profileFromCache:o}=this._filterRequestAndCacheUsers(e);if(0===t.length)return{code:0,data:o,successLog:{message:`userIDList.length:${e.length}`}};t.length>Rn&&(At.ssoLog.warn("getUserProfile","userIdListToRequest.length > 1000"),t.length=Rn);const{data:n,error:r}=yield this._batchFetchUserProfiles(t),s=t.length,a=n.length,g=s-a;if(0===o.length&&s===g&&!Ln(r))throw r;if(i(n))return n.forEach(A=>{kn(A.userID)?ho.getUserProfileMap().set(A.userID,A):this._strangerProfileMap.set(A.userID,A)}),{code:0,data:n.concat(o),successLog:{message:`getUserProfile query:${s} success:${a} fail:${g} from cache:${o.length}`}}}catch(e){const{errorCode:A}=e;throw new $t({functionName:"getUserProfile",code:A})}})}getMyProfileCacheThenServer(){return IA(this,void 0,void 0,function*(){const A=pi(),e=ho.getUserProfileMap().has(A);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(A){return IA(this,void 0,void 0,function*(){const e=pi(),t={};for(const n in A)void 0!==A[n]&&(t[n]=A[n]);const i=Nn.convertParamsToProfile(t);try{const A={From_Account:e,ProfileItem:i};yield function(A){return IA(this,void 0,void 0,function*(){const e="profile.portrait_set",t=bn({servcmd:e,data:A}),i=`${t.head.seq}${e}`,o=yield At.channel.sendPacket(t,{requestId:i});if(o){const{ActionStatus:A,ErrorCode:e,ErrorDisplay:t,ErrorInfo:i}=o;return{actionStatus:A,errorCode:e,errorDisplay:t,errorInfo:i}}})}(A);const o=ho.getUserProfile(e);let n;n=o?Object.assign(Object.assign({},o),t):Nn.createProfile(e,i);const r=!it(o,n,["lastUpdatedTime"]);return n.lastUpdatedTime=Date.now(),ho.getUserProfileMap().set(e,n),r&&this._emitProfileUpdated(n),{code:0,data:n,successLog:{message:`profileArray: ${At.utils.safeStringify(i)}`}}}catch(o){const{errorCode:A,errorInfo:e}=o;throw new $t({functionName:"updateMyProfile",code:A,message:e})}})}updateMyNickAndAvatar(A){return IA(this,void 0,void 0,function*(){const e=pi(),t=Date.now(),i=ho.getUserProfile(e);let o={};o=i?Object.assign(i,A):Nn.createProfile(e,A),o.lastUpdatedTime=t,ho.getUserProfileMap().set(e,o)})}_onProfileDataModify(A){const e=function(A){const{Profile_Account:e,PushType:t,ProfileList:i}=A;return{userId:e,pushType:t,profileList:Nn.parseProfileList(i)}}(A.ProfileDataMod[0]);if(Ln(e))return;const{isProfileUpdated:t,profile:i}=this._handleProfileModified(e);t&&this._emitProfileUpdated(i)}_emitProfileUpdated(A){At.notificationCenter.emitInnerEvent(at.PROFILE_UPDATE,{name:at.PROFILE_UPDATE,data:[A]}),At.notificationCenter.emitOuterEvent(rt.PROFILE_UPDATED,{name:rt.PROFILE_UPDATED,data:[A]}),Io.updateConversation(`C2C${null==A?void 0:A.userID}`,{userProfile:A})}_dispose(){const{notificationCenter:A}=At;A.unSubscribeInnerEvent(at.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(at.MESSAGE_PUSH,A.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),A.unSubscribeInnerEvent(at.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(A){const{userId:e,profileList:t}=A,i=ho.getUserProfile(e);if(!(pi()===e||kn(e)&&i))return{isProfileUpdated:!1,profile:null};const o=Nn.normalizeProfileFields(t),n=Object.keys(o).some(A=>A===wn?!it(i.profileCustomField,o.profileCustomField):i[A]!==o[A]);if(!n)return{isProfileUpdated:!1,profile:i};const r=Date.now(),s=Object.assign(Object.assign(Object.assign({},i),o),{lastUpdatedTime:r});return ho.getUserProfileMap().set(e,s),{isProfileUpdated:n,profile:s}}_filterRequestAndCacheUsers(A){const e=[],t=[];return A.forEach(A=>{const i=ho.getUserProfileMap().has(A);kn(A)&&i?t.push(ho.getUserProfile(A)):this._isStrangerAndProfileValid(A)?t.push(this._strangerProfileMap.get(A)):e.push(A)}),{userIdListToRequest:e,profileFromCache:t}}_handleProfileFormResponse(A){const{userProfile:e}=A;if(!Array.isArray(e))return[];const t=e.filter(A=>"@TLS#NOT_FOUND"!==A.userId&&""!==A.userId&&!Ln(A.profileItem)),i=Date.now();return t.map(A=>{const e=Nn.createProfile(A.userId,A.profileItem);return e.lastUpdatedTime=i,e})}_isStrangerAndProfileValid(A){var e;if(!kn(A)){const{lastUpdatedTime:t=0}=this._strangerProfileMap.get(A)||{},i=(null===(e=At.store.get("cloudConfig"))||void 0===e?void 0:e.stranger_profile_expiration_time)||6e5;return Date.now()-t<=i}return!1}_chunkUserIDList(A,e){return Array.from({length:Math.ceil(A.length/e)},(t,i)=>A.slice(i*e,(i+1)*e))}_batchFetchUserProfiles(A){return IA(this,void 0,void 0,function*(){const e=[],t=[];let o={};return this._chunkUserIDList(A,100).forEach(A=>{e.push(Gn(A))}),(yield Promise.allSettled(e)).forEach(A=>{if("fulfilled"===A.status){const e=A.value,o=this._handleProfileFormResponse(e);i(o)&&t.push(...o)}else if("rejected"===A.status){const{code:e,message:t}=A.reason||{};o={errorCode:e,message:t}}}),{data:t,error:o}})}_reset(){ho.getUserProfileMap().clear(),this._strangerProfileMap.clear()}}const Fn=new Map,On=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let tt=0,Ar=On.length;tt>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);try{return decodeURIComponent(escape(t))}catch(i){return console.warn(i),""}}const{isEmpty:Pn}=At.utils,{generateProtocolData:Yn}=At.common;function Jn(A){return IA(this,void 0,void 0,function*(){const e="im_open_status.ws_get_user_status",t=Yn({servcmd:e,data:{To_Account:A}}),i=`${t.head.seq}${e}`,o=yield At.channel.sendPacket(t,{requestId:i});if(o)return function(A){const{ErrorCode:e,ErrorInfo:t,ErrorList:i=[],UserStatusList:o=[]}=A;return{errorCode:e,errorInfo:t,successUserList:o.map(A=>{const{To_Account:e,Status:t,CustomStatus:i}=A;return{userID:e,statusType:t,customStatus:xn(i)}}),failureUserList:i.map(A=>{const{To_Account:e,Invalid_Account:t,ErrorCode:i,ErrorInfo:o}=A;return{userID:Pn(t)?e:t,code:i,message:o}})}}(o)})}class Hn{constructor(){this._customStatus=""}init(){const{notificationCenter:A}=At;Bo.getInstance().registerApi({apiName:"getUserStatus",context:this}),Bo.getInstance().registerApi({apiName:"setSelfStatus",context:this}),Bo.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),Bo.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),ci.getInstance().registerWorkflowStep(_t.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Tt.USER_STATUS_UPDATE,this._onReOnline,this),A.subscribeInnerEvent(at.MESSAGE_PUSH,A.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),A.subscribeInnerEvent(at.LOGOUT,this._reset,this),A.subscribeInnerEvent(at.DESTROY,this._dispose,this)}setSelfStatus(A){return IA(this,void 0,void 0,function*(){const e=pi(),{customStatus:t}=A;try{return yield function(A){return IA(this,void 0,void 0,function*(){const e="im_open_status.ws_set_custom_status",t=Yn({servcmd:e,data:{CustomStatus:A}}),i=`${t.head.seq}${e}`,o=yield At.channel.sendPacket(t,{requestId:i});if(o){const{ErrorCode:A,ErrorInfo:e}=o;return{errorCode:A,errorInfo:e}}})}(t),this._customStatus=t,{code:0,data:{userID:e,statusType:Mn,customStatus:t},successLog:{message:`customStatus: ${t}`}}}catch(i){const{errorCode:A,errorInfo:e}=i;throw new $t({functionName:"setSelfStatus",code:A,message:e})}})}getUserStatus(A){return IA(this,void 0,void 0,function*(){const{userIDList:e=[]}=A;let t={};return this._isOnlyMeInArray(e)&&(t=this._getMyStatus()),t=yield this._getUserStatus(e),Object.assign(Object.assign({},t),{successLog:{message:`userIDList length: ${e.length}`}})})}setCustomStatus(A){const e=xn(A);this._customStatus=e}subscribeUserStatus(A){return IA(this,void 0,void 0,function*(){try{const{userIDList:e=[]}=A;this._checkBusinessCapabilityBits("subscribeUserStatus");const t=this._getMaxUserCount("subscribe"),i=this._sliceUserIDList(e,t),o=yield function(A){return IA(this,void 0,void 0,function*(){const{channel:e}=At,t="im_open_status.ws_status_subscribe",i=Yn({servcmd:t,data:{To_Account:A}}),o=`${i.head.seq}${t}`;return yield e.sendPacket(i,{requestId:o})})}(i),n=this._parseResponse(o);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: ${n.length}`}}}catch(e){const{errorCode:A}=e;throw new $t({functionName:"subscribeUserStatus",code:A})}})}unsubscribeUserStatus(A){return IA(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("unsubscribeUserStatus");const{userIDList:e=[]}=A,t=this._getMaxUserCount("unsubscribe"),i=this._sliceUserIDList(e,t),o=yield function(A){return IA(this,void 0,void 0,function*(){const{channel:e}=At,t="im_open_status.ws_status_unsubscribe";let i={};i=0===A.length?{UnsubscribeAll:1}:{To_Account:A};const o=Yn({servcmd:t,data:i}),n=`${o.head.seq}${t}`;return yield e.sendPacket(o,{requestId:n})})}(i),n=this._parseResponse(o);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: ${n.length}`}}}catch(e){const{errorCode:A}=e;throw new $t({functionName:"unsubscribeUserStatus",code:A})}})}_onUserStatusUpdate(A){const{UserStatusList:e=[]}=A||{},t=e.map(A=>{const{To_Account:e,Status:t,CustomStatus:i}=A;return{userID:e,statusType:t,customStatus:xn(i)}});this._emitUserStatusUpdatedEvent(t)}_onReOnline(A){const e=xn(A.data.customStatus);if(this._customStatus===e)return;this._customStatus=e;const t={userID:pi(),statusType:Mn,customStatus:e};this._emitUserStatusUpdatedEvent(t)}_emitUserStatusUpdatedEvent(A){At.notificationCenter.emitOuterEvent(rt.USER_STATUS_UPDATED,{name:rt.USER_STATUS_UPDATED,data:A})}_sliceUserIDList(A,e){return A.slice(0,e)}_parseResponse(A){const{ErrorList:e=[]}=A;return e.map(A=>{const{To_Account:e,Invalid_Account:t,ErrorCode:i,ErrorInfo:o}=A;return{userID:At.utils.isEmpty(t)?e:t,code:i,message:o}})}_checkBusinessCapabilityBits(A){if(!At.store.get("commercialConfig").get(Sn))throw new $t({functionName:A,code:Mt.NO_USE,replacement1:A})}_getMaxUserCount(A){const e=At.store.get("cloudConfig")||{},t={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:100},unsubscribe:{key:"status_unsub_count",default:100}},{key:i,default:o}=t[A],n=e[i]||o;return parseInt(n,10)}_getMyStatus(){return{code:0,data:{successUserList:[{userID:pi(),statusType:Mn,customStatus:this._customStatus}],failureUserList:[]}}}_getUserStatus(A){return IA(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("getUserStatus");const e=this._getMaxUserCount("query"),t=this._sliceUserIDList(A,e),i=yield Jn(t),{successUserList:o,failureUserList:n}=i||{};return{code:0,data:{successUserList:o,failureUserList:n}}}catch(e){const{errorCode:A}=e;throw new $t({functionName:"getUserStatus",code:A})}})}_isOnlyMeInArray(A){const e=pi();return 1===A.length&&A.indexOf(e)>-1}_dispose(){const{notificationCenter:A}=At;A.unSubscribeInnerEvent(at.MESSAGE_PUSH,A.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),A.unSubscribeInnerEvent(at.DESTROY,this._dispose,this),A.unSubscribeInnerEvent(at.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}const qn={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0,customValidator:function(A){for(const e of A){if("object"!=typeof e)return"Each item in profileCustomField must be an object";if("string"!=typeof(null==e?void 0:e.key))return"Each item.key in profileCustomField must be a string";if(!(null==e?void 0:e.key.startsWith(vn)))return'Each item.key in profileCustomField must start with "Tag_Profile_Custom"'}return!0}}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},Vn={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class jn{constructor(){this.userProfile=new Un,this.userStatus=new Hn,this.userProfile.init(),this.userStatus.init(),ai({auth:Vn,params:qn})}}function Kn(A){const t=[];if(!e(A))return t;const i=A.length;if(0===i)return t;for(let e=i-1;e>=0;e--)"1"===A[e]&&t.push(2**(i-e-1));return t}var Wn,zn,Zn;!function(A){A.NOT_START="notStart",A.PENDING="pending",A.RESOLVED="resolved",A.REJECTED="rejected"}(Wn||(Wn={})),function(A){A[A.C2C=1]="C2C",A[A.GROUP=2]="GROUP"}(zn||(zn={})),function(A){A[A.C2C=8]="C2C",A[A.GROUP=2]="GROUP"}(Zn||(Zn={}));class Xn{constructor(){this._name="SyncConversationHandler",this._pagingStatus=Wn.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){const{notificationCenter:A}=At;ci.getInstance().registerWorkflowStep(_t.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Tt.CONVERSATION_RECOVER,this._syncConversationList,this),ci.getInstance().registerWorkflowStep(_t.SYNC_SERVER_INFO_AFTER_LOGIN,Tt.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),A.subscribeInnerEvent(at.LOGOUT,this._reset,this),A.subscribeInnerEvent(at.DESTROY,this._dispose,this),At.ssoLog.debug(`${this._name}.init`)}isSyncCompleted(){return this._pagingStatus===Wn.RESOLVED}_syncConversationListAfterLogin(){return IA(this,void 0,void 0,function*(){return this._pagingStatus=Wn.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}_syncConversationList(){return IA(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:e}}=At;A.debug("_syncConversationList","start");try{const e=yield this._pagingGetConversationList(!0);this._pagingStatus=Wn.RESOLVED;const{conversationList:t=[]}=e||{};return A.info("_syncConversationList",`success count:${t.length}`),e}catch(t){const{errorCode:i,errorInfo:o}=t,n=new $t({code:i,message:o});A.error("_syncConversationList",`fail ${e(t)}`,{error:n})}})}_pagingGetConversationList(A){return IA(this,void 0,void 0,function*(){try{const{notificationCenter:e}=At,t=[];this._pagingStatus=Wn.PENDING;const i=yield function(A){return IA(this,void 0,void 0,function*(){const{fromAccount:e,pagingTimeStamp:t,pagingStartIndex:i,pagingPinnedTimeStamp:o,pagingPinnedStartIndex:n}=A;return hi({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:e,StartIndex:i,TimeStamp:t,TopStartIndex:n,TopTimeStamp:o}})})}({fromAccount:pi(),pagingTimeStamp:A?this._pagingTimeStamp:0,pagingStartIndex:A?this._pagingStartIndex:0,pagingPinnedTimeStamp:A?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:A?this._pagingPinnedStartIndex:0}),{CompleteFlag:o,SessionItem:n=[],TimeStamp:r,StartIndex:s,TopTimeStamp:a,TopStartIndex:g}=i||{};let c=[];if(1===o&&(this._pagingStatus=Wn.RESOLVED),n.length>0&&(c=this._getConversationOptions(n),t.push(...c)),e.emitInnerEvent(at.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:c}),this._pagingTimeStamp=r,this._pagingStartIndex=s,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=g,1!==o){const{conversationList:e}=yield this._pagingGetConversationList(A);t.push(...e)}return{conversationList:t}}catch(e){throw e}})}_getConversationOptions(A){const{utils:{isUndefined:e}}=At,t=this._convertConversationKey(A);return this._filterValidConversations(t).map(A=>(e(A.lastMsg)&&(A.lastMsg={elements:[]}),A.type===zn.C2C?this._assembleC2COption(A):this._assembleGroupOption(A)))}_filterValidConversations(A){return A.filter(({type:A,userID:e})=>A===zn.C2C&&!function(A){let e;return A.startsWith(St.CONV_C2C)&&(e=A.replace(St.CONV_C2C,"")),"@TLS#ERROR"===e||"@TLS#NOT_FOUND"===e}(e)||2===A)}_assembleC2COption(A){var e,t,i,o,n,r;const s=this._createUserprofile(A);return{conversationID:`${St.CONV_C2C}${A.userID}`,type:St.CONV_C2C,lastMessage:{lastTime:A.time,lastSequence:A.sequence,fromAccount:A.lastC2CMsgFromAccount,type:(null===(e=A.lastMsg)||void 0===e?void 0:e.elements[0])?null===(t=A.lastMsg)||void 0===t?void 0:t.elements[0].type:null,payload:(null===(i=A.lastMsg)||void 0===i?void 0:i.elements[0])?this._amendLayersOverLimitProp(A.lastMsg.elements[0].content):null,cloudCustomData:(null===(o=A.lastMsg)||void 0===o?void 0:o.cloudCustomData)||"",isRevoked:A.lastMessageFlag===Zn.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(A),revoker:(null===(r=null===(n=A.lastMsg)||void 0===n?void 0:n.revokerInfo)||void 0===r?void 0:r.revoker)||null},unreadCount:0,userProfile:s,peerReadTime:A.peerReadTime,isPinned:1===A.isPinned,customData:A.customMark||"",markList:Kn(A.standardMark),conversationGroupList:[],remark:A.friendRemark||"",messageRemindType:this._transMsgRemindType(A.messageRemindType)}}_createUserprofile(A){var e;const{userID:t,nick:i,peerAvatar:o}=A,n=[{tag:"Tag_Profile_IM_Nick",value:i},{tag:"Tag_Profile_IM_Image",value:o}];return null===(e=At.user.userProfile)||void 0===e?void 0:e.createProfile(t,n)}_computeIsPeerRead(A){const e=pi(),{lastC2CMsgFromAccount:t,time:i,c2cPeerReadTime:o}=A;return t===e&&i<=o}_assembleGroupOption(A){var e,t,i;return{conversationID:`${St.CONV_GROUP}${A.groupID}`,type:St.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:A.time,lastSequence:A.sequence,fromAccount:A.msgGroupFromAccount},this._patchTypeAndPayload(A)),{cloudCustomData:(null===(e=A.lastMsg)||void 0===e?void 0:e.cloudCustomData)||"",isRevoked:A.lastMessageFlag===Zn.GROUP,onlineOnlyFlag:!1,nick:A.msgGroupFromNickName||"",nameCard:A.msgGroupFromCardName||"",revoker:(null===(i=null===(t=A.lastMsg)||void 0===t?void 0:t.revokerInfo)||void 0===i?void 0:i.revoker)||null}),groupProfile:{groupID:A.groupID,name:A.groupNick,avatar:A.groupImage,type:A.groupType,nextMessageSeq:A.nextMessageSeq},unreadCount:this._computeGroupUnreadCount(A),peerReadTime:0,isPinned:1===A.isPinned,version:0,customData:A.customMark||"",markList:Kn(A.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(A.messageRemindType),subType:A.groupType}}_convertConversationKey(A){return A.map(A=>({type:A.Type,userID:A.To_Account,nick:A.C2cNick,peerAvatar:A.C2cImage,time:A.MsgTimeStamp,sequence:A.MsgSeq,lastC2CMsgFromAccount:A.LastC2cMsgFrom_Account,lastMsg:this._convertLastMsgKey(A.LastMsg),lastMessageFlag:A.LastMsgFlags,c2cPeerReadTime:A.C2cPeerReadTime,peerReadTime:A.C2cPeerReadTime,friendRemark:A.C2cRemark,isPinned:A.TopFlags,standardMark:A.StandardMark,customMark:A.CustomMark,messageRemindType:A.MsgRecvOption,groupID:A.ToAccount,groupNick:A.GroupNick,groupImage:A.GroupImage,groupType:A.GroupType,nextMessageSeq:A.GroupNextMsgSeq,msgGroupFromAccount:A.MsgGroupFrom_Account,msgGroupFromNickName:A.MsgGroupFromNickName,MsgGroupFromCardName:A.MsgGroupFromCardName,unreadCount:A.UnreadMsgCount,noUnreadCount:A.GroupIgnoredUnreadSeqCount}))}_convertLastMsgKey(A){var e,t,i;const{utils:{isEmpty:o}}=At;if(o(A))return null;let n="",r=null;if(!o(A.GroupTips)){const{From_Account:t,GroupName:i}=(null===(e=A.GroupTips)||void 0===e?void 0:e.GroupInfo)||{};n=St.MSG_GRP_TIP,r=Object.assign(Object.assign({},this._parseContent(n,A.GroupTips.MsgBody)),{groupProfile:{from:t,groupName:i}})}return A.MsgBody&&(n=null===(t=A.MsgBody[0])||void 0===t?void 0:t.MsgType,r=this._parseContent(n,A.MsgBody[0])),{event:A.Event,elements:[{type:n,content:r,cloudCustomData:A.CloudCustomData}],revokerInfo:{revoker:null===(i=A.RevokerInfo)||void 0===i?void 0:i.Revoker_Account}}}_parseContent(A,e){var t;if(!e)return e;const i=At.message.messageFactory.getElementClass(A);return i?null===(t=i.parseServerPushElement(e))||void 0===t?void 0:t.content:e}_amendLayersOverLimitProp(A){const{LayersOverLimit:e}=A;return lA(A,["LayersOverLimit"]).layersOverLimit=1===e,A}_transMsgRemindType(A){let e="";return 0===A?e=St.MSG_REMIND_ACPT_AND_NOTE:1===A?e=St.MSG_REMIND_DISCARD:2===A?e=St.MSG_REMIND_ACPT_NOT_NOTE:3===A&&(e=St.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),e}_patchTypeAndPayload(A){var e;const{utils:{isUndefined:t}}=At,{event:i,elements:o=[]}=A.lastMsg||{};return t(i)?{type:o[0]?o[0].type:null,payload:o[0]?this._amendLayersOverLimitProp(o[0].content):null}:{type:St.MSG_GRP_TIP,payload:(null===(e=null==o?void 0:o[0])||void 0===e?void 0:e.content)||{}}}_computeGroupUnreadCount(A){const{unreadCount:e=0,noUnreadCount:t=0}=A,i=e-t;return i>0?i:0}_reset(){this._pagingStatus=Wn.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();const{notificationCenter:A}=At;A.unSubscribeInnerEvent(at.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(at.DESTROY,this._dispose,this)}}class $n{constructor(){this.syncConversationHandler=new Xn,this.syncConversationHandler.init()}}return console.log(`TencentCloudLiteChat.VERSION:${ne}`),{create:function(A){var e,t;const{SDKAppID:i,testEnv:o=!1,devMode:n=!1,unlimitedAVChatRoom:r=!1,scene:s="",oversea:a=!1,instance:g,disableIndependentDomain:c=!1}=A;let l=i;if(!function(A){if("number"==typeof A)return!0;const e=Number(A);return!Number.isNaN(e)}(l))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(l=Number(l),li.has(l))return li.get(l);let I=null;if(g)I=g,I._workflowManager&&ci.setInstance(I._workflowManager),I._pluginManager&&I._pluginManager.installBuiltInPlugin(go),g.isReady()&&(null===(t=(e=ci.getInstance()).executeWorkflow)||void 0===t||t.call(e,_t.SYNC_SERVER_INFO_AFTER_LOGIN));else{const A=function(){function A(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${A()+A()}${A()}${A()}${A()}${A()}${A()}${A()}`}();At.init({sdkAppId:l,instanceId:A,testEnv:o,devMode:n,unlimitedAVChatRoom:r,disableIndependentDomain:c,scene:s,oversea:a,sdkEdition:ao,version:ne}),ci.getInstance().init(),At.message=new mn,At.user=new jn,At.login=new mo,At.conversation=new $n,lo.getInstance().installBuiltInPlugin(go),I=Bo.getInstance().exposeApiForClient(),I._workflowManager=ci.getInstance(),I._pluginManager=lo.getInstance();const{utils:{IS_WORKER_AVAILABLE:e,USER_AGENT:t,getPlatformType:g,isIOSWebView:u}}=At,E=`instanceID:${A} SDKAppID:${i} platform:${g()} isIOSWebView:${u} workerAvailable:${e} UserAgent:${t}`;At.ssoLog.info("sdkConstruct",E)}return li.set(l,I),I},TSignaling:gt,EVENT:rt,VERSION:ne,TYPES:St}}();var NR=TR.exports;const bR=RR(NR),GR="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),kR="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||GR,LR="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),UR="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),FR="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),OR="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),xR="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,PR="undefined"!=typeof uni&&"undefined"==typeof window,YR="undefined"!=typeof uni,JR=("undefined"!=typeof uni||"undefined"!=typeof window)&&!(kR||LR||UR||FR||OR||xR||PR),HR=LR?qq:UR?tt:FR?swan:OR?my:kR?wx:PR?uni:xR?jd:JR?window:{};let qR=class{constructor(){this.serviceMap=new Map}registerService(A,e){this.serviceMap.has(A)||(console.log(`TUIServiceManager.registerService serviceName:${A}`),this.serviceMap.set(A,e))}unregisterService(A){this.serviceMap.has(A)&&(console.log(`TUIServiceManager.unregisterService serviceName:${A}`),this.serviceMap.delete(A))}getService(A){return this.serviceMap.get(A)}callService(A){const{serviceName:e,method:t,params:i,callback:o}=A,n=this.getService(e);if(console.log(`TUIServiceManager.callService serviceName:${e}, service:`,n),n)return n.onCall(t,i,o)}},VR=class{constructor(){this.extensionMap=new Map}registerExtension(A,e){if(console.log(`TUIExtensionManager.registerExtension extensionID:${A}`),!this.extensionMap.has(A)){const e=[];this.extensionMap.set(A,e)}const t=this.extensionMap.get(A);-1===t.indexOf(e)&&t.push(e)}unregisterExtension(A,e){if(console.log(`TUIExtensionManager.unregisterExtension extensionID:${A}`),this.extensionMap.has(A)){const t=this.extensionMap.get(A),i=t.indexOf(e);i>-1&&t.splice(i,1)}}getExtensionList(A,e){const t=e?`params:${JSON.stringify(e)}`:"";console.log(`TUIExtensionManager.getExtensionList extensionID:${A} ${t}`);let i=[],o=[];if(this.extensionMap.has(A)){i=this.extensionMap.get(A);for(let t=0;t(this.userID="",this.userSig="",this.TUICore.notifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS),Promise.resolve(A)))}destroy(){return this.chat.destroy().then(A=>(this.userID="",this.userSig="",this.TUICore.notifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS),Promise.resolve(A)))}setLogLevel(A){return this.chat.setLogLevel(A)}getContext(){return{chat:this.chat,SDKAppID:this.SDKAppID,userID:this.userID,userSig:this.userSig}}reportPlugin(){var A;for(const e in WR)this.TUICore.getService(e)&&(null===(A=this.chat.callExperimentalAPI("isFeatureEnabledForStat",WR[e]))||void 0===A||A.catch(()=>{}))}loginChat(A){const{userID:e,userSig:t}=A;return new Promise((A,i)=>{this.chat.login({userID:e,userSig:t}).then(e=>{e.data.repeatLogin&&this.chat.isReady()&&A(e),this.reportPlugin(),this.loginStatusPromise.set("login",{resolve:A,reject:i,imResponse:e})}).catch(A=>{i(A)})})}onChatEvent(){this.chat.on(this.EVENT.SDK_READY,this.onSDKReady,this),this.chat.on(this.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.chat.on(this.EVENT.KICKED_OUT,this.onUserKicked,this),this.isOnChatEvent=!0}offChatEvent(){this.isOnChatEvent&&(this.chat.off(this.EVENT.SDK_READY,this.onSDKReady,this),this.chat.off(this.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.chat.off(this.EVENT.KICKED_OUT,this.onUserKicked,this),this.isOnChatEvent=!1)}onSDKReady(){if(this.loginStatusPromise.has("login")){this.TUICore.notifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS);const A=setTimeout(()=>{const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),clearTimeout(A),this.loginStatusPromise.delete("login")},500)}}onSDKNotReady(){this.loginStatusPromise.has("login")&&this.loginStatusPromise.get("login").reject(new Error("sdk not ready")),this.loginStatusPromise.delete("login")}onUserKicked(A){A.data.type!==this.TYPES.KICKED_OUT_USERSIG_EXPIRED?this.TUICore.notifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_KICKED_OFFLINE):this.TUICore.notifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_SIG_EXPIRED)}_addSDKExtensions(){Array.isArray(HR.__$RTC_CHAT__)&&HR.__$RTC_CHAT__.length>0&&this.chat.use(HR.__$RTC_CHAT__)}getStatScene(A){return A&&jR.indexOf(A)>-1?"rn"===A?"38":YR?"vue2"===A?"31":"32":"vue2"===A?"29":"30":A}},ZR=class{constructor(){this.eventMap=new Map}registerEvent(A,e,t){const i=this.getKey(A,e);if(console.log(`TUIEventManager.registerEvent eventName:${A} subKey:${e}`),!this.eventMap.has(i)){const A=[];this.eventMap.set(i,A)}const o=this.eventMap.get(i);-1===o.indexOf(t)&&(o.push(t),this.renotify(A,e,t))}unregisterEvent(A,e,t){console.log(`TUIEventManager.unregisterEvent eventName:${A} subKey:${e}`);const i=this.getKey(A,e);if(this.eventMap.has(i)){const A=this.eventMap.get(i),e=A.indexOf(t);e>-1&&A.splice(e,1)}}notifyEvent(A,e,t){const i=this.getKey(A,e),o=t?`params:${JSON.stringify(t)}`:"";console.log(`TUIEventManager.notifyEvent eventName:${A} subKey:${e} ${o}`),this.eventMap.has(i)&&this.eventMap.get(i).forEach(i=>{i.onNotifyEvent(A,e,t)})}getKey(A,e){let t=A;return e&&(t=`${A}-${t}`),t}renotify(A,e,t){if(A===KR.TUILogin.EVENT.LOGIN_STATE_CHANGED&&e===KR.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS){const{chat:A}=zR.getInstance().getContext();A&&A.isReady()&&(t.onNotifyEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS),console.log("TUIEventManager.renotify success."))}}};console.log("TUICore-Lite.VERSION:1.0.0");const XR=class A{constructor(){this.serviceManager=new qR,this.extensionManager=new VR,this.eventManager=new ZR}static getInstance(){return HR.__$RTC_TUICore__&&HR.__$RTC_TUILogin__?HR.__$RTC_TUICore__:(A.instance||(console.log("TUICore.getInstance ok."),A.instance=new A),HR.__$RTC_TUICore__=A.instance,A.instance)}registerService(A,e){return this.serviceManager.registerService(A,e)}unregisterService(A){return this.serviceManager.unregisterService(A)}getService(A){return this.serviceManager.getService(A)}callService(A){return this.serviceManager.callService(A)}registerExtension(A,e){return this.extensionManager.registerExtension(A,e)}unregisterExtension(A,e){return this.extensionManager.unregisterExtension(A,e)}getExtensionList(A,e){return this.extensionManager.getExtensionList(A,e)}registerEvent(A,e,t){return this.eventManager.registerEvent(A,e,t)}unregisterEvent(A,e,t){return this.eventManager.unregisterEvent(A,e,t)}notifyEvent(A,e,t){return this.eventManager.notifyEvent(A,e,t)}}.getInstance(),$R=zR.getInstance(XR);var A_={exports:{}};A_.exports=function(){const A=new class{init(A){this.core=A}};function e(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const t=e=>{const{core:{OuterConstant:t,utils:{isString:i}}}=A;return i(e)&&e.slice(0,3)===t.CONV_C2C},i=e=>{const{core:{OuterConstant:t,utils:{isString:i}}}=A;return i(e)&&e.slice(0,5)===t.CONV_GROUP},o=e=>{const{core:{OuterConstant:t,utils:{isString:i}}}=A;return i(e)&&e===t.CONV_SYSTEM},n=e=>({lastTime:(null==e?void 0:e.time)||(null==e?void 0:e.lastTime)||0,lastSequence:(null==e?void 0:e.sequence)||(null==e?void 0:e.lastSequence)||0,fromAccount:(null==e?void 0:e.from)||(null==e?void 0:e.fromAccount)||"",messageForShow:A.core.common.getMessagePreviewText(null==e?void 0:e.type,null==e?void 0:e.payload),payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",onlineOnlyFlag:(null==e?void 0:e._onlineOnlyFlag)||!1,nick:(null==e?void 0:e.nick)||"",nameCard:(null==e?void 0:e.nameCard)||"",version:(null==e?void 0:e.version)||0,isPeerRead:(null==e?void 0:e.isPeerRead)||!1,revoker:(null==e?void 0:e.revoker)||null});function r(e){const{OuterConstant:t}=A.core;let i="";return 0===e?i=t.MSG_REMIND_ACPT_AND_NOTE:1===e?i=t.MSG_REMIND_DISCARD:2===e?i=t.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(i=t.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),i}function s(e){const{OuterConstant:t}=A.core;let i;return e.startsWith(t.CONV_C2C)&&(i=e.replace(t.CONV_C2C,"")),"@TLS#ERROR"===i||"@TLS#NOT_FOUND"===i}function a(e,t){const{helper:i}=A.core,o=new i.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(`${e} fail:`,o),o}class g{constructor(A){this.conversationID=A.conversationID||"",this.unreadCount=A.unreadCount||0,this.type=A.type||"",this.lastMessage=n(A.lastMessage),this.peerReadTime=A.peerReadTime||0,this.groupAtInfoList=[],this.remark=A.remark||"",this.isPinned=A.isPinned||!1,this.messageRemindType=A.messageRemindType,this.markList=A.markList||[],this.customData=A.customData||"",this.conversationGroupList=A.conversationGroupList||[],this.draftText=A.draftText||"",this.userProfile=A.userProfile,this.groupProfile=A.groupProfile,this.subType=A.subType||"",this._isInfoCompleted=!1,this._init()}_init(){const{core:{OuterConstant:e,utils:{isUndefined:t}}}=A;t(this.userProfile)&&this.type===e.CONV_C2C?this.userProfile={userID:this.conversationID.replace(e.CONV_C2C,"")}:t(this.groupProfile)&&this.type===e.CONV_GROUP&&(this.groupProfile={groupID:this.conversationID.replace(e.CONV_GROUP,""),selfInfo:{},lastMessage:{}}),this.subType&&this.type===e.CONV_GROUP&&(this.subType=this.groupProfile.type||"")}updateUnreadCount(e){const{core:{OuterConstant:t,utils:{isUndefined:i}}}=A,{nextUnreadCount:o,isFromGetConversations:n,isUnreadC2CMessage:r}=e;i(o)||(this.subType!==t.GRP_AVCHATROOM?n&&this.type===t.CONV_GROUP||r&&this.type===t.CONV_C2C?this.unreadCount=o:this.unreadCount+=o:this.unreadCount=0)}updateLastMessage(A){this.lastMessage=n(A)}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked(e){const{core:{OuterConstant:t}}=A,{sequence:i,time:o}=e;return this.type===t.CONV_C2C&&i===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&i===this.lastMessage.lastSequence}setLastMessageRevoked(A){this.lastMessage.isRevoked=A}setLastMessageRevoker(A){this.lastMessage.revoker=A}setDraftText(A){this.draftText=A}updateGroupAtInfoList(e){const{core:{common:{updateGroupAtInfo:t}}}=A;t(e,this.groupAtInfoList)}clearGroupAtInfoList(){this.groupAtInfoList.length=0}getProfileCompleted(){return this._isInfoCompleted}setProfileCompleted(){this._isInfoCompleted=!0}}var c,l,I,u;(u=c||(c={}))[u.OFF=0]="OFF",u[u.ON=1]="ON",function(A){A[A.ONLY_CONVERSATIONID=1]="ONLY_CONVERSATIONID"}(l||(l={})),function(A){A[A.CONV_NOT_FOUND=2500]="CONV_NOT_FOUND",A[A.USER_OR_GRP_NOT_FOUND=2501]="USER_OR_GRP_NOT_FOUND",A[A.CONV_UN_RECORDED_TYPE=2502]="CONV_UN_RECORDED_TYPE"}(I||(I={}));const E=0,d=1;var h=new class{constructor(){this._name="ConversationDataHandler",this._totalUnreadCount=0,this._groupAtTipsList=[]}init(A){this._core=A;const{helper:e,notificationCenter:t,appStore:{conversationStore:i},constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:n},InnerEvent:{SYNC_CONVERSATION_LIST:r,MESSAGE_PUSH:s,NEW_MESSAGE:a,MESSAGE_DELETED:g,MESSAGE_REVOKED:c,MESSAGE_MODIFIED:l,CONVERSATION_UPDATED:I,LOGOUT:u,DESTROY:E},InnerEventSubType:{C2C_MESSAGE_PEER_READ:d}}=A;this._conversationStore=i,e.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,n.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),e.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,n.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,this._handleGroupListSyncFinished,this),e.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,n.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),e.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,n.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),e.registerWorkflowStep(o.RECEIVE_GROUP_NEW_MESSAGE,n.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),e.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),e.registerWorkflowStep(o.RECEIVE_GROUP_TIPS_NOTIFICATION,n.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this);const{InnerEventSubType:{GROUP_AT_TIPS:h}}=t;t.subscribeInnerEvent(r,this._handleConversationSynced,this),t.subscribeInnerEvent(a,this._handleNewMessage,this),t.subscribeInnerEvent(s,h,this._handleNewGroupAtTips,this),t.subscribeInnerEvent(g,this._handleMessageDeleted,this),t.subscribeInnerEvent(c,this._handleMessageRevoked,this),t.subscribeInnerEvent(l,this._handleMessageModified,this),t.subscribeInnerEvent(I,this._handleConversationUpdated,this),t.subscribeInnerEvent(s,d,this._handleMessageRead,this),t.subscribeInnerEvent(u,this._reset,this),t.subscribeInnerEvent(E,this._dispose,this),A.ssoLog.debug(`${this._name}.init`)}_handleConversationSynced(A){this.updateLocalConversationList({conversationUpdateFieldList:A.conversationUpdateFieldList||[],isFromGetConversations:!0,updateUnreadCount:!0}),this.emitConversationListUpdate()}_handleUnreadSyncFinished(A){const{constants:{WORKFLOW_STEP:e}}=this._core,{conversationUpdateFieldList:t=[],groupTipList:i=[],isUnreadC2CMessage:o}=A.result[e.UNREAD_MESSAGE_SYNC]||{};let n=!1;t.forEach(A=>{const{conversationID:e,unreadCount:t}=A,i=this.getLocalConversation(e);i&&i.unreadCount!==t&&(i.updateUnreadCount({nextUnreadCount:t,isUnreadC2CMessage:o}),n=!0)}),n&&this.emitConversationListUpdate(),this._handleGroupAtTipsSynced(i)}_handleGroupAtTipsSynced(A){var e;for(let t=0;t0&&this._handleNewGroupAtTips({GroupTips:A._groupAtInfoList}),n=!0}n&&this.emitConversationListUpdate()}_handleNewMessage(A){const{conversationUpdateFieldList:e=[],isInstantMessage:t=!0,isUnreadC2CMessage:i=!1,updateUnreadCount:o=!0}=A.result||{};if(0===e.length)return;const{common:{isTopic:n}}=this._core;n(e[0].conversationID)||(this.updateLocalConversationList({conversationUpdateFieldList:e,isInstantMessage:t,isUnreadC2CMessage:i,isFromGetConversations:!1,updateUnreadCount:o}),e.filter(A=>this._isConversationNeedShow(A.conversationID)).length>0&&this.emitConversationListUpdate())}_handleNewGroupAtTips(A){const{GroupTips:e=[]}=A;e.forEach(A=>{const{GroupAtTips:e,MsgBody:t,MsgRandom:i,ClientSeq:o}=A;let n={};e?n=this._convertGroupAtTipsKey(e):t?n=Object.assign({},this._convertGroupAtTipsKey(t)):A.groupAtType&&(n=Object.assign({},A)),n.__random=i,n.__sequence=o,this._groupAtTipsList.push(n)}),console.log(`${this._name}._handleNewGroupAtTips groupAtTipsList: ${JSON.stringify(this._groupAtTipsList)}`),this._updateGroupAtInfoList()}_convertGroupAtTipsKey(A){const{From_Account:e,GroupId:t,MsgSeq:i,GroupAtType:o}=A;return{from:e,groupID:t,sequence:i,groupAtType:o}}_updateGroupAtInfoList(){if(0===this._groupAtTipsList.length)return;const{common:A,OuterConstant:e}=this._core,t=A.getCurrentUserID();let i=!1;this._groupAtTipsList.forEach(A=>{const{groupID:o,from:n}=A;if(n!==t){const t=this.getLocalConversation(`${e.CONV_GROUP}${o}`);t&&(t.updateGroupAtInfoList(A),i=!0)}}),i&&this.emitConversationListUpdate(),this._groupAtTipsList.length=0}_handleMessageDeleted(A){var e,t;console.log(`${this._name}._handleMessageDeleted, conversationID:`,A);const{message:{messageDataHandler:i},OuterConstant:o}=this._core,n=(null==i?void 0:i.getLocalMessageList(A))||[];let r={};for(let g=(n.length||0)-1;g>=0;g--)if(!n[g].isDeleted){r=n[g];break}const s=this.getLocalConversation(A);if(!s)return;let a=!1;s.lastMessage.lastSequence===r.sequence&&s.lastMessage.lastTime===r.time||((null===(t=null===(e=this._core)||void 0===e?void 0:e.helper)||void 0===t?void 0:t.isEmpty(r))&&(r=void 0),s.updateLastMessage(r),a=!0),A.startsWith(o.CONV_C2C)&&this.updateUnreadCount(A),a&&(this.emitConversationListUpdate(),console.log(`${this._name}._handleMessageDeleted. update conversationID:${A} with lastMessage:`,s.lastMessage))}_handleMessageRevoked(A){const{messageList:e=[],updateUnreadCount:t=!0}=A;if(console.log(`${this._name}._handleMessageRevoked messageList:${e.length}`),0===e.length)return;let i=null,o=!1;e.forEach(A=>{i=this.getLocalConversation(A.conversationID),i&&(t&&i.reduceUnreadCount()&&(o=!0),i.isLastMessageRevoked({sequence:A.sequence,time:A.time})&&(i.setLastMessageRevoked(!0),i.setLastMessageRevoker(A.revoker),o=!0))}),o&&this.emitConversationListUpdate()}_handleMessageModified(A){console.log(`${this._name}._handleMessageModified`,JSON.stringify(A));const{conversationID:e,messageList:t}=A,i=this.getLocalConversation(e),{utils:{isEmpty:o},common:{getMessagePreviewText:n}}=this._core;if(o(i))return;const{lastMessage:r}=i;if(r){const A=(null==t?void 0:t[0])||{};r.lastTime===A.time&&r.lastSequence===A.sequence&&r.version!==A.version&&(r.type=A.type,r.payload=A.payload,r.messageForShow=n(A.type,A.payload),r.cloudCustomData=A.cloudCustomData,r.version=A.version,this.emitConversationListUpdate(),console.log(`${this._name} conversationID:${e} lastMessage updated`))}}_handleConversationUpdated(A){this.emitConversationListUpdate(null==A?void 0:A.needSort)}updateLocalConversationList(A){const{isFromGetConversations:e}=A,{newConversationList:t}=this._getTmpConversationListMapping(A);this._sortConversationList(),e||this._updateNewConversationProfile(t),this._core.ssoLog.debug("updateLocalConversationList",` newConversationList: ${t.length}`)}_getTmpConversationListMapping(A){const{OuterConstant:e}=this._core,{conversationUpdateFieldList:t,isFromGetConversations:i,isInstantMessage:o,isUnreadC2CMessage:n=!1,updateUnreadCount:r}=A,a=[],c=null==t?void 0:t.length;for(let l=0;l{!0===e[1].isPinned?A(e[1].lastMessage.lastTime)?i.push(e):t.push(e):A(e[1].lastMessage.lastTime)?n.push(e):o.push(e)});const r=t.sort((A,e)=>e[1].lastMessage.lastTime-A[1].lastMessage.lastTime).concat(i).concat(o.sort((A,e)=>e[1].lastMessage.lastTime-A[1].lastMessage.lastTime)).concat(n);this._updateConversationMapFromList(r)}_updateNewConversationProfile(A){if(0===A.length)return;const e=[],t=[],{OuterConstant:{CONV_GROUP:i,CONV_C2C:o}}=this._core;A.forEach(A=>{const{conversationID:n,type:r}=A;if(r===o){const A=n.replace(o,"");e.push(A)}else if(r===i){const A=n.replace(i,"");t.push(A)}}),e.length>0&&this._updateC2CConversation(e),t.length>0&&this._updateGroupConversation(t)}_updateC2CConversation(A){var e;const{OuterConstant:{CONV_C2C:t},appStore:{userStore:i},user:o}=this._core;let n=!1;null===(e=o.userProfile)||void 0===e||e.getUserProfile({userIDList:A}).then(A=>{((null==A?void 0:A.data)||[]).forEach(A=>{var e;const{userID:o}=A,r=this.getLocalConversation(`${t}${o}`);if(r){const t=(null===(e=i.getFriend(o))||void 0===e?void 0:e.remark)||"";r.remark=t,r.userProfile=A,n=!0}}),n&&this.emitConversationListUpdate()}).catch(A=>{})}_updateGroupConversation(A){return e(this,void 0,void 0,function*(){const{OuterConstant:{CONV_GROUP:t},appStore:{groupStore:i},utils:{isEmpty:o,safeStringify:n},ssoLog:r,apiMap:{getGroupProfile:s}}=this._core;let a=!1;try{yield Promise.all(A.map(A=>e(this,void 0,void 0,function*(){const e=i.getGroup(A),n=this.getLocalConversation(`${t}${A}`);e&&n&&(n.groupProfile=e,a=!0),o(e)&&n&&"function"==typeof s&&(yield s({groupID:A}))}))),a&&this.emitConversationListUpdate()}catch(g){r.debug("_updateGroupConversation",n(g))}})}_handleMessageRead(A){const{OuterConstant:{CONV_C2C:e}}=this._core,{C2cNotifyMsgArray:t=[]}=A||{};t.forEach(A=>{const{To_Account:t,UinPairReadArray:i=[]}=(null==A?void 0:A.C2cReadedReceipt)||{};null==i||i.forEach(A=>{const{LastReadTime:i}=A,o=`${e}${t}`;this._updateConversationReadInfo({conversationID:o,peerReadTime:i}),this._updateMessageListPeerRead({conversationID:o,peerReadTime:i})})})}_updateConversationReadInfo(A){const{appStore:e,utils:{isEmpty:t},common:{getCurrentUserID:i}}=this._core,{conversationID:o,peerReadTime:n}=A,r=e.conversationStore.getConversationMap();if(r.has(o)){const A=r.get(o);A.peerReadTime=n;const s=null==A?void 0:A.lastMessage;t(s)||s.fromAccount===i()&&s.lastTime<=n&&!s.isPeerRead&&(s.isPeerRead=!0,e.conversationStore.updateConversation(o,{lastMessage:s}))}}_updateMessageListPeerRead(A){const{notificationCenter:e,OuterEvent:t,message:i}=this._core,{conversationID:o,peerReadTime:n}=A,r=i.messageDataHandler.getLocalMessageList(o),s=i.messageDataHandler.getSparseMessageList(o),a=[];r.forEach(A=>{A.time<=n&&!A.isPeerRead&&"out"===A.flow&&(A.isPeerRead=!0,a.push(A))}),s.forEach(A=>{A.time<=n&&!A.isPeerRead&&"out"===A.flow&&(A.isPeerRead=!0,a.push(A))}),e.emitOuterEvent(t.MESSAGE_READ_BY_PEER,{name:t.MESSAGE_READ_BY_PEER,data:a})}_isConversationNeedShow(A){var e,t;const{OuterConstant:{CONV_GROUP:i,GRP_ROOM:o,GRP_LIVE:n},utils:{isUndefined:r}}=this._core,s=this.getLocalConversation(A);if(r(s))return!0;const a=s.type===i&&(null===(e=s.groupProfile)||void 0===e?void 0:e.type)===o,g=s.type===i&&(null===(t=s.groupProfile)||void 0===t?void 0:t.type)===n;return!(a||g)}updateUnreadCount(A,e=!0){var t,i;let o=!1;const n=this.getLocalConversation(A),r=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageDataHandler)||void 0===i?void 0:i.getLocalMessageList(A);if(!n)return o;const s=n.unreadCount,a=null==r?void 0:r.filter(A=>!A.isRead&&!A._onlineOnlyFlag&&!A.isDeleted).length;return console.log(`${this._name}._updateUnreadCount conversationID:${A} currentUnreadCount:${s} newUnreadCount:${a}`),s!==a&&(n.unreadCount=a,o=!0,!0===e&&this.emitConversationListUpdate()),o}emitConversationListUpdate(A=!1){var e,t;A&&this._sortConversationList();const{OuterEvent:{CONVERSATION_LIST_UPDATED:i},conversation:o}=this._core,n=this.getLocalConversationList();this._emitEvent({name:i,data:n,isSyncCompleted:null===(t=null===(e=null==o?void 0:o.syncConversationHandler)||void 0===e?void 0:e.isSyncCompleted)||void 0===t?void 0:t.call(e)}),this._emitTotalUnreadCountUpdate()}_emitTotalUnreadCountUpdate(){var A;const e=this.getTotalUnreadMessageCount();this._totalUnreadCount!==e&&(this._core.ssoLog.debug("_emitTotalUnreadCountUpdate",` from ${this._totalUnreadCount} to ${e}`),this._totalUnreadCount=e,this._emitEvent({name:null===(A=this._core)||void 0===A?void 0:A.OuterEvent.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,data:e}))}_emitEvent(A){var e;null===(e=this._core)||void 0===e||e.notificationCenter.emitOuterEvent(A.name,A)}getTotalUnreadMessageCount(){const{OuterConstant:A,utils:{isEmpty:e}}=this._core,t=this.getLocalConversationList();let i=0;return t.forEach(t=>{t.type!==A.CONV_SYSTEM&&(e(t.messageRemindType)||t.messageRemindType===A.MSG_REMIND_ACPT_AND_NOTE)&&(i+=t.unreadCount)}),i}getLocalConversationList(){return[...this._conversationStore.getConversationMap().values()].filter(A=>this._isConversationNeedShow(A.conversationID))}hasLocalConversation(A){return this._conversationStore.getConversationMap().has(A)}getLocalConversation(A){return this._conversationStore.getConversationMap().get(A)}setLocalConversation(A,e){return this._conversationStore.getConversationMap().set(A,e)}deleteLocalConversation(A){this._conversationStore.getConversationMap().delete(A)}_updateConversationMapFromList(A){this._clearConversationMap();for(const[e,t]of A)this.setLocalConversation(e,t)}_clearConversationMap(){this._conversationStore.getConversationMap().clear()}patchMessageRemindType(A,e){let t=!1;A.forEach(A=>{const i=this.getLocalConversation(A);(null==i?void 0:i.messageRemindType)!==e&&(i.messageRemindType=e,t=!0)}),console.log(`${this._name}.patchMessageRemindType conversationIDList:${A} messageRemindType:${e} hasUpdated:${t}`),t&&this.emitConversationListUpdate()}markMessageAsRead(A){const{message:{messageDataHandler:e}}=this._core,{conversationID:t,lastReadTime:i=0,lastReadSequence:o=0}=A,n=null==e?void 0:e.getLocalMessageList(t);if(0===n.length)return;const{length:r}=n;for(let s=r-1;s>=0;s--){const A=n[s],e=i&&A.time>i,t=o&&A.sequence>o;if(!e&&!t){if("in"===A.flow&&A.isRead)break;A.setIsRead(!0)}}}appendToPinnedConversation(A){const e=[...this._conversationStore.getConversationMap().entries()],t=e.findIndex(A=>!1===A[1].isPinned);e.splice(t,0,[A.conversationID,A]),this._updateConversationMapFromList(e),this.emitConversationListUpdate()}_reset(){this._clearConversationMap(),this._totalUnreadCount=0,this._groupAtTipsList=[]}_dispose(){const{notificationCenter:A,InnerEvent:{NEW_MESSAGE:e,MESSAGE_DELETED:t,MESSAGE_REVOKED:i,MESSAGE_MODIFIED:o,CONVERSATION_UPDATED:n,LOGOUT:r,DESTROY:s,SYNC_CONVERSATION_LIST:a}}=this._core,{InnerEventSubType:{GROUP_AT_TIPS:g}}=A;A.unSubscribeInnerEvent(e,this._handleNewMessage,this),A.unSubscribeInnerEvent(e,g,this._handleNewGroupAtTips,this),A.unSubscribeInnerEvent(t,this._handleMessageDeleted,this),A.unSubscribeInnerEvent(i,this._handleMessageRevoked,this),A.unSubscribeInnerEvent(o,this._handleMessageModified,this),A.unSubscribeInnerEvent(n,this._handleConversationUpdated,this),A.unSubscribeInnerEvent(a,this._handleConversationSynced,this),A.unSubscribeInnerEvent(r,this._reset,this),A.unSubscribeInnerEvent(s,this._dispose,this)}},C=new class{constructor(){this._name="GetConversationList"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getConversationList",context:this})}getConversationList(A){return e(this,void 0,void 0,function*(){return{code:0,data:{conversationList:this._getConversationList(A),isSyncCompleted:this._core.conversation.syncConversationHandler.isSyncCompleted()}}})}_getConversationList(A){const{utils:{isUndefined:e,isArray:t,isPlainObject:i}}=this._core;if(e(A))return h.getLocalConversationList();if(t(A))return 0===A.length?[]:h.getLocalConversationList().filter(e=>A.includes(e.conversationID));if(i(A)){const{type:e,markType:t,groupName:i,hasUnreadCount:o,hasGroupAtInfo:n}=A;return h.getLocalConversationList().filter(A=>this._filterType(A,e)&&this._filterMarkType(A,t)&&this._filterGroupName(A,i)&&this._filterUnreadCount(A,o)&&this._filterGroupAtInfo(A,n))}return[]}_filterType(A,e){const{OuterConstant:t}=this._core;return e!==t.CONV_C2C&&e!==t.CONV_GROUP||A.type===e}_filterGroupName(A,e){const{utils:{isString:t}}=this._core;return!t(e)||(""===e?0===A.conversationGroupList.length:A.conversationGroupList.includes(e))}_filterMarkType(A,e){const{utils:{isNumber:t}}=this._core;return!t(e)||(0===e?0===A.markList.length:A.markList.includes(e))}_filterUnreadCount(A,e){let t=!0;return!0===e?t=A.unreadCount>=1:!1===e&&(t=0===A.unreadCount),t}_filterGroupAtInfo(A,e){let t=!0;return!0===e?t=A.groupAtInfoList.length>=1:!1===e&&(t=0===A.groupAtInfoList.length),t}},B=new class{constructor(){this._name="GetC2CMessageRemindType"}init(A){this._core=A}get(A){return e(this,void 0,void 0,function*(){try{const{common:t}=this._core,i=yield function(A,t){return e(this,void 0,void 0,function*(){const{toAccount:e,userIDList:i}=A,o={To_Account:e,Peer_Account:i};return t.common.buildAndSendPacket({servcmd:"openim.get_c2c_peer_mute_notifications",data:o})})}({toAccount:t.getCurrentUserID(),userIDList:A},this._core),{MuteNotificationsList:o=[]}=i||{};o.forEach(A=>{const{Peer_Account:e,MuteNotifications:t}=A,i=`${this._core.OuterConstant.CONV_C2C}${e}`,o=r(t);h.patchMessageRemindType([i],o)})}catch(t){console.error(`${this._name}.get fail:`,t)}})}},Q=new class{constructor(){this._name="GetGroupMessageRemindType"}init(A){this._core=A}get(A){return e(this,void 0,void 0,function*(){if(0!==A.length)try{const t=yield function(A,t){return e(this,void 0,void 0,function*(){const{groupIDList:e,responseFilter:i}=A,o={GroupIdList:e,ResponseFilter:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}({groupIDList:A,responseFilter:{MemberInfoFilter:["MsgFlag"]}},this._core),{GroupInfo:i=[]}=t||{};i.forEach(A=>{var e;const{GroupId:t,MemberList:i}=A,o=(null===(e=i[0])||void 0===e?void 0:e.MsgFlag)||"",n=`${this._core.OuterConstant.CONV_GROUP}${t}`;h.patchMessageRemindType([n],o)})}catch(t){console.error(`${this._name}.get fail:`,t)}})}},p=new class{constructor(){this._name="GetConversationProfile"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getConversationProfile",context:this})}getConversationProfile(A){return e(this,void 0,void 0,function*(){const{OuterConstant:{CONV_C2C:e,CONV_GROUP:i,GRP_AVCHATROOM:n},appStore:{groupStore:r},utils:{isEmpty:s}}=this._core,a={code:0,data:{}};let c=h.getLocalConversation(A);if(o(A))return a.data.conversation=c,a;let l=!1;const I=t(A)?e:i;if(s(c)&&(l=!0,c=new g({conversationID:A,type:I})),console.log(`${this._name}.getConversationProfile conversationID:${A} isNewConversation:${l}`),a.data.conversation=c,null==c?void 0:c.getProfileCompleted())return a;if(I===e){const t=A.replace(e,"");yield this._handleC2CConversation(c,t),l&&(yield B.get([t]))}if(I===i){const e=A.replace(i,"");if(!r.getGroup(e))return a;yield this._handleGroupConversation(c,e),l&&c.groupProfile.type!==n&&(yield Q.get([e]))}return a})}_handleC2CConversation(A,t){return e(this,void 0,void 0,function*(){var e,i;const{user:o,helper:n,utils:{isEmpty:r},appStore:{conversationStore:s,userStore:a}}=this._core,{conversationID:g}=A,c=yield null===(e=o.userProfile)||void 0===e?void 0:e.getUserProfile({userIDList:[t]});if(0===(null==c?void 0:c.data.length))throw new n.ChatError({code:I.USER_OR_GRP_NOT_FOUND});A.userProfile=null==c?void 0:c.data[0];const l=null===(i=a.getFriend(t))||void 0===i?void 0:i.remark;r(l)||A.remark===l||(A.remark=l),A.setProfileCompleted();const u=h.hasLocalConversation(g);console.log(`${this._name}._handleC2CConversation conversationID:${g} hasLocalConversation: ${u}`),u?s.updateConversation(g,A):h.appendToPinnedConversation(A)})}_handleGroupConversation(A,t){return e(this,void 0,void 0,function*(){const{apiMap:{getGroupProfile:e},appStore:{conversationStore:i}}=this._core,{conversationID:o}=A,n=yield e({groupID:t});A.groupProfile=null==n?void 0:n.data.group,A.setProfileCompleted();const r=h.hasLocalConversation(o);console.log(`${this._name}._handleGroupConversation conversationID:${o} hasLocalConversation: ${r}`),r?i.updateConversation(o,A):h.appendToPinnedConversation(A)})}},f=new class{init(A){const{helper:e}=A;e.registerApi({apiName:"getTotalUnreadMessageCount",context:this})}getTotalUnreadMessageCount(){return h.getTotalUnreadMessageCount()}},m=new class{constructor(){this._serverGroupConversationLastReadSeqMap=new Map,this._name="SetMessageRead"}init(A){this._core=A;const{helper:e,common:{isTopic:t},notificationCenter:i,InnerEvent:{MESSAGE_PUSH:o},InnerEventSubType:{ALL_MESSAGE_READ:n}}=A;e.registerApi({apiName:"setMessageRead",context:this,matcher:A=>!t(A[0].conversationID)}),e.registerApi({apiName:"setAllMessageRead",context:this}),i.subscribeInnerEvent(o,n,this._handleAllMessageRead,this)}handleC2CMessageReadSync(A){const{helper:{isEmpty:e},OuterConstant:t}=this._core;A.forEach(A=>{const{ReadC2cMsgNotify:i}=A;if(!e(i)){const{UinPairReadArray:A=[]}=i;A.forEach(A=>{const{From_Account:e,LastReadTime:i}=A,o=`${t.CONV_C2C}${e}`;console.log(`${this._name}.handleC2CMessageReadSync conversationID:${o} lastReadTime:${i}`),h.markMessageAsRead({conversationID:o,lastReadTime:i}),h.updateUnreadCount(o)})}})}handleGroupMessageReadSync(A){const{OuterConstant:e,utils:{isUndefined:t}}=this._core;A.forEach(A=>{const{GroupReadInfoArray:i}=A.MsgBody;t(i)||i.forEach(A=>{const{GroupId:t,LastReadMsgSeq:i}=A,o=`${e.CONV_GROUP}${t}`;console.log(`${this._name}.handleGroupMessageReadSync conversationID:${o} lastReadSequence:${i}`),h.markMessageAsRead({conversationID:o,lastReadSequence:i}),h.updateUnreadCount(o),this._clearGroupAtInfoList(o)})})}setMessageRead(A){return e(this,void 0,void 0,function*(){var e,t;const{OuterConstant:i}=this._core,{conversationID:o}=A,n={code:0,data:{}},r=h.getLocalConversation(o);let s=`${this._name}.setMessageRead conversationID:${o} unreadCount:${(null==r?void 0:r.unreadCount)||0}`;if(n.successLog={message:s},!r)return n;const a=!(null===(t=null===(e=this._core)||void 0===e?void 0:e.helper)||void 0===t?void 0:t.isEmpty(r.groupAtInfoList));if(r.type===i.CONV_GROUP&&a&&this._deleteGroupAtTips(o),0===r.unreadCount)return n;const{helper:{ChatError:g}}=this._core;try{if(r.type===i.CONV_C2C){const A=this._getLocalMessageMaxTime(r);yield this._setC2CMessageRead(o,A),s+=`lastMessageTime:${A}`}if(r.type===i.CONV_GROUP){const A=this._getLocalMessageMaxSequence(r);yield this._setGroupMessageRead(o,A),s+=`lastMessageSequence:${A}`}}catch(c){const{errorCode:A,errorInfo:e}=c;throw new g({functionName:"setMessageRead",code:A,message:e,moreMessage:s})}return r.type===i.CONV_SYSTEM&&(r.unreadCount=0),h.emitConversationListUpdate(),Object.assign(Object.assign({},n),{successLog:{message:s}})})}setAllMessageRead(){return e(this,arguments,void 0,function*(t={}){const{OuterConstant:{READ_ALL_MSG:i},utils:{safeStringify:o}}=this._core;let n=`scope:${t.scope}`;t.scope||(t.scope=i);const{scope:r}=t,s=this._generateSetAllMessageReadRequestData(r);if(s.allC2CMessageReadStatus===E&&0===s.groupMessageReadInfoList.length)return{code:0};try{const t=yield function(t){return e(this,void 0,void 0,function*(){const{allC2CMessageReadStatus:e,groupMessageReadInfoList:i}=t,o={C2CReadAllMsg:e,GroupReadInfo:i};return A.core.common.buildAndSendPacket({servcmd:"openim.read_all_unread_msg",data:o})})}(s);if(t){const{GroupReadInfoArray:A,C2CReadAllMsg:e}=t,i=this._parseGroupReadInfo(A);this._updateAllConversationReadStatus({allC2CMessageReadStatus:e})>0&&h.emitConversationListUpdate(),n+=`failureGroupInfoList:${o(i)}`}return{code:0,successLog:{message:n}}}catch(u){const{errorCode:e}=u;throw new this._core.helper.ChatError({functionName:"setAllMessageRead",code:e,moreMessage:n})}})}_handleAllMessageRead(A){const{GroupReadInfoArray:e,C2CReadAllMsg:t}=A;this._parseGroupReadInfo(e),this._updateAllConversationReadStatus({allC2CMessageReadStatus:t})>0&&h.emitConversationListUpdate()}_updateAllConversationReadStatus(A){const{OuterConstant:{CONV_C2C:e,CONV_GROUP:t},appStore:i}=this._core,o=i.conversationStore.getConversationMap(),{allC2CMessageReadStatus:n}=A;let r=0;for(const[s,a]of o)if(a.unreadCount>=1){if(n===d&&a.type===e){const A=this._getLocalMessageMaxTime(a);h.markMessageAsRead({conversationID:s,lastReadTime:A})}else if(a.type===t){const A=s.replace(t,"");if(this._serverGroupConversationLastReadSeqMap.has(A)){const e=this._serverGroupConversationLastReadSeqMap.get(A);h.markMessageAsRead({conversationID:s,lastReadSequence:e})}}h.updateUnreadCount(s,!1)&&(r+=1)}return r}_generateSetAllMessageReadRequestData(A){const{OuterConstant:{CONV_C2C:e,CONV_GROUP:t,READ_ALL_C2C_MSG:i},appStore:o}=this._core,n={allC2CMessageReadStatus:E,groupMessageReadInfoList:[]},r=o.conversationStore.getConversationMap();for(const[,s]of r){const{type:o,unreadCount:r}=s;if(this._shouldSetAllMessageRead({scope:A,type:o,unreadCount:r}))if(o===e&&n.allC2CMessageReadStatus===E){if(n.allC2CMessageReadStatus=d,A===i)break}else if(o===t){const A=this._getLocalMessageMaxSequence(s),{groupID:e}=s.groupProfile;n.groupMessageReadInfoList.push({GroupId:e,MsgSeq:A})}}return n}_parseGroupReadInfo(A){const{utils:{isUndefined:e}}=this._core,t=[];return null==A||A.forEach(A=>{const{GroupId:i,MsgSeq:o,RetCode:n,LastReadMsgSeq:r}=A;e(n)?this._serverGroupConversationLastReadSeqMap.set(i,r):(this._serverGroupConversationLastReadSeqMap.set(i,o),0!==n&&t.push(`${i}-${o}-${n}`))}),t}_deleteGroupAtTips(A){return e(this,void 0,void 0,function*(){console.log(`${this._name}._deleteGroupAtTips conversationID:${A}`);const t=h.getLocalConversation(A);if(!t)return;const i=(null==t?void 0:t.groupAtInfoList)||[];if(0!==i.length)try{const{common:{getCurrentUserID:t,isCommunity:o},OuterConstant:{CONV_GROUP:n,CONV_AT_ALL:r}}=this._core;let s=[...i];if(o({groupID:A.replace(n,"")})&&(s=i.filter(A=>!A.atTypeArray.includes(r)),0===s.length))return void this._clearGroupAtInfoList(A,!1);const a=s.map(A=>({From_Account:A.from,To_Account:t(),MsgSeq:A.__sequence,MsgRandom:A.__random,GroupId:A.groupID}));yield function(A,t){return e(this,void 0,void 0,function*(){const{messageListToDelete:e}=A,i={DelMsgList:e};return t.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:i})})}({messageListToDelete:a},this._core),console.log(`${this._name}._deleteGroupAtTips ok. count:${i.length}`),this._clearGroupAtInfoList(A)}catch(o){console.error(`${this._name}._deleteGroupAtTips fail:`,o)}})}_clearGroupAtInfoList(A,e=!0){const t=h.getLocalConversation(A);t&&(t.groupAtInfoList.length>0&&(t.clearGroupAtInfoList(),console.log(`${this._name}._clearGroupAtInfoList conversationID:${A} needEmitConversationUpdate:${e}`)),e&&h.emitConversationListUpdate())}_getLocalMessageMaxTime(A){var e;const{conversationID:t}=A,i=this._core.message.messageDataHandler.getLocalMessageList(t),o=Math.max(...i.map(A=>A.time));let n=(null===(e=null==A?void 0:A.lastMessage)||void 0===e?void 0:e.lastTime)||0;return o>n&&(console.log(`${this._name}._getLocalMessageMaxTime update lastMessageTime from ${n} to ${o}`),n=o),n}_getLocalMessageMaxSequence(A){var e;const{conversationID:t}=A,i=this._core.message.messageDataHandler.getLocalMessageList(t),o=Math.max(...i.map(A=>A.sequence));let n=(null===(e=null==A?void 0:A.lastMessage)||void 0===e?void 0:e.lastSequence)||0;return o>n&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${n} to ${o}`),n=o),n}_setC2CMessageRead(A,t){return e(this,void 0,void 0,function*(){try{yield function(A,t){return e(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"openim.msgreaded",data:A})})}({C2CMsgReaded:{Cookie:"",C2CMsgReadedItem:[{To_Account:A.replace("C2C",""),LastedMsgTime:t,Receipt:1}]}},this._core),console.log(`${this._name}._setC2CMessageRead ok, lastReadTime:${t}`),h.markMessageAsRead({conversationID:A,lastReadTime:t}),h.updateUnreadCount(A)}catch(i){throw console.warn(`${this._name}._setC2CMessageRead fail:`,i),i}})}_setGroupMessageRead(A,t){return e(this,void 0,void 0,function*(){try{yield function(A,t){return e(this,void 0,void 0,function*(){const{groupID:e,lastMessageSequence:i}=A,o={GroupId:e,MsgReadedSeq:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.msg_read_report",data:o})})}({groupID:A.replace("GROUP",""),lastMessageSequence:t},this._core),console.log(`${this._name}._setGroupMessageRead ok, lastReadSequence:${t}`),h.markMessageAsRead({conversationID:A,lastReadSequence:t}),h.updateUnreadCount(A)}catch(i){throw console.warn(`${this._name}._setGroupMessageRead fail:`,i),i}})}_shouldSetAllMessageRead(A){const{OuterConstant:{CONV_C2C:e,CONV_GROUP:t,READ_ALL_MSG:i,READ_ALL_C2C_MSG:o,READ_ALL_GROUP_MSG:n}}=this._core,{type:r,scope:s,unreadCount:a}=A;return!(a<=0||(r!==e||![i,o].includes(s))&&(r!==t||![i,n].includes(s)))}},y=new class{constructor(){this._name="PinConversation"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"pinConversation",context:this})}handleConversationPinned(A,e){const{utils:{isArray:t}}=this._core;if(!t(A))return;const{OuterConstant:i}=this._core;let o=!1;A.forEach(A=>{const{Type:t,To_Account:n,GroupId:r}=A;let s;1===t?s=h.getLocalConversation(`${i.CONV_C2C}${n}`):2===t&&(s=h.getLocalConversation(`${i.CONV_GROUP}${r}`)),s&&(console.log(`${this._name}.handleConversationPinned conversationID:${s.conversationID} localPinned:${s.isPinned} remotePinned:${e}`),e&&!s.isPinned&&(s.isPinned=!0,o=!0),!e&&s.isPinned&&(s.isPinned=!1,o=!0))}),o&&h.emitConversationListUpdate(!0)}pinConversation(A){return e(this,void 0,void 0,function*(){const{OuterConstant:n,common:r,helper:{ChatError:s}}=this._core,{conversationID:a,isPinned:c}=A,l={code:0,data:{conversationID:a}},I=h.getLocalConversation(a);if(I&&I.isPinned===c)return l;if(o(a))return I&&(I.isPinned=c),h.emitConversationListUpdate(!0),l;const u=`conversationID:${a} isPinned:${c}`;try{let A=null;if(t(a)?A={Type:1,To_Account:a.replace(n.CONV_C2C,"")}:i(a)&&(A={Type:2,GroupId:a.replace(n.CONV_GROUP,"")}),yield function(A,t){return e(this,void 0,void 0,function*(){const{fromAccount:e,operationType:i,itemList:o}=A,n={From_Account:e,OperationType:i,RecentContactItem:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.top",data:n})})}({fromAccount:r.getCurrentUserID(),operationType:!0===c?1:2,itemList:[A]},this._core)){if(I)I.isPinned!==c&&(I.isPinned=c);else{const A=new g({conversationID:a,type:t(a)?n.CONV_C2C:n.CONV_GROUP,isPinned:c});h.setLocalConversation(a,A)}h.emitConversationListUpdate(!0)}return Object.assign(Object.assign({},l),{successLog:{message:u}})}catch(E){const{errorCode:A,errorInfo:e}=E;throw new s({functionName:"pinConversation",code:A,message:e,moreMessage:u})}})}},D=new class{constructor(){this._name="DeleteConversation"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"deleteConversation",context:this})}handleConversationDeleted(A){const{utils:{isArray:e}}=this._core;if(!e(A))return;const{OuterConstant:t}=this._core,i=[];A.forEach(A=>{const{Type:e,Peer_Account:o,GroupId:n}=A;1===e&&i.push(`${t.CONV_C2C}${o}`),2===e&&i.push(`${t.CONV_GROUP}${n}`)}),console.log(`${this._name}.handleConversationDeleted conversationIDList:${i}`),this._deleteLocalConversationList(i)}deleteConversation(A){return e(this,void 0,void 0,function*(){const{utils:{isString:e}}=this._core;if(e(A))return void(yield this._deleteConversation({conversationIDList:[A],flag:l.ONLY_CONVERSATIONID}));const t=Object.assign({},A);t.conversationIDList.length>100&&(t.conversationIDList=t.conversationIDList.slice(0,100)),yield this._deleteConversation(t)})}_deleteConversation(A){return e(this,void 0,void 0,function*(){const{conversationIDList:e,clearHistoryMessage:t=!0,flag:i=0}=A,{helper:{ChatError:o}}=this._core,n=`conversationIDList:${e} clearHistoryMessage:${t}`;try{const A=yield Promise.all([this._deleteConversationFromLocal(e),this._deleteConversationFromServer(e,t)]),o=[...A[0],...A[1]];if(0===o.length)throw new this._core.helper.ChatError({code:I.CONV_NOT_FOUND});return{code:0,data:i===l.ONLY_CONVERSATIONID?{conversationID:o[0]}:{conversationIDList:o},successLog:{message:n}}}catch(r){const{errorCode:A,errorInfo:e}=r;throw new o({code:A,message:e,moreMessage:n})}})}_deleteConversationFromLocal(A){const{OuterConstant:e}=this._core;return A.filter(A=>{var t;if(!h.hasLocalConversation(A))return!1;const i=null===(t=h.getLocalConversation(A))||void 0===t?void 0:t.type;return i!==e.CONV_GROUP||this._hasLocalGroup(A)?i===e.CONV_SYSTEM&&(this._deleteLocalConversation(A),!0):(this._deleteLocalConversation(A),!0)})}_deleteConversationFromServer(A,t){return e(this,void 0,void 0,function*(){const{OuterConstant:i,common:o}=this._core,n={fromAccount:o.getCurrentUserID(),conversationList:[],clearHistoryMessage:t?1:0};if(A.forEach(A=>{var e;if(h.hasLocalConversation(A)){const t=(null===(e=h.getLocalConversation(A))||void 0===e?void 0:e.type)||"",o=A.replace(t,"");t===i.CONV_C2C?n.conversationList.push({To_Account:o,Type:1}):t===i.CONV_GROUP&&this._hasLocalGroup(A)&&n.conversationList.push({ToGroupid:o,Type:2})}}),0===n.conversationList.length)return[];const r=yield function(A,t){return e(this,void 0,void 0,function*(){const{fromAccount:e,conversationList:i,clearHistoryMessage:o}=A,n={From_Account:e,ContactItem:i,ClearRamble:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.batch_delete",data:n})})}(n,this._core);if(r){const{ResultItem:A=[]}=r,e=[];return A.length>0&&A.forEach(A=>{if(0===A.ResultCode){const t=1===A.Type?`${i.CONV_C2C}${A.To_Account}`:`${i.CONV_GROUP}${A.ToGroupid}`;e.push(t)}}),this._deleteLocalConversationList(e),e}return[]})}_deleteLocalConversationList(A){let e=!1;A.forEach(A=>{h.hasLocalConversation(A)&&(this._deleteLocalConversation(A,!1),e=!0)}),console.log(`${this._name}._deleteLocalConversationList isUpdate:${e}`),e&&h.emitConversationListUpdate()}_deleteLocalConversation(A,e=!0){const t=h.hasLocalConversation(A);console.log(`${this._name}._deleteLocalConversation conversationID:${A} has:${t}`),t&&(h.deleteLocalConversation(A),this._deleteConversationLocalMessage(A),e&&h.emitConversationListUpdate())}_hasLocalGroup(A){const{OuterConstant:{CONV_GROUP:e},appStore:{groupStore:t}}=this._core,i=A.replace(e,"");return!!t.getGroup(i)}_deleteConversationLocalMessage(A){console.log(`${this._name}._deleteConversationLocalMessage conversationID:${A}`),this._core.message.messageDataHandler.deleteConversationMessageList(A)}},v=new class{constructor(){this._name="SetConversationDraft"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setConversationDraft",context:this})}setConversationDraft(A){return e(this,void 0,void 0,function*(){const{conversationID:e,draftText:t}=A;if(console.log(`${this._name} conversationID:${e} draftText:${t}`),!h.hasLocalConversation(e))throw new this._core.helper.ChatError({code:I.CONV_NOT_FOUND});const i=h.getLocalConversation(e);return null==i||i.setDraftText(t),h.emitConversationListUpdate(),{code:0,data:{conversation:i}}})}},w=new class{constructor(){this._name="SetC2CMessageRemindType"}init(A){this._core=A}set(t,i){return e(this,void 0,void 0,function*(){t.length>30&&(console.warn(`${this._name}.set userIDList length:${t.length} exceeds limit 30`),t.splice(30));const o=function(){const{MSG_REMIND_ACPT_AND_NOTE:e,MSG_REMIND_DISCARD:t,MSG_REMIND_ACPT_NOT_NOTE:i}=A.core.OuterConstant;return{[e]:0,[t]:1,[i]:2}}()[i],n=yield function(A,t){return e(this,void 0,void 0,function*(){const{userIDList:e,receiveMessageOption:i}=A,o={Peer_Account:e,Mute_Notifications:i};return t.common.buildAndSendPacket({servcmd:"openim.set_c2c_peer_mute_notifications",data:o})})}({userIDList:t,receiveMessageOption:o},this._core),{ErrorList:r=[]}=n||{},s=[];r.forEach(A=>{const{Peer_Account:e,ErrorCode:i}=A;s.push({userID:e,code:i});const o=t.indexOf(e);o>-1&&t.splice(o,1)});const a=[],g=[],{OuterConstant:c}=this._core;return t.forEach(A=>{g.push(`${c.CONV_C2C}${A}`),a.push({userID:A})}),h.patchMessageRemindType(g,i),{code:0,data:{successUserIDList:a,failureUserIDList:s}}})}},S=new class{constructor(){this._name="SetGroupMessageRemindType"}init(A){this._core=A}set(A,t){return e(this,void 0,void 0,function*(){const{common:{getCurrentUserID:i,isTopic:o},OuterConstant:n}=this._core;if(yield function(A,t){return e(this,void 0,void 0,function*(){const{groupID:e,userID:i,receiveMessageOption:o}=A,n={GroupId:e,Member_Account:i,MsgFlag:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:n})})}({groupID:A,userID:i(),receiveMessageOption:t},this._core),!o(A)){const e=`${n.CONV_GROUP}${A}`;h.patchMessageRemindType([e],t)}return{code:0,data:{groupID:A,messageRemindType:t}}})}},M=new class{constructor(){this._name="SetMessageRemindType"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setMessageRemindType",context:this})}handleC2CMessageRemindTypeSync(A){const{helper:{isEmpty:e},OuterConstant:t,ssoLog:i}=this._core;A.forEach(A=>{const{MuteNotificationsSync:o}=A;if(!e(o)){const{To_Account:A,MuteNotifications:e}=o,n=A.map(A=>`${t.CONV_C2C}${A}`),s=r(e);i.debug(`${this._name}.handleC2CMessageRemindTypeSync conversationIDList:${n} messageRemindType:${s}`),h.patchMessageRemindType(n,s)}})}setMessageRemindType(A){return e(this,void 0,void 0,function*(){const e="setMessageRemindType",{groupID:t,userIDList:i,messageRemindType:o}=A,{helper:n,utils:{isUndefined:r},ssoLog:s}=this._core;try{if(!r(t))return s.debug(`${this._name}.${e} groupID:${t} messageRemindType:${o}`),yield S.set(t,o);if(!r(i))return s.debug(`${this._name}.${e} userIDList:${i} messageRemindType:${o}`),yield w.set(i,o);throw new n.ChatError({functionName:e,message:"userIDList or groupID is required"})}catch(a){const A=new n.ChatError({functionName:e,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo});throw console.error(`${this._name}.${e} fail:`,A),A}})}},R=new class{init(A){A.ssoLog.debug("ConversationAction.init"),this._core=A,C.init(A),p.init(A),f.init(A),m.init(A),y.init(A),D.init(A),v.init(A),M.init(A);const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:i}}=this._core,{InnerEventSubType:{CONV_MODIFIED:o,C2C_MESSAGE_READ_SYNC:n,GROUP_MESSAGE_READ_SYNC:r,C2C_REMIND_TYPE_SYNC:s}}=e;e.subscribeInnerEvent(t,o,this._onConversationModified,this),e.subscribeInnerEvent(t,n,this._onC2CMessageReadSync,this),e.subscribeInnerEvent(t,s,this._onC2CMessageRemindTypeSync,this),e.subscribeInnerEvent(t,r,this._onGroupMessageReadSync,this),e.subscribeInnerEvent(i,this._dispose,this)}_onConversationModified(A){const{constants:{ConvModifyPushType:e}}=this._core,{RecentContactMod:t=[]}=A;t.forEach(A=>{const{PushType:t}=A;if(t===e.CONV_DELETED){const{RecentContactList:e}=A.RecentContactDeleteItem;D.handleConversationDeleted(e)}if(t===e.CONV_PINED){const{RecentContactList:e}=A.RecentContactTopItem;y.handleConversationPinned(e,!0)}if(t===e.CONV_UNPINED){const{RecentContactList:e}=A.RecentContactTopItem;y.handleConversationPinned(e,!1)}})}_onC2CMessageReadSync(A){const{C2cNotifyMsgArray:e=[]}=A;m.handleC2CMessageReadSync(e)}_onC2CMessageRemindTypeSync(A){const{C2cNotifyMsgArray:e=[]}=A;M.handleC2CMessageRemindTypeSync(e)}_onGroupMessageReadSync(A){const{GroupTips:e=[]}=A;m.handleGroupMessageReadSync(e)}_dispose(){const{notificationCenter:A,InnerEvent:{MESSAGE_PUSH:e,DESTROY:t}}=this._core,{InnerEventSubType:{CONV_MODIFIED:i,C2C_MESSAGE_READ_SYNC:o,GROUP_MESSAGE_READ_SYNC:n,C2C_REMIND_TYPE_SYNC:r}}=A;A.unSubscribeInnerEvent(e,i,this._onConversationModified,this),A.unSubscribeInnerEvent(e,o,this._onC2CMessageReadSync,this),A.unSubscribeInnerEvent(e,r,this._onC2CMessageRemindTypeSync,this),A.unSubscribeInnerEvent(e,n,this._onGroupMessageReadSync,this),A.unSubscribeInnerEvent(t,this._dispose,this)}},_=new class{init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setAllReceiveMessageOpt",context:this})}setAllReceiveMessageOpt(t){return e(this,void 0,void 0,function*(){try{const{OuterConstant:{MSG_REMIND_ACPT_NOT_NOTE:i}}=this._core,{messageRemindType:o=i,isRepeated:n=!0}=t,{startTime:r=0,endTime:s=0}=this._calcStartAndEndTime(t),a=yield function(t){return e(this,void 0,void 0,function*(){const{common:e}=A.core,{startTime:i,endTime:o,isRepeated:n,messageRemindType:r}=t,s={StartTime:i,EndTime:o,IsRepeated:n,Level:r};return e.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_set_do_not_disturb",data:s})})}({messageRemindType:this._getType(o),startTime:r,endTime:s,isRepeated:n?c.ON:c.OFF});return{code:0,data:{errorCode:a.ErrorCode,errorInfo:a.ErrorInfo}}}catch(u){a("setAllReceiveMessageOpt",u)}})}_calcStartAndEndTime(A){const{startHour:e=0,startMinute:t=0,startSecond:i=0,duration:o=0,isRepeated:n=!0}=A,r=new Date,s=new Date(r.getFullYear(),r.getMonth(),r.getDate(),e,t,i),a=Math.round(s.getTime()/1e3);let g=a+o;return n&&o>=86400&&(g=a+86400),{startTime:a,endTime:g}}_getType(A){const{OuterConstant:e}=this._core;return{[e.MSG_REMIND_ACPT_AND_NOTE]:0,[e.MSG_REMIND_DISCARD]:1,[e.MSG_REMIND_ACPT_NOT_NOTE]:2}[A]}},T=new class{init(A){this._core=A;const{helper:e,notificationCenter:t,InnerEvent:i}=A;e.registerApi({apiName:"getAllReceiveMessageOpt",context:this}),t.subscribeInnerEvent(i.MESSAGE_PUSH,t.InnerEventSubType.ALL_RECEIVE_MESSAGE_OPTION,this.onAllReceiveMsgOptionNotify,this)}onAllReceiveMsgOptionNotify(A){const e=this._handleResult(A),{notificationCenter:t,OuterEvent:{ALL_RECEIVE_MESSAGE_OPT_UPDATED:i}}=this._core;t.emitOuterEvent(i,{name:i,data:e})}getAllReceiveMessageOpt(){return e(this,void 0,void 0,function*(){try{const t=yield function(){return e(this,void 0,void 0,function*(){const{common:e}=A.core,t={To_Account:e.getCurrentUserID()};return e.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_get_do_not_disturb",data:t})})}();return{code:0,data:this._handleResult(t)}}catch(u){a("getAllReceiveMessageOpt",u)}})}_handleResult(A){const{OuterConstant:e}=this._core,{MSG_REMIND_ACPT_AND_NOTE:t,MSG_REMIND_DISCARD:i,MSG_REMIND_ACPT_NOT_NOTE:o}=e,n={0:t,1:i,2:o},{Level:r,StartTime:s,EndTime:a,IsRepeated:g}=A;return{messageRemindType:n[r]||t,startTime:s,endTime:a,isRepeated:g===c.ON}}},N=new class{init(A){A.ssoLog.debug("ReceiveMessageOptions.init"),this._core=A,w.init(A),S.init(A),B.init(A),Q.init(A),_.init(A),T.init(A)}};const b=A=>!t(A)&&!i(A)&&!o(A),G={getConversationProfile:[{key:"conversationID",required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!b(A)||"conversationID is invalid."}],setMessageRead:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!b(A)||"conversationID is invalid."}},pinConversation:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!b(A)||"conversationID is invalid."},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},deleteConversation:[{key:"options",required:!0,rules:["string","object"],allowEmpty:!1,customValidator:e=>{const{core:{utils:{isArray:t,isObject:i,isString:o}}}=A;if(!o(e)&&!i(e))return"options is String or Object.";if(o(e)&&b(e))return"conversationID is invalid.";if(i(e)){if(!t(e.conversationIDList))return"conversationIDList is not Array.";if(0===e.conversationIDList.length)return"conversationIDList is empty.";if(e.conversationIDList.some(A=>{if(b(A))return!0}))return"conversationIDList includes invalid conversationID.";if(e.clearHistoryMessage&&"boolean"!=typeof e.clearHistoryMessage)return"clearHistoryMessage is not Boolean."}return!0}}],setConversationDraft:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!(!t(A)&&!i(A))||"conversationID is invalid."},draftText:{required:!0,rules:["string"],allowEmpty:!0}},setAllReceiveMessageOpt:{messageRemindType:{required:!1,rules:["string"],allowEmpty:!0},startHour:{required:!1,rules:["number"],allowEmpty:!0},startMinute:{required:!1,rules:["number"],allowEmpty:!0},startSecond:{required:!1,rules:["number"],allowEmpty:!0},duration:{required:!1,rules:["number"],allowEmpty:!0},isRepeated:{required:!1,rules:["boolean"],allowEmpty:!0}}},k={getConversationList:!0,getConversationProfile:!0,getTotalUnreadCount:!0,setMessageRead:!0,pinConversation:!0,deleteConversation:!0,setConversationDraft:!0,setMessageRemindType:!0,getAllReceiveMessageOpt:!0,setAllReceiveMessageOpt:!0};return new class{constructor(){this.name="Conversation"}install(e){A.init(e),R.init(e),N.init(e),h.init(e),e.helper.registerValidateConfig({auth:k,params:G})}}}();const e_=RR(A_.exports);var t_={exports:{}};t_.exports=function(){const A=new class{init(A){this.core=A}},e="AVChatRoom",t="AV_HISTORY_MSG",i="GRP_COUNTER",o="Set",n="Increase",r="Decrease",s=0,a=1,g=2,c=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],l=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],I=["Role","JoinTime","MsgFlag","MsgSeq"],u=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],E=0,d=1,h="notStart",C="resolved",B="rejected",Q=10018,p=11e3,f=2,m=["Owner","Admin","Member"],y=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],D=0,v=1,w=2,S=4,M=1,R=2,_=3,T=4,N=5,b=1,G=0,k=4,L=6,U=400,F=300,O={from:!0,groupID:!0,groupName:!0,to:!0},x={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},P=2,Y=4,J=5,H=7,q=8,V=15,j=20,K=21,W=2600,z=2602,Z=2603,X=2620,$=2621,AA=2623,eA=2660,tA=2661,iA=2681,oA=2683,nA=2684,rA=2685,sA=2687,aA=3122,gA=10018,cA=e=>e===A.core.OuterConstant.GRP_PUBLIC,lA=e=>e===A.core.OuterConstant.GRP_AVCHATROOM,IA=(e,t)=>{const{isArray:i}=A.core.utils;if(!i(e)||!i(t))return!1;let o=!1;return t.forEach(({key:A,value:t})=>{const i=e.find(e=>e.key===A);i?i.value!==t&&(i.value=t,o=!0):(e.push({key:A,value:t}),o=!0)}),o},uA=A=>{const e=[];if(!A)return e;for(let t=0,i=A.length;t{const e=[];for(let t=0,i=A.length;t0&&s.members.forEach(A=>{A.userID===this.selfInfo.userID&&r(this.selfInfo,A,["sequence"])})}updateSelfInfo(e){const{nameCard:t,joinTime:i,role:o,messageRemindType:n,readedSequence:r,excludedUnreadSequenceList:s}=e,{common:{deepMerge:a}}=A.core;a(this.selfInfo,{nameCard:t,joinTime:i,role:o,messageRemindType:n,readedSequence:r,excludedUnreadSequenceList:s},[],["",null,void 0,0,NaN])}setSelfNameCard(A){this.selfInfo.nameCard=A}}var QA=new class{constructor(){this._name="GroupDataHandler"}init(A){this._core=A;const{appStore:{groupStore:e}}=A;this._groupMap=e.getGroupMap()}hasLocalGroup(A){return this._groupMap.has(A)}getLocalGroup(A){return this._groupMap.get(A)}updateLocalGroup(A){const{common:{getCurrentUserID:e}}=this._core;let t;A.forEach(A=>{var e;t=A.groupID,this.hasLocalGroup(t)?null===(e=this.getLocalGroup(t))||void 0===e||e.updateGroup(A):this._groupMap.set(t,new BA(A))});const i=e();for(const[,o]of this._groupMap)o.selfInfo.userID=i,"Owner"===o.selfInfo.role&&(o.ownerID=i)}deleteLocalGroup(A){this._groupMap.delete(A)}getLocalGroupList(){const{OuterConstant:{GRP_ROOM:A,GRP_LIVE:e}}=this._core;return[...this._groupMap.values()].filter(t=>{const{type:i}=t;return i!==A&&i!==e})}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const A=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:e},notificationCenter:t}=this._core;t.emitOuterEvent(e,{name:e,data:A})}updateConversationGroupProfile(A){const{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core,i=`${t}${A}`;if(e.getConversation(i)){const t=this.getLocalGroup(A);e.updateConversation(i,{groupProfile:t})}}reset(){this.clearLocalGroup()}};function pA(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{const A=QA.getLocalGroupList();return yA({groupList:A,isSyncCompleted:this._isSyncCompleted()})}).catch(A=>{throw A});const e=QA.getLocalGroupList();return yA({groupList:e,isSyncCompleted:this._isSyncCompleted()},{message:`return group count:${e.length}`})})}_syncGroupList(){return fA(this,void 0,void 0,function*(){this._pagingStatus===h&&QA.clearLocalGroup();const A=this.PAGING_GRP_COUNT_LIMIT,e=[];try{yield this._pagingGetGroupList({limit:A,offset:0,groupList:e}),this._pagingStatus=C,this._groupListTreeShaking(e),QA.updateLocalGroup(e);const t=QA.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",`${this._name}._syncGroupList ok, count:${t.length}`),QA.emitGroupListUpdate(),t}catch(t){throw this._pagingStatus=B,t}})}_pagingGetGroupList(A){return fA(this,void 0,void 0,function*(){const{ssoLog:e}=this._core,{isCommunityRelay:t=!1,groupList:i}=A;let o,{limit:n,offset:r}=A;const s=[...c];t&&(o=this._core.OuterConstant.GRP_COMMUNITY,s.push("AtInfoList"));try{const A=yield mA({type:o,limit:n,offset:r,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:s,SelfInfoFilter:[...I]}},this._core),{GroupIdList:a=[],TotalCount:g=0}=A||{},c=this._convertGroupKey(a);i.push(...c);const l=r+n,u=!(g>l),E=`offset:${r} limit:${n} total:${g} isCompleted:${u} current:${i.length} isCommunityRelay:${t}`;return e.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. ${E}`),t?u?i:(r=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:r,groupList:i})):u?(e.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList start to get community list`),r=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:r,groupList:i})):(r=l,this._pagingGetGroupList({limit:n,offset:r,groupList:i}))}catch(a){if(a.ErrorCode===Q)return e.warn("_pagingGetGroupList",`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetGroupList({isCommunityRelay:t,limit:n,offset:r,groupList:i});if(t)return a.code===p&&e.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. community unavailable`),i;throw a}})}_pagingGetJoinedCommunityList(A){return fA(this,void 0,void 0,function*(){const{common:{getCurrentUserID:e},OuterConstant:t,ssoLog:i}=this._core,{groupList:o}=A;let{limit:n,offset:r}=A;try{const A=yield mA({limit:n,offset:r,type:t.GRP_COMMUNITY,memberAccount:e(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...c],SelfInfoFilter:[...I]}},this._core),{GroupIdList:s=[],TotalCount:a=0}=A||{},g=this._convertGroupKey(s);o.push(...g);const l=r+n,u=!(a>l),E=`offset:${r} limit:${n} total:${a} isCompleted:${u} current:${o.length}`;return i.debug("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList ok. ${E}`),u?o:(r=l,this._pagingGetJoinedCommunityList({limit:n,offset:r,groupList:o}))}catch(s){if(s.code===gA)return i.warn("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetJoinedCommunityList({limit:n,offset:r,groupList:o});throw s}})}_groupListTreeShaking(A){const e=new Map([...QA.getLocalGroupList()]);for(let i=0,o=A.length;i{const{AtFlagList:i,AtMsgSeq:o,From_Account:n}=e;t.push({groupID:A,groupAtType:i,sequence:o,from:n})}),t}},vA=new class{constructor(){this._name="CreateGroup"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"createGroup",context:this})}createGroup(A){return fA(this,void 0,void 0,function*(){var e;this._preCheckParams(A);const{helper:{ChatError:t}}=this._core;try{const{utils:{isEmpty:t},common:{getCurrentUserID:i}}=this._core,o=yield function(A,e){return fA(this,void 0,void 0,function*(){const{name:t,type:i,groupID:o,introduction:n,notification:r,avatar:s,maxMemberNum:a,joinOption:g,inviteOption:c,memberList:l,groupCustomField:I,isSupportTopic:u}=A;let E;l&&(E=l.map(A=>{const{userID:e,memberCustomField:t}=A;return{Member_Account:e,AppMemberDefinedData:t?EA(t):void 0}}));const d={Name:t,Type:i,GroupId:o,Introduction:n,Notification:r,FaceUrl:s,MaxMemberCount:a,ApplyJoinOption:g,InviteJoinOption:c,MemberList:E,AppDefinedData:I,SupportTopic:u,webPushFlag:1};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:d})})}(Object.assign(Object.assign({},A),{ownerID:i()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:r=[]}=o||{},s=`${this._name}.createGroup ok, type:${A.type} groupID:${n} overLimitUserIDList:${r}`;t(A.memberList)||t(r)||(A.memberList=null===(e=A.memberList)||void 0===e?void 0:e.filter(A=>r.includes(A.userID))),QA.updateLocalGroup([Object.assign(Object.assign({},A),{groupID:n})]);const a=QA.getLocalGroup(n);return this._notNeedSendCustomMessage(A)||(this._sendCustomMessage(n,A.type),QA.emitGroupListUpdate()),yA({group:a},{message:s})}catch(i){const{errorCode:e,errorInfo:o}=i;throw new t({functionName:"createGroup",code:e,message:o,moreMessage:` groupID:${A.groupID}`})}})}_preCheckParams(e){const{type:t,groupID:i}=e,{utils:{isEmpty:o,isUndefined:n},common:{isCommunity:r}}=this._core,s=!o(i);if(!(()=>{const{GRP_PUBLIC:e,GRP_WORK:t,GRP_MEETING:i,GRP_AVCHATROOM:o,GRP_COMMUNITY:n}=A.core.OuterConstant;return[e,t,i,o,n]})().includes(t))throw new this._core.helper.ChatError({code:W});if(!r({type:t})){if(s&&r({groupID:i}))throw new this._core.helper.ChatError({code:z});n(e.isSupportTopic)||(e.isSupportTopic=void 0)}if(this._canIUseMemberList(t)||n(e.memberList)||(e.memberList=void 0),this._canIUseJoinOption(t)||n(e.joinOption)||(e.joinOption=void 0),r({type:t})){if(s&&!r({groupID:i}))throw new this._core.helper.ChatError({code:z});e.isSupportTopic=this._canIUseTopic(e)?1:0}}_canIUseMemberList(A){return!lA(A)}_canIUseJoinOption(A){return cA(A)||this._core.common.isCommunity({type:A})}_canIUseTopic(A){const{isSupportTopic:e}=A;return!0===e}_notNeedSendCustomMessage(A){const{type:e,isSupportTopic:t}=A,{OuterConstant:{GRP_AVCHATROOM:i,GRP_COMMUNITY:o}}=this._core;return e===i||e===o&&1===t}_sendCustomMessage(A,e){var t,i,o,n,r,s;const{OuterConstant:a}=this._core;let g="Create Group",c=E;e===a.GRP_COMMUNITY&&(g="Create Community",c=d);const l={to:A,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:g,cmd:c,opUser:this._core.store.get("login").userId,version:4})}},I=null===(o=null===(i=null===(t=this._core)||void 0===t?void 0:t.message)||void 0===i?void 0:i.messageFactory)||void 0===o?void 0:o.createCustomMessage(l);null===(s=null===(r=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===r?void 0:r.messageSender)||void 0===s||s.sendMessage(I,{})}},wA=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(A){this._core=A;const{helper:e,constants:t}=A;e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach(A=>{A.localMainSequence=0})}isGroupAttributesUpdated(A){const{elements:{newGroupProfile:e}}=A,{utils:{isEmpty:t,isUndefined:i}}=this._core;return!i(e)&&!t(e.groupAttributeOption)}handleGroupAttributesUpdated(A){const{groupID:e,groupAttributeOption:t}=A,{serverMainSequence:i,groupAttributeList:o=[],operation:n}=t;this._core.ssoLog.debug("handleGroupAttributesUpdated",`${this._name}.handleGroupAttributesUpdated groupID:${e} operation:${n}`);const{utils:{isUndefined:r}}=this._core;r(n)||(this.refreshGroupAttributesCache({groupID:e,serverMainSequence:i,groupAttributeList:o,operation:n}),this.emitGroupAttributesUpdated(e))}initGroupAttributesCache(A){const{groupID:e,avChatRoomKey:t}=A;this._groupAttributesCache.set(e,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:t,values:new Map}),this._core.ssoLog.debug("initGroupAttributesCache",`${this._name}.initGroupAttributesCache. groupID:${e} avChatRoomKey:${t}`)}hasGroupAttributesCache(A){return this._groupAttributesCache.has(A)}getGroupAttributesCache(A){return this.hasGroupAttributesCache(A)||this.initGroupAttributesCache({groupID:A}),this._groupAttributesCache.get(A)}deleteGroupAttributesCache(A){this.hasGroupAttributesCache(A)&&this._groupAttributesCache.delete(A)}refreshGroupAttributesCache(A){const{groupID:e,serverMainSequence:t,groupAttributeList:i,operation:o}=A;if(this.hasGroupAttributesCache(e)){const A=this.getGroupAttributesCache(e),{localMainSequence:n}=A;o!==N&&t-n!=1||(A.serverMainSequence=t,A.localMainSequence=t,A.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:A,groupAttributeList:i,operation:o})),t-n>1&&(A.serverMainSequence=t),this._groupAttributesCache.set(e,A),this._core.ssoLog.debug("refreshGroupAttributesCache",`${this._name}.refreshGroupAttributesCache. operation:${o} localMainSequence:${n} serverMainSequence:${t}`)}}_updateGroupAttributesCacheValues(A){const{groupAttributes:e,groupAttributeList:t=[],operation:i}=A;i!==_?i!==T?(i===M&&e.values.clear(),t.forEach(A=>{const{key:t,value:i,sequence:o}=A;e.values.set(t,{value:i,sequence:o})})):t.forEach(A=>{e.values.delete(A.key)}):e.values.clear()}getGroupAttributesCacheValues(A){var e;const{groupID:t,keyList:i=[]}=A,o={};if(this.hasGroupAttributesCache(t)){const{values:A}=this.getGroupAttributesCache(t);if(0===i.length){for(const t of A.keys())o[t]=(null===(e=A.get(t))||void 0===e?void 0:e.value)||"";return o}return i.forEach(e=>{var t;A.has(e)&&(o[e]=(null===(t=A.get(e))||void 0===t?void 0:t.value)||"")}),o}return o}saveGroupAttributesCacheValuesCopy(A){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:A})}emitGroupAttributesUpdated(A){var e;const t=this.getGroupAttributesCacheValues({groupID:A}),{updatedKeyList:i,deletedKeyList:o}=this._computeValuesChangedData(t);this._core.ssoLog.debug("emitGroupAttributesUpdated",`${this._name}.emitGroupAttributesUpdated update count:${i.length}, delete count:${o.length}`),0===i.length&&0===o.length||this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:A,groupAttributes:t,updatedKeyList:i,deletedKeyList:o}})}_computeValuesChangedData(A){const{utils:{isUndefined:e}}=this._core,t=[],i=[];return Object.keys(A).forEach(e=>{A[e]!==this._groupAttributesCacheValuesCopy[e]&&t.push(e)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(t=>{e(A[t])&&i.push(t)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:t,deletedKeyList:i}}_emitEvent(A){var e;null===(e=this._core)||void 0===e||e.notificationCenter.emitOuterEvent(A.name,A)}convertKeyValueMapToList(A){const e=[];return Object.keys(A).forEach(t=>{e.push({key:t,value:A[t]})}),e}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}},SA=new class{constructor(){this._name="DismissGroup"}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}dismissGroup(A){return fA(this,void 0,void 0,function*(){const{helper:{ChatError:e}}=this._core;try{yield function(A,e){return fA(this,void 0,void 0,function*(){const t={GroupId:A};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:t})})}(A,this._core);const{type:e}=QA.getLocalGroup(A);return QA.deleteLocalGroup(A),QA.emitGroupListUpdate(),wA.deleteGroupAttributesCache(A),yA({groupID:A,type:e},{message:A})}catch(t){const{errorCode:A,errorInfo:i}=t;throw new e({functionName:"dismissGroup",code:A,message:i})}})}},MA=new class{constructor(){this._name="GetGroupProfile"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(A){return fA(this,void 0,void 0,function*(){const{groupID:e,groupCustomFieldFilter:t}=A,i={groupIDList:[e],responseFilter:{GroupBaseInfoFilter:[...c],AppDefinedDataFilter_Group:t,MemberInfoFilter:[...u]}},{helper:{ChatError:o}}=this._core;try{const A=yield this.getGroupProfileAdvance(i),{successGroupList:t,failureGroupList:o}=A;if(o.length>0)throw o[0];let n;return!QA.hasLocalGroup(e)&&lA(t[0].type)?n=new BA(t[0]):(QA.updateLocalGroup(t),n=QA.getLocalGroup(e)),n.isSupportTopic||QA.updateConversationGroupProfile(e),yA({group:n},{message:`groupID:${e}`})}catch(n){const{code:A,message:e}=n;throw new o({functionName:"getGroupProfile",code:A,message:e})}})}getGroupProfileAdvance(A){return fA(this,void 0,void 0,function*(){const{groupIDList:e}=A,{common:{isCommunity:t}}=this._core,i=e.filter(A=>!t({groupID:A})),o=e.filter(A=>t({groupID:A}));i.length>50&&(i.length=50),o.length>50&&(o.length=50);const n=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},A),{groupIDList:i})),this._getGroupProfileAdvance(Object.assign(Object.assign({},A),{groupIDList:o,isCommunityProfile:!0}))]),r=[],s=[];return n.forEach(A=>{r.push(...A.successGroupList),s.push(...A.failureGroupList)}),{successGroupList:r,failureGroupList:s}})}_getGroupProfileAdvance(A){return fA(this,void 0,void 0,function*(){const{ssoLog:e,utils:{isUndefined:t}}=this._core,{isCommunityProfile:i=!1}=A,o=pA(A,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupIDList:t,responseFilter:i}=A,o={GroupIdList:t,ResponseFilter:i};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}(o,this._core),{GroupInfo:i=[]}=A||{},n=this._convertGroupProfileKey(i),r=n.filter(A=>t(A.errorCode)||0===A.errorCode),s=n.filter(A=>A.errorCode&&0!==A.errorCode).map(A=>({code:A.errorCode,message:A.errorInfo,data:{groupID:A.groupID}}));return e.debug("_getGroupProfileAdvance",`${this._name}._getGroupProfileAdvance ok, groupID:${o.groupIDList.join(",")}`),{successGroupList:r,failureGroupList:s}}catch(n){if(i)return{successGroupList:[],failureGroupList:[]};throw n}})}_convertGroupProfileKey(A){const e=[];for(let t=0,i=A.length;t0&&i{const{Key:t,Value:i=0}=e;A.set(t,i)}),this._groupCountersMap.set(e,{lastUpdateTime:Date.now(),groupCounterSeq:i,counters:A,avChatRoomKey:o})}}initGroupCountersCache(A){const{groupID:e,avChatRoomKey:t}=A;this._groupCountersMap.set(e,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:t})}getLocalCounters(A,e){const t={};if(!this._hasLocalGroupCounters(A))return t;const{counters:i}=this.getLocalGroupCounters(A);if(e.length>0)e.forEach(A=>{i.has(A)&&(t[A]=i.get(A))});else for(const o of i.keys())t[o]=i.get(o);return t}deleteLocalGroupCounters(A){const{groupID:e,counterList:t=[],groupCounterSeq:i}=A;if(this._hasLocalGroupCounters(e)){const{counters:A,avChatRoomKey:o}=this.getLocalGroupCounters(e);t.forEach(e=>{A.delete(e.key)}),this._groupCountersMap.set(e,{lastUpdateTime:Date.now(),groupCounterSeq:i,counters:A,avChatRoomKey:o})}}setGroupCounters(A,e){if(!this._hasLocalGroupCounters(A))return;const t=this.getLocalGroupCounters(A),{counters:i}=t;let o=!1;Object.entries(e).forEach(([A,e])=>{i.has(A)&&i.get(A)!==e&&(i.set(A,e),o=!0)}),o&&this._groupCountersMap.set(A,Object.assign(Object.assign({},t),{lastUpdateTime:Date.now(),counters:i}))}_hasLocalGroupCounters(A){return this._groupCountersMap.has(A)}reset(){this._groupCountersMap.clear()}},_A=new class{constructor(){this._name="JoinGroup"}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"joinGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}joinGroup(A){return fA(this,void 0,void 0,function*(){const{groupID:e}=A,{helper:{ChatError:t},OuterConstant:i,ssoLog:o}=this._core;try{if(QA.hasLocalGroup(e))try{return yield MA.getGroupProfile({groupID:e}),yA({status:i.JOIN_STATUS_ALREADY_IN_GROUP,group:QA.getLocalGroup(e)},{message:`groupID:${e} joinedStatus:${i.JOIN_STATUS_ALREADY_IN_GROUP}`})}catch(n){return o.warn("joinGroup",`${this._name}.joinGroup ${e} was unjoined, start to join!`),QA.deleteLocalGroup(e),yield this._applyJoinGroup(A)}return yield this._applyJoinGroup(A)}catch(r){const{errorCode:A,errorInfo:i}=r;throw new t({functionName:"joinGroup",code:A,message:i,moreMessage:`groupID:${e}`})}})}_applyJoinGroup(A){return fA(this,void 0,void 0,function*(){const{OuterConstant:e,helper:i,ssoLog:o}=this._core,{groupID:n}=A,r=Object.assign({},A),s=i.checkBusinessCapabilityBits(t);s&&(r.historyMessageFlag=1);const a=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,applyMessage:i,historyMessageFlag:o}=A,n={GroupId:t,ApplyMsg:i,HugeGroupHistoryMsgFlag:o};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:n})})}(r,this._core),{Type:g,JoinedStatus:c,LongPollingKey:l,StartSeq:I,HugeGroupFlag:u,AVChatRoomKey:E,RspMsgList:d=[]}=a||{},h=`groupID:${n} joinedStatus:${c} longPollingKey:${l} startSeq:${I} avChatRoomFlag:${u} canGetAVChatRoomHistoryMsg:${s}, historyMessageCount:${d.length}`;o.debug("_applyJoinGroup",`${this._name}._applyJoinGroup ok, ${h}`);let C=new BA({groupID:n,type:g});if(c===e.JOIN_STATUS_WAIT_APPROVAL)return yA({status:e.JOIN_STATUS_WAIT_APPROVAL,group:C});if(c===e.JOIN_STATUS_SUCCESS){try{C=(yield MA.getGroupProfile({groupID:n})).data.group}catch(B){o.warn("_applyJoinGroup",`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${n}, errorCode:${null==B?void 0:B.code}`)}return this._handleJoinResult({group:C,avChatRoomFlag:u,longPollingKey:l,startSequence:I,avChatRoomKey:E,historyMessageList:d})}throw new this._core.helper.ChatError({code:eA})})}_handleJoinResult(A){const{group:e,avChatRoomFlag:t,avChatRoomKey:i}=A;return 1===t?(wA.initGroupAttributesCache({groupID:e.groupID,avChatRoomKey:i}),RA.initGroupCountersCache({groupID:e.groupID,avChatRoomKey:i}),yA(A)):(QA.updateLocalGroup([e]),QA.emitGroupListUpdate(),yA({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:e},{message:`groupID:${e.groupID}`}))}},TA=new class{constructor(){this._name="QuitGroup"}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"quitGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}quitGroup(A){return fA(this,void 0,void 0,function*(){if(!QA.hasLocalGroup(A))throw new this._core.helper.ChatError({code:AA});const{helper:{ChatError:e}}=this._core;try{yield function(A,e){return fA(this,void 0,void 0,function*(){const t={GroupId:A};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:t})})}(A,this._core);const{type:e}=QA.getLocalGroup(A);return QA.deleteLocalGroup(A),QA.emitGroupListUpdate(),wA.deleteGroupAttributesCache(A),yA({groupID:A,type:e},{message:`groupID:${A}`})}catch(t){const{errorCode:i,errorInfo:o}=t;throw new e({functionName:"quitGroup",code:i,message:o,moreMessage:`groupID:${A}`})}})}},NA=new class{constructor(){this._name="SearchGroup"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(A){return fA(this,void 0,void 0,function*(){try{const e=yield function(A,e){return fA(this,void 0,void 0,function*(){const t={GroupIdList:[A],GroupBasePublicInfoFilter:[...l]};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:t})})}(A,this._core),{GroupInfo:t=[]}=e||{},{AppDefinedData:i=[],ApplyJoinOption:o,CreateTime:n,FaceUrl:r,Introduction:s,InviteJoinOption:a,MaxMemberNum:g,MemberNum:c,Name:I,Owner_Account:u,Type:E,ErrorCode:d,ErrorInfo:h}=t[0];if(0!==d)throw new this._core.helper.ChatError({code:d,message:h});const C=uA(i),B=new BA({groupID:A,name:I,avatar:r,introduction:s,joinOption:o,inviteOption:a,maxMemberCount:g,memberCount:c,type:E,ownerID:u,createTime:n,groupCustomField:C});return yA({group:B})}catch(e){const{errorCode:A,errorInfo:t}=e;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:A,message:t})}})}},bA=new class{constructor(){this._name="UpdateGroupProfile"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(A){return fA(this,void 0,void 0,function*(){const{groupID:e}=A,{utils:{isUndefined:t},ssoLog:i,helper:o}=this._core;let n=QA.getLocalGroup(e);if(n){const{type:o}=n;this._canIUseJoinOption(o)||t(A.joinOption)||(i.warn("updateGroupProfile",`${this._name}.updateGroupProfile groupID:${e} joinOption is unavailable for Work/Meeting/AVChatRoom`),A.joinOption=void 0)}t(A.muteAllMembers)||(A.muteAllMembers=!0===A.muteAllMembers?"On":"Off");try{return yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,name:i,avatar:o,introduction:n,notification:r,muteAllMembers:s,joinOption:a,inviteOption:g,groupCustomField:c}=A,l={GroupId:t,Name:i,FaceUrl:o,Introduction:n,Notification:r,ShutUpAllMember:s,ApplyJoinOption:a,InviteJoinOption:g,AppDefinedData:c?EA(c):void 0};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:l})})}(A,this._core),n?(n.updateGroup(A),QA.emitGroupListUpdate()):n=new BA(A),yA({group:n},{message:`groupID:${e}`})}catch(r){const{errorCode:A,errorInfo:t}=r;throw new o.ChatError({code:A,message:t,moreMessage:`groupID:${e}`})}})}_canIUseJoinOption(A){return cA(A)||this._core.common.isCommunity({type:A})}},GA=new class{constructor(){this._name="ChangeGroupOwner"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(A){return fA(this,void 0,void 0,function*(){const e="changeGroupOwner",{groupID:t,newOwnerID:i}=A,o=QA.getLocalGroup(t),{helper:n,OuterConstant:r,common:{getCurrentUserID:s}}=this._core;if((null==o?void 0:o.type)===r.GRP_AVCHATROOM)throw new n.ChatError({functionName:e,code:X});if(i===s())throw new n.ChatError({functionName:e,code:$});try{return yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,newOwnerID:i}=A,o={GroupId:t,NewOwner_Account:i};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:o})})}(A,this._core),o.ownerID=i,QA.emitGroupListUpdate(),yA({group:o})}catch(a){throw new n.ChatError({functionName:e,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}},kA=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}getGroupOnlineMemberCount(A){return fA(this,void 0,void 0,function*(){const e="getGroupOnlineMemberCount";if(!QA.hasLocalGroup(A))return yA({memberCount:0});const t=Date.now();if(this._onlineMemberCountMap.has(A)){const e=this._onlineMemberCountMap.get(A),{lastReqTime:i=0,memberCount:o=0}=e||{};if(t-i<=6e4)return yA({memberCount:o})}try{const t=yield function(A,e){return fA(this,void 0,void 0,function*(){const t={GroupId:A};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:t})})}(A,this._core),{OnlineMemberNum:i=0}=t||{};this._onlineMemberCountMap.set(A,{lastReqTime:Date.now(),memberCount:i});const o=`${this._name}.${e} ok. groupID:${A} memberCount:${i}`;return yA({memberCount:i},{message:o})}catch(i){throw new this._core.helper.ChatError({functionName:e,code:null==i?void 0:i.errorCode,message:null==i?void 0:i.errorInfo})}})}},LA=new class{init(A,e){A.ssoLog.debug("GroupAction.init"),DA.init(A),vA.init(A),SA.init(A,e),_A.init(A,e),TA.init(A,e),NA.init(A),MA.init(A),bA.init(A),GA.init(A),kA.init(A,e)}dismissGroup(A){return SA.dismissGroup(A)}joinGroup(A){return _A.joinGroup(A)}quitGroup(A){return TA.quitGroup(A)}getGroupOnlineMemberCount(A){return kA.getGroupOnlineMemberCount(A)}},UA=new class{constructor(){this._name="GetGroupApplicationList"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return fA(this,void 0,void 0,function*(){const A="getGroupApplicationList";try{const e=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);this._core.ssoLog.debug("getGroupApplicationList",`${this._name}.${A} ok.`);const t=this._handleGroupApplicationResult([...e[0],...e[1]]);return yA({applicationList:t})}catch(e){throw new this._core.helper.ChatError({functionName:A,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_getGroupApplicationList(A){return fA(this,void 0,void 0,function*(){const{type:e,startTime:t=0,limit:i=20}=A||{},{common:o}=this._core;let n;try{n=yield function(A,e){return fA(this,void 0,void 0,function*(){const{type:t,startTime:i,limit:o,handleAccount:n}=A,r={Type:t,StartTime:i,Limit:o,Handle_Account:n};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:r})})}({type:e,startTime:t,limit:i,handleAccount:o.getCurrentUserID()},this._core)}catch(g){if(11e3!==(null==g?void 0:g.errorCode))throw g;n={}}const{NextStartTime:r=0,PendencyList:s=[]}=n||{};if(0===r)return s;const a=yield this._getGroupApplicationList(Object.assign(Object.assign({},A),{startTime:r}));return[...s,...a]})}_handleGroupApplicationResult(A){const e=[];return A.forEach(A=>{const t=this._convertApplicationData(A),{handled:i}=t,o=pA(t,["handled"]);0===i&&e.push(o)}),e}_convertApplicationData(A){const{Handled:e,AddTime:t,ApplyInviteMsg:i,Authentication:o,FromUserNickName:n,From_Account:r,GroupId:s,GroupName:a,PendencyType:g,To_Account:c}=A;return{handled:e,messageKey:t,applicant:r,applicantNick:n,groupID:s,groupName:a,authentication:o,applicationType:g,userID:c,note:i}}},FA=new class{constructor(){this._name="HandleGroupApplication"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(A){return fA(this,void 0,void 0,function*(){const{application:e}=A,t=this._handleParams(A);try{(null==e?void 0:e.applicationType)===f?yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,handleAction:i,handleMessage:o,applicant:n,authentication:r,invitee:s}=A,a={GroupId:t,HandleMsg:i,ApprovalMsg:o,Applicant_Account:n,Authentication:r,Invited_Account:s};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:a})})}(t,this._core):yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,handleAction:i,handleMessage:o,applicant:n,authentication:r,messageKey:s}=A,a={GroupId:t,HandleMsg:i,ApprovalMsg:o,Applicant_Account:n,Authentication:r,MsgKey:s};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:a})})}(t,this._core);const A=QA.getLocalGroup(t.groupID);return yA({group:A})}catch(i){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==i?void 0:i.errorCode,message:null==i?void 0:i.errorInfo})}})}_handleParams(A){var e;const{handleAction:t,handleMessage:i,message:o,application:n}=A;let r,s,a,g,c;if(o){const{payload:A}=o||{};r=A.operatorID,s=null===(e=A.groupProfile)||void 0===e?void 0:e.groupID,a=A.authentication,g=A.messageKey}else r=(null==n?void 0:n.applicant)||"",s=(null==n?void 0:n.groupID)||"",a=(null==n?void 0:n.authentication)||"",g=(null==n?void 0:n.messageKey)||0;return(null==n?void 0:n.applicationType)===f&&(c=n.userID),{handleAction:t,handleMessage:i,applicant:r,invitee:c,groupID:s,authentication:a,messageKey:g}}},OA=new class{init(A){A.ssoLog.debug("GroupApplication.init"),UA.init(A),FA.init(A)}};let xA=class{constructor(A){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(A)}updateMember(e){const{core:{utils:{isUndefined:t},common:{deepMerge:i}}}=A;t(e.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*e.muteTime)/1e3)),t(e.onlineStatus)||(this.isOnline="Online"===e.onlineStatus);const o=[null,void 0,"",0,NaN];e.memberCustomField&&IA(this.memberCustomField,e.memberCustomField),i(this,e,["memberCustomField","marks","onlineStatus","muteTime"],o)}};function PA(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,userID:i,muteTime:o,role:n,nameCard:r,memberCustomField:s}=A;let a;s&&(a=EA(s));const g={GroupId:t,Member_Account:i,ShutUpTime:o,Role:n,NameCard:r,AppMemberDefinedData:a};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:g})})}var YA=new class{constructor(){this._name="GetGroupMemberList"}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}getGroupMemberList(A){return fA(this,void 0,void 0,function*(){const e="getGroupMemberList",{groupID:t,offset:i=0,count:o=100,role:n="",filter:r=""}=A,s=QA.getLocalGroup(t),a=o>100?100:o,g={groupID:t,offset:i,limit:a,memberRoleFilter:m.includes(n)?[n]:void 0,memberInfoFilter:y};try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{isCommunity:t}=e.common,{groupID:i,offset:o,limit:n,memberRoleFilter:r,memberInfoFilter:s}=A,a={GroupId:i,Limit:n,MemberRoleFilter:r,MemberInfoFilter:s};return t({groupID:i})?a.Next=String(o):a.Offset=o,e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:a})})}(g,this._core),{MemberList:o,MemberNum:n,Next:r}=A||{},c=`${this._name}.${e} ok, totalMemberCount:${n} next:${r}`,{utils:{isArray:l,isEmpty:I},common:{isCommunity:u}}=this._core;if(s&&(s.memberCount=n),!l(o)||0===o.length)return yA({memberList:[],offset:0},{message:c});let E=i+a;u({groupID:t})&&(E=I(r)?0:r),o.lengthA.userID),i=yield null===(e=this._core.user.userProfile)||void 0===e?void 0:e.getUserProfile({userIDList:t}),o=(null==i?void 0:i.data)||[],n=new Map(o.map(A=>[A.userID,A]));return A.forEach(A=>{if(n.has(A.userID)){const{nick:e="",avatar:t=""}=n.get(A.userID);A.nick=e,A.avatar=t}}),A})}_generateGroupMember(A){const e=[];for(let t=0,i=A.length;t50&&(a.warn("getGroupMemberProfile",`${this._name}.${e} userIDList length:${i.length} exceeds limit 50`),i.splice(50));const g=`userIDList length:${i.length} groupID:${t}`;try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,userIDList:i,memberInfoFilter:o,memberCustomFieldFilter:n}=A,r={GroupId:t,Member_List_Account:i,MemberInfoFilter:o,AppDefinedDataFilter_GroupMember:n};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:r})})}({groupID:t,userIDList:i,memberCustomFieldFilter:o,memberInfoFilter:[...y]},this._core),{MemberList:e}=A||{};if(!s(e)||0===e.length)return yA({memberList:[]});let n=this._convertMemberInfo(e);n=yield this._getMemberAvatarAndNick(n);const r=this._generateGroupMember(n);return yA({memberList:r},{message:g})}catch(c){throw new r.ChatError({functionName:e,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo,moreMessage:g})}})}_convertMemberInfo(A){const e=[];for(let t=0,i=A.length;tA.userID),i=yield null===(e=this._core.user.userProfile)||void 0===e?void 0:e.getUserProfile({userIDList:t}),o=(null==i?void 0:i.data)||[],n=new Map(o.map(A=>[A.userID,A]));return A.forEach(A=>{if(n.has(A.userID)){const{nick:e="",avatar:t=""}=n.get(A.userID);A.nick=e,A.avatar=t}}),A})}_generateGroupMember(A){const e=[];for(let t=0,i=A.length;t({Member_Account:A}));try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,userIDList:i}=A,o={GroupId:t,MemberList:i};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:o})})}({groupID:t,userIDList:r},this._core),{MemberList:e=[]}=A||{},{failureUserIDList:i,successUserIDList:n,existedUserIDList:s,overLimitUserIDList:a}=this._handleResult(e);return yA({failureUserIDList:i,successUserIDList:n,existedUserIDList:s,overLimitUserIDList:a,group:o},{message:` groupID:${t} successUserIDList:${n} failureUserIDList:${i} existedUserIDList:${s} overLimitUserIDList:${a}`})}catch(s){throw new n.ChatError({functionName:e,code:null==s?void 0:s.errorCode,message:null==s?void 0:s.errorInfo})}})}_handleResult(A){const e=[],t=[],i=[],o=[];return A.forEach(A=>{const{Result:n,Member_Account:r}=A;n===D?e.push(r):n===v?t.push(r):n===w?i.push(r):n===S&&o.push(r)}),{failureUserIDList:e,successUserIDList:t,existedUserIDList:i,overLimitUserIDList:o}}},qA=new class{constructor(){this._name="DeleteGroupMember"}init(A,t){this._core=A;const{helper:i}=A;i.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(e)})}deleteGroupMember(A){return fA(this,void 0,void 0,function*(){const e="deleteGroupMember",{groupID:t,userIDList:i}=A,o=QA.getLocalGroup(t),{helper:n,utils:{isUndefined:r},ssoLog:s}=this._core;if(r(o))throw new n.ChatError({functionName:e,code:Z});i.length>20&&(s.warn("deleteGroupMember",`${this._name}.${e} userIDList length:${i.length} exceeds limit 20`),i.splice(20));try{return yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,userIDList:i,reason:o}=A,n={GroupId:t,MemberToDel_Account:i,Reason:o};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:n})})}({groupID:t,userIDList:i},this._core),yA({group:o,userIDList:i},{message:`groupID:${t} userIDList length:${i.length}`})}catch(a){throw new n.ChatError({functionName:e,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}},VA=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(A){return fA(this,void 0,void 0,function*(){const{helper:e}=this._core,{groupID:t,userID:i,muteTime:o}=A,n=` groupID:${t} userID:${i} muteTime:${o}`;this._preCheckSettingMuteParams(A);try{yield PA(A,this._core);const e=QA.getLocalGroup(t),r=new xA({userID:i,muteTime:o});return yA({group:e,member:r},{message:n})}catch(r){throw new e.ChatError({functionName:"setGroupMemberMuteTime",code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo,moreMessage:n})}})}_preCheckSettingMuteParams(A){const{userID:e}=A,{store:t,helper:i}=this._core;if(e===t.get("login").userId)throw new i.ChatError({functionName:"setGroupMemberMuteTime",code:rA})}},jA=new class{constructor(){this._name="SetGroupMemberRole"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(A){return fA(this,void 0,void 0,function*(){const e="setGroupMemberRole",{helper:t}=this._core,{groupID:i,userID:o,role:n}=A,r=`${this._name}.${e} ok, groupID:${i} userID:${o} role:${n}`;this._preCheckSettingRoleParams(A);try{yield PA(A,this._core);const e=QA.getLocalGroup(i),t=new xA({userID:o,role:n});return yA({group:e,member:t},{message:r})}catch(s){throw new t.ChatError({functionName:e,code:null==s?void 0:s.errorCode,message:null==s?void 0:s.errorInfo,moreMessage:r})}})}_preCheckSettingRoleParams(A){var e;const{groupID:t,userID:i,role:o}=A,{store:n,helper:r,OuterConstant:s,common:{isCommunity:a}}=this._core,g=QA.getLocalGroup(t);if((null===(e=null==g?void 0:g.selfInfo)||void 0===e?void 0:e.role)!==s.GRP_MBR_ROLE_OWNER)throw new r.ChatError({functionName:"setGroupMemberRole",code:iA});if(i===n.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberRole",code:nA});const c=[...m];if(a({groupID:t})&&c.push(s.GRP_MBR_ROLE_CUSTOM),!c.includes(o))throw new r.ChatError({functionName:"setGroupMemberRole",code:oA})}},KA=new class{constructor(){this._name="SetGroupMemberNameCard"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(A){return fA(this,void 0,void 0,function*(){const e="setGroupMemberNameCard",{helper:t,common:{getCurrentUserID:i}}=this._core;this._preCheckSettingNameCardParams(A);try{const{groupID:t,userID:o=i(),nameCard:n}=A,r={groupID:t,userID:o,nameCard:n};yield PA(r,this._core);const s=`${this._name}.${e} ok, groupID:${t} userID:${o} nameCard:${n}`,a=QA.getLocalGroup(t),g=new xA({userID:o,nameCard:n});return yA({group:a,member:g},{message:s})}catch(o){throw new t.ChatError({functionName:e,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo,moreMessage:logText})}})}_preCheckSettingNameCardParams(A){const{groupID:e}=A,{helper:t}=this._core,i=QA.getLocalGroup(e);if(lA(null==i?void 0:i.type))throw new t.ChatError({functionName:"setGroupMemberNameCard",code:sA})}},WA=new class{constructor(){this._name="SetGroupMemberCustomField"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(A){return fA(this,void 0,void 0,function*(){const e="setGroupMemberCustomField",{helper:t,common:{getCurrentUserID:i}}=this._core;this._preCheckSettingCustomFiledParams(A);const{groupID:o,userID:n=i(),memberCustomField:r}=A,s=`${this._name}.${e} ok, groupID:${o}userID:${n} memberCustomField:${JSON.stringify(r)}`;try{const A={groupID:o,userID:n,memberCustomField:r};yield PA(A,this._core);const e=QA.getLocalGroup(o),t=new xA({userID:n,memberCustomField:r});return yA({group:e,member:t},{message:s})}catch(a){throw new t.ChatError({functionName:e,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo,moreMessage:s})}})}_preCheckSettingCustomFiledParams(A){const{groupID:e}=A,{helper:t}=this._core,i=QA.getLocalGroup(e);if(lA(null==i?void 0:i.type))throw new t.ChatError({functionName:"setGroupMemberCustomField",code:sA})}},zA=new class{init(A,e){A.ssoLog.debug("GroupMember.init"),YA.init(A,e),JA.init(A),HA.init(A),qA.init(A,e),VA.init(A),jA.init(A),KA.init(A),WA.init(A)}getGroupMemberList(A){return YA.getGroupMemberList(A)}deleteGroupMember(A){return qA.deleteGroupMember(A)}},ZA=new class{init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(e){return fA(this,void 0,void 0,function*(){const t="getGroupCounters";try{dA(t,i);const{groupID:o,keyList:n=[]}=e,{avChatRoomKey:r,lastUpdateTime:s}=RA.getLocalGroupCounters(o);if(!(Date.now()-s>=this._getExpireTime()))return{code:0,data:{counters:RA.getLocalCounters(o,n)}};const a=yield function(e){return fA(this,void 0,void 0,function*(){const{groupID:t,GroupCounterKeys:i,avChatRoomKey:o}=e,{common:n}=A.core,r={GroupId:t,keyList:i,BytesKey:o};return n.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:r})})}({groupID:o,keyList:n,avChatRoomKey:r}),{GroupCounter:g=[],GroupCounterSeq:c}=a;return RA.updateLocalGroupCounters({groupID:o,counterList:g,groupCounterSeq:c}),{code:0,data:{counters:RA.getLocalCounters(o,n)}}}catch(o){hA(t,o)}})}_getExpireTime(){const{store:A,utils:{isUndefined:e}}=this._core,t=A.get("cloudConfig")||{},{grp_counter_expire_time:i}=t;return e(i)?3e4:Number(i)}},XA=new class{init(A){const{helper:e}=A;e.registerApi({apiName:"setGroupCounters",context:this}),e.registerApi({apiName:"increaseGroupCounter",context:this}),e.registerApi({apiName:"decreaseGroupCounter",context:this})}setGroupCounters(A){return fA(this,void 0,void 0,function*(){return this._handleCounterOperation(o,A)})}increaseGroupCounter(A){return fA(this,void 0,void 0,function*(){return this._handleCounterOperation(n,A)})}decreaseGroupCounter(A){return fA(this,void 0,void 0,function*(){return this._handleCounterOperation(r,A)})}_handleCounterOperation(A,e){return fA(this,void 0,void 0,function*(){const t=`${A}GroupCounter`;try{dA(t,i);const{groupID:n,key:r,value:s=0}=e,{avChatRoomKey:a}=RA.getLocalGroupCounters(n),g=A===o?this._convertObjectToList(e.counters):[{Key:r,Value:s}],c=yield this._updateGroupCounters({groupID:n,counterList:g,avChatRoomKey:a,mode:A});return RA.setGroupCounters(n,c),{code:0,data:{counters:c}}}catch(n){hA(t,n)}})}_updateGroupCounters(e){return fA(this,void 0,void 0,function*(){const t=yield function(e){const{groupID:t,counterList:i,mode:o,avChatRoomKey:n}=e,{common:r}=A.core,s={GroupId:t,GroupCounter:i,Mode:o,BytesKey:n};return r.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:s})}(e),{GroupCounter:i=[]}=t,o={};return i.forEach(A=>{const{Key:e,Value:t=0}=A;o[e]=t}),o})}_convertObjectToList(A){return Object.entries(A).map(([A,e])=>({Key:A,Value:e||0}))}},$A=new class{init(A){this._core=A,ZA.init(A),XA.init(A)}isGroupCounterUpdated(A){const{elements:{groupCounterInfo:e}}=A,{utils:{isEmpty:t}}=this._core;return!t(e)}handleGroupCounterUpdated(A){const{to:e,elements:{groupCounterInfo:t}}=A;t.forEach(A=>{const{type:t,groupCounterSeq:i,counterList:o=[]}=A;t!==s&&t!==g||this._processAndNotifyCounterUpdate(e,i,o),t===a&&RA.deleteLocalGroupCounters({groupID:e,groupCounterSeq:i,counterList:o})})}_processAndNotifyCounterUpdate(A,e,t){const{OuterEvent:i,notificationCenter:o}=this._core;RA.updateLocalGroupCounters({groupID:A,groupCounterSeq:e,counterList:t}),t.forEach(({Key:e,Value:t=0})=>{o.emitOuterEvent(i.GROUP_COUNTER_UPDATED,{name:i.GROUP_COUNTER_UPDATED,data:{groupID:A,key:e,value:t}})})}reset(){RA.reset()}},Ae=new class{constructor(){this._name="InitGroupAttributes"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(A){return fA(this,void 0,void 0,function*(){const{groupID:e,groupAttributes:t}=A,{serverMainSequence:i,avChatRoomKey:o}=wA.getGroupAttributesCache(e),n=wA.convertKeyValueMapToList(t);try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,mainSequence:i,groupAttributeList:o,avChatRoomKey:n}=A,r={GroupId:t,AttrMainSeq:i,GroupAttr:o,BytesKey:n,AttrControl:["RaceConflict"]};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:r})})}({groupID:e,avChatRoomKey:o,groupAttributeList:n,mainSequence:i},this._core),{AttrMainSeq:r,GroupAttr:s}=A||{},a=s.map(A=>{const{Key:e,seq:i}=A;return{key:e,value:t[e],sequence:i}});return wA.saveGroupAttributesCacheValuesCopy(e),wA.refreshGroupAttributesCache({groupID:e,serverMainSequence:r,groupAttributeList:a,operation:M}),wA.emitGroupAttributesUpdated(e),yA({groupAttributes:t},{message:` groupID:${e} serverMainSequence:${r}`})}catch(r){throw new this._core.helper.ChatError({functionName:"initGroupAttributes",code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo})}})}},ee=new class{constructor(){this._name="SetGroupAttributes"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(A){return fA(this,void 0,void 0,function*(){const{groupID:e,groupAttributes:t}=A,{serverMainSequence:i,avChatRoomKey:o,values:n}=wA.getGroupAttributesCache(e),r=wA.convertKeyValueMapToList(t).map(A=>{var e;const{key:t,value:i}=A;return{key:t,value:i,seq:(null===(e=n.get(A.key))||void 0===e?void 0:e.sequence)||0}});try{const A=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,mainSequence:i,groupAttributeList:o,avChatRoomKey:n}=A,r={GroupId:t,AttrMainSeq:i,GroupAttr:o,BytesKey:n,AttrControl:["RaceConflict"]};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:r})})}({groupID:e,avChatRoomKey:o,groupAttributeList:r,mainSequence:i},this._core),{AttrMainSeq:n,GroupAttr:s}=A||{},a=s.map(A=>{const{Key:e,seq:i}=A;return{key:e,value:t[e],sequence:i}});return wA.saveGroupAttributesCacheValuesCopy(e),wA.refreshGroupAttributesCache({groupID:e,serverMainSequence:n,groupAttributeList:a,operation:R}),wA.emitGroupAttributesUpdated(e),yA({groupAttributes:t},{message:` groupID:${e} serverMainSequence:${n}`})}catch(s){throw new this._core.helper.ChatError({functionName:"setGroupAttributes",code:null==s?void 0:s.errorCode,message:null==s?void 0:s.errorInfo})}})}},te=new class{constructor(){this._name="DeleteGroupAttributes"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(A){return fA(this,void 0,void 0,function*(){const e="deleteGroupAttributes",{groupID:t,keyList:i=[]}=A;try{let A;A=0===i.length?yield this._clearGroupAttributes(t):yield this._deleteGroupAttributes(t,i);const{resultList:o,serverMainSequence:n,operation:r,groupAttributeList:s}=A||{},a=`${this._name}.${e} ok. groupID:${t} operation: ${r}`;return wA.saveGroupAttributesCacheValuesCopy(t),wA.refreshGroupAttributesCache({groupID:t,serverMainSequence:n,groupAttributeList:s,operation:r}),wA.emitGroupAttributesUpdated(t),yA({keyList:o},{message:a})}catch(o){throw new this._core.helper.ChatError({functionName:e,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo})}})}_deleteGroupAttributes(A,e){return fA(this,void 0,void 0,function*(){const{serverMainSequence:t,avChatRoomKey:i,values:o}=wA.getGroupAttributesCache(A),n=[],r=[];e.forEach(A=>{if(o.has(A)){const{sequence:e=0}=o.get(A)||{};r.push({key:A,seq:e}),n.push(A)}});const s=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,mainSequence:i,groupAttributeList:o,avChatRoomKey:n}=A,r={GroupId:t,AttrMainSeq:i,GroupAttr:o,BytesKey:n,AttrControl:["RaceConflict"]};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:r})})}({groupID:A,avChatRoomKey:i,groupAttributeList:r,mainSequence:t},this._core),{AttrMainSeq:a}=s||{};return{resultList:n,serverMainSequence:a,groupAttributeList:r,operation:T}})}_clearGroupAttributes(A){return fA(this,void 0,void 0,function*(){const{serverMainSequence:e,avChatRoomKey:t,values:i}=wA.getGroupAttributesCache(A),o=[...i.keys()],n=yield function(A,e){return fA(this,void 0,void 0,function*(){const{groupID:t,mainSequence:i,avChatRoomKey:o}=A,n={GroupId:t,AttrMainSeq:i,BytesKey:o,AttrControl:["RaceConflict"]};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:n})})}({groupID:A,avChatRoomKey:t,mainSequence:e},this._core),{AttrMainSeq:r}=n||{};return{resultList:o,serverMainSequence:r,operation:_}})}},ie=new class{constructor(){this._name="GetGroupAttributes"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(A){return fA(this,void 0,void 0,function*(){const{groupID:e}=A,{avChatRoomKey:t,lastUpdateTime:i,localMainSequence:o,serverMainSequence:n}=wA.getGroupAttributesCache(e),{helper:{ChatError:r}}=this._core,s=`groupID:${e} localMainSequence:${o} serverMainSequence:${n} keyList:${A.keyList}`;if(Date.now()-i>=3e4||o{const{key:e,value:t,seq:i}=A;return{key:e,value:t,sequence:i}});return wA.refreshGroupAttributesCache({groupID:i,serverMainSequence:s,groupAttributeList:g,operation:N}),{serverGroupAttributeList:a}})}},oe=new class{init(A){A.ssoLog.debug("GroupAttribute.init"),Ae.init(A),ee.init(A),te.init(A),ie.init(A),wA.init(A)}isGroupAttributesUpdated(A){return wA.isGroupAttributesUpdated(A)}handleGroupAttributesUpdated(A){const{to:e,elements:{newGroupProfile:t}}=A,{groupAttributeOption:i}=t,{serverMainSequence:o,withChangedAttributeInfo:n}=i,{localMainSequence:r}=wA.getGroupAttributesCache(e),s=o-r;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${e} withChangedAttributeInfo:${n} diffSequence:${s}`),0!==s)if(wA.saveGroupAttributesCacheValuesCopy(e),1!==n||1!==s){if(wA.hasGroupAttributesCache(e)){const{avChatRoomKey:A}=wA.getGroupAttributesCache(e);ie.getGroupAttributesFromServer({groupID:e,avChatRoomKey:A}).then(()=>{wA.emitGroupAttributesUpdated(e)}).catch(()=>{})}}else wA.handleGroupAttributesUpdated({groupID:e,groupAttributeOption:i})}reset(){wA.reset()}};function ne(A,e="tips"){const{ClientSeq:t,From_Account:i,MsgClientTime:o,MsgPriority:n,MsgRandom:r,MsgSeq:s,MsgTimeStamp:a,TinyId:g,ToGroupId:c,GroupInfo:l,MsgBody:I}=A;return{clientSequence:t,from:i,clientTime:o,priority:n,random:r,sequence:s,time:a,tinyID:g,to:c,groupProfile:function(A){const{GroupCode:e,GroupId:t,GroupName:i,GroupType:o,MsgFrom_AccountExtraInfo:n,From_Account:r,To_Account:s}=A;return{groupCode:e,groupID:t,groupName:i,type:o,messageFromAccountExtraInformation:n,from:r,to:s}}(l),elements:"tips"===e?re(I):ae(I)}}function re(A){const e={};return Object.keys(A).forEach(t=>{var i,o;switch(t){case"MemberNum":e.memberCount=A[t];break;case"OpType":e.operationType=A[t];break;case"Operator_Account":e.operatorID=A[t];break;case"List_Account":e.userIDList=A[t];break;case"MsgMemberExtraInfo":e.memberInfoList=null===(i=A[t])||void 0===i?void 0:i.map(A=>se(A));break;case"MsgOperatorMemberExtraInfo":e.operatorInfo=se(A[t]);break;case"MsgGroupNewInfo":e.newGroupProfile=function(A){const e={};return Object.keys(A).forEach(t=>{switch(t){case"GroupIntroduction":e.introduction=A[t];break;case"GroupName":e.groupName=A[t];break;case"GroupFaceUrl":e.avatar=A[t];break;case"GroupNotification":e.notification=A[t];break;case"ApplyJoinOption":e.joinOption=A[t];break;case"InviteJoinOption":e.inviteOption=A[t];break;case"ShutupAll":e.muteAllMembers=A[t];break;case"Owner_Account":e.ownerID=A[t];break;case"GroupAttrOption":e.groupAttributeOption=function(A){const{BytesChangedKeys:e,GroupAttrSeq:t,OpType:i,PushChangedAttrValFlag:o,GroupAttrInfo:n}=A;return{changedKeyList:e,groupAttributeList:n.map(A=>{const{Key:e,Val:t,SubKeySeq:i}=A;return{key:e,value:t,sequence:i}}),serverMainSequence:t,operation:i,withChangedAttributeInfo:o}}(A[t])}}),e}(A[t]);break;case"MsgMemberInfo":e.msgMemberInfo=null===(o=A[t])||void 0===o?void 0:o.map(A=>function(A){const{ShutupTime:e,User_Account:t}=A;return{muteTime:e,userID:t}}(A));break;case"OnlineMemberInfo":e.onlineMemberInfo=function(A){const{ExpireTime:e,OnlineMemberNum:t}=A;return{expireTime:e,onlineMemberNum:t}}(A[t]);break;case"GroupCounterInfo":e.groupCounterInfo=A[t].map(A=>{const{GroupCounterSeq:e,GroupCounter:t,Type:i}=A;return{type:i,groupCounterSeq:e,counterList:t}})}}),e}function se(A){const{ImageUrl:e,NickName:t,Role:i,UserId:o}=A;return{avatar:e,nick:t,role:i,userID:o}}function ae(A){const e={};return Object.keys(A).forEach(t=>{switch(t){case"MsgKey":e.messageKey=A[t];break;case"Operator_Account":e.operatorID=A[t];break;case"ReportType":e.operationType=A[t];break;case"Authentication":e.authentication=A[t];break;case"MsgFlag":e.messageRemindType=A[t];break;case"UserDefinedField":e.userDefinedField=A[t];break;case"RemarkInfo":e.remarkInfo=A[t];break;case"BanDuration":e.duration=A[t];break;case"MuteTime":e.muteTime=A[t]}}),e}class ge{constructor(e){this.type=A.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(e)}static parseServerPushElement(A){const e=re(A);return new ge(e)}_initContent(A){Object.keys(A).forEach(e=>{switch(e){case"groupProfile":this._initGroupProfile(A[e]);break;case"operatorInfo":this._initOperatorInfo(A[e]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(A[e]);break;case"newGroupProfile":this._initNewGroupProfile(A[e]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[e]=A[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(A){this.content.groupProfile={};const e=Object.keys(A);for(let t=0;t{A.forEach(A=>{e.userID===A.userID&&Object.assign(e,A)})}):this.content.memberList=A}_initNewGroupProfile(A){this.content.newGroupProfile={};const e=Object.keys(A);for(let t=0;t0&&(o.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:t}),this._handleGroupTipMessage(t)),{conversationUpdateFieldList:i}}_handleGroupTips(A,e=!0){const{Event:t,GroupTips:i}=A,o=new Map,n=[],r=[];for(let s=0,a=i.length;s{const{operationType:t}=A.payload;switch(t){case e.JOINED:this._handleNewMemberJoined(A);break;case e.QUITTED:this._handleMemberQuitted(A);break;case e.KICKED:this._handleMemberKicked(A);break;case e.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(A)}})}_handleNewMemberJoined(A){this._handleGroupMemberCountUpdated(A)}_handleMemberQuitted(A){this._handleGroupMemberCountUpdated(A)}_handleMemberKicked(A){this._handleGroupMemberCountUpdated(A)}_handleGroupProfileUpdated(A){var e;const{newGroupProfile:t,groupProfile:i,operatorInfo:o}=A.payload,{groupID:n}=i,r=QA.getLocalGroup(n);Object.keys(t).forEach(A=>{switch(A){case"ownerID":this._handleGroupOwnerChanged(n,t);break;case"groupName":r.name=t[A];break;default:r[A]=t[A]}});const{utils:{isUndefined:s}}=this._core;s(o)||(null===(e=null==r?void 0:r.selfInfo)||void 0===e?void 0:e.userID)!==o.userID||Object.keys(o).forEach(A=>{"nameCard"===A&&r.updateSelfInfo({nameCard:o[A]}),"role"===A&&this._updateSelfRole(r,o[A])}),QA.emitGroupListUpdate(),QA.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(A,e){const{common:t,OuterConstant:i}=this._core,o=QA.getLocalGroup(A),n=t.getCurrentUserID(),{ownerID:r}=e;n===r&&o.updateGroup({ownerID:r,selfInfo:{role:i.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(A,e){const{OuterConstant:t}=this._core;let i=t.GRP_MBR_ROLE_MEMBER;e===U?i=t.GRP_MBR_ROLE_OWNER:e===F&&(i=t.GRP_MBR_ROLE_ADMIN),A.updateSelfInfo({role:i})}_handleGroupMemberCountUpdated(A){const{memberCount:e,groupProfile:{groupID:t}}=A.payload,i=QA.getLocalGroup(t),{utils:{isNumber:o}}=this._core;i&&o(e)&&i.memberCount!==e&&(i.memberCount=e,QA.emitGroupListUpdate(),QA.updateConversationGroupProfile(t))}_handleGroupTipsRecover(A){const{utils:{isArray:e}}=this._core,{groupTipList:t}=(null==A?void 0:A.result)||{};e(t)&&t.forEach(A=>{const{messageList:e}=this._handleGroupTips({Event:A.Event,GroupTips:[A]},!1);this._handleGroupTipMessage(e)})}};class le{constructor(e){this.type=A.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}static parseServerPushElement(A){const e=ae(A);return new le(e)}_initContent(A){Object.keys(A).forEach(e=>{switch(e){case"remarkInfo":this.content.handleMessage=A[e];break;case"groupProfile":this._initGroupProfile(A[e]);break;case"memberInfoList":break;default:this.content[e]=A[e]}})}_initGroupProfile(A){this.content.groupProfile={};const e=Object.keys(A);for(let t=0;t0&&this._handleGroupSysTemMessage(t,o),!0===t&&o.length>0&&n.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:o})}_handleGroupSystemNotification(A,e){const t=[];let i={};for(let o=0;o0?[i]:[],messageList:t}}_assembleMessage(A){const{message:{messageFactory:e},OuterConstant:t,utils:{randomInt:i}}=this._core;A.flow="in",A.conversationType=t.CONV_SYSTEM,A.conversationSubType=A.groupProfile.type,A.conversationID=t.CONV_SYSTEM;const o=e.createMessage(A),n=new le(Object.assign(Object.assign({},A.elements),{groupProfile:Object.assign({},A.groupProfile)}));o.setElement(n),o.isSystemMessage=!0;const r=1===o.sequence&&1===o.random,s=2===o.sequence&&2===o.random;return(r||s)&&(o.sequence=i(),o.random=i(),o.generateMessageID()),o}_handleConversationOptions(A,e){const{OuterConstant:t}=this._core,i={conversationID:t.CONV_SYSTEM,unreadCount:0,type:t.CONV_SYSTEM,subType:A.conversationSubType,lastMessage:null};return e&&i.unreadCount++,i}_handleGroupSysTemMessage(A,e){A&&e.forEach(A=>{const{operationType:e}=A.payload;switch(e){case P:this._handleGroupJoinResult(A);break;case Y:this._handleMemberKicked(A);break;case J:this._handleGroupDismissed(A);break;case H:this._handleGroupInvitedResult(A);break;case q:this._handleGroupQuitResult(A);break;case j:this._handleMessageRemindTypeSynced(A);break;case K:this._handleAVChatRoomMemberBanned(A)}})}_handleGroupJoinResult(A){const{groupProfile:e}=A.payload,{groupID:t,type:i}=e,o=QA.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupJoinResult",` groupID:${t} type:${i} hasLocalGroup:${o}`),o||lA(i)||(QA.updateLocalGroup([Object.assign({},e)]),QA.emitGroupListUpdate())}_handleMemberKicked(A){const{groupProfile:{groupID:e,type:t}}=A.payload;QA.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupDismissed(A){const{groupProfile:{groupID:e,type:t}}=A.payload;QA.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupInvitedResult(A){const{groupProfile:e}=A.payload,{groupID:t}=e,i=QA.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupInvitedResult",` groupID:${t} hasLocalGroup:${i}`),i||MA.getGroupProfile({groupID:t}).then(A=>{const{data:{group:e}}=A;QA.updateLocalGroup([Object.assign({},e)]),QA.emitGroupListUpdate()})}_handleGroupQuitResult(A){const{groupProfile:{groupID:e,type:t}}=A.payload,i=QA.hasLocalGroup(e);this._core.ssoLog.debug("_handleGroupQuitResult",` groupID:${e} type:${t} hasLocalGroup:${i}`),i&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleMessageRemindTypeSynced(A){const{groupProfile:{groupID:e},messageRemindType:t}=A.payload;this._updateConversationProfile(e,{messageRemindType:t})}_handleAVChatRoomMemberBanned(A){const{groupProfile:{groupID:e,type:t}}=A.payload;this._deleteLocalGroup(e,t)}_deleteLocalGroup(A,e){if(lA(e)){const{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core;e.deleteConversation(`${t}${A}`)}QA.deleteLocalGroup(A),QA.emitGroupListUpdate()}_updateConversationProfile(A,e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:i}}=this._core,o=`${i}${A}`;t.getConversation(o)&&t.updateConversation(o,e)}},ue=new class{init(A){this._core=A,A.ssoLog.debug("GroupNotificationHandler.init"),ce.init(A),Ie.init(A);const{notificationCenter:e,InnerEvent:t}=A,{InnerEventSubType:i}=e;e.subscribeInnerEvent(t.MESSAGE_PUSH,i.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.subscribeInnerEvent(t.MESSAGE_PUSH,i.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(A){const{common:{workflowManager:e},constants:{WORKFLOW_NAME:t}}=this._core;e.executeWorkflow(t.RECEIVE_GROUP_TIPS_NOTIFICATION,A)}_onNewGroupSystemNotification(A){Ie.onNewGroupSystemNotification(A)}_dispose(){const{notificationCenter:A,InnerEvent:e}=this._core,{InnerEventSubType:t}=A;A.unSubscribeInnerEvent(e.MESSAGE_PUSH,t.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),A.unSubscribeInnerEvent(e.MESSAGE_PUSH,t.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};const Ee={required:!0,rules:["string"],allowEmpty:!1},de={required:!0,rules:["number"],allowEmpty:!1},he={required:!0,rules:["array"],allowEmpty:!1},Ce={required:!0,rules:["object"],allowEmpty:!1},Be={createGroup:{name:Ee,type:Ee},dismissGroup:[Object.assign({key:"groupID"},Ee)],joinGroup:{groupID:Ee,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},Ee)],searchGroupByID:[Object.assign({key:"groupID"},Ee)],getGroupProfile:{groupID:Ee,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:Ee,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:Ee,newOwnerID:Ee},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},Ee)],handleGroupApplication:{handleAction:Ee},getGroupMemberList:{groupID:Ee},getGroupMemberProfile:{groupID:Ee,userIDList:he,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:Ee,userIDList:he},deleteGroupMember:{groupID:Ee,userIDList:he},setGroupMemberMuteTime:{groupID:Ee,userID:Ee,muteTime:Object.assign(Object.assign({},de),{customValidator:A=>!(A<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:Ee,userID:Ee,role:Ee},setGroupMemberNameCard:{groupID:Ee,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:Ee},setGroupMemberCustomField:{groupID:Ee,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:he},markGroupMemberList:{groupID:Ee,markType:Object.assign(Object.assign({},de),{customValidator:A=>!(A<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:he},initGroupAttributes:{groupID:Ee,groupAttributes:Ce},setGroupAttributes:{groupID:Ee,groupAttributes:Ce},deleteGroupAttributes:{groupID:Ee,keyList:Object.assign(Object.assign({},he),{allowEmpty:!0})},getGroupAttributes:{groupID:Ee,keyList:Object.assign(Object.assign({},he),{allowEmpty:!0})},getGroupCounters:{groupID:Ee,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:Ee,counters:Ce},increaseGroupCounter:{groupID:Ee,key:Ee,value:de},decreaseGroupCounter:{groupID:Ee,key:Ee,value:de}},Qe={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};return new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=QA,this.groupAction=LA,this.groupAttribute=oe,this.groupMember=zA,this.name="Group"}install(e,t=[]){this._core=e,A.init(e),QA.init(e),LA.init(e,this),zA.init(e,this),OA.init(e),$A.init(e),oe.init(e),ue.init(e),e.helper.registerValidateConfig({auth:Qe,params:Be}),this._installSubPlugins(t);const{notificationCenter:i,InnerEvent:o}=e;i.subscribeInnerEvent(o.LOGOUT,this._reset,this),i.subscribeInnerEvent(o.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(A){const{utils:{isArray:e}}=this._core;A&&e(A)&&A.forEach(A=>{var e;this._installedSubPlugins.includes(A.name)||(null===(e=A.install)||void 0===e||e.call(A,this._core,this),this._installedSubPlugins.push(A.name))})}_reset(){QA.reset(),oe.reset(),$A.reset()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}}}();const i_=RR(t_.exports);var o_={exports:{}};o_.exports=function(){const A=new class{init(A){this.core=A}};function e(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o-1&&clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),A))}stop(){console.log(`${this._name}.stop timerID:${this._timeoutID}`),this._timeoutID>-1&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}class u{constructor(A){this._maxLength=A,this._map=new Map}set(A){var e;if(this._map.size>=this._maxLength){const A=(null===(e=this._map.entries().next().value)||void 0===e?void 0:e[0])||"";this._map.delete(A)}this._map.set(A,1)}has(A){return this._map.has(A)}delete(A){this.has(A)&&this._map.delete(A)}clear(){this._map.clear()}}const E=A=>A===n.GROUP_TIPS_HAS_NO_ROAMING||A===n.GROUP_TIPS_HAS_ROAMING,d=A=>A===n.GROUP_SYSTEM_MESSAGE;function h(t){const i=function(A){const{E:t,MCT:i,MR:o,MP:n,MTS:r,GId:s,MS:a,CCD:g,F_Account:c,IsSys:l,GInf:I,MsgBody:u}=A,E=e(A,["E","MCT","MR","MP","MTS","GId","MS","CCD","F_Account","IsSys","GInf","MsgBody"]);return Object.assign({Event:t,MsgClientTime:i,MsgRandom:o,MsgPriority:n,MsgTimeStamp:r,ToGroupId:s,MsgSeq:a,CloudCustomData:g,From_Account:c,IsSystemMsg:l,GroupInfo:C(I),MsgBody:B(u)},E)}(t);return function(e){const{Event:t}=e;(E(t)||d(t))&&(e.From_Account=e.From_Account||"@TIM#SYSTEM"),(t===n.BROADCAST_MESSAGE||t===n.NORMAL_MESSAGE)&&function(e){const{core:{OuterConstant:t}}=A;e.CloudCustomData=e.CloudCustomData||"",e.MsgBody=e.MsgBody.map(A=>{if(A.MsgType===t.MSG_CUSTOM){const{content:e={}}=A;A.content=Object.assign({Data:"",Desc:"",Ext:""},e)}return A})}(e),E(t)&&function(A){const{GroupJoinType:e,MsgOperatorMemberExtraInfo:t={},MsgMemberExtraInfo:i,Operator_Account:o,List_Account:n,OpType:r}=A.MsgBody||{};"number"==typeof e||1!==r&&2!==r||(A.MsgBody.GroupJoinType=2===r?0:1),i||(A.MsgBody.MsgMemberExtraInfo=null==n?void 0:n.map(A=>({UserId:A}))),1!==r||i||(A.MsgBody.MsgMemberExtraInfo=[{UserId:t.UserId}]),A.MsgBody.MsgOperatorMemberExtraInfo=Object.assign({Operator_Account:o,ImageUrl:"",NickName:""},t)}(e),d(t)&&function(A){const{MsgOperatorMemberExtraInfo:e={},Operator_Account:t}=A.MsgBody||{};A.MsgBody.MsgMemberExtraInfo=Object.assign({UserId:t,ImageUrl:"",NickName:""},e),A.MsgBody=Object.assign({Authentication:"",RemarkInfo:"",MsgKey:1e3*A.MsgTimeStamp},A.MsgBody),A.MsgBody=Object.keys(A.MsgBody).filter(A=>"MsgOperatorMemberExtraInfo"!==A).reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:A.MsgBody[t]}),{})}(e)}(i),i}function C(A){const t=A||{},{GN:i,GT:o,F_Hd:n,F_NN:r,F_Ll:s}=t,a=e(t,["GN","GT","F_Hd","F_NN","F_Ll"]),g=Object.assign({GroupName:i,GroupType:o},a);return n&&(g.From_AccountHeadurl=n),r&&(g.From_AccountNick=r),s&&(g.From_AccountLevel=s),g}function B(A){let t=A;Array.isArray(A)||(t=[A]);const i=t.map(A=>{const{O_Account:t,Opt:i,L_Account:o,RT:n,UDF:r,OpInf:s,OnlineInf:a,MsgMemberExtraInfo:g}=A,c=e(A,["O_Account","Opt","L_Account","RT","UDF","OpInf","OnlineInf","MsgMemberExtraInfo"]),l=Object.assign({Operator_Account:t,OpType:i,List_Account:o,ReportType:n,UserDefinedField:r},c);return s&&(l.MsgOperatorMemberExtraInfo=function(A){const{Img:t,NN:i}=A,o=e(A,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:i},o)}(s)),g&&(l.MsgMemberExtraInfo=null==(I=g)?void 0:I.map(A=>{const{Img:t,NN:i}=A,o=e(A,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:i},o)})),a&&(l.OnlineMemberInfo=function(A){const{ET:e,Num:t}=A;return{ExpireTime:e,OnlineMemberNum:t}}(a)),l;var I});return Array.isArray(A)?i:i[0]}var Q=new class{constructor(){this._name="MessageParser",this._sequenceList=new u(200),this._messageIDList=new u(100),this._broadcastMessageIDMap=new Map,this._reportMessageStackedCount=0}init(A,e){this._core=A,this._avChatRoomHandler=e}onMessageReceived(e,t,i=!1){this._sortServerMessageList({groupID:e,serverMessageList:t,isHistoryMessage:i});const o=this._handleMessageList(e,t);if(0===o.length)return;if(!i){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:i}}=this._core,n=(e=>{const{core:{common:{getMessagePreviewText:t}}}=A;return{lastTime:(null==e?void 0:e.time)||(null==e?void 0:e.lastTime)||0,lastSequence:(null==e?void 0:e.sequence)||(null==e?void 0:e.lastSequence)||0,fromAccount:(null==e?void 0:e.from)||(null==e?void 0:e.fromAccount)||"",messageForShow:t(null==e?void 0:e.type,null==e?void 0:e.payload),payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",onlineOnlyFlag:(null==e?void 0:e._onlineOnlyFlag)||!1,nick:(null==e?void 0:e.nick)||"",nameCard:(null==e?void 0:e.nameCard)||"",version:(null==e?void 0:e.version)||0,isPeerRead:(null==e?void 0:e.isPeerRead)||!1,revoker:(null==e?void 0:e.revoker)||null}})(o[o.length-1]);t.updateConversation(`${i}${e}`,{lastMessage:n})}this._checkMessageStacked(o);const n=o.filter(A=>!0===A.isModified),r=o.filter(A=>!1===A.isModified),{OuterEvent:{MESSAGE_RECEIVED:s,MESSAGE_MODIFIED:a}}=this._core;n.length>0&&this._emitEvent({name:a,data:n}),r.length>0&&this._emitEvent({name:s,data:r})}_sortServerMessageList(A){const{groupID:e,serverMessageList:t,isHistoryMessage:i}=A;let o=[];this._avChatRoomHandler.isPollingSimplifiedMessage()&&!i?(t.sort((A,e)=>A.MS-e.MS),o=t.map(A=>A.MS)):(t.sort((A,e)=>A.MsgSeq-e.MsgSeq),o=t.map(A=>A.MsgSeq)),console.log(`${this._name}._sortServerMessageList groupID:${e} count:${o.length} sequenceList:${o}`),o.length=0}_handleMessageList(A,e){const{message:{messageDataHandler:t,messageHelper:i}}=this._core,o=this._avChatRoomHandler.isPollingSimplifiedMessage(),n=[],s=e.length;for(let a=0;aA===n.LIVE_CUSTOM_DATA)(e)?(this._onLiveCustomData(A),null):(A=>A===n.MESSAGE_REACTION)(e)?null:A:(console.warn(`${this._name}.onMessageReceived unknown event:${e}`),null)}_createMessage(A){const{message:{messageFactory:e},OuterConstant:t}=this._core;let i=t.CONV_GROUP;A.event===n.GROUP_SYSTEM_MESSAGE&&(i=t.CONV_SYSTEM);const o=!!A.isSystemMessage,r=e.createMessage(Object.assign(Object.assign({},A),{conversationType:i,isSystemMessage:o,flow:"in"}));return r.setElement(A.elements),r}_filterDuplicateMessage(A){const{common:e}=this._core;if(!e.isUnlimitedAVChatRoom()){if(this._sequenceList.has(A.sequence))return null;this._sequenceList.set(A.sequence)}const t=this._messageIDList.has(A.ID);return t?(console.warn(`${this._name}_filterDuplicateMessageItem ID:${A.ID} has:${t}`),null):(this._messageIDList.set(A.ID),A)}_handleMessageRevoked(A){const{OuterConstant:e,OuterEvent:{MESSAGE_REVOKED:t}}=this._core,{ToGroupId:i,MsgBody:{RevokeMsgList:o},RevokerInfo:{Revoker_Account:n,Reason:r=""}}=A,s=[];o.forEach(A=>{const{TinyId:t,MsgClientTime:o,Random:a,MsgSeq:g}=A,c={conversationID:`${e.CONV_GROUP}${i}`,ID:`${t}-${o}-${a}`,revoker:n,revokeReason:r,revokerInfo:{userID:n,nick:"",avatar:""},sequence:g};s.push(c)}),0!==s.length&&this._emitEvent({name:t,data:s})}_onLiveCustomData(A){const{OuterEvent:{ROOM_CUSTOM_DATA_RECEIVED:e}}=this._core,{ToGroupId:t,MsgSeq:i,MsgTimeStamp:o,MsgBody:n}=A,r=(null==n?void 0:n.Content)||(null==n?void 0:n.MsgContent)||"";this._emitEvent({name:e,data:r}),console.log(`${this._name}._onLiveCustomData groupID:${t} sequence:${i} time:${o} data:${r}`)}_onGroupDismissed(A){this._avChatRoomHandler.reset(A)}_checkMessageStacked(A){const{length:e}=A;if(e>=100&&this._reportMessageStackedCount<5){const A=this._avChatRoomHandler.getJoinedGroups();this._core.ssoLog.info("MessageStacked",`count:${e} groupID:${A.join(",")}`),this._reportMessageStackedCount+=1}}_emitEvent(A){this._core.notificationCenter.emitOuterEvent(A.name,A)}onBroadcastMessageReceived(A){const{message:{messageHelper:e},OuterEvent:{MESSAGE_RECEIVED:t}}=this._core,i=this._avChatRoomHandler.isPollingSimplifiedMessage(),o=[],r=A.length;for(let s=0;s0&&this._emitEvent({name:t,data:o})}_updateLocalOnlineMemberCountFromTips(A){const{utils:{isEmpty:e}}=this._core,{ToGroupId:t,MsgBody:{OnlineMemberInfo:i}}=A;if(e(i))return;const{OnlineMemberNum:o=0,ExpireTime:n=s}=i,r=Date.now();let a=this._avChatRoomHandler.getLocalOnlineMemberCount(t);e(a)?a={lastReqTime:0,lastSyncTime:0,latestUpdateTime:r,memberCount:o,expireTime:n}:(a.latestUpdateTime=r,a.memberCount=o),this._avChatRoomHandler.updateLocalOnlineMemberCount(t,a)}reset(){this._reportMessageStackedCount=0,this._sequenceList.clear(),this._messageIDList.clear(),this._broadcastMessageIDMap.clear()}};const p=e=>{const{core:{store:t}}=A;return(t.get("cloudConfig")||{})[e]},f=e=>{const{core:{utils:{isUndefined:t}}}=A;return!t(e)},m=()=>{const A=p("polling_interval");return f(A)?parseInt(A,10):300},y=()=>{const A=p("polling_simplified_msg");return f(A)?parseInt(A,10):0};var D=new class{constructor(){this._name="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._onlineMemberCountMap=new Map,this._pollingIntervalMap=new Map,this._pollingNoMessageCountMap=new Map,this._membersReqInfoMap=new Map,this._startBroadcastSequence=1}init(A,e){this._core=A,this._parentPlugin=e,Q.init(A,this),A.ssoLog.debug("AVChatRoomHandler.init")}onAVChatRoomSystemNotification(A){const{OuterConstant:{GRP_AVCHATROOM:e}}=this._core,{GroupTips:t=[]}=A;for(let i=0;i0&&(e=[...this._joinedGroupMap.values()].filter(e=>e.type===A)),e}handleJoinGroupResult(A){return t(this,void 0,void 0,function*(){const{utils:{isUndefined:e},OuterConstant:{CONV_GROUP:t},apiMap:{getConversationProfile:i},OuterConstant:o}=this._core,{longPollingKey:n,group:r,historyMessageList:s=[]}=A,{groupID:a}=r;return yield this._preCheck(r),this._joinedGroupMap.set(a,r),this._parentPlugin.groupDataHandler.updateLocalGroup([r]),this._parentPlugin.groupDataHandler.emitGroupListUpdate(),i(`${t}${a}`),s.length>0&&Q.onMessageReceived(a,s,!0),e(n)?{code:0,data:{status:o.JOIN_STATUS_SUCCESS,group:r}}:{code:0,data:this.startMessageLongPolling(A)}})}_preCheck(A){return t(this,void 0,void 0,function*(){const{common:e,OuterConstant:t,helper:i,apiMap:{quitGroup:o},ssoLog:n}=this._core;if(e.isUnlimitedAVChatRoom()){if(this._pollingInstanceMap.size>(()=>{const A=p("polling_count_limit");return f(A)&&A>0?parseInt(A,10):20})())throw new i.ChatError({code:c,message:"the count of longPolling exceeds the max limit"});return}if(0===this._joinedAVChatRoomCount())return;if(A.type===t.GRP_LIVE)return;const[r,s]=this._joinedGroupMap.entries().next().value;if(s.selfInfo.role===t.GRP_MBR_ROLE_OWNER)this._parentPlugin.groupDataHandler.deleteLocalGroup(r);else try{yield o(r)}catch(a){n.debug("quitGroup",`${this._name}._preCheck quitGroup failed, groupID:${r} info:`,a)}this.reset(r)})}startMessageLongPolling(A){const{OuterConstant:e}=this._core,{longPollingKey:t,startSequence:i=1,group:o}=A,{groupID:n}=o;return this._pollingRequestInfoMap.set(n,{longPollingKey:t,startSequence:i}),this._pollingIntervalMap.set(n,m()),this._startPolling(n),this._reportLongPollingCount(),{status:e.JOIN_STATUS_SUCCESS,group:o}}_startPolling(A){if(this._core.ssoLog.debug("_startPolling",`${this._name}._startPolling groupID:${A}`),this._pollingInstanceMap.has(A)){const e=this._pollingInstanceMap.get(A);return void((null==e?void 0:e.isRunning())||null==e||e.start())}const e=new I({core:this._core,manager:this,groupID:A,getRequestParams:this._handleRequestParams.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});e.start(),this._pollingInstanceMap.set(A,e)}_handleRequestParams(A){const{longPollingKey:e,startSequence:t}=this._pollingRequestInfoMap.get(A)||{};return A===[...this._pollingInstanceMap.keys()][0]?{longPollingKey:e,startSequence:t,startBroadcastSeq:this._startBroadcastSequence,simplifiedMessage:y()}:{longPollingKey:e,startSequence:t,simplifiedMessage:y()}}_handleSuccess(A,e){const{ErrorCode:t}=e;if(0===t)this._hasJoinedAVChatRoom(A)&&this._handleResponseData(A,e);else{const{longPollingKey:e,startSequence:i}=this._pollingRequestInfoMap.get(A)||{};console.warn(`${this._name}._handleSuccess groupID:${A} key:${e} startSeq:${i} errorCode:${t}`)}}_handleResponseData(A,e){const{Key:t,NextSeq:i,NextBroadcastSeq:o,RspMsgList:n=[],RspBroadcastMsgList:r=[]}=e;if(t&&i&&this._pollingRequestInfoMap.set(A,{longPollingKey:t,startSequence:i}),o&&o>this._startBroadcastSequence&&(this._startBroadcastSequence=o),n.length>0)0!==this._getPollingNoMessageCount(A)&&(this._updatePollingNoMessageCount(A,0),this._pollingIntervalMap.set(A,m())),Q.onMessageReceived(A,n);else{let e=this._getPollingNoMessageCount(A);if(e+=1,this._updatePollingNoMessageCount(A,e),e===(()=>{const A=p("polling_no_msg_count");return f(A)?parseInt(A,10):20})()){const e=m()+(()=>{const A=p("polling_interval_plus");return f(A)?parseInt(A,10):2e3})();this._pollingIntervalMap.set(A,e)}}r.length>0&&Q.onBroadcastMessageReceived(r)}_handleFailure(A,e){const{ssoLog:t,utils:{safeStringify:i}}=this._core;t.warn("polling",`${this._name}._handleFailure groupID:${A} error: ${i(e)}`)}_joinedAVChatRoomCount(){const{OuterConstant:A}=this._core;let e=[];return this._joinedGroupMap.size>0&&(e=this.getJoinedGroups().filter(e=>e.type===A.GRP_AVCHATROOM)),e.length}_hasJoinedAVChatRoom(A){return this._joinedGroupMap.has(A)}getJoinedGroups(){return[...this._joinedGroupMap.values()]}updateLocalLiveGroup(A,e){this._joinedGroupMap.set(A,e),this._parentPlugin.groupDataHandler.updateLocalGroup([e])}handleLiveHistoryMessages(A,e){Q.onMessageReceived(A,e,!0)}isOverFrequencyLimit(A){if(!this._membersReqInfoMap.has(A))return this._membersReqInfoMap.set(A,{startTime:Date.now(),requestCount:1}),!1;let{startTime:e,requestCount:t}=this._membersReqInfoMap.get(A);const{interval:i,count:o}=(()=>{const A=p("av_members_freq_limit");if(f(A)){const{interval:e,count:t}=JSON.parse(A);if(t>0&&e>0)return{interval:e,count:t}}return{interval:30,count:4}})();return Date.now()-e>1e3*i?(this._membersReqInfoMap.set(A,{startTime:Date.now(),requestCount:1}),!1):(t+=1,this._membersReqInfoMap.set(A,{startTime:e,requestCount:t}),t>o)}_stopPolling(A){if(this._core.ssoLog.debug("_stopPolling",`${this._name}._stopPolling groupID:${A}`),A){const{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core;e.deleteConversation(`${t}${A}`);const i=this._pollingInstanceMap.get(A);return null==i||i.stop(),this._parentPlugin.groupDataHandler.deleteLocalGroup(A),this._pollingInstanceMap.delete(A),this._pollingRequestInfoMap.delete(A),this._joinedGroupMap.delete(A),this._onlineMemberCountMap.delete(A),this._pollingIntervalMap.delete(A),this._pollingNoMessageCountMap.delete(A),void this._membersReqInfoMap.delete(A)}for(const e of this._pollingInstanceMap.values())null==e||e.stop();this._pollingInstanceMap.clear(),this._pollingRequestInfoMap.clear(),this._joinedGroupMap.clear(),this._onlineMemberCountMap.clear(),this._pollingIntervalMap.clear(),this._pollingNoMessageCountMap.clear(),this._membersReqInfoMap.clear()}_updatePollingNoMessageCount(A,e){this._pollingNoMessageCountMap.set(A,e)}_getPollingNoMessageCount(A){return this._pollingNoMessageCountMap.get(A)||0}_reportLongPollingCount(){const A=this._joinedGroupMap.size;if(A>1){const{common:e,OuterConstant:t,ssoLog:i}=this._core,o=e.isUnlimitedAVChatRoom()?1:0,n=[],r=[];this._joinedGroupMap.values().forEach(({groupID:A,type:e})=>{e===t.GRP_LIVE?r.push(A):n.push(A)}),i.info("longPollingCount",String(A),{moreMessage:`av:${n.join(",")} live:${r.join(",")} code: ${o}`,eventType:29})}}reset(A){this._stopPolling(A),this._startBroadcastSequence=1,Q.reset()}},v=new class{init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"joinGroup",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}joinGroup(A){return t(this,void 0,void 0,function*(){const{OuterConstant:e}=this._core,t=yield this._parentPlugin.groupAction.joinGroup(A),{data:{status:i,group:{type:o}}}=t;return o===e.GRP_AVCHATROOM?i===e.JOIN_STATUS_ALREADY_IN_GROUP?t:D.handleJoinGroupResult(t.data):t})}},w=new class{init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"quitGroup",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}quitGroup(A){return t(this,void 0,void 0,function*(){const{OuterConstant:e}=this._core,t=yield this._parentPlugin.groupAction.quitGroup(A),{data:{type:i}}=t;return i===e.GRP_AVCHATROOM&&D.reset(A),t})}},S=new class{init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"dismissGroup",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}dismissGroup(A){return t(this,void 0,void 0,function*(){const{OuterConstant:e}=this._core,t=yield this._parentPlugin.groupAction.dismissGroup(A),{data:{type:i}}=t;return i===e.GRP_AVCHATROOM&&D.reset(A),t})}},M=new class{constructor(){this._name="GetAVChatRoomMemberList"}init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}getGroupMemberList(A){return t(this,void 0,void 0,function*(){const{appStore:{groupStore:e},helper:t,OuterConstant:o}=this._core,{groupID:n}=A,r=e.getGroup(n);if((null==r?void 0:r.type)===o.GRP_AVCHATROOM&&t.checkBusinessCapabilityBits(i)){if(D.isOverFrequencyLimit(n))throw{code:2996,message:`Over frequency limit: get_members-${n}`};return this._getGroupMemberList(A)}return this._parentPlugin.groupMember.getGroupMemberList(A)})}_getGroupMemberList(A){return t(this,void 0,void 0,function*(){const e="_getGroupMemberList",{helper:i}=this._core;try{const i=yield function(A,e){return t(this,void 0,void 0,function*(){const{groupID:t,offset:i=0}=A,o={GroupId:t,Timestamp:i};return e.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.get_members",data:o})})}(A,this._core),{MemberList:o=[],NextTimestamp:n=0}=i||{},r=this._handleMemberList(o);return console.log(`${this._name}.${e} ok, groupID:${A.groupID} count:${r.length} nextOffset:${n}`),{code:0,data:{memberList:r,offset:n}}}catch(o){const A=new i.ChatError({functionName:e,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo});throw console.error(`${this._name}.${e} fail:`,A),A}})}_handleMemberList(A){return A.map(A=>{const{Member_Account:e,NickName:t="",Avatar:i="",Remark:o="",JoinTime:n=0,Marks:r=[]}=A;return{userID:e,nick:t,avatar:i,remark:o,joinTime:n,marks:r,isOnline:!0}})}},R=new class{constructor(){this._name="GetAVChatRoomOnlineMemberCount"}init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}getGroupOnlineMemberCount(A){return t(this,void 0,void 0,function*(){const{appStore:{groupStore:e},OuterConstant:t}=this._core,i=e.getGroup(A);return i?i.type===t.GRP_AVCHATROOM?this._getOnlineMemberCount(A):this._parentPlugin.groupAction.getGroupOnlineMemberCount(A):{code:0,data:{memberCount:0}}})}_getOnlineMemberCount(A){return t(this,void 0,void 0,function*(){const e="_getOnlineMemberCount",{utils:{isEmpty:t}}=this._core,i=D.getLocalOnlineMemberCount(A);if(t(i)||this._isExpired(A)){const{memberCount:t=0}=yield this._getOnlineMemberCountFromServer(A);return console.log(`${this._name}.${e} ok, groupID:${A} memberCount:${t} from server.`),{code:0,data:{memberCount:t}}}return console.log(`${this._name}.${e} ok, groupID:${A} memberCount:${i.memberCount} from local.`),{code:0,data:{memberCount:i.memberCount}}})}_isExpired(A){const e=D.getLocalOnlineMemberCount(A),t=Date.now(),i=t-e.lastSyncTime>1e3*e.expireTime,o=t-e.latestUpdateTime>1e4,n=t-e.lastReqTime>3e3;return i&&o&&n}_getOnlineMemberCountFromServer(A){return t(this,void 0,void 0,function*(){const e="_getOnlineMemberCountFromServer";try{const e=yield function(A,e){return t(this,void 0,void 0,function*(){const t={GroupId:A};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:t})})}(A,this._core),{OnlineMemberNum:i=0,ExpireTime:o=s}=e||{},n=Date.now(),r={lastSyncTime:n,latestUpdateTime:n,lastReqTime:n,memberCount:i,expireTime:o};return D.updateLocalOnlineMemberCount(A,r),{memberCount:i}}catch(i){const A=new this._core.helper.ChatError({functionName:e,code:null==i?void 0:i.errorCode,message:null==i?void 0:i.errorInfo});throw console.error(`${this._name}.${e} fail:`,A),A}})}},_=new class{constructor(){this._name="DeleteAVChatRoomMember"}init(A,e){this._core=A,this._parentPlugin=e;const{helper:t}=A;t.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>e.getInstalledSubPlugins().length>0})}deleteGroupMember(A){return t(this,void 0,void 0,function*(){const e="deleteGroupMember",{appStore:{groupStore:t},utils:{isUndefined:i},helper:n,OuterConstant:r}=this._core,{groupID:s}=A,g=t.getGroup(s);if(i(g))throw new n.ChatError({functionName:e,code:a});if(g.type===r.GRP_AVCHATROOM){if(n.checkBusinessCapabilityBits(o))return this._deleteGroupMember(A);throw new n.ChatError({functionName:e,code:l})}return this._parentPlugin.groupMember.deleteGroupMember(A)})}_deleteGroupMember(A){return t(this,void 0,void 0,function*(){const e="_deleteGroupMember",{appStore:{groupStore:i},helper:o,ssoLog:n}=this._core,{groupID:r,duration:s=0,userIDList:a}=A;if(0===s)throw new o.ChatError({functionName:e,code:g});try{return yield function(A,e){return t(this,void 0,void 0,function*(){const{groupID:t,userIDList:i,duration:o,reason:n}=A,r={GroupId:t,Members_Account:i,Duration:o,Description:n};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.ban_group_member",data:r})})}(A,this._core),n.debug(e,`${this._name}.${e} ok, groupID:${r}`),{code:0,data:{group:i.getGroup(r),userIDList:a}}}catch(c){throw new o.ChatError({functionName:e,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo})}})}},T=new class{constructor(){this._name="MarkAVChatRoomMember"}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"markGroupMemberList",context:this})}markGroupMemberList(A){return t(this,void 0,void 0,function*(){const e="markGroupMemberList",{groupID:i,markType:o,enableMark:n,userIDList:r=[]}=A,s=this._generateRequestData(A);try{const A=yield function(A,e){return t(this,void 0,void 0,function*(){const{groupID:t,operationType:i,memberList:o}=A,n={GroupId:t,CommandType:i,MemberList:o};return e.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.modify_user_info",data:n})})}(s,this._core),{MemberList:a=[]}=A||{},{successUserIDList:g,failureUserIDList:c}=this._handleResult(a,r);return{code:0,data:{successUserIDList:g,failureUserIDList:c},successLog:{message:`${this._name}.${e} ok, groupID:${i} markType:${o} enableMark:${n} success:${g.length} fail:${c.length}`}}}catch(a){throw new this._core.helper.ChatError({functionName:e,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}_generateRequestData(A){const{groupID:e,markType:t,enableMark:i,userIDList:o=[]}=A,n=!0===i?1:2,r=[...o];return r.length>500&&console.warn(`${this._name}._generateRequestData, the length of userIDList cannot exceed 500`),{groupID:e,operationType:n,memberList:r.map(A=>({Member_Account:A,Marks:[t]}))}}_handleResult(A,e){const t=[],i=[];return A.length===e.length?(t.push(...e),{successUserIDList:t,failureUserIDList:i}):(e.forEach(e=>{A.find(A=>A.Member_Account===e)?t.push(e):i.push(e)}),{successUserIDList:t,failureUserIDList:i})}},N=new class{init(A,e){A.ssoLog.debug("AVChatRoomAction.init"),v.init(A,e),w.init(A,e),S.init(A,e),M.init(A,e),R.init(A,e),_.init(A,e),T.init(A)}},b=new class{constructor(){this._name="LiveHandler"}init(A){this._core=A;const{helper:e,ssoLog:t}=A;e.registerExperimentalAPI("startMessageLongPolling",this),e.registerExperimentalAPI("stopMessageLongPolling",this),t.debug("LiveHandler.init")}startMessageLongPolling(A){const{common:e,utils:{isEmpty:t},OuterConstant:i,ssoLog:o}=this._core,{groupID:n,longPollingKey:r,longPollingSequence:s=1}=A;if(t(r))return o.warn("startMessageLongPolling",`${this._name}.startMessageLongPolling longPollingKey is empty.`),Promise.resolve({});D.hasPollingInstance(n)&&this.stopMessageLongPolling({groupID:n});const a=D.getJoinedLiveList(),g=e.isUnlimitedAVChatRoom();!g&&a.length>0&&this.stopMessageLongPolling({groupID:a[0].groupID}),o.debug("startMessageLongPolling",`${this._name}.startMessageLongPolling isUnlimited:${g} groupID:${n} longPollingKey:${r} longPollingSequence:${s}`);const c={groupID:n,type:i.GRP_LIVE};return D.updateLocalLiveGroup(n,c),this._getLiveHistoryMessages({groupID:n,longPollingKey:r,startSequence:s}),D.startMessageLongPolling({group:c,longPollingKey:r,startSequence:s})}stopMessageLongPolling(A){const{groupID:e}=A;return D.reset(e),this._core.ssoLog.debug("stopMessageLongPolling",`${this._name}.stopMessageLongPolling ok, groupID:${e}`),Promise.resolve({groupID:e})}_getLiveHistoryMessages(A){return t(this,void 0,void 0,function*(){const{ssoLog:e}=this._core,{groupID:i}=A;try{const o=yield function(A,e){return t(this,void 0,void 0,function*(){const{groupID:t,longPollingKey:i,startSequence:o}=A,n={GroupId:t,LongPollingKey:i,PullPreSeq:o};return e.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_huge_group_msg",data:n})})}(A,this._core),{RspMsgList:n=[]}=o||{};e.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages ok, groupID:${i} count:${n.length}`),n.length>0&&D.handleLiveHistoryMessages(i,n)}catch(o){e.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages failed, groupID:${i} info:${o.message}`)}})}};return new class{constructor(){this.name="AVChatRoom"}install(e,t){this._core=e,A.init(e),D.init(e,t),N.init(e,t),b.init(e);const{notificationCenter:i,InnerEvent:o}=e,{InnerEventSubType:n}=i;i.subscribeInnerEvent(o.MESSAGE_PUSH,n.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),i.subscribeInnerEvent(o.LOGOUT,this._reset,this),i.subscribeInnerEvent(o.DESTROY,this._dispose,this)}_onAVChatRoomSystemNotification(A){D.onAVChatRoomSystemNotification(A)}_reset(){D.reset()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core,{InnerEventSubType:t}=A;A.unSubscribeInnerEvent(e.MESSAGE_PUSH,t.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}}}();const n_=RR(o_.exports);var r_={exports:{}};r_.exports=function(){function A(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e=new class{init(A){this.core=A}};var t,i,o;(o=t||(t={})).MSG_TEXT="TIMTextElem",o.MSG_CUSTOM="TIMCustomElem",o.MSG_LOCATION="TIMLocationElem",o.MSG_FACE="TIMFaceElem",function(A){A[A.FORWARD=0]="FORWARD",A[A.BACKWARD=1]="BACKWARD"}(i||(i={}));const n="MSG_REACTION",r="MSG_EXT",s=0,a=1,g={ZH_CN:"zh (cmn-Hans-CN)",EN_US:"en-US",YUE_HK:"yue-Hant-HK",JA_JP:"ja-JP",ZH_PY:"zh-PY"},c="16k_zh",l="16k_en",I="16k_yue",u="16k_ja",E="16k_zh-PY",d={[g.ZH_CN]:c,[g.EN_US]:l,[g.YUE_HK]:I,[g.JA_JP]:u,[g.ZH_PY]:E},h=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/,C={READ:0,UNREAD:1},B=1,Q=2,p=3,f=1,m=2;var y;!function(A){A.IN="in",A.OUT="out"}(y||(y={}));const D=16,v=17,w=2116,S=2500,M="C2C",R="GROUP",_=20;function T(t){return A(this,void 0,void 0,function*(){var i,o;const{appStore:n,utils:{isEmpty:r},common:{getCurrentUserID:s},notificationCenter:a,OuterEvent:g}=e.core,{messageList:c,conversationID:l}=t,I=n.conversationStore.getConversationMap();let u=null===(i=I.get(l))||void 0===i?void 0:i.peerReadTime;if(!u){const t=l.replace(M,""),i=yield function(t){return A(this,void 0,void 0,function*(){const A={To_Account:t};return e.core.common.buildAndSendPacket({servcmd:"openim.get_peer_read_time",data:A})})}([t]);if(i){const{ReadTime:A}=i;u=null==A?void 0:A[0],I.has(l)&&(I.get(l).peerReadTime=u)}}if(I.has(l)){const A=null===(o=I.get(l))||void 0===o?void 0:o.lastMessage;r(A)||A.fromAccount===s()&&A.lastTime<=u&&!A.isPeerRead&&(A.isPeerRead=!0,n.conversationStore.updateConversation(l,{lastMessage:A}))}const E=[];c.forEach(A=>{A.time<=u&&!A.isPeerRead&&"out"===A.flow&&(A.isPeerRead=!0,E.push(A))}),a.emitOuterEvent(g.MESSAGE_READ_BY_PEER,{name:g.MESSAGE_READ_BY_PEER,data:E})})}function N(t){return A(this,void 0,void 0,function*(){var A;const{message:i,user:o,appStore:n,constants:{OuterConstant:r}}=e.core,s=n.conversationStore.getConversationMap();if(s.has(t)){const i=null===(A=s.get(t))||void 0===A?void 0:A.userProfile;if(i&&t.startsWith(r.CONV_C2C)){const{avatar:A,nick:o}=i;e.core.message.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:t,latestAvatar:A,latestNick:o,isSentByMe:!1})}}const{data:a}=(yield o.userProfile.getMyProfile())||{};if(a){const{avatar:A,nick:e}=a;i.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:t,latestAvatar:A,latestNick:e,isSentByMe:!0})}})}function b(A){let t;const{message:i}=e.core,{conversationID:o,messageID:n}=A;return t=i.messageDataHandler.getLocalMessageList(o).find(A=>A.ID===n),t||(t=i.messageDataHandler.getSparseMessageList(o).find(A=>A.ID===n)),t}function G(A){return A.map(A=>{const{from:e,to:t,cloudCustomData:i,avatar:o,nick:n,ID:r,clientSequence:s,clientTime:a,messageRandom:g,messageSequence:c,time:l}=A;return{ClientSeq:s,CloudCustomData:i,From_Account:e,From_AccountHeadurl:o,From_AccountNick:n,Id:r,MsgBody:JSON.parse(JSON.stringify(A.transformElementsToServerFormat())),MsgClientTime:a,MsgRandom:g,Random:g,MsgSeq:c,MsgTimeStamp:l,ReceiverId:t,SenderId:e,To_Account:t}})}function k(A){var t;const{From_Account:i,From_AccountHeadurl:o,From_AccountNick:n,GroupId:r,MsgClientTime:s,ClientSeq:a,To_Account:g,MsgTimeStamp:c,TinyId:l,MsgRandom:I,MsgSeq:u}=A;return{from:i,avatar:o,nick:n,clientTime:s,time:c,tinyID:l,random:I,sequence:u,to:g,groupID:r,clientSequence:a,_elements:null===(t=A.MsgBody)||void 0===t?void 0:t.map(A=>{const{MsgType:t}=A;return e.core.message.messageFactory.getElementClass(t).parseServerPushElement(A)})}}var L=new class{constructor(){this._reactionsMap=new Map}init(A){this._core=A;const{helper:e,notificationCenter:t,InnerEvent:{MESSAGE_PUSH:i},InnerEventSubType:{MESSAGE_REACTION_UPDATED:o,MESSAGE_REACTION_UPDATED_SYNC:n}}=A;e.registerApi({apiName:"addMessageReaction",context:this}),e.registerApi({apiName:"removeMessageReaction",context:this}),e.registerApi({apiName:"getMessageReactions",context:this}),e.registerApi({apiName:"getAllUserListOfMessageReaction",context:this}),t.subscribeInnerEvent(i,o,this._handleReactionUpdated,this),t.subscribeInnerEvent(i,n,this._handleReactionSync,this)}addMessageReaction(t,i){return A(this,void 0,void 0,function*(){const{OuterConstant:n,ssoLog:r,helper:s}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:a,ID:g,conversationType:c,from:l,to:I,clientSequence:u,random:E,time:d,sequence:h}=t,C=`conversationID:${a} messageID:${g} reactionID:${i}`;try{return this._recordMessageReactedByMe(g,i),c===n.CONV_C2C?yield function(t,i){return A(this,void 0,void 0,function*(){var A;const{from:o,to:n,clientSequence:r,random:s,time:a,reactionID:g}=t,c={From_Account:o,To_Account:n,MsgKey:`${r}_${s}_${a}`,Reaction:g,Add_Account:[null===(A=i.store.get("login"))||void 0===A?void 0:A.userId]};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_add",data:c})})}({from:l,to:I,clientSequence:u,random:E,time:d,reactionID:i},this._core):c===n.CONV_GROUP&&(yield function(t,i){return A(this,void 0,void 0,function*(){var A;const{to:o,reactionID:n,sequence:r}=t,s={GroupId:o,MsgSeq:r,Reaction:n,Add_Account:[null===(A=i.store.get("login"))||void 0===A?void 0:A.userId]};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_add",data:s})})}({to:I,reactionID:i,sequence:h},this._core)),{code:0,successLog:{message:C}}}catch(o){this._removeMyReactionRecord(g,i);const{errorCode:e}=o||{};throw new s.ChatError({functionName:"addMessageReaction",code:e,moreMessage:C})}})}removeMessageReaction(t,i){return A(this,void 0,void 0,function*(){const{OuterConstant:n,helper:r}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:s,ID:a,conversationType:g,from:c,to:l,clientSequence:I,random:u,time:E,sequence:d}=t,h=`conversationID:${s} messageID:${a} reactionID:${i}`;try{return this._removeMyReactionRecord(a,i),g===n.CONV_C2C?yield function(t,i){return A(this,void 0,void 0,function*(){var A;const{from:o,to:n,clientSequence:r,random:s,time:a,reactionID:g}=t,c={From_Account:o,To_Account:n,MsgKey:`${r}_${s}_${a}`,Reaction:g,Del_Account:[null===(A=i.store.get("login"))||void 0===A?void 0:A.userId]};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_del",data:c})})}({from:c,to:l,clientSequence:I,random:u,time:E,reactionID:i},this._core):g===n.CONV_GROUP&&(yield function(t,i){return A(this,void 0,void 0,function*(){var A;const{to:o,reactionID:n,sequence:r}=t,s={GroupId:o,MsgSeq:r,Reaction:n,Del_Account:[null===(A=i.store.get("login"))||void 0===A?void 0:A.userId]};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_del",data:s},i)})}({to:l,reactionID:i,sequence:d},this._core)),{code:0,successLog:{message:h}}}catch(o){const{errorCode:e}=o||{};throw new r.ChatError({functionName:"removeMessageReaction",code:e,moreMessage:h})}})}getAllUserListOfMessageReaction(t){return A(this,void 0,void 0,function*(){this._validateMessageReactionBusinessCapability();const{message:i,reactionID:n,nextSeq:r=0}=t,s=t.count>100?100:t.count,{conversationID:a}=i,{ssoLog:g,helper:c,constants:l}=this._core;try{let t=null;if(t=a.startsWith(l.OuterConstant.CONV_C2C)?yield function(t){return A(this,void 0,void 0,function*(){const{message:A,nextSeq:i,reactionID:o,count:n}=t,{from:r,to:s,clientSequence:a,random:g,time:c}=A,l={Reaction:o,NextSeq:i,Count:n,From_Account:r,To_Account:s,MsgKey:`${a}_${g}_${c}`};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_iterate",data:l})})}({message:i,reactionID:n,nextSeq:r,count:s}):yield function(t){return A(this,void 0,void 0,function*(){const{message:A,nextSeq:i,reactionID:o,count:n}=t,{sequence:r,to:s}=A,a={Reaction:o,NextSeq:i,GroupId:s,Count:n,MsgSeq:r};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_iterate",data:a})})}({message:i,reactionID:n,nextSeq:r,count:s}),t){const{Reaction_Account:A,NextSeq:e}=t;return{code:0,data:{nextSeq:e,isCompleted:0===r,userList:yield this._getUserProfileList(A)}}}}catch(o){const{errorCode:e}=o||{};throw new c.ChatError({functionName:"getAllUserListOfMessageReaction",code:e})}})}getMessageReactions(t){return A(this,void 0,void 0,function*(){const{constants:i}=this._core;this._validateMessageReactionBusinessCapability();const{messageList:o,maxUserCountPerReaction:n=10}=t,r=o[0];let s=null;const a=new Map,{from:g,to:c,conversationType:l}=r,I=this._generateMessageKeyList(o,a);l===i.OuterConstant.CONV_C2C?s=yield function(t){return A(this,void 0,void 0,function*(){const{from:A,to:i,messageKeyList:o,maxUserCountPerReaction:n}=t,r={From_Account:A,To_Account:i,MsgKeyList:o,Count:n};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_multi_stat",data:r})})}({from:g,to:c,messageKeyList:I,maxUserCountPerReaction:n}):l===i.OuterConstant.CONV_GROUP&&(s=yield function(t){return A(this,void 0,void 0,function*(){const{groupId:A,messageSequenceList:i,maxUserCountPerReaction:o}=t,n={GroupId:A,MsgSeqList:i,Count:o};return e.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_multi_stat",data:n})})}({groupId:c,messageSequenceList:I,maxUserCountPerReaction:n}));const{Results:u=[]}=s||{},E=this._extractUserIDsFromReactionResults(u),d=yield this._getUserProfileMap(E);return{code:0,data:{resultList:u.map(A=>{const{ReactionList:e,MsgSeq:t,MsgKey:i}=A;return{messageID:this._generateMessageID({messageSequence:t,messageKey:i,messageIDMap:a}),reactionList:e.map(A=>{const{Reaction:e,Count:t,Reaction_Account:i,ReactedByMe:o}=A;return{reactionID:e,totalUserCount:t,partialUserList:this._generatePartialUserInfo({userIDList:i,userProfileMap:d}),reactedByMyself:1===o}})}})}}})}dispose(){this._reactionsMap.clear()}_extractUserIDsFromReactionResults(A){const e=[];return null==A||A.forEach(A=>{const{ReactionList:t=[]}=A;t.forEach(A=>{A.Reaction_Account&&e.push(...A.Reaction_Account)})}),e}_getUserProfileList(e){return A(this,void 0,void 0,function*(){var A;try{const t=yield null===(A=this._core.user.userProfile)||void 0===A?void 0:A.getUserProfile({userIDList:e});return t?t.data:[]}catch(t){return[]}})}_getUserProfileMap(e){return A(this,void 0,void 0,function*(){const A=new Map;return(yield this._getUserProfileList(e)).forEach(e=>{const{nick:t,avatar:i,userID:o}=e;A.set(o,{nick:t,avatar:i,userID:o})}),A})}_recordMessageReactedByMe(A,e){const t=`${A}-${e}`;this._reactionsMap.has(t)?this._reactionsMap.get(t).reactedByMe=!0:this._reactionsMap.set(t,{reactedByMe:!0})}_removeMyReactionRecord(A,e){const t=`${A}-${e}`;this._reactionsMap.has(t)&&(this._reactionsMap.get(t).reactedByMe=!1)}_recordMessageReactionInfo(A){const{messageID:e,reactionID:t,reactionInfo:i}=A,o=`${e}-${t}`,n=this._reactionsMap.get(o)||{};this._reactionsMap.set(o,Object.assign(Object.assign({},n),i))}_validateMessageReactionBusinessCapability(){const{helper:A,constants:e}=this._core;if(!A.checkBusinessCapabilityBits(n))throw new A.ChatError({functionName:"addMessageReaction",code:e.ERROR_CODE.NO_USE,replacement1:"addMessageReaction"})}_handleReactionUpdated(e){const{MsgReactionNotifyList:t}=e,{notificationCenter:i,constants:o}=this._core;t.forEach(e=>A(this,void 0,void 0,function*(){const{C2CMsgInfo:A,GroupMsgInfo:t,MsgReactionSummary:n}=e,{TinyId:r,MsgClientTime:s,MsgRandom:a}=Object.assign(Object.assign({},A),t),g=`${r}-${s}-${a}`,c=this._extractUserIDsFromReactionResults([{ReactionList:n}]),l=yield this._getUserProfileMap(c),I=n.map(A=>{var e;const{Reaction:t,Reaction_Account:i}=A,o=this._generatePartialUserInfo({userIDList:i,userProfileMap:l}),n=i?A.Count:0,r=(null===(e=this._reactionsMap.get(`${g}-${t}`))||void 0===e?void 0:e.reactedByMe)||!1;return this._recordMessageReactionInfo({messageID:g,reactionID:t,reactionInfo:{reactionID:t,totalUserCount:n,partialUserList:o}}),{reactionID:t,totalUserCount:n,partialUserList:o,reactedByMyself:r}});i.emitOuterEvent(o.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:o.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:g,reactionList:I}})}))}_handleReactionSync(A){var e;const{notificationCenter:t,constants:i}=this._core,{C2CMsgInfo:o={},GroupMsgInfo:n={},Reaction:r,OperateType:s}=A.MsgReactionNotify,{TinyId:a="",MsgClientTime:g=0,MsgRandom:c=0}=Object.assign(Object.assign({},o),n),l=`${a}-${g}-${c}`,I=`${l}-${r}`;if(1===s?this._recordMessageReactedByMe(l,r):this._removeMyReactionRecord(l,r),null===(e=this._reactionsMap.get(I))||void 0===e?void 0:e.reactionID){const A=this._reactionsMap.get(I);A.reactedByMyself=1===s,t.emitOuterEvent(i.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:i.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:l,reactionList:[A]}})}}_generatePartialUserInfo({userIDList:A,userProfileMap:e}){const t=[];return null==A||A.forEach(A=>{e.has(A)&&t.push(e.get(A))}),t}_generateMessageID(A){const{messageSequence:e,messageKey:t,messageIDMap:i}=A;return t?i.get(t):i.get(e)}_generateMessageKeyList(A,e){const{constants:t}=this._core,i=A[0],{conversationType:o}=i;let n=[];return o===t.OuterConstant.CONV_C2C?n=A.map(A=>{const{clientSequence:t,random:i,time:o,ID:n}=A,r=`${t}_${i}_${o}`;return e.set(r,n),r}):o===t.OuterConstant.CONV_GROUP&&(n=A.map(A=>{const{ID:t,sequence:i}=A;return e.set(i,t),i})),n}},U=new class{init(A){this._core=A;const{helper:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:i,GROUP_MESSAGE_READ_RECEIPT:o},notificationCenter:n}=A;e.registerApi({apiName:"sendMessageReadReceipt",context:this}),e.registerApi({apiName:"getMessageReadReceiptList",context:this}),e.registerApi({apiName:"getGroupMessageReadMemberList",context:this}),n.subscribeInnerEvent(t,i,this._handleC2CMessageReadReceipt,this),n.subscribeInnerEvent(t,o,this._handleGroupMessageReadReceipt,this)}sendMessageReadReceipt(t){return A(this,void 0,void 0,function*(){const{common:i,constants:n}=this._core,r=this._filterValidMessageSendByOther(t);if(0===r.length)throw new i.ChatError({code:n.ERROR_CODE.READ_RECEIPT_MSG_LIST_EMPTY});try{const{conversationType:t}=r[0];return t===n.OuterConstant.CONV_C2C?yield function(t){return A(this,void 0,void 0,function*(){const{common:A,constants:i}=e.core,o={Peer_Account:t[0].conversationID.replace(i.OuterConstant.CONV_C2C,""),C2CMsgInfo:t.map(A=>{const{from:e,to:t,sequence:i,random:o,time:n,clientTime:r}=A;return{From_Account:e,To_Account:t,MsgSeq:i,MsgRandom:o,MsgTime:n,MsgClientTime:r}})};return A.buildAndSendPacket({servcmd:"openim.c2c_msg_read_receipt",data:o})})}(r):yield function(t){return A(this,void 0,void 0,function*(){const{common:A,constants:i}=e.core,o={GroupId:t[0].conversationID.replace(i.OuterConstant.CONV_GROUP,""),MsgSeqList:t.map(A=>({MsgSeq:A.sequence}))};return A.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_receipt",data:o})})}(r),{code:0,data:{}}}catch(o){const{errorCode:e,errorInfo:t}=o;throw new i.ChatError({code:e,message:t})}})}getMessageReadReceiptList(t){return A(this,void 0,void 0,function*(){const{common:i,constants:n}=this._core;try{const{conversationType:i}=t[0];if(i===n.OuterConstant.CONV_GROUP){const i=this._filterValidMessageSendByMe(t);if((null==i?void 0:i.length)>0){const o=yield function(t){return A(this,void 0,void 0,function*(){const{common:A,constants:i}=e.core,o={GroupId:t[0].conversationID.replace(i.OuterConstant.CONV_GROUP,""),MsgSeqList:t.map(A=>({MsgSeq:A.sequence}))};return A.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt",data:o})})}(i),{GroupMsgReceiptList:n}=o||{};this._updateGroupMessagesReadReceiptInfo({messageList:t,readReceiptList:n})}}return{code:0,data:{messageList:t}}}catch(o){const{errorCode:e,errorInfo:t}=o;throw new i.ChatError({code:e,message:t})}})}getGroupMessageReadMemberList(t){return A(this,void 0,void 0,function*(){const{constants:i,common:n}=this._core,{message:r,filter:s=C.READ,cursor:a=""}=t,{conversationID:g,sequence:c,ID:l}=r,I=g.replace(i.OuterConstant.CONV_GROUP,""),u=t.count>=100?100:t.count;try{const t=yield function(t){return A(this,void 0,void 0,function*(){const{sequence:A,groupID:i,filter:o,cursor:n,count:r}=t,s={MsgSeq:A,GroupId:i,Filter:o,Cursor:n,Num:r};return e.core.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt_detail",data:s})})}({groupID:I,sequence:c,filter:s,cursor:a,count:u});if(t){const{Cursor:A,IsFinish:e,UnreadList:i,ReadList:o}=t,n={cursor:A,isCompleted:1===e,messageID:l,unreadUserIDList:[],readUserIDList:[]};return s===C.READ?n.readUserIDList=o.map(A=>A.Read_Account):s===C.UNREAD&&(n.unreadUserIDList=i.map(A=>A.Unread_Account)),{code:0,data:n}}}catch(o){const{errorCode:e,errorInfo:t}=o;throw new n.ChatError({code:e,message:t})}})}_handleC2CMessageReadReceipt(A){const e=[],{constants:t,helper:i}=this._core,{C2cMsgInfo:o,PeerReadTime:n,Peer_Account:r}=A;if(i.isEmpty(o))return;const s=`${t.OuterConstant.CONV_C2C}${r}`;null==o||o.forEach(A=>{const{TinyId:t,MsgClientTime:i,MsgRandom:o}=A,a=`${t}-${i}-${o}`,g=b({conversationID:s,messageID:a});g&&!g.readReceiptInfo.isPeerRead&&(g.readReceiptInfo.isPeerRead=!0,g.readReceiptInfo.timestamp=n,e.push({userID:r,messageID:a,isPeerRead:!0,timestamp:n}))}),this._emitReadReceiptEventIfNeed(e)}_updateGroupMessagesReadReceiptInfo(A){const{messageList:e,readReceiptList:t}=A,i=new Map;e.forEach(A=>{i.set(A.sequence,A)}),null==t||t.forEach(A=>{if(0===A.Code){const{MsgSeq:e,ReadNum:t,UnreadNum:o}=A,n=i.get(e);n&&(n.readReceiptInfo.readCount=t,n.readReceiptInfo.unreadCount=o)}})}_handleGroupMessageReadReceipt(A){const e=[],{constants:t}=this._core,{GroupTips:i}=A;i.forEach(A=>{const{MsgBody:{GroupMsgReceiptList:i},GroupInfo:{GroupId:o}}=A,n=`${t.OuterConstant.CONV_GROUP}${o}`;null==i||i.forEach(A=>{const{TinyId:t,MsgClientTime:i,MsgRandom:r,ReadNum:s,UnreadNum:a}=A,g=`${t}-${i}-${r}`,c=b({conversationID:n,messageID:g}),l={groupID:o,messageID:g,readCount:0,unreadCount:0};c&&("number"==typeof s&&(c.readReceiptInfo.readCount=s,l.readCount=s),"number"==typeof a&&(c.readReceiptInfo.unreadCount=a,l.unreadCount=a),e.push(l))})}),this._emitReadReceiptEventIfNeed(e)}_emitReadReceiptEventIfNeed(A){const{notificationCenter:e,OuterEvent:t}=this._core;A.length>0&&e.emitOuterEvent(t.MESSAGE_READ_RECEIPT_RECEIVED,{name:t.MESSAGE_READ_RECEIPT_RECEIVED,data:A})}_filterValidMessageSendByOther(A){return this._filterNeedReadReceiptMessages(A).filter(A=>{const{from:e}=A;return e!==this._core.common.getCurrentUserID()})}_filterValidMessageSendByMe(A){const{OuterConstant:e}=this._core.constants;return this._filterNeedReadReceiptMessages(A).filter(A=>{const{from:t,status:i}=A;return t===this._core.common.getCurrentUserID()&&i===e.MessageStatus.SUCCESS})}_filterNeedReadReceiptMessages(A){return A.filter(A=>!0===A.needReadReceipt)}dispose(){const{InnerEvent:{MESSAGE_PUSH:A},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:e,GROUP_MESSAGE_READ_RECEIPT:t},notificationCenter:i}=this._core;i.unSubscribeInnerEvent(A,e,this._handleC2CMessageReadReceipt,this),i.unSubscribeInnerEvent(A,t,this._handleGroupMessageReadReceipt,this)}};function F(t,i,o){return A(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:A}}=e.core,{from:n,to:r,clientSequence:s,random:a,time:g}=t;return A({servcmd:"openim_msg_ext_http_svc.set_key_values",data:{From_Account:n,To_Account:r,MsgKey:`${s}_${a}_${g}`,OperateType:o,ExtensionList:i}})})}function O(t,i,o){return A(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:A}}=e.core,{to:n,sequence:r}=t;return A({servcmd:"openim_msg_ext_http_svc.group_set_key_values",data:{GroupId:n,MsgSeq:r,OperateType:o,ExtensionList:i}})})}var x=new class{constructor(){this._messageExtensionsMap=new Map,this._extensionsLatestSequenceMap=new Map,this._completedFetchExtensions=new Set}init(A){this._core=A;const{notificationCenter:e,helper:{registerApi:t},InnerEvent:{MESSAGE_PUSH:i,LOGOUT:o},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:n}}=A;t({apiName:"setMessageExtensions",context:this}),t({apiName:"getMessageExtensions",context:this}),t({apiName:"deleteMessageExtensions",context:this}),e.subscribeInnerEvent(i,n,this._handleMessageExtensionsNotify,this),e.subscribeInnerEvent(o,this.reset,this)}setMessageExtensions(e,t){return A(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("setMessageExtensions");const{constants:{OuterConstant:A},ssoLog:i}=this._core,{ID:o,conversationID:n,sequence:r,time:s,conversationType:a}=e;let g=t;t.length>20&&(g=t.slice(0,20),i.warn("setMessageExtensions","the length of extensions cannot exceed 20"));const c=this._generateServerExtensions(e,g),l=`convID:${n} messageID:${o} sequence:${r} time:${s} count:${g.length}`;try{let t;if(a===A.CONV_C2C?t=yield F(e,c,B):a===A.CONV_GROUP&&(t=yield O(e,c,B)),t){const{resultList:A,successCount:i,failureCount:o}=this._handleModifyMessageExtensions(e,t);return{code:0,data:{extensions:A},successLog:{message:`${l} successCount:${i} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(I){const{errorCode:A}=I;throw new this._core.helper.ChatError({functionName:"setMessageExtensions",code:A,moreMessage:l})}})}getMessageExtensions(e){return A(this,void 0,void 0,function*(){const{utils:{isUndefined:A}}=this._core;this._validateMessageExtensionBusinessCapability("getMessageExtensions");const{conversationID:t,ID:i,sequence:o,time:n}=e,r=`convID:${t} messageID:${i} sequence:${o} time:${n}`;try{let t;this._completedFetchExtensions.has(i)&&(t=this._extensionsLatestSequenceMap.get(i));const o=yield this._fetchMessageExtensions(e,t);return A(t)&&o.length>1&&this._completedFetchExtensions.add(i),{code:0,data:{extensions:o},successLog:{message:r}}}catch(s){const{errorCode:A,errorInfo:e=""}=s||{};throw new this._core.common.ChatError({code:A,message:e,moreMessage:r})}})}deleteMessageExtensions(e,t){return A(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("deleteMessageExtensions");const{utils:{isEmpty:A},constants:{OuterConstant:i}}=this._core,{conversationType:o,conversationID:n,sequence:r,ID:s,time:a}=e;let g=p;const c=[];A(t)||(g=Q,null==t||t.forEach(A=>{c.push({key:A,value:"",seq:0})}));const l=`convID:${n} messageID:${s} sequence:${r} time:${a} operateType:${g}`,I=this._generateServerExtensions(e,c);try{let A;if(o===i.CONV_C2C?A=yield F(e,I,g):o===i.CONV_GROUP&&(A=yield O(e,I,g)),A){const{resultList:t,successCount:i,failureCount:o}=this._handleModifyMessageExtensions(e,A);return{code:0,data:{extensions:t},successLog:{message:`${l}successCount:${i} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(u){const{errorCode:A}=u;throw new this._core.helper.ChatError({functionName:"deleteMessageExtensions",code:A,moreMessage:l})}})}reset(){this._messageExtensionsMap.clear(),this._extensionsLatestSequenceMap.clear(),this._completedFetchExtensions.clear()}dispose(){this.reset();const{notificationCenter:A,InnerEvent:{MESSAGE_PUSH:e,LOGOUT:t},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:i}}=this._core;A.unSubscribeInnerEvent(e,i,this._handleMessageExtensionsNotify,this),A.subscribeInnerEvent(t,this.reset,this)}_handleModifyMessageExtensions(A,e){const{ID:t}=A,{Seq:i}=e,o=e.ExtensionList||[],n=[];let r=0,s=0,a=[];return o.forEach(A=>{const{ErrorCode:e,Extension:t}=A,{Key:i,Value:o,Seq:g}=t;n.push({code:e,key:i,value:o}),0===e?r++:s++,a.push({key:i,value:o,seq:g})}),this._extensionsLatestSequenceMap.set(t,i),a.length>0&&this._updateLocalExtensions(A.ID,a),{resultList:n,successCount:r,failureCount:s}}_updateLocalExtensions(A,e){this._messageExtensionsMap.has(A)||this._messageExtensionsMap.set(A,new Map);const t=this._messageExtensionsMap.get(A);null==e||e.forEach(A=>{const{key:e,seq:i,value:o=""}=A;null==t||t.set(e,{value:o,seq:i})})}_fetchMessageExtensions(t,i){return A(this,void 0,void 0,function*(){const{constants:{OuterConstant:A},utils:{isEmpty:o}}=this._core;try{let n;const{conversationType:r,ID:s}=t;if(r===A.CONV_C2C?n=yield function(A,t){const{common:{buildAndSendPacket:i}}=e.core,{from:o,to:n,clientSequence:r,random:s,time:a}=A;return i({servcmd:"openim_msg_ext_http_svc.get_key_values",data:{From_Account:o,To_Account:n,MsgKey:`${r}_${s}_${a}`,StartSeq:t}})}(t,i):r===A.CONV_GROUP&&(n=yield function(A,t){const{common:{buildAndSendPacket:i}}=e.core,{to:o,sequence:n}=A;return i({servcmd:"openim_msg_ext_http_svc.group_get_key_values",data:{GroupId:o,MsgSeq:n,StartSeq:t}})}(t,i)),n){const{LatestSeq:A,ClearSeq:e,CompleteFlag:i}=n,r=(n.ExtensionList||[]).map(A=>({key:A.Key,value:A.Value,seq:A.Seq}));if(this._updateLocalExtensions(s,r),this._clearLocationExtensions(s,e),this._extensionsLatestSequenceMap.set(s,A),1!==i){const A=r[r.length-1].seq+1;return this._fetchMessageExtensions(t,A)}const a=[];if(this._messageExtensionsMap.has(s)){const A=this._messageExtensionsMap.get(s);null==A||A.forEach((A,e)=>{const{value:t}=A;o(t)||a.push({key:e,value:t})})}return a}}catch(n){throw n}})}_clearLocationExtensions(A,e){if(!(e<=0)&&this._messageExtensionsMap.has(A)){const t=this._messageExtensionsMap.get(A);null==t||t.forEach((A,i)=>{A.seq<=e&&t.delete(i)})}}_generateServerExtensions(A,e){const{ID:t}=A;if(this._messageExtensionsMap.has(t)){const A=this._messageExtensionsMap.get(t);return e.map(e=>{var t;const{key:i,value:o}=e;let n=0;return(null==A?void 0:A.has(i))&&(n=null===(t=A.get(i))||void 0===t?void 0:t.seq),{Key:i,Value:o,Seq:n}})}return e.map(A=>({Key:A.key,Value:A.value,Seq:0}))}_validateMessageExtensionBusinessCapability(A){const{helper:e,constants:t}=this._core;if(!e.checkBusinessCapabilityBits(r))throw new e.ChatError({functionName:A,code:t.ERROR_CODE.NO_USE,replacement1:A})}_handleMessageExtensionsNotify(A){const{SetKVInfo:e,DeleteKVInfo:t,ClearKVInfo:i,MsgOptType:o,TinyId:n,MsgLastSeq:r,ExtensionC2cMsgInfo:s,ExtensionGroupMsgInfo:a}=(null==A?void 0:A.MsgExtensionNotify)||{},g=s||a||{},{MsgClientTime:c,MsgRandom:l}=g,I=`${n}-${c}-${l}`;this._extensionsLatestSequenceMap.set(I,r),o===B?this._handleMessageExtensionsUpdated({messageID:I,updateMessageExtensionsInfo:e}):o===Q?this._handleMessageExtensionsDeleted({messageID:I,deleteMessageExtensionsInfo:t}):o===p&&this._handleMessageExtensionsCleared({messageID:I,clearMessageExtensionsInfo:i})}_handleMessageExtensionsUpdated(A){const{notificationCenter:e,OuterEvent:t}=this._core,{messageID:i,updateMessageExtensionsInfo:o=[]}=A,n=[];o.forEach(A=>{const{MsgKeyValue:e=[]}=A,t=e.map(A=>(n.push({key:A.Key,value:A.Value}),{key:A.Key,value:A.Value,seq:A.Seq}));this._updateLocalExtensions(i,t)}),e.emitOuterEvent(t.MESSAGE_EXTENSIONS_UPDATED,{name:t.MESSAGE_EXTENSIONS_UPDATED,data:{messageID:i,extensions:n}})}_handleMessageExtensionsDeleted(A){const{notificationCenter:e,OuterEvent:t}=this._core,{messageID:i,deleteMessageExtensionsInfo:o=[]}=A,n=[];o.forEach(A=>{const{MsgKeyValue:e=[]}=A,t=e.map(A=>(n.push(A.Key),{key:A.Key,seq:A.Seq}));this._updateLocalExtensions(i,t)}),e.emitOuterEvent(t.MESSAGE_EXTENSIONS_DELETED,{name:t.MESSAGE_EXTENSIONS_DELETED,data:{messageID:i,keyList:n}})}_handleMessageExtensionsCleared(A){const{notificationCenter:e,OuterEvent:{MESSAGE_EXTENSIONS_DELETED:t},utils:{isEmpty:i}}=this._core,{messageID:o,clearMessageExtensionsInfo:n=[]}=A,r=[];n.forEach(A=>{const{ClearMsgSeq:e}=A;this._messageExtensionsMap.has(o)&&(this._messageExtensionsMap.get(o)||[]).forEach((A,t)=>{A.seq<=e&&!i(A.value)&&r.push(t)}),this._clearLocationExtensions(o,e)}),e.emitOuterEvent(t,{name:t,data:{messageID:o,keyList:r}})}};const P={key:"message",required:!0,rules:["object"],allowEmpty:!1,customValidator:A=>{const{constants:{OuterConstant:t}}=e.core;return A.status!==t.MessageStatus.SUCCESS?"message is not success":!0===A.isSupportExtension||"message is not support extension"}},Y={setMessageExtensions:[P,{key:"extensions",required:!0,rules:["array"],allowEmpty:!1}],getMessageExtensions:[P],deleteMessageExtensions:[P]},J=Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:[{required:!0,rules:["array"],allowEmpty:!1}],revokeMessage:[{required:!0,rules:["object"],allowEmpty:!1}],resendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],getMessageList:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},nextReqMessageID:{required:!1,rules:["string"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},getMessageListHopping:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},sequence:{required:!1,rules:["number"],allowEmpty:!0},direction:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},createTextAtMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:A=>{const e="string"==typeof(null==(t=A)?void 0:t.text)&&("string"!=typeof t.text||0!==(null===(i=null==t?void 0:t.text)||void 0===i?void 0:i.length))||"payload.text is invalid.";var t,i;return!0!==e?e:!((null==A?void 0:A.atUserList)&&!Array.isArray(A.atUserList))||"atUserList should be an array or undefind."}}},findMessage:[{required:!0,rules:["string"],allowEmpty:!1}],translateText:{sourceTextList:{required:!0,rules:["array"],allowEmpty:!1},sourceLanguage:{required:!0,rules:["string"],allowEmpty:!1},targetLanguage:{required:!0,rules:["string"],allowEmpty:!1}},createForwardMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>!(!A.startsWith("C2C")&&!A.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1}},createLocationMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:A=>{const{utils:{isString:t,isNumber:i}}=e.core;return t(null==A?void 0:A.description)?i(null==A?void 0:A.longitude)?!!i(null==A?void 0:A.latitude)||"payload.latitude must be a number.":"payload.longitude must be a number.":"payload.description must be a string."}}}},{addMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],removeMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],getMessageReactions:{messageList:{required:!0,rules:["array"],allowEmpty:!1},maxUserCountPerReaction:{required:!1,rules:["number"],allowEmpty:!0,customValidator:A=>"number"!=typeof A?"maxUserCountPerReaction is invalid.":!(A<0||A>10)||"maxUserCountPerReaction should between [0, 10]."}},getAllUserListOfMessageReaction:{message:{required:!0,rules:["object"],allowEmpty:!1,customValidator:A=>"success"===A.status||"message is invalid."},reactionID:{required:!0,rules:["string"],allowEmpty:!1},nextSeq:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}}}),{sendMessageReadReceipt:[{required:!0,rules:["array"],allowEmpty:!1}],getMessageReadReceiptList:[{required:!0,rules:["array"],allowEmpty:!1}],getGroupMessageReadMemberList:{message:{required:!0,rules:["object"],allowEmpty:!1},filter:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0},cursor:{required:!1,rules:["string"],allowEmpty:!0}}}),Y),{pinGroupMessage:{groupID:{required:!0,rules:["string"],allowEmpty:!1},message:{required:!0,rules:["object"],allowEmpty:!1},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},getPinnedGroupMessageList:[{key:"groupID",required:!0,rules:["string"],allowEmpty:!1}]}),H=Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:!0,revokeMessage:!0,resendMessage:!0,getMessageList:!0,getMessageListHopping:!0,createTextAtMessage:!0,findMessage:!0,translateText:!0,createForwardMessage:!0,createLocationMessage:!0},{addMessageReaction:!0,removeMessageReaction:!0,getMessageReactions:!0,getAllUserListOfMessageReaction:!0}),{sendMessageReadReceipt:!0,getMessageReadReceiptList:!0,getGroupMessageReadMemberList:!0}),{setMessageExtensions:!0,getMessageExtensions:!0,deleteMessageExtensions:!0}),{pinGroupMessage:!0,getPinnedGroupMessageList:!0});class q{constructor(A){this._core=A}deleteMessage(e){return A(this,void 0,void 0,function*(){const{to:A,messageIdentifiers:t}=e,i={From_Account:this._core.common.getCurrentUserID(),To_Account:A,MsgKeyList:t};return this._core.common.buildAndSendPacket({servcmd:"openim.delete_c2c_msg_ramble",data:i})})}revokeMessage(e){return A(this,void 0,void 0,function*(){const{to:A,from:t,sequence:i,time:o,random:n}=e,r={MsgInfo:{From_Account:t,To_Account:A,MsgSeq:i,MsgRandom:n,MsgTimeStamp:o}};return this._core.common.buildAndSendPacket({servcmd:"openim.msgwithdraw",data:r})})}}class V{constructor(A){this._core=A}deleteMessage(e){return A(this,void 0,void 0,function*(){const{to:A,messageIdentifiers:t}=e,i={GroupId:A,Deleter_Account:this._core.common.getCurrentUserID(),Seqs:t};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_ramble_msg_by_seq",data:i})})}revokeMessage(e){return A(this,void 0,void 0,function*(){const{to:A,sequence:t}=e,i={GroupId:A,MsgSeqList:[{MsgSeq:t}]};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_recall",data:i})})}}class j{constructor(A){this._core=A}generateRevokeMessage(A){const{conversationID:e,sequence:t,random:i,tinyID:o,clientTime:n,revokeReason:r,revoker:s}=A;let a={};const{messageDataHandler:g}=this._core.message;return a=g.revokeMessage({conversationID:e,sequence:t,random:i,revoker:s}),a||(a={conversationID:e,sequence:t},o&&n&&i&&(a.ID=`${o}-${n}-${i}`)),a.revoker=s,a.revokeReason=r,a.revokerInfo={userID:s,nick:"",avatar:""},a}updateRevokerInfo(e){return A(this,void 0,void 0,function*(){const A=e.map(A=>A.revoker);try{const t=yield this._fetchUserInfos(A);t&&e.forEach(A=>{const{revoker:e}=A;t[e]&&(A.revokerInfo.nick=t[e].nick||"",A.revokerInfo.avatar=t[e].avatar||"",A.revokerInfo.userID=e)})}catch(t){console.debug(t)}})}_fetchUserInfos(e){return A(this,void 0,void 0,function*(){var A,t;const i=yield null===(A=this._core.user.userProfile)||void 0===A?void 0:A.getUserProfile({userIDList:e});return(null==i?void 0:i.data)?null===(t=i.data)||void 0===t?void 0:t.reduce((A,{userID:e,nick:t,avatar:i})=>(A[e]={nick:t||"",avatar:i||""},A),{}):null})}}var K=new class{constructor(){this._core=null,this._c2cMessageAction=null,this._groupMessageAction=null}init(A){this._core=A,this._groupMessageAction=new V(A),this._c2cMessageAction=new q(A),this._messageHelper=new j(A);const{helper:e}=A;e.registerApi({apiName:"deleteMessage",context:this}),e.registerApi({apiName:"revokeMessage",context:this}),e.registerApi({apiName:"resendMessage",context:this}),e.registerApi({apiName:"findMessage",context:this})}deleteMessage(e){return A(this,void 0,void 0,function*(){let A=[],t=[];const{conversationID:i,conversationType:o}=e[0],n=i.replace(o,"");if("@TIM#SYSTEM"===o)throw new this._core.helper.ChatError({code:w});if(e.forEach(e=>{const{conversationID:n,conversationType:r,status:s,_onlineOnlyFlag:a,sequence:g,random:c,time:l}=e||{};if("success"===s&&n===i&&r===o){if(!a){const e="C2C"===r?`${g}_${c}_${l}`:String(g);A.push(e)}t.push(e)}}),0===A.length)return this._handleDeleteMessageSuccess(t),{code:0,data:{messageList:t}};A.length>30&&(A=A.slice(0,30),t=t.slice(0,30));try{return"C2C"===o?yield this._c2cMessageAction.deleteMessage({to:n,messageIdentifiers:A}):yield this._groupMessageAction.deleteMessage({to:n,messageIdentifiers:A}),this._handleDeleteMessageSuccess(t),{code:0,data:{messageList:t}}}catch(r){const{errorCode:A}=r;throw new this._core.helper.ChatError({functionName:"deleteMessage",code:A})}})}revokeMessage(e){return A(this,void 0,void 0,function*(){var A;const{conversationType:t,isRevoked:i,ID:o,type:n,from:r,to:s}=e;let a=null;const g=`type:${n} from:${r} to:${s} ID:${o}`;if("@TIM#SYSTEM"===t)throw new this._core.helper.ChatError({message:"system message cannot be revoked"});if(i)throw new this._core.helper.ChatError({message:"message has been revoked",moreMessage:g});try{if(a="C2C"===t?yield this._c2cMessageAction.revokeMessage(e):yield this._groupMessageAction.revokeMessage(e),a){const{RecallRetList:t}=a,i=(null===(A=null==t?void 0:t[0])||void 0===A?void 0:A.RetCode)||0;if(0!==i)throw new this._core.helper.ChatError({code:i,moreMessage:g});return e.isRevoked=!0,yield this._handleRevokeMessageSuccess(e),{code:0,data:{message:e},successLog:{message:g}}}}catch(c){const{errorCode:A}=c;throw new this._core.helper.ChatError({functionName:"revokeMessage",code:A,moreMessage:g})}})}resendMessage(e,t){return A(this,void 0,void 0,function*(){var A,i;return e.isResend=!0,e.status="unSend",null===(i=null===(A=this._core)||void 0===A?void 0:A.apiMap)||void 0===i?void 0:i.sendMessage(e,t)})}findMessage(A){return this._core.message.messageDataHandler.findMessage(A)}_handleDeleteMessageSuccess(A){if(0===A.length)return;const{message:{messageDataHandler:e},common:{isTopic:t},notificationCenter:i,InnerEvent:o}=this._core;A.forEach(A=>{A.isDeleted=!0;const t=e.getLocalMessageList(A.conversationID);null==t||t.forEach(e=>{e.ID===A.ID&&(e.isDeleted=!0)})});const{conversationID:n=""}=A[0];t(n)?i.emitInnerEvent(o.TOPIC_MESSAGE_DELETED,n):i.emitInnerEvent(o.MESSAGE_DELETED,n)}_handleRevokeMessageSuccess(e){return A(this,void 0,void 0,function*(){var A;const t=null===(A=this._core.store.get("login"))||void 0===A?void 0:A.userId,{conversationID:i,sequence:o,random:n}=e;this._core.message.messageDataHandler.revokeMessage({conversationID:i,sequence:o,random:n,revoker:t}),yield this._messageHelper.updateRevokerInfo([e])})}};class W{static parseServerPushElement(A){const{MsgContent:e={}}=A,{Index:t,Data:i}=e;return new W({index:t,data:i})}constructor(A){this.type=t.MSG_FACE;const{index:e,data:i}=A;this.content={index:e,data:i}}validateBeforeSend(){var A,e;return"number"==typeof(null===(A=this.content)||void 0===A?void 0:A.index)&&"string"==typeof(null===(e=this.content)||void 0===e?void 0:e.data)?{isValid:!0}:{isValid:!1,error:{message:"content is invalid"}}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{index:i,data:o}=t;return{MsgType:this.type,MsgContent:{Index:i,Data:o}}}}class z{static parseServerPushElement(A){const{MsgContent:e={}}=A,{Desc:t,Longitude:i,Latitude:o}=e;return new z({description:t,longitude:i,latitude:o})}constructor(A){this.type=t.MSG_LOCATION;const{description:e,longitude:i,latitude:o}=A;this.content={description:e,longitude:i,latitude:o}}validateBeforeSend(){return{isValid:!0}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{description:i,longitude:o,latitude:n}=t;return{MsgType:this.type,MsgContent:{Desc:i,Longitude:o,Latitude:n}}}}var Z=new class{init(A){this._core=A,A.message.messageFactory.registerElementClass(t.MSG_FACE,W),A.message.messageFactory.registerElementClass(t.MSG_LOCATION,z),A.helper.registerApi({apiName:"createFaceMessage",context:this}),A.helper.registerApi({apiName:"createTextAtMessage",context:this}),A.helper.registerApi({apiName:"createForwardMessage",context:this}),A.helper.registerApi({apiName:"createLocationMessage",context:this})}createFaceMessage(A){if(!A)return null;const{index:e,data:t}=(null==A?void 0:A.payload)||{},i=new W({index:e,data:t}),o=this._core.common.getCurrentUserID(),n=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},A),{from:o}));return n.setElement(i),n}createTextAtMessage(A){const{atUserList:e}=(null==A?void 0:A.payload)||{},t=this._core.apiMap.createTextMessage(A),{OuterConstant:i}=this._core;if(!t)return null;if(Array.isArray(e)){const A=[],o=[];e.forEach(e=>{e!==i.MSG_AT_ALL?(A.push({GroupAtAllFlag:s,GroupAt_Account:e}),o.push(e)):(A.push({GroupAtAllFlag:a}),o.push(i.MSG_AT_ALL))}),t._groupAtInfoList=A,t.atUserList=o}return t}createForwardMessage(A){const{helper:e,OuterConstant:t}=this._core,{to:i,conversationType:o,priority:n,payload:r,needReadReceipt:s,receiverList:a,cloudCustomData:g="",isSupportExtension:c=!1}=A;if(!Array.isArray(r._elements))throw new e.ChatError({functionName:"createForwardMessage",code:2454});if(r.type===t.MSG_GRP_TIP)throw new e.ChatError({functionName:"createForwardMessage",code:2453});const l=this._core.common.getCurrentUserID(),I=this._core.message.messageFactory.createMessage({to:i,from:l,conversationType:o,isPlaceMessage:0,priority:n,payload:r,needReadReceipt:s,isSupportExtension:c,cloudCustomData:g,receiverList:a});return I.setRelayFlag(!0),I.setElement(r._elements[0]),I}createLocationMessage(A){if(!A)return null;const{description:e,longitude:t,latitude:i}=(null==A?void 0:A.payload)||{},o=new z({description:e,longitude:t,latitude:i}),n=this._core.common.getCurrentUserID(),r=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},A),{from:n}));return r.setElement(o),r}};class X{init(A){this._messageHelper=new j(A),this._core=A;const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{C2C_REVOKED_MESSAGE:i},helper:{registerWorkflowStep:o},constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:r}}=A;e.subscribeInnerEvent(t,i,this._handleC2CNotifyMessage,this),o(n.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,this._handleC2CRevokeMessagesFromUnreadMessageSync,this)}_handleC2CNotifyMessage(A){const{C2cNotifyMsgArray:e}=A;null==e||e.forEach(A=>{Object.keys(A).includes("WithdrawC2cMsgNotify")&&this._handleC2CRevokeMessage(A)})}_handleC2CRevokeMessage(e){return A(this,void 0,void 0,function*(){try{const{WithdrawC2cMsgNotify:{C2cWithdrawInfoArray:A}}=e;yield this._parseAndEmitC2CRevokedMessages(A)}catch(o){console.debug(o)}})}_parseAndEmitC2CRevokedMessages(e){return A(this,void 0,void 0,function*(){const A=[],{notificationCenter:t,OuterEvent:i,common:{getCurrentUserID:o}}=this._core;e.forEach(e=>{var t;const{MsgRand:i,MsgSeq:n,To_Account:r,From_Account:s,RevokerInfo:{Revoker_Account:a,Revoke_Reason:g}}=e,c=o()===s?`C2C${r}`:`C2C${s}`,l=(null===(t=null==e?void 0:e.RevokerInfo)||void 0===t?void 0:t.Reason)||g,I=this._messageHelper.generateRevokeMessage({conversationID:c,sequence:n,random:i,revoker:a,revokeReason:l});A.push(I)}),A.length>0&&(yield this._messageHelper.updateRevokerInfo(A),t.emitOuterEvent(i.MESSAGE_REVOKED,{name:i.MESSAGE_REVOKED,data:A}))})}_handleC2CRevokeMessagesFromUnreadMessageSync(e){return A(this,void 0,void 0,function*(){const{revokedMessageList:A}=e.result;yield this._parseAndEmitC2CRevokedMessages(A)})}dispose(){const{notificationCenter:A,InnerEvent:{MESSAGE_PUSH:e},InnerEventSubType:{C2C_REVOKED_MESSAGE:t}}=this._core;A.unSubscribeInnerEvent(e,t,this._handleC2CNotifyMessage,this)}}class ${init(A){this._messageHelper=new j(A),this._core=A;const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{GROUP_MESSAGE_REVOKED:i}}=A;e.subscribeInnerEvent(t,i,this._handleGroupNotifyMessage,this)}_handleGroupNotifyMessage(A){const{GroupTips:e}=A;null==e||e.forEach(A=>{var e;Array.isArray(null===(e=null==A?void 0:A.MsgBody)||void 0===e?void 0:e.GroupWithdrawInfoArray)&&this._handleGroupRevokeMessage(A)})}_handleGroupRevokeMessage(e){return A(this,void 0,void 0,function*(){try{const{RevokerInfo:A,MsgBody:{GroupWithdrawInfoArray:t},GroupInfo:i}=e,o=[],n=[],{notificationCenter:r,OuterEvent:s,utils:{isEmpty:a},common:{isCommunity:g}}=this._core;let c=!1;i&&(c=g({groupID:i.GroupId})||!a(i.TopicId)),t.forEach(e=>{const{Random:t,MsgSeq:r,GroupId:s,MsgClientTime:a,TinyId:g,TopicId:l,RevokerInfo:{Revoker_Account:I=(null==A?void 0:A.Revoker_Account)||"",Reason:u=(null==A?void 0:A.Reason)||""}}=e,E=l?`GROUP${l}`:`GROUP${s}`,d=this._messageHelper.generateRevokeMessage({conversationID:E,sequence:r,random:t,tinyID:g,clientTime:a,revoker:I,revokeReason:u});c?(d.revokerInfo.nick=i.From_AccountNick,d.revokerInfo.avatar=i.From_AccountHeadurl,o.push(d)):n.push(d)}),n.length>0&&(yield this._messageHelper.updateRevokerInfo(n),o.push(...n)),0!==o.length&&r.emitOuterEvent(s.MESSAGE_REVOKED,{name:s.MESSAGE_REVOKED,data:o})}catch(o){console.debug(o)}})}dispose(){const{notificationCenter:A,InnerEvent:{MESSAGE_PUSH:e},InnerEventSubType:{GROUP_MESSAGE_REVOKED:t}}=this._core;A.unSubscribeInnerEvent(e,t,this._handleGroupNotifyMessage,this)}}var AA=new class{constructor(){this._c2cMessageReceiver=new X,this._groupMessageReceiver=new $}init(A){this._c2cMessageReceiver.init(A),this._groupMessageReceiver.init(A)}dispose(){this._c2cMessageReceiver.dispose(),this._groupMessageReceiver.dispose()}};class eA{constructor(A){this._core=A;const{constants:e}=A;this._messageHelper=new j(A),A.helper.registerWorkflowStep(e.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,e.WORKFLOW_STEP.GROUP_REVOKED_NOTICE_RECOVER,this._recoverGroupRevokeNotice,this)}getRoamingMessagesByAnchor(A){return this._core.message.messageHistory.getGroupRoamingMessagesByAnchor(A)}_recoverGroupRevokeNotice(A){const{recoverRevokeNoticeGroupIDList:e=[]}=A.result,t=this._filterValidGroupIDList(e);if(0===t.length)return;const i=Math.min(Math.ceil(t.length/10),5);Promise.all(Array.from({length:i},(A,e)=>{const i=10*e,o=Math.min(i+10,t.length);return this._fetchGroupRevokeNotice(t.slice(i,o))})).catch(A=>console.error(A))}_fetchGroupRevokeNotice(t){return A(this,void 0,void 0,function*(){var i;try{const o=yield function(t){return A(this,void 0,void 0,function*(){const{appStore:A,constants:{OuterConstant:i},common:o}=e.core,n=A.groupStore.getGroupMap(),r={NotifyReqList:t.map(A=>{const t=n.get(A);return{NotifyType:1,Limit:20,Type:o.isCommunity({type:t.type,groupID:A})?i.GRP_COMMUNITY:void 0,GroupId:A,BeginTime:(null==t?void 0:t._lastRevokedTime)||0,EndTime:1e3*e.core.common.timeManager.getServerTimeMs()}})||[]};return o.buildAndSendPacket({servcmd:"group_open_http_svc.batch_get_group_notify",data:r})})}(t);if(o){const A=[];null===(i=null==o?void 0:o.NotifyRspList)||void 0===i||i.forEach(e=>{const{GroupId:t,NotifyMsgList:i}=e,o=this._parseServerRevokeMessageList({groupID:t,serverRevokeMessageList:i});A.push(...o)}),0!==A.length&&(yield this._emitMessageRevokedEvent(A))}}catch(o){console.error(o)}})}_parseServerRevokeMessageList(A){const{serverRevokeMessageList:e,groupID:t}=A,i=[];return null==e||e.forEach(A=>{const{ClientTime:e,MsgSeq:o,Random:n,RevokerInfo:{Revoker_Account:r="",Reason:s=""}}=A,a=`GROUP${t}`,g=this._messageHelper.generateRevokeMessage({conversationID:a,sequence:o,random:n,clientTime:e,revoker:r,revokeReason:s});i.push(g)}),i}_filterValidGroupIDList(A){const{constants:{OuterConstant:e}}=this._core,t=this._core.appStore.groupStore.getGroupMap();return(null==A?void 0:A.filter(A=>{if(!t.has(A))return!1;const i=t.get(A);return(null==i?void 0:i.type)!==e.GRP_AVCHATROOM&&!(null==i?void 0:i.isSupportTopic)}))||[]}_emitMessageRevokedEvent(e){return A(this,void 0,void 0,function*(){const{notificationCenter:A,OuterEvent:t}=this._core;yield this._messageHelper.updateRevokerInfo(e),A.emitOuterEvent(t.MESSAGE_REVOKED,{name:t.MESSAGE_REVOKED,data:e})})}}class tA{constructor(A){this._historyMessageListFetchAnchors=new Map,this._core=A,this._messageHelper=new j(A)}getRoamingMessagesByAnchor(t){return A(this,void 0,void 0,function*(){var i;try{const{conversationID:o,count:n,messageID:r,time:s,direction:a}=t;let g=s,c="";if(!s){const A=r?this._core.message.messageDataHandler.findMessage(r):null;if(g=(null==A?void 0:A.time)||0,r&&this._historyMessageListFetchAnchors.has(o)){const A=this._historyMessageListFetchAnchors.get(o);g=A.lastMessageTime,c=A.messageKey}}const l=o.replace(M,""),I=yield function(t){return A(this,void 0,void 0,function*(){const{peerAccount:A,count:i,lastMessageTime:o,messageKey:n,direction:r}=t,s={Peer_Account:A,MaxCnt:i,WithRecalledMsg:1,LastMsgTime:o,MsgKey:n,GetDirection:r};return e.core.common.buildAndSendPacket({servcmd:"openim.getroammsg",data:s})})}({count:n,lastMessageTime:g,messageKey:c,peerAccount:l,direction:a});if(I){const{MsgList:A=[],Complete:e,MsgKey:t,LastMsgTime:n}=I;this._historyMessageListFetchAnchors.set(o,{messageKey:t,lastMessageTime:n});const r=[];for(let i=0;iA.isRevoked).length;a=s.length-n.unreadCount-A}else a=s.length-n.unreadCount;for(let e=0;eA.isRevoked);yield this._messageHelper.updateRevokerInfo(c),n&&this._fetchedCompleteConversations.add(A);const l={nextReqMessageID:n?"":String(i),messageList:g,isCompleted:n},I=g.map(A=>A.sequence);return{code:0,data:l,successLog:{message:`conversationID: ${A} nextReqMessageID: ${o} availableLocalMessagesCount: ${r} sequenceList: ${JSON.stringify(I)}`}}}return{code:0,data:{messageList:[],isCompleted:!1,nextReqMessageID:""}}}return{code:0,data:yield this._getMessageListFromMemory({conversationID:A,nextReqMessageID:o,count:n}),successLog:{message:`conversationID: ${A} nextReqMessageID: ${o} availableLocalMessagesCount: ${r}}`}}}catch(o){throw new this._core.helper.ChatError({code:null==o?void 0:o.code})}})}getMessageListHopping(e){return A(this,void 0,void 0,function*(){var A,t;const{conversationID:o,sequence:n,time:r,direction:s=i.FORWARD}=e,{isEmpty:a}=this._core.helper;if(![i.BACKWARD,i.FORWARD].includes(s))throw new this._core.helper.ChatError({message:"direction must be 0 or 1"});let{count:g=_}=e;g=g>_?_:g;let c=null;if(o.startsWith(R)){if(c=yield this._groupMessageHistory.getRoamingMessagesByAnchor({conversationID:o,sequence:n,count:g,direction:s}),c){const{nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:o,messageList:r,invisibleSequenceList:g}=c;if(this._core.message.messageDataHandler.storeSparseMessageList(r),s===i.FORWARD){const A=o&&e<1;return{code:0,data:{messageList:r,isCompleted:A,nextMessageSeq:A?"":e}}}if(s===i.BACKWARD){if(a(r)&&a(g))return{code:0,data:{messageList:[],isCompleted:!0,nextMessageSeq:""}};const e=(null===(A=null==r?void 0:r[r.length-1])||void 0===A?void 0:A.sequence)||0,i=(null===(t=null==g?void 0:g[g.length-1])||void 0===t?void 0:t.sequence)||0;return{code:0,data:{messageList:r.filter(A=>A.sequence>=n),isCompleted:!o,nextMessageSeq:o?Math.max(e,i)+1:""}}}return{code:0,data:c}}}else if(o.startsWith(M)&&(c=yield this._c2cMessageHistory.getRoamingMessagesByAnchor({conversationID:o,count:g+1,time:r,direction:s}),c)){const{messageList:A,lastMessageTime:e,hasNoMoreHistoryMessage:t}=c;return t||(s===i.FORWARD?A.shift():A.pop()),this._core.message.messageDataHandler.storeSparseMessageList(A),{code:0,data:{messageList:A,isCompleted:t,nextMessageTime:t?"":e}}}})}clearHistoryMessage(t){return A(this,void 0,void 0,function*(){var i;const{appStore:n,common:{ChatError:r,getCurrentUserID:s},OuterConstant:{CONV_C2C:a,CONV_GROUP:g},message:c,apiMap:l}=this._core,I=n.conversationStore.getConversation(t);if(!I)throw new r({code:S});const u={fromAccount:s()},{type:E}=I;E===a?(u.type=f,u.toAccount=t.replace(a,"")):E===g&&(u.type=m,u.toGroupID=t.replace(g,""));try{yield null===(i=null==l?void 0:l.setMessageRead)||void 0===i?void 0:i.call(l,{conversationID:t});const o=yield function(t){return A(this,void 0,void 0,function*(){const{fromAccount:A,type:i,toAccount:o,toGroupID:n}=t,r={From_Account:A,Type:i,To_Account:o,ToGroupid:n};return e.core.common.buildAndSendPacket({servcmd:"recentcontact.clear_msg",data:r})})}(u);return o&&(c.messageDataHandler.deleteConversationMessageList(t),this._clearedConversations.add(t),this._fetchedCompleteConversations.delete(t),this._c2cMessageHistory.clearHistoryMessageListFetchAnchors(t),this._updateConversationLastMessage(t)),{code:0,data:{conversationID:t},successLog:{message:`convID:${t}`}}}catch(o){const{errorCode:e}=o;throw new this._core.helper.ChatError({functionName:"clearHistoryMessage",code:e,moreMessage:`convID:${t}`})}})}_updateConversationLastMessage(A){const{appStore:e}=this._core;e.conversationStore.updateConversation(A,{lastMessage:this._generateLastMessage()},{needSort:!0})}_getAvailableLocalMessagesCount({conversationID:A,nextReqMessageID:e}){const t=this._core.message.messageDataHandler.getLocalMessageList(A),{length:i}=t;if(!e)return i;let o=-1;return(null==A?void 0:A.startsWith(M))?o=t.findIndex(A=>A.ID===e):(null==A?void 0:A.startsWith(R))&&(o=t.findIndex(A=>e.includes("-")?A.ID===e:String(A.sequence)===e)),-1===o?0:o}_needFetchHistoryMessageList({conversationID:A,availableLocalMessagesCount:e,targetCount:t}){return!!this._clearedConversations.has(A)||eA.startsWith(M)?t.ID===e:String(t.sequence)===e),s=a>t?a-t:0,n=a):s=o>t?o-t:0,r.nextReqMessageID=0===s?"":this._generateNextReqMessageID({conversationID:A,targetIndex:s}),r.messageList=i.slice(s,a),r.isCompleted=n<=t,A.startsWith(M)&&(yield N(A),yield T({messageList:r.messageList,conversationID:A})),r})}_generateNextReqMessageID({conversationID:A,targetIndex:e}){const t=this._core.message.messageDataHandler.getLocalMessageList(A);return A.startsWith("C2C")?t[e].ID:String(t[e].sequence)}_generateLastMessage(){return{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}}reset(){this._clearedConversations.clear(),this._fetchedCompleteConversations.clear(),this._c2cMessageHistory.reset()}dispose(){this.reset()}},oA=new class{constructor(){this._core=null}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"translateText",context:this})}translateText(e){return A(this,void 0,void 0,function*(){try{const{sourceLanguage:t,sourceTextList:i,targetLanguage:o}=e,n=yield function(e,t){return A(this,void 0,void 0,function*(){var A,i;const{sourceTextList:o,sourceLanguage:n,targetLanguage:r}=e,{store:s,common:a}=t,g={SourceText:o,Source:n,Target:r,FromAccount:null===(A=s.get("login"))||void 0===A?void 0:A.tinyID,SDKAppID:null===(i=s.get("instance"))||void 0===i?void 0:i.sdkAppId},c=yield a.buildAndSendPacket({servcmd:"im_open_translate.ws_batch_trans_text",data:g});if(c){const{CmdErrorCode:A,TargetText:e}=c;return{cmdErrorCode:A,translatedTextList:e}}})}({sourceLanguage:t,sourceTextList:i,targetLanguage:o},this._core);if(n){const{cmdErrorCode:{ErrorCode:A,ErrorInfo:e},translatedTextList:t}=n;if(0===A)return{code:0,data:{translatedTextList:t}};throw{errorCode:A,errorInfo:e,message:e}}}catch(o){const{errorCode:e,errorInfo:t}=o||{};throw new this._core.helper.ChatError({functionName:"translateText",code:e,message:t})}})}},nA=new class{init(A){this._core=A,A.helper.registerApi({apiName:"convertVoiceToText",context:this})}convertVoiceToText(t){return A(this,void 0,void 0,function*(){var A;const{message:i,language:o=g.ZH_PY}=t;let{url:n}=i.payload||{};const r=this._core.common.getCurrentUserID();i.from===r&&"out"===i.flow&&(n=i.payload.remoteAudioUrl),this._validateVoiceFormat(n);const s=(null===(A=h.exec(n))||void 0===A?void 0:A[1])||"mp3",a=d[o]||E;try{const A=yield function(A){var t;const{store:i,common:o}=e.core,{url:n,format:r,serverLanguageType:s}=A,a={BytesUrl:n,BytesEngServiceType:s,BytesVoiceFormat:r,Uint32Sdkappid:null===(t=i.get("instance"))||void 0===t?void 0:t.sdkAppId,Uint64SourceType:0};return o.buildAndSendPacket({servcmd:"im_open_speech.ws_sentence_recognition",data:a})}({url:n,format:s,serverLanguageType:a});if(A){const{CmdErrorCode:e,BytesResult:t}=A;if(0===e.ErrorCode)return{code:0,data:{result:t}};throw{code:e.ErrorCode,message:e.ErrorInfo}}}catch(c){const{code:A,message:e}=c||{};throw new this._core.common.ChatError({functionName:"convertVoiceToText",code:A,message:e})}})}_validateVoiceFormat(A){if(!h.test(A))throw new this._core.common.ChatError({code:2119})}};class rA{constructor(A){const{constants:t,common:i,utils:o}=e.core,{CONV_C2C:n,CONV_GROUP:r}=t.OuterConstant,{ID:s,tinyID:a,from:g,to:c,clientTime:l=i.timeManager.getServerTimeSeconds()||0,random:I,sequence:u,cloudCustomData:E="",nick:d="",avatar:h="",clientSequence:C,conversationType:B,groupID:Q,_elements:p,time:f}=A;this.ID=s||`${a}-${l}-${I}`,this.messageRandom=I,this.from=g,this.messageSender=g,this.time=f,this.messageSequence=u,this.clientSequence=C||u,this.clientTime=l,this.cloudCustomData=E,this.messageReceiver=c,this.avatar=h,this.nick=d;const m=o.deepCopyWithMethods(p);m.forEach(A=>{A.payload=A.content,delete A.content}),this.messageBody=m,s?B.startsWith(n)?this.receiverUserID=c:B.startsWith(r)&&(this.receiverGroupID=c):Q?(this.receiverGroupID=Q,this.messageReceiver=Q):c&&(this.receiverUserID=c,this.messageReceiver=c)}transformElementsToServerFormat(){return this.messageBody?Array.isArray(this.messageBody)?this.messageBody.map(A=>A.transformToServerFormat({isMergerMessage:!0})):this.messageBody.transformToServerFormat({isMergerMessage:!0}):null}}class sA{static parseServerPushElement(A){const{MsgContent:e}=A,{MsgList:t=[],CompatibleText:i,AbstractList:o,Title:n,PbMsgKey:r,JsonMsgKey:s}=e||{},a=t.map(A=>k(A));return new sA({messageList:a,title:n,abstractList:o,compatibleText:i,pbDownloadKey:r,downloadKey:s})}constructor(A){this.type=e.core.constants.OuterConstant.MSG_MERGER;const{messageList:t,title:i,abstractList:o,compatibleText:n,pbDownloadKey:r="",downloadKey:s="",version:a=0,layersOverLimit:g=!1}=A,c=[];t.forEach(A=>{if(A){const e=new rA(A);c.push(e)}}),this.content={messageList:c,title:i,abstractList:o,compatibleText:n,version:a,downloadKey:s,pbDownloadKey:r,layersOverLimit:g}}validateBeforeSend(){const{isEmpty:A}=e.core.helper;return A(this.content.messageList)?{isValid:!1,error:{message:"content is invalid"}}:{isValid:!0}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{abstractList:i,compatibleText:o,downloadKey:n,layersOverLimit:r,pbDownloadKey:s,title:a,version:g,messageList:c}=t;return{MsgType:this.type,MsgContent:{AbstractList:i,CompatibleText:o,JsonMsgKey:n,LayersOverLimit:r,PbMsgKey:s,Title:a,Version:g,MsgList:G(c)}}}}var aA=new class{init(A){this._core=A;const{message:e,helper:t,constants:{OuterConstant:i}}=A;e.messageFactory.registerElementClass(i.MSG_MERGER,sA),t.registerApi({apiName:"createMergerMessage",context:this}),t.registerApi({apiName:"sendMessage",context:this,matcher:A=>A[0].type===i.MSG_MERGER}),t.registerApi({apiName:"downloadMergerMessage",context:this})}createMergerMessage(A){const{common:e}=this._core;if(!A)return null;const t=new sA(A.payload),i=e.getCurrentUserID(),o=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},A),{from:i}));return o.setRelayFlag(!0),o.setElement(t),o}sendMessage(t,i){return A(this,void 0,void 0,function*(){var n,r,s;try{const a=function(A){let t="utf-8";e.core.helper.IN_BROWSER&&document&&(t=document.charset.toLowerCase());let i,o=0,n=0;if(n=A.length,"utf-8"===t||"utf8"===t)for(let e=0;e11264){g=this._core.utils.deepCopyWithMethods(t);try{const{JsonMsgKey:t,PbMsgKey:i}=yield function(t){return A(this,void 0,void 0,function*(){const{payload:{messageList:A}}=t,i={MsgList:G(A)};return e.core.common.buildAndSendPacket({servcmd:"im_long_msg.save_relay_json_msg",data:i})})}(g),{payload:o}=g;c=new sA(Object.assign(Object.assign({},o),{messageList:[],downloadKey:t,pbDownloadKey:i})),g.setElement(c)}catch(o){console.error(o)}}const{data:{message:l}}=yield null===(s=null===(r=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===r?void 0:r.messageSender)||void 0===s?void 0:s.sendMessage(g,i);return c&&l.setElement(t._elements),{code:0,data:{message:l}}}catch(o){const{errorCode:e}=o;throw new this._core.helper.ChatError({code:e})}})}downloadMergerMessage(t){return A(this,void 0,void 0,function*(){const{ssoLog:i}=this._core,n=t.payload,{downloadKey:r,pbDownload:s,type:a,messageList:g}=n,c=function(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{const e=k(A);return new rA(e)});return"function"==typeof t.isOnlineMessage?t.setElement({type:t.type,content:Object.assign({messageList:s},c)}):(t.payload.messageList=s,t.payload.downloadKey="",t.payload.pbDownloadKey=""),i.info("downloadMergerMessage",` success downloadKey:${r}`),t}catch(o){const{errorCode:e}=o;throw new this._core.helper.ChatError({functionName:"downloadMergerMessage",code:e,moreMessage:r})}})}},gA=new class{init(A){this._core=A,this._core.helper.registerExperimentalAPI("sendComboMessage",this)}sendComboMessage(e){return A(this,void 0,void 0,function*(){const{appStore:A,message:t,common:{getCurrentUserID:i},utils:{isArray:o}}=this._core,{GroupId:n,To_Account:r}=e;e.From_Account=e.From_Account||i();let s=null;if(n){s=this._generateGroupMessage(Object.assign(Object.assign({},e),{ToGroupId:n}));const t=A.userStore.getUserProfile(i());s.level=(null==t?void 0:t.level)||0,o(r)&&r.length>0&&(s._receiverList=r)}else r&&(s=this._generateC2CMessage(e));return t.messageSender.sendMessage(s,e)})}_generateC2CMessage(A){const{message:e,OuterConstant:{CONV_C2C:t}}=this._core,i=t,o=e.messageHelper.parseServerPushMessage(A),n=e.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:i,flow:y.OUT})),{elements:r}=o;return n.setElement(r),n}_generateGroupMessage(A){const{message:e,OuterConstant:{CONV_GROUP:t}}=this._core,i=t,o=e.messageHelper.parseServerGroupMessage(A),n=e.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:i,flow:y.OUT})),{elements:r}=o;return n.setElement(r),n}},cA=new class{init(A){this._core=A;const{helper:e,notificationCenter:t,InnerEvent:{MESSAGE_PUSH:i},InnerEventSubType:{GROUP_MESSAGE_PINNED:o}}=A;t.subscribeInnerEvent(i,o,this._handleGroupMessagePinned,this),e.registerApi({apiName:"pinGroupMessage",context:this}),e.registerApi({apiName:"getPinnedGroupMessageList",context:this})}pinGroupMessage(t){return A(this,void 0,void 0,function*(){const{ssoLog:i,common:{isTopic:n},OuterConstant:{GROUP_ID_PREFIX:r},helper:{ChatError:s}}=this._core;let{groupID:a,message:g,isPinned:c}=t;const{sequence:l}=g;try{return yield function(t){return A(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:A,getCurrentUserID:i}}=e.core,{groupID:o,sequence:n,isPinned:r}=t,s=i(),a=r?"group_open_http_svc.pin_message":"group_open_http_svc.unpin_message",g={GroupId:o,MsgSeq:n};return r?g.Pinner_Account=s:g.UnPinner_Account=s,A({servcmd:a,data:g})})}({groupID:a,sequence:l,isPinned:c}),{code:0,data:{}}}catch(o){const{errorCode:e,errorInfo:t}=o||{};throw new s({code:e,message:t})}})}getPinnedGroupMessageList(t){return A(this,void 0,void 0,function*(){let i=[];try{const o=yield function(t){return A(this,void 0,void 0,function*(){const{groupID:A}=t,{common:{buildAndSendPacket:i}}=e.core;return i({servcmd:"group_open_http_svc.get_pinned_messages",data:{GroupId:A}})})}({groupID:t});if(o){const{PinnedMsgList:A=[]}=o;i=yield this._updatePinnedMessageInfo({serverPinnedMessageList:A,groupID:t})}return{code:0,data:{messageList:i}}}catch(o){throw o}})}_handleGroupMessagePinned(A){const{message:{messageHelper:e,messageFactory:t},notificationCenter:i,OuterEvent:o,OuterConstant:n}=this._core;A.GroupTips.forEach(A=>{const{ToGroupId:r,MsgBody:{PinnedMsg:s,OpType:a,MsgOperatorMemberExtraInfo:g,SdkGroupMessageId:c}}=A,{UserId:l,NickName:I="",ImageUrl:u=""}=g;let E=null,d=!1;if(a===D){d=!0;const A=e.parseServerGroupMessage(s);E=t.createMessage(Object.assign(Object.assign({},A),{conversationType:n.CONV_GROUP,flow:"in"})),E.setElement(A.elements),E.pinnerInfo={userID:l,nick:I,avatar:u}}else if(a===v){const{ClientTime:A,Random:e,SenderTinyId:t,ServerTime:i,MsgSeq:o}=c;E={ID:`${t}-${A}-${e}`,sequence:o,random:e,time:i,clientTime:A}}E&&i.emitOuterEvent(o.PINNED_GROUP_MESSAGE_UPDATED,{name:o.PINNED_GROUP_MESSAGE_UPDATED,data:{groupID:r,message:E,isPinned:d,operatorInfo:{userID:l,nick:I,avatar:u}}})})}_findMessageBySequence(A,e){const{message:{messageDataHandler:t}}=this._core;return[...t.getLocalMessageList(A),...t.getSparseMessageList(A)].find(A=>A.sequence===e)}_updatePinnedMessageInfo(e){return A(this,arguments,void 0,function*({serverPinnedMessageList:A,groupID:e}){const{OuterConstant:{CONV_GROUP:t},utils:{isEmpty:i}}=this._core,o=[],n=[],r=[],s=new Map,a=`${t}${e}`;for(let c=0;c{const{sequence:t}=e,i=s.get(t),o=A[i]||{userID:i,nick:"",avatar:""};e.pinnerInfo=o}),o.sort((A,e)=>A.sequence-e.sequence),o}return[]})}_fetchPinnedMessageInfo(e){return A(this,void 0,void 0,function*(){var A,t;const{message:{messageHistory:i},user:{userProfile:o},utils:{isArray:n}}=this._core,{conversationID:r,messageSequenceList:s,pinnerIDList:a}=e,g=yield Promise.all([this._fetchMessageBySequence({conversationID:r,messageSequenceList:s}),null==o?void 0:o.getUserProfile({userIDList:a})]);if(n(g)){const e={};return((null===(A=g[1])||void 0===A?void 0:A.data)||[]).forEach(A=>{const{userID:t,nick:i="",avatar:o=""}=A;e[t]={userID:t,nick:i,avatar:o}}),{messageList:(null===(t=g[0])||void 0===t?void 0:t.messageList)||[],pinnerInfoMap:e}}})}_fetchMessageBySequence(e){return A(this,void 0,void 0,function*(){const{utils:{isEmpty:A},message:{messageHistory:t}}=this._core,{conversationID:i,messageSequenceList:o}=e;return A(o)?[]:t.getGroupRoamingMessagesByAnchor({conversationID:i,messageSequenceList:o,getType:3})})}};return new class{constructor(){this.name="MessageEnhancer"}install(A){this._core=A,e.init(A),K.init(A),Z.init(A),AA.init(A),iA.init(A),L.init(A),oA.init(A),nA.init(A),U.init(A),aA.init(A),x.init(A),gA.init(A),cA.init(A),A.helper.registerValidateConfig({auth:H,params:J}),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.LOGOUT,this._reset,this),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this.dispose,this)}dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.LOGOUT,this._reset,this),A.unSubscribeInnerEvent(e.DESTROY,this.dispose,this),AA.dispose(),iA.dispose(),U.dispose(),x.dispose()}_reset(){iA.reset()}}}();const s_=RR(r_.exports);var a_={exports:{}};a_.exports=function(){function A(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{const e=this._getResponseBody(E,o,l&&I),i=this._buildResponse(E,e);if(200===E.status)t(null,i);else{if(I&&!u.includes(I))return A.url=this._domainName2IP(u,I),A.uploadByIP=!0,this.request(A,t);t({code:E.status,message:JSON.stringify(E.responseText)},i)}},E.onerror=()=>{const A=this._getResponseBody(E,o,l&&I),e=this._buildResponse(E,A),i={code:E.status,message:0===E.status?"CORS blocked or network error":JSON.stringify(E.responseText)};t(i,e)},A.onProgress&&E.upload&&(E.upload.onprogress=e=>{const{total:t,loaded:i}=e,o=Math.min(Math.floor(100*i/t),100);A.onProgress({total:t,loaded:i,percent:o/100})}),E.send(g),E})}_buildResponse(A,e){const t={};return A.getAllResponseHeaders().trim().split("\n").forEach(A=>{if(A){const[e,i]=A.split(":").map(A=>A.trim());t[e.toLowerCase()]=i}}),{statusCode:A.status,statusMessage:A.statusText,headers:t,data:e}}_getResponseBody(A,e,t){return 200===A.status&&e?{location:e,uploadIP:t}:{response:A.responseText,uploadIP:t}}_queryString(A,e="&",t="="){var i;const{isEmpty:o,isPlainObject:n}=null===(i=this._core)||void 0===i?void 0:i.utils;return o(A)?"":n(A)?Object.keys(A).map(i=>{const o=encodeURIComponent(i)+t;return Array.isArray(A[i])?A[i].map(A=>o+encodeURIComponent(A)).join(e):o+encodeURIComponent(A[i])}).filter(Boolean).join(e):void 0}_domainName2IP(A,e){return A.replace(/^http(s)?:\/\/(.*?)\//,`https://${e}/`)}};const i=["unknown","image","video","audio","log"];var o=new class{init(A){this._core=A}request(e,t){var o;const{MINI_APP_NAMESPACE:n,IN_ALIPAY_MINI_APP:r,isUniIOSApp:s}=null===(o=this._core)||void 0===o?void 0:o.utils,{resources:a="",headers:g={},url:c,downloadUrl:l=""}=e;let I=c,u=null;const E=l?l.match(/^(https?:\/\/[^/]+\/)([^/]*\/?)(.*)$/):null;if(!E)return void console.warn("message Invalid download URL format");const d=decodeURIComponent(E[3]),h=d.includes("?")?d.split("?")[0]:d||"",C={key:e.fileKey||h,success_action_status:200,"Content-Type":""},B={};if(s()){const[A,e]=c.split("?sign=");e&&(I=`${A}?sign=${encodeURIComponent(e)}`,B.sign=decodeURIComponent(e),B.signature=decodeURIComponent(e))}let Q={url:I,header:g,name:"file",filePath:a,formData:Object.assign(Object.assign({},C),B),timeout:e.timeout||3e5};if(r){const t=A(Q,["name"]);Q=Object.assign(Object.assign({},t),{fileName:"file",fileType:e.fileType?i[e.fileType]:"image"})}return u=n.uploadFile(Object.assign(Object.assign({},Q),{success:A=>{this._handleResponse({response:A,downloadUrl:l,callback:t})},fail:A=>{this._handleResponse({response:A,downloadUrl:l,callback:t})}})),u.onProgressUpdate&&u.onProgressUpdate(A=>{e.onProgress&&e.onProgress({total:A.totalBytesExpectedToSend||0,loaded:A.totalBytesSent||0,percent:A.progress?Math.floor(A.progress)/100:0})}),u}_handleResponse(A){const{downloadUrl:e,response:t,callback:i}=A,o={};if(t.header)for(const r in t.header)t.header.hasOwnProperty(r)&&(o[r.toLowerCase()]=t.header[r]);const n=+t.statusCode;200===n?i(null,{statusCode:n,headers:o,data:Object.assign(Object.assign({},t.data),{location:e})}):i({code:n,message:JSON.stringify(t.data)},{statusCode:n,headers:o,data:void 0})}};function n(A){return"file"===(e=A,Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase());var e}function r(A){const e=A||99999999;return Math.round(Math.random()*e)}function s(A,e=!0,t=!0){const i=Date.now();return e?t?i-A+" ms":`${Math.round((i-A)/1e3)} s`:t?i-A:Math.round((i-A)/1e3)}function a(A){return`${Array.from({length:8},()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1)).join("")}-${A}`}function g(A,e){return Math.round(Number(A)*10**e)/10**e}function c(A){return A<=1048576?`${g(A/1024,1)}KB/s`:`${g(A/1048576,1)}MB/s`}const l="TIMImageElem",I="TIMSoundElem",u="TIMFileElem",E="TIMVideoFileElem",d="RichMediaMessagePlugin",h=["rich.my-imcloud.com","imrich.qcloud.com"],C=1,B=2,Q=3,p=255;var f,m;(m=f||(f={})).UNSENT="unSend",m.SUCCESS="success",m.FAIL="fail";const y={wechat:/^(wxfile:\/\/tmp_|http:\/\/temp\/|cloud:\/\/temp-)/,alipay:/^(https:\/\/resource\/|alipayfile:\/\/tmp\/)/,baidu:/^(http:\/\/tmp\/|swanfile:\/\/tmp_)/,bytedance:/^(ttfile:\/\/tmp_|\/(var|tmp)\/|tttemp:\/\/)/,qq:/^(qqfile:\/\/tmp_|http:\/\/qtemp\/)/},D=Symbol("isCustomUpload");var v=new class{init(A){this._core=A}addAuthToUrl(A=""){if(this._isMiniProgramTempFile(A))return A;const e=(t=A)?t.startsWith("https://")?t:t.startsWith("http://")?t.replace("http://","https://"):t:"";var t;return this.processResourceUrl(e)}removeAuthToUrl(A){return function(A,e){const[t,i]=A.split("?");if(!i)return t;const o=i.split("&").reduce((A,t)=>{const[i,o]=t.split("=");return i&&i!==e&&(A[i]=o||""),A},{}),n=Object.keys(o).map(A=>`${A}${o[A]?`=${o[A]}`:""}`).join("&");return n?`${t}?${n}`:t}(A,"authKey")}_isMiniProgramTempFile(A){return!!this.getPlatformFlags().IN_MINI_APP&&Object.values(y).some(e=>e.test(A))}extractFileFromInput(A){const{utils:{isArray:e}}=this._core;return n(A)?A:function(A){if("object"!=typeof A||null===A)return!1;const e=Object.getPrototypeOf(A);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t}(A)&&"undefined"!=typeof uni?e(A.tempFiles)&&A.tempFiles.length>0?A.tempFiles[0]:e(A.files)?A.files[0]:A.tempFile?A.tempFile:null:A instanceof HTMLInputElement&&A.files&&A.files.length>0?A.files[0]:null}probeImageWidthHeight(A){return e(this,void 0,void 0,function*(){var e;const{IN_MINI_APP:t,IN_BROWSER:i}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};return this._shouldSkipProbing()?{width:0,height:0}:i?this._probeImageDimensionsWeb(A):t?this._probeImageDimensionsMiniApp(A):void 0})}isSimpleCos(){var A;const e=(null===(A=this._core)||void 0===A?void 0:A.store.get("cloudConfig"))||{},{simple_cos:t}=e;return"0"!==t}getFileDNList(){var A;let e=h;const t=(null===(A=this._core)||void 0===A?void 0:A.store.get("cloudConfig"))||{},{file_dn_list:i}=t;if(void 0===i)return e;try{JSON.parse(i).forEach(A=>{e.includes(A)||e.push(A)})}catch(o){console.warn(o),e=h}return e}getPlatform(){var A;return null===(A=this._core)||void 0===A?void 0:A.utils.platform}generateUUID(A,e){var t;let i=`${this.getSDKAppID()}-${this.getCurrentUserID()}-${null===(t=this._core)||void 0===t?void 0:t.utils.randomString()}`;if(e)return`${i}.${e}`;const o=A.name||A.value||A.url||A.tempFilePath,n=o&&o.slice(o.lastIndexOf(".")+1);return n&&(i=`${i}.${n}`),i}processResourceUrl(A){if(!A)return"";let e=A;const t=this.getFileDownloadProxy(),i=this.getAuthKey(),o=this.getFileDNList();return t&&(A.startsWith("http://")?e=A.replace(/^http:\/\/[^/]+/,t):A.startsWith("https://")&&(e=A.replace(/^https:\/\/[^/]+/,t))),i&&-1===e.indexOf("authKey=")&&function(A,e){let t=!1;if(A){const i=A.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),o=i&&i[2]||"";if(o.includes("rich-dev"))return!0;for(let A=0;A-1?`${e}&authKey=${i}`:`${e}?authKey=${i}`),e}getCurrentUserID(){var A,e;return null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("login"))||void 0===e?void 0:e.userId}getSDKAppID(){var A,e;return null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("instance"))||void 0===e?void 0:e.sdkAppId}getFileDownloadProxy(){var A,e;return(null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("instance"))||void 0===e?void 0:e.fileDownloadProxy)||""}getFileUploadProxy(){var A,e;return(null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("instance"))||void 0===e?void 0:e.fileUploadProxy)||""}getAuthKey(){var A,e;return(null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("login"))||void 0===e?void 0:e.authKey)||""}isPrivateNetWork(){var A,e;return null===(e=null===(A=this._core)||void 0===A?void 0:A.store.get("instance"))||void 0===e?void 0:e.proxyServer}getPlatformFlags(){var A;const{IN_BROWSER:e,IN_MINI_APP:t,IN_RN_APP:i,IN_UNI_NATIVE_APP:o}=null===(A=this._core)||void 0===A?void 0:A.utils;return{IN_BROWSER:e,IN_MINI_APP:t,IN_RN_APP:i,IN_UNI_NATIVE_APP:o}}isEmpty(A){var e;const{isEmpty:t}=null===(e=this._core)||void 0===e?void 0:e.utils;return t(A)}generateURL(A,e){const{needAddAuthToUrl:t=!0}=e||{};return t?this.addAuthToUrl(A):A}_probeImageDimensionsMiniApp(A){var e;const{MINI_APP_NAMESPACE:t}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};return new Promise(e=>{t.getImageInfo({src:A,success:A=>e({width:A.width,height:A.height}),fail:()=>e({width:0,height:0})})})}_shouldSkipProbing(){var A;const{IN_RN_APP:e,IS_IE:t,IE_VERSION:i,IN_WX_MINI_GAME:o}=(null===(A=this._core)||void 0===A?void 0:A.utils)||{};return e||t&&9===i||o}_probeImageDimensionsWeb(A){return new Promise(e=>{const t=new Image,i=()=>{t.onload=null,t.onerror=null,t.src=""};t.onload=()=>{e({width:t.width,height:t.height}),i()},t.onerror=()=>{e({width:0,height:0}),i()},t.src=A})}};function w(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var S,M={exports:{}},R=w((S||(S=1,function(A){A.exports=function(A){var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function t(A,e){var t=A[0],i=A[1],o=A[2],n=A[3];i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&o|~i&n)+e[0]-680876936|0)<<7|t>>>25)+i|0)&i|~t&o)+e[1]-389564586|0)<<12|n>>>20)+t|0)&t|~n&i)+e[2]+606105819|0)<<17|o>>>15)+n|0)&n|~o&t)+e[3]-1044525330|0)<<22|i>>>10)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&o|~i&n)+e[4]-176418897|0)<<7|t>>>25)+i|0)&i|~t&o)+e[5]+1200080426|0)<<12|n>>>20)+t|0)&t|~n&i)+e[6]-1473231341|0)<<17|o>>>15)+n|0)&n|~o&t)+e[7]-45705983|0)<<22|i>>>10)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&o|~i&n)+e[8]+1770035416|0)<<7|t>>>25)+i|0)&i|~t&o)+e[9]-1958414417|0)<<12|n>>>20)+t|0)&t|~n&i)+e[10]-42063|0)<<17|o>>>15)+n|0)&n|~o&t)+e[11]-1990404162|0)<<22|i>>>10)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&o|~i&n)+e[12]+1804603682|0)<<7|t>>>25)+i|0)&i|~t&o)+e[13]-40341101|0)<<12|n>>>20)+t|0)&t|~n&i)+e[14]-1502002290|0)<<17|o>>>15)+n|0)&n|~o&t)+e[15]+1236535329|0)<<22|i>>>10)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&n|o&~n)+e[1]-165796510|0)<<5|t>>>27)+i|0)&o|i&~o)+e[6]-1069501632|0)<<9|n>>>23)+t|0)&i|t&~i)+e[11]+643717713|0)<<14|o>>>18)+n|0)&t|n&~t)+e[0]-373897302|0)<<20|i>>>12)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&n|o&~n)+e[5]-701558691|0)<<5|t>>>27)+i|0)&o|i&~o)+e[10]+38016083|0)<<9|n>>>23)+t|0)&i|t&~i)+e[15]-660478335|0)<<14|o>>>18)+n|0)&t|n&~t)+e[4]-405537848|0)<<20|i>>>12)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&n|o&~n)+e[9]+568446438|0)<<5|t>>>27)+i|0)&o|i&~o)+e[14]-1019803690|0)<<9|n>>>23)+t|0)&i|t&~i)+e[3]-187363961|0)<<14|o>>>18)+n|0)&t|n&~t)+e[8]+1163531501|0)<<20|i>>>12)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i&n|o&~n)+e[13]-1444681467|0)<<5|t>>>27)+i|0)&o|i&~o)+e[2]-51403784|0)<<9|n>>>23)+t|0)&i|t&~i)+e[7]+1735328473|0)<<14|o>>>18)+n|0)&t|n&~t)+e[12]-1926607734|0)<<20|i>>>12)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i^o^n)+e[5]-378558|0)<<4|t>>>28)+i|0)^i^o)+e[8]-2022574463|0)<<11|n>>>21)+t|0)^t^i)+e[11]+1839030562|0)<<16|o>>>16)+n|0)^n^t)+e[14]-35309556|0)<<23|i>>>9)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i^o^n)+e[1]-1530992060|0)<<4|t>>>28)+i|0)^i^o)+e[4]+1272893353|0)<<11|n>>>21)+t|0)^t^i)+e[7]-155497632|0)<<16|o>>>16)+n|0)^n^t)+e[10]-1094730640|0)<<23|i>>>9)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i^o^n)+e[13]+681279174|0)<<4|t>>>28)+i|0)^i^o)+e[0]-358537222|0)<<11|n>>>21)+t|0)^t^i)+e[3]-722521979|0)<<16|o>>>16)+n|0)^n^t)+e[6]+76029189|0)<<23|i>>>9)+o|0,i=((i+=((o=((o+=((n=((n+=((t=((t+=(i^o^n)+e[9]-640364487|0)<<4|t>>>28)+i|0)^i^o)+e[12]-421815835|0)<<11|n>>>21)+t|0)^t^i)+e[15]+530742520|0)<<16|o>>>16)+n|0)^n^t)+e[2]-995338651|0)<<23|i>>>9)+o|0,i=((i+=((n=((n+=(i^((t=((t+=(o^(i|~n))+e[0]-198630844|0)<<6|t>>>26)+i|0)|~o))+e[7]+1126891415|0)<<10|n>>>22)+t|0)^((o=((o+=(t^(n|~i))+e[14]-1416354905|0)<<15|o>>>17)+n|0)|~t))+e[5]-57434055|0)<<21|i>>>11)+o|0,i=((i+=((n=((n+=(i^((t=((t+=(o^(i|~n))+e[12]+1700485571|0)<<6|t>>>26)+i|0)|~o))+e[3]-1894986606|0)<<10|n>>>22)+t|0)^((o=((o+=(t^(n|~i))+e[10]-1051523|0)<<15|o>>>17)+n|0)|~t))+e[1]-2054922799|0)<<21|i>>>11)+o|0,i=((i+=((n=((n+=(i^((t=((t+=(o^(i|~n))+e[8]+1873313359|0)<<6|t>>>26)+i|0)|~o))+e[15]-30611744|0)<<10|n>>>22)+t|0)^((o=((o+=(t^(n|~i))+e[6]-1560198380|0)<<15|o>>>17)+n|0)|~t))+e[13]+1309151649|0)<<21|i>>>11)+o|0,i=((i+=((n=((n+=(i^((t=((t+=(o^(i|~n))+e[4]-145523070|0)<<6|t>>>26)+i|0)|~o))+e[11]-1120210379|0)<<10|n>>>22)+t|0)^((o=((o+=(t^(n|~i))+e[2]+718787259|0)<<15|o>>>17)+n|0)|~t))+e[9]-343485551|0)<<21|i>>>11)+o|0,A[0]=t+A[0]|0,A[1]=i+A[1]|0,A[2]=o+A[2]|0,A[3]=n+A[3]|0}function i(A){var e,t=[];for(e=0;e<64;e+=4)t[e>>2]=A.charCodeAt(e)+(A.charCodeAt(e+1)<<8)+(A.charCodeAt(e+2)<<16)+(A.charCodeAt(e+3)<<24);return t}function o(A){var e,t=[];for(e=0;e<64;e+=4)t[e>>2]=A[e]+(A[e+1]<<8)+(A[e+2]<<16)+(A[e+3]<<24);return t}function n(A){var e,o,n,r,s,a,g=A.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=g;e+=64)t(c,i(A.substring(e-64,e)));for(o=(A=A.substring(e-64)).length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e>2]|=A.charCodeAt(e)<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(t(c,n),e=0;e<16;e+=1)n[e]=0;return r=(r=8*g).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),a=parseInt(r[1],16)||0,n[14]=s,n[15]=a,t(c,n),c}function r(A){var e,i,n,r,s,a,g=A.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=g;e+=64)t(c,o(A.subarray(e-64,e)));for(i=(A=e-64>2]|=A[e]<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(t(c,n),e=0;e<16;e+=1)n[e]=0;return r=(r=8*g).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),a=parseInt(r[1],16)||0,n[14]=s,n[15]=a,t(c,n),c}function s(A){var t,i="";for(t=0;t<4;t+=1)i+=e[A>>8*t+4&15]+e[A>>8*t&15];return i}function a(A){var e;for(e=0;ec?new ArrayBuffer(0):(o=c-g,n=new ArrayBuffer(o),r=new Uint8Array(n),s=new Uint8Array(this,g,o),r.set(s),n)}}(),E.prototype.append=function(A){return this.appendBinary(g(A)),this},E.prototype.appendBinary=function(A){this._buff+=A,this._length+=A.length;var e,o=this._buff.length;for(e=64;e<=o;e+=64)t(this._hash,i(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},E.prototype.end=function(A){var e,t,i=this._buff,o=i.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=i.charCodeAt(e)<<(e%4<<3);return this._finish(n,o),t=a(this._hash),A&&(t=u(t)),this.reset(),t},E.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},E.prototype.setState=function(A){return this._buff=A.buff,this._length=A.length,this._hash=A.hash,this},E.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},E.prototype._finish=function(A,e){var i,o,n,r=e;if(A[r>>2]|=128<<(r%4<<3),r>55)for(t(this._hash,A),r=0;r<16;r+=1)A[r]=0;i=(i=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(i[2],16),n=parseInt(i[1],16)||0,A[14]=o,A[15]=n,t(this._hash,A)},E.hash=function(A,e){return E.hashBinary(g(A),e)},E.hashBinary=function(A,e){var t=a(n(A));return e?u(t):t},E.ArrayBuffer=function(){this.reset()},E.ArrayBuffer.prototype.append=function(A){var e,i=I(this._buff.buffer,A),n=i.length;for(this._length+=A.byteLength,e=64;e<=n;e+=64)t(this._hash,o(i.subarray(e-64,e)));return this._buff=e-64>2]|=i[e]<<(e%4<<3);return this._finish(n,o),t=a(this._hash),A&&(t=u(t)),this.reset(),t},E.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.ArrayBuffer.prototype.getState=function(){var A=E.prototype.getState.call(this);return A.buff=l(A.buff),A},E.ArrayBuffer.prototype.setState=function(A){return A.buff=c(A.buff,!0),E.prototype.setState.call(this,A)},E.ArrayBuffer.prototype.destroy=E.prototype.destroy,E.ArrayBuffer.prototype._finish=E.prototype._finish,E.ArrayBuffer.hash=function(A,e){var t=a(r(new Uint8Array(A)));return e?u(t):t},E}()}(M)),M.exports)),_=new class{constructor(){this.uploadFileTryCount=0,this.maxRetries=1,this.systemClockOffset=0,this.httpRequest=null,this.uploadFileType="",this.duration=900,this.fetchCosTryCount=0}init(A){var e;this._core=A;const{IN_MINI_APP:i}=A.utils;this.httpRequest=i?o:t,null===(e=this.httpRequest)||void 0===e||e.init(A)}uploadToCOS(A){return e(this,void 0,void 0,function*(){const e=`${d} uploadToCOS`,{ssoLog:t,utils:{safeStringify:i}}=this._core,{file:o}=A;this.uploadFileType=A.uploadFileType,t.debug("uploadToCOS",`${e} options:${i(A)}`);try{const i=Date.now(),n=yield this._createCosOptions(A),r=n.fileExistsInCOS?{data:{location:n.downloadUrl}}:yield this._uploadFile(n);this._handleUploadError(r,A);const s=this._createUploadResult(o,r),a=Date.now()-i,g=`size:${function(A){const e=1024,t=1048576;return Athis._handleUploadProgress(e,A)}}catch(n){throw console.error("Failed to create COS pre-signed URL options:",n),n}})}_prepareUploadParams(A){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t,isEmpty:i}}=this._core;e.debug("_prepareUploadParams",` prepareUploadParams:${t(A)}`);const{file:o}=A,{IN_MINI_APP:n,IN_RN_APP:s}=v.getPlatformFlags(),g=n||s,c=g&&A.message.type!==u,{name:l}=o,I=l.slice(l.lastIndexOf(".")),E=`${r(999999)}${I}`,d=c?o.name:E,h=yield this._generateHashFileName(o);return{fileName:i(h)?a(d):`${h}${I}`,resources:g?o.url:o,uploadMethod:g?1:0}})}_generateHashFileName(A){return e(this,void 0,void 0,function*(){const{utils:{IN_MINI_APP:e,IN_BROWSER:t,IN_UNI_NATIVE_APP:i,isArray:o},ssoLog:n}=this._core,r=Date.now();let s="";return t&&(s=yield this._generateHashFileNameInWeb(A)),e&&(o(A.tempFiles)&&(A=A.tempFiles[0]),i||(s=yield this._generateFileNameInMiniProgram(A)),i&&(s=yield this._generateFileNameInUNINativeApp(A))),n.info("_generateHashFileName",`hashFileName:${s} costTime:${Date.now()-r}`),s})}_generateHashFileNameInWeb(A){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;let i="";try{i=yield new Promise((t,i)=>{const o=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;o||(e.warn("_generateHashFileNameInWeb","Browser does not support file slicing"),t(""));const n=10485760,r=Math.ceil(A.size/n);let s=0;const a=new R.ArrayBuffer,g=new FileReader,c=setTimeout(()=>{g.abort(),e.warn("_generateHashFileNameInWeb","File hash generation timeout"),t("")},2e3);function l(){const e=s*n,t=e+n>=A.size?A.size:e+n;g.readAsArrayBuffer(o.call(A,e,t))}g.onload=A=>{e.debug("_generateHashFileNameInWeb",`read chunk nr ${s+1} of ${r}`),a.append(A.target.result),s++,s{clearTimeout(c),i(A)},l()})}catch(o){e.warn("_generateHashFileNameInWeb",t(o))}return i})}_generateFileNameInMiniProgram(A){return e(this,void 0,void 0,function*(){const{utils:{MINI_APP_NAMESPACE:e,safeStringify:t,isEmpty:i},ssoLog:o}=this._core;let n="";if(i(A.url))return o.warn("_generateFileNameInMiniProgram","file.url is empty"),n;if("function"!=typeof(null==e?void 0:e.getFileSystemManager))return o.warn("_generateFileNameInUNINativeApp","getFileSystemManager is not a function"),n;try{n=yield new Promise((t,i)=>{e.getFileSystemManager().getFileInfo({filePath:A.url,success:A=>{t(A.digest)},fail:A=>{i(A)}})})}catch(r){o.warn("_generateFileNameInMiniProgram",t(r))}return n})}_generateFileNameInUNINativeApp(A){return e(this,void 0,void 0,function*(){var e;const{utils:{safeStringify:t,isEmpty:i},ssoLog:o}=this._core;let n="";if(i(A.url))return o.warn("_generateFileNameInUNINativeApp","file.url is empty"),n;if("function"!=typeof(null===(e=null===plus||void 0===plus?void 0:plus.io)||void 0===e?void 0:e.getFileInfo))return o.warn("_generateFileNameInUNINativeApp","plus.io.getFileInfo is not a function"),n;try{n=yield new Promise((e,t)=>{plus.io.getFileInfo({filePath:A.url,success:A=>{e(A.digest)},fail:A=>{t(A)}})})}catch(r){o.warn("_generateFileNameInMiniProgram",t(r))}return n})}_handleUploadProgress(A,e){if("function"==typeof e.onProgress)try{e.onProgress(A.percent)}catch(t){throw console.warn("Upload progress callback error:",t),t}}_fetchCosSignatureUrl(A){return e(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:i}}=this._core,o=v.isSimpleCos(),n=this._prepareCosRequestData(A),r=o?"im_cos_msg.simple_sig":"im_cos_msg.pre_sig";try{const A=yield function(A,t,i){return e(this,void 0,void 0,function*(){try{const{helper:e,channel:o}=i,n=e.generateCosSpecifiedData({servcmd:A,data:t}),r=`${n.head.seq}${A}`;return yield o.sendPacket(n,{requestId:r})}catch(e){throw console.warn("getCosSig error:",e),e}})}(r,n,this._core);this.fetchCosTryCount=0;const s=this._processResponse(A);return t.debug("_fetchCosSignatureUrl",` ok. isSimpleCos:${o} data:${i(s)}`),s||{}}catch(s){if(this.fetchCosTryCount<1)return this.fetchCosTryCount++,this._fetchCosSignatureUrl(A);throw this.fetchCosTryCount=0,s}})}_processResponse(A){var e;const t=v.isSimpleCos(),i=t?null===(e=null==A?void 0:A.rpt_pre_sig)||void 0===e?void 0:e[0]:A;if(!i)return{};if(t){const{str_final_ip:A,rpt_pre_sig:e,uint32_file_id:t,uint32_exist_flag:o,str_download_url:n,str_upload_url:r,str_snapshot_url:s,str_file_key:a}=i;return{uploadIP:A,preSig:e,fileID:t,existFlag:o,downloadUrl:n,uploadUrl:r,requestSnapshotUrl:s,fileKey:a}}const{upload_url:o,download_url:n,snapshot_url:r,thumb_url:s,large_url:a,file_key:g}=i;return{uploadUrl:o,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:s,largeUrl:a,fileKey:g}}_prepareCosRequestData(A){return v.isSimpleCos()?{uint32_upload_method:A.uploadMethod,uint32_platform:v.getPlatform(),uint32_sdkappid:v.getSDKAppID(),str_user_id:A.userID,uint32_scene:A.conversationType,rpt_upload_object:[{uint32_file_id:1,uint32_file_type:A.fileType,str_file_name:A.fileName}]}:{file_type:A.fileType,file_name:A.fileName,upload_method:A.uploadMethod,Duration:A.duration}}_uploadFile(A){return e(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.httpRequest.request(A,(i,o)=>{i&&this.uploadFileTryCount=3e4}_syncSystemClock(A){var e,t,i;const o=(null===(e=A.headers)||void 0===e?void 0:e.date)||(null===(t=A.headers)||void 0===t?void 0:t.Date)||(null===(i=A.error)||void 0===i?void 0:i.ServerTime);if(o){const A=Date.now(),e=Date.parse(o);this.systemClockOffset=e-A}}_getRawOrUploadProxyUrl(A){const e=v.getFileUploadProxy();let t=A;return e&&(t=A.replace(/^https:\/\/[^/]+/,e)),t}_isC2CConversation(A){return"C2C"===A.slice(0,3)}};const T=2108,N=2251,b=2252,G=2253,k=["jpg","jpeg","gif","png","bmp","image","webp"],L={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255};class U{constructor(A,e){this.instanceID=r(9999999),this.sizeType=A.type||0,this.type=0,this.size=A.size||0,this.width=A.width||0,this.height=A.height||0,this.imageUrl=v.addAuthToUrl(A.imageUrl||A.url||""),this.url=v.addAuthToUrl(A.url||e)}setSizeType(A){this.sizeType=A}setType(A){this.type=A}setImageUrl(A){A&&(this.imageUrl=v.addAuthToUrl(A))}getImageUrl(){return this.imageUrl}}function F(e){const{originUrl:t,originWidth:i,originHeight:o,min:n=198}=e,r=parseInt(i)||0,s=parseInt(o)||0,a={url:void 0,width:0,height:0};if((r<=s?r:s)<=n)a.url=t,a.width=r,a.height=s;else{s<=r?(a.width=Math.ceil(r*n/s),a.height=n):(a.width=n,a.height=Math.ceil(s*n/r));const A=t&&t.indexOf("?")>-1?`${t}&`:`${t}?`;a.url=198===n?`${A}imageView2/3/w/198/h/198`:`${A}imageView2/3/w/720/h/720`}return void 0===t?A(a,["url"]):a}class O{constructor(A){this._imageMemoryURL="",this._percent=0,this.type=l;const{uuid:e,file:t,imageFormat:i,imageInfoArray:o=[],isCustomUpload:n=!1}=A;this._imageMemoryURL=this.createImageDataAsURL(t),this.content={imageFormat:i,uuid:e,imageInfoArray:[]},this[D]=n,this.initImageInfoArray(o),this.autoFixUrl()}static parseServerPushElement(A){const{MsgContent:e}=A,{ImageFormat:t,ImageInfoArray:i,UUID:o}=e,n=i.map(A=>({size:A.Size,type:A.Type,width:A.Width,height:A.Height,url:A.URL}));return new O({imageFormat:t,imageInfoArray:n,uuid:o})}createImageDataAsURL(A){let e="";const{IN_MINI_APP:t,IN_RN_APP:i,IN_BROWSER:o}=v.getPlatformFlags();return A?((t||i)&&(e=A.url),o&&(e=window.URL.createObjectURL(A)),e):e}initImageInfoArray(A=[]){const e={type:0,size:0,width:0,height:0,url:""};for(let t=0;t<3;t++){const i=A[t]||Object.assign({},e),o=new U(i,this._imageMemoryURL);o.setSizeType(t+1),o.setType(t),this.addImageInfo(o)}this.updateAccessSideImageInfoArray()}autoFixUrl(){const A=["http","https"];this.content.imageInfoArray.forEach(e=>{if(!e.url||""===e.imageUrl)return;const[t,...i]=e.imageUrl.split("://"),o=i.join("://");A.includes(t)||e.setImageUrl(`https://${o}`)})}updatePercent(A){this._percent=Math.min(A,1)}updateImageFormat(A){this.content.imageFormat=L[A.toUpperCase()]||L.UNKNOWN}addImageInfo(A){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(A)}updateImageInfoArray(A){const e=this.content.imageInfoArray.length;let t;for(let i=0;i({InstanceId:A.instanceID,Type:A.sizeType,MsgType:A.type,Size:A.size,Width:A.width,Height:A.height,URL:v.removeAuthToUrl(A.imageUrl)}))}}var x=new class{constructor(){this._messageOptionsMap=new Map}init(A){var e;this._core=A;const{notificationCenter:t,helper:i,InnerEvent:o,message:n}=A;i.registerApi({apiName:"createImageMessage",context:this}),i.registerExperimentalAPI("createImageMessage",this,"createCustomUploadImageMessage"),null===(e=null==n?void 0:n.messageFactory)||void 0===e||e.registerElementClass(l,O),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createImageMessage(A){var e,t,i;try{const o=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,n=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:o})),r=this._processImage(A);A.payload.file=r;const s={imageFormat:L.UNKNOWN,uuid:v.generateUUID(r),file:r,imageInfoArray:[]},a=new O(s);return n.setElement(a),this._messageOptionsMap.set(n.clientSequence,A),n}catch(o){throw o}}createCustomUploadImageMessage(A){var e,t,i,o;const{store:n,utils:{isEmpty:r}}=this._core,s=null===(e=n.get("login"))||void 0===e?void 0:e.userId,a=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:s})),{largeImageUuid:g,largeFileSize:c,largeImageWidth:l,largeImageHeight:I,largeImageUrl:u,originImageUuid:E,originFileSize:d,originImageWidth:h,originImageHeight:C,originImageUrl:B,thumbImageUuid:Q,thumbFileSize:p,thumbImageWidth:f,thumbImageHeight:m,thumbImageUrl:y}=(null===(o=null==A?void 0:A.payload)||void 0===o?void 0:o.file)||{};if(r(B)||r(E))throw new Error("createImageMessageExperimental originImageUrl or originImageUuid is empty");const D=new O({imageFormat:L.UNKNOWN,uuid:E,imageInfoArray:[{instanceID:E,size:d,width:h,height:C,imageUrl:B,url:B},{instanceID:g,size:c,width:l,height:I,imageUrl:u,url:u},{instanceID:Q,size:p,width:f,height:m,imageUrl:y,url:y}],isCustomUpload:!0});return a.setElement(D),this._messageOptionsMap.set(a.clientSequence,A),a._skipUpload=!0,a}upload(A){return e(this,void 0,void 0,function*(){const e=A.getElements()[0],{file:t}=this._messageOptionsMap.get(A.clientSequence).payload;this._validateBeforeUploadImage(t);const i=yield this._performImageUpload(e,A,t),o=this._generateImageInfo(i);return e.updateImageFormat(null==i?void 0:i.fileType),e.updateImageInfoArray(o),A})}_performImageUpload(A,t,i){return e(this,void 0,void 0,function*(){const{to:e}=t,o={uploadFileType:C,file:i,to:e,message:t,onProgress:e=>{var i,o;A.updatePercent(e),null===(o=null===(i=this._messageOptionsMap.get(t.clientSequence))||void 0===i?void 0:i.onProgress)||void 0===o||o.call(i,e)}},{uploadOptions:n,response:r}=yield _.uploadToCOS(o);return this._parseResponse(n,r)})}_generateImageInfo(A){const{location:e,fileSize:t,width:i,height:o,smallImageUrl:n,smallImageWidth:r,smallImageHeight:s,largeImageUrl:a,largeImageWidth:g,largeImageHeight:c,imageInfoArray:l}=A,I=v.addAuthToUrl(e),u={size:t,url:I,width:i,height:o};return(null==l?void 0:l.length)>0?this._processImageInfoArray(l,t):n&&a?[Object.assign({},u),{largeImageUrl:a,largeImageWidth:g,largeImageHeight:c},{smallImageUrl:n,smallImageWidth:r,smallImageHeight:s}]:[Object.assign({},u),this._generateThumbInfo(I,i,o,720),this._generateThumbInfo(I,i,o,198)]}_generateThumbInfo(A,e,t,i){return F({originUrl:A,originWidth:e,originHeight:t,min:i})}_processImageInfoArray(A,e){let t,i,o;for(const n of A)1===n.type?(i=n,i.size=e):2===n.type?(o=n,o.size=e):(t=n,t.size=e);return[Object.assign({},t),Object.assign({},o),Object.assign({},i)]}_parseResponse(A,t){return e(this,void 0,void 0,function*(){try{const{thumbUrl:e,largeUrl:i,downloadUrl:o}=A;if(e&&i&&(yield this._getImageInfoByUrl(e,t,"thumb"),yield this._getImageInfoByUrl(i,t,"large")),v.isSimpleCos()&&!v.isPrivateNetWork()&&(yield this._getImageInfoArray(o,t),null==t?void 0:t.uploadIP)){const A=this._extractDomainFromUrl(o);A&&(yield this._getDownloadIP(A,t))}return t}catch(e){throw e}})}_extractDomainFromUrl(A){var e;try{const e=A.match(/:\/\/([^\/]+)/);return e?e[1]:null}catch(t){return null===(e=this._core)||void 0===e||e.ssoLog.warn("_extractDomainFromUrl",`Failed to extract domain from URL:${t.message}`),null}}_getImageInfoByUrl(A,t,i){return e(this,void 0,void 0,function*(){var e;try{const e=v.addAuthToUrl(A),{width:o=0,height:n=0}=yield v.probeImageWidthHeight(e);t.width=o,t.height=n,"thumb"===i?(t.smallImageUrl=A,t.smallImageWidth=o,t.smallImageHeight=n):(t.largeImageUrl=A,t.largeImageWidth=o,t.largeImageHeight=n)}catch(o){null===(e=this._core)||void 0===e||e.ssoLog.warn("_getImageInfoByUrl",`Failed to get ${i} image info:${o.message}`)}})}_validateBeforeUploadImage(A){var e;const{ChatError:t}=null===(e=this._core)||void 0===e?void 0:e.helper;if(!A)throw new t({code:N});this._checkImageType(A),this._checkImageSize(A)}_processImage(A){var e;try{const{IN_MINI_APP:t}=null===(e=this._core)||void 0===e?void 0:e.utils;let{file:i}=A.payload;return i=t?this._processMiniAppImageFile(i):this._processWebImageFile(i),i}catch(t){throw t}}_processMiniAppImageFile(A){n(A)&&console.warn("FileUnsupportedInMiniApp","createImageMessage");const e=A.tempFiles[0].path||A.tempFiles[0].tempFilePath;return{url:e,name:e.slice(e.lastIndexOf("/")+1),size:A.tempFiles&&A.tempFiles[0].size||1,type:e.slice(e.lastIndexOf(".")+1).toLowerCase()}}_processWebImageFile(A){var e;const{ChatError:t}=null===(e=this._core)||void 0===e?void 0:e.helper,i=v.extractFileFromInput(A);if(!i)throw new t({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return i}_getDownloadIP(A,t){return e(this,void 0,void 0,function*(){const i=`${d} getDownloadIP domainName: ${A}`;try{const o=yield function(A,t){return e(this,void 0,void 0,function*(){try{const{helper:e,channel:i}=t,o="im_cos_msg.get_final_ip",n={str_domain:A},r=e.generateProtocolData({servcmd:o,data:n}),s=`${r.head.seq}${o}`;return yield i.sendPacket(r,{requestId:s})}catch(e){throw console.warn("getFinalIP error:",e),e}})}(A,this._core);if(!o||!o.str_final_ip)return;console.log(`${i} ok. downloadIP:${o}`);const n=t.location.split("/");n[0]=o.str_final_ip,t.location=n.join("/")}catch(o){console.warn(o)}})}_getImageInfoArray(A,t){return e(this,void 0,void 0,function*(){try{const i=yield function(A,t){return e(this,void 0,void 0,function*(){try{const{helper:e,channel:i}=t,o="im_cos_msg.get_imageinfo",n={str_image_url:A},r=e.generateProtocolData({servcmd:o,data:n}),s=`${r.head.seq}${o}`;return yield i.sendPacket(r,{requestId:s})}catch(e){throw console.warn("getImageInfo error:",e),e}})}(A,this._core);return t.imageInfoArray=this._processImageInfoResponse(i),t}catch(i){throw t.imageInfoArray=void 0,i}})}_processImageInfoResponse(A){if(!A)return[];const{rpt_msg_image_info:e}=A;return e.map(A=>({type:A.uint32_image_type,url:A.str_url,width:A.uint32_width,height:A.uint32_height,imageFormat:A.str_image_format}))}_checkImageType(A){const{utils:e,helper:t}=this._core;let i="";if(e.IN_MINI_APP&&(i=A.url.slice(A.url.lastIndexOf(".")+1)),e.IN_BROWSER&&(i=A.name.slice(A.name.lastIndexOf(".")+1)),k.indexOf(i.toLowerCase())<0)throw new t.ChatError({code:b})}_checkImageSize(A){const{utils:e,helper:t}=this._core;let i=0;if(e.IN_MINI_APP,i=A.size,0===i)throw new t.ChatError({code:T});if(i>=20971520)throw new t.ChatError({code:G})}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}};const P=2108,Y=2401,J=2402,H="2.5.0",q="1.18.0";function V(A,e){const t=A.split("."),i=e.split("."),o=Math.max(t.length,i.length);for(;t.lengthe)return 1;if(A0;return{isValid:A,error:A?null:{message:"content can not be empty"}}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{uuid:i,downloadFlag:o,fileUrl:n,fileName:r,fileSize:s}=t;return{MsgType:this.type,MsgContent:{Download_Flag:o,Url:v.removeAuthToUrl(n),FileName:r,FileSize:s,UUID:i}}}_getFileInfo(A){const{utils:{IN_UNI_NATIVE_APP:e}}=j.core;if(A.fileName&&A.fileSize)return{size:A.fileSize,name:A.fileName};const{file:t}=A;return t?(e&&this._processNativeAppFile(t),{size:t.size,name:t.name}):{size:0,name:""}}_processNativeAppFile(A){if(A.path&&A.path.includes(".")){const e=A.path.slice(A.path.lastIndexOf(".")+1).toLowerCase();A.type=e,A.name||(A.name=`${r(999999)}.${e}`)}A.name||(A.type="",A.name=A.path.slice(A.path.lastIndexOf("/")+1).toLowerCase()),A.suffix&&(A.type=A.suffix),A.url||(A.url=A.path)}}K=D;var z=new class{constructor(){this._messageOptionsMap=new Map}init(A){var e;this._core=A;const{notificationCenter:t,helper:i,InnerEvent:o,message:n}=A;i.registerApi({apiName:"createFileMessage",context:this}),i.registerExperimentalAPI("createFileMessage",this,"createCustomUploadFileMessage"),null===(e=null==n?void 0:n.messageFactory)||void 0===e||e.registerElementClass(u,W),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createFileMessage(A){var e,t,i;try{this._checkVersion();const o=this._processFile(A.payload.file);A.payload.file=o;const n=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,r=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:n})),s={uuid:v.generateUUID(o),file:o},a=new W(s);return r.setElement(a),this._messageOptionsMap.set(r.clientSequence,A),r}catch(o){throw o}}createCustomUploadFileMessage(A){var e,t,i;try{const{store:o,message:n,utils:{isEmpty:r}}=this._core,s=null===(e=o.get("login"))||void 0===e?void 0:e.userId,{url:a,uuid:g,fileSize:c,fileName:l=""}=(null===(t=null==A?void 0:A.payload)||void 0===t?void 0:t.file)||{};if(r(a))throw new Error("url is required");const I=null===(i=n.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:s})),u=new W({url:a,uuid:g,file:{size:c,name:l},isCustomUpload:!0});return I.setElement(u),I}catch(o){throw o}}upload(A){return e(this,void 0,void 0,function*(){const{file:e}=this._messageOptionsMap.get(A.clientSequence).payload;this._validateBeforeUploadFile(e);const t=A.getElements()[0],i=yield this._performFileUpload(t,A,e),o=v.addAuthToUrl(null==i?void 0:i.location);return t.updateFileUrl(o),A})}_validateBeforeUploadFile(A){var e;const{ChatError:t}=null===(e=this._core)||void 0===e?void 0:e.helper;if(!A)throw new t({code:Y});if(A.size>104857600)throw new t({code:J});if(0===A.size)throw new t({code:P})}_performFileUpload(A,t,i){return e(this,void 0,void 0,function*(){const{to:e}=t,o={uploadFileType:p,file:i,to:e,message:t,onProgress:e=>{var i,o;A.updatePercent(e),null===(o=null===(i=this._messageOptionsMap.get(t.clientSequence))||void 0===i?void 0:i.onProgress)||void 0===o||o.call(i,e)}},{response:n}=yield _.uploadToCOS(o);return n})}_processFile(A){var e,t;const{IN_BROWSER:i,IN_RN_APP:o,IN_WX_MINI_APP:n,IN_QQ_MINI_APP:r,IN_UNI_NATIVE_APP:s}=null===(e=this._core)||void 0===e?void 0:e.utils,{ChatError:a}=null===(t=this._core)||void 0===t?void 0:t.helper;if(i||s){const e=v.extractFileFromInput(A);if(!e)throw new a({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return e}if(n||r){const{tempFiles:e}=A;return Object.assign(Object.assign({},e[0]),{url:e[0].path})}return o?Object.assign(Object.assign({},A),{url:A.uri}):A}_checkVersion(){var A,e;const{MINI_APP_NAMESPACE:t,IN_MINI_APP:i,IN_WX_MINI_APP:o,IN_QQ_MINI_APP:n,IN_UNI_NATIVE_APP:r}=null===(A=this._core)||void 0===A?void 0:A.utils,{ChatError:s}=null===(e=this._core)||void 0===e?void 0:e.helper;if(i){if(!(o||n||r))throw new s({message:"Unsupported mini app environment"});const A=t.getSystemInfoSync().SDKVersion;if(o&&V(A,H)<0)throw new s({message:`WXChooseMessageFile requires SDK version ${H} or higher`});if(n&&V(A,q)<0)throw new s({message:`QQChooseMessageFile requires SDK version ${q} or higher`})}}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}};const Z=2108,X=2351,$=2352,AA=["mp4","quicktime","mov"];var eA;class tA{constructor(A){this.type=E,this.uploadProgress=0,this[eA]=!1;const e="number"==typeof(null==A?void 0:A.videoSecond)?null==A?void 0:A.videoSecond:0;this[D]=A.isCustomUpload||!1,this.content={remoteVideoUrl:v.addAuthToUrl(A.remoteVideoUrl||A.videoUrl||""),videoFormat:A.videoFormat,videoSecond:parseInt(null==e?void 0:e.toString(),10),videoSize:A.videoSize,videoUrl:v.addAuthToUrl(A.videoUrl),videoDownloadFlag:2,videoUUID:A.videoUUID,thumbUUID:A.thumbUUID,thumbFormat:A.thumbFormat,thumbWidth:A.thumbWidth,snapshotWidth:A.thumbWidth,thumbHeight:A.thumbHeight,snapshotHeight:A.thumbHeight,thumbSize:A.thumbSize,snapshotSize:A.thumbSize,thumbDownloadFlag:2,thumbUrl:v.addAuthToUrl(A.thumbUrl),snapshotUrl:v.addAuthToUrl(A.thumbUrl)}}static parseServerPushElement(A){const{MsgContent:e}=A,{VideoUrl:t,VideoFormat:i,VideoSecond:o,VideoSize:n,VideoDownloadFlag:r,VideoUUID:s,ThumbUUID:a,ThumbFormat:g,ThumbWidth:c,SnapshotWidth:l,ThumbHeight:I,SnapshotHeight:u,ThumbSize:E,SnapshotSize:d,ThumbDownloadFlag:h,ThumbUrl:C,SnapshotUrl:B}=e;return new tA({videoUrl:t,videoFormat:i,videoSecond:o,videoSize:n,videoDownloadFlag:r,videoUUID:s,thumbUUID:a,thumbFormat:g,thumbWidth:c,snapshotWidth:l,thumbHeight:I,snapshotHeight:u,thumbSize:E,snapshotSize:d,thumbDownloadFlag:h,thumbUrl:C,snapshotUrl:B})}updatePercent(A){this.uploadProgress=Math.min(A,1)}updateVideoUrl(A){A&&(this.content.remoteVideoUrl=A)}updateSnapshotInfo(A){const{snapshotUrl:e,snapshotWidth:t,snapshotHeight:i}=A;v.isEmpty(e)||(this.content.thumbUrl=this.content.snapshotUrl=e),v.isEmpty(t)||(this.content.thumbWidth=this.content.snapshotWidth=Number(t)),v.isEmpty(i)||(this.content.thumbHeight=this.content.snapshotHeight=Number(i))}validateBeforeSend(){if(this[D])return{isValid:!0};const A=""!==this.content.remoteVideoUrl;return{isValid:A,error:A?null:{message:"content can not be empty"}}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{remoteVideoUrl:i,videoFormat:o,videoSecond:n,videoSize:r,videoDownloadFlag:s,videoUUID:a,thumbUUID:g,thumbFormat:c,thumbWidth:l,snapshotWidth:I,thumbHeight:u,snapshotHeight:E,thumbSize:d,snapshotSize:h,thumbDownloadFlag:C,thumbUrl:B,snapshotUrl:Q}=t;return{MsgType:this.type,MsgContent:{VideoUrl:v.removeAuthToUrl(i),VideoFormat:o,VideoSecond:n,VideoSize:r,VideoDownloadFlag:s,VideoUUID:a,ThumbUUID:g,ThumbFormat:c,ThumbWidth:l,SnapshotWidth:I,ThumbHeight:u,SnapshotHeight:E,ThumbSize:d,SnapshotSize:h,ThumbDownloadFlag:C,ThumbUrl:v.removeAuthToUrl(B),SnapshotUrl:v.removeAuthToUrl(Q)}}}}eA=D;var iA,oA=new class{constructor(){this._messageOptionsMap=new Map}init(A){var e;this._core=A;const{notificationCenter:t,helper:i,InnerEvent:o,message:n}=A;i.registerApi({apiName:"createVideoMessage",context:this}),i.registerExperimentalAPI("createVideoMessage",this,"createCustomUploadVideoMessage"),null===(e=null==n?void 0:n.messageFactory)||void 0===e||e.registerElementClass(E,tA),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createVideoMessage(A){var e,t,i;try{const o=this._processVideo(A);A.payload.file=o;const n=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,r=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:n})),s={videoFormat:o.videoFile.type,videoSecond:g(o.videoFile.second,0),videoSize:o.videoFile.size,remoteVideoUrl:"",videoUrl:o.videoFile.url,videoUUID:v.generateUUID(o.videoFile),thumbUUID:v.generateUUID(o.videoFile,"jpg"),thumbWidth:o.width||200,thumbHeight:o.height||200,thumbUrl:o.thumbUrl,thumbSize:o.thumbSize,thumbFormat:"jpg"},a=new tA(s);return r.setElement(a),this._messageOptionsMap.set(r.clientSequence,A),r}catch(o){throw o}}createCustomUploadVideoMessage(A){var e,t,i;try{const{store:o,message:n}=this._core;this._validateCustomUploadVideoMessage(A);const r=null===(e=o.get("login"))||void 0===e?void 0:e.userId,{videoUrl:s,videoUuid:a,duration:g,snapshotUrl:c,snapshotUuid:l,videoFileSize:I,videoType:u,snapshotWidth:E,snapshotHeight:d,snapshotFileSize:h,snapshotType:C="jpg"}=(null===(t=null==A?void 0:A.payload)||void 0===t?void 0:t.file)||{},B=null===(i=n.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:r})),Q=new tA({videoFormat:u,videoSecond:g||0,videoSize:I,remoteVideoUrl:s,videoUrl:s,videoUUID:a,thumbUUID:l,thumbWidth:E||200,thumbHeight:d||200,thumbUrl:c,thumbSize:h,thumbFormat:C,isCustomUpload:!0});return B.setElement(Q),this._messageOptionsMap.set(B.clientSequence,A),B}catch(o){throw o}}upload(A){return e(this,void 0,void 0,function*(){const e=A.getElements()[0],{file:t}=this._messageOptionsMap.get(A.clientSequence).payload;this._validateBeforeUploadVideo(t);const i=yield this._performVideoUpload(e,A,t),{location:o,snapshotInfo:n}=i,r=v.addAuthToUrl(o);return e.updateVideoUrl(r),v.isEmpty(n)||e.updateSnapshotInfo(n),A})}_validateBeforeUploadVideo(A){var e;const{ChatError:t}=null===(e=this._core)||void 0===e?void 0:e.helper;if(A.videoFile.size>104857600)throw new t({code:X});if(0===A.videoFile.size)throw new t({code:Z});if(-1===AA.indexOf(A.videoFile.type))throw new t({code:$})}_validateCustomUploadVideoMessage(A){var e;const{utils:{isEmpty:t,isNumber:i}}=this._core,{videoUrl:o,videoUuid:n,duration:r,snapshotUrl:s,snapshotUuid:a}=(null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.file)||{};if(t(o)||t(n)||!i(r)||t(s)||t(a))throw new Error("Invalid video message options: missing required fields (videoUrl, videoUuid, duration, snapshotUrl, snapshotUuid)")}_performVideoUpload(A,t,i){return e(this,void 0,void 0,function*(){const{to:e}=t,o={uploadFileType:B,file:i,to:e,message:t,onProgress:e=>{var i,o;A.updatePercent(e),null===(o=null===(i=this._messageOptionsMap.get(t.clientSequence))||void 0===i?void 0:i.onProgress)||void 0===o||o.call(i,e)}},{response:n,uploadOptions:r}=yield _.uploadToCOS(o);return{snapshotInfo:yield this._getSnapshotInfoByUrl(r.requestSnapshotUrl),location:n.location}})}_processVideo(A){var e,t;try{const{ChatError:i}=null===(e=this._core)||void 0===e?void 0:e.helper,{IN_MINI_APP:o,IN_BROWSER:n}=null===(t=this._core)||void 0===t?void 0:t.utils;let{file:r}=A.payload,s={};if(o&&(s=this._processMiniVideoFile(r),r.name=s.name,r.url=s.url,r.type=s.type),n){const A=v.extractFileFromInput(r);if(!A)throw new i({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});r=A,s=this._processWebVideoFile(r)}return r.videoFile=s,r.thumbUrl="",r.thumbSize=0,r}catch(i){throw console.warn(`${d} _processFile error:`,i),i}}_processMiniVideoFile(A){var e,t;const{IN_ALIPAY_MINI_APP:i,IN_UNI_NATIVE_APP:o}=null===(e=this._core)||void 0===e?void 0:e.utils,{ChatError:r}=null===(t=this._core)||void 0===t?void 0:t.helper;if(i)throw new r({message:"VideoUnsupportedInAlipay"});if(n(A))throw new r({message:"FileUnsupportedInMiniApp"});Array.isArray(A.tempFiles)&&(A=A.tempFiles[0]);let s=A.tempFilePath.slice(A.tempFilePath.lastIndexOf(".")+1).toLowerCase();return o&&(s=A.fileType||s),{url:A.tempFilePath,name:A.tempFilePath.slice(A.tempFilePath.lastIndexOf("/")+1),size:A.size||1,second:A.duration||0,type:s}}_processWebVideoFile(A){const{name:e,size:t=1,duration:i=0,type:o}=A,n=o.split("/")[1];return{url:window.URL.createObjectURL(A),name:e,size:t,second:i,type:n}}_getSnapshotInfoByUrl(A){return e(this,void 0,void 0,function*(){const{ssoLog:t}=this._core;try{t.debug("_getSnapshotInfoByUrl",`${d} _getSnapshotInfoByUrl url:${A}`);const i={version:1,platform:v.getPlatform(),cover_name:a(r(99999)),snapshot_url:A},o=yield function(A,t){return e(this,void 0,void 0,function*(){try{const e="im_cos_msg.video_cover",{helper:i,channel:o}=t,n=i.generateCosSpecifiedData({servcmd:e,data:A}),r=`${n.head.seq}${e}`;return yield o.sendPacket(n,{requestId:r})}catch(e){throw console.warn("getSnapshotInfo error:",e),e}})}(i,this._core),{download_url:n}=o||{};if(t.debug("_getSnapshotInfoByUrl",`${d} _getSnapshotInfoByUrl OK snapshotUrl:${n}`),v.isEmpty(n))return{};const s=v.addAuthToUrl(n),{width:g=0,height:c=0}=yield v.probeImageWidthHeight(s);return{snapshotUrl:s,snapshotWidth:g,snapshotHeight:c}}catch(i){throw i}})}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}};class nA{constructor(A){this.uploadProgress=0,this.type=I,this[iA]=!1,this[D]=A.isCustomUpload||!1,this.content={downloadFlag:2,second:A.second,size:A.size,url:v.generateURL(A.url,{needAddAuthToUrl:!this[D]}),remoteAudioUrl:v.addAuthToUrl(A.url||""),uuid:A.uuid}}static parseServerPushElement(A){const{MsgContent:e}=A,{Url:t,Download_Flag:i,Second:o,Size:n,UUID:r}=e;return new nA({url:t,downloadFlag:i,second:o,size:n,uuid:r})}updatePercent(A){this.uploadProgress=Math.min(A,1)}updateAudioUrl(A){this.content.remoteAudioUrl=A}validateBeforeSend(){if(this[D])return{isValid:!0};const A=""!==this.content.remoteAudioUrl;return{isValid:A,error:A?null:{message:"content can not be empty"}}}transformToServerFormat(A){const{isMergerMessage:e=!1}=A||{},t=e?this.payload:this.content,{uuid:i,downloadFlag:o,remoteAudioUrl:n,size:r,second:s}=t;return{MsgType:this.type,MsgContent:{Url:v.removeAuthToUrl(n),Download_Flag:o,Second:s,Size:r,UUID:i}}}}iA=D;const rA=2108,sA=2300,aA=2301;var gA=new class{constructor(){this._messageOptionsMap=new Map}init(A){var e;this._core=A;const{notificationCenter:t,helper:i,InnerEvent:o,message:n}=A;i.registerApi({apiName:"createAudioMessage",context:this}),i.registerExperimentalAPI("createAudioMessage",this,"createCustomUploadAudioMessage"),null===(e=null==n?void 0:n.messageFactory)||void 0===e||e.registerElementClass(I,nA),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createAudioMessage(A){var e,t,i;try{let{file:o}=A.payload;o=this._processAudioFile(A.payload.file),A.payload.file=o;const n=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,r=null===(i=null===(t=this._core)||void 0===t?void 0:t.message.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:n})),s={second:Math.floor((o.duration||o.second)/1e3),size:o.fileSize||o.size||1,url:o.tempFilePath||o.uri||o.url,uuid:v.generateUUID(o)},a=new nA(s);return r.setElement(a),this._messageOptionsMap.set(r.clientSequence,A),r}catch(o){throw o}}createCustomUploadAudioMessage(A){var e,t,i;try{this._validateCustomUploadOptions(A);const{store:o,message:n}=this._core,r=null===(e=o.get("login"))||void 0===e?void 0:e.userId,{url:s,uuid:a,duration:g,fileSize:c}=(null===(t=null==A?void 0:A.payload)||void 0===t?void 0:t.file)||{},l=null===(i=n.messageFactory)||void 0===i?void 0:i.createMessage(Object.assign(Object.assign({},A),{from:r})),I=new nA({second:g,size:c||1,url:s,uuid:a,isCustomUpload:!0});return l.setElement(I),this._messageOptionsMap.set(l.clientSequence,A),l}catch(o){throw o}}upload(A){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;e.debug("upload",`${d} uploadAudio message:${t(A)}`);const{file:i}=this._messageOptionsMap.get(A.clientSequence).payload;this._validateBeforeUploadAudio(i);const o=A.getElements()[0],n=yield this._performAudioUpload(o,A,i),r=v.addAuthToUrl(null==n?void 0:n.location);return o.updateAudioUrl(r),A})}_validateBeforeUploadAudio(A){var e;const{ChatError:t}=null===(e=this._core)||void 0===e?void 0:e.helper;if(!A)throw new t({code:sA});if(A.size>20971520)throw new t({code:aA});if(0===A.size)throw new t({code:rA})}_performAudioUpload(A,t,i){return e(this,void 0,void 0,function*(){const{to:e}=t,o={uploadFileType:Q,file:i,to:e,message:t,onProgress:e=>{var i,o;A.updatePercent(e),null===(o=null===(i=this._messageOptionsMap.get(t.clientSequence))||void 0===i?void 0:i.onProgress)||void 0===o||o.call(i,e)}},{response:n}=yield _.uploadToCOS(o);return n})}_processAudioFile(A){var e;const{IN_MINI_APP:t,IN_BROWSER:i}=null===(e=this._core)||void 0===e?void 0:e.utils;return t?this._processMiniFile(A):i?this._processWebFile(A):void 0}_processMiniFile(A){return{url:A.tempFilePath,name:A.tempFilePath.slice(A.tempFilePath.lastIndexOf("/")+1),size:A.fileSize,second:A.duration,type:A.tempFilePath.slice(A.tempFilePath.lastIndexOf(".")+1).toLowerCase()}}_processWebFile(A){if(A.tempFilePath||A.uri)return A;const e=URL.createObjectURL(A);return A.tempFilePath=e,A}_validateCustomUploadOptions(A){var e;const{utils:{isEmpty:t}}=this._core,{url:i,uuid:o,duration:n}=(null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.file)||{};if(t(i)||t(o)||t(n))throw new Error("Invalid audio message options")}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.DESTROY,this._dispose,this)}};const cA={to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1},onProgress:{required:!1,rules:["function"],allowEmpty:!1}},lA={createImageMessage:cA,createAudioMessage:cA,createVideoMessage:cA,createFileMessage:cA},IA={createImageMessage:!0,createAudioMessage:!0,createVideoMessage:!0,createFileMessage:!0},uA={[l]:x,[u]:z,[E]:oA,[I]:gA};var EA=new class{constructor(){this.name="RichMediaMessage"}install(A){this._core=A;const{constants:{OuterConstant:{MSG_AUDIO:e,MSG_FILE:t,MSG_IMAGE:i,MSG_VIDEO:o}}}=A;j.init(A),x.init(A),z.init(A),oA.init(A),gA.init(A),_.init(A),v.init(A),A.helper.registerApi({apiName:"sendMessage",context:this,matcher:A=>[e,t,i,o].includes(A[0].type)}),A.helper.registerValidateConfig({auth:IA,params:lA})}sendMessage(A,t){return e(this,void 0,void 0,function*(){var e,i,o;try{return this._isCustomUpload(A)||(yield this._upload(A)),yield null===(o=null===(i=null===(e=this._core)||void 0===e?void 0:e.message)||void 0===i?void 0:i.messageSender)||void 0===o?void 0:o.sendMessage(A,t)}catch(n){throw n}})}_upload(A){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;if(e.debug("_upload",` uploadFile message:${t(A)}`),!0!==A._relayFlag)try{const t=uA[A.type];t&&(yield t.upload(A),e.info("_upload",` type:${A.type}`))}catch(i){throw A.status=f.FAIL,i instanceof Error&&(i.data={message:A}),this._core.message.messageDataHandler.storeConversationMessage(A),i}})}_isCustomUpload(A){var e,t;return!0===(null===(t=null===(e=A._elements)||void 0===e?void 0:e[0])||void 0===t?void 0:t[D])}};return EA}();const g_=RR(a_.exports);var c_={exports:{}};c_.exports=function(){function A(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o!A||!!(Array.isArray(A)&&A.length<=5)||"keywordList should be an array and length <= 5"},c={required:!1,rules:["string"],allowEmpty:!0,customValidator:A=>!A||!![n.OR,n.AND].includes(A)||"keywordListMatchType should be OR or AND"},l={required:!1,rules:["number"],allowEmpty:!0,customValidator:A=>"number"==typeof A&&A>=1&&A<=100||"count must be a number between 1 and 100"},I={required:!1,rules:["string"],allowEmpty:!0},u={required:!1,rules:["array"],allowEmpty:!0,customValidator:A=>{const{OuterConstant:e}=t.core;if(!Array.isArray(A))return"groupTypeList should be an array";const i=[e.GRP_PUBLIC,e.GRP_COMMUNITY,e.GRP_WORK,e.GRP_MEETING];let o=!1;for(let t=0;t({required:!1,rules:["number"],allowEmpty:!0,customValidator:e=>"number"==typeof e&&e>=0||`${A} should be a number >= 0';`}),d={required:!1,rules:["string"],allowEmpty:!0,customValidator:A=>{const{OuterConstant:e}=t.core;return!![e.GENDER_FEMALE,e.GENDER_MALE].includes(A)||"gender is invalid"}},h={searchCloudMessages:{keywordList:g,keywordListMatchType:c,cursor:I,senderUserIDList:{required:!1,rules:["array"],allowEmpty:!0,customValidator:A=>!!(Array.isArray(A)&&A.length<=5)||"senderUserIDList should be an array and length <= 5"},messageTypeList:{required:!1,rules:["array"],allowEmpty:!0,customValidator:A=>{const{OuterConstant:e}=t.core,i=[e.MSG_TEXT,e.MSG_IMAGE,e.MSG_AUDIO,e.MSG_FILE,e.MSG_VIDEO,e.MSG_LOCATION,e.MSG_CUSTOM,e.MSG_MERGER];let o=!1;for(let t=0;t{const{OuterConstant:e}=t.core;return!(!(null==A?void 0:A.startsWith(e.CONV_C2C))&&!(null==A?void 0:A.startsWith(e.CONV_GROUP))&&A!==e.CONV_SYSTEM)||"conversationID is invalid"}},timePosition:E("timePosition"),timePeriod:E("timePeriod")},searchCloudUsers:{keywordList:g,keywordListMatchType:c,cursor:I,count:l,miniBirthday:E("miniBirthday"),maxBirthday:E("maxBirthday"),gender:d},searchCloudGroupMembers:{keywordList:g,keywordListMatchType:c,cursor:I,count:l,groupTypeList:u,groupIDList:{required:!1,rules:["array"],allowEmpty:!0}},searchCloudGroups:{keywordList:g,keywordListMatchType:c,cursor:I,count:l,groupTypeList:u}},C={searchCloudMessages:!0,searchCloudUsers:!0,searchCloudGroupMembers:!0,searchCloudGroups:!0};return new class{constructor(){this.name="CloudSearch"}install(A){this._core=A,t.init(A),A.helper.registerApi({apiName:"searchCloudMessages",context:this}),A.helper.registerApi({apiName:"searchCloudUsers",context:this}),A.helper.registerApi({apiName:"searchCloudGroupMembers",context:this}),A.helper.registerApi({apiName:"searchCloudGroups",context:this}),A.helper.registerValidateConfig({auth:C,params:h})}searchCloudMessages(o){return e(this,void 0,void 0,function*(){try{const{OuterConstant:i,helper:n}=this._core,{conversationID:r,timePeriod:s,timePosition:a}=o,g=A(o,["conversationID","timePeriod","timePosition"]),c=Object.assign({count:100},g);r&&(r.startsWith(i.CONV_C2C)?c.account=r.replace(i.CONV_C2C,""):r.startsWith(i.CONV_GROUP)&&(c.groupID=r.replace(i.CONV_GROUP,""))),this._setTimeRangeParams(c,{timePeriod:s,timePosition:a});const l=yield function(A){return e(this,void 0,void 0,function*(){const{count:e,keywordList:i,keywordListMatchType:o,senderUserIDList:n,messageTypeList:r,endTime:s,startTime:a,cursor:g,account:c,groupID:l}=A,I={Count:e,KeywordList:i,MatchType:o,SendUserIDList:n,MsgTypeList:r,EndTime:s,StartTime:a,Cursor:g,PeerAccount:c,GroupID:l};return t.core.common.buildAndSendPacket({servcmd:"message_search.query",data:I})})}(c);if(!l)return{code:0,data:{}};const{ErrorCode:I,ErrorInfo:u,TotalCount:E,Cursor:d="",ConversationMsgs:h=[]}=l;if(0!==I)throw{errorCode:I,errorInfo:u};const C=`keywordList:${o.keywordList} keywordListMatchType:${o.keywordListMatchType} cursor:${o.cursor} res: totalCount:${E}`;return{code:0,data:{searchResultList:h.map(A=>{const{MsgList:e,Count:t,GroupID:r,UserID:s}=A,a=r?`${i.CONV_GROUP}${r}`:`${i.CONV_C2C}${s}`;return this._isSearchingAllConversations(o)&&t>1?{conversationID:a,messageCount:t,messageList:[]}:{conversationID:a,messageCount:t,messageList:e.map(A=>n.isEmpty(r)?function(A,e){const t=e.OuterConstant.CONV_C2C,i=e.message.messageHelper.parseServerPushMessage(A),o=e.message.messageFactory.createMessage(Object.assign(Object.assign({},i),{conversationType:t,flow:"in"}));return o.setElement(i.elements),o}(A,this._core):function(A,e){const t=e.OuterConstant.CONV_GROUP,i=e.message.messageHelper.parseServerGroupMessage(A),o=e.message.messageFactory.createMessage(Object.assign(Object.assign({},i),{conversationType:t,flow:"in"}));return o.setElement(i.elements),o}(A,this._core))}}),cursor:d,totalCount:E},successLog:{message:C}}}catch(n){const{errorCode:A,errorInfo:e}=n||{};this._handleError({errorCode:A,errorInfo:e,searchType:i,functionName:"searchCloudMessages"})}})}searchCloudUsers(i){return e(this,void 0,void 0,function*(){var r;try{const{keywordListMatchType:o,count:a=s}=i,g=A(i,["keywordListMatchType","count"]),c=Object.assign({count:a,keywordListMatchType:o===n.AND?1:0},g);this._setBirthdayRangeParams(c,i);const l=yield function(A){return e(this,void 0,void 0,function*(){const{count:e,keywordList:i,keywordListMatchType:o,miniBirthday:n,maxBirthday:r,cursor:s,gender:a}=A,g={Count:e,Keywords:i,KeywordMatchType:o,Cursor:s,UserBirthStart:n,UserBirthEnd:r,Gender:a};return t.core.common.buildAndSendPacket({servcmd:"user_search.query",data:g})})}(c);if(!l)return{error:0,data:{}};const{ErrorCode:I,ErrorInfo:u,TotalCount:E,Cursor:d="",Users:h=[]}=l;if(0!==I)throw{errorCode:I,errorInfo:u};const C=`keywordList:${i.keywordList} keywordListMatchType:${i.keywordListMatchType} cursor:${i.cursor} count:${i.count} res: totalCount:${E}`,B=[];for(let A=0,e=h.length;A({tag:A.Tag,value:A.StrValue})),o=null===(r=this._core.user.userProfile)||void 0===r?void 0:r.createProfile(e,i);B.push(o)}return{code:0,data:{searchResultList:B,cursor:d,totalCount:E},successLog:{message:C}}}catch(a){const{errorCode:A,errorInfo:e}=a||{};this._handleError({errorCode:A,errorInfo:e,searchType:o,functionName:"searchCloudUsers"})}})}searchCloudGroupMembers(i){return e(this,void 0,void 0,function*(){try{const{count:o=a,keywordListMatchType:r}=i,s=A(i,["count","keywordListMatchType"]),g=Object.assign({count:o,keywordListMatchType:r===n.AND?1:0},s),c=yield function(A){return e(this,void 0,void 0,function*(){const{count:e,keywordList:i,keywordListMatchType:o,groupTypeList:n,cursor:r,groupIDList:s}=A,a={Count:e,Keywords:i,KeywordMatchType:o,Cursor:r,GroupType:n,GroupIdList:s};return t.core.common.buildAndSendPacket({servcmd:"group_member_search.query",data:a})})}(g);if(!c)return{code:0,data:{}};const{ErrorCode:l,ErrorInfo:I,GroupMembers:u=[],Cursor:E,TotalCount:d}=c;if(0!==l)throw{errorCode:l,errorInfo:I};const h=`keywordList:${i.keywordList} keywordListMatchType:${i.keywordListMatchType} cursor:${i.cursor} count:${i.count} res: totalCount:${d}`,C=new Map;return u.forEach(A=>{const{GroupID:e,GroupName:t,GroupType:i,GroupFaceUrl:o,GroupMemberUserName:n,GroupMemberUserID:r,GroupMemberNameCard:s,GroupMemberAvatar:a=""}=A,g={groupID:e,name:t,type:i,avatar:o},c={userID:r,nick:n,nameCard:s,avatar:a};if(C.has(e)){const A=C.get(e);A.memberList.push(c),C.set(e,A)}else C.set(e,{groupInfo:g,memberList:[c]})}),{code:0,data:{searchResultList:[...C.values()],cursor:E,totalCount:d},successLog:{message:h}}}catch(r){const{errorCode:A,errorInfo:e}=r||{};this._handleError({errorCode:A,errorInfo:e,searchType:o,functionName:"searchCloudGroupMembers"})}})}searchCloudGroups(i){return e(this,void 0,void 0,function*(){try{const{count:o=r,keywordListMatchType:s}=i,a=A(i,["count","keywordListMatchType"]),g=Object.assign({count:o,keywordListMatchType:s===n.AND?1:0},a),c=yield function(A){return e(this,void 0,void 0,function*(){const{count:e,keywordList:i,keywordListMatchType:o,groupTypeList:n,cursor:r}=A,s={Count:e,Keywords:i,KeywordMatchType:o,Cursor:r,GroupType:n};return t.core.common.buildAndSendPacket({servcmd:"group_search.query",data:s})})}(g);if(!c)return{code:0,data:{}};const{ErrorCode:l,ErrorInfo:I,Groups:u,Cursor:E,TotalCount:d}=c;if(0!==l)throw{errorCode:l,errorInfo:I};const h=`keywordList:${i.keywordList} keywordListMatchType:${i.keywordListMatchType} cursor:${i.cursor} count:${i.count} res: totalCount:${d}`;return{code:0,data:{searchResultList:(null==u?void 0:u.map(A=>function(A){const{GroupFaceUrl:e,GroupID:t,GroupIntroduction:i,GroupMemberNum:o,GroupName:n,GroupOwnerTinyID:r,GroupOwnerUserID:s,GroupOwnerUserName:a,GroupType:g,GroupAddOption:c,GroupInviteOption:l}=A;return{avatar:e,groupID:t,introduction:i,memberCount:o,name:n,ownerTinyID:r,ownerID:s,ownerNick:a,type:g,joinOption:c,inviteOption:l}}(A)))||[],cursor:E,totalCount:d},successLog:{message:h}}}catch(s){const{errorCode:A,errorInfo:e}=s||{};this._handleError({errorCode:A,errorInfo:e,searchType:o,functionName:"searchCloudGroups"})}})}_setTimeRangeParams(A,{timePeriod:e,timePosition:t}){e&&e>0&&(A.startTime=t&&t>0?t-e:this._core.helper.timeManager.getServerTimeSeconds()-e),A.startTime&&A.startTime<0&&(A.startTime=void 0),t&&t>0&&(A.endTime=t)}_handleError({errorCode:A,errorMessage:e,searchType:t}){const{helper:o}=this._core;let n=A;throw 60020===A?n="SearchUnable":t!==i&&27003===A?n="SearchParamsError":t!==i&&60018===A&&(n="SearchOverLimit"),new o.ChatError({code:n,message:e})}_isSearchingAllConversations(A){return this._core.helper.isEmpty(A.conversationID)}_setBirthdayRangeParams(A,e){const{miniBirthday:t,maxBirthday:i}=e;void 0!==t&&(A.miniBirthday=t,void 0===i&&(A.maxBirthday=4294967295)),void 0!==i&&(A.maxBirthday=i)}}}();const l_=RR(c_.exports);var I_={exports:{}};I_.exports=function(){function A(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e=1,t=2,i=3,o=4,n=5,r="TIMCustomElem",s="C2C",a="GROUP",g="invite",c="accept",l="cancel",I="reject",u="modifyInvitation",E="signaling",d=8010,h="signaling-timeout";function C(A){return A.filter(A=>{if(A.type===r){const{cloudCustomData:e="",payload:{data:t=""}={}}=A,i=e.match(/"type":"tsignaling"/),o=t.match(/inviteID/),n=t.match(/actionType/);return i||o&&n}return!1})}function B(A){const{data:e}=A.payload;try{return JSON.parse(e)}catch(t){return console.error(t),null}}function Q(A,e){return A.toString(16).padStart(e,"0")}function p(A){if(A<0||A>53)throw new Error("Number of digits must be between 0 and 53");if(A<=30)return Math.floor(Math.random()*(1<0;const A=this._core.common.getCurrentUserID();return r.includes(A)}return!0}updateSignaling(A){const e=`${E}.updateSignaling`,{inviteID:t,inviter:i,inviteeList:o,groupID:n}=A;if(console.log(`${e} inviteID:${t} inviter:${i} groupID:${n}`),n&&this.hasSignaling(t)){const A=o[0],{inviteeList:i}=this._onlineSignalingMap.get(t);i.includes(A)&&(i.splice(i.indexOf(A),1),console.log(`${e} remove ${A}. localInviteeList.length:${i.length}`)),0===i.length&&this.removeSignaling(t)}else this.removeSignaling(t)}setSignalingListenStatus(A){this._isSignalingListening=A}getSignalingListenStatus(){return this._isSignalingListening}_dispose(){var A,e;this._reset(),null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._isSignalingListening=!1}_reset(){this._onlineSignalingMap.clear()}},m=new class{init(A){this._core=A}createInviteSignaling(A){const e=this._generateInviteID(),t=this._createInviteSignalingData(Object.assign(Object.assign({},A),{inviteID:e})),{groupID:i,inviteeList:o}=t,n=i||o[0];return{signaling:this._createSignaling(t,n),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(A)}}createAcceptSignaling(A){const e=this._createAcceptSignalingData(A),{groupID:t,inviter:i}=e,o=t||i;return{signaling:this._createSignaling(e,o),signalingData:e,signalingExtensionOptions:this._createSignalingExtensionOptions(A)}}createCancelSignaling(A){const e=this._createCancelSignalingData(A),{groupID:t,inviteeList:i}=e,o=t||i[0];return{signaling:this._createSignaling(e,o),signalingData:e,signalingExtensionOptions:this._createSignalingExtensionOptions(A)}}createRejectSignaling(A){const e=this._createRejectSignalingData(A),{groupID:t,inviter:i}=e,o=t||i;return{signaling:this._createSignaling(e,o),signalingData:e,signalingExtensionOptions:this._createSignalingExtensionOptions(A)}}createTimeoutSignaling(A){const{isInviter:e=!1}=A,t=this._createTimeoutSignalingData(A),{groupID:i,inviteeList:o,inviter:n}=t,r=i||(e?o[0]:n);return{signaling:this._createSignaling(t,r),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(t)}}_createSignalingExtensionOptions(A){var e,t;const{data:i="",onlineUserOnly:o,inviteID:n="",offlinePushInfo:r,actionType:s}=A,a=(null===(t=null===(e=f.getSignaling(n))||void 0===e?void 0:e.signaling)||void 0===t?void 0:t._onlineOnlyFlag)||!1;return{onlineUserOnly:o||a,offlinePushInfo:r,messageControlInfo:this._createMessageControlInfo(i,s)}}_createMessageControlInfo(A,e){const t=e===n&&!!A.match(/excludeTimeoutSignalingFromHistoryMessage/),i=!!A.match(/excludeFromHistoryMessage/)||!!A.match(/excludeOriginalSignalingFromHistoryMessage/);return{excludedFromContentModeration:!0,excludedFromUnreadCount:t||i,excludedFromLastMessage:t||i}}_createInviteSignalingData(A){const t=`${E}._createInviteSignalingData`,{userID:i,timeout:o=0,groupID:n="",inviteeList:r=[]}=A,s=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(A)),{actionType:e,inviter:s,inviteeList:n?r:[i],timeout:o});return console.log(`${t} signalingData:`,a),a}_createAcceptSignalingData(A){const e=`${E}._createAcceptSignalingData`,{inviteID:t}=A,o=this._core.common.getCurrentUserID(),{inviter:n,groupID:r}=f.getSignaling(t),s=Object.assign(Object.assign({},this._generateBaseSignalData(A)),{actionType:i,groupID:r,inviter:n,inviteeList:[o]});return console.log(`${e} signalingData:`,s),s}_createCancelSignalingData(A){const e=`${E}._createCancelSignalingData`,{inviteID:i}=A,o=this._core.common.getCurrentUserID(),{inviteeList:n,groupID:r}=f.getSignaling(i),s=Object.assign(Object.assign({},this._generateBaseSignalData(A)),{actionType:t,groupID:r,inviter:o,inviteeList:n});return console.log(`${e} signalingData:`,s),s}_createRejectSignalingData(A){const e=`${E}._createRejectSignalingData`,{inviteID:t}=A,i=this._core.common.getCurrentUserID(),{inviter:n,groupID:r}=f.getSignaling(t),s=Object.assign(Object.assign({},this._generateBaseSignalData(A)),{actionType:o,groupID:r,inviter:n,inviteeList:[i]});return console.log(`${e} signalingData:`,s),s}_createTimeoutSignalingData(A){const e=`${E}._createTimeoutSignalingData`,{isInviter:t=!1,inviteID:i}=A,{inviteeList:o,inviter:r}=f.getSignaling(i),s=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(A)),{actionType:n,inviter:r,inviteeList:t?o:[s]});return console.log(`${e} signalingData:`,a),a}_createSignaling(A,e){var t,i,o;const{groupID:n=""}=A,r={to:e,conversationType:n?a:s,priority:"High",payload:{data:JSON.stringify(A)}};return null===(o=null===(i=null===(t=this._core)||void 0===t?void 0:t.message)||void 0===i?void 0:i.messageFactory)||void 0===o?void 0:o.createCustomMessage(r)}_generateInviteID(){return[Q(p(32),8),Q(p(16),4),Q(16384|p(12),4),Q(32768|p(14),4),Q(p(48),12)].join("-")}_generateBaseSignalData(A){const{data:e="",inviteID:t="",groupID:i=""}=A;return{businessID:1,timeout:0,data:e,inviteID:t,groupID:i}}},y=new class{constructor(){this._isProcessingSignaling=!1}init(A){this._core=A,A.helper.registerApi({apiName:"invite",context:this}),A.helper.registerApi({apiName:"accept",context:this}),A.helper.registerApi({apiName:"cancel",context:this}),A.helper.registerApi({apiName:"reject",context:this}),A.helper.registerApi({apiName:"modifyInvitation",context:this}),A.helper.registerApi({apiName:"getSignalingInfo",context:this}),A.helper.registerApi({apiName:"addSignalingListener",context:this}),A.helper.registerApi({apiName:"removeSignalingListener",context:this}),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.DESTROY,this._dispose,this),A.notificationCenter.subscribeInnerEvent(A.InnerEvent.LOGOUT,this._reset,this)}invite(e){return A(this,void 0,void 0,function*(){var A;try{this._validateBeforeInvite(e);const{signaling:t,signalingData:i,signalingExtensionOptions:o}=m.createInviteSignaling(e),n=yield this._sendSignaling(t,o);if(0===(null==n?void 0:n.code)){const{inviteID:e,timeout:o}=i;return f.saveSignaling(e,Object.assign(Object.assign({},i),{signaling:t})),o>0&&(null===(A=this._core)||void 0===A||A.helper.taskScheduler.addOnceTask({id:`${h}-${e}`,intervalMs:1e3*(o+5),callback:this.handleInvitationExpiryTimer.bind(this,e)})),Object.assign(Object.assign({},n),{inviteID:e})}return n}catch(t){throw t}})}accept(e){return A(this,void 0,void 0,function*(){try{const{inviteID:A}=e;this._validateBeforeAccept(A),this._isProcessingSignaling=!0;const{signaling:t,signalingData:i,signalingExtensionOptions:o}=m.createAcceptSignaling(e),n=yield this._sendSignaling(t,o);return 0===(null==n?void 0:n.code)?(f.updateSignaling(i),Object.assign(Object.assign({},n),{inviteID:A})):n}catch(A){throw A}finally{this._isProcessingSignaling=!1}})}cancel(e){return A(this,void 0,void 0,function*(){try{const{inviteID:A}=e;this._validateBeforeCancel(A),this._isProcessingSignaling=!0;const{signaling:t,signalingExtensionOptions:i}=m.createCancelSignaling(e),o=yield this._sendSignaling(t,i);return 0===(null==o?void 0:o.code)?(f.removeSignaling(A),Object.assign(Object.assign({},o),{inviteID:A})):o}catch(A){throw A}finally{this._isProcessingSignaling=!1}})}reject(e){return A(this,void 0,void 0,function*(){try{const{inviteID:A}=e;this._validateBeforeReject(A),this._isProcessingSignaling=!0;const{signaling:t,signalingExtensionOptions:i}=m.createRejectSignaling(e),o=yield this._sendSignaling(t,i);return 0===(null==o?void 0:o.code)?(f.removeSignaling(A),Object.assign(Object.assign({},o),{inviteID:A})):o}catch(A){throw A}finally{this._isProcessingSignaling=!1}})}modifyInvitation(e){return A(this,void 0,void 0,function*(){var A,t;const{inviteID:i,data:o}=e;let n="";try{this._validateBeforeModifyInvitation(i);const e=f.getSignaling(i),{signaling:r}=e,s=function(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{const e=B(A);if(e){const t=this._actionProcessor.get(e.actionType);null==t||t(e,A)}})}_handleMessageReceived(A){if(!f.getSignalingListenStatus())return;const e=C(A.data);0!==e.length&&this.handleActionSignaling(e)}_handleMessageModified(A){if(!f.getSignalingListenStatus())return;const e=C(A.data);e.length>0&&e.forEach(A=>{const e=B(A);e&&this._onInvitationModified(e,A)})}_onNewInvitationReceived(A,e){var t,i;const o=`${E}._onNewInvitationReceived`,{inviteID:n,inviteeList:r,groupID:s}=A,a=this._core.common.getCurrentUserID();if(this._core.ssoLog.debug("_onNewInvitationReceived",`${o} signalingData:${JSON.stringify(A)}}`),s&&!r.includes(a))return;let{timeout:g}=A;const c=Date.now()/1e3-e.time;g>0&&c>0&&g>c&&(g-=c);const l=f.getSignaling(n);l!==A&&(l||f.saveSignaling(n,Object.assign(Object.assign({},A),{signaling:e})),g>0&&(null===(t=this._core)||void 0===t||t.helper.taskScheduler.addOnceTask({id:`${h}-${n}`,intervalMs:1e3*g,callback:y.handleInvitationExpiryTimer.bind(y,n)})),this._emitEvent({name:null===(i=this._core)||void 0===i?void 0:i.SignalingEvent.NEW_INVITATION_RECEIVED,data:Object.assign(Object.assign({},this._generateBaseEmitData(A)),{inviteeList:r})}))}_onInviteeRejected(A){var e;const t=`${E}._onInviteeRejected`,{inviteID:i,inviter:o,groupID:n,inviteeList:r}=A,s=f.hasSignaling(i);this._core.ssoLog.debug("_onInviteeRejected",`${t} inviteID:${i} hasInviteID:${s} inviter:${o} groupID:${n}`),s&&(f.updateSignaling(A),this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.SignalingEvent.INVITEE_REJECTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(A)),{invitee:r[0]})}))}_onInviteeAccepted(A){var e;const t=`${E}._onInviteeAccepted`,{inviteID:i,inviter:o,groupID:n,inviteeList:r}=A,s=f.hasSignaling(i);this._core.ssoLog.debug("_onInviteeAccepted",`${t} inviteID:${i} hasInviteID:${s} inviter:${o} groupID:${n}`),s&&(f.updateSignaling(A),this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.SignalingEvent.INVITEE_ACCEPTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(A)),{invitee:r[0]})}))}_onInvitationCancelled(A){var e;const t=`${E}._onInvitationCancelled`,{inviteID:i,inviter:o,groupID:n}=A,r=f.hasSignaling(i);this._core.ssoLog.debug("_onInvitationCancelled",`${t} inviteID:${i} hasInviteID:${r} inviter:${o} groupID:${n}`),r&&(f.removeSignaling(i),this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.SignalingEvent.INVITATION_CANCELLED,data:this._generateBaseEmitData(A)}))}_onInvitationTimeout(A){var e;const t=`${E}._onInvitationTimeout`,{inviteID:i,inviteeList:o}=A,n=f.hasSignaling(i);this._core.ssoLog.debug("_onInvitationTimeout",`${t} inviteID:${i} hasInviteID:${n} data:${A.data}`),n&&(f.updateSignaling(A),this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.SignalingEvent.INVITATION_TIMEOUT,data:Object.assign(Object.assign({},this._generateBaseEmitData(A)),{inviteeList:o,isSelfTimeout:!1})}))}_onInvitationModified(A,e){var t;const i=`${E}._onInvitationModified`,{inviteID:o,data:n}=A,r=f.hasSignaling(o);this._core.ssoLog.debug("_onInvitationModified",`${i} inviteID:${o} data:${n}`),r&&(f.saveSignaling(o,Object.assign(Object.assign({},A),{signaling:e})),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITATION_MODIFIED,data:{inviteID:o,data:n}}))}_emitEvent(A){var e;null===(e=this._core)||void 0===e||e.notificationCenter.emitOuterEvent(A.name,A)}_generateBaseEmitData(A){const{inviteID:e,inviter:t,groupID:i,data:o}=A;return{inviteID:e,inviter:t,groupID:i,data:o||""}}_dispose(){var A,e,t;null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_RECEIVED,this._handleMessageReceived,this),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_MODIFIED,this._handleMessageModified,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeOuterEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}},v=new class{constructor(){this._offlineSignalingMap=new Map}init(A){this._core=A;const{notificationCenter:e,helper:t,constants:{InnerEvent:i,WORKFLOW_STEP:o,WORKFLOW_NAME:n}}=A;e.subscribeInnerEvent(i.DESTROY,this._dispose,this),e.subscribeInnerEvent(i.LOGOUT,this._reset,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.SIGNALING_MESSAGE_RECOVER,this._handleC2COfflineMessage,this)}_handleC2COfflineMessage(A){const{result:{unreadMessageMap:e}={}}=A||{};if(0===(null==e?void 0:e.size)||!f.getSignalingListenStatus())return;const t=C([...e.values()]);if(0!==t.length&&(t.forEach(A=>{this._handleC2CActionType(A)}),this._offlineSignalingMap.size>0)){const A=this._sortOfflineSignalingByTime();D.handleActionSignaling(A)}}_handleC2CActionType(A){const t=B(A);if(!t)return;const{actionType:i}=t;i===e?this._saveValidOfflineInvite(t,A):this._removeOfflineInvite(t)}_saveValidOfflineInvite(A,e){const{inviteID:t,inviteeList:i=[],timeout:o=0}=A,n=this._core.common.getCurrentUserID();if(!i.includes(n))return;const r=Date.now()/1e3-e.time;o>0&&r>o&&0!==o||this._offlineSignalingMap.set(t,Object.assign(Object.assign({},A),{signalingList:[e]}))}_removeOfflineInvite(A){const{inviteID:e=""}=A;this._offlineSignalingMap.has(e)&&this._offlineSignalingMap.delete(e)}_sortOfflineSignalingByTime(){let A=[];return this._offlineSignalingMap.forEach(e=>{A=[...A,...e.signalingList]}),A.sort((A,e)=>A.time-e.time)}_dispose(){var A,e;this._reset(),null===(A=this._core)||void 0===A||A.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._offlineSignalingMap.clear()}};const w={invite:{userID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0},timeout:{required:!1,rules:["number"],allowEmpty:!1},onlineUserOnly:{required:!1,rules:["boolean"],allowEmpty:!1},offlinePushInfo:{required:!1,rules:["object"],allowEmpty:!1}},cancel:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},accept:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},reject:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},modifyInvitation:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}}},S={invite:!0,cancel:!0,accept:!0,reject:!0,modifyInvitation:!0};return new class{constructor(){this.name="Signaling"}install(A){y.init(A),D.init(A),m.init(A),f.init(A),v.init(A),A.helper.registerValidateConfig({auth:S,params:w})}}}();const u_=RR(I_.exports);var E_={exports:{}};E_.exports=function(){function A(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e="friend",t=100,i=2700,o=2710,n=2711,r=2716,s=2742,a=30539,g="Tag_SNS_IM_",c={GROUP:`${g}Group`,REMARK:`${g}Remark`,ADDSOURCE:`${g}AddSource`,ADDWORDING:`${g}Wording`,ADDTIME:`${g}AddTime`},l="Update_Type_Add",I="Update_Type_Delete",u="add",E="remove",d="rename",h=A=>void 0===A;function C(e,t){return A(this,void 0,void 0,function*(){return Q(yield t.common.buildAndSendPacket({servcmd:"sns.friend_update",data:e}),"ResultItem",A=>({to:A.To_Account,resultCode:A.ResultCode,resultInfo:A.ResultInfo}))})}function B(e,t){return A(this,void 0,void 0,function*(){return Q(yield t.common.buildAndSendPacket({servcmd:"sns.friend_check",data:e}),"InfoItem",A=>({userID:A.To_Account,relation:A.Relation,resultCode:A.ResultCode,resultInfo:A.ResultInfo}))})}function Q(A,e="ResultItem",t=A=>({userID:A.To_Account,resultCode:A.ResultCode,resultInfo:A.ResultInfo})){const{[e]:i=[],ActionStatus:o,ErrorCode:n,ErrorInfo:r,ErrorDisplay:s}=A;return{resultList:i.map(t),actionStatus:o,errorCode:n,errorInfo:r,errorDisplay:s}}const p={[c.REMARK]:(A,e)=>{A.remark=e},[c.GROUP]:(A,e)=>{A.groupList=e?JSON.parse(JSON.stringify(e)):[]},[c.ADDSOURCE]:(A,e)=>{A.source=e},[c.ADDWORDING]:(A,e)=>{A.wording=e},[c.ADDTIME]:(A,e)=>{A.addTime=e}};let f=class{constructor(A){var e;this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];const{userID:t,tagValueList:i=[],core:o}=A,n=null===(e=o.user.userProfile)||void 0===e?void 0:e.createProfile(t,i);this.userID=t,this.profile=n,i.forEach(A=>{const{tag:e,value:t}=A;e.indexOf("Tag_Profile_Custom")>-1&&this.friendCustomField.push({key:e,value:t});const i=p[e];null==i||i(this,t)})}update(A){const e=[];this.friendCustomField.forEach(A=>{e.push(A.key)}),A.forEach(A=>{const{tag:t,value:i}=A;t.indexOf("Tag_Profile_Custom")>-1&&(e.indexOf(t)>-1?this.friendCustomField.forEach(A=>{A.key===t&&(A.value=i)}):this.friendCustomField.push({key:t,value:i}));const o=p[t];null==o||o(this,i)})}};var m=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(A){this._core=A;const{helper:e,constants:t}=A;e.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),e.registerApi({apiName:"getFriendProfile",context:this}),e.registerApi({apiName:"addFriend",context:this}),e.registerApi({apiName:"deleteFriend",context:this}),e.registerApi({apiName:"updateFriend",context:this}),e.registerApi({apiName:"checkFriend",context:this}),e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return A(this,void 0,void 0,function*(){const{appStore:{userStore:A},ssoLog:t,utils:{safeStringify:i}}=this._core,o=[...A.getFriendMap().values()];return t.debug("getFriendListFromCache",`${e} getFriendListFromCache, data:${i(o)}`),{code:0,data:o}})}syncFriendListFromServer(){return A(this,void 0,void 0,function*(){var t;const{ssoLog:i,helper:o}=this._core;try{i.debug("syncFriendListFromServer",`${e} syncFriendListFromServer`);const o={From_Account:null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},n=yield function(e,t){return A(this,void 0,void 0,function*(){return function(A){const{UserDataItem:e=[],StandardSequence:t,CustomSequence:i,FriendNum:o,CompleteFlag:n,NextStartIndex:r,ActionStatus:s,ErrorCode:a,ErrorInfo:g,ErrorDisplay:c}=A;return{friendList:e.map(A=>{var e;return{userID:A.To_Account,tagValueList:null===(e=A.ValueItem)||void 0===e?void 0:e.map(A=>({tag:A.Tag,value:A.Value}))}}),standardSequence:t,customSequence:i,friendNumber:o,completeFlag:n,nextStartIndex:r,actionStatus:s,errorCode:a,errorInfo:g,errorDisplay:c}}(yield t.common.buildAndSendPacket({servcmd:"sns.friend_get",data:e}))})}(o,this._core),{friendList:r,nextStartIndex:s,standardSequence:a,customSequence:g,completeFlag:c}=n;this._startIndex=s,this._standardSequence=a,this._customSequence=g,this._processFriendList(r),0===c?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),i.debug("syncFriendListFromServer",`${e} syncFriendListFromServer ok`)}catch(n){const{errorCode:A}=n||{};throw new o.ChatError({code:A})}})}getFriendProfile(e){return A(this,void 0,void 0,function*(){var i;try{let{userIDList:o}=e;o.length>t&&(o=o.slice(0,t));const{friendUserIdList:n,unFriendUserIdList:r}=this.partitionByIsFriend(o),s=this._createNonFriendErrorList(r);if(0===n.length)return{code:0,data:{friendList:[],failureUserIDList:s}};const a={From_Account:null===(i=this._core.store.get("login"))||void 0===i?void 0:i.userId,To_Account:n},g=(yield function(e,t){return A(this,void 0,void 0,function*(){return function(A){const{InfoItem:e=[],ActionStatus:t,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=A;return{friendProfileList:e.map(A=>{var e;return{userID:A.To_Account,resultCode:A.ResultCode,resultInfo:A.ResultInfo,relation:A.Relation,standardSequence:A.StandardSequence,customSequence:A.CustomSequence,profileItem:(null===(e=A.SnsProfileItem)||void 0===e?void 0:e.map(A=>({tag:A.Tag,value:A.Value})))||[]}}),actionStatus:t,errorCode:i,errorInfo:o,errorDisplay:n}}(yield t.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:e}))})}(a,this._core))||{},{successProfiles:c,failedProfiles:l}=this._processFriendProfileResponse(g);return{code:0,data:{friendList:c,failureUserIDList:[...l,...s]}}}catch(o){const{errorCode:A}=o||{};throw new this._core.helper.ChatError({code:A})}})}addFriend(t){return A(this,void 0,void 0,function*(){var i;const{helper:o,store:n,ssoLog:r}=this._core;try{const{to:s,source:g,type:c,wording:l,remark:I,groupName:u}=t,E={From_Account:null===(i=n.get("login"))||void 0===i?void 0:i.userId,AddFriendItem:[{To_Account:s,AddSource:g,AddWording:l,GroupName:u,Remark:I}],AddType:c},d=yield function(e,t){return A(this,void 0,void 0,function*(){return Q(yield t.common.buildAndSendPacket({servcmd:"sns.friend_add",data:e}))})}(E,this._core),{resultList:h=[]}=d,{userID:C,resultCode:B}=h[0];if(0===B)return r.debug("addFriend",`${e} addFriend ok`),{code:0,data:{userID:C}};if(B===a)return r.debug("addFriend",`${e} addFriend wait for the other party to agree`),{code:0,data:{userID:C,code:B,message:"wait for the other party to agree"}};throw new o.ChatError({functionName:"addFriend",code:B})}catch(s){const{errorCode:A}=s||{};throw new o.ChatError({code:A})}})}deleteFriend(i){return A(this,void 0,void 0,function*(){var o;const{store:n,ssoLog:r,helper:s}=this._core;try{let{userIDList:s,type:a}=i;const g=null===(o=n.get("login"))||void 0===o?void 0:o.userId;s.length>1e3&&(r.info("deleteFriend",`${e} deleteFriend the length of userIDList cannot exceed:1000`),s=s.slice(0,t));const{friendUserIdList:c,unFriendUserIdList:l}=this.partitionByIsFriend(s);if(0===c.length)return{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(l)}};const I={From_Account:g,To_Account:c,DeleteType:a},u=yield function(e,t){return A(this,void 0,void 0,function*(){return Q(yield t.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:e}))})}(I,this._core),{successUserIDList:E,failureUserIDList:d}=this._processOperationResult({resultList:u.resultList,includeRelation:!1});return{code:0,data:{successUserIDList:E,failureUserIDList:d}}}catch(a){const{errorCode:A}=a||{};throw new s.ChatError({code:A})}})}updateFriend(e){return A(this,void 0,void 0,function*(){var A;const{helper:t,store:o,appStore:{userStore:n}}=this._core;try{const{userID:r,remark:s,friendCustomField:a}=e,g=null===(A=o.get("login"))||void 0===A?void 0:A.userId;if(!n.getFriendMap().has(r))throw new t.ChatError({functionName:"updateFriend",code:i});const c={From_Account:g,UpdateItem:[{To_Account:r,SnsItem:this._buildSnsItemList(s,a)}]},l=yield C(c,this._core),{resultList:I}=l,{to:u,resultCode:E,resultInfo:d}=I[0];if(h(E)||0===E)return{code:0,data:this._updateLocalFriend({userID:u,remark:s,friendCustomField:a})};throw new t.ChatError({functionName:"updateFriend",code:E,message:d})}catch(r){const{errorCode:A}=r||{};throw new t.ChatError({code:A})}})}checkFriend(e){return A(this,void 0,void 0,function*(){var A;const{OuterConstant:t,store:i,helper:o}=this._core;try{const{userIDList:o,type:n}=e,r={From_Account:null===(A=i.get("login"))||void 0===A?void 0:A.userId,To_Account:o,CheckType:n===t.SNS_CHECK_TYPE_SINGLE?n:t.SNS_CHECK_TYPE_BOTH},s=yield B(r,this._core),{successUserIDList:a=[],failureUserIDList:g=[]}=this._processOperationResult({resultList:s.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:a,failureUserIDList:g}}}catch(n){const{errorCode:A}=n||{};throw new o.ChatError({code:A})}})}dispose(){this.reset();const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.LOGOUT,this.reset,this)}reset(){const{userStore:A}=this._core.appStore;A.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(t){return A(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:i}}=this._core;A.debug("updateFriendList",`${e} updateFriendList data:${i(t)}`);const{userStore:o}=this._core.appStore,{addedFriendList:n=[],removedFriendList:r=[]}=t;n.length>0&&(n.forEach(A=>{const e=new f({userID:A,core:this._core});o.getFriendMap().set(A,e)}),yield this.getFriendProfile({userIDList:n}),this._emitFriendListUpdated()),r.length>0&&(r.forEach(A=>{o.getFriendMap().delete(A)}),this._emitFriendListUpdated())})}updateFriendInfo(A){const{ssoLog:t,utils:{safeStringify:i}}=this._core;t.debug("updateFriendList",`${e} updateFriendInfo data:${i(A)}`);const{appStore:{userStore:o,conversationStore:n},utils:{isEmpty:r}}=this._core,{userID:s,tagValueList:a}=A[0]||{},g=o.getFriend(s);if(r(a)||!g)return;const l=a.map(A=>({tag:A.BytesTag,value:A.BytesValue}));l.forEach(A=>{var e;const{tag:t,value:i}=A,o=null===(e=n.getConversation(`C2C${s}`))||void 0===e?void 0:e.remark;t===c.REMARK&&i!==o&&n.updateConversation(`C2C${s}`,{remark:i}),g.update(l)}),this._emitFriendListUpdated()}_processFriendList(A){const{utils:{isEmpty:e},appStore:{userStore:t}}=this._core;e(A)||A.forEach(A=>{const{userID:e,tagValueList:i}=A;if(this._isInvalidFriend(e))return;const o=new f({userID:e,tagValueList:i,core:this._core});t.getFriendMap().set(e,o)})}_isInvalidFriend(A){return"@TLS#NOT_FOUND"===A||""===A}_fetchFriendProfile(){return A(this,void 0,void 0,function*(){const{appStore:{userStore:A},user:{userProfile:t},ssoLog:i}=this._core;i.debug("_fetchFriendProfile",`${e} _fetchFriendProfile`);const o=[...A.getFriendMap().keys()],n=Math.ceil(o.length/100);for(let e=0;e{const t=A.getFriend(e.userID);t&&(t.profile=e)}),this._emitFriendListUpdated()}})}_emitFriendListUpdated(){const{notificationCenter:A,OuterEvent:e,appStore:{userStore:t}}=this._core,i=Array.from(t.getFriendMap().values());A.emitOuterEvent(e.FRIEND_LIST_UPDATED,{name:e.FRIEND_LIST_UPDATED,data:i})}_updateCustomField(A,e){if(!Array.isArray(A)||!Array.isArray(e))return!1;let t=!1;return e.forEach(({key:e,value:i})=>{const o=A.find(A=>A.key===e);o?o.value!==i&&(o.value=i,t=!0):(A.push({key:e,value:i}),t=!0)}),t}_updateLocalFriend(A){const{userStore:e}=this._core.appStore,{userID:t,remark:i,friendCustomField:o}=A,n=e.getFriend(t);if(n)return h(i)||(n.remark=i),Array.isArray(o)&&o.length>0&&this._updateCustomField(n.friendCustomField,o),this._emitFriendListUpdated(),n}_processOperationResult(A){const{resultList:e,includeRelation:t=!1}=A,{isEmpty:i}=this._core.utils,o=[],n=[];return Array.isArray(e)&&!i(e)&&e.forEach(A=>{const{userID:e,relation:i,resultCode:r,resultInfo:s}=A;if(h(r)||0===r){const A={userID:e};t&&(A.code=0,A.relation=i),o.push(A)}else n.push({userID:e,code:r,message:s})}),{successUserIDList:o,failureUserIDList:n}}_createNonFriendErrorList(A){return A.map(A=>({userID:A,code:i,message:"The specified userID is not my friend"}))}_buildSnsItemList(A,e){const t=[];return h(A)||t.push({Tag:c.REMARK,Value:A}),Array.isArray(e)&&e.length>0&&e.forEach(A=>{t.push({tag:A.key,value:A.value})}),t}_processFriendProfileResponse(A){const{friendProfileList:e=[]}=A,{userStore:t}=this._core.appStore,i=[],o=[];return e.forEach(A=>{const{userID:e,resultCode:n,resultInfo:r,profileItem:s}=A;if(0===n){const A=new f({userID:e,tagValueList:s,core:this._core});i.push(A),t.getFriendMap().set(e,A)}else o.push({userID:e,code:n,message:r})}),{successProfiles:i,failedProfiles:o}}partitionByIsFriend(A){const e=[],t=[];return A.forEach(A=>{const{userStore:i}=this._core.appStore;i.getFriendMap().has(A)?e.push(A):t.push(A)}),{friendUserIdList:e,unFriendUserIdList:t}}isMyFriend(A){const{userStore:e}=this._core.appStore;return e.getFriendMap().has(A)}},y=new class{init(A){this.core=A}};function D(e){return A(this,void 0,void 0,function*(){var A;const{store:t,common:i}=y.core,o={From_Account:null===(A=t.get("login"))||void 0===A?void 0:A.userId,ResponseFriendItem:[{To_Account:e.userID,ResponseAction:e.type,Remark:e.remark}]};return S(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function v(e){return A(this,void 0,void 0,function*(){var A;const{store:t,common:i}=y.core,o={From_Account:null===(A=t.get("login"))||void 0===A?void 0:A.userId,ResponseFriendItem:[{To_Account:e.userID,ResponseAction:"Response_Action_Reject"}]};return S(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function w(e){return A(this,void 0,void 0,function*(){var A;const{store:t,common:i}=y.core,o={From_Account:null===(A=t.get("login"))||void 0===A?void 0:A.userId,To_Account:[e.userID],PendencyType:e.type};return S(yield i.buildAndSendPacket({servcmd:"sns.pendency_delete",data:o}))})}function S(A){const{ResultItem:e=[],ActionStatus:t,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=A;return{resultList:e.map(A=>({userID:A.To_Account,resultCode:A.ResultCode,resultInfo:A.ResultInfo})),actionStatus:t,errorCode:i,errorInfo:o,errorDisplay:n}}var M=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),e.registerApi({apiName:"acceptFriendApplication",context:this}),e.registerApi({apiName:"refuseFriendApplication",context:this}),e.registerApi({apiName:"deleteFriendApplication",context:this}),e.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return A(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:t}}=this._core,i=[...this._friendApplicationMap.values()];return A.debug("getFriendApplicationListFromCache",`${e} getFriendApplicationListFromCache friendApplicationList:${t(i)}`),{code:0,data:{friendApplicationList:i,unreadCount:this._unreadCount}}})}syncFriendApplicationListFromServer(){return A(this,void 0,void 0,function*(){const{ssoLog:i,utils:{safeStringify:o}}=this._core,n="syncFriendApplicationListFromServer";try{const e=yield function(e){return A(this,void 0,void 0,function*(){var A;const{store:i,OuterConstant:o,common:n}=y.core,r={From_Account:null===(A=i.get("login"))||void 0===A?void 0:A.userId,PendencyType:o.SNS_APPLICATION_TYPE_BOTH,MaxLimited:t,StartTime:e.startTime,LastSequence:e.currentSequence};return function(A){const{PendencyItem:e=[],StartTime:t,UnreadPendencyCount:i,CurrentSequence:o,ActionStatus:n,ErrorCode:r,ErrorInfo:s,ErrorDisplay:a}=A;return{resultList:e.map(A=>({userID:A.To_Account,time:A.AddTime,source:A.AddSource,wording:A.AddWording,nick:A.Nick,type:A.PendencyType,avatar:A.Image})),startTime:t,unreadCount:i,currentSequence:o,actionStatus:n,errorCode:r,errorInfo:s,errorDisplay:a}}(yield n.buildAndSendPacket({servcmd:"sns.pendency_get",data:r}))})}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:i,unreadCount:o,startTime:n,currentSequence:r}=e;this._startTime=n,this._currentSequence=r,this._unreadCount=o,this._friendApplicationMap.clear(),Array.isArray(i)&&i.forEach(A=>{const{userID:e,type:t}=A,i=this._createFriendApplication(A);this._friendApplicationMap.set(`${e}_${t}`,i)}),this._emitApplicationListUpdated()}catch(r){const A=new this._core.helper.ChatError({functionName:n,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw i.error("syncFriendApplicationListFromServer",`${e} ${n} error:`,{error:A}),A}})}acceptFriendApplication(e){return A(this,void 0,void 0,function*(){const{OuterConstant:{SNS_APPLICATION_AGREE:A,SNS_APPLICATION_AGREE_AND_ADD:t}}=this._core;return[A,t].includes(e.type)||(e.type=t),this._operationApplication({functionName:"acceptFriendApplication",options:e,protocolFunction:D})})}refuseFriendApplication(e){return A(this,void 0,void 0,function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:e,protocolFunction:v})})}deleteFriendApplication(e){return A(this,void 0,void 0,function*(){const{userID:A,type:t}=e;return this._checkApplicationExists(A,t,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:e,protocolFunction:w})})}_checkApplicationExists(A,e,t){if(!this._friendApplicationMap.has(`${A}_${e}`))throw new this._core.helper.ChatError({functionName:t,code:r})}_operationApplication(t){return A(this,void 0,void 0,function*(){const{functionName:A,options:i,protocolFunction:o}=t;console.log(`${e} ${A} options:`,i);try{const t=yield o(i),{resultList:n=[]}=t,{resultCode:r,resultInfo:s}=n[0];if(0===r)return console.log(`${e} ${A} ok`),{code:0,data:{}};throw{errorCode:r,errorInfo:s}}catch(n){const t=new this._core.helper.ChatError({functionName:A,code:null==n?void 0:n.errorCode,message:null==n?void 0:n.errorInfo});throw console.error(`${e} ${A} error:`,t),t}})}setFriendApplicationRead(){return A(this,void 0,void 0,function*(){try{return yield function(){return A(this,void 0,void 0,function*(){var A;const{store:e,common:t}=y.core,i={From_Account:null===(A=e.get("login"))||void 0===A?void 0:A.userId,LatestPendencyTimeStamp:(o=Math.floor(Date.now()/1e3),n=0,Math.round(Number(o)*Math.pow(10,n))/Math.pow(10,n))};var o,n;return function(A){const{ActionStatus:e,ErrorCode:t,ErrorInfo:i,ErrorDisplay:o}=A;return{actionStatus:e,errorCode:t,errorInfo:i,errorDisplay:o}}(yield t.buildAndSendPacket({servcmd:"sns.pendency_report",data:i}))})}(),this._unreadCount=0,this._emitApplicationListUpdated(),{code:0,data:{}}}catch(e){throw new this._core.helper.ChatError({functionName:"setFriendApplicationRead",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}updateFriendApplicationList(A){const{from:e,addedApplicationList:t=[],removedApplicationList:i=[]}=A,{isEmpty:o}=this._core.utils;o(t)||this.onApplicationAdded(t,e),o(i)||this.onApplicationDeleted()}onApplicationAdded(A,e){var t;const{store:i,OuterConstant:o}=this._core,n=e===(null===(t=i.get("login"))||void 0===t?void 0:t.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;A.forEach(A=>{const e=`${A.userID}_${n}`;n!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(e)||(this._unreadCount+=1),this._friendApplicationMap.set(e,this._createFriendApplication(Object.assign(Object.assign({},A),{type:n})))}),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(A){return{userID:A.userID||"",nick:A.nick||"",avatar:A.avatar||"",time:A.time||0,source:A.source||"",wording:A.wording||"",type:A.type||""}}_emitApplicationListUpdated(){const{notificationCenter:A,OuterEvent:e}=this._core;A.emitOuterEvent(e.FRIEND_APPLICATION_LIST_UPDATED,{name:e.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function R(){return A(this,void 0,void 0,function*(){const{common:A}=y.core,e={From_Account:A.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return L(yield A.buildAndSendPacket({servcmd:"sns.group_get",data:e}),A=>({name:A.GroupName,userIDList:A.To_Account||[],count:A.FriendNumber}))})}function _(e){return A(this,void 0,void 0,function*(){const{name:A,userIDList:t}=e,{common:i}=y.core,o={From_Account:i.getCurrentUserID(),GroupName:[A],To_Account:t};return L(yield i.buildAndSendPacket({servcmd:"sns.group_add",data:o}),A=>({userID:A.To_Account,resultCode:A.ResultCode,resultInfo:A.ResultInfo}))})}function T(e){return A(this,void 0,void 0,function*(){const{common:A}=y.core,t={From_Account:A.getCurrentUserID(),GroupName:[e.name]};return L(yield A.buildAndSendPacket({servcmd:"sns.group_delete",data:t}))})}function N(e){return A(this,void 0,void 0,function*(){const{common:A}=y.core,{name:t,userIDList:i}=e,o=k(i,l),n={From_Account:A.getCurrentUserID(),GroupOldName:t,UpdateGroupItem:o};return L(yield A.buildAndSendPacket({servcmd:"sns.group_update",data:n}),A=>({userID:A.To_Account,updateType:A.UpdateType,resultCode:A.ResultCode,resultInfo:A.ResultInfo}))})}function b(e){return A(this,void 0,void 0,function*(){const{common:A}=y.core,{name:t,userIDList:i}=e,o=k(i,I),n={From_Account:A.getCurrentUserID(),GroupOldName:t,UpdateGroupItem:o};return L(yield A.buildAndSendPacket({servcmd:"sns.group_update",data:n}),A=>({userID:A.To_Account,updateType:A.UpdateType,resultCode:A.ResultCode,resultInfo:A.ResultInfo}))})}function G(e){return A(this,void 0,void 0,function*(){const{common:A}=y.core,{oldName:t,newName:i}=e,o={From_Account:A.getCurrentUserID(),GroupOldName:t,GroupNewName:i};return L(yield A.buildAndSendPacket({servcmd:"sns.group_update",data:o}))})}function k(A,e){return A.filter(A=>m.isMyFriend(A)).map(A=>({To_Account:A,UpdateType:e}))}function L(A,e){const{CurrentSequence:t,ActionStatus:i,ErrorCode:o,ErrorInfo:n,ErrorDisplay:r,ResultItem:s=[]}=A,a={currentSequence:t,actionStatus:i,errorCode:o,errorInfo:n,errorDisplay:r};return e&&s.length>0?Object.assign(Object.assign({},a),{resultList:s.map(e)}):a}class U{constructor(A){const{name:e="",userIDList:t=[]}=A;this.name=e,this.userIDList=t,this.count=t.length}addToUserIDList(A){-1===this.userIDList.indexOf(A)&&(this.userIDList.push(A),this.count=this.userIDList.length)}removeFromUserIDList(A){const e=this.userIDList.indexOf(A);e>-1&&(this.userIDList.splice(e,1),this.count=this.userIDList.length)}}var F=new class{constructor(){this._friendGroupMap=new Map}init(A){this._core=A;const{helper:e}=A;e.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),e.registerApi({apiName:"createFriendGroup",context:this}),e.registerApi({apiName:"deleteFriendGroup",context:this}),e.registerApi({apiName:"addToFriendGroup",context:this}),e.registerApi({apiName:"removeFromFriendGroup",context:this}),e.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return A(this,void 0,void 0,function*(){const{ssoLog:A,utils:{safeStringify:t}}=this._core,i=[...this._friendGroupMap.values()];return A.debug(`${e} getFriendGroupListFromCache, data:${t(i)}`),{code:0,data:i}})}syncFriendGroupListFromServer(){return A(this,void 0,void 0,function*(){const{ssoLog:A}=this._core,t="syncFriendGroupListFromServer";try{const i=yield R(),{resultList:o=[]}=i;this._core.helper.isEmpty(o)&&A.debug("syncFriendGroupListFromServer",`${e} ${t} ok. count: 0`),o.forEach(A=>{const e=new U(A);this._friendGroupMap.set(A.name,e)}),this._emitGroupListUpdated()}catch(i){this._handleError(t,i)}})}createFriendGroup(e){return A(this,void 0,void 0,function*(){const A="createFriendGroup";try{const{name:t}=e;this._checkGroupExist(A,t);const i=yield _(e),{successUserIDList:o,failureUserIDList:n}=this._parseCreateGroupResponse(i),r=new U({name:t,userIDList:o});return this._friendGroupMap.set(t,r),this._emitGroupListUpdated(),{code:0,data:{friendGroup:r,failureUserIDList:n}}}catch(t){this._handleError(A,t)}})}deleteFriendGroup(e){return A(this,void 0,void 0,function*(){const A="deleteFriendGroup";try{const{name:t}=e;this._checkGroupNotExist(A,t),yield T(e);const i=this._friendGroupMap.get(t);return i&&(this._updateFriendGroup({name:t,userIDList:i.userIDList,action:E}),this._friendGroupMap.delete(t)),this._emitGroupListUpdated(),{code:0,data:i}}catch(t){this._handleError(A,t)}})}addToFriendGroup(e){return A(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:e,protocolFunction:N})})}removeFromFriendGroup(e){return A(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:e,protocolFunction:b})})}renameFriendGroup(e){return A(this,void 0,void 0,function*(){const A="renameFriendGroup";try{const{oldName:t,newName:i}=e;this._checkGroupNotExist(A,t),this._checkGroupExist(A,i),yield G(e);const o=this._updateGroupNameInCache(t,i);return o&&this._updateFriendGroup({name:t,userIDList:o.userIDList,action:d,newName:i}),this._emitGroupListUpdated(),{code:0,data:o}}catch(t){this._handleError(A,t)}})}_updateFriendGroupMember(e){return A(this,void 0,void 0,function*(){const{functionName:A,params:t,protocolFunction:i}=e;try{const{name:e}=t;this._checkGroupNotExist(A,e);const o=yield i(t),{friendGroup:n,failureUserIDList:r}=this._parseUpdateFriendGroupResponse(e,o);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:n,failureUserIDList:r}}}catch(o){this._handleError(A,o)}})}_updateGroupNameInCache(A,e){const t=this._friendGroupMap.get(A);return t&&(t.name=e,this._friendGroupMap.delete(A),this._friendGroupMap.set(e,t)),t}_parseCreateGroupResponse(A){const{resultList:e=[]}=A,t=[],i=[];return e.forEach(({userID:A,resultCode:e,resultInfo:o})=>{h(e)||0===e?t.push(A):i.push({userID:A,code:e,message:o})}),{successUserIDList:t,failureUserIDList:i}}_parseUpdateFriendGroupResponse(A,e){const{resultList:t=[]}=e,i=this._friendGroupMap.get(A),o=[],n=[],r=[];return t.forEach(e=>{0===e.resultCode?i&&(e.updateType===l?this._addFriendToGroup(A,e.userID,i,n):e.updateType===I&&this._removeFriendFromGroup(A,e.userID,i,r)):o.push({userID:e.userID,code:e.resultCode,message:e.resultInfo})}),{friendGroup:i,failureUserIDList:o}}_addFriendToGroup(A,e,t,i){t.addToUserIDList(e),i.push(e),this._updateFriendGroup({name:A,userIDList:i,action:u})}_removeFriendFromGroup(A,e,t,i){t.removeFromUserIDList(e),i.push(e),this._updateFriendGroup({name:A,userIDList:i,action:E})}_emitGroupListUpdated(){const{notificationCenter:A,OuterEvent:e}=this._core,t=[...this._friendGroupMap.values()];A.emitOuterEvent(e.FRIEND_GROUP_LIST_UPDATED,{name:e.FRIEND_GROUP_LIST_UPDATED,data:t})}_checkGroupNotExist(A,e){if(!this._friendGroupMap.has(e))throw new this._core.helper.ChatError({functionName:A,code:n})}_checkGroupExist(A,e){if(this._friendGroupMap.has(e))throw new this._core.helper.ChatError({functionName:A,code:o})}_updateFriendGroup(A){const{name:e,userIDList:t,action:i,newName:o}=A,{userStore:n}=this._core.appStore;e&&!this._core.utils.isEmpty(t)&&t.forEach(A=>{const t=n.getFriend(A);if(!t)return;const{groupList:r}=t;switch(i){case u:-1===r.indexOf(e)&&(r.push(e),t.count=r.length);break;case E:{const A=r.indexOf(e);A>-1&&(r.splice(A,1),t.count=r.length);break}case d:{if(!o)return;const A=r.indexOf(e);-1!==A&&(r[A]=o);break}}})}_handleError(A,e){throw new this._core.helper.ChatError({functionName:A,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function O(A){return A&&0!==A.length?A.map(A=>({userID:A.To_Account,addBlackTimeStamp:A.AddBlackTimeStamp})):[]}var x=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(A){this._core=A;const{helper:e,constants:t}=A;e.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),e.registerApi({apiName:"addToBlacklist",context:this}),e.registerApi({apiName:"removeFromBlacklist",context:this}),e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return A(this,void 0,void 0,function*(){return{code:0,data:Array.from(this._blacklistMap.keys())}})}syncBlacklistFromServer(){return A(this,void 0,void 0,function*(){try{this._core.ssoLog.debug(`${e} syncBlacklistFromServer`);const i={From_Account:this._core.common.getCurrentUserID(),MaxLimited:t,StartIndex:this._startIndex},o=yield function(e,t){return A(this,void 0,void 0,function*(){const{helper:A,channel:i}=t,o="sns.black_list_get",n=A.generateProtocolData({servcmd:o,data:e}),r=`${n.head.seq}${o}`,s=yield i.sendPacket(n,{requestId:r}),{BlackListItem:a=[],StartIndex:g=0}=s;return{blackList:O(a),startIndex:g}})}(i,this._core),{blackList:n=[],startIndex:r=0}=o;return this._startIndex=r,this._addBlacklistMap(n),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(i){throw this._retryCount=0,i}})}addToBlacklist(e){return A(this,void 0,void 0,function*(){const{helper:t}=this._core;try{const t=this._preprocessBlacklist(e),i={From_Account:this._core.common.getCurrentUserID(),To_Account:t},o=yield function(e,t){return A(this,void 0,void 0,function*(){const{helper:A,channel:i}=t,o="sns.black_list_add",n=A.generateProtocolData({servcmd:o,data:e}),r=`${n.head.seq}${o}`,s=yield i.sendPacket(n,{requestId:r}),{ResultItem:a=[]}=s;return{blackList:O(a)}})}(i,this._core),{blackList:n=[]}=o;return this._addBlacklistMap(n),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(i){const{errorCode:A}=i||{};throw new t.ChatError({code:A})}})}removeFromBlacklist(e){return A(this,void 0,void 0,function*(){const{helper:t}=this._core;try{const t={From_Account:this._core.common.getCurrentUserID(),To_Account:e.userIDList},i=yield function(e,t){return A(this,void 0,void 0,function*(){const{helper:A,channel:i}=t,o="sns.black_list_delete",n=A.generateProtocolData({servcmd:o,data:e}),r=`${n.head.seq}${o}`,s=yield i.sendPacket(n,{requestId:r}),{ResultItem:a=[]}=s;return{blackList:O(a)}})}(t,this._core),{blackList:o=[]}=i;return this._deleteBlacklistMap(o),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(i){const{errorCode:A}=i||{};throw new t.ChatError({code:A})}})}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(A){const{ssoLog:t,utils:{safeStringify:i}}=this._core;t.debug("updateBlacklist",`${e} updateBlacklist data: ${i(A)}`);const{addedBlacklist:o=[],removedBlacklist:n=[]}=A;let r=!1;o.length>0&&o.some(A=>!this._blacklistMap.has(A))&&(r=!0,this._addBlacklistMap(o.map(A=>({userID:A})))),n.length>0&&n.some(A=>this._blacklistMap.has(A))&&(r=!0,this._deleteBlacklistMap(n.map(A=>({userID:A})))),r&&this._emitBlackListUpdated()}_addBlacklistMap(A){const{ssoLog:t,utils:{safeStringify:i}}=this._core;t.debug("_addBlacklistMap",`${e} _addBlacklistMap blackList: ${i(A)}`),A.forEach(A=>{const{userID:e,addBlackTimeStamp:t=Date.now()}=A;e&&!this._blacklistMap.has(e)&&this._blacklistMap.set(e,{userID:e,addBlackTimeStamp:t})})}_deleteBlacklistMap(A){const{ssoLog:t,utils:{safeStringify:i}}=this._core;t.debug("_deleteBlacklistMap",`${e} _deleteBlacklistMap blackList: ${i(A)}`),A.forEach(A=>{const{userID:e}=A;e&&this._blacklistMap.has(e)&&this._blacklistMap.delete(e)})}_preprocessBlacklist(A){let{userIDList:e}=A;const t=this._core.common.getCurrentUserID();if(1===e.length&&e[0]===t)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:s});return e.includes(t)&&(e=A.userIDList.filter(A=>A!==t)),e}_emitBlackListUpdated(){const{notificationCenter:A,OuterEvent:t,ssoLog:i,utils:{safeStringify:o}}=this._core,n=Array.from(this._blacklistMap.keys());i.debug(`${e} _emitBlackListUpdated blackList:${o(n)}`),A.emitOuterEvent(t.BLACKLIST_UPDATED,{name:t.BLACKLIST_UPDATED,data:n})}};const P={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:A=>{const{OuterConstant:e}=y.core;return A===e.SNS_ADD_TYPE_SINGLE||A===e.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:A=>{const{OuterConstant:e}=y.core;return A===e.SNS_DELETE_TYPE_SINGLE||A===e.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:A=>{const{OuterConstant:e}=y.core;return A===e.SNS_APPLICATION_SENT_TO_ME||A===e.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},Y={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};return new class{constructor(){this.name="Friend"}install(A){A.ssoLog.debug(`${e} install`),this._core=A;const{helper:t,notificationCenter:i,InnerEvent:o,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:r}}=A;y.init(A),m.init(A),M.init(A),F.init(A),x.init(A),t.registerValidateConfig({auth:Y,params:P}),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,r.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),i.subscribeInnerEvent(o.LOGOUT,this.reset,this),i.subscribeInnerEvent(o.MESSAGE_PUSH,i.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){x.syncBlacklistFromServer(),m.syncFriendListFromServer(),M.syncFriendApplicationListFromServer(),F.syncFriendGroupListFromServer()}onFriendModified(A){const{from:e,addedBlacklist:t,removedBlacklist:i,addedFriendList:o,removedFriendList:n,addedApplicationList:r,removedApplicationList:s,friendUpdateInfo:a,reportTime:g}=this._parseFriendListModification(null==A?void 0:A.FriendListMod[0]),{isEmpty:c}=this._core.utils;c(t)&&c(i)||x.updateBlacklist({addedBlacklist:t,removedBlacklist:i}),c(o)&&c(n)||(m.updateFriendList({addedFriendList:o,removedFriendList:n}),M.updateFriendApplicationList({from:e,removedApplicationList:o})),c(a)||m.updateFriendInfo(a),c(r)&&c(s)||M.updateFriendApplicationList({from:e,addedApplicationList:r,removedApplicationList:s}),g&&M.onApplicationRead()}_parseFriendListModification(A){const{PushType:e,From_Account:t,To_Account:i,ReportTime:o,BlackListAdd_Account:n=[],BlackListDel_Account:r=[],FriendAdd_Account:s=[],FriendDel_Account:a=[],PendencyAdd:g=[],FrienPencydDel_Account:c=[],FriendUpInfo:l=[]}=A,I=l.map(A=>({userID:A.Friend_Account,tagValueList:[...A.SNS]}));return{pushType:e,from:t,to:i,reportTime:o,addedBlacklist:n,removedBlacklist:r,addedFriendList:s,removedFriendList:a,addedApplicationList:g.map(A=>({userID:A.PendencyAdd_Account,source:A.AddSource,time:A.AddTime,wording:A.AddWording,nick:A.ProfileImNick})),friendUpdateInfo:I,removedApplicationList:c}}reset(){x.reset(),m.reset(),M.reset(),F.reset()}dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.LOGOUT,this.reset,this),A.unSubscribeInnerEvent(e.MESSAGE_PUSH,A.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),x.dispose(),m.dispose(),M.dispose(),F.dispose()}}}();const d_=RR(E_.exports);var h_={exports:{}};h_.exports=function(){var A=new class{constructor(){this._conversationGroupMap=new Map}init(A){this._core=A}getConversationGroupMap(){return this._conversationGroupMap}getConversationGroup(A){return this._conversationGroupMap.get(A)}setConversationGroup(A,e){this._conversationGroupMap.set(A,e)}};function e(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const t=new class{init(A){this.core=A}},i="CONV_GROUP",o=2500,n=2503,r=1,s=2,a="NOT_STARTED",g="FETCHING",c="FINISHED",l="FAILED",I=0,u=1,E=1,d=2,h=3,C=1,B=2;function Q(A){const{helper:e,constants:o}=t.core;if(!e.checkBusinessCapabilityBits(i))throw new e.ChatError({functionName:A,code:o.ERROR_CODE.NO_USE,replacement1:A})}function p(){const{notificationCenter:e,OuterEvent:i}=t.core;e.emitOuterEvent(i.CONVERSATION_GROUP_LIST_UPDATED,{name:i.CONVERSATION_GROUP_LIST_UPDATED,data:[...A.getConversationGroupMap().values()]})}function f(A){const{utils:{isUndefined:e},constants:{OuterConstant:i}}=t.core,{Type:o,To_Account:n,Peer_Account:a}=A;let g="";const c=A.ToGroupId||A.GroupId;return o===r?e(a)?e(n)||(g=`${i.CONV_C2C}${n}`):g=`${i.CONV_C2C}${a}`:o===s&&(g=`${i.CONV_GROUP}${c}`),g}function m(A){const e=[],{OuterConstant:i,common:{isC2CConv:o,isGroupConv:n}}=t.core,{conversationIDList:a,failureConversationIDList:g,additionalData:c={}}=A;return a.forEach(A=>{y(A,g),o(A)?e.push(Object.assign({ContactItem:{Type:r,To_Account:A.replace(i.CONV_C2C,"")}},c)):n(A)&&e.push(Object.assign({ContactItem:{Type:s,ToGroupId:A.replace(i.CONV_GROUP,"")}},c))}),e}function y(A,e){const{appStore:{conversationStore:i},common:{isC2CConv:r,isGroupConv:s}}=t.core;i.getConversation(A)?r(A)||s(A)||e.push({conversationID:A,code:n}):e.push({conversationID:A,code:o})}function D(A){const{utils:{isString:e}}=t.core,i=[];if(!e(A))return i;const o=A.length;if(0===o)return i;for(let t=o-1;t>=0;t--)"1"===A[t]&&i.push(Math.pow(2,o-t-1));return i}function v(A){null==A||A.forEach((e,i)=>{const{appStore:o}=t.core,{conversationID:n,data:r}=e,s=i===A.length-1;o.conversationStore.updateConversation(n,r,{emit:s})})}function w(A){const{conversationInfoList:e,fromAccount:i}=A,o={From_Account:i,MarkItem:e};return t.core.common.buildAndSendPacket({servcmd:"recentcontact.mark_contact",data:o})}function S(A){const{fromAccount:e,groupName:i,conversationInfoList:o}=A,n={From_Account:e,UpdateType:1,UpdateGroup:{UpdateGroupType:B,OldGroupName:i,ContactUpdateItem:o}};return t.core.common.buildAndSendPacket({servcmd:"recentcontact.update_contact_group",data:n})}var M=new class{init(A){const{helper:{registerApi:e}}=A;this._core=A,e({apiName:"createConversationGroup",context:this})}createConversationGroup(i){return e(this,void 0,void 0,function*(){const{utils:{isPlainObject:e,isArray:o},appStore:n}=this._core;Q("createConversationGroup");const{groupName:r,conversationIDList:s}=i,a=[],g=this._generateConversationInfo(s,a);if(a.length===s.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:a}};try{const i=yield function(A){const{common:{buildAndSendPacket:e,getCurrentUserID:i}}=t.core,{item:o,groupName:n}=A;return e({servcmd:"recentcontact.create_contact_group",data:{From_Account:i(),GroupContactItem:[{GroupName:n,ContactItem:o}]}})}({groupName:r,item:g});if(i){const{GroupResultItem:t=[]}=i,{GroupItem:s,ResultItem:g}=(null==t?void 0:t[0])||{},c=[];if(e(s)){const{GroupName:e,GroupId:t}=s;A.setConversationGroup(t,e),p()}if(o(g)){const A=[];g.forEach(e=>{const{ContactItem:t,ResultCode:i,ResultInfo:o}=e,s=f(t);if(0===i){const e=n.conversationStore.getConversation(s);if(e&&!e.conversationGroupList.includes(r)){const t=e.conversationGroupList.slice();t.push(r),A.push({conversationID:s,data:{conversationGroupList:t}})}}else a.push({conversationID:s,code:i,message:o})}),A.length>0&&(v(A),p())}return{code:0,data:{successConversationIDList:c,failureConversationIDList:a}}}}catch(c){const{errorCode:A,errorInfo:e}=c;throw new this._core.helper.ChatError({functionName:"createConversationGroup",code:A,message:e})}})}_generateConversationInfo(A,e,t={}){const i=[],{OuterConstant:o,common:{isC2CConv:n,isGroupConv:a}}=this._core;return A.forEach(A=>{y(A,e),n(A)?i.push(Object.assign({Type:r,To_Account:A.replace(o.CONV_C2C,"")},t)):a(A)&&i.push(Object.assign({Type:s,ToGroupId:A.replace(o.CONV_GROUP,"")},t))}),i}},R=new class{constructor(){this._fetchConversationGroupStatus=a}init(A){const{helper:{registerApi:e,registerWorkflowStep:t},constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:o}}=A;this._core=A,e({apiName:"getConversationGroupList",context:this}),t(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.CONVERSATION_GROUP_LIST_SYNC,this._syncConversationGroupList,this),t(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.CONVERSATION_GROUP_UPDATE,this._updateConversation,this)}getConversationGroupList(){return e(this,void 0,void 0,function*(){return Q("getConversationGroupList"),this._fetchConversationGroupStatus===l&&(yield this._fetchConversationGroupList(0)),{code:0,data:[...A.getConversationGroupMap().values()]}})}_syncConversationGroupList(){return e(this,void 0,void 0,function*(){return yield this._fetchConversationGroupList(0)})}_fetchConversationGroupList(i){return e(this,arguments,void 0,function*(e,i=[]){const{common:{getCurrentUserID:o},utils:{isArray:n}}=this._core;this._fetchConversationGroupStatus=g;try{const r=o(),s=yield function(A){const{fromAccount:e,startIndex:i}=A,o={From_Account:e,StartIndex:i};return t.core.common.buildAndSendPacket({servcmd:"recentcontact.get_contact_group",data:o})}({fromAccount:r,startIndex:e});if(s){const{CompleteFlag:e,ContactItem:t=[],NextStartIndex:o=0,GroupItem:r=[]}=s;if(n(r)&&r.forEach(e=>{const{GroupName:t,GroupId:i}=e;A.setConversationGroup(i,t)}),i.push(...t),e===I)return this._fetchConversationGroupList(o);if(e===u)return this._fetchConversationGroupStatus=c,i}}catch(r){this._fetchConversationGroupStatus=l,console.error(r)}})}_updateConversation(A){var e;const{constants:{WORKFLOW_STEP:t}}=this._core,i=(null===(e=null==A?void 0:A.result)||void 0===e?void 0:e[t.CONVERSATION_GROUP_LIST_SYNC])||[];v(this._generateConversationUpdateFields(i)),p()}_generateConversationUpdateFields(e){const{utils:{isArray:t},appStore:i}=this._core,o=[];if(t(e)){let n;e.forEach(e=>{const r=[],{StandardMark:s,CustomMark:a="",ContactGroupId:g}=e;t(g)&&g.forEach(e=>{A.getConversationGroupMap().has(e)&&r.push(A.getConversationGroup(e))});const c=f(e);n=i.conversationStore.getConversation(c),n&&o.push({conversationID:c,data:{markList:D(s),customData:a,conversationGroupList:[...r]}})})}return o}reset(){this._fetchConversationGroupStatus=a}dispose(){this.reset()}},_=new class{init(A){const{notificationCenter:e,helper:{registerApi:t},InnerEvent:{MESSAGE_PUSH:i},InnerEventSubType:{CONVERSATION_MARK_UPDATED:o,CONVERSATION_GROUP_ADD:n,CONVERSATION_GROUP_DELETED:r,CONVERSATION_GROUP_UPDATED:s}}=A;this._core=A,t({apiName:"renameConversationGroup",context:this}),t({apiName:"deleteConversationGroup",context:this}),t({apiName:"markConversation",context:this}),t({apiName:"setConversationCustomData",context:this}),t({apiName:"deleteConversationsFromGroup",context:this}),t({apiName:"addConversationsToGroup",context:this}),e.subscribeInnerEvent(i,n,this._handleConversationGroupAdd,this),e.subscribeInnerEvent(i,r,this._handleConversationGroupDeleted,this),e.subscribeInnerEvent(i,s,this._handleConversationGroupUpdated,this),e.subscribeInnerEvent(i,o,this._handleConversationMarkUpdated,this)}renameConversationGroup(i){return e(this,void 0,void 0,function*(){Q("renameConversationGroup");const{common:{getCurrentUserID:e}}=this._core,{oldName:o,newName:n}=i,r=`oldName:${o} newName:${n}`;try{const i=yield function(A){const{fromAccount:e,oldName:i,newName:o}=A,n={From_Account:e,UpdateType:1,UpdateGroup:{UpdateGroupType:C,OldGroupName:i,NewGroupName:o}};return t.core.common.buildAndSendPacket({servcmd:"recentcontact.update_contact_group",data:n})}({fromAccount:e(),oldName:o,newName:n});if(i){const{UpdateGroupResult:e}=i,{GroupId:t}=e;A.setConversationGroup(t,n),p(),this._updateLocalConversationGroupName({oldName:o,newName:n})}return{successLog:{message:r}}}catch(s){const{errorCode:A,errorInfo:e}=s;throw new this._core.helper.ChatError({functionName:"renameConversationGroup",code:A,message:e,moreMessage:r})}})}deleteConversationGroup(i){return e(this,void 0,void 0,function*(){Q("deleteConversationGroup");const{common:{getCurrentUserID:e}}=this._core;try{const o=yield function(A){const{fromAccount:e,groupName:i}=A,o={From_Account:e,GroupName:[i]};return t.core.common.buildAndSendPacket({servcmd:"recentcontact.del_contact_group",data:o})}({fromAccount:e(),groupName:i});if(o){const{GroupItem:e}=o;let t=!1;return null==e||e.forEach(e=>{const{GroupId:i}=e,o=A.getConversationGroupMap();o.has(i)&&(o.delete(i),t=!0)}),t&&p(),this._deleteLocalConversationGroupName([i]),{successLog:{message:`groupName:${i}`}}}}catch(o){const{errorCode:A,errorInfo:e}=o;throw new this._core.helper.ChatError({functionName:"deleteConversationGroup",code:A,message:e,moreMessage:`groupName:${i}`})}})}markConversation(A){return e(this,void 0,void 0,function*(){Q("markConversation");const{utils:{isNumber:e},common:{getCurrentUserID:t},appStore:i}=this._core,{conversationIDList:o,markType:n,enableMark:r}=A,s=this._getFlagBit(n),a=[],g=[];let c,l;!0===r&&e(s)?c=[s]:l=[s];const I=m({conversationIDList:o,failureConversationIDList:a,additionalData:{SetMark:c,ClearMark:l,OptType:E}});if(a.length===o.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:a}};try{const A=yield w({conversationInfoList:I,fromAccount:t()});if(A){const{ResultItem:e}=A,t=[];e.forEach(A=>{const{ContactItem:e,ResultCode:o,ResultInfo:s}=A,c=f(e);if(0===o){g.push(c);const A=i.conversationStore.getConversation(c);if(A){const e=A.markList.indexOf(n),i=!1===r&&-1!==e;if(!0===r&&-1===e)t.push({conversationID:c,data:{markList:[...A.markList,n]}});else if(i){const i=A.markList.slice();i.splice(e,1),t.push({conversationID:c,data:{markList:i}})}}}else a.push({conversationID:c,code:o,message:s})}),v(t)}return{code:0,data:{successConversationIDList:g,failureConversationIDList:a}}}catch(u){const{errorCode:A,errorInfo:e}=u;throw new this._core.helper.ChatError({functionName:"markConversation",code:A,message:e})}})}setConversationCustomData(A){return e(this,void 0,void 0,function*(){Q("setConversationCustomData");const{common:{getCurrentUserID:e},appStore:t}=this._core,{conversationIDList:i,customData:o}=A,n=[],r=[],s=m({conversationIDList:i,failureConversationIDList:n,additionalData:{CustomMark:o,OptType:d}});if(n.length===i.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:n}};try{const A=yield w({fromAccount:e(),conversationInfoList:s});if(A){const{ResultItem:e}=A,i=[];null==e||e.forEach(A=>{const{ContactItem:e,ResultCode:s,ResultInfo:a}=A;if(0===s){const A=f(e);r.push(A);const n=t.conversationStore.getConversation(A);n&&n.customData!==o&&i.push({conversationID:A,data:{customData:o}})}else n.push({conversationID:conversationID,code:s,message:a})}),v(i)}return{code:0,data:{successConversationIDList:r,failureConversationIDList:n}}}catch(a){const{errorCode:A,errorInfo:e}=a;throw new this._core.helper.ChatError({functionName:"setConversationCustomData",code:A,message:e})}})}deleteConversationsFromGroup(A){return e(this,void 0,void 0,function*(){Q("deleteConversationsFromGroup");const{common:{getCurrentUserID:e},appStore:t}=this._core,{conversationIDList:i,groupName:o}=A,n=[],r=[],s=m({conversationIDList:i,failureConversationIDList:n,additionalData:{ContactOptType:2}});if(n.length===i.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:n}};try{const A=yield S({fromAccount:e(),groupName:o,conversationInfoList:s});if(A){const e=[],{UpdateGroupResult:{ContactResultItem:i}}=A;null==i||i.forEach(A=>{const i=f(A.ContactItem);if(0===A.ResultCode){const A=t.conversationStore.getConversation(i);if(A){const t=A.conversationGroupList.indexOf(o);if(-1!==t){const o=A.conversationGroupList.slice();o.splice(t,1),r.push(i),e.push({conversationID:i,data:{conversationGroupList:o}})}}}else n.push({conversationID:i,code:A.ResultCode,message:A.ResultInfo})}),e.length>0&&(p(),v(e))}return{code:0,data:{successConversationIDList:r,failureConversationIDList:n}}}catch(a){const{errorCode:A,errorInfo:e}=a;throw new this._core.helper.ChatError({functionName:"deleteConversationsFromGroup",code:A,message:e})}})}addConversationsToGroup(A){return e(this,void 0,void 0,function*(){Q("deleteConversationsFromGroup");const{common:{getCurrentUserID:e},appStore:t}=this._core,{conversationIDList:i,groupName:o}=A,n=[],r=[],s=m({conversationIDList:i,failureConversationIDList:n,additionalData:{ContactOptType:1}});if(n.length===i.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:n}};try{const A=yield S({fromAccount:e(),groupName:o,conversationInfoList:s});if(A){const e=[],{UpdateGroupResult:{ContactResultItem:i}}=A;null==i||i.forEach(A=>{const i=f(A.ContactItem);if(0===A.ResultCode){const A=t.conversationStore.getConversation(i);if(A&&-1===A.conversationGroupList.indexOf(o)){const t=A.conversationGroupList.slice();t.push(o),r.push(i),e.push({conversationID:i,data:{conversationGroupList:t}})}}else n.push({conversationID:i,code:A.ResultCode,message:A.ResultInfo})}),e.length>0&&(p(),v(e))}return{code:0,data:{successConversationIDList:r,failureConversationIDList:n}}}catch(a){const{errorCode:A,errorInfo:e}=a;throw new this._core.helper.ChatError({functionName:"deleteConversationsFromGroup",code:A,message:e})}})}_updateLocalConversationGroupName(A){const{appStore:e}=this._core,{oldName:t,newName:i}=A;let o=[];const n=[];let r=-1;Array.from(e.conversationStore.getConversationMap().values()).forEach(A=>{if(o=A.conversationGroupList,r=o.indexOf(t),-1!==r){const e=o.slice();e.splice(r,1,i),n.push({conversationID:A.conversationID,data:{conversationGroupList:e}})}}),v(n)}_deleteLocalConversationGroupName(A){const{utils:{isEmpty:e},appStore:t}=this._core;if(e(A))return;const i=[];Array.from(t.conversationStore.getConversationMap().values()).forEach(e=>{const{conversationID:t,conversationGroupList:o}=e,n=o.filter(e=>!A.includes(e));n.length=0;i--)if("1"===e[i])return t-i-1}_handleConversationGroupAdd(e){var t;const{utils:{isArray:i},appStore:o}=this._core;null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{const{RecentContactCreateContactGroup:{MsgContactGroupContactItem:t}}=e;let n=!1;null==t||t.forEach(e=>{const{MsgGroupItem:t,MsgRecentContactItem:r}=e,{GroupId:s,GroupName:a}=t,g=[];A.getConversationGroup(s)!==a&&(A.setConversationGroup(s,a),n=!0),i(r)&&r.forEach(A=>{var e;const t=f(A),i=o.conversationStore.getConversation(t);if(i&&!(null===(e=i.conversationGroupList)||void 0===e?void 0:e.includes(a))){const A=i.conversationGroupList.slice();A.push(a),g.push({conversationID:t,data:{conversationGroupList:A}})}}),n&&p(),v(g)})})}_handleConversationGroupDeleted(e){var t;const{utils:{isArray:i}}=this._core;null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{const{MsgGroupItem:t}=(null==e?void 0:e.RecentContactDelContactGroup)||{};if(i(t)){let e=!1;const i=[];t.forEach(t=>{const{GroupId:o,GroupName:n}=t,r=A.getConversationGroupMap();r.has(o)&&(r.delete(o),e=!0,i.push(n))}),e&&p(),i.length>0&&this._deleteLocalConversationGroupName(i)}})}_handleConversationGroupUpdated(A){var e;null===(e=A.RecentContactMod)||void 0===e||e.forEach(A=>{const{RecentContactUpdateContactGroup:{MsgUpdateGroup:{GroupId:e,GroupName:t,OldGroupName:i,RecentContactUpdateGroupItem:o,UpdateGroupType:n}}}=A;1===n?this._handleGroupNameUpdated({groupID:e,newName:t,oldName:i}):2===n&&this._handleGroupAddOrDeleteFromConversation({groupInfoList:o,groupName:i})})}_handleConversationMarkUpdated(A){var e;const{appStore:t}=this._core;null===(e=null==A?void 0:A.RecentContactMod)||void 0===e||e.forEach(A=>{const{RecentContactMarkContact:{RecentContactMarkContactItem:e}}=A,i=[];null==e||e.forEach(A=>{const{RecentContactItem:e,CustomMark:o,StandardMark:n,OptType:r}=A,s=f(e),a=t.conversationStore.getConversation(s);a&&(r===E?this._updateStandMark({conversation:a,standardMark:n,updateConversationList:i}):r===d?this._updateCustomMark({conversation:a,customMark:o,updateConversationList:i}):r===h&&(this._updateStandMark({conversation:a,standardMark:n,updateConversationList:i}),this._updateCustomMark({conversation:a,customMark:o,updateConversationList:i})))}),v(i)})}_updateStandMark(A){const{conversation:e,standardMark:t,updateConversationList:i}=A,o=D(t);(function(A,e){if(A===e)return!0;if(!A||!e)return!1;if(A.length!==e.length)return!1;A.sort(),e.sort();for(let t=0,i=A.length;t{const{RecentContactItem:o,ContactOptType:n}=A,r=f(o),s=t.conversationStore.getConversation(r),a=s.conversationGroupList.indexOf(e);if(s){const A=s.conversationGroupList.slice();1===n&&-1===a?(A.push(e),i.push({conversationID:r,data:{conversationGroupList:A}})):2===n&&-1!==a&&(A.splice(a,1),i.push({conversationID:r,data:{conversationGroupList:A}}))}}),v(i)}dispose(){const{notificationCenter:A,InnerEvent:{MESSAGE_PUSH:e},InnerEventSubType:{CONVERSATION_MARK_UPDATED:t,CONVERSATION_GROUP_ADD:i,CONVERSATION_GROUP_DELETED:o,CONVERSATION_GROUP_UPDATED:n}}=this._core;A.unSubscribeInnerEvent(e,i,this._handleConversationGroupAdd,this),A.unSubscribeInnerEvent(e,o,this._handleConversationGroupDeleted,this),A.unSubscribeInnerEvent(e,n,this._handleConversationGroupUpdated,this),A.unSubscribeInnerEvent(e,t,this._handleConversationMarkUpdated,this)}};const T={required:!0,rules:["string"],allowEmpty:!1},N={required:!0,rules:["array"],allowEmpty:!1},b={createConversationGroup:{groupName:T,conversationIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameConversationGroup:{oldName:T,newName:Object.assign(Object.assign({},T),{customValidator:A=>!(A.length>32)||"newName length cannot longer than 32"})},deleteConversationGroup:[{required:!0,rules:["string"],allowEmpty:!1}],addConversationsToGroup:{conversationIDList:N,groupName:T},deleteConversationsFromGroup:{conversationIDList:N,groupName:T},markConversation:{conversationIDList:N,markType:{required:!0,rules:["number"],allowEmpty:!1,customValidator:A=>A<=0?"markType must be greater than 0":!(A>=Math.pow(2,64))||"markType must be less than 2^64"},enableMark:{required:!0,rules:["boolean"],allowEmpty:!1}},setConversationCustomData:{conversationIDList:N,customData:{required:!1,rules:["string"],allowEmpty:!0,customValidator:A=>"string"!=typeof A?"customData must be string":!(A.length>256)||"customData length cannot longer than 256"}}},G={createConversationGroup:!0,deleteConversationGroup:!0,renameConversationGroup:!0,getConversationGroupList:!0,addConversationsToGroup:!0,deleteConversationsFromGroup:!0,markConversation:!0,setConversationCustomData:!0};return new class{constructor(){this.name="ConversationGroup"}install(e){this._core=e,t.init(e),A.init(e),M.init(e),R.init(e),_.init(e),e.helper.registerValidateConfig({auth:G,params:b}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this.reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this.dispose,this)}dispose(){const{notificationCenter:A,InnerEvent:e}=this._core;A.unSubscribeInnerEvent(e.LOGOUT,this.reset,this),A.unSubscribeInnerEvent(e.DESTROY,this.dispose,this),_.dispose(),R.dispose()}reset(){R.reset()}}}();const C_=RR(h_.exports);function B_(A,e){var t={};for(var i in A)Object.prototype.hasOwnProperty.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(A);o{this.events[A].clear()}),this.events={}}dispatch(A,e){if(this.events[A])for(const t of this.events[A].keys())t.call(this,e)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.on(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.on(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.off(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.off(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this),A.instance=null}onSDKReady(A){this.dispatch(this.engine.EVENT.SDK_READY,A.data)}onSDKNotReady(A){this.dispatch(this.engine.EVENT.SDK_NOT_READY,A.data)}onKickedOut(A){this.dispatch(this.engine.EVENT.KICKED_OUT,A.data)}onNetStateChange(A){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,A.data)}onReceiveMessage(A){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,A.data)}onMessageModified(A){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,A.data)}onMessageRevoked(A){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,A.data)}onMessageReadByPeer(A){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,A.data)}onMessageReadReceiptReceived(A){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,A.data)}onMessageReactionsUpdated(A){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,A.data)}onConversationListUpdated(A){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,A.data)}onTotalMessageCountUpdated(A){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,A.data)}onProfileUpdated(A){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,A.data)}onBlacklistUpdated(A){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,A.data)}onUserStatusUpdated(A){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,A.data)}onGroupListUpdated(A){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,A.data)}onGroupAttributesUpdated(A){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,A.data)}onGroupCounterUpdated(A){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,A.data)}onFriendListUpdated(A){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,A.data)}onFriendApplicationListUpdated(A){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,A.data)}onFriendGroupListUpdated(A){this.dispatch(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,A.data)}};var f_,m_,y_,D_,v_,w_,S_,M_,R_,__;(__=f_||(f_={})).TUIStore="TUIStore",__.TUITranslate="TUITranslate",__.TUIConversation="TUIConversation",__.TUIChat="TUIChat",__.TUIGroup="TUIGroup",__.TUIUser="TUIUser",__.TUIFriend="TUIFriend",__.TUIReport="TUIReport",__.TUISearch="TUISearch",function(A){A.APP="application",A.CONV="conversation",A.CHAT="chat",A.GRP="group",A.USER="user",A.FRIEND="friend",A.SEARCH="search",A.CUSTOM="custom"}(m_||(m_={})),function(A){A[A.UNSUB_USER=-1]="UNSUB_USER"}(y_||(y_={})),function(A){A.BUSINESS_ID="user_typing_status",A[A.STATUS_START=1]="STATUS_START",A[A.STATUS_END=0]="STATUS_END",A[A.VERSION=1]="VERSION",A[A.ACTION_START_ID=14]="ACTION_START_ID",A[A.ACTION_END_ID=0]="ACTION_END_ID",A.ACTION_START="EIMAMSG_InputStatus_Ing",A.ACTION_END="EIMAMSG_InputStatus_End",A[A.NEED_TYPING=1]="NEED_TYPING"}(D_||(D_={})),function(A){A.ADD="add",A.REMOVE="remove"}(v_||(v_={})),function(A){A[A.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",A[A.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",A[A.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(w_||(w_={})),function(A){A[A.NOT_INIT=-1e5]="NOT_INIT",A[A.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",A[A.CONV_ID_SAME=-100002]="CONV_ID_SAME",A[A.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",A[A.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",A[A.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(S_||(S_={})),function(A){A.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",A.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",A.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(M_||(M_={})),function(A){A.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",A.INVALID_CONV_ID="会话 ID 无效",A.CONV_ID_SAME="您切换的是同一个会话 ID",A.CONV_NOT_EXIST="会话不存在",A.GET_MSG_LIST_ERROR="Chat SDK is not ready.",A.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(R_||(R_={}));const T_={logout:1,destroy:1},N_=function(A){return void 0===A},b_=function(A){return A.startsWith("_")},G_=function(A){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(A)},k_=function(A){return A&&function(A){if("string"==typeof A)try{return!!JSON.parse(A)}catch(e){return!1}return!1}(A)?JSON.parse(A):A},L_=function(A){let e="";return e=A>=1048576?`${(A/1048576).toFixed(2)} Mb`:A>=1024?`${(A/1024).toFixed(2)} Kb`:`${A.toFixed(2)}B`,e},U_={"[TUIEmoji_Expect]":"emoji_0@2x.png","[TUIEmoji_Blink]":"emoji_1@2x.png","[TUIEmoji_Guffaw]":"emoji_2@2x.png","[TUIEmoji_KindSmile]":"emoji_3@2x.png","[TUIEmoji_Haha]":"emoji_4@2x.png","[TUIEmoji_Cheerful]":"emoji_5@2x.png","[TUIEmoji_Smile]":"emoji_6@2x.png","[TUIEmoji_Sorrow]":"emoji_7@2x.png","[TUIEmoji_Speechless]":"emoji_8@2x.png","[TUIEmoji_Amazed]":"emoji_9@2x.png","[TUIEmoji_Complacent]":"emoji_10@2x.png","[TUIEmoji_Lustful]":"emoji_11@2x.png","[TUIEmoji_Stareyes]":"emoji_12@2x.png","[TUIEmoji_Giggle]":"emoji_13@2x.png","[TUIEmoji_Daemon]":"emoji_14@2x.png","[TUIEmoji_Rage]":"emoji_15@2x.png","[TUIEmoji_Yawn]":"emoji_16@2x.png","[TUIEmoji_TearsLaugh]":"emoji_17@2x.png","[TUIEmoji_Silly]":"emoji_18@2x.png","[TUIEmoji_Wail]":"emoji_19@2x.png","[TUIEmoji_Kiss]":"emoji_20@2x.png","[TUIEmoji_Trapped]":"emoji_21@2x.png","[TUIEmoji_Fear]":"emoji_22@2x.png","[TUIEmoji_BareTeeth]":"emoji_23@2x.png","[TUIEmoji_FlareUp]":"emoji_24@2x.png","[TUIEmoji_Tact]":"emoji_25@2x.png","[TUIEmoji_Shit]":"emoji_26@2x.png","[TUIEmoji_ShutUp]":"emoji_27@2x.png","[TUIEmoji_Sigh]":"emoji_28@2x.png","[TUIEmoji_Hehe]":"emoji_29@2x.png","[TUIEmoji_Silent]":"emoji_30@2x.png","[TUIEmoji_Skull]":"emoji_31@2x.png","[TUIEmoji_Mask]":"emoji_32@2x.png","[TUIEmoji_Beer]":"emoji_33@2x.png","[TUIEmoji_Cake]":"emoji_34@2x.png","[TUIEmoji_RedPacket]":"emoji_35@2x.png","[TUIEmoji_Bombs]":"emoji_36@2x.png","[TUIEmoji_Ai]":"emoji_37@2x.png","[TUIEmoji_Celebrate]":"emoji_38@2x.png","[TUIEmoji_Bless]":"emoji_39@2x.png","[TUIEmoji_Flower]":"emoji_40@2x.png","[TUIEmoji_Watermelon]":"emoji_41@2x.png","[TUIEmoji_Cow]":"emoji_42@2x.png","[TUIEmoji_Fool]":"emoji_43@2x.png","[TUIEmoji_Surprised]":"emoji_44@2x.png","[TUIEmoji_Askance]":"emoji_45@2x.png","[TUIEmoji_Monster]":"emoji_46@2x.png","[TUIEmoji_Pig]":"emoji_47@2x.png","[TUIEmoji_Coffee]":"emoji_48@2x.png","[TUIEmoji_Ok]":"emoji_49@2x.png","[TUIEmoji_Heart]":"emoji_50@2x.png","[TUIEmoji_Sun]":"emoji_51@2x.png","[TUIEmoji_Moon]":"emoji_52@2x.png","[TUIEmoji_Star]":"emoji_53@2x.png","[TUIEmoji_Rich]":"emoji_54@2x.png","[TUIEmoji_Fortune]":"emoji_55@2x.png","[TUIEmoji_857]":"emoji_56@2x.png","[TUIEmoji_666]":"emoji_57@2x.png","[TUIEmoji_Prohibit]":"emoji_58@2x.png","[TUIEmoji_Convinced]":"emoji_59@2x.png","[TUIEmoji_Knife]":"emoji_60@2x.png","[TUIEmoji_Like]":"emoji_61@2x.png"},F_={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},O_={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},x_=["messageList","conversationList","newMessageList"],P_=["translateTextInfo","voiceToTextInfo"],Y_="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),J_="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||Y_,H_="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),q_="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),V_="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),j_="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),K_="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,W_="undefined"!=typeof uni&&"undefined"==typeof window,z_=J_||H_||q_||V_||j_||K_||W_,Z_=("undefined"!=typeof uni||"undefined"!=typeof window)&&!z_,X_=H_?qq:q_?tt:V_?swan:j_?my:J_?wx:W_?uni:K_?jd:Z_?window:{},$_=Z_&&window&&window.navigator&&window.navigator.userAgent||"",AT=/Android/i.test($_),eT=/(?:Windows Phone)/.test($_),tT=/(?:SymbianOS)/.test($_),iT=/iPad/i.test($_)||/iPhone/i.test($_)||/iPod/i.test($_),oT=AT||eT||tT||iT,nT=Z_&&!oT;let rT=class A{constructor(){this.global=X_,this.isOfficial=!1}static getInstance(){return A.instance||(A.instance=new A),A.instance}initOfficial(A){this.isOfficial=A}getPlatform(){let A="";return nT?A="pc":oT?A="h5":J_?A="wechat":W_&&!J_&&(A="app"),A}};let sT=class A{constructor(){this.EVENT=bR.EVENT,this.TYPES=bR.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return A.instance||(A.instance=new A),X_.__$RTC_CHAT__=[e_,i_,n_,s_,g_,l_,u_,d_,C_],A.instance}mount(A,e){this[A]=e}login(A){const{chat:e,SDKAppID:t,userID:i}=A,o=1400187352===t||1400188366===t;return this.createChat(A),this.userID=i,rT.getInstance().initOfficial(o),this.TUIStore.update(m_.APP,"isOfficial",o),this.TUIStore.update(m_.APP,"SDKVersion",bR.VERSION),this.eventCenter=new p_(this),this.eventCenter.removeEvents(),this.resetStore(),this.initService(),e&&e.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(this.eventCenter.addEvent(this.EVENT.SDK_READY,()=>{this.onSDKReady()}),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,()=>{this.onSDKNotReady()}),this.loginChat(A))}logout(){return this.userID="",this.isInited=!1,this.resetStore(),this.chat.logout()}isReady(){var A;return(null===(A=this.chat)||void 0===A?void 0:A.isReady())||!1}setLogLevel(A){this.chat?this.chat.setLogLevel(A):console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.resetStore(),this.chat.destroy()}getMyUserID(){return this.userID}resetStore(){this.TUIStore.reset(m_.CHAT),this.TUIStore.reset(m_.CONV),this.TUIStore.reset(m_.GRP),this.TUIStore.reset(m_.USER),this.TUIStore.reset(m_.SEARCH),this.TUIStore.reset(m_.FRIEND),this.TUIStore.reset(m_.CUSTOM),console.log("TUIChatEngine.resetStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.initOptionalServices(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}initOptionalServices(){const A=bR.VERSION.split(".");3===A[0]&&A[1]>=3&&A[2]>0?(!0===this.chat.callExperimentalAPI("canIUseModule",["group-module"])&&this.TUIGroup.init(),!0===this.chat.callExperimentalAPI("canIUseModule",["relationship-module"])&&this.TUIFriend.init()):(this.TUIGroup.init(),this.TUIFriend.init())}createChat(A){const{chat:e}=A,t=B_(A,["chat"]);N_(e)?(this.chat=bR.create(Object.assign(Object.assign({},t),{scene:"engine-lite"})),this.chat.use([e_,i_,n_,s_,g_,l_,u_,d_,C_])):this.chat=e}loginChat(A){const{userID:e,userSig:t}=A;return new Promise((A,i)=>{this.chat.login({userID:e,userSig:t}).then(e=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),e.data.repeatLogin&&this.chat.isReady()&&A(e),this.loginStatusPromise.set("login",{resolve:A,reject:i,imResponse:e})}).catch(A=>{i(A)})})}onSDKReady(){if(this.loginStatusPromise.has("login")){const A=this.loginStatusPromise.get("login");A.resolve(A.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){this.loginStatusPromise.has("login")&&this.loginStatusPromise.get("login").reject(new Error("sdk not ready")),this.loginStatusPromise.delete("login"),this.resetStore()}checkCommercialAbility(){Object.keys(O_).forEach(A=>{const e=O_[A];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",e).then(e=>{const{enabled:t=!1}=e.data;this.TUIStore.update(m_.APP,A,t)})})}},aT=class{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(A,e){this.store[A]=e}getData(A){return this.store[A]}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}},gT=class{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(A,e){"userStatusList"===A?this.updateUserStatusList(e):this.store[A]=e}getData(A){return this.store[A]}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}updateUserStatusList(A){0!==A.length?A.forEach(A=>{const{userID:e,statusType:t=0,customStatus:i=""}=A;t===y_.UNSUB_USER?this.store.userStatusList.delete(e):this.store.userStatusList.set(e,{statusType:t,customStatus:i})}):this.store.userStatusList.clear()}},cT=class{getEngine(){return sT.getInstance()}};const lT=function(A){if(null==A)return!0;if("boolean"==typeof A)return!1;if("number"==typeof A)return 0===A;if("string"==typeof A)return 0===A.length;if("function"==typeof A)return 0===A.length;if(Array.isArray(A))return 0===A.length;if(A instanceof Error)return""===A.message;if(function(A){if("object"!=typeof A||null===A)return!1;const e=Object.getPrototypeOf(A);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t}(A)){for(const e in A)if(Object.prototype.hasOwnProperty.call(A,e))return!1;return!0}return!1},IT={"[Image]":"[图片]","[Voice]":"[语音]","[Video]":"[视频]","[File]":"[文件]","[Location]":"[位置]","[Animated Sticker]":"[动画表情]","[Custom Messages]":"[自定义消息]","[Group Notification]":"[群提示消息]","[Group System Message]":"[群系统消息]","[Chat Record]":"[聊天记录]","[Chat History]":"[聊天记录]"};let uT=class extends cT{constructor(A){super(),this.initProxy(A),this.isMuted=this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_ACPT_NOT_NOTE||this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_DISCARD,this.operationType=0,this._conversation=A}initProxy(A){Object.keys(A).forEach(e=>{b_(e)||(this[e]=A[e])})}updateProperties(A){Object.keys(A).forEach(e=>{b_(e)||(this[e]=A[e])})}updateOperationType(A){this.operationType=A}getConversation(){return this._conversation}deleteConversation(A=!0){return this.getEngine().TUIConversation.deleteConversation({conversationIDList:[this.conversationID],clearHistoryMessage:A})}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const A=this.getEngine(),e={messageRemindType:!0===this.isMuted?A.TYPES.MSG_REMIND_ACPT_AND_NOTE:A.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===A.TYPES.CONV_C2C){const t=this.conversationID.replace(A.TYPES.CONV_C2C,"");e.userIDList=[t]}else if(this.type===A.TYPES.CONV_GROUP){const t=this.conversationID.replace(A.TYPES.CONV_GROUP,"");e.groupID=t}return A.TUIConversation.muteConversation(e)}setMessageRead(){return this.getEngine().TUIConversation.setMessageRead(this.conversationID)}getAvatar(){var A,e,t,i,o,n;const r=this.getEngine();let s="";switch(this.type){case r.TYPES.CONV_C2C:s=G_(null===(A=this.userProfile)||void 0===A?void 0:A.avatar)?null===(e=this.userProfile)||void 0===e?void 0:e.avatar:"https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_16.png";break;case r.TYPES.CONV_GROUP:s=G_(null===(t=this.groupProfile)||void 0===t?void 0:t.avatar)?null===(i=this.groupProfile)||void 0===i?void 0:i.avatar:"https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.png";break;case r.TYPES.CONV_SYSTEM:s=G_(null===(o=this.groupProfile)||void 0===o?void 0:o.avatar)?null===(n=this.groupProfile)||void 0===n?void 0:n.avatar:"https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png"}return s}getShowName(){var A,e,t,i;const o=this.getEngine();let n="";switch(this.type){case o.TYPES.CONV_C2C:n=this.remark||(null===(A=this.userProfile)||void 0===A?void 0:A.nick)||(null===(e=this.userProfile)||void 0===e?void 0:e.userID)||"";break;case o.TYPES.CONV_GROUP:n=(null===(t=this.groupProfile)||void 0===t?void 0:t.name)||(null===(i=this.groupProfile)||void 0===i?void 0:i.groupID)||"";break;case o.TYPES.CONV_SYSTEM:n=o.TUITranslate.t("系统通知")}return n}getGroupAtInfo(){const A=this.getEngine(),e=A.TUITranslate.t.bind(A.TUITranslate),t=[`[${e("TUIConversation.有人@我")}]`,`[${e("TUIConversation.@所有人")}]`,`[${e("TUIConversation.@所有人")}][${e("TUIConversation.有人@我")}]`];let i="";for(let o=0;o0&&(t=function(A,e){const t=36e5,i=24*t,o=7*i,n=(new Date).getTime()-A;let r="";if(n<0)return r;const s=n/6e4,a=n/t,g=n/i,c=n/o;if(c>=1&&c<=4)r=` ${parseInt(`${c}`,10)} ${e("time.周")}${e("time.前")}`;else if(g>=1&&g<=6)r=` ${parseInt(`${g}`,10)} ${e("time.天")}${e("time.前")}`;else if(a>=1&&a<=23)r=` ${parseInt(`${a}`,10)} ${e("time.小时")}${e("time.前")}`;else if(s>=1&&s<=59)r=` ${parseInt(`${s}`,10)} ${e("time.分钟")}${e("time.前")}`;else if(n>=0&&n<=6e4)r=`${e("time.刚刚")}`;else{const e=new Date;e.setTime(A),r=`${e.getFullYear()}-${e.getMonth()+1<10?`0${e.getMonth()+1}`:e.getMonth()+1}-${e.getDate()<10?`0${e.getDate()}`:e.getDate()}`}return r}(1e3*this.lastMessage.lastTime,e.TUITranslate.t.bind(e.TUITranslate))),t}getLastMessageText(){var A;if(this.draftText)return k_(this.draftText).abstract;const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate);if(4===this.operationType)return t("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return t("TUIConversation.该群聊已被解散");if(8===this.operationType)return t("TUIConversation.您已退出该群聊");const i=this._conversation,{lastMessage:o}=this;let n="",r="";const s=i.unreadCount>0&&i.messageRemindType===e.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${i.unreadCount>99?"99+":i.unreadCount}${t("TUIConversation.条")}]`:"";if(i.type===e.TYPES.CONV_GROUP)if(o.fromAccount===e.getMyUserID())n=t("TUIConversation.我");else{const A=o.fromAccount;n=e.TUIFriend.getFriendRemark([A])[A]||o.nameCard||o.nick||A}if(o.type===e.TYPES.MSG_TEXT)r=this.decodeTextMessage(o.payload.text);else if(o.type===e.TYPES.MSG_CUSTOM){const i=k_(null===(A=null==o?void 0:o.payload)||void 0===A?void 0:A.data);if(1===(null==i?void 0:i.businessID))return r=e.TUIChat.messageHandler.handleCallKitSignaling(o),r;const n=o.messageForShow;r=IT[n]?t(`TUIChat.${IT[n]}`):n}else{const A=o.messageForShow;r=IT[A]?t(`TUIChat.${IT[A]}`):A}return o.isRevoked&&(r=t("TUIChat.撤回了一条消息")),i.type===e.TYPES.CONV_GROUP&&o.type===e.TYPES.MSG_GRP_TIP?r:`${s}${n?`${n}:`:""}${r}`}decodeTextMessage(A){if(lT(A))return A;const e=/(\[.+?\])/g;let t=A;if(e.test(A)){const i=this.getEngine(),o=i.TUITranslate.t.bind(i.TUITranslate);t=A.replace(e,A=>{const e=o(`Emoji.${A}`);return J_||!e||e.startsWith("Emoji.")?F_[A]||A:e})}return t}},ET=class{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(A,e){switch(A){case"conversationList":this.updateConversationList(e);break;case"operationTypeMap":this.updateOperationTypeMap(e);break;default:this.store[A]=e}}getData(A){return this.store[A]}getModel(A){return this.store.conversationList.find(e=>e.conversationID===A)}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}updateConversationList(A){const e=[];A.forEach(A=>{let t=A;A instanceof uT?t.updateProperties(A):t=new uT(A);const i=this.getOperationType(A);t.updateOperationType(i),e.push(t)}),this.store.conversationList=e}updateOperationTypeMap(A){const{conversationID:e,operationType:t=0}=A;this.store.operationTypeMap.set(e,t)}getOperationType(A){const{conversationID:e}=A;return this.store.operationTypeMap.get(e)||0}},dT=class extends cT{constructor(A){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:A=>this.getEngine().TUIChat.messageHandler.handleTextMessage(A),[this.getEngine().TYPES.MSG_FACE]:A=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(A),[this.getEngine().TYPES.MSG_LOCATION]:A=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(A),[this.getEngine().TYPES.MSG_IMAGE]:A=>this.getEngine().TUIChat.messageHandler.handleImageMessage(A),[this.getEngine().TYPES.MSG_AUDIO]:A=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(A),[this.getEngine().TYPES.MSG_VIDEO]:A=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(A),[this.getEngine().TYPES.MSG_FILE]:A=>this.getEngine().TUIChat.messageHandler.handleFileMessage(A),[this.getEngine().TYPES.MSG_CUSTOM]:A=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(A),[this.getEngine().TYPES.MSG_MERGER]:A=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(A),[this.getEngine().TYPES.MSG_GRP_TIP]:A=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(A)},this._message=A,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(A)}initProperties(A){Object.keys(A).forEach(e=>{b_(e)||(this[e]=A[e])})}updateProperties(A){this._message=A,Object.keys(A).forEach(e=>{b_(e)||(this[e]=A[e])})}getMessage(){return this._message}modifyMessage(A){return A.type&&this._message.type!==A.type&&!A.payload?Promise.reject({code:S_.MISMATCH_TYPE_AND_PAYLOAD,message:R_.MISMATCH_TYPE_AND_PAYLOAD}):(this._message.type=A.type||this._message.type,this._message.payload=A.payload||this._message.payload,this._message.cloudCustomData=A.cloudCustomData||this._message.cloudCustomData,this.getEngine().TUIChat.modifyMessage(this._message))}revokeMessage(){return this.getEngine().TUIChat.revokeMessage(this._message)}resendMessage(){return this.getEngine().TUIChat.resendMessage(this._message)}deleteMessage(){return this.getEngine().TUIChat.deleteMessage([this._message])}quoteMessage(){return this.getEngine().TUIChat.quoteMessage(this._message)}replyMessage(){return this.getEngine().TUIChat.replyMessage(this._message)}setMessageExtensions(A){return this.getEngine().TUIChat.setMessageExtensions(this._message,A)}getMessageExtensions(){return this.getEngine().TUIChat.getMessageExtensions(this._message)}deleteMessageExtensions(A){return this.getEngine().TUIChat.deleteMessageExtensions(this._message,A)}getSignalingInfo(){return this.type!==this.getEngine().TYPES.MSG_CUSTOM?null:N_(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const A=this.messageHandlers[this.type];if(N_(A))return{};if(this.type===this.getEngine().TYPES.MSG_GRP_TIP)return A(this._message);const e=this.getEngine().TUIFriend.getFriendRemark([this.from]);return Object.assign(Object.assign({},A(this._message)),{showName:e[this.from]||this.nameCard||this.nick||this.from})}sendForwardMessage(A){return this.getEngine().TUIChat.sendForwardMessage(A,[this._message])}},hT=class{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(A,e){switch(A){case"messageList":this.updateMessageList(e);break;case"translateTextInfo":this.updateTranslateTextInfo(e);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(e);break;default:this.store[A]=e}}getData(A){return this.store[A]}getModel(A){return this.store.messageList.find(e=>e.ID===A)}reset(A=[]){const e=A.filter(A=>!P_.includes(A));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==e?void 0:e.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}updateMessageList(A){const e=[];A.forEach(A=>{let t=A;A instanceof dT||(t=this.getModel(A.ID),t?t.updateProperties(A):t=new dT(A)),e.push(t)}),this.store.messageList=e}updateTranslateTextInfo(A){this.updateBykey("translateTextInfo",A)}updateVoiceToTextInfo(A){this.updateBykey("voiceToTextInfo",A)}updateBykey(A,e){const{conversationID:t,messageID:i,visible:o=!1}=e;this.store[A]||(this.store[A]=new Map),this.store[A].has(t)||this.store[A].set(t,[]);const n=this.store[A].get(t)||[];let r=!0;for(let s=0;s{b_(e)||(this[e]=A[e])})}},BT=class{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0}}update(A,e){switch(A){case"groupList":this.updateGroupList(e);break;case"currentGroup":this.store.currentGroup=e instanceof CT?e:new CT(e);break;default:this.store[A]=e}}getData(A){if("groupSystemNoticeList"===A){const A=[...this.store.groupSystemNoticeList];return this.store.groupSystemNoticeList.length=0,A}return this.store[A]}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}updateGroupList(A){this.store.groupList=A.map(A=>A instanceof CT?A:new CT(A))}},QT=class{constructor(){this.store={}}update(A,e){this.store[A]=e}getData(A){return this.store[A]}reset(A=[]){0===A.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:void 0}),{}))}},pT=class{constructor(){this.defaultStore={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0,friendGroupList:[]},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0,friendGroupList:[]}}update(A,e){this.store[A]=e}getData(A){return this.store[A]}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}},fT=class{constructor(){this.defaultStore={searchMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchChatMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchUserResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchGroupResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchMessageParams:{},searchChatMessageParams:{},searchUserParams:{},searchGroupParams:{},error:null},this.store=this.defaultStore}update(A,e){this.store[A]=e}getData(A){return this.store[A]}reset(A=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==A?void 0:A.reduce((A,e)=>Object.assign(Object.assign({},A),{[e]:this.defaultStore[e]}),{}))}},mT=class A extends cT{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return A.instance||(A.instance=new A),A.instance}init(){const A=this.getEngine();A.eventCenter.addEvent(A.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated.bind(this)),A.eventCenter.addEvent(A.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalUnreadCountUpdated.bind(this)),A.eventCenter.addEvent(A.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getConversationInitData()}onConversationListUpdated(A){const e=this.filterSystemConversation(A);this.getEngine().TUIStore.update(m_.CONV,"conversationList",e),this.updateCurrentConversation()}onTotalUnreadCountUpdated(A){this.getEngine().TUIStore.update(m_.CONV,"totalUnreadCount",A)}onMessageReceived(A){const e=this.getEngine(),t=this.getEngine().TUIStore.getData(m_.CONV,"conversationList");let i=!1;for(let o=0;o0){this.getEngine().TUIStore.update(m_.CONV,"operationTypeMap",{conversationID:r,operationType:0}),i=!0;break}}}if(i){this.getEngine().TUIStore.update(m_.CONV,"conversationList",t);const A=this.getEngine().TUIStore.getData(m_.CONV,"currentConversationID")||"",e=this.findConversation(A);e&&this.getEngine().TUIStore.update(m_.CONV,"currentConversation",e)}}getConversationInitData(){const A=this.getEngine();A.chat.isReady()&&A.chat.getConversationList().then(e=>{const{conversationList:t,isSyncCompleted:i}=e.data;if(console.log(`${this.serv}.init, getConversationList count:${t.length} isSyncCompleted:${i}`),t.length>0){this.onConversationListUpdated(t);const e=A.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(e)}})}switchConversation(A){return Q_(this,void 0,void 0,function*(){const e=`${this.serv}.switchConversation`,t=this.getEngine();if(!A)return t.TUIStore.reset(m_.CHAT,["messageList","isCompleted","nextReqMessageID"]),t.TUIStore.update(m_.CONV,"currentConversationID",""),t.TUIStore.update(m_.CONV,"currentConversation",null),console.log(`${e} conversationID is empty, conversationID:${A}`),Promise.resolve({});if(!A.startsWith(t.TYPES.CONV_C2C)&&!A.startsWith(t.TYPES.CONV_GROUP))return console.warn(`${e} conversationID is invalid, conversationID:${A}`),Promise.reject({code:S_.INVALID_CONV_ID,message:R_.INVALID_CONV_ID});const i=t.TUIStore.getData(m_.APP,"enableAutoMessageRead"),o=t.TUIStore.getData(m_.CONV,"currentConversationID");if(o&&o===A)return i&&this.setMessageRead(o),console.warn(`${e} please check conversationID, conversationID:${A}`),Promise.resolve({code:S_.CONV_ID_SAME,message:R_.CONV_ID_SAME});const n=yield this.getConversationModel(A);return N_(n)?(console.warn(`${e} target conversation is not exist, conversationID:${A}`),Promise.reject({code:S_.CONV_NOT_EXIST,message:R_.CONV_NOT_EXIST})):(i&&(o&&this.setMessageRead(o),A&&this.setMessageRead(A)),t.TUIStore.reset(m_.CHAT,["messageList","isCompleted","nextReqMessageID"]),t.TUIStore.update(m_.CONV,"currentConversationID",A),t.TUIStore.update(m_.CONV,"currentConversation",n),Promise.resolve(n))})}getConversationModel(A){return Q_(this,void 0,void 0,function*(){let e=this.findConversation(A);if(N_(e))try{const t=yield this.getConversationProfile(A);t.data&&t.data.conversation&&(e=new uT(t.data.conversation))}catch(t){e=void 0}return e})}findConversation(A){let e;const t=this.getEngine().TUIStore.getData(m_.CONV,"conversationList");for(let i=0;i{const t=this.getEngine().TUIStore.getData(m_.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${t}`),e===t&&(this.getEngine().TUIStore.update(m_.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(m_.CONV,"currentConversation",null)),A})}pinConversation(A){return this.getEngine().chat.pinConversation(A)}muteConversation(A){return this.getEngine().chat.setMessageRemindType(A)}clearHistoryMessage(A){return this.getEngine().chat.clearHistoryMessage(A).then(A=>(this.getEngine().TUIStore.update(m_.CHAT,"messageList",[]),this.getEngine().TUIStore.update(m_.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(m_.CHAT,"isCompleted",!0),A))}setMessageRead(A){return this.getEngine().chat.setMessageRead({conversationID:A})}setConversationDraft(A){const{conversationID:e,draftInfo:t,draftText:i=""}=A;return this.getEngine().chat.setConversationDraft({conversationID:e,draftText:i||(t?JSON.stringify(t):"")}).then(A=>{const{conversation:e}=A.data;this.updateConversation(e)})}updateConversation(A){let e=!1;const t=this.getEngine().TUIStore.getData(m_.CONV,"conversationList");for(let i=0;iA.type!==this.getEngine().TYPES.CONV_SYSTEM)}markConversation(A){return this.getEngine().chat.markConversation(A)}},yT=class{constructor(A){this.TUIUserService=A}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.USER,"userProfile");A.forEach(A=>{A.userID===t.userID&&e.TUIStore.update(m_.USER,"userProfile",A)})}onBlacklistUpdated(A){const e=this.getEngine();this.getBlacklistProfile(A).then(A=>{e.TUIStore.update(m_.USER,"userBlacklist",A)})}getUserProfileInitData(){const A=this.getEngine();A.chat.isReady()&&A.chat.getBlacklist().then(A=>{const e=A.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${e.length}`),e.length>0&&this.onBlacklistUpdated(e)})}getBlacklistProfile(A){const e=[];let t=0;for(;t{i.push(this.TUIUserService.getUserProfile({userIDList:A}))});const o=[];return Promise.all(i).then(A=>(A.forEach(A=>{const e=A.data.map(A=>{const{userID:e,nick:t,avatar:i}=A;return{userID:e,nick:t,avatar:i}});o.push(...e)}),o))}getUserProfile(A){const e=this.getEngine();return N_(A)?e.chat.getMyProfile().then(A=>(e.TUIStore.update(m_.USER,"userProfile",A.data),A)).catch(A=>Promise.reject(A)):e.chat.getUserProfile(A)}updateMyProfile(A){return this.getEngine().chat.updateMyProfile(A)}addToBlacklist(A){return this.getEngine().chat.addToBlacklist(A)}removeFromBlacklist(A){return this.getEngine().chat.removeFromBlacklist(A)}};function DT(A,e,t=!0){var i,o;i=t?wT(A):A,o=e,z_?X_.setStorageSync(i,o):ST()&&localStorage.setItem(i,JSON.stringify(o))}function vT(A,e=!0){try{return function(A){if(z_)return X_.getStorageSync(A);if(ST()){const e=localStorage.getItem(A);if("undefined"!==e)return JSON.parse(e)}}(e?wT(A):A)}catch(t){return void console.warn("Storage.getStorageItem error:",t)}}function wT(A){return`chat_engine_${A}`}function ST(){return navigator&&navigator.cookieEnabled&&localStorage}let MT=class{constructor(A){this.TUIUserService=A}getEngine(){return this.TUIUserService.getEngine()}init(){const A=this.getEngine(),e=vT("displayOnlineStatus")||!1;A.TUIStore.update(m_.USER,"displayOnlineStatus",e),A.eventCenter.addEvent(A.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated.bind(this)),this.onConversationListUpdated()}onConversationListUpdated(){const A=this.getEngine();A.TUIStore.watch(m_.CONV,{conversationList:()=>{const e=A.TUIStore.getData(m_.APP,"enabledOnlineStatus"),t=A.TUIStore.getData(m_.USER,"displayOnlineStatus");e&&t&&this.startToSubscribe()}})}onUserStatusUpdated(A){this.getEngine().TUIStore.update(m_.USER,"userStatusList",A)}switchUserStatus(A){const e=this.getEngine(),{displayOnlineStatus:t=!1}=A;e.TUIStore.update(m_.USER,"displayOnlineStatus",t),DT("displayOnlineStatus",t);const i=e.TUIStore.getData(m_.APP,"enabledOnlineStatus");i?!0===t?this.startToSubscribe():this.unsubscribeUserStatus().catch(A=>{console.warn("UserStatusHandler.switchUserStatus error:",A)}):console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${i} displayOnlineStatus:${t}`)}getUserStatus(A){const e=this.getEngine();return e.chat.getUserStatus(A).then(A=>{const{successUserList:t}=A.data;return t.length>0&&e.TUIStore.update(m_.USER,"userStatusList",t),A}).catch(A=>Promise.reject(A))}subscribeUserStatus(A){var e;const t=(null===(e=null==A?void 0:A.userIDList)||void 0===e?void 0:e.length)||0;return 0===t?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${t}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(A)}unsubscribeUserStatus(A){const e=this.getEngine(),{userIDList:t=[]}=A||{};return e.chat.unsubscribeUserStatus({userIDList:t}).then(A=>{const{failureUserList:i}=A.data,o=[];return t.forEach(A=>{i.includes(A)||o.push({userID:A,statusType:y_.UNSUB_USER})}),e.TUIStore.update(m_.USER,"userStatusList",o),A}).catch(A=>Promise.reject(A))}startToSubscribe(){const A=this.getEngine(),e=A.TUIStore.getData(m_.CONV,"conversationList"),t=A.TUIStore.getData(m_.USER,"userStatusList"),i=[];e.forEach(e=>{if(e.type===A.TYPES.CONV_C2C){const o=e.conversationID.replace(A.TYPES.CONV_C2C,"");t.has(o)||i.push(o)}}),0!==i.length&&A.chat.isReady()&&(this.subscribeUserStatus({userIDList:i}).catch(A=>{console.warn("UserStatusHandler.startToSubscribe,",A)}),this.getUserStatus({userIDList:i}).catch(A=>{console.warn("UserStatusHandler.startToSubscribe,",A)}))}},RT=class{constructor(A){this.TUIChatService=A,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(A){return this.getEngine().TUITranslate.t(A)}handleTextMessage(A){return{text:this.decodeText(A.payload)}}handleFaceMessage(A){const e={name:"",url:"",type:""};return A.payload.data.indexOf("@custom")>-1?(e.name=A.payload.data,e.type="custom",e):(e.name=A.payload.data.indexOf("@2x")<0?`${A.payload.data}@2x`:A.payload.data,e.url=`https://web.sdk.qcloud.com/im/assets/face-elem/${e.name}.png`,e)}handleLocationMessage(A){const e={lon:"",lat:"",href:"",url:"",description:""};return e.lon=A.payload.longitude.toFixed(6),e.lat=A.payload.latitude.toFixed(6),e.href=`https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=${e.lon}&pointy=${e.lat}&name=${A.payload.description}`,e.url=`https://apis.map.qq.com/ws/staticmap/v2/?center=${e.lat},${e.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${e.lat},${e.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`,e.description=A.payload.description,e}handleImageMessage(A){return{url:A.payload.imageInfoArray[0].url,width:A.payload.imageInfoArray[0].width,height:A.payload.imageInfoArray[0].height}}handleAudioMessage(A){return{url:A.payload.url,second:A.payload.second}}handleVideoMessage(A){return{url:A.payload.videoUrl,snapshotUrl:A.payload.snapshotUrl,snapshotWidth:A.payload.snapshotWidth,snapshotHeight:A.payload.snapshotHeight}}handleFileMessage(A){return{url:A.payload.fileUrl,name:A.payload.fileName,size:L_(A.payload.fileSize)}}handleCustomMessage(A){var e;const t=this.handleCreateGroupCustomMessage(A);return{custom:this.handleCallKitSignaling(A)||t||(null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.extension)||`${this.t("TUIChat.[自定义消息]")}`,businessID:t?"group_create":""}}handleMergeMessage(A){return Object.assign({},A.payload)}handleGroupTipsMessage(A){var e,t,i,o,n,r;const s=this.getEngine(),a={text:""};let g=(null==A?void 0:A.nick)||(null===(t=null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.userIDList)||void 0===t?void 0:t.join(","));switch((null===(o=null===(i=null==A?void 0:A.payload)||void 0===i?void 0:i.memberList)||void 0===o?void 0:o.length)>0&&(g="",null===(r=null===(n=null==A?void 0:A.payload)||void 0===n?void 0:n.memberList)||void 0===r||r.map(A=>{const e=(null==A?void 0:A.nick)||(null==A?void 0:A.userID);return g+=`${this.substringByLength(e)},`,A}),g=null==g?void 0:g.slice(0,-1)),A.payload.operationType){case s.TYPES.GRP_TIP_MBR_JOIN:a.text=`${g} ${this.t("message.tip.加入群组")}`;break;case s.TYPES.GRP_TIP_MBR_QUIT:a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.退出群组")}`;break;case s.TYPES.GRP_TIP_MBR_KICKED_OUT:a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case s.TYPES.GRP_TIP_MBR_SET_ADMIN:a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.成为管理员")}`;break;case s.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被撤销管理员")}`;break;case s.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:a.text=this.handleGroupProfileUpdated(A);break;case s.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const e of A.payload.memberList)e.muteTime>0?a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被禁言")}`:a.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被取消禁言")}`;break;default:a.text=`[${this.t("message.tip.群提示消息")}]`}return a}handleGroupSystemMessage(A){const e=A.payload.groupProfile.name||A.payload.groupProfile.groupID,t={text:""};switch(A.payload.operationType){case 1:t.text=`${A.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${e}`;break;case 2:t.text=`${this.t("message.tip.成功加入群组")}:${e}`;break;case 3:t.text=`${this.t("message.tip.申请加入群组")}:${e} ${this.t("message.tip.被拒绝")}`;break;case 4:t.text=`${this.t("message.tip.你被管理员")}${A.payload.operatorID} ${this.t("message.tip.踢出群组")}:${e}`;break;case 5:t.text=`${this.t("message.tip.群")}:${e} ${this.t("message.tip.被")} ${A.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:t.text=`${A.payload.operatorID} ${this.t("message.tip.创建群")}:${e}`;break;case 7:case 12:t.text=`${A.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${e}`;break;case 8:t.text=`${this.t("message.tip.你退出群组")}:${e}`;break;case 9:t.text=`${this.t("message.tip.你被")}${A.payload.operatorID} ${this.t("message.tip.设置为群")}:${e} ${this.t("message.tip.的管理员")}`;break;case 10:t.text=`${this.t("message.tip.你被")}${A.payload.operatorID} ${this.t("message.tip.撤销群")}:${e} ${this.t("message.tip.的管理员身份")}`;break;case 13:t.text=`${A.payload.operatorID} ${this.t("message.tip.同意加群")}:${e}`;break;case 14:t.text=`${A.payload.operatorID} ${this.t("message.tip.拒接加群")}:${e}`;break;case 255:t.text=`${this.t("message.tip.自定义群系统通知")}: ${A.payload.userDefinedField}`;break;default:t.text="未解析的群系统通知"}return t}handleCallKitSignaling(A){var e,t,i,o,n,r,s,a,g,c;const l=k_(A.payload.data);if(1!==(null==l?void 0:l.businessID))return"";const I=k_(null==l?void 0:l.data),u=A.fromAccount||A.from,E=this.getEngine().TUIFriend.getFriendRemark([u]),d=this.getEngine().getMyUserID();let h=E[u]||A.nameCard||A.nick||u;switch(h=this.substringByLength(h),null==l?void 0:l.actionType){case 1:return"audioCall"!==(null===(e=null==I?void 0:I.data)||void 0===e?void 0:e.cmd)&&"videoCall"!==(null===(t=null==I?void 0:I.data)||void 0===t?void 0:t.cmd)||!(null==l?void 0:l.groupID)?"hangup"===(null===(i=null==I?void 0:I.data)||void 0===i?void 0:i.cmd)?(null==l?void 0:l.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(A){const e=A;let t,i,o,n="";return e>=3600?(t=parseInt(""+e/3600,10)<10?`0${parseInt(""+e/3600,10)}`:parseInt(""+e/3600,10),i=parseInt(""+e%60/60,10)<10?`0${parseInt(""+e%60/60,10)}`:parseInt(""+e%60/60,10),o=e%3600<10?"0"+e%3600:e%3600,o>60&&(i=parseInt(""+o/60,10)<10?`0${parseInt(""+o/60,10)}`:parseInt(""+o/60,10),o=o%60<10?"0"+o%60:o%60),n=`${t}:${i}:${o}`):e>=60&&e<3600?(i=parseInt(""+e/60,10)<10?`0${parseInt(""+e/60,10)}`:parseInt(""+e/60,10),o=e%60<10?"0"+e%60:e%60,n=`00:${i}:${o}`):e<60&&(o=e<10?`0${e}`:e,n=`00:00:${o}`),n}(null==I?void 0:I.call_end)}`:"switchToAudio"===(null===(o=null==I?void 0:I.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(n=null==I?void 0:I.data)||void 0===n?void 0:n.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${h} ${this.t("message.custom.发起通话")}`;case 2:return(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(null==l?void 0:l.inviter)===d?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return"switchToAudio"===(null===(r=null==I?void 0:I.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(s=null==I?void 0:I.data)||void 0===s?void 0:s.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):"line_busy"===(null==I?void 0:I.line_busy)||"lineBusy"===(null==I?void 0:I.data.message)?(null==l?void 0:l.inviter)===d?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(null==l?void 0:l.inviter)===d?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if("switchToAudio"===(null===(a=null==I?void 0:I.data)||void 0===a?void 0:a.cmd))return`${this.t("message.custom.切换语音通话")}`;if("switchToVideo"===(null===(g=null==I?void 0:I.data)||void 0===g?void 0:g.cmd))return`${this.t("message.custom.切换视频通话")}`;if(null==l?void 0:l.groupID){if(u===(null==l?void 0:l.inviter)){this.handleCallkitTimeoutSignaling(l.inviteeList);let A="";return null===(c=l.inviteeList)||void 0===c||c.forEach(e=>{const t=this.userShowNameMap.get(e)||e;A+=`${this.substringByLength(t)}、`}),A=A.substring(0,A.lastIndexOf("、")),`${A} ${this.t("message.custom.无应答")}`}return`${h} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(null==l?void 0:l.inviter)===d?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleCreateGroupCustomMessage(A){let e;const t=k_(A.payload.data);return"group_create"===(null==t?void 0:t.businessID)&&(e=`${t.opUser} ${t.content}`),e}decodeText(A){const e=[];let t=A.text,i=-1,o=-1;for(;""!==t;)switch(i=t.indexOf("["),o=t.indexOf("]"),i){case 0:if(-1===o)e.push({name:"text",text:t}),t="";else{const A=t.slice(0,o+1);A.indexOf("@custom")>-1?(e.push({name:"img",src:"",type:"custom",emojiKey:A}),t=t.substring(o+1)):U_[A]?(e.push({name:"img",src:"https://web.sdk.qcloud.com/im/assets/emoji-plugin/"+U_[A],emojiKey:A}),t=t.substring(o+1)):(e.push({name:"text",text:"["}),t=t.slice(1))}break;case-1:e.push({name:"text",text:t}),t="";break;default:e.push({name:"text",text:t.slice(0,i)}),t=t.substring(i)}return e}handleGroupProfileUpdated(A){const{nick:e,payload:t}=A,{newGroupProfile:i,memberList:o,operatorID:n}=t;let r="";const s=e||n,a=Object.keys(i)[0];switch(a){case"muteAllMembers":r=i[a]?`${this.t("message.tip.管理员")} ${s} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${s} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":r=`${o[0].nick||o[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":r=`${s} ${this.t("message.tip.修改群名为")} ${i[a]}`;break;case"notification":r=this.isOldUIKit("message.tip.把群公告修改为")?`${s} ${this.t("message.tip.发布新公告")}`:`${s} ${this.t("message.tip.把群公告修改为")} "${i[a]}"`}return r}handleCallkitTimeoutSignaling(A=[]){if(0===A.length)return;const e=this.getEngine().TUIFriend.getFriendRemark(A),t=[];A.forEach(A=>{const i=e[A];i?this.userShowNameMap.set(A,i):this.requestedUserMap.has(A)||(t.push(A),this.requestedUserMap.set(A,1))}),t.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:t}).then(A=>{(A.data||[]).forEach(A=>{const{userID:e,nick:t}=A,i=t||e;this.userShowNameMap.set(e,i)})}).catch(()=>{})}substringByLength(A,e=12){return A.length>e?`${A.slice(0,e)}...`:A}isOldUIKit(A){var e;const t=A.lastIndexOf("."),i=A.slice(0,t+1);return null===(e=this.t(A))||void 0===e?void 0:e.startsWith(i)}},_T=class{constructor(A){this.TUIChatService=A,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(m_.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(m_.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.CHAT,"typingStatus");if(A.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===A.flow){const i=k_(A.payload.data);if(i.businessID===D_.BUSINESS_ID){const{typingStatus:A,userAction:o}=i;if(A===D_.STATUS_START||o===D_.ACTION_START_ID)return t?(this.timer&&clearTimeout(this.timer),this.timer=null):e.TUIStore.update(m_.CHAT,"typingStatus",!0),this.timer=setTimeout(()=>{this.clearTypingStatus()},3e4),e.TUIStore.getData(m_.CHAT,"typingStatus");A!==D_.STATUS_END&&o!==D_.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(A=[]){return 0===A.length?[]:(this.getEngine().TUIStore.getData(m_.APP,"enableTyping")&&this.handleLastMessage(A[A.length-1]),A.filter(A=>A.type!==this.getEngine().TYPES.MSG_CUSTOM||k_(A.payload.data).businessID!==D_.BUSINESS_ID))}createTypingMessage(A=D_.STATUS_END,e=""){const{BUSINESS_ID:t,STATUS_START:i,VERSION:o,ACTION_START_ID:n,ACTION_END_ID:r,ACTION_START:s,ACTION_END:a,NEED_TYPING:g}=D_;return{to:e,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:t,typingStatus:A,version:o,userAction:A===i?n:r,actionParam:A===i?s:a}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:g,version:o}})}}sendTyping(A=!1,e=""){if(A){this.typingTo=e;const A=this.createTypingMessage(D_.STATUS_START,e);this.getEngine().TUIChat.sendCustomMessage(A,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const A=this.createTypingMessage(D_.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(A,{onlineUserOnly:!0})}this.typingTo=""}},TT=class{constructor(A){this.TUIChatService=A}getEngine(){return this.TUIChatService.getEngine()}init(){const A=this.getEngine();A.eventCenter.addEvent(A.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived.bind(this))}onMessageReadReceiptReceived(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.CONV,"currentConversationID"),i=[];A.forEach(A=>{const{messageID:o}=A,n=e.chat.findMessage(o);n&&t===n.conversationID&&i.push(n)}),i.length>0&&e.TUIChat.updateMessageList(i,"edit")}sendMessageReadReceipt(A){const e=[];return A.forEach(A=>{const t=A.getMessage();e.push(t)}),this.getEngine().chat.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(A){const e=A.message.getMessage(),t=Object.assign(Object.assign({},A),{message:e});return this.getEngine().chat.getGroupMessageReadMemberList(t)}getMessageReadReceiptList(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.APP,"enabledMessageReadReceipt"),i=e.TUIStore.getData(m_.USER,"displayMessageReadReceipt");!t||!i||0===A.length||A[0].conversationType!==e.TYPES.CONV_GROUP||e.chat.getMessageReadReceiptList(A).then(A=>{const{messageList:e}=A.data;this.TUIChatService.updateMessageList(e,"edit")}).catch(A=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${A.message}`)})}};var NT,bT,GT;!function(A){A.MESSAGE="message",A.CHAT_MESSAGE="chat_message",A.USER="user",A.GROUP="group"}(NT||(NT={})),function(A){A.MSG_TEXT="TIMTextElem",A.MSG_IMAGE="TIMImageElem",A.MSG_SOUND="TIMSoundElem",A.MSG_FILE="TIMFileElem",A.MSG_VIDEO="TIMVideoFileElem",A.MSG_LOCATION="TIMLocationElem",A.MSG_CUSTOM="TIMCustomElem",A.MSG_MERGER="TIMRelayElem"}(bT||(bT={})),function(A){A.GRP_WORK="Private",A.GRP_PUBLIC="Public",A.GRP_MEETING="ChatRoom",A.GRP_COMMUNITY="Community"}(GT||(GT={}));let kT=class{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(A){return"function"!=typeof A&&console.error("middleware must be a function"),this.cache.push(A),this}next(){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}run(A){return this.middlewares=this.cache.map(A=>A),this.options=A,this.next()}};function LT(A,e,t){const i=Object.create(null);Object.keys(t).forEach(t=>{if(!e[t])return;i[t]=e[t];const o=new kT;e[t]=function(){const n=Array.from(arguments);return o.use((e,i)=>A.isInited?i():Promise.reject({code:S_.NOT_INIT,message:`${t} | ${R_.NOT_INIT}`})).use(A=>i[t].apply(e,A)),o.run(n)}})}console.log("TUIChatEngine-Lite.VERSION:1.0.3");const UT=sT.getInstance();rT.getInstance();const FT=class A{constructor(){this.storeMap={[m_.APP]:new aT,[m_.USER]:new gT,[m_.CONV]:new ET,[m_.CHAT]:new hT,[m_.GRP]:new BT,[m_.FRIEND]:new pT,[m_.SEARCH]:new fT},this.task={}}static getInstance(){return A.instance||(A.instance=new A),A.instance}watch(A,e){this.task[A]||(this.task[A]={});const t=this.task[A];Object.keys(e).forEach(i=>{const o=e[i];t[i]||(t[i]=new Map),t[i].set(o,1),this.notifyOnWatch(A,i,o)})}unwatch(A,e){if(!this.task[A])return;const t=this.task[A];Object.keys(e).forEach(A=>{var i;null===(i=t[A])||void 0===i||i.delete(e[A])})}update(A,e,t){var i;A!==m_.CUSTOM||this.storeMap[A]||(this.storeMap[A]=new QT),null===(i=this.storeMap[A])||void 0===i||i.update(e,t),this.notify(A,e)}getData(A,e){var t;return A!==m_.CUSTOM||this.storeMap[A]||(this.storeMap[A]=new QT),null===(t=this.storeMap[A])||void 0===t?void 0:t.getData(e)}getConversationModel(A){var e;return null===(e=this.storeMap[m_.CONV])||void 0===e?void 0:e.getModel(A)}getMessageModel(A){var e;return null===(e=this.storeMap[m_.CHAT])||void 0===e?void 0:e.getModel(A)}reset(A,e=[],t=!1){if(A in this.storeMap){const i=this.storeMap[A];0===e.length&&(e=Object.keys(null==i?void 0:i.store)),i.reset(e),t&&e.forEach(e=>{this.notify(A,e)})}}notifyOnWatch(A,e,t){const i=this.getData(A,e);x_.indexOf(e)>-1&&0===i.length||t&&t.call(this,i)}notify(A,e){if(!this.task[A])return;const t=this.task[A];if(t[e]){const i=t[e],o=this.getData(A,e);for(const[A]of i.entries())A.call(this,o)}}}.getInstance(),OT=class A extends cT{constructor(){super(),this.languages=null,this.keyMap={}}static getInstance(){return A.instance||(A.instance=new A),A.instance}setI18next(A){this.i18next?console.warn("TUITranslateService.setI18next already have i18next instance."):this.i18next=A}provideLanguages(A){var e;J_||(this.languages=A,(null===(e=A["zh-CN"])||void 0===e?void 0:e.Chat)&&this.setKeyMap(A["zh-CN"]),console.log("TUITranslateService.provideLanguages ok."))}useI18n(A){var e;if(J_)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const t={};for(const[o,n]of Object.entries(this.languages))t["zh_cn"===o?"zh":o]={translation:n};this.i18next.init({compatibilityJSON:"v3",lng:A||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:t});const i=this.normalizeLanguageKey(A||"zh");null===(e=this.getEngine().TUIReport)||void 0===e||e.reportFeature(201,i)}changeLanguage(A){const e=this.normalizeLanguageKey(A);return this.getEngine().TUIReport.reportFeature(201,e),this.i18next.changeLanguage(A)}normalizeLanguageKey(A){return A.includes("en")?"en-us":A.includes("tw")?"zh-tw":A.includes("zh")||A.includes("cn")?"zh-cn":A.includes("ko")||A.includes("kr")?"ko-kr":A.includes("ja")||A.includes("jp")?"ja-jp":`other-${A}`}t(A){if(!this.languages){let e=A;return!N_(A)&&A.indexOf(".")>-1&&(e=A.split(".").pop()||""),e}const e=this.keyMap[A];return e?this.i18next.t(e):this.i18next.t(A)}setKeyMap(A,e){for(const t in A)if(Object.prototype.hasOwnProperty.call(A,t)){const i=e?`${e}.${t}`:t;if(A[t]&&"object"==typeof A[t]&&!Array.isArray(A[t])&&null!==A[t])this.setKeyMap(A[t],i);else{let i=e?`${e}.${A[t]}`:A[t];i=this.replaceKey(i),this.keyMap[i]=`${e}.${t}`}}}replaceKey(A){return A.startsWith("Chat")?A.replace("Chat","TUIChat"):A.startsWith("Conversation")?A.replace("Conversation","TUIConversation"):A.startsWith("Message")?A.replace("Message","message.tip"):A.startsWith("Call")?A.replace("Call","message.custom"):A}}.getInstance(),xT=mT.getInstance(),PT=class A extends cT{constructor(){super(),this.userProfileHandler=new yT(this),this.userStatusHandler=new MT(this)}static getInstance(){return A.instance||(A.instance=new A),A.instance}init(){const A=this.getEngine();A.eventCenter.addEvent(A.EVENT.KICKED_OUT,this.onKickedOut.bind(this)),A.eventCenter.addEvent(A.EVENT.NET_STATE_CHANGE,this.onNetStateChange.bind(this)),this.userProfileHandler.init(),this.userStatusHandler.init(),this.initMessageReadReceipt()}onKickedOut(A){this.getEngine().TUIStore.update(m_.USER,"kickedOut",A.type)}onNetStateChange(A){this.getEngine().TUIStore.update(m_.USER,"netStateChange",A.state)}initMessageReadReceipt(){const A=vT("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(m_.USER,"displayMessageReadReceipt",A)}switchUserStatus(A){return this.userStatusHandler.switchUserStatus(A)}switchMessageReadStatus(A){this.getEngine().TUIStore.update(m_.USER,"displayMessageReadReceipt",A),DT("displayMessageReadReceipt",A)}getUserProfile(A){return this.userProfileHandler.getUserProfile(A)}updateMyProfile(A){return this.userProfileHandler.updateMyProfile(A)}addToBlacklist(A){return this.userProfileHandler.addToBlacklist(A)}removeFromBlacklist(A){return this.userProfileHandler.removeFromBlacklist(A)}getUserStatus(A){return this.userStatusHandler.getUserStatus(A)}subscribeUserStatus(A){return this.userStatusHandler.subscribeUserStatus(A)}unsubscribeUserStatus(A){return this.userStatusHandler.unsubscribeUserStatus(A)}}.getInstance(),YT=class A extends cT{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new RT(this),this.typingHandler=new _T(this),this.readReceiptHandler=new TT(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return A.instance||(A.instance=new A),A.instance}init(){const A=this.getEngine();A.eventCenter.addEvent(A.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),A.eventCenter.addEvent(A.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),A.eventCenter.addEvent(A.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),A.eventCenter.addEvent(A.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),A.eventCenter.addEvent(A.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(A){this.updateMessageList(A,"received"),this.getEngine().TUIStore.update(m_.CHAT,"newMessageList",A)}onMessageModified(A){this.updateMessageList(A,"edit")}onMessageRevoked(A){this.updateMessageList(A,"edit")}onMessageReadByPeer(A){this.updateMessageList(A,"edit")}onMessageReactionsUpdated(A){this.updateMessageReactionList([A])}onCurrentConversationIDUpdated(){const A=this.getEngine();A.TUIStore.watch(m_.CONV,{currentConversationID:e=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),A.TUIStore.reset(m_.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),lT(e)||this.getMessageList().finally(()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()})}})}onMessageSource(){const A=this.getEngine();A.TUIStore.watch(m_.CHAT,{messageSource:e=>{const t=this.getStoreData(m_.CONV,"currentConversationID");if(!t||e&&e.conversationID!==t)return;if(N_(e))return this.hoppingConfigMap.clear(),A.TUIStore.update(m_.CHAT,"messageList",[]),A.TUIStore.update(m_.CHAT,"nextReqMessageID",""),A.TUIStore.update(m_.CHAT,"isCompleted",!1),void this.getMessageList();const i=this.getStoreData(m_.CHAT,"messageList");i&&i.find(A=>e&&A.ID===e.ID)||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const A=this.getStoreData(m_.CHAT,"messageList"),{conversationID:e,sequence:t,time:i,ID:o}=this.getStoreData(m_.CHAT,"messageSource");if(A&&A.find(A=>o&&A.ID===o))return;const n=this.getEngine();n.TUIStore.update(m_.CHAT,"messageList",[]),n.TUIStore.update(m_.CHAT,"nextReqMessageID",""),n.TUIStore.update(m_.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:e,sequence:t,time:i,direction:1})}getStoreData(A,e){return this.getEngine().TUIStore.getData(A,e)}sendMessage(A,e){this.updateMessageList([A],"send");const t=this.getEngine().chat.sendMessage(A,e);return this.getResponse(t)}getResponse(A,e=!0,t=!0){return A.then(A=>{const t=A.data.messageList?A.data.messageList:[A.data.message];return e&&this.updateMessageList(t,"edit"),A}).catch(A=>{var e;return t&&(null===(e=null==A?void 0:A.data)||void 0===e?void 0:e.message)&&this.updateMessageList([A.data.message],"edit"),Promise.reject(A)})}updateMessageList(A,e=""){if(this.getStoreData(m_.CHAT,"messageSource")&&"unshift"!==e&&"edit"!==e)return;const t=this.getStoreData(m_.CHAT,"messageList"),i=this.updateTargetMessageList(A,t,e);this.getEngine().TUIStore.update(m_.CHAT,"messageList",i)}updateTargetMessageList(A,e,t=""){const i=this.getStoreData(m_.CONV,"currentConversationID");let o=A.filter(A=>A.conversationID===i);if(o=this.handleC2CCallSignaling(o),!t||0===o.length)return e;const n=e||[];let r=[];if("send"===t||"push"===t||"received"===t){const A=this.getStoreData(m_.CHAT,"userInfo");Object.keys(A).length>0&&this.updateLocalMessage(o,A)}const s=this.getStoreData(m_.APP,"enableAutoMessageRead");switch(t){case"edit":for(const A of e){const e=o.find(e=>e.ID===A.ID);r.push(e||A)}break;case"resend":r=n.filter(A=>A.ID!==o[0].ID).concat(o);break;case"send":r=n.concat(this.typingHandler.filterTypingMessage(o));break;case"push":r=n.concat(this.typingHandler.filterTypingMessage(o)),this.getEngine().chat.setMessageRead({conversationID:i});break;case"received":r=n.concat(this.typingHandler.filterTypingMessage(o)),r=this.sortMessageList(r),s&&this.getEngine().chat.setMessageRead({conversationID:i});break;case"unshift":r=o.filter(A=>0===n.length||!n.find(e=>e.ID===A.ID)),r.push(...n),r=this.sortMessageList(r)}return r}enterTypingState(){this.getStoreData(m_.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(m_.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(A){const e=this.getEngine(),t=this.getStoreData(m_.CONV,"currentConversationID");if(!t.startsWith(e.TYPES.CONV_C2C))return;const i=t.replace(e.TYPES.CONV_C2C,"");if(A){const A=this.getStoreData(m_.CHAT,"messageList").filter(A=>"in"===A.flow);if(0===A.length)return;const e=1e3*A[A.length-1].time;if((new Date).getTime()-e>3e4)return}this.typingHandler.sendTyping(A,i)}quoteMessage(A){var e;return this.getEngine().TUIStore.update(m_.CHAT,"quoteMessage",{message:A,type:"quote"}),null===(e=this.getEngine().TUIReport)||void 0===e||e.reportFeature(205),A}replyMessage(A){return this.getEngine().TUIStore.update(m_.CHAT,"quoteMessage",{message:A,type:"reply"}),A}getCurrentConvInfo(){const{conversationID:A="",type:e}=this.getStoreData(m_.CONV,"currentConversation")||{};return{to:A.replace(e,""),conversationType:e}}t(A){return this.getEngine().TUITranslate.t(A)||A}getMessageAbstractAndType(A){var e,t;const i=this.getEngine(),o={abstract:"",type:0};switch(A.type){case i.TYPES.MSG_TEXT:o.abstract=null===(e=null==A?void 0:A.payload)||void 0===e?void 0:e.text,o.type=1;break;case i.TYPES.MSG_CUSTOM:o.abstract="[自定义消息]",o.type=2;break;case i.TYPES.MSG_IMAGE:o.abstract="[图片]",o.type=3;break;case i.TYPES.MSG_AUDIO:o.abstract="[语音]",o.type=4;break;case i.TYPES.MSG_VIDEO:o.abstract="[视频]",o.type=5;break;case i.TYPES.MSG_FILE:o.abstract="[文件]",o.type=6;break;case i.TYPES.MSG_LOCATION:o.type=7;break;case i.TYPES.MSG_FACE:o.abstract="[表情]",o.type=8;break;case i.TYPES.MSG_GRP_TIP:o.type=9;break;case i.TYPES.MSG_MERGER:o.abstract=null===(t=null==A?void 0:A.payload)||void 0===t?void 0:t.title,o.type=10}return o}genMessageReply(A,e){if("reply"!==e&&"quote"!==e)return{};const{abstract:t,type:i}=this.getMessageAbstractAndType(A),o={messageAbstract:t,messageSender:A.nick||A.from,messageID:A.ID},n=Object.assign(Object.assign({},o),{messageType:i,messageTime:null==A?void 0:A.time,messageSequence:null==A?void 0:A.sequence,version:1});if("reply"===e&&(n.messageRootID=A.ID,A.cloudCustomData)){const e=k_(A.cloudCustomData);e.messageReply&&e.messageReply.messageRootID&&(n.messageRootID=e.messageReply.messageRootID)}return{messageReply:n,messageReplyRoot:o}}getMessageInfo(A,e,t){const{messageReply:i,messageReplyRoot:o}=this.genMessageReply(e,t),n=A.cloudCustomData?k_(A.cloudCustomData):{};let r;if(n.messageReply?n.messageReply=Object.assign(Object.assign({},i),n.messageReply):n.messageReply=i,"reply"===t){const{messageRootID:A}=i;r=this.getEngine().chat.findMessage(A);const e=(null==r?void 0:r.cloudCustomData)?k_(r.cloudCustomData):{};e.messageReplies||(e.messageReplies={}),s=e.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(s):"array"===Object.prototype.toString.call(s).match(/^\[object (.*)\]$/)[1].toLowerCase())||(e.messageReplies.replies=[]),e.messageReplies.replies.push(o),r.cloudCustomData=JSON.stringify(e)}var s;return{cloudCustomData:JSON.stringify(n),rootMessage:r}}sendTextMessage(A,e){const t=this.getEngine(),{message:i,type:o}=this.getStoreData(m_.CHAT,"quoteMessage");let n={cloudCustomData:A.cloudCustomData||"",rootMessage:void 0};i&&(n=this.getMessageInfo(A,i,o));const r=t.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{cloudCustomData:n.cloudCustomData}));return this.sendMessage(r,e).then(A=>(n.rootMessage&&this.modifyMessage(n.rootMessage),t.TUIStore.reset(m_.CHAT,["quoteMessage"],!0),A))}sendTextAtMessage(A,e){const t=this.getEngine(),{message:i,type:o}=this.getStoreData(m_.CHAT,"quoteMessage");let n={cloudCustomData:A.cloudCustomData||"",rootMessage:void 0};i&&(n=this.getMessageInfo(A,i,o));const r=t.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{cloudCustomData:n.cloudCustomData}));return this.sendMessage(r,e).then(A=>(n.rootMessage&&this.modifyMessage(n.rootMessage),t.TUIStore.reset(m_.CHAT,["quoteMessage"],!0),A))}sendImageMessage(A,e){const t=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{onProgress:A=>{this.onProgress(t.ID,A)}}));return this.sendMessage(t,e)}sendAudioMessage(A,e){const t=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{onProgress:A=>{this.onProgress(t.ID,A)}}));return this.sendMessage(t,e)}sendVideoMessage(A,e){const t=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{onProgress:A=>{this.onProgress(t.ID,A)}}));return this.sendMessage(t,e)}sendCustomMessage(A,e){const t=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),A));return this.sendMessage(t,e)}sendFaceMessage(A,e){const t=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),A));return this.sendMessage(t,e)}sendFileMessage(A,e){const t=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),A),{onProgress:A=>{this.onProgress(t.ID,A)}}));return this.sendMessage(t,e)}sendLocationMessage(A,e){const t=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),A));return this.sendMessage(t,e)}onProgress(A,e){const t=this.getEngine().TUIStore.getMessageModel(A);t&&(e-t.progress>=.1||1===e)&&(t.progress=e,this.updateMessageList([t],"edit"))}setAbstractList(A){const e=this.getEngine(),t=A.nick||A.from;let i="";switch(A.type){case e.TYPES.MSG_TEXT:i=A.payload.text||"",i.length>20&&(i=i.slice(0,20));break;case e.TYPES.MSG_MERGER:i=`${this.t("TUIChat.[聊天记录]")}`;break;case e.TYPES.MSG_IMAGE:i=`${this.t("TUIChat.[图片]")}`;break;case e.TYPES.MSG_AUDIO:i=`${this.t("TUIChat.[音频]")}`;break;case e.TYPES.MSG_VIDEO:i=`${this.t("TUIChat.[视频]")}`;break;case e.TYPES.MSG_CUSTOM:i=`${this.t("TUIChat.[自定义消息]")}`;break;case e.TYPES.MSG_FILE:i=`${this.t("TUIChat.[文件]")}`;break;case e.TYPES.MSG_FACE:i=`${this.t("TUIChat.[动画表情]")}`}return`${t}: ${i}`}genMergerForwardPayload(A,e){const{abstractList:t=[],compatibleText:i="",title:o}=e;return 0===t.length&&A.forEach(A=>{t.push(this.setAbstractList(A))}),{messageList:A,title:o,abstractList:t,compatibleText:i||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(A){const{conversationList:e,messageList:t,params:i,mergeInfo:o,sendMessageOptions:n}=A,r=[];for(let s=0;sA instanceof dT?A.getMessage():A)}sendForwardMessage(A,e,t){e=this.getOriginMessageList(e);const i=t||{},{needMerge:o=!1,params:n={},mergeInfo:r={}}=i,s=B_(i,["needMerge","params","mergeInfo"]);if(o)return this.sendMergerForwardMessage({conversationList:A,messageList:e,params:n,mergeInfo:r,sendMessageOptions:s});const a=[];for(let g=0;g{const{code:e=0,data:t={}}=A.code;throw e===w_.MSG_MODIFY_CONFLICT?console.warn(`${M_.MSG_MODIFY_CONFLICT} data.message: ${null==t?void 0:t.message}`):e===w_.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(M_.MSG_MODIFY_DISABLED_IN_AVCHATROOM):e===w_.MODIFY_MESSAGE_NOT_EXIST&&console.warn(M_.MODIFY_MESSAGE_NOT_EXIST),A})}getMessageList(A={conversationID:this.getStoreData(m_.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(m_.CHAT,"nextReqMessageID")}){const e=this.getEngine();if(!e.chat.isReady())return Promise.reject({code:S_.GET_MSG_LIST_ERROR,message:R_.GET_MSG_LIST_ERROR});if(this.getStoreData(m_.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const t=this.getStoreData(m_.CHAT,"messageSource"),i=this.hoppingConfigMap.get("nextMessageSeq"),o=this.hoppingConfigMap.get("nextMessageTime"),n=i||o;return t&&t.conversationID===(null==A?void 0:A.conversationID)&&n?this.getMessageListHopping():e.chat.getMessageList(A).then(A=>{var t;const{messageList:i,nextReqMessageID:o,isCompleted:n}=A.data,r=this.getStoreData(m_.CHAT,"userInfo");Object.keys(r).length>0&&this.updateLocalMessage(i,r),this.updateMessageList(i,"unshift"),e.TUIStore.update(m_.CHAT,"nextReqMessageID",o),e.TUIStore.update(m_.CHAT,"isCompleted",n);const s=null===(t=i[0])||void 0===t?void 0:t.conversationID,{operationType:a=0}=this.getEngine().TUIStore.getConversationModel(s)||{};return 0===a&&(this.getMessageReactions({messageList:i}),this.readReceiptHandler.getMessageReadReceiptList(i)),A}).catch(A=>Promise.reject(A))}getMessageListHopping(A){var e;void 0===A&&(A={conversationID:null===(e=this.getStoreData(m_.CHAT,"messageSource"))||void 0===e?void 0:e.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const t=this.getEngine();return t.chat.getMessageListHopping(A).then(e=>{const{messageList:i,nextMessageSeq:o,nextMessageTime:n,isCompleted:r}=e.data,s=1===A.direction?A.sequence:o,a=1===A.direction?A.time:n;return this.updateMessageList(i,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",s),this.hoppingConfigMap.set("nextMessageTime",a),t.TUIStore.update(m_.CHAT,"isCompleted",r),e}).catch(A=>Promise.reject(A))}sendMessageReadReceipt(A){return this.readReceiptHandler.sendMessageReadReceipt(A)}getGroupMessageReadMemberList(A){return this.readReceiptHandler.getGroupMessageReadMemberList(A).then(A=>{const{isCompleted:e,cursor:t,messageID:i,unreadUserIDList:o,readUserIDList:n}=A.data,r={code:0,data:{cursor:t,isCompleted:e,messageID:i,unreadUserInfoList:[],readUserInfoList:[]}},s=[...o,...n];return 0===s.length?r:this.getEngine().TUIUser.getUserProfile({userIDList:s}).then(A=>(o.length>0?A.data.forEach(A=>{const{userID:e,nick:t="",avatar:i=""}=A;r.data.unreadUserInfoList.push({userID:e,nick:t,avatar:i})}):A.data.forEach(A=>{const{userID:e,nick:t="",avatar:i=""}=A;r.data.readUserInfoList.push({userID:e,nick:t,avatar:i})}),r))})}downloadMergedMessages(A){return this.getEngine().chat.downloadMergerMessage(A)}setTranslationLanguage(A){this.getEngine().TUIStore.update(m_.USER,"targetLanguage",A)}translateText(A){const e=this.getStoreData(m_.USER,"targetLanguage"),t=Object.assign({targetLanguage:e,sourceLanguage:"auto"},A);return this.getEngine().chat.translateText(t)}searchCloudMessages(A){return this.getEngine().TUISearch.searchCloudMessages(A)}addMessageReaction(A,e){return this.getEngine().chat.addMessageReaction(A.getMessage(),e)}removeMessageReaction(A,e){return this.getEngine().chat.removeMessageReaction(A.getMessage(),e)}getMessageReactions(A){const{messageList:e=[]}=A,t=this.getStoreData(m_.APP,"enabledEmojiPlugin");console.log(`TUIChatService.getMessageReactions enabledEmojiPlugin:${t} messageList length:${e.length}`),t&&e.length>0&&this.getEngine().chat.getMessageReactions(A).then(A=>{const e=A.data.resultList||A.data;this.updateMessageReactionList(e)}).catch(()=>{})}getAllUserListOfMessageReaction(A){var e;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},A),{message:null===(e=null==A?void 0:A.message)||void 0===e?void 0:e.getMessage()}))}updateMessageReactionList(A){const e=[];A.forEach(A=>{const{messageID:t,reactionList:i}=A,o=this.getEngine().TUIStore.getMessageModel(t);if(o){const A=[];for(let e=0;e0&&this.updateMessageList(e,"edit")}convertVoiceToText(A){const{message:e,language:t="zh"}=A,i=e.getMessage();return this.getEngine().chat.convertVoiceToText({message:i,language:t})}clearHistoryMessage(A){const e=this.getEngine();return e.chat.clearHistoryMessage(A).then(A=>(e.TUIStore.update(m_.CHAT,"messageList",[]),e.TUIStore.update(m_.CHAT,"nextReqMessageID",""),e.TUIStore.update(m_.CHAT,"isCompleted",!1),A))}updateMessageInfo(A){const e=this.getStoreData(m_.CHAT,"userInfo");this.getEngine().TUIStore.update(m_.CHAT,"userInfo",Object.assign(e,A));const t=this.getStoreData(m_.CHAT,"messageList");t.length>0&&this.updateLocalMessage(t,A)&&this.getEngine().TUIStore.update(m_.CHAT,"messageList",t)}updateLocalMessage(A,e){let t=!1;return A.forEach(A=>{if(e[A.from]){const{nick:i,nameCard:o,avatar:n}=e[A.from];i&&(A.nick=i,t=!0),o&&(A.nameCard=o,t=!0),n&&(A.avatar=n,t=!0)}}),t}handleC2CCallSignaling(A=[]){var e,t,i,o,n;const r=[],s=this.getEngine(),a=s.getMyUserID();for(let g=0;gA.time-e.time);const t=A.filter(A=>"success"===A.status).sort((A,e)=>A.sequence-e.sequence);for(let i=0;i{A.groupID===t&&e.TUIStore.update(m_.GRP,"currentGroup",A)})}onGroupAttributesUpdated(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.GRP,"currentGroupID");let i=e.TUIStore.getData(m_.GRP,"groupList");const{groupID:o,groupAttributes:n}=A;t===o&&e.TUIStore.update(m_.GRP,"currentGroupAttributes",n),i=i.map(A=>(A.groupID===o&&(A.groupAttributes=n),A)),e.TUIStore.update(m_.GRP,"groupList",i)}onGroupCounterUpdated(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.GRP,"currentGroupID"),i=e.TUIStore.getData(m_.GRP,"currentGroupCounters")||{};let o=e.TUIStore.getData(m_.GRP,"groupList");const{groupID:n,key:r,value:s}=A;t===n&&(i[r]=s,e.TUIStore.update(m_.GRP,"currentGroupCounters",i)),o=o.map(A=>(A.groupID===n&&(A.groupCounters=Object.assign(Object.assign({},A.groupCounters),{[r]:s})),A)),e.TUIStore.update(m_.GRP,"groupList",o)}onMessageReceived(A){const e=this.getEngine(),t=[];A.forEach(A=>{if(A.type===e.TYPES.MSG_GRP_TIP){const{payload:t}=A,{operationType:i,userIDList:o}=t;switch(i){case e.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(o);break;case e.TYPES.GRP_TIP_MBR_QUIT:case e.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(o);break;case e.TYPES.GRP_TIP_MBR_SET_ADMIN:case e.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(o);break;case e.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:break;case e.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:case e.TYPES.GRP_TIP_BAN_AVCHATROOM_MEMBER:case e.TYPES.GRP_TIP_UNBAN_AVCHATROOM_MEMBER:this.updateGroupMember(o)}}A.type===e.TYPES.MSG_GRP_SYS_NOTICE&&t.push(A)}),t.length>0&&e.TUIStore.update(m_.GRP,"groupSystemNoticeList",t)}getGroupInitData(){const A=this.getEngine();A.chat.isReady()&&A.chat.getGroupList().then(A=>{const{groupList:e=[]}=A.data;console.log(`TUIGroupService.init, getGroupList count:${e.length}`),e.length>0&&this.onGroupListUpdated(e)})}updateGroupMember(A){return Q_(this,void 0,void 0,function*(){const e=this.getEngine().TUIStore.getData(m_.GRP,"currentGroupID");if(e){const t=yield this.getGroupMemberProfile({groupID:e,userIDList:A}),{memberList:i}=t.data;this.updateMemberList(i)}})}resetCurrentStore(){this.getEngine().TUIStore.reset(m_.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(A){return Q_(this,void 0,void 0,function*(){const e=this.getEngine();e.TUIStore.update(m_.GRP,"offset",0),e.TUIStore.update(m_.GRP,"isCompleted",!1);const t=e.TUIStore.getConversationModel(`GROUP${A}`);if((null==t?void 0:t.operationType)>0){const A=e.TUIStore.getData(m_.GRP,"currentGroup");return Promise.resolve(A)}const i=e.TUIStore.getData(m_.GRP,"currentGroupID");if(!A)return this.resetCurrentStore(),Promise.resolve({});if(i===A){const A=e.TUIStore.getData(m_.GRP,"currentGroup");return Promise.resolve(A)}this.resetCurrentStore(),e.TUIStore.update(m_.GRP,"currentGroupID",A);try{yield this.getGroupInfo(A)}catch(r){Promise.reject(r)}const o=setTimeout(()=>{this.groupMap.delete(A),clearTimeout(o)},5e3),n=e.TUIStore.getData(m_.GRP,"currentGroup");return Promise.resolve(n)})}getGroupInfo(A){return Q_(this,void 0,void 0,function*(){const e=this.getEngine(),t=this.groupMap.get(A);if(t)return this.updateMemberList((null==t?void 0:t.memberList)||[]),e.TUIStore.update(m_.GRP,"currentGroup",t.group),e.TUIStore.update(m_.GRP,"currentGroupAttributes",t.groupAttributes||{}),void e.TUIStore.update(m_.GRP,"currentGroupCounters",t.counters||{});const i={group:{},memberList:[],groupAttributes:void 0,counters:void 0},{data:{group:o}}=yield this.getGroupProfile({groupID:A});i.group=o;const{data:{memberList:n}}=yield this.getGroupMemberList({groupID:A});i.memberList=n;const r=yield this.getGroupAttributes({groupID:A,keyList:[]}),{groupAttributes:s}=r.data;i.groupAttributes=s,e.TUIStore.update(m_.GRP,"currentGroupAttributes",s);try{const t=yield this.getGroupCounters({groupID:A,keyList:[]}),{counters:o}=t.data;i.counters=o,e.TUIStore.update(m_.GRP,"currentGroupCounters",o)}catch(a){console.warn(null==a?void 0:a.message)}this.groupMap.set(A,i)})}getGroupProfile(A){const e=this.getEngine();return e.chat.getGroupProfile(A).then(t=>Q_(this,void 0,void 0,function*(){if(e.TUIStore.getData(m_.GRP,"currentGroupID")===A.groupID){const{group:A}=t.data;e.TUIStore.update(m_.GRP,"currentGroup",A)}return t}))}updateGroupProfile(A){return this.getEngine().chat.updateGroupProfile(A)}createGroup(A){return this.getEngine().chat.createGroup(A)}dismissGroup(A){return this.getEngine().chat.dismissGroup(A)}searchGroupByID(A){const e=this.getEngine();return e.chat.searchGroupByID(A).then(A=>{const{group:t}=A.data,i=e.TUIStore.getData(m_.GRP,"groupList");return A.data.group.isJoinedGroup=i.some(A=>A.groupID===t.groupID),A})}joinGroup(A){return this.getEngine().chat.joinGroup(A)}quitGroup(A){return this.getEngine().chat.quitGroup(A)}getGroupApplicationList(){return this.getEngine().chat.getGroupApplicationList()}handleGroupApplication(A){return this.getEngine().chat.handleGroupApplication(A)}getGroupOnlineMemberCount(A){return this.getEngine().chat.getGroupOnlineMemberCount(A)}changeGroupOwner(A){return this.getEngine().chat.changeGroupOwner(A)}initGroupAttributes(A){return this.getEngine().chat.initGroupAttributes(A)}setGroupAttributes(A){return this.getEngine().chat.setGroupAttributes(A)}deleteGroupAttributes(A){return this.getEngine().chat.deleteGroupAttributes(A)}getGroupAttributes(A){return this.getEngine().chat.getGroupAttributes(A)}setGroupCounters(A){return this.getEngine().chat.setGroupCounters(A)}increaseGroupCounter(A){return this.getEngine().chat.increaseGroupCounter(A)}decreaseGroupCounter(A){return this.getEngine().chat.decreaseGroupCounter(A)}getGroupCounters(A){return this.getEngine().chat.getGroupCounters(A)}updateMemberList(A){const e=this.getEngine(),t=[...(e.TUIStore.getData(m_.GRP,"currentGroupMemberList")||[]).filter(e=>!A.find(A=>A.userID===e.userID)),...A];e.TUIStore.update(m_.GRP,"currentGroupMemberList",t)}addMemberList(A){return Q_(this,void 0,void 0,function*(){const e=this.getEngine().TUIStore.getData(m_.GRP,"currentGroupID");if(e)try{const t=yield this.getGroupMemberProfile({groupID:e,userIDList:A}),{memberList:i}=t.data;this.updateMemberList(i)}catch(t){const e=A.map(A=>({userID:A,avatar:"",nick:"",role:"",joinTime:0,nameCard:"",muteUntil:0,memberCustomField:[]}));this.updateMemberList(e)}})}removeMemberList(A){const e=this.getEngine(),t=e.TUIStore.getData(m_.GRP,"currentGroupMemberList").filter(e=>-1===A.indexOf(e.userID));e.TUIStore.update(m_.GRP,"currentGroupMemberList",t)}getGroupMemberList(A){const e=this.getEngine();if(N_(A.offset)){const t=e.TUIStore.getData(m_.GRP,"offset");A.offset=t}return e.chat.getGroupMemberList(A).then(t=>{if(e.TUIStore.getData(m_.GRP,"currentGroupID")===A.groupID){const{memberList:A,offset:i=0}=t.data;this.updateMemberList(A),e.TUIStore.update(m_.GRP,"offset",i),0===i&&e.TUIStore.update(m_.GRP,"isCompleted",!0)}return t})}getGroupMemberProfile(A){return this.getEngine().chat.getGroupMemberProfile(A)}addGroupMember(A){const e=this.getEngine();return e.chat.addGroupMember(A).then(t=>Q_(this,void 0,void 0,function*(){if(e.TUIStore.getData(m_.GRP,"currentGroupID")===A.groupID){const{successUserIDList:A,group:i}=t.data;e.TUIStore.update(m_.GRP,"currentGroup",i),this.addMemberList(A)}return t}))}deleteGroupMember(A){const e=this.getEngine();return e.chat.deleteGroupMember(A).then(t=>{if(e.TUIStore.getData(m_.GRP,"currentGroupID")===A.groupID){const{userIDList:A,group:i}=t.data;this.removeMemberList(A),e.TUIStore.update(m_.GRP,"currentGroup",i)}return t})}setGroupMemberMuteTime(A){return this.getEngine().chat.setGroupMemberMuteTime(A)}setGroupMemberRole(A){return this.getEngine().chat.setGroupMemberRole(A)}setGroupMemberNameCard(A){return this.getEngine().chat.setGroupMemberNameCard(A)}setGroupMemberCustomField(A){return this.getEngine().chat.setGroupMemberCustomField(A)}markGroupMemberList(A){return this.getEngine().chat.markGroupMemberList(A)}}.getInstance(),HT=class A extends cT{constructor(){super(),this.tobeUpdatedFriendGroupList=void 0}static getInstance(){return A.instance||(A.instance=new A),A.instance}init(){const A=this.getEngine();A.eventCenter.addEvent(A.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated.bind(this)),A.eventCenter.addEvent(A.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated.bind(this)),A.eventCenter.addEvent(A.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated.bind(this)),this.getFriendInitData()}onFriendListUpdated(A){this.getEngine().TUIStore.update(m_.FRIEND,"friendList",A),this.updatedFriendGroupList(A,this.tobeUpdatedFriendGroupList)}onFriendApplicationListUpdated(A){const{friendApplicationList:e,unreadCount:t=0}=A,i=this.getEngine();i.TUIStore.update(m_.FRIEND,"friendApplicationList",e),i.TUIStore.update(m_.FRIEND,"friendApplicationUnreadCount",t)}onFriendGroupListUpdated(A){const e=this.getEngine().TUIStore.getData(m_.FRIEND,"friendList");e.length>0?this.updatedFriendGroupList(e,A):this.tobeUpdatedFriendGroupList=A}updatedFriendGroupList(A,e){const t=this.getEngine();if(e&&e.length>0){const i=e.map(e=>{const{userIDList:t}=e,i=B_(e,["userIDList"]),o=t.map(e=>A.find(A=>A.userID===e));return Object.assign(Object.assign({},i),{friendList:o})});t.TUIStore.update(m_.FRIEND,"friendGroupList",i),this.tobeUpdatedFriendGroupList=void 0}}getFriendInitData(){const A=this.getEngine();A.chat.isReady()&&(A.chat.getFriendList().then(A=>{const e=A.data||[];console.log(`TUIFriendService.init, getFriendList count:${e.length}`),e.length>0&&this.onFriendListUpdated(e)}),A.chat.getFriendGroupList().then(A=>{const e=A.data||[];console.log(`TUIFriendService.init, getFriendGroupList count:${e.length}`),e.length>0&&this.onFriendGroupListUpdated(e)}),A.chat.getFriendApplicationList().then(A=>{this.onFriendApplicationListUpdated(A.data)}))}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(A){const e=this.getEngine().TUIStore.getData(m_.FRIEND,"friendList"),t={};return A.forEach(A=>{for(let i=0;iQ_(this,void 0,void 0,function*(){const{searchResultList:t}=e.data;if((null==t?void 0:t.length)>0){const A=[];if(e.data.searchResultList=t.map(e=>{const{messageList:t,conversationID:i}=e,o=B_(e,["messageList","conversationID"]),n=t.map(A=>new dT(A)),s=r.find(A=>A.conversationID===i);return N_(s)&&A.push(mT.getInstance().getConversationProfile(i)),Object.assign(Object.assign({},o),{messageList:n.sort((A,e)=>e.time-A.time),conversation:s})}),A.length>0)try{const i=yield Promise.all(A);e.data.searchResultList=t.map(A=>{const{messageList:e,conversationID:t}=A,o=B_(A,["messageList","conversationID"]),n=e.map(A=>new dT(A)),{data:{conversation:r}}=i.find(A=>A.data.conversation.conversationID===t),s=new uT(r);return Object.assign(Object.assign({},o),{messageList:n.sort((A,e)=>e.time-A.time),conversation:s})})}catch(o){console.log("fetch conversation error",o)}}return e.data.params=A,i?this.handleSearchResult(NT.CHAT_MESSAGE,e.data):this.handleSearchResult(NT.MESSAGE,e.data),e})).catch(A=>(this.getEngine().TUIStore.update(m_.SEARCH,"error",A),Promise.reject(A)))}searchCloudUsers(A){const{keyword:e,keywordList:t}=A,i=B_(A,["keyword","keywordList"]),o=this.getStoreData(m_.FRIEND,"friendList");return this.searchParamsValidate(NT.USER,A)?this.getEngine().chat.searchCloudUsers(Object.assign({keywordList:e?[e]:t||void 0,keywordListMatchType:"or"},i)).then(e=>{const{searchResultList:t}=e.data;if(t.length>0){const A=new Map(t.map(A=>[A.userID,{profile:A,relation:bR.TYPES.SNS_TYPE_NO_RELATION}]));o.forEach(e=>{const{userID:t}=e,i=A.get(t);i&&(i.relation=bR.TYPES.SNS_TYPE_BOTH_WAY)}),e.data.searchResultList=Array.from(A.values())}return e.data.params=A,this.handleSearchResult(NT.USER,e.data),e}).catch(A=>(this.getEngine().TUIStore.update(m_.SEARCH,"error",A),Promise.reject(A))):Promise.resolve()}searchCloudGroups(A){const{keyword:e,keywordList:t}=A,i=B_(A,["keyword","keywordList"]),o=this.getStoreData(m_.CONV,"conversationList"),n=this.getStoreData(m_.GRP,"groupList");return this.searchParamsValidate(NT.GROUP,A)?this.getEngine().chat.searchCloudGroups(Object.assign({keywordList:e?[e]:t||void 0,keywordListMatchType:"or"},i)).then(e=>{const{searchResultList:t}=e.data;return t.length>0&&(e.data.searchResultList=t.map(A=>{const e=n.find(e=>e.groupID===A.groupID),t=o.find(e=>e.conversationID===`GROUP${A.groupID}`);return{groupInfo:e||A,conversation:t}})),e.data.params=A,this.handleSearchResult(NT.GROUP,e.data),e}).catch(A=>(this.getEngine().TUIStore.update(m_.SEARCH,"error",A),Promise.reject(A))):Promise.resolve()}}.getInstance();UT.mount(f_.TUIStore,FT),UT.mount(f_.TUITranslate,OT),UT.mount(f_.TUIConversation,xT),UT.mount(f_.TUIUser,PT),UT.mount(f_.TUIChat,YT),UT.mount(f_.TUIGroup,JT),UT.mount(f_.TUIFriend,HT),UT.mount(f_.TUIReport,qT),UT.mount(f_.TUISearch,VT),LT(UT,UT,T_),LT(UT,xT,{deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1,setMessageRead:1,markConversation:1}),LT(UT,YT,{modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1}),LT(UT,JT,{switchGroup:1,getGroupProfile:1,updateGroupProfile:1,createGroup:1,dismissGroup:1,searchGroupByID:1,joinGroup:1,quitGroup:1,getGroupApplicationList:1,handleGroupApplication:1,getGroupOnlineMemberCount:1,changeGroupOwner:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getGroupMemberList:1,getGroupMemberProfile:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberNameCard:1,setGroupMemberCustomField:1,markGroupMemberList:1}),LT(UT,PT,{switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1}),LT(UT,HT,{getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1}),LT(UT,qT,T_),LT(UT,VT,T_);const jT=()=>sR({url:"/api/service/userPassword/details",method:"get"}),KT=(A,e="post")=>sR({url:"/api/service/userPassword",method:e,data:A}),WT=(A,e="post")=>sR({url:"/api/service/userCard",method:e,data:A}),zT=A=>sR({url:`/api/service/userCard/${A}`,method:"delete"}),ZT=()=>sR({url:"/api/service/userCard/list",method:"get"}),XT=A=>sR({url:`/api/service/userCard/details/${A}`,method:"get"}),$T=(A,e="post")=>sR({url:"/api/service/userPayment",method:e,data:A}),AN=A=>sR({url:`/api/service/userPayment/${A}`,method:"get"}),eN=()=>sR({url:"/api/service/userPayment/list",method:"get"}),tN=()=>sR({url:"/api/service/userVerification/details",method:"get"}),iN=(A,e="post")=>sR({url:"/api/service/userVerification",method:e,data:A}),oN=A=>sR({url:`/api/service/appWithdrawalConfig/${A}`,method:"get"}),nN=A=>sR({url:"/api/service/SerAppUserWithdrawal",method:"post",data:A}),rN=A=>sR({url:"/api/service/SerAppUserWithdrawal/list",method:"get",data:A}),sN=A=>sR({url:"/api/system/logPoints/list",method:"get",data:A}),aN=A=>sR({url:"/api/service/userMoments",method:"post",data:A}),gN=A=>sR({url:"/api/service/userMoments/list",method:"get",loading:!1,data:A}),cN=A=>sR({url:`/api/service/userMoments/like/${A}`,method:"put"}),lN=A=>sR({url:"/api/service/userMoments/comment",method:"post",data:A}),IN=A=>sR({url:`/api/service/userMoments/${A}`,method:"delete"}),uN=A=>sR({url:"/api/service/feedback",method:"post",data:A}),EN=A=>sR({url:"/api/service/serNotification/list",method:"get",data:A}),dN=A=>sR({url:`/api/service/serNotification/${A}`,method:"get"}),hN=()=>sR({url:"/api/service/customerStaff/listFree",method:"get"}),CN=A=>sR({url:`/api/service/customerStaff/end/${A}`,method:"get"}),BN=qM("user",()=>{const{clearToken:A}=nR(),{showDialog:e,showToast:t}=SR(),i=Kt(iR()?null==JSON?void 0:JSON.parse(iR()):{}),o=Kt(uni.getStorageSync(AR)||26),n=Kt(oR()?null==JSON?void 0:JSON.parse(oR()):{}),r=Kt(0),s=async A=>{const e=await sR({url:"/api/user/usersig",method:"get"});var t;n.value=e.data,i.value=A,tR(A),t=e.data,uni.setStorageSync($M,JSON.stringify(t))},a=async()=>{const A=await sR({url:"/api/system/userPoints/details",method:"get"});r.value=A.data.availablePoints},g=async()=>{await I(),await $R.login({SDKAppID:n.value.sdkappID,userID:n.value.userId,userSig:n.value.userSig,framework:"vue3"}),await UT.login({SDKAppID:n.value.sdkappID,userID:n.value.userId,userSig:n.value.userSig,useUploadPlugin:!0})},c=async()=>{if(i.value)try{i.value=null,await sR({url:"/api/mobile/out",method:"get"}),await $R.logout(),await UT.logout(),l(),await t("退出登录成功","success"),DM("/pages/login/login")}catch(A){l(),await t("退出登录成功","success"),DM("/pages/login/login")}},l=async()=>{i.value=null,n.value=null,o.value=26,A(),uni.removeStorageSync(XM),uni.removeStorageSync($M),uni.removeStorageSync(AR)},I=async()=>{const A=await lR();await a(),await tR(A.data),i.value=A.data};return{userInfo:i,integralData:r,tencentUserSig:n,fontSizeData:o,getIntegral:a,clearAllUserInfo:l,updateFontSize:async A=>{var e;o.value=A,e=A,uni.setStorageSync(AR,e)},logout:c,refreshUserInfo:I,fetchUserInfo:async()=>{const A=eR(),e=iR(),t=oR();if(A&&e)return i.value=JSON.parse(e),n.value=JSON.parse(t),void g();await a();const o=await lR();await s(o.data),g()},loginTencentIM:g,setUserInfo:s,clearUserInfo:async()=>{await e("提示","确定要退出登录吗?")&&await c()},updateUserInfo:async A=>{var e;i.value&&(await(e=A,sR({url:"/api/user/edit",method:"put",data:e})),await I())}}}),QN=()=>{const A=BN(),e=nR(),{userInfo:t,tencentUserSig:i,fontSizeData:o,integralData:n}=WM(A),{token:r}=WM(e);return{integralData:n,userInfo:t,tencentUserSig:i,fontSizeData:o,token:r}};var pN="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},fN=[],mN=[],yN="undefined"!=typeof Uint8Array?Uint8Array:Array,DN=!1;function vN(){DN=!0;for(var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)fN[e]=A[e],mN[A.charCodeAt(e)]=e;mN["-".charCodeAt(0)]=62,mN["_".charCodeAt(0)]=63}function wN(A,e,t){for(var i,o,n=[],r=e;r>18&63]+fN[o>>12&63]+fN[o>>6&63]+fN[63&o]);return n.join("")}function SN(A){var e;DN||vN();for(var t=A.length,i=t%3,o="",n=[],r=0,s=t-i;rs?s:r+16383));return 1===i?(e=A[t-1],o+=fN[e>>2],o+=fN[e<<4&63],o+="=="):2===i&&(e=(A[t-2]<<8)+A[t-1],o+=fN[e>>10],o+=fN[e>>4&63],o+=fN[e<<2&63],o+="="),n.push(o),n.join("")}function MN(A,e,t,i,o){var n,r,s=8*o-i-1,a=(1<>1,c=-7,l=t?o-1:0,I=t?-1:1,u=A[e+l];for(l+=I,n=u&(1<<-c)-1,u>>=-c,c+=s;c>0;n=256*n+A[e+l],l+=I,c-=8);for(r=n&(1<<-c)-1,n>>=-c,c+=i;c>0;r=256*r+A[e+l],l+=I,c-=8);if(0===n)n=1-g;else{if(n===a)return r?NaN:1/0*(u?-1:1);r+=Math.pow(2,i),n-=g}return(u?-1:1)*r*Math.pow(2,n-i)}function RN(A,e,t,i,o,n){var r,s,a,g=8*n-o-1,c=(1<>1,I=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,u=i?0:n-1,E=i?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,r=c):(r=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-r))<1&&(r--,a*=2),(e+=r+l>=1?I/a:I*Math.pow(2,1-l))*a>=2&&(r++,a/=2),r+l>=c?(s=0,r=c):r+l>=1?(s=(e*a-1)*Math.pow(2,o),r+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),r=0));o>=8;A[t+u]=255&s,u+=E,s/=256,o-=8);for(r=r<0;A[t+u]=255&r,u+=E,r/=256,g-=8);A[t+u-E]|=128*d}var _N={}.toString,TN=Array.isArray||function(A){return"[object Array]"==_N.call(A)};function NN(){return GN.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function bN(A,e){if(NN()=NN())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+NN().toString(16)+" bytes");return 0|A}function xN(A){return!(null==A||!A._isBuffer)}function PN(A,e){if(xN(A))return A.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(A)||A instanceof ArrayBuffer))return A.byteLength;"string"!=typeof A&&(A=""+A);var t=A.length;if(0===t)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return Eb(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return db(A).length;default:if(i)return Eb(A).length;e=(""+e).toLowerCase(),i=!0}}function YN(A,e,t){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(e>>>=0))return"";for(A||(A="utf8");;)switch(A){case"hex":return ib(this,e,t);case"utf8":case"utf-8":return $N(this,e,t);case"ascii":return eb(this,e,t);case"latin1":case"binary":return tb(this,e,t);case"base64":return XN(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ob(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),i=!0}}function JN(A,e,t){var i=A[e];A[e]=A[t],A[t]=i}function HN(A,e,t,i,o){if(0===A.length)return-1;if("string"==typeof t?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=o?0:A.length-1),t<0&&(t=A.length+t),t>=A.length){if(o)return-1;t=A.length-1}else if(t<0){if(!o)return-1;t=0}if("string"==typeof e&&(e=GN.from(e,i)),xN(e))return 0===e.length?-1:qN(A,e,t,i,o);if("number"==typeof e)return e&=255,GN.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(A,e,t):Uint8Array.prototype.lastIndexOf.call(A,e,t):qN(A,[e],t,i,o);throw new TypeError("val must be string, number or Buffer")}function qN(A,e,t,i,o){var n,r=1,s=A.length,a=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(A.length<2||e.length<2)return-1;r=2,s/=2,a/=2,t/=2}function g(A,e){return 1===r?A[e]:A.readUInt16BE(e*r)}if(o){var c=-1;for(n=t;ns&&(t=s-a),n=t;n>=0;n--){for(var l=!0,I=0;Io&&(i=o):i=o;var n=e.length;if(n%2!=0)throw new TypeError("Invalid hex string");i>n/2&&(i=n/2);for(var r=0;r>8,o=t%256,n.push(o),n.push(i);return n}(e,A.length-t),A,t,i)}function XN(A,e,t){return 0===e&&t===A.length?SN(A):SN(A.slice(e,t))}function $N(A,e,t){t=Math.min(A.length,t);for(var i=[],o=e;o239?4:g>223?3:g>191?2:1;if(o+l<=t)switch(l){case 1:g<128&&(c=g);break;case 2:128==(192&(n=A[o+1]))&&(a=(31&g)<<6|63&n)>127&&(c=a);break;case 3:n=A[o+1],r=A[o+2],128==(192&n)&&128==(192&r)&&(a=(15&g)<<12|(63&n)<<6|63&r)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:n=A[o+1],r=A[o+2],s=A[o+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(a=(15&g)<<18|(63&n)<<12|(63&r)<<6|63&s)>65535&&a<1114112&&(c=a)}null===c?(c=65533,l=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),o+=l}return function(A){var e=A.length;if(e<=Ab)return String.fromCharCode.apply(String,A);for(var t="",i=0;i0&&(A=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(A+=" ... ")),""},GN.prototype.compare=function(A,e,t,i,o){if(!xN(A))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===t&&(t=A?A.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),e<0||t>A.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=t)return 0;if(i>=o)return-1;if(e>=t)return 1;if(this===A)return 0;for(var n=(o>>>=0)-(i>>>=0),r=(t>>>=0)-(e>>>=0),s=Math.min(n,r),a=this.slice(i,o),g=A.slice(e,t),c=0;co)&&(t=o),A.length>0&&(t<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var n=!1;;)switch(i){case"hex":return VN(this,A,e,t);case"utf8":case"utf-8":return jN(this,A,e,t);case"ascii":return KN(this,A,e,t);case"latin1":case"binary":return WN(this,A,e,t);case"base64":return zN(this,A,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ZN(this,A,e,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),n=!0}},GN.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ab=4096;function eb(A,e,t){var i="";t=Math.min(A.length,t);for(var o=e;oi)&&(t=i);for(var o="",n=e;nt)throw new RangeError("Trying to access beyond buffer length")}function rb(A,e,t,i,o,n){if(!xN(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||eA.length)throw new RangeError("Index out of range")}function sb(A,e,t,i){e<0&&(e=65535+e+1);for(var o=0,n=Math.min(A.length-t,2);o>>8*(i?o:1-o)}function ab(A,e,t,i){e<0&&(e=4294967295+e+1);for(var o=0,n=Math.min(A.length-t,4);o>>8*(i?o:3-o)&255}function gb(A,e,t,i,o,n){if(t+i>A.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function cb(A,e,t,i,o){return o||gb(A,0,t,4),RN(A,e,t,i,23,4),t+4}function lb(A,e,t,i,o){return o||gb(A,0,t,8),RN(A,e,t,i,52,8),t+8}GN.prototype.slice=function(A,e){var t,i=this.length;if((A=~~A)<0?(A+=i)<0&&(A=0):A>i&&(A=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e0&&(o*=256);)i+=this[A+--e]*o;return i},GN.prototype.readUInt8=function(A,e){return e||nb(A,1,this.length),this[A]},GN.prototype.readUInt16LE=function(A,e){return e||nb(A,2,this.length),this[A]|this[A+1]<<8},GN.prototype.readUInt16BE=function(A,e){return e||nb(A,2,this.length),this[A]<<8|this[A+1]},GN.prototype.readUInt32LE=function(A,e){return e||nb(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+16777216*this[A+3]},GN.prototype.readUInt32BE=function(A,e){return e||nb(A,4,this.length),16777216*this[A]+(this[A+1]<<16|this[A+2]<<8|this[A+3])},GN.prototype.readIntLE=function(A,e,t){A|=0,e|=0,t||nb(A,e,this.length);for(var i=this[A],o=1,n=0;++n=(o*=128)&&(i-=Math.pow(2,8*e)),i},GN.prototype.readIntBE=function(A,e,t){A|=0,e|=0,t||nb(A,e,this.length);for(var i=e,o=1,n=this[A+--i];i>0&&(o*=256);)n+=this[A+--i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},GN.prototype.readInt8=function(A,e){return e||nb(A,1,this.length),128&this[A]?-1*(255-this[A]+1):this[A]},GN.prototype.readInt16LE=function(A,e){e||nb(A,2,this.length);var t=this[A]|this[A+1]<<8;return 32768&t?4294901760|t:t},GN.prototype.readInt16BE=function(A,e){e||nb(A,2,this.length);var t=this[A+1]|this[A]<<8;return 32768&t?4294901760|t:t},GN.prototype.readInt32LE=function(A,e){return e||nb(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24},GN.prototype.readInt32BE=function(A,e){return e||nb(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]},GN.prototype.readFloatLE=function(A,e){return e||nb(A,4,this.length),MN(this,A,!0,23,4)},GN.prototype.readFloatBE=function(A,e){return e||nb(A,4,this.length),MN(this,A,!1,23,4)},GN.prototype.readDoubleLE=function(A,e){return e||nb(A,8,this.length),MN(this,A,!0,52,8)},GN.prototype.readDoubleBE=function(A,e){return e||nb(A,8,this.length),MN(this,A,!1,52,8)},GN.prototype.writeUIntLE=function(A,e,t,i){A=+A,e|=0,t|=0,i||rb(this,A,e,t,Math.pow(2,8*t)-1,0);var o=1,n=0;for(this[e]=255&A;++n=0&&(n*=256);)this[e+o]=A/n&255;return e+t},GN.prototype.writeUInt8=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,1,255,0),GN.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),this[e]=255&A,e+1},GN.prototype.writeUInt16LE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,2,65535,0),GN.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):sb(this,A,e,!0),e+2},GN.prototype.writeUInt16BE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,2,65535,0),GN.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):sb(this,A,e,!1),e+2},GN.prototype.writeUInt32LE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,4,4294967295,0),GN.TYPED_ARRAY_SUPPORT?(this[e+3]=A>>>24,this[e+2]=A>>>16,this[e+1]=A>>>8,this[e]=255&A):ab(this,A,e,!0),e+4},GN.prototype.writeUInt32BE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,4,4294967295,0),GN.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):ab(this,A,e,!1),e+4},GN.prototype.writeIntLE=function(A,e,t,i){if(A=+A,e|=0,!i){var o=Math.pow(2,8*t-1);rb(this,A,e,t,o-1,-o)}var n=0,r=1,s=0;for(this[e]=255&A;++n=0&&(r*=256);)A<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(A/r|0)-s&255;return e+t},GN.prototype.writeInt8=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,1,127,-128),GN.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),A<0&&(A=255+A+1),this[e]=255&A,e+1},GN.prototype.writeInt16LE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,2,32767,-32768),GN.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):sb(this,A,e,!0),e+2},GN.prototype.writeInt16BE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,2,32767,-32768),GN.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):sb(this,A,e,!1),e+2},GN.prototype.writeInt32LE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,4,2147483647,-2147483648),GN.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8,this[e+2]=A>>>16,this[e+3]=A>>>24):ab(this,A,e,!0),e+4},GN.prototype.writeInt32BE=function(A,e,t){return A=+A,e|=0,t||rb(this,A,e,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),GN.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):ab(this,A,e,!1),e+4},GN.prototype.writeFloatLE=function(A,e,t){return cb(this,A,e,!0,t)},GN.prototype.writeFloatBE=function(A,e,t){return cb(this,A,e,!1,t)},GN.prototype.writeDoubleLE=function(A,e,t){return lb(this,A,e,!0,t)},GN.prototype.writeDoubleBE=function(A,e,t){return lb(this,A,e,!1,t)},GN.prototype.copy=function(A,e,t,i){if(t||(t=0),i||0===i||(i=this.length),e>=A.length&&(e=A.length),e||(e=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),A.length-e=0;--o)A[o+e]=this[o+t];else if(n<1e3||!GN.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,t=void 0===t?this.length:t>>>0,A||(A=0),"number"==typeof A)for(n=e;n55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&n.push(239,191,189);continue}if(r+1===i){(e-=3)>-1&&n.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&n.push(239,191,189),o=t;continue}t=65536+(o-55296<<10|t-56320)}else o&&(e-=3)>-1&&n.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;n.push(t)}else if(t<2048){if((e-=2)<0)break;n.push(t>>6|192,63&t|128)}else if(t<65536){if((e-=3)<0)break;n.push(t>>12|224,t>>6&63|128,63&t|128)}else{if(!(t<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;n.push(t>>18|240,t>>12&63|128,t>>6&63|128,63&t|128)}}return n}function db(A){return function(A){var e,t,i,o,n,r;DN||vN();var s=A.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");n="="===A[s-2]?2:"="===A[s-1]?1:0,r=new yN(3*s/4-n),i=n>0?s-4:s;var a=0;for(e=0,t=0;e>16&255,r[a++]=o>>8&255,r[a++]=255&o;return 2===n?(o=mN[A.charCodeAt(e)]<<2|mN[A.charCodeAt(e+1)]>>4,r[a++]=255&o):1===n&&(o=mN[A.charCodeAt(e)]<<10|mN[A.charCodeAt(e+1)]<<4|mN[A.charCodeAt(e+2)]>>2,r[a++]=o>>8&255,r[a++]=255&o),r}(function(A){if((A=(e=A,e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(Ib,"")).length<2)return"";for(var e;A.length%4!=0;)A+="=";return A}(A))}function hb(A,e,t,i){for(var o=0;o=e.length||o>=A.length);++o)e[o+t]=A[o];return o}function Cb(A){return null!=A&&(!!A._isBuffer||Bb(A)||"function"==typeof(e=A).readFloatLE&&"function"==typeof e.slice&&Bb(e.slice(0,0)));var e}function Bb(A){return!!A.constructor&&"function"==typeof A.constructor.isBuffer&&A.constructor.isBuffer(A)}function Qb(A,e){return A(e={exports:{}},e.exports),e.exports}var pb=Qb(function(A,e){var t,i,o,n,r,s,a,g,c,l,I,u,E;A.exports=(t=t||(i=Math,o=Object.create||function(){function A(){}return function(e){var t;return A.prototype=e,t=new A,A.prototype=null,t}}(),r=(n={}).lib={},s=r.Base={extend:function(A){var e=o(this);return A&&e.mixIn(A),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var A=this.extend();return A.init.apply(A,arguments),A},init:function(){},mixIn:function(A){for(var e in A)A.hasOwnProperty(e)&&(this[e]=A[e]);A.hasOwnProperty("toString")&&(this.toString=A.toString)},clone:function(){return this.init.prototype.extend(this)}},a=r.WordArray=s.extend({init:function(A,e){A=this.words=A||[],this.sigBytes=null!=e?e:4*A.length},toString:function(A){return(A||c).stringify(this)},concat:function(A){var e=this.words,t=A.words,i=this.sigBytes,o=A.sigBytes;if(this.clamp(),i%4)for(var n=0;n>>2]>>>24-n%4*8&255;e[i+n>>>2]|=r<<24-(i+n)%4*8}else for(n=0;n>>2]=t[n>>>2];return this.sigBytes+=o,this},clamp:function(){var A=this.words,e=this.sigBytes;A[e>>>2]&=4294967295<<32-e%4*8,A.length=i.ceil(e/4)},clone:function(){var A=s.clone.call(this);return A.words=this.words.slice(0),A},random:function(A){for(var e,t=[],o=function(A){var e=987654321,t=4294967295;return function(){var o=((e=36969*(65535&e)+(e>>16)&t)<<16)+(A=18e3*(65535&A)+(A>>16)&t)&t;return o/=4294967296,(o+=.5)*(i.random()>.5?1:-1)}},n=0;n>>2]>>>24-o%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(A){for(var e=A.length,t=[],i=0;i>>3]|=parseInt(A.substr(i,2),16)<<24-i%8*4;return new a.init(t,e/2)}},l=g.Latin1={stringify:function(A){for(var e=A.words,t=A.sigBytes,i=[],o=0;o>>2]>>>24-o%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(A){for(var e=A.length,t=[],i=0;i>>2]|=(255&A.charCodeAt(i))<<24-i%4*8;return new a.init(t,e)}},I=g.Utf8={stringify:function(A){try{return decodeURIComponent(escape(l.stringify(A)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(A){return l.parse(unescape(encodeURIComponent(A)))}},u=r.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(A){"string"==typeof A&&(A=I.parse(A)),this._data.concat(A),this._nDataBytes+=A.sigBytes},_process:function(A){var e=this._data,t=e.words,o=e.sigBytes,n=this.blockSize,r=o/(4*n),s=(r=A?i.ceil(r):i.max((0|r)-this._minBufferSize,0))*n,g=i.min(4*s,o);if(s){for(var c=0;c>>2]|=A[o]<<24-o%4*8;e.call(this,i,t)}else e.apply(this,arguments)}).prototype=A}}(),t.lib.WordArray)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib.WordArray,i=A.enc;function o(A){return A<<8&4278255360|A>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(A){for(var e=A.words,t=A.sigBytes,i=[],o=0;o>>2]>>>16-o%4*8&65535;i.push(String.fromCharCode(n))}return i.join("")},parse:function(A){for(var t=A.length,i=[],o=0;o>>1]|=A.charCodeAt(o)<<16-o%2*16;return e.create(i,2*t)}},i.Utf16LE={stringify:function(A){for(var e=A.words,t=A.sigBytes,i=[],n=0;n>>2]>>>16-n%4*8&65535);i.push(String.fromCharCode(r))}return i.join("")},parse:function(A){for(var t=A.length,i=[],n=0;n>>1]|=o(A.charCodeAt(n)<<16-n%2*16);return e.create(i,2*t)}}}(),t.enc.Utf16)}),Qb(function(A,e){var t,i,o;A.exports=(o=(i=t=pb).lib.WordArray,i.enc.Base64={stringify:function(A){var e=A.words,t=A.sigBytes,i=this._map;A.clamp();for(var o=[],n=0;n>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,s=0;s<4&&n+.75*s>>6*(3-s)&63));var a=i.charAt(64);if(a)for(;o.length%4;)o.push(a);return o.join("")},parse:function(A){var e=A.length,t=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var n=0;n>>6-r%4*2;i[n>>>2]|=(s|a)<<24-n%4*8,n++}return o.create(i,n)}(A,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},t.enc.Base64)}),Qb(function(A,e){var t;A.exports=(t=pb,function(A){var e=t,i=e.lib,o=i.WordArray,n=i.Hasher,r=e.algo,s=[];!function(){for(var e=0;e<64;e++)s[e]=4294967296*A.abs(A.sin(e+1))|0}();var a=r.MD5=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var i=e+t,o=A[i];A[i]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var n=this._hash.words,r=A[e+0],a=A[e+1],u=A[e+2],E=A[e+3],d=A[e+4],h=A[e+5],C=A[e+6],B=A[e+7],Q=A[e+8],p=A[e+9],f=A[e+10],m=A[e+11],y=A[e+12],D=A[e+13],v=A[e+14],w=A[e+15],S=n[0],M=n[1],R=n[2],_=n[3];S=g(S,M,R,_,r,7,s[0]),_=g(_,S,M,R,a,12,s[1]),R=g(R,_,S,M,u,17,s[2]),M=g(M,R,_,S,E,22,s[3]),S=g(S,M,R,_,d,7,s[4]),_=g(_,S,M,R,h,12,s[5]),R=g(R,_,S,M,C,17,s[6]),M=g(M,R,_,S,B,22,s[7]),S=g(S,M,R,_,Q,7,s[8]),_=g(_,S,M,R,p,12,s[9]),R=g(R,_,S,M,f,17,s[10]),M=g(M,R,_,S,m,22,s[11]),S=g(S,M,R,_,y,7,s[12]),_=g(_,S,M,R,D,12,s[13]),R=g(R,_,S,M,v,17,s[14]),S=c(S,M=g(M,R,_,S,w,22,s[15]),R,_,a,5,s[16]),_=c(_,S,M,R,C,9,s[17]),R=c(R,_,S,M,m,14,s[18]),M=c(M,R,_,S,r,20,s[19]),S=c(S,M,R,_,h,5,s[20]),_=c(_,S,M,R,f,9,s[21]),R=c(R,_,S,M,w,14,s[22]),M=c(M,R,_,S,d,20,s[23]),S=c(S,M,R,_,p,5,s[24]),_=c(_,S,M,R,v,9,s[25]),R=c(R,_,S,M,E,14,s[26]),M=c(M,R,_,S,Q,20,s[27]),S=c(S,M,R,_,D,5,s[28]),_=c(_,S,M,R,u,9,s[29]),R=c(R,_,S,M,B,14,s[30]),S=l(S,M=c(M,R,_,S,y,20,s[31]),R,_,h,4,s[32]),_=l(_,S,M,R,Q,11,s[33]),R=l(R,_,S,M,m,16,s[34]),M=l(M,R,_,S,v,23,s[35]),S=l(S,M,R,_,a,4,s[36]),_=l(_,S,M,R,d,11,s[37]),R=l(R,_,S,M,B,16,s[38]),M=l(M,R,_,S,f,23,s[39]),S=l(S,M,R,_,D,4,s[40]),_=l(_,S,M,R,r,11,s[41]),R=l(R,_,S,M,E,16,s[42]),M=l(M,R,_,S,C,23,s[43]),S=l(S,M,R,_,p,4,s[44]),_=l(_,S,M,R,y,11,s[45]),R=l(R,_,S,M,w,16,s[46]),S=I(S,M=l(M,R,_,S,u,23,s[47]),R,_,r,6,s[48]),_=I(_,S,M,R,B,10,s[49]),R=I(R,_,S,M,v,15,s[50]),M=I(M,R,_,S,h,21,s[51]),S=I(S,M,R,_,y,6,s[52]),_=I(_,S,M,R,E,10,s[53]),R=I(R,_,S,M,f,15,s[54]),M=I(M,R,_,S,a,21,s[55]),S=I(S,M,R,_,Q,6,s[56]),_=I(_,S,M,R,w,10,s[57]),R=I(R,_,S,M,C,15,s[58]),M=I(M,R,_,S,D,21,s[59]),S=I(S,M,R,_,d,6,s[60]),_=I(_,S,M,R,m,10,s[61]),R=I(R,_,S,M,u,15,s[62]),M=I(M,R,_,S,p,21,s[63]),n[0]=n[0]+S|0,n[1]=n[1]+M|0,n[2]=n[2]+R|0,n[3]=n[3]+_|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,o=8*e.sigBytes;t[o>>>5]|=128<<24-o%32;var n=A.floor(i/4294967296),r=i;t[15+(o+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,a=s.words,g=0;g<4;g++){var c=a[g];a[g]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return s},clone:function(){var A=n.clone.call(this);return A._hash=this._hash.clone(),A}});function g(A,e,t,i,o,n,r){var s=A+(e&t|~e&i)+o+r;return(s<>>32-n)+e}function c(A,e,t,i,o,n,r){var s=A+(e&i|t&~i)+o+r;return(s<>>32-n)+e}function l(A,e,t,i,o,n,r){var s=A+(e^t^i)+o+r;return(s<>>32-n)+e}function I(A,e,t,i,o,n,r){var s=A+(t^(e|~i))+o+r;return(s<>>32-n)+e}e.MD5=n._createHelper(a),e.HmacMD5=n._createHmacHelper(a)}(Math),t.MD5)}),Qb(function(A,e){var t,i,o,n,r,s,a,g;A.exports=(o=(i=t=pb).lib,n=o.WordArray,r=o.Hasher,s=i.algo,a=[],g=s.SHA1=r.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=this._hash.words,i=t[0],o=t[1],n=t[2],r=t[3],s=t[4],g=0;g<80;g++){if(g<16)a[g]=0|A[e+g];else{var c=a[g-3]^a[g-8]^a[g-14]^a[g-16];a[g]=c<<1|c>>>31}var l=(i<<5|i>>>27)+s+a[g];l+=g<20?1518500249+(o&n|~o&r):g<40?1859775393+(o^n^r):g<60?(o&n|o&r|n&r)-1894007588:(o^n^r)-899497514,s=r,r=n,n=o<<30|o>>>2,o=i,i=l}t[0]=t[0]+i|0,t[1]=t[1]+o|0,t[2]=t[2]+n|0,t[3]=t[3]+r|0,t[4]=t[4]+s|0},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,i=8*A.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(t/4294967296),e[15+(i+64>>>9<<4)]=t,A.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var A=r.clone.call(this);return A._hash=this._hash.clone(),A}}),i.SHA1=r._createHelper(g),i.HmacSHA1=r._createHmacHelper(g),t.SHA1)}),Qb(function(A,e){var t;A.exports=(t=pb,function(A){var e=t,i=e.lib,o=i.WordArray,n=i.Hasher,r=e.algo,s=[],a=[];!function(){function e(e){for(var t=A.sqrt(e),i=2;i<=t;i++)if(!(e%i))return!1;return!0}function t(A){return 4294967296*(A-(0|A))|0}for(var i=2,o=0;o<64;)e(i)&&(o<8&&(s[o]=t(A.pow(i,.5))),a[o]=t(A.pow(i,1/3)),o++),i++}();var g=[],c=r.SHA256=n.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(A,e){for(var t=this._hash.words,i=t[0],o=t[1],n=t[2],r=t[3],s=t[4],c=t[5],l=t[6],I=t[7],u=0;u<64;u++){if(u<16)g[u]=0|A[e+u];else{var E=g[u-15],d=(E<<25|E>>>7)^(E<<14|E>>>18)^E>>>3,h=g[u-2],C=(h<<15|h>>>17)^(h<<13|h>>>19)^h>>>10;g[u]=d+g[u-7]+C+g[u-16]}var B=i&o^i&n^o&n,Q=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),p=I+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&c^~s&l)+a[u]+g[u];I=l,l=c,c=s,s=r+p|0,r=n,n=o,o=i,i=p+(Q+B)|0}t[0]=t[0]+i|0,t[1]=t[1]+o|0,t[2]=t[2]+n|0,t[3]=t[3]+r|0,t[4]=t[4]+s|0,t[5]=t[5]+c|0,t[6]=t[6]+l|0,t[7]=t[7]+I|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=A.floor(i/4294967296),t[15+(o+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var A=n.clone.call(this);return A._hash=this._hash.clone(),A}});e.SHA256=n._createHelper(c),e.HmacSHA256=n._createHmacHelper(c)}(Math),t.SHA256)}),Qb(function(A,e){var t,i,o,n,r,s;A.exports=(o=(i=t=pb).lib.WordArray,n=i.algo,r=n.SHA256,s=n.SHA224=r.extend({_doReset:function(){this._hash=new o.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var A=r._doFinalize.call(this);return A.sigBytes-=4,A}}),i.SHA224=r._createHelper(s),i.HmacSHA224=r._createHmacHelper(s),t.SHA224)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib.Hasher,i=A.x64,o=i.Word,n=i.WordArray,r=A.algo;function s(){return o.create.apply(o,arguments)}var a=[s(1116352408,3609767458),s(1899447441,602891725),s(3049323471,3964484399),s(3921009573,2173295548),s(961987163,4081628472),s(1508970993,3053834265),s(2453635748,2937671579),s(2870763221,3664609560),s(3624381080,2734883394),s(310598401,1164996542),s(607225278,1323610764),s(1426881987,3590304994),s(1925078388,4068182383),s(2162078206,991336113),s(2614888103,633803317),s(3248222580,3479774868),s(3835390401,2666613458),s(4022224774,944711139),s(264347078,2341262773),s(604807628,2007800933),s(770255983,1495990901),s(1249150122,1856431235),s(1555081692,3175218132),s(1996064986,2198950837),s(2554220882,3999719339),s(2821834349,766784016),s(2952996808,2566594879),s(3210313671,3203337956),s(3336571891,1034457026),s(3584528711,2466948901),s(113926993,3758326383),s(338241895,168717936),s(666307205,1188179964),s(773529912,1546045734),s(1294757372,1522805485),s(1396182291,2643833823),s(1695183700,2343527390),s(1986661051,1014477480),s(2177026350,1206759142),s(2456956037,344077627),s(2730485921,1290863460),s(2820302411,3158454273),s(3259730800,3505952657),s(3345764771,106217008),s(3516065817,3606008344),s(3600352804,1432725776),s(4094571909,1467031594),s(275423344,851169720),s(430227734,3100823752),s(506948616,1363258195),s(659060556,3750685593),s(883997877,3785050280),s(958139571,3318307427),s(1322822218,3812723403),s(1537002063,2003034995),s(1747873779,3602036899),s(1955562222,1575990012),s(2024104815,1125592928),s(2227730452,2716904306),s(2361852424,442776044),s(2428436474,593698344),s(2756734187,3733110249),s(3204031479,2999351573),s(3329325298,3815920427),s(3391569614,3928383900),s(3515267271,566280711),s(3940187606,3454069534),s(4118630271,4000239992),s(116418474,1914138554),s(174292421,2731055270),s(289380356,3203993006),s(460393269,320620315),s(685471733,587496836),s(852142971,1086792851),s(1017036298,365543100),s(1126000580,2618297676),s(1288033470,3409855158),s(1501505948,4234509866),s(1607167915,987167468),s(1816402316,1246189591)],g=[];!function(){for(var A=0;A<80;A++)g[A]=s()}();var c=r.SHA512=e.extend({_doReset:function(){this._hash=new n.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(A,e){for(var t=this._hash.words,i=t[0],o=t[1],n=t[2],r=t[3],s=t[4],c=t[5],l=t[6],I=t[7],u=i.high,E=i.low,d=o.high,h=o.low,C=n.high,B=n.low,Q=r.high,p=r.low,f=s.high,m=s.low,y=c.high,D=c.low,v=l.high,w=l.low,S=I.high,M=I.low,R=u,_=E,T=d,N=h,b=C,G=B,k=Q,L=p,U=f,F=m,O=y,x=D,P=v,Y=w,J=S,H=M,q=0;q<80;q++){var V=g[q];if(q<16)var j=V.high=0|A[e+2*q],K=V.low=0|A[e+2*q+1];else{var W=g[q-15],z=W.high,Z=W.low,X=(z>>>1|Z<<31)^(z>>>8|Z<<24)^z>>>7,$=(Z>>>1|z<<31)^(Z>>>8|z<<24)^(Z>>>7|z<<25),AA=g[q-2],eA=AA.high,tA=AA.low,iA=(eA>>>19|tA<<13)^(eA<<3|tA>>>29)^eA>>>6,oA=(tA>>>19|eA<<13)^(tA<<3|eA>>>29)^(tA>>>6|eA<<26),nA=g[q-7],rA=nA.high,sA=nA.low,aA=g[q-16],gA=aA.high,cA=aA.low;j=(j=(j=X+rA+((K=$+sA)>>>0<$>>>0?1:0))+iA+((K+=oA)>>>0>>0?1:0))+gA+((K+=cA)>>>0>>0?1:0),V.high=j,V.low=K}var lA,IA=U&O^~U&P,uA=F&x^~F&Y,EA=R&T^R&b^T&b,dA=_&N^_&G^N&G,hA=(R>>>28|_<<4)^(R<<30|_>>>2)^(R<<25|_>>>7),CA=(_>>>28|R<<4)^(_<<30|R>>>2)^(_<<25|R>>>7),BA=(U>>>14|F<<18)^(U>>>18|F<<14)^(U<<23|F>>>9),QA=(F>>>14|U<<18)^(F>>>18|U<<14)^(F<<23|U>>>9),pA=a[q],fA=pA.high,mA=pA.low,yA=J+BA+((lA=H+QA)>>>0>>0?1:0),DA=CA+dA;J=P,H=Y,P=O,Y=x,O=U,x=F,U=k+(yA=(yA=(yA=yA+IA+((lA+=uA)>>>0>>0?1:0))+fA+((lA+=mA)>>>0>>0?1:0))+j+((lA+=K)>>>0>>0?1:0))+((F=L+lA|0)>>>0>>0?1:0)|0,k=b,L=G,b=T,G=N,T=R,N=_,R=yA+(hA+EA+(DA>>>0>>0?1:0))+((_=lA+DA|0)>>>0>>0?1:0)|0}E=i.low=E+_,i.high=u+R+(E>>>0<_>>>0?1:0),h=o.low=h+N,o.high=d+T+(h>>>0>>0?1:0),B=n.low=B+G,n.high=C+b+(B>>>0>>0?1:0),p=r.low=p+L,r.high=Q+k+(p>>>0>>0?1:0),m=s.low=m+F,s.high=f+U+(m>>>0>>0?1:0),D=c.low=D+x,c.high=y+O+(D>>>0>>0?1:0),w=l.low=w+Y,l.high=v+P+(w>>>0>>0?1:0),M=I.low=M+H,I.high=S+J+(M>>>0>>0?1:0)},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,i=8*A.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(t/4294967296),e[31+(i+128>>>10<<5)]=t,A.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var A=e.clone.call(this);return A._hash=this._hash.clone(),A},blockSize:32});A.SHA512=e._createHelper(c),A.HmacSHA512=e._createHmacHelper(c)}(),t.SHA512)}),Qb(function(A,e){var t,i,o,n,r,s,a,g;A.exports=(o=(i=t=pb).x64,n=o.Word,r=o.WordArray,s=i.algo,a=s.SHA512,g=s.SHA384=a.extend({_doReset:function(){this._hash=new r.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var A=a._doFinalize.call(this);return A.sigBytes-=16,A}}),i.SHA384=a._createHelper(g),i.HmacSHA384=a._createHmacHelper(g),t.SHA384)}),Qb(function(A,e){var t;A.exports=(t=pb,function(A){var e=t,i=e.lib,o=i.WordArray,n=i.Hasher,r=e.x64.Word,s=e.algo,a=[],g=[],c=[];!function(){for(var A=1,e=0,t=0;t<24;t++){a[A+5*e]=(t+1)*(t+2)/2%64;var i=(2*A+3*e)%5;A=e%5,e=i}for(A=0;A<5;A++)for(e=0;e<5;e++)g[A+5*e]=e+(2*A+3*e)%5*5;for(var o=1,n=0;n<24;n++){for(var s=0,l=0,I=0;I<7;I++){if(1&o){var u=(1<>>24)|4278255360&(n<<24|n>>>8),r=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),(M=t[o]).high^=r,M.low^=n}for(var s=0;s<24;s++){for(var I=0;I<5;I++){for(var u=0,E=0,d=0;d<5;d++)u^=(M=t[I+5*d]).high,E^=M.low;var h=l[I];h.high=u,h.low=E}for(I=0;I<5;I++){var C=l[(I+4)%5],B=l[(I+1)%5],Q=B.high,p=B.low;for(u=C.high^(Q<<1|p>>>31),E=C.low^(p<<1|Q>>>31),d=0;d<5;d++)(M=t[I+5*d]).high^=u,M.low^=E}for(var f=1;f<25;f++){var m=(M=t[f]).high,y=M.low,D=a[f];D<32?(u=m<>>32-D,E=y<>>32-D):(u=y<>>64-D,E=m<>>64-D);var v=l[g[f]];v.high=u,v.low=E}var w=l[0],S=t[0];for(w.high=S.high,w.low=S.low,I=0;I<5;I++)for(d=0;d<5;d++){var M=t[f=I+5*d],R=l[f],_=l[(I+1)%5+5*d],T=l[(I+2)%5+5*d];M.high=R.high^~_.high&T.high,M.low=R.low^~_.low&T.low}M=t[0];var N=c[s];M.high^=N.high,M.low^=N.low}},_doFinalize:function(){var e=this._data,t=e.words,i=(this._nDataBytes,8*e.sigBytes),n=32*this.blockSize;t[i>>>5]|=1<<24-i%32,t[(A.ceil((i+1)/n)*n>>>5)-1]|=128,e.sigBytes=4*t.length,this._process();for(var r=this._state,s=this.cfg.outputLength/8,a=s/8,g=[],c=0;c>>24)|4278255360&(I<<24|I>>>8),u=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),g.push(u),g.push(I)}return new o.init(g,s)},clone:function(){for(var A=n.clone.call(this),e=A._state=this._state.slice(0),t=0;t<25;t++)e[t]=e[t].clone();return A}});e.SHA3=n._createHelper(I),e.HmacSHA3=n._createHmacHelper(I)}(Math),t.SHA3)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib,i=e.WordArray,o=e.Hasher,n=A.algo,r=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),g=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),c=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),I=n.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var i=e+t,o=A[i];A[i]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var n,I,Q,p,f,m,y,D,v,w,S,M=this._hash.words,R=c.words,_=l.words,T=r.words,N=s.words,b=a.words,G=g.words;for(m=n=M[0],y=I=M[1],D=Q=M[2],v=p=M[3],w=f=M[4],t=0;t<80;t+=1)S=n+A[e+T[t]]|0,S+=t<16?u(I,Q,p)+R[0]:t<32?E(I,Q,p)+R[1]:t<48?d(I,Q,p)+R[2]:t<64?h(I,Q,p)+R[3]:C(I,Q,p)+R[4],S=(S=B(S|=0,b[t]))+f|0,n=f,f=p,p=B(Q,10),Q=I,I=S,S=m+A[e+N[t]]|0,S+=t<16?C(y,D,v)+_[0]:t<32?h(y,D,v)+_[1]:t<48?d(y,D,v)+_[2]:t<64?E(y,D,v)+_[3]:u(y,D,v)+_[4],S=(S=B(S|=0,G[t]))+w|0,m=w,w=v,v=B(D,10),D=y,y=S;S=M[1]+Q+v|0,M[1]=M[2]+p+w|0,M[2]=M[3]+f+m|0,M[3]=M[4]+n+y|0,M[4]=M[0]+I+D|0,M[0]=S},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,i=8*A.sigBytes;e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8),A.sigBytes=4*(e.length+1),this._process();for(var o=this._hash,n=o.words,r=0;r<5;r++){var s=n[r];n[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return o},clone:function(){var A=o.clone.call(this);return A._hash=this._hash.clone(),A}});function u(A,e,t){return A^e^t}function E(A,e,t){return A&e|~A&t}function d(A,e,t){return(A|~e)^t}function h(A,e,t){return A&t|e&~t}function C(A,e,t){return A^(e|~t)}function B(A,e){return A<>>32-e}A.RIPEMD160=o._createHelper(I),A.HmacRIPEMD160=o._createHmacHelper(I)}(),t.RIPEMD160)}),Qb(function(A,e){var t,i,o,n;A.exports=(i=(t=pb).lib.Base,o=t.enc,n=o.Utf8,void(t.algo.HMAC=i.extend({init:function(A,e){A=this._hasher=new A.init,"string"==typeof e&&(e=n.parse(e));var t=A.blockSize,i=4*t;e.sigBytes>i&&(e=A.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),r=this._iKey=e.clone(),s=o.words,a=r.words,g=0;g>>2];A.sigBytes-=e}},o.BlockCipher=I.extend({cfg:I.cfg.extend({mode:d,padding:C}),reset:function(){I.reset.call(this);var A=this.cfg,e=A.iv,t=A.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=t.createEncryptor;else{i=t.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==i?this._mode.init(this,e&&e.words):(this._mode=i.call(t,this,e&&e.words),this._mode.__creator=i)},_doProcessBlock:function(A,e){this._mode.processBlock(A,e)},_doFinalize:function(){var A=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){A.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);A.unpad(e)}return e},blockSize:4}),B=o.CipherParams=n.extend({init:function(A){this.mixIn(A)},toString:function(A){return(A||this.formatter).stringify(this)}}),Q=i.format={},p=Q.OpenSSL={stringify:function(A){var e=A.ciphertext,t=A.salt;if(t)var i=r.create([1398893684,1701076831]).concat(t).concat(e);else i=e;return i.toString(g)},parse:function(A){var e=g.parse(A),t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var i=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return B.create({ciphertext:e,salt:i})}},f=o.SerializableCipher=n.extend({cfg:n.extend({format:p}),encrypt:function(A,e,t,i){i=this.cfg.extend(i);var o=A.createEncryptor(t,i),n=o.finalize(e),r=o.cfg;return B.create({ciphertext:n,key:t,iv:r.iv,algorithm:A,mode:r.mode,padding:r.padding,blockSize:A.blockSize,formatter:i.format})},decrypt:function(A,e,t,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),A.createDecryptor(t,i).finalize(e.ciphertext)},_parse:function(A,e){return"string"==typeof A?e.parse(A,this):A}}),m=i.kdf={},y=m.OpenSSL={execute:function(A,e,t,i){i||(i=r.random(8));var o=l.create({keySize:e+t}).compute(A,i),n=r.create(o.words.slice(e),4*t);return o.sigBytes=4*e,B.create({key:o,iv:n,salt:i})}},D=o.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:y}),encrypt:function(A,e,t,i){var o=(i=this.cfg.extend(i)).kdf.execute(t,A.keySize,A.ivSize);i.iv=o.iv;var n=f.encrypt.call(this,A,e,o.key,i);return n.mixIn(o),n},decrypt:function(A,e,t,i){i=this.cfg.extend(i),e=this._parse(e,i.format);var o=i.kdf.execute(t,A.keySize,A.ivSize,e.salt);return i.iv=o.iv,f.decrypt.call(this,A,e,o.key,i)}})))}),Qb(function(A,e){var t;A.exports=((t=pb).mode.CFB=function(){var A=t.lib.BlockCipherMode.extend();function e(A,e,t,i){var o=this._iv;if(o){var n=o.slice(0);this._iv=void 0}else n=this._prevBlock;i.encryptBlock(n,0);for(var r=0;r>24))A+=1<<24;else{var e=A>>16&255,t=A>>8&255,i=255&A;255===e?(e=0,255===t?(t=0,255===i?i=0:++i):++t):++e,A=0,A+=e<<16,A+=t<<8,A+=i}return A}var i=A.Encryptor=A.extend({processBlock:function(A,t){var i,o=this._cipher,n=o.blockSize,r=this._iv,s=this._counter;r&&(s=this._counter=r.slice(0),this._iv=void 0),0===((i=s)[0]=e(i[0]))&&(i[1]=e(i[1]));var a=s.slice(0);o.encryptBlock(a,0);for(var g=0;g>>2]|=o<<24-n%4*8,A.sigBytes+=o},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},t.pad.Ansix923)}),Qb(function(A,e){var t;A.exports=((t=pb).pad.Iso10126={pad:function(A,e){var i=4*e,o=i-A.sigBytes%i;A.concat(t.lib.WordArray.random(o-1)).concat(t.lib.WordArray.create([o<<24],1))},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},t.pad.Iso10126)}),Qb(function(A,e){var t;A.exports=((t=pb).pad.Iso97971={pad:function(A,e){A.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(A,e)},unpad:function(A){t.pad.ZeroPadding.unpad(A),A.sigBytes--}},t.pad.Iso97971)}),Qb(function(A,e){var t;A.exports=((t=pb).pad.ZeroPadding={pad:function(A,e){var t=4*e;A.clamp(),A.sigBytes+=t-(A.sigBytes%t||t)},unpad:function(A){for(var e=A.words,t=A.sigBytes-1;!(e[t>>>2]>>>24-t%4*8&255);)t--;A.sigBytes=t+1}},t.pad.ZeroPadding)}),Qb(function(A,e){var t;A.exports=((t=pb).pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding)}),Qb(function(A,e){var t,i,o,n;A.exports=(o=(i=t=pb).lib.CipherParams,n=i.enc.Hex,i.format.Hex={stringify:function(A){return A.ciphertext.toString(n)},parse:function(A){var e=n.parse(A);return o.create({ciphertext:e})}},t.format.Hex)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib.BlockCipher,i=A.algo,o=[],n=[],r=[],s=[],a=[],g=[],c=[],l=[],I=[],u=[];!function(){for(var A=[],e=0;e<256;e++)A[e]=e<128?e<<1:e<<1^283;var t=0,i=0;for(e=0;e<256;e++){var E=i^i<<1^i<<2^i<<3^i<<4;E=E>>>8^255&E^99,o[t]=E,n[E]=t;var d=A[t],h=A[d],C=A[h],B=257*A[E]^16843008*E;r[t]=B<<24|B>>>8,s[t]=B<<16|B>>>16,a[t]=B<<8|B>>>24,g[t]=B,B=16843009*C^65537*h^257*d^16843008*t,c[E]=B<<24|B>>>8,l[E]=B<<16|B>>>16,I[E]=B<<8|B>>>24,u[E]=B,t?(t=d^A[A[A[C^d]]],i^=A[A[i]]):t=i=1}}();var E=[0,1,2,4,8,16,32,64,128,27,54],d=i.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var A=this._keyPriorReset=this._key,e=A.words,t=A.sigBytes/4,i=4*((this._nRounds=t+6)+1),n=this._keySchedule=[],r=0;r6&&r%t==4&&(s=o[s>>>24]<<24|o[s>>>16&255]<<16|o[s>>>8&255]<<8|o[255&s]):(s=o[(s=s<<8|s>>>24)>>>24]<<24|o[s>>>16&255]<<16|o[s>>>8&255]<<8|o[255&s],s^=E[r/t|0]<<24),n[r]=n[r-t]^s}for(var a=this._invKeySchedule=[],g=0;g>>24]]^l[o[s>>>16&255]]^I[o[s>>>8&255]]^u[o[255&s]]}},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._keySchedule,r,s,a,g,o)},decryptBlock:function(A,e){var t=A[e+1];A[e+1]=A[e+3],A[e+3]=t,this._doCryptBlock(A,e,this._invKeySchedule,c,l,I,u,n),t=A[e+1],A[e+1]=A[e+3],A[e+3]=t},_doCryptBlock:function(A,e,t,i,o,n,r,s){for(var a=this._nRounds,g=A[e]^t[0],c=A[e+1]^t[1],l=A[e+2]^t[2],I=A[e+3]^t[3],u=4,E=1;E>>24]^o[c>>>16&255]^n[l>>>8&255]^r[255&I]^t[u++],h=i[c>>>24]^o[l>>>16&255]^n[I>>>8&255]^r[255&g]^t[u++],C=i[l>>>24]^o[I>>>16&255]^n[g>>>8&255]^r[255&c]^t[u++],B=i[I>>>24]^o[g>>>16&255]^n[c>>>8&255]^r[255&l]^t[u++];g=d,c=h,l=C,I=B}d=(s[g>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&I])^t[u++],h=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[I>>>8&255]<<8|s[255&g])^t[u++],C=(s[l>>>24]<<24|s[I>>>16&255]<<16|s[g>>>8&255]<<8|s[255&c])^t[u++],B=(s[I>>>24]<<24|s[g>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^t[u++],A[e]=d,A[e+1]=h,A[e+2]=C,A[e+3]=B},keySize:8});A.AES=e._createHelper(d)}(),t.AES)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib,i=e.WordArray,o=e.BlockCipher,n=A.algo,r=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],s=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],a=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],g=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=n.DES=o.extend({_doReset:function(){for(var A=this._key.words,e=[],t=0;t<56;t++){var i=r[t]-1;e[t]=A[i>>>5]>>>31-i%32&1}for(var o=this._subKeys=[],n=0;n<16;n++){var g=o[n]=[],c=a[n];for(t=0;t<24;t++)g[t/6|0]|=e[(s[t]-1+c)%28]<<31-t%6,g[4+(t/6|0)]|=e[28+(s[t+24]-1+c)%28]<<31-t%6;for(g[0]=g[0]<<1|g[0]>>>31,t=1;t<7;t++)g[t]=g[t]>>>4*(t-1)+3;g[7]=g[7]<<5|g[7]>>>27}var l=this._invSubKeys=[];for(t=0;t<16;t++)l[t]=o[15-t]},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._subKeys)},decryptBlock:function(A,e){this._doCryptBlock(A,e,this._invSubKeys)},_doCryptBlock:function(A,e,t){this._lBlock=A[e],this._rBlock=A[e+1],I.call(this,4,252645135),I.call(this,16,65535),u.call(this,2,858993459),u.call(this,8,16711935),I.call(this,1,1431655765);for(var i=0;i<16;i++){for(var o=t[i],n=this._lBlock,r=this._rBlock,s=0,a=0;a<8;a++)s|=g[a][((r^o[a])&c[a])>>>0];this._lBlock=r,this._rBlock=n^s}var l=this._lBlock;this._lBlock=this._rBlock,this._rBlock=l,I.call(this,1,1431655765),u.call(this,8,16711935),u.call(this,2,858993459),I.call(this,16,65535),I.call(this,4,252645135),A[e]=this._lBlock,A[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function I(A,e){var t=(this._lBlock>>>A^this._rBlock)&e;this._rBlock^=t,this._lBlock^=t<>>A^this._lBlock)&e;this._lBlock^=t,this._rBlock^=t<>>2]>>>24-r%4*8&255;n=(n+i[o]+s)%256;var a=i[o];i[o]=i[n],i[n]=a}this._i=this._j=0},_doProcessBlock:function(A,e){A[e]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var A=this._S,e=this._i,t=this._j,i=0,o=0;o<4;o++){t=(t+A[e=(e+1)%256])%256;var n=A[e];A[e]=A[t],A[t]=n,i|=A[(A[e]+A[t])%256]<<24-8*o}return this._i=e,this._j=t,i}A.RC4=e._createHelper(o);var r=i.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var A=this.cfg.drop;A>0;A--)n.call(this)}});A.RC4Drop=e._createHelper(r)}(),t.RC4)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib.StreamCipher,i=A.algo,o=[],n=[],r=[],s=i.Rabbit=e.extend({_doReset:function(){for(var A=this._key.words,e=this.cfg.iv,t=0;t<4;t++)A[t]=16711935&(A[t]<<8|A[t]>>>24)|4278255360&(A[t]<<24|A[t]>>>8);var i=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],o=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];for(this._b=0,t=0;t<4;t++)a.call(this);for(t=0;t<8;t++)o[t]^=i[t+4&7];if(e){var n=e.words,r=n[0],s=n[1],g=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=g>>>16|4294901760&c,I=c<<16|65535&g;for(o[0]^=g,o[1]^=l,o[2]^=c,o[3]^=I,o[4]^=g,o[5]^=l,o[6]^=c,o[7]^=I,t=0;t<4;t++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),o[0]=t[0]^t[5]>>>16^t[3]<<16,o[1]=t[2]^t[7]>>>16^t[5]<<16,o[2]=t[4]^t[1]>>>16^t[7]<<16,o[3]=t[6]^t[3]>>>16^t[1]<<16;for(var i=0;i<4;i++)o[i]=16711935&(o[i]<<8|o[i]>>>24)|4278255360&(o[i]<<24|o[i]>>>8),A[e+i]^=o[i]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)n[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0,t=0;t<8;t++){var i=A[t]+e[t],o=65535&i,s=i>>>16,a=((o*o>>>17)+o*s>>>15)+s*s,g=((4294901760&i)*i|0)+((65535&i)*i|0);r[t]=a^g}A[0]=r[0]+(r[7]<<16|r[7]>>>16)+(r[6]<<16|r[6]>>>16)|0,A[1]=r[1]+(r[0]<<8|r[0]>>>24)+r[7]|0,A[2]=r[2]+(r[1]<<16|r[1]>>>16)+(r[0]<<16|r[0]>>>16)|0,A[3]=r[3]+(r[2]<<8|r[2]>>>24)+r[1]|0,A[4]=r[4]+(r[3]<<16|r[3]>>>16)+(r[2]<<16|r[2]>>>16)|0,A[5]=r[5]+(r[4]<<8|r[4]>>>24)+r[3]|0,A[6]=r[6]+(r[5]<<16|r[5]>>>16)+(r[4]<<16|r[4]>>>16)|0,A[7]=r[7]+(r[6]<<8|r[6]>>>24)+r[5]|0}A.Rabbit=e._createHelper(s)}(),t.Rabbit)}),Qb(function(A,e){var t;A.exports=(t=pb,function(){var A=t,e=A.lib.StreamCipher,i=A.algo,o=[],n=[],r=[],s=i.RabbitLegacy=e.extend({_doReset:function(){var A=this._key.words,e=this.cfg.iv,t=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],i=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];this._b=0;for(var o=0;o<4;o++)a.call(this);for(o=0;o<8;o++)i[o]^=t[o+4&7];if(e){var n=e.words,r=n[0],s=n[1],g=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=g>>>16|4294901760&c,I=c<<16|65535&g;for(i[0]^=g,i[1]^=l,i[2]^=c,i[3]^=I,i[4]^=g,i[5]^=l,i[6]^=c,i[7]^=I,o=0;o<4;o++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),o[0]=t[0]^t[5]>>>16^t[3]<<16,o[1]=t[2]^t[7]>>>16^t[5]<<16,o[2]=t[4]^t[1]>>>16^t[7]<<16,o[3]=t[6]^t[3]>>>16^t[1]<<16;for(var i=0;i<4;i++)o[i]=16711935&(o[i]<<8|o[i]>>>24)|4278255360&(o[i]<<24|o[i]>>>8),A[e+i]^=o[i]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)n[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0,t=0;t<8;t++){var i=A[t]+e[t],o=65535&i,s=i>>>16,a=((o*o>>>17)+o*s>>>15)+s*s,g=((4294901760&i)*i|0)+((65535&i)*i|0);r[t]=a^g}A[0]=r[0]+(r[7]<<16|r[7]>>>16)+(r[6]<<16|r[6]>>>16)|0,A[1]=r[1]+(r[0]<<8|r[0]>>>24)+r[7]|0,A[2]=r[2]+(r[1]<<16|r[1]>>>16)+(r[0]<<16|r[0]>>>16)|0,A[3]=r[3]+(r[2]<<8|r[2]>>>24)+r[1]|0,A[4]=r[4]+(r[3]<<16|r[3]>>>16)+(r[2]<<16|r[2]>>>16)|0,A[5]=r[5]+(r[4]<<8|r[4]>>>24)+r[3]|0,A[6]=r[6]+(r[5]<<16|r[5]>>>16)+(r[4]<<16|r[4]>>>16)|0,A[7]=r[7]+(r[6]<<8|r[6]>>>24)+r[5]|0}A.RabbitLegacy=e._createHelper(s)}(),t.RabbitLegacy)}),Qb(function(A,e){A.exports=pb});var yb=fb,Db=mb;function vb(A){if(yb===setTimeout)return setTimeout(A,0);if((yb===fb||!yb)&&setTimeout)return yb=setTimeout,setTimeout(A,0);try{return yb(A,0)}catch(e){try{return yb.call(null,A,0)}catch(t){return yb.call(this,A,0)}}}"function"==typeof pN.setTimeout&&(yb=setTimeout),"function"==typeof pN.clearTimeout&&(Db=clearTimeout);var wb,Sb=[],Mb=!1,Rb=-1;function _b(){Mb&&wb&&(Mb=!1,wb.length?Sb=wb.concat(Sb):Rb=-1,Sb.length&&Tb())}function Tb(){if(!Mb){var A=vb(_b);Mb=!0;for(var e=Sb.length;e;){for(wb=Sb,Sb=[];++Rb1)for(var t=1;t0&&r.length>o){r.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=A,a.type=e,a.count=r.length,s=a,"function"==typeof console.warn?console.warn(s):console.log(s)}}else r=n[e]=t,++A._eventsCount;return A}function Ob(A,e,t){var i=!1;function o(){A.removeListener(e,o),i||(i=!0,t.apply(A,arguments))}return o.listener=t,o}function xb(A){var e=this._events;if(e){var t=e[A];if("function"==typeof t)return 1;if(t)return t.length}return 0}function Pb(A,e){for(var t=new Array(e);e--;)t[e]=A[e];return t}Gb.now||Gb.mozNow||Gb.msNow||Gb.oNow||Gb.webkitNow,kb.prototype=Object.create(null),Lb.EventEmitter=Lb,Lb.usingDomains=!1,Lb.prototype.domain=void 0,Lb.prototype._events=void 0,Lb.prototype._maxListeners=void 0,Lb.defaultMaxListeners=10,Lb.init=function(){this.domain=null,Lb.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new kb,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Lb.prototype.setMaxListeners=function(A){if("number"!=typeof A||A<0||isNaN(A))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=A,this},Lb.prototype.getMaxListeners=function(){return Ub(this)},Lb.prototype.emit=function(A){var e,t,i,o,n,r,s,a="error"===A;if(r=this._events)a=a&&null==r.error;else if(!a)return!1;if(s=this.domain,a){if(e=arguments[1],!s){if(e instanceof Error)throw e;var g=new Error('Uncaught, unspecified "error" event. ('+e+")");throw g.context=e,g}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=s,e.domainThrown=!1,s.emit("error",e),!1}if(!(t=r[A]))return!1;var c="function"==typeof t;switch(i=arguments.length){case 1:!function(A,e,t){if(e)A.call(t);else for(var i=A.length,o=Pb(A,i),n=0;n0;)if(t[n]===e||t[n].listener&&t[n].listener===e){r=t[n].listener,o=n;break}if(o<0)return this;if(1===t.length){if(t[0]=void 0,0==--this._eventsCount)return this._events=new kb,this;delete i[A]}else!function(A,e){for(var t=e,i=t+1,o=A.length;i0?Reflect.ownKeys(this._events):[]};var Yb="function"==typeof Object.create?function(A,e){A.super_=e,A.prototype=Object.create(e.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}})}:function(A,e){A.super_=e;var t=function(){};t.prototype=e.prototype,A.prototype=new t,A.prototype.constructor=A},Jb=/%[sdj%]/g;function Hb(A){if(!tG(A)){for(var e=[],t=0;t=o)return A;switch(A){case"%s":return String(i[t++]);case"%d":return Number(i[t++]);case"%j":try{return JSON.stringify(i[t++])}catch(e){return"[Circular]"}default:return A}}),r=i[t];t=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),AG(e)?t.showHidden=e:e&&function(A,e){if(!e||!nG(e))return A;for(var t=Object.keys(e),i=t.length;i--;)A[t[i]]=e[t[i]]}(t,e),iG(t.showHidden)&&(t.showHidden=!1),iG(t.depth)&&(t.depth=2),iG(t.colors)&&(t.colors=!1),iG(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=Wb),Zb(t,A,t.depth)}function Wb(A,e){var t=Kb.styles[e];return t?"["+Kb.colors[t][0]+"m"+A+"["+Kb.colors[t][1]+"m":A}function zb(A,e){return A}function Zb(A,e,t){if(A.customInspect&&e&&aG(e.inspect)&&e.inspect!==Kb&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(t,A);return tG(i)||(i=Zb(A,i,t)),i}var o=function(A,e){if(iG(e))return A.stylize("undefined","undefined");if(tG(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return A.stylize(t,"string")}return"number"==typeof e?A.stylize(""+e,"number"):AG(e)?A.stylize(""+e,"boolean"):eG(e)?A.stylize("null","null"):void 0}(A,e);if(o)return o;var n,r=Object.keys(e),s=(n={},r.forEach(function(A,e){n[A]=!0}),n);if(A.showHidden&&(r=Object.getOwnPropertyNames(e)),sG(e)&&(r.indexOf("message")>=0||r.indexOf("description")>=0))return Xb(e);if(0===r.length){if(aG(e)){var a=e.name?": "+e.name:"";return A.stylize("[Function"+a+"]","special")}if(oG(e))return A.stylize(RegExp.prototype.toString.call(e),"regexp");if(rG(e))return A.stylize(Date.prototype.toString.call(e),"date");if(sG(e))return Xb(e)}var g,c,l="",I=!1,u=["{","}"];return g=e,Array.isArray(g)&&(I=!0,u=["[","]"]),aG(e)&&(l=" [Function"+(e.name?": "+e.name:"")+"]"),oG(e)&&(l=" "+RegExp.prototype.toString.call(e)),rG(e)&&(l=" "+Date.prototype.toUTCString.call(e)),sG(e)&&(l=" "+Xb(e)),0!==r.length||I&&0!=e.length?t<0?oG(e)?A.stylize(RegExp.prototype.toString.call(e),"regexp"):A.stylize("[Object]","special"):(A.seen.push(e),c=I?function(A,e,t,i,o){for(var n=[],r=0,s=e.length;r60?t[0]+(""===e?"":e+"\n ")+" "+A.join(",\n ")+" "+t[1]:t[0]+e+" "+A.join(", ")+" "+t[1]}(c,l,u)):u[0]+l+u[1]}function Xb(A){return"["+Error.prototype.toString.call(A)+"]"}function $b(A,e,t,i,o,n){var r,s,a;if((a=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?s=a.set?A.stylize("[Getter/Setter]","special"):A.stylize("[Getter]","special"):a.set&&(s=A.stylize("[Setter]","special")),cG(i,o)||(r="["+o+"]"),s||(A.seen.indexOf(a.value)<0?(s=eG(t)?Zb(A,a.value,null):Zb(A,a.value,t-1)).indexOf("\n")>-1&&(s=n?s.split("\n").map(function(A){return" "+A}).join("\n").substr(2):"\n"+s.split("\n").map(function(A){return" "+A}).join("\n")):s=A.stylize("[Circular]","special")),iG(r)){if(n&&o.match(/^\d+$/))return s;(r=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(r=r.substr(1,r.length-2),r=A.stylize(r,"name")):(r=r.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),r=A.stylize(r,"string"))}return r+": "+s}function AG(A){return"boolean"==typeof A}function eG(A){return null===A}function tG(A){return"string"==typeof A}function iG(A){return void 0===A}function oG(A){return nG(A)&&"[object RegExp]"===gG(A)}function nG(A){return"object"==typeof A&&null!==A}function rG(A){return nG(A)&&"[object Date]"===gG(A)}function sG(A){return nG(A)&&("[object Error]"===gG(A)||A instanceof Error)}function aG(A){return"function"==typeof A}function gG(A){return Object.prototype.toString.call(A)}function cG(A,e){return Object.prototype.hasOwnProperty.call(A,e)}function lG(){this.head=null,this.tail=null,this.length=0}Kb.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Kb.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},lG.prototype.push=function(A){var e={data:A,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},lG.prototype.unshift=function(A){var e={data:A,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},lG.prototype.shift=function(){if(0!==this.length){var A=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,A}},lG.prototype.clear=function(){this.head=this.tail=null,this.length=0},lG.prototype.join=function(A){if(0===this.length)return"";for(var e=this.head,t=""+e.data;e=e.next;)t+=A+e.data;return t},lG.prototype.concat=function(A){if(0===this.length)return GN.alloc(0);if(1===this.length)return this.head.data;for(var e=GN.allocUnsafe(A>>>0),t=this.head,i=0;t;)t.data.copy(e,i),i+=t.data.length,t=t.next;return e};var IG=GN.isEncoding||function(A){switch(A&&A.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function uG(A){switch(this.encoding=(A||"utf8").toLowerCase().replace(/[-_]/,""),function(A){if(A&&!IG(A))throw new Error("Unknown encoding: "+A)}(A),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=dG;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=hG;break;default:return void(this.write=EG)}this.charBuffer=new GN(6),this.charReceived=0,this.charLength=0}function EG(A){return A.toString(this.encoding)}function dG(A){this.charReceived=A.length%2,this.charLength=this.charReceived?2:0}function hG(A){this.charReceived=A.length%3,this.charLength=this.charReceived?3:0}uG.prototype.write=function(A){for(var e="";this.charLength;){var t=A.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:A.length;if(A.copy(this.charBuffer,this.charReceived,0,t),this.charReceived+=t,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===A.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(A);var i,o=A.length;if(this.charLength&&(A.copy(this.charBuffer,0,A.length-this.charReceived,o),o-=this.charReceived),o=(e+=A.toString(this.encoding,0,o)).length-1,(i=e.charCodeAt(o))>=55296&&i<=56319){var n=this.surrogateSize;return this.charLength+=n,this.charReceived+=n,this.charBuffer.copy(this.charBuffer,n,0,n),A.copy(this.charBuffer,0,0,n),e.substring(0,o)}return e},uG.prototype.detectIncompleteChar=function(A){for(var e=A.length>=3?3:A.length;e>0;e--){var t=A[A.length-e];if(1==e&&t>>5==6){this.charLength=2;break}if(e<=2&&t>>4==14){this.charLength=3;break}if(e<=3&&t>>3==30){this.charLength=4;break}}this.charReceived=e},uG.prototype.end=function(A){var e="";if(A&&A.length&&(e=this.write(A)),this.charReceived){var t=this.charReceived,i=this.charBuffer,o=this.encoding;e+=i.slice(0,t).toString(o)}return e},QG.ReadableState=BG;var CG=function(A){return iG(Vb)&&(Vb=""),A=A.toUpperCase(),jb[A]||(new RegExp("\\b"+A+"\\b","i").test(Vb)?jb[A]=function(){var e=Hb.apply(null,arguments);console.error("%s %d: %s",A,0,e)}:jb[A]=function(){}),jb[A]}("stream");function BG(A,e){A=A||{},this.objectMode=!!A.objectMode,e instanceof jG&&(this.objectMode=this.objectMode||!!A.readableObjectMode);var t=A.highWaterMark,i=this.objectMode?16:16384;this.highWaterMark=t||0===t?t:i,this.highWaterMark=~~this.highWaterMark,this.buffer=new lG,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=A.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,A.encoding&&(this.decoder=new uG(A.encoding),this.encoding=A.encoding)}function QG(A){if(!(this instanceof QG))return new QG(A);this._readableState=new BG(A,this),this.readable=!0,A&&"function"==typeof A.read&&(this._read=A.read),Lb.call(this)}function pG(A,e,t,i,o){var n,r,s,a=(n=e,s=null,Cb(r=t)||"string"==typeof r||null==r||n.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s);if(a)A.emit("error",a);else if(null===t)e.reading=!1,function(A,e){if(!e.ended){if(e.decoder){var t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,yG(A)}}(A,e);else if(e.objectMode||t&&t.length>0)if(e.ended&&!o){var g=new Error("stream.push() after EOF");A.emit("error",g)}else if(e.endEmitted&&o){var c=new Error("stream.unshift() after end event");A.emit("error",c)}else{var l;!e.decoder||o||i||(t=e.decoder.write(t),l=!e.objectMode&&0===t.length),o||(e.reading=!1),l||(e.flowing&&0===e.length&&!e.sync?(A.emit("data",t),A.read(0)):(e.length+=e.objectMode?1:t.length,o?e.buffer.unshift(t):e.buffer.push(t),e.needReadable&&yG(A))),function(A,e){e.readingMore||(e.readingMore=!0,Nb(vG,A,e))}(A,e)}else o||(e.reading=!1);return function(A){return!A.ended&&(A.needReadable||A.lengthe.highWaterMark&&(e.highWaterMark=((t=A)>=fG?t=fG:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t)),A<=e.length?A:e.ended?e.length:(e.needReadable=!0,0));var t}function yG(A){var e=A._readableState;e.needReadable=!1,e.emittedReadable||(CG("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?Nb(DG,A):DG(A))}function DG(A){CG("emit readable"),A.emit("readable"),MG(A)}function vG(A,e){for(var t=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):(t=A,i=e.buffer,o=e.decoder,tn.length?n.length:A;if(r===n.length?o+=n:o+=n.slice(0,A),0===(A-=r)){r===n.length?(++i,t.next?e.head=t.next:e.head=e.tail=null):(e.head=t,t.data=n.slice(r));break}++i}return e.length-=i,o}(t,i):function(A,e){var t=GN.allocUnsafe(A),i=e.head,o=1;for(i.data.copy(t),A-=i.data.length;i=i.next;){var n=i.data,r=A>n.length?n.length:A;if(n.copy(t,t.length-A,0,r),0===(A-=r)){r===n.length?(++o,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=n.slice(r));break}++o}return e.length-=o,t}(t,i),r=n),r);var t,i,o,n,r}function _G(A){var e=A._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,Nb(TG,e,A))}function TG(A,e){A.endEmitted||0!==A.length||(A.endEmitted=!0,e.readable=!1,e.emit("end"))}function NG(A,e){for(var t=0,i=A.length;t=e.highWaterMark||e.ended))return CG("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?_G(this):yG(this),null;if(0===(A=mG(A,e))&&e.ended)return 0===e.length&&_G(this),null;var i,o=e.needReadable;return CG("need readable",o),(0===e.length||e.length-A0?RG(A,e):null)?(e.needReadable=!0,A=0):e.length-=A,0===e.length&&(e.ended||(e.needReadable=!0),t!==A&&e.ended&&_G(this)),null!==i&&this.emit("data",i),i},QG.prototype._read=function(A){this.emit("error",new Error("not implemented"))},QG.prototype.pipe=function(A,e){var t=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=A;break;case 1:i.pipes=[i.pipes,A];break;default:i.pipes.push(A)}i.pipesCount+=1,CG("pipe count=%d opts=%j",i.pipesCount,e);var o=e&&!1===e.end?g:r;function n(A){CG("onunpipe"),A===t&&g()}function r(){CG("onend"),A.end()}i.endEmitted?Nb(o):t.once("end",o),A.on("unpipe",n);var s=function(A){return function(){var e=A._readableState;CG("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&A.listeners("data").length&&(e.flowing=!0,MG(A))}}(t);A.on("drain",s);var a=!1;function g(){CG("cleanup"),A.removeListener("close",u),A.removeListener("finish",E),A.removeListener("drain",s),A.removeListener("error",I),A.removeListener("unpipe",n),t.removeListener("end",r),t.removeListener("end",g),t.removeListener("data",l),a=!0,!i.awaitDrain||A._writableState&&!A._writableState.needDrain||s()}var c=!1;function l(e){CG("ondata"),c=!1,!1!==A.write(e)||c||((1===i.pipesCount&&i.pipes===A||i.pipesCount>1&&-1!==NG(i.pipes,A))&&!a&&(CG("false write response, pause",t._readableState.awaitDrain),t._readableState.awaitDrain++,c=!0),t.pause())}function I(e){CG("onerror",e),d(),A.removeListener("error",I),0===A.listeners("error").length&&A.emit("error",e)}function u(){A.removeListener("finish",E),d()}function E(){CG("onfinish"),A.removeListener("close",u),d()}function d(){CG("unpipe"),t.unpipe(A)}return t.on("data",l),function(A,e,t){if("function"==typeof A.prependListener)return A.prependListener(e,t);A._events&&A._events[e]?Array.isArray(A._events[e])?A._events[e].unshift(t):A._events[e]=[t,A._events[e]]:A.on(e,t)}(A,"error",I),A.once("close",u),A.once("finish",E),A.emit("pipe",t),i.flowing||(CG("pipe resume"),t.resume()),A},QG.prototype.unpipe=function(A){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return A&&A!==e.pipes||(A||(A=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,A&&A.emit("unpipe",this)),this;if(!A){var t=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1))throw new TypeError("Unknown encoding: "+A);return this._writableState.defaultEncoding=A,this},LG.prototype._write=function(A,e,t){t(new Error("not implemented"))},LG.prototype._writev=null,LG.prototype.end=function(A,e,t){var i,o,n,r=this._writableState;"function"==typeof A?(t=A,A=null,e=null):"function"==typeof e&&(t=e,e=null),null!=A&&this.write(A,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||(i=this,n=t,(o=r).ending=!0,YG(i,o),n&&(o.finished?Nb(n):i.once("finish",n)),o.ended=!0,i.writable=!1)},Yb(jG,QG);for(var HG=Object.keys(LG.prototype),qG=0;qG=0;)A[e]=0}var ak=256,gk=286,ck=30,lk=15,Ik=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],uk=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ek=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],dk=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],hk=new Array(576);sk(hk);var Ck=new Array(60);sk(Ck);var Bk=new Array(512);sk(Bk);var Qk=new Array(256);sk(Qk);var pk=new Array(29);sk(pk);var fk,mk,yk,Dk=new Array(ck);function vk(A,e,t,i,o){this.static_tree=A,this.extra_bits=e,this.extra_base=t,this.elems=i,this.max_length=o,this.has_stree=A&&A.length}function wk(A,e){this.dyn_tree=A,this.max_code=0,this.stat_desc=e}function Sk(A){return A<256?Bk[A]:Bk[256+(A>>>7)]}function Mk(A,e){A.pending_buf[A.pending++]=255&e,A.pending_buf[A.pending++]=e>>>8&255}function Rk(A,e,t){A.bi_valid>16-t?(A.bi_buf|=e<>16-A.bi_valid,A.bi_valid+=t-16):(A.bi_buf|=e<>>=1,t<<=1}while(--e>0);return t>>>1}function Nk(A,e,t){var i,o,n=new Array(16),r=0;for(i=1;i<=lk;i++)n[i]=r=r+t[i-1]<<1;for(o=0;o<=e;o++){var s=A[2*o+1];0!==s&&(A[2*o]=Tk(n[s]++,s))}}function bk(A){var e;for(e=0;e8?Mk(A,A.bi_buf):A.bi_valid>0&&(A.pending_buf[A.pending++]=A.bi_buf),A.bi_buf=0,A.bi_valid=0}function kk(A,e,t,i){var o=2*e,n=2*t;return A[o]>1;t>=1;t--)Lk(A,n,t);o=a;do{t=A.heap[1],A.heap[1]=A.heap[A.heap_len--],Lk(A,n,1),i=A.heap[1],A.heap[--A.heap_max]=t,A.heap[--A.heap_max]=i,n[2*o]=n[2*t]+n[2*i],A.depth[o]=(A.depth[t]>=A.depth[i]?A.depth[t]:A.depth[i])+1,n[2*t+1]=n[2*i+1]=o,A.heap[1]=o++,Lk(A,n,1)}while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],function(A,e){var t,i,o,n,r,s,a=e.dyn_tree,g=e.max_code,c=e.stat_desc.static_tree,l=e.stat_desc.has_stree,I=e.stat_desc.extra_bits,u=e.stat_desc.extra_base,E=e.stat_desc.max_length,d=0;for(n=0;n<=lk;n++)A.bl_count[n]=0;for(a[2*A.heap[A.heap_max]+1]=0,t=A.heap_max+1;t<573;t++)(n=a[2*a[2*(i=A.heap[t])+1]+1]+1)>E&&(n=E,d++),a[2*i+1]=n,i>g||(A.bl_count[n]++,r=0,i>=u&&(r=I[i-u]),s=a[2*i],A.opt_len+=s*(n+r),l&&(A.static_len+=s*(c[2*i+1]+r)));if(0!==d){do{for(n=E-1;0===A.bl_count[n];)n--;A.bl_count[n]--,A.bl_count[n+1]+=2,A.bl_count[E]--,d-=2}while(d>0);for(n=E;0!==n;n--)for(i=A.bl_count[n];0!==i;)(o=A.heap[--t])>g||(a[2*o+1]!==n&&(A.opt_len+=(n-a[2*o+1])*a[2*o],a[2*o+1]=n),i--)}}(A,e),Nk(n,g,A.bl_count)}function Ok(A,e,t){var i,o,n=-1,r=e[1],s=0,a=7,g=4;for(0===r&&(a=138,g=3),e[2*(t+1)+1]=65535,i=0;i<=t;i++)o=r,r=e[2*(i+1)+1],++s>>8&255,A.pending_buf[A.d_buf+2*A.last_lit+1]=255&e,A.pending_buf[A.l_buf+A.last_lit]=255&t,A.last_lit++,0===e?A.dyn_ltree[2*t]++:(A.matches++,e--,A.dyn_ltree[2*(Qk[t]+ak+1)]++,A.dyn_dtree[2*Sk(e)]++),A.last_lit===A.lit_bufsize-1}function Hk(A,e,t,i){for(var o=65535&A,n=A>>>16&65535,r=0;0!==t;){t-=r=t>2e3?2e3:t;do{n=n+(o=o+e[i++]|0)|0}while(--r);o%=65521,n%=65521}return o|n<<16}var qk=function(){for(var A,e=[],t=0;t<256;t++){A=t;for(var i=0;i<8;i++)A=1&A?3988292384^A>>>1:A>>>1;e[t]=A}return e}();function Vk(A,e,t,i){var o=qk,n=i+t;A^=-1;for(var r=i;r>>8^o[255&(A^e[r])];return-1^A}var jk,Kk=-2,Wk=258,zk=262,Zk=103,Xk=113,$k=666;function AL(A,e){return A.msg=ek[e],e}function eL(A){return(A<<1)-(A>4?9:0)}function tL(A){for(var e=A.length;--e>=0;)A[e]=0}function iL(A){var e=A.state,t=e.pending;t>A.avail_out&&(t=A.avail_out),0!==t&&(ik(A.output,e.pending_buf,e.pending_out,t,A.next_out),A.next_out+=t,e.pending_out+=t,A.total_out+=t,A.avail_out-=t,e.pending-=t,0===e.pending&&(e.pending_out=0))}function oL(A,e){(function(A,e,t,i){var o,n,r=0;A.level>0?(2===A.strm.data_type&&(A.strm.data_type=function(A){var e,t=4093624447;for(e=0;e<=31;e++,t>>>=1)if(1&t&&0!==A.dyn_ltree[2*e])return 0;if(0!==A.dyn_ltree[18]||0!==A.dyn_ltree[20]||0!==A.dyn_ltree[26])return 1;for(e=32;e=3&&0===A.bl_tree[2*dk[e]+1];e--);return A.opt_len+=3*(e+1)+5+5+4,e}(A),o=A.opt_len+3+7>>>3,(n=A.static_len+3+7>>>3)<=o&&(o=n)):o=n=t+5,t+4<=o&&-1!==e?Yk(A,e,t,i):4===A.strategy||n===o?(Rk(A,2+(i?1:0),3),Uk(A,hk,Ck)):(Rk(A,4+(i?1:0),3),function(A,e,t,i){var o;for(Rk(A,e-257,5),Rk(A,t-1,5),Rk(A,i-4,4),o=0;o=0?A.block_start:-1,A.strstart-A.block_start,e),A.block_start=A.strstart,iL(A.strm)}function nL(A,e){A.pending_buf[A.pending++]=e}function rL(A,e){A.pending_buf[A.pending++]=e>>>8&255,A.pending_buf[A.pending++]=255&e}function sL(A,e){var t,i,o=A.max_chain_length,n=A.strstart,r=A.prev_length,s=A.nice_match,a=A.strstart>A.w_size-zk?A.strstart-(A.w_size-zk):0,g=A.window,c=A.w_mask,l=A.prev,I=A.strstart+Wk,u=g[n+r-1],E=g[n+r];A.prev_length>=A.good_match&&(o>>=2),s>A.lookahead&&(s=A.lookahead);do{if(g[(t=e)+r]===E&&g[t+r-1]===u&&g[t]===g[n]&&g[++t]===g[n+1]){n+=2,t++;do{}while(g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&g[++n]===g[++t]&&nr){if(A.match_start=e,r=i,i>=s)break;u=g[n+r-1],E=g[n+r]}}}while((e=l[e&c])>a&&0!=--o);return r<=A.lookahead?r:A.lookahead}function aL(A){var e,t,i,o,n,r,s,a,g,c,l=A.w_size;do{if(o=A.window_size-A.lookahead-A.strstart,A.strstart>=l+(l-zk)){ik(A.window,A.window,l,l,0),A.match_start-=l,A.strstart-=l,A.block_start-=l,e=t=A.hash_size;do{i=A.head[--e],A.head[e]=i>=l?i-l:0}while(--t);e=t=l;do{i=A.prev[--e],A.prev[e]=i>=l?i-l:0}while(--t);o+=l}if(0===A.strm.avail_in)break;if(r=A.strm,s=A.window,a=A.strstart+A.lookahead,g=o,c=void 0,(c=r.avail_in)>g&&(c=g),t=0===c?0:(r.avail_in-=c,ik(s,r.input,r.next_in,c,a),1===r.state.wrap?r.adler=Hk(r.adler,s,c,a):2===r.state.wrap&&(r.adler=Vk(r.adler,s,c,a)),r.next_in+=c,r.total_in+=c,c),A.lookahead+=t,A.lookahead+A.insert>=3)for(n=A.strstart-A.insert,A.ins_h=A.window[n],A.ins_h=(A.ins_h<=3&&(A.ins_h=(A.ins_h<=3)if(i=Jk(A,A.strstart-A.match_start,A.match_length-3),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=3){A.match_length--;do{A.strstart++,A.ins_h=(A.ins_h<=3&&(A.ins_h=(A.ins_h<4096)&&(A.match_length=2)),A.prev_length>=3&&A.match_length<=A.prev_length){o=A.strstart+A.lookahead-3,i=Jk(A,A.strstart-1-A.prev_match,A.prev_length-3),A.lookahead-=A.prev_length-1,A.prev_length-=2;do{++A.strstart<=o&&(A.ins_h=(A.ins_h<>=7;i5||e<0)return A?AL(A,Kk):Kk;if(i=A.state,!A.output||!A.input&&0!==A.avail_in||i.status===$k&&4!==e)return AL(A,0===A.avail_out?-5:Kk);if(i.strm=A,t=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)A.adler=0,nL(i,31),nL(i,139),nL(i,8),i.gzhead?(nL(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),nL(i,255&i.gzhead.time),nL(i,i.gzhead.time>>8&255),nL(i,i.gzhead.time>>16&255),nL(i,i.gzhead.time>>24&255),nL(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),nL(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(nL(i,255&i.gzhead.extra.length),nL(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(A.adler=Vk(A.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(nL(i,0),nL(i,0),nL(i,0),nL(i,0),nL(i,0),nL(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),nL(i,3),i.status=Xk);else{var r=8+(i.w_bits-8<<4)<<8;r|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(r|=32),r+=31-r%31,i.status=Xk,rL(i,r),0!==i.strstart&&(rL(i,A.adler>>>16),rL(i,65535&A.adler)),A.adler=1}if(69===i.status)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),iL(A),o=i.pending,i.pending!==i.pending_buf_size));)nL(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),iL(A),o=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexo&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),iL(A),o=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexo&&(A.adler=Vk(A.adler,i.pending_buf,i.pending-o,o)),0===n&&(i.status=Zk)}else i.status=Zk;if(i.status===Zk&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&iL(A),i.pending+2<=i.pending_buf_size&&(nL(i,255&A.adler),nL(i,A.adler>>8&255),A.adler=0,i.status=Xk)):i.status=Xk),0!==i.pending){if(iL(A),0===A.avail_out)return i.last_flush=-1,0}else if(0===A.avail_in&&eL(e)<=eL(t)&&4!==e)return AL(A,-5);if(i.status===$k&&0!==A.avail_in)return AL(A,-5);if(0!==A.avail_in||0!==i.lookahead||0!==e&&i.status!==$k){var s=2===i.strategy?function(A,e){for(var t;;){if(0===A.lookahead&&(aL(A),0===A.lookahead)){if(0===e)return 1;break}if(A.match_length=0,t=Jk(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,t&&(oL(A,!1),0===A.strm.avail_out))return 1}return A.insert=0,4===e?(oL(A,!0),0===A.strm.avail_out?3:4):A.last_lit&&(oL(A,!1),0===A.strm.avail_out)?1:2}(i,e):3===i.strategy?function(A,e){for(var t,i,o,n,r=A.window;;){if(A.lookahead<=Wk){if(aL(A),A.lookahead<=Wk&&0===e)return 1;if(0===A.lookahead)break}if(A.match_length=0,A.lookahead>=3&&A.strstart>0&&(i=r[o=A.strstart-1])===r[++o]&&i===r[++o]&&i===r[++o]){n=A.strstart+Wk;do{}while(i===r[++o]&&i===r[++o]&&i===r[++o]&&i===r[++o]&&i===r[++o]&&i===r[++o]&&i===r[++o]&&i===r[++o]&&oA.lookahead&&(A.match_length=A.lookahead)}if(A.match_length>=3?(t=Jk(A,1,A.match_length-3),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0):(t=Jk(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++),t&&(oL(A,!1),0===A.strm.avail_out))return 1}return A.insert=0,4===e?(oL(A,!0),0===A.strm.avail_out?3:4):A.last_lit&&(oL(A,!1),0===A.strm.avail_out)?1:2}(i,e):jk[i.level].func(i,e);if(3!==s&&4!==s||(i.status=$k),1===s||3===s)return 0===A.avail_out&&(i.last_flush=-1),0;if(2===s&&(1===e?function(A){var e;Rk(A,2,3),_k(A,256,hk),16===(e=A).bi_valid?(Mk(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(i):5!==e&&(Yk(i,0,0,!1),3===e&&(tL(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),iL(A),0===A.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(nL(i,255&A.adler),nL(i,A.adler>>8&255),nL(i,A.adler>>16&255),nL(i,A.adler>>24&255),nL(i,255&A.total_in),nL(i,A.total_in>>8&255),nL(i,A.total_in>>16&255),nL(i,A.total_in>>24&255)):(rL(i,A.adler>>>16),rL(i,65535&A.adler)),iL(A),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)}jk=[new lL(0,0,0,0,function(A,e){var t=65535;for(t>A.pending_buf_size-5&&(t=A.pending_buf_size-5);;){if(A.lookahead<=1){if(aL(A),0===A.lookahead&&0===e)return 1;if(0===A.lookahead)break}A.strstart+=A.lookahead,A.lookahead=0;var i=A.block_start+t;if((0===A.strstart||A.strstart>=i)&&(A.lookahead=A.strstart-i,A.strstart=i,oL(A,!1),0===A.strm.avail_out))return 1;if(A.strstart-A.block_start>=A.w_size-zk&&(oL(A,!1),0===A.strm.avail_out))return 1}return A.insert=0,4===e?(oL(A,!0),0===A.strm.avail_out?3:4):(A.strstart>A.block_start&&(oL(A,!1),A.strm.avail_out),1)}),new lL(4,4,8,4,gL),new lL(4,5,16,8,gL),new lL(4,6,32,32,gL),new lL(4,4,16,16,cL),new lL(8,16,32,32,cL),new lL(8,16,128,128,cL),new lL(8,32,128,256,cL),new lL(32,128,258,1024,cL),new lL(32,258,258,4096,cL)];function dL(A,e){var t,i,o,n,r,s,a,g,c,l,I,u,E,d,h,C,B,Q,p,f,m,y,D,v,w;t=A.state,i=A.next_in,v=A.input,o=i+(A.avail_in-5),n=A.next_out,w=A.output,r=n-(e-A.avail_out),s=n+(A.avail_out-257),a=t.dmax,g=t.wsize,c=t.whave,l=t.wnext,I=t.window,u=t.hold,E=t.bits,d=t.lencode,h=t.distcode,C=(1<>>=p=Q>>>24,E-=p,0==(p=Q>>>16&255))w[n++]=65535&Q;else{if(!(16&p)){if(!(64&p)){Q=d[(65535&Q)+(u&(1<>>=p,E-=p),E<15&&(u+=v[i++]<>>=p=Q>>>24,E-=p,!(16&(p=Q>>>16&255))){if(!(64&p)){Q=h[(65535&Q)+(u&(1<a){A.msg="invalid distance too far back",t.mode=30;break A}if(u>>>=p,E-=p,m>(p=n-r)){if((p=m-p)>c&&t.sane){A.msg="invalid distance too far back",t.mode=30;break A}if(y=0,D=I,0===l){if(y+=g-p,p2;)w[n++]=D[y++],w[n++]=D[y++],w[n++]=D[y++],f-=3;f&&(w[n++]=D[y++],f>1&&(w[n++]=D[y++]))}else{y=n-m;do{w[n++]=w[y++],w[n++]=w[y++],w[n++]=w[y++],f-=3}while(f>2);f&&(w[n++]=w[y++],f>1&&(w[n++]=w[y++]))}break}}break}}while(i>3,u&=(1<<(E-=f<<3))-1,A.next_in=i,A.next_out=n,A.avail_in=i=1&&0===_[f];f--);if(m>f&&(m=f),0===f)return o[n++]=20971520,o[n++]=20971520,s.bits=1,0;for(p=1;p0&&(0===A||1!==f))return-1;for(T[1]=0,B=1;B852||2===A&&w>592)return 1;for(;;){E=B-D,r[Q]u?(d=N[b+r[Q]],h=M[R+r[Q]]):(d=96,h=0),a=1<>D)+(g-=a)]=E<<24|d<<16|h}while(0!==g);for(a=1<>=1;if(0!==a?(S&=a-1,S+=a):S=0,Q++,0==--_[B]){if(B===f)break;B=e[t+r[Q]]}if(B>m&&(S&l)!==c){for(0===D&&(D=m),I+=p,v=1<<(y=B-D);y+D852||2===A&&w>592)return 1;o[c=S&l]=m<<24|y<<16|I-n}}return 0!==S&&(o[I+S]=B-D<<24|64<<16),s.bits=m,0}var mL=-2,yL=12,DL=30;function vL(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function wL(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new nk(320),this.work=new nk(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function SL(A){var e,t,i;return A&&A.state?((e=A.state).wsize=0,e.whave=0,e.wnext=0,(t=A)&&t.state?(i=t.state,t.total_in=t.total_out=i.total=0,t.msg="",i.wrap&&(t.adler=1&i.wrap),i.mode=1,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new rk(852),i.distcode=i.distdyn=new rk(592),i.sane=1,i.back=-1,0):mL):mL}var ML,RL,_L=!0;function TL(A){if(_L){var e;for(ML=new rk(512),RL=new rk(32),e=0;e<144;)A.lens[e++]=8;for(;e<256;)A.lens[e++]=9;for(;e<280;)A.lens[e++]=7;for(;e<288;)A.lens[e++]=8;for(fL(1,A.lens,0,288,ML,0,A.work,{bits:9}),e=0;e<32;)A.lens[e++]=5;fL(2,A.lens,0,32,RL,0,A.work,{bits:5}),_L=!1}A.lencode=ML,A.lenbits=9,A.distcode=RL,A.distbits=5}var NL;function bL(A){if(A<1||A>7)throw new TypeError("Bad argument");this.mode=A,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function GL(A,e){for(var t=0;t15&&(r=2,i-=16),o<1||o>9||i<8||i>15||e<0||e>9||n<0||n>4)return AL(A,Kk);8===i&&(i=9);var s=new IL;return A.state=s,s.strm=A,s.wrap=r,s.gzhead=null,s.w_bits=i,s.w_size=1<>4),n<48&&(n&=15)),n&&(n<8||n>15)?mL:(null!==s.window&&s.wbits!==n&&(s.window=null),s.wrap=r,s.wbits=n,SL(o))):mL)&&(A.state=null),t):mL}(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===n?(this.write_in_progress=!1,this.init_done=!0):this._error(n)},bL.prototype.params=function(){throw new Error("deflateParams Not supported")},bL.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},bL.prototype.write=function(A,e,t,i,o,n,r){this._writeCheck(),this.write_in_progress=!0;var s=this;return Nb(function(){s.write_in_progress=!1;var a=s._write(A,e,t,i,o,n,r);s.callback(a[0],a[1]),s.pending_close&&s.close()}),this},bL.prototype.writeSync=function(A,e,t,i,o,n,r){return this._writeCheck(),this._write(A,e,t,i,o,n,r)},bL.prototype._write=function(A,e,t,i,o,n,r){if(this.write_in_progress=!0,0!==A&&1!==A&&2!==A&&3!==A&&4!==A&&5!==A)throw new Error("Invalid flush value");null==e&&(e=new GN(0),i=0,t=0),o._set?o.set=o._set:o.set=GL;var s,a=this.strm;switch(a.avail_in=i,a.input=e,a.next_in=t,a.avail_out=r,a.output=o,a.next_out=n,this.mode){case 1:case 3:case 5:s=EL(a,A);break;case 7:case 2:case 4:case 6:s=function(A,e){var t,i,o,n,r,s,a,g,c,l,I,u,E,d,h,C,B,Q,p,f,m,y,D,v,w,S,M,R,_,T,N=0,b=new ok(4),G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&0!==A.avail_in)return mL;(t=A.state).mode===yL&&(t.mode=13),r=A.next_out,o=A.output,a=A.avail_out,n=A.next_in,i=A.input,s=A.avail_in,g=t.hold,c=t.bits,l=s,I=a,y=0;A:for(;;)switch(t.mode){case 1:if(0===t.wrap){t.mode=13;break}for(;c<16;){if(0===s)break A;s--,g+=i[n++]<>>8&255,t.check=Vk(t.check,b,2,0),g=0,c=0,t.mode=2;break}if(t.flags=0,t.head&&(t.head.done=!1),!(1&t.wrap)||(((255&g)<<8)+(g>>8))%31){A.msg="incorrect header check",t.mode=DL;break}if(8!=(15&g)){A.msg="unknown compression method",t.mode=DL;break}if(c-=4,m=8+(15&(g>>>=4)),0===t.wbits)t.wbits=m;else if(m>t.wbits){A.msg="invalid window size",t.mode=DL;break}t.dmax=1<>8&1),512&t.flags&&(b[0]=255&g,b[1]=g>>>8&255,t.check=Vk(t.check,b,2,0)),g=0,c=0,t.mode=3;case 3:for(;c<32;){if(0===s)break A;s--,g+=i[n++]<>>8&255,b[2]=g>>>16&255,b[3]=g>>>24&255,t.check=Vk(t.check,b,4,0)),g=0,c=0,t.mode=4;case 4:for(;c<16;){if(0===s)break A;s--,g+=i[n++]<>8),512&t.flags&&(b[0]=255&g,b[1]=g>>>8&255,t.check=Vk(t.check,b,2,0)),g=0,c=0,t.mode=5;case 5:if(1024&t.flags){for(;c<16;){if(0===s)break A;s--,g+=i[n++]<>>8&255,t.check=Vk(t.check,b,2,0)),g=0,c=0}else t.head&&(t.head.extra=null);t.mode=6;case 6:if(1024&t.flags&&((u=t.length)>s&&(u=s),u&&(t.head&&(m=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),ik(t.head.extra,i,n,u,m)),512&t.flags&&(t.check=Vk(t.check,i,u,n)),s-=u,n+=u,t.length-=u),t.length))break A;t.length=0,t.mode=7;case 7:if(2048&t.flags){if(0===s)break A;u=0;do{m=i[n+u++],t.head&&m&&t.length<65536&&(t.head.name+=String.fromCharCode(m))}while(m&&u>9&1,t.head.done=!0),A.adler=t.check=0,t.mode=yL;break;case 10:for(;c<32;){if(0===s)break A;s--,g+=i[n++]<>>=7&c,c-=7&c,t.mode=27;break}for(;c<3;){if(0===s)break A;s--,g+=i[n++]<>>=1)){case 0:t.mode=14;break;case 1:if(TL(t),t.mode=20,6===e){g>>>=2,c-=2;break A}break;case 2:t.mode=17;break;case 3:A.msg="invalid block type",t.mode=DL}g>>>=2,c-=2;break;case 14:for(g>>>=7&c,c-=7&c;c<32;){if(0===s)break A;s--,g+=i[n++]<>>16^65535)){A.msg="invalid stored block lengths",t.mode=DL;break}if(t.length=65535&g,g=0,c=0,t.mode=15,6===e)break A;case 15:t.mode=16;case 16:if(u=t.length){if(u>s&&(u=s),u>a&&(u=a),0===u)break A;ik(o,i,n,u,r),s-=u,n+=u,a-=u,r+=u,t.length-=u;break}t.mode=yL;break;case 17:for(;c<14;){if(0===s)break A;s--,g+=i[n++]<>>=5,c-=5,t.ndist=1+(31&g),g>>>=5,c-=5,t.ncode=4+(15&g),g>>>=4,c-=4,t.nlen>286||t.ndist>30){A.msg="too many length or distance symbols",t.mode=DL;break}t.have=0,t.mode=18;case 18:for(;t.have>>=3,c-=3}for(;t.have<19;)t.lens[G[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,D={bits:t.lenbits},y=fL(0,t.lens,0,19,t.lencode,0,t.work,D),t.lenbits=D.bits,y){A.msg="invalid code lengths set",t.mode=DL;break}t.have=0,t.mode=19;case 19:for(;t.have>>16&255,B=65535&N,!((h=N>>>24)<=c);){if(0===s)break A;s--,g+=i[n++]<>>=h,c-=h,t.lens[t.have++]=B;else{if(16===B){for(v=h+2;c>>=h,c-=h,0===t.have){A.msg="invalid bit length repeat",t.mode=DL;break}m=t.lens[t.have-1],u=3+(3&g),g>>>=2,c-=2}else if(17===B){for(v=h+3;c>>=h)),g>>>=3,c-=3}else{for(v=h+7;c>>=h)),g>>>=7,c-=7}if(t.have+u>t.nlen+t.ndist){A.msg="invalid bit length repeat",t.mode=DL;break}for(;u--;)t.lens[t.have++]=m}}if(t.mode===DL)break;if(0===t.lens[256]){A.msg="invalid code -- missing end-of-block",t.mode=DL;break}if(t.lenbits=9,D={bits:t.lenbits},y=fL(1,t.lens,0,t.nlen,t.lencode,0,t.work,D),t.lenbits=D.bits,y){A.msg="invalid literal/lengths set",t.mode=DL;break}if(t.distbits=6,t.distcode=t.distdyn,D={bits:t.distbits},y=fL(2,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,D),t.distbits=D.bits,y){A.msg="invalid distances set",t.mode=DL;break}if(t.mode=20,6===e)break A;case 20:t.mode=21;case 21:if(s>=6&&a>=258){A.next_out=r,A.avail_out=a,A.next_in=n,A.avail_in=s,t.hold=g,t.bits=c,dL(A,I),r=A.next_out,o=A.output,a=A.avail_out,n=A.next_in,i=A.input,s=A.avail_in,g=t.hold,c=t.bits,t.mode===yL&&(t.back=-1);break}for(t.back=0;C=(N=t.lencode[g&(1<>>16&255,B=65535&N,!((h=N>>>24)<=c);){if(0===s)break A;s--,g+=i[n++]<>Q)])>>>16&255,B=65535&N,!(Q+(h=N>>>24)<=c);){if(0===s)break A;s--,g+=i[n++]<>>=Q,c-=Q,t.back+=Q}if(g>>>=h,c-=h,t.back+=h,t.length=B,0===C){t.mode=26;break}if(32&C){t.back=-1,t.mode=yL;break}if(64&C){A.msg="invalid literal/length code",t.mode=DL;break}t.extra=15&C,t.mode=22;case 22:if(t.extra){for(v=t.extra;c>>=t.extra,c-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=23;case 23:for(;C=(N=t.distcode[g&(1<>>16&255,B=65535&N,!((h=N>>>24)<=c);){if(0===s)break A;s--,g+=i[n++]<>Q)])>>>16&255,B=65535&N,!(Q+(h=N>>>24)<=c);){if(0===s)break A;s--,g+=i[n++]<>>=Q,c-=Q,t.back+=Q}if(g>>>=h,c-=h,t.back+=h,64&C){A.msg="invalid distance code",t.mode=DL;break}t.offset=B,t.extra=15&C,t.mode=24;case 24:if(t.extra){for(v=t.extra;c>>=t.extra,c-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){A.msg="invalid distance too far back",t.mode=DL;break}t.mode=25;case 25:if(0===a)break A;if(u=I-a,t.offset>u){if((u=t.offset-u)>t.whave&&t.sane){A.msg="invalid distance too far back",t.mode=DL;break}u>t.wnext?(u-=t.wnext,E=t.wsize-u):E=t.wnext-u,u>t.length&&(u=t.length),d=t.window}else d=o,E=r-t.offset,u=t.length;u>a&&(u=a),a-=u,t.length-=u;do{o[r++]=d[E++]}while(--u);0===t.length&&(t.mode=21);break;case 26:if(0===a)break A;o[r++]=t.length,a--,t.mode=21;break;case 27:if(t.wrap){for(;c<32;){if(0===s)break A;s--,g|=i[n++]<=T.wsize?(ik(T.window,S,M-T.wsize,T.wsize,0),T.wnext=0,T.whave=T.wsize):((_=T.wsize-T.wnext)>R&&(_=R),ik(T.window,S,M-R,_,T.wnext),(R-=_)?(ik(T.window,S,M-R,R,0),T.wnext=R,T.whave=T.wsize):(T.wnext+=_,T.wnext===T.wsize&&(T.wnext=0),T.whaveLL.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+A.chunkSize);if(A.windowBits&&(A.windowBitsLL.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+A.windowBits);if(A.level&&(A.levelLL.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+A.level);if(A.memLevel&&(A.memLevelLL.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+A.memLevel);if(A.strategy&&A.strategy!=LL.Z_FILTERED&&A.strategy!=LL.Z_HUFFMAN_ONLY&&A.strategy!=LL.Z_RLE&&A.strategy!=LL.Z_FIXED&&A.strategy!=LL.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+A.strategy);if(A.dictionary&&!Cb(A.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new LL.Zlib(e);var t=this;this._hadError=!1,this._binding.onerror=function(A,e){t._binding=null,t._hadError=!0;var i=new Error(A);i.errno=e,i.code=LL.codes[e],t.emit("error",i)};var i=LL.Z_DEFAULT_COMPRESSION;"number"==typeof A.level&&(i=A.level);var o=LL.Z_DEFAULT_STRATEGY;"number"==typeof A.strategy&&(o=A.strategy),this._binding.init(A.windowBits||LL.Z_DEFAULT_WINDOWBITS,i,A.memLevel||LL.Z_DEFAULT_MEMLEVEL,o,A.dictionary),this._buffer=new GN(this._chunkSize),this._offset=0,this._closed=!1,this._level=i,this._strategy=o,this.once("end",this.close)}function OL(A){return(OL="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(A)}function xL(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}function PL(A){var e=function(A,e){if("object"!=OL(A)||!A)return A;var t=A[Symbol.toPrimitive];if(void 0!==t){var i=t.call(A,e||"default");if("object"!=OL(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(A)}(A,"string");return"symbol"==OL(e)?e:e+""}function YL(A,e){for(var t=0;tA.length)&&(e=A.length);for(var t=0,i=Array(e);tLL.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+A);if(e!=LL.Z_FILTERED&&e!=LL.Z_HUFFMAN_ONLY&&e!=LL.Z_RLE&&e!=LL.Z_FIXED&&e!=LL.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+e);if(this._level!==A||this._strategy!==e){var i=this;this.flush(LL.Z_SYNC_FLUSH,function(){i._binding.params(A,e),i._hadError||(i._level=A,i._strategy=e,t&&t())})}else Nb(t)},FL.prototype.reset=function(){return this._binding.reset()},FL.prototype._flush=function(A){this._transform(new GN(0),"",A)},FL.prototype.flush=function(A,e){var t=this._writableState;if(("function"==typeof A||void 0===A&&!e)&&(e=A,A=LL.Z_FULL_FLUSH),t.ended)e&&Nb(e);else if(t.ending)e&&this.once("end",e);else if(t.needDrain){var i=this;this.once("drain",function(){i.flush(e)})}else this._flushFlag=A,this.write(new GN(0),"",e)},FL.prototype.close=function(A){if(A&&Nb(A),!this._closed){this._closed=!0,this._binding.close();var e=this;Nb(function(){e.emit("close")})}},FL.prototype._transform=function(A,e,t){var i,o=this._writableState,n=(o.ending||o.ended)&&(!A||o.length===A.length);if(null===!A&&!Cb(A))return t(new Error("invalid input"));n?i=LL.Z_FINISH:(i=this._flushFlag,A.length>=o.length&&(this._flushFlag=this._opts.flush||LL.Z_NO_FLUSH)),this._processChunk(A,i,t)},FL.prototype._processChunk=function(A,e,t){var i=A&&A.length,o=this._chunkSize-this._offset,n=0,r=this,s="function"==typeof t;if(!s){var a,g=[],c=0;this.on("error",function(A){a=A});do{var l=this._binding.writeSync(e,A,n,i,this._buffer,this._offset,o)}while(!this._hadError&&E(l[0],l[1]));if(this._hadError)throw a;var I=GN.concat(g,c);return this.close(),I}var u=this._binding.write(e,A,n,i,this._buffer,this._offset,o);function E(a,l){if(!r._hadError){var I=o-l;if(function(A){if(!A)throw new Error("have should not go down")}(I>=0),I>0){var u=r._buffer.slice(r._offset,r._offset+I);r._offset+=I,s?r.push(u):(g.push(u),c+=u.length)}if((0===l||r._offset>=r._chunkSize)&&(o=r._chunkSize,r._offset=0,r._buffer=new GN(r._chunkSize)),0===l){if(n+=i-a,i=a,!s)return!0;var d=r._binding.write(e,A,n,i,r._buffer,r._offset,r._chunkSize);return d.callback=E,void(d.buffer=A)}if(!s)return!1;t()}}u.buffer=A,u.callback=E},Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.DEFLATE)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.INFLATE)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.GZIP)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.GUNZIP)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.DEFLATERAW)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.INFLATERAW)},FL),Yb(function A(e){if(!(this instanceof A))return new A(e);FL.call(this,e,LL.UNZIP)},FL);var AU={type:"logger",log:function(A){this.output("log",A)},warn:function(A){this.output("warn",A)},error:function(A){this.output("error",A)},output:function(A,e){console&&console[A]&&console[A].apply(console,e)}},eU=new(function(){function A(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};xL(this,A),this.init(e,t)}return JL(A,[{key:"init",value:function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=e.prefix||"i18next:",this.logger=A||AU,this.options=e,this.debug=e.debug}},{key:"setDebug",value:function(A){this.debug=A}},{key:"log",value:function(){for(var A=arguments.length,e=new Array(A),t=0;t1?e-1:0),i=1;i-1?A.replace(/###/g,"."):A}function o(){return!A||"string"==typeof A}for(var n="string"!=typeof e?[].concat(e):e.split(".");n.length>1;){if(o())return{};var r=i(n.shift());!A[r]&&t&&(A[r]=new t),A=Object.prototype.hasOwnProperty.call(A,r)?A[r]:{}}return o()?{}:{obj:A,k:i(n.shift())}}function rU(A,e,t){var i=nU(A,e,Object);i.obj[i.k]=t}function sU(A,e){var t=nU(A,e),i=t.obj,o=t.k;if(i)return i[o]}function aU(A,e,t){for(var i in e)"__proto__"!==i&&"constructor"!==i&&(i in A?"string"==typeof A[i]||A[i]instanceof String||"string"==typeof e[i]||e[i]instanceof String?t&&(A[i]=e[i]):aU(A[i],e[i],t):A[i]=e[i]);return A}function gU(A){return A.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var cU={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function lU(A){return"string"==typeof A?A.replace(/[&<>"'\/]/g,function(A){return cU[A]}):A}var IU="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,uU=[" ",",","?","!",";"];function EU(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(A){if(A[e])return A[e];for(var i=e.split(t),o=A,n=0;nn+r;)r++,a=o[s=i.slice(n,n+r).join(t)];if(void 0===a)return;if(null===a)return null;if(e.endsWith(s)){if("string"==typeof a)return a;if(s&&"string"==typeof a[s])return a[s]}var g=i.slice(n+r).join(t);return g?EU(a,g,t):void 0}o=o[i[n]]}return o}}function dU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function hU(A){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return xL(this,e),i=A.call(this),IU&&tU.call(HL(i)),i.data=t||{},i.options=o,void 0===i.options.keySeparator&&(i.options.keySeparator="."),void 0===i.options.ignoreJSONStructure&&(i.options.ignoreJSONStructure=!0),i}return JL(e,[{key:"addNamespaces",value:function(A){this.options.ns.indexOf(A)<0&&this.options.ns.push(A)}},{key:"removeNamespaces",value:function(A){var e=this.options.ns.indexOf(A);e>-1&&this.options.ns.splice(e,1)}},{key:"getResource",value:function(A,e,t){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,n=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure,r=[A,e];t&&"string"!=typeof t&&(r=r.concat(t)),t&&"string"==typeof t&&(r=r.concat(o?t.split(o):t)),A.indexOf(".")>-1&&(r=A.split("."));var s=sU(this.data,r);return s||!n||"string"!=typeof t?s:EU(this.data&&this.data[A]&&this.data[A][e],t,o)}},{key:"addResource",value:function(A,e,t,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,r=[A,e];t&&(r=r.concat(n?t.split(n):t)),A.indexOf(".")>-1&&(i=e,e=(r=A.split("."))[1]),this.addNamespaces(e),rU(this.data,r,i),o.silent||this.emit("added",A,e,t,i)}},{key:"addResources",value:function(A,e,t){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in t)"string"!=typeof t[o]&&"[object Array]"!==Object.prototype.toString.apply(t[o])||this.addResource(A,e,o,t[o],{silent:!0});i.silent||this.emit("added",A,e,t)}},{key:"addResourceBundle",value:function(A,e,t,i,o){var n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},r=[A,e];A.indexOf(".")>-1&&(i=t,t=e,e=(r=A.split("."))[1]),this.addNamespaces(e);var s=sU(this.data,r)||{};i?aU(s,t,o):s=hU(hU({},s),t),rU(this.data,r,s),n.silent||this.emit("added",A,e,t)}},{key:"removeResourceBundle",value:function(A,e){this.hasResourceBundle(A,e)&&delete this.data[A][e],this.removeNamespaces(e),this.emit("removed",A,e)}},{key:"hasResourceBundle",value:function(A,e){return void 0!==this.getResource(A,e)}},{key:"getResourceBundle",value:function(A,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?hU(hU({},{}),this.getResource(A,e)):this.getResource(A,e)}},{key:"getDataByLanguage",value:function(A){return this.data[A]}},{key:"hasLanguageSomeTranslations",value:function(A){var e=this.getDataByLanguage(A);return!!(e&&Object.keys(e)||[]).find(function(A){return e[A]&&Object.keys(e[A]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),e}(),QU={processors:{},addPostProcessor:function(A){this.processors[A.name]=A},handle:function(A,e,t,i,o){var n=this;return A.forEach(function(A){n.processors[A]&&(e=n.processors[A].process(e,t,i,o))}),e}};function pU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function fU(A){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{};return xL(this,e),i=A.call(this),IU&&tU.call(HL(i)),o=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],n=t,r=HL(i),o.forEach(function(A){n[A]&&(r[A]=n[A])}),i.options=s,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=eU.create("translator"),i}return JL(e,[{key:"changeLanguage",value:function(A){A&&(this.language=A)}},{key:"exists",value:function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==A)return!1;var t=this.resolve(A,e);return t&&void 0!==t.res}},{key:"extractFromKey",value:function(A,e){var t=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");var i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,o=e.ns||this.options.defaultNS||[],n=t&&A.indexOf(t)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(A,e,t){e=e||"",t=t||"";var i=uU.filter(function(A){return e.indexOf(A)<0&&t.indexOf(A)<0});if(0===i.length)return!0;var o=new RegExp("(".concat(i.map(function(A){return"?"===A?"\\?":A}).join("|"),")")),n=!o.test(A);if(!n){var r=A.indexOf(t);r>0&&!o.test(A.substring(0,r))&&(n=!0)}return n}(A,t,i));if(n&&!r){var s=A.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:A,namespaces:o};var a=A.split(t);(t!==i||t===i&&this.options.ns.indexOf(a[0])>-1)&&(o=a.shift()),A=a.join(i)}return"string"==typeof o&&(o=[o]),{key:A,namespaces:o}}},{key:"translate",value:function(A,t,i){var o=this;if("object"!==OL(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),"object"===OL(t)&&(t=fU({},t)),t||(t={}),null==A)return"";Array.isArray(A)||(A=[String(A)]);var n=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(A[A.length-1],t),a=s.key,g=s.namespaces,c=g[g.length-1],l=t.lng||this.language,I=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(I){var u=t.nsSeparator||this.options.nsSeparator;return n?{res:"".concat(c).concat(u).concat(a),usedKey:a,exactUsedKey:a,usedLng:l,usedNS:c}:"".concat(c).concat(u).concat(a)}return n?{res:a,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:c}:a}var E=this.resolve(A,t),d=E&&E.res,h=E&&E.usedKey||a,C=E&&E.exactUsedKey||a,B=Object.prototype.toString.apply(d),Q=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,p=!this.i18nFormat||this.i18nFormat.handleAsObject;if(p&&d&&("string"!=typeof d&&"boolean"!=typeof d&&"number"!=typeof d)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(B)<0&&("string"!=typeof Q||"[object Array]"!==B)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var f=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,d,fU(fU({},t),{},{ns:g})):"key '".concat(a," (").concat(this.language,")' returned an object instead of string.");return n?(E.res=f,E):f}if(r){var m="[object Array]"===B,y=m?[]:{},D=m?C:h;for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)){var w="".concat(D).concat(r).concat(v);y[v]=this.translate(w,fU(fU({},t),{joinArrays:!1,ns:g})),y[v]===w&&(y[v]=d[v])}d=y}}else if(p&&"string"==typeof Q&&"[object Array]"===B)(d=d.join(Q))&&(d=this.extendTranslation(d,A,t,i));else{var S=!1,M=!1,R=void 0!==t.count&&"string"!=typeof t.count,_=e.hasDefaultValue(t),T=R?this.pluralResolver.getSuffix(l,t.count,t):"",N=t["defaultValue".concat(T)]||t.defaultValue;!this.isValidLookup(d)&&_&&(S=!0,d=N),this.isValidLookup(d)||(M=!0,d=a);var b=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:d,G=_&&N!==d&&this.options.updateMissing;if(M||S||G){if(this.logger.log(G?"updateKey":"missingKey",l,c,a,G?N:d),r){var k=this.resolve(a,fU(fU({},t),{},{keySeparator:!1}));k&&k.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var L=[],U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&U&&U[0])for(var F=0;F1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof A&&(A=[A]),A.forEach(function(A){if(!r.isValidLookup(e)){var a=r.extractFromKey(A,s),g=a.key;t=g;var c=a.namespaces;r.options.fallbackNS&&(c=c.concat(r.options.fallbackNS));var l=void 0!==s.count&&"string"!=typeof s.count,I=l&&!s.ordinal&&0===s.count&&r.pluralResolver.shouldUseIntlApi(),u=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,E=s.lngs?s.lngs:r.languageUtils.toResolveHierarchy(s.lng||r.language,s.fallbackLng);c.forEach(function(A){r.isValidLookup(e)||(n=A,!yU["".concat(E[0],"-").concat(A)]&&r.utils&&r.utils.hasLoadedNamespace&&!r.utils.hasLoadedNamespace(n)&&(yU["".concat(E[0],"-").concat(A)]=!0,r.logger.warn('key "'.concat(t,'" for languages "').concat(E.join(", "),'" won\'t get resolved as namespace "').concat(n,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),E.forEach(function(t){if(!r.isValidLookup(e)){o=t;var n,a=[g];if(r.i18nFormat&&r.i18nFormat.addLookupKeys)r.i18nFormat.addLookupKeys(a,g,t,A,s);else{var c;l&&(c=r.pluralResolver.getSuffix(t,s.count,s));var E="".concat(r.options.pluralSeparator,"zero");if(l&&(a.push(g+c),I&&a.push(g+E)),u){var d="".concat(g).concat(r.options.contextSeparator).concat(s.context);a.push(d),l&&(a.push(d+c),I&&a.push(d+E))}}for(;n=a.pop();)r.isValidLookup(e)||(i=n,e=r.getResource(t,A,n,s))}}))})}}),{res:e,usedKey:t,exactUsedKey:i,usedLng:o,usedNS:n}}},{key:"isValidLookup",value:function(A){return!(void 0===A||!this.options.returnNull&&null===A||!this.options.returnEmptyString&&""===A)}},{key:"getResource",value:function(A,e,t){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(A,e,t,i):this.resourceStore.getResource(A,e,t,i)}}],[{key:"hasDefaultValue",value:function(A){var e="defaultValue";for(var t in A)if(Object.prototype.hasOwnProperty.call(A,t)&&e===t.substring(0,12)&&void 0!==A[t])return!0;return!1}}]),e}();function vU(A){return A.charAt(0).toUpperCase()+A.slice(1)}var wU=function(){function A(e){xL(this,A),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=eU.create("languageUtils")}return JL(A,[{key:"getScriptPartFromCode",value:function(A){if(!A||A.indexOf("-")<0)return null;var e=A.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}},{key:"getLanguagePartFromCode",value:function(A){if(!A||A.indexOf("-")<0)return A;var e=A.split("-");return this.formatLanguageCode(e[0])}},{key:"formatLanguageCode",value:function(A){if("string"==typeof A&&A.indexOf("-")>-1){var e=["hans","hant","latn","cyrl","cans","mong","arab"],t=A.split("-");return this.options.lowerCaseLng?t=t.map(function(A){return A.toLowerCase()}):2===t.length?(t[0]=t[0].toLowerCase(),t[1]=t[1].toUpperCase(),e.indexOf(t[1].toLowerCase())>-1&&(t[1]=vU(t[1].toLowerCase()))):3===t.length&&(t[0]=t[0].toLowerCase(),2===t[1].length&&(t[1]=t[1].toUpperCase()),"sgn"!==t[0]&&2===t[2].length&&(t[2]=t[2].toUpperCase()),e.indexOf(t[1].toLowerCase())>-1&&(t[1]=vU(t[1].toLowerCase())),e.indexOf(t[2].toLowerCase())>-1&&(t[2]=vU(t[2].toLowerCase()))),t.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?A.toLowerCase():A}},{key:"isSupportedCode",value:function(A){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(A=this.getLanguagePartFromCode(A)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(A)>-1}},{key:"getBestMatchFromCodes",value:function(A){var e,t=this;return A?(A.forEach(function(A){if(!e){var i=t.formatLanguageCode(A);t.options.supportedLngs&&!t.isSupportedCode(i)||(e=i)}}),!e&&this.options.supportedLngs&&A.forEach(function(A){if(!e){var i=t.getLanguagePartFromCode(A);if(t.isSupportedCode(i))return e=i;e=t.options.supportedLngs.find(function(A){return A===i?A:A.indexOf("-")<0&&i.indexOf("-")<0?void 0:0===A.indexOf(i)?A:void 0})}}),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e):null}},{key:"getFallbackCodes",value:function(A,e){if(!A)return[];if("function"==typeof A&&(A=A(e)),"string"==typeof A&&(A=[A]),"[object Array]"===Object.prototype.toString.apply(A))return A;if(!e)return A.default||[];var t=A[e];return t||(t=A[this.getScriptPartFromCode(e)]),t||(t=A[this.formatLanguageCode(e)]),t||(t=A[this.getLanguagePartFromCode(e)]),t||(t=A.default),t||[]}},{key:"toResolveHierarchy",value:function(A,e){var t=this,i=this.getFallbackCodes(e||this.options.fallbackLng||[],A),o=[],n=function(A){A&&(t.isSupportedCode(A)?o.push(A):t.logger.warn("rejecting language code not found in supportedLngs: ".concat(A)))};return"string"==typeof A&&A.indexOf("-")>-1?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(A)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(A)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(A))):"string"==typeof A&&n(this.formatLanguageCode(A)),i.forEach(function(A){o.indexOf(A)<0&&n(t.formatLanguageCode(A))}),o}}]),A}(),SU=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],MU={1:function(A){return Number(A>1)},2:function(A){return Number(1!=A)},3:function(A){return 0},4:function(A){return Number(A%10==1&&A%100!=11?0:A%10>=2&&A%10<=4&&(A%100<10||A%100>=20)?1:2)},5:function(A){return Number(0==A?0:1==A?1:2==A?2:A%100>=3&&A%100<=10?3:A%100>=11?4:5)},6:function(A){return Number(1==A?0:A>=2&&A<=4?1:2)},7:function(A){return Number(1==A?0:A%10>=2&&A%10<=4&&(A%100<10||A%100>=20)?1:2)},8:function(A){return Number(1==A?0:2==A?1:8!=A&&11!=A?2:3)},9:function(A){return Number(A>=2)},10:function(A){return Number(1==A?0:2==A?1:A<7?2:A<11?3:4)},11:function(A){return Number(1==A||11==A?0:2==A||12==A?1:A>2&&A<20?2:3)},12:function(A){return Number(A%10!=1||A%100==11)},13:function(A){return Number(0!==A)},14:function(A){return Number(1==A?0:2==A?1:3==A?2:3)},15:function(A){return Number(A%10==1&&A%100!=11?0:A%10>=2&&(A%100<10||A%100>=20)?1:2)},16:function(A){return Number(A%10==1&&A%100!=11?0:0!==A?1:2)},17:function(A){return Number(1==A||A%10==1&&A%100!=11?0:1)},18:function(A){return Number(0==A?0:1==A?1:2)},19:function(A){return Number(1==A?0:0==A||A%100>1&&A%100<11?1:A%100>10&&A%100<20?2:3)},20:function(A){return Number(1==A?0:0==A||A%100>0&&A%100<20?1:2)},21:function(A){return Number(A%100==1?1:A%100==2?2:A%100==3||A%100==4?3:0)},22:function(A){return Number(1==A?0:2==A?1:(A<0||A>10)&&A%10==0?2:3)}},RU=["v1","v2","v3"],_U={zero:0,one:1,two:2,few:3,many:4,other:5};var TU=function(){function A(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};xL(this,A),this.languageUtils=e,this.options=i,this.logger=eU.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(t={},SU.forEach(function(A){A.lngs.forEach(function(e){t[e]={numbers:A.nr,plurals:MU[A.fc]}})}),t)}return JL(A,[{key:"addRule",value:function(A,e){this.rules[A]=e}},{key:"getRule",value:function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(A,{type:e.ordinal?"ordinal":"cardinal"})}catch(t){return}return this.rules[A]||this.rules[this.languageUtils.getLanguagePartFromCode(A)]}},{key:"needsPlural",value:function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=this.getRule(A,e);return this.shouldUseIntlApi()?t&&t.resolvedOptions().pluralCategories.length>1:t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(A,t).map(function(A){return"".concat(e).concat(A)})}},{key:"getSuffixes",value:function(A){var e=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getRule(A,t);return i?this.shouldUseIntlApi()?i.resolvedOptions().pluralCategories.sort(function(A,e){return _U[A]-_U[e]}).map(function(A){return"".concat(e.options.prepend).concat(A)}):i.numbers.map(function(i){return e.getSuffix(A,i,t)}):[]}},{key:"getSuffix",value:function(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.getRule(A,t);return i?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(i.select(e)):this.getSuffixRetroCompatible(i,e):(this.logger.warn("no plural rule found for: ".concat(A)),"")}},{key:"getSuffixRetroCompatible",value:function(A,e){var t=this,i=A.noAbs?A.plurals(e):A.plurals(Math.abs(e)),o=A.numbers[i];this.options.simplifyPluralSuffix&&2===A.numbers.length&&1===A.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var n=function(){return t.options.prepend&&o.toString()?t.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===A.numbers.length&&1===A.numbers[0]?n():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}},{key:"shouldUseIntlApi",value:function(){return!RU.includes(this.options.compatibilityJSON)}}]),A}();function NU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function bU(A){for(var e=1;e3&&void 0!==arguments[3]?arguments[3]:".",o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=function(A,e,t){var i=sU(A,t);return void 0!==i?i:sU(e,t)}(A,e,t);return!n&&o&&"string"==typeof t&&void 0===(n=EU(A,t,i))&&(n=EU(e,t,i)),n}var kU=function(){function A(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};xL(this,A),this.logger=eU.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(A){return A},this.init(e)}return JL(A,[{key:"init",value:function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};A.interpolation||(A.interpolation={escapeValue:!0});var e=A.interpolation;this.escape=void 0!==e.escape?e.escape:lU,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?gU(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?gU(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?gU(e.nestingPrefix):e.nestingPrefixEscaped||gU("$t("),this.nestingSuffix=e.nestingSuffix?gU(e.nestingSuffix):e.nestingSuffixEscaped||gU(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var A="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(A,"g");var e="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(e,"g");var t="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(t,"g")}},{key:"interpolate",value:function(A,e,t,i){var o,n,r,s=this,a=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function g(A){return A.replace(/\$/g,"$$$$")}var c=function(A){if(A.indexOf(s.formatSeparator)<0){var o=GU(e,a,A,s.options.keySeparator,s.options.ignoreJSONStructure);return s.alwaysFormat?s.format(o,void 0,t,bU(bU(bU({},i),e),{},{interpolationkey:A})):o}var n=A.split(s.formatSeparator),r=n.shift().trim(),g=n.join(s.formatSeparator).trim();return s.format(GU(e,a,r,s.options.keySeparator,s.options.ignoreJSONStructure),g,t,bU(bU(bU({},i),e),{},{interpolationkey:r}))};this.resetRegExp();var l=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,I=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(A){return g(A)}},{regex:this.regexp,safeValue:function(A){return s.escapeValue?g(s.escape(A)):g(A)}}].forEach(function(e){for(r=0;o=e.regex.exec(A);){var t=o[1].trim();if(void 0===(n=c(t)))if("function"==typeof l){var a=l(A,o,i);n="string"==typeof a?a:""}else if(i&&Object.prototype.hasOwnProperty.call(i,t))n="";else{if(I){n=o[0];continue}s.logger.warn("missed to pass in variable ".concat(t," for interpolating ").concat(A)),n=""}else"string"==typeof n||s.useRawValueToEscape||(n=oU(n));var g=e.safeValue(n);if(A=A.replace(o[0],g),I?(e.regex.lastIndex+=n.length,e.regex.lastIndex-=o[0].length):e.regex.lastIndex=0,++r>=s.maxReplaces)break}}),A}},{key:"nest",value:function(A,e){var t,i,o,n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function s(A,e){var t=this.nestingOptionsSeparator;if(A.indexOf(t)<0)return A;var i=A.split(new RegExp("".concat(t,"[ ]*{"))),n="{".concat(i[1]);A=i[0];var r=(n=this.interpolate(n,o)).match(/'/g),s=n.match(/"/g);(r&&r.length%2==0&&!s||s.length%2!=0)&&(n=n.replace(/'/g,'"'));try{o=JSON.parse(n),e&&(o=bU(bU({},e),o))}catch(__){return this.logger.warn("failed parsing options string in nesting for key ".concat(A),__),"".concat(A).concat(t).concat(n)}return delete o.defaultValue,A}for(;t=this.nestingRegexp.exec(A);){var a=[];(o=(o=bU({},r)).replace&&"string"!=typeof o.replace?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;var g=!1;if(-1!==t[0].indexOf(this.formatSeparator)&&!/{.*}/.test(t[1])){var c=t[1].split(this.formatSeparator).map(function(A){return A.trim()});t[1]=c.shift(),a=c,g=!0}if((i=e(s.call(this,t[1].trim(),o),o))&&t[0]===A&&"string"!=typeof i)return i;"string"!=typeof i&&(i=oU(i)),i||(this.logger.warn("missed to resolve ".concat(t[1]," for nesting ").concat(A)),i=""),g&&(i=a.reduce(function(A,e){return n.format(A,e,r.lng,bU(bU({},r),{},{interpolationkey:t[1].trim()}))},i.trim())),A=A.replace(t[0],i),this.regexp.lastIndex=0}return A}}]),A}();function LU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function UU(A){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};xL(this,A),this.logger=eU.create("formatter"),this.options=e,this.formats={number:FU(function(A,e){var t=new Intl.NumberFormat(A,UU({},e));return function(A){return t.format(A)}}),currency:FU(function(A,e){var t=new Intl.NumberFormat(A,UU(UU({},e),{},{style:"currency"}));return function(A){return t.format(A)}}),datetime:FU(function(A,e){var t=new Intl.DateTimeFormat(A,UU({},e));return function(A){return t.format(A)}}),relativetime:FU(function(A,e){var t=new Intl.RelativeTimeFormat(A,UU({},e));return function(A){return t.format(A,e.range||"day")}}),list:FU(function(A,e){var t=new Intl.ListFormat(A,UU({},e));return function(A){return t.format(A)}})},this.init(e)}return JL(A,[{key:"init",value:function(A){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}},{key:"add",value:function(A,e){this.formats[A.toLowerCase().trim()]=e}},{key:"addCached",value:function(A,e){this.formats[A.toLowerCase().trim()]=FU(e)}},{key:"format",value:function(A,e,t){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(function(A,e){var n=function(A){var e=A.toLowerCase().trim(),t={};if(A.indexOf("(")>-1){var i=A.split("(");e=i[0].toLowerCase().trim();var o=i[1].substring(0,i[1].length-1);"currency"===e&&o.indexOf(":")<0?t.currency||(t.currency=o.trim()):"relativetime"===e&&o.indexOf(":")<0?t.range||(t.range=o.trim()):o.split(";").forEach(function(A){if(A){var e=ZL(A.split(":")),i=e[0],o=e.slice(1).join(":").trim().replace(/^'+|'+$/g,"");t[i.trim()]||(t[i.trim()]=o),"false"===o&&(t[i.trim()]=!1),"true"===o&&(t[i.trim()]=!0),isNaN(o)||(t[i.trim()]=parseInt(o,10))}})}return{formatName:e,formatOptions:t}}(e),r=n.formatName,s=n.formatOptions;if(i.formats[r]){var a=A;try{var g=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},c=g.locale||g.lng||o.locale||o.lng||t;a=i.formats[r](A,c,UU(UU(UU({},s),o),g))}catch(l){i.logger.warn(l)}return a}return i.logger.warn("there was no format function for ".concat(r)),A},A)}}]),A}();function xU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function PU(A){for(var e=1;e3&&void 0!==arguments[3]?arguments[3]:{};return xL(this,e),n=A.call(this),IU&&tU.call(HL(n)),n.backend=t,n.store=i,n.services=o,n.languageUtils=o.languageUtils,n.options=r,n.logger=eU.create("backendConnector"),n.waitingReads=[],n.maxParallelReads=r.maxParallelReads||10,n.readingCalls=0,n.maxRetries=r.maxRetries>=0?r.maxRetries:5,n.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,n.state={},n.queue=[],n.backend&&n.backend.init&&n.backend.init(o,r.backend,r),n}return JL(e,[{key:"queueLoad",value:function(A,e,t,i){var o=this,n={},r={},s={},a={};return A.forEach(function(A){var i=!0;e.forEach(function(e){var s="".concat(A,"|").concat(e);!t.reload&&o.store.hasResourceBundle(A,e)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===r[s]&&(r[s]=!0):(o.state[s]=1,i=!1,void 0===r[s]&&(r[s]=!0),void 0===n[s]&&(n[s]=!0),void 0===a[e]&&(a[e]=!0)))}),i||(s[A]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(a)}}},{key:"loaded",value:function(A,e,t){var i=A.split("|"),o=i[0],n=i[1];e&&this.emit("failedLoading",o,n,e),t&&this.store.addResourceBundle(o,n,t),this.state[A]=e?-1:2;var r={};this.queue.forEach(function(t){var i,s,a,g,c,l;i=t.loaded,s=n,g=nU(i,[o],Object),c=g.obj,l=g.k,c[l]=c[l]||[],a&&(c[l]=c[l].concat(s)),a||c[l].push(s),function(A,e){void 0!==A.pending[e]&&(delete A.pending[e],A.pendingCount--)}(t,A),e&&t.errors.push(e),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(function(A){r[A]||(r[A]={});var e=t.loaded[A];e.length&&e.forEach(function(e){void 0===r[A][e]&&(r[A][e]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",r),this.queue=this.queue.filter(function(A){return!A.done})}},{key:"read",value:function(A,e,t){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,r=arguments.length>5?arguments[5]:void 0;if(!A.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:A,ns:e,fcName:t,tried:o,wait:n,callback:r});else{this.readingCalls++;var s=function(s,a){if(i.readingCalls--,i.waitingReads.length>0){var g=i.waitingReads.shift();i.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}s&&a&&o2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof A&&(A=this.languageUtils.toResolveHierarchy(A)),"string"==typeof e&&(e=[e]);var n=this.queueLoad(A,e,i,o);if(!n.toLoad.length)return n.pending.length||o(),null;n.toLoad.forEach(function(A){t.loadOne(A)})}},{key:"load",value:function(A,e,t){this.prepareLoading(A,e,{},t)}},{key:"reload",value:function(A,e,t){this.prepareLoading(A,e,{reload:!0},t)}},{key:"loadOne",value:function(A){var e=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=A.split("|"),o=i[0],n=i[1];this.read(o,n,"read",void 0,void 0,function(i,r){i&&e.logger.warn("".concat(t,"loading namespace ").concat(n," for language ").concat(o," failed"),i),!i&&r&&e.logger.log("".concat(t,"loaded namespace ").concat(n," for language ").concat(o),r),e.loaded(A,i,r)})}},{key:"saveMissing",value:function(A,e,t,i,o){var n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn('did not save key "'.concat(t,'" as the namespace "').concat(e,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=t&&""!==t){if(this.backend&&this.backend.create){var s=PU(PU({},n),{},{isUpdate:o}),a=this.backend.create.bind(this.backend);if(a.length<6)try{var g;(g=5===a.length?a(A,e,t,i,s):a(A,e,t,i))&&"function"==typeof g.then?g.then(function(A){return r(null,A)}).catch(r):r(null,g)}catch(c){r(c)}else a(A,e,t,i,r,s)}A&&A[0]&&this.store.addResource(A[0],e,t,i)}}}]),e}();function HU(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(A){var e={};if("object"===OL(A[1])&&(e=A[1]),"string"==typeof A[1]&&(e.defaultValue=A[1]),"string"==typeof A[2]&&(e.tDescription=A[2]),"object"===OL(A[2])||"object"===OL(A[3])){var t=A[3]||A[2];Object.keys(t).forEach(function(A){e[A]=t[A]})}return e},interpolation:{escapeValue:!0,format:function(A,e,t,i){return A},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function qU(A){return"string"==typeof A.ns&&(A.ns=[A.ns]),"string"==typeof A.fallbackLng&&(A.fallbackLng=[A.fallbackLng]),"string"==typeof A.fallbackNS&&(A.fallbackNS=[A.fallbackNS]),A.supportedLngs&&A.supportedLngs.indexOf("cimode")<0&&(A.supportedLngs=A.supportedLngs.concat(["cimode"])),A}function VU(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,i)}return t}function jU(A){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(xL(this,e),t=A.call(this),IU&&tU.call(HL(t)),t.options=qU(o),t.services={},t.logger=eU,t.modules={external:[]},i=HL(t),Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach(function(A){"function"==typeof i[A]&&(i[A]=i[A].bind(i))}),n&&!t.isInitialized&&!o.isClone){if(!t.options.initImmediate)return t.init(o,n),jL(t,HL(t));setTimeout(function(){t.init(o,n)},0)}return t}return JL(e,[{key:"init",value:function(){var A=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;"function"==typeof e&&(t=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));var i=HU();function o(A){return A?"function"==typeof A?new A:A:null}if(this.options=jU(jU(jU({},i),this.options),qU(e)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=jU(jU({},i.interpolation),this.options.interpolation)),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){var n;this.modules.logger?eU.init(o(this.modules.logger),this.options):eU.init(null,this.options),this.modules.formatter?n=this.modules.formatter:"undefined"!=typeof Intl&&(n=OU);var r=new wU(this.options);this.store=new BU(this.options.resources,this.options);var s=this.services;s.logger=eU,s.resourceStore=this.store,s.languageUtils=r,s.pluralResolver=new TU(r,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!n||this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format||(s.formatter=o(n),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new kU(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new JU(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),o=1;o1?t-1:0),o=1;o0&&"dev"!==a[0]&&(this.options.lng=a[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(e){A[e]=function(){var t;return(t=A.store)[e].apply(t,arguments)}});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(e){A[e]=function(){var t;return(t=A.store)[e].apply(t,arguments),A}});var g=iU(),c=function(){var e=function(e,i){A.isInitialized&&!A.initializedStoreOnce&&A.logger.warn("init: i18next is already initialized. You should call init just once!"),A.isInitialized=!0,A.options.isClone||A.logger.log("initialized",A.options),A.emit("initialized",A.options),g.resolve(i),t(e,i)};if(A.languages&&"v1"!==A.options.compatibilityAPI&&!A.isInitialized)return e(null,A.t.bind(A));A.changeLanguage(A.options.lng,e)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),g}},{key:"loadResources",value:function(A){var e=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:WU,i="string"==typeof A?A:this.language;if("function"==typeof A&&(t=A),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return t();var o=[],n=function(A){A&&e.services.languageUtils.toResolveHierarchy(A).forEach(function(A){o.indexOf(A)<0&&o.push(A)})};if(i)n(i);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(A){return n(A)});this.options.preload&&this.options.preload.forEach(function(A){return n(A)}),this.services.backendConnector.load(o,this.options.ns,function(A){A||e.resolvedLanguage||!e.language||e.setResolvedLanguage(e.language),t(A)})}else t(null)}},{key:"reloadResources",value:function(A,e,t){var i=iU();return A||(A=this.languages),e||(e=this.options.ns),t||(t=WU),this.services.backendConnector.reload(A,e,function(A){i.resolve(),t(A)}),i}},{key:"use",value:function(A){if(!A)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!A.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===A.type&&(this.modules.backend=A),("logger"===A.type||A.log&&A.warn&&A.error)&&(this.modules.logger=A),"languageDetector"===A.type&&(this.modules.languageDetector=A),"i18nFormat"===A.type&&(this.modules.i18nFormat=A),"postProcessor"===A.type&&QU.addPostProcessor(A),"formatter"===A.type&&(this.modules.formatter=A),"3rdParty"===A.type&&this.modules.external.push(A),this}},{key:"setResolvedLanguage",value:function(A){if(A&&this.languages&&!(["cimode","dev"].indexOf(A)>-1))for(var e=0;e-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}}},{key:"changeLanguage",value:function(A,e){var t=this;this.isLanguageChangingTo=A;var i=iU();this.emit("languageChanging",A);var o=function(A){t.language=A,t.languages=t.services.languageUtils.toResolveHierarchy(A),t.resolvedLanguage=void 0,t.setResolvedLanguage(A)},n=function(n){A||n||!t.services.languageDetector||(n=[]);var r="string"==typeof n?n:t.services.languageUtils.getBestMatchFromCodes(n);r&&(t.language||o(r),t.translator.language||t.translator.changeLanguage(r),t.services.languageDetector&&t.services.languageDetector.cacheUserLanguage&&t.services.languageDetector.cacheUserLanguage(r)),t.loadResources(r,function(A){!function(A,n){n?(o(n),t.translator.changeLanguage(n),t.isLanguageChangingTo=void 0,t.emit("languageChanged",n),t.logger.log("languageChanged",n)):t.isLanguageChangingTo=void 0,i.resolve(function(){return t.t.apply(t,arguments)}),e&&e(A,function(){return t.t.apply(t,arguments)})}(A,r)})};return A||!this.services.languageDetector||this.services.languageDetector.async?!A&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(n):this.services.languageDetector.detect(n):n(A):n(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(A,e,t){var i=this,o=function A(e,o){var n;if("object"!==OL(o)){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=t.lng||this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;var r=function(A,t){var i=e.services.backendConnector.state["".concat(A,"|").concat(t)];return-1===i||2===i};if(t.precheck){var s=t.precheck(this,r);if(void 0!==s)return s}return!!this.hasResourceBundle(i,A)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!r(i,A)||o&&!r(n,A)))}},{key:"loadNamespaces",value:function(A,e){var t=this,i=iU();return this.options.ns?("string"==typeof A&&(A=[A]),A.forEach(function(A){t.options.ns.indexOf(A)<0&&t.options.ns.push(A)}),this.loadResources(function(A){i.resolve(),e&&e(A)}),i):(e&&e(),Promise.resolve())}},{key:"loadLanguages",value:function(A,e){var t=iU();"string"==typeof A&&(A=[A]);var i=this.options.preload||[],o=A.filter(function(A){return i.indexOf(A)<0});return o.length?(this.options.preload=i.concat(o),this.loadResources(function(A){t.resolve(),e&&e(A)}),t):(e&&e(),Promise.resolve())}},{key:"dir",value:function(A){if(A||(A=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!A)return"rtl";var e=this.services&&this.services.languageUtils||new wU(HU());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(A))>-1||A.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var A=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:WU,o=jU(jU(jU({},this.options),t),{isClone:!0}),n=new e(o);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach(function(e){n[e]=A[e]}),n.services=jU({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n.translator=new DU(n.services,n.options),n.translator.on("*",function(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)});var ZU=zU.createInstance();ZU.createInstance=zU.createInstance,ZU.createInstance,ZU.dir,ZU.init,ZU.loadResources,ZU.reloadResources,ZU.use,ZU.changeLanguage,ZU.getFixedT,ZU.t,ZU.exists,ZU.setDefaultNamespace,ZU.hasLoadedNamespace,ZU.loadNamespaces,ZU.loadLanguages;const XU="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),$U="undefined"!=typeof uni&&"undefined"==typeof window,AF="undefined"!=typeof uni,eF=("undefined"!=typeof uni||"undefined"!=typeof window)&&!(XU||$U),tF=XU?wx:AF?uni:"undefined"!=typeof window?window:{},iF=eF&&window&&window.navigator&&window.navigator.userAgent||"",oF=/Android/i.test(iF),nF=/(?:Windows Phone)/.test(iF),rF=/(?:SymbianOS)/.test(iF),sF=/OpenHarmony/i.test(iF),aF=eF&&("ontouchstart"in window||navigator.maxTouchPoints>0)&&function(){if(eF){if(/Tablet|Pad/i.test(iF))return!0;if(180===window.orientation||0===window.orientation)return window.innerWidth>=768&&window.innerHeight>=1024;if(90===window.orientation||-90===window.orientation)return window.innerWidth>=1024&&window.innerHeight>=768}return!1}(),gF=/iPhone/i.test(iF)||/iPod/i.test(iF),cF=XU,lF=oF||nF||rF||gF||aF||sF,IF=eF&&!lF,uF=$U&&!XU;function EF(){let A="";return IF?A="pc":lF?A="h5":cF?A="wechat":uF&&(A="app"),A}const dF=new Map;function hF(A,e){dF.set(A,e)}function CF(A,e){if(!A)return Promise.reject(new Error(`getBoundingClientRect get error selector ${typeof A}.`));if(window||document){const e="object"==typeof A?A:document.querySelector(A);if(!e)return Promise.reject(new Error(`getBoundingClientRect can't find ${A} dom.`));const t=e.getBoundingClientRect();return Promise.resolve({id:e.id,top:t.top,left:t.left,right:t.right,bottom:t.bottom,width:t.width,height:t.height,x:t.x,y:t.y})}if(AF){if(!e)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const t=uni.createSelectorQuery().in(dF.get(e));return new Promise((e,i)=>{t.select(A).boundingClientRect(A=>{A&&e(A)}).exec(),setTimeout(()=>i(new Error(`getBoundingClientRect ${A} timeout.`)),500)})}return Promise.reject(new Error("getBoundingClientRect occur error"))}function BF(A,e){if(!A)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof A}.`));if(!AF&&window){const e="object"==typeof A?A:document.querySelector(A);return e?Promise.resolve({id:e.id,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight}):Promise.reject(new Error(`getScrollInfo can't find ${A} dom.`))}if(AF){if(!e)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const t=uni.createSelectorQuery().in(dF.get(e));return new Promise((e,i)=>{t.select(A).scrollOffset(A=>{A&&e(A)}).exec(),setTimeout(()=>i(new Error(`getScrollInfo ${A} timeout.`)),500)})}return Promise.reject(new Error("getScrollInfo occur error"))}class QF{constructor(){if(QF.instance)return QF.instance;QF.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){eF&&(this.eventCallback=A=>{this.listener&&this.listener(A)},document.addEventListener("mousedown",this.eventCallback))}listen(A){if(eF){const{domRefs:e,ignoreDomRefs:t,handler:i,button:o=0}=A;this.button=o,this.listener=A=>{const o=Array.isArray(t)?t:[t];for(const e of o)if(e&&e.contains(A.target))return;const n=Array.isArray(e)?e:[e];for(const e of n)if(e&&e.contains(A.target)&&this.button===A.button)return;i(A),this.remove()}}}remove(){this.listener=null,this.button=-1}}function pF(A){const{element:e,onLongPress:t,options:i={}}=A;if(!e||!t)throw new Error("addLongPressEventListener missing arguments");const{duration:o=800,eventDelegation:n}=i;let r;function s(){clearTimeout(r),g()}function a(){clearTimeout(r),g()}function g(){e.removeEventListener("pointerup",s),e.removeEventListener("pointermove",a)}e.addEventListener("pointerdown",A=>{const i=A.target,g=(null==n?void 0:n.subSelector)?i.closest(n.subSelector)||void 0:i,c=A.currentTarget;r=setTimeout(()=>t(A,g,c),o),e.addEventListener("pointerup",s),e.addEventListener("pointermove",a)})}const fF={PROTOCOLS:["javascript:","vbscript:","file:","about:","ftp:","ws:","wss:","mailto:","tel:","sms:","gopher:","data:","blob:"],HTML_TAGS:["","]]>","{if(A&&t.push({type:"text",text:A}),o[n]){const A=o[n];let e=A;A.toLowerCase().startsWith("www.")&&(e="https://"+A),t.push({type:"url",text:A,url:e}),n++}}),t}(A).map(A=>{if("url"===A.type){const e=function(e,t={}){const{maxLength:i=2083,allowedProtocols:o=["http:","https:","mailto:"],allowCredentials:n=!1,allowDataUrl:r=!1}=t;if(!e||"string"!=typeof e)return"about:blank";if(e.length>i)return"about:blank";try{let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/g,"");t=t.normalize("NFKC"),t=t.replace(/\s+/g," ").trim();let i=t;const s=new Set;let a=0;for(;a<5;)try{const A=decodeURIComponent(i);if(s.has(A))break;s.add(A),i=A,a++}catch(A){break}const g=function(){const A=[],e=Object.keys(fF);for(let t=0;t1){const A=t[0].split(":");o=A[0]||"",n=A[1]||""}const r=i.split(":"),s=r[0],a=r[1]||"";return{href:A,protocol:(e[1]||"").toLowerCase(),host:i,hostname:s,port:a,pathname:e[5]||"",search:e[6]||"",hash:e[8]||"",username:o,password:n}}(t),l=c.protocol.replace(":","").toLowerCase()+":";let I=!1;for(let A=0;A"function"==typeof A,vF=A=>/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(A),wF=A=>A&&(A=>{if("string"==typeof A)try{return!!JSON.parse(A)}catch(e){return!1}return!1})(A)?JSON.parse(A):A,SF="pc"===EF(),MF="h5"===EF(),RF="wechat"===EF(),_F="app"===EF(),TF="undefined"!=typeof uni,NF=MF||RF||_F;class bF{constructor(){XR.registerEvent(KR.TUILogin.EVENT.LOGIN_STATE_CHANGED,KR.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS,this),XR.registerService(KR.TUICalling.SERVICE.NAME,this),XR.registerExtension(KR.TUIChat.EXTENSION.INPUT_MORE.EXT_ID,this)}onNotifyEvent(A,e){if(A===KR.TUILogin.EVENT.LOGIN_STATE_CHANGED){let A,t,i,o;if(e===KR.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS)o=$R.getContext(),A=o.SDKAppID,t=o.userID,i=o.userSig,tF.$TUICallKit&&tF.$TUICallKit.login({SDKAppID:A,userID:t,userSig:i},A=>{0===A.code?(console.log("TUICallkit login success!"),tF.$TUICallKit.enableFloatWindow(!0)):console.error(`TUICallkit login failed,${A.msg}`)})}}onGetExtension(A,e){if(!tF.$TUICallKit)return console.warn("请检查原生插件 TencentCloud-TUICallKit 是否已集成"),[];if(A===KR.TUIChat.EXTENSION.INPUT_MORE.EXT_ID){const A=[],t={weight:1e3,text:"语音通话",icon:"https://web.sdk.qcloud.com/component/TUIKit/assets/uni-app/voice-call.svg",data:{name:"voiceCall"},listener:{onClicked:A=>{this.setCallExtension(A)}}},i={weight:900,text:"视频通话",icon:"https://web.sdk.qcloud.com/component/TUIKit/assets/uni-app/video-call.svg",data:{name:"videoCall"},listener:{onClicked:A=>{this.setCallExtension(A)}}};return(null==e?void 0:e.filterVoice)||A.push(t),(null==e?void 0:e.filterVideo)||A.push(i),A}}onCall(A,e){if(tF.$TUICallKit){if(A===KR.TUICalling.SERVICE.METHOD.START_CALL){const{groupID:A,userIDList:t=[],type:i,callParams:o}=e;tF.$TUICallKit.calls({userIDList:t,callMediaType:i,callParams:{...o,chatGroupId:A}},A=>{0===A.code?console.log("TUICallkit calls success"):console.error(`TUICallkit calls failed,${A.msg}`)})}}else console.warn("请检查原生插件 TencentCloud-TUICallKit 是否已集成")}setCallExtension(A){const{groupID:e,userIDList:t=[],type:i,callParams:o}=A;try{tF.$TUICallKit.calls({userIDList:t,callMediaType:i,callParams:{...o,chatGroupId:e}},A=>{0===A.code?console.log("TUICallkit calls success"):console.log(`TUICallkit calls failed,${A.msg}`)})}catch(n){tF.showToast({title:"拨打失败!",icon:"error"})}}}const GF={"[TUIEmoji_Smile]":"[Smile]","[TUIEmoji_Expect]":"[Expect]","[TUIEmoji_Blink]":"[Blink]","[TUIEmoji_Guffaw]":"[Guffaw]","[TUIEmoji_KindSmile]":"[KindSmile]","[TUIEmoji_Haha]":"[Haha]","[TUIEmoji_Cheerful]":"[Cheerful]","[TUIEmoji_Speechless]":"[Speechless]","[TUIEmoji_Amazed]":"[Amazed]","[TUIEmoji_Sorrow]":"[Sorrow]","[TUIEmoji_Complacent]":"[Complacent]","[TUIEmoji_Silly]":"[Silly]","[TUIEmoji_Lustful]":"[Lustful]","[TUIEmoji_Giggle]":"[Giggle]","[TUIEmoji_Kiss]":"[Kiss]","[TUIEmoji_Wail]":"[Wail]","[TUIEmoji_TearsLaugh]":"[TearsLaugh]","[TUIEmoji_Trapped]":"[Trapped]","[TUIEmoji_Mask]":"[Mask]","[TUIEmoji_Fear]":"[Fear]","[TUIEmoji_BareTeeth]":"[BareTeeth]","[TUIEmoji_FlareUp]":"[FlareUp]","[TUIEmoji_Yawn]":"[Yawn]","[TUIEmoji_Tact]":"[Tact]","[TUIEmoji_Stareyes]":"[StarEyes]","[TUIEmoji_ShutUp]":"[ShutUp]","[TUIEmoji_Sigh]":"[Sigh]","[TUIEmoji_Hehe]":"[Hehe]","[TUIEmoji_Silent]":"[Silent]","[TUIEmoji_Surprised]":"[Surprised]","[TUIEmoji_Askance]":"[Askance]]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[Shit]","[TUIEmoji_Monster]":"[Monster]","[TUIEmoji_Daemon]":"[Daemon]","[TUIEmoji_Rage]":"[Rage]","[TUIEmoji_Fool]":"[Fool]","[TUIEmoji_Pig]":"[Pig]","[TUIEmoji_Cow]":"[Cow]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[Skull]","[TUIEmoji_Bombs]":"[Bombs]","[TUIEmoji_Coffee]":"[Coffee]","[TUIEmoji_Cake]":"[Cake]","[TUIEmoji_Beer]":"[Beer]","[TUIEmoji_Flower]":"[Flower]","[TUIEmoji_Watermelon]":"[Watermelon]","[TUIEmoji_Rich]":"[Rich]","[TUIEmoji_Heart]":"[Heart]","[TUIEmoji_Moon]":"[Moon]","[TUIEmoji_Sun]":"[Sun]","[TUIEmoji_Star]":"[Star]","[TUIEmoji_RedPacket]":"[RedPacket]","[TUIEmoji_Celebrate]":"[Celebrate]","[TUIEmoji_Bless]":"[Bless]","[TUIEmoji_Fortune]":"[Fortune]","[TUIEmoji_Convinced]":"[Convinced]","[TUIEmoji_Prohibit]":"[Prohibit]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[Knife]","[TUIEmoji_Like]":"[Like]"},kF={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},LF={...{en:{"取消":"Cancel","发送":"Send","系统通知":"System notification","关闭":"Close","确定":"Save","开始时间":"Start Date","结束时间":"End Date","消息":"Messages","通讯录":"Contacts","欢迎使用腾讯云即时通信IM":"Welcome to Tencent Cloud Chat",TUIChat:{"【安全提示】本 APP 仅用于体验腾讯云即时通信 IM 产品功能,不可用于业务洽谈与拓展。请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。":"【Security Tips】This APP is only used to experience the functions of Tencent Cloud Instant Messaging products, and cannot be used for business negotiation and expansion. Don't trust money-related information such as remittances and lottery wins, don't make unfamiliar phone calls easily, and beware of being deceived.","按Enter发送,Ctrl+Enter换行":"Press Enter to send a message and Ctrl+Enter to start a new line","表情":"[Face]","查看更多":"View more","撤回":"Recall","撤回了一条消息":" recalled a message","打开":"Open","单击下载":"Click download","点此投诉":"Complain","点击处理":"Click action","对方正在输入":"Typing...","发起群视频":"Make group video call","发起群语音":"Make group voice call","发起通话":"Start Call","发送失败":"send failed","复制":"Copy","复制成功":"Copied to clipboard","该消息不存在":"The message does not exist","关闭阅读状态":"Read status closed","管理员开启全员禁言":"The admin enables Mute All","欢迎使用TUICallKit":"Welcome to TUICallKit","回到最新位置":"Back to the latest location","回复":"Reply","回复详情":"Replies","集成TUICallKit":" Integrate TUICallKit ","检测到您暂未集成TUICallKit,无法体验音视频通话功能":"It is detected that you have not integrated TUI CallKit yet, so you cannot experience the audio and video call. ","结束群聊":"Edit Group Call","进行体验":"to experience.","经度":"Longitude","拒绝":"Reject","拒绝通话":"Decline Call","开通腾讯实时音视频服务":"Integration Tencent Real-Time Communication","聊天记录":"[Chat history]","描述":"Description","内容包含敏感词汇":"Content contains sensitive words","您":"You","您当前购买使用的套餐包暂未开通此功能":"The package you purchased does not support this ability.","您当前购买使用的套餐包暂未开通群消息已读回执功能":"The package you purchased does not support the read receipt of group messages.","您当前购买使用的套餐包暂未开通在线用户列表功能":"The package you purchased does not support the online user list.","您已被管理员禁言":"You have been muted by the admin","您有":"You have","请点击":"Please click","请输入消息":"Enter a message","取消":"Cancel","取消通话":"Cancel Call","全部已读":"All read","确定":"Submit","确认重发该消息?":"Confirm to resend the message?","人关闭阅读状态":" read status closed","人未读":" unread","人已读":" read","删除":"Delete","涉及敏感内容":"Sensitive content","申请加入":"Application for join in","视频":"[video]","视频通话":"Video Call","条回复":"replies","条入群申请":"Item group application","条新消息":" new messages","通话时长":"Duration","同意":"Agree","图片":"[Image]","图片消息失败,无效的图片格式":"Image message failed, invalid image format.","纬度":"Latitude","未读":"Unread","位置":"[Location]","文件":"[File]","文件不存在,请检查文件路径是否正确":"The file does not exist, please check if the file path is correct.","文件大小超出了限制,如果上传文件,最大限制是100MB":"The file size exceeds the limit; if uploading a file, the maximum limit is 100MB.","文件消息失败,禁止发送违规封禁的文件":"File message failed, sending prohibited and banned files is not allowed.","我":"I","无法查看":"unable to view","无法定位到原消息":"Unable to navigate to the original message","无法收听":"unable to listen","正在加载":"Loading...","加载结束":"Load end","无应答":"No Answer","系统消息":"System message","消息":"[message]","消息或者资料中文本存在敏感内容,发送失败":"Sensitive content found in the message or information text, sending failed.","消息详情":"Message Detail","消息长度超出限制,消息长度不要超过12K":"Message length exceeds the limit; please keep the message length under 12K.","消息中图片存在敏感内容,发送失败":" Sensitive content is found in the picture in the message, sending failed.","选择提醒的人":"Select Contact","已读":"Read","已过撤回时限":"Withdrawal deadline has passed","已接听":"Answered","已拒绝":"Rejected","已同意":"Approved","引用":"Reference","引用失败":"quote failed","语音":"[Voice]","语音通话":"Voice Call","重新编辑":"Re-edit","重新发送":"Resend","转发":"Forward","翻译":"Translate","转文字":"Convert","隐藏":"Hidden","转发给":"Forward to","自定义":"[custom message]","自定义消息":"Custom message","腾讯云 IM":"Tencent Cloud Chat","空":"Empty","文本包含本地审核拦截词":"Text contains local moderation blocking words","按住说话":"Hold to speak","抬起发送":"Release to send","抬起取消":"Release to cancel","正在录音":"Recording","继续上滑可取消":"Continue to swipe to cancel","松开手指 取消发送":"Release to cancel","此机型暂不支持复制功能":"This model does not support the copy","请开通翻译功能":"Please open the translation feature","请开通语音转文字功能":"Please open the convert feature","翻译中":"Translating","转换中":"Converting","由IM提供翻译支持":"support by IM","所有人":"All","已达到表情回应上限数量":"You have reached the max reaction limit","等":"and others","人":"users","返回":"Back","关闭":"Close","多选":"Select","合并转发":"Combine Forward","逐条转发":"One-By-One Forward","未选择消息":"No message selected","[草稿]":"[Drafts]","[消息]":"[Message]","[文本]":"[Text]","[自定义消息]":"[Custom Message]","[图片]":"[Image]","[音频]":"[Voice]","[语音]":"[Voice]","[视频]":"[Video]","[文件]":"[File]","[位置]":"[Location]","[地理位置]":"[Location]","[动画表情]":"[Animated Sticker]","[群提示]":"[Group Tip]","[群提示消息]":"[Group Notification]","[聊天记录]":"[Chat History]","[机器人自定义消息]":"[Robot Custom Message]","引用内容已撤回":"The quoted message has been withdrawn","群聊的聊天记录":"Chat history for Group Chat","和":"and","的聊天记录":"chat history","请升级IMSDK到v2.10.1或更高版本查看此消息":"Please upgrade IMSDK to v2.10.1 or higher to view this message","该群聊已被解散":"The group has been dismissed","您已被管理员移出群聊":"You have been removed from the group by the admin.","您已退出该群聊":"You have left the group.","您已被禁止聊天":"you have been forbidden to speak","点击打断":"Click to interrupt","停止回答":"Stop answering","确认要清空当前的聊天记录吗?":"Are you sure you want to clear the current chat history?","清空后无法恢复":"Clearing cannot be restored","回答输出中,请稍后或点击停止回答":"Answering, please wait or click stop answering","获取麦克风权限状态失败,请重试":"Failed to get microphone permission status, please try again","权限申请":"Permission Request","请允许使用麦克风权限用于发送语音消息":"Please allow microphone permission to send voice messages","需要麦克风权限":"Microphone Permission Required",'麦克风权限已被拒绝,请前往"设置 → 应用信息 → 权限"中开启麦克风权限':'Microphone permission has been denied. Please go to "Settings → App Info → Permissions" to enable microphone permission','麦克风权限已被拒绝,请前往"设置 → 隐私 → 麦克风"中开启权限':'Microphone permission has been denied. Please go to "Settings → Privacy → Microphone" to enable permission','麦克风权限已被拒绝,请前往"右上角设置"中开启权限':'Microphone permission has been denied. Please go to "Settings" in the top right corner to enable permission',"去设置":"Go to Settings","需要您授权麦克风权限以使用语音功能":"Microphone permission is required to use voice features","授权":"Authorize","录音时间太短":"Recording duration is too short","录音失败,请重试":"Recording failed, please try again"},TUIConversation:{"发起会话":"Start chat","发起单聊":"New one-to-one chat","发起群聊":"New group chat","请输入userID":"Enter a user ID","删除会话":"Delete","删除后,将清空该聊天的消息记录":"Once deleted, all chat messages will be cleared.","删除后,将清空该群聊的消息记录":"Once deleted, group chat history will be cleared.","系统通知":"System notification","置顶会话":"Pin","取消置顶":"Unpin","消息免打扰":"Mute Notifications","取消免打扰":"Enable Notifications","有人@我":"Someone @ me","@所有人":"@All","条":"strip","我":"me","网络异常,请您检查网络设置":"Network exception, please check the network settings","您已被群管理员移出群聊":"You have been removed from the group chat by the group administrator","该群聊已被解散":"The group chat has been disband","您已退出该群聊":"You have left the group chat"},TUIGroup:{"输入groupID搜索":"Enter groupId search","群名称":"Group name","群ID":"Group ID","加入群聊":"Join","解散群聊":"Dissolution","退出群聊":"Quit","群类型":"Group type","请填写验证信息":"Please fill in the verification information","申请加入":"Apply Join","群公告":"Group notice","群成员":"Group member","群管理":"Manage group","好友工作群":"Work","陌生人社交群":"Public","临时会议群":"Meeting","直播群":"AVChatRoom","社群":"Community","自由加入":"Join freely","需要验证":"Require approval","禁止加群":"Disallow group joining","人":"","确认":"Confirm","群头像":"Group profile photo","加群方式":"Group joining mode","转让群组":"Transfer ownership","退出群组":"Quit group","群管理员":"Group admin","全员禁言":"Mute All","全员禁言开启后,只允许群主和管理员发言。":"If Mute All is enabled, only the group owner and admin can speak.","单独禁言人员":"Mute a member","删除成员":"Remove member","确定从群聊中删除该成员?":"Are you sure you want to remove this member from the group chat?","确定从群聊中删除所选成员?":"Are you sure you want to remove selected member(s) from the group chat?","暂无公告":"No notice","发布":"Post","编辑":"Edit","查看更多":"View more","查看更多群成员":"View more group members","管理员":"Admin","群主":"Group owner","我":"me","添加成员":"Add member","新增管理员":"Add admin","移除管理员":"Revoke admin","新增禁言用户":"Add muted member","移除禁言用户":"Remove muted member","修改群聊名称":"Edit group name","修改群聊名称后,将在群内通知其他成员":"After modifying the group chat name, other members will be notified in the group","仅限中文、字母、数字和下划线,2-20个字":"Chinese, letters, numbers and underscores only, 2-20 words","请先注册 TUIGroup 模块":"Please register the TUIGroup module first","该用户不存在":"The user does not exist","该用户不在群组内":"The user is not in the group","添加群聊":"Add a group chat","该群组不存在":"The group does not exist","创建群聊,请注册 TUIGroup 模块":"To create a group chat, please register the TUIGroup module","创建成功":"Creation successful","发起多人会话(群聊)":"New group chat","选填":"Optional","取消":"Cancel","创建":"Create","类似普通微信群,创建后仅支持已在群内的好友邀请加群,且无需被邀请方同意或群主审批。详见":"Similar to a WeChat group. Users can join the group only via invitation by existing members. The invitation does not need to be agreed by the invitee or approved by the group owner. See the documentation for details.","类似 QQ 群,创建后群主可以指定群管理员,用户搜索群 ID 发起加群申请后,需要群主或管理员审批通过才能入群。详见":"Similar to a QQ group. After a public group is created, the group owner can designate group admins. To join the group, a user needs to search the group ID and send a request, which needs to be approved by the group owner or an admin before the user can join the group. See the documentation for details. ","创建后可以随意进出,且支持查看入群前消息;适合用于音视频会议场景、在线教育场景等与实时音视频产品结合的场景。详见":"After the group is created, a user can join and quit the group freely and can view the messages sent before joining the group. It is suitable for scenarios that integrate Tencent Real-Time Communication (TRTC), such as audio and video conferences and online education. See the documentation for details.","创建后可以随意进出,没有群成员数量上限,但不支持历史消息存储;适合与直播产品结合,用于弹幕聊天场景。详见":"After creation, a user can join and quit the group freely. The group can have an unlimited number of members, but it does not store message history. It can be combined with Live Video Broadcasting (LVB) to support on-screen comment scenarios. See the documentation for details. ","创建后可以随意进出,最多支持100000人,支持历史消息存储,用户搜索群 ID 发起加群申请后,无需管理员审批即可进群。详见":"After creation, you can enter and leave at will, support up to 100,000 people, support historical message storage, and after users search for group ID and initiate a group application, they can join the group without administrator approval. See product documentation for details. ","产品文档":"product documentation","设置群名称":"Group name","请输入群名称":"Enter the group name","设置群ID":"Group ID","请输入群ID":"Enter the group ID","选择群类型":"Group type","陌生人社交群(Public)":"Stranger social group (Public)","临时会议群(Meeting)":"Temporary meeting group (Meeting)","好友工作群(Work)":"Friends work group (Work)","直播群(AVChatroom)":"Live Streaming Group (AVChatroom)","社群(Community)":"Community(Community)","群组创建成功":"Create group success","群组解散成功":"Dismiss group success","禁言设置成功":"Mute all success","取消禁言成功":"Remove mute success","群名称不能为空":"Group name cannot be empty","群名称修改成功":"Group name modified success","群公告字数超出限制,最大长度为150":"The number of characters in the group announcement exceeds the limit, the maximum length is 150"},TUIContact:{"群聊通知":"Group Chat Notifications","系统通知":"System Notifications","我的群聊":"My Group Chats","输入ID":"Enter a groupID/userID","群名称":"Group name","群ID":"Group ID","加入群聊":"Join group chat","解散群聊":"Disband group chat","退出群聊":"Quit group chat","进入群聊":"Enter group chat","群类型":"Group type","请填写验证信息":"Enter the verification info","申请加入":"Request to join","已申请":"Requested","接受":"Accept","拒绝":"Refuse","已处理":"Handled","添加群聊":"add group chat","已加入":"joined","该群组不存在":"The group does not exist","加群":"join","我的好友":"Friend","发送消息":"Send Message","个性签名":"Signature","等待管理员同意":"Successful application, waiting for the administrator to agree to join the group application","加群成功":"Join the group successfully","您已是群成员":"You are already a group member","新的联系人":"New Contacts","黑名单":"Blocked List","无搜索结果":"No Result","客服号":"Customer Service List",ID:"ID","联系人":"User","群聊":"Group","添加好友/群聊":"Add friend/group","备注名":"remark","加入黑名单":"block","删除好友":"Delete friend","等待验证":"waiting for verification","验证信息":"verification info","发送申请":"Send application","加入直播群":"Join AVChatRoom","同意":"Agree","删除好友成功":"Delete friend success","删除好友失败":"Delete friend failed","申请已发送":"Application has been sent","申请发送失败":"Application failed to send","进入会话失败":"Failed to enter session","添加好友成功":"Add friend success","同意好友申请失败":"Failed to agree to friend request","拒绝成功":"Reject friend request success","拒绝好友申请失败":"Failed to reject friend request","解散群聊成功":"Dismissed group success","解散群聊失败":"Dismissed group failed","退出群组成功":"Quit group success","退出群组失败":"Quit group failed","申请入群失败":"Application to join the group failed","加入黑名单失败":"Add to blocklist failed","移除黑名单失败":"Remove from blocklist failed","修改备注失败: 备注长度不得超过 96 字节":"Failed to modify the remark: the length of the remark cannot exceed 96 bytes","修改备注成功":"Remark modified success","修改备注失败":"Remark modified failed"},message:{tip:{"群成员":"group members","加入群组":"joined the group","退出群组":"left the group","被":"by","踢出群组":"was kicked out of the group","成为管理员":"was set as an admin","被撤销管理员":"was revoked","被禁言":" was muted","被取消禁言":"cancel the prohibition","群提示消息":"group prompt message","管理员":"The admin","开启全员禁言":"enabled Mute All","取消全员禁言":"disabled Mute All","成为新的群主":"became the new group owner","修改群名为":"changed the group name to","发布新公告":"posted a new notice","把群公告修改为":"changed the group notice to","申请加入群组":"requested to join the group","成功加入群组":"Successfully joined the group","被拒绝":"The request to join the group was refused","你被管理员":"You","群":"group","解散":"disbanded","创建群":"created the group","邀请你加群":"invite you to join the group","你退出群组":"You left the group","你被":"You were","设置为群":"set as group","的管理员":"as an admin","撤销群":"revoked","的管理员身份":"admin role of the group","同意加群":"agreed to join the group","拒接加群":"refused to join the group","自定义群系统通知":"Custom group system notification"},custom:{"自定义消息":"Custom message","通话时长":"Call duration","通话结束":"Call End","切换语音通话":"Switch voice call","切换视频通话":"Switch video call","发起通话":"Start a call","取消通话":"Cancel","已接听":"Answered","拒绝通话":"Decline","无应答":"No answer","已取消":"Canceled","对方已取消":"Call canceled by caller","已拒绝":"Declined","对方已拒绝":"Call declined by user","对方忙线中":"Line busy","忙线未接听":"Line busy. Call not received.","对方无应答":"Call wasn't answered","超时无应答":"Call not answered","对本次服务评价":"Rate this service","查看详情>>":"View details >>"}},component:{"取消":"Cancel","完成":"Done","已选中":"Selected","人":"","保存":"Save","请输入userID":"Enter a userID","请输入groupID":"Enter a groupID","确定":"submit","全选":"All","已在群聊中":"exists","查看更多":"More","图片 url 不存在":"Image url does not exist","已取消":"Cancelled","获取权限失败":"Failed to obtain permission","已保存至相册":"Saved to album","图片下载失败":"Image download failed","暂不支持下载此类型图片":"Downloading this type of pictures is not supported yet"},time:{"周":"week(s) ","天":"day(s)","小时":"hour(s) ","分钟":"minute(s)","刚刚":"Just now","前":" ago","昨天":"Yesterday","星期一":"Monday","星期二":"Tuesday","星期三":"Wednesday","星期四":"Thursday","星期五":"Friday","星期六":"Saturday","星期日":"Sunday","一月":"January","二月":"February","三月":"March","四月":"April","五月":"May","六月":"June","七月":"July","八月":"August","九月":"September","十月":"October","十一月":"November","十二月":"December","一":"Mon","二":"Tues","三":"Wed","四":"Thur","五":"Fri","六":"Sat","日":"Sun"},Evaluate:{"请对本次服务进行评价":"Please rate this service","提交评价":"Feedback","服务评价工具":"Service rate tool","使用":"Build with","自定义消息":"Custom message","搭建":"","星":"Star"},Words:{"请对本次服务进行评价":"Please rate this service","提交评价":"Feedback","常用语-快捷回复工具":"Common Expressions - Quick Reply Tool","使用":"Build with","自定义消息":"Custom message","搭建":"","在吗?在吗?在吗?重要的话说三遍。":"Are you there? ","好久没聊天了,快来和我说说话~":"It’s been a long time. How about you?","好的,就这么说定了。":"Okay. It's a deal.","感恩的心,感谢有你。":"So grateful! ","糟糕!是心动的感觉!":"Oh, no. Flipped.","心疼地抱抱自己,我太难了!":"Give myself a warm hug. ","没关系,别在意,事情过去就过去了。":"Take it easy.","早上好,今天也是让人期待的一天呢!":"Good morning. Have a wonderful day.","熬夜有什么用,又没人陪你聊天,早点休息吧。":"It's better to go to bed early."},TUISearch:{"搜索":"Search","全部":"All","联系人":"Contacts","群聊":"Groups","聊天记录":"Chat History","文本":"Text","文件":"File","其他":"Other","图片/视频":"Image/Video","选择时间":"Select time","今天":"Today","近三天":"Nearly three days","近七天":"Nearly seven days","查看更多":"View more ","条相关":" related ","条与":" related to ","相关的":"keywords","进入聊天":"enter","定位到聊天位置":"Navigate to the chat position","搜索会话内容":"Search in conversation","查看更多历史记录":"View more history message","暂无搜索结果":"No Results","结果":"results","取消":"Cancel","[文本]":"[Text Message]","[图片]":"[Image Message]","[语音]":"[Audio Message]","[视频]":"[Video Message]","[文件]":"[File Message]","[自定义消息]":"[Custom Message]","[系统消息]":"[System Message]","[合并消息]":"[Merged Message]","[位置消息]":"[Position Message]","消息云端搜索失败:":"Message cloud search failed: ","查找联系人失败:":"Failed to find contact: ","查找群聊失败:":"Failed to find group: ","进入会话失败":"Failed to enter conversation"},Emoji:GF}},...{zh_cn:{"取消":"取消","发送":"发送","系统通知":"系统通知","关闭":"关闭","确定":"确定","开始时间":"开始时间","结束时间":"结束时间","消息":"消息","通讯录":"通讯录","欢迎使用腾讯云即时通信IM":"欢迎使用腾讯云即时通信IM",TUIChat:{"【安全提示】本 APP 仅用于体验腾讯云即时通信 IM 产品功能,不可用于业务洽谈与拓展。请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。":"【安全提示】本 APP 仅用于体验腾讯云即时通信 IM 产品功能,不可用于业务洽谈与拓展。请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。","按Enter发送,Ctrl+Enter换行":"按Enter发送,Ctrl+Enter换行","表情":"[表情]","查看更多":"查看更多","撤回":"撤回","撤回了一条消息":"撤回了一条消息","打开":"打开","单击下载":"单击下载","点此投诉":"点此投诉","点击处理":"点击处理","对方正在输入":"对方正在输入...","发起群视频":"发起群视频","发起群语音":"发起群语音","发起通话":"发起通话","发送失败":"发送失败","复制":"复制","复制成功":"文本复制成功","该消息不存在":"该消息不存在","关闭阅读状态":"关闭","管理员开启全员禁言":"管理员开启全员禁言","欢迎使用TUICallKit":"欢迎使用腾讯云音视频通话组件TUICallKit ","回到最新位置":"回到最新位置","回复":"回复","回复详情":"回复详情","集成TUICallKit":"集成 TUICallKit ","检测到您暂未集成TUICallKit,无法体验音视频通话功能":"检测到您暂未集成TUICallKit,无法体验音视频通话功能。","结束群聊":"结束群聊","进行体验":"进行体验。","经度":"经度","拒绝":"拒绝","拒绝通话":"拒绝通话","开通腾讯实时音视频服务":"开通腾讯实时音视频服务","聊天记录":"[聊天记录]","描述":"描述","内容包含敏感词汇":"内容包含敏感词汇","您":"您","您当前购买使用的套餐包暂未开通此功能":"您当前购买使用的套餐包暂未开通此功能。","您当前购买使用的套餐包暂未开通群消息已读回执功能":"您当前购买使用的套餐包暂未开通【群消息已读回执】功能,请升级至旗舰版进行体验","您当前购买使用的套餐包暂未开通在线用户列表功能":"您当前购买使用的套餐包暂未开通【在线用户列表】功能,请升级至旗舰版进行体验","您已被管理员禁言":"您已被管理员禁言","您有":"您有","请点击":"请点击","请输入消息":"请输入消息","取消":"取消","取消通话":"取消通话","全部已读":"全部已读","确定":"确定","确认重发该消息?":"确认重发该消息?","人关闭阅读状态":"人关闭阅读状态","人未读":"人未读","人已读":"人已读","删除":"删除","涉及敏感内容":"涉及敏感内容","申请加入":"申请加入","视频":"[视频]","视频通话":"视频通话","条回复":"条回复","条入群申请":"条入群申请","条新消息":"条新消息","通话时长":"通话时长","同意":"同意","图片":"[图片]","图片消息失败,无效的图片格式":"图片消息失败,无效的图片格式","纬度":"纬度","未读":"未读","位置":"[位置]","文件":"[文件]","文件不存在,请检查文件路径是否正确":"文件不存在,请检查文件路径是否正确","文件大小超出了限制,如果上传文件,最大限制是100MB":"文件大小超出了限制,如果上传文件,最大限制是100MB","文件消息失败,禁止发送违规封禁的文件":"文件消息失败,禁止发送违规封禁的文件","我":"我","无法查看":"无法查看","无法定位到原消息":"无法定位到原消息","无法收听":"无法收听","正在加载":"正在加载...","加载结束":"加载结束","无应答":"无应答","系统消息":"系统消息","消息":"message","消息或者资料中文本存在敏感内容,发送失败":"消息或者资料中文本存在敏感内容,发送失败","消息详情":"消息详情","消息长度超出限制,消息长度不要超过12K":"消息长度超出限制,消息长度不要超过12K","消息中图片存在敏感内容,发送失败":"消息中图片存在敏感内容,发送失败","选择提醒的人":"选择提醒的人","已读":"已读","已过撤回时限":"已过撤回时限","已接听":"已接听","已拒绝":"已拒绝","已同意":"已同意","引用":"引用","引用失败":"引用失败","语音":"[语音]","语音通话":"语音通话","重新编辑":"重新编辑","重新发送":"重新发送","转发":"转发","翻译":"翻译","转文字":"转文字","隐藏":"隐藏","转发给":"转发给","自定义":"[自定义消息]","自定义消息":"自定义消息","腾讯云 IM":"腾讯云 IM","空":"空","文本包含本地审核拦截词":"文本包含本地审核拦截词","按住说话":"按住说话","抬起发送":"抬起发送","抬起取消":"抬起取消","正在录音":"正在录音","继续上滑可取消":"继续上滑可取消","松开手指 取消发送":"松开手指 取消发送","此机型暂不支持复制功能":"此机型暂不支持复制功能","请开通翻译功能":"请开通翻译功能","请开通语音转文字功能":"请开通语音转文字功能","翻译中":"翻译中","转换中":"转换中","由IM提供翻译支持":"由IM提供翻译支持","所有人":"所有人","已达到表情回应上限数量":"已达到表情回应上限数量","等":"等","人":"人","返回":"返回","关闭":"关闭","多选":"多选","合并转发":"合并转发","逐条转发":"逐条转发","未选择消息":"未选择消息","引用内容已撤回":"引用内容已撤回","[草稿]":"[草稿]","[消息]":"[消息]","[文本]":"[文本]","[自定义消息]":"[自定义消息]","[图片]":"[图片]","[音频]":"[音频]","[语音]":"[语音]","[视频]":"[视频]","[文件]":"[文件]","[位置]":"[地理位置]","[地理位置]":"[地理位置]","[动画表情]":"[动画表情]","[群提示]":"[群提示]","[群提示消息]":"[群提示消息]","[聊天记录]":"[聊天记录]","[机器人自定义消息]":"[机器人自定义消息]","群聊的聊天记录":"群聊的聊天记录","和":"和","的聊天记录":"的聊天记录","请升级IMSDK到v2.10.1或更高版本查看此消息":"请升级IMSDK到v2.10.1或更高版本查看此消息","您已被管理员移出群聊":"您已被管理员移出群聊","该群聊已被解散":"该群聊已被解散","您已退出该群聊":"您已退出该群聊","您已被禁止聊天":"您已被禁止聊天","点击打断":"点击打断","停止回答":"停止回答","确认要清空当前的聊天记录吗?":"确认要清空当前的聊天记录吗?","清空后无法恢复":"清空后无法恢复","回答输出中,请稍后或点击停止回答":"回答输出中,请稍后或点击停止回答","获取麦克风权限状态失败,请重试":"获取麦克风权限状态失败,请重试","权限申请":"权限申请","请允许使用麦克风权限用于发送语音消息":"请允许使用麦克风权限用于发送语音消息","需要麦克风权限":"需要麦克风权限",'麦克风权限已被拒绝,请前往"设置 → 应用信息 → 权限"中开启麦克风权限':'麦克风权限已被拒绝,请前往"设置 → 应用信息 → 权限"中开启麦克风权限','麦克风权限已被拒绝,请前往"设置 → 隐私 → 麦克风"中开启权限':'麦克风权限已被拒绝,请前往"设置 → 隐私 → 麦克风"中开启权限','麦克风权限已被拒绝,请前往"右上角设置"中开启权限':'麦克风权限已被拒绝,请前往"右上角设置"中开启权限',"去设置":"去设置","需要您授权麦克风权限以使用语音功能":"需要您授权麦克风权限以使用语音功能","授权":"授权","录音时间太短":"录音时间太短","录音失败,请重试":"录音失败,请重试"},TUIConversation:{"发起会话":"发起会话","发起单聊":"发起单聊","发起群聊":"发起群聊","请输入userID":"请输入userID","删除会话":"删除会话","删除后,将清空该聊天的消息记录":"删除后,将清空该聊天的消息记录","删除后,将清空该群聊的消息记录":"删除后,将清空该群聊的消息记录","置顶会话":"置顶会话","取消置顶":"取消置顶","消息免打扰":"消息免打扰","取消免打扰":"取消免打扰","系统通知":"系统通知","有人@我":"有人@我","@所有人":"@所有人","条":"条","我":"我","网络异常,请您检查网络设置":"网络异常,请您检查网络设置","您已被群管理员移出群聊":"您已被群管理员移出群聊","该群聊已被解散":"该群聊已被解散","您已退出该群聊":"您已退出该群聊"},TUIGroup:{"输入groupID搜索":"输入groupID搜索","群名称":"群名称","群ID":"群ID","加入群聊":"加入群聊","解散群聊":"解散群聊","退出群聊":"退出群聊","群类型":"群类型","请填写验证信息":"请填写验证信息","申请加入":"申请加入","已申请":"已申请","群公告":"群公告","群成员":"群成员","群管理":"群管理","好友工作群":"好友工作群","陌生人社交群":"陌生人社交群","临时会议群":"临时会议群","直播群":"直播群","社群":"社群","自由加入":"自由加入","需要验证":"需要验证","禁止加群":"禁止加群","人":"人","群头像":"群头像","加群方式":"加群方式","转让群组":"转让群组","退出群组":"退出群组","群管理员":"群管理员","全员禁言":"全员禁言","全员禁言开启后,只允许群主和管理员发言。":"全员禁言开启后,只允许群主和管理员发言。","单独禁言人员":"单独禁言人员","删除成员":"删除成员","确定从群聊中删除该成员?":"确定从群聊中删除该成员?","确定从群聊中删除所选成员?":"确定从群聊中删除所选成员?","暂无公告":"暂无公告","发布":"发布","编辑":"编辑","查看更多":"查看更多","查看更多群成员":"查看更多群成员","管理员":"管理员","群主":"群主","我":"我","确认":"确认","添加成员":"添加成员","新增管理员":"新增管理员","移除管理员":"移除管理员","新增禁言用户":"新增禁言用户","移除禁言用户":"移除禁言用户","修改群聊名称":"修改群聊名称","修改群聊名称后,将在群内通知其他成员":"修改群聊名称后,将在群内通知其他成员","仅限中文、字母、数字和下划线,2-20个字":"仅限中文、字母、数字和下划线,2-20个字","请先注册 TUIGroup 模块":"请先注册 TUIGroup 模块","该用户不存在":"该用户不存在","该用户不在群组内":"该用户不在群组内","添加群聊":"添加群聊","该群组不存在":"该群组不存在","创建群聊,请注册 TUIGroup 模块":"创建群聊,请注册 TUIGroup 模块","创建成功":"创建成功","发起多人会话(群聊)":"发起多人会话(群聊)","选填":"选填","取消":"取消","创建":"创建","类似普通微信群,创建后仅支持已在群内的好友邀请加群,且无需被邀请方同意或群主审批。详见":"类似普通微信群,创建后仅支持已在群内的好友邀请加群,且无需被邀请方同意或群主审批。详见","类似 QQ 群,创建后群主可以指定群管理员,用户搜索群 ID 发起加群申请后,需要群主或管理员审批通过才能入群。详见":"类似 QQ 群,创建后群主可以指定群管理员,用户搜索群 ID 发起加群申请后,需要群主或管理员审批通过才能入群。详见","创建后可以随意进出,且支持查看入群前消息;适合用于音视频会议场景、在线教育场景等与实时音视频产品结合的场景。详见":"创建后可以随意进出,且支持查看入群前消息;适合用于音视频会议场景、在线教育场景等与实时音视频产品结合的场景。详见","创建后可以随意进出,没有群成员数量上限,但不支持历史消息存储;适合与直播产品结合,用于弹幕聊天场景。详见":"创建后可以随意进出,没有群成员数量上限,但不支持历史消息存储;适合与直播产品结合,用于弹幕聊天场景。详见","创建后可以随意进出,最多支持100000人,支持历史消息存储,用户搜索群 ID 发起加群申请后,无需管理员审批即可进群。详见":"创建后可以随意进出,最多支持100000人,支持历史消息存储,用户搜索群 ID 发起加群申请后,无需管理员审批即可进群。详见","产品文档":"产品文档","设置群名称":"设置群名称","请输入群名称":"请输入群名称","设置群ID":"设置群ID","请输入群ID":"请输入群ID","选择群类型":"选择群类型","陌生人社交群(Public)":"陌生人社交群(Public)","临时会议群(Meeting)":"临时会议群(Meeting)","好友工作群(Work)":"好友工作群(Work)","直播群(AVChatroom)":"直播群(AVChatroom)","社群(Community)":"社群(Community)","群组创建成功":"群组创建成功","群组解散成功":"群组解散成功","禁言设置成功":"禁言设置成功","取消禁言成功":"取消禁言成功","群名称不能为空":"群名称不能为空","群名称修改成功":"群名称修改成功","群公告字数超出限制,最大长度为150":"群公告字数超出限制,最大长度为150"},TUIContact:{"群聊通知":"群聊通知","系统通知":"系统通知","我的群聊":"我的群聊","输入ID":"请输入用户/群聊 ID,回车搜索","群名称":"群名称","群ID":"群ID","加入群聊":"加入群聊","解散群聊":"解散群聊","退出群聊":"退出群聊","进入群聊":"进入群聊","群类型":"群类型","请填写验证信息":"请填写验证信息","申请加入":"申请加入","已申请":"已申请","接受":"接受","拒绝":"拒绝","已处理":"已处理","添加群聊":"添加群聊","已加入":"已加入","该群组不存在":"该群组不存在","加群":"加群","我的好友":"我的好友","发送消息":"发送消息","个性签名":"个性签名","等待管理员同意":"申请成功,等待管理员同意入群申请","加群成功":"加群成功","您已是群成员":"您已是群成员","新的联系人":"新的联系人","黑名单":"黑名单","无搜索结果":"无搜索结果","客服号":"客服号",ID:"ID","联系人":"联系人","群聊":"群聊","添加好友/群聊":"添加好友/群聊","备注名":"备注名","加入黑名单":"加入黑名单","删除好友":"删除好友","等待验证":"等待验证","验证信息":"验证信息","发送申请":"发送申请","加入直播群":"加入直播群","同意":"同意","删除好友成功":"删除好友成功","删除好友失败":"删除好友失败","申请已发送":"申请已发送","申请发送失败":"申请发送失败","进入会话失败":"进入会话失败","添加好友成功":"添加好友成功","同意好友申请失败":"同意好友申请失败","拒绝成功":"拒绝成功","拒绝好友申请失败":"拒绝好友申请失败","解散群聊成功":"解散群聊成功","解散群聊失败":"解散群聊失败","退出群组成功":"退出群组成功","退出群组失败":"退出群组失败","申请入群失败":"申请入群失败","加入黑名单失败":"加入黑名单失败","移除黑名单失败":"移除黑名单失败","修改备注失败: 备注长度不得超过 96 字节":"修改备注失败: 备注长度不得超过 96 字节","修改备注成功":"修改备注成功","修改备注失败":"修改备注失败"},message:{tip:{"群成员":"群成员","加入群组":"加入群组","退出群组":"退出群组","被":"被","踢出群组":"踢出群组","成为管理员":"成为管理员","被撤销管理员":"被撤销管理员","被禁言":"被禁言","被取消禁言":"被取消禁言","群提示消息":"群提示消息","管理员":"管理员","开启全员禁言":"开启全员禁言","取消全员禁言":"取消全员禁言","成为新的群主":"成为新的群主","修改群名为":"修改群名为","发布新公告":"发布新公告","把群公告修改为":"把群公告修改为","申请加入群组":"申请加入群组","成功加入群组":"成功加入群组","被拒绝":"被拒绝","你被管理员":"你被管理员","群":"群","解散":"解散","创建群":"创建群","邀请你加群":"邀请你加群","你退出群组":"你退出群组","你被":"你被","设置为群":"设置为群","的管理员":"的管理员","撤销群":"撤销群","的管理员身份":"的管理员身份","同意加群":"同意加群","拒接加群":"拒接加群","自定义群系统通知":"自定义群系统通知"},custom:{"自定义消息":"自定义消息","通话时长":"通话时长","通话结束":"通话结束","切换语音通话":"切换语音通话","切换视频通话":"切换视频通话","发起通话":"发起通话","取消通话":"取消通话","已接听":"已接听","拒绝通话":"拒绝通话","无应答":"无应答","对本次服务评价":"对本次服务评价","查看详情>>":"查看详情>>","已取消":"已取消","对方已取消":"对方已取消","已拒绝":"已拒绝","对方已拒绝":"对方已拒绝","对方忙线中":"对方忙线中","忙线未接听":"忙线无应答","对方无应答":"对方无应答","超时无应答":"超时无应答"}},component:{"取消":"取消","完成":"完成","已选中":"已选中","人":"人","保存":"保存","请输入userID":"请输入userID","请输入groupID":"请输入groupID","确定":"确定","全选":"全选","已在群聊中":"已在群聊中","查看更多":"查看更多","图片 url 不存在":"图片 url 不存在","已取消":"已取消","获取权限失败":"获取权限失败","已保存至相册":"已保存至相册","图片下载失败":"图片下载失败","暂不支持下载此类型图片":"暂不支持下载此类型图片"},time:{"周":"周","天":"天","小时":"小时","分钟":"分钟","刚刚":"刚刚","前":"前","昨天":"昨天","星期一":"星期一","星期二":"星期二","星期三":"星期三","星期四":"星期四","星期五":"星期五","星期六":"星期六","星期日":"星期日","一月":"一月","二月":"二月","三月":"三月","四月":"四月","五月":"五月","六月":"六月","七月":"七月","八月":"八月","九月":"九月","十月":"十月","十一月":"十一月","十二月":"十二月","一":"一","二":"二","三":"三","四":"四","五":"五","六":"六","日":"日"},Evaluate:{"请对本次服务进行评价":"请对本次服务进行评价","提交评价":"提交评价","服务评价工具":"服务评价工具","使用":"使用","自定义消息":"自定义消息","搭建":"搭建","星":"星"},Words:{"常用语-快捷回复工具":"常用语-快捷回复工具","在吗?在吗?在吗?重要的话说三遍。":"在吗?在吗?在吗?重要的话说三遍。","好久没聊天了,快来和我说说话~":"好久没聊天了,快来和我说说话~","好的,就这么说定了。":"好的,就这么说定了。","感恩的心,感谢有你。":"感恩的心,感谢有你。","糟糕!是心动的感觉!":"糟糕!是心动的感觉!","心疼地抱抱自己,我太难了!":"心疼地抱抱自己,我太难了!","没关系,别在意,事情过去就过去了。":"没关系,别在意,事情过去就过去了。","早上好,今天也是让人期待的一天呢!":"早上好,今天也是让人期待的一天呢!","熬夜有什么用,又没人陪你聊天,早点休息吧。":"熬夜有什么用,又没人陪你聊天,早点休息吧。"},TUISearch:{"搜索":"搜索","全部":"全部","联系人":"联系人","群聊":"群聊","聊天记录":"聊天记录","文本":"文本","文件":"文件","图片/视频":"图片/视频","其他":"其他","选择时间":"选择时间","今天":"今天","近三天":"近三天","近七天":"近七天","查看更多":"查看更多","条相关":"条相关","条与":"条与","相关的":"相关的","进入聊天":"进入聊天","定位到聊天位置":"定位到聊天位置","搜索会话内容":"搜索会话内容","查看更多历史记录":"查看更多历史记录","暂无搜索结果":"暂无搜索结果","结果":"结果","取消":"取消","[文本]":"[文本]","[图片]":"[图片]","[语音]":"[语音]","[视频]":"[视频]","[文件]":"[文件]","[自定义消息]":"[自定义消息]","[系统消息]":"[系统消息]","[合并消息]":"[合并消息]","[位置消息]":"[位置消息]","消息云端搜索失败:":"消息云端搜索失败:","查找联系人失败:":"查找联系人失败:","查找群聊失败:":"查找群聊失败:","进入会话失败":"进入会话失败"},Emoji:kF}},...{zh_tw:{"取消":"取消","发送":"發送","系统通知":"系統通知","关闭":"關閉","确定":"確定","开始时间":"開始時間","结束时间":"結束時間","消息":"消息","通讯录":"通訊錄","欢迎使用腾讯云即时通信IM":"歡迎使用騰訊雲即時通信IM",TUIChat:{"【安全提示】本 APP 仅用于体验腾讯云即时通信 IM 产品功能,不可用于业务洽谈与拓展。请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。":"【安全提示】本 APP 僅用於體驗騰訊雲即時通信 IM 產品功能,不可用於業務洽談與拓展。請勿輕信匯款、中奖等涉及錢款的信息,勿輕易撥打陌生電話,謹防上當受騙。","按Enter发送,Ctrl+Enter换行":"按Enter發送,Ctrl+Enter換行","表情":"[表情]","查看更多":"查看更多","撤回":"撤回","撤回了一条消息":"撤回了一條消息","打开":"打開","单击下载":"單擊下載","点此投诉":"點此投訴","点击处理":"點擊處理","对方正在输入":"對方正在輸入...","发起群视频":"發起群視頻","发起群语音":"發起群語音","发起通话":"發起通話","发送失败":"發送失敗","复制":"複製","复制成功":"文本複製成功","该消息不存在":"該消息不存在","关闭阅读状态":"關閉","管理员开启全员禁言":"管理員開啟全員禁言","欢迎使用TUICallKit":"歡迎使用騰訊雲音視頻通話組件TUICallKit","回到最新位置":"回到最新位置","回复":"回覆","回复详情":"回覆詳情","集成TUICallKit":"集成 TUICallKit","检测到您暂未集成TUICallKit,无法体验音视频通话功能":"檢測到您暫未集成TUICallKit,無法體驗音視頻通話功能。","结束群聊":"結束群聊","进行体验":"進行體驗。","经度":"經度","拒绝":"拒絕","拒绝通话":"拒絕通話","开通腾讯实时音视频服务":"開通騰訊實時音視頻服務","聊天记录":"[聊天記錄]","描述":"描述","内容包含敏感词汇":"內容包含敏感詞彙","您":"您","您当前购买使用的套餐包暂未开通此功能":"您當前購買使用的套餐包暫未開通此功能。","您当前购买使用的套餐包暂未开通群消息已读回执功能":"您當前購買使用的套餐包暫未開通【群消息已讀回執】功能,請升級至旗艦版進行體驗","您当前购买使用的套餐包暂未开通在线用户列表功能":"您當前購買使用的套餐包暫未開通【在線用戶列表】功能,請升級至旗艦版進行體驗","您已被管理员禁言":"您已被管理員禁言","您有":"您有","请点击":"請點擊","请输入消息":"請輸入消息","取消":"取消","取消通话":"取消通話","全部已读":"全部已讀","确定":"確定","确认重发该消息?":"確認重發該消息?","人关闭阅读状态":"人關閉閱讀狀態","人未读":"人未讀","人已读":"人已讀","删除":"刪除","涉及敏感内容":"涉及敏感內容","申请加入":"申請加入","视频":"[視頻]","视频通话":"視頻通話","条回复":"條回覆","条入群申请":"條入群申請","条新消息":"條新消息","通话时长":"通話時長","同意":"同意","图片":"[圖片]","图片消息失败,无效的图片格式":"圖片消息失敗,無效的圖片格式","纬度":"緯度","未读":"未讀","位置":"[位置]","文件":"[文件]","文件不存在,请检查文件路径是否正确":"文件不存在,請檢查文件路徑是否正確","文件大小超出了限制,如果上传文件,最大限制是100MB":"文件大小超出了限制,如果上傳文件,最大限制是100MB","文件消息失败,禁止发送违规封禁的文件":"文件消息失敗,禁止發送違規封禁的文件","我":"我","无法查看":"無法查看","无法定位到原消息":"無法定位到原消息","无法收听":"無法收聽","正在加载":"正在加載...","加载结束":"加載結束","无应答":"無應答","系统消息":"系統消息","消息":"message","消息或者资料中文本存在敏感内容,发送失败":"消息或者資料中文本存在敏感內容,發送失敗","消息详情":"消息詳情","消息长度超出限制,消息长度不要超过12K":"消息長度超出限制,消息長度不要超過12K","消息中图片存在敏感内容,发送失败":"消息中圖片存在敏感內容,發送失敗","选择提醒的人":"選擇提醒的人","已读":"已讀","已过撤回时限":"已過撤回時限","已接听":"已接聽","已拒绝":"已拒絕","已同意":"已同意","引用":"引用","引用失败":"引用失敗","语音":"[語音]","语音通话":"語音通話","重新编辑":"重新編輯","重新发送":"重新發送","转发":"轉發","翻译":"翻譯","转文字":"轉文字","隐藏":"隱藏","转发给":"轉發給","自定义":"[自定義消息]","自定义消息":"自定義消息","腾讯云 IM":"騰訊雲 IM","空":"空","文本包含本地审核拦截词":"文本包含本地審核攔截詞","按住说话":"按住說話","抬起发送":"抬起發送","抬起取消":"抬起取消","正在录音":"正在錄音","继续上滑可取消":"繼續上滑可取消","松开手指 取消发送":"松開手指 取消發送","此机型暂不支持复制功能":"此機型暫不支持複製功能","请开通翻译功能":"請開通翻譯功能","请开通语音转文字功能":"請開通語音轉文字功能","翻译中":"翻譯中","转换中":"轉換中","由IM提供翻译支持":"由IM提供翻譯支持","所有人":"所有人","已达到表情回应上限数量":"已達到表情回應上限數量","等":"等","人":"人","返回":"返回","关闭":"關閉","多选":"多選","合并转发":"合併轉發","逐条转发":"逐條轉發","未选择消息":"未選擇消息","引用内容已撤回":"引用內容已撤回","[草稿]":"[草稿]","[消息]":"[消息]","[文本]":"[文本]","[自定义消息]":"[自定義消息]","[图片]":"[圖片]","[音频]":"[音頻]","[语音]":"[語音]","[视频]":"[視頻]","[文件]":"[文件]","[位置]":"[地理位置]","[地理位置]":"[地理位置]","[动画表情]":"[動畫表情]","[群提示]":"[群提示]","[群提示消息]":"[群提示消息]","[聊天记录]":"[聊天記錄]","[机器人自定义消息]":"[機器人自訂訊息]","群聊的聊天记录":"群聊的聊天記錄","和":"和","的聊天记录":"的聊天記錄","请升级IMSDK到v2.10.1或更高版本查看此消息":"請升級IMSDK到v2.10.1或更高版本查看此消息","您已被管理员移出群聊":"您已被管理員移出群聊","该群聊已被解散":"該群聊已被解散","您已退出该群聊":"您已退出該群聊","您已被禁止聊天":"您已被禁止聊天","点击打断":"點擊打斷","停止回答":"停止回答","确认要清空当前的聊天记录吗?":"確認要清空當前的聊天記錄嗎?","清空后无法恢复":"清空後無法恢復","回答输出中,请稍后或点击停止回答":"回答輸出中,請稍後或點擊停止回答","获取麦克风权限状态失败,请重试":"獲取麥克風權限狀態失敗,請重試","权限申请":"權限申請","请允许使用麦克风权限用于发送语音消息":"請允許使用麥克風權限用於發送語音消息","需要麦克风权限":"需要麥克風權限",'麦克风权限已被拒绝,请前往"设置 → 应用信息 → 权限"中开启麦克风权限':'麥克風權限已被拒絕,請前往"設置 → 應用信息 → 權限"中開啟麥克風權限','麦克风权限已被拒绝,请前往"设置 → 隐私 → 麦克风"中开启权限':'麥克風權限已被拒絕,請前往"設置 → 隱私 → 麥克風"中開啟權限','麦克风权限已被拒绝,请前往"右上角设置"中开启权限':'麥克風權限已被拒絕,請前往"右上角設置"中開啟權限',"去设置":"去設置","需要您授权麦克风权限以使用语音功能":"需要您授權麥克風權限以使用語音功能","授权":"授權","录音时间太短":"錄音時間太短","录音失败,请重试":"錄音失敗,請重試"},TUIConversation:{"发起会话":"發起會話","发起单聊":"發起單聊","发起群聊":"發起群聊","请输入userID":"請輸入userID","删除会话":"刪除會話","删除后,将清空该聊天的消息记录":"刪除後,將清空該聊天的消息記錄","删除后,将清空该群聊的消息记录":"刪除後,將清空該群聊的消息記錄","置顶会话":"置頂會話","取消置顶":"取消置頂","消息免打扰":"消息免打擾","取消免打扰":"取消免打擾","系统通知":"系統通知","有人@我":"有人@我","@所有人":"@所有人","条":"條","我":"我","网络异常,请您检查网络设置":"網絡異常,請您檢查網絡設置","您已被群管理员移出群聊":"您已被群管理員移出群聊","该群聊已被解散":"該群聊已被解散","您已退出该群聊":"您已退出該群聊"},TUIGroup:{"输入groupID搜索":"輸入groupID搜索","群名称":"群名稱","群ID":"群ID","加入群聊":"加入群聊","解散群聊":"解散群聊","退出群聊":"退出群聊","群类型":"群類型","请填写验证信息":"請填寫驗證信息","申请加入":"申請加入","已申请":"已申請","群公告":"群公告","群成员":"群成員","群管理":"群管理","好友工作群":"好友工作群","陌生人社交群":"陌生人社交群","临时会议群":"臨時會議群","直播群":"直播群","社群":"社群","自由加入":"自由加入","需要验证":"需要驗證","禁止加群":"禁止加群","人":"人","群头像":"群頭像","加群方式":"加群方式","转让群组":"轉讓群組","退出群组":"退出群組","群管理员":"群管理員","全员禁言":"全員禁言","全员禁言开启后,只允许群主和管理员发言。":"全員禁言開啟後,只允許群主和管理員發言。","单独禁言人员":"單獨禁言人員","删除成员":"刪除成員","确定从群聊中删除该成员?":"確定從群聊中刪除該成員?","确定从群聊中删除所选成员?":"確定從群聊中刪除所選成員?","暂无公告":"暫無公告","发布":"發布","编辑":"編輯","查看更多":"查看更多","查看更多群成员":"查看更多群成員","管理员":"管理員","群主":"群主","我":"我","确认":"確認","添加成员":"添加成員","新增管理员":"新增管理員","移除管理员":"移除管理員","新增禁言用户":"新增禁言用戶","移除禁言用户":"移除禁言用戶","修改群聊名称":"修改群聊名稱","修改群聊名称后,将在群内通知其他成员":"修改群聊名稱後,將在群內通知其他成員","仅限中文、字母、数字和下划线,2-20个字":"僅限中文、字母、數字和下劃線,2-20個字","请先注册 TUIGroup 模块":"請先註冊 TUIGroup 模塊","该用户不存在":"該用戶不存在","该用户不在群组内":"該用戶不在群組內","添加群聊":"添加群聊","该群组不存在":"該群組不存在","创建群聊,请注册 TUIGroup 模块":"創建群聊,請註冊 TUIGroup 模塊","创建成功":"創建成功","发起多人会话(群聊)":"發起多人會話(群聊)","选填":"選填","取消":"取消","创建":"創建","类似普通微信群,创建后仅支持已在群内的好友邀请加群,且无需被邀请方同意或群主审批。详见":"類似普通微信群,創建後僅支持已在群內的好友邀請加群,且無需被邀請方同意或群主審批。詳見","类似 QQ 群,创建后群主可以指定群管理员,用户搜索群 ID 发起加群申请后,需要群主或管理员审批通过才能入群。详见":"類似 QQ 群,創建後群主可以指定群管理員,用戶搜索群 ID 發起加群申請後,需要群主或管理員審批通過才能入群。詳見","创建后可以随意进出,且支持查看入群前消息;适合用于音视频会议场景、在线教育场景等与实时音视频产品结合的场景。详见":"創建後可以隨意進出,且支持查看入群前消息;適合用於音視頻會議場景、在線教育場景等與實時音視頻產品結合的場景。詳見","创建后可以随意进出,没有群成员数量上限,但不支持历史消息存储;适合与直播产品结合,用于弹幕聊天场景。详见":"創建後可以隨意進出,沒有群成員數量上限,但不支持歷史消息存儲;適合與直播產品結合,用於彈幕聊天場景。詳見","创建后可以随意进出,最多支持100000人,支持历史消息存储,用户搜索群 ID 发起加群申请后,无需管理员审批即可进群。详见":"創建後可以隨意進出,最多支持100000人,支持歷史消息存儲,用戶搜索群 ID 發起加群申請後,無需管理員審批即可進群。詳見","产品文档":"產品文檔","设置群名称":"設置群名稱","请输入群名称":"請輸入群名稱","设置群ID":"設置群ID","请输入群ID":"請輸入群ID","选择群类型":"選擇群類型","陌生人社交群(Public)":"陌生人社交群(Public)","临时会议群(Meeting)":"臨時會議群(Meeting)","好友工作群(Work)":"好友工作群(Work)","直播群(AVChatroom)":"直播群(AVChatroom)","社群(Community)":"社群(Community)","群组创建成功":"群組創建成功","群组解散成功":"群組解散成功","禁言设置成功":"禁言設置成功","取消禁言成功":"取消禁言成功","群名称不能为空":"群名稱不能為空","群名称修改成功":"群名稱修改成功","群公告字数超出限制,最大长度为150":"群公告字數超出限制,最大長度為150"},TUIContact:{"群聊通知":"群聊通知","系统通知":"系統通知","我的群聊":"我的群聊","输入ID":"請輸入用戶/群聊 ID,回車搜索","群名称":"群名稱","群ID":"群ID","加入群聊":"加入群聊","解散群聊":"解散群聊","退出群聊":"退出群聊","进入群聊":"進入群聊","群类型":"群類型","请填写验证信息":"請填寫驗證信息","申请加入":"申請加入","已申请":"已申請","接受":"接受","拒绝":"拒絕","已处理":"已處理","添加群聊":"添加群聊","已加入":"已加入","该群组不存在":"該群組不存在","加群":"加群","我的好友":"我的好友","发送消息":"發送消息","个性签名":"個性簽名","等待管理员同意":"申請成功,等待管理員同意入群申請","加群成功":"加群成功","您已是群成员":"您已是群成員","新的联系人":"新的聯繫人","黑名单":"黑名單","无搜索结果":"無搜索結果","客服号":"客服號",ID:"ID","联系人":"聯繫人","群聊":"群聊","添加好友/群聊":"添加好友/群聊","备注名":"備註名","加入黑名单":"加入黑名單","删除好友":"刪除好友","等待验证":"等待驗證","验证信息":"驗證信息","发送申请":"發送申請","加入直播群":"加入直播群","同意":"同意","删除好友成功":"刪除好友成功","删除好友失败":"刪除好友失敗","申请已发送":"申請已發送","申请发送失败":"申請發送失敗","进入会话失败":"進入會話失敗","添加好友成功":"添加好友成功","同意好友申请失败":"同意好友申請失敗","拒绝成功":"拒絕成功","拒绝好友申请失败":"拒絕好友申請失敗","解散群聊成功":"解散群聊成功","解散群聊失败":"解散群聊失敗","退出群组成功":"退出群組成功","退出群组失败":"退出群組失敗","申请入群失败":"申請入群失敗","加入黑名单失败":"加入黑名單失敗","移除黑名单失败":"移除黑名單失敗","修改备注失败: 备注长度不得超过 96 字节":"修改備註失敗: 備註長度不得超過 96 字節","修改备注成功":"修改備註成功","修改备注失败":"修改備註失敗"},message:{tip:{"群成员":"群成員","加入群组":"加入群組","退出群组":"退出群組","被":"被","踢出群组":"踢出群組","成为管理员":"成為管理員","被撤销管理员":"被撤銷管理員","被禁言":"被禁言","被取消禁言":"被取消禁言","群提示消息":"群提示消息","管理员":"管理員","开启全员禁言":"開啟全員禁言","取消全员禁言":"取消全員禁言","成为新的群主":"成為新的群主","修改群名为":"修改群名為","发布新公告":"發布新公告","把群公告修改为":"把群公告修改為","申请加入群组":"申請加入群組","成功加入群组":"成功加入群組","被拒绝":"被拒絕","你被管理员":"你被管理員","群":"群","解散":"解散","创建群":"創建群","邀请你加群":"邀請你加群","你退出群组":"你退出群組","你被":"你被","设置为群":"設置為群","的管理员":"的管理員","撤销群":"撤銷群","的管理员身份":"的管理員身份","同意加群":"同意加群","拒接加群":"拒接加群","自定义群系统通知":"自定義群系統通知"},custom:{"自定义消息":"自定義消息","通话时长":"通話時長","通话结束":"通話結束","切换语音通话":"切換語音通話","切换视频通话":"切換視頻通話","发起通话":"發起通話","取消通话":"取消通話","已接听":"已接聽","拒绝通话":"拒絕通話","无应答":"無應答","对本次服务评价":"對本次服務評價","查看详情>>":"查看詳情>>","已取消":"已取消","对方已取消":"對方已取消","已拒绝":"已拒絕","对方已拒绝":"對方已拒絕","对方忙线中":"對方忙線中","忙线未接听":"忙線無應答","对方无应答":"對方無應答","超时无应答":"超時無應答"}},component:{"取消":"取消","完成":"完成","已选中":"已選中","人":"人","保存":"保存","请输入userID":"請輸入userID","请输入groupID":"請輸入groupID","确定":"確定","全选":"全選","已在群聊中":"已在群聊中","查看更多":"查看更多","图片 url 不存在":"圖片 url 不存在","已取消":"已取消","获取权限失败":"獲取權限失敗","已保存至相册":"已保存至相冊","图片下载失败":"圖片下載失敗","暂不支持下载此类型图片":"暫不支持下載此類型圖片"},time:{"周":"週","天":"天","小时":"小時","分钟":"分鐘","刚刚":"剛剛","前":"前","昨天":"昨天","星期一":"星期一","星期二":"星期二","星期三":"星期三","星期四":"星期四","星期五":"星期五","星期六":"星期六","星期日":"星期日","一月":"一月","二月":"二月","三月":"三月","四月":"四月","五月":"五月","六月":"六月","七月":"七月","八月":"八月","九月":"九月","十月":"十月","十一月":"十一月","十二月":"十二月","一":"一","二":"二","三":"三","四":"四","五":"五","六":"六","日":"日"},Evaluate:{"请对本次服务进行评价":"請對本次服務進行評價","提交评价":"提交評價","服务评价工具":"服務評價工具","使用":"使用","自定义消息":"自定義消息","搭建":"搭建","星":"星"},Words:{"常用语-快捷回复工具":"常用語-快捷回覆工具","在吗?在吗?在吗?重要的话说三遍。":"在嗎?在嗎?在嗎?重要的話說三遍。","好久没聊天了,快来和我说说话~":"好久沒聊天了,快來和我說說話~","好的,就这么说定了。":"好的,就這麼說定了。","感恩的心,感谢有你。":"感恩的心,感謝有你。","糟糕!是心动的感觉!":"糟糕!是心動的感覺!","心疼地抱抱自己,我太难了!":"心疼地抱抱自己,我太難了!","没关系,别在意,事情过去就过去了。":"沒關係,別在意,事情過去就過去了。","早上好,今天也是让人期待的一天呢!":"早上好,今天也是讓人期待的一天呢!","熬夜有什么用,又没人陪你聊天,早点休息吧。":"熬夜有什麼用,又沒人陪你聊天,早點休息吧。"},TUISearch:{"搜索":"搜索","全部":"全部","联系人":"聯繫人","群聊":"群聊","聊天记录":"聊天記錄","文本":"文本","文件":"文件","图片/视频":"圖片/視頻","其他":"其他","选择时间":"選擇時間","今天":"今天","近三天":"近三天","近七天":"近七天","查看更多":"查看更多","条相关":"條相關","条与":"條與","相关的":"相關的","进入聊天":"進入聊天","定位到聊天位置":"定位到聊天位置","搜索会话内容":"搜索會話內容","查看更多历史记录":"查看更多歷史記錄","暂无搜索结果":"暫無搜索結果","结果":"結果","取消":"取消","[文本]":"[文本]","[图片]":"[圖片]","[语音]":"[語音]","[视频]":"[視頻]","[文件]":"[文件]","[自定义消息]":"[自定義消息]","[系统消息]":"[系統消息]","[合并消息]":"[合併消息]","[位置消息]":"[位置消息]","消息云端搜索失败:":"消息雲端搜索失敗:","查找联系人失败:":"查找聯繫人失敗:","查找群聊失败:":"查找群聊失敗:","进入会话失败":"進入會話失敗"},Emoji:{"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[無語]","[TUIEmoji_Amazed]":"[驚訝]","[TUIEmoji_Sorrow]":"[悲傷]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[親親]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐懼]","[TUIEmoji_BareTeeth]":"[齜牙]","[TUIEmoji_FlareUp]":"[發怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[機智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[閉嘴]","[TUIEmoji_Sigh]":"[嘆氣]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收聲]","[TUIEmoji_Surprised]":"[驚喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪獸]","[TUIEmoji_Daemon]":"[惡魔]","[TUIEmoji_Rage]":"[惡魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[豬]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髏]","[TUIEmoji_Bombs]":"[炸彈]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[愛心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太陽]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[紅包]","[TUIEmoji_Celebrate]":"[慶祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[發]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[讚]"}}}};let UF;UF=3,console.warn("[adapter-vue]: vue version is 3");var FF,OF={exports:{}},xF={exports:{}},PF={exports:{}};function YF(){return FF||(FF=1,PF.exports=function(){function A(A,e){return e.forEach(function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(function(t){if("default"!==t&&!(t in A)){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(A,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})}),Object.freeze(A)}var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==MR?MR:"undefined"!=typeof self?self:{};function t(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var i=function(A){return A&&A.Math===Math&&A},o=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||i("object"==typeof e&&e)||function(){return this}()||Function("return this")(),n={},r=function(A){try{return!!A()}catch(kd){return!0}},s=!r(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),a=!r(function(){var A=function(){}.bind();return"function"!=typeof A||A.hasOwnProperty("prototype")}),g=a,c=Function.prototype.call,l=g?c.bind(c):function(){return c.apply(c,arguments)},I={},u={}.propertyIsEnumerable,E=Object.getOwnPropertyDescriptor,d=E&&!u.call({1:2},1);I.f=d?function(A){var e=E(this,A);return!!e&&e.enumerable}:u;var h,C,B=function(A,e){return{enumerable:!(1&A),configurable:!(2&A),writable:!(4&A),value:e}},Q=a,p=Function.prototype,f=p.call,m=Q&&p.bind.bind(f,f),y=Q?m:function(A){return function(){return f.apply(A,arguments)}},D=y,v=D({}.toString),w=D("".slice),S=function(A){return w(v(A),8,-1)},M=r,R=S,_=Object,T=y("".split),N=M(function(){return!_("z").propertyIsEnumerable(0)})?function(A){return"String"===R(A)?T(A,""):_(A)}:_,b=function(A){return null==A},G=b,k=TypeError,L=function(A){if(G(A))throw new k("Can't call method on "+A);return A},U=N,F=L,O=function(A){return U(F(A))},x="object"==typeof document&&document.all,P=void 0===x&&void 0!==x?function(A){return"function"==typeof A||A===x}:function(A){return"function"==typeof A},Y=P,J=function(A){return"object"==typeof A?null!==A:Y(A)},H=o,q=P,V=function(A,e){return arguments.length<2?(t=H[A],q(t)?t:void 0):H[A]&&H[A][e];var t},j=y({}.isPrototypeOf),K=o.navigator,W=K&&K.userAgent,z=W?String(W):"",Z=o,X=z,$=Z.process,AA=Z.Deno,eA=$&&$.versions||AA&&AA.version,tA=eA&&eA.v8;tA&&(C=(h=tA.split("."))[0]>0&&h[0]<4?1:+(h[0]+h[1])),!C&&X&&(!(h=X.match(/Edge\/(\d+)/))||h[1]>=74)&&(h=X.match(/Chrome\/(\d+)/))&&(C=+h[1]);var iA=C,oA=iA,nA=r,rA=o.String,sA=!!Object.getOwnPropertySymbols&&!nA(function(){var A=Symbol("symbol detection");return!rA(A)||!(Object(A)instanceof Symbol)||!Symbol.sham&&oA&&oA<41}),aA=sA&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,gA=V,cA=P,lA=j,IA=Object,uA=aA?function(A){return"symbol"==typeof A}:function(A){var e=gA("Symbol");return cA(e)&&lA(e.prototype,IA(A))},EA=String,dA=function(A){try{return EA(A)}catch(kd){return"Object"}},hA=P,CA=dA,BA=TypeError,QA=function(A){if(hA(A))return A;throw new BA(CA(A)+" is not a function")},pA=QA,fA=b,mA=function(A,e){var t=A[e];return fA(t)?void 0:pA(t)},yA=l,DA=P,vA=J,wA=TypeError,SA={exports:{}},MA=o,RA=Object.defineProperty,_A=function(A,e){try{RA(MA,A,{value:e,configurable:!0,writable:!0})}catch(t){MA[A]=e}return e},TA=o,NA=_A,bA="__core-js_shared__",GA=SA.exports=TA[bA]||NA(bA,{});(GA.versions||(GA.versions=[])).push({version:"3.47.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru), 2025 CoreJS Company (core-js.io)",license:"https://github.com/zloirock/core-js/blob/v3.47.0/LICENSE",source:"https://github.com/zloirock/core-js"});var kA=SA.exports,LA=kA,UA=function(A,e){return LA[A]||(LA[A]=e||{})},FA=L,OA=Object,xA=function(A){return OA(FA(A))},PA=xA,YA=y({}.hasOwnProperty),JA=Object.hasOwn||function(A,e){return YA(PA(A),e)},HA=y,qA=0,VA=Math.random(),jA=HA(1.1.toString),KA=function(A){return"Symbol("+(void 0===A?"":A)+")_"+jA(++qA+VA,36)},WA=UA,zA=JA,ZA=KA,XA=sA,$A=aA,Ae=o.Symbol,ee=WA("wks"),te=$A?Ae.for||Ae:Ae&&Ae.withoutSetter||ZA,ie=function(A){return zA(ee,A)||(ee[A]=XA&&zA(Ae,A)?Ae[A]:te("Symbol."+A)),ee[A]},oe=l,ne=J,re=uA,se=mA,ae=function(A,e){var t,i;if("string"===e&&DA(t=A.toString)&&!vA(i=yA(t,A)))return i;if(DA(t=A.valueOf)&&!vA(i=yA(t,A)))return i;if("string"!==e&&DA(t=A.toString)&&!vA(i=yA(t,A)))return i;throw new wA("Can't convert object to primitive value")},ge=TypeError,ce=ie("toPrimitive"),le=function(A,e){if(!ne(A)||re(A))return A;var t,i=se(A,ce);if(i){if(void 0===e&&(e="default"),t=oe(i,A,e),!ne(t)||re(t))return t;throw new ge("Can't convert object to primitive value")}return void 0===e&&(e="number"),ae(A,e)},Ie=le,ue=uA,Ee=function(A){var e=Ie(A,"string");return ue(e)?e:e+""},de=J,he=o.document,Ce=de(he)&&de(he.createElement),Be=function(A){return Ce?he.createElement(A):{}},Qe=Be,pe=!s&&!r(function(){return 7!==Object.defineProperty(Qe("div"),"a",{get:function(){return 7}}).a}),fe=s,me=l,ye=I,De=B,ve=O,we=Ee,Se=JA,Me=pe,Re=Object.getOwnPropertyDescriptor;n.f=fe?Re:function(A,e){if(A=ve(A),e=we(e),Me)try{return Re(A,e)}catch(t){}if(Se(A,e))return De(!me(ye.f,A,e),A[e])};var _e={},Te=s&&r(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Ne=J,be=String,Ge=TypeError,ke=function(A){if(Ne(A))return A;throw new Ge(be(A)+" is not an object")},Le=s,Ue=pe,Fe=Te,Oe=ke,xe=Ee,Pe=TypeError,Ye=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,He="enumerable",qe="configurable",Ve="writable";_e.f=Le?Fe?function(A,e,t){if(Oe(A),e=xe(e),Oe(t),"function"==typeof A&&"prototype"===e&&"value"in t&&Ve in t&&!t[Ve]){var i=Je(A,e);i&&i[Ve]&&(A[e]=t.value,t={configurable:qe in t?t[qe]:i[qe],enumerable:He in t?t[He]:i[He],writable:!1})}return Ye(A,e,t)}:Ye:function(A,e,t){if(Oe(A),e=xe(e),Oe(t),Ue)try{return Ye(A,e,t)}catch(i){}if("get"in t||"set"in t)throw new Pe("Accessors not supported");return"value"in t&&(A[e]=t.value),A};var je=_e,Ke=B,We=s?function(A,e,t){return je.f(A,e,Ke(1,t))}:function(A,e,t){return A[e]=t,A},ze={exports:{}},Ze=s,Xe=JA,$e=Function.prototype,At=Ze&&Object.getOwnPropertyDescriptor,et=Xe($e,"name"),tt={EXISTS:et,PROPER:et&&"something"===function(){}.name,CONFIGURABLE:et&&(!Ze||Ze&&At($e,"name").configurable)},it=P,ot=kA,nt=y(Function.toString);it(ot.inspectSource)||(ot.inspectSource=function(A){return nt(A)});var rt,st,at,gt=ot.inspectSource,ct=P,lt=o.WeakMap,It=ct(lt)&&/native code/.test(String(lt)),ut=KA,Et=UA("keys"),dt=function(A){return Et[A]||(Et[A]=ut(A))},ht={},Ct=It,Bt=o,Qt=J,pt=We,ft=JA,mt=kA,yt=dt,Dt=ht,vt="Object already initialized",wt=Bt.TypeError,St=Bt.WeakMap;if(Ct||mt.state){var Mt=mt.state||(mt.state=new St);Mt.get=Mt.get,Mt.has=Mt.has,Mt.set=Mt.set,rt=function(A,e){if(Mt.has(A))throw new wt(vt);return e.facade=A,Mt.set(A,e),e},st=function(A){return Mt.get(A)||{}},at=function(A){return Mt.has(A)}}else{var Rt=yt("state");Dt[Rt]=!0,rt=function(A,e){if(ft(A,Rt))throw new wt(vt);return e.facade=A,pt(A,Rt,e),e},st=function(A){return ft(A,Rt)?A[Rt]:{}},at=function(A){return ft(A,Rt)}}var _t={set:rt,get:st,has:at,enforce:function(A){return at(A)?st(A):rt(A,{})},getterFor:function(A){return function(e){var t;if(!Qt(e)||(t=st(e)).type!==A)throw new wt("Incompatible receiver, "+A+" required");return t}}},Tt=y,Nt=r,bt=P,Gt=JA,kt=s,Lt=tt.CONFIGURABLE,Ut=gt,Ft=_t.enforce,Ot=_t.get,xt=String,Pt=Object.defineProperty,Yt=Tt("".slice),Jt=Tt("".replace),Ht=Tt([].join),qt=kt&&!Nt(function(){return 8!==Pt(function(){},"length",{value:8}).length}),Vt=String(String).split("String"),jt=ze.exports=function(A,e,t){"Symbol("===Yt(xt(e),0,7)&&(e="["+Jt(xt(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!Gt(A,"name")||Lt&&A.name!==e)&&(kt?Pt(A,"name",{value:e,configurable:!0}):A.name=e),qt&&t&&Gt(t,"arity")&&A.length!==t.arity&&Pt(A,"length",{value:t.arity});try{t&&Gt(t,"constructor")&&t.constructor?kt&&Pt(A,"prototype",{writable:!1}):A.prototype&&(A.prototype=void 0)}catch(o){}var i=Ft(A);return Gt(i,"source")||(i.source=Ht(Vt,"string"==typeof e?e:"")),A};Function.prototype.toString=jt(function(){return bt(this)&&Ot(this).source||Ut(this)},"toString");var Kt=ze.exports,Wt=P,zt=_e,Zt=Kt,Xt=_A,$t=function(A,e,t,i){i||(i={});var o=i.enumerable,n=void 0!==i.name?i.name:e;if(Wt(t)&&Zt(t,n,i),i.global)o?A[e]=t:Xt(e,t);else{try{i.unsafe?A[e]&&(o=!0):delete A[e]}catch(r){}o?A[e]=t:zt.f(A,e,{value:t,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return A},Ai={},ei=Math.ceil,ti=Math.floor,ii=Math.trunc||function(A){var e=+A;return(e>0?ti:ei)(e)},oi=function(A){var e=+A;return e!=e||0===e?0:ii(e)},ni=oi,ri=Math.max,si=Math.min,ai=function(A,e){var t=ni(A);return t<0?ri(t+e,0):si(t,e)},gi=oi,ci=Math.min,li=function(A){var e=gi(A);return e>0?ci(e,9007199254740991):0},Ii=li,ui=function(A){return Ii(A.length)},Ei=O,di=ai,hi=ui,Ci=function(A){return function(e,t,i){var o=Ei(e),n=hi(o);if(0===n)return!A&&-1;var r,s=di(i,n);if(A&&t!=t){for(;n>s;)if((r=o[s++])!=r)return!0}else for(;n>s;s++)if((A||s in o)&&o[s]===t)return A||s||0;return!A&&-1}},Bi={includes:Ci(!0),indexOf:Ci(!1)},Qi=JA,pi=O,fi=Bi.indexOf,mi=ht,yi=y([].push),Di=function(A,e){var t,i=pi(A),o=0,n=[];for(t in i)!Qi(mi,t)&&Qi(i,t)&&yi(n,t);for(;e.length>o;)Qi(i,t=e[o++])&&(~fi(n,t)||yi(n,t));return n},vi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],wi=Di,Si=vi.concat("length","prototype");Ai.f=Object.getOwnPropertyNames||function(A){return wi(A,Si)};var Mi={};Mi.f=Object.getOwnPropertySymbols;var Ri=V,_i=Ai,Ti=Mi,Ni=ke,bi=y([].concat),Gi=Ri("Reflect","ownKeys")||function(A){var e=_i.f(Ni(A)),t=Ti.f;return t?bi(e,t(A)):e},ki=JA,Li=Gi,Ui=n,Fi=_e,Oi=function(A,e,t){for(var i=Li(e),o=Fi.f,n=Ui.f,r=0;rr;)Jo.f(A,t=o[r++],i[t]);return A};var jo,Ko=V("document","documentElement"),Wo=ke,zo=Uo,Zo=vi,Xo=ht,$o=Ko,An=Be,en="prototype",tn="script",on=dt("IE_PROTO"),nn=function(){},rn=function(A){return"<"+tn+">"+A+""},sn=function(A){A.write(rn("")),A.close();var e=A.parentWindow.Object;return A=null,e},an=function(){try{jo=new ActiveXObject("htmlfile")}catch(e){}var A,e,t;an="undefined"!=typeof document?document.domain&&jo?sn(jo):(e=An("iframe"),t="java"+tn+":",e.style.display="none",$o.appendChild(e),e.src=String(t),(A=e.contentWindow.document).open(),A.write(rn("document.F=Object")),A.close(),A.F):sn(jo);for(var i=Zo.length;i--;)delete an[en][Zo[i]];return an()};Xo[on]=!0;var gn=Object.create||function(A,e){var t;return null!==A?(nn[en]=Wo(A),t=new nn,nn[en]=null,t[on]=A):t=an(),void 0===e?t:zo.f(t,e)},cn=ie,ln=gn,In=_e.f,un=cn("unscopables"),En=Array.prototype;void 0===En[un]&&In(En,un,{configurable:!0,value:ln(null)});var dn=function(A){En[un][A]=!0},hn=Bi.includes,Cn=dn;to({target:"Array",proto:!0,forced:r(function(){return!Array(1).includes()})},{includes:function(A){return hn(this,A,arguments.length>1?arguments[1]:void 0)}}),Cn("includes");var Bn,Qn,pn,fn={},mn=!r(function(){function A(){}return A.prototype.constructor=null,Object.getPrototypeOf(new A)!==A.prototype}),yn=JA,Dn=P,vn=xA,wn=mn,Sn=dt("IE_PROTO"),Mn=Object,Rn=Mn.prototype,_n=wn?Mn.getPrototypeOf:function(A){var e=vn(A);if(yn(e,Sn))return e[Sn];var t=e.constructor;return Dn(t)&&e instanceof t?t.prototype:e instanceof Mn?Rn:null},Tn=r,Nn=P,bn=J,Gn=_n,kn=$t,Ln=ie("iterator"),Un=!1;[].keys&&("next"in(pn=[].keys())?(Qn=Gn(Gn(pn)))!==Object.prototype&&(Bn=Qn):Un=!0),(!bn(Bn)||Tn(function(){var A={};return Bn[Ln].call(A)!==A}))&&(Bn={}),Nn(Bn[Ln])||kn(Bn,Ln,function(){return this});var Fn={IteratorPrototype:Bn,BUGGY_SAFARI_ITERATORS:Un},On=_e.f,xn=JA,Pn=ie("toStringTag"),Yn=function(A,e,t){A&&!t&&(A=A.prototype),A&&!xn(A,Pn)&&On(A,Pn,{configurable:!0,value:e})},Jn=Fn.IteratorPrototype,Hn=gn,qn=B,Vn=Yn,jn=fn,Kn=function(){return this},Wn=function(A,e,t,i){var o=e+" Iterator";return A.prototype=Hn(Jn,{next:qn(+!i,t)}),Vn(A,o,!1),jn[o]=Kn,A},zn=y,Zn=QA,Xn=J,$n=function(A){return Xn(A)||null===A},Ar=String,er=TypeError,tr=function(A,e,t){try{return zn(Zn(Object.getOwnPropertyDescriptor(A,e)[t]))}catch(i){}},ir=J,or=L,nr=function(A){if($n(A))return A;throw new er("Can't set "+Ar(A)+" as a prototype")},rr=Object.setPrototypeOf||("__proto__"in{}?function(){var A,e=!1,t={};try{(A=tr(Object.prototype,"__proto__","set"))(t,[]),e=t instanceof Array}catch(i){}return function(t,i){return or(t),nr(i),ir(t)?(e?A(t,i):t.__proto__=i,t):t}}():void 0),sr=to,ar=l,gr=P,cr=Wn,lr=_n,Ir=rr,ur=Yn,Er=We,dr=$t,hr=fn,Cr=tt.PROPER,Br=tt.CONFIGURABLE,Qr=Fn.IteratorPrototype,pr=Fn.BUGGY_SAFARI_ITERATORS,fr=ie("iterator"),mr="keys",yr="values",Dr="entries",vr=function(){return this},wr=function(A,e,t,i,o,n,r){cr(t,e,i);var s,a,g,c=function(A){if(A===o&&d)return d;if(!pr&&A&&A in u)return u[A];switch(A){case mr:case yr:case Dr:return function(){return new t(this,A)}}return function(){return new t(this)}},l=e+" Iterator",I=!1,u=A.prototype,E=u[fr]||u["@@iterator"]||o&&u[o],d=!pr&&E||c(o),h="Array"===e&&u.entries||E;if(h&&(s=lr(h.call(new A)))!==Object.prototype&&s.next&&(lr(s)!==Qr&&(Ir?Ir(s,Qr):gr(s[fr])||dr(s,fr,vr)),ur(s,l,!0)),Cr&&o===yr&&E&&E.name!==yr&&(Br?Er(u,"name",yr):(I=!0,d=function(){return ar(E,this)})),o)if(a={values:c(yr),keys:n?d:c(mr),entries:c(Dr)},r)for(g in a)(pr||I||!(g in u))&&dr(u,g,a[g]);else sr({target:e,proto:!0,forced:pr||I},a);return u[fr]!==d&&dr(u,fr,d,{name:o}),hr[e]=d,a},Sr=function(A,e){return{value:A,done:e}},Mr=O,Rr=dn,_r=fn,Tr=_t,Nr=_e.f,br=wr,Gr=Sr,kr=s,Lr="Array Iterator",Ur=Tr.set,Fr=Tr.getterFor(Lr),Or=br(Array,"Array",function(A,e){Ur(this,{type:Lr,target:Mr(A),index:0,kind:e})},function(){var A=Fr(this),e=A.target,t=A.index++;if(!e||t>=e.length)return A.target=null,Gr(void 0,!0);switch(A.kind){case"keys":return Gr(t,!1);case"values":return Gr(e[t],!1)}return Gr([t,e[t]],!1)},"values"),xr=_r.Arguments=_r.Array;if(Rr("keys"),Rr("values"),Rr("entries"),kr&&"values"!==xr.name)try{Nr(xr,"name",{value:"values"})}catch(JV){}var Pr=QA,Yr=xA,Jr=N,Hr=ui,qr=TypeError,Vr="Reduce of empty array with no initial value",jr=function(A){return function(e,t,i,o){var n=Yr(e),r=Jr(n),s=Hr(n);if(Pr(t),0===s&&i<2)throw new qr(Vr);var a=A?s-1:0,g=A?-1:1;if(i<2)for(;;){if(a in r){o=r[a],a+=g;break}if(a+=g,A?a<0:s<=a)throw new qr(Vr)}for(;A?a>=0:s>a;a+=g)a in r&&(o=t(o,r[a],a,n));return o}},Kr={left:jr(!1),right:jr(!0)},Wr=r,zr=function(A,e){var t=[][A];return!!t&&Wr(function(){t.call(null,e||function(){return 1},1)})},Zr=o,Xr=z,$r=S,As=function(A){return Xr.slice(0,A.length)===A},es=As("Bun/")?"BUN":As("Cloudflare-Workers")?"CLOUDFLARE":As("Deno/")?"DENO":As("Node.js/")?"NODE":Zr.Bun&&"string"==typeof Bun.version?"BUN":Zr.Deno&&"object"==typeof Deno.version?"DENO":"process"===$r(Zr.process)?"NODE":Zr.window&&Zr.document?"BROWSER":"REST",ts="NODE"===es,is=Kr.left;to({target:"Array",proto:!0,forced:!ts&&iA>79&&iA<83||!zr("reduce")},{reduce:function(A){var e=arguments.length;return is(this,A,e,e>1?arguments[1]:void 0)}});var os=Kr.right;to({target:"Array",proto:!0,forced:!ts&&iA>79&&iA<83||!zr("reduceRight")},{reduceRight:function(A){return os(this,A,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ns=S,rs=Array.isArray||function(A){return"Array"===ns(A)},ss=to,as=rs,gs=y([].reverse),cs=[1,2];ss({target:"Array",proto:!0,forced:String(cs)===String(cs.reverse())},{reverse:function(){return as(this)&&(this.length=this.length),gs(this)}});var ls=dA,Is=TypeError,us=y([].slice),Es=us,ds=Math.floor,hs=function(A,e){var t=A.length;if(t<8)for(var i,o,n=1;n0;)A[o]=A[--o];o!==n++&&(A[o]=i)}else for(var r=ds(t/2),s=hs(Es(A,0,r),e),a=hs(Es(A,r),e),g=s.length,c=a.length,l=0,I=0;l3)){if(Gs)return!0;if(Ls)return Ls<603;var A,e,t,i,o="";for(A=65;A<76;A++){switch(e=String.fromCharCode(A),A){case 66:case 69:case 70:case 72:t=3;break;case 68:case 71:t=4;break;default:t=2}for(i=0;i<47;i++)Us.push({k:e+i,v:t})}for(Us.sort(function(A,e){return e.v-A.v}),i=0;iRs(t)?1:-1}}(A)),t=Ss(o),i=0;it||a!=a?1/0*r:r*a},ra=Math.fround||function(A){return na(A,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},sa=Array,aa=Math.abs,ga=Math.pow,ca=Math.floor,la=Math.log,Ia=Math.LN2,ua=xA,Ea=ai,da=ui,ha=function(A){for(var e=ua(this),t=da(e),i=arguments.length,o=Ea(i>1?arguments[1]:void 0,t),n=i>2?arguments[2]:void 0,r=void 0===n?t:Ea(n,t);r>o;)e[o++]=A;return e},Ca=P,Ba=J,Qa=rr,pa=function(A,e,t){var i,o;return Qa&&Ca(i=e.constructor)&&i!==t&&Ba(o=i.prototype)&&o!==t.prototype&&Qa(A,o),A},fa=o,ma=y,ya=s,Da=Hs,va=We,wa=Co,Sa=Vs,Ma=r,Ra=Ws,_a=oi,Ta=li,Na=$s,ba=ra,Ga={pack:function(A,e,t){var i,o,n,r=sa(t),s=8*t-e-1,a=(1<>1,c=23===e?ga(2,-24)-ga(2,-77):0,l=A<0||0===A&&1/A<0?1:0,I=0;for((A=aa(A))!=A||1/0===A?(o=A!=A?1:0,i=a):(i=ca(la(A)/Ia),A*(n=ga(2,-i))<1&&(i--,n*=2),(A+=i+g>=1?c/n:c*ga(2,1-g))*n>=2&&(i++,n/=2),i+g>=a?(o=0,i=a):i+g>=1?(o=(A*n-1)*ga(2,e),i+=g):(o=A*ga(2,g-1)*ga(2,e),i=0));e>=8;)r[I++]=255&o,o/=256,e-=8;for(i=i<0;)r[I++]=255&i,i/=256,s-=8;return r[I-1]|=128*l,r},unpack:function(A,e){var t,i=A.length,o=8*i-e-1,n=(1<>1,s=o-7,a=i-1,g=A[a--],c=127&g;for(g>>=7;s>0;)c=256*c+A[a--],s-=8;for(t=c&(1<<-s)-1,c>>=-s,s+=e;s>0;)t=256*t+A[a--],s-=8;if(0===c)c=1-r;else{if(c===n)return t?NaN:g?-1/0:1/0;t+=ga(2,e),c-=r}return(g?-1:1)*t*ga(2,c-e)}},ka=_n,La=rr,Ua=ha,Fa=us,Oa=pa,xa=Oi,Pa=Yn,Ya=_t,Ja=tt.PROPER,Ha=tt.CONFIGURABLE,qa="ArrayBuffer",Va="DataView",ja="prototype",Ka="Wrong index",Wa=Ya.getterFor(qa),za=Ya.getterFor(Va),Za=Ya.set,Xa=fa[qa],$a=Xa,Ag=$a&&$a[ja],eg=fa[Va],tg=eg&&eg[ja],ig=Object.prototype,og=fa.Array,ng=fa.RangeError,rg=ma(Ua),sg=ma([].reverse),ag=Ga.pack,gg=Ga.unpack,cg=function(A){return[255&A]},lg=function(A){return[255&A,A>>8&255]},Ig=function(A){return[255&A,A>>8&255,A>>16&255,A>>24&255]},ug=function(A){return A[3]<<24|A[2]<<16|A[1]<<8|A[0]},Eg=function(A){return ag(ba(A),23,4)},dg=function(A){return ag(A,52,8)},hg=function(A,e,t){wa(A[ja],e,{configurable:!0,get:function(){return t(this)[e]}})},Cg=function(A,e,t,i){var o=za(A),n=Na(t),r=!!i;if(n+e>o.byteLength)throw new ng(Ka);var s=o.bytes,a=n+o.byteOffset,g=Fa(s,a,a+e);return r?g:sg(g)},Bg=function(A,e,t,i,o,n){var r=za(A),s=Na(t),a=i(+o),g=!!n;if(s+e>r.byteLength)throw new ng(Ka);for(var c=r.bytes,l=s+r.byteOffset,I=0;I>24)},setUint8:function(A,e){fg(this,A,e<<24>>24)}},{unsafe:!0})}else Ag=($a=function(A){Ra(this,Ag);var e=Na(A);Za(this,{type:qa,bytes:rg(og(e),0),byteLength:e}),ya||(this.byteLength=e,this.detached=!1)})[ja],tg=(eg=function(A,e,t){Ra(this,tg),Ra(A,Ag);var i=Wa(A),o=i.byteLength,n=_a(e);if(n<0||n>o)throw new ng("Wrong offset");if(n+(t=void 0===t?o-n:Ta(t))>o)throw new ng("Wrong length");Za(this,{type:Va,buffer:A,byteLength:t,byteOffset:n,bytes:i.bytes}),ya||(this.buffer=A,this.byteLength=t,this.byteOffset=n)})[ja],ya&&(hg($a,"byteLength",Wa),hg(eg,"buffer",za),hg(eg,"byteLength",za),hg(eg,"byteOffset",za)),Sa(tg,{getInt8:function(A){return Cg(this,1,A)[0]<<24>>24},getUint8:function(A){return Cg(this,1,A)[0]},getInt16:function(A){var e=Cg(this,2,A,arguments.length>1&&arguments[1]);return(e[1]<<8|e[0])<<16>>16},getUint16:function(A){var e=Cg(this,2,A,arguments.length>1&&arguments[1]);return e[1]<<8|e[0]},getInt32:function(A){return ug(Cg(this,4,A,arguments.length>1&&arguments[1]))},getUint32:function(A){return ug(Cg(this,4,A,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(A){return gg(Cg(this,4,A,arguments.length>1&&arguments[1]),23)},getFloat64:function(A){return gg(Cg(this,8,A,arguments.length>1&&arguments[1]),52)},setInt8:function(A,e){Bg(this,1,A,cg,e)},setUint8:function(A,e){Bg(this,1,A,cg,e)},setInt16:function(A,e){Bg(this,2,A,lg,e,arguments.length>2&&arguments[2])},setUint16:function(A,e){Bg(this,2,A,lg,e,arguments.length>2&&arguments[2])},setInt32:function(A,e){Bg(this,4,A,Ig,e,arguments.length>2&&arguments[2])},setUint32:function(A,e){Bg(this,4,A,Ig,e,arguments.length>2&&arguments[2])},setFloat32:function(A,e){Bg(this,4,A,Eg,e,arguments.length>2&&arguments[2])},setFloat64:function(A,e){Bg(this,8,A,dg,e,arguments.length>2&&arguments[2])}});Pa($a,qa),Pa(eg,Va);var mg={ArrayBuffer:$a,DataView:eg},yg=V,Dg=Co,vg=s,wg=ie("species"),Sg=function(A){var e=yg(A);vg&&e&&!e[wg]&&Dg(e,wg,{configurable:!0,get:function(){return this}})},Mg=Sg,Rg="ArrayBuffer",_g=mg[Rg];to({global:!0,constructor:!0,forced:o[Rg]!==_g},{ArrayBuffer:_g}),Mg(Rg);var Tg=S,Ng=y,bg=function(A){if("Function"===Tg(A))return Ng(A)},Gg=to,kg=bg,Lg=r,Ug=ke,Fg=ai,Og=li,xg=mg.ArrayBuffer,Pg=mg.DataView,Yg=Pg.prototype,Jg=kg(xg.prototype.slice),Hg=kg(Yg.getUint8),qg=kg(Yg.setUint8);Gg({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Lg(function(){return!new xg(2).slice(1,void 0).byteLength})},{slice:function(A,e){if(Jg&&void 0===e)return Jg(Ug(this),A);for(var t=Ug(this).byteLength,i=Fg(A,t),o=Fg(void 0===e?t:e,t),n=new xg(Og(o-i)),r=new Pg(this),s=new Pg(n),a=0;in;n++)if((s=C(A[n]))&&yu(Ru,s))return s;return new Mu(!1)}i=Du(A,o)}for(a=I?A.next:i.next;!(g=Bu(a,i)).done;){try{s=C(g.value)}catch(JV){wu(i,"throw",JV)}if("object"==typeof s&&s&&yu(Ru,s))return s}return new Mu(!1)},Tu=ie("iterator"),Nu=!1;try{var bu=0,Gu={next:function(){return{done:!!bu++}},return:function(){Nu=!0}};Gu[Tu]=function(){return this},Array.from(Gu,function(){throw 2})}catch(JV){}var ku=function(A,e){try{if(!e&&!Nu)return!1}catch(JV){return!1}var t=!1;try{var i={};i[Tu]=function(){return{next:function(){return{done:t=!0}}}},A(i)}catch(JV){}return t},Lu=kl,Uu=jl.CONSTRUCTOR||!ku(function(A){Lu.all(A).then(void 0,function(){})}),Fu=l,Ou=QA,xu=Kl,Pu=Gl,Yu=_u;to({target:"Promise",stat:!0,forced:Uu},{all:function(A){var e=this,t=xu.f(e),i=t.resolve,o=t.reject,n=Pu(function(){var t=Ou(e.resolve),n=[],r=0,s=1;Yu(A,function(A){var a=r++,g=!1;s++,Fu(t,e,A).then(function(A){g||(g=!0,n[a]=A,--s||i(n))},o)}),--s||i(n)});return n.error&&o(n.value),t.promise}});var Ju=to,Hu=jl.CONSTRUCTOR,qu=kl,Vu=V,ju=P,Ku=$t,Wu=qu&&qu.prototype;if(Ju({target:"Promise",proto:!0,forced:Hu,real:!0},{catch:function(A){return this.then(void 0,A)}}),ju(qu)){var zu=Vu("Promise").prototype.catch;Wu.catch!==zu&&Ku(Wu,"catch",zu,{unsafe:!0})}var Zu=l,Xu=QA,$u=Kl,AE=Gl,eE=_u;to({target:"Promise",stat:!0,forced:Uu},{race:function(A){var e=this,t=$u.f(e),i=t.reject,o=AE(function(){var o=Xu(e.resolve);eE(A,function(A){Zu(o,e,A).then(t.resolve,i)})});return o.error&&i(o.value),t.promise}});var tE=Kl;to({target:"Promise",stat:!0,forced:jl.CONSTRUCTOR},{reject:function(A){var e=tE.f(this);return(0,e.reject)(A),e.promise}});var iE=ke,oE=J,nE=Kl,rE=function(A,e){if(iE(A),oE(e)&&e.constructor===A)return e;var t=nE.f(A);return(0,t.resolve)(e),t.promise},sE=to,aE=jl.CONSTRUCTOR,gE=rE;V("Promise"),sE({target:"Promise",stat:!0,forced:aE},{resolve:function(A){return gE(this,A)}});var cE=to,lE=kl,IE=r,uE=V,EE=P,dE=Bc,hE=rE,CE=$t,BE=lE&&lE.prototype;if(cE({target:"Promise",proto:!0,real:!0,forced:!!lE&&IE(function(){BE.finally.call({then:function(){}},function(){})})},{finally:function(A){var e=dE(this,uE("Promise")),t=EE(A);return this.then(t?function(t){return hE(e,A()).then(function(){return t})}:A,t?function(t){return hE(e,A()).then(function(){throw t})}:A)}}),EE(lE)){var QE=uE("Promise").prototype.finally;BE.finally!==QE&&CE(BE,"finally",QE,{unsafe:!0})}var pE=J,fE=S,mE=ie("match"),yE=function(A){var e;return pE(A)&&(void 0!==(e=A[mE])?!!e:"RegExp"===fE(A))},DE=r,vE=o.RegExp,wE=!DE(function(){var A=!0;try{vE(".","d")}catch(JV){A=!1}var e={},t="",i=A?"dgimsy":"gimsy",o=function(A,i){Object.defineProperty(e,A,{get:function(){return t+=i,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var r in A&&(n.hasIndices="d"),n)o(r,n[r]);return Object.getOwnPropertyDescriptor(vE.prototype,"flags").get.call(e)!==i||t!==i}),SE=ke,ME=function(){var A=SE(this),e="";return A.hasIndices&&(e+="d"),A.global&&(e+="g"),A.ignoreCase&&(e+="i"),A.multiline&&(e+="m"),A.dotAll&&(e+="s"),A.unicode&&(e+="u"),A.unicodeSets&&(e+="v"),A.sticky&&(e+="y"),e},RE=l,_E=JA,TE=j,NE={correct:wE},bE=ME,GE=RegExp.prototype,kE=NE.correct?function(A){return A.flags}:function(A){return NE.correct||!TE(GE,A)||_E(A,"flags")?A.flags:RE(bE,A)},LE=r,UE=o.RegExp,FE=LE(function(){var A=UE("a","y");return A.lastIndex=2,null!==A.exec("abcd")}),OE=FE||LE(function(){return!UE("a","y").sticky}),xE={BROKEN_CARET:FE||LE(function(){var A=UE("^r","gy");return A.lastIndex=2,null!==A.exec("str")}),MISSED_STICKY:OE,UNSUPPORTED_Y:FE},PE=_e.f,YE=r,JE=o.RegExp,HE=YE(function(){var A=JE(".","s");return!(A.dotAll&&A.test("\n")&&"s"===A.flags)}),qE=r,VE=o.RegExp,jE=qE(function(){var A=VE("(?b)","g");return"b"!==A.exec("b").groups.a||"bc"!=="b".replace(A,"$c")}),KE=s,WE=o,zE=y,ZE=Ki,XE=pa,$E=We,Ad=gn,ed=Ai.f,td=j,id=yE,od=uo,nd=kE,rd=xE,sd=function(A,e,t){t in A||PE(A,t,{configurable:!0,get:function(){return e[t]},set:function(A){e[t]=A}})},ad=$t,gd=r,cd=JA,ld=_t.enforce,Id=Sg,ud=HE,Ed=jE,dd=ie("match"),hd=WE.RegExp,Cd=hd.prototype,Bd=WE.SyntaxError,Qd=zE(Cd.exec),pd=zE("".charAt),fd=zE("".replace),md=zE("".indexOf),yd=zE("".slice),Dd=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,vd=/a/g,wd=/a/g,Sd=new hd(vd)!==vd,Md=rd.MISSED_STICKY,Rd=rd.UNSUPPORTED_Y,_d=KE&&(!Sd||Md||ud||Ed||gd(function(){return wd[dd]=!1,hd(vd)!==vd||hd(wd)===wd||"/a/i"!==String(hd(vd,"i"))}));if(ZE("RegExp",_d)){for(var Td=function(A,e){var t,i,o,n,r,s,a=td(Cd,this),g=id(A),c=void 0===e,l=[],I=A;if(!a&&g&&c&&A.constructor===Td)return A;if((g||td(Cd,A))&&(A=A.source,c&&(e=nd(I))),A=void 0===A?"":od(A),e=void 0===e?"":od(e),I=A,ud&&"dotAll"in vd&&(i=!!e&&md(e,"s")>-1)&&(e=fd(e,/s/g,"")),t=e,Md&&"sticky"in vd&&(o=!!e&&md(e,"y")>-1)&&Rd&&(e=fd(e,/y/g,"")),Ed&&(A=(n=function(A){for(var e,t=A.length,i=0,o="",n=[],r=Ad(null),s=!1,a=!1,g=0,c="";i<=t;i++){if("\\"===(e=pd(A,i)))e+=pd(A,++i);else if("]"===e)s=!1;else if(!s)switch(!0){case"["===e:s=!0;break;case"("===e:if(o+=e,"?:"===yd(A,i+1,i+3))continue;Qd(Dd,yd(A,i+1))&&(i+=2,a=!0),g++;continue;case">"===e&&a:if(""===c||cd(r,c))throw new Bd("Invalid capture group name");r[c]=!0,n[n.length]=[c,g],a=!1,c="";continue}a?c+=e:o+=e}return[o,n]}(A))[0],l=n[1]),r=XE(hd(A,e),a?this:Cd,Td),(i||o||l.length)&&(s=ld(r),i&&(s.dotAll=!0,s.raw=Td(function(A){for(var e,t=A.length,i=0,o="",n=!1;i<=t;i++)"\\"!==(e=pd(A,i))?n||"."!==e?("["===e?n=!0:"]"===e&&(n=!1),o+=e):o+="[\\s\\S]":o+=e+pd(A,++i);return o}(A),t)),o&&(s.sticky=!0),l.length&&(s.groups=l)),A!==I)try{$E(r,"source",""===I?"(?:)":I)}catch(JV){}return r},Nd=ed(hd),bd=0;Nd.length>bd;)sd(Td,hd,Nd[bd++]);Cd.constructor=Td,Td.prototype=Cd,ad(WE,"RegExp",Td,{constructor:!0})}Id("RegExp");var Gd,kd,Ld=l,Ud=y,Fd=uo,Od=ME,xd=xE,Pd=gn,Yd=_t.get,Jd=HE,Hd=jE,qd=UA("native-string-replace",String.prototype.replace),Vd=RegExp.prototype.exec,jd=Vd,Kd=Ud("".charAt),Wd=Ud("".indexOf),zd=Ud("".replace),Zd=Ud("".slice),Xd=(kd=/b*/g,Ld(Vd,Gd=/a/,"a"),Ld(Vd,kd,"a"),0!==Gd.lastIndex||0!==kd.lastIndex),$d=xd.BROKEN_CARET,Ah=void 0!==/()??/.exec("")[1];(Xd||Ah||$d||Jd||Hd)&&(jd=function(A){var e,t,i,o,n,r,s,a=this,g=Yd(a),c=Fd(A),l=g.raw;if(l)return l.lastIndex=a.lastIndex,e=Ld(jd,l,c),a.lastIndex=l.lastIndex,e;var I=g.groups,u=$d&&a.sticky,E=Ld(Od,a),d=a.source,h=0,C=c;if(u&&(E=zd(E,"y",""),-1===Wd(E,"g")&&(E+="g"),C=Zd(c,a.lastIndex),a.lastIndex>0&&(!a.multiline||a.multiline&&"\n"!==Kd(c,a.lastIndex-1))&&(d="(?: "+d+")",C=" "+C,h++),t=new RegExp("^(?:"+d+")",E)),Ah&&(t=new RegExp("^"+d+"$(?!\\s)",E)),Xd&&(i=a.lastIndex),o=Ld(Vd,u?t:a,C),u?o?(o.input=Zd(o.input,h),o[0]=Zd(o[0],h),o.index=a.lastIndex,a.lastIndex+=o[0].length):a.lastIndex=0:Xd&&o&&(a.lastIndex=a.global?o.index+o[0].length:i),Ah&&o&&o.length>1&&Ld(qd,o[0],t,function(){for(n=1;n0;(i>>>=1)&&(e+=e))1&i&&(t+=e);return t}),lh=rh("".slice),Ih=Math.ceil,uh=function(A){return function(e,t,i){var o,n,r=ah(gh(e)),s=sh(t),a=r.length,g=void 0===i?" ":ah(i);return s<=a||""===g?r:((n=ch(g,Ih((o=s-a)/g.length))).length>o&&(n=lh(n,0,o)),A?r+n:n+r)}},Eh={start:uh(!1),end:uh(!0)},dh=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(z),hh=Eh.start;to({target:"String",proto:!0,forced:dh},{padStart:function(A){return hh(this,A,arguments.length>1?arguments[1]:void 0)}});var Ch=l,Bh=$t,Qh=eh,ph=r,fh=ie,mh=We,yh=fh("species"),Dh=RegExp.prototype,vh=y,wh=oi,Sh=uo,Mh=L,Rh=vh("".charAt),_h=vh("".charCodeAt),Th=vh("".slice),Nh=function(A){return function(e,t){var i,o,n=Sh(Mh(e)),r=wh(t),s=n.length;return r<0||r>=s?A?"":void 0:(i=_h(n,r))<55296||i>56319||r+1===s||(o=_h(n,r+1))<56320||o>57343?A?Rh(n,r):i:A?Th(n,r,r+2):o-56320+(i-55296<<10)+65536}},bh={codeAt:Nh(!1),charAt:Nh(!0)},Gh=bh.charAt,kh=y,Lh=xA,Uh=Math.floor,Fh=kh("".charAt),Oh=kh("".replace),xh=kh("".slice),Ph=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Yh=/\$([$&'`]|\d{1,2})/g,Jh=function(A,e,t,i,o,n){var r=t+A.length,s=i.length,a=Yh;return void 0!==o&&(o=Lh(o),a=Ph),Oh(n,a,function(n,a){var g;switch(Fh(a,0)){case"$":return"$";case"&":return A;case"`":return xh(e,0,t);case"'":return xh(e,r);case"<":g=o[xh(a,1,-1)];break;default:var c=+a;if(0===c)return n;if(c>s){var l=Uh(c/10);return 0===l?n:l<=s?void 0===i[l-1]?Fh(a,1):i[l-1]+Fh(a,1):n}g=i[c-1]}return void 0===g?"":g})},Hh=l,qh=ke,Vh=P,jh=S,Kh=eh,Wh=TypeError,zh=yc,Zh=l,Xh=y,$h=function(A,e,t,i){var o=fh(A),n=!ph(function(){var e={};return e[o]=function(){return 7},7!==""[A](e)}),r=n&&!ph(function(){var e=!1,t=/a/;if("split"===A){var i={};i[yh]=function(){return t},(t={constructor:i,flags:""})[o]=/./[o]}return t.exec=function(){return e=!0,null},t[o](""),!e});if(!n||!r||t){var s=/./[o],a=e(o,""[A],function(A,e,t,i,o){var r=e.exec;return r===Qh||r===Dh.exec?n&&!o?{done:!0,value:Ch(s,e,t,i)}:{done:!0,value:Ch(A,t,e,i)}:{done:!1}});Bh(String.prototype,A,a[0]),Bh(Dh,o,a[1])}i&&mh(Dh[o],"sham",!0)},AC=r,eC=ke,tC=P,iC=J,oC=oi,nC=li,rC=uo,sC=L,aC=function(A,e,t){return e+(t?Gh(A,e).length:1)},gC=mA,cC=Jh,lC=kE,IC=function(A,e){var t=A.exec;if(Vh(t)){var i=Hh(t,A,e);return null!==i&&qh(i),i}if("RegExp"===jh(A))return Hh(Kh,A,e);throw new Wh("RegExp#exec called on incompatible receiver")},uC=ie("replace"),EC=Math.max,dC=Math.min,hC=Xh([].concat),CC=Xh([].push),BC=Xh("".indexOf),QC=Xh("".slice),pC=function(A){return void 0===A?A:String(A)},fC="$0"==="a".replace(/./,"$0"),mC=!!/./[uC]&&""===/./[uC]("a","$0"),yC=!AC(function(){var A=/./;return A.exec=function(){var A=[];return A.groups={a:"7"},A},"7"!=="".replace(A,"$")});$h("replace",function(A,e,t){var i=mC?"$":"$0";return[function(A,t){var i=sC(this),o=iC(A)?gC(A,uC):void 0;return o?Zh(o,A,i,t):Zh(e,rC(i),A,t)},function(A,o){var n=eC(this),r=rC(A);if("string"==typeof o&&-1===BC(o,i)&&-1===BC(o,"$<")){var s=t(e,n,r,o);if(s.done)return s.value}var a=tC(o);a||(o=rC(o));var g,c=rC(lC(n)),l=-1!==BC(c,"g");l&&(g=-1!==BC(c,"u"),n.lastIndex=0);for(var I,u=[];null!==(I=IC(n,r))&&(CC(u,I),l);)""===rC(I[0])&&(n.lastIndex=aC(r,nC(n.lastIndex),g));for(var E="",d=0,h=0;h=d&&(E+=QC(r,d,Q)+C,d=Q+B.length)}return E+QC(r,d)}]},!yC||!fC||mC);var DC="\t\n\v\f\r                 \u2028\u2029\ufeff",vC=L,wC=uo,SC=DC,MC=y("".replace),RC=RegExp("^["+SC+"]+"),_C=RegExp("(^|[^"+SC+"])["+SC+"]+$"),TC=function(A){return function(e){var t=wC(vC(e));return 1&A&&(t=MC(t,RC,"")),2&A&&(t=MC(t,_C,"$1")),t}},NC={start:TC(1),end:TC(2),trim:TC(3)},bC=tt.PROPER,GC=r,kC=DC,LC=NC.trim;to({target:"String",proto:!0,forced:function(A){return GC(function(){return!!kC[A]()||"​…᠎"!=="​…᠎"[A]()||bC&&kC[A].name!==A})}("trim")},{trim:function(){return LC(this)}});var UC,FC,OC,xC={exports:{}},PC=Hs,YC=s,JC=o,HC=P,qC=J,VC=JA,jC=co,KC=dA,WC=We,zC=$t,ZC=Co,XC=j,$C=_n,AB=rr,eB=ie,tB=KA,iB=_t.enforce,oB=_t.get,nB=JC.Int8Array,rB=nB&&nB.prototype,sB=JC.Uint8ClampedArray,aB=sB&&sB.prototype,gB=nB&&$C(nB),cB=rB&&$C(rB),lB=Object.prototype,IB=JC.TypeError,uB=eB("toStringTag"),EB=tB("TYPED_ARRAY_TAG"),dB="TypedArrayConstructor",hB=PC&&!!AB&&"Opera"!==jC(JC.opera),CB=!1,BB={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},QB={BigInt64Array:8,BigUint64Array:8},pB=function(A){var e=$C(A);if(qC(e)){var t=oB(e);return t&&VC(t,dB)?t[dB]:pB(e)}},fB=function(A){if(!qC(A))return!1;var e=jC(A);return VC(BB,e)||VC(QB,e)};for(UC in BB)(OC=(FC=JC[UC])&&FC.prototype)?iB(OC)[dB]=FC:hB=!1;for(UC in QB)(OC=(FC=JC[UC])&&FC.prototype)&&(iB(OC)[dB]=FC);if((!hB||!HC(gB)||gB===Function.prototype)&&(gB=function(){throw new IB("Incorrect invocation")},hB))for(UC in BB)JC[UC]&&AB(JC[UC],gB);if((!hB||!cB||cB===lB)&&(cB=gB.prototype,hB))for(UC in BB)JC[UC]&&AB(JC[UC].prototype,cB);if(hB&&$C(aB)!==cB&&AB(aB,cB),YC&&!VC(cB,uB))for(UC in CB=!0,ZC(cB,uB,{configurable:!0,get:function(){return qC(this)?this[EB]:void 0}}),BB)JC[UC]&&WC(JC[UC],EB,UC);var mB={NATIVE_ARRAY_BUFFER_VIEWS:hB,TYPED_ARRAY_TAG:CB&&EB,aTypedArray:function(A){if(fB(A))return A;throw new IB("Target is not a typed array")},aTypedArrayConstructor:function(A){if(HC(A)&&(!AB||XC(gB,A)))return A;throw new IB(KC(A)+" is not a typed array constructor")},exportTypedArrayMethod:function(A,e,t,i){if(YC){if(t)for(var o in BB){var n=JC[o];if(n&&VC(n.prototype,A))try{delete n.prototype[A]}catch(JV){try{n.prototype[A]=e}catch(r){}}}cB[A]&&!t||zC(cB,A,t?e:hB&&rB[A]||e,i)}},exportTypedArrayStaticMethod:function(A,e,t){var i,o;if(YC){if(AB){if(t)for(i in BB)if((o=JC[i])&&VC(o,A))try{delete o[A]}catch(JV){}if(gB[A]&&!t)return;try{return zC(gB,A,t?e:hB&&gB[A]||e)}catch(JV){}}for(i in BB)!(o=JC[i])||o[A]&&!t||zC(o,A,e)}},getTypedArrayConstructor:pB,isView:function(A){if(!qC(A))return!1;var e=jC(A);return"DataView"===e||VC(BB,e)||VC(QB,e)},isTypedArray:fB,TypedArray:gB,TypedArrayPrototype:cB},yB=o,DB=r,vB=ku,wB=mB.NATIVE_ARRAY_BUFFER_VIEWS,SB=yB.ArrayBuffer,MB=yB.Int8Array,RB=!wB||!DB(function(){MB(1)})||!DB(function(){new MB(-1)})||!vB(function(A){new MB,new MB(null),new MB(1.5),new MB(A)},!0)||DB(function(){return 1!==new MB(new SB(2),1,void 0).length}),_B=J,TB=Math.floor,NB=Number.isInteger||function(A){return!_B(A)&&isFinite(A)&&TB(A)===A},bB=oi,GB=RangeError,kB=function(A){var e=bB(A);if(e<0)throw new GB("The argument can't be less than 0");return e},LB=RangeError,UB=function(A,e){var t=kB(A);if(t%e)throw new LB("Wrong offset");return t},FB=Math.round,OB=co,xB=le,PB=TypeError,YB=function(A){var e=xB(A,"number");if("number"==typeof e)throw new PB("Can't convert number to bigint");return BigInt(e)},JB=Sc,HB=l,qB=uc,VB=xA,jB=ui,KB=Iu,WB=nu,zB=$I,ZB=function(A){var e=OB(A);return"BigInt64Array"===e||"BigUint64Array"===e},XB=mB.aTypedArrayConstructor,$B=YB,AQ=function(A){var e,t,i,o,n,r,s,a,g=qB(this),c=VB(A),l=arguments.length,I=l>1?arguments[1]:void 0,u=void 0!==I,E=WB(c);if(E&&!zB(E))for(a=(s=KB(c,E)).next,c=[];!(r=HB(a,s)).done;)c.push(r.value);for(u&&l>2&&(I=JB(I,arguments[2])),t=jB(c),i=new(XB(g))(t),o=ZB(i),e=0;t>e;e++)n=u?I(c[e],e):c[e],i[e]=o?$B(n):+n;return i},eQ=rs,tQ=gc,iQ=J,oQ=ie("species"),nQ=Array,rQ=function(A){var e;return eQ(A)&&(e=A.constructor,(tQ(e)&&(e===nQ||eQ(e.prototype))||iQ(e)&&null===(e=e[oQ]))&&(e=void 0)),void 0===e?nQ:e},sQ=Sc,aQ=N,gQ=xA,cQ=ui,lQ=function(A,e){return new(rQ(A))(0===e?0:e)},IQ=y([].push),uQ=function(A){var e=1===A,t=2===A,i=3===A,o=4===A,n=6===A,r=7===A,s=5===A||n;return function(a,g,c,l){for(var I,u,E=gQ(a),d=aQ(E),h=cQ(d),C=sQ(g,c),B=0,Q=l||lQ,p=e?Q(a,h):t||r?Q(a,0):void 0;h>B;B++)if((s||B in d)&&(u=C(I=d[B],B,E),A))if(e)p[B]=u;else if(u)switch(A){case 3:return!0;case 5:return I;case 6:return B;case 2:IQ(p,I)}else switch(A){case 4:return!1;case 7:IQ(p,I)}return n?-1:i||o?o:p}},EQ={forEach:uQ(0),map:uQ(1),filter:uQ(2),some:uQ(3),every:uQ(4),find:uQ(5),findIndex:uQ(6),filterReject:uQ(7)},dQ=ui,hQ=to,CQ=o,BQ=l,QQ=s,pQ=RB,fQ=mB,mQ=mg,yQ=Ws,DQ=B,vQ=We,wQ=NB,SQ=li,MQ=$s,RQ=UB,_Q=function(A){var e=FB(A);return e<0?0:e>255?255:255&e},TQ=Ee,NQ=JA,bQ=co,GQ=J,kQ=uA,LQ=gn,UQ=j,FQ=rr,OQ=Ai.f,xQ=AQ,PQ=EQ.forEach,YQ=Sg,JQ=Co,HQ=_e,qQ=n,VQ=function(A,e,t){for(var i=0,o=arguments.length>2?t:dQ(e),n=new A(o);o>i;)n[i]=e[i++];return n},jQ=pa,KQ=_t.get,WQ=_t.set,zQ=_t.enforce,ZQ=HQ.f,XQ=qQ.f,$Q=CQ.RangeError,Ap=mQ.ArrayBuffer,ep=Ap.prototype,tp=mQ.DataView,ip=fQ.NATIVE_ARRAY_BUFFER_VIEWS,op=fQ.TYPED_ARRAY_TAG,np=fQ.TypedArray,rp=fQ.TypedArrayPrototype,sp=fQ.isTypedArray,ap="BYTES_PER_ELEMENT",gp="Wrong length",cp=function(A,e){JQ(A,e,{configurable:!0,get:function(){return KQ(this)[e]}})},lp=function(A){var e;return UQ(ep,A)||"ArrayBuffer"===(e=bQ(A))||"SharedArrayBuffer"===e},Ip=function(A,e){return sp(A)&&!kQ(e)&&e in A&&wQ(+e)&&e>=0},up=function(A,e){return e=TQ(e),Ip(A,e)?DQ(2,A[e]):XQ(A,e)},Ep=function(A,e,t){return e=TQ(e),!(Ip(A,e)&&GQ(t)&&NQ(t,"value"))||NQ(t,"get")||NQ(t,"set")||t.configurable||NQ(t,"writable")&&!t.writable||NQ(t,"enumerable")&&!t.enumerable?ZQ(A,e,t):(A[e]=t.value,A)};QQ?(ip||(qQ.f=up,HQ.f=Ep,cp(rp,"buffer"),cp(rp,"byteOffset"),cp(rp,"byteLength"),cp(rp,"length")),hQ({target:"Object",stat:!0,forced:!ip},{getOwnPropertyDescriptor:up,defineProperty:Ep}),xC.exports=function(A,e,t){var i=A.match(/\d+/)[0]/8,o=A+(t?"Clamped":"")+"Array",n="get"+A,r="set"+A,s=CQ[o],a=s,g=a&&a.prototype,c={},l=function(A,e){ZQ(A,e,{get:function(){return A=e,(t=KQ(this)).view[n](A*i+t.byteOffset,!0);var A,t},set:function(A){return o=e,n=A,void(s=KQ(this)).view[r](o*i+s.byteOffset,t?_Q(n):n,!0);var o,n,s},enumerable:!0})};ip?pQ&&(a=e(function(A,e,t,o){return yQ(A,g),jQ(GQ(e)?lp(e)?void 0!==o?new s(e,RQ(t,i),o):void 0!==t?new s(e,RQ(t,i)):new s(e):sp(e)?VQ(a,e):BQ(xQ,a,e):new s(MQ(e)),A,a)}),FQ&&FQ(a,np),PQ(OQ(s),function(A){A in a||vQ(a,A,s[A])}),a.prototype=g):(a=e(function(A,e,t,o){yQ(A,g);var n,r,s,c=0,I=0;if(GQ(e)){if(!lp(e))return sp(e)?VQ(a,e):BQ(xQ,a,e);n=e,I=RQ(t,i);var u=e.byteLength;if(void 0===o){if(u%i)throw new $Q(gp);if((r=u-I)<0)throw new $Q(gp)}else if((r=SQ(o)*i)+I>u)throw new $Q(gp);s=r/i}else s=MQ(e),n=new Ap(r=s*i);for(WQ(A,{buffer:n,byteOffset:I,byteLength:r,length:s,view:new tp(n)});c1?arguments[1]:void 0,e>2?arguments[2]:void 0)},pp(function(){var A=0;return new Int8Array(2).fill({valueOf:function(){return A++}}),1!==A})),(0,mB.exportTypedArrayStaticMethod)("from",AQ,RB);var Dp=o,vp=l,wp=mB,Sp=ui,Mp=UB,Rp=xA,_p=r,Tp=Dp.RangeError,Np=Dp.Int8Array,bp=Np&&Np.prototype,Gp=bp&&bp.set,kp=wp.aTypedArray,Lp=wp.exportTypedArrayMethod,Up=!_p(function(){var A=new Uint8ClampedArray(2);return vp(Gp,A,{length:1,0:3},1),3!==A[1]}),Fp=Up&&wp.NATIVE_ARRAY_BUFFER_VIEWS&&_p(function(){var A=new Np(2);return A.set(1),A.set("2",1),0!==A[0]||2!==A[1]});Lp("set",function(A){kp(this);var e=Mp(arguments.length>1?arguments[1]:void 0,1),t=Rp(A);if(Up)return vp(Gp,this,t,e);var i=this.length,o=Sp(t),n=0;if(o+e>i)throw new Tp("Wrong length");for(;n0&&1/t<0?1:-1:e>t}}(A))},!Xp||Zp);var $p=to,Af=l,ef=y,tf=L,of=P,nf=J,rf=yE,sf=uo,af=mA,gf=kE,cf=Jh,lf=ie("replace"),If=TypeError,uf=ef("".indexOf);ef("".replace);var Ef=ef("".slice),df=Math.max;$p({target:"String",proto:!0},{replaceAll:function(A,e){var t,i,o,n,r,s,a,g,c,l=tf(this),I=0,u="";if(nf(A)){if(rf(A)&&(t=sf(tf(gf(A))),!~uf(t,"g")))throw new If("`.replaceAll` does not allow non-global regexes");if(i=af(A,lf))return Af(i,A,l,e)}for(o=sf(l),n=sf(A),(r=of(e))||(e=sf(e)),s=n.length,a=df(1,s),g=uf(o,n);-1!==g;)c=r?sf(e(n,g,o)):cf(n,o,g,[],void 0,e),u+=Ef(o,I,g)+c,I=g+s,g=g+a>o.length?-1:uf(o,n,g+a);return I1?arguments[1]:void 0)},mf=o,yf=hf,Df=Qf,vf=ff,wf=We,Sf=function(A){if(A&&A.forEach!==vf)try{wf(A,"forEach",vf)}catch(JV){A.forEach=vf}};for(var Mf in yf)yf[Mf]&&Sf(mf[Mf]&&mf[Mf].prototype);Sf(Df);var Rf=o,_f=hf,Tf=Qf,Nf=Or,bf=We,Gf=Yn,kf=ie("iterator"),Lf=Nf.values,Uf=function(A,e){if(A){if(A[kf]!==Lf)try{bf(A,kf,Lf)}catch(JV){A[kf]=Lf}if(Gf(A,e,!0),_f[e])for(var t in Nf)if(A[t]!==Nf[t])try{bf(A,t,Nf[t])}catch(JV){A[t]=Nf[t]}}};for(var Ff in _f)Uf(Rf[Ff]&&Rf[Ff].prototype,Ff);Uf(Tf,"DOMTokenList");var Of=il.clear;to({global:!0,bind:!0,enumerable:!0,forced:o.clearImmediate!==Of},{clearImmediate:Of});var xf=o,Pf=yc,Yf=P,Jf=es,Hf=z,qf=us,Vf=Rc,jf=xf.Function,Kf=/MSIE .\./.test(Hf)||"BUN"===Jf&&function(){var A=xf.Bun.version.split(".");return A.length<3||"0"===A[0]&&(A[1]<3||"3"===A[1]&&"0"===A[2])}(),Wf=to,zf=o,Zf=il.set,Xf=function(A,e){var t=e?2:1;return Kf?function(i,o){var n=Vf(arguments.length,1)>t,r=Yf(i)?i:jf(i),s=n?qf(arguments,t):[],a=n?function(){Pf(r,this,s)}:r;return e?A(a,o):A(a)}:A},$f=zf.setImmediate?Xf(Zf,!1):Zf;Wf({global:!0,bind:!0,enumerable:!0,forced:zf.setImmediate!==$f},{setImmediate:$f});var Am=bh.charAt,em=uo,tm=_t,im=wr,om=Sr,nm="String Iterator",rm=tm.set,sm=tm.getterFor(nm);im(String,"String",function(A){rm(this,{type:nm,string:em(A),index:0})},function(){var A,e=sm(this),t=e.string,i=e.index;return i>=t.length?om(void 0,!0):(A=Am(t,i),e.index+=A.length,om(A,!1))});var am=r,gm=s,cm=ie("iterator"),lm=!am(function(){var A=new URL("b?a=1&b=2&c=3","https://a"),e=A.searchParams,t=new URLSearchParams("a=1&a=2&b=3"),i="";return A.pathname="c%20d",e.forEach(function(A,t){e.delete("b"),i+=t+A}),t.delete("a",2),t.delete("b",void 0),!e.size&&!gm||!e.sort||"https://a/c%20d?a=1&c=3"!==A.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[cm]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==i||"x"!==new URL("https://x",void 0).host}),Im=s,um=y,Em=l,dm=r,hm=xo,Cm=Mi,Bm=I,Qm=xA,pm=N,fm=Object.assign,mm=Object.defineProperty,ym=um([].concat),Dm=!fm||dm(function(){if(Im&&1!==fm({b:1},fm(mm({},"a",{enumerable:!0,get:function(){mm(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var A={},e={},t=Symbol("assign detection"),i="abcdefghijklmnopqrst";return A[t]=7,i.split("").forEach(function(A){e[A]=A}),7!==fm({},A)[t]||hm(fm({},e)).join("")!==i})?function(A,e){for(var t=Qm(A),i=arguments.length,o=1,n=Cm.f,r=Bm.f;i>o;)for(var s,a=pm(arguments[o++]),g=n?ym(hm(a),n(a)):hm(a),c=g.length,l=0;c>l;)s=g[l++],Im&&!Em(r,a,s)||(t[s]=a[s]);return t}:fm,vm=ke,wm=hu,Sm=s,Mm=_e,Rm=B,_m=Sc,Tm=l,Nm=xA,bm=function(A,e,t,i){try{return i?e(vm(t)[0],t[1]):e(t)}catch(JV){wm(A,"throw",JV)}},Gm=$I,km=gc,Lm=ui,Um=function(A,e,t){Sm?Mm.f(A,e,Rm(0,t)):A[e]=t},Fm=Iu,Om=nu,xm=Array,Pm=y,Ym=2147483647,Jm=/[^\0-\u007E]/,Hm=/[.\u3002\uFF0E\uFF61]/g,qm="Overflow: input needs wider integers to process",Vm=RangeError,jm=Pm(Hm.exec),Km=Math.floor,Wm=String.fromCharCode,zm=Pm("".charCodeAt),Zm=Pm([].join),Xm=Pm([].push),$m=Pm("".replace),Ay=Pm("".split),ey=Pm("".toLowerCase),ty=function(A){return A+22+75*(A<26)},iy=function(A,e,t){var i=0;for(A=t?Km(A/700):A>>1,A+=Km(A/e);A>455;)A=Km(A/35),i+=36;return Km(i+36*A/(A+38))},oy=function(A){var e,t,i=[],o=(A=function(A){for(var e=[],t=0,i=A.length;t=55296&&o<=56319&&t=n&&tKm((Ym-r)/l))throw new Vm(qm);for(r+=(c-n)*l,n=c,e=0;eYm)throw new Vm(qm);if(t===n){for(var I=r,u=36;;){var E=u<=s?1:u>=s+26?26:u-s;if(Io;){if(e=+arguments[o++],sy(e,1114111)!==e)throw new ay(e+" is not a valid code point");t[o]=e<65536?gy(e):gy(55296+((e-=65536)>>10),e%1024+56320)}return ly(t,"")}});var Iy=to,uy=o,Ey=sl,dy=V,hy=l,Cy=y,By=s,Qy=lm,py=$t,fy=Co,my=Vs,yy=Yn,Dy=Wn,vy=_t,wy=Ws,Sy=P,My=JA,Ry=Sc,_y=co,Ty=ke,Ny=J,by=uo,Gy=gn,ky=B,Ly=Iu,Uy=nu,Fy=Sr,Oy=Rc,xy=Cs,Py=ie("iterator"),Yy="URLSearchParams",Jy=Yy+"Iterator",Hy=vy.set,qy=vy.getterFor(Yy),Vy=vy.getterFor(Jy),jy=Ey("fetch"),Ky=Ey("Request"),Wy=Ey("Headers"),zy=Ky&&Ky.prototype,Zy=Wy&&Wy.prototype,Xy=uy.TypeError,$y=uy.encodeURIComponent,AD=String.fromCharCode,eD=dy("String","fromCodePoint"),tD=parseInt,iD=Cy("".charAt),oD=Cy([].join),nD=Cy([].push),rD=Cy("".replace),sD=Cy([].shift),aD=Cy([].splice),gD=Cy("".split),cD=Cy("".slice),lD=Cy(/./.exec),ID=/\+/g,uD=/^[0-9a-f]+$/i,ED=function(A,e){var t=cD(A,e,e+2);return lD(uD,t)?tD(t,16):NaN},dD=function(A){for(var e=0,t=128;t>0&&0!==(A&t);t>>=1)e++;return e},hD=function(A){var e=null;switch(A.length){case 1:e=A[0];break;case 2:e=(31&A[0])<<6|63&A[1];break;case 3:e=(15&A[0])<<12|(63&A[1])<<6|63&A[2];break;case 4:e=(7&A[0])<<18|(63&A[1])<<12|(63&A[2])<<6|63&A[3]}return e>1114111?null:e},CD=function(A){for(var e=(A=rD(A,ID," ")).length,t="",i=0;ie){t+="%",i++;continue}var n=ED(A,i+1);if(n!=n){t+=o,i++;continue}i+=2;var r=dD(n);if(0===r)o=AD(n);else{if(1===r||r>4){t+="�",i++;continue}for(var s=[n],a=1;ae||"%"!==iD(A,i));){var g=ED(A,i+1);if(g!=g){i+=3;break}if(g>191||g<128)break;nD(s,g),i+=2,a++}if(s.length!==r){t+="�";continue}var c=hD(s);null===c?t+="�":o=eD(c)}}t+=o,i++}return t},BD=/[!'()~]|%20/g,QD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},pD=function(A){return QD[A]},fD=function(A){return rD($y(A),BD,pD)},mD=Dy(function(A,e){Hy(this,{type:Jy,target:qy(A).entries,index:0,kind:e})},Yy,function(){var A=Vy(this),e=A.target,t=A.index++;if(!e||t>=e.length)return A.target=null,Fy(void 0,!0);var i=e[t];switch(A.kind){case"keys":return Fy(i.key,!1);case"values":return Fy(i.value,!1)}return Fy([i.key,i.value],!1)},!0),yD=function(A){this.entries=[],this.url=null,void 0!==A&&(Ny(A)?this.parseObject(A):this.parseQuery("string"==typeof A?"?"===iD(A,0)?cD(A,1):A:by(A)))};yD.prototype={type:Yy,bindURL:function(A){this.url=A,this.update()},parseObject:function(A){var e,t,i,o,n,r,s,a=this.entries,g=Uy(A);if(g)for(t=(e=Ly(A,g)).next;!(i=hy(t,e)).done;){if(n=(o=Ly(Ty(i.value))).next,(r=hy(n,o)).done||(s=hy(n,o)).done||!hy(n,o).done)throw new Xy("Expected sequence with length 2");nD(a,{key:by(r.value),value:by(s.value)})}else for(var c in A)My(A,c)&&nD(a,{key:c,value:by(A[c])})},parseQuery:function(A){if(A)for(var e,t,i=this.entries,o=gD(A,"&"),n=0;n0?arguments[0]:void 0));By||(this.size=A.entries.length)},vD=DD.prototype;if(my(vD,{append:function(A,e){var t=qy(this);Oy(arguments.length,2),nD(t.entries,{key:by(A),value:by(e)}),By||this.size++,t.updateURL()},delete:function(A){for(var e=qy(this),t=Oy(arguments.length,1),i=e.entries,o=by(A),n=t<2?void 0:arguments[1],r=void 0===n?n:by(n),s=0;se.key?1:-1}),A.updateURL()},forEach:function(A){for(var e,t=qy(this).entries,i=Ry(A,arguments.length>1?arguments[1]:void 0),o=0;o1?MD(arguments[1]):{})}}),Sy(Ky)){var RD=function(A){return wy(this,zy),new Ky(A,arguments.length>1?MD(arguments[1]):{})};zy.constructor=RD,RD.prototype=zy,Iy({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:RD})}}var _D,TD=to,ND=s,bD=lm,GD=o,kD=Sc,LD=y,UD=$t,FD=Co,OD=Ws,xD=JA,PD=Dm,YD=function(A){var e=Nm(A),t=km(this),i=arguments.length,o=i>1?arguments[1]:void 0,n=void 0!==o;n&&(o=_m(o,i>2?arguments[2]:void 0));var r,s,a,g,c,l,I=Om(e),u=0;if(!I||this===xm&&Gm(I))for(r=Lm(e),s=t?new this(r):xm(r);r>u;u++)l=n?o(e[u],u):e[u],Um(s,u,l);else for(s=t?new this:[],c=(g=Fm(e,I)).next;!(a=Tm(c,g)).done;u++)l=n?bm(g,o,[a.value,u],!0):a.value,Um(s,u,l);return s.length=u,s},JD=us,HD=bh.codeAt,qD=function(A){var e,t,i=[],o=Ay($m(ey(A),Hm,"."),".");for(e=0;e?@[\\\]^|]/,Rv=/[\0\t\n\r #/:<>?@[\\\]^|]/,_v=/^[\u0000-\u0020]+/,Tv=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Nv=/[\t\n\r]/g,bv=function(A){var e,t,i,o;if("number"==typeof A){for(e=[],t=0;t<4;t++)Cv(e,A%256),A=ov(A/256);return av(e,".")}if("object"==typeof A){for(e="",i=function(A){for(var e=null,t=1,i=null,o=0,n=0;n<8;n++)0!==A[n]?(o>t&&(e=i,t=o),i=null,o=0):(null===i&&(i=n),++o);return o>t?i:e}(A),t=0;t<8;t++)o&&0===A[t]||(o&&(o=!1),i===t?(e+=t?":":"::",o=!0):(e+=gv(A[t],16),t<7&&(e+=":")));return"["+e+"]"}return A},Gv={},kv=PD({},Gv,{" ":1,'"':1,"<":1,">":1,"`":1}),Lv=PD({},kv,{"#":1,"?":1,"{":1,"}":1}),Uv=PD({},Lv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Fv=function(A,e){var t=HD(A,0);return t>32&&t<127&&!xD(e,A)?A:encodeURIComponent(A)},Ov={ftp:21,file:null,http:80,https:443,ws:80,wss:443},xv=function(A,e){var t;return 2===A.length&&sv(fv,rv(A,0))&&(":"===(t=rv(A,1))||!e&&"|"===t)},Pv=function(A){var e;return A.length>1&&xv(dv(A,0,2))&&(2===A.length||"/"===(e=rv(A,2))||"\\"===e||"?"===e||"#"===e)},Yv=function(A){return"."===A||"%2e"===hv(A)},Jv=function(A){return".."===(A=hv(A))||"%2e."===A||".%2e"===A||"%2e%2e"===A},Hv={},qv={},Vv={},jv={},Kv={},Wv={},zv={},Zv={},Xv={},$v={},Aw={},ew={},tw={},iw={},ow={},nw={},rw={},sw={},aw={},gw={},cw={},lw=function(A,e,t){var i,o,n,r=VD(A);if(e){if(o=this.parse(r))throw new tv(o);this.searchParams=null}else{if(void 0!==t&&(i=new lw(t,!0)),o=this.parse(r,null,i))throw new tv(o);(n=Av(new $D)).bindURL(this),this.searchParams=n}};lw.prototype={type:"URL",parse:function(A,e,t){var i,o,n,r,s=this,a=e||Hv,g=0,c="",l=!1,I=!1,u=!1;for(A=VD(A),e||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,A=Iv(A,_v,""),A=Iv(A,Tv,"$1")),A=Iv(A,Nv,""),i=YD(A);g<=i.length;){switch(o=i[g],a){case Hv:if(!o||!sv(fv,o)){if(e)return Bv;a=Vv;continue}c+=hv(o),a=qv;break;case qv:if(o&&(sv(mv,o)||"+"===o||"-"===o||"."===o))c+=hv(o);else{if(":"!==o){if(e)return Bv;c="",a=Vv,g=0;continue}if(e&&(s.isSpecial()!==xD(Ov,c)||"file"===c&&(s.includesCredentials()||null!==s.port)||"file"===s.scheme&&!s.host))return;if(s.scheme=c,e)return void(s.isSpecial()&&Ov[s.scheme]===s.port&&(s.port=null));c="","file"===s.scheme?a=iw:s.isSpecial()&&t&&t.scheme===s.scheme?a=jv:s.isSpecial()?a=Zv:"/"===i[g+1]?(a=Kv,g++):(s.cannotBeABaseURL=!0,lv(s.path,""),a=aw)}break;case Vv:if(!t||t.cannotBeABaseURL&&"#"!==o)return Bv;if(t.cannotBeABaseURL&&"#"===o){s.scheme=t.scheme,s.path=JD(t.path),s.query=t.query,s.fragment="",s.cannotBeABaseURL=!0,a=cw;break}a="file"===t.scheme?iw:Wv;continue;case jv:if("/"!==o||"/"!==i[g+1]){a=Wv;continue}a=Xv,g++;break;case Kv:if("/"===o){a=$v;break}a=sw;continue;case Wv:if(s.scheme=t.scheme,o===_D)s.username=t.username,s.password=t.password,s.host=t.host,s.port=t.port,s.path=JD(t.path),s.query=t.query;else if("/"===o||"\\"===o&&s.isSpecial())a=zv;else if("?"===o)s.username=t.username,s.password=t.password,s.host=t.host,s.port=t.port,s.path=JD(t.path),s.query="",a=gw;else{if("#"!==o){s.username=t.username,s.password=t.password,s.host=t.host,s.port=t.port,s.path=JD(t.path),s.path.length--,a=sw;continue}s.username=t.username,s.password=t.password,s.host=t.host,s.port=t.port,s.path=JD(t.path),s.query=t.query,s.fragment="",a=cw}break;case zv:if(!s.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){s.username=t.username,s.password=t.password,s.host=t.host,s.port=t.port,a=sw;continue}a=$v}else a=Xv;break;case Zv:if(a=Xv,"/"!==o||"/"!==rv(c,g+1))continue;g++;break;case Xv:if("/"!==o&&"\\"!==o){a=$v;continue}break;case $v:if("@"===o){l&&(c="%40"+c),l=!0,n=YD(c);for(var E=0;E65535)return pv;s.port=s.isSpecial()&&C===Ov[s.scheme]?null:C,c=""}if(e)return;a=rw;continue}return pv}c+=o;break;case iw:if(s.scheme="file","/"===o||"\\"===o)a=ow;else{if(!t||"file"!==t.scheme){a=sw;continue}switch(o){case _D:s.host=t.host,s.path=JD(t.path),s.query=t.query;break;case"?":s.host=t.host,s.path=JD(t.path),s.query="",a=gw;break;case"#":s.host=t.host,s.path=JD(t.path),s.query=t.query,s.fragment="",a=cw;break;default:Pv(av(JD(i,g),""))||(s.host=t.host,s.path=JD(t.path),s.shortenPath()),a=sw;continue}}break;case ow:if("/"===o||"\\"===o){a=nw;break}t&&"file"===t.scheme&&!Pv(av(JD(i,g),""))&&(xv(t.path[0],!0)?lv(s.path,t.path[0]):s.host=t.host),a=sw;continue;case nw:if(o===_D||"/"===o||"\\"===o||"?"===o||"#"===o){if(!e&&xv(c))a=sw;else if(""===c){if(s.host="",e)return;a=rw}else{if(r=s.parseHost(c))return r;if("localhost"===s.host&&(s.host=""),e)return;c="",a=rw}continue}c+=o;break;case rw:if(s.isSpecial()){if(a=sw,"/"!==o&&"\\"!==o)continue}else if(e||"?"!==o)if(e||"#"!==o){if(o!==_D&&(a=sw,"/"!==o))continue}else s.fragment="",a=cw;else s.query="",a=gw;break;case sw:if(o===_D||"/"===o||"\\"===o&&s.isSpecial()||!e&&("?"===o||"#"===o)){if(Jv(c)?(s.shortenPath(),"/"===o||"\\"===o&&s.isSpecial()||lv(s.path,"")):Yv(c)?"/"===o||"\\"===o&&s.isSpecial()||lv(s.path,""):("file"===s.scheme&&!s.path.length&&xv(c)&&(s.host&&(s.host=""),c=rv(c,0)+":"),lv(s.path,c)),c="","file"===s.scheme&&(o===_D||"?"===o||"#"===o))for(;s.path.length>1&&""===s.path[0];)uv(s.path);"?"===o?(s.query="",a=gw):"#"===o&&(s.fragment="",a=cw)}else c+=Fv(o,Lv);break;case aw:"?"===o?(s.query="",a=gw):"#"===o?(s.fragment="",a=cw):o!==_D&&(s.path[0]+=Fv(o,Gv));break;case gw:e||"#"!==o?o!==_D&&("'"===o&&s.isSpecial()?s.query+="%27":s.query+="#"===o?"%23":Fv(o,Gv)):(s.fragment="",a=cw);break;case cw:o!==_D&&(s.fragment+=Fv(o,kv))}g++}},parseHost:function(A){var e,t,i;if("["===rv(A,0)){if("]"!==rv(A,A.length-1))return Qv;if(!(e=function(A){var e,t,i,o,n,r,s,a=[0,0,0,0,0,0,0,0],g=0,c=null,l=0,I=function(){return rv(A,l)};if(":"===I()){if(":"!==rv(A,1))return;l+=2,c=++g}for(;I();){if(8===g)return;if(":"!==I()){for(e=t=0;t<4&&sv(Sv,I());)e=16*e+iv(I(),16),l++,t++;if("."===I()){if(0===t)return;if(l-=t,g>6)return;for(i=0;I();){if(o=null,i>0){if(!("."===I()&&i<4))return;l++}if(!sv(yv,I()))return;for(;sv(yv,I());){if(n=iv(I(),10),null===o)o=n;else{if(0===o)return;o=10*o+n}if(o>255)return;l++}a[g]=256*a[g]+o,2!==++i&&4!==i||g++}if(4!==i)return;break}if(":"===I()){if(l++,!I())return}else if(I())return;a[g++]=e}else{if(null!==c)return;l++,c=++g}}if(null!==c)for(r=g-c,g=7;0!==g&&r>0;)s=a[g],a[g--]=a[c+r-1],a[c+--r]=s;else if(8!==g)return;return a}(dv(A,1,-1))))return Qv;this.host=e}else if(this.isSpecial()){if(A=qD(A),sv(Mv,A))return Qv;if(null===(e=function(A){var e,t,i,o,n,r,s,a=Ev(A,".");if(a.length&&""===a[a.length-1]&&a.length--,(e=a.length)>4)return A;for(t=[],i=0;i1&&"0"===rv(o,0)&&(n=sv(Dv,o)?16:8,o=dv(o,8===n?1:2)),""===o)r=0;else{if(!sv(10===n?wv:8===n?vv:Sv,o))return A;r=iv(o,n)}lv(t,r)}for(i=0;i=nv(256,5-e))return null}else if(r>255)return null;for(s=cv(t),i=0;i1?arguments[1]:void 0,i=ZD(e,new lw(A,!1,t));ND||(e.href=i.serialize(),e.origin=i.getOrigin(),e.protocol=i.getProtocol(),e.username=i.getUsername(),e.password=i.getPassword(),e.host=i.getHost(),e.hostname=i.getHostname(),e.port=i.getPort(),e.pathname=i.getPathname(),e.search=i.getSearch(),e.searchParams=i.getSearchParams(),e.hash=i.getHash())},uw=Iw.prototype,Ew=function(A,e){return{get:function(){return XD(this)[A]()},set:e&&function(A){return XD(this)[e](A)},configurable:!0,enumerable:!0}};if(ND&&(FD(uw,"href",Ew("serialize","setHref")),FD(uw,"origin",Ew("getOrigin")),FD(uw,"protocol",Ew("getProtocol","setProtocol")),FD(uw,"username",Ew("getUsername","setUsername")),FD(uw,"password",Ew("getPassword","setPassword")),FD(uw,"host",Ew("getHost","setHost")),FD(uw,"hostname",Ew("getHostname","setHostname")),FD(uw,"port",Ew("getPort","setPort")),FD(uw,"pathname",Ew("getPathname","setPathname")),FD(uw,"search",Ew("getSearch","setSearch")),FD(uw,"searchParams",Ew("getSearchParams")),FD(uw,"hash",Ew("getHash","setHash"))),UD(uw,"toJSON",function(){return XD(this).serialize()},{enumerable:!0}),UD(uw,"toString",function(){return XD(this).serialize()},{enumerable:!0}),ev){var dw=ev.createObjectURL,hw=ev.revokeObjectURL;dw&&UD(Iw,"createObjectURL",kD(dw,ev)),hw&&UD(Iw,"revokeObjectURL",kD(hw,ev))}jD(Iw,"URL"),TD({global:!0,constructor:!0,forced:!bD,sham:!ND},{URL:Iw});var Cw=l;to({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return Cw(URL.prototype.toString,this)}});let Bw=!0,Qw=!0;function pw(A,e,t){const i=A.match(e);return i&&i.length>=t&&parseFloat(i[t],10)}function fw(A,e,t){if(!A.RTCPeerConnection)return;const i=A.RTCPeerConnection.prototype,o=i.addEventListener;i.addEventListener=function(A,i){if(A!==e)return o.apply(this,arguments);const n=A=>{const e=t(A);e&&(i.handleEvent?i.handleEvent(e):i(e))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(i,n),o.apply(this,[A,n])};const n=i.removeEventListener;i.removeEventListener=function(A,t){if(A!==e||!this._eventMap||!this._eventMap[e])return n.apply(this,arguments);if(!this._eventMap[e].has(t))return n.apply(this,arguments);const i=this._eventMap[e].get(t);return this._eventMap[e].delete(t),0===this._eventMap[e].size&&delete this._eventMap[e],0===Object.keys(this._eventMap).length&&delete this._eventMap,n.apply(this,[A,i])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(A){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),A&&this.addEventListener(e,this["_on"+e]=A)},enumerable:!0,configurable:!0})}function mw(A){return"boolean"!=typeof A?new Error("Argument type: "+typeof A+". Please use a boolean."):(Bw=A,A?"adapter.js logging disabled":"adapter.js logging enabled")}function yw(A){return"boolean"!=typeof A?new Error("Argument type: "+typeof A+". Please use a boolean."):(Qw=!A,"adapter.js deprecation warnings "+(A?"disabled":"enabled"))}function Dw(){if("object"==typeof window){if(Bw)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function vw(A,e){Qw&&console.warn(A+" is deprecated, please use "+e+" instead.")}function ww(A){return"[object Object]"===Object.prototype.toString.call(A)}function Sw(A){return ww(A)?Object.keys(A).reduce(function(e,t){const i=ww(A[t]),o=i?Sw(A[t]):A[t],n=i&&!Object.keys(o).length;return void 0===o||n?e:Object.assign(e,{[t]:o})},{}):A}function Mw(A,e,t){e&&!t.has(e.id)&&(t.set(e.id,e),Object.keys(e).forEach(i=>{i.endsWith("Id")?Mw(A,A.get(e[i]),t):i.endsWith("Ids")&&e[i].forEach(e=>{Mw(A,A.get(e),t)})}))}function Rw(A,e,t){const i=t?"outbound-rtp":"inbound-rtp",o=new Map;if(null===e)return o;const n=[];return A.forEach(A=>{"track"===A.type&&A.trackIdentifier===e.id&&n.push(A)}),n.forEach(e=>{A.forEach(t=>{t.type===i&&t.trackId===e.id&&Mw(A,t,o)})}),o}const _w=Dw;function Tw(A,e){const t=A&&A.navigator;if(!t.mediaDevices)return;const i=function(A){if("object"!=typeof A||A.mandatory||A.optional)return A;const e={};return Object.keys(A).forEach(t=>{if("require"===t||"advanced"===t||"mediaSource"===t)return;const i="object"==typeof A[t]?A[t]:{ideal:A[t]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const o=function(A,e){return A?A+e.charAt(0).toUpperCase()+e.slice(1):"deviceId"===e?"sourceId":e};if(void 0!==i.ideal){e.optional=e.optional||[];let A={};"number"==typeof i.ideal?(A[o("min",t)]=i.ideal,e.optional.push(A),A={},A[o("max",t)]=i.ideal,e.optional.push(A)):(A[o("",t)]=i.ideal,e.optional.push(A))}void 0!==i.exact&&"number"!=typeof i.exact?(e.mandatory=e.mandatory||{},e.mandatory[o("",t)]=i.exact):["min","max"].forEach(A=>{void 0!==i[A]&&(e.mandatory=e.mandatory||{},e.mandatory[o(A,t)]=i[A])})}),A.advanced&&(e.optional=(e.optional||[]).concat(A.advanced)),e},o=function(A,o){if(e.version>=61)return o(A);if((A=JSON.parse(JSON.stringify(A)))&&"object"==typeof A.audio){const e=function(A,e,t){e in A&&!(t in A)&&(A[t]=A[e],delete A[e])};e((A=JSON.parse(JSON.stringify(A))).audio,"autoGainControl","googAutoGainControl"),e(A.audio,"noiseSuppression","googNoiseSuppression"),A.audio=i(A.audio)}if(A&&"object"==typeof A.video){let n=A.video.facingMode;n=n&&("object"==typeof n?n:{ideal:n});const r=e.version<66;if(n&&("user"===n.exact||"environment"===n.exact||"user"===n.ideal||"environment"===n.ideal)&&(!t.mediaDevices.getSupportedConstraints||!t.mediaDevices.getSupportedConstraints().facingMode||r)){let e;if(delete A.video.facingMode,"environment"===n.exact||"environment"===n.ideal?e=["back","rear"]:"user"!==n.exact&&"user"!==n.ideal||(e=["front"]),e)return t.mediaDevices.enumerateDevices().then(t=>{let r=(t=t.filter(A=>"videoinput"===A.kind)).find(A=>e.some(e=>A.label.toLowerCase().includes(e)));return!r&&t.length&&e.includes("back")&&(r=t[t.length-1]),r&&(A.video.deviceId=n.exact?{exact:r.deviceId}:{ideal:r.deviceId}),A.video=i(A.video),_w("chrome: "+JSON.stringify(A)),o(A)})}A.video=i(A.video)}return _w("chrome: "+JSON.stringify(A)),o(A)},n=function(A){return e.version>=64?A:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[A.name]||A.name,message:A.message,constraint:A.constraint||A.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(t.getUserMedia=function(A,e,i){o(A,A=>{t.webkitGetUserMedia(A,e,A=>{i&&i(n(A))})})}.bind(t),t.mediaDevices.getUserMedia){const A=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return o(e,e=>A(e).then(A=>{if(e.audio&&!A.getAudioTracks().length||e.video&&!A.getVideoTracks().length)throw A.getTracks().forEach(A=>{A.stop()}),new DOMException("","NotFoundError");return A},A=>Promise.reject(n(A))))}}}function Nw(A){A.MediaStream=A.MediaStream||A.webkitMediaStream}function bw(A){if("object"==typeof A&&A.RTCPeerConnection&&!("ontrack"in A.RTCPeerConnection.prototype)){Object.defineProperty(A.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(A){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=A)},enumerable:!0,configurable:!0});const e=A.RTCPeerConnection.prototype.setRemoteDescription;A.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=e=>{e.stream.addEventListener("addtrack",t=>{let i;i=A.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(A=>A.track&&A.track.id===t.track.id):{track:t.track};const o=new Event("track");o.track=t.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[e.stream],this.dispatchEvent(o)}),e.stream.getTracks().forEach(t=>{let i;i=A.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(A=>A.track&&A.track.id===t.id):{track:t};const o=new Event("track");o.track=t,o.receiver=i,o.transceiver={receiver:i},o.streams=[e.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else fw(A,"track",A=>(A.transceiver||Object.defineProperty(A,"transceiver",{value:{receiver:A.receiver}}),A))}function Gw(A){if("object"==typeof A&&A.RTCPeerConnection&&!("getSenders"in A.RTCPeerConnection.prototype)&&"createDTMFSender"in A.RTCPeerConnection.prototype){const e=function(A,e){return{track:e,get dtmf(){return void 0===this._dtmf&&("audio"===e.kind?this._dtmf=A.createDTMFSender(e):this._dtmf=null),this._dtmf},_pc:A}};if(!A.RTCPeerConnection.prototype.getSenders){A.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const t=A.RTCPeerConnection.prototype.addTrack;A.RTCPeerConnection.prototype.addTrack=function(A,i){let o=t.apply(this,arguments);return o||(o=e(this,A),this._senders.push(o)),o};const i=A.RTCPeerConnection.prototype.removeTrack;A.RTCPeerConnection.prototype.removeTrack=function(A){i.apply(this,arguments);const e=this._senders.indexOf(A);-1!==e&&this._senders.splice(e,1)}}const t=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(A){this._senders=this._senders||[],t.apply(this,[A]),A.getTracks().forEach(A=>{this._senders.push(e(this,A))})};const i=A.RTCPeerConnection.prototype.removeStream;A.RTCPeerConnection.prototype.removeStream=function(A){this._senders=this._senders||[],i.apply(this,[A]),A.getTracks().forEach(A=>{const e=this._senders.find(e=>e.track===A);e&&this._senders.splice(this._senders.indexOf(e),1)})}}else if("object"==typeof A&&A.RTCPeerConnection&&"getSenders"in A.RTCPeerConnection.prototype&&"createDTMFSender"in A.RTCPeerConnection.prototype&&A.RTCRtpSender&&!("dtmf"in A.RTCRtpSender.prototype)){const e=A.RTCPeerConnection.prototype.getSenders;A.RTCPeerConnection.prototype.getSenders=function(){const A=e.apply(this,[]);return A.forEach(A=>A._pc=this),A},Object.defineProperty(A.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function kw(A){if(!A.RTCPeerConnection)return;const e=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){const[A,t,i]=arguments;if(arguments.length>0&&"function"==typeof A)return e.apply(this,arguments);if(0===e.length&&(0===arguments.length||"function"!=typeof A))return e.apply(this,[]);const o=function(A){const e={};return A.result().forEach(A=>{const t={id:A.id,timestamp:A.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[A.type]||A.type};A.names().forEach(e=>{t[e]=A.stat(e)}),e[t.id]=t}),e},n=function(A){return new Map(Object.keys(A).map(e=>[e,A[e]]))};if(arguments.length>=2){const i=function(A){t(n(o(A)))};return e.apply(this,[i,A])}return new Promise((A,t)=>{e.apply(this,[function(e){A(n(o(e)))},t])}).then(t,i)}}function Lw(A){if(!("object"==typeof A&&A.RTCPeerConnection&&A.RTCRtpSender&&A.RTCRtpReceiver))return;if(!("getStats"in A.RTCRtpSender.prototype)){const e=A.RTCPeerConnection.prototype.getSenders;e&&(A.RTCPeerConnection.prototype.getSenders=function(){const A=e.apply(this,[]);return A.forEach(A=>A._pc=this),A});const t=A.RTCPeerConnection.prototype.addTrack;t&&(A.RTCPeerConnection.prototype.addTrack=function(){const A=t.apply(this,arguments);return A._pc=this,A}),A.RTCRtpSender.prototype.getStats=function(){const A=this;return this._pc.getStats().then(e=>Rw(e,A.track,!0))}}if(!("getStats"in A.RTCRtpReceiver.prototype)){const e=A.RTCPeerConnection.prototype.getReceivers;e&&(A.RTCPeerConnection.prototype.getReceivers=function(){const A=e.apply(this,[]);return A.forEach(A=>A._pc=this),A}),fw(A,"track",A=>(A.receiver._pc=A.srcElement,A)),A.RTCRtpReceiver.prototype.getStats=function(){const A=this;return this._pc.getStats().then(e=>Rw(e,A.track,!1))}}if(!("getStats"in A.RTCRtpSender.prototype)||!("getStats"in A.RTCRtpReceiver.prototype))return;const e=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof A.MediaStreamTrack){const A=arguments[0];let e,t,i;return this.getSenders().forEach(t=>{t.track===A&&(e?i=!0:e=t)}),this.getReceivers().forEach(e=>(e.track===A&&(t?i=!0:t=e),e.track===A)),i||e&&t?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):e?e.getStats():t?t.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Uw(A){A.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(A=>this._shimmedLocalStreams[A][0])};const e=A.RTCPeerConnection.prototype.addTrack;A.RTCPeerConnection.prototype.addTrack=function(A,t){if(!t)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=e.apply(this,arguments);return this._shimmedLocalStreams[t.id]?-1===this._shimmedLocalStreams[t.id].indexOf(i)&&this._shimmedLocalStreams[t.id].push(i):this._shimmedLocalStreams[t.id]=[t,i],i};const t=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(A){this._shimmedLocalStreams=this._shimmedLocalStreams||{},A.getTracks().forEach(A=>{if(this.getSenders().find(e=>e.track===A))throw new DOMException("Track already exists.","InvalidAccessError")});const e=this.getSenders();t.apply(this,arguments);const i=this.getSenders().filter(A=>-1===e.indexOf(A));this._shimmedLocalStreams[A.id]=[A].concat(i)};const i=A.RTCPeerConnection.prototype.removeStream;A.RTCPeerConnection.prototype.removeStream=function(A){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[A.id],i.apply(this,arguments)};const o=A.RTCPeerConnection.prototype.removeTrack;A.RTCPeerConnection.prototype.removeTrack=function(A){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},A&&Object.keys(this._shimmedLocalStreams).forEach(e=>{const t=this._shimmedLocalStreams[e].indexOf(A);-1!==t&&this._shimmedLocalStreams[e].splice(t,1),1===this._shimmedLocalStreams[e].length&&delete this._shimmedLocalStreams[e]}),o.apply(this,arguments)}}function Fw(A,e){if(!A.RTCPeerConnection)return;if(A.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Uw(A);const t=A.RTCPeerConnection.prototype.getLocalStreams;A.RTCPeerConnection.prototype.getLocalStreams=function(){const A=t.apply(this);return this._reverseStreams=this._reverseStreams||{},A.map(A=>this._reverseStreams[A.id])};const i=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(e){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},e.getTracks().forEach(A=>{if(this.getSenders().find(e=>e.track===A))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[e.id]){const t=new A.MediaStream(e.getTracks());this._streams[e.id]=t,this._reverseStreams[t.id]=e,e=t}i.apply(this,[e])};const o=A.RTCPeerConnection.prototype.removeStream;function n(A,e){let t=e.sdp;return Object.keys(A._reverseStreams||[]).forEach(e=>{const i=A._reverseStreams[e],o=A._streams[i.id];t=t.replace(new RegExp(o.id,"g"),i.id)}),new RTCSessionDescription({type:e.type,sdp:t})}A.RTCPeerConnection.prototype.removeStream=function(A){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},o.apply(this,[this._streams[A.id]||A]),delete this._reverseStreams[this._streams[A.id]?this._streams[A.id].id:A.id],delete this._streams[A.id]},A.RTCPeerConnection.prototype.addTrack=function(e,t){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(A=>A===e))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(A=>A.track===e))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[t.id];if(o)o.addTrack(e),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const i=new A.MediaStream([e]);this._streams[t.id]=i,this._reverseStreams[i.id]=t,this.addStream(i)}return this.getSenders().find(A=>A.track===e)},["createOffer","createAnswer"].forEach(function(e){const t=A.RTCPeerConnection.prototype[e],i={[e](){const A=arguments;return arguments.length&&"function"==typeof arguments[0]?t.apply(this,[e=>{const t=n(this,e);A[0].apply(null,[t])},e=>{A[1]&&A[1].apply(null,e)},arguments[2]]):t.apply(this,arguments).then(A=>n(this,A))}};A.RTCPeerConnection.prototype[e]=i[e]});const r=A.RTCPeerConnection.prototype.setLocalDescription;A.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(A,e){let t=e.sdp;return Object.keys(A._reverseStreams||[]).forEach(e=>{const i=A._reverseStreams[e],o=A._streams[i.id];t=t.replace(new RegExp(i.id,"g"),o.id)}),new RTCSessionDescription({type:e.type,sdp:t})}(this,arguments[0]),r.apply(this,arguments)):r.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(A.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(A.RTCPeerConnection.prototype,"localDescription",{get(){const A=s.get.apply(this);return""===A.type?A:n(this,A)}}),A.RTCPeerConnection.prototype.removeTrack=function(A){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!A._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(A._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let e;this._streams=this._streams||{},Object.keys(this._streams).forEach(t=>{this._streams[t].getTracks().find(e=>A.track===e)&&(e=this._streams[t])}),e&&(1===e.getTracks().length?this.removeStream(this._reverseStreams[e.id]):e.removeTrack(A.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ow(A,e){!A.RTCPeerConnection&&A.webkitRTCPeerConnection&&(A.RTCPeerConnection=A.webkitRTCPeerConnection),A.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const t=A.RTCPeerConnection.prototype[e],i={[e](){return arguments[0]=new("addIceCandidate"===e?A.RTCIceCandidate:A.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}};A.RTCPeerConnection.prototype[e]=i[e]})}function xw(A,e){fw(A,"negotiationneeded",A=>{const t=A.target;if(!(e.version<72||t.getConfiguration&&"plan-b"===t.getConfiguration().sdpSemantics)||"stable"===t.signalingState)return A})}var Pw=Object.freeze({__proto__:null,shimMediaStream:Nw,shimOnTrack:bw,shimGetSendersWithDtmf:Gw,shimGetStats:kw,shimSenderReceiverGetStats:Lw,shimAddTrackRemoveTrackWithNative:Uw,shimAddTrackRemoveTrack:Fw,shimPeerConnection:Ow,fixNegotiationNeeded:xw,shimGetUserMedia:Tw,shimGetDisplayMedia:function(A,e){A.navigator.mediaDevices&&"getDisplayMedia"in A.navigator.mediaDevices||A.navigator.mediaDevices&&("function"==typeof e?A.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(e=>{const i=t.video&&t.video.width,o=t.video&&t.video.height,n=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxFrameRate:n||3}},i&&(t.video.mandatory.maxWidth=i),o&&(t.video.mandatory.maxHeight=o),A.navigator.mediaDevices.getUserMedia(t)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function Yw(A,e){const t=A&&A.navigator,i=A&&A.MediaStreamTrack;if(t.getUserMedia=function(A,e,i){vw("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(A).then(e,i)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const A=function(A,e,t){e in A&&!(t in A)&&(A[t]=A[e],delete A[e])},e=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(t){return"object"==typeof t&&"object"==typeof t.audio&&(t=JSON.parse(JSON.stringify(t)),A(t.audio,"autoGainControl","mozAutoGainControl"),A(t.audio,"noiseSuppression","mozNoiseSuppression")),e(t)},i&&i.prototype.getSettings){const e=i.prototype.getSettings;i.prototype.getSettings=function(){const t=e.apply(this,arguments);return A(t,"mozAutoGainControl","autoGainControl"),A(t,"mozNoiseSuppression","noiseSuppression"),t}}if(i&&i.prototype.applyConstraints){const e=i.prototype.applyConstraints;i.prototype.applyConstraints=function(t){return"audio"===this.kind&&"object"==typeof t&&(t=JSON.parse(JSON.stringify(t)),A(t,"autoGainControl","mozAutoGainControl"),A(t,"noiseSuppression","mozNoiseSuppression")),e.apply(this,[t])}}}}function Jw(A){"object"==typeof A&&A.RTCTrackEvent&&"receiver"in A.RTCTrackEvent.prototype&&!("transceiver"in A.RTCTrackEvent.prototype)&&Object.defineProperty(A.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Hw(A,e){if("object"!=typeof A||!A.RTCPeerConnection&&!A.mozRTCPeerConnection)return;!A.RTCPeerConnection&&A.mozRTCPeerConnection&&(A.RTCPeerConnection=A.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const t=A.RTCPeerConnection.prototype[e],i={[e](){return arguments[0]=new("addIceCandidate"===e?A.RTCIceCandidate:A.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}};A.RTCPeerConnection.prototype[e]=i[e]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){const[A,o,n]=arguments;return i.apply(this,[A||null]).then(A=>{if(e.version<53&&!o)try{A.forEach(A=>{A.type=t[A.type]||A.type})}catch(i){if("TypeError"!==i.name)throw i;A.forEach((e,i)=>{A.set(i,Object.assign({},e,{type:t[e.type]||e.type}))})}return A}).then(o,n)}}function qw(A){if("object"!=typeof A||!A.RTCPeerConnection||!A.RTCRtpSender)return;if(A.RTCRtpSender&&"getStats"in A.RTCRtpSender.prototype)return;const e=A.RTCPeerConnection.prototype.getSenders;e&&(A.RTCPeerConnection.prototype.getSenders=function(){const A=e.apply(this,[]);return A.forEach(A=>A._pc=this),A});const t=A.RTCPeerConnection.prototype.addTrack;t&&(A.RTCPeerConnection.prototype.addTrack=function(){const A=t.apply(this,arguments);return A._pc=this,A}),A.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Vw(A){if("object"!=typeof A||!A.RTCPeerConnection||!A.RTCRtpSender)return;if(A.RTCRtpSender&&"getStats"in A.RTCRtpReceiver.prototype)return;const e=A.RTCPeerConnection.prototype.getReceivers;e&&(A.RTCPeerConnection.prototype.getReceivers=function(){const A=e.apply(this,[]);return A.forEach(A=>A._pc=this),A}),fw(A,"track",A=>(A.receiver._pc=A.srcElement,A)),A.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function jw(A){A.RTCPeerConnection&&!("removeStream"in A.RTCPeerConnection.prototype)&&(A.RTCPeerConnection.prototype.removeStream=function(A){vw("removeStream","removeTrack"),this.getSenders().forEach(e=>{e.track&&A.getTracks().includes(e.track)&&this.removeTrack(e)})})}function Kw(A){A.DataChannel&&!A.RTCDataChannel&&(A.RTCDataChannel=A.DataChannel)}function Ww(A){if("object"!=typeof A||!A.RTCPeerConnection)return;const e=A.RTCPeerConnection.prototype.addTransceiver;e&&(A.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let A=arguments[1]&&arguments[1].sendEncodings;void 0===A&&(A=[]),A=[...A];const t=A.length>0;t&&A.forEach(A=>{if("rid"in A&&!/^[a-z0-9]{0,16}$/i.test(A.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in A&&!(parseFloat(A.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in A&&!(parseFloat(A.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(t){const{sender:e}=i,t=e.getParameters();(!("encodings"in t)||1===t.encodings.length&&0===Object.keys(t.encodings[0]).length)&&(t.encodings=A,e.sendEncodings=A,this.setParametersPromises.push(e.setParameters(t).then(()=>{delete e.sendEncodings}).catch(()=>{delete e.sendEncodings})))}return i})}function zw(A){if("object"!=typeof A||!A.RTCRtpSender)return;const e=A.RTCRtpSender.prototype.getParameters;e&&(A.RTCRtpSender.prototype.getParameters=function(){const A=e.apply(this,arguments);return"encodings"in A||(A.encodings=[].concat(this.sendEncodings||[{}])),A})}function Zw(A){if("object"!=typeof A||!A.RTCPeerConnection)return;const e=A.RTCPeerConnection.prototype.createOffer;A.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Xw(A){if("object"!=typeof A||!A.RTCPeerConnection)return;const e=A.RTCPeerConnection.prototype.createAnswer;A.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var $w=Object.freeze({__proto__:null,shimOnTrack:Jw,shimPeerConnection:Hw,shimSenderGetStats:qw,shimReceiverGetStats:Vw,shimRemoveStream:jw,shimRTCDataChannel:Kw,shimAddTransceiver:Ww,shimGetParameters:zw,shimCreateOffer:Zw,shimCreateAnswer:Xw,shimGetUserMedia:Yw,shimGetDisplayMedia:function(A,e){A.navigator.mediaDevices&&"getDisplayMedia"in A.navigator.mediaDevices||A.navigator.mediaDevices&&(A.navigator.mediaDevices.getDisplayMedia=function(t){if(!t||!t.video){const A=new DOMException("getDisplayMedia without video constraints is undefined");return A.name="NotFoundError",A.code=8,Promise.reject(A)}return!0===t.video?t.video={mediaSource:e}:t.video.mediaSource=e,A.navigator.mediaDevices.getUserMedia(t)})}});function AS(A){if("object"==typeof A&&A.RTCPeerConnection){if("getLocalStreams"in A.RTCPeerConnection.prototype||(A.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in A.RTCPeerConnection.prototype)){const e=A.RTCPeerConnection.prototype.addTrack;A.RTCPeerConnection.prototype.addStream=function(A){this._localStreams||(this._localStreams=[]),this._localStreams.includes(A)||this._localStreams.push(A),A.getAudioTracks().forEach(t=>e.call(this,t,A)),A.getVideoTracks().forEach(t=>e.call(this,t,A))},A.RTCPeerConnection.prototype.addTrack=function(A,...t){return t&&t.forEach(A=>{this._localStreams?this._localStreams.includes(A)||this._localStreams.push(A):this._localStreams=[A]}),e.apply(this,arguments)}}"removeStream"in A.RTCPeerConnection.prototype||(A.RTCPeerConnection.prototype.removeStream=function(A){this._localStreams||(this._localStreams=[]);const e=this._localStreams.indexOf(A);if(-1===e)return;this._localStreams.splice(e,1);const t=A.getTracks();this.getSenders().forEach(A=>{t.includes(A.track)&&this.removeTrack(A)})})}}function eS(A){if("object"==typeof A&&A.RTCPeerConnection&&("getRemoteStreams"in A.RTCPeerConnection.prototype||(A.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in A.RTCPeerConnection.prototype))){Object.defineProperty(A.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(A){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=A),this.addEventListener("track",this._onaddstreampoly=A=>{A.streams.forEach(A=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(A))return;this._remoteStreams.push(A);const e=new Event("addstream");e.stream=A,this.dispatchEvent(e)})})}});const e=A.RTCPeerConnection.prototype.setRemoteDescription;A.RTCPeerConnection.prototype.setRemoteDescription=function(){const A=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(e=>{if(A._remoteStreams||(A._remoteStreams=[]),A._remoteStreams.indexOf(e)>=0)return;A._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,A.dispatchEvent(t)})}),e.apply(A,arguments)}}}function tS(A){if("object"!=typeof A||!A.RTCPeerConnection)return;const e=A.RTCPeerConnection.prototype,t=e.createOffer,i=e.createAnswer,o=e.setLocalDescription,n=e.setRemoteDescription,r=e.addIceCandidate;e.createOffer=function(A,e){const i=arguments.length>=2?arguments[2]:arguments[0],o=t.apply(this,[i]);return e?(o.then(A,e),Promise.resolve()):o},e.createAnswer=function(A,e){const t=arguments.length>=2?arguments[2]:arguments[0],o=i.apply(this,[t]);return e?(o.then(A,e),Promise.resolve()):o};let s=function(A,e,t){const i=o.apply(this,[A]);return t?(i.then(e,t),Promise.resolve()):i};e.setLocalDescription=s,s=function(A,e,t){const i=n.apply(this,[A]);return t?(i.then(e,t),Promise.resolve()):i},e.setRemoteDescription=s,s=function(A,e,t){const i=r.apply(this,[A]);return t?(i.then(e,t),Promise.resolve()):i},e.addIceCandidate=s}function iS(A){const e=A&&A.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const A=e.mediaDevices,t=A.getUserMedia.bind(A);e.mediaDevices.getUserMedia=A=>t(oS(A))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(A,t,i){e.mediaDevices.getUserMedia(A).then(t,i)}.bind(e))}function oS(A){return A&&void 0!==A.video?Object.assign({},A,{video:Sw(A.video)}):A}function nS(A){if(!A.RTCPeerConnection)return;const e=A.RTCPeerConnection;A.RTCPeerConnection=function(A,t){if(A&&A.iceServers){const e=[];for(let t=0;te.generateCertificate})}function rS(A){"object"==typeof A&&A.RTCTrackEvent&&"receiver"in A.RTCTrackEvent.prototype&&!("transceiver"in A.RTCTrackEvent.prototype)&&Object.defineProperty(A.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function sS(A){const e=A.RTCPeerConnection.prototype.createOffer;A.RTCPeerConnection.prototype.createOffer=function(A){if(A){void 0!==A.offerToReceiveAudio&&(A.offerToReceiveAudio=!!A.offerToReceiveAudio);const e=this.getTransceivers().find(A=>"audio"===A.receiver.track.kind);!1===A.offerToReceiveAudio&&e?"sendrecv"===e.direction?e.setDirection?e.setDirection("sendonly"):e.direction="sendonly":"recvonly"===e.direction&&(e.setDirection?e.setDirection("inactive"):e.direction="inactive"):!0!==A.offerToReceiveAudio||e||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==A.offerToReceiveVideo&&(A.offerToReceiveVideo=!!A.offerToReceiveVideo);const t=this.getTransceivers().find(A=>"video"===A.receiver.track.kind);!1===A.offerToReceiveVideo&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==A.offerToReceiveVideo||t||this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function aS(A){"object"!=typeof A||A.AudioContext||(A.AudioContext=A.webkitAudioContext)}var gS=Object.freeze({__proto__:null,shimLocalStreamsAPI:AS,shimRemoteStreamsAPI:eS,shimCallbacksAPI:tS,shimGetUserMedia:iS,shimConstraints:oS,shimRTCIceServerUrls:nS,shimTrackEventTransceiver:rS,shimCreateOfferLegacy:sS,shimAudioContext:aS}),cS={exports:{}};!function(A){const e={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};e.localCName=e.generateIdentifier(),e.splitLines=function(A){return A.trim().split("\n").map(A=>A.trim())},e.splitSections=function(A){return A.split("\nm=").map((A,e)=>(e>0?"m="+A:A).trim()+"\r\n")},e.getDescription=function(A){const t=e.splitSections(A);return t&&t[0]},e.getMediaSections=function(A){const t=e.splitSections(A);return t.shift(),t},e.matchPrefix=function(A,t){return e.splitLines(A).filter(A=>0===A.indexOf(t))},e.parseCandidate=function(A){let e;e=0===A.indexOf("a=candidate:")?A.substring(12).split(" "):A.substring(10).split(" ");const t={foundation:e[0],component:{1:"rtp",2:"rtcp"}[e[1]]||e[1],protocol:e[2].toLowerCase(),priority:parseInt(e[3],10),ip:e[4],address:e[4],port:parseInt(e[5],10),type:e[7]};for(let i=8;i0?e[0].split("/")[1]:"sendrecv",uri:e[1],attributes:e.slice(2).join(" ")}},e.writeExtmap=function(A){return"a=extmap:"+(A.id||A.preferredId)+(A.direction&&"sendrecv"!==A.direction?"/"+A.direction:"")+" "+A.uri+(A.attributes?" "+A.attributes:"")+"\r\n"},e.parseFmtp=function(A){const e={};let t;const i=A.substring(A.indexOf(" ")+1).split(";");for(let o=0;o{void 0!==A.parameters[e]?i.push(e+"="+A.parameters[e]):i.push(e)}),e+="a=fmtp:"+t+" "+i.join(";")+"\r\n"}return e},e.parseRtcpFb=function(A){const e=A.substring(A.indexOf(" ")+1).split(" ");return{type:e.shift(),parameter:e.join(" ")}},e.writeRtcpFb=function(A){let e="",t=A.payloadType;return void 0!==A.preferredPayloadType&&(t=A.preferredPayloadType),A.rtcpFeedback&&A.rtcpFeedback.length&&A.rtcpFeedback.forEach(A=>{e+="a=rtcp-fb:"+t+" "+A.type+(A.parameter&&A.parameter.length?" "+A.parameter:"")+"\r\n"}),e},e.parseSsrcMedia=function(A){const e=A.indexOf(" "),t={ssrc:parseInt(A.substring(7,e),10)},i=A.indexOf(":",e);return i>-1?(t.attribute=A.substring(e+1,i),t.value=A.substring(i+1)):t.attribute=A.substring(e+1),t},e.parseSsrcGroup=function(A){const e=A.substring(13).split(" ");return{semantics:e.shift(),ssrcs:e.map(A=>parseInt(A,10))}},e.getMid=function(A){const t=e.matchPrefix(A,"a=mid:")[0];if(t)return t.substring(6)},e.parseFingerprint=function(A){const e=A.substring(14).split(" ");return{algorithm:e[0].toLowerCase(),value:e[1].toUpperCase()}},e.getDtlsParameters=function(A,t){return{role:"auto",fingerprints:e.matchPrefix(A+t,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(A,e){let t="a=setup:"+e+"\r\n";return A.fingerprints.forEach(A=>{t+="a=fingerprint:"+A.algorithm+" "+A.value+"\r\n"}),t},e.parseCryptoLine=function(A){const e=A.substring(9).split(" ");return{tag:parseInt(e[0],10),cryptoSuite:e[1],keyParams:e[2],sessionParams:e.slice(3)}},e.writeCryptoLine=function(A){return"a=crypto:"+A.tag+" "+A.cryptoSuite+" "+("object"==typeof A.keyParams?e.writeCryptoKeyParams(A.keyParams):A.keyParams)+(A.sessionParams?" "+A.sessionParams.join(" "):"")+"\r\n"},e.parseCryptoKeyParams=function(A){if(0!==A.indexOf("inline:"))return null;const e=A.substring(7).split("|");return{keyMethod:"inline",keySalt:e[0],lifeTime:e[1],mkiValue:e[2]?e[2].split(":")[0]:void 0,mkiLength:e[2]?e[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(A){return A.keyMethod+":"+A.keySalt+(A.lifeTime?"|"+A.lifeTime:"")+(A.mkiValue&&A.mkiLength?"|"+A.mkiValue+":"+A.mkiLength:"")},e.getCryptoParameters=function(A,t){return e.matchPrefix(A+t,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(A,t){const i=e.matchPrefix(A+t,"a=ice-ufrag:")[0],o=e.matchPrefix(A+t,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substring(12),password:o.substring(10)}:null},e.writeIceParameters=function(A){let e="a=ice-ufrag:"+A.usernameFragment+"\r\na=ice-pwd:"+A.password+"\r\n";return A.iceLite&&(e+="a=ice-lite\r\n"),e},e.parseRtpParameters=function(A){const t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(A)[0].split(" ");t.profile=i[2];for(let n=3;n{t.headerExtensions.push(e.parseExtmap(A))});const o=e.matchPrefix(A,"a=rtcp-fb:* ").map(e.parseRtcpFb);return t.codecs.forEach(A=>{o.forEach(e=>{A.rtcpFeedback.find(A=>A.type===e.type&&A.parameter===e.parameter)||A.rtcpFeedback.push(e)})}),t},e.writeRtpDescription=function(A,t){let i="";i+="m="+A+" ",i+=t.codecs.length>0?"9":"0",i+=" "+(t.profile||"UDP/TLS/RTP/SAVPF")+" ",i+=t.codecs.map(A=>void 0!==A.preferredPayloadType?A.preferredPayloadType:A.payloadType).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(A=>{i+=e.writeRtpMap(A),i+=e.writeFmtp(A),i+=e.writeRtcpFb(A)});let o=0;return t.codecs.forEach(A=>{A.maxptime>o&&(o=A.maxptime)}),o>0&&(i+="a=maxptime:"+o+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach(A=>{i+=e.writeExtmap(A)}),i},e.parseRtpEncodingParameters=function(A){const t=[],i=e.parseRtpParameters(A),o=-1!==i.fecMechanisms.indexOf("RED"),n=-1!==i.fecMechanisms.indexOf("ULPFEC"),r=e.matchPrefix(A,"a=ssrc:").map(A=>e.parseSsrcMedia(A)).filter(A=>"cname"===A.attribute),s=r.length>0&&r[0].ssrc;let a;const g=e.matchPrefix(A,"a=ssrc-group:FID").map(A=>A.substring(17).split(" ").map(A=>parseInt(A,10)));g.length>0&&g[0].length>1&&g[0][0]===s&&(a=g[0][1]),i.codecs.forEach(A=>{if("RTX"===A.name.toUpperCase()&&A.parameters.apt){let e={ssrc:s,codecPayloadType:parseInt(A.parameters.apt,10)};s&&a&&(e.rtx={ssrc:a}),t.push(e),o&&(e=JSON.parse(JSON.stringify(e)),e.fec={ssrc:s,mechanism:n?"red+ulpfec":"red"},t.push(e))}}),0===t.length&&s&&t.push({ssrc:s});let c=e.matchPrefix(A,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substring(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substring(5),10)*.95-16e3:void 0,t.forEach(A=>{A.maxBitrate=c})),t},e.parseRtcpParameters=function(A){const t={},i=e.matchPrefix(A,"a=ssrc:").map(A=>e.parseSsrcMedia(A)).filter(A=>"cname"===A.attribute)[0];i&&(t.cname=i.value,t.ssrc=i.ssrc);const o=e.matchPrefix(A,"a=rtcp-rsize");t.reducedSize=o.length>0,t.compound=0===o.length;const n=e.matchPrefix(A,"a=rtcp-mux");return t.mux=n.length>0,t},e.writeRtcpParameters=function(A){let e="";return A.reducedSize&&(e+="a=rtcp-rsize\r\n"),A.mux&&(e+="a=rtcp-mux\r\n"),void 0!==A.ssrc&&A.cname&&(e+="a=ssrc:"+A.ssrc+" cname:"+A.cname+"\r\n"),e},e.parseMsid=function(A){let t;const i=e.matchPrefix(A,"a=msid:");if(1===i.length)return t=i[0].substring(7).split(" "),{stream:t[0],track:t[1]};const o=e.matchPrefix(A,"a=ssrc:").map(A=>e.parseSsrcMedia(A)).filter(A=>"msid"===A.attribute);return o.length>0?(t=o[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},e.parseSctpDescription=function(A){const t=e.parseMLine(A),i=e.matchPrefix(A,"a=max-message-size:");let o;i.length>0&&(o=parseInt(i[0].substring(19),10)),isNaN(o)&&(o=65536);const n=e.matchPrefix(A,"a=sctp-port:");if(n.length>0)return{port:parseInt(n[0].substring(12),10),protocol:t.fmt,maxMessageSize:o};const r=e.matchPrefix(A,"a=sctpmap:");if(r.length>0){const A=r[0].substring(10).split(" ");return{port:parseInt(A[0],10),protocol:A[1],maxMessageSize:o}}},e.writeSctpDescription=function(A,e){let t=[];return t="DTLS/SCTP"!==A.protocol?["m="+A.kind+" 9 "+A.protocol+" "+e.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+e.port+"\r\n"]:["m="+A.kind+" 9 "+A.protocol+" "+e.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+e.port+" "+e.protocol+" 65535\r\n"],void 0!==e.maxMessageSize&&t.push("a=max-message-size:"+e.maxMessageSize+"\r\n"),t.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(A,t,i){let o;const n=void 0!==t?t:2;return o=A||e.generateSessionId(),"v=0\r\no="+(i||"thisisadapterortc")+" "+o+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},e.getDirection=function(A,t){const i=e.splitLines(A);for(let e=0;e(e.candidate&&Object.defineProperty(e,"candidate",{value:new A.RTCIceCandidate(e.candidate),writable:"false"}),e))}function dS(A){!A.RTCIceCandidate||A.RTCIceCandidate&&"relayProtocol"in A.RTCIceCandidate.prototype||fw(A,"icecandidate",A=>{if(A.candidate){const e=IS.parseCandidate(A.candidate.candidate);"relay"===e.type&&(A.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[e.priority>>24])}return A})}function hS(A,e){if(!A.RTCPeerConnection)return;"sctp"in A.RTCPeerConnection.prototype||Object.defineProperty(A.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const t=A.RTCPeerConnection.prototype.setRemoteDescription;A.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===e.browser&&e.version>=76){const{sdpSemantics:A}=this.getConfiguration();"plan-b"===A&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(A){if(!A||!A.sdp)return!1;const e=IS.splitSections(A.sdp);return e.shift(),e.some(A=>{const e=IS.parseMLine(A);return e&&"application"===e.kind&&-1!==e.protocol.indexOf("SCTP")})}(arguments[0])){const A=function(A){const e=A.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===e||e.length<2)return-1;const t=parseInt(e[1],10);return t!=t?-1:t}(arguments[0]),t=function(A){let t=65536;return"firefox"===e.browser&&(t=e.version<57?-1===A?16384:2147483637:e.version<60?57===e.version?65535:65536:2147483637),t}(A),i=function(A,t){let i=65536;"firefox"===e.browser&&57===e.version&&(i=65535);const o=IS.matchPrefix(A.sdp,"a=max-message-size:");return o.length>0?i=parseInt(o[0].substring(19),10):"firefox"===e.browser&&-1!==t&&(i=2147483637),i}(arguments[0],A);let o;o=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const n={};Object.defineProperty(n,"maxMessageSize",{get:()=>o}),this._sctp=n}return t.apply(this,arguments)}}function CS(A){if(!A.RTCPeerConnection||!("createDataChannel"in A.RTCPeerConnection.prototype))return;function e(A,e){const t=A.send;A.send=function(){const i=arguments[0],o=i.length||i.size||i.byteLength;if("open"===A.readyState&&e.sctp&&o>e.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+e.sctp.maxMessageSize+" bytes)");return t.apply(A,arguments)}}const t=A.RTCPeerConnection.prototype.createDataChannel;A.RTCPeerConnection.prototype.createDataChannel=function(){const A=t.apply(this,arguments);return e(A,this),A},fw(A,"datachannel",A=>(e(A.channel,A.target),A))}function BS(A){if(!A.RTCPeerConnection||"connectionState"in A.RTCPeerConnection.prototype)return;const e=A.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(A){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),A&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=A)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(A=>{const t=e[A];e[A]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=A=>{const e=A.target;if(e._lastConnectionState!==e.connectionState){e._lastConnectionState=e.connectionState;const t=new Event("connectionstatechange",A);e.dispatchEvent(t)}return A},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),t.apply(this,arguments)}})}function QS(A,e){if(!A.RTCPeerConnection)return;if("chrome"===e.browser&&e.version>=71)return;if("safari"===e.browser&&e._safariVersion>=13.1)return;const t=A.RTCPeerConnection.prototype.setRemoteDescription;A.RTCPeerConnection.prototype.setRemoteDescription=function(e){if(e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")){const t=e.sdp.split("\n").filter(A=>"a=extmap-allow-mixed"!==A.trim()).join("\n");A.RTCSessionDescription&&e instanceof A.RTCSessionDescription?arguments[0]=new A.RTCSessionDescription({type:e.type,sdp:t}):e.sdp=t}return t.apply(this,arguments)}}function pS(A,e){if(!A.RTCPeerConnection||!A.RTCPeerConnection.prototype)return;const t=A.RTCPeerConnection.prototype.addIceCandidate;t&&0!==t.length&&(A.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===e.browser&&e.version<78||"firefox"===e.browser&&e.version<68||"safari"===e.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function fS(A,e){if(!A.RTCPeerConnection||!A.RTCPeerConnection.prototype)return;const t=A.RTCPeerConnection.prototype.setLocalDescription;t&&0!==t.length&&(A.RTCPeerConnection.prototype.setLocalDescription=function(){let A=arguments[0]||{};if("object"!=typeof A||A.type&&A.sdp)return t.apply(this,arguments);if(A={type:A.type,sdp:A.sdp},!A.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":A.type="offer";break;default:A.type="answer"}return A.sdp||"offer"!==A.type&&"answer"!==A.type?t.apply(this,[A]):("offer"===A.type?this.createOffer:this.createAnswer).apply(this).then(A=>t.apply(this,[A]))})}var mS=Object.freeze({__proto__:null,shimRTCIceCandidate:ES,shimRTCIceCandidateRelayProtocol:dS,shimMaxMessageSize:hS,shimSendThrowTypeError:CS,shimConnectionState:BS,removeExtmapAllowMixed:QS,shimAddIceCandidateNullOrEmpty:pS,shimParameterlessSetLocalDescription:fS});!function({window:A}={},e={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const t=Dw,i=function(A){const e={browser:null,version:null};if(void 0===A||!A.navigator||!A.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:t}=A;if(t.mozGetUserMedia)e.browser="firefox",e.version=parseInt(pw(t.userAgent,/Firefox\/(\d+)\./,1));else if(t.webkitGetUserMedia||!1===A.isSecureContext&&A.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(pw(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2));else{if(!A.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return e.browser="Not a supported browser.",e;e.browser="safari",e.version=parseInt(pw(t.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=A.RTCRtpTransceiver&&"currentDirection"in A.RTCRtpTransceiver.prototype,e._safariVersion=pw(t.userAgent,/Version\/(\d+(\.?\d+))/,1)}return e}(A),o={browserDetails:i,commonShim:mS,extractVersion:pw,disableLog:mw,disableWarnings:yw,sdp:uS};switch(i.browser){case"chrome":if(!Pw||!Ow||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),o;if(null===i.version)return t("Chrome shim can not determine version, not shimming."),o;t("adapter.js shimming chrome."),o.browserShim=Pw,pS(A,i),fS(A),Tw(A,i),Nw(A),Ow(A,i),bw(A),Fw(A,i),Gw(A),kw(A),Lw(A),xw(A,i),ES(A),dS(A),BS(A),hS(A,i),CS(A),QS(A,i);break;case"firefox":if(!$w||!Hw||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),o;t("adapter.js shimming firefox."),o.browserShim=$w,pS(A,i),fS(A),Yw(A,i),Hw(A,i),Jw(A),jw(A),qw(A),Vw(A),Kw(A),Ww(A),zw(A),Zw(A),Xw(A),ES(A),BS(A),hS(A,i),CS(A);break;case"safari":if(!gS||!e.shimSafari)return t("Safari shim is not included in this adapter release."),o;t("adapter.js shimming safari."),o.browserShim=gS,pS(A,i),fS(A),nS(A),sS(A),tS(A),AS(A),eS(A),rS(A),iS(A),aS(A),ES(A),dS(A),hS(A,i),CS(A),QS(A,i);break;default:t("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var yS,DS=Object.create,vS=Object.defineProperty,wS=Object.defineProperties,SS=Object.getOwnPropertyDescriptor,MS=Object.getOwnPropertyDescriptors,RS=Object.getOwnPropertyNames,_S=Object.getOwnPropertySymbols,TS=Object.getPrototypeOf,NS=Object.prototype.hasOwnProperty,bS=Object.prototype.propertyIsEnumerable,GS=Reflect.get,kS=Math.pow,LS=(A,e,t)=>e in A?vS(A,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[e]=t,US=(A,e)=>{for(var t in e||(e={}))NS.call(e,t)&&LS(A,t,e[t]);if(_S)for(var t of _S(e))bS.call(e,t)&&LS(A,t,e[t]);return A},FS=(A,e)=>wS(A,MS(e)),OS=(A,e)=>{var t={};for(var i in A)NS.call(A,i)&&e.indexOf(i)<0&&(t[i]=A[i]);if(null!=A&&_S)for(var i of _S(A))e.indexOf(i)<0&&bS.call(A,i)&&(t[i]=A[i]);return t},xS=(A,e)=>()=>(e||A((e={exports:{}}).exports,e),e.exports),PS=(A,e)=>{for(var t in e)vS(A,t,{get:e[t],enumerable:!0})},YS=(A,e,t)=>(t=null!=A?DS(TS(A)):{},((A,e,t,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of RS(e))!NS.call(A,o)&&o!==t&&vS(A,o,{get:()=>e[o],enumerable:!(i=SS(e,o))||i.enumerable});return A})(!e&&A&&A.__esModule?t:vS(t,"default",{value:A,enumerable:!0}),A)),JS=(A,e,t,i)=>{for(var o,n=i>1?void 0:i?SS(e,t):e,r=A.length-1;r>=0;r--)(o=A[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&vS(e,t,n),n},HS=(A,e,t)=>LS(A,"symbol"!=typeof e?e+"":e,t),qS=(A,e,t)=>GS(TS(A),t,e),VS=(A,e,t)=>new Promise((i,o)=>{var n=A=>{try{s(t.next(A))}catch(e){o(e)}},r=A=>{try{s(t.throw(A))}catch(e){o(e)}},s=A=>A.done?i(A.value):Promise.resolve(A.value).then(n,r);s((t=t.apply(A,e)).next())}),jS=xS((A,e)=>{var t=Object.prototype.hasOwnProperty,i="~";function o(){}function n(A,e,t){this.fn=A,this.context=e,this.once=t||!1}function r(A,e,t,o,r){if("function"!=typeof t)throw new TypeError("The listener must be a function");var s=new n(t,o||A,r),a=i?i+e:e;return A._events[a]?A._events[a].fn?A._events[a]=[A._events[a],s]:A._events[a].push(s):(A._events[a]=s,A._eventsCount++),A}function s(A,e){0===--A._eventsCount?A._events=new o:delete A._events[e]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),a.prototype.eventNames=function(){var A,e,o=[];if(0===this._eventsCount)return o;for(e in A=this._events)t.call(A,e)&&o.push(i?e.slice(1):e);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(A)):o},a.prototype.listeners=function(A){var e=i?i+A:A,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var o=0,n=t.length,r=new Array(n);o{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(A){return A.encoding?"rtpmap:%d %s/%s/%s":A.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(A){return null!=A.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(A){return null!=A.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(A){return"extmap:%d"+(A.direction?"/%s":"%v")+(A["encrypt-uri"]?" %s":"%v")+" %s"+(A.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(A){return null!=A.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(A){var e="candidate:%s %d %s %d %s %d typ %s";return e+=null!=A.raddr?" raddr %s rport %d":"%v%v",e+=null!=A.tcptype?" tcptype %s":"%v",null!=A.generation&&(e+=" generation %d"),(e+=null!=A["network-id"]?" network-id %d":"%v")+(null!=A["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(A){var e="ssrc:%d";return null!=A.attribute&&(e+=" %s",null!=A.value&&(e+=":%s")),e}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(A){return null!=A.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(A){return A.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(A){return"imageattr:%s %s %s"+(A.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(A){return"simulcast:%s %s"+(A.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(A){return"ts-refclk:%s"+(null!=A.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(A){var e="mediaclk:";return e+=null!=A.id?"id=%s %s":"%v%s",e+=null!=A.mediaClockValue?"=%s":"",(e+=null!=A.rateNumerator?" rate=%s":"")+(null!=A.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(A){t[A].forEach(function(A){A.reg||(A.reg=/(.*)/),A.format||(A.format="%s")})})}),WS=xS(A=>{var e=function(A){return String(Number(A))===A?Number(A):A},t=function(A,t,i){var o=A.name&&A.names;A.push&&!t[A.push]?t[A.push]=[]:o&&!t[A.name]&&(t[A.name]={});var n=A.push?{}:o?t[A.name]:t;(function(A,t,i,o){if(o&&!i)t[o]=e(A[1]);else for(var n=0;n1&&(A[i[0]]=void 0),A};A.parseParams=function(A){return A.split(/;\s?/).reduce(n,{})},A.parseFmtpConfig=A.parseParams,A.parsePayloads=function(A){return A.toString().split(" ").map(Number)},A.parseRemoteCandidates=function(A){for(var t=[],i=A.split(" ").map(e),o=0;o{var t=KS(),i=/%[sdv%]/g,o=function(A){var e=1,t=arguments,o=t.length;return A.replace(i,function(A){if(e>=o)return A;var i=t[e];switch(e+=1,A){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},n=function(A,e,t){var i=[A+"="+(e.format instanceof Function?e.format(e.push?t:t[e.name]):e.format)];if(e.names)for(var n=0;n{var e=WS(),t=zS(),i=KS();A.grammar=i,A.write=t,A.parse=e.parse,A.parseParams=e.parseParams,A.parseFmtpConfig=e.parseFmtpConfig,A.parsePayloads=e.parsePayloads,A.parseRemoteCandidates=e.parseRemoteCandidates,A.parseImageAttributes=e.parseImageAttributes,A.parseSimulcastStreamList=e.parseSimulcastStreamList}),XS=xS((A,e)=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(A){return A.encoding?"rtpmap:%d %s/%s/%s":A.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(A){return null!=A.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(A){return null!=A.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(A){return"extmap:%d"+(A.direction?"/%s":"%v")+(A["encrypt-uri"]?" %s":"%v")+" %s"+(A.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(A){return null!=A.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(A){var e="candidate:%s %d %s %d %s %d typ %s";return e+=null!=A.raddr?" raddr %s rport %d":"%v%v",e+=null!=A.tcptype?" tcptype %s":"%v",null!=A.generation&&(e+=" generation %d"),(e+=null!=A["network-id"]?" network-id %d":"%v")+(null!=A["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(A){var e="ssrc:%d";return null!=A.attribute&&(e+=" %s",null!=A.value&&(e+=":%s")),e}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(A){return null!=A.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(A){return A.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(A){return"imageattr:%s %s %s"+(A.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(A){return"simulcast:%s %s"+(A.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(A){return"ts-refclk:%s"+(null!=A.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(A){var e="mediaclk:";return e+=null!=A.id?"id=%s %s":"%v%s",e+=null!=A.mediaClockValue?"=%s":"",(e+=null!=A.rateNumerator?" rate=%s":"")+(null!=A.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(A){t[A].forEach(function(A){A.reg||(A.reg=/(.*)/),A.format||(A.format="%s")})})}),$S=xS(A=>{var e=function(A){return String(Number(A))===A?Number(A):A},t=function(A,t,i){var o=A.name&&A.names;A.push&&!t[A.push]?t[A.push]=[]:o&&!t[A.name]&&(t[A.name]={});var n=A.push?{}:o?t[A.name]:t;(function(A,t,i,o){if(o&&!i)t[o]=e(A[1]);else for(var n=0;n1&&(A[i[0]]=void 0),A};A.parseParams=function(A){return A.split(/;\s?/).reduce(n,{})},A.parseFmtpConfig=A.parseParams,A.parsePayloads=function(A){return A.toString().split(" ").map(Number)},A.parseRemoteCandidates=function(A){for(var t=[],i=A.split(" ").map(e),o=0;o{var t=XS(),i=/%[sdv%]/g,o=function(A){var e=1,t=arguments,o=t.length;return A.replace(i,function(A){if(e>=o)return A;var i=t[e];switch(e+=1,A){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},n=function(A,e,t){var i=[A+"="+(e.format instanceof Function?e.format(e.push?t:t[e.name]):e.format)];if(e.names)for(var n=0;n{var e=$S(),t=AM();A.write=t,A.parse=e.parse,A.parseParams=e.parseParams,A.parseFmtpConfig=e.parseFmtpConfig,A.parsePayloads=e.parsePayloads,A.parseRemoteCandidates=e.parseRemoteCandidates,A.parseImageAttributes=e.parseImageAttributes,A.parseSimulcastStreamList=e.parseSimulcastStreamList}),tM=YS(jS()),iM=((yS=iM||{})[yS.INVALID_PARAMETER=4096]="INVALID_PARAMETER",yS[yS.INVALID_OPERATION=4097]="INVALID_OPERATION",yS[yS.NOT_SUPPORTED=4098]="NOT_SUPPORTED",yS[yS.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",yS[yS.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",yS[yS.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",yS[yS.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",yS[yS.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",yS[yS.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",yS[yS.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",yS[yS.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",yS[yS.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",yS[yS.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",yS[yS.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",yS[yS.CLIENT_BANNED=16448]="CLIENT_BANNED",yS[yS.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",yS[yS.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",yS[yS.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",yS[yS.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",yS[yS.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",yS[yS.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",yS[yS.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",yS[yS.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",yS[yS.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",yS[yS.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",yS[yS.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",yS[yS.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",yS[yS.API_CALL_ABORTED=16461]="API_CALL_ABORTED",yS[yS.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",yS[yS.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",yS[yS.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",yS[yS.VIDEO_ENCODE_FAILED=16465]="VIDEO_ENCODE_FAILED",yS[yS.AUDIO_ENCODE_FAILED=16466]="AUDIO_ENCODE_FAILED",yS[yS.UNKNOWN=65535]="UNKNOWN",yS),oM=iM,nM=class extends Error{constructor(A){let{name:e="RtcError",message:t,code:i=oM.UNKNOWN,extraCode:o=0,constraint:n}=A,r="<".concat(function(A){for(let e in oM)if(oM[e]===A)return e;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(t).concat(n?" constraint: ".concat(n):"").concat(null!=t&&t.includes(r)?"":" ".concat(r));super(s),HS(this,"code"),HS(this,"extraCode"),HS(this,"message"),HS(this,"originMessage"),HS(this,"name"),HS(this,"constraint"),this.code=i,this.extraCode=o,this.name=e,this.message=s,this.constraint=n,this.originMessage=t}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},rM=nM,sM=0,aM=!0,gM=function(A){sM=A;let e=new Date;e.setTime(e.getTime()+A),sG[aM?"info":"debug"]("baseTime from server: ".concat(e," offset: ").concat(A)),aM=!1},cM=function(){return sM},lM=function(){return Date.now()+sM},IM=function(){let A=new Date;return A.setTime(lM()),A.toLocaleString()},uM=function(A){let e=String(A.getMilliseconds());return"padStart"in String.prototype&&(e=e.toString().padStart(3,"0")),"".concat(A.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(e)},EM={};PS(EM,{REPORT_TYPE:()=>NT,buildSSOPackage:()=>bT,bytes2ms:()=>b_,calculateScaleResolutionDownNumber:()=>MT,concatArrayBuffers:()=>GT,convertObjectNumberToInt:()=>yT,copyProperties:()=>N_,deepClone:()=>uT,deepCloneBasic:()=>TT,deepMerge:()=>IT,delay:()=>DT,fibonacci:()=>x_,formatedTime:()=>hT,getConstructorName:()=>AT,getContainerFromElement:()=>dT,getEnv:()=>f_,getFirst16Bits:()=>LT,getInternalVersion:()=>rT,getLast16Bits:()=>kT,getLoggerUrl:()=>D_,getMediaStreamTrackInfo:()=>ST,getMuteStateFromFlag:()=>gT,getNetworkType:()=>w_,getNumNetworkType:()=>T_,getReconnectionTimeout:()=>P_,getStringByteLength:()=>QT,getTestSignalDomain:()=>m_,getTurnServer:()=>cT,getUint32Version:()=>mT,getValueType:()=>Y_,getViewListFromView:()=>ET,glog:()=>U_,ipv4ToUint32:()=>lT,isArray:()=>W_,isAudioWorkletSupported:()=>eT,isBoolean:()=>j_,isConstructor:()=>$_,isEmpty:()=>aT,isFunction:()=>J_,isLangChinese:()=>F_,isMediaStreamTrack:()=>z_,isNumber:()=>V_,isObject:()=>K_,isOverseaSdkAppId:()=>y_,isPlainObject:()=>O_,isPortrait:()=>pT,isPromise:()=>X_,isRemoteTrack:()=>Z_,isRotate90Or270:()=>RT,isSetSinkIdSupported:()=>tT,isString:()=>q_,isUndefined:()=>H_,loadImage:()=>fT,loadVideo:()=>_T,ms2bytes:()=>k_,ms2samples:()=>L_,normalizeUrl:()=>wT,performanceNow:()=>oT,promiseAny:()=>iT,samples2ms:()=>G_,setNetworkTypeFromWebRTC:()=>__,stringify:()=>CT,stringifyIncludeValue:()=>BT,throttlePromise:()=>vT});var dM={};PS(dM,{ASR_ROBOT_FROM_TYPE:()=>$R,AUDIO_MUTE_BIT:()=>iR,AUDIO_STAT_BIT:()=>tR,AUX_STAT_BIT:()=>eR,AUX_STREAM_MSID:()=>gR,BACKEND_ENV:()=>ZM,BASE_DOC_URL:()=>_M,BASE_HOST:()=>wM,CAPABILITIES_KEYS:()=>ZR,CLASS_NAME:()=>YR,CLOUD_CONSOLE_URL:()=>RM,CROSS_ROOM_BIT:()=>rR,DATA_CHANNEL_FROM_TYPE_BIT:()=>sR,DATA_FREEZE_TIMING:()=>kR,DOC_BILLING_CN:()=>NM,DOC_BILLING_OVERSEA:()=>bM,DOC_URL:()=>TM,DTLS_STATE_UNKNOWN:()=>QR,ENV_NAME:()=>FM,EXCHANGE_SDP_TIMEOUT:()=>_R,IS_WORKER:()=>fM,IS_WORKLET:()=>mM,KIBANA_EVENT:()=>wR,LOCAL_STREAM_PUBLISH_STATE:()=>GR,LOGGER_CMD_TYPE:()=>UM,LOGGER_DOMAIN:()=>GM,LOGGER_DOMAIN_OVERSEA:()=>kM,LOG_LEVEL:()=>OM,LOG_LEVEL_NAME:()=>jR,MAIN_STREAM_MSID:()=>aR,MAX_RTT:()=>XR,MICROPHONE_COMMUNICATIONS:()=>VR,MICROPHONE_DEFAULT:()=>HR,MUTE_ALL_BIT:()=>nR,NAME:()=>WM,NETWORK_TYPE:()=>YM,NOT_SUPPORTED_H264:()=>bR,PAUSED_RETRY_COUNT:()=>JR,PEERCONNECTION_CONNECTING_TIMEOUT:()=>OR,PEER_CONNECTION_STATE:()=>pR,PEER_LEAVE_REASON:()=>KR,RECOVER_CAPTURE_INTERVAL:()=>zR,REMOTE_STREAM_TYPE_AUX:()=>lR,REMOTE_STREAM_TYPE_MAIN:()=>cR,RENDER_FREEZE_TIMING:()=>LR,SCHEDULE_DOMAIN:()=>xR,SCHEDULE_TIMEOUT:()=>PR,SDP_SEMANTICS_PLAN_B:()=>NR,SDP_SEMANTICS_UNIFIED_PLAN:()=>TR,SECOND_HOST:()=>SM,SIGNAL_PING_PONG_INTERVAL:()=>PM,SIGNAL_PING_TIMEOUT:()=>xM,SIGNAL_RECONNECTION_COUNT:()=>vR,SMALL_STAT_BIT:()=>AR,SPEAKER_DEFAULT:()=>qR,STORAGE_EXPIRES_TIME:()=>JM,STREAM_TYPE_BIG:()=>UR,STREAM_TYPE_SMALL:()=>FR,SUBSCRIBE_SMALL_RETRY_COUNT:()=>WR,SYNC_USER_LIST_INTERVAL:()=>SR,Scene:()=>XM,THIRD_HOST:()=>MM,TRANSPORT_DIRECTION:()=>zM,TRTC_ERROR_ASSISTANCE:()=>LM,TRTC_QUALITY_BAD:()=>hR,TRTC_QUALITY_DISCONNECTED:()=>BR,TRTC_QUALITY_EXCELLENT:()=>uR,TRTC_QUALITY_GOOD:()=>ER,TRTC_QUALITY_POOR:()=>dR,TRTC_QUALITY_UNKNOWN:()=>IR,TRTC_QUALITY_VERY_BAD:()=>CR,UPDATE_OFFER_TIMEOUT:()=>RR,VIDEO_MUTE_BIT:()=>oR,VIDEO_STAT_BIT:()=>$M,WEBGL_ATTRIBUTES:()=>A_,audioProfileMap:()=>HM,defaultBigVideoProfile:()=>VM,defaultSmallVideoProfile:()=>jM,getRetryCount:()=>yR,getScriptDir:()=>yM,innerVersion:()=>hM,loggerProxy:()=>DM,screenProfileMap:()=>KM,setLoggerProxy:()=>vM,setRetryCount:()=>mR,setVersion:()=>BM,version:()=>CM,videoProfileMap:()=>qM});var hM="4.15.00.1600",CM="5.0.0";function BM(A){CM=A;let[e,t,i]=A.split(".").map(A=>parseInt(A,10));hM="".concat(e,".").concat(Math.min(15,t),".").concat(Math.min(15,i),".").concat(t.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var QM,pM,fM="undefined"!=typeof importScripts,mM="undefined"!=typeof registerProcessor,yM=()=>{let A=fM?self.location.href:document.currentScript.src;return A.substring(0,A.lastIndexOf("/")+1)},DM="",vM=A=>DM=A,wM="web.sdk.qcloud.com",SM="web.sdk.tencent.cn",MM="web.sdk.cloud.tencent.cn",RM="https://console.cloud.tencent.com/trtc",_M="https://".concat(wM,"/trtc/webrtc/doc"),TM="".concat(_M,"/zh-cn/"),NM="https://cloud.tencent.com/document/product/647/85386",bM="https://trtc.io/document/56025",GM="https://yun.tim.qq.com",kM="https://apisgp.my-imcloud.com",LM="trtc_error_assistance",UM={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},FM={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},OM=((pM=OM||{})[pM.TRACE=0]="TRACE",pM[pM.DEBUG=1]="DEBUG",pM[pM.INFO=2]="INFO",pM[pM.WARN=3]="WARN",pM[pM.ERROR=4]="ERROR",pM[pM.NONE=5]="NONE",pM),xM=18e3,PM=2e3,YM={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5,"5g":6},JM=6048e5,HM={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},qM={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},VM=qM["480p_2"],jM=qM["120p_2"],KM={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},WM={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADSTART:"loadstart",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",FULLSCREEN_CHANGE:"fullscreenchange",RESIZE:"resize",TIME_UPDATE:"timeupdate"},zM={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},ZM={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},XM=((QM=XM||{}).LIVE="live",QM.RTC="rtc",QM),$M=1,AR=2,eR=4,tR=8,iR=64,oR=16,nR=112,rR=128,sR=256,aR="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",gR="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",cR=WM.MAIN,lR=WM.AUXILIARY,IR=0,uR=1,ER=2,dR=3,hR=4,CR=5,BR=6,QR="unknown",pR={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},fR=1/0;function mR(A){fR=A}function yR(){return fR}var DR,vR=30,wR={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry",VIDEO_ENCODE_FAILED_DURING_CALL:"video-encode-failed-during-call",VIDEO_ENCODE_RESUME_DURING_CALL:"video-encode-resume-during-call",AUDIO_ENCODE_FAILED_DURING_CALL:"audio-encode-failed-during-call",AUDIO_ENCODE_RESUME_DURING_CALL:"audio-encode-resume-during-call",VIDEO_DECODE_FAILED_DURING_CALL:"video-decode-failed-during-call",VIDEO_DECODE_RESUME_DURING_CALL:"video-decode-resume-during-call",AUDIO_DECODE_FAILED_DURING_CALL:"audio-decode-failed-during-call",AUDIO_DECODE_RESUME_DURING_CALL:"audio-decode-resume-during-call",VIDEO_HARDWARE_DECODE_FAILED:"video-hardware-decode-failed",VIDEO_HARDWARE_DECODE_RESUME:"video-hardware-decode-resume"},SR=1e4,RR=1e4,_R=1e4,TR="unified-plan",NR="plan-b",bR=1028,GR=((DR=GR||{})[DR.UNPUBLISH=-1]="UNPUBLISH",DR[DR.PUBLISHING=0]="PUBLISHING",DR[DR.PUBLISHED=1]="PUBLISHED",DR),kR=500,LR=1e3,UR=WM.BIG,FR=WM.SMALL,OR=1e4,xR={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},PR=2e3,YR={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},JR=5,HR="default",qR=HR,VR="communications",jR=Object.keys(OM),KR=["normal leave","timeout leave","kick","role change"],WR=10,zR=2e3,ZR=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],XR=1e4,$R=14,A_={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},e_=function(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})},t_=Symbol(32),i_=Symbol(16),o_=Symbol(8),n_=class{constructor(A){this.g=A,this.consumed=0,A&&(this.need=A.next().value)}setG(A){this.g=A,this.demand(A.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(A,e){return e&&this.consume(),this.need=A,this.flush()}read(A){return e_(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,t)=>{var i;this.reject=t,this.resolve=A=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(A)},this.demand(A,!0)||null===(i=this.pull)||void 0===i||i.call(this,A)})})}readU32(){return this.read(t_)}readU16(){return this.read(i_)}readU8(){return this.read(o_)}close(){var A;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(A=this.reject)||void 0===A||A.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let A=null,e=this.buffer.subarray(this.consumed),t=0,i=A=>e.length<(t=A);if("number"==typeof this.need){if(i(this.need))return;A=e.subarray(0,t)}else if(this.need===t_){if(i(4))return;A=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===i_){if(i(2))return;A=e[0]<<8|e[1]}else if(this.need===o_){if(i(1))return;A=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(e.subarray(0,t)),A=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(i(this.need.byteLength))return;new Uint8Array(this.need).set(e.subarray(0,t)),A=this.need}return this.consumed+=t,this.g?this.demand(this.g.next(A).value,!0):this.resolve&&this.resolve(A),A}write(A){if(A instanceof Uint8Array?this.malloc(A.length).set(A):"buffer"in A?this.malloc(A.byteLength).set(new Uint8Array(A.buffer,A.byteOffset,A.byteLength)):this.malloc(A.byteLength).set(new Uint8Array(A)),!this.g&&!this.resolve)return new Promise(A=>this.pull=A);this.flush()}writeU32(A){this.malloc(4).set([A>>24&255,A>>16&255,A>>8&255,255&A]),this.flush()}writeU16(A){this.malloc(2).set([A>>8&255,255&A]),this.flush()}writeU8(A){this.malloc(1)[0]=A,this.flush()}malloc(A){if(this.buffer){let e=this.buffer.length,t=e+A;if(t<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,t);else{let A=new Uint8Array(t);A.set(this.buffer),this.buffer=A}return this.buffer.subarray(e,t)}return this.buffer=new Uint8Array(A),this.buffer}};n_.U32=t_,n_.U16=i_,n_.U8=o_;var r_=128;function s_(A){let e=new n_;for(;A>=128;)e.malloc(1)[0]=255&A|r_,A>>>=7;return e.malloc(1)[0]=255&A,e.buffer||new Uint8Array(0)}function a_(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=new n_,i=e<<3;switch(typeof A){case"boolean":let o=t.malloc(2);o[0]=i,o[1]=A?1:0;break;case"number":t.malloc(1)[0]=i,t.write(s_(A));break;case"string":t.malloc(1)[0]=2|i;let n=(new TextEncoder).encode(A);t.write(s_(n.length));let r=t.malloc(n.length);for(let A=0;A>>24&255),this.buffer.push(A>>>16&255),this.buffer.push(A>>>8&255),this.buffer.push(255&A)}writeInt16(A){this.buffer.push(A>>>8&255),this.buffer.push(255&A)}writeByte(A){this.buffer.push(255&A)}writeBytes(A){for(let e=0;e>>24&255,A[t+1]=e>>>16&255,A[t+2]=e>>>8&255,A[t+3]=255&e}function l_(A,e){return A[e]<<24|A[e+1]<<16|A[e+2]<<8|A[e+3]}function I_(A,e){return A[e]}function u_(A,e,t){return(new TextDecoder).decode((i=e,o=t,A.slice(i,i+o)));var i,o}var E_=0,d_=2654435769,h_=16,C_=2,B_=7;function Q_(A,e){let t=new g_,i=function(A,e,t){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,uin:"",uinLen:0,reqHead:{seqNumber:t,appId:A,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:i,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:e}}(e,A,E_);E_=E_+1&2147483647,t.writeInt32(0),t.writeInt32(i.version),t.writeByte(i.encryption);let o=(new TextEncoder).encode(i.d2);t.writeInt32(o.length+4),o&&t.writeBytes(o),t.writeByte(i.uinType);let n=(new TextEncoder).encode(i.uin);t.writeInt32(n.length+4),n.length&&t.writeBytes(n);let r=new g_;r.writeInt32(0),r.writeInt32(i.reqHead.seqNumber),r.writeInt32(i.reqHead.appId),r.writeByte(i.reqHead.appId>>>24&255),r.writeByte(i.reqHead.appId>>>16&255),r.writeByte(i.reqHead.appId>>>8&255),r.writeByte(255&i.reqHead.appId);for(let B=4;B<16;B++)r.writeByte(0);let s=(new TextEncoder).encode(i.reqHead.a2);r.writeInt32(s.length+4),s.length&&r.writeBytes(s);let a=(new TextEncoder).encode(i.reqHead.serviceCmd);r.writeInt32(a.length+4),a.length&&r.writeBytes(a);let g=(new TextEncoder).encode(i.reqHead.cookie);r.writeInt32(g.length+4),g.length&&r.writeBytes(g);let c=(new TextEncoder).encode(i.reqHead.imei);r.writeInt32(c.length+4),c.length&&r.writeBytes(c);let l=(new TextEncoder).encode(i.reqHead.ksid);r.writeInt32(l.length+4),l.length&&r.writeBytes(l);let I=(new TextEncoder).encode(i.reqHead.clientVersionInfo);r.writeInt16(I.length+2),I.length&&r.writeBytes(I);let u=r.length;r.data[0]=u>>>24&255,r.data[1]=u>>>16&255,r.data[2]=u>>>8&255,r.data[3]=255&u,q_(A)&&(A=(new TextEncoder).encode(A)),r.writeInt32(A.length+4),A.length&&r.writeBytes(A);let E=new Uint8Array(r.data),d=null;1===i.encryption?d=(new TextEncoder).encode(i.uin):2===i.encryption&&(d=new Uint8Array(16)),d&&(E=function(A,e){let t=A.length,i=(t+1+C_+B_)%8;i&&(i=8-i);let o=new Uint8Array(t+1+C_+B_+i),n=0,r=new Uint8Array(8),s=new Uint8Array(8),a=new Uint8Array(8),g=0;r[0]=248&Math.floor(256*Math.random())|i,g=1;for(let l=0;l>>24&255,h[1]=C>>>16&255,h[2]=C>>>8&255,h[3]=255&C,h}function p_(A,e,t,i,o,n){for(let r=0;r<8;r++)A[r]^=i[r];!function(A,e,t,i){let o=l_(A,0),n=l_(A,4),r=[];for(let a=0;a<4;a++)r[a]=l_(e,4*a);let s=0;for(let a=0;a>>=0,o+=(n<<4)+r[0]^n+s^(n>>>5)+r[1],o>>>=0,n+=(o<<4)+r[2]^o+s^(o>>>5)+r[3],n>>>=0;c_(t,o,i),c_(t,n,i+4)}(A,e,o,n);for(let r=0;r<8;r++)o[n+r]^=t[r];for(let r=0;r<8;r++)t[r]=A[r]}var f_=function(){return new URLSearchParams(location.search).get("trtc_env")||""},m_=function(A){return A.includes(".")?A:"".concat(A).concat(".rtc.qq.com")},y_=A=>Number(A)<14e8,D_=function(A,e){let t;t=DM||(y_(A)?kM:GM);let i=Math.floor(Math.random()*kS(2,31));return"".concat(t,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(A,"&cmdtype=").concat(e)},v_="unknown";function w_(){var A;M_||(M_=!0,null==(A=navigator.connection)||A.addEventListener("typechange",S_));let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let o=t&&t.type&&t.type.toLowerCase(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===n&&(n="2g"),o?R_(o,n):v_}function S_(){sG.warn("netType changed",w_())}var M_=!1;function R_(A,e){if(YM[A])return A;switch(A){case"cellular":case"wimax":return e||"unknown";case"ethernet":return"wired";default:return"unknown"}}function __(A){v_=R_(A)}function T_(){return YM[w_()]}function N_(A,e){for(let t of Reflect.ownKeys(e))if("constructor"!==t&&"prototype"!==t&&"name"!==t){let i=Object.getOwnPropertyDescriptor(e,t)||"";Object.defineProperty(A,t,i)}return A}function b_(A){return G_(A/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function G_(A){return 1e3*A/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function k_(A){return 4*L_(A,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function L_(A){return A*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var U_="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},F_=()=>{let A=navigator.language;return A=A.substring(0,2),"zh"===A},O_=function(A){if(!A||"object"!=typeof A||"[object Object]"!=Object.prototype.toString.call(A))return!1;let e=Object.getPrototypeOf(A);if(null===e)return!0;let t=Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor;return"function"==typeof t&&t instanceof t&&Function.prototype.toString.call(t)===Function.prototype.toString.call(Object)};function x_(A){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return A<=1?e:x_(A-1,e,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+e)}function P_(A){return A>8?3e4:1e3*x_(A)}function Y_(A){return Reflect.apply(Object.prototype.toString,A,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var J_=A=>"function"==typeof A,H_=A=>void 0===A,q_=A=>"string"==typeof A,V_=A=>"number"==typeof A,j_=A=>"boolean"==typeof A,K_=A=>"object"===Y_(A),W_=A=>"array"===Y_(A),z_=A=>Y_(A)==="MediaStreamTrack".toLowerCase(),Z_=A=>A.isRemote,X_=A=>"promise"===Y_(A),$_=A=>J_(A)&&A.prototype.constructor===A,AT=A=>$_(A)?A.prototype.constructor.name:"",eT="undefined"!=typeof AudioWorkletNode,tT="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function iT(A){return new Promise((e,t)=>{let i=[];A.forEach(o=>{o.then(e).catch(e=>{i.push(e),i.length===A.length&&t(i)})})})}function oT(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var nT=A=>+A<10?"0".concat(A):A,rT=A=>{let e=A.match(/^\d+\.\d+\.\d+/)[0];if(!e)return A;let t=e.split("."),i=nT(t[1])+nT(t[2]);return t[1]-15>0&&(t[1]="15"),t[2]-15>0&&(t[2]="15"),"".concat(t.join("."),".").concat(i)},sT=Object.prototype.hasOwnProperty;function aT(A){if(null==A)return!0;if("boolean"==typeof A)return!1;if("number"==typeof A)return 0===A;if("string"==typeof A||"function"==typeof A||Array.isArray(A))return 0===A.length;if(A instanceof Error)return""===A.message;if(O_(A))switch(Object.prototype.toString.call(A)){case"[object File]":case"[object Map]":case"[object Set]":return 0===A.size;case"[object Object]":for(let e in A)if(sT.call(A,e))return!1;return!0}return!1}function gT(A,e){return{userId:e,hasAudio:!!(A&tR),hasVideo:!!(A&$M),hasAuxiliary:!!(A&eR),hasSmall:!!(A&AR),audioMuted:!!(A&iR),videoMuted:!!(A&oR),audioAvailable:!(!(A&tR)||A&iR),videoAvailable:!(!(A&$M)||A&oR),hasDatachannel:!!(A&sR)}}function cT(A){let e={urls:A.url.startsWith("turn:")||A.url.startsWith("turns:")?A.url:"turn:".concat(A.url)};return!H_(A.username)&&!H_(A.credential)&&(e.username=A.username,e.credential=A.credential,e.credentialType="password",H_(A.credentialType)||(e.credentialType=A.credentialType)),e}function lT(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!q_(A))return 0;let t=A.split(".");return e?(Number(t[0])<<24|Number(t[1])<<16|Number(t[2])<<8|Number(t[3]))>>>0:(Number(t[3])<<24|Number(t[2])<<16|Number(t[1])<<8|Number(t[0]))>>>0}var IT=function(A,e,t,i){if(!K_(A)||!K_(e))return 0;let o,n=0,r=Object.keys(e);for(let s=0,a=r.length;s{e[t]=uT(A)}),e}if(K_(A)){let e={};return Object.keys(A).forEach(t=>{e[t]=uT(A[t])}),e}return A}var ET=A=>{let e=[];if(W_(A))e=[...A];else if(q_(A)){let t=document.getElementById(A);t&&e.push(t)}else A&&e.push(A);return e},dT=A=>q_(A)?document.getElementById(A):A,hT=()=>(A=>{let e=A=>A<10?"0".concat(A):"".concat(A),t=A.getFullYear(),i=A.getMonth()+1,o=A.getDate(),n=e(A.getHours()),r=e(A.getMinutes()),s=e(A.getSeconds());return"".concat(t,"/").concat(i,"/").concat(o," ").concat(n,":").concat(r,":").concat(s)})(new Date);function CT(A,e){let{keysToInclude:t,keysToExclude:i}=e;try{if(W_(A))return"[".concat(A.map(A=>CT(A,{keysToInclude:t,keysToExclude:i})).join(","),"]");if(!O_(A)||!W_(t)&&!W_(i))return JSON.stringify(A);let e={},o=new Set(t),n=new Set(i);return Object.keys(A).forEach(r=>{(0===n.size&&o.has(r)||0===o.size&&!n.has(r))&&(e[r]=O_(A[r])||W_(A[r])?JSON.parse(CT(A[r],{keysToExclude:i,keysToInclude:t})):A[r])}),JSON.stringify(e)}catch(o){return"{}"}}function BT(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=[];return Object.keys(A).forEach(i=>{e===A[i]&&t.push(i)}),CT(A,{keysToInclude:t})}function QT(A){return A.replace(/[\u4e00-\u9fa5]/g,"aa").length}var pT=()=>{var A,e,t,i;return null!=(A=window.screen)&&A.orientation?!(null==(i=null==(t=null==(e=window.screen)?void 0:e.orientation)?void 0:t.type)||!i.includes("portrait")):0===window.orientation||180===window.orientation},fT=A=>VS(null,null,function*(){return new Promise((e,t)=>{let i;if(q_(A))i=new Image,i.crossOrigin="anonymous",i.src=A;else if(i=A,i.complete)return void e(i);i.onload=()=>e(i),i.onerror=()=>{t(new rM({code:oM.INVALID_PARAMETER,message:"load image failed, url: ".concat(A)}))}})}),mT=A=>{let e=A.split(".");return+e[0]<<24|+e[1]<<16|+e[2]<<8|+e[3]},yT=A=>(Object.keys(A).forEach(e=>{V_(A[e])&&(e.startsWith("uint")||e.startsWith("int"))?A[e]=Math.floor(A[e]):(O_(A[e])||W_(A[e]))&&yT(A[e])}),A);function DT(A,e){return new Promise(t=>{let i=setTimeout(t,A);e&&e(i)})}function vT(A,e){let t=null;return function(){for(var i=arguments.length,o=new Array(i),n=0;nt=null),t)}}function wT(A){return A.replace(/(^|[^:])\/{2,}/g,"$1/")}function ST(A){var e;try{let{width:t,height:i,frameRate:o,sampleRate:n,sampleSize:r,channelCount:s}=null==(e=A.getSettings)?void 0:e.call(A),a=A.kind===WM.AUDIO?"".concat(n,"x").concat(r,"@").concat(s):"".concat(t,"x").concat(i,"@").concat(o),g=A.stats?" stats: ".concat(JSON.stringify(A.stats).replaceAll('"',"")):"";return"".concat(A.id," ").concat(A.readyState," muted:").concat(A.muted," ").concat(A.kind," ").concat(A.label," ").concat(a).concat(g)}catch(t){return""}}function MT(A,e){return A.width*A.height===e.width*e.height?1:pT()&&e.width>e.height&&A.height>e.width?Math.max(A.width/e.height,A.height/e.width,1):Math.max(A.width/e.width,A.height/e.height,1)}function RT(A){return 90===A||270===A}function _T(A){return VS(this,null,function*(){return new Promise((e,t)=>{let i=document.createElement("video");i.crossOrigin="anonymous",i.src=A,i.muted=!0,i.loop=!0,i.playsInline=!0,i.play().then(()=>e(i)),i.onerror=()=>{t(i.error)}})})}function TT(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!=typeof A||null===A)return A;if(e.has(A))return e.get(A);if(Array.isArray(A)){let t=[];return e.set(A,t),A.forEach((A,i)=>{t[i]=TT(A,e)}),t}if("[object Object]"===Object.prototype.toString.call(A)){let t={};return e.set(A,t),Reflect.ownKeys(A).forEach(i=>{t[i]=TT(A[i],e)}),t}return A}var NT=(A=>(A[A.END_REPORT=2001]="END_REPORT",A[A.LOG=2002]="LOG",A[A.KEY_METRIC_REPORT=2003]="KEY_METRIC_REPORT",A))(NT||{});function bT(A,e,t,i){try{return Q_(a_(function(A,e,t,i){let o={data:A,random:Math.floor(2147483648*Math.random()),sdkAppId:t};return H_(i)||(o=FS(US({},o),{gzip:+i})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:e,bytes_report_data:JSON.stringify(o)}}}(A,e,t,i)),t)}catch(o){return JSON.stringify(A)}}function GT(A,e){let t=new Uint8Array(A.byteLength+e.byteLength);return t.set(new Uint8Array(A),0),t.set(new Uint8Array(e),A.byteLength),t.buffer}function kT(A){return(65535&A)>>>0}function LT(A){return(4294901760&A)>>>0}function UT(A){let e=function(A){try{let e={},t=0;e.totalLength=l_(A,t),t+=4,e.version=l_(A,t),t+=4,e.encryption=I_(A,t),t+=1,e.uinType=I_(A,t),t+=1,e.uinLength=l_(A,t),t+=4,e.uin=e.uinLength>4?u_(A,t,e.uinLength-4):"",t+=e.uinLength-4;let i=A.slice(t);return 2===e.encryption?(A=function(A,e){let t=0,i=new Uint8Array(8).fill(0),o=FT(new Uint8Array(A.slice(0,8)),e),n=7&o[0],r=A.length-1-n-C_-B_,s=new Uint8Array(r),a=0,g=i,c=A.slice(0,8);t=8;let l=1;l+=n;for(let u=1;u<=C_;)if(l<8)l++,u++;else if(8===l){let i=OT(A,t,g,c,o,e);g=i.ivPreCrypt,c=i.ivCurCrypt,o=i.debiBuf,t=i.bufPos,l=0}let I=r;for(;I>0;)if(l<8)s[a++]=o[l]^g[l],l++,I--;else if(8===l){let i=OT(A,t,g,c,o,e);g=i.ivPreCrypt,c=i.ivCurCrypt,o=i.debiBuf,t=i.bufPos,l=0}for(let u=1;u<=B_;)if(l<8)o[l],g[l],l++,u++;else if(8===l){if(t>=A.length)break;let i=OT(A,t,g,c,o,e);if(!i.success)break;g=i.ivPreCrypt,c=i.ivCurCrypt,o=i.debiBuf,t=i.bufPos,l=0}return s}(i,new Uint8Array(16).fill(0)),e.decrypted=!0,t=0):(A=i,t=0),e.rspHeadLength=l_(A,t),t+=4,e.seqNo=l_(A,t),t+=4,e.retCode=l_(A,t),t+=4,e.retStrLength=l_(A,t),t+=4,e.retStr=e.retStrLength?u_(A,t,e.retStrLength-4):"",t+=e.retStrLength-4,e.serviceCmdLength=l_(A,t),t+=4,e.serviceCmd=e.serviceCmdLength?u_(A,t,e.serviceCmdLength-4):"",t+=e.serviceCmdLength-4,e.cookieLength=l_(A,t),t+=4,e.cookie=e.cookieLength?u_(A,t,e.cookieLength-4):"",t+=e.cookieLength-4,e.flag=l_(A,t),t+=4,e.busiBuffLength=l_(A,t),t+=4,e.busiBuff=e.busiBuffLength?u_(A,t,e.busiBuffLength-4):"",t+=e.busiBuffLength-4,e}catch(e){}}(A);return null==e?void 0:e.busiBuff}function FT(A,e){let t=A[0]<<24|A[1]<<16|A[2]<<8|A[3],i=A[4]<<24|A[5]<<16|A[6]<<8|A[7];t>>>=0,i>>>=0;let o=d_*h_>>>0;for(let n=0;n>>5)+e[3],i>>>=0,t-=(i<<4)+e[0]^i+o^(i>>>5)+e[1],t>>>=0,o-=d_,o>>>=0;return new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i])}function OT(A,e,t,i,o,n){if(e+8>A.length)return{success:!1};let r=new Uint8Array(i),s=A.slice(e,e+8),a=new Uint8Array(8);for(let g=0;g<8;g++)a[g]=o[g]^s[g];return{success:!0,ivPreCrypt:r,ivCurCrypt:s,debiBuf:FT(a,n),bufPos:e+8}}var xT="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function PT(A){let{url:e,body:t,method:i="POST",timeout:o,priority:n}=A;return new Promise((A,r)=>{if("fetch"in window)return fetch(e,{method:i,body:t,priority:n}).then(A=>A.clone().json().then(A=>({data:A}),()=>A.arrayBuffer().then(A=>({data:UT(new Uint8Array(A))||(xT?xT.decode(A):A)})))).then(A,r);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let e=JSON.parse(s.response);A({data:e})}catch(e){A({data:s.response})}else r({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,e,!0),s.send(t)})}function YT(A){return VS(this,null,function*(){let e=oT(),t=JSON.stringify(A);try{if(!CompressionStream||t.length<=2800)return t;let A=new Blob([t],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),i=yield(yield(yield new Response(A)).blob()).arrayBuffer();return sG.debug("compressJSON ".concat(t.length," -> ").concat(i.byteLength," ").concat(oT()-e,"ms")),i}catch(i){return t}})}var JT=Object.prototype.hasOwnProperty,HT=A=>"function"==typeof A,qT=A=>void 0===A,VT=A=>"string"==typeof A,jT=A=>"boolean"==typeof A,KT=A=>A.isRemote,WT=function(A){if(!A||"object"!=typeof A||"[object Object]"!=Object.prototype.toString.call(A))return!1;let e=Object.getPrototypeOf(A);if(null===e)return!0;let t=Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor;return"function"==typeof t&&t instanceof t&&Function.prototype.toString.call(t)===Function.prototype.toString.call(Object)},zT=function(A){let{retryFunction:e,settings:t,onError:i,onRetrying:o,onRetryFailed:n,onRetrySuccess:r,context:s}=A;return function(){for(var A=arguments.length,a=new Array(A),g=0;gVS(this,null,function*(){let g=s||this;try{let t=yield e.apply(g,a);I>0&&r&&r.call(this,I),I=0,A(t)}catch(h){let e=()=>{clearTimeout(u),I=0,E=2,t(h)},r=()=>{2!==E&&I<(HT(c)?c():c)?(I++,E=1,HT(o)&&o.call(this,I,e),u=window.setTimeout(()=>{u=-1,d(A,t)},HT(l)?l(I):l)):(e(),HT(n)&&n.call(this,h))};HT(i)?i.call(this,{error:h,retry:r,reject:t,retryFuncArgs:a,retriedCount:I}):r()}});return new Promise(d)}},ZT=class A{constructor(A){HS(this,"_parentPath"),HS(this,"userId"),HS(this,"remoteUserId"),HS(this,"id"),HS(this,"sdkAppId"),HS(this,"type"),HS(this,"isLocal"),this.id=A.id,this.userId=A.userId,this.sdkAppId=A.sdkAppId,this.remoteUserId=A.remoteUserId,this.isLocal=!jT(A.isLocal)||A.isLocal,this.type=this.isLocal?"":A.type}getFullId(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}createChild(e){let t=new A({id:e.id,userId:qT(e.userId)?this.userId:e.userId,sdkAppId:qT(e.sdkAppId)?this.sdkAppId:e.sdkAppId,type:qT(e.type)?this.type:e.type,isLocal:qT(e.isLocal)?this.isLocal:e.isLocal,remoteUserId:qT(e.remoteUserId)?this.remoteUserId:e.remoteUserId});return t.bindParent(this),t}bindParent(A){let e=A.getFullId();this._parentPath!==e&&(this.debug("bind logger parent: ".concat(A.id)),this._parentPath=e,this.userId=A.userId||this.userId,this.sdkAppId=A.sdkAppId||this.sdkAppId)}setUserId(A){this.userId=A}setSdkAppId(A){this.sdkAppId=A}log(A,e){let t=this.isLocal?this.userId:this.remoteUserId,i=this.getFullId();e.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(i).concat(t?"|".concat(t):"","]")),sG.log(A,e,qT(this.userId)||function(A){if(null==A)return!0;if("boolean"==typeof A)return!1;if("number"==typeof A)return 0===A;if("string"==typeof A||"function"==typeof A||Array.isArray(A))return 0===A.length;if(A instanceof Error)return""===A.message;if(WT(A))switch(Object.prototype.toString.call(A)){case"[object File]":case"[object Map]":case"[object Set]":return 0===A.size;case"[object Object]":for(let e in A)if(JT.call(A,e))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}info(){for(var A=arguments.length,e=new Array(A),t=0;tIN,CHROME_MAJOR_VERSION:()=>Cb,CHROME_VERSION:()=>Qb,EDGE_VERSION:()=>QN,EDG_MAJOR_VERSION:()=>mN,EDG_VERSION:()=>fN,ELECTRON_MAJOR_VERSION:()=>pb,FIREFOX_MAJOR_VERSION:()=>CN,FIREFOX_VERSION:()=>hN,HUAWEI_VERSION:()=>ib,IE_VERSION:()=>bN,IOS_MAIN_VERSION:()=>Mb,IOS_VERSION:()=>vb,IPADQQB_VERSION:()=>HN,IS_ANDROID:()=>lN,IS_ANDROID_WEBVIEW:()=>Db,IS_ANY_SAFARI:()=>mb,IS_CHROME:()=>db,IS_CHROME_OS:()=>KN,IS_CHROMIUM_128_TO_143:()=>Bb,IS_CHROMIUM_BASE:()=>Eb,IS_DESKTOP_IOS_CHROME:()=>Nb,IS_EDG:()=>pN,IS_EDGE:()=>BN,IS_ELECTRON:()=>ZN,IS_FIREFOX:()=>dN,IS_HEADLESS_CHROME:()=>hb,IS_HONOR:()=>tb,IS_HUAWEI:()=>eb,IS_HUAWEIBROWSER:()=>Ab,IS_IE:()=>NN,IS_IE8:()=>TN,IS_IOS:()=>gN,IS_IOS_13_OR_14:()=>Tb,IS_IOS_15_1:()=>_b,IS_IOS_CHROME:()=>ub,IS_IPAD:()=>nN,IS_IPADQQB:()=>JN,IS_IPAD_PRO:()=>rN,IS_IPHONE:()=>sN,IS_IPOD:()=>aN,IS_LINUX:()=>jN,IS_LOCAL:()=>bb,IS_MAC:()=>VN,IS_MACQQB:()=>PN,IS_MIBROWSER:()=>XN,IS_MQQB:()=>UN,IS_NATIVE_ANDROID:()=>EN,IS_OLD_ANDROID:()=>uN,IS_OPENHARMONY:()=>cb,IS_OPPOBROWSER:()=>rb,IS_SAFARI:()=>fb,IS_SAFARI_15_1:()=>Rb,IS_SAMSUNGBROWSER:()=>ob,IS_SOGOU:()=>vN,IS_SOGOUM:()=>yN,IS_TBS:()=>SN,IS_UCBROWSER:()=>zN,IS_VIVOBROWSER:()=>ab,IS_WECHAT:()=>GN,IS_WIN:()=>qN,IS_WQQB:()=>ON,IS_WX:()=>WN,IS_X5MQQB:()=>LN,IS_XWEB:()=>RN,MACQQB_VERSION:()=>YN,MI_VERSION:()=>$N,MQQB_VERSION:()=>FN,OPENHARMONY_VERSION:()=>lb,OPPO_VERSION:()=>sb,SAFARI_VERSION:()=>yb,SAMSUNG_VERSION:()=>nb,SOGOUM_VERSION:()=>DN,SOGOU_VERSION:()=>wN,TBS_VERSION:()=>MN,UA_DATA_STRING:()=>Ob,USER_AGENT:()=>$T,VIVO_VERSION:()=>gb,WECHAT_VERSION:()=>kN,WQQB_VERSION:()=>xN,XWEB_VERSION:()=>_N,browserInfo:()=>kb,getBrowserCoreNumber:()=>Zb,getBrowserInfo:()=>Lb,getChromeMajorVersion:()=>Ib,getDeviceModel:()=>Vb,getDeviceModelFromUA:()=>jb,getGPUInfo:()=>Yb,getOSName:()=>Wb,getOSNumber:()=>zb,getOSString:()=>Xb,getOSType:()=>AG,getTerminalType:()=>$b,getUserAgentData:()=>xb,isAMDGPU:()=>Jb,isAppleSiliconGPU:()=>qb,isLocalStorageEnabled:()=>Gb,isMobile:()=>Fb,isNvidiaGPU:()=>Hb,isRealIOS:()=>cN,isVersionLargerThan:()=>Sb,isVersionSmallerThan:()=>wb});var $T="undefined"==typeof navigator?"":navigator.userAgent,AN=A=>new RegExp(A,"i").test($T),eN=A=>{if(AN(A)){let e=new RegExp("".concat(A,"\\/([\\d.]+)")),t=$T.match(e);if(t&&t[1])return t[1]}return""},tN=A=>{if(AN(A)){let e=new RegExp("".concat(A,"\\/(\\d+)")),t=$T.match(e);if(t&&t[1])return parseFloat(t[1])}return NaN},iN=/AppleWebKit\/([\d.]+)/i.exec($T),oN=iN?parseFloat(iN[1]):NaN,nN=AN("iPad"),rN="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&AN("Macintosh"),sN=AN("iPhone")&&!nN,aN=AN("iPod"),gN=sN||nN||aN||rN,cN=()=>{try{return gN&&navigator.maxTouchPoints>1&&navigator.vendor.includes("Apple")}catch(Gd){return gN}},lN=AN("Android"),IN=function(){if(lN){let A=$T.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(A){let e=A[1]&&parseFloat(A[1]),t=A[2]&&parseFloat(A[2]);if(e&&t)return parseFloat("".concat(A[1],".").concat(A[2]));if(e)return e}}return NaN}(),uN=lN&&AN("webkit")&&IN<2.3,EN=lN&&IN<5&&oN<537,dN=AN("Firefox"),hN=eN("Firefox"),CN=tN("Firefox"),BN=AN("Edge"),QN=eN("Edge"),pN=AN("Edg"),fN=eN("Edg"),mN=tN("Edg"),yN=AN("SogouMobileBrowser"),DN=eN("SogouMobileBrowser"),vN=AN("MetaSr\\s"),wN=eN("MetaSr\\s"),SN=AN("TBS"),MN=eN("TBS"),RN=AN("XWEB"),_N=eN("XWEB"),TN=AN("MSIE\\s8\\.0"),NN=AN("MSIE\\/\\d+"),bN=function(){if(NN){let A=/MSIE\s(\d+)\.\d/.exec($T),e=A&&parseFloat(A[1]);return!e&&/Trident\/7.0/i.test($T)&&/rv:11.0/.test($T)&&(e=11),e}return NaN}(),GN=AN("(micromessenger|webbrowser)"),kN=eN("MicroMessenger"),LN=!SN&&AN("MQQBrowser")&&AN("COVC"),UN=!SN&&AN("MQQBrowser")&&!AN("COVC"),FN=UN||LN?eN("MQQBrowser"):"",ON=!SN&&AN(" QQBrowser"),xN=eN(" QQBrowser"),PN=!SN&&AN("QQBrowserLite"),YN=eN("QQBrowserLite"),JN=!SN&&AN("MQBHD"),HN=eN("MQBHD"),qN=AN("Windows"),VN=!gN&&AN("MAC OS X"),jN=!lN&&AN("Linux"),KN=AN("CrOS"),WN=AN("MicroMessenger"),zN=AN("UCBrowser"),ZN=AN("Electron"),XN=AN("MiuiBrowser"),$N=eN("MiuiBrowser"),Ab=AN("HuaweiBrowser"),eb=AN("Huawei")||AN("HUAWEI"),tb=AN("Honor")||AN("HONOR"),ib=eN("HuaweiBrowser"),ob=AN("SamsungBrowser"),nb=eN("SamsungBrowser"),rb=AN("HeyTapBrowser"),sb=eN("HeyTapBrowser"),ab=AN("VivoBrowser"),gb=eN("VivoBrowser"),cb=AN("OpenHarmony"),lb=eN("OpenHarmony"),Ib=()=>tN("Chrome"),ub=AN("CriOS"),Eb=AN("Chrome"),db=!BN&&!vN&&!yN&&!SN&&!RN&&!pN&&!ON&&!XN&&!Ab&&!ob&&!rb&&!ab&&Eb,hb=AN("HeadlessChrome"),Cb=Ib(),Bb=Eb&&Cb>=128&&Cb<=143,Qb=eN("Chrome"),pb=tN("Electron"),fb=!Eb&&!UN&&!LN&&!PN&&!JN&&AN("Safari"),mb=fb||gN,yb=eN("Version"),Db=/Android.*(wv|.0.0.0)/.test($T),vb=(()=>{if(rN)return yb;if(gN){let A=$T.match(/OS (\d+)_(\d+)/i);if(A&&A[1]){let e=A[1];return A[2]&&(e+=".".concat(A[2])),e}}return""})();function wb(A,e){let t=A.split(".").map(A=>Number(A)),i=e.split(".").map(A=>Number(A));for(let o=0;oe)return!1}return!1}function Sb(A,e){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=A.split(".").map(A=>Number(A)),o=e.split(".").map(A=>Number(A));for(let n=0;ne)return!0;if(A{let A=Number(vb.split(".")[0]);return 14===A||13===A})(),Nb=ub&&"11.1.1"===yb,bb="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Gb=(()=>{let A;return()=>{if(void 0===A)try{A=!!window.localStorage}catch(e){A=!1}return A}})(),kb=Lb();function Lb(){let A=new Map([[dN,["Firefox",hN]],[pN,["Edg",fN]],[db,["Chrome",Qb]],[ub,["ChiOS",eN("CriOS")]],[fb&&!ub,["Safari",yb]],[SN,["TBS",MN]],[RN,["XWEB",_N]],[GN&&sN,["WeChat",kN]],[ON,["QQ(Win)",xN]],[UN,["QQ(Mobile)",FN]],[LN,["QQ(Mobile X5)",FN]],[PN,["QQ(Mac)",YN]],[JN,["QQ(iPad)",HN]],[XN,["MI",$N]],[Ab,["HW",ib]],[ob,["Samsung",nb]],[rb,["OPPO",sb]],[ab,["VIVO",gb]],[BN,["EDGE",QN]],[yN,["SogouMobile",DN]],[vN,["Sogou",wN]]]),e="unknown",t="unknown";return A.has(!0)&&([e,t]=A.get(!0)),{name:e,version:t}}var Ub=null;function Fb(){return Ub&&"boolean"==typeof Ub.mobile?Ub.mobile:lN||gN||sN||nN||cb}var Ob="";function xb(){return VS(this,null,function*(){if(Ub)return Ub;if(!navigator.userAgentData||"function"!=typeof navigator.userAgentData.getHighEntropyValues)return null;try{return(Ub=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]))&&!Ob&&(Ob="UAData: ".concat(Ub.platform,"/").concat(Ub.platformVersion),Ub.architecture&&Ub.bitness&&(Ob+=" ".concat(Ub.architecture,"/").concat(Ub.bitness)),Ub.mobile&&(Ob+=" mobile"),Ub.model&&(Ob+=" model: ".concat(Ub.model.replace(/\s+/g,"/"))),Ub.fullVersionList&&(Ob+=" ".concat(Ub.fullVersionList.filter(A=>"Not/A)Brand"!==A.brand).map(A=>"".concat(A.brand,"/").concat(A.version)).join(",")))),Ub}catch(Gd){return null}})}var Pb="";function Yb(){try{if(Pb)return Pb;let A=document.createElement("canvas"),e=A.getContext("webgl")||A.getContext("experimental-webgl");if(!e)return"";let t=e.getExtension("WEBGL_debug_renderer_info");if(t){let A=e.getParameter(t.UNMASKED_VENDOR_WEBGL),i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);return Pb="".concat(A," ").concat(i)}return""}catch(Gd){return""}}function Jb(){try{let A=Yb();return A.includes("AMD")||A.includes("ATI")}catch(Gd){return!1}}function Hb(){try{let A=Yb();return A.includes("NVIDIA")||A.includes("GeForce")}catch(Gd){return!1}}function qb(){try{return Yb().includes("Apple M")}catch(Gd){return!1}}function Vb(){return(null==Ub?void 0:Ub.model)||jb()||""}function jb(){let A=$T.match(/;\s*([^;)]+)\s+Build\//);return null!=A&&A[1]?A[1].trim():null}var Kb=new Map([[lN,"Android"],[gN,"iOS"],[qN,"Windows"],[VN,"MacOS"],[jN,"Linux"],[KN,"ChromeOS"]]),Wb=function(){return Kb.get(!0)?Kb.get(!0):Ub?Ub.platform:"unknown"};function zb(){return qN?1:lN?2:VN?3:gN?4:jN?5:KN?6:cb?7:0}function Zb(){return GN||RN?4:Eb?1:fb?2:dN?3:0}var Xb=()=>{let A=Wb();return null!=Ub&&Ub.platformVersion?A+="/".concat(Ub.platformVersion):gN?A+="/".concat(vb):lN&&(A+="/".concat(IN)),A+="/".concat(kb.name,"/").concat(fb&&!ub?kb.version:kb.version.split(".")[0]),null!=Ub&&Ub.architecture&&(A+="/".concat(Ub.architecture)),A};function $b(){return lN?4:sN?2:nN?3:VN?12:qN?5:jN?13:cb?22:1}function AG(){return lN?"Android":sN?"iPhone":nN?"iPad":VN?"Mac":qN?"Windows":jN?"Linux":"unknown"}var eG,tG=new(YS(jS(),1).default),iG=((eG=iG||{}).ROOM_DESTROY="1",eG.JOIN_START="21",eG.JOIN_SCHEDULE_SUCCESS="22",eG.JOIN_SIGNAL_CONNECTION_START="23",eG.JOIN_SIGNAL_CONNECTION_END="24",eG.JOIN_SEND_CMD="25",eG.JOIN_RECEIVED_CMD_RES="26",eG.JOIN_SUCCESS="27",eG.JOIN_FAILED="28",eG.LEAVE_START="51",eG.LEAVE_SEND_CMD="52",eG.LEAVE_SUCCESS="53",eG.PUBLISH_START="61",eG.SEND_FIRST_VIDEO_FRAME="62",eG.PUBLISH_FAILED="63",eG.SUBSCRIBE_START="81",eG.SUBSCRIBE_SUCCESS="82",eG.SUBSCRIBE_FAILED="84",eG.UNSUBSCRIBE_SUCCESS="83",eG.LOCAL_TRACK_CAPTURE_START="101",eG.LOCAL_TRACK_CAPTURE_SUCCESS="102",eG.LOCAL_TRACK_CAPTURE_FAILED="103",eG.LOCAL_TRACK_PUBLISHED="104",eG.LOCAL_TRACK_UNPUBLISHED="105",eG.LOCAL_TRACK_REPLACED="106",eG.SWITCH_DEVICE_SUCCESS="107",eG.TRACK_MUTED="108",eG.TRACK_UNMUTED="109",eG.REMOTE_TRACK_SUBSCRIBED="110",eG.REMOTE_TRACK_UNSUBSCRIBED="111",eG.LOCAL_TRACK_RECAPTURE="112",eG.LOCAL_AUDIO_STARTED="113",eG.LOCAL_AUDIO_STOPPED="114",eG.REMOTE_AUDIO_STARTED="115",eG.REMOTE_AUDIO_STOPPED="116",eG.PLAY_TRACK_START="151",eG.PLAYER_STATE_CHANGED="152",eG.VIDEO_LOADED_DATA="153",eG.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",eG.AUDIO_CONTEXT_LONG_SUSPENDED="155",eG.REMOTE_VIDEO_PLAY_START="156",eG.REMOTE_VIDEO_PLAY_FINISH="157",eG.SIGNAL_CONNECTION_STATE_CHANGED="201",eG.PEER_CONNECTION_STATE_CHANGED="202",eG.SINGLE_CONNECTION_STAT="203",eG.SPC_RECONNECTED="204",eG.HEARTBEAT_REPORT="251",eG.RECEIVED_PUBLISHED_USER_LIST="252",eG.REMOTE_PUBLISH_STATE_CHANGED="253",eG.AUDIO_LEVEL_INTERVAL="260",eG.NETWORK_QUALITY="261",eG.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",eG.QUALITY_LIMITATION_CHANGED="263",eG.LOG="264",eG.AUDIO_PROCESSOR_DEBUG="265",eG.SSO_SWITCH="266",eG.SEI_MESSAGE="267",eG.USER_PAUSE_IN_PIP="268",eG.USER_RESUME_IN_PIP="269",eG.ENTER_PICTURE_IN_PICTURE="270",eG.LEAVE_PICTURE_IN_PICTURE="271",eG.SWITCH_ROOM_START="401",eG.SWITCH_ROOM_SUCCESS="407",eG.SWITCH_ROOM_FAILED="408",eG),oG=iG,nG=new class{constructor(){HS(this,"enable",!1),HS(this,"ssoFailCount",0),tG.on("22",A=>{let{schedule:e}=A;var t;null!=(t=null==e?void 0:e.config)&&t.sso&&tG.emit("266",{enable:!0})}),tG.on("266",A=>{let{enable:e}=A;this.enable=e})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&tG.emit("266",{enable:!1})}},rG=class A{constructor(){HS(this,"_isEnableUploadLog",!0),HS(this,"_localJoinedUser",new Map),HS(this,"_queue",[]),HS(this,"_timeoutId",-1),HS(this,"_logLevel",1),HS(this,"_logLevelToUpload",2),!fM&&!mM&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){tG.on(oG.JOIN_SCHEDULE_SUCCESS,A=>{let{schedule:e}=A;var t;null!=(t=null==e?void 0:e.config)&&t.logLevelToUpload&&OM[e.config.logLevelToUpload]&&(this._logLevelToUpload=e.config.logLevelToUpload)}),tG.on(oG.JOIN_START,A=>{let{params:e}=A;this.addJoinedUser({userId:e.userId,sdkAppId:e.sdkAppId}),this.startUpload()}),tG.on(oG.LEAVE_SUCCESS,A=>{let{room:e}=A;this.deleteJoinedUser(e.userId)})}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(A){this._localJoinedUser.set(A.userId,A),this.startUpload()}deleteJoinedUser(A){this._localJoinedUser.delete(A)}uploadInterval(){this.upload().catch(()=>{}),this._timeoutId=window.setTimeout(()=>this.uploadInterval(),5e3)}getLogsToUpload(){let A={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return A;let e=0;for(;e{let{userId:i,sdkAppId:o}=e;A.map.has(i)?A.map.get(i).logs.push(t):A.map.set(i,{userId:i,sdkAppId:o,logs:[t]})});else if(q_(t.userId)&&V_(t.sdkAppId)){let{userId:e,sdkAppId:i}=t;A.map.has(e)?A.map.get(e).logs.push(t):A.map.set(e,{userId:e,sdkAppId:i,logs:[t]})}}return A.map.size>0&&(A.splicedQueue=this._queue.splice(0,e)),A}upload(){return VS(this,null,function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:A,splicedQueue:e}=this.getLogsToUpload();if(0===A.size)return;try{let e=[...A.values()];for(let A=0;AA.log).join("\n")},r=JSON.stringify(n),s=nG.enable?bT(n,2002,i):r;yield this.uploadLogWithRetry(s,i,s instanceof Uint8Array,r),o.forEach(A=>A.uploaded=!0)}}catch(i){}let t=e.filter(A=>!A.uploaded);t.length>0&&(this._queue=t.concat(this._queue))})}uploadLogWithRetry(A,e,t,i){return zT({retryFunction:()=>PT({url:D_(e,UM.LOG),body:A,timeout:5e3,priority:"low"}).then(A=>{t&&"ok"!==A.data&&(nG.handleUploadFailed(),this.uploadLogWithRetry(i,e,!1,i))}),settings:{retries:3,timeout:2e3},onError:A=>{let{retry:e}=A;e()}})()}getPrefix(A){let e=new Date;return e.setTime(lM()),"[".concat(uM(e),"] <").concat(OM[A],">")}getLogLevel(){return this._logLevel}setLogLevel(A){H_(OM[A])||(this._logLevel!==A&&this.info("setLogLevel",A),this._logLevel=A)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(A){if(q_(A))return A;try{return A instanceof Error?A.toString():JSON.stringify(A)}catch(e){return""}}addLogToQueue(A,e){let t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n={log:e.reduce((A,e)=>"".concat(A," ").concat(this.logChunkToString(e)).trim(),""),level:A,userId:i,sdkAppId:o,forAllJoinedClients:t};tG.emit(oG.LOG,{log:n}),this._isEnableUploadLog&&A>=this._logLevelToUpload&&this._queue.push(n)}log(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var r;if(t.unshift(this.getPrefix(e)),this.addLogToQueue(e,t,i,o,n),e{let e=16*Math.random()|0;return("x"==A?e:3&e|8).toString(16)})},gG=new class{constructor(){HS(this,"_prefix","TRTC"),HS(this,"_queue",new Map)}getRealKey(A){return"".concat(this._prefix,"_").concat(A)}checkStorage(){Gb()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter(A=>{if(A.startsWith(this._prefix))try{let e=localStorage.getItem(A);if(!e)return!1;let t=JSON.parse(e);if(t&&t.expiresInlocalStorage.removeItem(A)))}doFlush(){if(Gb())try{for(let[A,e]of this._queue)localStorage.setItem(A,JSON.stringify(e))}catch(A){sG.warn(A)}}getItem(A){if(!Gb())return null;try{let e=localStorage.getItem(this.getRealKey(A));if(!e)return null;let t=JSON.parse(e);return t&&t.expiresIn>=Date.now()?t.value:null}catch(e){sG.warn(e)}}setItem(A,e){if(Gb())try{let t={expiresIn:Date.now()+JM,value:e};this._queue.set(this.getRealKey(A),t)}catch(t){sG.warn(t)}}deleteItem(A){if(!Gb())return!1;try{return A=this.getRealKey(A),this._queue.delete(A),localStorage.removeItem(A),!0}catch(e){return sG.warn(e),!1}}clear(){if(Gb())try{localStorage.clear()}catch(A){sG.warn(A)}}},cG={};PS(cG,{HTTPS_API:()=>$k,IS_GET_CAPABILITIES_FROM_INPUTDEVICE_SUPPORTED:()=>fL,IS_GET_CAPABILITIES_SUPPORTED:()=>pL,IS_GET_SETTINGS_SUPPORTED:()=>QL,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>BL,IS_INSERTABLE_STREAM_SUPPORTED:()=>mL,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>kL,IS_RTC_RTP_SENDER_SUPPORTED:()=>dL,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>yL,IS_SEI_SUPPORTED:()=>DL,IS_SPC_SUPPORTED:()=>uL,basis:()=>_L,capabilityCheck:()=>bL,checkSystemRequirementsInternal:()=>jk,decodeSupportStatus:()=>Vk,detectVideoCodecCapabilities:()=>FL,detectVideoDecoderCapabilities:()=>xL,detectVideoEncoderCapabilities:()=>OL,encodeSupportStatus:()=>qk,getBrowserInfo:()=>Uk,getDisplayResolution:()=>eL,getH264ProfileLevelIds:()=>PL,isAddTransceiverSupported:()=>IL,isBrowserSupported:()=>Fk,isCanvasCaptureStreamAPISupported:()=>oL,isCanvasSmallStreamSupported:()=>nL,isGetReceiversSupported:()=>gL,isGetSendersSupported:()=>cL,isGetTransceiversSupported:()=>lL,isGetUserMediaSupported:()=>tL,isMediaDevicesSupported:()=>xk,isMediaSessionSupported:()=>SL,isMediaStreamTrackGeneratorSupported:()=>Hk,isMediaStreamTrackProcessorSupported:()=>Jk,isReplaceTrackSupported:()=>hL,isRequestVideoFrameCallbackSupported:()=>GL,isSIMDSupported:()=>RL,isScaleResolutionDownBySupported:()=>rL,isScreenCaptureApiAvailable:()=>Wk,isSelectedCandidatePair:()=>AL,isSetParametersSupported:()=>CL,isSetSinkIdSupported:()=>zk,isSmallStreamSupported:()=>sL,isStopTransceiverSupported:()=>EL,isTRTCSupported:()=>Kk,isUnifiedPlanDefault:()=>aL,isUsedInHttpProtocol:()=>Yk,isWebAudioSupported:()=>iL,isWebCodecSupported:()=>wL,isWebCodecsSupported:()=>Ok,isWebRTCSupported:()=>vL,isWebTransportSupported:()=>ML});var lG={};PS(lG,{AUDIO_LEVEL_SCALE:()=>ik,AlphaStitchingType:()=>Ck,AudioCodecPipelineType:()=>gk,AudioDecoderDowngradeState:()=>FG,AudioPlayerMode:()=>Ak,AudioType:()=>HG,BASIC_TYPE:()=>rk,BannedReason:()=>ek,CONNECTION_CLOSED_REASON:()=>vG,CheckPermissionType:()=>dk,ClientEvent:()=>wG,CodecType:()=>ck,ConnectionEvent:()=>DG,ConnectionState:()=>UG,DECODE_FAILED_ERROR_CODE:()=>lk,DenoiserMode:()=>ok,DeviceType:()=>hk,FacingMode:()=>XG,FrameWorkType:()=>yG,LeaveReason:()=>tk,LocalTrackEvent:()=>MG,MULTI_VIDEO_DATA_TYPE:()=>KG,MediaType:()=>YG,MediaTypeLabel:()=>JG,MonitorEventId:()=>WG,MutedFlag:()=>bG,NetworkQualityValue:()=>zG,PlayerState:()=>RG,ReceiveMode:()=>ZG,RemoteStreamType:()=>jG,RemoteTrackEvent:()=>NG,RoomEvent:()=>_G,SMALL_MODE:()=>Ek,SceneNumber:()=>GG,StreamEvent:()=>SG,StreamType:()=>VG,SubscribeMediaType:()=>nk,TIMER_TYPE:()=>uk,TRACK_ACTION:()=>PG,TRACK_KIND:()=>xG,TrackEvent:()=>TG,UserRole:()=>LG,UserRoleNumber:()=>kG,VideoCodec:()=>sk,VideoCodecPipelineType:()=>ak,VideoContentHint:()=>Ik,VideoDecoderDowngradeState:()=>OG,VideoPlayerMode:()=>$G,VideoType:()=>qG});var IG,uG,EG,dG,hG,CG,BG,QG,pG,fG,mG,yG=(A=>(A[A.WEBRTC=30]="WEBRTC",A[A.WASM=37]="WASM",A))(yG||{}),DG=((mG=DG||{}).TRACK_ADDED="track-added",mG.TRACK_UPDATED="track-updated",mG.TRACK_SUBSCRIBED="track-subscribed",mG.STREAM_ADDED="stream-added",mG.STREAM_REMOVED="stream-removed",mG.STREAM_UPDATED="stream-updated",mG.STREAM_PUBLISHED="stream-published",mG.STREAM_SUBSCRIBED="stream-subscribed",mG.STREAM_UNSUBSCRIBED="stream-unsubscribed",mG.STATE_CHANGED="state-changed",mG.ERROR="error",mG.CONNECTION_STATE_CHANGED="connection-state-changed",mG.FIREWALL_RESTRICTION="firewall-restriction",mG.SEI_MESSAGE="sei-message",mG.CLOSED="closed",mG),vG=(A=>(A.REMOTE_LEAVE="remote user exitRoom",A.REMOTE_UNPUBLISH="remote user unpublished",A.LOCAL_LEAVE="you exitRoom",A.LOCAL_UNPUBLISH="you unpublished",A.LOCAL_UNSUBSCRIBE="you unsubscribed",A.SWITCH_ROLE="you switch role to audience",A))(vG||{}),wG=((fG=wG||{}).STREAM_ADDED="stream-added",fG.STREAM_REMOVED="stream-removed",fG.STREAM_UPDATED="stream-updated",fG.STREAM_SUBSCRIBED="stream-subscribed",fG.CONNECTION_STATE_CHANGED="connection-state-changed",fG.PEER_JOIN="peer-join",fG.PEER_LEAVE="peer-leave",fG.MUTE_AUDIO="mute-audio",fG.MUTE_VIDEO="mute-video",fG.UNMUTE_AUDIO="unmute-audio",fG.UNMUTE_VIDEO="unmute-video",fG.CLIENT_BANNED="client-banned",fG.NETWORK_QUALITY="network-quality",fG.AUDIO_VOLUME="audio-volume",fG.SEI_MESSAGE="sei-message",fG.ERROR="error",fG),SG=((pG=SG||{}).PLAYER_STATE_CHANGED="player-state-changed",pG.SCREEN_SHARING_STOPPED="screen-sharing-stopped",pG.CONNECTION_STATE_CHANGED="connection-state-changed",pG.DEVICE_AUTO_RECOVERED="device-auto-recovered",pG.ERROR="error",pG),MG=((QG=MG||{}).DEVICE_AUTO_RECOVERED="1",QG.DEVICE_RECOVER_FAILED="5",QG.DEVICE_CHANGED="2",QG.ERROR="3",QG.PUBLISH_STATE_CHANGED="4",QG.ENCODE_FAILED="6",QG.TRACK_ENDED="7",QG.RENDER="render",QG),RG=(A=>(A.PAUSED="PAUSED",A.PLAYING="PLAYING",A.STOPPED="STOPPED",A))(RG||{}),_G=((BG=_G||{}).PEER_JOIN="peer-join",BG.PEER_LEAVE="peer-leave",BG.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",BG.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",BG.BANNED="banned",BG.NETWORK_QUALITY="network-quality",BG.AUDIO_VOLUME="audio-volume",BG.SEI_MESSAGE="sei-message",BG.ERROR="error",BG.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",BG.REMOTE_PUBLISHED="remote-published",BG.REMOTE_UNPUBLISHED="remote-unpublished",BG.FIREWALL_RESTRICTION="firewall-restriction",BG.HEARTBEAT_REPORT="heartbeat-report",BG.CUSTOM_MESSAGE="custom-message",BG.LAYER_DATA="layerData",BG.FIRST_VIDEO_FRAME="first-video-frame",BG.DUMP="dump",BG.AUDIO_FRAME="audio-frame",BG.SUBSCRIBE_SMALL_VIDEO_CHANGED="subscribe-small-video-changed",BG.LOCAL_PUBLISH_FLAG_CHANGED="local-publish-flag-changed",BG.NTP_TIME_UPDATED="ntp-time-updated",BG.DATA_CHANNEL_MESSAGE="data-channel-message",BG.ASR_ROBOT_PEER_JOIN="asr-robot-peer-join",BG.ASR_ROBOT_PEER_LEAVE="asr-robot-peer-leave",BG),TG=(A=>(A.PLAYER_STATE_CHANGED="player-state-changed",A.MUTE="mute",A.UNMUTE="unmute",A.ERROR="error",A.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",A.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",A.FIRST_VIDEO_FRAME="first-video-frame",A.VIDEO_SIZE_CHANGED="video-size-changed",A))(TG||{}),NG=(A=>(A.DECODE_FAILED="decode-failed",A.DECODE_FAILED_DURING_CALL="decode-failed-during-call",A.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",A.REMOTE_PUBLISH_CHANGED="remote-publish-changed",A.AUDIO_FRAME_WITH_NTP="audio-frame-with-ntp",A))(NG||{}),bG=((CG=bG||{})[CG.VIDEO=1]="VIDEO",CG[CG.SMALL=2]="SMALL",CG[CG.AUX=4]="AUX",CG[CG.AUDIO=8]="AUDIO",CG[CG.VIDEO_MUTE=16]="VIDEO_MUTE",CG[CG.AUX_MUTE=32]="AUX_MUTE",CG[CG.AUDIO_MUTE=64]="AUDIO_MUTE",CG),GG=(A=>(A[A.RTC=1]="RTC",A[A.LIVE=2]="LIVE",A))(GG||{}),kG=(A=>(A[A.ANCHOR=20]="ANCHOR",A[A.AUDIENCE=21]="AUDIENCE",A))(kG||{}),LG=(A=>(A.ANCHOR="anchor",A.AUDIENCE="audience",A))(LG||{}),UG=(A=>(A.CONNECTED="CONNECTED",A.DISCONNECTED="DISCONNECTED",A.CONNECTING="CONNECTING",A.RECONNECTED="RECONNECTED",A.RECONNECTING="RECONNECTING",A))(UG||{}),FG=((hG=FG||{}).INITIALIZED="INITIALIZED",hG.STARTING="STARTING",hG.STARTED="STARTED",hG.FAILED="FAILED",hG),OG=(A=>(A.INITIALIZED="INITIALIZED",A.STARTING="STARTING",A.STARTED="STARTED",A.FAILED="FAILED",A))(OG||{}),xG=(A=>(A.AUDIO="audio",A.VIDEO="video",A.AUXILIARY="auxVideo",A))(xG||{}),PG=(A=>(A.ADD="add",A.REMOVE="remove",A))(PG||{}),YG=(A=>(A[A.NULL=0]="NULL",A[A.AUDIO=1]="AUDIO",A[A.AUX_VIDEO=2]="AUX_VIDEO",A[A.BIG_VIDEO=4]="BIG_VIDEO",A[A.SMALL_VIDEO=8]="SMALL_VIDEO",A))(YG||{}),JG={1:"audio",2:"auxVideo",4:"video"},HG=((dG=HG||{})[dG.opus=111]="opus",dG),qG=(A=>(A[A.h264=100]="h264",A[A.vp8=101]="vp8",A))(qG||{}),VG=(A=>(A.Big="big",A.Small="small",A))(VG||{}),jG=(A=>(A.Main="main",A.Aux="auxiliary",A))(jG||{}),KG=(A=>(A[A.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",A[A.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",A[A.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",A[A.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",A[A.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",A))(KG||{}),WG=((EG=WG||{})[EG.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",EG[EG.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",EG[EG.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",EG[EG.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",EG[EG.MUTE_AUDIO=32772]="MUTE_AUDIO",EG[EG.MUTE_VIDEO=32773]="MUTE_VIDEO",EG[EG.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",EG[EG.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",EG[EG.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",EG[EG.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",EG[EG.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",EG[EG.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",EG[EG.SWITCH_CAMERA=32780]="SWITCH_CAMERA",EG[EG.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",EG[EG.REPLACE_VIDEO=32782]="REPLACE_VIDEO",EG[EG.REPLACE_AUDIO=32783]="REPLACE_AUDIO",EG[EG.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",EG[EG.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",EG[EG.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",EG[EG.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",EG[EG.JOIN=32788]="JOIN",EG[EG.LEAVE=32789]="LEAVE",EG[EG.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",EG[EG.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",EG[EG.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",EG[EG.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",EG[EG.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",EG[EG.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",EG[EG.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",EG[EG.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",EG[EG.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",EG[EG.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",EG[EG.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",EG[EG.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",EG[EG.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",EG[EG.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",EG[EG.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",EG[EG.PUBLISH_AUX=32805]="PUBLISH_AUX",EG[EG.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",EG[EG.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",EG[EG.VIDEO_ENCODER=4004]="VIDEO_ENCODER",EG[EG.VIDEO_DECODER=4005]="VIDEO_DECODER",EG),zG=(A=>(A[A.UNKNOWN=0]="UNKNOWN",A[A.EXCELLENT=1]="EXCELLENT",A[A.GOOD=2]="GOOD",A[A.POOR=3]="POOR",A[A.BAD=4]="BAD",A[A.VERY_BAD=5]="VERY_BAD",A[A.DISCONNECTED=6]="DISCONNECTED",A))(zG||{}),ZG=(A=>(A[A.MANUAL=0]="MANUAL",A[A.AUTO_AUDIO=1]="AUTO_AUDIO",A[A.AUTO_VIDEO=2]="AUTO_VIDEO",A[A.AUTO_ALL=3]="AUTO_ALL",A))(ZG||{}),XG=(A=>(A.user="user",A.environment="environment",A))(XG||{}),$G=(A=>(A[A.ELEMENT=0]="ELEMENT",A[A.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",A[A.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",A))($G||{}),Ak=(A=>(A[A.ELEMENT=0]="ELEMENT",A[A.CONTEXT=1]="CONTEXT",A))(Ak||{}),ek=(A=>(A.BANNED="banned",A.KICK="kick",A.USER_TIME_OUT="user_time_out",A.ROOM_DISBAND="room_disband",A))(ek||{}),tk=((uG=tk||{})[uG.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",uG[uG.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",uG[uG.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",uG[uG.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",uG[uG.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",uG[uG.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",uG[uG.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",uG[uG.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",uG[uG.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",uG),ik=1e8,ok=(A=>(A[A.NORMAL=0]="NORMAL",A[A.FAR_FIELD_REDUCTION=1]="FAR_FIELD_REDUCTION",A))(ok||{}),nk=class{constructor(){HS(this,"mediaType",0)}set audio(A){A?this.mediaType|=1:this.mediaType&=-2}get audio(){return!!(1&this.mediaType)}set video(A){A?this.mediaType|=4:this.mediaType&=-5}get video(){return!!(4&this.mediaType)}set auxiliary(A){A?this.mediaType|=2:this.mediaType&=-3}get auxiliary(){return!!(2&this.mediaType)}set smallVideo(A){A?this.mediaType|=8:this.mediaType&=-9}get smallVideo(){return!!(8&this.mediaType)}},rk=(A=>(A.String="string",A.Number="number",A.Boolean="boolean",A.Array="array",A.Object="object",A))(rk||{}),sk=(A=>(A.H264="h264",A.H265="h265",A.VP8="vp8",A.VP9="vp9",A.AV1="av1",A))(sk||{}),ak=(A=>(A[A.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",A[A.DUMP=1]="DUMP",A[A.SEI=2]="SEI",A[A.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",A))(ak||{}),gk=(A=>(A[A.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",A[A.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",A[A.DUMP=2]="DUMP",A[A.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",A))(gk||{}),ck=(A=>(A.WebRTC="webrtc",A.WebCodecs="webcodecs",A.WebAssembly="webassembly",A))(ck||{}),lk=((IG=lk||{})[IG.SUCCESS=0]="SUCCESS",IG[IG.FAILED=1]="FAILED",IG[IG.WEBCODEC_INIT=2]="WEBCODEC_INIT",IG[IG.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",IG[IG.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",IG[IG.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",IG[IG.WASM_INIT=6]="WASM_INIT",IG[IG.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",IG[IG.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",IG[IG.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",IG[IG.TEST=10]="TEST",IG[IG.RENDER_2D_ERROR=11]="RENDER_2D_ERROR",IG),Ik=(A=>(A.NONE="",A.DETAIL="detail",A.MOTION="motion",A.TEXT="text",A))(Ik||{}),uk=(A=>(A.INTERVAL="interval",A.TIMEOUT="timeout",A.RAF="raf",A.RIC="ric",A.INTERVAL_IN_WORKER="intervalInWorker",A))(uk||{}),Ek=(A=>(A.CANVAS="canvas",A.API="api",A))(Ek||{}),dk=(A=>(A[A.NONE=0]="NONE",A[A.MICROPHONE=1]="MICROPHONE",A[A.CAMERA=2]="CAMERA",A[A.BOTH=3]="BOTH",A))(dk||{}),hk=(A=>(A.CAMERA="camera",A.MICROPHONE="microphone",A))(hk||{}),Ck=(A=>(A[A.none=0]="none",A[A.horizontal=1]="horizontal",A[A.vertical=2]="vertical",A))(Ck||{}),Bk={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},Qk={AVOID_REPEATED_CALL:A=>"previous ".concat(A.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(A){let{key:e,rule:t,fnName:i,value:o}=A,n="".concat(e||t.name),r="";return r=Array.isArray(t.type)?t.type.join("|"):t.type,"'".concat(n,"' must be type of ").concat(r," when calling ").concat(i,"(), received type: ").concat(Y_(o),".")},INVALID_PARAMETER_EMPTY(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(A){let{key:e,rule:t,fnName:i,value:o}=A,n="".concat(e||t.name),r="".concat(t.instanceOf.name||t.instanceOf);return"'".concat(n,"' must be instanceof ").concat(r," when calling ").concat(i,"(), received type: ").concat(Y_(o),".")},INVALID_PARAMETER_RANGE(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' must be one of ").concat(t.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_MIN(A){let{key:e,rule:t,fnName:i,value:o}=A;return"the min value of ".concat(e||t.name," is ").concat(t.min,", received: ").concat(o,".")},INVALID_PARAMETER_MAX(A){let{key:e,rule:t,fnName:i,value:o}=A;return"the max value of ".concat(e||t.name," is ").concat(t.max,", received: ").concat(o,".")},API_CALL_TIMEOUT:A=>"".concat(A.commandDesc||A.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:A=>"SignalChannel setup failure: (errorCode: ".concat(A.errorCode,", errorMsg: ").concat(A.errorMsg," })."),ERROR_MESSAGE(A){let e="".concat(A.type," failed");return A.message&&(e="".concat(e,": ").concat(A.message,".")),e},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:A=>"exchange sdp failed ".concat(A.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:A=>"'".concat(A,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:A=>"'".concat(A,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(A){let{error:e,code:t}=A;return"Failed to join room - ".concat(e," code: ").concat(t)},REJOIN_ROOM_FAILED:A=>"reJoin room: ".concat(A.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:A=>"duplicate ".concat(A," stream publishing, please unpublish your prev ").concat(A," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(A){let{message:e,userId:t,streamType:i}=A;return"failed to subscribe ".concat(t," ").concat(i," stream, reason: ").concat(e,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:A=>"switchRole failed, errCode: ".concat(A.code," errMsg: ").concat(A.message,"."),CLIENT_BANNED:A=>"client was banned because of ".concat(A.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:A=>"startPublishCDNStream failed, errMsg: ".concat(A.message,"."),STOP_PUBLISH_CDN_FAILED:A=>"stopPublishCDNStream failed, errMsg: ".concat(A.message,"."),INVALID_STREAM_ID:A=>"'".concat(A,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:A=>"cannot replace ".concat(A.kind," track because stream has not ").concat(A.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:A=>"startMixTranscode failed, errMsg: ".concat(A.message,"."),STOP_MIX_TRANSCODE_FAILED:A=>"stopMixTranscode failed, errMsg: ".concat(A.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' cannot be less than 0 when calling ").concat(i,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:A=>"'".concat(A,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:A=>{let{key:e,fnName:t}=A;return"'".concat(e,"' is not found in the document object when calling ").concat(t,"().")},INVALID_ELEMENT_ID_TYPE:A=>{let{key:e,fnName:t,type:i}=A;return"the element corresponding to '".concat(e,"' must be instanceof HTMLElement when calling ").concat(t,"(), received: ").concat(i,".")},PLAY_FAILED:A=>"".concat(A.media," play failed, browser exception: ").concat(A.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:A=>"".concat(A,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:A=>"".concat(A.signalResponse," failed, response code is ").concat(A.code," , errMsg: ").concat(A.message,"."),CATCH_HANDLER_ERROR(A){let{name:e,event:t}=A;return"an error was caught in ".concat(e,".on('").concat(t,"', handler), please check your code in 'handler'.")},API_NOT_EXIST(A){let{name:e}=A;return"experimental api ".concat(e," does not exist.")},REPEAT_JOIN:A=>"please avoid repeated join.",CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(A){let{funName:e}=A;return"failed to call ".concat(e,"() because client was destroyed.")},SEI_NOT_SUPPORT:A=>"not support to sendSEIMessage".concat(!1===A?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:A=>{let{isSize:e,name:t,timesInSecond:i,maxSizeInSecond:o}=A;return"api ".concat(t," call ").concat(e?"size":"times"," is over ").concat(e?"".concat(o," bytes"):i," in a second.")},CONNECTION_ABORTED:A=>"connection aborted due to: ".concat(A),API_CALL_ABORTED(A){let e;return e=A.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(A.userId," ").concat(A.streamType," stream aborted, reason: remote user ").concat(A.userId," unpublished stream."):"API aborted, reason: ".concat(A.message),e},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:A=>"'streamType' is required when 'userId' is not '*', calling ".concat(A,"()")},pk=(A,e)=>e?"".concat(_M,"/").concat(A,"/").concat(e):"".concat(_M,"/").concat(A,"/index.html"),fk=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let A=null==localStorage?void 0:localStorage.getItem(LM);if(A){A=JSON.parse(A);let e=document.createElement("script");e.type="text/javascript",e.text=A.message,document.body.appendChild(e);let t=window.TRTC_ERROR_INFO,i=window.TRTC_ERROR_LINK;return document.body.removeChild(e),{TRTC_ERROR_INFO:t,TRTC_ERROR_LINK:i}}return{}};function mk(A){let{key:e,data:t,link:i,addDocLink:o=!0}=A,n="",r="",s="";J_(Qk[e])?n=Qk[e](t):q_(Qk[e])&&(n=Qk[e]);let{TRTC_ERROR_INFO:a,TRTC_ERROR_LINK:g}=fk();i?s="".concat(i.className,".html#").concat(i.fnName):g&&g[e]&&(J_(g[e])?s=g[e](t):q_(g[e])&&(s=g[e]));let c=n;return F_()&&(a&&a[e]&&(J_(a[e])?r=a[e](t):q_(a[e])&&(r=a[e])),r&&(c=o?"".concat(r,"\n请查看文档: ").concat(pk("zh-cn",s),"\n\n"):"".concat(r,"\n\n"),c+=n)),o&&(c+=" \nRefer to: ".concat(pk("en",s),"\n")),c}var yk,Dk,vk=YS(ZS(),1),wk=class{constructor(){let A=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];HS(this,"countMap",new Map),HS(this,"distributionMap",new Map),HS(this,"version"),HS(this,"log",sG.createLogger({id:"kv"})),A&&(tG.on("102",A=>{let{track:e,cost:t}=A;this.addSuccessEvent({key:e.kind===WM.AUDIO?501700:511700,cost:t})}),tG.on("103",A=>{let{track:e,error:t}=A;this.addFailedEvent({key:e.kind===WM.AUDIO?501700:511700,error:t})}),tG.on("266",A=>{let{enable:e}=A;this.log.info("".concat(e?"enable":"disable"," sso")),e?this.addSuccessEvent({key:525701}):this.addFailedEvent({key:525701})}))}getReportData(A,e){let t={msg_sdk_basic_info:{uint32_sdk_version:mT(this.version||CM),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:[...this.countMap.entries()].map(A=>{let[e,t]=A;return{uint32_key:e,uint32_count:t}}),stats_distribution:[...this.distributionMap.entries()].map(A=>{let[e,t]=A;return{uint32_key:e,distribution_items:[...t.entries()].map(A=>{let[e,t]=A;return{uint32_item_key:e,uint32_item_value:t}})}}),str_user_sig:A,bytes_report_token:e};return this.countMap.clear(),this.distributionMap.clear(),t}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(A){let e=+String(A).slice(-3);return e>=700&&e<799}isErrorCodeKey(A){let e=+String(A).slice(-3);return e>=600&&e<699}isCountKey(A){let e=+String(A).slice(-3);return e>=0&&e<599}isNumberKey(A){let e=+String(A).slice(-3);return e>=800&&e<899}addCount(A){let{key:e,useUV:t=!1}=A;this.isCountKey(e)?t&&this.countMap.has(e)||this.countMap.set(e,(this.countMap.get(e)||0)+1):this.log.debug("".concat(e," is not count key, last 3 number should be 0~599"))}addEnum(A){let{key:e,value:t,useUV:i=!0}=A;var o;if(!this.isEnumKey(e))return this.log.debug("".concat(e," is not enum key, last 3 number should be 700~799"));if(i&&this.countMap.has(e))return;this.countMap.set(e,(this.countMap.get(e)||0)+1);let n=(null==(o=this.distributionMap)?void 0:o.get(e))||new Map;n.set(t,(n.get(t)||0)+1),this.distributionMap.set(e,n)}addNumber(A){let{key:e,value:t,split:i=100,useUV:o=!1,max:n=5e3}=A;var r;if(!this.isNumberKey(e))return this.log.debug("".concat(e," is not number key, last 3 number should be 800~899"));if(o&&this.countMap.has(e))return;t>n&&(t=n),this.countMap.set(e,(this.countMap.get(e)||0)+1);let s=(null==(r=this.distributionMap)?void 0:r.get(e))||new Map,a=0;if(V_(i))a=Math.floor(t/i);else for(let g=i.length-1;g>0;g--)if(t>i[g]){a=g;break}s.set(a,(s.get(a)||0)+1),this.distributionMap.set(e,s)}addSuccessEvent(A){let{key:e,cost:t,timeKey:i,split:o}=A;if(e&&(this.addEnum({key:e,value:1,useUV:!1}),t)){let A=+String(e).slice(-3);A<800&&A>=700?this.addNumber({key:i||e+100,value:t,split:o}):i||this.log.debug("time stat ignored, ".concat(e))}}addFailedEvent(A){let{key:e,error:t}=A;if(!e)return;let i=oM.UNKNOWN;t&&(V_(t)?i=t:(!H_(t.extraCode)||!H_(t.code))&&(i=t.extraCode||t.code)),this.addEnum({key:e,value:0,useUV:!1}),this.addEnum({key:e,value:Math.abs(i),useUV:!1})}},Sk=((yk=Sk||{})[yk.enterRoom=500700]="enterRoom",yk[yk.exitRoom=500701]="exitRoom",yk[yk.switchRole=500702]="switchRole",yk[yk.destroy=500703]="destroy",yk[yk.startLocalAudio=500704]="startLocalAudio",yk[yk.updateLocalAudio=500705]="updateLocalAudio",yk[yk.stopLocalAudio=500706]="stopLocalAudio",yk[yk.startLocalVideo=500707]="startLocalVideo",yk[yk.updateLocalVideo=500708]="updateLocalVideo",yk[yk.stopLocalVideo=500709]="stopLocalVideo",yk[yk.startScreenShare=500710]="startScreenShare",yk[yk.updateScreenShare=500711]="updateScreenShare",yk[yk.stopScreenShare=500712]="stopScreenShare",yk[yk.startRemoteVideo=500713]="startRemoteVideo",yk[yk.updateRemoteVideo=500714]="updateRemoteVideo",yk[yk.stopRemoteVideo=500715]="stopRemoteVideo",yk[yk.muteRemoteAudio=500716]="muteRemoteAudio",yk[yk.setRemoteAudioVolume=500717]="setRemoteAudioVolume",yk[yk.use=500718]="use",yk[yk.switchRoom=500719]="switchRoom",yk[yk.getPermissions=500720]="getPermissions",yk[yk.sendSEIMessage=5e5]="sendSEIMessage",yk[yk.sendCustomMessage=500001]="sendCustomMessage",yk),Mk=(A=>(A[A.AudioMixer=550700]="AudioMixer",A[A.AIDenoiser=551700]="AIDenoiser",A[A.VirtualBackground=570700]="VirtualBackground",A[A.Beauty=571700]="Beauty",A[A.Watermark=572700]="Watermark",A[A.BasicBeauty=574700]="BasicBeauty",A[A.FaceDetector=575700]="FaceDetector",A[A.CDNStreaming=590700]="CDNStreaming",A[A.DeviceDetector=591700]="DeviceDetector",A[A.Debug=592700]="Debug",A[A.SmallStreamAutoSwitcher=593700]="SmallStreamAutoSwitcher",A[A.VideoMixer=594700]="VideoMixer",A[A.AudioProcessor=595700]="AudioProcessor",A[A.LEBPlayer=596700]="LEBPlayer",A[A.RealtimeTranscriber=597700]="RealtimeTranscriber",A))(Mk||{}),Rk=(A=>(A[A.AudioMixer=550701]="AudioMixer",A[A.AIDenoiser=551701]="AIDenoiser",A[A.VirtualBackground=570701]="VirtualBackground",A[A.Beauty=571701]="Beauty",A[A.Watermark=572701]="Watermark",A[A.BasicBeauty=574701]="BasicBeauty",A[A.FaceDetector=575701]="FaceDetector",A[A.CDNStreaming=590701]="CDNStreaming",A[A.DeviceDetector=591701]="DeviceDetector",A[A.Debug=592701]="Debug",A[A.SmallStreamAutoSwitcher=593701]="SmallStreamAutoSwitcher",A[A.VideoMixer=594701]="VideoMixer",A[A.AudioProcessor=595701]="AudioProcessor",A[A.LEBPlayer=596701]="LEBPlayer",A[A.RealtimeTranscriber=597701]="RealtimeTranscriber",A))(Rk||{}),_k=(A=>(A[A.AudioMixer=550702]="AudioMixer",A[A.AIDenoiser=551702]="AIDenoiser",A[A.VirtualBackground=570702]="VirtualBackground",A[A.Beauty=571702]="Beauty",A[A.Watermark=572702]="Watermark",A[A.BasicBeauty=574702]="BasicBeauty",A[A.FaceDetector=575702]="FaceDetector",A[A.CDNStreaming=590702]="CDNStreaming",A[A.DeviceDetector=591702]="DeviceDetector",A[A.Debug=592702]="Debug",A[A.SmallStreamAutoSwitcher=593702]="SmallStreamAutoSwitcher",A[A.VideoMixer=594702]="VideoMixer",A[A.AudioProcessor=595702]="AudioProcessor",A[A.LEBPlayer=596702]="LEBPlayer",A[A.RealtimeTranscriber=597702]="RealtimeTranscriber",A))(_k||{}),Tk=((Dk=Tk||{})[Dk.DECODER_TYPE=514700]="DECODER_TYPE",Dk[Dk.DECODER_HW_SW=514701]="DECODER_HW_SW",Dk[Dk.DECODE_RESULT=514702]="DECODE_RESULT",Dk[Dk.DECODE_FAILED_OS=514703]="DECODE_FAILED_OS",Dk[Dk.DOWNGRADE_RESULT=514704]="DOWNGRADE_RESULT",Dk[Dk.DOWNGRADE_WEBCODECS_VIDEO=514705]="DOWNGRADE_WEBCODECS_VIDEO",Dk[Dk.DOWNGRADE_WEBCODECS_2D=514706]="DOWNGRADE_WEBCODECS_2D",Dk[Dk.DOWNGRADE_WASM_WEGBL=514707]="DOWNGRADE_WASM_WEGBL",Dk[Dk.DOWNGRADE_WASM_VIDEO=514708]="DOWNGRADE_WASM_VIDEO",Dk[Dk.DOWNGRADE_WASM_2D=514709]="DOWNGRADE_WASM_2D",Dk[Dk.DECODE_H264_RESULT=514710]="DECODE_H264_RESULT",Dk[Dk.DECODE_H265_RESULT=514711]="DECODE_H265_RESULT",Dk[Dk.DECODE_VP8_RESULT=514712]="DECODE_VP8_RESULT",Dk[Dk.DECODE_CAPABILITIES=514713]="DECODE_CAPABILITIES",Dk[Dk.H264_PROFILE_LEVEL_ID_HIGH=514714]="H264_PROFILE_LEVEL_ID_HIGH",Dk[Dk.H264_PROFILE_LEVEL_ID_MAIN=514715]="H264_PROFILE_LEVEL_ID_MAIN",Dk[Dk.RENDER_FREEZE_RATE=514850]="RENDER_FREEZE_RATE",Dk[Dk.DATA_FREEZE_RATE=514851]="DATA_FREEZE_RATE",Dk[Dk.VIDEO_CONSUME_RENDER_RATE=514852]="VIDEO_CONSUME_RENDER_RATE",Dk),Nk=new wk(!0),bk=new wk(!1),Gk=Nk,kk={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}},Lk=new Map([[dN,["Firefox",hN]],[pN,["Edg",fN]],[db,["Chrome",Qb]],[fb,["Safari",yb]],[SN,["TBS",MN]],[RN,["XWEB",_N]],[GN&&sN,["WeChat",kN]],[ON,["QQ(Win)",xN]],[UN,["QQ(Mobile)",FN]],[LN,["QQ(Mobile X5)",FN]],[PN,["QQ(Mac)",YN]],[JN,["QQ(iPad)",HN]],[XN,["MI",$N]],[Ab,["HW",ib]],[ob,["Samsung",nb]],[rb,["OPPO",sb]],[ab,["VIVO",gb]],[BN,["EDGE",QN]],[yN,["SogouMobile",DN]],[vN,["Sogou",wN]]]);function Uk(){let A=Lk.get(!0);return{browserName:A?A[0]:"unknown",browserVersion:A?A[1]:"unknown"}}var Fk=function(){return!(zN||BN||pN&&mN<80||dN&&CN<56)},Ok=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every(A=>A in window)},xk=function(){if(!navigator.mediaDevices)return Yk()||sG.error(Qk.NOT_SUPPORTED_MEDIA),!1;let A=["getUserMedia","enumerateDevices"];return A.filter(A=>A in navigator.mediaDevices).length===A.length},Pk=!1;function Yk(){return"http:"===location.protocol&&!bb&&(Pk||sG.error(mk({key:Bk.NOT_SUPPORTED_HTTP})),Pk=!0,!0)}var Jk=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},Hk=function(){return!(null==window||!window.MediaStreamTrackGenerator)},qk=function(){return VS(this,null,function*(){var A,e,t;if(kk.detail.isH264EncodeSupported&&kk.detail.isVp8EncodeSupported)return{isH264EncodeSupported:kk.detail.isH264EncodeSupported,isVp8EncodeSupported:kk.detail.isVp8EncodeSupported,isH265EncodeSupported:kk.detail.isH265EncodeSupported};let i,o=!1,n=!1,r=!1;try{let s=new RTCPeerConnection,a=document.createElement(WM.CANVAS);a.getContext("2d");let g=a.captureStream(0);return s.addTrack(g.getVideoTracks()[0],g),i=yield s.createOffer(),o=-1!==(null==(A=i.sdp)?void 0:A.toLowerCase().indexOf("h264")),n=-1!==(null==(e=i.sdp)?void 0:e.toLowerCase().indexOf("vp8")),r=-1!==(null==(t=i.sdp)?void 0:t.toLowerCase().indexOf("h265")),s.close(),{isH264EncodeSupported:o,isVp8EncodeSupported:n,isH265EncodeSupported:r}}catch(s){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1}}})},Vk=function(){return VS(this,null,function*(){var A;if(kk.detail.isH264DecodeSupported&&kk.detail.isVp8DecodeSupported)return{isH264DecodeSupported:kk.detail.isH264DecodeSupported,isVp8DecodeSupported:kk.detail.isVp8DecodeSupported,isH265DecodeSupported:kk.detail.isH265DecodeSupported};let e,t=!1,i=!1;try{let o=new RTCPeerConnection;IL()?(o.addTransceiver(WM.VIDEO,{direction:"recvonly"}),e=yield o.createOffer()):e=yield o.createOffer({offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0);let n=-1!==(null==(A=e.sdp)?void 0:A.toLowerCase().indexOf("h265"));return o.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:i,isH265DecodeSupported:n}}catch(o){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}}})},jk=vT(A=>VS(null,null,function*(){let e=Date.now(),t=vL(),i=xk(),o=Ok();if(kk.detail.isWebRTCSupported=t,kk.detail.isMediaDevicesSupported=i,kk.detail.isWebCodecsSupported=o,kk.detail.isScreenShareSupported=Wk(),kk.detail.isSmallStreamSupported=sL(),37===A)return Object.assign(kk.detail,yield function(){return VS(this,null,function*(){return Xk||(Xk=new Promise(A=>VS(null,null,function*(){let e={isH264EncodeSupported:!1,isH264DecodeSupported:!1,isVp8EncodeSupported:!1,isVp8DecodeSupported:!1};if(!Ok())return void A(e);let t=null,i=null,o=null,n=()=>{o&&clearTimeout(o),t=null,i=null};try{t=document.createElement("canvas"),i=t.getContext("2d"),t.width=320,t.height=240;let r=0,s=()=>{!i||!t||(i.fillStyle="hsl(".concat(r%360,", 50%, 50%)"),i.fillRect(0,0,t.width,t.height),i.fillStyle="white",i.font="20px Arial",i.fillText("Frame ".concat(r),10,30),r++)};o=setTimeout(()=>{n(),A(e)},5e3);let a=[{type:"h264",encodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"},width:320,height:240,bitrate:1e6},decodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"}}},{type:"vp8",encodeConfig:{codec:"vp8",width:320,height:240,bitrate:1e6},decodeConfig:{codec:"vp8"}}];(yield Promise.all(a.map(A=>VS(null,null,function*(){let e,i={type:A.type,encodeSupported:!1,decodeSupported:!1};try{e=yield new Promise((e,o)=>VS(null,null,function*(){try{let n=new VideoEncoder({output:A=>{e(A),i.encodeSupported=!0},error:o});n.configure(A.encodeConfig),s();let r=new VideoFrame(t,{timestamp:0});n.encode(r,{keyFrame:!0}),r.close(),yield n.flush(),n.close()}catch(n){o(n)}}))}catch(o){return sG.warn("".concat(A.type," encoder error:"),o),i}try{yield new Promise((t,o)=>VS(null,null,function*(){try{let n=new VideoDecoder({output:A=>{i.decodeSupported=!0,t(0),A.close()},error:o});n.configure(A.decodeConfig),n.decode(e),yield n.flush(),n.close()}catch(n){o(n)}}))}catch(o){sG.warn("".concat(A.type," decoder error:"),o)}return i})))).forEach(A=>{"h264"===A.type?(e.isH264EncodeSupported=A.encodeSupported,e.isH264DecodeSupported=A.decodeSupported):"vp8"===A.type&&(e.isVp8EncodeSupported=A.encodeSupported,e.isVp8DecodeSupported=A.decodeSupported)}),n(),A(e)}catch(r){n(),sG.warn("detectWebCodecsSupported failed:",r),A(e)}})))})}()),kk.detail.isBrowserSupported=o,kk.result=i&&o,kk.result||sG.error("".concat(navigator.userAgent," ").concat(BT(kk.detail,!1))),NL(A),Gk.addNumber({key:523800,value:Date.now()-e}),kk;if(kk.result&&kk.detail.isH264EncodeSupported&&kk.detail.isVp8EncodeSupported&&kk.detail.isH265EncodeSupported&&kk.detail.isH264DecodeSupported&&kk.detail.isVp8DecodeSupported&&kk.detail.isH265DecodeSupported)return kk;let n=Fk(),{encode:r,decode:s}=yield function(){return VS(this,null,function*(){let[A,e]=yield Promise.all([qk(),Vk()]);return{encode:{h264:A.isH264EncodeSupported,vp8:A.isVp8EncodeSupported,h265:A.isH265EncodeSupported},decode:{h264:e.isH264DecodeSupported,vp8:e.isVp8DecodeSupported,h265:e.isH265DecodeSupported}}})}(),{h264:a,vp8:g}=r,{h264:c}=s,{h265:l}=r,{vp8:I,h265:u}=s;if(!a||!g){let A=yield qk();sG.warn("detect encode again h264:".concat(a," vp8:").concat(g," result: ").concat(JSON.stringify(A))),a=A.isH264EncodeSupported,g=A.isVp8EncodeSupported}if(a&&c&&lN&&Eb&&!RN&&!SN&&(!rb||115!==Cb)){let{encode:A,decode:e}=yield function(){return VS(this,null,function*(){return Zk||(Zk=new Promise(A=>VS(null,null,function*(){let e={encode:!1,decode:!1},t=()=>{};try{let i=document.createElement("canvas"),o=i.getContext("2d");i.width=640,i.height=480;let n=setInterval(()=>{o.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},66),r=-1,s=-1;t=()=>{clearInterval(r),clearInterval(n),clearTimeout(s),g.close(),c.close(),a.getTracks().forEach(A=>A.stop())},s=setTimeout(()=>{t(),A(e)},2e3);let a=i.captureStream(),g=new RTCPeerConnection({}),c=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});g.addEventListener("icecandidate",A=>c.addIceCandidate(A.candidate)),c.addEventListener("icecandidate",A=>g.addIceCandidate(A.candidate)),g.addTrack(a.getVideoTracks()[0],a);let l=yield g.createOffer();yield g.setLocalDescription(l),yield c.setRemoteDescription(l);let I=yield c.createAnswer(),u=vk.default.parse(I.sdp),E=u.media[0].rtp.findIndex(A=>"H264"===A.codec);u.media[0].rtp=[u.media[0].rtp[E]],u.media[0].fmtp=u.media[0].fmtp.filter(A=>A.payload===u.media[0].rtp[0].payload),u.media[0].rtcpFb&&(u.media[0].rtcpFb=u.media[0].rtcpFb.filter(A=>A.payload===u.media[0].rtp[0].payload)),I.sdp=vk.default.write(u),yield c.setLocalDescription(I),yield g.setRemoteDescription(I),r=setInterval(()=>VS(null,null,function*(){e.encode&&e.decode&&(t(),A(e));let[i,o]=yield Promise.all([g.getSenders()[0].getStats(),c.getReceivers()[0].getStats()]);e.encode||i.forEach(A=>{"outbound-rtp"===A.type&&A.mediaType===WM.VIDEO&&A.bytesSent>0&&(e.encode=!0)}),e.decode||o.forEach(A=>{"inbound-rtp"===A.type&&A.mediaType===WM.VIDEO&&A.bytesReceived>0&&(e.decode=!0)})}),100)}catch(i){t(),sG.warn("detectH264Supported failed",i),A({encode:!0,decode:!0})}})).then(A=>(A.encode||(A.decode=!0),(!A.encode||!A.decode)&&sG.warn("detectH264Supported encode: ".concat(A.encode," decode: ").concat(A.decode," ").concat(Ob)),A)))})}();a=A,c=e}return kk.result=n&&t&&i&&(a||g)&&(c||I),kk.detail.isBrowserSupported=n,kk.detail.isWebRTCSupported=t,kk.detail.isH264EncodeSupported=a,kk.detail.isVp8EncodeSupported=g,kk.detail.isH265EncodeSupported=l,kk.detail.isH264DecodeSupported=c,kk.detail.isVp8DecodeSupported=I,kk.detail.isH265DecodeSupported=u,kk.result||sG.error("".concat(navigator.userAgent," ").concat(BT(kk.detail,!1))),NL(),Gk.addNumber({key:523800,value:Date.now()-e}),kk})),Kk=function(){return kk.result},Wk=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},zk="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype,Zk=null,Xk=null,$k=(A,e,t)=>{"http:"===location.protocol&&!bb&&(A[e]=()=>{throw new rM({code:oM.INVALID_OPERATION,message:Qk.NOT_SUPPORTED_HTTP})})},AL=function(A){return!("candidate-pair"!==A.type||!A.nominated||"in-progress"!==A.state&&"succeeded"!==A.state||j_(A.selected)&&!A.selected)};function eL(){let A="";if(screen.width){let e=screen.width?screen.width*window.devicePixelRatio:"",t=screen.height?screen.height*window.devicePixelRatio:"";A+="".concat(e," * ").concat(t)}return A}function tL(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function iL(){let A={isSupported:!1},e=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let t=0;t=86,yL="RTCRtpScriptTransform"in window,DL=dL&&(mL||yL),vL=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(A=>A in window).length>0};function wL(){let A={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return H_(window.AudioDecoder)||(A.AudioDecoder=!0),H_(window.AudioEncoder)||(A.AudioEncoder=!0),H_(window.VideoDecoder)||(A.VideoDecoder=!0),H_(window.VideoEncoder)||(A.VideoEncoder=!0),H_(window.ImageDecoder)||(A.ImageDecoder=!0),A}function SL(){return"mediaSession"in navigator&&!H_(navigator.mediaSession.setActionHandler)}function ML(){return!H_(window.WebTransport)}function RL(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function _L(){let A={browser:"".concat(kb.name,"/").concat(kb.version),os:Wb(),displayResolution:eL(),isScreenShareSupported:Wk(),isWebRTCSupported:vL(),isGetUserMediaSupported:tL(),isWebAudioSupported:iL(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:wL(),isMediaSessionSupported:SL(),isWebTransportSupported:ML()};return navigator.userAgent.includes("miniProgram")&&(A.browser="mini/".concat(A.browser)),A}var TL="checkResult";function NL(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;gG.setItem(TL+A,{ua:navigator.userAgent,checkResult:kk})}function bL(A){Yk();let e=gG.getItem(TL+A);var t,i;e&&e.ua===navigator.userAgent&&e.checkResult&&(t=e.checkResult.detail,i=kk.detail,!!K_(t)&&Object.keys(i).every(A=>A in t))&&(kk=e.checkResult),jk(A)}function GL(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var kL="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype;function LL(A){return{h264:1,h265:2,vp8:3,vp9:4,av1:5}[A]}var UL=!1;function FL(){return VS(this,null,function*(){var A;try{if(UL||null==(A=null==navigator?void 0:navigator.mediaCapabilities)||!A.encodingInfo)return;let e=zb(),t=Zb();if(0===e||0===t)return;UL=!0;let i=["H264","VP8","VP9","AV1","H265"],[o,n]=yield Promise.all([OL(i),xL(i)]);o&&Object.keys(o).forEach(A=>{let i=LL(A.toLowerCase());Gk.addEnum({key:513707,value:+"".concat(i).concat(+o[A].supported).concat(+o[A].powerEfficient).concat(e).concat(t),useUV:!1})}),n&&Object.keys(n).forEach(A=>{let i=LL(A.toLowerCase());Gk.addEnum({key:514713,value:+"".concat(i).concat(+n[A].supported).concat(+n[A].powerEfficient).concat(e).concat(t),useUV:!1})});let{sender:r,receiver:s}=PL();Gk.addEnum({key:513708,value:+"".concat(e).concat(t).concat(+r.high),useUV:!1}),Gk.addEnum({key:513709,value:+"".concat(e).concat(t).concat(+r.main),useUV:!1}),Gk.addEnum({key:514714,value:+"".concat(e).concat(t).concat(+s.high),useUV:!1}),Gk.addEnum({key:514715,value:+"".concat(e).concat(t).concat(+s.main),useUV:!1})}catch(e){sG.info("detectVideoCodecCapabilities failed",e)}})}function OL(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return VS(this,null,function*(){let n={};try{for(let r of A){let A=yield navigator.mediaCapabilities.encodingInfo({type:"webrtc",video:{contentType:"video/".concat(r),width:e,height:t,bitrate:o,framerate:i}});n[r]=A}}catch(r){}return n})}function xL(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return VS(this,null,function*(){let n={};try{for(let r of A){let A=yield navigator.mediaCapabilities.decodingInfo({type:"webrtc",video:{contentType:"video/".concat(r),width:e,height:t,bitrate:o,framerate:i}});n[r]=A}}catch(r){}return n})}function PL(){let A={sender:{base:!1,main:!1,high:!1},receiver:{base:!1,main:!1,high:!1}};try{if(RTCRtpSender&&"function"==typeof RTCRtpSender.getCapabilities){let e=RTCRtpSender.getCapabilities("video");e&&e.codecs&&e.codecs.filter(A=>"video/h264"===A.mimeType.toLowerCase()).forEach(e=>{if(e.sdpFmtpLine){let t=e.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(t&&t[1])switch(t[1].slice(0,2)){case"42":A.sender.base=!0;break;case"4d":A.sender.main=!0;break;case"64":A.sender.high=!0}}})}if(RTCRtpReceiver&&"function"==typeof RTCRtpReceiver.getCapabilities){let e=RTCRtpReceiver.getCapabilities("video");e&&e.codecs&&e.codecs.filter(A=>"video/h264"===A.mimeType.toLowerCase()).forEach(e=>{if(e.sdpFmtpLine){let t=e.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(t&&t[1])switch(t[1].slice(0,2)){case"42":A.receiver.base=!0;break;case"4d":A.receiver.main=!0;break;case"64":A.receiver.high=!0}}})}}catch(e){sG.warn("get H264 profile levelId failed",e)}return A}var YL=YS(jS(),1),JL=Symbol("instance"),HL=Symbol("cacheResult"),qL=class{constructor(A,e,t){this.oldState=A,this.newState=e,this.action=t,this.aborted=!1}abort(A){this.aborted=!0,zL.call(A,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},VL=class extends Error{constructor(A,e,t){super(e),this.state=A,this.message=e,this.cause=t}},jL=new Map;function KL(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let r=t.action||o;if(!t.context){let t=jL.get(i)||[];jL.has(i)||jL.set(i,t),t.push({from:A,to:e,action:r})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),a=0;a{if(t.fail&&t.fail.call(this,A),t.sync){if(t.ignoreError)return A;throw A}return t.ignoreError?Promise.resolve(A):Promise.reject(A)};if(g)return c(g);let l=i.state,I=new qL(l,e,r);zL.call(i,I);let u=A=>{var o;return i[HL]=A,I.aborted||(zL.call(i,e),null===(o=t.success)||void 0===o||o.call(this,i[HL])),A},E=A=>(zL.call(i,l,A),c(A));try{let A=s.apply(this,n);return"object"==typeof(d=A)&&d&&"then"in d?A.then(u).catch(E):t.sync?u(A):Promise.resolve(u(A))}catch(h){return E(new VL(i._state,"".concat(i.name," ").concat(r," from ").concat(A," to ").concat(e," failed: ").concat(h),h instanceof Error?h:new Error(String(h))))}var d}}}var WL="undefined"!=typeof window&&window.__AFSM__?(A,e)=>{window.dispatchEvent(new CustomEvent(A,{detail:e}))}:"undefined"!=typeof importScripts?(A,e)=>{postMessage({type:A,payload:e})}:()=>{};function zL(A,e){let t=this._state;this._state=A;let i=A.toString();A&&this.emit(i,t),this.emit(ZL.STATECHANGED,A,t,e),this.updateDevTools({value:A,old:t,err:e instanceof Error?e.message:String(e)})}var ZL=class A extends YL.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=A.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let o=i[JL];o?this.name=o.name+"-"+o.count++:i[JL]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let A=Object.getPrototypeOf(this),e=jL.get(A)||[],t=new Set,i=[],o=[],n=new Set,r=Object.getPrototypeOf(A);jL.has(r)&&(r.stateDiagram.forEach(A=>t.add(A)),r.allStates.forEach(A=>n.add(A))),e.forEach(A=>{let{from:e,to:t,action:n}=A;"string"==typeof e?i.push({from:e,to:t,action:n}):e.length?e.forEach(A=>{i.push({from:A,to:t,action:n})}):o.push({to:t,action:n})}),i.forEach(A=>{let{from:e,to:i,action:o}=A;n.add(e),n.add(i),n.add(o+"ing"),t.add("".concat(e," --\x3e ").concat(o,"ing : ").concat(o)),t.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),t.add("".concat(o,"ing --\x3e ").concat(e," : ").concat(o," 🔴"))}),o.forEach(A=>{let{to:e,action:i}=A;t.add("".concat(i,"ing --\x3e ").concat(e," : ").concat(i," 🟢")),n.forEach(A=>{A!==e&&t.add("".concat(A," --\x3e ").concat(i,"ing : ").concat(i))})});let s=[...t];return Object.defineProperties(A,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(e){let t;return"string"==typeof e?(t=A.instances.get(e),t||A.instances.set(e,t=new A(e,void 0,Object.create(A.prototype)))):(t=A.instances2.get(e),t||A.instances2.set(e,t=new A(e.constructor.name,void 0,Object.create(A.prototype)))),t}static getState(e){var t;return null===(t=A.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};WL(A.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(A){zL.call(this,A)}};ZL.STATECHANGED="stateChanged",ZL.UPDATEAFSM="updateAFSM",ZL.INIT="[*]",ZL.ON="on",ZL.OFF="off",ZL.instances=new Map,ZL.instances2=new WeakMap;var XL="undefined"!=typeof window,$L=XL&&window.requestIdleCallback||function(A){let e=Date.now();return setTimeout(()=>{A({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1e3)},AU=XL&&window.cancelIdleCallback||function(A){clearTimeout(A)},eU=XL&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),tU=class A{static generateTaskID(){return this.currentTaskID++}static run(A,e,t){null!=t&&t.fps&&(t.delay=t.delay||Number((1e3/t.fps).toFixed(2))),t=US("interval"===A?{delay:2e3,count:0,backgroundTask:!0}:"ric"===A?{delay:1e4,count:0}:"raf"===A?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},t);let i=FS(US({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:A,callback:e},t),{delay:t.delay});return this.taskMap.set(i.taskID,i),this[A](i),i.taskID}static interval(e){return e.intervalID=setInterval(()=>{e.callback(),e.loopCount+=1,A.isBreakLoop(e)},e.delay)}static intervalInWorker(e){A.sharedWorker||(A.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),A.sharedWorker.onmessage=e=>{var t;if("tick"===e.data.type){let i=A.workerTasks.get(e.data.taskId);i&&(A.isBreakLoop(i)?(null==(t=A.sharedWorker)||t.postMessage({type:"stop",taskId:i.taskID}),A.workerTasks.delete(i.taskID)):(i.callback(),i.loopCount+=1))}}),A.workerTasks.set(e.taskID,e),A.sharedWorker.postMessage({taskId:e.taskID,delay:e.delay,type:"start"})}static timeout(e){let t=()=>{if(e.callback(),e.loopCount+=1,!A.isBreakLoop(e))return e.timeoutID=setTimeout(t,e.delay)};return e.timeoutID=setTimeout(t,e.delay)}static ric(e){let t,i=oT(),o=()=>{if(t=oT()-i,t>=e.delay&&(i=oT()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),!A.isBreakLoop(e))return e.ricID=$L(o,{timeout:e.delay})};return e.ricID=$L(o,{timeout:e.delay})}static raf(e){let t,i=oT(),o=()=>document.hidden&&e.backgroundTask?(t=oT()-i,i=oT(),e.callback(),e.loopCount+=1,A.isBreakLoop(e)?void 0:e.timeoutID=setTimeout(o,e.delay-Math.floor(t%e.delay))):(t=oT()-i,t>=e.delay&&(i=oT()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),A.isBreakLoop(e)?void 0:e.rafID=requestAnimationFrame(o));if(e.rafID=requestAnimationFrame(o),e.backgroundTask){let A=()=>{if(document.hidden){let A=oT()-i;A>=e.delay?o():e.timeoutID=setTimeout(o,e.delay-A)}};document.addEventListener("visibilitychange",A),e.onVisibilitychange=A,document.hidden&&A()}return e.taskID}static hasTask(A){return this.taskMap.has(A)}static clearTask(A){if(!this.taskMap.has(A))return!0;let{intervalID:e,timeoutID:t,rafID:i,ricID:o,onVisibilitychange:n}=this.taskMap.get(A);return e&&clearInterval(e),t&&clearTimeout(t),i&&eU&&eU(i),o&&AU(o),n&&document.removeEventListener("visibilitychange",n),this.taskMap.delete(A),!0}static isBreakLoop(A){return!this.hasTask(A.taskID)||0!==A.count&&A.loopCount>=A.count&&(this.clearTask(A.taskID),!0)}};HS(tU,"taskMap",new Map),HS(tU,"currentTaskID",1),HS(tU,"sharedWorker",null),HS(tU,"workerTasks",new Map);var iU=tU,oU={LOAD_START:WM.LOADSTART,LOADED_DATA:WM.LOADEDDATA,LOADED_META_DATA:WM.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",RESIZE:WM.RESIZE,TIME_UPDATE:"time-update",LEAVE_PICTURE_IN_PICTURE:WM.LEAVE_PICTURE_IN_PICTURE,ENTER_PICTURE_IN_PICTURE:WM.ENTER_PICTURE_IN_PICTURE,USER_RESUME_IN_PIP_OR_FULL_SCREEN:"user-resume-in-pip-or-full-screen",USER_PAUSE_IN_PIP_OR_FULL_SCREEN:"user-pause-in-pip-or-full-screen",ENTER_FULL_SCREEN:"enter-full-screen",LEAVE_FULL_SCREEN:"leave-full-screen",VOLUME_CHANGE:"volume-change"},nU={};PS(nU,{create:()=>sU,remove:()=>aU});var rU=new WeakMap;function sU(A,e){rU.has(A)||rU.set(A,[]);let t=rU.get(A),i={add:(A,o)=>("addEventListener"in e?(t.push(e.removeEventListener.bind(e,A,o)),e.addEventListener(A,o)):(t.push(e.off.bind(e,A,o)),e.on(A,o)),i)};return i}function aU(A){let e=rU.get(A);e&&(e.forEach(A=>A()),rU.delete(A))}var gU=new class{constructor(){HS(this,"_roomIdMap",new Map),HS(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:CM,env:FM.QCLOUD,browserVersion:kb.name+kb.version,ua:navigator.userAgent})}setConfig(A){let{sdkAppId:e,env:t,userId:i,roomId:o}=A;e!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(e)),this._configs.env=t,this._configs.userId=i,this._roomIdMap.set(i,String(o))}logSuccessEvent(A){bb||!sG.isAbleToUpload||this._configs.env===FM.QCLOUD&&this.uploadEventToKibana(FS(US({},A),{result:"success"}))}logFailedEvent(A){if(bb||!sG.isAbleToUpload)return;let{eventType:e,code:t,error:i,userId:o}=A,n={roomId:this._roomIdMap.get(o||this._configs.userId),userId:o,eventType:e,result:"failed",code:t||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||oM.UNKNOWN};this._configs.env===FM.QCLOUD&&this.uploadEventToKibana(FS(US({},n),{error:i}))}uploadEventToKibana(A){let e="stat-".concat(A.eventType,"-").concat(A.result);("delta-join"===A.eventType||"delta-leave"===A.eventType||"delta-publish"===A.eventType)&&(e="".concat(A.eventType,":").concat(A.delta)),this.uploadEvent({log:e,userId:A.userId}),"failed"===A.result&&(e="stat-".concat(A.eventType,"-").concat(A.result,"-").concat(A.code),this.uploadEvent({log:e,userId:A.userId,error:A.error}))}uploadEvent(A){let{log:e,userId:t,error:i}=A,o={timestamp:IM(),sdkAppId:this._configs.sdkAppId,userId:t||this._configs.userId,version:CM,log:e};i&&(o.errorInfo=i.message,i.stack&&(o.errorInfo+="\n".concat(i.stack)));let n=nG.enable?bT(o,2002,Number(this._configs.sdkAppId)):JSON.stringify(o);this.sendRequest(D_(this._configs.sdkAppId,UM.LOG),n)}sendRequest(A,e){setTimeout(()=>PT({url:A,body:e,priority:"low"}).catch(()=>{}),2e3)}},cU=new WeakMap;function lU(A){let{settings:e={retries:5,timeout:2e3},onError:t,onRetrying:i,onRetryFailed:o}=A;return function(A,n,r){let s=zT({retryFunction:r.value,settings:e,onError(e){let{error:i,retry:o,reject:r,retryFuncArgs:s}=e;var a;t?t.call(this,i,()=>{var e;null!=(e=cU.get(A))&&e.has(n)?o():r(i)},r,s):null!=(a=cU.get(A))&&a.has(n)?o():r(i)},onRetrying(e,t){var o;HT(i)&&i.call(this,e,t),null!=(o=cU.get(A))&&o.has(n)&&(cU.get(A).get(n).stopRetry=t)},onRetryFailed:o});return r.value=function(){let e=cU.get(A);for(var t=arguments.length,i=new Array(t),o=0;o{var e;return null==(e=cU.get(A))?void 0:e.delete(n)})},r}}function IU(A){let{fnName:e,callback:t,validateArgs:i=!0}=A;return function(A,o,n){let r=n.value;return n.value=function(){for(var o,n,s=arguments.length,a=new Array(s),g=0;ge===A)){s=!1;break}s&&(t&&t.apply(this,a),o&&o(),null==(n=cU.get(A))||n.delete(e))}return r.apply(this,a)},n}}var uU=class extends ZL{constructor(A,e){super(A.id,"".concat(e,"-player")),this.options=A,this.kind=e,HS(this,"id"),HS(this,"element",null),HS(this,"track"),HS(this,"url"),HS(this,"attr"),HS(this,"mode"),HS(this,"muted"),HS(this,"_log"),HS(this,"isPausedByUserCall",!1),HS(this,"_pausedRetryCount"),HS(this,"_isElementPlayingFired",!1),HS(this,"_interval"),HS(this,"_delayDestroyTimeoutId",0),HS(this,"_playSuccessResolve"),HS(this,"_isReplayByRecreateMediaStreamCalled",!1),HS(this,"isPlayCalled",!1),HS(this,"isInAutoPlayFailedState",!1),this.id=A.id,this._log=A.log,this.track=A.track,this.muted=A.muted,this._pausedRetryCount=JR,this._state="STOPPED",this.bindTrackEvents(),this._log.info("create ".concat(e,"-player ").concat(this.id))}get isPlaying(){var A;return"PLAYING"===this._state&&!1===(null==(A=this.element)?void 0:A.paused)}get isPaused(){var A;return"PAUSED"===this._state||!0===(null==(A=this.element)?void 0:A.paused)}get isStopped(){return"STOPPED"===this._state}setAttr(A){this.attr=A}setUrl(A){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),A!==this.url&&(this.url=A,null!==A&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=A))}play(){return VS(this,null,function*(){if(!this.isPlaying)try{this.isPlayCalled=!0,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),yield new Promise((A,e)=>{this._playSuccessResolve=A,this.element.play().then(A,e)})}catch(A){let e=mk({key:Bk.PLAY_FAILED,data:{media:this.kind,error:A}});if(this._log.warn(A),e.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new rM({code:oM.PLAY_NOT_ALLOWED,message:e})}})}stop(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var e;this.isPlayCalled=!1,this._isElementPlayingFired=!1,this.unbindEvents(),A>0&&!mb?this._delayDestroyTimeoutId||(null==(e=this.element)||e.remove(),this._log.info("destroy element after 3 * ".concat(A)),this._delayDestroyTimeoutId=setTimeout(()=>this.destroyElement(),3*A)):this.destroyElement(),this.handleStopped(WM.ENDED),this._interval>0&&iU.clearTask(this._interval)}destroyElement(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.src="",this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}pause(){this._log.info("pause"),this.isPausedByUserCall=!0,this.doPause()}doPause(){var A;null==(A=this.element)||A.pause()}resume(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPausedByUserCall=!1,this.doResume(A)}doResume(){return this._log.info("resume"),this.isPausedByUserCall||this.isPlaying?Promise.resolve():_b?this.replay():this.play().catch(()=>{})}setMuted(A){this.element&&(this.element.muted=A),this.muted=A}replay(){return this.stop(),this.play().catch(()=>{})}bindElementEvents(){if(this.element){let A=this.handleElementEvent.bind(this);return sU(this.element,this.element).add(WM.PLAYING,A).add(WM.ENDED,A).add(WM.PAUSE,A).add(WM.ERROR,A).add(WM.LOADSTART,A).add(WM.LOADEDDATA,A).add(WM.LOADEDMETADATA,A)}}bindTrackEvents(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(A){let e=this.handleTrackEvent.bind(this);null==nU||nU.create(A,A).add(WM.ENDED,e).add(WM.MUTE,e).add(WM.UNMUTE,e),A.readyState===WM.ENDED&&this.handleTrackEvent({type:WM.ENDED}),A.muted&&this.handleTrackEvent({type:WM.MUTE})}}bindAutoPlayEvent(){tG.listeners(oG.AUTOPLAY_DIALOG_CLICK_CONFIRM).includes(this.resume)||tG.on(oG.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;A&&aU(A)}unbindEvents(){this.element&&aU(this.element),this.unbindTrackEvents(),tG.off(oG.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(A){switch(A.type){case WM.PLAYING:TU()||(this.isInAutoPlayFailedState=!1),this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(WM.PLAYING),this._interval&&(iU.clearTask(this._interval),this._interval=-1);break;case WM.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(WM.ENDED);break;case WM.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(WM.PAUSE);break;case WM.ERROR:if(this.element&&this.element.error){this.handlePaused(WM.ERROR);let{code:A,message:e}=this.element.error;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(A," message: ").concat(e," userAgent: ").concat(navigator.userAgent)),gU.uploadEvent({log:"stat-".concat(this.kind,"-").concat(wR.PLAYER_ERROR,"-").concat(A,"-").concat(navigator.userAgent),error:this.element.error}),tb||eb?this.emit(oU.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case WM.LOADEDDATA:this.kind===WM.VIDEO&&this.emit(oU.LOADED_DATA);break;case WM.LOADEDMETADATA:this.kind===WM.VIDEO&&this.emit(oU.LOADED_META_DATA);break;case WM.LOADSTART:this.emit(oU.LOAD_START)}}replayByRecreateMediaStream(A){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then(()=>{this._log.warn("replayByRecreateMediaStream success"),gU.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),Gk.addSuccessEvent({key:this.kind===WM.AUDIO?506700:516700})}).catch(()=>{var e;this._log.error("replayByRecreateMediaStream failed"),gU.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),Gk.addFailedEvent({key:this.kind===WM.AUDIO?506700:516700,error:null==(e=this.element)?void 0:e.error}),this.emit(oU.ERROR,A)})}doReplayByRecreateMediaStream(A){return this._log.warn("delay ".concat(A,"ms to recreate mediaStream")),new Promise((e,t)=>{DT(A).then(()=>{this.element&&(this.element.srcObject=null,this.element.srcObject=new MediaStream([this.track]),this._log.warn("recreated mediaStream"),this.element.onerror=()=>{var A,e,i;this._log.warn("element onerror ".concat(null==(e=null==(A=this.element)?void 0:A.error)?void 0:e.code," fired after recreated mediaStream")),t(null==(i=this.element)?void 0:i.error)}),DT(5e3).then(()=>{var A,i;(!this.isPlaying||null!=(A=this.element)&&A.error)&&t(null==(i=this.element)?void 0:i.error),e()})})}).finally(()=>{this.element&&(this.element.onerror=null)})}handleTrackEvent(A){return VS(this,null,function*(){let e=A.type;switch(this.options.enableLogTrackState&&this._log[e===WM.UNMUTE?"info":"warn"]("track ".concat(e)),e){case WM.ENDED:this.handleStopped(WM.ENDED);break;case WM.MUTE:this.handlePaused(WM.MUTE);break;case WM.UNMUTE:this.mode>0?this.handlePlaying(this.mode.toString()):this.element&&(this.element.paused&&!this.isPausedByUserCall&&(this._log.warn("track unmuted and element is paused, resume"),yield this.doResume()),this.element&&!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(WM.UNMUTE))}})}handlePlaying(A){var e;return this._log.debug("handlePlaying",A),null==(e=this._playSuccessResolve)||e.call(this,A),A}handlePaused(A){return this._log.debug("handlePaused",A),A}handleStopped(A){return this._log.debug("handleStopped",A),A}getElement(){return this.element}};HS(uU,"PlayerEvent",oU),JS([lU({settings:{retries:2,timeout:0},onError(A,e,t,i){i[0]=(i[0]||1e3)+1e3,e()}})],uU.prototype,"doReplayByRecreateMediaStream",1),JS([KL([],"PLAYING",{sync:!0,success(A){this.emit(oU.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:A})}})],uU.prototype,"handlePlaying",1),JS([KL("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(A){this.emit(oU.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:A})}})],uU.prototype,"handlePaused",1),JS([KL([],"STOPPED",{sync:!0,success(A){this.emit(oU.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:A})}})],uU.prototype,"handleStopped",1);var EU="trtc_autoplay",dU="".concat(EU,"_mask"),hU="".concat(EU,"_wrapper"),CU="".concat(EU,"_header"),BU="".concat(EU,"_content"),QU="".concat(EU,"_action_wrapper"),pU="".concat(EU,"_question"),fU="".concat(EU,"_collapse"),mU="".concat(EU,"_action_confirm"),yU="".concat(EU,"_detail"),DU="#2473E8",vU="dialog",wU="".concat(vU,"-show"),SU="".concat(vU,"-1"),MU="".concat(vU,"-2"),RU=!1,_U=!1,TU=()=>_U,NU="".concat(_M,"/").concat(F_()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),bU="
").concat(F_()?"其他方案?":"Any other solution?",""),GU="".concat(F_()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(bU):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(bU)),kU=class{constructor(){if(HS(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),HS(this,"_dialogNode",null),HS(this,"_bodyPosition",""),HS(this,"_showDetail",!1),HS(this,"_isCollapseClicked",!1),HS(this,"_isQuestionClicked",!1),F_()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!RU){let A=document.createElement("style");A.innerHTML=".".concat(dU,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(dU," div:not(.").concat(QU,"){display:block !important;}.").concat(hU,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(hU," a{color:").concat(DU,";}.").concat(CU,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(BU,"{margin:8px 0;}.").concat(QU,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(fU,"{margin-right:auto;cursor:pointer}.").concat(pU,"{height:100%;line-height:16px;cursor:pointer;}.").concat(mU,"{margin-left:8px;color:#fff;background:").concat(DU,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(mU,":hover{opacity:0.9;}.").concat(fU,",.").concat(mU,",.").concat(BU,",.").concat(pU,"{font-size:14px;}@media screen and (max-width:750px){.").concat(hU,"{width:80vw;}}"),document.head.appendChild(A),RU=!0}this.addDiaLog()}createDiaLog(){let A=document.createElement("template");A.innerHTML='
").concat(location.host,"
").concat(this.content,"
").trim();let e=document.createElement("button");e.className=mU,e.innerText=F_()?"恢复播放":"Resume",e.onclick=this.onConfirm.bind(this);let t=document.createElement("div");t.className=pU,t.innerHTML='\n \n \n \n \n \n ',t.onclick=this.onQuestionClick.bind(this);let i=document.createElement("div");i.className=fU,i.innerText="".concat(F_()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let o=A.content.firstChild,n=o.querySelector(".".concat(QU));return n.appendChild(i),n.appendChild(t),n.appendChild(e),o}addDiaLog(){TU()||(_U=!0,this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(hU)).onclick=A=>A.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",sG.info("show autoplay dialog"),gU.uploadEvent({log:wU}))}deleteDialog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null,_U=!1),LU=null}onConfirm(){sG.warn("confirm clicked, try resume stream"),tG.emit(oG.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDialog()}onCollapseClick(){let A=this._dialogNode.querySelector(".".concat(yU));A.style.visibility="".concat(this._showDetail?"hidden":"visible"),A.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||gU.uploadEvent({log:SU}),this._isCollapseClicked=!0}onQuestionClick(){window.open(NU,"_blank"),this._isQuestionClicked||gU.uploadEvent({log:MU}),this._isQuestionClicked=!0}},LU=null;function UU(){LU||(LU=new kU)}var FU,OU=class A extends uU{constructor(A){super(A,WM.VIDEO),HS(this,"stat",{}),HS(this,"_calculateTimeout",-1),HS(this,"viewMirror",!1),HS(this,"objectFit","cover"),HS(this,"container"),HS(this,"canvas"),HS(this,"shouldRenderAlpha",!1),HS(this,"_preSize",{width:0,height:0}),HS(this,"posterImg"),HS(this,"pipWindow"),HS(this,"enterPIPPromise"),HS(this,"_originContainerPosition"),HS(this,"_isResettingSrcObject",!1),HS(this,"_wrapper",null),HS(this,"_useWrapper",!1),this.mode=A.canvas?1:0,this.container=A.container,this.canvas=A.canvas,H_(A.viewMirror)||(this.viewMirror=A.viewMirror),H_(A.objectFit)||(this.objectFit=A.objectFit),this.initializeElement()}get isPlaying(){var A;return!("PLAYING"!==this._state||this.element&&this.element.paused||"live"!==(null==(A=this.track)?void 0:A.readyState)||this.track.muted)}initializeElement(){let A=document.createElement(WM.VIDEO);this.track&&2!==this.mode&&(A.srcObject=new MediaStream([this.track])),A.muted=!0,A.setAttribute("id","video_".concat(this.id)),A.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),A.setAttribute("autoplay","autoplay"),A.setAttribute("playsinline","playsinline"),this.element=A,lN&&(A.poster="data:,"),this._appendToWrapper(),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let A=this._useWrapper?"grid-area:1/1;width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";"):"width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";");return this.viewMirror&&(A+="transform:scaleX(-1);"),A}setLiveMode(A){if(this._useWrapper!==A&&(this._useWrapper=A,this.elementToRender&&this.elementToRender.setAttribute("style",this.styleAttribute),this.container&&this.elementToRender))if(A){let A=this._getOrCreateWrapper();A.insertBefore(this.elementToRender,A.firstChild)}else this.container.appendChild(this.elementToRender),this._cleanupWrapper()}setContainer(A){let e=this._wrapper,t=this.container;this.container=A,this._pausedRetryCount=JR,this.track&&this.elementToRender&&this._appendToWrapper(),e&&t&&t!==this.container&&e.isConnected&&0===e.children.length&&e.remove()}_getOrCreateWrapper(){if(!this.container)throw new Error("[VideoPlayer] container is required");let A=this.container.querySelector("[data-trtc-video-wrapper]");return A||(A=document.createElement("div"),A.setAttribute("data-trtc-video-wrapper","true"),A.style.cssText="display:grid;width:100%;height:100%;",this.container.appendChild(A)),this._wrapper=A,A}_appendToWrapper(A){let e=null!=A?A:this.elementToRender;if(this.container&&e)if(this._useWrapper){let A=this._getOrCreateWrapper();A.insertBefore(e,A.firstChild)}else this.container.appendChild(e)}bindElementEvents(){let A=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),this.handleFullscreenChange=this.handleFullscreenChange.bind(this),this.handleVolumeChange=this.handleVolumeChange.bind(this),A&&A.add(WM.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(WM.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent).add(WM.RESIZE,this.handleElementEvent),this.element&&(this.element.addEventListener(WM.FULLSCREEN_CHANGE,this.handleFullscreenChange),this.element.addEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.addEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.addEventListener("volumechange",this.handleVolumeChange))}handleTrackEvent(A){var e;return A.type===WM.MUTE&&(null!=(e=this.stat)&&e.fps&&(this.stat.fps=0),this.isFullscreen()&&this.resetSrcObjectToReplay()),super.handleTrackEvent(A)}handleFullscreenChange(){this.isFullscreen()?(this._log.info("enter fullscreen"),this.emit(oU.ENTER_FULL_SCREEN)):(this._log.info("leave fullscreen"),this.emit(oU.LEAVE_FULL_SCREEN))}handleVolumeChange(){var A;(this.isPictureInPicture()||this.isFullscreen())&&this.emit(oU.VOLUME_CHANGE,{muted:null==(A=this.element)?void 0:A.muted})}handleElementEvent(A){var e,t,i,o,n,r;if(2===this.mode)return;super.handleElementEvent(A);let s=A.type,a=this.isPictureInPicture(),g=this.isFullscreen(),c=A.isTrusted&&(a&&fb||g);if(s===WM.PLAYING&&c&&!this._isResettingSrcObject&&(this._log.warn("user resume in ".concat(g?"fullscreen":"pip")),this.emit(oU.USER_RESUME_IN_PIP_OR_FULL_SCREEN)),s===WM.PAUSE&&(c&&(this._log.warn("user pause in ".concat(g?"fullscreen":"pip")),this.emit(oU.USER_PAUSE_IN_PIP_OR_FULL_SCREEN)),this.container&&!this.container.isConnected&&(this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(this.container.id)),DT(500).then(()=>{var A;null!=(A=this.container)&&A.isConnected&&(this._pausedRetryCount=JR,this._log.info("view container ".concat(this.container.id," is in dom, reset pausedRetryCount")))})),this._pausedRetryCount>0&&!TU()&&!this.isPausedByUserCall&&!c&&(this._log.info("[".concat(JR-this._pausedRetryCount+1,"/").concat(JR,"] ").concat(this.kind," player auto resume when paused")),this.doResume(),this._pausedRetryCount--),gN&&!c&&(this._interval=iU.run("timeout",()=>{this.element&&"PAUSED"===this._state&&!this.isPausedByUserCall&&this.doResume()},{delay:3e3})),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let A=this.element.style.transform;s===WM.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=A.replace("scaleX(-1)",""):s===WM.LEAVE_PICTURE_IN_PICTURE&&!A.includes("scaleX")&&(this.element.style.transform="".concat(A," scaleX(-1)"))}s===WM.RESIZE&&(this._preSize.height!==(null==(e=this.element)?void 0:e.videoHeight)||this._preSize.width!==(null==(t=this.element)?void 0:t.videoWidth))&&(this._log.info("video size changed to ".concat(null==(i=this.element)?void 0:i.videoWidth,"x").concat(null==(o=this.element)?void 0:o.videoHeight)),this._preSize.height=(null==(n=this.element)?void 0:n.videoHeight)||0,this._preSize.width=(null==(r=this.element)?void 0:r.videoWidth)||0,this.emit(oU.RESIZE,{newWidth:this._preSize.width,newHeight:this._preSize.height})),s===WM.LEAVE_PICTURE_IN_PICTURE&&(this._log.warn("exit pip"),this.isPaused&&!this.isPausedByUserCall&&(this._log.warn("resume after exit pip"),this.doResume()),this.resetSrcObjectToReplay(),this.emit(oU.LEAVE_PICTURE_IN_PICTURE)),s===WM.ENTER_PICTURE_IN_PICTURE&&this.emit(oU.ENTER_PICTURE_IN_PICTURE)}resetSrcObjectToReplay(){lN&&Bb&&this.isPlayCalled&&this.element&&this.track&&!this.isPausedByUserCall&&(this._log.warn("reset srcObject to replay for android chromium"),this._isResettingSrcObject=!0,this.element.srcObject=new MediaStream([this.track]),this.element.play().catch(A=>{this._log.warn("play failed after reset srcObject",A)}).finally(()=>{this._isResettingSrcObject=!1}))}setCanvas(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var t,i;this.canvas!==A&&(null==(t=this.canvas)||t.remove(),null==A||A.setAttribute("style",this.styleAttribute),this.canvas=A,this.mode=A?e:0,2===this.mode&&this.setTrack(A.captureStream().getVideoTracks()[0]),A?(null==(i=this.element)||i.remove(),this._appendToWrapper()):this.element&&this._appendToWrapper())}setAttr(A){let e=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},A);e.style=Object.assign({width:"100%",height:"100%"},e.style),super.setAttr(e)}get mirror(){return this.viewMirror}setRect(A,e){this.elementToRender&&(this.elementToRender.style.width="".concat(A,"px"),this.elementToRender.style.height="".concat(e,"px"))}setViewMirror(A){this.elementToRender&&(this.elementToRender.style.transform=A?"scaleX(-1)":""),this.viewMirror=A}setObjectFit(A){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(A)),this.objectFit=A}setPoster(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise(t=>{if(!this.element||(this._log.info("setPoster",A.slice(0,10)),""===A?this.element.removeAttribute("poster"):this.element.poster=A,!e||!fb&&!dN))return t();if(""===A)return this.removePosterImg(),t();if(this.posterImg)return t();let i=document.createElement("img");i.src=A;let o=window.getComputedStyle(this.element).objectFit||this.objectFit;i.style.cssText=this._useWrapper?"grid-area:1/1;width:100%;height:100%;object-fit:".concat(o,";"):"position:absolute;top:0;left:0;width:100%;height:100%;object-fit:".concat(o,";"),i.onload=()=>VS(this,null,function*(){try{i.decode&&(yield i.decode()),this.container&&!this._useWrapper&&"static"===window.getComputedStyle(this.container).position&&(this._originContainerPosition=this.container.style.position,this.container.style.position="relative"),this.posterImg=i;let A=this._useWrapper?this._wrapper:this.container;null==A||A.appendChild(i),cN()&&Mb<=17&&this.elementToRender&&(this.elementToRender.style.visibility="hidden")}catch(A){this._log.warn("decode poster image error",A)}return t()}),i.onerror=()=>(this._log.warn("load poster image error"),t())})}removePosterImg(){this.posterImg&&(cN()&&Mb<=17&&this.elementToRender&&(this.elementToRender.style.visibility=""),this.posterImg.remove(),URL.revokeObjectURL(this.posterImg.src),!this._useWrapper&&this.container&&!H_(this._originContainerPosition)&&"relative"===this.container.style.position&&(this.container.style.position=this._originContainerPosition),delete this.posterImg)}get hasPoster(){var A;return!!this.posterImg||!(null==(A=this.element)||!A.getAttribute("poster"))}pause(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return VS(this,null,function*(){qS(A.prototype,this,"pause").call(this),!this.isPictureInPicture()&&!this.hasPoster&&(Bb||e&&(dN||fb))&&(yield this.setPoster(this.getVideoFrame(),!0))})}resume(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return super.resume(A).then(()=>{var A;(this.posterImg||null!=(A=this.element)&&A.poster)&&this.setPoster("",!0)})}doResume(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPaused&&A&&this.element&&this.track&&Bb&&"video"===this.track.kind&&(this.element.srcObject=new MediaStream([this.track])),super.doResume()}stop(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var e;this.isPictureInPicture()&&this.exitPictureInPicture().catch(A=>{}),this.isFullscreen()&&this.exitFullscreen().catch(A=>{}),this.element&&(this.element.removeEventListener(WM.FULLSCREEN_CHANGE,this.handleFullscreenChange),this.element.removeEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.removeEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.removeEventListener("volumechange",this.handleVolumeChange)),super.stop(A),null==(e=this.canvas)||e.remove(),this.removePosterImg(),this._useWrapper&&this._cleanupWrapper()}_cleanupWrapper(){this._wrapper&&0===this._wrapper.children.length&&this._wrapper.remove(),this._wrapper=null}play(A){if(H_(null==A?void 0:A.isLiveStream)||this.setLiveMode(A.isLiveStream),this.element){if(this.elementToRender&&this.container)if(this._useWrapper){let A=this._getOrCreateWrapper();this.elementToRender.parentElement!==A&&A.insertBefore(this.elementToRender,A.firstChild)}else this.elementToRender.parentElement!==this.container&&this.container.append(this.elementToRender)}else this.initializeElement();return 2===this.mode?Promise.resolve():super.play()}get elementToRender(){return this.canvas||this.element}setTrack(A){A!==this.track&&(this.unbindTrackEvents(),this.track=A,this.emit(oU.MEDIA_TRACK_CHANGED,A),null!==A&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([A]),this.element.remove()),this._appendToWrapper()))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let A=document.createElement("canvas");return A.width=this.element.videoWidth,A.height=this.element.videoHeight,A.getContext("2d").drawImage(this.element,0,0),A.toDataURL("image/png")}getElement(){return this.element}calculateStat(){try{if(GL()&&this.element&&this._calculateTimeout<0){let A=0,e=null,t=(i,o)=>{this.stat.width=o.width,this.stat.height=o.height,e&&(this.stat.fps=Math.round((o.presentedFrames-e.presentedFrames)/(i-A)*1e3)),A=i,e=o,this._calculateTimeout=-1,this.element&&(this._calculateTimeout=setTimeout(()=>{var A;return null==(A=this.element)?void 0:A.requestVideoFrameCallback(t)},2e3))};this.element.requestVideoFrameCallback(t)}}catch(A){this._log.warn("init stat failed",A)}}enterFullscreen(){return VS(this,null,function*(){let A=this.elementToRender;if(!A)throw this._log.warn("no element to render, cannot enter fullscreen"),new Error("No element available for fullscreen");if(gN&&this.isPictureInPicture()){this._log.info("exit pip before entering fullscreen");try{yield this.exitPictureInPicture()}catch(e){this._log.warn("exit pip failed before fullscreen:",e)}}try{if(A.requestFullscreen)yield A.requestFullscreen();else if(A.webkitRequestFullscreen)yield A.webkitRequestFullscreen();else if(A.webkitEnterFullscreen)yield A.webkitEnterFullscreen();else if(A.mozRequestFullScreen)yield A.mozRequestFullScreen();else{if(!A.msRequestFullscreen)throw new Error("Fullscreen API not supported");yield A.msRequestFullscreen()}this._log.info("entered fullscreen mode")}catch(e){throw this._log.error("failed to enter fullscreen:",e),e}})}exitFullscreen(){return VS(this,null,function*(){try{if(!this.isFullscreen())return;if(document.exitFullscreen)yield document.exitFullscreen();else if(document.webkitExitFullscreen)yield document.webkitExitFullscreen();else if(document.mozCancelFullScreen)yield document.mozCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Exit fullscreen API not supported");yield document.msExitFullscreen()}this._log.info("exited fullscreen mode")}catch(A){throw this._log.error("failed to exit fullscreen:",A),A}})}isFullscreen(){let A=this.elementToRender;return!!A&&(this.element&&this.element.webkitDisplayingFullscreen?!this.isPictureInPicture():(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)===A)}toggleFullscreen(){return VS(this,null,function*(){this.isFullscreen()?yield this.exitFullscreen():yield this.enterFullscreen()})}enterPictureInPicture(){return VS(this,null,function*(){this.enterPIPPromise=this._enterPictureInPicture();try{return yield this.enterPIPPromise}finally{delete this.enterPIPPromise}})}_enterPictureInPicture(){return VS(this,null,function*(){try{if(!this.element)throw new Error("No video element available for pip");if(this.canvas&&1!==this.mode)throw new Error("pip is not supported for canvas-only mode");let{element:A}=this;if(A.requestPictureInPicture){this._log.info("requestPictureInPicture");let e=yield A.requestPictureInPicture();return this.pipWindow=e,this._log.info("entered pip mode"),this.elementToRender===this.canvas&&(this.canvas.remove(),this._appendToWrapper(this.element)),e}if(A.webkitSetPresentationMode)return this._log.info("webkitSetPresentationMode"),yield A.webkitSetPresentationMode("picture-in-picture"),this._log.info("entered pip mode (webkit)"),{};throw new Error("pip API not supported")}catch(A){throw this._log.error("failed to enter pip:",A.name,A.message),A}})}exitPictureInPicture(){return VS(this,null,function*(){var A;try{if(!this.isPictureInPicture())return;if(delete this.pipWindow,document.pictureInPictureElement&&document.exitPictureInPicture)yield document.exitPictureInPicture(),this.elementToRender===this.canvas&&(null==(A=this.element)||A.remove(),this._pausedRetryCount=JR,this._appendToWrapper(this.canvas)),this._log.info("exited pip mode");else{if(!this.element||!this.element.webkitSetPresentationMode)throw new Error("Exit pip API not supported or not in PiP mode");yield this.element.webkitSetPresentationMode("inline"),this._log.info("exited pip mode (webkit)")}}catch(e){throw this._log.error("failed to exit pip:",e),e}})}isPictureInPicture(){if(!this.element)return!1;let{element:A}=this;return document.pictureInPictureElement?document.pictureInPictureElement===A:!!A.webkitPresentationMode&&"picture-in-picture"===A.webkitPresentationMode}togglePictureInPicture(){return VS(this,null,function*(){this.isPictureInPicture()?yield this.exitPictureInPicture():yield this.enterPictureInPicture()})}};function xU(A,e){return VS(this,null,function*(){if(!A.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield A.audioWorklet.addModule(e),sG.info("worklet addModule success")}catch(t){throw sG.info("worklet addModule catch error. ".concat(t.message)),t}})}"undefined"!=typeof AudioContext?FU=AudioContext:"undefined"!=typeof webkitAudioContext?FU=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(FU=mozAudioContext);var PU,YU=1500,JU=-1,HU=0,qU=-1,VU=!1,jU=0,KU=-1,WU=-1;!function A(){try{if(PU)return;(PU=new FU({sampleRate:48e3})).onstatechange=()=>{sG.info("context state: ".concat(PU.state).concat("running"!==PU.state?" visibilityState: ".concat(document.visibilityState):"")),zU()},clearTimeout(JU)}catch(kd){sG.error("initAudioContext failed: ".concat(kd," typeof AudioContextClass: ").concat(typeof FU)),JU=setTimeout(A,1e3)}}();var zU=()=>{"suspended"===PU.state?(HU=oT(),-1===qU&&(qU=setTimeout(()=>{"suspended"===PU.state&&(VU=!0,tG.emit("155",{isSuspended:!0}))},YU)),$U(),document.addEventListener("click",zU)):"interrupted"===PU.state?$U():(HU&&(Gk.addNumber({key:507800,value:oT()-HU,split:[0,500,1e3,1500,2e3,3e3,4e3,5e3,1e4,3e4],max:6e4}),HU=0),-1!==qU&&(clearTimeout(qU),qU=-1,VU&&(VU=!1,tG.emit("155",{isSuspended:!1}))),document.removeEventListener("visibilitychange",zU),document.removeEventListener("click",zU))},ZU=0,XU=-1;function $U(){return new Promise((A,e)=>{if("running"===PU.state)return A();Date.now()-ZU<1e3?(clearTimeout(XU),XU=setTimeout(()=>{ZU=Date.now(),PU.resume().then(A,e)},1e3)):(clearTimeout(XU),ZU=Date.now(),PU.resume().then(A,e))}).catch(A=>{sG.warn("context resume failed: ".concat(A)),document.addEventListener("visibilitychange",zU)})}document.addEventListener("click",zU);var AF=A=>PU,eF=class{constructor(A){this.name=A,HS(this,"node"),HS(this,"node2"),HS(this,"pre",new Set),HS(this,"next",new Set),HS(this,"context"),HS(this,"connectedNodes",new Set),HS(this,"nextInputChannelMap",new Map),HS(this,"_channelCount",1)}get channelCount(){return this._channelCount}set channelCount(A){this._channelCount=A,this.setChannelCount(this.node,A),this.setChannelCount(this.node2,A),this.next.forEach(e=>e.channelCount=A)}setChannelCount(A,e){!A||A instanceof ScriptProcessorNode||(A.channelCountMode="explicit",A.channelCount=e||this.channelCount||1)}setContext(A){this.context=A,this.node&&A.addMixWeight()}removeContext(){var A;this.node&&(null==(A=this.context)||A.reduceMixWeight()),delete this.context}replaceNode(A){var e;if(A!==this.node)try{this.node?this._disconnect():null==(e=this.context)||e.addMixWeight(),this.node=A,this.setChannelCount(this.node),this.preNodeReconnect(),this.reconnect()}catch(t){sG.error(t)}}setNode(A,e){var t;if(!this.node)try{null==(t=this.context)||t.addMixWeight(),this.node=A,this.setChannelCount(this.node),e&&(this.node2=e,this.setChannelCount(this.node2)),this.preNodeReconnect(),this.reconnect(),Gk.addSuccessEvent({key:502701})}catch(i){sG.error(i),Gk.addFailedEvent({key:502701,error:i})}}deleteNode(){var A;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(A=this.context)||A.reduceMixWeight(),this.preNodeReconnect(),Gk.addSuccessEvent({key:502702})}catch(e){sG.error(e),Gk.addFailedEvent({key:502702,error:e})}}preNodeReconnect(){this.pre.forEach(A=>{A.node?A.reconnect():A.preNodeReconnect()})}connectNext(A){this.next.forEach(e=>{let t=this.nextInputChannelMap.get(e);A._connect(e.node,t)||e.connectNext(A)})}_connect(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!this.node||!A||((this.node2||this.node).connect(A,0,e),this.connectedNodes.add(A),0))}_disconnect(){this.connectedNodes.forEach(A=>{var e;return null==(e=this.node2||this.node)?void 0:e.disconnect(A)}),this.connectedNodes.clear()}reconnect(){this._disconnect(),this.connectNext(this)}pipeTo(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.next.add(A),A.pre.add(this),this.nextInputChannelMap.set(A,e),A}},tF=class extends eF{constructor(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=A,HS(this,"dataArray",new Uint8Array(0))}setNode(A){A.fftSize=this.fftSize,this.dataArray=new Uint8Array(A.frequencyBinCount),super.setNode(A)}getByteTimeDomainData(){var A;return null==(A=this.node)||A.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var A;return null==(A=this.node)||A.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let A=this.getByteTimeDomainData(),e=0,t=0,i="M".concat(e,",").concat(t);for(let o=0;o0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=A,this.mixWeight-1==A+1>>1&&this.mixOnChange()}reduceMixWeight(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-A)}close(){this.inputs.forEach(A=>A.remove())}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},rF=new WeakMap;function sF(A){try{let e=rF.get(A);if(e)return e;let t=AF();if(A instanceof HTMLAudioElement)e=t.createMediaElementSource(A);else{if(!(A instanceof MediaStreamTrack))return A;e=t.createMediaStreamSource(new MediaStream([A]))}return rF.set(A,e),e}catch(e){if(!(dN&&e instanceof Error&&"NotSupportedError"===e.name))throw e;sG.warn(e)}}var aF=class A{constructor(A){HS(this,"_volume",0),HS(this,"_volumeDb",0),HS(this,"_log"),HS(this,"_scriptProcessorNode",null),HS(this,"_audioWorkletNode",null),HS(this,"_interval",200),HS(this,"ready",this.preload());let{log:e}=A;this._log=e,tG.on(oG.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-A.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(!A.workletReady){let e='class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(it+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);';A.workletReady=xU(A.audioContext,URL.createObjectURL(new Blob([e],{type:"application/javascript"})))}return A.workletReady.then(()=>this.initAudioWorklet()).catch(A=>(this._log.error("volumeMeter preload error: ".concat(A)),this.initScriptProcessor()))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(A.audioContext,"volume-meter");let e=!1;this._audioWorkletNode.port.onmessage=t=>{A.lastMessageTime=Date.now(),this._volume=t.data.volume||0,this._volumeDb=t.data.volumeDb||0,!e&&t.data.cacheLen&&t.data.outputLen&&(this._log.warn("worklet play success"),e=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(e){this._log.error("volumeMeter init audio worklet error: ".concat(e)),gU.logFailedEvent({userId:this._log.userId,eventType:wR.LOAD_WORKLET,error:e}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=AF().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=e=>{A.lastMessageTime=Date.now();let t=e.inputBuffer.getChannelData(0),i=0;for(let A=0;A>2);A.copyTo(t,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:t},[t.buffer]),A.close()}}},lF=gF,IF=YS(jS(),1),uF=A=>e=>e.deviceId===A,EF=class{constructor(A,e){HS(this,"kind"),HS(this,"type"),HS(this,"devices",[]),this.kind=A,this.type=e}update(A,e){let t=A.filter(A=>A.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase()));1===this.devices.length&&CF(this.devices[0])||e&&(t.forEach(A=>{if(A.deviceId&&!this.devices.find(uF(A.deviceId))){let t="".concat(this.kind).concat(this.type,"Added");sG.warn("".concat(t,": ").concat(JSON.stringify(A))),e.emit(t,A)}}),this.devices.forEach(A=>{if(A.deviceId&&!t.find(uF(A.deviceId))){let t="".concat(this.kind).concat(this.type,"Removed");sG.warn("".concat(t,": ").concat(JSON.stringify(A))),e.emit(t,A)}})),this.devices=t}hasDevice(A){return!!this.devices.find(e=>e.deviceId===A)}},dF=class extends IF.EventEmitter{constructor(){super(),HS(this,"audioInputs",new EF(WM.AUDIO,"Input")),HS(this,"videoInputs",new EF(WM.VIDEO,"Input")),HS(this,"audioOutputs",new EF(WM.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",()=>this.update()),"ondevicechange"in navigator.mediaDevices||iU.run("interval",()=>{this.update()},{delay:1e4}))}init(){BF().then(A=>{this.audioInputs.update(A),this.videoInputs.update(A),this.audioOutputs.update(A)})}update(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let t=yield BF(e);return A.audioInputs.update(t,A),A.videoInputs.update(t,A),A.audioOutputs.update(t,A),A}()})}hasBlueTooth(){var A;if(1e3*(null==(A=AF())?void 0:A.outputLatency)>150)return!0;let e=["bluetooth","air","wireless","bt","tws","buds","headset","headphone"];return this.audioOutputs.devices.some(A=>e.some(e=>A.label.toLowerCase().includes(e)))||this.audioInputs.devices.some(A=>e.some(e=>A.label.toLowerCase().includes(e)))}},hF=mM||fM?null:new dF;function CF(A){return A.deviceId===A.groupId&&""===A.groupId}function BF(){return VS(this,arguments,function(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(Yk()||!xk())return[];let e=yield navigator.mediaDevices.enumerateDevices();if(0!==A){let i={audio:!1,video:!1};if(e.forEach(A=>{CF(A)&&(A.kind===WM.AUDIO_INPUT?i.audio=!0:A.kind===WM.VIDEO_INPUT&&(i.video=!0))}),2===A&&(i.audio=!1),1===A&&(i.video=!1),i.audio||i.video){let A;try{A=yield navigator.mediaDevices.getUserMedia(i),i.audio&&$U()}catch(t){sG.debug("capture before getDevices failed: ",t)}e=yield navigator.mediaDevices.enumerateDevices(),null==A||A.getTracks().forEach(A=>A.stop())}}return e.map((A,e)=>{let t={kind:A.kind,deviceId:A.deviceId,groupId:A.groupId,label:A.label||"".concat(A.kind,"_").concat(e)};return A.deviceId.length>0&&yF.add("".concat(A.deviceId,"_").concat(A.kind)),A.getCapabilities&&(t.getCapabilities=()=>A.getCapabilities()),t})}()})}function QF(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return hF.update(A?1:0).then(A=>A.audioInputs.devices)}function pF(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return hF.update(A?2:0).then(A=>A.videoInputs.devices)}var fF=!1;function mF(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return VS(this,null,function*(){return(gN||fb)&&(A=!1),hF.update(A?1:0).then(A=>A.audioOutputs.devices)})}var yF=new Set;function DF(A,e){return VS(this,null,function*(){let t=(yield QF()).find(A=>A.deviceId===HR);return!e&&(null==t?void 0:t.groupId)===A||(null==t?void 0:t.groupId)===A&&t.label===e})}var vF,wF=class extends iF{constructor(A){super(),this.log=A,HS(this,"volumeMeter"),HS(this,"volumeMeterAfter3A"),HS(this,"volumeDestination"),HS(this,"analyser",new tF),this.volumeMeter=new cF({log:this.log}),this.volumeMeterAfter3A=new cF({log:this.log}),this.volumeDestination=new eF,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},SF=class A extends uU{constructor(A){super(A,WM.AUDIO),HS(this,"_outputDeviceId"),HS(this,"_floatVolume",1),HS(this,"_destination"),HS(this,"pipeline"),HS(this,"volumeMeterMode","worklet"),HS(this,"enableVolumeControlInIOS"),this.enableVolumeControlInIOS=A.enableVolumeControlInIOS,this.mode=0,A.url&&(this.url=A.url),this.pipeline=new wF(this._log)}setTrack(A){}get duration(){var A;return Math.floor(1e3*((null==(A=this.element)?void 0:A.duration)||0))}get currentTime(){var A;return Math.floor(1e3*((null==(A=this.element)?void 0:A.currentTime)||0))}set currentTime(A){this.element&&(this.element.currentTime=A/1e3)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(A){if(("15.2"===vb||"15.3"===vb||"15.4"===vb)&&this.muted)return void this._log.info("audioElement is muted.");let e=vF||new Audio;e.setAttribute("autoplay","autoplay"),e.srcObject=this.getMediaStream(),e.muted=this.muted,this.url&&(e.crossOrigin="anonymous",e.src=this.url),this.element=e,this.setVolume(V_(A)?A/100:this._floatVolume),e===vF&&(vF=void 0),this.options.enableTimeupdateEvent&&(this.element.ontimeupdate=()=>this.emit(oU.TIME_UPDATE,this.currentTime)),this.bindElementEvents()}play(e){return VS(this,null,function*(){if(this.track||this.url){try{!this.pipeline.source.node&&this.track&&this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?(this.pipeline.volumeMeter.init(),this.pipeline.volumeMeterAfter3A.init()):"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(AF().createAnalyser()),function(){VS(this,null,function*(){try{fF||(fF=!0,sG.info("speakers:".concat((yield mF()).map(A=>" ".concat(A.deviceId.slice(0,8),": ").concat(A.label)))))}catch(A){}})}()}catch(t){throw this._log.warn("audio play error: ".concat(t)),(RN||GN)&&Sb(vb,"18.7",!0)&&this.bindAutoPlayEvent(),t}return qS(A.prototype,this,"play").call(this)}})}stop(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(A)}setVolume(A){this._floatVolume=A,this.element&&(this.element.volume=A)}setSinkId(A){return VS(this,null,function*(){var e,t;this._outputDeviceId!==A&&(this._outputDeviceId=A),this.element&&this.element.sinkId!==A&&(yield null==(t=(e=this.element).setSinkId)?void 0:t.call(e,A))})}get useDestination(){return!!this.pipeline.stream}setLoop(A){this.element&&(this.element.loop=A)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}getInternalAudioLevelAfter3A(){return this.pipeline.volumeMeterAfter3A.getInternalAudioLevel()}},MF=class extends SF{setTrack(A){this.track!==A&&(this.unbindTrackEvents(),this.track=A,this.emit(oU.MEDIA_TRACK_CHANGED,A),A&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([A]))))}},RF=class extends SF{constructor(A){super(A),HS(this,"_sourceElement"),HS(this,"_output",new eF),this.pipeline.source.pipeTo(this.pipeline.gain),this.pipeline.gain.pipeTo(this.pipeline.volumeMeter).pipeTo(this._output),this.pipeline.gain.pipeTo(this.pipeline.destination)}setOutput(){this.mode=1,this._output.setNode(AF().destination)}write(A){this.pipeline.volumeMeter.write(A)}setTrack(A){var e,t,i;(null==(t=null==(e=this.element)?void 0:e.error)?void 0:t.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==A&&(this.unbindTrackEvents(),this.track=A,this.emit(oU.MEDIA_TRACK_CHANGED,A),A?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([A]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([A])),this.pipeline.source.channelCount=(null==(i=A.getSettings())?void 0:i.channelCount)||1,this.pipeline.replaceSource(A)):this.pipeline.source.deleteNode())}setVolume(A){var e;let t=A<=1&&!cN();if(this._floatVolume!==A||!(t&&(null==(e=this.element)?void 0:e.volume)===A||!t&&this.pipeline.volume===A))if(this._floatVolume=A,this.useDestination)this.pipeline.setVolume(A),this._log.info("set pipeline volume: ".concat(A));else if(t)this.element?(this._log.info("set element volume: ".concat(A)),this.element.volume=A):this._log.info("set element volume: no element");else{if(cN()){if(!this.enableVolumeControlInIOS)return;!function(){if(!gN||-1!==WU)return;let A=()=>{oT()-jU<500||(PU&&"running"===PU.state&&PU.currentTime===KU&&(sG.warn("context is fake running, auto resume"),PU.suspend().catch(A=>{sG.warn("context suspend failed: ".concat(A))})),KU=PU.currentTime,jU=oT())};WU=setInterval(()=>{A()},2e3),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&A()})}()}if(dN&&!this.pipeline.source.node)return void this._log.warn("set pipeline volume failed: no source node");this._log.info("start set pipeline volume: ".concat(A)),this.pipeline.setVolume(A),this.element&&!this._sourceElement&&(this._destination||(this._destination=AF().createMediaStreamDestination()),this.pipeline.destination.setNode(this._destination),aU(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play().catch(A=>{this.emit(oU.AUTOPLAY_FAILED,A)}))}}stop(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let e=this._sourceElement||this.element;e&&mb&&(vF=e),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(A)}},_F=class extends ZL{constructor(A){let{userId:e,sdkAppId:t,mediaType:i,room:o,PlayerClass:n=(1===i?RF:OU)}=A;var r;super(),HS(this,"id",aG()),HS(this,"userId",""),HS(this,"isRemote"),HS(this,"mediaType"),HS(this,"room"),HS(this,"user"),HS(this,"_log"),HS(this,"_inputTrack"),HS(this,"_outputTrack"),HS(this,"isPlayCalled"),HS(this,"container",null),HS(this,"player"),HS(this,"subVideoPlayerMap"),HS(this,"muted",!1),HS(this,"abortCtrl"),HS(this,"objectFit","cover"),HS(this,"mirror"),HS(this,"rotation"),HS(this,"isScreen",!1),HS(this,"manager"),HS(this,"trackSettings"),HS(this,"isFirstVideoFrameEmitted",!1),this.userId=e||"",this.mediaType=i,this._log=sG.createLogger({parent:null==o?void 0:o.getLogger(),id:"".concat(this.kind[0],"t"),userId:null==(r=o||this.room)?void 0:r.userId,remoteUserId:this instanceof hP?void 0:this.userId,sdkAppId:t,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof hP}),this.player=new n({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log,enableVolumeControlInIOS:null==o?void 0:o.enableVolumeControlInIOS}),this.player.on(oU.PLAYER_STATE_CHANGED,A=>{if(tG.emit(oG.PLAYER_STATE_CHANGED,US({track:this},A)),this.emit("player-state-changed",A),"PLAYING"===A.state&&this.room){let A=!0;for(let{remoteAudioTrack:e,remoteVideoTrack:t,remoteAuxiliaryTrack:i}of[...this.room.remotePublishedUserMap.values()])if(e.isAvailable&&!e.player.isPlaying||t.isAvailable&&!t.player.isPlaying||i.isAvailable&&!i.player.isPlaying){A=!1;break}A&&TU()&&LU&&LU.deleteDialog()}}),this.kind===WM.VIDEO&&(this.player.on(oU.LOADED_DATA,()=>{this.emitFirstVideoFrameEvent(oU.LOADED_DATA),tG.emit(oG.VIDEO_LOADED_DATA,{track:this})}),this.player.on(oU.LOADED_META_DATA,()=>{this.emitFirstVideoFrameEvent(oU.LOADED_META_DATA)}),this.player.on(oU.MEDIA_TRACK_CHANGED,A=>{var e;null==(e=this.subVideoPlayerMap)||e.forEach(e=>e.setTrack(A))}),this.player.on(oU.RESIZE,A=>{this.emitFirstVideoFrameEvent(oU.RESIZE),this.emit("video-size-changed",US({userId:this.userId,streamType:2===this.mediaType?"auxiliary":"main"},A))})),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this),this.onPlayerError&&this.player.on(oU.ERROR,this.onPlayerError.bind(this)),this.player.on(oU.AUTOPLAY_FAILED,this.handleAutoPlayFailed,this)}get log(){return this._log||sG}get kind(){return 1===this.mediaType?WM.AUDIO:WM.VIDEO}get isAudio(){return this.kind===WM.AUDIO}get strMediaType(){return 4===this.mediaType?WM.VIDEO:2===this.mediaType?WM.SCREEN:WM.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled}play(A,e){return VS(this,null,function*(){let t=W_(A)?A[0]:A;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(e))),e&&!H_(e.muted)&&this.setPlayerMute(e.muted),e&&!H_(e.objectFit)&&(this.objectFit=e.objectFit),void(this.player instanceof OU&&(this.player.setObjectFit(this.objectFit),this.container!==t&&t&&(W_(A)&&A.length>=1&&this.container&&A.includes(this.container)&&this.container.contains(this.player.elementToRender)?(A.splice(A.indexOf(this.container),1),A.unshift(this.container)):(this.container=t,this.player.setContainer(t))),W_(A)&&A.length>=1&&(yield this.playSubContainer(A.slice(1),e))));if(e&&!H_(e.muted)?this.setPlayerMute(e.muted):(!this.isRemote||this.kind===WM.VIDEO)&&this.setPlayerMute(!0),e&&!H_(e.objectFit)&&(this.objectFit=e.objectFit),this.player instanceof OU&&(H_(null==e?void 0:e.isLiveStream)||this.player.setLiveMode(e.isLiveStream),this.player.setObjectFit(this.objectFit),e&&!H_(e.poster)&&this.player.setPoster(e.poster)),this.isPlayCalled=!0,t&&(this.container=t,this.player instanceof OU&&this.player.setContainer(t)),tG.emit(oG.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(e)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(e),W_(A)&&A.length>1&&(yield this.playSubContainer(A.slice(1),e))}catch(i){throw this.handleAutoPlayFailed(i),i}}else this.log.info("play has not mediaTrack, abort")})}setMirror(A,e){if(this.isScreen||this.kind!==WM.VIDEO||H_(A)||A===this.mirror)return;this.mirror=A;let t=this.player;e&&(t=e);let i=this.manager;if(j_(this.mirror))return t.setViewMirror(this.mirror),void(!this.isRemote&&i&&(i.mirror=!1));switch(this.mirror){case"view":i&&(i.mirror=!1),t.setViewMirror(!0);break;case"publish":i&&(i.mirror=!0),t.setViewMirror(!0);break;case"both":i&&(i.mirror=!0),t.setViewMirror(!1)}}playSubContainer(A,e){return VS(this,null,function*(){if(!this._outputTrack||this.kind===WM.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach((e,t)=>{var i;A.find(A=>t===A)||(e.stop(),null==(i=this.subVideoPlayerMap)||i.delete(t))});for(let[i,o]of A.entries()){let A=this.subVideoPlayerMap.get(o);A?e&&(H_(e.objectFit)||A.setObjectFit(e.objectFit)):this.subVideoPlayerMap.set(o,new OU({id:this.userId||this.id,track:this.playerMediaTrack,container:o,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let t=[...this.subVideoPlayerMap.values()];for(let A of t)A.setViewMirror(this.player.mirror),yield A.play()})}setAudioOutput(A){return this.player.setSinkId(A)}setAudioVolume(A){this.player.setVolume(A)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var A;return(null==(A=this.player)?void 0:A.getInternalAudioLevel())||0}stop(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.isFirstVideoFrameEmitted=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(KT(this)&&!A?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach(A=>{A.stop()}),this.container=null)}resume(){return VS(this,null,function*(){var A;this.isPlayCalled&&(yield null==(A=this.player)?void 0:A.resume())})}close(){this._toInitState(),this.log.info("close"),this.isPlayCalled&&this.stop(!0)}_toInitState(){}setMute(A){this.muted=A,this._inputTrack&&(this._inputTrack.enabled=!A),this._outputTrack&&(this._outputTrack.enabled=!A),this.emit(A?"mute":"unmute",this),tG.emit(A?oG.TRACK_MUTED:oG.TRACK_UNMUTED,{track:this})}setPlayerMute(A){this.player.setMuted(A)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}get playerMediaTrack(){return this.outMediaTrack}installTrackEvent(A){sU(A,A).add(WM.MUTE,this.onTrackMuted).add(WM.UNMUTE,this.onTrackUnmuted).add(WM.ENDED,this.onTrackEnded),A.muted&&this.onTrackMuted(),A.readyState===WM.ENDED&&this.onTrackEnded()}uninstallTrackEvent(A){aU(A)}setInputMediaStreamTrack(A){var e;let t=this._inputTrack;if(A!==t)return this._inputTrack=A,this.trackSettings=null==(e=A.getSettings)?void 0:e.call(A),A.enabled=!this.muted,t&&this.uninstallTrackEvent(t),this.installTrackEvent(A),this.emit("input-media-track-changed",A||null,t||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(A)}setOutputMediaStreamTrack(A){var e,t,i;let o=this._outputTrack;null!=o&&o.canvas&&null!=(t=null==(e=o.canvas)?void 0:e.id)&&t.includes("trtc_mix")||A!==o&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",A.label):this.log.info("setOutputMediaStreamTrack",null==(i=A.getSettings)?void 0:i.call(A).deviceId,A.label),this._outputTrack=A,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!A),this.emit("output-media-track-changed",A))}setMediaType(A){this.mediaType=A}updatePlayingState(A){var e,t;if(this.isPlayCalled)if(A){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch(A=>this.handleAutoPlayFailed(A)),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped){if(KT(this)&&this.isAudio&&null!=(e=this.user)&&e.muteState.hasAudio&&null!=(t=this.user)&&t.muteState.audioMuted)return;return this.player.stop(KT(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind))}this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(A," ").concat(this.player.isStopped))}handleAutoPlayFailed(A){return VS(this,null,function*(){var e;this.log.warn("handleAutoPlayFailed",A);let t=()=>{this.resume().then(()=>{document.removeEventListener("click",t,!0)})};if(this.room&&this.room.enableAutoPlayDialog){if((RN||GN)&&(yield DT(100),null!=(e=this.player)&&e.isPlaying))return;UU()}else document.addEventListener("click",t,!0);tG.once(oG.LOCAL_TRACK_CAPTURE_SUCCESS,A=>{let{track:e}=A;"audio"===e.kind&&TU()&&!this.player.isPlaying&&this.isRemote&&this.isAvailable&&t()}),this.emit("error",A)})}getVideoFrame(){return this.player instanceof OU?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(A){var e,t,i;if(this.isFirstVideoFrameEmitted)return;let o=null==(e=this.mediaTrack)?void 0:e.getSettings(),n=(null==o?void 0:o.width)||(null==(t=this.player.element)?void 0:t.videoWidth)||0,r=(null==o?void 0:o.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;A===oU.RESIZE&&!n&&!r||A===oU.LOADED_META_DATA&&!n&&!r||(A===oU.LOADED_DATA&&!n&&!r&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,RT(this.rotation)&&([n,r]=[r,n]),this.emit("first-video-frame",{width:n,height:r,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}onTrackMuted(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}onTrackUnmuted(){this._log.info("".concat(this.kind," track is able to provide media output"))}onTrackEnded(){this._log.warn("".concat(this.kind," track ended"))}};JS([KL([],ZL.INIT,{sync:!0})],_F.prototype,"_toInitState",1);var TF=Object.prototype.hasOwnProperty,NF=function(A){if(null==A)return!0;if("boolean"==typeof A)return!1;if("number"==typeof A)return 0===A;if("string"==typeof A||"function"==typeof A||Array.isArray(A))return 0===A.length;if(A instanceof Error)return""===A.message;if(O_(A))switch(Object.prototype.toString.call(A)){case"[object File]":case"[object Map]":case"[object Set]":return 0===A.size;case"[object Object]":for(let e in A)if(TF.call(A,e))return!1;return!0}return!1};function bF(A,e){return VS(this,null,function*(){let t=(e?yield pF():yield QF()).find(e=>e.deviceId===A);t&&J_(t.getCapabilities)&&sG.warn(CT(t.getCapabilities(),{keysToInclude:ZR}))})}function GF(A){if(!A.audio)return!1;if(A.useTrueAsConstraint)return!0;let e={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:A.sampleRate};return!NF(A.microphoneId)&&(e.deviceId=A.useExactDeviceId?{exact:A.microphoneId}:A.microphoneId,A.useDeviceIdOnly)?e:(V_(A.channelCount)&&(e.channelCount=A.channelCount),(j_(A.echoCancellation)||"remote-only"===A.echoCancellation||"all"===A.echoCancellation)&&(e.echoCancellation=A.echoCancellation),j_(A.noiseSuppression)&&!A.noiseSuppression&&(e.noiseSuppression=!1),j_(A.autoGainControl)&&!A.autoGainControl&&(e.autoGainControl=!1),!!NF(e)||e)}function kF(A){if(!A.video)return!1;if(A.useTrueAsConstraint)return!0;let{maxResolution:e=!0}=A,t={};return A.cameraId?t.deviceId=A.useExactDeviceId?{exact:A.cameraId}:A.cameraId:A.facingMode&&(t.facingMode=A.facingMode),A.useDeviceIdOnly&&!NF(t)?t:(A.width&&(t.width={ideal:A.width},e&&!dN&&(t.width.max=A.width)),A.height&&(t.height={ideal:A.height},e&&!dN&&(t.height.max=A.height)),dN&&VN&&A.width&&A.height&&A.width*A.height<101376&&(t.width=A.width,t.height=A.height),A.frameRate&&(t.frameRate=A.frameRate),!!NF(t)||t)}var LF=zT({retryFunction:function(A){return VS(this,null,function*(){let e={audio:GF(t=A),video:kF(t)};var t;sG.info("getUserMedia with constraints: ".concat(JSON.stringify(e)));let i=[],o=[],n=["label","deviceId","groupId"];if(e.audio&&(i=yield QF(),sG.info("microphones: ".concat(CT(i.map(A=>FS(US({},A),{groupId:A.groupId.substring(0,8)})),{keysToInclude:n})))),e.video&&(o=yield pF(),sG.info("cameras: ".concat(CT(o,{keysToInclude:n}))),!j_(e.video)&&"user"===e.video.facingMode&&!e.video.deviceId)){let A=o.filter(A=>!A.label.includes("infrared")).find(A=>A.label.includes("facing front"));A&&(e.video.deviceId=A.deviceId,sG.info("exclude infrared camera: ".concat(JSON.stringify(e))))}try{let t=yield navigator.mediaDevices.getUserMedia(e);return pL&&t.getTracks().forEach(e=>{var t;let i=e.getCapabilities();sG.info("".concat(e.kind," capabilities: ").concat(CT(i,{keysToInclude:ZR}))),!H_(A.echoCancellation)&&-1===(null==(t=i.echoCancellation)?void 0:t.indexOf(A.echoCancellation))&&sG.warn("Invalid argument for 'echoCancellation'. Expected one of [".concat(JSON.stringify(i.echoCancellation),"], but received '").concat(A.echoCancellation,"'"))}),e.audio&&$U(),t}catch(r){let{message:e}=r;throw"NotFoundError"===r.name&&(A.video&&o&&0===o.length&&(e=mk({key:Bk.CAMERA_NOT_FOUND})),A.audio&&i&&0===i.length&&(e=mk({key:Bk.MICROPHONE_NOT_FOUND}))),new rM({code:oM.INITIALIZE_FAILED,name:r.name,message:e,constraint:r.constraint})}})},settings:{retries:3,timeout:500},onError:A=>{let{error:e,retry:t,reject:i,retryFuncArgs:o,retriedCount:n}=A,r=n+1;"NotReadableError"===e.name||"OverconstrainedError"===e.name||"AbortError"===e.name?(1===r?(o[0].video&&(o[0].maxResolution=!1,(!fb||o[0].width*o[0].height<=2073600)&&o[0].frameRate&&(o[0].frameRate=o[0].frameRate>10?10:5)),o[0].retryWhenExactFailed&&o[0].useExactDeviceId&&(o[0].useExactDeviceId=!1)):2===r?o[0].useDeviceIdOnly=!0:3===r&&!o[0].useExactDeviceId&&(o[0].useTrueAsConstraint=!0),t()):i(e),o[0].microphoneId&&bF(o[0].microphoneId,!1),o[0].cameraId&&bF(o[0].cameraId,!0)},onRetrying:A=>{sG.warn("getUserMedia NotReadableError observed, retrying [".concat(A,"/3]"))},onRetryFailed:A=>{gU.logFailedEvent({eventType:wR.GET_USER_MEDIA_RETRY,error:A})},onRetrySuccess:A=>{gU.logSuccessEvent({eventType:wR.GET_USER_MEDIA_RETRY}),gU.uploadEvent({log:"stat-".concat(wR.GET_USER_MEDIA_RETRY,"-success-").concat(A)})}});function UF(A){return xF((e,t)=>function(){for(var t=arguments.length,i=new Array(t),o=0;ofunction(){for(var t=arguments.length,i=new Array(t),o=0;ofunction(){for(var t=arguments.length,i=new Array(t),o=0;o{let A=!1,e=document.visibilityState;return()=>{document.visibilityState!==e&&sG.info("visibility change: ".concat(document.visibilityState)),!A&&(document.addEventListener("visibilitychange",()=>{sG.info("visibility change: ".concat(document.visibilityState)),e=document.visibilityState}),A=!0)}})(),YF=0,JF=class{constructor(A){HS(this,"log"),HS(this,"isRunning",!1),HS(this,"queue",[]);let e="fq".concat(++YF);A&&(e+="|".concat(A)),this.log=sG.createLogger({id:e})}get length(){return this.queue.length}get lastQueueItem(){return 0===this.length?null:this.queue[this.length-1]}push(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var t,i;let o=US({},A),n=new Promise((A,e)=>{o.resolve=A,o.reject=e});return o.promise=n,e?this.length<=1?this.queue.push(o):null==(i=null==(t=this.lastQueueItem)?void 0:t.promise)||i.then(o.resolve,o.reject):this.queue.push(o),this.log.debug("push ".concat(this.length),A.funcName,A.args),this.isRunning||this.callNext(),n}shift(){let A=this.queue.shift();return this.log.debug("shift ".concat(this.length),null==A?void 0:A.funcName,null==A?void 0:A.args),A}callNext(){if(this.isRunning||0===this.length)return;let{fn:A,args:e,context:t,resolve:i,reject:o,funcName:n}=this.queue[0];this.log.debug("callNext",this.length,n,e),this.isRunning=!0,A.apply(t,e).then(i,o).finally(()=>{this.isRunning=!1,this.shift(),this.callNext()})}},HF=new WeakMap,qF=new WeakMap;function VF(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(e,t,i){let o=i.value;return i.value=function(){let e=HF.get(this)||new JF;for(var i=arguments.length,n=new Array(i),r=0;rn.push(A)),null==(i=qF.get(this))||i.forEach(A=>null==A?void 0:A.queue.forEach(A=>n.push(A))),n.forEach(e=>{e.reject(new rM({code:oM.API_CALL_ABORTED,message:A}))}),HF.delete(this),qF.delete(this),o.apply(this,s)},i}}function KF(A,e){return function(t,i,o){let n=o.value,r=e=>A(...e);return o.value=function(){for(var A=arguments.length,t=new Array(A),o=0;ofunction(){let i=A;try{for(var o=arguments.length,n=new Array(o),r=0;r(e?Gk.addSuccessEvent({key:i,cost:oT()-s}):Gk.addSuccessEvent({key:i}),A)).catch(A=>{throw Gk.addFailedEvent({key:i,error:A}),A}):(Gk.addSuccessEvent({key:i}),A)}catch(s){throw Gk.addFailedEvent({key:i,error:s}),s}})}var zF={};function ZF(){}PS(zF,{Events:()=>IO,Inspect:()=>iO,LastSink:()=>oO,Sink:()=>nO,Subscribe:()=>rO,TimeoutError:()=>uO,audit:()=>px,bindCallback:()=>WO,bindNodeCallback:()=>zO,buffer:()=>wO,bufferCount:()=>vO,bufferTime:()=>iP,call:()=>XF,catchError:()=>nP,combineLatest:()=>fO,concat:()=>BO,concatMap:()=>qx,concatMapTo:()=>Vx,count:()=>tx,create:()=>aO,debounce:()=>yx,debounceTime:()=>Dx,defer:()=>RO,delay:()=>oP,deliver:()=>gO,dispose:()=>AO,elementAt:()=>vx,empty:()=>$O,every:()=>_x,exhaustMap:()=>$x,exhaustMapTo:()=>AP,expand:()=>sP,filter:()=>rx,find:()=>wx,findIndex:()=>Sx,first:()=>Mx,fromAnimationFrame:()=>jO,fromArray:()=>LO,fromEvent:()=>PO,fromEventPattern:()=>xO,fromFetch:()=>JO,fromIterable:()=>HO,fromPromise:()=>YO,fromReadableStream:()=>VO,fromReader:()=>qO,groupBy:()=>eP,identity:()=>$F,ignoreElements:()=>sx,iif:()=>pO,inspect:()=>eO,interval:()=>UO,last:()=>Rx,map:()=>Gx,mapTo:()=>kx,max:()=>ix,merge:()=>hO,mergeMap:()=>Wx,mergeMapTo:()=>zx,min:()=>ox,never:()=>ZO,nothing:()=>ZF,of:()=>kO,pairwise:()=>Nx,pipe:()=>sO,race:()=>CO,range:()=>KO,reduce:()=>ex,retry:()=>uP,scan:()=>Tx,setAsapScheduler:()=>bO,share:()=>dO,shareReplay:()=>QO,skip:()=>Ix,skipUntil:()=>ux,skipWhile:()=>Ex,startWith:()=>yO,subject:()=>MO,subscribe:()=>cP,sum:()=>nx,switchMap:()=>xx,switchMapTo:()=>Yx,take:()=>ax,takeLast:()=>lx,takeUntil:()=>gx,takeWhile:()=>cx,tap:()=>lP,throttle:()=>Bx,throwError:()=>XO,timeInterval:()=>tP,timeout:()=>IP,timer:()=>FO,toPromise:()=>aP,toReadableStream:()=>gP,withLatestFrom:()=>DO,zip:()=>mO});var XF=A=>A(),$F=A=>A;function AO(){this.dispose()}var eO=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,tO=1,iO=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(A){let e=new lO(A,this,this.streamId++);return IO.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},oO=class{constructor(){this.defers=new Set,this.disposed=!1}next(A){}complete(){this.dispose()}error(A){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=ZF,this.error=ZF,this.next=ZF,this.dispose=ZF,this.subscribe=ZF,this.doDefer()}subscribe(A){return A instanceof iO?A.subscribe(this):A(this),this}get bindSubscribe(){return A=>this.subscribe(A)}doDefer(){this.defers.forEach(XF),this.defers.clear()}defer(A){this.defers.add(A)}removeDefer(A){this.defers.delete(A)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},nO=class extends oO{constructor(A){super(),this.sink=A,A.defer(this.bindDispose)}next(A){this.sink.next(A)}complete(){this.sink.complete()}error(A){this.sink.error(A)}},rO=class extends oO{constructor(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZF,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ZF,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ZF;if(super(),this._next=e,this._error=t,this._complete=i,this.then=ZF,A instanceof iO){let o={toString:()=>"subscribe",id:0,source:A};this.defer(()=>{IO.defer(o,0)}),IO.create(o),IO.pipe(o),this.sourceId=o.id,this.subscribe(A),IO.subscribe({id:o.id,end:!0}),e==ZF?this._next=A=>IO.next(o,0,A):this.next=A=>{IO.next(o,0,A),e(A)},i==ZF?this._complete=()=>IO.complete(o,0):this.complete=()=>{this.dispose(),IO.complete(o,0),i()},t==ZF?this._error=A=>IO.complete(o,0,A):this.error=A=>{this.dispose(),IO.complete(o,0,A),t(A)}}else this.subscribe(A)}next(A){this._next(A)}complete(){this.dispose(),this._complete()}error(A){this.dispose(),this._error(A)}};function sO(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;ie(A),A)}function aO(A,e,t){if(eO()){let i=Object.defineProperties(Object.setPrototypeOf(A,iO.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:e,writable:!0,configurable:!0},args:{value:t,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});IO.create(i);for(let A=0;A{if(t instanceof iO){let o=aO(e=>{let n=new A(e,...i);n.sourceId=o.id,n.subscribe(t)},e,arguments);return o.source=t,IO.pipe(o),o}return e=>t(new A(e,...i))}}}function cO(A,e){window.postMessage({source:"fastrx-devtools-backend",payload:{event:A,payload:e}})}var lO=class extends nO{constructor(A,e,t){super(A),this.source=e,this.id=t,this.sourceId=A.sourceId,this.defer(()=>{IO.defer(this.source,this.id)})}next(A){IO.next(this.source,this.id,A),this.sink.next(A)}complete(){IO.complete(this.source,this.id),this.sink.complete()}error(A){IO.complete(this.source,this.id,A),this.sink.error(A)}},IO={addSource(A,e){cO("addSource",{id:A.id,name:A.toString(),source:{id:e.id,name:e.toString()}})},next(A,e,t){cO("next",{id:A.id,streamId:e,data:t&&t.toString()})},subscribe(A,e){let{id:t,end:i}=A;cO("subscribe",{id:t,end:i,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(A,e,t){cO("complete",{id:A.id,streamId:e,err:t?t.toString():null})},defer(A,e){cO("defer",{id:A.id,streamId:e})},pipe(A){cO("pipe",{name:A.toString(),id:A.id,source:{id:A.source.id,name:A.source.toString()}})},update(A){cO("update",{id:A.id,name:A.toString()})},create(A){A.id||(A.id=tO++),cO("create",{name:A.toString(),id:A.id})}},uO=class extends Error{constructor(A){super("timeout after ".concat(A,"ms")),this.timeout=A}},EO=class extends oO{constructor(A){super(),this.source=A,this.sinks=new Set}add(A){A.defer(()=>this.remove(A)),1===this.sinks.add(A).size&&(this.reset(),this.subscribe(this.source))}remove(A){this.sinks.delete(A),0===this.sinks.size&&this.dispose()}next(A){this.sinks.forEach(e=>e.next(A))}complete(){this.sinks.forEach(A=>A.complete()),this.sinks.clear()}error(A){this.sinks.forEach(e=>e.error(A)),this.sinks.clear()}};function dO(){return A=>{let e=new EO(A);if(A instanceof iO){let t=aO(A=>{e.add(A)},"share",arguments);return e.sourceId=t.id,t.source=A,IO.pipe(t),t}return aO(e.add.bind(e),"share",arguments)}}function hO(){for(var A=arguments.length,e=new Array(A),t=0;t{let t=new nO(A),i=e.length;t.complete=()=>{0===--i&&A.complete()},e.forEach(t.bindSubscribe)},"merge",arguments)}function CO(){for(var A=arguments.length,e=new Array(A),t=0;t{let t=new Map;e.forEach(e=>{let i=new nO(A);t.set(e,i),i.complete=()=>{t.delete(e),0===t.size?A.complete():i.dispose()},i.next=A=>{t.delete(e),t.forEach(A=>A.dispose()),i.resetNext(),i.resetComplete(),i.next(A)}}),e.forEach(A=>t.get(A).subscribe(A))},"race",arguments)}function BO(){for(var A=arguments.length,e=new Array(A),t=0;t{let t=0,i=e.length,o=new nO(A);o.complete=()=>{t{let t=new EO(e),i=[];return t.next=function(e){i.push(e),i.length>A&&i.shift(),this.sinks.forEach(A=>A.next(e))},aO(A=>{A.defer(()=>t.remove(A)),i.forEach(e=>A.next(e)),t.add(A)},"shareReplay",arguments)}}function pO(A,e,t){return aO(i=>A()?e(i):t(i),"iif",arguments)}function fO(){for(var A=arguments.length,e=new Array(A),t=0;t{let t=e.length,i=t,o=t,n=new Array(t),r=()=>{0===--o&&A.complete()};e.forEach((e,t)=>{let o=new nO(A);o.next=e=>{i--,o.next=e=>{n[t]=e,0===i&&A.next(n)},o.next(e)},o.complete=r,o.subscribe(e)})},"combineLatest",arguments)}function mO(){for(var A=arguments.length,e=new Array(A),t=0;t{let t=e.length,i=t,o=new Array(t),n=()=>{0===--i&&A.complete()};e.forEach((e,t)=>{let i=new nO(A),r=[];o[t]=r,i.next=e=>{r.push(e),o.every(A=>A.length)&&A.next(o.map(A=>A.shift()))},i.complete=n,i.subscribe(e)})},"zip",arguments)}function yO(){for(var A=arguments.length,e=new Array(A),t=0;taO(function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length;for(;i1?t-1:0),o=1;othis.buffer=A,e.complete=ZF,e.subscribe(fO(...i))}next(A){this.buffer&&this.sink.next([A,...this.buffer])}},"withLatestFrom"),vO=gO(class extends nO{constructor(A,e,t){super(A),this.bufferSize=e,this.startBufferEvery=t,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(A){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(A)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(A),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(A=>this.sink.next(A)),super.complete()}},"bufferCount"),wO=gO(class extends nO{constructor(A,e){super(A),this.buffer=[];let t=new nO(A);t.next=e=>{A.next(this.buffer),this.buffer=[]},t.complete=ZF,t.subscribe(e)}next(A){this.buffer.push(A)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},"buffer"),SO=function(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})};function MO(A){let e=arguments,t=dO()(aO(e=>{t.next=A=>e.next(A),t.complete=()=>e.complete(),t.error=A=>e.error(A),A&&e.subscribe(A)},"subject",e));return t.next=ZF,t.complete=ZF,t.error=ZF,t}function RO(A){return aO(e=>e.subscribe(A()),"defer",arguments)}var _O={promise:A=>{Promise.resolve().then(A)},setImmediate:"undefined"!=typeof setImmediate?A=>setImmediate(A):null,setTimeout:A=>setTimeout(A,0)},TO="undefined"!=typeof Promise?_O.promise:_O.setImmediate?_O.setImmediate:_O.setTimeout,NO=A=>e=>{TO(()=>A(e))},bO=A=>{"function"==typeof A?TO=A:_O[A]&&(TO=_O[A])},GO=A=>NO(e=>{for(let t=0;!e.disposed&&t{let t=0,i=setInterval(()=>e.next(t++),A);return e.defer(()=>{clearInterval(i)}),"interval"},"interval",arguments)}function FO(A,e){return aO(t=>{let i=0,o=setTimeout(()=>{if(t.removeDefer(n),t.next(i++),e){let A=setInterval(()=>t.next(i++),e);t.defer(()=>{clearInterval(A)})}else t.complete()},A),n=()=>clearTimeout(o);t.defer(n)},"timer",arguments)}function OO(A,e){return t=>{let i=A=>t.next(A);t.defer(()=>e(i)),A(i)}}function xO(A,e){return aO(OO(A,e),"fromEventPattern",arguments)}function PO(A,e){if("on"in A&&"off"in A)return aO(OO(t=>A.on(e,t),t=>A.off(e,t)),"fromEvent",arguments);if("addListener"in A&&"removeListener"in A)return aO(OO(t=>A.addListener(e,t),t=>A.removeListener(e,t)),"fromEvent",arguments);if("addEventListener"in A)return aO(OO(t=>A.addEventListener(e,t),t=>A.removeEventListener(e,t)),"fromEvent",arguments);throw"target is not a EventDispachter"}function YO(A){return aO(e=>{A.then(A=>{e.next(A),e.complete()},e.error.bind(e))},"fromPromise",arguments)}function JO(A,e){return aO(RO(()=>YO(fetch(A,e))),"fromFetch",arguments)}function HO(A){return aO(NO(e=>{try{for(let t of A){if(e.disposed)return;e.next(t)}e.complete()}catch(t){e.error(t)}}),"fromIterable",arguments)}function qO(A){let e=t=>SO(this,void 0,void 0,function*(){try{if(t.disposed)return;let{done:i,value:o}=yield A.read();if(i)return void t.complete();t.next(o),e(t)}catch(i){t.error(i)}});return aO(A=>{e(A)},"fromReader",arguments)}function VO(A){return aO(e=>{let t=new AbortController,i=t.signal;e.defer(()=>t.abort("cancelled")),A.pipeTo(new WritableStream({write(A){e.next(A)},close(){e.complete()},abort(A){e.error(A)}}),{signal:i}).then(()=>e.complete(),A=>e.error(A))},"fromReadableStream",arguments)}function jO(){return aO(A=>{let e=requestAnimationFrame(function t(i){A.disposed||(A.next(i),e=requestAnimationFrame(t))});A.defer(()=>cancelAnimationFrame(e))},"fromAnimationFrame",arguments)}function KO(A,e){return aO(function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:A,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e+A;for(;i2?t-2:0),o=2;o{let o=i.concat(A=>(t.next(A),t.complete()));A.apply(e,o)},"bindCallback",arguments)}function zO(A,e){for(var t=arguments.length,i=new Array(t>2?t-2:0),o=2;o{let o=i.concat((A,e)=>A?t.error(A):(t.next(e),t.complete()));A.apply(e,o)},"bindNodeCallback",arguments)}function ZO(){return aO(()=>{},"never",arguments)}function XO(A){return aO(e=>e.error(A),"throwError",arguments)}function $O(){return aO(A=>A.complete(),"empty",arguments)}var Ax=class extends nO{constructor(A,e,t){super(A),this.f=e;let i=()=>{this.sink.next(this.acc),this.sink.complete()};void 0===t?this.next=A=>{this.acc=A,this.complete=i,this.resetNext()}:(this.acc=t,this.complete=i)}next(A){this.acc=this.f(this.acc,A)}},ex=gO(Ax,"reduce"),tx=A=>gO(Ax,"count")((e,t)=>A(t)?e+1:e,0),ix=()=>gO(Ax,"max")(Math.max),ox=()=>gO(Ax,"min")(Math.min),nx=()=>gO(Ax,"sum")((A,e)=>A+e,0),rx=gO(class extends nO{constructor(A,e,t){super(A),this.filter=e,this.thisArg=t}next(A){this.filter.call(this.thisArg,A)&&this.sink.next(A)}},"filter"),sx=gO(class extends nO{next(A){}},"ignoreElements"),ax=gO(class extends nO{constructor(A,e){super(A),this.count=e}next(A){this.sink.next(A),0===--this.count&&(this.doDefer(),this.complete())}},"take"),gx=gO(class extends nO{constructor(A,e){super(A);let t=new nO(A);t.next=()=>{t.doDefer(),A.complete()},t.complete=AO,t.subscribe(e)}},"takeUntil"),cx=gO(class extends nO{constructor(A,e){super(A),this.f=e}next(A){this.f(A)?this.sink.next(A):(this.doDefer(),this.complete())}},"takeWhile"),lx=A=>ex((e,t)=>(e.push(t),e.length>A&&e.shift(),e),[]),Ix=gO(class extends nO{constructor(A,e){super(A),this.count=e}next(A){0===--this.count&&(this.next=super.next)}},"skip"),ux=gO(class extends nO{constructor(A,e){super(A),A.next=ZF;let t=new nO(A);t.next=()=>{t.doDefer(),A.resetNext()},t.complete=AO,t.subscribe(e)}},"skipUntil"),Ex=gO(class extends nO{constructor(A,e){super(A),this.f=e}next(A){this.f(A)||(this.next=super.next,this.next(A))}},"skipWhile"),dx={leading:!0,trailing:!1},hx=class extends nO{constructor(A,e,t){super(A),this.durationSelector=e,this.trailing=t}cacheValue(A){this.last=A,this.disposed&&this.throttle(A)}send(A){this.sink.next(A),this.throttle(A)}throttle(A){this.reset(),this.subscribe(this.durationSelector(A))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Cx=class extends nO{constructor(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:dx;super(A),this.durationSelector=e,this.config=t,this._throttle=new hx(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(A){this._throttle.disposed&&this.config.leading?this._throttle.send(A):this._throttle.cacheValue(A)}complete(){this._throttle.throttle=ZF,this._throttle.complete(),super.complete()}},Bx=gO(Cx,"throttle"),Qx={leading:!1,trailing:!0},px=A=>gO(Cx,"audit")(A,Qx),fx=class extends nO{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},mx=class extends nO{constructor(A,e){super(A),this.durationSelector=e,this._debounce=new fx(this.sink),this._debounce.dispose()}next(A){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=A,this._debounce.subscribe(this.durationSelector(A))}complete(){this._debounce.complete(),super.complete()}},yx=gO(mx,"debounce"),Dx=A=>gO(mx,"debounceTime")(e=>FO(A)),vx=gO(class extends nO{constructor(A,e,t){super(A),this.count=e,this.defaultValue=t}next(A){0===this.count--&&(this.defaultValue=A,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("not enough elements in sequence"))}},"elementAt"),wx=A=>e=>ax(1)(Ex(e=>!A(e))(e)),Sx=gO(class extends nO{constructor(A,e){super(A),this.f=e,this.i=0}next(A){this.f(A)?(this.sink.next(this.i++),this.doDefer(),this.complete()):++this.i}},"findIndex"),Mx=gO(class extends nO{constructor(A,e,t){super(A),this.f=e,this.defaultValue=t,this.index=0}next(A){(!this.f||this.f(A,this.index++))&&(this.defaultValue=A,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"first"),Rx=gO(class extends nO{constructor(A,e,t){super(A),this.f=e,this.defaultValue=t,this.index=0}next(A){(!this.f||this.f(A,this.index++))&&(this.defaultValue=A)}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"last"),_x=gO(class extends nO{constructor(A,e){super(A),this.predicate=e,this.index=0}next(A){this.predicate(A,this.index++)?this.result=!0:(this.result=!1,this.doDefer(),this.complete())}complete(){void 0!==this.result?(this.sink.next(this.result),super.complete()):this.error(new Error("no elements in sequence"))}},"every"),Tx=gO(class extends nO{constructor(A,e,t){super(A),this.f=e,void 0===t?this.next=A=>{this.acc=A,this.resetNext(),this.sink.next(this.acc)}:this.acc=t}next(A){this.sink.next(this.acc=this.f(this.acc,A))}},"scan"),Nx=gO(class extends nO{constructor(){super(...arguments),this.hasLast=!1}next(A){this.hasLast?this.sink.next([this.last,A]):this.hasLast=!0,this.last=A}},"pairwise"),bx=class extends nO{constructor(A,e,t){super(A),this.mapper=e,this.thisArg=t}next(A){super.next(this.mapper.call(this.thisArg,A))}},Gx=gO(bx,"map"),kx=A=>gO(bx,"mapTo")(e=>A),Lx=class extends nO{constructor(A,e,t){super(A),this.data=e,this.context=t}next(A){let e=this.context.combineResults;e?this.sink.next(e(this.data,A)):this.sink.next(A)}tryComplete(){this.context.resetComplete(),this.dispose()}},Ux=class A extends nO{constructor(A,e,t){super(A),this.makeSource=e,this.combineResults=t,this.index=0}subInner(e,t){let i=this.currentSink=new t(this.sink,e,this);this.complete===A.prototype.complete&&(this.complete=this.tryComplete),i.complete=i.tryComplete,i.subscribe(this.makeSource(e,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Fx=class extends Lx{},Ox=class extends Ux{next(A){this.subInner(A,Fx),this.next=A=>{this.currentSink.dispose(),this.subInner(A,Fx)}}},xx=gO(Ox,"switchMap");function Px(A){return(e,t)=>A(()=>e,t)}var Yx=Px(gO(Ox,"switchMapTo")),Jx=class extends Lx{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Hx=class extends Ux{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(A){this.next2(A),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Jx),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}tryComplete(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}},qx=gO(Hx,"concatMap"),Vx=Px(gO(Hx,"concatMapTo")),jx=class extends Lx{tryComplete(){this.context.inners.delete(this),super.dispose(),0===this.context.inners.size&&this.context.resetComplete()}},Kx=class extends Ux{constructor(){super(...arguments),this.inners=new Set}next(A){this.subInner(A,jx),this.inners.add(this.currentSink)}tryComplete(){1===this.inners.size?this.inners.forEach(A=>A.resetComplete()):this.dispose()}},Wx=gO(Kx,"mergeMap"),zx=Px(gO(Kx,"mergeMapTo")),Zx=class extends Lx{dispose(){this.context.resetNext(),super.dispose()}},Xx=class extends Ux{next(A){this.next=ZF,this.subInner(A,Zx)}},$x=gO(Xx,"exhaustMap"),AP=Px(gO(Xx,"exhaustMapTo")),eP=gO(class extends nO{constructor(A,e){super(A),this.f=e,this.groups=new Map}next(A){let e=this.f(A),t=this.groups.get(e);void 0===t&&(t=MO(),t.key=e,this.groups.set(e,t),super.next(t)),t.next(A)}complete(){this.groups.forEach(A=>A.complete()),super.complete()}error(A){this.groups.forEach(e=>e.error(A)),super.error(A)}},"groupBy"),tP=gO(class extends nO{constructor(){super(...arguments),this.start=new Date}next(A){this.sink.next({value:A,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},"timeInterval"),iP=gO(class extends nO{constructor(A,e){super(A),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(A){this.buffer.push(A)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},"bufferTime"),oP=gO(class extends nO{constructor(A,e){super(A),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(A){this.timeoutId=setTimeout(()=>{let A=this.buffer.shift();if(A){let{time:e,data:t}=A;super.next(t),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(e))}},A)}next(A){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:A})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},"delay"),nP=gO(class extends nO{constructor(A,e){super(A),this.selector=e}error(A){this.dispose(),this.selector(A)(this.sink)}},"catchError"),rP=class extends Lx{tryComplete(){let A=this.context.inners.delete(this);super.dispose(),A&&this.context.checkComplete()}next(A){this.sink.next(A),this.context.expandValue(A)}},sP=gO(class extends Ux{constructor(A,e){super(A,e),this.project=e,this.inners=new Set,this.sourceCompleted=!1}next(A){this.sink.next(A),this.expandValue(A)}expandValue(A){let e=new rP(this.sink,A,this);this.currentSink=e,this.complete=this.tryComplete,e.complete=e.tryComplete,this.inners.add(e),e.subscribe(this.makeSource(A,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&0===this.inners.size&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}},"expand"),aP=()=>A=>new Promise((e,t)=>{let i;new rO(A,A=>i=A,t,()=>e(i))}),gP=()=>A=>{let e;return new ReadableStream({start(t){e=new rO(A,t.enqueue.bind(t),t.error.bind(t),t.close.bind(t))},cancel(){e.dispose()}})},cP=function(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ZF,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZF,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ZF;return i=>new rO(i,A,e,t)},lP=gO(class extends nO{constructor(A,e){super(A),e instanceof Function?this.next=t=>{e(t),A.next(t)}:(e.next&&(this.next=t=>{e.next(t),A.next(t)}),e.complete&&(this.complete=()=>{e.complete(),A.complete()}),e.error&&(this.error=t=>{e.error(t),A.error(t)}))}},"tap"),IP=gO(class extends nO{constructor(A,e){super(A),this.timeout=e,this.id=setTimeout(()=>this.error(new uO(this.timeout)),this.timeout)}next(A){super.next(A),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},"timeout"),uP=function(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return e=>{if(e instanceof iO){let t=aO(i=>{let o=A,n=new nO(i);n.error=A=>{o-- >0?n.subscribe(e):i.error(A)},n.sourceId=t.id,n.subscribe(e)},"retry",[A]);return t.source=e,IO.pipe(t),t}return t=>{let i=A,o=new nO(t);o.error=A=>{i-- >0?e(o):t.error(A)},e(o)}}},EP=(A=>(A[A.AUTO_SWITCH_NEW_DEVICE=0]="AUTO_SWITCH_NEW_DEVICE",A[A.WAIT_CURRENT_DEVICE=1]="WAIT_CURRENT_DEVICE",A))(EP||{}),dP=class A extends _F{constructor(A,e){super({mediaType:A,PlayerClass:e}),HS(this,"isRemote",!1),HS(this,"deviceId"),HS(this,"groupId",""),HS(this,"label",""),HS(this,"sourceTrack"),HS(this,"enableAutoSwitchWhenRecapturing",!0),HS(this,"_isRecapturing",!1),HS(this,"_lastRecaptureTime",0),HS(this,"_onMuteTimeoutId",-1),HS(this,"_encodeCheckTimeoutId",-1),HS(this,"recaptureMode",0),HS(this,"profile"),HS(this,"retryEncodeFailed")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}get isUseCustomSource(){return!(!this.mediaTrack||this.sourceTrack===this.mediaTrack)}encodeFrame(A,e){throw new Error("Method not implemented.")}installTrackEvent(A){A.addEventListener(WM.MUTE,this.onTrackMuted),A.addEventListener(WM.UNMUTE,this.onTrackUnmuted),A.addEventListener(WM.ENDED,this.onTrackEnded),A.muted&&this.onTrackMuted(),A.readyState===WM.ENDED&&this.onTrackEnded()}uninstallTrackEvent(A){A.removeEventListener(WM.MUTE,this.onTrackMuted),A.removeEventListener(WM.UNMUTE,this.onTrackUnmuted),A.removeEventListener(WM.ENDED,this.onTrackEnded)}setStateToReady(){}capture(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return VS(this,null,function*(){var t;let i=this.sourceTrack;try{let i,o=oT();tG.emit(oG.LOCAL_TRACK_CAPTURE_START,{track:this}),A.customSource?(i=new MediaStream,i.addTrack(A.customSource)):(e||null==(t=this.sourceTrack)||t.stop(),i=yield LF(A));let n=i.getTracks()[0];return yield this.setInputMediaStreamTrack(n),A.customSource||(this.sourceTrack=n,this.updateDeviceIdInUse(),this.listenDeviceChange()),tG.emit(oG.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:oT()-o}),i}catch(o){throw tG.emit(oG.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:o}),this.log.error("getUserMedia error observed ".concat(o)),o}finally{e&&(null==i||i.stop())}})}setOutputMediaStreamTrack(A){var e;if(super.setOutputMediaStreamTrack(A),this.setStateToReady(),this.isPublishing||this.isPublished)return null==(e=this.room)?void 0:e.replaceTrack(this)}get hasFlag(){var A,e;let t=gT((null==(A=this.room)?void 0:A.localPublishFlag)||0,(null==(e=this.room)?void 0:e.userId)||"");return 4===this.mediaType&&t.hasVideo||1===this.mediaType&&t.hasAudio||2===this.mediaType&&t.hasAuxiliary}publish(A,e){return VS(this,null,function*(){return this.room=A,this.room.localTracks.add(this),this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=A.userId,this._log.bindParent(A.getLogger()),yield e,this._checkPublishFlag(A)})}_checkPublishFlag(A){return new Promise((e,t)=>VS(this,null,function*(){var i,o,n,r,s;let a=()=>t(new rM({code:oM.API_CALL_ABORTED,message:"publish aborted"}));if(this.hasFlag||this.muted?e():((this.state===ZL.INIT||"ready"===this.state)&&a(),sO(PO(A,"local-publish-flag-changed"),rx(()=>this.hasFlag),gx(hO(PO(this,ZL.INIT),PO(this,"ready"))),cP(e,t,a))),null!=(n=null==(o=null==(i=this.room)?void 0:i.networkQuality)?void 0:o.hadRecentBadUplink)&&n.call(o,2))return e();let g=A.heartbeatCount,c=(null==(s=null==(r=this.mediaTrack)?void 0:r.stats)?void 0:s.totalFrames)||0;this._encodeCheckTimeoutId=setTimeout(()=>VS(this,null,function*(){var i,o,n,r,s,a,l,I;if(null!=(n=null==(o=null==(i=this.room)?void 0:i.networkQuality)?void 0:o.hadRecentBadUplink)&&n.call(o,2)||A.heartbeatCount-g<3)return e();if((this.isPublished||this.isPublishing)&&this.isMediaTrackActive){if(null!=(r=this.mediaTrack)&&r.stats){let A=this.mediaTrack.stats.totalFrames||0;A-c===0&&this.log.warn("capture totalFrames is 0 during encode check, totalFrames",A)}let A=this.kind===WM.AUDIO,i=this.stat.bytesSent>0;if(Gk[i?"addSuccessEvent":"addFailedEvent"]({key:A?503700:513702}),!A){let A={H264:513704,H265:513705,VP8:513706}[(null==(a=null==(s=this.room)?void 0:s.videoCodec)?void 0:a.toUpperCase())||"H264"];A&&Gk[i?"addSuccessEvent":"addFailedEvent"]({key:A})}if(!i){if(Gk.addEnum({key:A?503701:513703,value:zb()}),gU.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(Vb()||Xb()),userId:this.userId}),this.log.warn(A?"encode failed":"".concat(null==(I=null==(l=this.room)?void 0:l.videoCodec)?void 0:I.toUpperCase()," encode failed")),this.retryEncodeFailed&&(this.log.warn("retry encode"),yield this.retryEncodeFailed(this),this.stat.bytesSent>0||this.hasFlag||(yield DT(5e3),this.stat.bytesSent>0||this.hasFlag)))return e();this.emit("6",this),t(new rM({message:"".concat(this.strMediaType," encode failed"),code:A?oM.AUDIO_ENCODE_FAILED:oM.VIDEO_ENCODE_FAILED}))}}}),1e4)}))}unpublish(){this.room&&this.room.localTracks.delete(this),this.log.info("unpublish"),tG.emit(oG.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return VS(this,null,function*(){if(this.sourceTrack&&QL){let{deviceId:A,groupId:e}=this.sourceTrack.getSettings(),{label:t}=this.sourceTrack;(yield function(A){return VS(this,arguments,function(A){let{newDeviceId:e,oldDeviceId:t,oldGroupId:i,oldLabel:o,kind:n}=A;return function*(){return e===t&&(n!==WM.AUDIO||e!==HR||(yield DF(i,o)))}()})}({newDeviceId:A,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=A,this.label=t,e&&(this.groupId=e),BF().then(t=>{let i=t.find(t=>{let i=t.deviceId===A;return e&&(i=i&&t.groupId===e),i});i&&this.emit("2",i)}))}})}setProfile(A){this.log.info("setProfile",A),Object.assign(this.profile,A)}isNeedToRecapture(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.sourceTrack||this.kind===WM.AUDIO&&!function(A){if(A instanceof CanvasCaptureMediaStreamTrack||!(A instanceof MediaStreamTrack))return!1;let e=A.label.toLocaleLowerCase();if(e.includes("mic")||e.includes("麦克风"))return!0;let t="".concat(((null==A?void 0:A.getSettings())||{}).deviceId,"_").concat(WM.AUDIO_INPUT);return!!yF.has(t)}(this.sourceTrack)||this.kind===WM.VIDEO&&!function(A){if(A instanceof CanvasCaptureMediaStreamTrack||!(A instanceof MediaStreamTrack))return!1;let e=A.label.toLocaleLowerCase();if(e.includes("camera")||e.includes("webcam"))return!0;let t="".concat(((null==A?void 0:A.getSettings())||{}).deviceId,"_").concat(WM.VIDEO_INPUT);return!!yF.has(t)}(this.sourceTrack)||this._isRecapturing||A&&VN&&fb)}onTrackMuted(){if(super.onTrackMuted(),PF(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTimethis.onTrackMuted(),zR);this._onMuteTimeoutId=setTimeout(()=>VS(this,null,function*(){var A;if(null!=(A=this.sourceTrack)&&A.muted){if((gN||lN)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}),5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return VS(this,null,function*(){if(qS(A.prototype,this,"onTrackEnded").call(this),this.isNeedToRecapture()&&0===this.recaptureMode){if(Date.now()-this._lastRecaptureTimethis.onTrackEnded(),zR);this.emit("7"),this.recapture(yield this.getRecoverCaptureDeviceId())}})}recapture(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return VS(this,null,function*(){var t;if(this._isRecapturing||!this.sourceTrack)return;this.log.warn("recapture trying");let i=this.sourceTrack;e||null==(t=this.sourceTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let o={useExactDeviceId:!0};if("user"===A||"environment"===A)o.facingMode=A;else{let e;("audio"===this.kind?yield QF():yield pF()).find(e=>e.deviceId===A)&&(e=A),o.deviceId=e}return this.capture(o,e).then(()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),tG.emit(oG.LOCAL_TRACK_RECAPTURE,{track:this})}).catch(A=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(A.message)),this.emit("5",A),tG.emit(oG.LOCAL_TRACK_RECAPTURE,{track:this,error:A})}).finally(()=>{e&&(null==i||i.stop())})})}getRecoverCaptureDeviceId(){return VS(this,null,function*(){let A=this instanceof DP;if(A&&this.facingMode)return this.facingMode;let{deviceId:e}=this;if(e){let t=(CP.get(e)||0)+1;if(CP.set(e,t),t>=3&&this.enableAutoSwitchWhenRecapturing){let i=A?(yield pF()).find(A=>!CP.has(A.deviceId)):(yield QF()).find(A=>!CP.has(A.deviceId));i&&(this.log.warn("".concat(e," capture fail ").concat(t," times, change new ").concat(i.deviceId)),e=i.deviceId)}}return e})}stopCapture(){var A;this.sourceTrack&&(this.sourceTrack.stop(),this.uninstallTrackEvent(this.sourceTrack)),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack),null==(A=this.manager)||A.removeInput(this)}close(){super.close(),this.stopCapture()}};JS([KL(ZL.INIT,"ready",{ignoreError:!0,sync:!0})],dP.prototype,"setStateToReady",1),JS([VF()],dP.prototype,"capture",1),JS([KL("ready","publish",{ignoreError:!0,success(){tG.emit(oG.LOCAL_TRACK_PUBLISHED,{track:this,room:this.room}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),this.log.info("published")},fail(A){var e;null==(e=this.room)||e.localTracks.delete(this);let t="error",i=A instanceof rM?A:A.cause instanceof rM?A.cause:A,o=!1;i instanceof rM&&(i.message.includes("timeout")?t="timeout":i.code===oM.API_CALL_ABORTED&&(o=!0,t="api-call")),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:i}),this.log[o?"info":"error"]("publish failed",i)}}),WF(521714,!1)],dP.prototype,"publish",1),JS([xF(A=>function(){return VS(this,null,function*(){let e="publish"===this.state?"started":"starting";A.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:e,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId)})}),KL([],"ready",{sync:!0})],dP.prototype,"unpublish",1);var hP=dP,CP=new Map;tG.on(oG.SWITCH_DEVICE_SUCCESS,A=>{A.track.deviceId&&CP.delete(A.track.deviceId)});var BP=class A extends hP{constructor(A){super(1,MF),HS(this,"mediaType",1),HS(this,"volume",0),HS(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),HS(this,"playerMuted",!0),HS(this,"pipeline"),HS(this,"earMonitorGainNode",new eF),HS(this,"_output",new eF),HS(this,"codecPipeline",[]),HS(this,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),HS(this,"mixedAudioReferenceMap",new Map),HS(this,"isAudioContextLongSuspended",!1),HS(this,"after3aSilenceStartTime",0),HS(this,"_micMuted",!1),HS(this,"_volumeDetectionTrack",null),HS(this,"_volumeDetectionSource",new eF),this.manager=A,this.pipeline=new oF(A),this.pipeline.source.pipeTo(this.player.pipeline.volumeMeter),this.pipeline.gain.pipeTo(this.earMonitorGainNode).pipeTo(this._output),this.pipeline.gain.pipeTo(this.player.pipeline.volumeMeterAfter3A),this._volumeDetectionSource.pipeTo(this.player.pipeline.volumeMeter),this.handleMicrophoneAdded=this.handleMicrophoneAdded.bind(this),this.handleMicrophoneRemoved=this.handleMicrophoneRemoved.bind(this),tG.on(oG.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this)}get dbVolume(){return lF.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}getAudioLevel(){let A=(this.volume||super.getAudioLevel())*this.captureVolume;return A>1?1:A}getInternalAudioLevelAfter3A(){if(this.pipeline.isProcessEnabled)return this.player.getInternalAudioLevelAfter3A()}updateAfter3aSilenceStartTime(A){H_(A)||(0!==A||this.after3aSilenceStartTime?A>0&&(this.after3aSilenceStartTime=0):this.after3aSilenceStartTime=oT())}setInputMediaStreamTrack(e){return VS(this,null,function*(){let t=this.trackSettings||{};Gk.addEnum({key:501701,value:t.channelCount||0,useUV:!1}),Gk.addEnum({key:501702,value:t.sampleRate||0,useUV:!1}),Gk.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:o}=t;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:o}))),this.pipeline.source.channelCount=o||1,this.pipeline.replaceSource(e),yield qS(A.prototype,this,"setInputMediaStreamTrack").call(this,e),this.updatePlayingState(!!e)})}capture(e){return VS(this,arguments,function(e){var t=this;let{deviceId:i,customSource:o,useExactDeviceId:n=!0,retryWhenExactFailed:r}=e,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function*(){let e=yield qS(A.prototype,t,"capture").call(t,{video:!1,audio:!0,microphoneId:i,echoCancellation:t.profile.echoCancellation,autoGainControl:t.profile.autoGainControl,noiseSuppression:t.profile.noiseSuppression,sampleRate:t.profile.sampleRate,channelCount:t.profile.channelCount,useExactDeviceId:n,retryWhenExactFailed:r,customSource:o},s);return $U(),e}()})}switchDevice(A){return VS(this,null,function*(){if(this.mediaTrack){if(this.deviceId===A&&!this.isUseCustomSource){if(A!==HR)return;if(yield DF(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(A)),this.sourceTrack&&this.sourceTrack.stop(),yield this.capture({deviceId:A,useExactDeviceId:!0,retryWhenExactFailed:!1}),tG.emit(oG.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(e){throw this.log.error("switch microphone failed ".concat(e)),this.deviceId&&this.recapture(this.deviceId),e}}})}listenDeviceChange(){hF&&!hF.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&hF.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(A){return VS(this,null,function*(){if(A.deviceId===this.deviceId){let e=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(EP[this.recaptureMode],". Current microphone is lost: ").concat(JSON.stringify(A))),0===this.recaptureMode){lY(this.userId,{eventId:2003,param1:6,streamType:1});let A=yield QF();A[0]?this.recapture(A[0].deviceId):e=!0}e&&hF.on("audioInputAdded",this.handleMicrophoneAdded,this)}})}handleMicrophoneAdded(A){1===this.recaptureMode&&A.deviceId!==this.deviceId||(hF.off("audioInputAdded",this.handleMicrophoneAdded,this),this.log.warn("microphone added: ".concat(JSON.stringify(A))),this.recapture(A.deviceId))}update3A(A){return VS(this,arguments,function(A){var e=this;let{echoCancellation:t,noiseSuppression:i,autoGainControl:o}=A;return function*(){let A=e.sourceTrack||e.mediaTrack;if(!A)return;let n=A.getConstraints(),r=!1;!H_(t)&&t!==e.profile.echoCancellation&&(e.profile.echoCancellation=t,n.echoCancellation=t,r=!0),!H_(i)&&i!==e.profile.noiseSuppression&&(e.profile.noiseSuppression=i,n.noiseSuppression=i,r=!0),!H_(o)&&o!==e.profile.autoGainControl&&(e.profile.autoGainControl=o,n.autoGainControl=o,r=!0),r&&(dN||fb?yield A.applyConstraints(n).catch(A=>e._log.warn("update3A failed: ",A)):e.deviceId&&(yield e.recapture(e.deviceId,!0)))}()})}get captureVolume(){return this.pipeline.volume}setCaptureVolume(A){this.pipeline.setVolume(A/100),this.pipeline.gain.node&&Gk.addEnum({key:502700,value:2})}setMute(A,e){var t;this._cleanupVolumeDetectionTrack(),"microphone"===A?(this._micMuted=!0,this.sourceTrack&&(this.sourceTrack.enabled=!1),e&&this._setupVolumeDetectionTrack(),(null==(t=this.manager)?void 0:t.mixWeight)<=1?(this.muted=!0,this._inputTrack&&(this._inputTrack.enabled=!1),this._outputTrack&&(this._outputTrack.enabled=!1),this.emit("mute",this),tG.emit(oG.TRACK_MUTED,{track:this})):this._outputTrack&&(this._outputTrack.enabled=!0)):!0===A?(this._micMuted=!1,this.muted=!0,this.sourceTrack&&(this.sourceTrack.enabled=!1),this._inputTrack&&(this._inputTrack.enabled=!1),this._outputTrack&&(this._outputTrack.enabled=!1),e&&this._setupVolumeDetectionTrack(),this.emit("mute",this),tG.emit(oG.TRACK_MUTED,{track:this})):(this._micMuted=!1,this.muted=!1,this.sourceTrack&&(this.sourceTrack.enabled=!0),this._inputTrack&&(this._inputTrack.enabled=!0),this._outputTrack&&(this._outputTrack.enabled=!0),this.emit("unmute",this),tG.emit(oG.TRACK_UNMUTED,{track:this}))}_setupVolumeDetectionTrack(){let A=this.sourceTrack||this.mediaTrack;if(!A)return;this._volumeDetectionTrack=A.clone(),this._volumeDetectionTrack.enabled=!0;let e=sF(this._volumeDetectionTrack);e&&this._volumeDetectionSource.setNode(e)}_cleanupVolumeDetectionTrack(){this._volumeDetectionTrack&&(this._volumeDetectionTrack.stop(),this._volumeDetectionTrack=null),this._volumeDetectionSource.deleteNode()}get isMicMuted(){return this._micMuted}setAudioVolume(A){super.setAudioVolume(0),gN&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(AF().createGain()),this._output.setNode(AF().destination)),this.earMonitorGainNode.node.gain.value=A}enableTrackANS(A){return this.update3A({noiseSuppression:A})}enableTrackAEC(A){if(this.sourceTrack&&!fb&&!gN)return this.update3A({echoCancellation:A})}addDenoiser(A){var e;Cb<=92&&48e3!==(null==(e=this.trackSettings)?void 0:e.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(Gk.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(A),this.enableTrackANS(!1))}mixAudioReference(A,e){if(this.mixedAudioReferenceMap.has(e))return;this.log.info("mixAudioReference() => ".concat(e));let t=sF(A);if(!t)return;let i=new eF,o=AF().createGain();o.gain.value=1;let n=new eF;i.pipeTo(n).pipeTo(this.pipeline.mixNode),i.setNode(t),n.setNode(o),this.mixedAudioReferenceMap.set(e,[i,n])}unMixAudioReference(A){let[e,t]=this.mixedAudioReferenceMap.get(A)||[];e&&(this.log.info("unMixAudioReference() => ".concat(A)),e.deleteNode(),null==t||t.deleteNode(),this.mixedAudioReferenceMap.delete(A))}setAudioReferenceVolume(A,e){let[t,i]=this.mixedAudioReferenceMap.get(A)||[];null!=i&&i.node&&(i.node.gain.value=e/100,this.log.info("setAudioReferenceVolume() => ".concat(A," ").concat(i.node.gain.value)))}addAudioProcessor(A,e,t){this.pipeline.silentNode.setNode(t),this.pipeline.mixNode.setNode(e),this.pipeline.aec.setNode(A)}removeDenoiser(A){if(this.pipeline.denoiser.node===A)return this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0)}removeAudioProcessor(A){this.pipeline.aec.node===A&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode())}close(){this._cleanupVolumeDetectionTrack(),this.mixedAudioReferenceMap.forEach(A=>{let[e,t]=A;e.deleteNode(),t.deleteNode()}),this.mixedAudioReferenceMap.clear(),this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),hF.off("audioInputAdded",this.handleMicrophoneAdded,this),hF.off("audioInputRemoved",this.handleMicrophoneRemoved,this),tG.off(oG.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this),super.close()}recapture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return VS(this,null,function*(){try{yield qS(A.prototype,this,"recapture").call(this,e,t)}catch(i){let t=(yield QF()).find(A=>A.deviceId!==e);if(!t)throw i;yield qS(A.prototype,this,"recapture").call(this,t.deviceId)}})}encodeFrame(A){return this.manager?this.manager.encodePipeline.reduceRight((A,e)=>e?e({frame:A,ntp:lM()}):A,A):A}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some(A=>A)}get enableEncryptFrame(){return this.manager&&!!this.manager.encodePipeline[0]}handleAudioContextLongSuspended(A){let{isSuspended:e}=A;if(this.pipeline.isProcessEnabled)if(e){this.isAudioContextLongSuspended=!0,this.log.warn("context has suspended for ".concat(1.5," seconds, change to source audio").concat(mb?"":", non-Safari"));let A=this.sourceTrack||this.mediaTrack;A&&this.setOutputMediaStreamTrack(A)}else this.isAudioContextLongSuspended=!1,this.log.warn("context has resumed, change to processed audio"),this.pipeline.track&&this.setOutputMediaStreamTrack(this.pipeline.track)}setOutputMediaStreamTrack(A){if(this.isAudioContextLongSuspended){let e=this.sourceTrack||this.mediaTrack;e&&(A=e)}super.setOutputMediaStreamTrack(A)}};function QP(A,e){return e+4<=A.byteLength&&0===A.getUint8(e)&&0===A.getUint8(e+1)&&0===A.getUint8(e+2)&&1===A.getUint8(e+3)?4:e+3<=A.byteLength&&0===A.getUint8(e)&&0===A.getUint8(e+1)&&1===A.getUint8(e+2)?3:0}function pP(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=new DataView(A),i=[],o=0;for(;o0){n=e;break}let r=-1===n?t.byteLength:n,s=r-o,a=new ArrayBuffer(s),g=new DataView(a);for(let e=0;e1&&void 0!==arguments[1]&&arguments[1];this.dataView=A,this.isSEI&&(e?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let{seiPayloadStartIndex:A}=this,e=this.dataView.byteLength-2,t=[],i=0;for(let n=A;n<=e;n++){let A=this.dataView.getInt8(n);switch(A){case 0:case 1:case 2:case 3:2===i&&(t.push(3),i=0),0===A?i+=1:i=0,t.push(A);break;default:i=0,t.push(A)}}t.push(this.dataView.getInt8(this.dataView.byteLength-1));let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,A),...t]).buffer);this.dataView=o}removePreventionByte(){let{seiPayloadStartIndex:A}=this,e=this.dataView.byteLength-1,t=[],i=0;for(let n=A;n<=e;n++)switch(this.dataView.getInt8(n)){case 0:i++,t.push(this.dataView.getInt8(n));break;case 3:2!==i&&t.push(this.dataView.getInt8(n)),i=0;break;default:t.push(this.dataView.getInt8(n)),i=0}let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,A),...t]).buffer);this.dataView=o}get seiPayloadStartIndex(){let A=6;for(let e=6;e=this.dataView.byteLength?0:31&this.dataView.getUint8(A)}getStartCodeLength(){return this.dataView.byteLength>=4&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&0===this.dataView.getUint8(2)&&1===this.dataView.getUint8(3)?4:this.dataView.byteLength>=3&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&1===this.dataView.getUint8(2)?3:0}get isIDR(){return 5===this.naluType}get isSPS(){return 7===this.naluType}get isPPS(){return 8===this.naluType}get isSEI(){return 6===this.naluType}},mP=class{constructor(){HS(this,"_seiMessageList",[]),HS(this,"_smallSeiMessageList",[]),HS(this,"_seiPayloadType",243)}encodeSEINalu(A){let e=A.byteLength,t=parseInt(String(e/255),10),i=e%255,o=[];o.push(0,0,0,1,6,this._seiPayloadType);for(let r=0;r0&&A.data.byteLength>0){let e=9-this.getNaluCount(A.data);if(e<=0)return 0;let i=t.splice(0,e).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce((A,e)=>A+e.dataView.byteLength,0),n=new ArrayBuffer(o+A.data.byteLength),r=new DataView(n),s=new DataView(A.data),a=0;for(let A=0;A1&&void 0!==arguments[1]?arguments[1]:4,OU),HS(this,"profile",US({},VM)),HS(this,"avoidCropping",!1),HS(this,"_scaleResolutionDownBy"),HS(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0,framesCaptured:0}),HS(this,"small"),HS(this,"isNeedToSetBandwidth"),HS(this,"muteImage"),HS(this,"manager"),HS(this,"_seiCodec",new mP),this.manager=A;let e=()=>{var A;if(this.isAllowed2k4k(this.profile))this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1});else{let e=y_((null==(A=this.room)?void 0:A.sdkAppId)||0)?bM:NM;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(e)),this.setProfile(FS(US({},this.profile),{width:1920,height:1080})),this.applyProfile()}};this.on("input-media-track-changed",e),this.on("publish",e),this.handleCameraAdded=this.handleCameraAdded.bind(this),this.handleCameraRemoved=this.handleCameraRemoved.bind(this)}get facingMode(){if(QL&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var A;return(null==(A=this._inputTrack)?void 0:A.contentHint)||""}get isQosClearFirst(){var A;return"detail"===(null==(A=this._inputTrack)?void 0:A.contentHint)}get hasSmall(){var A;return!(null==(A=this.manager)||!A.hasSmall)}setMute(e){return VS(this,null,function*(){var t,i,o;if(q_(e)){if(this.muteImage===e)return;yield null==(t=this.manager)?void 0:t.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e,fillVideo:!0}),this.muteImage=e,qS(A.prototype,this,"setMute").call(this,!1)}else this.muteImage&&(yield null==(o=this.manager)?void 0:o.deleteWatermark("mute"),this.muteImage=void 0),qS(A.prototype,this,"setMute").call(this,e)})}capture(e){return VS(this,arguments,function(e){var t=this;let{deviceId:i,facingMode:o,useExactDeviceId:n=!0,customSource:r,retryWhenExactFailed:s=!0}=e;return function*(){let e={audio:!1,video:!0,facingMode:o||t.facingMode,cameraId:i,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,useExactDeviceId:n,retryWhenExactFailed:s,customSource:r};if("environment"===e.facingMode){let A=yield t.getDeviceIdWhenUsingBackCamera();A&&(e.cameraId=A)}return qS(A.prototype,t,"capture").call(t,e)}()})}setProfile(A){var e;let t=this.fallbackProfile(A);if(t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile))super.setProfile(t);else{let A=y_((null==(e=this.room)?void 0:e.sdkAppId)||0)?bM:NM;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(A)),super.setProfile(FS(US({},this.profile),{width:1920,height:1080}))}}applyProfile(){return VS(this,null,function*(){var A;if(!this.mediaTrack)return;let{width:e=0,height:t=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=e*t,o=this.settings,n=o.height!==this.profile.height||o.width!==this.profile.width||o.frameRate!==this.profile.frameRate;if(n&&(16===Mb&&this.deviceId?yield this.recapture(this.deviceId):(yield null==(A=this.sourceTrack||this.mediaTrack)?void 0:A.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}),this.manager&&this.manager.changeInput(this)),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1})),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth){this.isNeedToSetBandwidth=!1;let{width:A=0,height:e=0}=(this.sourceTrack||this.mediaTrack).getSettings(),t=A*e;return n&&t&&i&&t===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:WM.VIDEO,videoType:WM.BIG})}})}get settings(){let A={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},e=this.sourceTrack||this.mediaTrack;return QL&&e&&Object.assign(A,e.getSettings()),A}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:MT(this.settings,this.profile)}isAllowed2k4k(A){var e;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(A.height*A.width<3686400))||1===(null==(e=this.room.scheduleResult.trtcAutoConf)?void 0:e["2k4k"])}isNeedToSwitchDevice(A){return!(!this.mediaTrack||this.deviceId===A||this.facingMode===A)}switchDevice(A){return VS(this,null,function*(){try{if(!this.isNeedToSwitchDevice(A)&&!this.isUseCustomSource)return;let e={useExactDeviceId:!0,retryWhenExactFailed:!1};"user"===A||"environment"===A?e.facingMode=A:e.deviceId=A,this.sourceTrack&&this.sourceTrack.stop(),yield this.capture(e),tG.emit(oG.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(e){throw this.log.error("switch camera failed ".concat(e)),this.deviceId&&this.recapture(this.deviceId),e}})}getDeviceIdWhenUsingBackCamera(){return VS(this,null,function*(){let A;try{if(eb&&!cb&&fL){let e=(yield pF(!0)).map(A=>{var e;return FS(US({},A),{capabilities:null==(e=A.getCapabilities)?void 0:e.call(A)})}).filter(A=>{var e,t;return null==(t=null==(e=A.capabilities)?void 0:e.facingMode)?void 0:t.includes("environment")}),t=e[0];e.forEach(A=>{var e,i,o,n;let{capabilities:r}=A;(null!=(e=r.width)&&e.max&&null!=(i=r.height)&&i.max?r.width.max*r.height.max:0)>(null!=(o=t.capabilities.width)&&o.max&&null!=(n=t.capabilities.height)&&n.max?t.capabilities.width.max*t.capabilities.height.max:0)&&(t=A)}),null!=t&&t.capabilities&&(this._log.info("use max resolution back camera",t),A=t.deviceId)}}catch(e){this._log.warn("get max res camera failed",e)}return A})}updateSmallConfig(A){return VS(this,null,function*(){var e,t;this._log.info("update small stream config: ".concat(JSON.stringify(A)));let i=!this.small;this.small=this.fallbackProfile(A,!0),yield null==(e=this.manager)?void 0:e.update(),i&&(yield null==(t=this.room)?void 0:t.enableSmall(!0)),this.log.info("update small stream config success")})}fallbackProfile(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=A.width>A.height,i=US({},A);return A.width*A.height<=19200&&lN&&Eb&&(this.log.warn("".concat(e?"small ":"","resolution is ").concat(A.width,"*").concat(A.height,", fallback to 240*180 for android chrome")),i.width=t?240:180,i.height=t?180:240,i.bitrate=Math.max(A.bitrate,150)),A.width*A.height>921600&&Tb&&(i.width=t?1280:720,i.height=t?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),wb(vb,"14.3")&&Sb(vb,"14.0",!0)&&this.on("7",()=>{let A=this.profile.width>this.profile.height;this.profile.width*this.profile.height>307200?(this.profile.width=A?640:480,this.profile.height=A?480:640,this.log.warn("reduce the resolution to 480p on iOS 14.0 ~ 14.2")):this.profile.width*this.profile.height>230400&&(this.profile.width=A?640:360,this.profile.height=A?360:640,this.log.warn("reduce the resolution to 360p on iOS 14.0 ~ 14.2"))}),!e&&this.avoidCropping&&(Eb||dN)&&!Fb()&&A.width*A.height<=230400&&A.width/A.height===16/9&&(this._scaleResolutionDownBy=1280/A.width,A.width=1280,A.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),i}stopSmall(){var A,e;this.small&&(delete this.small,null==(A=this.manager)||A.update(),null==(e=this.room)||e.enableSmall(!1))}listenDeviceChange(){hF&&!hF.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&hF.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(A){return VS(this,null,function*(){if(A.deviceId===this.deviceId){let e=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(EP[this.recaptureMode],". Current camera is lost: ").concat(JSON.stringify(A))),0===this.recaptureMode){lY(this.userId,{eventId:2003,param1:7,streamType:2});let A=yield pF();A[0]?this.recapture(A[0].deviceId):e=!0}e&&hF.on("videoInputAdded",this.handleCameraAdded,this)}})}handleCameraAdded(A){return VS(this,null,function*(){1===this.recaptureMode&&A.deviceId!==this.deviceId||(hF.off("videoInputAdded",this.handleCameraAdded,this),this.log.warn("camera added: ".concat(JSON.stringify(A))),this.recapture(A.deviceId))})}encodeFrame(A,e){if(!this.manager)return A;let t=e?8:this.mediaType;return this.manager.encodePipeline.reduceRight((A,e)=>e?e({frame:A,mediaType:t}):A,A)}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some(A=>A)}play(A,e){return H_(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(A,e)}close(){hF.off("videoInputAdded",this.handleCameraAdded,this),hF.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}recapture(e){return VS(this,null,function*(){try{yield qS(A.prototype,this,"recapture").call(this,e)}catch(t){let i=(yield pF()).find(A=>A.deviceId!==e);if(!i)throw t;yield qS(A.prototype,this,"recapture").call(this,i.deviceId)}})}setContentHint(A){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==A&&(this.log.info("setContentHint ".concat(A)),this.mediaTrack.contentHint=A),this.outMediaTrack&&this.outMediaTrack.contentHint!==A&&(this.outMediaTrack.contentHint=A))}setRotation(A){this.manager&&(this.isScreen||H_(A)||A!==this.rotation&&(this.rotation=A,this.manager.rotation=A))}};JS([FF(function(A){this.setContentHint(A.contentHint||"motion")})],yP.prototype,"capture",1);var DP=yP,vP={};PS(vP,{REPORT_TYPE:()=>NT,buildSSOPackage:()=>bT,bytes2ms:()=>b_,calculateScaleResolutionDownNumber:()=>MT,concatArrayBuffers:()=>GT,convertObjectNumberToInt:()=>yT,copyProperties:()=>N_,deepClone:()=>uT,deepCloneBasic:()=>TT,deepMerge:()=>IT,delay:()=>DT,fibonacci:()=>x_,formatedTime:()=>hT,getConstructorName:()=>AT,getContainerFromElement:()=>dT,getEnv:()=>f_,getFirst16Bits:()=>LT,getInternalVersion:()=>rT,getLast16Bits:()=>kT,getLoggerUrl:()=>D_,getMediaStreamTrackInfo:()=>ST,getMuteStateFromFlag:()=>gT,getNetworkType:()=>w_,getNumNetworkType:()=>T_,getReconnectionTimeout:()=>P_,getStringByteLength:()=>QT,getTestSignalDomain:()=>m_,getTurnServer:()=>cT,getUint32Version:()=>mT,getValueType:()=>Y_,getViewListFromView:()=>ET,glog:()=>U_,ipv4ToUint32:()=>lT,isArray:()=>W_,isAudioWorkletSupported:()=>eT,isBoolean:()=>j_,isConstructor:()=>$_,isEmpty:()=>aT,isFunction:()=>J_,isLangChinese:()=>F_,isMediaStreamTrack:()=>z_,isNumber:()=>V_,isObject:()=>K_,isOverseaSdkAppId:()=>y_,isPlainObject:()=>O_,isPortrait:()=>pT,isPromise:()=>X_,isRemoteTrack:()=>Z_,isRotate90Or270:()=>RT,isSetSinkIdSupported:()=>tT,isString:()=>q_,isUndefined:()=>H_,loadImage:()=>fT,loadVideo:()=>_T,ms2bytes:()=>k_,ms2samples:()=>L_,normalizeUrl:()=>wT,performanceNow:()=>oT,promiseAny:()=>iT,samples2ms:()=>G_,setNetworkTypeFromWebRTC:()=>__,stringify:()=>CT,stringifyIncludeValue:()=>BT,throttlePromise:()=>vT});var wP=[-1,-1,1,-1,-1,1,1,1],SP=[0,0,1,0,0,1,1,1],MP=class A extends ZL{constructor(A,e){if(super(),this.context=A,HS(this,"name"),HS(this,"input"),HS(this,"output"),HS(this,"texture"),HS(this,"ctx2d",null),HS(this,"fbo"),HS(this,"width",0),HS(this,"height",0),HS(this,"x",0),HS(this,"y",0),HS(this,"program"),HS(this,"vertexShader"),HS(this,"fragmentShader"),HS(this,"totalFrames",0),HS(this,"dropFrames",0),HS(this,"matchInputSize",!0),HS(this,"texCoordBuffer"),HS(this,"positionBuffer"),HS(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),HS(this,"cost",0),HS(this,"_canvas",null),HS(this,"_image"),HS(this,"log"),this.context.on("disconnect",this.close,this),this.name=e.name,this.log=e.logger,this.matchInputSize=!1!==e.matchInputSize,this.width=e.width||A.width,this.height=e.height||A.height,this._image=e.image,A instanceof JP)A.ctx&&e.create2d&&("function"==typeof OffscreenCanvas&&16!==Mb?this._canvas=new OffscreenCanvas(this.width,this.height):(this._canvas=document.createElement("canvas"),this._canvas.width=this.width,this._canvas.height=this.height),this.ctx2d=this._canvas.getContext("2d"),this._image=this._canvas);else try{let t=A.ctx;this.texCoordBuffer=this.createBuffer(SP),this.positionBuffer=this.createBuffer(wP),!1!==e.createTexture&&(this.texture=t.createTexture(),this.useTexture(),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_ALIGNMENT,1)),e.useFbo&&(this.fbo=t.createFramebuffer(),this.useBufferFrame(),this.useTexture(),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture,0)),e.useDefaultProgram?this.program=A.defaultProgam:(e.vertexShaderSource||e.fragmentShaderSource)&&(this.vertexShader=e.vertexShaderSource?A.createShader(t.VERTEX_SHADER,e.vertexShaderSource):A.defaultVShader,this.fragmentShader=e.fragmentShaderSource?A.createShader(t.FRAGMENT_SHADER,e.fragmentShaderSource):A.defaultFShader,this.program=A.createProgram(this.vertexShader,this.fragmentShader))}catch(t){this.context.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(t.message||t)}))}}get image(){return this._image}set image(A){this._image=A}createFramebuffer(A){let e=this.context.ctx,t=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,A,0),t}connect(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:0;var e;null==(e=this.output)||e.update(A)}disconnect(){for(var A,e=arguments.length,t=new Array(e),i=0;i{e&&(A.activeTexture(A.TEXTURE0+t),A.bindTexture(A.TEXTURE_2D,e))})}useProgram(){this.context.ctx.useProgram(this.program)}useBufferFrame(){let A=this.context.ctx;A.bindFramebuffer(A.FRAMEBUFFER,this.fbo||null)}createBuffer(A){let e=this.context.ctx,t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array(A),e.STATIC_DRAW),t}setTexBuffer(A){let e=this.context.ctx;e.bindBuffer(e.ARRAY_BUFFER,this.texCoordBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(A),e.STATIC_DRAW)}setPosBuffer(A){let e=this.context.ctx;e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(A),e.STATIC_DRAW)}changeBufferData(A,e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,A),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setAttributes(){let A=this.context.ctx;for(var e=arguments.length,t=new Array(e),i=0;i{A.enableVertexAttribArray(t),A.bindBuffer(A.ARRAY_BUFFER,e),A.vertexAttribPointer(t,2,A.FLOAT,!1,0,0)})}getVertexPoint(A,e){return[A/this.width*2-1,e/this.height*2-1]}layout2texCoords(A){return[...this.getVertexPoint(A.x,A.y),...this.getVertexPoint(A.x+A.width,A.y),...this.getVertexPoint(A.x,A.y+A.height),...this.getVertexPoint(A.x+A.width,A.y+A.height)]}resize(A,e){if(this.width!==A||this.height!==e){if(this.width=A,this.height=e,this._canvas&&(this._canvas.width=A,this._canvas.height=e),this.texture&&this.fbo){this.useTexture();let t=this.context.ctx;t.texImage2D(t.TEXTURE_2D,0,t.RGBA,A,e,0,t.RGBA,t.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(A,e)}}draw(A,e){this.setAttributes(A||this.positionBuffer,e||this.texCoordBuffer);let t=this.context.ctx;t.drawArrays(t.TRIANGLE_STRIP,0,4)}draw2d(e,t,i,o,n,r,s,a,g){let c=!(H_(r)||H_(s)||H_(a)||H_(g));return!(!this.ctx2d||!e||(e instanceof ImageData?(c?this.ctx2d.putImageData(e,t,i,r,s,a,g):this.ctx2d.putImageData(e,t,i),this.emit(A.RENDER,this.ctx2d.canvas)):(c?this.ctx2d.drawImage(e,r,s,a,g,t,i,o,n):this.ctx2d.drawImage(e,t,i,o,n),this.emit(A.RENDER,e)),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close(),0))}drawBackGround2d(A){this.ctx2d&&(this.ctx2d.save(),this.ctx2d.fillStyle=A,this.ctx2d.fillRect(0,0,this.width,this.height),this.ctx2d.restore())}getInfo(){var A;let{totalFrames:e,x:t,y:i,width:o,height:n,name:r,cost:s}=this,a=Date.now(),g=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:i,width:o,height:n,timestamp:a,fps:g,name:r,cost:s},US({parent:null==(A=this.input)?void 0:A.getInfo()},this.lastInfo)}createTexture(A){let e=this.context.ctx,t=e.createTexture();return this.useTextures(t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,A),t}};HS(MP,"RENDER","render"),JS([KL(ZL.INIT,"connected",{sync:!0})],MP.prototype,"connect",1),JS([KL("connected",ZL.INIT,{ignoreError:!0,sync:!0})],MP.prototype,"disconnect",1),JS([KL([],"closed",{sync:!0})],MP.prototype,"close",1);var RP=MP,_P=sO(UO(250),Gx(()=>performance.now()),dO()),TP=[0,1,1,1,0,0,1,0],NP=class extends RP{constructor(A,e){super(A,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},e)),HS(this,"_intervalId",0),HS(this,"_sequence",0),HS(this,"checkGLError",!1),HS(this,"checkVisibilityChange"),A instanceof JP?this.ctx2d=A.ctx||null:A.available&&null!=e&&e.mirrorUpAndDown&&this.setTexBuffer(TP)}start(A){this.log.info("".concat(this.name," start render ").concat(A," fps")),iU.clearTask(this._intervalId),this._intervalId=iU.run("intervalInWorker",()=>{if(A!==this.context.frameRate&&(iU.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof YP){let A=this.context.ctx.getError();A&&this.context.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(A)}))}},{fps:this.context.frameRate})}render(A){var e;return!(null==(e=this.input)||!e.requestFrame(A)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),this.emit(RP.RENDER,this.context._canvas),0))}addInput(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:0;"closed"!==this.state&&(this._intervalId&&(iU.clearTask(this._intervalId),this._intervalId=0,1===A&&(this.log.info("".concat(this.name," use requestVideoFrameCallback")),this.checkVisibilityChange=()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")),document.removeEventListener("visibilitychange",this.checkVisibilityChange))},document.addEventListener("visibilitychange",this.checkVisibilityChange))),this.requestFrame(this._sequence++))}removeInput(A){super.removeInput(A),iU.clearTask(this._intervalId)}resize(A,e){super.resize(A,e),this.context.setSize(A,e)}close(){super.close(),iU.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}},bP=class extends NP{constructor(A,e){super(A,e),HS(this,"_videoTrack"),HS(this,"_muteOb"),HS(this,"_closedOb",PO(this,"closed")),HS(this,"_subscription"),HS(this,"_canvasContainer"),Number(yb)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),[this._videoTrack]=A.canvas.captureStream().getVideoTracks(),this._muteOb=PO(this._videoTrack,"mute"),sO(PO(this._videoTrack,"ended"),gx(this._closedOb),cP(()=>{this.context.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))}enableCheckMute(){var A;this._subscription=sO(this._muteOb,gx(this._closedOb),Yx((A=5e3,e=>{let t=performance.now();sO(_P,Ex(e=>e-t{var A;return!(null==(A=this._videoTrack)||!A.muted||document.hidden)}),cP(()=>{this.context.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))}))}disableCheckMute(){var A;null==(A=this._subscription)||A.dispose()}get videoTrack(){return this._videoTrack}putCanvasIntoDom(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}render(A){return this.putCanvasIntoDom(),super.render(A)}render2d(A){return this.putCanvasIntoDom(),super.render2d(A)}close(){var A,e;super.close(),null==(A=this._videoTrack)||A.stop(),delete this._videoTrack,null==(e=this._canvasContainer)||e.remove()}},GP=class extends bP{render(A){var e;let t=!(null==(e=this.input)||!e.requestFrame(A));if(this.context._canvas2d){let A=this.context._canvas2d.getContext("2d");A.clearRect(0,0,this.context._canvas2d.width,this.context._canvas2d.height),A.drawImage(this.context._canvas,0,0,this.context._canvas2d.width,this.context._canvas2d.height),this.emit(RP.RENDER,this.context._canvas2d)}else this.emit(RP.RENDER,this.context._canvas);return t}},kP=class extends bP{constructor(A,e,t){super(A,{name:"smallDestination",logger:t}),this.resolution=e}resize(A,e){let t,i=A*e,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(A,"*").concat(e," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>o?t=i/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(A," * ").concat(e," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),t=i/19200),super.resize(A/Math.sqrt(t),e/Math.sqrt(t))}},LP=class extends RP{constructor(A,e){super(A,US({name:"imageSource"},e)),HS(this,"_lastImage"),HS(this,"_totalFrames",0),HS(this,"_autoResize",!1),HS(this,"_canvasRendered"),HS(this,"videoCallbackId",0),HS(this,"waitingFirstFrame",!0),HS(this,"shouldUpdate",!0),this._autoResize=!1!==(null==e?void 0:e.autoResize),16===Mb&&(this._canvasRendered=MO(),sO(this._canvasRendered,yO(this._image),xx(A=>A instanceof HTMLCanvasElement?PO(A,"rendered"):$O()),gx(PO(this,"closed")),cP(()=>{this.update()})))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){if(!this.shouldUpdate)return;let A=this.image;this.videoCallbackId&&A.cancelVideoFrameCallback(this.videoCallbackId),GL()&&!document.hidden&&(this.videoCallbackId=A.requestVideoFrameCallback((A,e)=>{this.waitingFirstFrame&&this.onFirstFrame(),document.hidden||(this._totalFrames=e.presentedFrames,this.update(1))}))}_render(A,e){var t;let{width:i,height:o}=this,{image:n}=this;if(n instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:o}=n),!i||!o)return!1;n.width=i,n.height=o}else if(n instanceof HTMLImageElement||n instanceof ImageData||n instanceof ImageBitmap){if(({width:i,height:o}=n),n!==this._lastImage)this._lastImage=n;else if(i===this.width&&o===this.height)return!0}else n instanceof HTMLCanvasElement||n instanceof OffscreenCanvas?(({width:i,height:o}=n),this._lastImage=n):"undefined"!=typeof VideoFrame&&n instanceof VideoFrame&&(({displayWidth:i,displayHeight:o}=n),null==(t=this._lastImage)||t.close(),this._lastImage=n);if(!this._autoResize)return!0;if(this.width===i&&this.height===o&&this.totalFrames){if(e){this.useTexture();let A=this.context.ctx;A.texSubImage2D(A.TEXTURE_2D,0,0,0,A.RGBA,A.UNSIGNED_BYTE,n)}}else{if(e){this.useTexture();let A=this.context.ctx;A.texImage2D(A.TEXTURE_2D,0,A.RGBA,A.RGBA,A.UNSIGNED_BYTE,n)}this.resize(i,o)}return!0}get image(){return this._image}set image(A){var e;null==(e=this._canvasRendered)||e.next(A),this._image=A}render(A){return this._render(A,!0)}render2d(A){return this._render(A,!1)}},UP=class extends LP{constructor(A,e,t){super(A,t),this._player=e,this.name="videoPlayerSource",sO(PO(this._player,oU.PLAYER_STATE_CHANGED),gx(PO(this,"closed")),rx(A=>{let{state:e}=A;return"PLAYING"===e}),cP(()=>{this.tryVideoFrameCallback()}))}get image(){return this._player.element}},FP=class extends UP{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(A,e,t){super(A,new OU({id:t.name,track:e,muted:!0,container:null,objectFit:"contain",log:t.logger}),t),this.name="videoTrackSource",this._player.play()}replaceTrack(A){this.waitingFirstFrame=!0,this._player.setTrack(A),this._player.play()}close(){super.close(),this._player.stop()}},OP=class extends RP{constructor(A,e,t){super(A,FS(US({name:"textSource"},t),{create2d:!0})),HS(this,"hasChange",!0),HS(this,"content",""),this.ctx2d.textBaseline="top",this.content=e.content||"",e.font&&(this.font=e.font),e.color&&(this.color=e.color)}set font(A){this.ctx2d&&(this.ctx2d.font=A,this.hasChange=!0)}get font(){var A;return(null==(A=this.ctx2d)?void 0:A.font)||""}set color(A){this.ctx2d&&(this.ctx2d.fillStyle=A,this.hasChange=!0)}get color(){var A;return(null==(A=this.ctx2d)?void 0:A.fillStyle)||""}render2d(A){return!(!this.ctx2d||!this.hasChange||(this.ctx2d.clearRect(0,0,this.width,this.height),this.drawMultilineText(0,0),this.hasChange=!1,0))}render(A){return!1}resize(A,e){if(!this.ctx2d)return;let{color:t,font:i}=this;super.resize(A,e),this.color=t,this.font=i}drawMultilineText(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.2;if(!this.ctx2d)return;let i=this.ctx2d.measureText(this.content);e+=i.fontBoundingBoxAscent||i.actualBoundingBoxAscent||0;let o=this.font.match(/(\d+)px/),n=(o?parseInt(o[1],10):16)*t,r=this.content.split("\n");for(let s=0;s0&&void 0!==arguments[0]&&arguments[0];if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(xP._ids++)),A&&(this._canvas2d=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",A_),!this.ctx)throw new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",()=>{this.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))})}destroy(A){let e="";return A&&(e=A.message,this.error=A,Gk.addFailedEvent({key:512702,error:A})),this.disconnect(),this.log.info("video context destroy".concat(e)?": ".concat(e):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),A}set width(A){var e;null==(e=this.ctx)||e.viewport(0,0,A,this.height),super.width=A,this._canvas2d&&(this._canvas2d.width=A)}set height(A){var e;null==(e=this.ctx)||e.viewport(0,0,this.width,A),super.height=A,this._canvas2d&&(this._canvas2d.height=A)}setSize(A,e){var t;null==(t=this.ctx)||t.viewport(0,0,A,e),super.setSize(A,e),this._canvas2d&&(this._canvas2d.width=A,this._canvas2d.height=e)}createShader(A,e){let t=this.ctx,i=t.createShader(A);return t.shaderSource(i,e),t.compileShader(i),i}createProgram(A,e){let t=this.ctx,i=t.createProgram();return t.attachShader(i,A),t.attachShader(i,e),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS)||this.log.error(t.getProgramInfoLog(i)),i}};HS(PP,"UNAVAILABLE","unavailable"),JS([KL(ZL.INIT,"created",{sync:!0,fail(A){this.log.error("video gl context create failed",A.cause),Gk.addFailedEvent({key:512700,error:A.cause||A})},success(){this.log.info("video context created use webgl"),Gk.addSuccessEvent({key:512700})}})],PP.prototype,"create",1),JS([KL("created",ZL.INIT,{ignoreError:!0,sync:!0,success(A){A&&this.emit(PP.UNAVAILABLE,A),this.removeAllListeners()}})],PP.prototype,"destroy",1);var YP=PP,JP=class extends xP{constructor(){super(...arguments),HS(this,"ctx")}create(A){if(this.hasAlpha=A.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(xP._ids++),this.ctx=this._canvas.getContext("2d",{alpha:A.alpha,willReadFrequently:A.willReadFrequently}),!this.ctx)throw new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",()=>{this.log.error("2d context lost")}),this._canvas.addEventListener("contextrestored",()=>{this.log.warn("2d context restored")})}destroy(A){let e="";A&&(e=A.message,this.error=A,Gk.addFailedEvent({key:512703,error:A})),this.disconnect(),this.log.info("video context destroy ".concat(e?": ".concat(e):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),Gk.addSuccessEvent({key:512703})}};function HP(A,e,t,i,o){arguments.length>5&&void 0!==arguments[5]&&arguments[5]&&([t,i]=[i,t]);let n={sWidth:A,sHeight:e,dWidth:t,dHeight:i,sx:0,sy:0,dx:0,dy:0};if(0===A||0===e)return n;switch(o){case void 0:case"fill":break;case"contain":{let o=Math.min(t/A,i/e);n.dWidth=A*o,n.dHeight=e*o,n.dx=(t-n.dWidth)/2,n.dy=(i-n.dHeight)/2;break}case"cover":{let o=Math.max(t/A,i/e),r=t/o,s=i/o;n.sx=(A-r)/2,n.sy=(e-s)/2,n.sWidth=r,n.sHeight=s;break}}return n}JS([KL(ZL.INIT,"created",{sync:!0,fail(A){this.log.error("video 2d context create failed",A.cause),Gk.addFailedEvent({key:512701,error:A.cause||A})},success(){this.log.info("video context created use 2d"),Gk.addSuccessEvent({key:512701})}})],JP.prototype,"create",1),JS([KL("created",ZL.INIT,{ignoreError:!0,sync:!0})],JP.prototype,"destroy",1);var qP=class{constructor(A,e){this.node=A,this.layout=e,HS(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get fillMode(){return this.layout.fillMode}get rotation(){return this.layout.rotation}get hidden(){return!!this.layout.hidden}},VP=class extends RP{constructor(A,e){super(A,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:e}),HS(this,"inputs",[]),HS(this,"backgroundColor","black")}addInput(A,e){let t=0,i=this.inputs.length;for(;te.zIndex))throw new Error("input already exists at zIndex ".concat(e.zIndex));i=A}}let o=new qP(A,e);this.inputs.splice(t,0,o)}changeInputLayout(A,e){let t=this.inputs.findIndex(e=>e.node===A);if(t<0)return;let{x:i,y:o,width:n,height:r,zIndex:s,fillMode:a,rotation:g,hidden:c}=e;if(!H_(s)&&this.inputs.some(e=>e.layout.zIndex===s&&e.node!==A))throw new Error("input already exists at zIndex ".concat(e.zIndex));let l=this.inputs[t];H_(i)||(l.layout.x=i),H_(o)||(l.layout.y=o),H_(n)||(l.layout.width=n),H_(r)||(l.layout.height=r),H_(g)||(l.layout.rotation=g),H_(c)||(l.layout.hidden=c),a&&(l.layout.fillMode=a),!H_(s)&&s!==l.layout.zIndex&&(l.layout.zIndex=s,this.inputs.sort((A,e)=>A.layout.zIndex-e.layout.zIndex))}hasInput(A){return this.inputs.some(e=>e.node===A)}hasNoInput(){return 0===this.inputs.length}resize(A,e){if(!this.matchInputSize)return void super.resize(A,e);let t=this.inputs.reduce((A,e)=>e?Object.assign(A,{width:Math.max(A.width,e.right),height:Math.max(A.height,e.bottom)}):A,{width:0,height:0});super.resize(t.width,t.height),this.context instanceof YP&&this.inputs.forEach(A=>{if(A){let e=this.layout2texCoords(A);A.positionBuffer?this.changeBufferData(A.positionBuffer,e):A.positionBuffer=this.createBuffer(e)}})}connect(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;ie.node!==A),0===this.inputs.length&&this.drawBackGround2d(this.backgroundColor)}render(A){let e=this.context.ctx;if(e.clearColor(0,0,0,0),this.inputs.reduce((e,t)=>t.node.requestFrame(A)||e,!1)&&e){this.useProgram(),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let A=0;Ae.node.requestFrame(A)),this.ctx2d){this.drawBackGround2d(this.backgroundColor);for(let A=0;A4&&void 0!==arguments[4]&&arguments[4];this.ctx2d&&(o&&([t,i]=[i,t]),this.ctx2d.save(),this.ctx2d.strokeStyle="red",this.ctx2d.lineWidth=2,this.ctx2d.strokeRect(A,e,t,i),this.ctx2d.restore())}getInfo(){let{totalFrames:A,x:e,y:t,width:i,height:o,name:n}=this,r=Date.now(),s=(A-this.lastInfo.totalFrames)/((r-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:A,x:e,y:t,width:i,height:o,timestamp:r,fps:s,name:n},US({parent:this.inputs.filter(A=>A).map(A=>A.node.getInfo())},this.lastInfo)}removeAllInputs(){this.inputs.forEach(A=>{var e;if(A.node.disconnect(),A.positionBuffer&&this.context instanceof YP)try{null==(e=this.context.ctx)||e.deleteBuffer(A.positionBuffer)}catch(t){}})}close(){super.close(),this.removeAllInputs()}},jP=[1,0,0,0,1,1,0,1],KP=class extends RP{constructor(A,e,t,i){if(super(A,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:e}),HS(this,"mirror",!1),HS(this,"rotation",0),t&&(this.mirror=t),i&&(this.rotation=i),A instanceof YP)try{this.setTexBuffer(jP)}catch(o){A.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(o.message||o)}))}}draw2d(A,e,t,i,o){if(this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height),this.ctx2d.save(),this.mirror&&(this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0)),90===this.rotation?(this.ctx2d.translate(i,0),this.ctx2d.rotate(Math.PI/2),this.ctx2d.scale(o/i,i/o)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,o),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(o/i,i/o));let n=super.draw2d(A,e,t,i,o);return this.ctx2d.restore(),n}return!1}render(A){var e;return!(null==(e=this.input)||!e.requestFrame(A)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}resize(A,e){RT(this.rotation)&&([A,e]=[e,A]),super.resize(A,e)}},WP=class extends hP{constructor(A){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,OU),HS(this,"inputLocalVideoTracks",new Map),HS(this,"inputLocalScreenTracks",new Map),HS(this,"cameraNodeMap",new Map),HS(this,"screenNodeMap",new Map),HS(this,"textNodeMap",new Map),HS(this,"imageNodeMap",new Map),HS(this,"videoNodeMap",new Map),HS(this,"endedIds",new Set),HS(this,"videoContext"),HS(this,"mixNode"),HS(this,"destination"),HS(this,"manager"),HS(this,"stat"),HS(this,"_checkId",0),HS(this,"autoSetFps",!0),this.manager=A,this.log.id+="mix",this.create2dVideoContext(),this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(RP.RENDER,A=>{this.emit("render",A)}),this.mixNode=new VP(this.videoContext,this.log),this.mixNode.matchInputSize=!1}listenDeviceChange(){throw new Error("Method not implemented.")}enablePrintDetail(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=iU.run("interval",()=>{this.destination&&this.log.debug(this.destination.getInfo())},{delay:A})}create2dVideoContext(){this.videoContext?this.videoContext.destroy():this.videoContext=new JP({frameRate:15,logger:this.log,name:"mix-ctx"}),this.videoContext.create({alpha:!1})}setFps(A){this.autoSetFps=!1,this.videoContext.frameRate=A;for(let e of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])e.shouldUpdate=!1;setTimeout(()=>{var A;return null==(A=this.destination)?void 0:A.start(this.videoContext.frameRate)},500)}setFpsAuto(){var A;if(!this.autoSetFps)return;for(let o of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])o.shouldUpdate=!1;let e=null,t=0,i=!0;for(let[o,n]of this.inputLocalVideoTracks)if(n.profile.frameRate>t){if(this.endedIds.has(o)){let A=this.cameraNodeMap.get(o);A&&A.image.cancelVideoFrameCallback(A.videoCallbackId);continue}t=n.profile.frameRate,e=o}for(let[o,n]of this.inputLocalScreenTracks)if(n.profile.frameRate>t){if(this.endedIds.has(o)){let A=this.screenNodeMap.get(o);A&&A.image.cancelVideoFrameCallback(A.videoCallbackId);continue}t=n.profile.frameRate,e=o,i=!1}if(null!==e){let A=i?this.cameraNodeMap.get(e):this.screenNodeMap.get(e);A&&(A.shouldUpdate=!0,A.tryVideoFrameCallback()),this.log.info("set mix fps: ",t)}else null==(A=this.destination)||A.start(this.videoContext.frameRate),this.log.info("fallback to timer, fps: ",this.videoContext.frameRate)}setMixBackground(A){this.mixNode&&(this.mixNode.backgroundColor=A)}resizeMixCanvas(A,e){var t;null==(t=this.mixNode)||t.resize(A,e)}startMix(){return VS(this,null,function*(){var A;if(!this.mixNode||!this.destination)throw new Error("can't mix without necessary conditions");this.mixNode.disconnect(),this.mixNode.connect(this.destination),mb&&this.player.setCanvas(this.videoContext._canvas),this.setOutputMediaStreamTrack(this.destination.videoTrack),null==(A=this.manager)||A.changeInput(this)})}addCameraSource(A,e,t){if(this.inputLocalVideoTracks.has(A)||this.cameraNodeMap.has(A))throw new Error("There is already a cameraSource with the same ID: ".concat(A));let i,{mediaTrack:o}=e;if(!o)throw new Error("no mediaTrack, add cameraSource failed");e.recaptureMode=1,sU(this,hF).add("videoInputRemoved",t=>{t.deviceId===e.deviceId&&(this.endedIds.add(A),this.setFpsAuto())}),e.on("output-media-track-changed",()=>{this.endedIds.delete(A),this.updateCameraSource(A,t,e.mediaTrack)}),i=16===Mb&&o instanceof CanvasCaptureMediaStreamTrack?this.videoContext.createVideoImageSource(o.canvas,{name:"cameraCanvasSource",logger:this.log}):this.videoContext.createVideoTrackSource(o,"cameraNodeSource"),i.resize(e.settings.width,e.settings.height),i.shouldUpdate=!1,this._connectMix(i,t,"cover"),this.inputLocalVideoTracks.set(A,e),this.cameraNodeMap.set(A,i),this.setFpsAuto()}addScreenSource(A,e,t){if(this.inputLocalScreenTracks.has(A)||this.screenNodeMap.has(A))throw new Error("There is already a screenSource with the same ID: ".concat(A));let{mediaTrack:i}=e;if(!i)throw new Error("no mediaTrack, add screenSource failed");e.on("output-media-track-changed",()=>{this.updateScreenSource(A,t,e.mediaTrack)});let o=this.videoContext.createVideoTrackSource(i,"screenNodeSource");o.resize(e.settings.width,e.settings.height),o.shouldUpdate=!1,this._connectMix(o,t),this.inputLocalScreenTracks.set(A,e),this.screenNodeMap.set(A,o),this.setFpsAuto()}addTextSource(A){let{id:e,content:t="",font:i,color:o,layout:n}=A;if(this.textNodeMap.has(e))throw new Error("There is already a textSource with the same ID: ".concat(e));let r=this.videoContext.createTextSource({content:t,font:i,color:o});r.resize(n.width,n.height),this._connectMix(r,n),this.textNodeMap.set(e,r)}addImageSource(A,e,t){if(this.imageNodeMap.has(A))throw new Error("There is already a imageSource with the same ID: ".concat(A));let i=this.videoContext.createVideoImageSource(e,{autoResize:!1,logger:this.log});i.resize(e.width,e.height),this._connectMix(i,t),this.imageNodeMap.set(A,i)}addVideoSource(A,e,t){if(this.videoNodeMap.has(A))throw new Error("There is already a videoSource with the same ID: ".concat(A));let i=this.videoContext.createVideoImageSource(e,{autoResize:!1,logger:this.log});i.resize(e.videoWidth,e.videoHeight),i.shouldUpdate=!1,this._connectMix(i,t),this.videoNodeMap.set(A,i)}updateCameraSource(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3?arguments[3]:void 0,o=this.cameraNodeMap.get(A);if(o){if(t){if(16===Mb&&t instanceof CanvasCaptureMediaStreamTrack)if(o instanceof FP){let e=o.output;o.close(),o=this.videoContext.createVideoImageSource(t.canvas,{name:"cameraCanvasSource",logger:this.log}),o.connect(e),this.cameraNodeMap.set(A,o)}else o.image=t.canvas;else if(o instanceof FP)o.replaceTrack(t);else{let e=o.output;o.close(),o=this.videoContext.createVideoTrackSource(t,"cameraNodeSource"),o.connect(e),this.cameraNodeMap.set(A,o)}let{width:e,height:i}=t.getSettings();e&&i&&o.resize(e,i)}i&&o.resize(i.width,i.height),(i||t)&&this.setFpsAuto(),this._changeMixLayout(o,e)}}updateScreenSource(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=this.screenNodeMap.get(A);i&&(t&&i.replaceTrack(t),this._changeMixLayout(i,e))}updateTextSource(A){let{id:e,content:t,font:i,color:o,layout:n}=A,r=this.textNodeMap.get(e);r&&(H_(t)||(r.content=t),H_(i)||(r.font=i),H_(o)||(r.color=o),r.resize(n.width,n.height),this._changeMixLayout(r,n))}updateImageSource(A,e,t){let i=this.imageNodeMap.get(A);i&&(t&&(i.image=t,i.resize(t.width,t.height)),this._changeMixLayout(i,e))}updateVideoSource(A,e,t){let i=this.videoNodeMap.get(A);if(i){if(t){let A=i.image;A instanceof HTMLVideoElement&&this.stopVideoElement(A),i.image=t,i.resize(t.videoWidth,t.videoHeight)}this._changeMixLayout(i,e)}}_connectMix(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"contain";if(!this.mixNode)return;let{mirror:i,rotation:o}=e;A.disconnect();let n=new KP(this.videoContext,this.log,i,o);n=A.connect(n),e.fillMode||(e.fillMode=t),n.connect(this.mixNode,e)}_changeMixLayout(A,e){if(!this.mixNode)return;let{mirror:t,rotation:i}=e,o=A.output||A;o instanceof KP&&(H_(t)||(o.mirror=t),H_(i)||(o.rotation=i),o.resize(A.width,A.height)),this.mixNode.changeInputLayout(o,e)}removeCameraSource(A){let e=this.inputLocalVideoTracks.get(A);if(!e)return;e.close(),this.inputLocalVideoTracks.delete(A);let t=this.cameraNodeMap.get(A);t&&(t.output instanceof KP&&t.output.close(),t.close(),this.cameraNodeMap.delete(A)),this.checkAfterRemove(!0)}removeScreenSource(A){let e=this.inputLocalScreenTracks.get(A);if(!e)return;e.close(),this.inputLocalScreenTracks.delete(A);let t=this.screenNodeMap.get(A);t&&(t.output instanceof KP&&t.output.close(),t.close(),this.screenNodeMap.delete(A)),this.checkAfterRemove(!0)}removeTextSource(A){let e=this.textNodeMap.get(A);e&&(e.output instanceof KP&&e.output.close(),e.close(),this.textNodeMap.delete(A)),this.checkAfterRemove()}removeImageSource(A){let e=this.imageNodeMap.get(A);e&&(e.output instanceof KP&&e.output.close(),e.close(),this.imageNodeMap.delete(A)),this.checkAfterRemove()}removeVideoSource(A){let e=this.videoNodeMap.get(A);e&&(e.output instanceof KP&&e.output.close(),e.image instanceof HTMLVideoElement&&this.stopVideoElement(e.image),e.close(),this.videoNodeMap.delete(A)),this.checkAfterRemove()}checkAfterRemove(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.setFpsAuto()}stopVideoElement(A){A.pause(),A.src="",A.srcObject=null,A.remove()}close(){var A;super.close(),iU.clearTask(this._checkId),null==(A=this.videoContext)||A.destroy(),delete this.mixNode,delete this.destination;for(let e of[...this.inputLocalVideoTracks.values(),...this.inputLocalScreenTracks.values()])e.close();this.inputLocalVideoTracks.clear(),this.inputLocalScreenTracks.clear(),this.cameraNodeMap.clear(),this.screenNodeMap.clear(),this.textNodeMap.clear(),this.imageNodeMap.clear(),aU(this);for(let e of this.videoNodeMap.values())e.image instanceof HTMLVideoElement&&this.stopVideoElement(e.image);this.videoNodeMap.clear(),this.log.info("localMixVideoTrack close, stop mix")}},zP=aG();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:zP,exposeOrigin:!0,permittedOrigins:["*"]})}catch(HV){}var ZP=function(A){return VS(this,null,function*(){let e=null,t=function(A){let e={preferCurrentTab:"current-tab"===A.preferDisplaySurface||!!A.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},t={width:fb?{max:A.width}:{ideal:A.width,max:A.width},height:fb?{max:A.height}:{ideal:A.height,max:A.height},frameRate:A.frameRate,displaySurface:A.preferDisplaySurface||"monitor"};if(e.video=t,A.systemAudio){let{echoCancellation:t=!0,noiseSuppression:i=!1,autoGainControl:o=!1}=A;e.audio={echoCancellation:t,noiseSuppression:i,autoGainControl:o,sampleRate:48e3}}return e}(A);sG.info("getDisplayMedia with constraints: ".concat(JSON.stringify(t)));let i=yield navigator.mediaDevices.getDisplayMedia(t);A.systemAudio&&0===i.getAudioTracks().length&&(db&&Cb<74||fb||dN)&&sG.warn("Your browser not support capture system audio");let o=i.getVideoTracks()[0];if(o){if(A.frameRate)try{yield o.applyConstraints({frameRate:{min:A.frameRate,ideal:A.frameRate},width:A.width,height:A.height})}catch(n){sG.warn("screen applyConstraints failed: ".concat(n))}A.captureElement&&(yield function(A,e){return VS(this,null,function*(){var t;if("CropTarget"in window&&"fromElement"in CropTarget&&J_(A.cropTo))try{if((null==(t=A.getCaptureHandle())?void 0:t.handle)!==zP)return;let i=yield CropTarget.fromElement(e);yield A.cropTo(i)}catch(i){sG.warn("cropTo target failed ".concat(i))}})}(o,A.captureElement))}if(A.audio){let t=function(A){let e={echoCancellation:A.echoCancellation,autoGainControl:A.autoGainControl,noiseSuppression:A.noiseSuppression,sampleRate:A.sampleRate,channelCount:A.channelCount};return H_(A.microphoneId)||(e.deviceId=A.microphoneId),{audio:e,video:!1}}(A);sG.info("getUserMedia with constraints: ".concat(JSON.stringify(t))),e=yield navigator.mediaDevices.getUserMedia(t),i.addTrack(e.getAudioTracks()[0])}return i})},XP=class extends DP{constructor(A){super(A,2),HS(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),HS(this,"objectFit","contain"),HS(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}get isShareCurrentTab(){var A,e;try{return zP===(null==(e=null==(A=this.mediaTrack)?void 0:A.getCaptureHandle())?void 0:e.handle)}catch(t){return}}capture(A){return VS(this,arguments,function(A){var e=this;let{systemAudio:t=!1,autoGainControl:i,echoCancellation:o,noiseSuppression:n,audioTrack:r,videoTrack:s,captureElement:a,preferDisplaySurface:g}=A;return function*(){try{let A,c=oT();return s||r?(A=new MediaStream,s&&A.addTrack(s),r&&A.addTrack(r)):(A=yield ZP({audio:!1,systemAudio:t,width:e.profile.width,height:e.profile.height,frameRate:e.profile.frameRate,autoGainControl:i,echoCancellation:o,noiseSuppression:n,captureElement:a,preferDisplaySurface:g}),e.sourceTrack=A.getVideoTracks()[0]),yield e.setInputMediaStreamTrack(A.getVideoTracks()[0]),tG.emit(oG.LOCAL_TRACK_CAPTURE_SUCCESS,{track:e,cost:oT()-c}),A}catch(A){throw e.log.error("getDisplayMedia error observed ".concat(A)),A instanceof rM?A:new rM({code:oM.INITIALIZE_FAILED,name:A.name,message:A.message})}}()})}switchDevice(A){return VS(this,null,function*(){throw new Error("Method not implemented.")})}};JS([FF(function(A){this.setContentHint(A.contentHint||"detail")})],XP.prototype,"capture",1);var $P,AY=class extends BP{constructor(A){super(A),this._log.id="s-".concat(this._log.id),this.isScreen=!0}addAudioProcessor(A,e,t){this.pipeline.silentNode.setNode(t),this.pipeline.mixNode.setNode(e),this.pipeline.aec.setNode(A),this.enableTrackAEC(!1)}removeAudioProcessor(A){this.pipeline.aec.node===A&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode(),this.enableTrackAEC(!0))}};function eY(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0;return VS(this,null,function*(){let o=AF();$P||($P=xU(o,URL.createObjectURL(new Blob(['registerProcessor("dumper",class extends AudioWorkletProcessor{constructor(e){super(),this.sourceSampleRate=e.processorOptions.sourceSampleRate||48e3,this.targetSampleRate=e.processorOptions.targetSampleRate||48e3,this.port.onmessage=e=>{this.port2=e.data.port}}process(e){return(this.port2||this.port).postMessage(this.resampleAll(e,this.sourceSampleRate,this.targetSampleRate)),!0}resampleAll(r,s,a){if(s===a)return r;var o=[];for(let t=0;tA.connect(r,0,e)),new ReadableStream({start(A){r.port.onmessage=e=>{A.enqueue(e.data)}},cancel(){A.forEach(A=>A.disconnect(r)),r.port.close()}})})}var tY=class extends nF{constructor(A){super(),this.room=A,HS(this,"_localAudioTrack"),HS(this,"_localScreenAudioTrack"),HS(this,"log"),HS(this,"denoiser"),HS(this,"voiceChanger"),HS(this,"mixChangedDebounce"),HS(this,"audioProcessor"),HS(this,"encodePipeline",[]),HS(this,"decodePipeline",[]),HS(this,"getPCMAbortCtrlMap",new Map),HS(this,"audioFrameEventConfigMap",new Map),HS(this,"audioReferenceMap",new Map),HS(this,"isLocalAudioNeedAudioProcess",!1),HS(this,"isScreenAudioNeedAudioProcess",!1),this.log=sG.createLogger({parent:null==A?void 0:A.getLogger(),id:"am",userId:null==A?void 0:A.userId,sdkAppId:null==A?void 0:A.sdkAppId}),this.installEvent()}get localAudioTrack(){return this._localAudioTrack}get _localAudioPipline(){var A;return null==(A=this._localAudioTrack)?void 0:A.pipeline}get _localScreenAudioPipeline(){var A;return null==(A=this._localScreenAudioTrack)?void 0:A.pipeline}dump(A){var e,t;if(!this._localAudioTrack)return;let i=[],o=[];null!=(e=this._localAudioPipline)&&e.source.node&&(i.push(this._localAudioPipline.source.node),o.push("mic")),null!=(t=this._localAudioPipline)&&t.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(A));let n=new AbortController,r=[],s=setTimeout(()=>{this.log.info('dump audio track complete please input "download()" to download.'),n.abort("timeout")},1e3*A),a=()=>{for(let A=0;AA.pipeTo(new WritableStream({write(A){A.forEach((A,e)=>r[e]=r[e]?r[e].concat(A[0]):[A[0]])}}),n).catch(A=>a));return{then:g.then.bind(g),download:a}}getPCM(A,e){var t,i,o;if("undefined"==typeof WritableStream)return void this.log.warn("getPCM failed: browser not support WritableStream");let{enable:n,sampleRate:r=48e3,channelCount:s=1,port:a}=(""===e?this.audioFrameEventConfigMap.get(""):this.audioFrameEventConfigMap.get(e)||this.audioFrameEventConfigMap.get("*"))||{};if(!n)return;this.log.info("getPCM ".concat(e||"local"));let g,c,l=Math.floor(.04*r),I=new Float32Array(l),u=new Float32Array(l),E=0,d=new AbortController,h=""===e?null==(t=this._localAudioTrack)?void 0:t.mediaTrack:null==(o=null==(i=this.room)?void 0:i.remotePublishedUserMap.get(e))?void 0:o.remoteAudioTrack.mediaTrack;if(h)return eY([AF().createMediaStreamSource(new MediaStream([h]))],r,s,a).then(t=>t.pipeTo(new WritableStream({write(t){t[0][0]&&(E+t[0][0].length>l?(I.set(t[0][0].subarray(0,l-E),E),g=t[0][0].subarray(l-E),t[0][1]&&(u.set(t[0][1].subarray(0,l-E),E),c=t[0][1].subarray(l-E)),E+=l-E):(g&&(I.set(g,E),E+=g.length,g=void 0),c&&(u.set(c,E),c=void 0),I.set(t[0][0],E),t[0][1]&&u.set(t[0][1],E),E+=t[0][0].length),E>=l&&(E=0,A({userId:e,sampleRate:r,channelCount:s,data:1===s?I:[I,u]}),I=new Float32Array(l),u=new Float32Array(l)))}}),d).catch(A=>this.log.warn("stop getPCM reason:".concat(A)))),d;this.log.info("getPCM failed: ".concat(e||"local"," has no audio track"))}get hasScreenAudioTrack(){return!H_(this._localScreenAudioTrack)}get hasAudioTrack(){return!H_(this._localAudioTrack)}changeInput(A){var e,t;return A instanceof AY?(this._localScreenAudioTrack=A,this.isScreenAudioNeedAudioProcess&&null!=(e=this.audioProcessor)&&e.screenAudioWorkletNode&&(A.addAudioProcessor(this.audioProcessor.screenAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach((e,t)=>{A.mixAudioReference(e,t)})),A.pipeline.connect(),this.mixOnChange()):A instanceof BP?(this._localAudioTrack=A,this.denoiser&&A.addDenoiser(this.denoiser),this.isLocalAudioNeedAudioProcess&&null!=(t=this.audioProcessor)&&t.localAudioWorkletNode&&(A.addAudioProcessor(this.audioProcessor.localAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach((e,t)=>{A.mixAudioReference(e,t)})),A.pipeline.connect(),this.mixOnChange()):A instanceof rY?A.setOutputMediaStreamTrack(A.mediaTrack):void 0}mixAudioReference(A,e){var t;null==(t=this._localAudioTrack)||t.mixAudioReference(A,e)}unMixAudioReference(A){var e;null==(e=this._localAudioTrack)||e.unMixAudioReference(A)}setAudioReferenceVolume(A,e){var t;null==(t=this._localAudioTrack)||t.setAudioReferenceVolume(A,e)}mixOnChange(){return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then(()=>{var A,e;return delete this.mixChangedDebounce,Promise.all([null==(A=this._localAudioTrack)?void 0:A.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(e=this._localScreenAudioTrack)?void 0:e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)])})),this.mixChangedDebounce}removeInput(A){A instanceof AY?delete this._localScreenAudioTrack:A instanceof BP&&delete this._localAudioTrack}addDenoiser(A){var e;this.denoiser=A,null==(e=this._localAudioTrack)||e.addDenoiser(A)}addAudioProcessor(A,e,t,i){var o;this.audioProcessor={localAudioWorkletNode:t,mixNode:A,silentNode:e,screenAudioWorkletNode:i},this.isLocalAudioNeedAudioProcess&&this._localAudioTrack&&t&&(this._localAudioTrack.addAudioProcessor(t,A,e),this.audioReferenceMap.forEach((A,e)=>{var t;null==(t=this._localAudioTrack)||t.mixAudioReference(A,e)})),this.isScreenAudioNeedAudioProcess&&this._localScreenAudioTrack&&i&&(null==(o=this._localScreenAudioTrack)||o.addAudioProcessor(i,A,e),this.audioReferenceMap.forEach((A,e)=>{var t;null==(t=this._localScreenAudioTrack)||t.mixAudioReference(A,e)}))}removeDenoiser(A){var e;return delete this.denoiser,null==(e=this._localAudioTrack)?void 0:e.removeDenoiser(A)}addVoiceChanger(A,e){var t;this.voiceChanger=[A,e],null==(t=this._localAudioTrack)||t.pipeline.voiceChanger.setNode(A,e)}removeVoiceChanger(){var A;delete this.voiceChanger,null==(A=this._localAudioTrack)||A.pipeline.voiceChanger.deleteNode()}removeAudioProcessor(A,e){var t,i;delete this.audioProcessor,null==(t=this._localAudioTrack)||t.removeAudioProcessor(A),null==(i=this._localScreenAudioTrack)||i.removeAudioProcessor(e)}destroy(){this.close(),this.audioReferenceMap.clear(),this.getPCMAbortCtrlMap.forEach(A=>null==A?void 0:A.abort("destroy")),this.getPCMAbortCtrlMap.clear(),this.audioFrameEventConfigMap.clear(),this.uninstallEvent()}addEncodeProcessor(A){let{processor:e,type:t}=A;var i;this.encodePipeline.includes(e)||(this.encodePipeline[t]=e,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(A){let{processor:e,type:t}=A;var i;this.decodePipeline.includes(e)||(this.decodePipeline[t]=e,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(A){let{type:e}=A;this.encodePipeline[e]=void 0}removeDecodeProcessor(A){let{type:e}=A;this.decodePipeline[e]=void 0}handleLocalTrackStarted(A){let{room:e,userId:t}=A;var i;if(e!==this.room||this.getPCMAbortCtrlMap.get(t))return;let o=this.getPCM(A=>{var e;null==(e=this.room)||e.emit("audio-frame",A)},"");this.getPCMAbortCtrlMap.set(t,o),this.getPCMAbortCtrlMap.get(t)&&(null==(i=this._localAudioTrack)||i.on("input-media-track-changed",()=>{let A=this.getPCMAbortCtrlMap.get(t);A&&(A.abort("inputMediaTrackChanged"),A=this.getPCM(A=>{var e;null==(e=this.room)||e.emit("audio-frame",A)},""),this.getPCMAbortCtrlMap.set(t,A))}))}handleLocalTrackStopped(A){let{room:e,userId:t}=A;if(e!==this.room)return;let i=this.getPCMAbortCtrlMap.get(t);i&&(i.abort("stopLocalAudio"),this.getPCMAbortCtrlMap.delete(t))}handleRemoteTrackStarted(A){let{room:e,userId:t}=A;if(e===this.room&&!this.getPCMAbortCtrlMap.get(t)){let A=this.room.audioManager.getPCM(A=>{var e;null==(e=this.room)||e.emit("audio-frame",A)},t);this.getPCMAbortCtrlMap.set(t,A)}}handleRemoteTrackStopped(A){let{room:e,userId:t}=A;if(e!==this.room)return;let i=this.getPCMAbortCtrlMap.get(t);i&&(i.abort("stopRemoteAudio"),this.getPCMAbortCtrlMap.delete(t))}installEvent(){tG.on("113",this.handleLocalTrackStarted,this),tG.on("114",this.handleLocalTrackStopped,this),tG.on("115",this.handleRemoteTrackStarted,this),tG.on("116",this.handleRemoteTrackStopped,this)}uninstallEvent(){tG.off("113",this.handleLocalTrackStarted),tG.off("114",this.handleLocalTrackStopped),tG.off("115",this.handleRemoteTrackStarted),tG.off("116",this.handleRemoteTrackStopped)}updateAudioReference(A){let{type:e,audioReference:t,refId:i,volume:o}=A;if("add"===e){if(this.audioReferenceMap.get(i)||!t||(this.audioReferenceMap.set(i,t),!this.audioProcessor))return;this.mixAudioReference(t,i)}else if("remove"===e)this.audioReferenceMap.get(i)&&(this.audioReferenceMap.delete(i),this.unMixAudioReference(i));else if("updateVolume"===e){if(!this.audioProcessor||H_(o))return;this.setAudioReferenceVolume(i,o)}}};function iY(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return xF((t,i)=>function(){for(var o=arguments.length,n=new Array(o),r=0;r{let s=setTimeout(()=>{let t=new rM({code:oM.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(A,"s")});(this.log||this._log||sG).warn(t),2===e?r(t):1===e&&o()},1e3*A);this._checkPendingPromiseSet||(this._checkPendingPromiseSet=new Set),this._checkPendingPromiseSet.add(s),t.apply(this,n).then(o,r).finally(()=>{clearTimeout(s),this._checkPendingPromiseSet&&s&&this._checkPendingPromiseSet.delete(s)})})})}var oY=class A extends _F{constructor(e,t,i){super({userId:t.userId,sdkAppId:e.sdkAppId,mediaType:i,room:e}),this.room=e,this.user=t,HS(this,"tinyId"),HS(this,"isRemote",!0),HS(this,"jitterBufferDelay",0),HS(this,"availableState"),HS(this,"remotePublishState"),HS(this,"_triggerCheckDecodeSubject",MO(PO(this,A.STATE_SUBSCRIBE))),HS(this,"ignoreUpdatePlayingState"),this.tinyId=t.tinyId,this.availableState=new ZL("".concat(t.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new ZL("".concat(t.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),sO(hO(PO(this,ZL.STATECHANGED),PO(this.remotePublishState,ZL.STATECHANGED)),Gx(()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing)),cP(A=>{this.availableState.state!==(A?ZL.ON:ZL.OFF)&&(this.availableState.state=A?ZL.ON:ZL.OFF),(!this.isRemotePublished||!this.ignoreUpdatePlayingState)&&this.updatePlayingState(A)}));let o=sO(PO(this.player,oU.ERROR),rx(A=>A.code===MediaError.MEDIA_ERR_DECODE)),n=sO(FO(5e3),rx(()=>!(!(!this.ignoreDecodeError&&this.isSubscribed&&this.isPlayCalled&&this.stat.bytesReceived&&this.isRemotePublished)||(this.player.isPlaying||(this.kind===WM.AUDIO?this.getAudioLevel()>0:this.stat.framesDecoded>0))&&(this.reportDecodeResult(!0),1)))),r=sO(CO(o,n),gx(PO(this,ZL.INIT)));sO(this._triggerCheckDecodeSubject,rx(()=>!this.ignoreDecodeError),Yx(r),cP(A=>{this.reportDecodeResult(!1,A)}))}setMute(A){this.isRemotePublished&&super.setMute(A)}setInputMediaStreamTrack(A){super.setInputMediaStreamTrack(A),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}checkDecodeResult(){this._triggerCheckDecodeSubject.next(!0)}waitHasMediaTrack(){return new Promise(A=>{this.mediaTrack?A():this.once("input-media-track-changed",A)})}get ignoreDecodeError(){var A,e,t,i;return null!=(i=null==(t=null==(e=null==(A=this.room)?void 0:A.networkQuality)?void 0:e.hadRecentBadDownlink)?void 0:t.call(e,2))&&i||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===A.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===ZL.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(A){return A}unsubscribe(){"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(A,e){var t,i;let o=this.kind===WM.AUDIO;if(Gk[A?"addSuccessEvent":"addFailedEvent"]({key:o?504700:514702}),!o){let e=(null==(t=this.room)?void 0:t.downlinkVideoCodec.toUpperCase())||"H264";Gk[A?"addSuccessEvent":"addFailedEvent"]({key:Tk["DECODE_".concat(e,"_RESULT")]}),A||this.log.warn("".concat(null==(i=this.room)?void 0:i.downlinkVideoCodec," decode failed"))}A||(Gk.addEnum({key:o?504701:514703,value:zb()}),gU.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(Vb()||Xb()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===WM.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:e}))}updatePlayingState(A){if(this.player.isPlayCalled&&this.player.setTrack(this.playerMediaTrack),this.isPlayCalled&&this.player.isStopped===A){if(A&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));super.updatePlayingState(A)}}close(){super.close(),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}onFlagChanged(){this.remotePublishState.state=this.isRemotePublished?ZL.ON:ZL.OFF,this.emit("remote-publish-changed",this.isRemotePublished)}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};HS(oY,"STATE_SUBSCRIBE","subscribe"),JS([iY(5,1)],oY.prototype,"waitHasMediaTrack",1),JS([KL(ZL.INIT,oY.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),tG.emit(oG.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),WF(521716,!1)],oY.prototype,"subscribe",1),JS([KL(oY.STATE_SUBSCRIBE,ZL.INIT,{sync:!0,success(){this.log.info("unsubscribed"),tG.emit(oG.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],oY.prototype,"unsubscribe",1);var nY=oY,rY=class extends nY{constructor(A,e){super(A,e,1),HS(this,"volume",0),HS(this,"mediaType",1),HS(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=A.audioManager}get dbVolume(){return lF.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}onPlayerError(A){this.enableDecodeFrame&&(this._log.warn("use audio decoder"),this.room.enableInsertableStreams())}get enableDecodeFrame(){var A,e;return!!this.manager&&(this.manager.decodePipeline.some(A=>A)||(null==(e=null==(A=this.player.element)?void 0:A.error)?void 0:e.code)===MediaError.MEDIA_ERR_DECODE&&wL().AudioDecoder&&mL)}get enableDecryptFrame(){return this.manager&&!!this.manager.decodePipeline[0]}decodeFrame(A){if(!this.manager)return A;let e=A;for(let[t,i]of this.manager.decodePipeline.entries()){if(!i)continue;let o={frame:A,track:this};if(1===t&&this.isAvailable&&"audience"===this.room.role&&(o.onAudioFrameNTPTime=A=>{let{ntp:e,frame:t,hasLeavingTag:i}=A;this.emit("audio-frame-with-ntp",{ntp:e,frame:t,hasLeavingTag:i})}),e=i(o),!e)return}return e}getAudioLevel(){if(!this.isAvailable)return 0;let A=this.volume||super.getAudioLevel();return A>1?1:A}getInternalAudioLevel(){return this.isAvailable?super.getInternalAudioLevel():0}get isRemotePublished(){return this.user.muteState.audioAvailable}},sY=class extends RP{constructor(A,e,t,i,o){super(A,{useDefaultProgram:!0,useFbo:!0,name:"alpha",create2d:!0,logger:e}),this.setContainer=i,HS(this,"initStat",{alphaStitchingType:1}),HS(this,"end",MO()),HS(this,"minSize",320),HS(this,"maxSize",1280),HS(this,"draggable",!1),HS(this,"startDragX",0),HS(this,"startDragY",0),HS(this,"left",0),HS(this,"top",0),HS(this,"baseWidth",320),HS(this,"baseRatio"),HS(this,"container"),this.initStat=o,this.draggable=t,this.bindDragEvents(),Gk.addEnum({key:515700,value:1}),this.draggable&&Gk.addEnum({key:515700,value:11})}bindDragEvents(){let A=this.context._canvas;if(A)if(this.draggable){let e=gx(this.end);sO(PO(A,"mousedown"),lP(this.startDrag.bind(this)),xx(()=>sO(PO(window,"mousemove"),gx(PO(window,"mouseup")))),e,cP(this.doDrag.bind(this))),sO(PO(A,"dblclick"),e,cP(this.resetPosition.bind(this))),sO(PO(A,"wheel"),e,cP(this.handleZoom.bind(this))),this.renderCanvas()}else{if(!this.container)return;this.container.style.removeProperty("left"),this.container.style.removeProperty("top"),this.end.next()}}render(A){var e;return!(null==(e=this.input)||!e.requestFrame(A)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}startDrag(A){A.preventDefault(),0===A.button&&(this.startDragX=A.clientX-this.left,this.startDragY=A.clientY-this.top)}renderCanvas(){let{container:A}=this;A||this.setContainer(),A&&this.baseRatio&&this.draggable&&(A.style.setProperty("width","".concat(this.baseWidth,"px")),A.style.setProperty("height","".concat(this.baseWidth/this.baseRatio,"px")),A.style.setProperty("position","fixed"),A.style.setProperty("left","".concat(this.left,"px")),A.style.setProperty("top","".concat(this.top,"px")))}doDrag(A){A.preventDefault(),this.left=A.clientX-this.startDragX,this.top=A.clientY-this.startDragY,this.renderCanvas()}handleZoom(A){A.preventDefault();let e=A.deltaY,t=this.context._canvas;t&&(this.baseWidth||(this.baseWidth=t.offsetWidth),this.baseWidth=e<0?Math.min(1.1*this.baseWidth,this.maxSize):Math.max(.9*this.baseWidth,this.minSize),this.renderCanvas())}resetPosition(){this.left=0,this.top=0,this.renderCanvas()}onRatioReset(){this.renderCanvas()}draw2d(A,e,t,i,o){var n;let{ctx2d:r}=this,s=this.context._canvas;if(!r||!s)return!1;let a=super.draw2d(A,e,t,i,o),g=r.getImageData(0,0,i,o),{data:c}=g,l=!1;if(1===this.initStat.alphaStitchingType){let A=Math.floor(i/2);for(let e=0;e=100;c[o+3]=s?255:0}l=super.draw2d(g,0,0,0,0,A,o),s.width=A}else if(2===this.initStat.alphaStitchingType){let A=Math.floor(o/2);for(let e=0;e=100;c[o+3]=s?255:0}l=super.draw2d(g,0,0,0,0,i,A),s.height=A}return null==(n=this.context.ctx)||n.clearRect(0,0,i,o),a&&l}close(){this.baseRatio=void 0,this.end.next(),this.end.complete()}},aY=class extends nY{constructor(A,e){super(A,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),HS(this,"mediaType",4),HS(this,"source"),HS(this,"shouldRenderAlpha",!1),HS(this,"alphaNode"),HS(this,"shouldBeDraggable",!0),HS(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0,keyFramesDecoded:0}),HS(this,"_keyFrameCountLogged",!1),HS(this,"_keyFrameStartTimestamp",0),HS(this,"_keyFrameStartCount",0),HS(this,"_keyFrameIntervals",[]),HS(this,"_prevKeyFrameTimestamp",0),this.manager=A.videoManager,this.on("first-video-frame",A=>{this.room.emit("first-video-frame",A)})}isAlphaSei(A){if(this.userId!==A.userId||50!==A.seiPayloadType)return!1;let e=new Uint8Array(A.data);return e.length%3==0&&0===e[0]&&1===e[1]&&e}play(A,e){return null!=e&&e.canvasRender&&!this.source&&this.useCanvasPlayer(),super.play(A,e).then(()=>{this.player.calculateStat(),tG.emit("156",{track:this,player:this.player})})}updateAlphaRenderInfo(A){let e=this.isAlphaSei(A);if(e)if(this.alphaNode){let A=e[2];if(this.alphaNode.baseRatio&&this.alphaNode.initStat.alphaStitchingType===A)return;this.alphaNode.initStat={alphaStitchingType:A};let t=this.player.getElement();if(t){let e=t.videoWidth/t.videoHeight;e&&(this.alphaNode.baseRatio=e*(1===A?.5:2),this.alphaNode.onRatioReset())}this.player.canvas&&(this.player.canvas.id=this.generateAlphaCanvasName(A))}else this.shouldRenderAlpha=!0,this.player.shouldRenderAlpha=!0,this.useCanvasPlayer(e[2])}generateAlphaCanvasName(A){let e=Ck[A];return"".concat("alpha","_").concat(e,"_").concat(this.userId)}useCanvasPlayer(A){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),!this.player.element)return;let e=new JP({frameRate:15,logger:this.log,name:this.shouldRenderAlpha&&A?this.generateAlphaCanvasName(A):this.userId});e.create({alpha:this.shouldRenderAlpha,willReadFrequently:this.shouldRenderAlpha});let t=new NP(e,{name:"remotePlayer",logger:this.log});if(this.source=e.createVideoPlayerSource(this.player),this.player.setCanvas(e._canvas),this.shouldRenderAlpha&&A){let i=()=>{!this.player.container||!this.alphaNode||(this.alphaNode.container=this.player.container,this.alphaNode.renderCanvas())},o=new sY(e,this.log,this.shouldBeDraggable,i,{alphaStitchingType:A});this.source.connect(o),o.connect(t),this.alphaNode=o}else this.source.connect(t);GL()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(A){let e=this.decodeFPS,t=(i=e,[15,30,45,60].reduce((A,e)=>Math.abs(e-i)A.msg_user_info.str_identifier===this.userId))||{},t=2===this.mediaType?7:this.isSmall?3:2;if(!e||0===e.length)return 0;let i=e.find(A=>A.uint32_video_stream_type===t);return(null==i?void 0:i.uint32_video_dec_fps)||0}stop(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),tG.emit("157",{track:this,player:this.player}),this.alphaNode&&this.alphaNode.close(),super.stop()}decodeFrame(A){if(!this.manager)return A;for(let e of this.manager.decodePipeline)if(e&&!(A=e({frame:A,track:this})))return;return A}get isBig(){return 4===this.mediaType}get isSmall(){return 8===this.mediaType}changeType(A){this.room.changeType(A,this.user)}get isRemotePublished(){return this.user.muteState.videoAvailable}setMirror(A){"publish"===A||"both"===A||super.setMirror(A)}setDraggable(A){this.shouldBeDraggable=A,this.alphaNode&&(this.alphaNode.draggable=A,this.alphaNode.bindDragEvents())}onDecodeDowngradeStateChanged(A){this.emit("decode-downgrade-state-changed",A)}updateKeyFramesDecoded(A){let e=this.stat.keyFramesDecoded||0;if(this.stat.keyFramesDecoded=A,this._keyFrameCountLogged)return;let t=Date.now();if(!this._keyFrameStartTimestamp)return this._keyFrameStartTimestamp=t,this._keyFrameStartCount=A,void(this._prevKeyFrameTimestamp=t);if(this._prevKeyFrameTimestamp&&A>e){let i=A-e,o=(t-this._prevKeyFrameTimestamp)/1e3/i;this._keyFrameIntervals.push(o)}this._prevKeyFrameTimestamp=t;let i=t-this._keyFrameStartTimestamp;if(i>=16e3){let e=A-this._keyFrameStartCount,t=e>0?i/1e3/e:0,o="".concat(e," keyframes in 16s ").concat(t," [").concat(this._keyFrameIntervals.map(A=>A.toFixed(1)).join(","),"] keyFramesDecoded ").concat(A),n=t<=2.5?"debug":"info";this.log[n](o),this._keyFrameCountLogged=!0}}},gY=class extends aY{constructor(A,e){super(A,e,2),HS(this,"mediaType",2),HS(this,"objectFit","contain")}get isRemotePublished(){return this.user.muteState.hasAuxiliary}},cY=new Map;function lY(A,e){let t=FS(US({},e),{timestamp:lM()});cY.has(A)?cY.get(A).push(t):cY.set(A,[t])}function IY(A,e,t,i){try{if(W_(A))for(let o=0;o$_(A)?AT(A):q_(A)?A:Y_(A))},fnName:o,value:t},link:{className:n,fnName:o}})})}else if(!H_(e.type)&&Y_(t)!==e.type)throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_TYPE,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})});if(!1===e.allowEmpty){let A=V_(t)&&(0===t||Number.isNaN(t)),r=q_(t)&&""===t.trim();if(A||r)throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_EMPTY,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})})}if(e.notLessThanZero&&V_(t)&&t<0)throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.CANNOT_LESS_THAN_ZERO,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})});if(!H_(e.min)&&V_(t)&&te.max)throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_MAX,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})});if(q_(e.instanceOf)){if(!t||t._name!==e.instanceOf)throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})})}else if(J_(e.instanceOf)&&!(t instanceof e.instanceOf))throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})});if(e.values&&!e.values.includes(t))throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PARAMETER_RANGE,data:{key:i,rule:e,fnName:o,value:t},link:{className:n,fnName:o}})});let{properties:r}=e;O_(r)&&K_(t)&&Object.keys(r).forEach(A=>{uY.call(this,{rule:r[A],value:t&&t[A],key:"".concat(i,".").concat(A),fnName:o,className:n})});let{arrayItem:s}=e;O_(s)&&W_(t)&&t.forEach((A,e)=>{uY.call(this,{rule:s,value:A,key:"".concat(i,"[").concat(e,"]"),fnName:o,className:n})}),J_(e.validate)&&e.validate.call(this,t,i,o,n,this)}tG.on(oG.JOIN_SUCCESS,A=>{let{room:e}=A;lY(e.userId,{eventId:32788})}),tG.on(oG.LEAVE_START,A=>{let{room:e}=A;lY(e.userId,{eventId:32789})}),tG.on(oG.LOCAL_TRACK_PUBLISHED,A=>{let{track:e}=A;if(e.room){let A=32769;4===e.mediaType?A=32768:2===e.mediaType&&(A=32805),lY(e.room.userId,{eventId:A})}}),tG.on(oG.LOCAL_TRACK_UNPUBLISHED,A=>{let{track:e}=A;if(e.room){let A=32771;4===e.mediaType?A=32770:2===e.mediaType&&(A=32806),lY(e.room.userId,{eventId:A})}}),tG.on(oG.TRACK_MUTED,A=>{let{track:e}=A;e.room&&(e.kind===WM.AUDIO?lY(e.room.userId,{eventId:e.isRemote?32785:32772,remoteUserId:e.isRemote?e.userId:void 0}):lY(e.room.userId,{eventId:e.isRemote?32784:32773,remoteUserId:e.isRemote?e.userId:void 0}))}),tG.on(oG.TRACK_UNMUTED,A=>{let{track:e}=A;e.room&&(e.kind===WM.AUDIO?lY(e.room.userId,{eventId:e.isRemote?32787:32774,remoteUserId:e.isRemote?e.userId:void 0}):lY(e.room.userId,{eventId:e.isRemote?32786:32775,remoteUserId:e.isRemote?e.userId:void 0}))}),tG.on(oG.REMOTE_TRACK_SUBSCRIBED,A=>{let{track:e}=A;e.room&&(1===e.mediaType&&lY(e.room.userId,{eventId:32777,remoteUserId:e.userId}),4===e.mediaType&&lY(e.room.userId,{eventId:32776,remoteUserId:e.userId}),8===e.mediaType&&lY(e.room.userId,{eventId:32803,remoteUserId:e.userId}))}),tG.on(oG.REMOTE_TRACK_UNSUBSCRIBED,A=>{let{track:e}=A;e.room&&(1===e.mediaType&&lY(e.room.userId,{eventId:32779,remoteUserId:e.userId}),4===e.mediaType&&lY(e.room.userId,{eventId:32778,remoteUserId:e.userId}),8===e.mediaType&&lY(e.room.userId,{eventId:32804,remoteUserId:e.userId}))}),tG.on(oG.SWITCH_DEVICE_SUCCESS,A=>{let{track:e}=A;e.room&&lY(e.room.userId,{eventId:e.kind===WM.VIDEO?32780:32781})}),tG.on(oG.LOCAL_TRACK_REPLACED,A=>{let{track:e}=A;e.room&&lY(e.room.userId,{eventId:e.kind===WM.VIDEO?32782:32783})}),tG.on(oG.SIGNAL_CONNECTION_STATE_CHANGED,A=>{let e,{room:t,prevState:i,state:o}=A;switch(o){case"CONNECTED":e="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":e="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":e=32794}e&&lY(t.userId,{eventId:e})}),tG.on(oG.PEER_CONNECTION_STATE_CHANGED,A=>{let e,{room:t,prevState:i,state:o,remoteUserId:n}=A,r=!!n;switch(o){case"CONNECTED":e="RECONNECTING"===i?r?32801:32798:r?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(e=r?32802:32799);break;case"RECONNECTING":e=r?32800:32797}e&&lY(t.userId,{eventId:e,remoteUserId:n})}),tG.on(oG.VIDEO_CODEC_IMPLEMENTATION_CHANGED,A=>{let{implementation:e,userId:t,remoteUserId:i,codec:o,isHWCodec:n,prevImplementation:r,streamType:s}=A,a=n?1:0;r||(a=n?3:2);let g={H264:0,H265:1,VP8:2}[o.toUpperCase()],c={eventId:4004,param1:a,param2:g,streamType:s||2};i&&(c.remoteUserId=i,c.eventId=4005),lY(t,c),Gk.addEnum({key:i?514701:513701,value:a}),Gk.addEnum({key:i?514700:513700,value:g})}),tG.on(oG.LOCAL_TRACK_RECAPTURE,A=>{let{track:e,error:t}=A;if(e.userId){let A={eventId:2003,param1:0};e.kind===WM.AUDIO?(A.streamType=1,t&&(A.param1=2)):(A.streamType="auxiliary"===e.streamType?7:2,t&&(A.param1=8)),lY(e.userId,A)}});var EY=YS(jS(),1),dY=class extends EY.EventEmitter{constructor(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";super(),this.mySelfId=A,this._log=e,this.key=t,HS(this,"userMap",new Map),HS(this,"remotePublishedUserMap",new Map),HS(this,"asrRobotUserMap",new Map)}get hasRobotUser(){return!![...this.remotePublishedUserMap.values()].find(A=>A.isRobot)}getPublishedUser(A){return this.remotePublishedUserMap.get(A)}addUser(A){let e=A[this.key],{userId:t,tinyId:i,role:o,fromType:n}=A;if(n===$R)return void this.addAsrRobotUser(A);if(this.userMap.has(e))return;let r={userId:t,tinyId:i,role:20===o?"anchor":"audience"};this.userMap.set(e,r),this.emit("1",r)}addAsrRobotUser(A){let e=A[this.key],{userId:t,tinyId:i,role:o}=A;if(this.asrRobotUserMap.has(e))return;let n={userId:t,tinyId:i,role:20===o?"anchor":"audience"};this.asrRobotUserMap.set(e,n),this.emit("8",n)}deleteUser(A,e){let t=this.userMap.get(A);if(!t)return;if(this.asrRobotUserMap.has(A))return void this.deleteAsrRobotUser(A);let i="peer leave [".concat(A,"]");H_(e)||(i+=":".concat(KR[e])),this._log.info(i);let o=this.remotePublishedUserMap.get(A);if(o){let e=o.muteState;o.flag=0,this.emit("5",o.userId),this.deleteRemotePublishedUser(A),this.emit("6",{prevMuteState:e,muteState:o.muteState,flag:0})}this.userMap.delete(A),this.emit("2",{userId:t.userId,reason:e})}deleteAsrRobotUser(A){if(!this.asrRobotUserMap.has(A))return;let e=this.asrRobotUserMap.get(A);e&&(this.asrRobotUserMap.delete(A),this.emit("9",e))}setUserList(A){this.userMap.forEach(e=>{A.findIndex(A=>A[this.key]===e[this.key])<0&&this.deleteUser(e[this.key],0)}),A.forEach(A=>{!this.userMap.has(A[this.key])&&A[this.key]!==this.mySelfId&&this.addUser(A)})}addRemotePublishedUser(A){this.remotePublishedUserMap.has(A[this.key])||this.remotePublishedUserMap.set(A[this.key],A)}deleteRemotePublishedUser(A){this.remotePublishedUserMap.has(A)&&this.remotePublishedUserMap.delete(A)}setRemotePublishedUserList(A){this.remotePublishedUserMap.forEach(e=>{let t=e[this.key];if(A.findIndex(A=>A[this.key]===e[this.key])<0){this._log.info("remote [".concat(t,"] unpublish"));let A=e.muteState;e.flag=0,this.emit("5",e.userId),this.deleteRemotePublishedUser(t),this.emit("6",{prevMuteState:A,muteState:e.muteState,flag:0})}}),A.forEach(A=>{var e;let t=A[this.key];if(t===this.mySelfId)return void this.emit("7",A);let{flag:i,userId:o,tinyId:n,fromType:r}=A,s=gT(i,o),a=null==(e=this.remotePublishedUserMap.get(t))?void 0:e.muteState;if(a){let A=this.remotePublishedUserMap.get(t);A&&A.flag!==i&&(A.flag=i,this._log.info("remote publish updated: ".concat(JSON.stringify(A.muteState))),this.emit("6",{prevMuteState:a,muteState:s,flag:i}))}else this._log.info("remote publish. state: ".concat(JSON.stringify(s))),this.addUser({userId:o,tinyId:n,role:20,fromType:r}),this.emit("3",A),this.emit("6",{prevMuteState:gT(0,o),muteState:s,flag:i})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}},hY=YS(jS(),1),CY=class extends hY.default{constructor(){super(...arguments),HS(this,"_connectionTimeoutCount",0),HS(this,"_isFirewallRestrictionEventEmitted",!1)}increaseTimeoutCount(){this._connectionTimeoutCount+=1,this.checkAndEmitFirewallRestriction()}resetTimeoutCount(){this._connectionTimeoutCount=0}checkAndEmitFirewallRestriction(){this._connectionTimeoutCount>=3&&!this._isFirewallRestrictionEventEmitted&&(this._isFirewallRestrictionEventEmitted=!0,this.emit("firewall-restriction"))}destroy(){this._connectionTimeoutCount=0,this._isFirewallRestrictionEventEmitted=!1,this.removeAllListeners()}};function BY(A){let{timesInSecond:e,maxSizeInSecond:t,getSize:i}=A;return xF((A,o)=>{let n=new WeakMap;return tG.on(oG.ROOM_DESTROY,A=>{let{room:e}=A;return n.delete(e)}),function(){let r=n.get(this);for(var s=arguments.length,a=new Array(s),g=0;g1e3&&(r.timestamp=Date.now(),r.callCountInSecond=0,r.totalSizeInSecond=0),i&&(r.totalSizeInSecond+=i(...a)),0!==r.timestamp&&Date.now()-r.timestamp<1e3&&(r.callCountInSecond>=e||r.totalSizeInSecond>t))throw new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.CALL_FREQUENCY_LIMIT,data:{isTimes:r.callCountInSecond>=e,isSize:r.totalSizeInSecond>t,name:o,timesInSecond:e,maxSizeInSecond:t}})});r.callCountInSecond++,A.call(this,...a)}})}var QY,pY=!0,fY={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},mY={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},yY=((QY=yY||{})[QY.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",QY[QY.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",QY[QY.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",QY[QY.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",QY[QY.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",QY[QY.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",QY[QY.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",QY[QY.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",QY[QY.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",QY[QY.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",QY[QY.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",QY[QY.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",QY[QY.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",QY[QY.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",QY[QY.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",QY[QY.INVALID_ROOM_ID_REQUIRED=5015]="INVALID_ROOM_ID_REQUIRED",QY[QY.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",QY[QY.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",QY[QY.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",QY[QY.INVALID_ROOM_ID_TYPE_MISMATCH=5019]="INVALID_ROOM_ID_TYPE_MISMATCH",QY[QY.INVALID_ROOM_ID_DUPLICATE=5020]="INVALID_ROOM_ID_DUPLICATE",QY[QY.INVALID_OPERATION=5100]="INVALID_OPERATION",QY[QY.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",QY[QY.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",QY[QY.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",QY[QY.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",QY[QY.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",QY[QY.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",QY[QY.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",QY[QY.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",QY[QY.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",QY[QY.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",QY[QY.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",QY[QY.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",QY[QY.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",QY[QY.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",QY[QY.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",QY[QY.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",QY[QY.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",QY[QY.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",QY[QY.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",QY[QY.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",QY[QY.DEVICE_ERROR=5300]="DEVICE_ERROR",QY[QY.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",QY[QY.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",QY[QY.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",QY[QY.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",QY[QY.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",QY[QY.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",QY[QY.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",QY[QY.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",QY[QY.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",QY[QY.NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX=5310]="NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX",QY[QY.SERVER_ERROR=5400]="SERVER_ERROR",QY[QY.NEED_TO_BUY=5401]="NEED_TO_BUY",QY[QY.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",QY[QY.OPERATION_FAILED=5500]="OPERATION_FAILED",QY[QY.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",QY[QY.REJOIN_FAILED=5502]="REJOIN_FAILED",QY[QY.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",QY[QY.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",QY[QY.VIDEO_ENCODE_FAILED=5505]="VIDEO_ENCODE_FAILED",QY[QY.AUDIO_ENCODE_FAILED=5506]="AUDIO_ENCODE_FAILED",QY[QY.VIDEO_DECODE_FAILED=5507]="VIDEO_DECODE_FAILED",QY[QY.AUDIO_DECODE_FAILED=5508]="AUDIO_DECODE_FAILED",QY[QY.OPERATION_ABORT=5998]="OPERATION_ABORT",QY[QY.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",QY),DY=FS(US({},Qk),{INVALID_PARAMETER(A){let{fnName:e}=A;return"the parameters of the '".concat(e,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(A){let{key:e,rule:t,fnName:i,value:o}=A,n="".concat(e||t.name),r="";return r=Array.isArray(t.type)?t.type.join("|"):t.type,"'".concat(n,"' must be type of ").concat(r," when calling ").concat(i,"(), received type: ").concat(Y_(o),".")},INVALID_PARAMETER_EMPTY(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(A){let{key:e,rule:t,fnName:i,value:o}=A,n="".concat(e||t.name),r="".concat(t.instanceOf.name||t.instanceOf);return"'".concat(n,"' must be instanceof ").concat(r," when calling ").concat(i,"(), received type: ").concat(Y_(o),".")},INVALID_PARAMETER_RANGE(A){let{key:e,rule:t,fnName:i,value:o}=A;return"'".concat(e||t.name,"' must be one of ").concat(t.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_LESS_THAN_ZERO(A){let{key:e,rule:t,fnName:i}=A;return"'".concat(e||t.name,"' cannot be less than 0 when calling ").concat(i,"().")},INVALID_PARAMETER_MIN(A){let{key:e,rule:t,value:i}=A;return"the min value of ".concat(e||t.name," is ").concat(t.min,", received: ").concat(i,".")},INVALID_PARAMETER_MAX(A){let{key:e,rule:t,value:i}=A;return"the max value of ".concat(e||t.name," is ").concat(t.max,", received: ").concat(i,".")},INVALID_ELEMENT_ID(A){let{key:e,fnName:t}=A;return"'".concat(e,"' is not found in the document object when calling ").concat(t,"().")},INVALID_ELEMENT_ID_TYPE(A){let{key:e,fnName:t,type:i}=A;return"the element corresponding to '".concat(e,"' must be instanceof HTMLElement when calling ").concat(t,"(), received: ").concat(i,".")},INVALID_STREAM_ID(A){let{key:e}=A;return"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(A){let{key:e}=A;return"'".concat(e,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(A){let{key:e}=A;return"'".concat(e,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(A){let{key:e}=A;return"'".concat(e,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIRED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_ROOM_ID_TYPE_MISMATCH(A){let{key:e}=A;return"The type of target roomId must match the current roomId. Current room is using '".concat(e,"', but received '").concat("strRoomId"===e?"roomId":"strRoomId","'.")},INVALID_ROOM_ID_DUPLICATE(A){let{key:e}=A;return"the target '".concat(e,"' must not be the same as the current '").concat(e,"'.")},INVALID_STREAM_TYPE:A=>{let{fnName:e}=A;return"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(A){let{fnName:e}=A;return"the API '".concat(e,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(A){let{fnName:e}=A;return"cannot ".concat(e," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(A){let{fnName:e,value:t}=A;return"cannot ".concat(e," because remote user(userId: ").concat(t.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(A){let{fnName:e,value:t}=A;return"cannot ".concat(e," because remote user(userId: ").concat(t.userId,") does not publishing ").concat(t.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(A){let{fnName:e}=A;return"you are already ".concat(e,"(), cannot repeated call '").concat(e,"'.")},INVALID_OPERATION_NEED_VIDEO(A){let{fnName:e}=A;return"cannot call '".concat(e,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(A){let{fnName:e}=A;return"cannot call '".concat(e,"' because the microphone or screen share is not turned on.")},INVALID_BUFFER_EMPTY:A=>{let{key:e}=A;return"the buffer size of paramerter '".concat(e,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:A=>{let{fnName:e}=A;return"you need to call ".concat(e,"() after publish stream.")},ENV_NOT_SUPPORTED(A){let{fnName:e}=A;return"the current browser does not support the capability of the function '".concat(e,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(A){let{fnName:e}=A;return"cannot call ".concat(e," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(A){let{fnName:e,error:t}=A;return"'".concat(e,"' got device exception").concat(t?", error: ".concat(t.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"NotFoundError, no ".concat(t," detected, please check your device and the configuration on '").concat(e,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"NotAllowedError, you have disabled ".concat(t," access, please allow the current application to use the ").concat(t).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"NotReadableError, the ".concat(t," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(t).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"SecurityError, check whether the system security policy restricts the use of the ".concat(t,", and it is recommended to turn on the ").concat(t," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR(A){let{fnName:e,deviceType:t=vY(e),error:i}=A;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(i?" error: ".concat(i.toString(),"."):".")},CAMERA_RECOVER_FAILED(A){let{error:e}=A;return"camera recover capture failed ".concat((null==e?void 0:e.name)||"",": ").concat((null==e?void 0:e.originMessage)||(null==e?void 0:e.message))},MICROPHONE_RECOVER_FAILED(A){let{error:e}=A;return"microphone recover capture failed ".concat((null==e?void 0:e.name)||"",": ").concat((null==e?void 0:e.originMessage)||(null==e?void 0:e.message))},OPERATION_FAILED(A){let{fnName:e,error:t}=A;return"'".concat(e,"' failed, reason: ").concat(null==t?void 0:t.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(A){let{eventName:e}=A;return"an error was caught on trtc.on('".concat(e,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(A){let{reason:e,error:t}=A;return"video context error ".concat(e," ").concat((null==t?void 0:t.name)||""," ").concat((null==t?void 0:t.message)||"")},SERVER_ERROR(A){let{fnName:e,error:t}=A;return"'".concat(e,"' got server error: ").concat(null==t?void 0:t.toString(),", please check the SDK documentation.")},NEED_TO_BUY(A){let{value:e,url:t}=A;return"You need to buy packages for ".concat(e,". Refer to: ").concat(t)},ACCOUNT_NO_MONEY:A=>{let{fnParams:e}=A;return"your TRTC account run out of credit, please recharge.".concat(e.sdkAppId?" SDKAppId: ".concat(e.sdkAppId):"")},OPERATION_ABORT(A){let{fnName:e}=A;return"'".concat(e,"' abort")},UNKNOWN_ERROR(A){let{fnName:e,error:t}=A;return"'".concat(e,"' throw unknown exception").concat(t?", error: ".concat(t.toString(),"."):".")}});function vY(A){if(!A)return"camera";let e=A.toLowerCase();return e.includes("screen")?"screen share":e.includes("audio")?"microphone":"camera"}var wY=class A extends Error{constructor(A){let{code:e,extraCode:t,message:i="",messageParams:o,fnName:n="",originError:r,data:s}=A;var a;let g;g=i||function(A){let e,{code:t,params:i,enableDocLink:o=!1}=A,n="",r=yY[t];try{e=DY[r]}catch(s){e=DY.UNKNOWN_ERROR}return J_(e)?n=e(i):q_(e)&&(n=e),i.fnName&&!n.includes(i.fnName)&&("."!==n[n.length-1]&&(n+="."),n+=" thrown from ".concat(i.fnName,"()")),o&&(n+=" doc:"),n}({code:e===mY.SERVER_ERROR?e:t||e,params:US({fnName:n,error:r},o)}),super(g),HS(this,"name","RtcError"),HS(this,"code"),HS(this,"extraCode"),HS(this,"functionName"),HS(this,"message"),HS(this,"data"),HS(this,"handler"),HS(this,"originError"),this.name=yY[e],this.code=e,this.extraCode=t,this.functionName=n,this.originError=r,this.message=g,this.data=s,5302===this.extraCode&&null!=(a=this.originError)&&a.message.includes("system")&&(this.handler=()=>{let A=document.createElement("a");qN?A.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):VN&&(A.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),A.href.length>0&&A.click()})}static convertFrom(e,t,i){let o=e;if(e instanceof rM){let{stack:n}=e,r={code:mY.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case oM.INVALID_PARAMETER:r.code=mY.INVALID_PARAMETER,r.message=e.message;break;case oM.INVALID_OPERATION:r.code=mY.INVALID_OPERATION;break;case oM.NOT_SUPPORTED:case oM.NOT_SUPPORTED_H264:r.code=mY.ENV_NOT_SUPPORTED,e.getCode()===oM.NOT_SUPPORTED_H264&&(r.extraCode=e.message.includes(Qk.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case oM.JOIN_ROOM_FAILED:r.messageParams={fnParams:i};case oM.SERVER_TIMEOUT:case oM.SWITCH_ROLE_FAILED:case oM.SWITCH_ROOM_FAILED:r.code=mY.SERVER_ERROR,r.extraCode=e.getExtraCode();break;case oM.API_CALL_ABORTED:r.code=mY.OPERATION_ABORT;break;case oM.DEVICE_NOT_FOUND:case oM.DEVICE_AUTO_RECOVER_FAILED:case oM.INITIALIZE_FAILED:r.code=5300,e.name&&(r.extraCode=function(A){let e;switch(A){case"NotFoundError":e=5301;break;case"NotAllowedError":e=5302;break;case"NotReadableError":e=5303;break;case"OverconstrainedError":e=5304;break;case"InvalidStateError":e=5305;break;case"SecurityError":e=5306;break;case"AbortError":e=5307;break;default:e=5300}return e}(e.name));break;case oM.VIDEO_ENCODE_FAILED:r.extraCode=5505;case oM.AUDIO_ENCODE_FAILED:r.extraCode=5506,r.code=mY.OPERATION_FAILED;break;case oM.UNKNOWN:break;default:r.code=mY.OPERATION_FAILED}o=new A(r),n&&(o.stack+=n.substr(n.indexOf("\n")))}else{if(e instanceof A)return e;o=new A({code:mY.UNKNOWN_ERROR,fnName:t,originError:e})}return o}};function SY(A){return"sub"===A?"auxiliary":"auxiliary"===A?"sub":"main"}function MY(A){return A===fY.QOS_PREFERENCE_CLEAR?"detail":A===fY.QOS_PREFERENCE_SMOOTH?"motion":""}function RY(A,e){let t=e?jM:VM;return WT(A)?US(US({},t),A):qM[A]?qM[A]:t}var _Y={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{type:["string","object","boolean"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},TY={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},NY={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(A,e,t){if(q_(A)&&!document.getElementById(A))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5009,fnName:t,messageParams:{key:e}})}},bY={name:"userId",required:!0,type:"string"},GY={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{type:["string","object"],properties:{bitrate:{type:"number"},channelCount:{type:"number"}}},echoCancellation:{values:[!0,!1,"remote-only","all"]},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function kY(A,e){if(!A)throw new wY({code:mY.INVALID_OPERATION,extraCode:5101,fnName:e})}function LY(A,e,t){if(!A)throw new wY({code:mY.INVALID_OPERATION,extraCode:5102,fnName:e,messageParams:{value:t}})}function UY(A,e,t){if(!(/^[1-9]\d*$/.test(String(A))&&A<4294967295))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5013,fnName:e,messageParams:{key:t}})}function FY(A,e,t){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(A))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5012,fnName:e,messageParams:{key:t}})}function OY(A){var e;if(null==(e=null==A?void 0:A.option)||!e.small)return;if(!sL())return sG.warn("small stream is not supported"),void delete A.option.small;let t=RY(A.option.profile),i=RY(A.option.small,!0);return n=i,(o=t).width*o.height>=n.width*n.height&&o.frameRate>=n.frameRate&&o.bitrate>=n.bitrate?void 0:(sG.warn("small stream profile must be less than big stream profile. Big: ".concat(JSON.stringify(t),", Small: ").concat(JSON.stringify(i))),void delete A.option.small);var o,n}var xY={TRTC:{create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(A,e,t){if(this._room.isJoined)throw new wY({code:mY.INVALID_OPERATION,extraCode:5104,fnName:t});if(A.roomId){if(q_(A.roomId))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5016,fnName:t,messageParams:{key:e}});UY(A.roomId,t,e)}else{if(!A.strRoomId)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5015,fnName:t});FY(A.strRoomId,t,e)}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:NY,mute:{type:["boolean","string"]},publish:{type:"boolean"},capture:{required:!1,type:"boolean"},option:_Y},validate(A){var e,t;if((null==(e=null==A?void 0:A.option)||!e.videoTrack)&&Yk())throw new wY({code:mY.ENV_NOT_SUPPORTED,extraCode:5201});null!=(t=null==A?void 0:A.option)&&t.small&&OY(A)}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:FS(US({},NY),{required:!1}),publish:{type:"boolean"},capture:{required:!1,type:"boolean"},mute:{type:["boolean","string"]},option:_Y},validate(A){var e;null!=(e=null==A?void 0:A.option)&&e.small&&OY(A)}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},mute:{type:["boolean","string"],values:[!0,!1,"microphone"]},muteKeepVolumeDetection:{type:"boolean"},option:GY},validate(A){var e;if((null==(e=null==A?void 0:A.option)||!e.audioTrack)&&Yk())throw new wY({code:mY.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:["boolean","string"],values:[!0,!1,"microphone"]},muteKeepVolumeDetection:{type:"boolean"},option:GY}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:NY,publish:{type:"boolean"},option:TY},validate(A,e,t,i,o){var n;if(null==(n=null==A?void 0:A.option)||!n.videoTrack){if(Yk())throw new wY({code:mY.ENV_NOT_SUPPORTED,extraCode:5201});if(!Wk())throw new wY({code:mY.ENV_NOT_SUPPORTED,fnName:t,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:NY,publish:{type:"boolean"},option:TY}},muteRemoteAudio:[bY,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[bY,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:NY,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(A,e,t){kY(this._room.isJoined,t);let i=this._room.remotePublishedUserMap.get(A.userId);if(LY(!!i,t,A),i&&("main"===A.streamType&&!i.muteState.videoAvailable||"sub"===A.streamType&&!i.muteState.hasAuxiliary))throw new wY({code:mY.INVALID_OPERATION,extraCode:5103,fnName:t,messageParams:{value:A}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:FS(US({},NY),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(A,e,t){kY(this._room.isJoined,t);let i=this._room.remotePublishedUserMap.get(A.userId);if(LY(!!i,t,A),i){if("main"===A.streamType&&!i.muteState.videoAvailable||"sub"===A.streamType&&!i.muteState.hasAuxiliary)throw new wY({code:mY.INVALID_OPERATION,extraCode:5103,fnName:t,messageParams:{value:A}});if(A.option){let e="main"===A.streamType?i.remoteVideoTrack:i.remoteAuxiliaryTrack;if((A.option.pictureInPicture||A.option.fullScreen||A.option.fullScreen)&&(!e.isSubscribed||!e.player.isPlaying))throw new wY({code:mY.INVALID_OPERATION,message:"cannot set pictureInPicture or fullScreen when remote video is not playing"})}}}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(A,e,t){if("*"!==A.userId&&H_(A.streamType))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5014,fnName:t})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(A,e,t){kY(this._room.isJoining||this._room.isJoined,t)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(A,e,t,i){if(!DL)throw new wY({code:mY.ENV_NOT_SUPPORTED,fnName:t,extraCode:5207});if(!this._room.enableSEI)throw new wY({code:mY.INVALID_OPERATION,fnName:t,extraCode:5108});if(A.byteLength>1e3)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5018,fnName:t});if(0===A.byteLength)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5017,messageParams:{key:e},fnName:t});kY(this._room.isJoined,t)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(A,e,t){if(!A&&!this._room.isMainStreamPublished||A&&!this._room.isAuxStreamPublished)throw new wY({code:mY.INVALID_OPERATION,extraCode:5109,messageParams:{key:e},fnName:t})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(A,e,t,i){if(A.byteLength>1e3)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5018,fnName:t});if(0===A.byteLength)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5017,fnName:t,messageParams:{key:e}})}}},validate(A,e,t){if(kY(this._room.isJoined,t),"live"===this._room.scene&&"audience"===this._room.role)throw new wY({code:mY.INVALID_OPERATION,extraCode:5107,fnName:t,messageParams:{key:e}})}},switchRoom:{name:"switchRoomConfig",type:"object",required:!0,validate(A,e,t){if(kY(this._room.isJoined,t),this._room.useStringRoomId&&A.strRoomId===this._room.roomId||!this._room.useStringRoomId&&A.roomId===Number(this._room.roomId))throw new wY({code:mY.INVALID_PARAMETER,extraCode:5020,fnName:t,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(A.roomId&&this._room.useStringRoomId||!A.roomId&&A.strRoomId&&!this._room.useStringRoomId)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5019,fnName:t,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(A.roomId)UY(A.roomId,t,e);else{if(!A.strRoomId)throw new wY({code:mY.INVALID_PARAMETER,extraCode:5015,fnName:t});FY(A.strRoomId,t,e)}},properties:{roomId:{type:"number"},strRoomId:{type:"string"},privateMapKey:{type:"string"},userSig:{type:"string",required:!0},autoSubscribeCount:{type:"number",min:0,max:50}}},_switchPlaybackQuality:{name:"SwitchToQualityOptions",required:!0,type:["string","object"],properties:{quality:{type:"string"},streamList:{type:"array",arrayItem:{type:"object",properties:{name:{type:"string",required:!0},userId:{type:"string",required:!0},streamType:{type:"string",values:["main","sub"]}}}}}}}},PY=class extends Error{};function YY(A,e){let t=uT(A);for(let i=0;i!0),HS(this,"mergeUpdate",YY);let i=A.instances.get(e);i?i.set(t,this):A.instances.set(e,new Map([[t,this]]))}static get(e,t){if(!t)return;let i=A.instances.get(e);return i&&i.get(t)||new A(e,t)}static gets(e,t){let i=A.instances.get(e),o=[];return i&&i.forEach((A,e)=>{t.test(e)&&o.push(A)}),o}action(A,e,t){let i=e=>{var t;return 0===A?this.started=!0:3===A&&(this.started=!1),this.ops.shift(),null==(t=this.currentOp)||t.action(),e},o=e=>{var t,i;throw this.ops.shift(),0===A&&2===(null==(t=this.currentOp)?void 0:t.type)&&this.ops.shift().reject(new PY("start failed")),null==(i=this.currentOp)||i.action(),e},n={type:A,action:()=>e(...n.args).then(i,o),args:t,resolve:JY,reject:HY};try{switch(this.state){case 1:if(0===A)throw new PY("already started");break;case 4:if(2===A)throw new PY("not started");break;default:return this.cacheOp(n)}}catch(r){return Promise.reject(r)}return this.ops.push(n),n.promise=e(...n.args).then(i,o)}cacheOp(A){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===A.type)throw new PY("already start");break;case 3:switch(A.type){case 2:throw new PY("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new PY("unknown state")}else switch(A.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let A=new PY("keep stop");if(this.ops.slice(1).forEach(e=>e.reject(A)),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,A.args),this.lastOp.promise;case 3:throw new PY("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new PY("start not allowed after update");case 0:throw new PY("duplicate start");case 3:if(this.startSame(this.currentOp.args,A.args))throw this.ops.pop().reject(new PY("keep start")),new PY("already start")}}A.promise=new Promise((e,t)=>{A._resolve?A._resolve.then(e):A.resolve=e,A._reject?A._reject.catch(t):A.reject=t});let{action:e}=A;return A.action=()=>e().then(A.resolve,A.reject),this.ops.push(A),A.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};HS(qY,"instances",new WeakMap);var VY=qY,jY=new WeakMap,KY=(A,e)=>{if(e instanceof PY){let{stack:t}=e;e=new wY({code:mY.OPERATION_ABORT,message:"".concat(A," abort: ").concat(e.message),fnName:A}),t&&(e.stack+=t.substr(t.indexOf("\n")))}throw e};function WY(A,e){return xF((t,i)=>function(){for(var o=arguments.length,n=new Array(o),r=0;rfunction(){for(var n=arguments.length,r=new Array(n),s=0;s{var s,g;let c=null==(s=jY.get(this))?void 0:s.get(t(...r));if(c){let{timeoutId:A,resolve:e}=c;clearTimeout(A),e()}let l=setTimeout(()=>{if(3===a.state||4===a.state)return i();a.action(2,e.bind(this),r).catch(KY.bind(null,o)).then(i,n)},A);jY.has(this)?null==(g=jY.get(this))||g.set(t(...r),{timeoutId:l,resolve:i}):jY.set(this,new Map([[t(...r),{timeoutId:l,resolve:i}]]))})}return a.action(2,e.bind(this),r).catch(KY.bind(null,o))})}function ZY(A){return xF((e,t)=>function(){for(var i=arguments.length,o=new Array(i),n=0;nA.action(3,()=>Promise.resolve(),o))).then(()=>e.call(this,...o));let s=VY.get(this,r);return s?s.action(3,e.bind(this),o).catch(KY.bind(null,t)):e.apply(this,o)})}function XY(){return function(A,e,t){return A.prototype[e]=function(){let A=this._log||console,t='"'.concat(e,'" is a static method. Use TRTC.').concat(e,"() instead. See: ").concat(_M,"/en/TRTC.html#.").concat(e);A.warn(t)},t}}var $Y={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame",PERMISSION_STATE_CHANGE:"permission-state-change",VIDEO_SIZE_CHANGED:"video-size-changed",REALTIME_TRANSCRIBER_MESSAGE:"realtime-transcriber-message",REALTIME_TRANSCRIBER_STATE_CHANGED:"realtime-transcriber-state-changed",PICTURE_IN_PICTURE_STATE_CHANGED:"picture-in-picture-state-changed",FULL_SCREEN_STATE_CHANGED:"full-screen-state-changed"},AJ=new Set([$Y.AUDIO_VOLUME,$Y.AUDIO_FRAME,$Y.NETWORK_QUALITY,$Y.STATISTICS,$Y.SEI_MESSAGE,$Y.CUSTOM_MESSAGE,$Y.LAYER_DATA]),eJ={};PS(eJ,{ScheduleRequestType:()=>lJ,getAbilityConfig:()=>uJ,getScheduleDomain:()=>EJ,isNeedToSchedule:()=>rJ,scheduleProxy:()=>gJ,sendScheduleRequest:()=>aJ,setIsNeedToSchedule:()=>sJ,setScheduleProxy:()=>cJ});var tJ=null,iJ=0,oJ=72e5,nJ="trtc_schedule_cache",rJ=!0;function sJ(A){j_(A)&&A!==rJ&&(rJ=A,sG.info("setIsNeedToSchedule ".concat(A)),A?function(){if("undefined"!=typeof window&&"undefined"!=typeof localStorage)try{localStorage.removeItem(nJ)}catch(A){sG.error("clearScheduleCache error",A)}}():iJ=Date.now()+oJ)}function aJ(A){return VS(this,arguments,function(A){let{userId:e,sdkAppId:t,useStringRoomId:i,roomId:o,userSig:n,version:r,frameWorkType:s,role:a,latencyLevel:g}=A;return function*(){var A;if(!rJ&&tJ&&iJ>Date.now())return{isCached:!0,result:tJ};let c={delta:0,count:[1,1],msg:[],detail:[]};try{let E=new FormData;E.append("userId",String(e)),E.append("sdkAppId",String(t)),E.append("isStrGroupId",String(i)),E.append("groupId",String(o)),E.append("sdkVersion",r),E.append("userSig",String(n));let d=(null==(A=yield xb())?void 0:A.model)||jb();d&&E.append("model",d);let h=Xb();h&&E.append("osString",h);let C=Yb();C&&E.append("gpu",C),a&&E.append("role",String(a)),g&&E.append("latencyLevel",String(g)),s&&E.append("frameWorkType",String(s));let B=oT(),Q=yield(l=E,I=c,u=t,new Promise((A,e)=>{let t=null;iT([hJ(A=>I.count[0]=A+1,A=>{let{error:e,retry:i,retriedCount:o,retryFuncArgs:n}=A;I.msg[0]=e.message,t||(o>=1&&(n[0]=IJ(u,"config",WM.MAIN,!0)),i())})(IJ(u,"config",WM.MAIN),l,{get timeout(){return 1e3*x_(2+I.count[0])}}),hJ(A=>I.count[1]=A+1,A=>{let{error:e,retry:i,retriedCount:o,retryFuncArgs:n}=A;I.msg[1]=e.message,t||(o>=2&&(n[0]=IJ(u,"config",WM.BACKUP,!0)),i())})(IJ(u,"config",WM.BACKUP),l,{get timeout(){return 1e3*x_(2+I.count[1])}})]).then(e=>{t=e,A(t)}).catch(e)}));Q.config&&(Q.config.loggerDomain&&vM(Q.config.loggerDomain),j_(Q.config.scheduleCache)&&sJ(!Q.config.scheduleCache)),c.delta=oT()-B;let p=function(A,e,t){let i={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),n=IJ(A,"config",WM.MAIN),r=IJ(A,"config",WM.BACKUP);for(let A of o)if(A.startTime>=t&&(A.name===n||A.name===r)&&A.transferSize>0){let t=A.name===n?WM.MAIN:WM.BACKUP,o=Math.round(A.duration),r=Math.round(A.domainLookupStart-A.startTime),s=A.redirectStart>0?Math.round(A.redirectEnd-A.redirectStart):0,a=A.fetchStart>0?Math.round(A.domainLookupStart-A.fetchStart):0,g=Math.round(A.domainLookupEnd-A.domainLookupStart),c=Math.round(A.requestStart-A.secureConnectionStart),l=Math.round(A.secureConnectionStart-A.connectStart),I=Math.round(A.responseStart-A.requestStart),u=Math.round(A.responseEnd-A.responseStart),E=[g,c,l,I,u];gU.uploadEvent({log:"stat-schedule-net:".concat(o,"(").concat(r,"(").concat(s,"->").concat(a,")->").concat(E.join("->"),") ").concat(t),userId:e}),i=FS(US({},i),{totalCost:o,local:r,dns:g,tcp:l,tls:c,request:I,response:u});break}}catch(o){sG.error("getScheduleDetailCost error",o)}return i}(Number(t),e,B);return tJ=Q,function(A){if("undefined"!=typeof window&&"undefined"!=typeof localStorage)try{let e=Date.now()+oJ;localStorage.setItem(nJ,JSON.stringify({result:A,expireIn:e})),iJ=e}catch(u){sG.error("saveScheduleToLocalStorage error",u)}}(Q),{isCached:!1,result:Q,detailCost:p}}catch(E){let A=W_(E)?E[0]:E,e=V_(A.code)?A.code:0,t="schedule failed".concat(A.message?": ".concat(A.message):""),i=new rM({code:oM.SCHEDULE_FAILED,extraCode:e,message:mk({key:Bk.JOIN_ROOM_FAILED,data:{error:t,code:e}})});throw sG.error(t,e),i}var l,I,u}()})}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(xR).map(A=>'')).join("\r\n")),function(){if("undefined"!=typeof window&&"undefined"!=typeof localStorage)try{let A=localStorage.getItem(nJ);if(A){let{result:e,expireIn:t}=JSON.parse(A);t>Date.now()?(tJ=e,iJ=t,rJ=!1):localStorage.removeItem(nJ)}}catch(HV){sG.error("loadScheduleFromLocalStorage error",HV)}}(),tG.on("28",()=>sJ(!0)),tG.on("63",()=>sJ(!0)),tG.on("84",()=>sJ(!0)),tG.on("201",A=>{"RECONNECTING"===A.state&&sJ(!0)}),tG.on("202",A=>{"RECONNECTING"===A.state&&sJ(!0)});var gJ={main:"",backup:""};function cJ(A){W_(A)?(gJ.main=A[0],gJ.backup=A[1]):(gJ.main=A,gJ.backup=A)}var lJ=(A=>(A.CONFIG="config",A.TRTC_AUTO_CONF="trtcAutoConf",A.AUDIO_AI_AUTH="audioAiAuth",A))(lJ||{});function IJ(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:WM.MAIN,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(gJ[t]||EJ(A,t,i),"/api/v1/").concat(e)}function uJ(A,e,t){let i=IJ(A,e),o=IJ(A,e,WM.BACKUP),n=new URLSearchParams(t).toString();return iT([fetch("".concat(i,"?").concat(n)).then(A=>A.json()),fetch("".concat(o,"?").concat(n)).then(A=>A.json())])}function EJ(A){let e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:WM.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e=y_(A)?i?t===WM.MAIN?xR.MAIN_OVERSEA_BACKUP:xR.BACKUP_OVERSEA:t===WM.MAIN?xR.MAIN_OVERSEA:xR.BACKUP_OVERSEA:t===WM.MAIN?xR.MAIN:xR.BACKUP,e}function dJ(A,e,t){return new Promise((i,o)=>{PT({url:A,body:e,timeout:t.timeout,priority:"high"}).then(A=>{0===A.data.code?i(A.data.data):o({code:A.data.code,message:A.data.msg})}).catch(o)})}var hJ=(A,e)=>zT({retryFunction:dJ,settings:{retries:3,timeout:0},onError:e,onRetrying:A}),CJ=class{constructor(){HS(this,"_log"),this._log=sG.createLogger({id:"fd"})}download(A,e){return VS(this,null,function*(){let{type:t="blob"}=e||{};A=wT(A);try{let e,i=oT();if(e=J_(fetch)?yield this.downloadWithFetch(A,t):yield this.downloadWithXHR(A,t),!e||!e.data)throw new Error("data is empty");let o=oT()-i;return this._log.info("downloaded: ".concat(A,", return type: ").concat(t,", cost: ").concat(o,"ms")),Gk.addSuccessEvent({key:522700,cost:oT()-i}),e.data}catch(i){throw this._log.error("failed to download: ".concat(A,", error: ").concat(i)),Gk.addFailedEvent({key:522700,error:i}),i}})}downloadWithFetch(A,e){return VS(this,null,function*(){this._log.info("download with fetch: ".concat(A,", return type: ").concat(e));try{let t,i=yield fetch(A);if(!i.ok){let A=new Error("network response was not ok: ".concat(i.status));throw A.status=i.status,A}return t="arraybuffer"===e?yield i.arrayBuffer():yield i.blob(),{data:t}}catch(t){throw t}})}downloadWithXHR(A,e){return this._log.info("download with xhr: ".concat(A,", return type: ").concat(e)),new Promise((t,i)=>{let o=new XMLHttpRequest;o.open("GET",A,!0),o.responseType=e,o.onload=()=>{if(200===o.status||0===o.status&&o.response)t({data:o.response});else{let A=new Error("XHR failed, status: ".concat(o.status));A.status=o.status,i(A)}},o.onerror=i,o.send(null)})}loadWasm(A,e){return VS(this,null,function*(){this._log.info("loadWasm ".concat(A,", importObject: ").concat(JSON.stringify(e)));let t=oT(),i=null,o=null;if(J_(WebAssembly.instantiateStreaming)&&!A.startsWith("data:application/octet-stream;base64,")&&!A.startsWith("file://")&&J_(fetch))try{let t=fetch(A);i=(yield WebAssembly.instantiateStreaming(t,e)).instance}catch(n){o=n}if(!i)try{let t=yield this.download(A,{type:"arraybuffer"});i=(yield WebAssembly.instantiate(t,e)).instance}catch(n){o=n}if(i){let e=oT()-t;return this._log.info("loadedWasm ".concat(A,", cost: ").concat(e,"ms")),Gk.addSuccessEvent({key:522701,cost:e}),i}throw this._log.error("failed to loadWasm ".concat(A,", error: ").concat(o)),Gk.addFailedEvent({key:522701,error:o}),o})}loadScript(A){this._log.info("loadScript ".concat(A));let e=oT();return new Promise((t,i)=>{let o=document.createElement("script");o.type="text/javascript",o.onload=()=>{this._log.info("loadedScript ".concat(A,", cost: ").concat(oT()-e,"ms")),Gk.addSuccessEvent({key:522702,cost:oT()-e,split:1e3}),t(o)},o.onerror=e=>{this._log.error("failed to loadScript ".concat(A,", error: ").concat((null==e?void 0:e.message)||JSON.stringify(e))),Gk.addFailedEvent({key:522702}),i(e)},o.crossOrigin="anonymous",o.src=A,document.head.append?document.head.append(o):document.getElementsByTagName("head")[0].appendChild(o)})}};JS([lU({settings:{timeout:0,retries:3},onError(A,e,t){var i;404===(null==A?void 0:A.status)||null!=(i=null==A?void 0:A.message)&&i.includes("404")?(this._log.warn("download 404, stop retry"),t(A)):e()},onRetrying(A){this._log.warn("download retrying: ".concat(A))}})],CJ.prototype,"download",1),JS([lU({settings:{timeout:3e3,retries:3},onRetrying(A){this._log.warn("loadScript retrying: ".concat(A))}})],CJ.prototype,"loadScript",1);var BJ=new CJ;function QJ(A){let[e,t]=A,i=t.byteLength,o=parseInt(String(i/255),10),n=i%255,r=[];r.push(0,0,0,1,6,e);for(let a=0;aA+e.dataView.byteLength,0),r=new ArrayBuffer(n+e.data.byteLength),s=new DataView(r),a=new DataView(e.data),g=0;for(let c=0;cA.isSEI);null==t||t(A.reverse())}catch(i){}return e}function vJ(A){let{seiMessageList:e,isAudio:t,getNtpTime:i,isMain:o}=A;return new TransformStream({transform(A,n){let r=A;t?audioEncodePipeline.forEach(A=>{r=A({frame:r,ntp:i(),onDump:()=>{self.postMessage({type:"dump",isAudio:t,data:r.data,userId:""})}})}):videoEncodePipeline.forEach(A=>{r=A({frame:r,seiMessageList:e,onDump:()=>{self.postMessage({type:"dump",isAudio:t,data:r.data,userId:"",streamType:o?"main":"auxiliary"})}})}),n.enqueue(r)}})}function wJ(A){let{userId:e,streamType:t,isAudio:i}=A;return new TransformStream({transform(A,o){let n=A;i?(audioDecodePipeline.forEach(A=>{n=A({frame:n,onAudioFrameNTPTime:A=>{self.postMessage({type:"audio-ntp",data:A,userId:e,streamType:t})},onDump:()=>{self.postMessage({type:"dump",isAudio:i,data:n.data,userId:e})}})}),o.enqueue(n)):videoDecodePipeline.forEach(A=>{n=A({frame:n,onSEI:A=>{A.forEach(A=>{self.postMessage({type:"sei",seiPayloadType:A.seiPayloadType,data:A.seiPayload.buffer,userId:e,streamType:t})})},onDump:()=>{self.postMessage({type:"dump",isAudio:i,data:n.data,userId:e,streamType:t})}})}),o.enqueue(n)}})}function SJ(A){let e=[fP],t=[mJ,pJ,pP,fJ,QJ,vJ,wJ,kT,GT,QP],i="const videoEncodePipeline=[".concat(A.videoEncodePipeline.toString(),"];\n const videoDecodePipeline=[").concat(A.videoDecodePipeline.toString(),"];\n const audioEncodePipeline = [").concat(A.audioEncodePipeline.toString(),"];\n const audioDecodePipeline = [").concat(A.audioDecodePipeline.toString(),"];"),o="(()=>{".concat(e.map(A=>"const ".concat(A.name,"=(()=>").concat(A.toString(),")()")).join("\n"),"\n").concat(t.map(A=>A.toString()).join("\n"),";(").concat(()=>{let A=[],e=[],t=[],i=0;self.onmessage=o=>{switch(o.data.type){case"sei":o.data.isMain?(A.push(o.data.data),o.data.small&&t.push(o.data.data)):e.push(o.data.data);break;case"ntp-offset":i=o.data.data}},self.onrtctransform=o=>{let{options:n}=o.transformer,r=n.isReceiver?wJ({userId:n.userId,streamType:n.streamType,isAudio:n.isAudio}):vJ({getNtpTime:()=>Date.now()+i,isAudio:n.isAudio,isMain:n.isMain,seiMessageList:n.isMain?n.small?t:A:e});o.transformer.readable.pipeThrough(r).pipeTo(o.transformer.writable)}},")();").concat(i,"})()"),n=new Blob([o],{type:"text/javascript"}),r=URL.createObjectURL(n),s=new Worker(r);return URL.revokeObjectURL(r),s}var MJ,RJ=class{constructor(A){HS(this,"audioPlayer"),HS(this,"videoPlayer"),HS(this,"log"),this.audioPlayer=A.audioPlayer,this.videoPlayer=A.videoPlayer,this.log=A.log.createChild({id:"pip"}),this.videoPlayer.on(oU.USER_RESUME_IN_PIP_OR_FULL_SCREEN,this.handleUserResumeInPIPOrFullScreen,this),this.videoPlayer.on(oU.USER_PAUSE_IN_PIP_OR_FULL_SCREEN,this.handleUserPauseInPIPOrFullScreen,this),this.videoPlayer.on(oU.ENTER_PICTURE_IN_PICTURE,this.handleEnterPIPOrFullScreen,this),this.videoPlayer.on(oU.ENTER_FULL_SCREEN,this.handleEnterPIPOrFullScreen,this),this.videoPlayer.on(oU.LEAVE_PICTURE_IN_PICTURE,this.handleLeavePIP,this),this.videoPlayer.on(oU.LEAVE_FULL_SCREEN,this.handleLeaveFullScreen,this),this.videoPlayer.on(oU.VOLUME_CHANGE,this.handleVolumeChange,this)}handleUserResumeInPIPOrFullScreen(){this.audioPlayer.isPaused&&(this.log.warn("resume audio in ".concat(this.videoPlayer.isPictureInPicture()?"pip":"fullscreen")),this.audioPlayer.doResume()),lN&&Bb&&this.videoPlayer.resetSrcObjectToReplay()}handleUserPauseInPIPOrFullScreen(){this.audioPlayer.isPaused||(this.log.warn("pause audio in ".concat(this.videoPlayer.isPictureInPicture()?"pip":"fullscreen")),this.audioPlayer.doPause())}handleEnterPIPOrFullScreen(){this.videoPlayer.element&&this.audioPlayer.muted!==this.videoPlayer.element.muted&&(this.log.warn("sync video muted to ".concat(this.audioPlayer.muted," when enter ").concat(this.videoPlayer.isPictureInPicture()?"pip":"fullscreen")),this.videoPlayer.element.muted=this.audioPlayer.muted)}handleLeavePIP(){this.audioPlayer.isPaused&&!this.audioPlayer.isPausedByUserCall&&(this.log.warn("resume after leave pip"),this.audioPlayer.doResume()),this.videoPlayer.isPaused&&!this.videoPlayer.isPausedByUserCall&&(this.log.warn("resume video after leave pip"),this.videoPlayer.doResume())}handleLeaveFullScreen(){this.audioPlayer.isPaused&&!this.audioPlayer.isPausedByUserCall&&(this.log.warn("resume audio after leave fullscreen"),this.audioPlayer.doResume()),this.videoPlayer.isPaused&&!this.videoPlayer.isPausedByUserCall&&(this.log.warn("resume video after leave fullscreen"),lN&&Bb?this.videoPlayer.resetSrcObjectToReplay():this.videoPlayer.doResume())}handleVolumeChange(A){void 0!==A.muted&&this.audioPlayer.muted!==A.muted&&(this.log.warn("sync audio muted to ".concat(A.muted," in ").concat(this.videoPlayer.isPictureInPicture()?"pip":"fullscreen")),this.audioPlayer.setMuted(A.muted))}destroy(){this.videoPlayer.off(oU.USER_RESUME_IN_PIP_OR_FULL_SCREEN,this.handleUserResumeInPIPOrFullScreen,this),this.videoPlayer.off(oU.USER_PAUSE_IN_PIP_OR_FULL_SCREEN,this.handleUserPauseInPIPOrFullScreen,this),this.videoPlayer.off(oU.ENTER_PICTURE_IN_PICTURE,this.handleEnterPIPOrFullScreen,this),this.videoPlayer.off(oU.ENTER_FULL_SCREEN,this.handleEnterPIPOrFullScreen,this),this.videoPlayer.off(oU.LEAVE_PICTURE_IN_PICTURE,this.handleLeavePIP,this),this.videoPlayer.off(oU.LEAVE_FULL_SCREEN,this.handleLeaveFullScreen,this),this.videoPlayer.off(oU.VOLUME_CHANGE,this.handleVolumeChange,this)}},_J=!1;function TJ(A){var e=this;let{TRTC:t,room:i,errorModule:o,assetsPath:n}=A;return{TRTC:t,LocalMixVideoTrack:WP,LocalVideoTrack:DP,LocalScreenTrack:XP,room:i,assetsPath:n,fileDownloader:BJ,innerEmitter:tG,INNER_EVENT:oG,constants:dM,environment:XT,utils:vP,eventLogger:gU,log:this.room.getLogger(),loggerManager:sG,errorModule:o,kvStatManager:Gk,rtcDectection:cG,trtc:this,rx:zF,enums:lG,schedule:eJ,getDevices:BF,initVisionTaskRegistry:function(A,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/mediapipe/vision.js";return VS(e,null,function*(){!window.VisionTaskRegistry&&!_J&&(_J=!0,MJ=BJ.loadScript("".concat(A,"/").concat(i).replace(/([^:]\/)\/+/g,"$1"))),yield MJ,yield(yield window.VisionTaskRegistry.getInstance(A)).preloadModels(t)})},audioContext:AF(),deviceDetector:hF,AudioPlayer:SF,RemoteAudioPlayer:RF,VideoPlayer:OU,showAutoPlayDialog:UU,Timer:iU,clearStarted:(A,e)=>{let t=A.getAlias(),i=VY.instances.get(this);if(i)if(e){let A=i.get(t+e);if(!A)return;A.started=!1}else i.forEach((A,e)=>{e.startsWith(t)&&(A.started=!1)})},startGetPCM:eY,createAudioNode:sF,getNetworkTimeOffset:cM,validateSourceNode:()=>{var A;if(dN&&(null==(A=this.room.audioManager._localAudioPipline)||!A.source.node))throw new wY({code:mY.DEVICE_ERROR,extraCode:5310,message:"The audio processing plugin cannot be used due to the microphone's sampling rate is not 48KHz in Firefox. Please switch to another browser such as Chrome."})},createScriptTransformWorker:SJ,AVPlayerStateSyncManager:RJ,PlayerEvent:oU}}var NJ=new WeakMap,bJ="5.15.1-beta.8";function GJ(){for(var A=arguments.length,e=new Array(A),t=0;tfunction(){for(var i=arguments.length,o=new Array(i),n=0;nfunction(){for(var i=arguments.length,o=new Array(i),n=0;n$_(A)?AT(A):q_(A)?A:Y_(A))},value:t}})}else if(!H_(e.type)&&Y_(t)!==e.type)throw new wY(r(5002));if(!1===e.allowEmpty){let A=V_(t)&&(0===t||Number.isNaN(t)),e=q_(t)&&""===t.trim();if(A||e)throw new wY(r(5003))}if(e.notLessThanZero&&V_(t)&&t<0)throw new wY(r(5006));if(!H_(e.min)&&V_(t)&&te.max)throw new wY(r(5008));if(q_(e.instanceOf)){if(!t||t._name!==e.instanceOf)throw new wY(r(5004))}else if(J_(e.instanceOf)&&!(t instanceof e.instanceOf))throw new wY(r(5004));if(Array.isArray(e.values)&&!e.values.includes(t))throw new wY(r(5005));let{properties:s}=e;O_(s)&&K_(t)&&Object.keys(s).forEach(A=>{UJ.call(this,{rule:s[A],value:t&&t[A],key:"".concat(A),fnName:o,className:n})});let{arrayItem:a}=e;O_(a)&&W_(t)&&t.forEach((A,e)=>{UJ.call(this,{rule:a,value:A,key:"".concat(i,"[").concat(e,"]"),fnName:o,className:n})}),J_(e.validate)&&e.validate.call(this,t,i,o,n,this)}var FJ=0;function OJ(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:e=()=>"",replaceArg:t,getKVReportKey:i,ignoreLog:o,ignoreErrorLog:n}=A;return xF((A,r)=>function(){for(var s=arguments.length,a=new Array(s),g=0;g0?E.info("".concat(r,"() ").concat(d," ").concat(JSON.stringify(a,(A,e)=>u(A,e,["userSig","privateMapKey"])))):E.info("".concat(r,"() ").concat(d));let h=i?i(...a):Sk[r],C=(null==n?void 0:n(...a))||!1;try{let t=A.apply(this,a),i=oT();if(X_(t)){let A="".concat(r.includes("Plugin")?"".concat((null==(l=(c=a[0]).getName)?void 0:l.call(c))||""," "):" ");return t.then(t=>(E.info("".concat(r,"() success ").concat(d," ").concat(A).concat(e.call(this,...a))),Gk.addSuccessEvent({key:h,cost:oT()-i}),t)).catch(t=>{var i;let o=(t=wY.convertFrom.call(this,t,r,1===a.length?a[0]:a)).extraCode||t.code,n=null!=(i=t.message)&&i.includes(o)?"":" code:".concat(o),s=(null==t?void 0:t.code)===mY.OPERATION_ABORT;throw C||E[s?"warn":"error"]("".concat(r,"() failed ").concat(d," ").concat(A).concat(e.call(this,...a)," ").concat(t).concat(n," params: ").concat(JSON.stringify(a,u))),Gk.addFailedEvent({key:h,error:t}),t})}return Gk.addSuccessEvent({key:h}),t}catch(B){let A=(B=wY.convertFrom.call(this,B,r)).extraCode||B.code,e=null!=(I=B.message)&&I.includes(A)?"":" code:".concat(A),t=(null==B?void 0:B.code)===mY.OPERATION_ABORT;throw C||E[t?"warn":"error"]("".concat(r,"() failed ").concat(d," ").concat(B).concat(e," params: ").concat(JSON.stringify(a,u))),Gk.addFailedEvent({key:h,error:B}),B}})}var xJ,PJ=A=>xF((e,t)=>function(i,o){return VS(this,null,function*(){let n=this._plugins.get(i);if(!n)throw this._log.error("plugin ".concat(String(i)," is not found")),new wY({code:mY.OPERATION_ABORT,message:"plugin ".concat(String(i)," is not found"),fnName:t});if(J_(n.constructor.isSupported)&&!n.constructor.isSupported())throw this._log.error("plugin ".concat(String(i)," is not supported")),new wY({code:mY.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(i)," is not supported"),extraCode:5210,fnName:t});return LJ.call(this,n.getValidateRule(A),[o],t,"TRTC"),e.call(this,n,o)})}),YJ=0,JJ=class A{constructor(A){this.core=A,HS(this,"log"),HS(this,"customAudioReferenceMap",new Map),HS(this,"audioRefId",0),HS(this,"audioContext",AF()),HS(this,"localAudioWorkletNode"),HS(this,"screenAudioWorkletNode"),HS(this,"mixNode"),HS(this,"silentNode"),YJ+=1,this.log=A.log.createChild({id:"".concat(this.getAlias()).concat(YJ)}),this.log.info("created id=".concat(this.getAlias()).concat(YJ)),this.installEvent()}static getStartValidateRule(A){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(e,t,i,o){if(!A.room.audioManager.hasAudioTrack&&!A.room.audioManager.hasScreenAudioTrack)throw new wY({code:mY.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(A){return xJ||(xJ=this.doPreload(A)),xJ}doPreload(A){return VS(this,null,function*(){let e=yield this.core.fileDownloader.download(A,{type:"blob"}),t=URL.createObjectURL(e);try{yield xU(this.audioContext,t)}catch(i){this.log.error("preload audioProcessor failed. ".concat(i))}finally{URL.revokeObjectURL(t)}})}getName(){return A.Name}getAlias(){return"ap"}getGroup(){return"ap"}getValidateRule(e){switch(e){case"start":return A.getStartValidateRule(this.core);case"update":return A.updateValidateRule;case"stop":return A.stopValidateRule}}start(A){return VS(this,null,function*(){var e,t,i,o;let{room:n}=this.core,{sdkAppId:r,userId:s,userSig:a,assetsPath:g=this.core.assetsPath,audioReference:c,processLevel:l,enableDump:I,isLocalAudioNeedAudioProcess:u=!0,isScreenAudioNeedAudioProcess:E=!1}=A;if(this.core.room.audioManager.isLocalAudioNeedAudioProcess=u,this.core.room.audioManager.isScreenAudioNeedAudioProcess=E,!g)throw new wY({code:mY.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(g,"/audioProcessor-wasm.js")),u&&!this.localAudioWorkletNode){let{sign:A,status:e,timestamp:t}=yield this.getAuthData(r,s,a);this.localAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.localAudioWorkletNode,"localAudio",r,s,t,A,e,n)}if(E&&!this.screenAudioWorkletNode){let{sign:A,status:e,timestamp:t}=yield this.getAuthData(r,s,a);this.screenAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.screenAudioWorkletNode,"screenAudio",r,s,t,A,e,n)}this.mixNode||(this.mixNode=this.audioContext.createGain(),this.mixNode.gain.value=1),this.silentNode||(this.silentNode=this.audioContext.createConstantSource(),this.silentNode.offset.setValueAtTime(0,this.audioContext.currentTime),this.silentNode.start()),null==(e=this.localAudioWorkletNode)||e.port.postMessage({type:"enable"}),null==(t=this.screenAudioWorkletNode)||t.port.postMessage({type:"enable"}),n.audioManager.addAudioProcessor(this.mixNode,this.silentNode,this.localAudioWorkletNode,this.screenAudioWorkletNode),H_(c)||c.forEach(A=>{this.customAudioReferenceMap.set(A,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:A,refId:"o-".concat(this.audioRefId++)})}),H_(l)||null==(i=this.localAudioWorkletNode)||i.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:l}}),H_(I)||null==(o=this.localAudioWorkletNode)||o.port.postMessage({type:"dump",data:{enable:I}})})}update(A){return VS(this,null,function*(){var e,t,i;let{audioReference:o,enableDump:n,processLevel:r}=A;H_(o)||(this.customAudioReferenceMap.forEach((A,e)=>{this.customAudioReferenceMap.delete(e),this.core.room.audioManager.updateAudioReference({type:"remove",refId:A})}),o.forEach(A=>{this.customAudioReferenceMap.set(A,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:A,refId:"o-".concat(this.audioRefId++)})})),H_(r)||null==(e=this.localAudioWorkletNode)||e.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:r}}),H_(n)||(null==(t=this.localAudioWorkletNode)||t.port.postMessage({type:"dump",data:{enable:n}}),null==(i=this.screenAudioWorkletNode)||i.port.postMessage({type:"dump",data:{enable:n}}))})}stop(){return VS(this,null,function*(){var A,e;let{room:t}=this.core;null==(A=this.localAudioWorkletNode)||A.port.postMessage({type:"disable"}),null==(e=this.screenAudioWorkletNode)||e.port.postMessage({type:"disable"}),yield t.audioManager.removeAudioProcessor(this.localAudioWorkletNode,this.screenAudioWorkletNode)})}destroy(){this.localAudioWorkletNode&&(this.localAudioWorkletNode.port.onmessage=null),this.screenAudioWorkletNode&&(this.screenAudioWorkletNode.port.onmessage=null),this.uninstallEvent()}getAuthData(A,e,t){return VS(this,null,function*(){let i=String(Date.now()).slice(0,-3),{auth:o,sign:n,status:r,message:s}=yield function(A){return VS(this,arguments,function(A){let{sdkAppId:e,userId:t,userSig:i,timestamp:o}=A;return function*(){let A="".concat(function(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:WM.MAIN;return"https://".concat(gJ[e]||EJ(A,e),"/api/v1/audioAiAuth")}(e),"?sdkAppId=").concat(e,"&userId=").concat(t,"&userSig=").concat(i,"×tamp=").concat(o),n=yield fetch(A),{data:{errCode:r,errMsg:s,sign:a,status:g}}=yield n.json();if("1"===g)return{auth:!0,sign:a,status:g,message:s};let c=y_(e)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",l="Init RTCAudioProcessor failed.",I="";switch(r){case 1:I="Please check your params.";break;case 2:I="You need to buy packages. Refer to: ".concat(c);break;case 3:I="Server is invalid. Please contact our engineer. ";break;case 4:I="Your packages is not active. Refer to: ".concat(c);break;case 5:I="Your packages is expired. Refer to: ".concat(c);break;case 6:I="Your version is not supported."}return{auth:!1,status:g,message:s?"".concat(l," Reason: ").concat(s,". ").concat(I):"".concat(l,", ").concat(I)}}()})}({sdkAppId:A,userSig:t,userId:e,timestamp:i});if(!o)throw this.log.info("audioProcessor: ".concat(e," auth result: ").concat(o,". Message: ").concat(s)),new wY({code:mY.INVALID_PARAMETER,message:s});return{sign:n,status:r,timestamp:i}})}initWorkletNode(A,e,t,i,o,n,r,s){A.port.postMessage({type:"init",data:{sdkAppId:String(t),userId:i,timestamp:o,sign:n,status:r}}),A.port.onmessage=A=>{var t;let{data:i}=A;switch(i.type){case"cost":let A=(null==i?void 0:i.value)>10?"info":"debug";return void this.log[A]("".concat("localAudio"===e?"":"[".concat(e,"] "),"avg cost: ").concat(i.value," max: ").concat(null==i?void 0:i.max,"(").concat(uM(new Date(null==i?void 0:i.maxCostTimestamp)),") hist: ").concat(null==(t=null==i?void 0:i.hist)?void 0:t.join(" ")));case"log":return void this.log[i.logLevel]("".concat("localAudio"===e?"":"[".concat(e,"] ")).concat(i.value));case"dump":return void tG.emit("265",{room:s,data:i.value,type:"localAudio"===e?"dump":"dump-screen-audio"});case"detectEcho":return void this.log.warn("".concat("localAudio"===e?"":"[".concat(e,"] "),"detect echo: ").concat(Fb()?Vb():Xb()))}}}handleLocalAudioStarted(A){return VS(this,null,function*(){var e;if(this.hitTest(A.room)&&!0===(null==(e=this.core.room.scheduleResult.config)?void 0:e.audioProcessor))try{yield this.core.trtc.startPlugin("AudioProcessor",{sdkAppId:this.core.room.sdkAppId,userId:this.core.room.userId,userSig:this.core.room.userSig}),this.log.warn("audio processor auto start success")}catch(t){this.log.warn("audio processor auto start failed, error: ".concat(t))}})}handleLocalAudioStopped(A){return VS(this,null,function*(){var e;!this.hitTest(A.room)||!0!==(null==(e=this.core.room.scheduleResult.config)?void 0:e.audioProcessor)||(yield this.core.trtc.stopPlugin("AudioProcessor"))})}installEvent(){this.core.innerEmitter.on("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.on("114",this.handleLocalAudioStopped,this)}uninstallEvent(){this.core.innerEmitter.off("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.off("114",this.handleLocalAudioStopped,this)}hitTest(A){return A===this.core.room}};HS(JJ,"updateValidateRule",{type:"object"}),HS(JJ,"stopValidateRule",{type:"object"}),HS(JJ,"Name","AudioProcessor");var HJ=JJ,qJ=0,VJ=class{constructor(A,e){HS(this,"audioObjectURL"),HS(this,"player"),HS(this,"publisher"),HS(this,"mixInput"),this.mixInput=new oF(e),A.url?(this.player=new Audio(A.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(A.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(A.track),this.mixInput.connect()}updateSettings(A){this.player&&(H_(A.volume)||(this.volume=A.volume),H_(A.loop)||(this.loop=A.loop),H_(A.playbackRate)||(this.playbackRate=A.playbackRate))}updateListener(A){if(this.player){if(A.onDurationChange){let{onDurationChange:e}=A;this.player.ondurationchange=A=>{e(A.target.duration)}}if(A.onTimeUpdate){let e=A.onTimeUpdate,{player:t}=this;t.ontimeupdate=()=>{e(t.currentTime,t.duration)}}A.onEnded&&(this.player.onended=A.onEnded)}}reload(A){return VS(this,null,function*(){if(A.url){let e=yield BJ.download(A.url,{retries:3,type:"blob"});this.audioObjectURL&&URL.revokeObjectURL(this.audioObjectURL),this.audioObjectURL=URL.createObjectURL(e),this.player&&this.publisher?(this.player.src=this.audioObjectURL,this.publisher.src=this.audioObjectURL):(this.player=new Audio(this.audioObjectURL),this.player.crossOrigin="anonymous",this.publisher=new Audio(this.audioObjectURL),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher),this.updateListener(A),this.updateSettings(A))}else this.mixInput.replaceSource(A.track)})}reset(){this.seek(0),this.mixInput.connect()}seek(A){this.player&&(A<0&&A>this.player.duration||(this.player.currentTime=A,this.publisher.currentTime=A))}play(){var A,e;return Promise.all([null==(A=this.player)?void 0:A.play(),null==(e=this.publisher)?void 0:e.play()])}pause(){var A,e;null==(A=this.player)||A.pause(),null==(e=this.publisher)||e.pause()}stop(){var A;null==(A=this.player)||A.pause(),this.mixInput.disconnect()}setOperation(A){"pause"===A&&this.pause(),"resume"===A&&(this.pause(),this.play()),"stop"===A&&(this.pause(),this.seek(0))}set volume(A){!this.player||!this.publisher||(this.player.volume=A,this.publisher.volume=A)}set loop(A){!this.player||!this.publisher||(this.player.loop=A,this.publisher.loop=A)}set playbackRate(A){!this.player||!this.publisher||(this.player.playbackRate=A,this.publisher.playbackRate=A)}};function jJ(A,e){if(e&&"function"!=typeof e)throw new wY({code:mY.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(A," should be a function.")})}var KJ=class A{constructor(A){this.core=A,HS(this,"log"),HS(this,"mixedMusicMap",new Map),HS(this,"cacheMusicMap",new Map),qJ+=1,this.log=A.log.createChild({id:"".concat(this.getAlias()).concat(qJ)}),this.log.info("created id=".concat(this.getAlias()).concat(qJ))}getName(){return A.Name}getAlias(){return"ax"}getGroup(A){return null==A?void 0:A.id}getValidateRule(e){switch(e){case"start":return A.startValidateRule;case"update":return A.updateValidateRule;case"stop":return A.stopValidateRule}}start(A){return VS(this,null,function*(){let{room:e}=this.core;this.core.validateSourceNode(),this.log.info("add music source, id: ".concat(A.id," url: ").concat(A.url,", track: ").concat(A.track));let{id:t,url:i}=A;if(this.mixedMusicMap.has(t))return;let o=this.cacheMusicMap.get(t);o?A.url?o.reset():(o.mixInput.replaceSource(A.track),o.mixInput.connect()):(o=new VJ(A,e.audioManager),this.cacheMusicMap.set(t,o)),o.updateListener(A),o.updateSettings(A);try{yield o.play()}catch(n){yield this.handleAutoPlayFailed(o,A,n)}this.mixedMusicMap.set(t,o),o.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"add",audioReference:o.mixInput.source.node,refId:"ax-".concat(t)}),this.log.info("start mix audio track ".concat(t," success.")),Gk.addEnum({key:502700,value:3}),this.kvUpload(A)})}handleAutoPlayFailed(A,e,t){return VS(this,null,function*(){if("NotSupportedError"===t.name)this.log.error("play failed, try to reload source. error: ".concat(t)),yield A.reload(e),yield A.play();else{if("NotAllowedError"!==t.name)throw t;if(this.core.room.enableAutoPlayDialog){let e=()=>{var t;null==(t=A.play())||t.finally(()=>{tG.off("154",e,this)})};tG.on("154",e,this),UU()}else this.core.trtc.emit($Y.AUTOPLAY_FAILED,{userId:"",mediaType:"audio",resume:()=>VS(this,null,function*(){return A.play()})})}})}update(A){return VS(this,null,function*(){let{id:e,operation:t,seekFrom:i,playbackRate:o}=A;this.log.info("update music source, ".concat(JSON.stringify(A)));let n=this.mixedMusicMap.get(e);n?(n.updateSettings(A),n.updateListener(A),H_(t)||n.setOperation(t),H_(i)||n.seek(i),this.kvUpload(A)):this.log.warn("update music source failed, music id: ".concat(e," not found."))})}stop(A){return VS(this,arguments,function(A){var e=this;let{id:t}=A;return function*(){if(e.mixedMusicMap.has(t)){e.log.info("remove music source, music id: ".concat(t));let A=e.mixedMusicMap.get(t);null!=A&&A.mixInput.source.node&&e.core.room.audioManager.updateAudioReference({type:"remove",audioReference:A.mixInput.source.node,refId:"ax-".concat(t)}),null==A||A.stop(),e.mixedMusicMap.delete(t)}"*"===t&&e.destroyAllMusic()}()})}kvUpload(A){let{track:e,loop:t,volume:i,playbackRate:o,operation:n,seekFrom:r,onTimeUpdate:s,onDurationChange:a,onEnded:g}=A;e&&Gk.addCount({key:502009}),t&&Gk.addCount({key:502001}),i&&Gk.addCount({key:502002}),o&&Gk.addCount({key:502003}),n&&Gk.addCount({key:502004}),r&&Gk.addCount({key:502005}),"function"!=typeof s&&Gk.addCount({key:502007}),"function"!=typeof g&&Gk.addCount({key:502008}),"function"!=typeof a&&Gk.addCount({key:502006})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach((A,e)=>{null!=A&&A.mixInput.track&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:A.mixInput.track,refId:e}),this.stop({id:e})})}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};HS(KJ,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(A,e,t){if(A.url&&"*"!==A.url){let e=A.url.split("?")[0],i=["mp3","ogg","wav","flac"],o=e.split(".").pop(),n=i.indexOf(o)>=0,r=e.startsWith("blob"),s=e.startsWith("data");if(!(n||r||s))throw new wY({code:mY.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:t})}if(!A.url&&!A.track)throw new wY({code:mY.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:t});jJ("onTimeUpdate",A.onTimeUpdate),jJ("onEnded",A.onEnded),jJ("onDurationChange",A.onDurationChange)}}),HS(KJ,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(A,e,t){jJ("onTimeUpdate",A.onTimeUpdate),jJ("onEnded",A.onEnded),jJ("onDurationChange",A.onDurationChange)}}),HS(KJ,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),HS(KJ,"Name","AudioMixer");var WJ,zJ=KJ,ZJ=0,XJ=class A{constructor(A){this.core=A,HS(this,"log"),HS(this,"audioContext",AF()),HS(this,"workletNode"),HS(this,"config",{enableFarFieldReduce:!1,farFieldReduceThreshold:.5}),ZJ+=1,this.log=A.log.createChild({id:"".concat(this.getAlias()).concat(ZJ)}),this.log.info("created id=".concat(this.getAlias()).concat(ZJ))}static startValidateRule(A){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0},mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}},validate(e,t,i,o){if(!A.room.audioManager.hasAudioTrack)throw new wY({code:mY.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(A){return WJ||(WJ=this.doPreload(A)),WJ}doPreload(A){return VS(this,null,function*(){let e=yield this.core.fileDownloader.download(A,{type:"blob"}),t=URL.createObjectURL(e);try{yield xU(this.audioContext,t)}catch(i){throw this.log.error("load worklet failed",i),i}finally{URL.revokeObjectURL(t)}})}getName(){return A.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser"}getValidateRule(e){switch(e){case"start":return A.startValidateRule(this.core);case"update":return A.updateValidateRule;case"stop":return A.stopValidateRule}}start(A){return VS(this,null,function*(){let{room:e,schedule:t}=this.core,{assetsPath:i=this.core.assetsPath}=A;if(!i)throw new wY({code:mY.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(i,"/denoiser-wasm").concat(RL()?"":"-nosimd",".js")),!this.workletNode){let e=String(Date.now()).slice(0,-3),{auth:i,sign:o,status:n,message:r}=yield function(A,e){return VS(this,arguments,function(A,e){let{sdkAppId:t,userId:i,userSig:o,timestamp:n}=e;return function*(){try{let{data:{errCode:e,errMsg:r,sign:s,status:a}}=yield A.getAbilityConfig(t,A.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:t,userId:i,userSig:o,timestamp:n});if("1"===a)return{auth:!0,sign:s,status:a,message:r};let g=y_(t)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",c="Init RTCAIDenoiser failed.",l="";switch(e){case 1:l="Please check your params.";break;case 2:l="You need to buy packages. Refer to: ".concat(g);break;case 3:l="Server is invalid. Please contact our engineer. ";break;case 4:l="Your packages is not active. Refer to: ".concat(g);break;case 5:l="Your packages is expired. Refer to: ".concat(g);break;case 6:l="Your version is not supported."}return{auth:!1,status:a,message:r?"".concat(c," Reason: ").concat(r,". ").concat(l):"".concat(c,", ").concat(l)}}catch(e){return{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(e)}}}()})}(t,FS(US({},A),{timestamp:e}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(A.userId," auth result: ").concat(i,". Message: ").concat(r)),new wY({code:mY.INVALID_PARAMETER,message:r});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(A.sdkAppId),userId:A.userId,timestamp:e,sign:o,status:n}}),this.workletNode.port.onmessage=A=>{var e;let{data:t}=A;if("cost"===t.type){let A=(null==t?void 0:t.max)>20?"warn":(null==t?void 0:t.max)>10?"info":"debug";this.log[A]("avg cost: ".concat(t.value," max: ").concat(null==t?void 0:t.max,"(").concat(uM(new Date(null==t?void 0:t.maxCostTimestamp)),") hist: ").concat(null==(e=null==t?void 0:t.hist)?void 0:e.join(" ")))}else"log"===t.type&&this.log[t.logLevel]("".concat(t.value))}}this.updateConfig(A),this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(A){return VS(this,null,function*(){this.updateConfig(A)})}stop(){return VS(this,null,function*(){if(!this.workletNode)return;let{room:A}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield A.audioManager.removeDenoiser(this.workletNode)})}updateConfig(A){if(!this.workletNode)return;let e=!1;H_(A.mode)||(0===A.mode?this.config.enableFarFieldReduce=!1:1===A.mode&&(this.config.enableFarFieldReduce=!0),e=!0),H_(A.farFieldReduceThreshold)||(this.config.farFieldReduceThreshold=A.farFieldReduceThreshold,e=!0),e&&this.workletNode.port.postMessage({type:"setConfig",data:this.config})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};HS(XJ,"updateValidateRule",{type:"object",properties:{mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}}}),HS(XJ,"stopValidateRule",{type:"object"}),HS(XJ,"Name","AIDenoiser");var $J=XJ,AH=YS(jS(),1),eH=new class extends AH.EventEmitter{constructor(){super(),HS(this,"observer"),HS(this,"state","nominal"),this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return VS(this,null,function*(){if(!this.observer)try{"PressureObserver"in window&&!lN&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(A){gU.uploadEvent({log:"stat-pressure-detector-start-failed",error:A})}})}onPressureChange(A){let e=this.stateNum,t=A[A.length-1];this.state=t.state,(this.stateNum>3||e>3)&&sG.info("".concat(t.source,": ").concat(t.state)),this.emit("state-changed",{type:t.source,state:this.state})}destroy(){var A;try{null==(A=this.observer)||A.disconnect(),this.observer=null}catch(e){gU.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:e})}}},tH=0,iH=class A{constructor(A){this.core=A,HS(this,"log"),HS(this,"_seiMessageList",[]),HS(this,"_smallSeiMessageList",[]),HS(this,"_subStreamSeiMessageList",[]),tH++,this.log=A.log.createChild({id:"".concat(this.getAlias()).concat(tH)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(tH)),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode(A){let{frame:e,mediaType:t}=A;try{return yJ({frame:e,seiMessageList:8===t?this._smallSeiMessageList:2===t?this._subStreamSeiMessageList:this._seiMessageList})}catch(i){this.log.warn(i)}return e}decode(A){let{frame:e,track:t}=A;return DJ({frame:e,onSEI:A=>{A.forEach(A=>{null!=t&&t.userId?this.core.trtc.emit($Y.SEI_MESSAGE,{seiPayloadType:A.seiPayloadType,data:A.seiPayload.buffer,userId:t.userId,streamType:2===t.mediaType?"sub":"main"}):this.core.innerEmitter.emit(this.core.INNER_EVENT.SEI_MESSAGE,{room:this.core.room,nalu:A})})}})}destroy(){this.log.debug("destroy"),this.stop(),delete this.core}getValidateRule(A){switch(A){case"start":case"update":case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:mL?this.encode:yJ,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:mL?this.decode:DJ,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update(A){let{buffer:e,options:t}=A;var i;let o=[t.seiPayloadType,e],n=!!t.small;t.toSubStream?this._subStreamSeiMessageList.push(o):(this._seiMessageList.push(o),n&&this._smallSeiMessageList.push(o)),null==(i=this.core.room.scriptTransformWorker)||i.postMessage({type:"sei",data:o,isMain:!t.toSubStream,small:n})}getName(){return A.Name}getAlias(){return"sei"}getGroup(){return"sei"}};HS(iH,"autoStart",!0),HS(iH,"Name","SEI");var oH,nH=iH,rH=0,sH=class A{constructor(A){this.core=A,HS(this,"_core"),HS(this,"log"),HS(this,"dialog"),this._core=A,this.log=A.log.createChild({id:"".concat(this.getAlias()).concat(++rH)}),this.log.info("created")}getName(){return A.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(A){switch(A){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}start(){return VS(this,null,function*(){var A;!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(A=window.sessionStorage)?void 0:A.getItem("TRTC_ENABLE_DEBUG_PLUGIN"))||(yield this.openDebugDiaLog())})}update(A){return VS(this,arguments,function(A){var e=this;let{visible:t}=A;return function*(){t?yield e.openDebugDiaLog():e.closeDebugDiaLog()}()})}stop(){this.closeDebugDiaLog()}destroy(){this.stop()}openDebugDiaLog(){return VS(this,null,function*(){var A;if(!this.dialog)try{if(oH)yield oH;else{let e=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(A=window.sessionStorage)?void 0:A.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(CM,"/assets/debug-dialog.js");oH=this._core.fileDownloader.loadScript(e),yield oH}this.dialog=new TRTCDebugDialog(this._core,this.log),this._core.kvStatManager.addSuccessEvent({key:592705})}catch(e){this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(e))}})}closeDebugDiaLog(){this.dialog&&(this.dialog.closeDialog(),this.dialog=null)}};HS(sH,"Name","Debug"),HS(sH,"autoStart",!0);var aH=sH,gH=A=>{switch(A){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},cH=class{constructor(A,e,t){HS(this,"trackDoneOB"),HS(this,"startOB"),HS(this,"stopOB"),HS(this,"inputFrameCount",0),HS(this,"decodedFrameCount",0),HS(this,"type","auto"),HS(this,"config"),HS(this,"decoder"),HS(this,"_decodeSink");let{kvStatManager:i,trtc:o}=A;this.config=t.config,this.trackDoneOB=PO(e,ZL.INIT),this.stopOB=MO(),this.startOB=MO(),"auto"===t.type?this.type="webCodecs":this.type=t.type;let n=MO();sO(this.startOB,yO(0),xx(A=>{let t=this.pipe(e);return n.next("STARTING"),e.log.info("decoder type: ".concat(this.type)),sO(t,gx(this.stopOB),cP(()=>{},t=>{e.log.error(t),i.addFailedEvent({key:gH(this.type),error:t}),A>4?this.startOB.error(t):this.startOB.next(A+1)})),sO(t,ax(1),nP($O))}),gx(this.stopOB),cP(()=>{e.player.setOutput(),n.next("STARTED")},A=>{n.next("FAILED")},()=>{i.addSuccessEvent({key:gH(this.type)}),i.addSuccessEvent({key:504702})}))}mock(A){this._decodeSink?this._decodeSink.error(A):this.startOB.next(0)}close(A){this.stopOB.next(A)}pipe(A){return dO()(e=>VS(this,null,function*(){this._decodeSink=e,e.defer(()=>{var A;null==(A=this.decoder)||A.close()});let{type:t}=this;try{"webCodecs"===t&&(this.decoder=new AudioDecoder({error:t=>{A.log.error(t),e.error(4)},output:t=>{this.decodedFrameCount++,e.next(t),A.player.write(t)}})),this.decoder.configure(this.config)}catch(i){A.log.error(i),e.error("webCodecs"===t?2:6)}}))}decodeFrame(A){var e;this.inputFrameCount++,"configured"===(null==(e=this.decoder)?void 0:e.state)&&this.decoder.decode(new EncodedAudioChunk({data:A.data,timestamp:A.timestamp,type:"key"}))}},lH={type:"object"},IH=class A{constructor(A){this.core=A,HS(this,"log"),HS(this,"contextMap",new Map),HS(this,"decodeProcessorMap",new WeakMap),this.log=A.log.createChild({id:"".concat(this.getAlias())})}getAlias(){return A.Name}getGroup(A){return A.track.userId+A.track.streamType}getName(){return A.Name}getValidateRule(A){return lH}start(A){let{track:e}=A;this.decodeProcessorMap.set(e,this.decode(A)),this.core.room.audioManager.addDecodeProcessor({processor:A=>{let{frame:e,track:t}=A;return this.decodeProcessorMap.has(t)?this.decodeProcessorMap.get(t)({frame:e,track:t}):e},type:3})}decode(A){return e=>{let{frame:t,track:i}=e;if(i!==A.track)return t;if(this.contextMap.has(i))return this.contextMap.get(i).decodeFrame(t);let o=new cH(this.core,i,A);return sO(o.trackDoneOB,ax(1),cP(()=>{this.core.clearStarted(this,this.getGroup(A)),this.stop({track:i})})),this.contextMap.set(i,o),o.decodeFrame(t)}}stop(A){let{track:e}=A,t=this.contextMap.get(e);t&&(t.close("stop"),this.contextMap.delete(e),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}update(A){let e=this.contextMap.get(A.track);if(e){if("mock"===A.type)return void e.mock(10);e.close("update"),this.contextMap.set(A.track,new cH(this.core,A.track,A))}}};HS(IH,"Name","TRTCAudioDecoder");var uH=IH,EH=class{constructor(){HS(this,"log"),this.log=sG.createLogger({id:"exp"})}call(A,e){return VS(this,null,function*(){return J_(this[A])?this[A](e):Promise.reject(new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.API_NOT_EXIST,data:{name:A}})}))})}enableAudioFrameEvent(A){return VS(this,null,function*(){let{trtcInstance:e,enable:t,userId:i,sampleRate:o=48e3,channelCount:n=1,port:r}=A,{audioManager:s}=e.room,{getPCMAbortCtrlMap:a,audioFrameEventConfigMap:g}=s;if(g.set(i,{enable:t,sampleRate:o,channelCount:n,port:r}),t)if("*"===i)e.room.remotePublishedUserMap.forEach(A=>{if(A.remoteAudioTrack.isAvailable){if(a.get(A.userId))return;let t=s.getPCM(A=>{e.emit($Y.AUDIO_FRAME,A)},A.userId);a.set(A.userId,t)}});else{if(a.get(i))return;let A=s.getPCM(A=>{e.emit($Y.AUDIO_FRAME,A)},i);a.set(i,A)}else if("*"===i)e.room.remotePublishedUserMap.forEach(A=>{if(A.remoteAudioTrack.isSubscribed){let{userId:e}=A,t=a.get(e);null==t||t.abort("disable"),a.delete(e)}});else{let A=a.get(i);null==A||A.abort("disable"),a.delete(i)}})}resumeRemotePlayer(A){return VS(this,null,function*(){if("*"===A.userId){let e=[];return A.trtcInstance.room.remotePublishedUserMap.forEach(t=>{let{remoteAudioTrack:i,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=t;A.streamType?"main"===A.streamType?(i.isAvailable&&e.push(i.player.resume()),o.isAvailable&&e.push(o.player.resume())):n.isAvailable&&e.push(n.player.resume()):(i.isAvailable&&e.push(i.player.resume()),o.isAvailable&&e.push(o.player.resume()),n.isAvailable&&e.push(n.player.resume()))}),Promise.all(e)}let e=A.trtcInstance.room.remotePublishedUserMap.get(A.userId);if(e)return"main"===A.streamType?Promise.all([e.remoteAudioTrack.player.resume(),e.remoteVideoTrack.player.resume()]):e.remoteAuxiliaryTrack.player.resume()})}pauseRemotePlayer(A){if("*"===A.userId)A.trtcInstance.room.remotePublishedUserMap.forEach(e=>{let{remoteAudioTrack:t,remoteVideoTrack:i,remoteAuxiliaryTrack:o}=e;A.streamType?"main"===A.streamType?(t.isAvailable&&t.player.pause(),i.isAvailable&&i.player.pause(!1)):o.isAvailable&&o.player.pause(!1):(t.isAvailable&&t.player.pause(),i.isAvailable&&i.player.pause(!1),o.isAvailable&&o.player.pause(!1))});else{let e=A.trtcInstance.room.remotePublishedUserMap.get(A.userId);e&&("main"===A.streamType?(e.remoteAudioTrack.player.pause(),e.remoteVideoTrack.player.pause(!1)):e.remoteAuxiliaryTrack.player.pause(!1))}}requestPictureInPicture(A){let e=[...A.trtcInstance.room.remotePublishedUserMap.values()].find(A=>A.remoteVideoTrack.isAvailable);return e?A.enable?e.remoteVideoTrack.player.enterPictureInPicture():e.remoteVideoTrack.player.exitPictureInPicture():Promise.reject(new rM({code:oM.INVALID_OPERATION,message:"no available remote video"}))}requestFullScreen(A){let e=[...A.trtcInstance.room.remotePublishedUserMap.values()].find(A=>A.remoteVideoTrack.isAvailable);return e?A.enable?e.remoteVideoTrack.player.enterFullscreen():e.remoteVideoTrack.player.exitFullscreen():Promise.reject(new rM({code:oM.INVALID_OPERATION,message:"no available remote video"}))}getCurrentPlayingStream(A){var e,t,i,o;let n=A;if(n._currentLiveUserId){let A=null!=(e=n._currentLiveStreamType)?e:"main",i=null==(t=n._remoteVideoConfigMap.get("".concat(n._currentLiveUserId,"_").concat(A)))?void 0:t.config;if(i)return{userId:n._currentLiveUserId,streamType:A,config:i}}for(let[r,s]of A.room.remotePublishedUserMap){if(s.remoteVideoTrack.isPlayCalled){let A=null==(i=n._remoteVideoConfigMap.get("".concat(r,"_main")))?void 0:i.config;if(A)return{userId:r,streamType:"main",config:A}}if(s.remoteAuxiliaryTrack.isPlayCalled){let A=null==(o=n._remoteVideoConfigMap.get("".concat(r,"_sub")))?void 0:o.config;if(A)return{userId:r,streamType:"sub",config:A}}}return null}switchPlaybackQuality(A){return VS(this,null,function*(){var e;let{trtcInstance:t,streamList:i,quality:o}=A,n=t;if(i&&i.length>0&&(n._playbackQualityList=i.map(A=>{var e;return FS(US({},A),{streamType:null!=(e=A.streamType)?e:"main"})})),"auto"===o||!o)return;if(!n._playbackQualityList||n._playbackQualityList.length<=0)return void this.log.warn("switchPlaybackQuality: streamList is empty, please call with streamList first");let r=n._playbackQualityList.find(A=>A.name===o);if(!r)return void this.log.warn('switchPlaybackQuality: quality "'.concat(o,'" not found in streamList'));let s=this.getCurrentPlayingStream(t);if(this.log.info("currentPlaying userId: ".concat(null==s?void 0:s.userId,", streamType: ").concat(null==s?void 0:s.streamType)),!s)return;let a=null!=(e=r.streamType)?e:"main";yield t.startRemoteVideo(FS(US({},s.config),{userId:r.userId,streamType:a,option:FS(US({},s.config.option),{isLiveStream:!0})})),yield t.stopRemoteVideo(US({},s.config)),n._currentLiveUserId=r.userId,n._currentLiveStreamType=a})}};JS([function(){for(var A=arguments.length,e=new Array(A),t=0;tfunction(){for(var i=arguments.length,o=new Array(i),n=0;n{var A,e;this.emit("permission-state-change",{camera:null==(A=this.states.camera)?void 0:A.state,microphone:null==(e=this.states.microphone)?void 0:e.state})}}request(A){return VS(this,null,function*(){if(this.log.info("request ".concat(A.join(", "))),0===A.length)return Promise.resolve();(yield navigator.mediaDevices.getUserMedia({video:A.includes("camera"),audio:A.includes("microphone")})).getTracks().forEach(A=>A.stop())})}get(A){return VS(this,null,function*(){try{return this.states[A]||(this.states[A]=yield navigator.permissions.query({name:A}),this.states[A].addEventListener("change",this.permissionChangeHandler)),this.log.info("get ".concat(A," permission state: ").concat(this.states[A].state)),this.states[A].state}catch(e){return this.log.error("get ".concat(A," permission failed, error: ").concat(e instanceof Error?e.message:e)),null}})}destroy(){Object.values(this.states).forEach(A=>{null==A||A.removeEventListener("change",this.permissionChangeHandler)}),this.states={}}},BH=0,QH=new Set,pH=null;BM(bJ),gG.checkStorage();var fH=class A extends tM.EventEmitter{constructor(e,t){super(),HS(this,"_room"),HS(this,"_eventListened",new Set),HS(this,"_localVideoTrack",null),HS(this,"_localAudioTrack",null),HS(this,"_localScreenTrack",null),HS(this,"_localScreenAudioTrack",null),HS(this,"_localVideoConfig",null),HS(this,"_localScreenConfig",null),HS(this,"_localAudioConfig",null),HS(this,"_remoteVideoConfigMap",new Map),HS(this,"_remoteAudioConfigMap",new Map),HS(this,"_remoteAudioVolumeMap",new Map),HS(this,"_remoteAudioMuteMap",new Map),HS(this,"_mediaTrackMap",new WeakMap),HS(this,"_log",sG.createLogger({id:"t".concat(++BH)})),HS(this,"_plugins",new Map),HS(this,"_networkQuality",null),HS(this,"_speakerId"),HS(this,"enterRoomParams"),HS(this,"_enableAutoSwitchWhenRecapturing",!0),HS(this,"_autoSubscribeDataChannel",!1),HS(this,"_playbackQualityList",[]),HS(this,"_currentLiveUserId"),HS(this,"_currentLiveStreamType","main"),this._room=new e(US({logger:this._log,frameWorkType:A.frameWorkType},t)),this._room.videoDecodeFallbackType=t.videoDecodeFallback,j_(t.enableAutoSwitchWhenRecapturing)&&(this._enableAutoSwitchWhenRecapturing=t.enableAutoSwitchWhenRecapturing),this._log.info("create() ".concat(JSON.stringify(t,(A,e)=>"plugins"===A?e.map(A=>A.Name):e))),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(A){return this._room.audioManager.dump(A)}}}),t.plugins&&t.plugins.forEach(A=>{this._use(A,t.assetsPath)}),this._use(zJ,t.assetsPath),this._use(HJ,t.assetsPath),this._use($J,t.assetsPath),this._use(uH,t.assetsPath),this._use(aH),t.enableSEI&&DL&&this._use(nH),this._room.on("audio-volume",A=>{var e,i;!A.find(A=>""===A.userId)&&this._localAudioTrack&&A.push({userId:"",volume:Math.floor(100*(null!=(e=this._localAudioTrack.getInternalAudioLevelAfter3A())?e:this._localAudioTrack.getAudioLevel())),floatVolume:null!=(i=this._localAudioTrack.getInternalAudioLevelAfter3A())?i:this._localAudioTrack.getInternalAudioLevel()}),1===t.volumeType&&A.forEach(A=>{var e;let t=""===A.userId?this._localAudioTrack:null==(e=this.room.remotePublishedUserMap.get(A.userId))?void 0:e.remoteAudioTrack;t&&(A.volume=t.dbVolume)}),t.enableDbVolume&&A.forEach(A=>{var e;let t=""===A.userId?this._localAudioTrack:null==(e=this.room.remotePublishedUserMap.get(A.userId))?void 0:e.remoteAudioTrack;t&&(A.volume=t.dbVolume)}),this.emit($Y.AUDIO_VOLUME,{result:A.sort((A,e)=>e.volume-A.volume)})}),this._room.videoManager.on("error",A=>{this._log.error(new wY({code:mY.OPERATION_FAILED,extraCode:5504,message:A.message,originError:A}))}),this._listenEvents(),this._initActiveSpeaker(),((A,e)=>{let{emit:t}=A;A.emit=function(){for(var i=arguments.length,o=new Array(i),n=0;n{A&&sG.info(Ob)})}}();let i=new A(e,t||{});return QH.add(i),i.__v_skip=!0,i}get room(){return this._room}_listenEvents(){sU(this,this._room).add("peer-join",A=>{let{userId:e}=A;this.emit($Y.REMOTE_USER_ENTER,{userId:e})}).add("peer-leave",A=>{let{userId:e,reason:t}=A;this.emit($Y.REMOTE_USER_EXIT,{userId:e,reason:t})}).add("banned",A=>{sJ(!0),this._exitRoom().finally(()=>{this.emit($Y.KICKED_OUT,{reason:A.reason})})}).add("error",A=>{this._exitRoom().finally(()=>{this.emit($Y.ERROR,wY.convertFrom(A))})}).add("signal-connection-state-changed",A=>{this.emit($Y.CONNECTION_STATE_CHANGED,A)}).add("network-quality",A=>{this._networkQuality=A;let e=FS(US({},A),{uplinkRTT:Math.min(A.uplinkRTT,XR),downlinkRTT:Math.min(A.downlinkRTT,XR)});this.emit($Y.NETWORK_QUALITY,e)}).add("remote-published",A=>{[A.remoteAudioTrack,A.remoteVideoTrack,A.remoteAuxiliaryTrack].forEach(e=>{sU(e,e).add("player-state-changed",t=>{let i=FS(US({},t),{userId:A.userId});e.kind===WM.VIDEO&&(i.streamType=SY(e.streamType)),this.emit(e.kind===WM.AUDIO?$Y.AUDIO_PLAY_STATE_CHANGED:$Y.VIDEO_PLAY_STATE_CHANGED,i)}).add("error",A=>{A.getCode()===oM.PLAY_NOT_ALLOWED&&this.emit($Y.AUTOPLAY_FAILED,{userId:e.userId,mediaType:e.strMediaType,resume:()=>e.player.resume()})})})}).add("remote-unpublished",A=>{[A.remoteAudioTrack,A.remoteVideoTrack,A.remoteAuxiliaryTrack].forEach(A=>{aU(A)})}).add("remote-publish-state-changed",A=>{let{prevMuteState:e,muteState:t}=A,{userId:i}=t,o=e.audioAvailable,n=e.videoAvailable,{audioAvailable:r,videoAvailable:s}=t;r||this._remoteAudioConfigMap.delete(i),s||this._removeRemoteVideoConfig(i,"main"),t.hasAuxiliary||this._removeRemoteVideoConfig(i,"sub"),n!==s&&(s?this._onVideoAvailable({userId:i,streamType:"main"}):this._onVideoUnavailable({userId:i,streamType:"main"}),this.emit(s?$Y.REMOTE_VIDEO_AVAILABLE:$Y.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==r&&(r?this._onAudioAvailable({userId:i}):this._onAudioUnavailable({userId:i,muteState:t}),this.emit(r?$Y.REMOTE_AUDIO_AVAILABLE:$Y.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),e.hasAuxiliary!==t.hasAuxiliary&&(t.hasAuxiliary?this._onVideoAvailable({userId:i,streamType:"sub"}):this._onVideoUnavailable({userId:i,streamType:"sub"}),this.emit(t.hasAuxiliary?$Y.REMOTE_VIDEO_AVAILABLE:$Y.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"})),e.hasDatachannel!==t.hasDatachannel&&t.hasDatachannel&&this._onDataChannelAvailable()}).add("sei-message",A=>{this.emit($Y.SEI_MESSAGE,FS(US({},A),{streamType:SY(A.streamType)}))}).add("firewall-restriction",()=>{this.emit($Y.ERROR,new wY({code:mY.OPERATION_FAILED,extraCode:5501}))}).add("heartbeat-report",A=>{var e,t,i,o,n,r,s;let a={2:"big",3:"small",7:"sub"},g={rtt:Math.min(A.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(e=A.msg_down_stream_info[0])?void 0:e.msg_network_status.uint32_rtt)||(null==(t=this._networkQuality)?void 0:t.uplinkRTT)||(null==(i=this._networkQuality)?void 0:i.downlinkRTT)||0,XR),upLoss:(null==(o=this._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(n=this._networkQuality)?void 0:n.downlinkLoss)||0,bytesSent:A.bytes_sent||0,bytesReceived:A.bytes_received||0,localStatistics:{audio:{bitrate:((null==(r=A.msg_up_stream_info.msg_audio_status)?void 0:r.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(s=A.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_level)||0)/ik},video:A.msg_up_stream_info.msg_video_status.filter(A=>a[A.uint32_video_stream_type]).map(A=>({bitrate:(A.uint32_video_codec_bitrate||0)/1e3,width:A.uint32_video_width,height:A.uint32_video_height,frameRate:A.uint32_video_enc_fps,videoType:a[A.uint32_video_stream_type]}))},remoteStatistics:A.msg_down_stream_info.map(A=>({userId:A.msg_user_info.str_identifier,audio:{bitrate:(A.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(A.msg_audio_status.uint32_audio_level||0)/ik,point2pointDelay:(A.msg_audio_status.uint32_audio_p2p_delay||0)+(A.msg_audio_status.uint32_audio_cache_ms||0),jitterBufferDelay:A.msg_audio_status.uint32_audio_cache_ms||0},video:A.msg_video_status.map(A=>({bitrate:(A.uint32_video_codec_bitrate||0)/1e3,width:A.uint32_video_width,height:A.uint32_video_height,frameRate:A.uint32_video_dec_fps,videoType:a[A.uint32_video_stream_type],point2pointDelay:(A.uint32_video_p2p_delay||0)+(A.uint32_video_cache_ms||0),jitterBufferDelay:A.uint32_video_cache_ms||0,codec:A.uint32_video_codec}))}))};this.emit($Y.STATISTICS,g)}).add("custom-message",A=>{this.emit($Y.CUSTOM_MESSAGE,A)}).add("layerData",A=>this.emit($Y.LAYER_DATA,A)).add("first-video-frame",A=>{this.emit($Y.FIRST_VIDEO_FRAME,FS(US({},A),{streamType:SY(A.streamType)}))}).add("audio-frame",A=>{this.emit($Y.AUDIO_FRAME,A)}).add("data-channel-message",A=>{var e,t,i,o,n;let{data:r}=A;if(""===r.sender)return;let s={segmentId:null==(e=r.payload)?void 0:e.roundid,speakerUserId:r.sender,sourceText:null==(t=r.payload)?void 0:t.text,translationTexts:null==(i=r.payload)?void 0:i.translate_msg,timestamp:null==(o=r.payload)?void 0:o.start_utc_ms,isCompleted:null==(n=r.payload)?void 0:n.end,robotId:r.robotid};""!==s.sourceText&&this.emit($Y.REALTIME_TRANSCRIBER_MESSAGE,s)}).add("asr-robot-peer-join",A=>{this.emit($Y.REALTIME_TRANSCRIBER_STATE_CHANGED,{state:"started",roomId:this.room.roomId,transcriberRobotId:A.userId})}).add("asr-robot-peer-leave",A=>{this.emit($Y.REALTIME_TRANSCRIBER_STATE_CHANGED,{state:"stopped",roomId:this.room.roomId,transcriberRobotId:A.userId})}),sU(this,hF).add("audioInputAdded",A=>{this.emit($Y.DEVICE_CHANGED,{type:"microphone",action:"add",device:A})}).add("audioInputRemoved",A=>{this.emit($Y.DEVICE_CHANGED,{type:"microphone",action:"remove",device:A})}).add("videoInputAdded",A=>{this.emit($Y.DEVICE_CHANGED,{type:"camera",action:"add",device:A})}).add("videoInputRemoved",A=>{this.emit($Y.DEVICE_CHANGED,{type:"camera",action:"remove",device:A})}).add("audioOutputAdded",A=>VS(this,null,function*(){if(this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"add",device:A}),pH&&pH.deviceId===qR){let A=(yield mF()).find(A=>A.deviceId===qR);A&&pH.groupId!==A.groupId&&(pH=A,this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:A}))}})).add("audioOutputRemoved",A=>VS(this,null,function*(){this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"remove",device:A});let e=(yield mF())[0];if(!e||!pH||pH.groupId===e.groupId)return;let t=pH.deviceId===A.deviceId,i=pH.deviceId===qR&&pH.deviceId===e.deviceId;(t||i)&&(pH=e,this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))})),sU(this,CH).add("permission-state-change",A=>{this.emit($Y.PERMISSION_STATE_CHANGE,A)}),this.room.enableSEI&&this.on($Y.SEI_MESSAGE,A=>{var e;let t=null==(e=this.room.remotePublishedUserMap.get(A.userId))?void 0:e.remoteVideoTrack;t&&t.updateAlphaRenderInfo(A)})}getNetworkTime(){return lM()}use(A){let e,t;return"plugin"in A?(e=A.plugin,t=A.assetsPath):e=A,"Chorus"===e.Name&&(this.room.enableChorus=!0),this._use(e,t)}_use(e,t){let i=this._plugins.get(e.Name);if(i)return this._log.warn("duplicate install plugin",e.Name),i;let o=new e(TJ.call(this,{TRTC:A,room:this._room,assetsPath:t,errorModule:{RtcError:wY,ErrorCode:mY,CoreErrorCode:oM,ErrorCodeDictionary:yY}}));return this._plugins.set(e.Name,o),o.__v_skip=!0,e.autoStart&&this.startPlugin(e.Name),o}enterRoom(e){return VS(this,null,function*(){var t,i;this.enterRoomParams=e;let{scene:o="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:r=!0,autoReceiveVideo:s=!1}=e;e.proxy&&(this._room.setProxyServer(e.proxy),!q_(e.proxy)&&e.proxy.turnServer&&(null==(i=(t=this._room).setTurnServer)||i.call(t,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=r,this._room.autoReceiveVideo=s,j_(e.preferHW)&&(this._room.preferHW=e.preferHW),e.playoutDelay&&(this._room.playoutDelay=e.playoutDelay),e.jitterBufferDelay&&(this._room.jitterBufferDelay=e.jitterBufferDelay);let a={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,latencyLevel:e.latencyLevel,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,enableDataChannel:this._plugins.has("RealtimeTranscriber"),frameWorkType:e.frameWorkType,component:e.component,language:e.language,priority:e.priority,useVp8:e.useVp8,useH265:e.useH265||!1,keepAlive:e.keepAlive};e.strRoomId&&!e.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,yield this._room.join(a,o,A.frameWorkType),this._checkTrackToPublish(),eH.start()})}exitRoom(){return VS(this,null,function*(){return yield this._exitRoom()})}switchRoom(A){return VS(this,null,function*(){if(this.room.isSwitchRoomSupported())try{this._clearRemoteTracks(),yield this._room.switchRoom(A)}catch(e){if(!(e instanceof nM)||e.code!==oM.API_CALL_TIMEOUT&&e.code!==oM.SWITCH_ROOM_FAILED)throw e;this._log.warn("switchRoom ".concat(e.code===oM.API_CALL_TIMEOUT?"timeout":"failed",", fallback to exitRoom() and enterRoom()")),yield this._rejoinRoom(A)}else yield this._rejoinRoom(A)})}_rejoinRoom(A){return VS(this,null,function*(){yield this.exitRoom();let e=US(US({},this.enterRoomParams),A);yield this.enterRoom(e)})}_clearRemoteTracks(){new Set([...this._remoteAudioConfigMap.keys(),...this._remoteAudioMuteMap.keys()]).forEach(A=>{this._stopRemoteAudio({userId:A}).catch(()=>{})}),[...this._remoteVideoConfigMap.keys()].forEach(A=>{let e=A.includes("main")?"main":"sub",t=A.split("_".concat(e))[0];t&&this._stopRemoteVideo({userId:t,streamType:e}).catch(()=>{})}),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),function(A){let e=NJ.get(A);e&&(e.forEach(A=>clearTimeout(A)),NJ.delete(A))}(this),this._room.remotePublishedUserMap.forEach(A=>{aU(A.remoteAudioTrack),aU(A.remoteVideoTrack),aU(A.remoteAuxiliaryTrack)})}switchRole(A,e){return VS(this,null,function*(){null!=e&&e.privateMapKey&&(this._room.privateMapKey=e.privateMapKey),null!=e&&e.latencyLevel&&(this._room.latencyLevel=e.latencyLevel),yield this._room.switchRole(A),"anchor"===A&&this._checkTrackToPublish()})}destroy(){this._plugins.forEach(A=>{var e;return null==(e=A.destroy)?void 0:e.call(A)}),this._plugins.clear(),aU(this),this.removeAllListeners(),this._room.destroy(),QH.delete(this),0===QH.size&&eH.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),tG.off("102",this._onLocalTrackCaptured,this)}startLocalAudio(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(A._localAudioTrack)return void A._log.warn("local audio is already started");let{publish:t=!0,mute:i,muteKeepVolumeDetection:o,option:n}=e,r=new BP(A._room.audioManager),s={},a={muted:!0};n&&(H_(n.microphoneId)?H_(n.audioTrack)||(s.customSource=n.audioTrack):s.deviceId=n.microphoneId,n&&V_(n.captureVolume)&&r.setCaptureVolume(n.captureVolume),H_(n.profile)||(q_(n.profile)?HM[n.profile]&&r.setProfile(HM[n.profile]):r.setProfile(n.profile)),V_(n.earMonitorVolume)&&(a.muted=!(n.earMonitorVolume>0),a.volume=n.earMonitorVolume),H_(n.echoCancellation)||(r.profile.echoCancellation=n.echoCancellation),H_(n.noiseSuppression)||(r.profile.noiseSuppression=n.noiseSuppression),H_(n.autoGainControl)||(r.profile.autoGainControl=n.autoGainControl),j_(A._enableAutoSwitchWhenRecapturing)&&(r.enableAutoSwitchWhenRecapturing=A._enableAutoSwitchWhenRecapturing)),r.on("5",e=>{A.emit($Y.ERROR,new wY({code:mY.DEVICE_ERROR,extraCode:5309,messageParams:{error:e}}))}),r.on("2",e=>{A.emit($Y.DEVICE_CHANGED,{type:"microphone",action:"active",device:e})}),r.on("4",e=>{let t;e.error&&(t=wY.convertFrom(e.error)),A.emit($Y.PUBLISH_STATE_CHANGED,FS(US({},e),{error:t}))}),r.on("6",()=>{}),A._listenOutputTrackChanged(r),A._speakerId&&r.setAudioOutput(A._speakerId),yield r.capture(s),H_(i)||r.setMute(i,o),sU(r,r).add("player-state-changed",e=>{A.emit($Y.AUDIO_PLAY_STATE_CHANGED,FS(US({},e),{userId:""}))}),t&&A._room.isJoined&&A._room.publish(r).catch(()=>{}),A._localAudioTrack=r,A._room.capturedLocalMainAudioTrack=r,A._localAudioConfig=FS(US({},e),{publish:t}),yield A._updateAudioPlayOption({playOption:a,track:r}),tG.emit("113",{userId:"",room:A.room})}()})}updateLocalAudio(A){return VS(this,null,function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:e,mute:t,muteKeepVolumeDetection:i,option:o}=A,n={};o&&(o.microphoneId?yield this._localAudioTrack.switchDevice(o.microphoneId):H_(o.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(o.audioTrack)),H_(o.captureVolume)||this._localAudioTrack.setCaptureVolume(o.captureVolume),H_(o.earMonitorVolume)||(n.muted=!(o.earMonitorVolume>0),n.volume=o.earMonitorVolume),yield this._localAudioTrack.update3A(o)),this._room.isJoined&&!H_(e)&&(e&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch(()=>{}),this._localAudioConfig.publish&&!e&&this._room.unpublish(this._localAudioTrack).catch(()=>{})),H_(t)||this._localAudioTrack.setMute(t,i),yield this._updateAudioPlayOption({playOption:n,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),IT(this._localAudioConfig,A)})}stopLocalAudio(){return VS(this,null,function*(){this._localAudioTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch(()=>{})),tG.emit("114",{userId:"",room:this.room}),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),aU(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null,delete this._room.capturedLocalMainAudioTrack)})}startLocalVideo(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null,capture:!0};return function*(){var t,i;if(A._localVideoTrack)return void A._log.warn("local video is already started");let{view:o,publish:n=!0,capture:r=!0,mute:s,option:a}=e,g=n,c=new DP(A._room.videoManager),l={},I={};a&&(j_(a.avoidCropping)&&(c.avoidCropping=a.avoidCropping),a.cameraId?l.deviceId=a.cameraId:H_(a.useFrontCamera)?H_(a.videoTrack)||(l.customSource=a.videoTrack):l.facingMode=a.useFrontCamera?WM.FACING_MODE_USER:WM.FACING_MODE_ENVIRONMENT,H_(a.retryWhenExactFailed)||(l.retryWhenExactFailed=a.retryWhenExactFailed),a.qosPreference&&(l.contentHint=MY(a.qosPreference)),H_(a.profile)||(q_(a.profile)?qM[a.profile]&&c.setProfile(qM[a.profile]):c.setProfile(a.profile)),H_(a.fillMode)||(I.objectFit=a.fillMode),H_(a.mirror)||(I.mirror=a.mirror),H_(a.small)||(H_(a.smallMode)||(A._room.smallMode=a.smallMode),j_(a.small)&&!1===a.small?c.stopSmall():c.updateSmallConfig(RY(a.small,!0))),H_(a.rotation)||c.setRotation(a.rotation),j_(A._enableAutoSwitchWhenRecapturing)&&(c.enableAutoSwitchWhenRecapturing=A._enableAutoSwitchWhenRecapturing)),c.once("first-video-frame",e=>{A.emit($Y.FIRST_VIDEO_FRAME,FS(US({},e),{streamType:SY(e.streamType)}))}),c.on("5",e=>{A.emit($Y.ERROR,new wY({code:mY.DEVICE_ERROR,extraCode:5308,messageParams:{error:e}}))}),c.on("2",e=>{A.emit($Y.DEVICE_CHANGED,{type:"camera",action:"active",device:e})}),c.on("4",e=>{let t;e.error&&(t=wY.convertFrom(e.error)),A.emit($Y.PUBLISH_STATE_CHANGED,FS(US({},e),{error:t}))}),c.on("6",()=>{}),A._listenOutputTrackChanged(c),r?yield c.capture(l):null==(t=c.manager)||t.changeInput(c),H_(s)||(yield c.setMute(s)),sU(c,c).add("player-state-changed",e=>{A.emit($Y.VIDEO_PLAY_STATE_CHANGED,FS(US({},e),{userId:"",streamType:"main"}))}).add("video-size-changed",e=>{A.emit($Y.VIDEO_SIZE_CHANGED,FS(US({},e),{streamType:SY(e.streamType)}))}),g&&A._room.isJoined&&(A._localScreenTrack&&(null==(i=A._localScreenConfig)?void 0:i.publish)&&"main"===A._localScreenConfig.streamType?(g=!1,A._log.warn("main stream is already published, local video track will not publish")):A._room.publish(c).catch(()=>{})),A._localVideoTrack=c,A._room.capturedLocalMainVideoTrack=c,A._localVideoConfig=FS(US({},e),{view:o,publish:g,capture:r}),yield A._updateVideoPlayOption({view:o,playOption:I,track:c})}()})}updateLocalVideo(A){return VS(this,null,function*(){var e,t,i,o;if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:n,publish:r=!0,mute:s,capture:a,option:g,forcePublish:c=!1}=A,l=r||c,I={};if(this._localVideoConfig.capture)!1!==a?null!=g&&g.cameraId?yield this._localVideoTrack.switchDevice(null==g?void 0:g.cameraId):H_(null==g?void 0:g.useFrontCamera)?H_(null==g?void 0:g.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(null==g?void 0:g.videoTrack)):yield this._localVideoTrack.switchDevice(null!=g&&g.useFrontCamera?WM.FACING_MODE_USER:WM.FACING_MODE_ENVIRONMENT):this._localVideoTrack.stopCapture();else if(a){let A={};A.deviceId=(null==g?void 0:g.cameraId)||(null==(e=this._localVideoConfig.option)?void 0:e.cameraId),A.facingMode=null!=g&&g.useFrontCamera||null!=(t=this._localVideoConfig.option)&&t.useFrontCamera?WM.FACING_MODE_USER:WM.FACING_MODE_ENVIRONMENT,A.customSource=(null==g?void 0:g.videoTrack)||(null==(i=this._localVideoConfig.option)?void 0:i.videoTrack),yield this._localVideoTrack.capture(A)}g&&(H_(g.profile)||(q_(g.profile)?qM[g.profile]&&this._localVideoTrack.setProfile(qM[g.profile]):this._localVideoTrack.setProfile(g.profile),(!g.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(g.cameraId||g.useFrontCamera?WM.FACING_MODE_USER:WM.FACING_MODE_ENVIRONMENT))&&(yield this._localVideoTrack.applyProfile())),H_(g.fillMode)||(I.objectFit=g.fillMode),H_(g.mirror)||(I.mirror=g.mirror),H_(g.rotation)||this._localVideoTrack.setRotation(g.rotation),g.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(MY(g.qosPreference)),H_(g.small)||(j_(g.small)&&!g.small?this._localVideoTrack.stopSmall():this._localVideoTrack.updateSmallConfig(RY(g.small,!0)))),this._room.isJoined&&H_(l)&&this._localVideoConfig.publish&&a&&!this._localVideoConfig.capture&&this._room.publish(this._localVideoTrack).catch(()=>{}),this._room.isJoined&&((null!=l?l:this._localVideoConfig.publish)||c?this._localScreenTrack&&(null==(o=this._localScreenConfig)?void 0:o.publish)&&"main"===this._localScreenConfig.streamType&&!c?(l=!1,this._log.warn("main stream is already published, local video track will not publish")):this._room.publish(this._localVideoTrack).catch(()=>{}):this._room.unpublish(this._localVideoTrack).catch(()=>{})),H_(s)||(yield this._localVideoTrack.setMute(s)),yield this._updateVideoPlayOption({view:n,playOption:I,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),IT(this._localVideoConfig,FS(US({},A),{publish:l}))})}stopLocalVideo(){return VS(this,null,function*(){var A;this._localVideoTrack&&(this._room.isJoined&&null!=(A=this._localVideoConfig)&&A.publish&&(yield this._room.unpublish(this._localVideoTrack).catch(()=>{})),this._localVideoTrack.stop(),this._localVideoTrack.close(),aU(this._localVideoTrack),this._localVideoTrack=null,delete this._room.capturedLocalMainVideoTrack,this._localVideoConfig=null)})}startScreenShare(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){var t,i,o;if(A._localScreenTrack)return void A._log.warn("screen share is already started");let{view:n=null,publish:r=!0,muteSystemAudio:s,option:a}=e,g=r,c=new XP(A._room.videoManager);c.on("4",e=>{let t;e.error&&(t=wY.convertFrom(e.error)),A.emit($Y.PUBLISH_STATE_CHANGED,FS(US({},e),{error:t}))}),c.once("first-video-frame",e=>{A.emit($Y.FIRST_VIDEO_FRAME,FS(US({},e),{streamType:SY(e.streamType)}))}),A._listenOutputTrackChanged(c),"main"===e.streamType&&(c.mediaType=4);let l=null,I={},u={};a&&(H_(a.profile)||(q_(a.profile)?KM[a.profile]&&c.setProfile(KM[a.profile]):c.setProfile(a.profile)),a.systemAudio&&(I.systemAudio=!0,I.echoCancellation=a.echoCancellation,I.noiseSuppression=a.noiseSuppression,I.autoGainControl=a.autoGainControl),H_(a.fillMode)||(u.objectFit=a.fillMode),a.videoTrack&&(I.videoTrack=a.videoTrack),a.audioTrack&&(I.audioTrack=a.audioTrack),a.captureElement&&(I.captureElement=a.captureElement),a.preferDisplaySurface&&(I.preferDisplaySurface=a.preferDisplaySurface),a.qosPreference&&(I.contentHint=MY(a.qosPreference)));let E=yield c.capture(I);if(c.mediaTrack.addEventListener(WM.ENDED,()=>{A._stopScreenShare(),A.emit($Y.SCREEN_SHARE_STOPPED)}),E.getAudioTracks()[0]){l=new AY(A._room.audioManager);let o=E.getAudioTracks()[0];null!=(t=e.option)&&t.systemAudio&&!(null!=(i=e.option)&&i.audioTrack)&&(l.sourceTrack=o),yield l.setInputMediaStreamTrack(o),j_(s)&&l.mediaTrack&&(l.mediaTrack.enabled=!s),A._speakerId&&l.setAudioOutput(A._speakerId)}if(sU(c,c).add("player-state-changed",e=>{A.emit($Y.VIDEO_PLAY_STATE_CHANGED,FS(US({},e),{userId:"",streamType:"sub"}))}),g&&A._room.isJoined){let t=A._localVideoTrack&&(null==(o=A._localVideoConfig)?void 0:o.publish);"main"===e.streamType&&t?(g=!1,A._log.warn("main stream is already published, screen share main will not publish")):A._room.publish(c).catch(()=>{}),l&&(A._checkScreenAudioEchoCancellation(c,l),A._room.publish(l).catch(()=>{}))}A._localScreenTrack=c,A._room.capturedLocalAuxVideoTrack=c,A._localScreenAudioTrack=l,A._localScreenConfig=FS(US({},e),{view:n,publish:g}),yield A._updateVideoPlayOption({view:n,playOption:u,track:c})}()})}updateScreenShare(A){return VS(this,null,function*(){var e,t;if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:i,publish:o,muteSystemAudio:n,option:r}=A,s=o,a={};if(r){if(H_(r.fillMode)||(a.objectFit=r.fillMode),r.qosPreference){let A=MY(r.qosPreference);this._localScreenTrack.setContentHint(A)}r.videoTrack&&this._localScreenTrack.setInputMediaStreamTrack(r.videoTrack),r.audioTrack&&this._localScreenAudioTrack&&this._localScreenAudioTrack.setInputMediaStreamTrack(r.audioTrack)}if(this._room.isJoined&&!H_(s)){if(s&&!this._localScreenConfig.publish){let A=this._localVideoTrack&&(null==(e=this._localVideoConfig)?void 0:e.publish);"main"===this._localScreenConfig.streamType&&A?(s=!1,this._log.warn("main stream is already published, screen share main will not publish")):this._room.publish(this._localScreenTrack).catch(()=>{}),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch(()=>{})}if(this._localScreenConfig.publish&&!s){let A=[this._localScreenTrack];this._localScreenAudioTrack&&A.push(this._localScreenAudioTrack),A.forEach(A=>this._room.unpublish(A).catch(()=>{}))}}null!=(t=this._localScreenAudioTrack)&&t.mediaTrack&&j_(n)&&(this._localScreenAudioTrack.mediaTrack.enabled=!n),yield this._updateVideoPlayOption({view:i,playOption:a,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),IT(this._localScreenConfig,FS(US({},A),{publish:s}))})}stopScreenShare(){return VS(this,null,function*(){return yield this._stopScreenShare()})}startRemoteVideo(A){return VS(this,null,function*(){let{view:e,userId:t,streamType:i,option:o}=A,n="".concat(t,"_").concat(i);if(this._remoteVideoConfigMap.has(n))return void this._log.warn("remote video has already started. userId:".concat(t,", streamType:").concat(i));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let s={},a="main"===i?r.remoteVideoTrack:r.remoteAuxiliaryTrack,g=this._bindRemoteVideoTrackEvents(a);this._listenOutputTrackChanged(a),o&&(H_(o.fillMode)||(s.objectFit=o.fillMode),H_(o.mirror)||(s.mirror=o.mirror),H_(o.poster)||(s.poster=o.poster),s.canvasRender=o.canvasRender,"main"===i&&!H_(o.small)&&(!r.remoteVideoTrack.isSubscribing&&!r.remoteVideoTrack.isSubscribed&&r.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,a.user)),H_(o.draggable)||a.setDraggable(o.draggable)),s.isLiveStream=!!this._playbackQualityList.find(A=>A.userId===t&&A.streamType===i),yield this._room.subscribe(a),yield this._enableVideoDecodeFallback(a,i),yield this._updateVideoPlayOption({view:e,playOption:s,track:a}),this._emitTrackEvent(a),this._remoteVideoConfigMap.set(n,{config:A,handlers:g}),o&&!H_(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:a,view:e,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot}),s.isLiveStream&&(this._currentLiveUserId=t,this._currentLiveStreamType=i)})}updateRemoteVideo(A){return VS(this,null,function*(){var e,t;let{view:i,userId:o,streamType:n,option:r,mute:s}=A,a="".concat(o,"_").concat(n),g=this._remoteVideoConfigMap.get(a);if(!g||!this._room.remotePublishedUserMap.has(o))return;let c={};r&&(H_(r.fillMode)||(c.objectFit=r.fillMode),H_(r.mirror)||(c.mirror=r.mirror));let l=null,I=this._room.remotePublishedUserMap.get(o);if("main"===n&&null!=I&&I.muteState.hasVideo&&(l=I.remoteVideoTrack),"sub"===n&&null!=I&&I.muteState.hasAuxiliary&&(l=I.remoteAuxiliaryTrack),!l)return;let{config:u}=g;"main"===n&&r&&!H_(r.small)&&this._room.changeType(r.small,l.user),r&&!H_(r.draggable)&&l.setDraggable(r.draggable),r&&(j_(r.pictureInPicture)&&(r.pictureInPicture?yield l.player.enterPictureInPicture():yield l.player.exitPictureInPicture()),j_(r.fullScreen)&&(r.fullScreen?yield l.player.enterFullscreen():yield l.player.exitFullscreen())),j_(s)&&(l.ignoreUpdatePlayingState=!0,s?(yield l.player.pause(),yield this.room.unsubscribe(l)):(yield this.room.subscribe(l),yield l.player.resume(!0))),yield this._updateVideoPlayOption({view:i,playOption:c,track:l,prevConfig:u}),IT(u,A);let E=H_(null==r?void 0:r.receiveWhenViewVisible)?null==(e=u.option)?void 0:e.receiveWhenViewVisible:r.receiveWhenViewVisible,d=H_(i)?u.view:i,h=H_(null==r?void 0:r.viewRoot)?null==(t=u.option)?void 0:t.viewRoot:r.viewRoot;this._observeView({remoteTrack:l,view:d,receiveWhenViewVisible:E,viewRoot:h})})}stopRemoteVideo(A){return VS(this,null,function*(){return this._stopRemoteVideo(A)})}_stopRemoteVideo(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return VS(this,null,function*(){let t=[],i=this._room.remotePublishedUserMap.get(A.userId);if(i){let{muteState:e,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=i;"main"===A.streamType&&(o.stop(),e.hasVideo&&t.push(o)),"sub"===A.streamType&&(n.stop(),e.hasAuxiliary&&t.push(n))}for(let A of t)e&&(delete A.ignoreUpdatePlayingState,yield this._room.unsubscribe(A),this._mediaTrackMap.delete(A.outMediaTrack));this._removeRemoteVideoConfig(A.userId,A.streamType)})}_removeRemoteVideoConfig(A,e){let t="".concat(A,"_").concat(e),i=this._remoteVideoConfigMap.get(t);if(i&&(i.observer&&i.observer.disconnect(),i.handlers)){let t=this._room.remotePublishedUserMap.get(A);if(t){let A="main"===e?t.remoteVideoTrack:t.remoteAuxiliaryTrack;this._unbindRemoteVideoTrackEvents(A,i.handlers)}}this._remoteVideoConfigMap.delete(t)}_bindRemoteVideoTrackEvents(A){let e={onEnterPIP:()=>VS(this,null,function*(){yield A.player.enterPIPPromise,this.emit($Y.PICTURE_IN_PICTURE_STATE_CHANGED,{streamType:SY(A.streamType),userId:A.userId,isPictureInPicture:!0,pictureInPictureWindow:A.player.pipWindow})}),onLeavePIP:()=>{this.emit($Y.PICTURE_IN_PICTURE_STATE_CHANGED,{streamType:SY(A.streamType),userId:A.userId,isPictureInPicture:!1})},onEnterFullScreen:()=>{this.emit($Y.FULL_SCREEN_STATE_CHANGED,{streamType:SY(A.streamType),userId:A.userId,isFullScreen:!0})},onLeaveFullScreen:()=>{this.emit($Y.FULL_SCREEN_STATE_CHANGED,{streamType:SY(A.streamType),userId:A.userId,isFullScreen:!1})},onDecodeFailed:()=>{this.emit($Y.ERROR,new wY({code:mY.OPERATION_FAILED,extraCode:5507,message:"video decode failed"}))},onVideoSizeChanged:A=>{this.emit($Y.VIDEO_SIZE_CHANGED,FS(US({},A),{streamType:SY(A.streamType)}))}};return A.player.on(oU.ENTER_PICTURE_IN_PICTURE,e.onEnterPIP),A.player.on(oU.LEAVE_PICTURE_IN_PICTURE,e.onLeavePIP),A.player.on(oU.ENTER_FULL_SCREEN,e.onEnterFullScreen),A.player.on(oU.LEAVE_FULL_SCREEN,e.onLeaveFullScreen),A.on("decode-failed",e.onDecodeFailed),A.on("video-size-changed",e.onVideoSizeChanged),e}_unbindRemoteVideoTrackEvents(A,e){A.player.off(oU.ENTER_PICTURE_IN_PICTURE,e.onEnterPIP),A.player.off(oU.LEAVE_PICTURE_IN_PICTURE,e.onLeavePIP),A.player.off(oU.ENTER_FULL_SCREEN,e.onEnterFullScreen),A.player.off(oU.LEAVE_FULL_SCREEN,e.onLeaveFullScreen),A.off("decode-failed",e.onDecodeFailed),A.off("video-size-changed",e.onVideoSizeChanged)}muteRemoteAudio(A,e){return VS(this,null,function*(){this._remoteAudioMuteMap.set(A,e);try{if("*"===A)if(e)yield this._stopRemoteAudio({userId:A});else{let A=[...this._room.remotePublishedUserMap.values()];for(let e of A)e.muteState.hasAudio&&!this._remoteAudioConfigMap.has(e.userId)&&this.room.isJoined&&(yield this._startRemoteAudio({userId:e.userId}))}else e?yield this._stopRemoteAudio({userId:A}):!this._remoteAudioConfigMap.has(A)&&this.room.isJoined&&(yield this._startRemoteAudio({userId:A}))}catch(t){throw t.code!==mY.OPERATION_ABORT&&this._remoteAudioMuteMap.delete(A),t}})}setRemoteAudioVolume(A,e){if("*"===A){this._remoteAudioVolumeMap.set("*",e),this._remoteAudioVolumeMap.forEach((A,t)=>this._remoteAudioVolumeMap.set(t,e));let A=[...this._room.remotePublishedUserMap.values()];for(let t of A)this._remoteAudioVolumeMap.set(t.userId,e),t.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:e},track:t.remoteAudioTrack})}else if(A){let t=this._room.remotePublishedUserMap.get(A);this._remoteAudioVolumeMap.set(A,e),t&&t.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:e},track:t.remoteAudioTrack})}}startPlugin(A,e){return VS(this,null,function*(){return A.start(e)})}updatePlugin(A,e){return VS(this,null,function*(){return A.update(e)})}stopPlugin(A,e){return VS(this,null,function*(){return A.stop(e)})}enableAudioVolumeEvaluation(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(A,e)}on(A,e,t){if(this.listeners(A).includes(e))return this;if(this._log.debug("on",A),super.on(A,e,t),this._eventListened.add(A),this.listeners($Y.AUDIO_FRAME).length>0){let{audioFrameEventConfigMap:A}=this.room.audioManager;A.get("")||A.set("",{enable:!0}),this._localAudioTrack&&this.room.audioManager.handleLocalTrackStarted({userId:"",room:this.room})}return"realtime-transcriber-message"===A&&this._room.subscribeDataChannel(),this}emit(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i{null==A||A.abort("off")}),A.clear()}return this}getAudioTrack(){let A,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},t=null,i="main",o=!1;if(q_(e)?A=e:(A=e.userId,o=!0===e.processed,e.streamType&&(i=e.streamType)),A){let e=this._room.remotePublishedUserMap.get(A);e&&(t=e.remoteAudioTrack)}else t="sub"===i?this._localScreenAudioTrack:this._localAudioTrack;return t?o&&t.outMediaTrack&&t.outMediaTrack!==t.mediaTrack?t.outMediaTrack.clone():t.mediaTrack:null}getVideoTrack(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:e="",streamType:t="main",processed:i=!1}=A,o=null;if(""===e)"main"===t&&this._localVideoTrack&&(o=this._localVideoTrack),"sub"===t&&this._localScreenTrack&&(o=this._localScreenTrack);else{let A=this._room.remotePublishedUserMap.get(e);A&&(o="main"===t?A.remoteVideoTrack:A.remoteAuxiliaryTrack)}return o?i&&o.outMediaTrack&&o.outMediaTrack!==o.mediaTrack?o.outMediaTrack.clone():o.mediaTrack:null}getVideoSnapshot(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:e,streamType:t="main"}=A;if(e){let A=this._room.remotePublishedUserMap.get(e);if("main"===t&&null!=A&&A.muteState.hasVideo)return A.remoteVideoTrack.getVideoFrame();if("sub"===t&&null!=A&&A.muteState.hasAuxiliary)return A.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===t&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===t&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}_setCurrentSpeaker(A){var e,t;this._speakerId=A,null==(e=this._localAudioTrack)||e.setAudioOutput(A),null==(t=this._localScreenAudioTrack)||t.setAudioOutput(A),this._room.remotePublishedUserMap.forEach(e=>e.remoteAudioTrack.setAudioOutput(A))}setCurrentSpeaker(A){return VS(this,null,function*(){(yield mF()).forEach(e=>{e.deviceId===A&&(this._setCurrentSpeaker(A),this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}),pH=e)}),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: '.concat(_M,"/en/TRTC.html#.setCurrentSpeaker"))})}_startRemoteAudio(A){return this._doStartRemoteAudio(A)}_doStartRemoteAudio(A){return VS(this,null,function*(){var e;let{userId:t}=A;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let i=this._room.remotePublishedUserMap.get(t);if(!i)return;let o={},n=i.remoteAudioTrack;n.on("decode-failed",A=>{this.emit($Y.ERROR,new wY({code:mY.OPERATION_FAILED,extraCode:5508,message:"audio decode failed"}))}),this._listenOutputTrackChanged(n),this._speakerId&&n.setAudioOutput(this._speakerId);try{let i=null!=(e=this._remoteAudioVolumeMap.get(t))?e:this._remoteAudioVolumeMap.get("*"),r=V_(i)?i:100;o.volume=r,this._remoteAudioConfigMap.set(t,A),yield this._room.subscribe(n),sO(PO(n,"decode-failed"),gx(PO(n,ZL.INIT)),cP(()=>{this.startPlugin(uH.Name,{track:n,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})})),yield this._updateAudioPlayOption({playOption:o,track:n}),tG.emit("115",{userId:t,room:this.room}),n.outMediaTrack&&this.room.audioManager.updateAudioReference({type:"add",audioReference:n.outMediaTrack,refId:"ra-".concat(t)})}catch(r){throw this._remoteAudioConfigMap.delete(t),r}this._emitTrackEvent(n)})}_stopRemoteAudio(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return VS(this,null,function*(){let t=this._room.remotePublishedUserMap.get(A.userId);t&&(t.remoteAudioTrack.stop(),t.muteState.hasAudio&&e&&(yield this._room.unsubscribe(t.remoteAudioTrack)),this._mediaTrackMap.delete(t.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(A.userId)),tG.emit("116",{userId:A.userId,room:this.room}),this.room.audioManager.updateAudioReference({type:"remove",refId:"ra-".concat(A.userId)})})}_enableVideoDecodeFallback(A,e){let t,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(A.log.debug("remote video will fall back when decode failed",A.id),sO(PO(A,"decode-failed"),gx(PO(A,ZL.INIT)),lP(()=>{"h265"!==this._room.downlinkVideoCodec&&this.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:A,config:{codec:"avc1.420028"},fallback:i})}),Yx(PO(A,"decode-downgrade-state-changed")),cP(i=>{t=i.state,this.emit($Y.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,FS(US({},i),{streamType:e,userId:A.userId}))},e=>{A.log.error("fallback",e)},()=>{"STARTED"===t&&A.log.info("fallback complete")})))}_updateVideoPlayOption(A){return VS(this,arguments,function(A){let{view:e,playOption:t,track:i,prevConfig:o}=A;return function*(){if(i.setMirror(t.mirror),H_(e)&&o&&o.view&&!aT(t)){let A=ET(o.view);A.length>0&&(yield i.play(A,t))}if(!H_(e)){let A=ET(e);A.length>0?yield i.play(A,t):i.stop()}}()})}_updateAudioPlayOption(A){return VS(this,arguments,function(A){var e=this;let{playOption:t={},track:i,prevConfig:o}=A;return function*(){if(!i.isPlayCalled)try{yield i.play(null,t)}catch(A){}if(H_(t.muted)||i.setPlayerMute(t.muted),H_(t.volume)||i.setAudioVolume(t.volume/100),i instanceof BP&&i.mediaTrack){let A=!1===t.muted&&!H_(t.volume)&&t.volume>0?"add":"remove";e.room.audioManager.updateAudioReference({type:A,audioReference:i.mediaTrack,refId:"em"})}else if(i instanceof rY){let A=t.muted?0:t.volume;if(H_(A))return;e.room.audioManager.updateAudioReference({type:"updateVolume",refId:"ra-".concat(i.userId),volume:t.volume})}}()})}_listenOutputTrackChanged(A){0===A.listeners("output-media-track-changed").length&&A.on("output-media-track-changed",()=>this._emitTrackEvent(A,!1))}_emitTrackEvent(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=A.isRemote?A.userId:"";A.outMediaTrack&&(e&&this._mediaTrackMap.get(A.outMediaTrack)===t||(this._mediaTrackMap.set(A.outMediaTrack,t),this.emit($Y.TRACK,{userId:t,streamType:SY(A.streamType),track:A.outMediaTrack,sourceTrack:A.mediaTrack})))}_checkTrackToPublish(){var A,e,t;let i=[];if(null!=(A=this._localAudioConfig)&&A.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(e=this._localVideoConfig)&&e.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(t=this._localScreenConfig)&&t.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack),this._checkScreenAudioEchoCancellation(this._localScreenTrack,this._localScreenAudioTrack)),0!==i.length)return Promise.all(i.map(A=>this._room.publish(A).catch(()=>{})))}_observeView(A){let{remoteTrack:e,view:t,receiveWhenViewVisible:i,viewRoot:o}=A;if(H_(t)||H_(i))return;let n=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(SY(e.streamType)));if(!n)return;let r=n.observer||void 0;if(null===t||W_(t)&&0===t.length||!i)return null==r||r.disconnect(),void(e.isSubscribed||(this._log.info("_observeView observer disconnect, resubscribe",e.userId,e.strMediaType),this._room.subscribe(e).catch(()=>{})));let s=n.visibleViewMap||new Map,a=-1;(!r||r.root!==o)&&(null==r||r.disconnect(),s.clear(),r=new IntersectionObserver(A=>{A.forEach(A=>{s.set(A.target,A.isIntersecting),e.log.info("view ".concat(A.target.id," is").concat(A.isIntersecting?"":" not"," visible"))}),clearTimeout(a),a=window.setTimeout(()=>{[...s.values()].find(A=>A)?e.isSubscribed||this._room.subscribe(e).catch(()=>{}):e.isSubscribed&&this._room.unsubscribe(e).catch(()=>{})},200)},{root:o}));let g=new Set(ET(t));s.forEach((A,e)=>{g.has(e)||(r.unobserve(e),s.delete(e))}),g.forEach(A=>{s.set(A,!0),r.observe(A)}),r.takeRecords().forEach(A=>{s.set(A.target,A.isIntersecting)}),n.visibleViewMap=s,n.observer=r}_exitRoom(){return VS(this,null,function*(){this._room.isJoined&&(yield this._room.leave()),this._clearRemoteTracks()})}_stopScreenShare(){return VS(this,null,function*(){var A,e;if(this._localScreenTrack){if(this._room.isJoined){let e=[];null!=(A=this._localScreenConfig)&&A.publish&&e.push(this._localScreenTrack),this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),yield Promise.all(e.map(A=>this._room.unpublish(A).catch(()=>{})))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(!1===(null==(e=this._localScreenAudioTrack.trackSettings)?void 0:e.echoCancellation)&&this.stopPlugin("AudioProcessor"),this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),aU(this._localScreenTrack),this._localScreenTrack=null,delete this._room.capturedLocalAuxVideoTrack,this._localScreenConfig=null}})}_checkScreenAudioEchoCancellation(A,e){return VS(this,null,function*(){var t,i;if(!A||!e)return;let o=null==(t=A.trackSettings)?void 0:t.displaySurface;if(!1===(null==(i=e.trackSettings)?void 0:i.echoCancellation)&&("monitor"===o||"browser"===o&&A.isShareCurrentTab)){this._log.warn("echoCancellation of screen audio track is disable. Try starting audioProcessor plugin");try{yield this.startPlugin("AudioProcessor",{sdkAppId:Number(this.room.sdkAppId),userId:this._room.userId,userSig:this.room.userSig,isScreenAudioNeedAudioProcess:!0,isLocalAudioNeedAudioProcess:!1})}catch(n){this._log.warn("start audioProcessor plugin failed: ",n)}}})}_onLocalTrackCaptured(A){let{track:e}=A;"audio"===e.kind&&(!pH||CF(pH))&&(this._initActiveSpeaker(),tG.off("102",this._onLocalTrackCaptured,this))}_initActiveSpeaker(){return VS(this,null,function*(){if(pH&&!CF(pH))this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:pH});else{let A=yield mF();A[0]&&!CF(A[0])?(pH=A[0],this.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:A[0]})):tG.on("102",this._onLocalTrackCaptured,this)}})}_onAudioAvailable(A){let{userId:e}=A,t=this._remoteAudioMuteMap.has(e)?this._remoteAudioMuteMap.get(e):this._remoteAudioMuteMap.get("*");(!1===t||this._room.autoReceiveAudio&&!t)&&this._doStartRemoteAudio({userId:e}).catch(()=>{})}_onVideoAvailable(A){let{userId:e,streamType:t}=A;if(!this._room.autoReceiveVideo)return;let i=this._room.remotePublishedUserMap.get(e);if(i){let A="main"===t?i.remoteVideoTrack:i.remoteAuxiliaryTrack,e=[A];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&e.push(i.remoteAudioTrack),this._room.subscribe(...e).then(()=>{this._emitTrackEvent(A)}).catch(()=>{})}}_onAudioUnavailable(A){let{userId:e,muteState:t}=A;t.hasAudio&&t.audioMuted||this._stopRemoteAudio({userId:e},!1).catch(()=>{})}_onVideoUnavailable(A){let{userId:e,streamType:t}=A;this._stopRemoteVideo({userId:e,streamType:t},!1).catch(()=>{})}_onDataChannelAvailable(){if(this.listeners("realtime-transcriber-message").length>0)return this._room.subscribeDataChannel()}sendSEIMessage(A,e){var t;let i=this._plugins.get("SEI");i&&(i.update({buffer:A,options:FS(US({seiPayloadType:243},e),{small:!(null==(t=this._localVideoTrack)||!t.small)})}),Gk.addCount({key:5e5,useUV:!0}))}sendCustomMessage(A){var e,t;null==(t=(e=this._room).sendCustomMessage)||t.call(e,A),Gk.addCount({key:500001,useUV:!0})}callExperimentalAPI(A,e){return VS(this,null,function*(){return this._log.info("callExperimentalAPI(".concat(A,", ").concat(JSON.stringify(e),")")),dH.call(A,US({trtcInstance:this},e))})}static setLogLevel(A,e){sG.setLogLevel(A),H_(e)||(e?sG.enableUploadLog():sG.disableUploadLog())}static isSupported(){return jk(A.frameWorkType)}static getPermissions(A){return VS(this,arguments,function(A){let{request:e=!0,types:t=["camera","microphone"]}=A;return function*(){e&&(yield CH.request(t).catch(A=>{var e;return sG.error("getPermissions request failed, error: ".concat(null!=(e=null==A?void 0:A.message)?e:A))}));let[A,i]=yield Promise.all([CH.get("camera"),CH.get("microphone")]);return{camera:A,microphone:i}}()})}static getCameraList(){return pF(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getMicrophoneList(){return QF(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getSpeakerList(){return mF(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static setCurrentSpeaker(e){return VS(this,null,function*(){if(lN&&(e===fY.SPEAKER||e===fY.HEADSET)){let t=yield A.getMicrophoneList(),i="";if(t.forEach(A=>{A.label===e&&(i=A.deviceId)}),!i)return;return void QH.forEach(A=>VS(null,null,function*(){A._localAudioTrack&&(yield A.updateLocalAudio({option:{microphoneId:i}}))}))}(yield mF()).forEach(A=>{A.deviceId===e&&(QH.forEach(t=>{t._setCurrentSpeaker(e),t.emit($Y.DEVICE_CHANGED,{type:"speaker",action:"active",device:A})}),pH=A)})})}static _addKVStat(A){let{type:e,key:t,value:i,base:o,useUV:n,version:r,max:s}=A;switch(r&&(bk.version=r),e){case"count":bk.addCount({key:t,useUV:n});break;case"enum":bk.addEnum({key:t,value:i,useUV:n});break;case"number":bk.addNumber({key:t,value:i,split:o,max:s})}}get localVideoTrack(){return this._localVideoTrack}get localScreenTrack(){return this._localScreenTrack}get localScreenAudioTrack(){return this._localScreenAudioTrack}};HS(fH,"VERSION",bJ),HS(fH,"_loggerManager",sG),HS(fH,"EVENT",$Y),HS(fH,"ERROR_CODE",mY),HS(fH,"TYPE",fY),HS(fH,"frameWorkType",30),JS([OJ({replaceArg:A=>({argIndex:0,value:{name:"plugin"in A?A.plugin.Name:A.Name,assetsPath:"assetsPath"in A?null==A?void 0:A.assetsPath:"default"}})})],fH.prototype,"use",1),JS([GJ(xY.TRTC.enterRoom),WY("room",(A,e)=>{let[t]=A,[i]=e;return(t.roomId||t.strRoomId)===(i.roomId||i.strRoomId)&&t.userId===i.userId&&t.sdkAppId===i.sdkAppId}),xF(A=>function(e){return this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),A.call(this,e)}),OJ()],fH.prototype,"enterRoom",1),JS([OJ()],fH.prototype,"exitRoom",1),JS([GJ(xY.TRTC.switchRoom),OJ(),VF()],fH.prototype,"switchRoom",1),JS([GJ(xY.TRTC.switchRole),zY("room",{merge:(A,e)=>e}),OJ()],fH.prototype,"switchRole",1),JS([OJ()],fH.prototype,"destroy",1),JS([GJ(xY.TRTC.startLocalAudio),WY("audio",(A,e)=>{let[t]=A,[i]=e;var o,n;return(null==(o=null==t?void 0:t.option)?void 0:o.microphoneId)===(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)}),OJ()],fH.prototype,"startLocalAudio",1),JS([GJ(xY.TRTC.updateLocalAudio),zY("audio",{debounce:{delay:200,getKey:()=>"".concat(BH,"-localAudio"),isNeedToDebounce:A=>{var e;return!H_(null==(e=A.option)?void 0:e.captureVolume)}}}),OJ()],fH.prototype,"updateLocalAudio",1),JS([ZY("audio"),OJ()],fH.prototype,"stopLocalAudio",1),JS([GJ(xY.TRTC.startLocalVideo),WY("video",(A,e)=>{let[t]=A,[i]=e;var o,n;return(null==(o=null==t?void 0:t.option)?void 0:o.cameraId)===(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)}),OJ()],fH.prototype,"startLocalVideo",1),JS([GJ(xY.TRTC.updateLocalVideo),zY("video"),OJ()],fH.prototype,"updateLocalVideo",1),JS([ZY("video"),OJ()],fH.prototype,"stopLocalVideo",1),JS([GJ(xY.TRTC.startScreenShare),WY("screen",()=>!0),OJ()],fH.prototype,"startScreenShare",1),JS([GJ(xY.TRTC.updateScreenShare),zY("screen"),OJ()],fH.prototype,"updateScreenShare",1),JS([OJ()],fH.prototype,"stopScreenShare",1),JS([GJ(xY.TRTC.startRemoteVideo),WY(A=>"v".concat(A.userId).concat(A.streamType),()=>!0),OJ({getRemoteId:A=>"".concat(A.userId,"_").concat(A.streamType)})],fH.prototype,"startRemoteVideo",1),JS([GJ(xY.TRTC.updateRemoteVideo),zY(A=>"v".concat(A.userId).concat(A.streamType)),OJ({getRemoteId:A=>"".concat(A.userId,"_").concat(A.streamType)})],fH.prototype,"updateRemoteVideo",1),JS([GJ(xY.TRTC.stopRemoteVideo),xF(A=>function(e){return VS(this,null,function*(){if("*"===e.userId){let A=[];return this._room.remotePublishedUserMap.forEach(e=>{this._remoteVideoConfigMap.has("".concat(e.userId,"_main"))&&A.push(this.stopRemoteVideo({streamType:"main",userId:e.userId}).catch(()=>{})),this._remoteVideoConfigMap.has("".concat(e.userId,"_sub"))&&A.push(this.stopRemoteVideo({streamType:"sub",userId:e.userId}).catch(()=>{}))}),Promise.all(A)}return A.call(this,e)})}),OJ({getRemoteId:A=>"".concat(A.userId,"_").concat(A.streamType)})],fH.prototype,"stopRemoteVideo",1),JS([ZY(A=>"v".concat(A.userId).concat(A.streamType))],fH.prototype,"_stopRemoteVideo",1),JS([GJ(...xY.TRTC.muteRemoteAudio),OJ({getRemoteId:A=>A})],fH.prototype,"muteRemoteAudio",1),JS([kJ(...xY.TRTC.setRemoteAudioVolume),function(A,e){return xF((t,i)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n{var A;null==(A=NJ.get(this))||A.delete(s)},A);r.set(s,e)}else{clearTimeout(a);let e=window.setTimeout(()=>{var A;t.apply(this,o),null==(A=NJ.get(this))||A.delete(s)},A);r.set(s,e)}})}(200,A=>A),OJ({getRemoteId:A=>A})],fH.prototype,"setRemoteAudioVolume",1),JS([PJ("start"),FF(A=>{var e;return null==(e=A.afterStart)?void 0:e.call(A)}),WY((A,e)=>A.disableRandomCall?null:A.getAlias()+A.getGroup(e)),OJ({replaceArg:A=>({argIndex:0,value:A.getName()}),getKVReportKey:A=>Mk[A.getName()],ignoreLog:A=>"Debug"===A.getName(),ignoreErrorLog:A=>"AudioProcessor"===A.getName()})],fH.prototype,"startPlugin",1),JS([PJ("update"),zY((A,e)=>A.disableRandomCall?null:A.getAlias()+A.getGroup(e),{merge:(A,e)=>(IT(A[1],e[1]),A)}),OJ({replaceArg:A=>({argIndex:0,value:A.getName()}),getKVReportKey:A=>Rk[A.getName()]})],fH.prototype,"updatePlugin",1),JS([PJ("stop"),ZY((A,e)=>{if(A.disableRandomCall)return null;let t=A.getGroup(e),i=A.getAlias();return"*"===t?new RegExp("".concat(i,".*")):i+t}),OJ({replaceArg:A=>({argIndex:0,value:A.getName()}),getKVReportKey:A=>_k[A.getName()]})],fH.prototype,"stopPlugin",1),JS([kJ(...xY.TRTC.enableAudioVolumeEvaluation)],fH.prototype,"enableAudioVolumeEvaluation",1),JS([OJ()],fH.prototype,"getVideoSnapshot",1),JS([OJ()],fH.prototype,"_setCurrentSpeaker",1),JS([WY(A=>"a".concat(A.userId),()=>!0)],fH.prototype,"_startRemoteAudio",1),JS([xF(A=>function(e){return VS(this,null,function*(){return"*"===e.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map(A=>this._stopRemoteAudio(FS(US({},e),{userId:A.userId})).catch(()=>{}))):A.call(this,e)})}),ZY(A=>"a".concat(A.userId))],fH.prototype,"_stopRemoteAudio",1),JS([ZY("room")],fH.prototype,"_exitRoom",1),JS([ZY("screen")],fH.prototype,"_stopScreenShare",1),JS([GJ(...xY.TRTC.sendSEIMessage),BY({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var A=arguments.length,e=new Array(A),t=0;tA.data.byteLength})],fH.prototype,"sendCustomMessage",1),JS([XY()],fH,"create",1),JS([GJ(xY.TRTC.create)],fH,"_create",1),JS([XY()],fH,"setLogLevel",1),JS([XY()],fH,"isSupported",1),JS([XY(),OJ()],fH,"getPermissions",1),JS([XY()],fH,"getCameraList",1),JS([XY()],fH,"getMicrophoneList",1),JS([XY()],fH,"getSpeakerList",1);var mH=fH,yH=class{constructor(){HS(this,"_set",new Set),tG.on(oG.LEAVE_SUCCESS,this.delete,this),tG.on(oG.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess,this)}add(A){let{room:e,roomId:t}=A;if("rtc"===e.scene)return;let i=this.getKey(e.userId,t||e.roomId,e.sdkAppId,e.useStringRoomId);this._set.add(i)}delete(A){let{room:e,roomId:t}=A;if("rtc"===e.scene)return;let i=this.getKey(e.userId,e.roomId||t,e.sdkAppId,e.useStringRoomId);this._set.delete(i)}getKey(A,e,t,i){return"".concat(t,"_").concat(e,"_").concat(A,"_").concat(i)}isJoined(A){let{userId:e,roomId:t,sdkAppId:i,room:o}=A;return"rtc"!==o.scene&&this._set.has(this.getKey(e,t,i,o.useStringRoomId))}handleSwitchRoomSuccess(A){let{room:e,currentRoomId:t,targetRoomId:i}=A;"rtc"!==e.scene&&(this._set.delete(this.getKey(e.userId,t,e.sdkAppId,e.useStringRoomId)),this._set.add(this.getKey(e.userId,i,e.sdkAppId,e.useStringRoomId)))}};function DH(){return VS(this,null,function*(){let A,e;try{let e=yield QF();A=e&&e.length}catch(u){}try{let A=yield pF();e=A&&A.length}catch(u){}let t={microphone:A,camera:e},{isH264EncodeSupported:i,isVp8EncodeSupported:o,isH264DecodeSupported:n,isVp8DecodeSupported:r,isH265EncodeSupported:s,isH265DecodeSupported:a}=this.checkSystemResult.detail,g=cG.basis(),c={webRTC:g.isWebRTCSupported,getUserMedia:g.isGetUserMediaSupported,webSocket:g.isWebSocketsSupported,screenShare:g.isScreenShareSupported,webAudio:g.isWebAudioSupported,h264Encode:i,h264Decode:n,vp8Encode:o,vp8Decode:r,h265Encode:s,h265Decode:a},l={browser:g.browser,os:g.os,trtc:c,devices:t},I={isWebCodecSupported:g.isWebCodecSupported,isMediaSessionSupported:g.isMediaSessionSupported,isWebTransportSupported:g.isWebTransportSupported};gU.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),gU.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(I)),userId:this.userId}),FL()})}var vH=YS(jS()),wH="1",SH="2",MH="3",RH="4",_H="5",TH="6",NH="7",bH="8",GH={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,START_PUBLISH_CDN_STREAM_RES:8196,UPDATE_PUBLISH_CDN_STREAM_RES:8198,STOP_PUBLISH_CDN_STREAM_RES:8200,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_FIRST_PACKAGE_RECEIVED:5e3,RECEIVE_CUSTOM_MSG:4140,FALLBACK_CODEC:66,SEND_SWITCH_ROOM_RES:4160,SEND_SWITCH_ROOM_SUBED_REQ:4161,UPDATE_NETWORK_TIME_RESULT:5001,CUSTOM_CMD_RES:8220},kH=[GH.UPDATE_REMOTE_MUTE_STAT,GH.UPLINK_NETWORK_STATS,GH.USER_LIST_RES,GH.MUTE_RESULT,GH.SERVER_FIRST_PACKAGE_RECEIVED,GH.RECEIVE_CUSTOM_MSG,GH.UPDATE_NETWORK_TIME_RESULT],LH={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",START_PUBLISH_CDN_STREAM_RES:"start-publish-cdn-stream-res",UPDATE_PUBLISH_CDN_STREAM_RES:"update-publish-cdn-stream-res",STOP_PUBLISH_CDN_STREAM_RES:"stop-publish-cdn-stream-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_FIRST_PACKAGE_RECEIVED:"first-pkg-received",RECEIVE_CUSTOM_MSG:"receive-custom-msg",FALLBACK_CODEC:"fallback-codec",SEND_SWITCH_ROOM_RES:"send-switch-room-res",SEND_SWITCH_ROOM_SUBED_REQ:"send-switch-room-subed-res",UPDATE_NETWORK_TIME_RESULT:"update_network_time_result",CUSTOM_CMD_RES:"custom-cmd-res"},UH="publish_change",FH="join",OH="leave",xH="quality_report",PH="mute_uplink",YH="publish",JH="publish_state_change",HH="unpublish",qH="subscribe",VH="unsubscribe",jH="subscribe_change",KH="start_publishing",WH="stop_publishing",zH="start_push_user_cdn",ZH="stop_push_user_cdn",XH="start_mcu_mix",$H="stop_mcu_mix",Aq="start_publish_cdn_stream",eq="update_publish_cdn_stream",tq="stop_publish_cdn_stream",iq="get_user_list",oq="change_role",nq="update_constraint_config",rq="rebuild_pc",sq="join/v2",aq="publish/v2",gq="subscribe/v3",cq="ability_status_report",lq="reconnect",Iq="channel_msg",uq="switch_room",Eq="update_network_time",dq=new Set([YH,UH,JH,HH,qH,jH,VH,aq,gq]),hq=new Set,Cq=["autoTest","relayInnerIp","relayOuterIp","mcd","newRelay","clientIp"],Bq=0,Qq=class extends vH.default{constructor(A){var e,t,i;super(),HS(this,"room"),HS(this,"sdkAppId"),HS(this,"userId"),HS(this,"userSig"),HS(this,"url"),HS(this,"backupUrl"),HS(this,"destroyed",!1),HS(this,"_socketInUse"),HS(this,"_socket"),HS(this,"_backupSocket"),HS(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,bakRelayIps:[],reportToken:void 0}),HS(this,"_currentState","DISCONNECTED"),HS(this,"_isReconnecting",!1),HS(this,"_seq",0),HS(this,"_log"),HS(this,"_lastMessageTime",-1),HS(this,"_connectStartTime",-1),HS(this,"_stopConnectRetry"),HS(this,"_isFirstConnect",!0),HS(this,"bytesSent",0),HS(this,"bytesReceived",0),HS(this,"keepAlive",!1),HS(this,"signalDomainWhenUnifiedProxy"),HS(this,"stopKeepAliveTimeout"),HS(this,"rtt",0),this.room=A.room,this.sdkAppId=A.sdkAppId,this.userId=A.userId,this.userSig=A.userSig,this.signalDomainWhenUnifiedProxy=A.signalDomainWhenUnifiedProxy;let o=(null==(t=null==(e=this.room.scheduleResult)?void 0:e.config)?void 0:t.keepAliveClient)||0;null!=(i=this.room.joinParams)&&i.keepAlive&&!o&&(o=1),o-hq.size>0&&this.room.enableSPC&&(this.keepAlive=!0,hq.add(this)),this.url=A.url,this.backupUrl=A.backupUrl,this._seq=0,this._log=sG.createLogger({parent:this.room.getLogger(),id:"ws".concat(++Bq),userId:this.userId,sdkAppId:this.sdkAppId}),this.onmessage=this.onmessage.bind(this),this.onerror=this.onerror.bind(this),this.onclose=this.onclose.bind(this)}get race(){return this.room.enableSPC&&!this.room.proxy_ws}get urlParam(){let A="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));this.signalDomainWhenUnifiedProxy&&(A+="&signalDomain=".concat(encodeURIComponent(this.signalDomainWhenUnifiedProxy)));let e=new URLSearchParams(location.search);return Cq.forEach(t=>{let i=e.get("trtc_".concat(t));i&&(A+="&".concat(t,"=").concat(encodeURIComponent(i)))}),this.race?"".concat(A,"&race=1"):A}get _urlWithParam(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get _backupUrlWithParam(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get isConnected(){return"CONNECTED"===this._currentState}get isConnecting(){return"CONNECTING"===this._currentState}get isOnline(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}connect(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return function*(){if(A.isConnected)return Promise.resolve();A._log.info("connect to [".concat(A.url,", ").concat(A.backupUrl,"] ").concat(A.race?"race":"").concat(e?" timeout: ".concat(e):""," keepAlive: ").concat(Number(A.keepAlive))),A.emitConnectionStateChanged("CONNECTING"),A._connectStartTime=oT();let t=[A.connectWS({url:A._urlWithParam,isMain:!0,timeout:e})];A.race&&A._backupUrlWithParam!==A._urlWithParam&&t.push(A.connectWS({url:A._backupUrlWithParam,isMain:!1,timeout:e})),A._socketInUse=yield iT(t),A.unbindAndCloseSocket(A._socketInUse===A._socket?WM.BACKUP:WM.MAIN),A._isFirstConnect&&(Gk.addSuccessEvent({key:521720}),A._isFirstConnect=!1),A.emitConnectionStateChanged("CONNECTED")}()})}connectWS(A){let{url:e,timeout:t,isMain:i}=A,o=new WebSocket(e);this.bindSocket(o),i?this._socket=o:this._backupSocket=o;let n=-1;return new Promise((A,e)=>{o.onclose=e,o.onerror=e,o.onopen=()=>A(o),t&&(n=setTimeout(()=>{this.unbindAndCloseSocket(i?WM.MAIN:WM.BACKUP),e(new rM({code:oM.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))},t))}).finally(()=>{o.onclose=null,o.onerror=null,o.onopen=null,clearTimeout(n)})}bindSocket(A){A.addEventListener("close",this.onclose),A.addEventListener("error",this.onerror),A.addEventListener("message",this.onmessage)}unbindSocket(A){A.removeEventListener("close",this.onclose),A.removeEventListener("error",this.onerror),A.removeEventListener("message",this.onmessage)}unbindAndCloseSocket(A){if(A===WM.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(e){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(e){}this._backupSocket=null}}onclose(A){A.target===this._socketInUse&&(this._log.warn("".concat(A.target===this._socket?"main":"backup"," is closed code:").concat(A.code," ").concat(A.reason)),this.emitConnectionStateChanged("DISCONNECTED"),(!A.wasClean||1e3!==A.code)&&this.startReconnection(),this.room.isJoining&&this.emit(_H,new rM({code:oM.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onclose"})))}onerror(A){this._log.error("".concat(A.target===this._socket?"main":"backup"," error observed")),this.emitConnectionStateChanged("DISCONNECTED"),A.target===this._socketInUse&&(this.unbindAndCloseSocket(WM.MAIN),this.unbindAndCloseSocket(WM.BACKUP),this._socketInUse=null,this.reconnect()),this.room.isJoining&&this.emit(_H,new rM({code:oM.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onerror"}))}onmessage(A){if(!this.isConnected)return;let{isOnline:e}=this;this._lastMessageTime=Date.now(),e||this.emit(bH),this.bytesReceived+=QT(A.data);let t=JSON.parse(A.data),{cmd:i,data:o}=t,n=Object.values(GH),r=Object.keys(GH)[n.indexOf(i)],s=LH[r]||i;switch(kH.includes(i)||(this._log.debug("received ".concat(i," msg: ").concat(A.data)),s&&this._log.info("Received event: [ ".concat(s," ]"))),i){case GH.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=o.clientIp,this._signalInfo.signalIp=o.signalInnerIp,o.svrTime&&gM(o.svrTime-(new Date).getTime()),this._log.info("ChannelSetup Success ".concat(oT()-this._connectStartTime)),Gk.addSuccessEvent({key:521701,cost:oT()-this._connectStartTime}),this._connectStartTime=-1,this.room.firewallDetector.resetTimeoutCount(),this.emit(wH,{signalInfo:this._signalInfo});else{let A=new rM({code:oM.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:mk({key:Bk.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),Gk.addFailedEvent({key:521701,error:A}),this.emit(_H,A)}break;case GH.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=o.relayOuterIp,this._signalInfo.relayInnerIp=o.relayInnerIp,this._signalInfo.bakRelayIps=o.bakRelayIps,this._signalInfo.relayPort=o.relayPort,this._signalInfo.tinyId=t.tinyId,this._signalInfo.endReportExtend=o.endReportExtend,this._signalInfo.reportToken=o.reportToken,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(s,{data:t});break;default:this.emit(String(s),{data:t})}}reGetSignalChannelUrl(){return VS(this,null,function*(){try{if(!this.room.joinParams)return;sJ(!0),yield this.room.schedule(this.room.joinParams);let{mainUrl:A,backupUrl:e}=this.room.getSignalChannelUrl();this.url=A,this.backupUrl=e}catch(A){}})}startReconnection(){if(!this._socketInUse)return;this._socketInUse.onclose=null,this._socketInUse.close(4011);let A=this._socketInUse===this._socket;this.unbindAndCloseSocket(A?WM.MAIN:WM.BACKUP),this._socketInUse=null,this.emitConnectionStateChanged("DISCONNECTED"),this.reconnect()}reconnect(){return VS(this,null,function*(){if(!this._isReconnecting){if(!this.room.isJoined&&this.keepAlive)return void this.close();this._isReconnecting=!0;try{this._log.warn("reconnect"),yield this.connect();let{roomId:A,useStringRoomId:e}=this.room,{relayIp:t,relayInnerIp:i,relayPort:o}=this._signalInfo,{data:n}=yield this.sendWaitForResponse({command:lq,data:{roomId:A,useStringRoomId:e,relayInnerIp:i,relayOuterIp:t,relayPort:o},responseCommand:LH.CHANNEL_RECONNECT_RESULT});0===n.code?(this._log.warn("reconnect success"),this.stopReconnection(),Gk.addSuccessEvent({key:521702,cost:oT()-this._connectStartTime}),this._connectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(Gk.addFailedEvent({key:521702,error:n.code}),this._log.warn("reconnect failed, ".concat(n.code," ").concat(n.message)),this.room.reJoin())}catch(A){this._log.error(A),this.room.reJoin()}}})}send(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){let t={cmd:A,data:e,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},i=JSON.stringify(t);return this._socketInUse.send(i),dq.has(A)&&this._log.info("send",A,e),this.bytesSent+=QT(i),t.seq}}sendWaitForResponse(A){let{command:e,data:t,timeout:i=5e3,responseCommand:o,commandDesc:n,enableLog:r=!0,addReceiveTime:s=!1}=A;return new Promise((A,a)=>{let g=()=>{clearTimeout(c),a(new rM({code:oM.API_CALL_ABORTED,message:"".concat(e," aborted due to connection closed")}))};this.once(NH,g);let c=setTimeout(()=>{this.off(o,l),this.off(NH,g);let A=new rM({code:oM.API_CALL_TIMEOUT,message:mk({key:Bk.API_CALL_TIMEOUT,data:{commandDesc:n,command:e}})});r&&this._log.warn(A),a(A)},i),l=e=>{e.data.seq===I&&(clearTimeout(c),this.off(o,l),this.off(NH,g),s&&(e.data.receiveTime=Date.now()),A(e))};this.on(o,l);let I=this.send(e,t)})}sendWaitForResponseWithRetry(A){let{commandDesc:e,command:t,retries:i=0,retryTimeout:o=0}=A;return zT({retryFunction:this.sendWaitForResponse,onError:A=>{let{retry:e,reject:i,error:o}=A;!this.room.isJoined||this.destroyed||o.code===oM.API_CALL_ABORTED?i(o):this.isOnline?e():(this._log.warn("retry ".concat(t," when connected")),this.once(bH,e))},onRetrying:A=>{this._log.warn("".concat(e||t," timeout observed, retrying [").concat(A,"/").concat(i,"]"))},settings:{retries:i,timeout:o},context:this})(A)}getCurrentState(){return this._currentState}getSignalInfo(){return this._signalInfo}stopReconnection(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}close(){this._log.info("closed"),clearTimeout(this.stopKeepAliveTimeout),hq.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,bakRelayIps:[],endReportExtend:void 0,reportToken:void 0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(WM.MAIN),this.unbindAndCloseSocket(WM.BACKUP),this.emitConnectionStateChanged("DISCONNECTED"),this.emit(NH)}destroy(){this.close(),this.destroyed=!0}getBackupRelayIpPair(){var A;let e=null==(A=this._signalInfo.bakRelayIps)?void 0:A.shift();return e&&(e.relayPort=e.relayPort||this._signalInfo.relayPort),e}clearBakRelayIps(){this._signalInfo.bakRelayIps=[]}stopKeepAliveIn(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(A,"s")),this.stopKeepAliveTimeout=setTimeout(()=>{this.keepAlive=!1,this._log.info("close due to not used ".concat(A,"s")),this.close(),this.off(LH.JOIN_ROOM_RESULT,e)},1e3*A);let e=A=>{0===A.data.code&&(this._log.info("stopKeepAlive clear timeout"),clearTimeout(this.stopKeepAliveTimeout),this.off(LH.JOIN_ROOM_RESULT,e))};this.on(LH.JOIN_ROOM_RESULT,e)}}emitConnectionStateChanged(A){if(A===this._currentState)return;this._log.info("".concat(this._currentState," -> ").concat(A));let e={prevState:this._currentState,state:A};"CONNECTING"===A&&(e.isReconnecting=this._isReconnecting),this.emit(SH,e),this._currentState=A,"CONNECTED"===A?this.emit(MH):"DISCONNECTED"===A&&this.emit(TH)}};JS([lU({settings:{retries:1/0,timeout:2e3},onError(A,e){!this.room.isDestroyed&&!this.destroyed&&(this._isFirstConnect&&(Gk.addFailedEvent({key:521720,error:A}),this._isFirstConnect=!1),this.room.firewallDetector.increaseTimeoutCount(),e())},onRetrying(A,e){this._log.warn("retrying to connect ".concat(A)),A>=3&&A%3==0&&this.reGetSignalChannelUrl(),e&&(this._stopConnectRetry=e,(this.room.isDestroyed||this.destroyed)&&e())}})],Qq.prototype,"connect",1);var pq=YS(jS()),fq=!1,mq=class{constructor(A){HS(this,"userId"),HS(this,"tinyId"),HS(this,"_sdpSemantics"),HS(this,"_isUplink"),HS(this,"_room"),HS(this,"_log"),HS(this,"_signalChannel"),HS(this,"_isErrorObserved",!1),HS(this,"_waitForPeerConnectionConnectedPromise"),HS(this,"_waitForPeerConnectionConnectedPromiseReject",null),HS(this,"_peerConnection",null),HS(this,"_emitter",new pq.default),HS(this,"_currentState","DISCONNECTED"),HS(this,"_isReconnecting",!1),HS(this,"_reconnectionCount",0),HS(this,"_reconnectionTimer",-1),HS(this,"_isFirstConnection",!0),HS(this,"_prevTime",-1),HS(this,"_localAddress"),HS(this,"_remoteAddress"),HS(this,"isDestoyed",!1),this.userId=A.userId,this.tinyId=A.tinyId,this._room=A.room,this._sdpSemantics=A.room.sdpSemantics,this._isUplink=A.isUplink,this._log=A.room.getLogger().createChild({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=A.signalChannel}beforeConnect(){this._prevTime<0&&(this._prevTime=oT())}afterConnect(){try{this._isFirstConnection?(this._isFirstConnection=!1,Gk.addSuccessEvent({key:521705,cost:Math.min(oT()-this._prevTime,3e4)})):this._isReconnecting&&Gk.addSuccessEvent({key:521706,cost:oT()-this._prevTime}),this._prevTime=-1}catch(A){throw this._isFirstConnection?(this._isFirstConnection=!1,Gk.addFailedEvent({key:521705,error:A})):this._isReconnecting&&this._reconnectionCount>=3&&Gk.addFailedEvent({key:521706,error:A}),A}}initialize(){let A={iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(A),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}close(A){this._log.info("close connection"),this._emitter.emit("closed",A),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection()}destroy(){this.isDestoyed=!0}closePeerConnection(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,A&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new rM({code:oM.API_CALL_ABORTED,message:"connection closed"}))}getDTLSTransportState(){if(!this._peerConnection)return QR;let A=null;if(this._isUplink){if(!cL()||0===this._peerConnection.getSenders().length)return QR;A=this._peerConnection.getSenders()[0].transport}else{if(!gL()||0===this._peerConnection.getReceivers().length)return QR;A=this._peerConnection.getReceivers()[0].transport}return A?A.state:QR}onConnectionStateChange(A){let e=this._peerConnection.iceConnectionState,t=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(A.target.connectionState,", ICE: ").concat(e,", DTLS: ").concat(t)),A.target.connectionState===pR.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),A.target.connectionState===pR.FAILED||A.target.connectionState===pR.CLOSED){let i="connection ".concat(A.target.connectionState,". ICE Transport state: ").concat(e,", DTLS Transport state: ").concat(t),o=new rM({message:i,code:oM.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",o)}(A.target.connectionState===pR.CONNECTED||A.target.connectionState===pR.COMPLETED)&&(this.logSelectedCandidate(),gU.logSuccessEvent({userId:this._room.userId,eventType:wR.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}emitConnectionStateChangedEvent(A){return A!==this._currentState&&("CONNECTED"===A&&(this._room.firewallDetector.resetTimeoutCount(),fq=!0),tG.emit(oG.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:A,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:A}),this._currentState=A,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}logSelectedCandidate(){return VS(this,null,function*(){if(!this._peerConnection)return;let A=yield this._peerConnection.getStats();for(let[,e]of A)if(AL(e)){let t=A.get(e.localCandidateId),i=A.get(e.remoteCandidateId);t&&(this._log.info("local candidate: ".concat(t.candidateType," ").concat(t.protocol,":").concat(t.ip||t.address,":").concat(t.port," ").concat(t.networkType||""," ").concat("relay"===t.candidateType?"relayProtocol:".concat(t.relayProtocol):"")),this._localAddress="".concat(t.ip||t.address,":").concat(t.port)),i&&(this._log.info("remote candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port)),this._remoteAddress="".concat(i.protocol,":").concat(i.ip||i.address));break}})}getCurrentState(){return this._currentState}waitForPeerConnectionConnected(){return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise((A,e)=>{if("CONNECTED"===this._currentState)return A();this._waitForPeerConnectionConnectedPromiseReject=e;let t=e=>{"CONNECTED"===e.state&&(clearTimeout(n),o(),A())},i=A=>{let{room:t}=A;t===this._room&&(clearTimeout(n),o(),e(new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.CONNECTION_ABORTED,data:"leave room"})})))},o=()=>{tG.off(oG.LEAVE_SUCCESS,i,this),this._emitter.off("connection-state-changed",t,this)},n=setTimeout(()=>{o();let A=new rM({code:oM.API_CALL_TIMEOUT,message:"connection timeout"});this._room.firewallDetector.increaseTimeoutCount(),e(A)},OR);tG.on(oG.LEAVE_SUCCESS,i,this),this._emitter.on("connection-state-changed",t,this)}),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally(()=>{this._waitForPeerConnectionConnectedPromise=null,this._waitForPeerConnectionConnectedPromiseReject=null})),this._waitForPeerConnectionConnectedPromise}getReconnectionCount(){return this._reconnectionCount}startReconnection(){this._isReconnecting=!0,this.reconnect()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}stopReconnection(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(MH,this.reconnect,this)}beforeReconnect(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=yR()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();let A=new rM({code:this._isUplink?oM.UPLINK_RECONNECTION_FAILED:oM.DOWNLINK_RECONNECTION_FAILED,message:mk({key:this._isUplink?Bk.UPLINK_RECONNECTION_FAILED:Bk.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",A),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(MH,this.reconnect,this),-1)}on(A,e,t){this._emitter.on(A,e,t)}off(A,e,t){this._emitter.off(A,e,t)}getIsReconnecting(){return this._isReconnecting}get isH264(){var A,e;return!(null==(e=null==(A=this._peerConnection)?void 0:A.remoteDescription)||!e.sdp.includes("H264"))}setOffer(A){var e;return null==(e=this._peerConnection)?void 0:e.setLocalDescription(A)}setAnswer(A){var e;return null==(e=this._peerConnection)?void 0:e.setRemoteDescription(A)}};JS([WF(521712,!1)],mq.prototype,"setOffer",1),JS([WF(521713,!1)],mq.prototype,"setAnswer",1);var yq=YS(eM()),Dq=function(A){return yq.default.parse(A)},vq=function(A){return yq.default.write(A)};function wq(A){return Object.keys(A).filter(e=>A[e])}var Sq=class A extends mq{constructor(A){super(FS(US({},A),{isUplink:!1})),HS(this,"_flag",0),HS(this,"isRobot",!1),HS(this,"role","anchor"),HS(this,"remoteAudioTrack"),HS(this,"remoteVideoTrack"),HS(this,"remoteAuxiliaryTrack"),HS(this,"avPlayerStateSyncManager"),HS(this,"ssrc",{audio:0,video:0,auxiliary:0}),HS(this,"_isSDPExchanging",!1),HS(this,"_videoCodec"),HS(this,"fromType"),this.flag=A.flag,this.isRobot=A.isRobot||!1,this.remoteAudioTrack=A.remoteAudioTrack||new rY(this._room,this),this.remoteVideoTrack=A.remoteVideoTrack||new aY(this._room,this),this.remoteAuxiliaryTrack=A.remoteAuxiliaryTrack||new gY(this._room,this),this.avPlayerStateSyncManager=new RJ({log:this._log,audioPlayer:this.remoteAudioTrack.player,videoPlayer:this.remoteVideoTrack.player})}get videoCodec(){var A,e;let t=null==(e=null==(A=this._peerConnection)?void 0:A.remoteDescription)?void 0:e.sdp;return t?t.includes("H264")?"h264":"vp8":this._videoCodec||"h264"}set videoCodec(A){this._videoCodec=A}get subscribeState(){let A={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?A.smallVideo=!0:A.video=!0),this.remoteAudioTrack.isSubscribed&&(A.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(A.auxiliary=!0),A}get muteState(){return gT(this.flag,this.userId)}get flag(){return this._flag}set flag(A){var e,t,i;A!==this._flag&&(this._flag=A,null==(e=this.remoteAudioTrack)||e.onFlagChanged(),null==(t=this.remoteVideoTrack)||t.onFlagChanged(),null==(i=this.remoteAuxiliaryTrack)||i.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(A){return A===WM.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){super.initialize(),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}close(A){super.close(A),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.avPlayerStateSyncManager.destroy(),this.uninstallEvents()}installEvents(){}uninstallEvents(){this._emitter.removeAllListeners()}emitConnectionStateChangedEvent(A){var e,t;let i=this._currentState,o=super.emitConnectionStateChangedEvent(A);return o&&i!==A&&(null==(e=this.remoteVideoTrack)||e.emit("connection-state-changed",{prevState:i,state:A}),null==(t=this.remoteAuxiliaryTrack)||t.emit("connection-state-changed",{prevState:i,state:A})),o}onTrack(A){let e=A.streams[0],{track:t}=A,i=e.id===aR?WM.MAIN:WM.AUXILIARY;this._log.debug("ontrack ".concat(i," ").concat(t.kind));let o=WM.AUDIO;t.kind===WM.VIDEO&&(o=i===WM.MAIN?WM.VIDEO:WM.AUXILIARY);let n=this.remoteAudioTrack;o===WM.VIDEO?n=this.remoteVideoTrack:o===WM.AUXILIARY&&(n=this.remoteAuxiliaryTrack),n.setInputMediaStreamTrack(t)}addRRTRLine(A){let e=A.split("\r\n"),t=new Map;e.forEach((A,i)=>{/^a=rtcp-fb:/.test(A)&&e[i+1]&&!/^a=rtcp-fb:/.test(e[i+1])&&t.set(i+1,"".concat(A.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))});let i=[...t];for(let o=0;o{A.type===WM.VIDEO&&A.fmtp.forEach(A=>{A.config+=";sps-pps-idr-in-keyframe=1"})}),vq(e)}removeSDESDescription(A){let e=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],t=Dq(A);return t.media.forEach(A=>{A.ext&&(A.ext=A.ext.filter(A=>!e.includes(A.uri)))}),vq(t)}isSubscriptionStateNotChanged(A){return JSON.stringify(A)===JSON.stringify(this.subscribeState)}subscribe(A,e){return VS(this,null,function*(){var t,i;try{if(((null==(t=this._peerConnection)?void 0:t.connectionState)===pR.NEW||(null==(i=this._peerConnection)?void 0:i.connectionState)===pR.CONNECTING)&&(yield this.waitForPeerConnectionConnected()),this.isSubscriptionStateNotChanged(A))return void(this._peerConnection||(this.initialize(),yield this.connect(A)));if(this._log.info("subscribe ".concat(e," ").concat(JSON.stringify(A))),this._peerConnection||this._isSDPExchanging){let e="subscribe_change";Object.values(A).find(A=>!0===A)||(e="unsubscribe"),yield this.sendSubscription(e,A)}else this.initialize(),yield this.connect(A)}catch(o){throw this._room.isJoined&&this.isStreamUnpublished(e)?(this._log.warn("".concat(o.message," ").concat(JSON.stringify(this.muteState))),new rM({code:oM.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):o}})}unsubscribe(A){return VS(this,arguments,function(A){var e=this;let{remoteTracks:t,streamType:i}=A;return function*(){if("CONNECTED"===e._currentState&&("main"===i&&!e.isMainStreamSubscribed||"auxiliary"===i&&!e.isAuxStreamSubscribed))return void e._log.info("".concat(i," stream already unsubscribed"));let A=US({},e.subscribeState);t.forEach(e=>{switch(e.mediaType){case 1:A.audio=!1;break;case 4:A.video=!1;break;case 8:A.smallVideo=!1;break;case 2:A.auxiliary=!1}});let o="subscribe_change";Object.values(A).find(A=>!0===A)||(o="unsubscribe"),e._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(i," [").concat(wq(A),"]")),yield e.sendSubscription(o,A),"unsubscribe"===o&&(e.closePeerConnection(),e.emitConnectionStateChangedEvent("DISCONNECTED"))}()})}unsubscribeDataChannel(){return VS(this,null,function*(){})}sendSubscription(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,t={srcTinyId:this.tinyId,srcUserId:this.userId},i=VH,o=LH.UNSUBSCRIBE_RESULT;return"subscribe_change"===A&&(t={audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo,srcTinyId:this.tinyId},i=jH,o=LH.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:i,data:t,responseCommand:o,timeout:1e4}).then(e=>{let{data:t}=e;if(0!==t.code){let e=new rM({code:t.code,message:mk({key:Bk.ERROR_MESSAGE,data:{type:A,message:t.message}})});throw this._log.error(e),e}})}connect(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return function*(){try{yield A.exchangeSDP(e),yield A.waitForPeerConnectionConnected()}catch(t){throw A.closePeerConnection(!0),t}}()})}exchangeSDP(A){return VS(this,null,function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer");let{type:e,sdp:t}=this._peerConnection.localDescription,i={type:e,sdp:t,srcUserId:this.userId,srcTinyId:this.tinyId,audio:A.audio,bigVideo:A.video,auxVideo:A.auxiliary,smallVideo:A.smallVideo},o=yield this._signalChannel.sendWaitForResponse({command:qH,commandDesc:"exchange sdp",data:i,responseCommand:LH.SUBSCRIBE_RESULT,timeout:_R});if(!this._peerConnection){let A=new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.CONNECTION_CLOSED})});throw this._log.warn(A),A}yield this.onSubscribeResult(o),this._isSDPExchanging=!1}catch(e){throw this._isSDPExchanging=!1,e}})}createOffer(){return VS(this,null,function*(){let A={voiceActivityDetection:!1};IL()&&this._sdpSemantics===TR?(this._peerConnection.addTransceiver(WM.AUDIO,{direction:zM.RECVONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:zM.RECVONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:zM.RECVONLY})):(A.offerToReceiveAudio=!0,A.offerToReceiveVideo=!0);let e=yield this._peerConnection.createOffer(A);if(e.sdp){let{isH264DecodeSupported:A}=yield Vk();A||(this._log.warn("remove h264 desc from sdp"),e.sdp=function(A){let e=Dq(A);return e.media.forEach(A=>{var e,t;if(A.type===WM.VIDEO){let i=new Set;A.rtp.forEach(A=>{let{payload:e,codec:t}=A;return"H264"===t&&i.add(e)}),A.fmtp.forEach(A=>{let{payload:e,config:t}=A,o=t.match(/apt=(\d+)/);o&&o[1]&&i.has(Number(o[1]))&&i.add(e)});let o=A=>{let{payload:e}=A;return!i.has(e)};A.rtp=A.rtp.filter(o),A.rtcpFb=null==(e=A.rtcpFb)?void 0:e.filter(o),A.fmtp=A.fmtp.filter(o),A.payloads=null==(t=A.payloads)?void 0:t.split(" ").filter(A=>!i.has(Number(A))).join(" ")}}),vq(e)}(e.sdp)),e.sdp=this.addRRTRLine(e.sdp),e.sdp=this.addSPSDescription(e.sdp),e.sdp=function(A){let e=Dq(A);return e.media.forEach(A=>{A.type===WM.AUDIO&&A.fmtp.forEach(A=>{A.config+=";sprop-stereo=1;stereo=1"})}),vq(e)}(e.sdp),this._sdpSemantics===TR&&(e.sdp=this.removeSDESDescription(e.sdp))}yield this.setOffer(e)})}onSubscribeResult(A){return VS(this,null,function*(){let{code:e,message:t=""}=A&&A.data||{},{type:i,sdp:o}=A&&A.data&&A.data.data||{};if(e===bR)throw new rM({code:oM.NOT_SUPPORTED_H264,message:mk({key:Bk.NOT_SUPPORTED_H264DECODE})});try{if(0!==e)throw new rM({code:e,message:mk({key:Bk.EXCHANGE_SDP_FAILED,data:{errMsg:t}})});this._log.debug("accept remote answer: ".concat(o)),yield this.setAnswer({type:i,sdp:o}),this.updateSSRC(o)}catch(n){throw this._log.error(n),n}})}updateSSRC(A){try{Dq(A).media.forEach(A=>{if(A.ssrcs)if(A.type===WM.AUDIO){let e=A.ssrcs.find(A=>{var e;return null==(e=A.value)?void 0:e.includes(aR)});e&&(this.ssrc.audio=Number(e.id))}else{let e=A.ssrcs.find(A=>{var e;return null==(e=A.value)?void 0:e.includes(aR)}),t=A.ssrcs.find(A=>{var e;return null==(e=A.value)?void 0:e.includes(gR)});e&&(this.ssrc.video=Number(e.id)),t&&(this.ssrc.auxiliary=Number(t.id))}})}catch(e){}}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}reconnect(){return VS(this,null,function*(){if(!(qS(A.prototype,this,"beforeReconnect").call(this)<0))try{this.closePeerConnection(),this.initialize(),yield this.connect(),this.stopReconnection(),this._log.warn("reconnect() success")}catch(e){let A=P_(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(A/1e3,"s")),this._reconnectionTimer=setTimeout(()=>{this.clearReconnectionTimer(),this.reconnect()},A)}})}getIsReconnecting(){return this._isReconnecting}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}getCurrentState(){return this._currentState}setDelay(A){let{audioDelay:e,videoDelay:t}=A;this.remoteAudioTrack.stat.end2EndDelay=e,this.remoteVideoTrack.stat.end2EndDelay=t}get audioReceiver(){var A;return(null==(A=this._peerConnection)?void 0:A.getReceivers()[0])||null}};JS([xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;i{let o=A=>{this._emitter.off("closed",o),i(new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.CONNECTION_ABORTED,data:A})}))};this._emitter.on("closed",o),A.apply(this,t).then(e,i).finally(()=>{this._emitter.off("closed",o)})})})],Sq.prototype,"subscribe",1),JS([WF(521717,!1)],Sq.prototype,"unsubscribe",1),JS([FF(mq.prototype.afterConnect),UF(mq.prototype.beforeConnect)],Sq.prototype,"connect",1);var Mq=Sq,Rq={voiceActivityDetection:!1},_q=class A extends mq{constructor(A){super(FS(US({},A),{isUplink:!0})),HS(this,"localMainAudioTrack",null),HS(this,"localMainVideoTrack",null),HS(this,"localAuxAudioTrack",null),HS(this,"localAuxVideoTrack",null),HS(this,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),HS(this,"_isPublishingAux",!1),HS(this,"_publishingLocalAudioTrack"),HS(this,"_publishingLocalVideoTrack"),HS(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),HS(this,"flag",0)}get videoCodec(){return this._mediaSettings.videoCodec.toLowerCase()||"h264"}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}initialize(){super.initialize(),this.installEvents()}reset(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}close(A){super.close(A),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}uninstallEvents(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}emitConnectionStateChangedEvent(A,e){var t,i,o;let n=this._currentState,r=super.emitConnectionStateChangedEvent(A);return r&&n!==A&&(e?e.emit("connection-state-changed",{prevState:n,state:A}):(null==(t=this.localMainVideoTrack)||t.emit("connection-state-changed",{prevState:n,state:A}),null==(i=this.localAuxVideoTrack)||i.emit("connection-state-changed",{prevState:n,state:A}),null==(o=this._publishingLocalVideoTrack)||o.emit("connection-state-changed",{prevState:n,state:A}))),r}publish(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i,isAuxiliary:o}=A;return function*(){let A;e._peerConnection||e.initialize(),t&&(e._publishingLocalAudioTrack=t),i&&(e._publishingLocalVideoTrack=i),e._isPublishingAux=o,i&&!o&&i.small&&(A=e._room.videoManager.smallTrack),e.sendMediaSettings(),IL()?yield e.publishByTransceiver({localAudioTrack:t,localVideoTrack:i,smallTrack:A,isAuxiliary:o}):yield e.publishByAddTrack({localAudioTrack:t,localVideoTrack:i,smallTrack:A}),e._publishingLocalAudioTrack=null,e._publishingLocalVideoTrack=null,e._isPublishingAux=!1,o?(i&&(e.localAuxVideoTrack=i),t&&(e.localAuxAudioTrack=t)):(i&&(e.localMainVideoTrack=i),t&&(e.localMainAudioTrack=t)),e.installTrackMuteEvents(t,i),e.sendMutedFlag()}()})}publishByTransceiver(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i,smallTrack:o,isAuxiliary:n}=A;return function*(){e._log.info("publish by transceiver");let A=new MediaStream,r=null==i?void 0:i.outMediaTrack,s=null==t?void 0:t.outMediaTrack;s&&A.addTrack(s),r&&A.addTrack(r);let a=e._peerConnection.getTransceivers();if(0===a.length)e._peerConnection.addTransceiver(s||WM.AUDIO,{direction:zM.SENDONLY,streams:[A]}),e._peerConnection.addTransceiver(n?WM.VIDEO:r||WM.VIDEO,{direction:zM.SENDONLY,streams:[A]}),e._peerConnection.addTransceiver(o||WM.VIDEO,{direction:zM.SENDONLY,streams:[A]}),e._peerConnection.addTransceiver(n&&r||WM.VIDEO,{direction:zM.SENDONLY,streams:[A]}),yield e.connect();else{let A=[];if(s&&(a[0].sender.track||A.push(0),yield a[0].sender.replaceTrack(s),yield e.setBandwidth({bandwidth:(null==t?void 0:t.profile.bitrate)||40,type:WM.AUDIO})),r){let t=n?3:1;yield a[t].sender.replaceTrack(r),yield e.setBandwidth({bandwidth:i.profile.bitrate,type:WM.VIDEO,videoType:n?WM.AUXILIARY:WM.BIG}),A.push(t),o&&(yield a[2].sender.replaceTrack(o),yield e.setBandwidth({bandwidth:i.small.bitrate,type:WM.VIDEO,videoType:WM.SMALL}),A.push(2))}yield e.setTransceiverDirection(zM.SENDONLY,A),yield e.doPublishChange(),null==i||i.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==i||i.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"})}}()})}publishByAddTrack(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i,smallTrack:o}=A;return function*(){e._log.info("publish by addtrack");let A=null==i?void 0:i.outMediaTrack,n=null==t?void 0:t.outMediaTrack;if(e._peerConnection&&"new"!==e._peerConnection.connectionState)return t&&n&&(yield e.addTrack(t)),void(A&&(yield e.addTrack(i)));let r=new MediaStream;if(n&&r.addTrack(n),A&&r.addTrack(A),n&&e._peerConnection.addTrack(n,r),A&&(e._peerConnection.addTrack(A,r),o)){let A=new MediaStream;A.addTrack(o),e._peerConnection.addTrack(o,A)}yield e.connect()}()})}enableSmall(A){return VS(this,null,function*(){let e=this._peerConnection.getTransceivers();A?this._room.videoManager.smallTrack&&(yield e[2].sender.replaceTrack(this._room.videoManager.smallTrack),yield this.setTransceiverDirection(zM.SENDONLY,[2])):(yield e[2].sender.replaceTrack(null),yield this.setTransceiverDirection(zM.INACTIVE,[2])),this.updateMediaSettings(),yield this.doPublishChange()})}installTrackMuteEvents(){for(var A=arguments.length,e=new Array(A),t=0;t{A&&(null==A||A.on("mute",this.sendMutedFlag,this),null==A||A.on("unmute",this.sendMutedFlag,this))})}uninstallTrackMuteEvents(){for(var A=arguments.length,e=new Array(A),t=0;t{A&&(null==A||A.off("mute",this.sendMutedFlag,this),null==A||A.off("unmute",this.sendMutedFlag,this))})}unpublish(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i}=A;return function*(){if(!lL())return t&&t.outMediaTrack&&!i&&e.localMainVideoTrack?(yield e.removeTrack(t),void(e.localMainAudioTrack=null)):i&&i.outMediaTrack&&!t&&e.localMainAudioTrack?(yield e.removeTrack(i),void(e.localMainVideoTrack=null)):(yield e.doUnpublish(),e.uninstallTrackMuteEvents(t,i),void e.emitConnectionStateChangedEvent("DISCONNECTED",i));let A=i&&i===e.localAuxVideoTrack,o=null==i?void 0:i.outMediaTrack,n=e._peerConnection.getSenders(),r=[];t&&(A?e.localAuxAudioTrack=null:e.localMainAudioTrack=null,!e.localAuxAudioTrack&&!e.localMainAudioTrack&&(yield n[0].replaceTrack(null),r.push(0))),o&&(A?(yield n[3].replaceTrack(null),e.localAuxVideoTrack=null,e._mediaSettings=FS(US({},e._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),r.push(3)):(yield n[1].replaceTrack(null),yield n[2].replaceTrack(null),e.localMainVideoTrack=null,e._mediaSettings=FS(US({},e._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),r.push(1,2))),e.isMainStreamPublished||e.isAuxStreamPublished?(yield e.setTransceiverDirection(zM.INACTIVE,r),yield e.doPublishChange(!1)):yield e.doUnpublish(),e.uninstallTrackMuteEvents(t,i),null==i||i.emit("connection-state-changed",{prevState:e._currentState,state:"DISCONNECTED"})}()})}doPublishChange(){let A=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return VS(this,null,function*(){let e={state:this._room.publishState,constraintConfig:this._mediaSettings},t=yield this._signalChannel.sendWaitForResponse({command:JH,data:e,responseCommand:LH.PUBLISH_STATE_CHANGE_RESULT,enableLog:A});this.checkPublishResultCode(t.data.code,t.data.message)})}doUnpublish(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:HH,commandDesc:"unpublish",responseCommand:LH.UNPUBLISH_RESULT,enableLog:A}).catch(A=>{if(A.getCode()===oM.API_CALL_TIMEOUT)return Promise.resolve();throw A})}updateMediaSettings(){let{detail:{isH264EncodeSupported:A,isVp8EncodeSupported:e}}=this._room.checkSystemResult;A?this._mediaSettings.videoCodec="H264":e&&(this._mediaSettings.videoCodec="VP8");let t=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:i,localAuxVideoTrack:o}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?o=this._publishingLocalVideoTrack:i=this._publishingLocalVideoTrack),QL){if(t&&t.outMediaTrack){let A=t.outMediaTrack.getSettings();this._mediaSettings.audioChannel=A.channelCount||1,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=A.sampleRate||0}if(i&&i.outMediaTrack){let A=i.outMediaTrack.getSettings();this._mediaSettings.videoWidth=A.width||0,this._mediaSettings.videoHeight=A.height||0,this._mediaSettings.videoFps=A.frameRate||0,this._mediaSettings.videoBps=1e3*i.profile.bitrate,i.small&&(this._mediaSettings.smallVideoWidth=i.small.width,this._mediaSettings.smallVideoHeight=i.small.height,this._mediaSettings.smallVideoFps=i.small.frameRate,this._mediaSettings.smallVideoBps=1e3*i.small.bitrate)}if(o&&o.outMediaTrack){let A=o.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=A.width||0,this._mediaSettings.auxVideoHeight=A.height||0,this._mediaSettings.auxVideoFps=A.frameRate||0,this._mediaSettings.auxVideoBps=1e3*o.profile.bitrate}}else t&&t.outMediaTrack&&(this._mediaSettings.audioChannel=t.profile.channelCount,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=t.profile.sampleRate),i&&i.outMediaTrack&&(this._mediaSettings.videoWidth=i.profile.width,this._mediaSettings.videoHeight=i.profile.height,this._mediaSettings.videoFps=i.profile.frameRate,this._mediaSettings.videoBps=1e3*i.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:nq,data:this._mediaSettings,responseCommand:LH.UPDATE_CONSTRAINT_CONFIG_RES}).then(A=>{0!==A.data.code&&this._log.warn(A.data.message)}).catch(()=>{})}addTrack(A){return VS(this,null,function*(){if(!this._peerConnection)return;let e=A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;this._log.info("is adding ".concat(A.kind," track to current published local ").concat(e?WM.AUXILIARY:WM.MAIN," stream")),IL()?yield this.addTrackByTransceiver(A,e):yield this.addTrackBySender(A)})}addTrackByTransceiver(A,e){return VS(this,null,function*(){var t;if(!A.mediaTrack)return;let i=this._peerConnection.getTransceivers();if(A.kind===WM.AUDIO)yield i[0].sender.replaceTrack(A.outMediaTrack);else{let o=e?3:1;yield i[o].sender.replaceTrack(A.outMediaTrack),1===o&&null!=(t=this.localMainVideoTrack)&&t.small&&(yield i[2].sender.replaceTrack(this._room.videoManager.smallTrack)),i[o].direction===zM.INACTIVE&&(yield this.setTransceiverDirection(zM.SENDONLY,[o]))}this.updateMediaSettings(),yield this.doPublishChange()})}addTrackBySender(A){return VS(this,null,function*(){if(!A.outMediaTrack)return;let e=A.outMediaTrack;lL()&&this._peerConnection.getTransceivers().findIndex(A=>"stopped"===A.direction)>=0&&(this._log.warn("transceiver is stopping, negotiate sdp first"),yield this.updateOffer("remove",e));let t=this._peerConnection.getSenders().find(A=>A.track&&A.track.kind===e.kind);if(t&&t.track){this._log.warn("sender already exists, remove sender first");let A=t.track;this.removeSender(t),yield this.updateOffer("remove",A)}if(e&&this._peerConnection.addTrack(e,new MediaStream([e])),e.kind===WM.VIDEO&&A instanceof DP&&A.small){let A=new MediaStream,{smallTrack:e}=this._room.videoManager;A.addTrack(e),this._peerConnection.addTrack(e,A)}yield this.updateOffer("add",e)})}isNeedToResetOfferOrder(){if(this._sdpSemantics===NR||!this._peerConnection||!this._peerConnection.localDescription)return!1;let{sdp:A}=this._peerConnection.localDescription,e=Dq(A);for(let t=0;te.sender&&e.sender.track===A.track)),this._peerConnection.removeTrack(A),e&&J_(e.stop)&&(this._log.info("stop transceiver"),e.stop())}removeTrack(A){return VS(this,null,function*(){if(!this._peerConnection)return;let e=A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;this._log.info("is removing ".concat(A.kind," track from current published local ").concat(e?WM.AUXILIARY:WM.MAIN," stream")),IL()?yield this.removeTrackByTransceiver(A,e):yield this.removeTrackBySender(A)})}removeTrackByTransceiver(A,e){return VS(this,null,function*(){if(!A.outMediaTrack)return;let t=this._peerConnection.getTransceivers();if(A.kind===WM.AUDIO)yield t[0].sender.replaceTrack(null);else{let i=e?3:1;yield t[i].sender.replaceTrack(null),1===i&&A.small&&(yield t[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(zM.INACTIVE,[i])}this.updateMediaSettings(),yield this.doPublishChange()})}setTransceiverDirection(A,e){return VS(this,null,function*(){if(!dN)return;let t=!1,i=!1;this._log.info("setting transceiver ".concat(e.join(",")," direction to ").concat(A));let o=this._peerConnection.getTransceivers();if(e.forEach(e=>{o[e].direction!==A&&(o[e].direction=A,t=!0)}),t){this._log.info("updating offer");let A=yield this._peerConnection.createOffer();yield this.setOffer(A)}let n=-1,r=this._peerConnection.remoteDescription.sdp.split("\r\n").map(t=>{if(t.match(new RegExp("a=(".concat(zM.INACTIVE,"|").concat(zM.RECVONLY,"|").concat(zM.SENDONLY,")")))&&n++,e.includes(n)){if(A===zM.INACTIVE&&t.includes("a=".concat(zM.RECVONLY)))return i=!0,"a=".concat(A);if(A===zM.SENDONLY&&t.includes("a=".concat(zM.INACTIVE)))return i=!0,"a=".concat(zM.RECVONLY)}return t}).join("\r\n");i&&(this._log.info("updating answer"),yield this.setAnswer({type:"answer",sdp:r}))})}removeTrackBySender(A){return VS(this,null,function*(){if(!A.outMediaTrack)return;if(A.kind===WM.VIDEO&&this.isNeedToResetOfferOrder()&&this.localMainAudioTrack)return this.reset(),this.initialize(),void(yield this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1}));let e=this._peerConnection.getSenders().find(e=>e.track===A.outMediaTrack);e&&(this.removeSender(e),A.kind===WM.VIDEO&&A.small&&this._peerConnection.getSenders().forEach(A=>{A.track&&A.track.kind===WM.VIDEO&&this.removeSender(A)})),yield this.updateOffer("remove",A.outMediaTrack)})}replaceTrack(A){return VS(this,null,function*(){var e;let t,i=null==(e=this._peerConnection)?void 0:e.getSenders();if(!i||0===i.length||!A.mediaTrack)return!1;if(t=IL()?A.kind===WM.AUDIO?i[0]:i[1]:i.find(e=>e.track&&e.track.kind===A.kind),!t)return!1;let o=A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;return this._log.info("is replacing ".concat(A.kind," track on ").concat(o?WM.AUXILIARY:WM.MAIN," stream")),A.kind===WM.AUDIO?yield t.replaceTrack(A.outMediaTrack):A.kind===WM.VIDEO&&(o?i[3]&&(yield i[3].replaceTrack(A.outMediaTrack)):yield t.replaceTrack(A.outMediaTrack)),!0})}updateOffer(A,e){return VS(this,null,function*(){try{let t=yield this._peerConnection.createOffer(Rq);dN&&t.sdp&&(t.sdp=this.setSDPDirection(t.sdp,"sendrecv")),yield this.setOffer(t);let i=this.updateMediaSettings(),o={action:A,trackId:e.id,kind:e.kind===WM.VIDEO?"bigVideo":e.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:i,state:this._room.publishState};this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(o.sdp));let n=yield this._signalChannel.sendWaitForResponse({command:UH,data:o,responseCommand:LH.UPDATE_OFFER_RESULT,timeout:RR,commandDesc:"update offer"}),{code:r,message:s}=n.data;0!==r&&this.checkPublishResultCode(r,s),yield this.acceptAnswer(n.data.data),t.sdp&&this.updateSSRC(t.sdp)}catch(t){throw this._log.error(t),t}})}setBandwidth(A){return VS(this,arguments,function(A){var e=this;let{bandwidth:t,type:i,videoType:o,sdp:n}=A;return function*(){if(!CL())return n?i===WM.VIDEO?e.updateVideoBandwidthRestriction(n,t,o):e.updateAudioBandwidthRestriction(n,t):void 0;let A,r=e._peerConnection.getSenders();if(IL()){let e=0;i===WM.VIDEO&&(e=o===WM.SMALL?2:o===WM.AUXILIARY?3:1),A=r[e]}else A=r.find(A=>A.track&&A.track.kind===i);if(A){let r=A.getParameters();(!r.encodings||0===r.encodings.length)&&(r.encodings=[{}]),r.encodings[0].maxBitrate=1e3*t;try{return yield A.setParameters(r),e._log.info("".concat(o||"").concat(i," bandwidth ").concat(t," kbps")),n}catch(s){if(e._log.info("failed to set bandwidth by setting maxBitrate: ".concat(s)),n)return i===WM.VIDEO?e.updateVideoBandwidthRestriction(n,t,o):e.updateAudioBandwidthRestriction(n,t)}}return n}()})}updateVideoBandwidthRestriction(A,e,t){let i="AS";dN&&(i="TIAS",e*=1e3);let o=0,n=-1;return t===WM.SMALL?o=1:t===WM.AUXILIARY&&(o=2),A=A.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,A=>(n+=1,n===o?"".concat(A,"b=").concat(i,":").concat(e,"\r\n"):A))}updateAudioBandwidthRestriction(A,e){let t="AS";return dN&&(t="TIAS",e*=1e3),A.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(t,":").concat(e,"\r\n"))}removeBandwidthRestriction(A){return A.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}removeVideoOrientation(A){return A.replace(/urn:3gpp:video-orientation/,"")}connect(){return VS(this,null,function*(){try{yield this.exchangeSDP(),yield this.waitForPeerConnectionConnected()}catch(A){throw this.closePeerConnection(!0),this.uninstallEvents(),A}})}exchangeSDP(){return VS(this,null,function*(){try{yield this.createOffer(),this._log.info("createOffer success, sending offer to remote server"),yield this.doExchangeSDP()}catch(A){throw A}})}createOffer(){return VS(this,null,function*(){try{let A=yield this._peerConnection.createOffer(Rq);yield this.setOffer(A),A.sdp&&this.updateSSRC(A.sdp)}catch(A){throw A}})}doExchangeSDP(){let A={command:YH,responseCommand:LH.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof XP||this.localAuxVideoTrack instanceof XP,state:this._room.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(A.data.sdp)),this._signalChannel.sendWaitForResponse(A).then(A=>{let{code:e,message:t,data:i}=A.data;return 0===e?this.acceptAnswer(i):this.checkPublishResultCode(e,t)})}setSDPDirection(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",i=Dq(A);return i.media.forEach(A=>{("all"===t||A.type===t)&&(A.direction=e)}),vq(i)}acceptAnswer(A){return VS(this,null,function*(){var e,t,i,o,n;try{let r;if(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished){let A=(null==(e=this._publishingLocalVideoTrack)?void 0:e.profile.bitrate)||(null==(t=this.localMainVideoTrack)?void 0:t.profile.bitrate),n=(null==(i=this._publishingLocalAudioTrack)?void 0:i.profile.bitrate)||(null==(o=this.localMainAudioTrack)?void 0:o.profile.bitrate);if(A){let e=this._isPublishingAux?WM.AUXILIARY:WM.BIG;r=yield this.setBandwidth({bandwidth:A,type:WM.VIDEO,sdp:r,videoType:e})}n&&(r=yield this.setBandwidth({bandwidth:n,type:WM.AUDIO,sdp:r}))}if(r=this.removeVideoOrientation(A.sdp),null!=(n=this._publishingLocalVideoTrack)&&n.small){let{smallStreamConfig:A}=this._room;r=yield this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||A.bitrate,type:WM.VIDEO,videoType:WM.SMALL,sdp:r})}let s={type:A.type,sdp:r};yield this.setAnswer(s),this._log.debug("accepted answer: ".concat(r))}catch(r){throw this._log.error("failed to accept remote answer ".concat(r)),r}})}sendMutedFlag(A){A===this.localAuxAudioTrack||A===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this._room.muteState))),this._signalChannel.send(PH,this._room.muteState))}getIsReconnecting(){return this._isReconnecting}reconnect(){return VS(this,null,function*(){if(!(qS(A.prototype,this,"beforeReconnect").call(this)<0))try{yield this._signalChannel.sendWaitForResponse({command:HH,responseCommand:LH.UNPUBLISH_RESULT,enableLog:!1}),this.closePeerConnection(),this.initialize(),this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0})),this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection()}catch(e){let A=P_(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(A/1e3,"s")),this._reconnectionTimer=setTimeout(()=>{this.clearReconnectionTimer(),this.reconnect()},A)}})}handleConnectionStateChange(A){"CONNECTED"===A.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&tG.emit(oG.SEND_FIRST_VIDEO_FRAME,{room:this._room})}updateSSRC(A){try{Dq(A).media.forEach((A,e)=>{if(A.type===WM.AUDIO){let e=A.ssrcs&&A.ssrcs[0];e&&(this.ssrc.audio=Number(e.id))}else{if(this._sdpSemantics===NR&&A.ssrcGroups)return void A.ssrcGroups.forEach((A,e)=>{let t=Number(A.ssrcs.split(" ")[0]);0===e?this.ssrc.video=t:1===e&&(this.ssrc.small=t)});let t=A.ssrcs&&A.ssrcs[0];if(!t)return;switch(e){case 1:this.ssrc.video=Number(t.id);break;case 2:this.ssrc.small=Number(t.id);break;case 3:this.ssrc.auxiliary=Number(t.id)}}})}catch(e){}}getVideoTrackId(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:WM.VIDEO;if(this._peerConnection){let e=this._peerConnection.getSenders();if(A===WM.AUXILIARY&&e[3]&&e[3].track)return e[3].track.id;if(A===WM.VIDEO&&e[1]&&e[1].track)return e[1].track.id}if(this.localMainVideoTrack&&A===WM.VIDEO){let A=this.localMainVideoTrack.mediaTrack;if(A)return A.id}if(this.localAuxVideoTrack&&A===WM.AUXILIARY){let A=this.localAuxVideoTrack.mediaTrack;if(A)return A.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(A,e){if(0!==A)throw A===bR?(this._log.error(Qk.NOT_SUPPORTED_H264ENCODE),new rM({code:oM.NOT_SUPPORTED_H264,message:mk({key:Bk.NOT_SUPPORTED_H264ENCODE})})):new rM({code:oM.UNKNOWN,message:mk({key:Bk.SIGNAL_RESPONSE_FAILED,data:{signalResponse:LH.PUBLISH_RESULT,code:A,message:e}})})}};JS([xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;i{let o=A=>{this._emitter.off("closed",o),i(new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.CONNECTION_ABORTED,data:A})}))};this._emitter.on("closed",o),A.apply(this,t).then(e,i).finally(()=>{this._emitter.off("closed",o)})})})],_q.prototype,"publish",1),JS([WF(521715,!1)],_q.prototype,"unpublish",1),JS([FF(mq.prototype.afterConnect),UF(mq.prototype.beforeConnect)],_q.prototype,"connect",1);var Tq=_q,Nq=class{constructor(A,e){this.room=A,HS(this,"_log"),HS(this,"_prevReportTime",0),HS(this,"_prevReport",{}),HS(this,"_prevStats",null),HS(this,"_prevEncoderImplementation",""),HS(this,"_prevAuxEncoderImpl",""),HS(this,"_prevQualityLimitationReason",""),HS(this,"_prevAuxQualityLimitationReason",""),HS(this,"_prevDecoderImplementationMap",new Map),HS(this,"_decodeMap",new Map),HS(this,"_prevQpSum",0),HS(this,"_prevAuxQpSum",0),HS(this,"totalBytesSent",0),HS(this,"totalBytesReceived",0),HS(this,"_spcStats",null),this._log=e}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}getSenderStats(A){return VS(this,null,function*(){var e,t,i,o,n,r,s;let a={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},g=A.getPeerConnection(),c=A.getSSRC();if(g)try{if((this._spcStats||(yield g.getStats())).forEach(e=>{var t,i,o,n,r,s,g,l,I,u,E,d,h;let C,B;if("outbound-rtp"===e.type)if((e.mediaType||e.kind)===WM.VIDEO){if(e.ssrc===c.video?(C=WM.VIDEO,B=A.localMainVideoTrack):e.ssrc===c.small?C=WM.SMALL:e.ssrc===c.auxiliary&&(B=A.localAuxVideoTrack,C=WM.AUXILIARY),!C)return;a[C].bytesSent=e.bytesSent,a[C].packetsSent=e.packetsSent,a[C].framesEncoded=e.framesEncoded,H_(e.keyFramesEncoded)||(a[C].keyFramesEncoded=e.keyFramesEncoded),H_(e.nackCount)||(a[C].nackCount=e.nackCount),H_(e.pliCount)||(a[C].pliCount=e.pliCount),H_(e.retransmittedPacketsSent)||(a[C].retransmittedPacketsSent=e.retransmittedPacketsSent),H_(e.totalEncodeTime)||(a[C].totalEncodeTime=e.totalEncodeTime),H_(e.totalPacketSendDelay)||(a[C].totalPacketSendDelay=e.totalPacketSendDelay);let g=0;if(!H_(e.qpSum)&&!H_(e.framesEncoded)&&e.framesEncoded>0){let r=e.qpSum,s=e.framesEncoded,a=C===WM.VIDEO?this._prevQpSum:this._prevAuxQpSum,c=C===WM.VIDEO?(null==(i=null==(t=A.localMainVideoTrack)?void 0:t.stat)?void 0:i.framesEncoded)||0:(null==(n=null==(o=A.localAuxVideoTrack)?void 0:o.stat)?void 0:n.framesEncoded)||0;if(s>c&&r>a){let t=r-a,i=s-c;g=Math.round(t/i),g>35&&this._log.warn("".concat(C===WM.AUXILIARY?"aux ":"","video encoder QP is high: ").concat(g,", resolution: ").concat(e.frameWidth,"x").concat(e.frameHeight,", codec: ").concat(A.videoCodec,", "))}C===WM.VIDEO?this._prevQpSum=r:C===WM.AUXILIARY&&(this._prevAuxQpSum=r)}if(!H_(e.encoderImplementation)&&(C===WM.VIDEO&&this._prevEncoderImplementation!==e.encoderImplementation||C===WM.AUXILIARY&&this._prevAuxEncoderImpl!==e.encoderImplementation)){let t=2,i=this._prevEncoderImplementation;C===WM.AUXILIARY&&(t=7,i=this._prevAuxEncoderImpl),tG.emit("262",{userId:A.userId,streamType:t,prevImplementation:i,implementation:e.encoderImplementation,codec:A.videoCodec,isHWCodec:e.powerEfficientEncoder}),this[C===WM.VIDEO?"_prevEncoderImplementation":"_prevAuxEncoderImpl"]=e.encoderImplementation,null==B||B.log.info("encoderImplementation change to ".concat(e.encoderImplementation,"(").concat(A.videoCodec,") HWEncoder: ").concat(e.powerEfficientEncoder))}e.ssrc===c.video?!H_(e.qualityLimitationReason)&&0!==e.bytesSent&&this._prevQualityLimitationReason!==e.qualityLimitationReason&&(null==B||B.log.info("qualityLimitationReason change to ".concat(e.qualityLimitationReason)),tG.emit("263",{userId:A.userId,reason:e.qualityLimitationReason,prevReason:this._prevQualityLimitationReason,streamType:2,isQosClearFirst:null==(r=A.localMainVideoTrack)?void 0:r.isQosClearFirst}),this._prevQualityLimitationReason=e.qualityLimitationReason):e.ssrc===c.auxiliary&&!H_(e.qualityLimitationReason)&&0!==e.bytesSent&&this._prevAuxQualityLimitationReason!==e.qualityLimitationReason&&(this._log.info("aux qualityLimitationReason change to ".concat(e.qualityLimitationReason)),tG.emit("263",{userId:A.userId,reason:e.qualityLimitationReason,prevReason:this._prevAuxQualityLimitationReason,streamType:7,isQosClearFirst:null==(s=A.localAuxVideoTrack)?void 0:s.isQosClearFirst}),this._prevAuxQualityLimitationReason=e.qualityLimitationReason)}else a.audio.bytesSent=e.bytesSent,a.audio.packetsSent=e.packetsSent;else if("candidate-pair"===e.type)AL(e)&&(this.totalBytesSent=e.bytesSent,V_(e.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*e.currentRoundTripTime)));else if("media-source"===e.type)if(e.kind===WM.AUDIO)a.audio.audioLevel=e.audioLevel||0,a.audio.totalAudioEnergy=e.totalAudioEnergy||0,e.echoReturnLoss,H_(null==(I=null==(l=null==(g=A.localMainAudioTrack)?void 0:g.sourceTrack)?void 0:l.stats)?void 0:I.deliveredFramesDuration)?e.totalSamplesDuration&&(a.audio.totalSamplesDuration=e.totalSamplesDuration):a.audio.totalSamplesDuration=A.localMainAudioTrack.sourceTrack.stats.deliveredFramesDuration/1e3;else if(e.kind===WM.VIDEO)if(e.trackIdentifier===A.getVideoTrackId(WM.VIDEO))if(null!=(d=null==(E=null==(u=A.localMainVideoTrack)?void 0:u.sourceTrack)?void 0:E.stats)&&d.deliveredFrames){let{deliveredFrames:t}=A.localMainVideoTrack.sourceTrack.stats;a.video.framesCaptured=t,A.localMainVideoTrack.stat.framesCaptured&&A.localMainVideoTrack.stat.framesCaptured>0&&t>=A.localMainVideoTrack.stat.framesCaptured?a.video.fpsCapture=Math.floor((t-A.localMainVideoTrack.stat.framesCaptured)/this.statInterval):a.video.fpsCapture=e.framesPerSecond}else a.video.fpsCapture=e.framesPerSecond;else e.trackIdentifier===A.getVideoTrackId(WM.AUXILIARY)?a.auxiliary.fpsCapture=e.framesPerSecond:a.small.fpsCapture=e.framesPerSecond;if(!H_(e.audioLevel)&&null!=(h=A.localMainAudioTrack)&&h.mediaTrack&&e.trackIdentifier===A.localMainAudioTrack.mediaTrack.id&&(a.audio.audioLevel=e.audioLevel||0),!H_(e.frameWidth)){let t=WM.SMALL;e.trackIdentifier===A.getVideoTrackId(WM.VIDEO)||e.ssrc===c.video?t=WM.VIDEO:(e.trackIdentifier===A.getVideoTrackId(WM.AUXILIARY)||e.ssrc===c.auxiliary)&&(t=WM.AUXILIARY),a[t].frameWidth=e.frameWidth,a[t].frameHeight=e.frameHeight,a[t].framesSent=e.framesSent}}),A.localMainAudioTrack||A.getRoom().capturedLocalMainAudioTrack){let i=A.localMainAudioTrack||A.getRoom().capturedLocalMainAudioTrack;if(i){let o=i.getInternalAudioLevel(),n=i.getInternalAudioLevelAfter3A();a.audio.audioCaptureEnergyAfter3a=n,a.audio.micAudioLevel=o,0===a.audio.audioLevel&&A.localMainAudioTrack&&(a.audio.audioLevel=null!=n?n:o),!A.localMainAudioTrack&&!H_(null==(t=null==(e=i.sourceTrack)?void 0:e.stats)?void 0:t.deliveredFramesDuration)&&(a.audio.totalSamplesDuration=i.sourceTrack.stats.deliveredFramesDuration/1e3)}}if(!A.localMainVideoTrack&&A.getRoom().capturedLocalMainVideoTrack){let e=A.getRoom().capturedLocalMainVideoTrack;if(null!=(o=null==(i=null==e?void 0:e.sourceTrack)?void 0:i.stats)&&o.deliveredFrames){let{deliveredFrames:A}=e.sourceTrack.stats;a.video.framesCaptured=A,e.stat.framesCaptured&&e.stat.framesCaptured>0&&A>=e.stat.framesCaptured&&(a.video.fpsCapture=Math.floor((A-e.stat.framesCaptured)/this.statInterval)),e.stat.framesCaptured=A}}if(!A.localAuxVideoTrack&&A.getRoom().capturedLocalAuxVideoTrack){let e=A.getRoom().capturedLocalAuxVideoTrack;if(null!=(r=null==(n=null==e?void 0:e.sourceTrack)?void 0:n.stats)&&r.deliveredFrames){let{deliveredFrames:A}=e.sourceTrack.stats;a.auxiliary.framesCaptured=A,e.stat.framesCaptured&&e.stat.framesCaptured>0&&A>=e.stat.framesCaptured&&(a.auxiliary.fpsCapture=Math.floor((A-e.stat.framesCaptured)/this.statInterval)),e.stat.framesCaptured=A}}this.totalBytesSent||(this.totalBytesSent+=a.audio.bytesSent+a.video.bytesSent+a.auxiliary.bytesSent),Object.keys(a).forEach(e=>{e===WM.AUDIO?(A.localMainAudioTrack&&(A.localMainAudioTrack.stat=a[e]),A.localAuxAudioTrack&&(A.localAuxAudioTrack.stat=a[e])):e===WM.VIDEO?A.localMainVideoTrack&&(A.localMainVideoTrack.stat=a[e]):e===WM.AUXILIARY&&A.localAuxVideoTrack&&(A.localAuxVideoTrack.stat=a[e])})}catch(l){this._log.warn("failed to getStats on sender connection ".concat(l))}return 0===a.rtt&&(a.rtt=(null==(s=this.room.networkQuality)?void 0:s.uplinkRTT)||0),a})}getReceiverStats(A){return VS(this,null,function*(){var e,t,i;let o={tinyId:A.tinyId,userId:A.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,avSyncDelay:0,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,freezeCount:0,totalFreezesDuration:0,totalJitter:0,totalJitterCount:0,p2pDelay:0,codec:""},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,totalJitter:0,totalJitterCount:0,p2pDelay:0,codec:""}},n=A.getPeerConnection();if(n)try{let{ssrc:i}=A,{muteState:r,subscribeState:s}=A;(this._spcStats||(yield n.getStats())).forEach(e=>{var t,n;if("codec"===e.type&&this._decodeMap.set(e.id,e),"inbound-rtp"===e.type){let a=(e.mediaType||e.kind)===WM.AUDIO;if(a){if(e.ssrc!==i.audio||!r.hasAudio)return;o.audio.packetsReceived=e.packetsReceived,o.audio.bytesReceived=e.bytesReceived,o.audio.packetsLost=e.packetsLost,e.insertedSamplesForDeceleration&&(o.audio.insertedSamplesForDeceleration=e.insertedSamplesForDeceleration),e.removedSamplesForAcceleration&&(o.audio.removedSamplesForAcceleration=e.removedSamplesForAcceleration),e.totalSamplesDuration&&(o.audio.totalSamplesDuration=e.totalSamplesDuration),e.totalSamplesReceived&&(o.audio.totalSamplesReceived=e.totalSamplesReceived),e.concealedSamples&&(o.audio.concealedSamples=e.concealedSamples),e.silentConcealedSamples&&(o.audio.silentConcealedSamples=e.silentConcealedSamples);let{remoteAudioTrack:t}=A;t.stat.packetsReceived=e.packetsReceived,t.stat.bytesReceived=e.bytesReceived,t.stat.packetsLost=e.packetsLost,o.audio.p2pDelay=t.stat.end2EndDelay,o.hasAudio=!0}else{if(dN&&0===e.bytesReceived)return;let a;e.ssrc===i.video&&r.hasVideo&&(o.video.packetsReceived=e.packetsReceived,o.video.bytesReceived=e.bytesReceived,o.video.packetsLost=e.packetsLost,o.video.framesReceived=e.framesReceived,o.video.framesDecoded=e.framesDecoded,o.video.fpsDecoded=e.framesPerSecond,o.hasVideo=!0,A.videoCodec=sk[null==(t=this._decodeMap.get(e.codecId))?void 0:t.mimeType.split("/")[1]]||"h264",o.video.codec=A.videoCodec,a=A.remoteVideoTrack,r.hasSmall&&s.smallVideo&&(o.isSmallSubscribed=!0),e.decoderImplementation&&(!this._prevDecoderImplementationMap.has(o.userId)||this._prevDecoderImplementationMap.get(o.userId)!==e.decoderImplementation)&&(a.log.info("decoderImplementation change to ".concat(e.decoderImplementation,"(").concat(A.videoCodec,") HWDecoder: ").concat(e.powerEfficientDecoder)),tG.emit("262",{userId:this.room.userId,remoteUserId:o.userId,prevImplementation:this._prevDecoderImplementationMap.get(o.userId),implementation:e.decoderImplementation,codec:A.videoCodec,isHWCodec:e.powerEfficientDecoder}),this._prevDecoderImplementationMap.set(o.userId,e.decoderImplementation)),H_(e.keyFramesDecoded)||a.updateKeyFramesDecoded(e.keyFramesDecoded)),e.ssrc===i.auxiliary&&r.hasAuxiliary&&(o.auxiliary.packetsReceived=e.packetsReceived,o.auxiliary.bytesReceived=e.bytesReceived,o.auxiliary.packetsLost=e.packetsLost,o.auxiliary.framesReceived=e.framesReceived,o.auxiliary.framesDecoded=e.framesDecoded,o.auxiliary.fpsDecoded=e.framesPerSecond,a=A.remoteAuxiliaryTrack,o.auxiliary.p2pDelay=a.stat.end2EndDelay,o.hasAuxiliary=!0,o.video.codec=(null==(n=this._decodeMap.get(e.codecId))?void 0:n.mimeType.split("/")[1].toLowerCase())||"h264",H_(e.keyFramesDecoded)||a.updateKeyFramesDecoded(e.keyFramesDecoded)),a&&(a.stat.packetsReceived=e.packetsReceived,a.stat.bytesReceived=e.bytesReceived,a.stat.packetsLost=e.packetsLost,a.stat.framesReceived=e.framesReceived,a.stat.framesDecoded=e.framesDecoded,e.jitterBufferDelay&&(a.stat.jitterBufferDelay=Math.floor(e.jitterBufferDelay/e.jitterBufferEmittedCount*1e3)),o.video.p2pDelay=a.stat.end2EndDelay)}e.jitterBufferDelay&&(a?(o.audio.totalJitter=e.jitterBufferDelay,o.audio.totalJitterCount=e.jitterBufferEmittedCount,o.audio.estimatedPlayoutTimestamp=e.estimatedPlayoutTimestamp):e.ssrc===i.video&&r.hasVideo?(o.video.totalJitter=e.jitterBufferDelay,o.video.totalJitterCount=e.jitterBufferEmittedCount,o.video.estimatedPlayoutTimestamp=e.estimatedPlayoutTimestamp):e.ssrc===i.auxiliary&&r.hasAuxiliary&&(o.auxiliary.totalJitter=e.jitterBufferDelay,o.auxiliary.totalJitterCount=e.jitterBufferEmittedCount))}else"candidate-pair"===e.type&&AL(e)&&(this.totalBytesReceived=e.bytesReceived,V_(e.currentRoundTripTime)&&(o.rtt=Math.floor(1e3*e.currentRoundTripTime)));H_(e.frameWidth)||((e.trackIdentifier===A.getMainStreamVideoTrackId()||e.ssrc===i.video)&&(o.video.frameWidth=e.frameWidth,o.video.frameHeight=e.frameHeight,A.remoteVideoTrack.stat.frameWidth=e.frameWidth,A.remoteVideoTrack.stat.frameHeight=e.frameHeight),(e.trackIdentifier===A.getAuxStreamVideoTrackId()||e.ssrc===i.auxiliary)&&(o.auxiliary.frameWidth=e.frameWidth,o.auxiliary.frameHeight=e.frameHeight,A.remoteAuxiliaryTrack.stat.frameWidth=e.frameWidth,A.remoteAuxiliaryTrack.stat.frameHeight=e.frameHeight)),!H_(e.audioLevel)&&A.muteState.audioAvailable&&A.remoteAudioTrack.mediaTrack&&e.trackIdentifier===A.remoteAudioTrack.mediaTrack.id&&(o.audio.audioLevel=e.audioLevel||0,o.audio.totalAudioEnergy=e.totalAudioEnergy||0)}),0===o.audio.audioLevel&&A.muteState.audioAvailable&&(o.audio.audioLevel=A.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=o.audio.bytesReceived+o.video.bytesReceived+o.auxiliary.bytesReceived),H_(null==(e=A.remoteVideoTrack.player.stat)?void 0:e.fps)||(o.video.fpsRender=A.remoteVideoTrack.player.stat.fps),H_(null==(t=A.remoteAuxiliaryTrack.player.stat)?void 0:t.fps)||(o.auxiliary.fpsRender=A.remoteAuxiliaryTrack.player.stat.fps);let a=o.audio.estimatedPlayoutTimestamp,g=o.video.estimatedPlayoutTimestamp;if(a&&g&&A.remoteAudioTrack.isAvailable&&A.remoteVideoTrack.isAvailable){let A=g-a;Math.abs(A)<=1e4&&(o.avSyncDelay=A,Math.abs(A)>150&&this._log.warn("av sync delay",A))}}catch(r){this._log.warn("failed to getStats on receiver connection ".concat(r))}return 0===o.rtt&&(o.rtt=(null==(i=this.room.networkQuality)?void 0:i.uplinkRTT)||0),o})}getStats(A,e){return VS(this,null,function*(){let t,i={},o=[];if(this.room.singlePC){let A=this.room.singlePC.getPeerConnection();if(!A)return{senderStats:i,receiverStats:o};let e=oT(),t=yield A.getStats(),n=oT();n-e>2e3&&this._log.warn("getStats cost ".concat(n-e,"ms"));let r=[],s=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source","codec","media-playout"]);t.forEach(A=>s.has(A.type)&&r.push(A)),this._spcStats=r}A&&(i=yield this.getSenderStats(A));for(let[A,n]of e){let A=yield this.getReceiverStats(n);A&&o.push(A)}return e.size&&(t=this.getMediaPlayoutStats(this._spcStats)),{senderStats:i,receiverStats:o,mediaPlayoutStats:t}})}getDifferenceValue(A,e){if(NF(A))return e;let t=e-A;return t<0?0:t}prepareReport(A){let{stats:e,report:t,freezeMap:i,uplinkConnection:o}=A;var n,r,s,a,g,c,l,I,u;if(!NF(e.senderStats)){let A={uint32_audio_level:e.senderStats.audio.audioLevel*ik,uint32_audio_energy:1e6*(e.senderStats.audio.totalAudioEnergy||0),uint32_audio_codec_bitrate:e.senderStats.audio.bytesSent};e.senderStats.audio.micAudioLevel&&(A.uint32_mic_audio_level=e.senderStats.audio.micAudioLevel*ik),H_(e.senderStats.audio.audioCaptureEnergyAfter3a)||(A.uint32_audio_capture_energy_after3a=e.senderStats.audio.audioCaptureEnergyAfter3a*ik),e.senderStats.audio.totalSamplesDuration&&(t.msg_device_info.uint32_audio_capture_cost=e.senderStats.audio.totalSamplesDuration);let i=[];if(e.senderStats.video.bytesSent){let A={uint32_video_stream_type:2,uint32_video_codec_fps:e.senderStats.video.framesSent,uint32_video_capture_fps:e.senderStats.video.fpsCapture,uint32_video_width:e.senderStats.video.frameWidth,uint32_video_height:e.senderStats.video.frameHeight,uint32_video_codec_bitrate:e.senderStats.video.bytesSent,uint32_video_enc_fps:e.senderStats.video.framesEncoded,uint32_key_frame_count:e.senderStats.video.keyFramesEncoded,uint32_nack_count:e.senderStats.video.nackCount,uint32_pli_count:e.senderStats.video.pliCount,uint32_encode_cost:1e3*(e.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(e.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:e.senderStats.video.retransmittedPacketsSent};i.push(A)}if(e.senderStats.small.bytesSent){let A={uint32_video_stream_type:3,uint32_video_codec_fps:e.senderStats.small.framesSent||0,uint32_video_capture_fps:e.senderStats.small.fpsCapture||0,uint32_video_width:e.senderStats.small.frameWidth||0,uint32_video_height:e.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:e.senderStats.small.bytesSent,uint32_video_enc_fps:e.senderStats.small.framesEncoded||0,uint32_key_frame_count:e.senderStats.small.keyFramesEncoded,uint32_nack_count:e.senderStats.small.nackCount,uint32_pli_count:e.senderStats.small.pliCount,uint32_encode_cost:1e3*(e.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(e.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:e.senderStats.small.retransmittedPacketsSent};i.push(A)}if(e.senderStats.auxiliary.bytesSent){let A={uint32_video_stream_type:7,uint32_video_codec_fps:e.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:e.senderStats.auxiliary.fpsCapture||0,uint32_video_width:e.senderStats.auxiliary.frameWidth||0,uint32_video_height:e.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:e.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:e.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:e.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:e.senderStats.auxiliary.nackCount,uint32_pli_count:e.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(e.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(e.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:e.senderStats.auxiliary.retransmittedPacketsSent};i.push(A)}let o={uint32_bitrate:0,uint32_lost:0,uint32_rtt:e.senderStats.rtt};t.msg_up_stream_info={msg_audio_status:A,msg_video_status:i,msg_network_status:o}}let{statInterval:E}=this;t.msg_down_stream_info=[],e.receiverStats.forEach(A=>{let e={msg_user_info:{str_identifier:A.userId,uint64_tinyid:A.tinyId},msg_network_status:{uint32_rtt:A.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(A.hasAudio){let t={uint32_audio_p2p_delay:A.audio.p2pDelay,uint32_audio_cache_ms:A.audio.totalJitter,uint32_audio_cache_ms_count:A.audio.totalJitterCount,uint32_audio_codec_bitrate:A.audio.bytesReceived,uint32_audio_total_bitrate:A.audio.bytesReceived,uint32_audio_level:1e8*A.audio.audioLevel,uint32_audio_energy:1e6*A.audio.totalAudioEnergy,uint32_audio_receive:A.audio.packetsReceived,uint32_audio_origin_lost:A.audio.packetsLost};e.msg_audio_status=t}if(A.hasVideo){let t=i.get("".concat(A.userId,"_").concat(cR)),o=t?t.duration:0,n={uint32_video_stream_type:A.isSmallSubscribed?3:2,uint32_video_receive_fps:A.video.framesReceived,uint32_video_width:A.video.frameWidth,uint32_video_height:A.video.frameHeight,uint32_video_codec_bitrate:A.video.bytesReceived,uint32_video_receive:A.video.packetsReceived,uint32_video_origin_lost:A.video.packetsLost,uint32_video_block_time:o,uint32_video_dec_fps:A.video.framesDecoded,uint32_video_codec_fps:A.video.fpsRender,uint32_video_cache_ms:A.video.totalJitter,uint32_video_cache_ms_count:A.video.totalJitterCount,uint32_video_p2p_delay:A.video.p2pDelay,uint32_video_codec:A.video.codec,int32_video_audio_relative_delay:A.avSyncDelay+5e3};e.msg_video_status.push(n)}if(A.hasAuxiliary){let t=i.get("".concat(A.userId,"_").concat(lR)),o=t?t.duration:0,n={uint32_video_stream_type:7,uint32_video_receive_fps:A.auxiliary.framesReceived,uint32_video_width:A.auxiliary.frameWidth,uint32_video_height:A.auxiliary.frameHeight,uint32_video_codec_bitrate:A.auxiliary.bytesReceived,uint32_video_receive:A.auxiliary.packetsReceived+A.auxiliary.packetsLost,uint32_video_origin_lost:A.auxiliary.packetsLost,uint32_video_block_time:o,uint32_video_dec_fps:A.auxiliary.framesDecoded,uint32_video_codec_fps:A.video.fpsRender,uint32_video_cache_ms:A.auxiliary.totalJitter,uint32_video_cache_ms_count:A.auxiliary.totalJitterCount,uint32_video_p2p_delay:A.auxiliary.p2pDelay,uint32_video_codec:A.video.codec};e.msg_video_status.push(n)}t.msg_down_stream_info.push(e)}),e.mediaPlayoutStats&&!NF(e.mediaPlayoutStats)&&(e.mediaPlayoutStats.synthesizedSamplesDuration*=1e3,e.mediaPlayoutStats.totalSamplesDuration*=1e3);let d=this._prevReport,h=this._prevStats;if(this._prevReport=JSON.parse(JSON.stringify(t)),this._prevStats=JSON.parse(JSON.stringify(e)),t.msg_up_stream_info.msg_audio_status&&d.msg_up_stream_info.msg_audio_status){let A=d.msg_up_stream_info.msg_audio_status,i=t.msg_up_stream_info.msg_audio_status;if(0===A.uint32_audio_codec_bitrate)i.uint32_audio_codec_bitrate=0;else{let e=this.getDifferenceValue(A.uint32_audio_codec_bitrate,i.uint32_audio_codec_bitrate);i.uint32_audio_codec_bitrate=Math.round(8*e/E),t.msg_up_stream_info.msg_network_status.uint32_bitrate+=i.uint32_audio_codec_bitrate}null!=(n=d.msg_device_info)&&n.uint32_audio_capture_cost?(t.msg_device_info.uint32_audio_capture_cost=2*Math.floor(1e3*this.getDifferenceValue(d.msg_device_info.uint32_audio_capture_cost,t.msg_device_info.uint32_audio_capture_cost)/E),t.msg_device_info.uint32_audio_capture_cost>0&&(null==(s=null==o?void 0:o.localMainAudioTrack)||s.updateAfter3aSilenceStartTime(null!=(r=e.senderStats.audio.audioCaptureEnergyAfter3a)?r:e.senderStats.audio.micAudioLevel))):delete t.msg_device_info.uint32_audio_capture_cost}let C=d.msg_up_stream_info.msg_video_status;t.msg_up_stream_info.msg_video_status.forEach(A=>{let e=C.find(e=>e.uint32_video_stream_type===A.uint32_video_stream_type);if(!e||0===e.uint32_video_codec_bitrate)return A.uint32_video_codec_bitrate=0,A.uint32_video_enc_fps=0,void(A.uint32_video_codec_fps=0);let i=0,o=0,n=0;e&&A.uint32_video_codec_bitrate>=e.uint32_video_codec_bitrate&&(i=e.uint32_video_codec_bitrate,o=e.uint32_video_enc_fps,n=e.uint32_video_codec_fps);let r=this.getDifferenceValue(i,A.uint32_video_codec_bitrate);A.uint32_video_codec_bitrate=Math.round(8*r/E),t.msg_up_stream_info.msg_network_status.uint32_bitrate+=A.uint32_video_codec_bitrate,A.uint32_video_enc_fps=Math.round(this.getDifferenceValue(o,A.uint32_video_enc_fps)/E),A.uint32_video_codec_fps=Math.round(this.getDifferenceValue(n,A.uint32_video_codec_fps)/E),0===e.uint32_video_width&&0===e.uint32_video_height&&0===e.uint32_video_codec_fps&&(A.uint32_video_codec_fps=A.uint32_video_enc_fps),H_(e.uint32_key_frame_count)||(A.uint32_key_frame_count=Math.round(this.getDifferenceValue(e.uint32_key_frame_count,A.uint32_key_frame_count))),H_(e.uint32_nack_count)||(A.uint32_nack_count=Math.round(this.getDifferenceValue(e.uint32_nack_count,A.uint32_nack_count))),H_(e.uint32_pli_count)||(A.uint32_pli_count=Math.round(this.getDifferenceValue(e.uint32_pli_count,A.uint32_pli_count))),H_(e.uint32_video_arq_packets)||(A.uint32_video_arq_packets=Math.round(this.getDifferenceValue(e.uint32_video_arq_packets,A.uint32_video_arq_packets))),H_(e.uint32_encode_cost)||(A.uint32_encode_cost=Math.round(this.getDifferenceValue(e.uint32_encode_cost,A.uint32_encode_cost)/E)),H_(e.uint32_send_packet_cost)||(A.uint32_send_packet_cost=Math.round(this.getDifferenceValue(e.uint32_send_packet_cost,A.uint32_send_packet_cost)/E))});let B=d.msg_down_stream_info;t.msg_down_stream_info=t.msg_down_stream_info.filter(A=>B.find(e=>e.msg_user_info.uint64_tinyid===A.msg_user_info.uint64_tinyid));let Q=t.msg_down_stream_info;if(Q.forEach(A=>{let e=B.find(e=>e.msg_user_info.uint64_tinyid===A.msg_user_info.uint64_tinyid);if(NF(A.msg_audio_status)||NF(e.msg_audio_status))A.msg_audio_status={};else{let t=A.msg_audio_status,i=e.msg_audio_status,o=this.getDifferenceValue(i.uint32_audio_cache_ms_count,t.uint32_audio_cache_ms_count);delete t.uint32_audio_cache_ms_count,t.uint32_audio_cache_ms=Math.floor(1e3*this.getDifferenceValue(i.uint32_audio_cache_ms,t.uint32_audio_cache_ms)/o)||0;let n=this.room.remotePublishedUserMap.get(A.msg_user_info.str_identifier);n&&(n.remoteAudioTrack.stat.jitterBufferDelay=t.uint32_audio_cache_ms),t.uint32_audio_origin_lost=this.getDifferenceValue(i.uint32_audio_origin_lost,t.uint32_audio_origin_lost),t.uint32_audio_receive=this.getDifferenceValue(i.uint32_audio_receive,t.uint32_audio_receive),t.uint32_audio_receive+=t.uint32_audio_origin_lost;let r=this.getDifferenceValue(i.uint32_audio_codec_bitrate,t.uint32_audio_codec_bitrate);t.uint32_audio_codec_bitrate=Math.round(8*r/E),t.uint32_audio_total_bitrate=Math.round(8*r/E)}if(A.msg_video_status&&e.msg_video_status){let t=e.msg_video_status;A.msg_video_status=A.msg_video_status.filter(A=>t.find(e=>e.uint32_video_stream_type===A.uint32_video_stream_type)),A.msg_video_status.forEach(A=>{let e=t.find(e=>e.uint32_video_stream_type===A.uint32_video_stream_type),i=e.uint32_video_receive,o=e.uint32_video_origin_lost,n=e.uint32_video_codec_bitrate,r=e.uint32_video_receive_fps,s=e.uint32_video_dec_fps;A.uint32_video_origin_lost=this.getDifferenceValue(o,A.uint32_video_origin_lost),A.uint32_video_receive=this.getDifferenceValue(i,A.uint32_video_receive)+A.uint32_video_origin_lost;let a=this.getDifferenceValue(n,A.uint32_video_codec_bitrate);A.uint32_video_codec_bitrate=Math.round(8*a/E);let g=this.getDifferenceValue(r,A.uint32_video_receive_fps);A.uint32_video_receive_fps=Math.round(g/E),A.uint32_video_dec_fps=Math.round(this.getDifferenceValue(s,A.uint32_video_dec_fps)/E);let c=this.getDifferenceValue(e.uint32_video_cache_ms_count,A.uint32_video_cache_ms_count);delete A.uint32_video_cache_ms_count,A.uint32_video_cache_ms=Math.floor(1e3*this.getDifferenceValue(e.uint32_video_cache_ms,A.uint32_video_cache_ms)/c)||0})}}),!H_(null==(a=null==h?void 0:h.mediaPlayoutStats)?void 0:a.totalSamplesDuration)&&!H_(null==(g=e.mediaPlayoutStats)?void 0:g.totalSamplesDuration)){let A=2*Math.floor(this.getDifferenceValue(null==(c=null==h?void 0:h.mediaPlayoutStats)?void 0:c.synthesizedSamplesDuration,null==(l=e.mediaPlayoutStats)?void 0:l.synthesizedSamplesDuration)/E),i=2*Math.floor(this.getDifferenceValue(null==(I=null==h?void 0:h.mediaPlayoutStats)?void 0:I.totalSamplesDuration,null==(u=e.mediaPlayoutStats)?void 0:u.totalSamplesDuration)/E);t.msg_device_info.uint32_audio_play_cost=i-A}return h&&e.receiverStats.forEach(A=>{if(A.audio.concealedSamples&&A.audio.totalSamplesReceived){let e=h.receiverStats.find(e=>e.userId===A.userId);if(e&&e.audio.concealedSamples&&e.audio.totalSamplesReceived){let t=(A.audio.silentConcealedSamples||0)-(e.audio.silentConcealedSamples||0),i=A.audio.concealedSamples-e.audio.concealedSamples,o=A.audio.totalSamplesReceived-e.audio.totalSamplesReceived,n=Math.floor((i-t)/o*1e3*E);if(n>1e3*E/5){let e=Q.find(e=>e.msg_user_info.str_identifier===A.userId);e&&(e.msg_audio_status.uint32_audio_block_time=n)}}}}),t.msg_down_stream_info.forEach(A=>{A.msg_video_status.forEach(A=>{0===A.uint32_video_codec_bitrate&&0===A.uint32_video_receive_fps&&(A.uint32_video_width=0,A.uint32_video_height=0)})}),t}getStatsReport(A){return VS(this,arguments,function(A){var e=this;let{uplinkConnection:t,downlinkConnections:i,freezeMap:o}=A;return function*(){let A={msg_device_info:{},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_capture_energy_after3a:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_cache_ms:0,uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0,uint32_video_codec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},n=yield e.getStats(t,i);return"{}"===JSON.stringify(e._prevReport)&&(e._prevReport=JSON.parse(JSON.stringify(A))),e.prepareReport({stats:n,report:A,freezeMap:o,uplinkConnection:t}),e._prevReportTime=Date.now(),A}()})}getMediaPlayoutStats(A){let e;if(W_(A)){for(let t of A)if("media-playout"===t.type){let{synthesizedSamplesDuration:A,totalSamplesDuration:i}=t;e={synthesizedSamplesDuration:A,totalSamplesDuration:i};break}return e}}reset(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map,[this.room.localMainVideoTrack,this.room.capturedLocalMainVideoTrack,this.room.localAuxVideoTrack,this.room.capturedLocalAuxVideoTrack].forEach(A=>{null!=A&&A.stat&&(A.stat.framesCaptured=0)})}},bq=YS(jS());function Gq(A){return new Promise(e=>VS(null,null,function*(){let t=setTimeout(()=>{e({totalCost:1e4,local:0,dns:0,tcp:0,tls:0,request:0,response:0})},1e4),i=Date.now(),o="https://".concat(A,"/?t=").concat(i);try{yield fetch(o)}catch(r){}clearTimeout(t);let n=function(A){let e={totalCost:0,local:0,redirect:0,httpCache:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let t=performance.getEntriesByType("resource").reverse();for(let i of t)if(i.name===A){let A=Math.round(i.duration),t=Math.max(Math.round(i.domainLookupStart-i.startTime),0),o=i.redirectStart>0?Math.max(Math.round(i.redirectEnd-i.redirectStart),0):0,n=i.fetchStart>0?Math.max(Math.round(i.domainLookupStart-i.fetchStart),0):0,r=Math.round(i.domainLookupEnd-i.domainLookupStart),s=Math.round(i.requestStart-i.secureConnectionStart),a=Math.round(i.secureConnectionStart-i.connectStart),g=Math.round(i.responseStart-i.requestStart),c=Math.round(i.responseEnd-(i.responseStart||i.startTime));e=FS(US({},e),{totalCost:A,local:t,redirect:o,httpCache:n,dns:r,tcp:a,tls:s,request:g,response:c});break}}catch(t){}return e}(o);0===n.totalCost&&(n.totalCost=Date.now()-i),e(n)}))}var kq=class A extends bq.default{constructor(A){let{signalChannel:e,room:t}=A;super(),HS(this,"_room"),HS(this,"_signalChannel"),HS(this,"_log"),HS(this,"uplinkRTT",0),HS(this,"uplinkLoss",0),HS(this,"downlinkRTT",0),HS(this,"downlinkLoss",0),HS(this,"pingResults",{}),HS(this,"_downlinkPrevStatMap",new Map),HS(this,"_downlinkLossAndRTTMap",new Map),HS(this,"_interval",-1),HS(this,"_uplinkNetworkQuality",0),HS(this,"_downlinkNetworkQuality",0),HS(this,"_uplinkQualityHistory",[]),HS(this,"_downlinkQualityHistory",[]),this._room=t,this._signalChannel=e,this._log=sG.createLogger({parent:t.getLogger(),id:"q",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.initialize()}get uplinkNetworkQuality(){return this._uplinkNetworkQuality}set uplinkNetworkQuality(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this.uplinkRTT,", loss: ").concat(this.uplinkLoss," ws-rtt: ").concat(this._signalChannel.rtt)),this._uplinkNetworkQuality=e,this._uplinkQualityHistory.push(e),this._uplinkQualityHistory.length>A.HISTORY_SIZE&&this._uplinkQualityHistory.shift()}get downlinkNetworkQuality(){return this._downlinkNetworkQuality}set downlinkNetworkQuality(e){if(e!==this._downlinkNetworkQuality){let{rtt:A,loss:t}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(A,", loss: ").concat(t," ws-rtt: ").concat(this._signalChannel.rtt))}this._downlinkNetworkQuality=e,this._downlinkQualityHistory.push(e),this._downlinkQualityHistory.length>A.HISTORY_SIZE&&this._downlinkQualityHistory.shift()}initialize(){this._signalChannel.on(LH.UPLINK_NETWORK_STATS,A=>{this.handleUplinkNetworkQuality(A)}),this._signalChannel.on(SH,this.handleSignalConnectionStateChange.bind(this)),this.start()}handleUplinkNetworkQuality(A){var e,t;if(0!==A.data.code)return;let i=A.data.data;if(i.delay&&this.updateDelay(i.delay),this._room.signalChannel&&i.wsRtt&&(this._room.signalChannel.rtt=i.wsRtt),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this.uplinkLoss=0,void(this.uplinkRTT=0);let o=null==(t=null==(e=this._room)?void 0:e.uplinkConnection)?void 0:t.getPeerConnection();if(o&&this.isPeerConnectionDisconnected(o))return this.uplinkNetworkQuality=6,this.uplinkLoss=0,void(this.uplinkRTT=0);let n=i.expectAudPkg+i.expectVidPkg,r=i.recvAudPkg+i.recvVidPkg,s=n-r;0===n&&0===r||(this.uplinkLoss=s<=0?0:Math.round(s/n*100),this.uplinkRTT=i.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss,this.uplinkRTT))}handleDownlinkNetworkQuality(){return VS(this,null,function*(){if(0===this._room.remotePublishedUserMap.size)return void(this.downlinkNetworkQuality=0);let A=[...this._room.remotePublishedUserMap.values()],e=A.filter(A=>{var e;return(null==(e=A.getPeerConnection())?void 0:e.connectionState)===pR.CONNECTED});if(A.filter(A=>this.isPeerConnectionDisconnected(A.getPeerConnection())).length===A.length)return void(this.downlinkNetworkQuality=6);for(let o=0;o{this.isPeerConnectionDisconnected(A)&&(this._downlinkPrevStatMap.delete(A),this._downlinkLossAndRTTMap.delete(A))}),0===this._downlinkLossAndRTTMap.size)return this.downlinkRTT=0,this.downlinkLoss=0,void(this.downlinkNetworkQuality=0);let{rtt:t,loss:i}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this.downlinkRTT=t,this.downlinkLoss=i,this.downlinkNetworkQuality=this.getNetworkQuality(i,t)})}getStat(A){return VS(this,null,function*(){let e={rtt:0,totalPacketsLost:0,totalPacketsReceived:0};if(!A||!gL())return e;let t=A.getReceivers();try{for(let A=0;A{"candidate-pair"===A.type&&V_(A.currentRoundTripTime)&&(e.rtt=Math.round(1e3*A.currentRoundTripTime)),"inbound-rtp"===A.type&&(A.mediaType===WM.AUDIO||A.mediaType===WM.VIDEO)&&(e.totalPacketsLost+=A.packetsLost,e.totalPacketsReceived+=A.packetsReceived)});return 0===e.rtt&&(e.rtt=this.uplinkRTT),e}catch(i){return e}})}getAverageLossAndRTT(A){let e={rtt:0,loss:0};return Array.isArray(A)&&A.length>0&&(A.forEach(A=>{e.rtt+=A.rtt,e.loss+=A.loss}),Object.keys(e).forEach(t=>{e[t]=Math.round(e[t]/A.length)})),e}getNetworkQuality(A,e){return A>50||e>500?5:A>30||e>350?4:A>20||e>200?3:A>10||e>100?2:A>=0||e>=0?1:0}handleSignalConnectionStateChange(A){"DISCONNECTED"===A.state?(this.uplinkRTT=0,this.uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===A.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}handleUplinkConnectionStateChange(A){let{state:e}=A;"DISCONNECTED"===e?(this.uplinkLoss=0,this.uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===e&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}isPeerConnectionDisconnected(A){return!(!A||A.connectionState!==pR.DISCONNECTED&&A.connectionState!==pR.FAILED&&A.connectionState!==pR.CLOSED)}setUplinkConnection(A){this._room.uplinkConnection=A,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT=0,this.uplinkLoss=0)}start(){-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=iU.run("ric",()=>{var e;this.handleDownlinkNetworkQuality();let t=[...this._downlinkLossAndRTTMap.values()];tG.emit(oG.NETWORK_QUALITY,{room:this._room,uplink:{rtt:this.uplinkRTT,loss:this.uplinkLoss},downlinks:t});let i=null==(e=this._room.scheduleResult.config)?void 0:e.pingDomainInfo,o={uplinkNetworkQuality:this.uplinkNetworkQuality,downlinkNetworkQuality:this.downlinkNetworkQuality,uplinkRTT:this.uplinkRTT,uplinkLoss:this.uplinkLoss,downlinkRTT:this.downlinkRTT,downlinkLoss:this.downlinkLoss};i&&(o=FS(US({},o),{pingResults:this.uplinkRTT>i.rttThreshold||this.downlinkRTT>i.rttThreshold?this.pingResults:{}})),this.emit(A.EVENT_NETWORK_QUALITY,o);let n=Date.now();if(i&&(this.uplinkRTT>i.rttThreshold||this.downlinkRTT>i.rttThreshold)&&n-A.lastPingTime>1e3*i.interval){A.lastPingTime=Date.now();let e=i.domain.map(A=>Gq(A).then(e=>({domain:A,cost:e.totalCost})));Promise.all(e).then(A=>{this.pingResults.isPoorNetwork=A.some(A=>A.cost>700),this.pingResults.timestamp=n,this.pingResults.data=A,A.forEach(A=>{Gk.addSuccessEvent({key:521718,cost:A.cost})}),this._log.warn("All ping results: ".concat(JSON.stringify(A)))}).catch(A=>{this._log.warn("Error during pinging domains: ".concat(A))})}},{delay:2e3})):this._log.info("network quality calculating is already started")}hadRecentBadUplink(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;return this._uplinkQualityHistory.some(e=>e>A)}hadRecentBadDownlink(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;return this._downlinkQualityHistory.some(e=>e>A)}stop(){this._log.debug("stopped"),-1!==this._interval&&(iU.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}updateDelay(A){let{tinyIdToUserIdMap:e}=this._room;A.forEach(A=>{let{srcTinyId:t,videoDelay:i,audioDelay:o}=A,n=e.get(t);if(n){let A=this._room.remotePublishedUserMap.get(n);null==A||A.setDelay({videoDelay:i,audioDelay:o})}})}};HS(kq,"HISTORY_SIZE",10),HS(kq,"EVENT_NETWORK_QUALITY","0"),HS(kq,"lastPingTime",0);var Lq=kq,Uq=class{constructor(A){HS(this,"_frameWorkType"),HS(this,"_component"),HS(this,"_language"),HS(this,"connectionType"),HS(this,"_room"),HS(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,reportToken:void 0}),HS(this,"_keyPrefix"),HS(this,"_log"),HS(this,"_intervalId"),HS(this,"_firstPublishedUserList"),HS(this,"_networkQuality"),HS(this,"_basicInfo"),HS(this,"_pathJoinRoom"),HS(this,"_pathLeaveRoom"),HS(this,"_pathMainVideoMap"),HS(this,"_pathMainAudioMap"),HS(this,"_pathAuxiliaryMap"),HS(this,"_remoteStreamStatMap"),HS(this,"_localStreamStat"),HS(this,"_eventMap",new Map),HS(this,"_captureCostSum",0),HS(this,"_captureCostCount",0),HS(this,"isDestroyed",!1),this._frameWorkType=A.frameWorkType||30,this._component=A.component||0,this.connectionType=A.connectionType||1,this._language=A.language||0,this._room=A.room,this._keyPrefix="key_point",this._log=sG.createLogger({parent:this._room.getLogger(),id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach(A=>{A.startsWith("handle")&&J_(this[A])&&(this[A]=function(A){let{fn:e,context:t}=A;return function(){try{for(var A=arguments.length,i=new Array(A),o=0;osG.error("".concat(e.name,"() error observed ").concat(A))):n}catch(n){sG.error("".concat(e.name,"() error observed ").concat(n))}}}({fn:this[A],context:this}))}),this.initData(),this.installEvents()}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:CM,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0,uint32_audio_capture_thread_health_zero_cnt:0,uint32_after3a_silence_duration:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,xb().then(()=>{this._basicInfo.string_os_version=Xb(),this._basicInfo.string_device_name=Vb()||this._basicInfo.string_os_version})}addEvent(A,e){return this._eventMap.set(A,e),tG.on(A,e),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})),this.addEvent(oG.JOIN_START,this.handleJoinStart).addEvent(oG.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(oG.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(oG.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(oG.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(oG.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(oG.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(oG.JOIN_FAILED,this.handleJoinFailed).addEvent(oG.LEAVE_START,this.handleLeaveStart).addEvent(oG.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(oG.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(oG.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(oG.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(oG.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(oG.PUBLISH_START,this.handlePublishStart).addEvent(oG.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(oG.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(oG.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(oG.PLAY_TRACK_START,this.handlePlayStart).addEvent(oG.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(oG.PLAYER_STATE_CHANGED,A=>{let{track:e,state:t,type:i}=A;!e.isRemote||!this.hitTest(e.room)||"PLAYING"===t&&(i===WM.AUDIO?this.handleAudioPlaying(e):this.handleVideoPlaying(e))}).addEvent(oG.SWITCH_ROOM_START,this.handleSwitchRoomStart).addEvent(oG.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess).addEvent(oG.SWITCH_ROOM_FAILED,this.handleSwitchRoomFailed).addEvent(oG.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(oG.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(oG.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(oG.REMOTE_PUBLISH_STATE_CHANGED,A=>{let{room:e,prevMuteState:t,muteState:i}=A;if(!this.hitTest(e))return;let o=t.hasAudio||t.hasVideo||t.hasSmall,n=t.hasAuxiliary,r=i.hasAudio||i.hasVideo||i.hasSmall,s=i.hasAuxiliary;!o&&r&&this.handleRemoteStreamAdded(i.userId,"main"),!n&&s&&this.handleRemoteStreamAdded(i.userId,"auxiliary")}).addEvent(oG.SINGLE_CONNECTION_STAT,A=>{let{room:e,stat:t}=A;this.hitTest(e)&&(this._pathJoinRoom.int32_ice_cost=t.ice,this._pathJoinRoom.int32_dtls_cost=t.dtls,this._pathJoinRoom.int32_peer_connection_cost=t.peerConnection)})}uninstallEvents(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach((A,e)=>tG.off(e,A)),this._eventMap.clear()}destroy(){this.uninstallEvents(),iU.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(A){this.hitTest(A.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),A.params&&(H_(A.params.frameWorkType)||(this._frameWorkType=A.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),H_(A.params.component)||(this._component=A.params.component,this._basicInfo.uint32_component=this._component),H_(A.params.language)||(this._language=A.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(A){let{room:e,detailCost:t}=A;if(this.hitTest(e)&&t){let{totalCost:A,local:e,dns:i,tcp:o,tls:n,request:r,response:s}=t;this._pathJoinRoom.int32_schedule_cost=A,this._pathJoinRoom.int32_schedule_local=e,this._pathJoinRoom.int32_schedule_dns=i,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=n,this._pathJoinRoom.int32_schedule_request=r,this._pathJoinRoom.int32_schedule_response=s}}handleSignalConnectionStart(A){let{room:e}=A;this.hitTest(e)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(A){let{room:e,error:t}=A;this.hitTest(e)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),t&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=t instanceof rM?Number(t.getExtraCode()||t.getCode()):oM.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(A){this.hitTest(A.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(A){this.hitTest(A.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=A.code,0!==A.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(A){this.hitTest(A.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=A.room.getSignalInfo())}handleJoinFailed(A){let{room:e,error:t}=A;this.hitTest(e)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=t.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout(()=>{this.report()}))}handleReceivedPublishUserList(A){this.hitTest(A.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=A.publishedUserList||[])}handleSendFirstVideoFrame(A){let{room:e}=A;this.hitTest(e)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(A){this.hitTest(A.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(A){var e;if(this.hitTest(A.room)&&0===this._pathLeaveRoom.uint64_end_time){if(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time){this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time;let A=null==(e=this._room.audioManager.localAudioTrack)?void 0:e.after3aSilenceStartTime;A&&(this._localStreamStat.statsToReport.uint32_after3a_silence_duration=oT()-A)}else this._log.warn("pathJoinRoom endTime is 0");this.report()}}handleLeaveSendCMD(A){this.hitTest(A.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleSwitchRoomStart(A){if(this.hitTest(A.room)){let A=Date.now();this.report().then(()=>{this._pathJoinRoom.uint64_start_time=A,this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=A})}}handleSwitchRoomSuccess(A){let{room:e}=A;if(this.hitTest(e)&&0===this._pathJoinRoom.uint64_end_time){let A=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=A,this._pathJoinRoom.uint64_end_time=A,this._pathJoinRoom.int32_end_ret}}handleSwitchRoomFailed(A){let{room:e,error:t}=A;if(this.hitTest(e)){let A=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=A,this._pathJoinRoom.uint64_end_time=A,t&&(this._pathJoinRoom.int32_end_ret=t instanceof rM?Number(t.getExtraCode()||t.getCode()):oM.UNKNOWN)}}handleRemoteStreamAdded(A,e){var t;let i="".concat(A,"_").concat(e);if(!this._remoteStreamStatMap.has(i)){let o={userId:A,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:FS(US({},Oq),{msg_user_info:new xq({userId:A,tinyId:null==(t=this._room.remotePublishedUserMap.get(A))?void 0:t.tinyId,role:20})})};o.statsToReport.uint32_stream_type="main"===e?2:7,this._remoteStreamStatMap.set(i,o)}}handleSubscribeStart(A){let{room:e,remotePublishedUser:t,streamType:i,subscribeState:o}=A;if(!this.hitTest(e))return;let{userId:n,tinyId:r,role:s}=t,a=new xq({userId:n,tinyId:r,role:"anchor"===s?20:21}),g=Date.now(),c="".concat(n,"_").concat(i),l=this._remoteStreamStatMap.get(c);l&&0===l.subscribeStartTime&&(l.subscribeStartTime=g),"main"===i?(t.muteState.hasVideo&&(o.video||o.smallVideo)&&!this._pathMainVideoMap.has(c)&&this._pathMainVideoMap.set(c,{statsToReport:{msg_user_info:a,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:n,sendSubscribeCMDTime:g}),t.muteState.hasAudio&&o.audio&&!this._pathMainAudioMap.has(c)&&this._pathMainAudioMap.set(c,{statsToReport:{msg_user_info:a,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:n,sendSubscribeCMDTime:g})):t.muteState.hasAuxiliary&&o.auxiliary&&!this._pathAuxiliaryMap.has(c)&&this._pathAuxiliaryMap.set(c,{sendSubscribeCMDTime:g})}handleSubscribed(A){let{room:e,remotePublishedUser:t,streamType:i}=A;if(this.hitTest(e)){let A="".concat(t.userId,"_").concat(i),e=this._remoteStreamStatMap.get(A);e&&0===e.subscribedTime&&(e.subscribedTime=Date.now())}}handlePlayStart(A){let{track:e}=A;if(!e.isRemote||!this.hitTest(e.room))return;let t="".concat(e.userId,"_").concat(e.streamType),i=this._remoteStreamStatMap.get(t);0===(null==i?void 0:i.playStreamTime)&&(i.playStreamTime=Date.now())}handleVideoLoadedData(A){let{track:e}=A;if(!e.isRemote||!this.hitTest(e.room))return;let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainVideoMap.get(t);i&&0===i.statsToReport.uint64_combine_first_frame_time&&(i.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(A){let e="".concat(A.userId,"_").concat(A.streamType),t=Date.now(),i=this._pathMainVideoMap.get(e),o=this._remoteStreamStatMap.get(e);if(o){let{statsToReport:e}=o;if(e.uint32_video_render_first||"main"!==A.streamType?this.hasAuxFlag(A.userId):this.hasVideoFlag(A.userId)){let A=t-this._pathJoinRoom.uint64_start_time;e.uint32_video_render_first=A,Gk.addNumber({key:516820,value:A})}}0===(null==i?void 0:i.statsToReport.uint64_render_first_frame_time)&&(i.statsToReport.uint64_render_first_frame_time=t)}handleAudioPlaying(A){let e="".concat(A.userId,"_").concat(A.streamType),t=this._pathMainAudioMap.get(e);t&&0===t.statsToReport.uint64_play_first_frame_time&&(t.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(A){this.hitTest(A.room)&&(this._networkQuality.totalUplinkLoss+=A.uplink.loss,this._networkQuality.totalUplinkRTT+=A.uplink.rtt,this._networkQuality.count++,A.downlinks.forEach(A=>{let{rtt:e,loss:t,userId:i,videoDelay:o,audioDelay:n}=A,r=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(r)r.totalRTT+=e,r.totalLoss+=t,o&&(r.totalVideoDelay=(r.totalVideoDelay||0)+o,r.videoDelayCount=(r.videoDelayCount||0)+1),n&&(r.totalAudioDelay=(r.totalAudioDelay||0)+n,r.audioDelayCount=(r.audioDelayCount||0)+1),r.count++;else{let A,r,s,a;o&&(r=o,s=1),n&&(A=n,a=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(i,{totalRTT:e,totalLoss:t,count:1,totalAudioDelay:A,totalVideoDelay:r,audioDelayCount:a,videoDelayCount:s})}}))}handleHeartbeatStats(A){var e;if(this.hitTest(A.room)){let{msg_device_info:t,msg_up_stream_info:i,msg_down_stream_info:o}=A.report;if(i.msg_video_status[0]){let{uint32_video_codec_bitrate:A,uint32_video_enc_fps:e,uint32_video_width:t,uint32_video_height:o}=i.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=A,this._localStreamStat.totalVideoFPS+=e,this._localStreamStat.totalVideoWidth+=t,this._localStreamStat.totalVideoHeight+=o,this._localStreamStat.videoCount++}if(i.msg_audio_status){let{uint32_audio_level:A}=i.msg_audio_status;Math.floor(A/ik*100)>0&&(this._localStreamStat.totalAudioLevel+=A/ik,this._localStreamStat.audioLevelCount++)}o.forEach(A=>{let{msg_user_info:e,msg_audio_status:t,msg_video_status:i}=A,o=e.str_identifier,n=this._room.remotePublishedUserMap.get(o);if(i.forEach(A=>{let e=2===A.uint32_video_stream_type,t=7===A.uint32_video_stream_type,i="".concat(o,"_").concat(e?"main":"auxiliary"),r=this._remoteStreamStatMap.get(i);if(r&&(e&&null!=n&&n.remoteVideoTrack.isSubscribed||t&&null!=n&&n.remoteAuxiliaryTrack)){r.totalVideoFPS+=A.uint32_video_receive_fps,r.totalVideoBitrate+=A.uint32_video_codec_bitrate,r.videoCount++,0===r.statsToReport.uint32_video_width&&(r.statsToReport.uint32_video_width=A.uint32_video_width),0===r.statsToReport.uint32_video_height&&(r.statsToReport.uint32_video_height=A.uint32_video_height);let t=e?n.remoteVideoTrack:n.remoteAuxiliaryTrack;t.stat.jitterBufferDelay&&(r.videoJitterBufferDelay=t.stat.jitterBufferDelay),t.stat.framesReceived&&(r.statsToReport.uint32_video_consume_render_rate=Math.floor(t.stat.framesDecoded/t.stat.framesReceived*kS(10,6)))}}),!aT(t)){let A="".concat(o,"_main"),e=this._remoteStreamStatMap.get(A);this._remoteStreamStatMap.has(A)&&e&&null!=n&&n.remoteAudioTrack.isSubscribed&&(e.totalAudioBitrate+=t.uint32_audio_codec_bitrate,e.audioCount++,n.remoteAudioTrack.stat.jitterBufferDelay&&(e.audioJitterBufferDelay=n.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(t.uint32_audio_level/ik*100)>0&&(e.totalAudioLevel+=t.uint32_audio_level/ik,e.audioLevelCount++),t.uint32_audio_block_time&&(e.statsToReport.uint32_audio_block_time+=t.uint32_audio_block_time))}}),t.uint32_audio_capture_cost&&(this._captureCostSum+=t.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0)),0===t.uint32_audio_capture_cost&&!1===(null==(e=this._room.audioManager.localAudioTrack)?void 0:e.muted)&&(this._localStreamStat.statsToReport.uint32_audio_capture_thread_health_zero_cnt+=1)}}handlePublishStart(A){let{room:e}=A;this.hitTest(e)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(A){let{track:e}=A;1===e.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===e.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(A){let{track:e}=A;1===e.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===e.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(A){let{track:e,error:t}=A,i={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[t.name]||(t instanceof rM?t.getExtraCode()||t.getCode():oM.UNKNOWN);1===e.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=i,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===e.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=i,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(A){return this._firstPublishedUserList.findIndex(e=>e.userId===A&&e.flag&$M)>=0}hasAudioFlag(A){return this._firstPublishedUserList.findIndex(e=>e.userId===A&&e.flag&tR)>=0}hasAuxFlag(A){return this._firstPublishedUserList.findIndex(e=>e.userId===A&&e.flag&eR)>=0}hitTest(A){return A===this._room}prepareReport(){if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let A=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),e=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=A<<16|e}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach((A,e)=>{let{userId:t}=A,i=this._networkQuality.totalDownlinkRTTAndLossMap.get(t);if(i){let{totalLoss:e,count:t,audioDelayCount:o,videoDelayCount:n,totalAudioDelay:r,totalVideoDelay:s}=i;A.statsToReport.uint32_avg_down_loss=Math.floor(e/t),o&&r&&(A.statsToReport.uint32_audio_network_p2p_delay=Math.floor(r/o),A.audioJitterBufferDelay&&(A.statsToReport.uint32_p2p_delay=Math.floor(A.statsToReport.uint32_audio_network_p2p_delay+A.audioJitterBufferDelay))),n&&s&&(A.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/n))}A.videoCount>0&&(A.statsToReport.uint32_video_avg_fps=Math.floor(A.totalVideoFPS/A.videoCount),A.statsToReport.uint32_video_avg_bitrate=Math.floor(A.totalVideoBitrate/A.videoCount)),A.audioCount>0&&(A.statsToReport.uint32_audio_recv_bitrate=A.statsToReport.uint32_audio_bitrate=Math.floor(A.totalAudioBitrate/A.audioCount)),A.audioLevelCount>0&&(A.statsToReport.uint32_audio_play_db=Math.floor(A.totalAudioLevel/A.audioLevelCount*100));let{callDurationCalculator:o}=this._room;o&&(A.statsToReport.uint32_audio_play_time=o.getDuration(e,WM.AUDIO),A.statsToReport.uint32_video_play_time=o.getDuration(e,WM.VIDEO)),A.statsToReport.uint32_video_render_first&&(A.statsToReport.uint32_video_render_first=Math.min(A.statsToReport.uint32_video_render_first,Fq));let{badCaseDetector:n}=this._room,{dataFreeze:r,count:s}=n.getDataFreezeDuration(e),{renderFreeze:a}=n.getRenderFreezeDuration(e);A.statsToReport.uint32_video_block_count=s,A.statsToReport.uint32_video_block_time=Math.min(r,A.statsToReport.uint32_video_play_time),A.statsToReport.uint32_video_external_block_time=Math.min(a,A.statsToReport.uint32_video_play_time),A.statsToReport.uint32_audio_block_time=Math.min(A.statsToReport.uint32_audio_block_time,A.statsToReport.uint32_audio_play_time),n.isBlackStream(e)&&0===A.statsToReport.uint32_video_avg_fps?A.statsToReport.uint32_video_black_screen_subjective=1:A.statsToReport.uint32_video_black_screen_subjective=0}),this._pathMainAudioMap.forEach((A,e)=>{this.hasAudioFlag(A.userId)?A.statsToReport.uint64_play_first_frame_time-A.statsToReport.uint64_start_enter_time>Fq&&(A.statsToReport.uint64_play_first_frame_time=A.statsToReport.uint64_start_enter_time+Fq):this._pathMainAudioMap.delete(e)}),this._pathMainVideoMap.forEach((A,e)=>{this.hasVideoFlag(A.userId)?A.statsToReport.uint64_render_first_frame_time-A.statsToReport.uint64_start_enter_time>Fq&&(A.statsToReport.uint64_render_first_frame_time=A.statsToReport.uint64_start_enter_time+Fq):this._pathMainVideoMap.delete(e)}),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>Fq&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+Fq)}getReportData(){this._basicInfo.uint32_networkType=T_();let A={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new xq({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:lT(this._signalInfo.relayIp),uint32_client_ip:lT(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*kS(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map(A=>A.statsToReport),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map(A=>A.statsToReport),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map(A=>A.statsToReport),uint32_info_client_ip:lT(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend,str_user_sig:this._room.userSig,bytes_report_token:this._signalInfo.reportToken};return yT(A),A}report(){return VS(this,null,function*(){try{this.prepareReport();let A=this.getReportData();yield this.upload(A),this.initData()}catch(A){this._log.warn(A)}finally{this.isDestroyed&&(this._room=null)}})}upload(A){return VS(this,null,function*(){if(0===A.msg_path_enter_room.uint64_start_time)return;let e=Number(this._room.sdkAppId),t=nG.enable?bT(A,2001,e):yield YT(A),i=t instanceof ArrayBuffer,o="".concat(D_(e,UM.KEY_POINT),"&gzip=").concat(+i),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,t));let r=[this.uploadKVStat(Gk),this.uploadKVStat(bk)];n||r.push(PT({url:o,body:t,priority:"low"})),yield Promise.all(r)})}setConnectionType(A){this.connectionType=A,this._basicInfo.uint32_connection_type=A}uploadKVStat(A){return VS(this,arguments,function(A){var e=this;let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._room.sdkAppId;return function*(){var i,o;let n=A.getReportData(null==(i=e._room)?void 0:i.userSig,null==(o=e._signalInfo)?void 0:o.reportToken);if(0===n.stats_count.length&&0===n.stats_distribution.length)return;n.msg_sdk_basic_info=FS(US({},n.msg_sdk_basic_info),{bytes_device_name:e._basicInfo.string_device_name||"",bytes_os_version:e._basicInfo.string_os_version||"",uint32_framework:e._frameWorkType,uint32_network_type:e._basicInfo.uint32_networkType||0}),e._log.debug(n);let r=nG.enable?bT(n,2003,t):yield YT(n),s=r instanceof ArrayBuffer,a="".concat(D_(+t,UM.KV_STAT),"&gzip=").concat(+s),g=!1;navigator.sendBeacon&&(g=navigator.sendBeacon(a,r)),g||PT({url:a,body:r})}()})}};JS([lU({settings:{timeout:500,retries:3}})],Uq.prototype,"upload",1);var Fq=5e3,Oq={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},xq=class{constructor(A){HS(this,"str_identifier"),HS(this,"str_tinyid"),HS(this,"uint32_role"),this.str_identifier=String(A.userId),this.str_tinyid=String(A.tinyId||0),this.uint32_role=A.role}},Pq=Uq,Yq=class{constructor(){HS(this,"_startTime"),HS(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=oT())}stop(){0===this._endTime&&(this._endTime=oT())}getDuration(){return 0===this._endTime?oT()-this._startTime:this._endTime-this._startTime}get startTime(){return this._startTime}get endTime(){return this._endTime}},Jq=class{constructor(A){HS(this,"_room",null),HS(this,"_durationMap"),HS(this,"_eventMap",new Map),this._room=A.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(oG.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(oG.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(oG.REMOTE_PUBLISH_STATE_CHANGED,A=>{let{room:e,prevMuteState:t,muteState:i}=A;var o;let{userId:n}=i;if(!this.hitTest(e))return;t.hasAudio&&!i.hasAudio&&this.stopDurationItem("".concat(n,"_main"),WM.AUDIO),t.hasVideo&&!i.hasVideo&&this.stopDurationItem("".concat(n,"_main"),WM.VIDEO),t.hasAuxiliary&&!i.hasAuxiliary&&this.stopDurationItem("".concat(n,"_auxiliary"),WM.VIDEO);let r=null==(o=this._room)?void 0:o.remotePublishedUserMap.get(n);r&&(!t.hasAudio&&i.hasAudio&&r.remoteAudioTrack.isSubscribed&&this.addDuractionItem(n,WM.AUDIO,"main"),!t.hasVideo&&i.hasVideo&&r.remoteVideoTrack.isSubscribed&&this.addDuractionItem(n,WM.VIDEO,"main"),!t.hasAuxiliary&&i.hasAuxiliary&&r.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(n,WM.VIDEO,"auxiliary"))}),this._eventMap.forEach((A,e)=>tG.on(e,A,this))}uninstallEvents(){this._eventMap.forEach((A,e)=>tG.off(e,A,this)),this._eventMap.clear()}handleSubscribed(A){let{track:e}=A;if(!this.hitTest(e.room))return;let{userId:t,streamType:i,kind:o}=e;e.isSubscribed?this.addDuractionItem(t,o,i):this.stopDurationItem("".concat(t,"_").concat(i),o)}handleUnsubscribed(A){let{track:e}=A;this.hitTest(e.room)&&this.stopDurationItem("".concat(e.userId,"_").concat(e.streamType),e.kind)}isRecording(A){return A.findIndex(A=>0===A.endTime)>=0}addDuractionItem(A,e,t){let i="".concat(A,"_").concat(t),o=new Yq,n=this._durationMap.get(i);n?this.isRecording(n[e])||n[e].push(o):this._durationMap.set(i,{userId:A,type:t,audio:e===WM.AUDIO?[o]:[],video:e===WM.AUDIO?[]:[o]})}stopDurationItem(A,e){if(this._durationMap.has(A)){let t=this._durationMap.get(A)[e].find(A=>0===A.endTime);t&&t.stop()}}hitTest(A){return this._room===A}getDuration(A,e){return this._durationMap.has(A)?this._durationMap.get(A)[e].reduce((A,e)=>A+e.getDuration(),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},Hq=class{constructor(){HS(this,"renderFreezeMap",new Map),HS(this,"dataFreezeMap",new Map)}get(A,e){let t=this.renderFreezeMap.get(A),i=this.dataFreezeMap.get(A);return e?"data"===e?i:t:(fb||dN)&&t&&i&&t.duration>i.duration?t:i}set(A,e,t){"data"===t?this.dataFreezeMap.set(A,e):this.renderFreezeMap.set(A,e)}clear(){this.renderFreezeMap.clear(),this.dataFreezeMap.clear()}},qq=class{constructor(A){HS(this,"_room"),HS(this,"_renderFreezeMap",new Map),HS(this,"_isVideoPlayingEventFiredMap",new Map),HS(this,"_dataFreezeMap",new Map),HS(this,"_monitorFreezeData",new Hq),HS(this,"_eventMap",new Map),HS(this,"_videoEncodeFailedCount",0),HS(this,"_audioEncodeFailedCount",0),HS(this,"_encodeFailedThreshold",3),HS(this,"ABNORMAL_TIME_LOWER_LIMIT",3e3),HS(this,"ABNORMAL_TIME_UPPER_LIMIT",5e3),HS(this,"_videoAbnormalTimestampMap",new Map),HS(this,"_remoteVideoAbnormalTimestampMap",new Map),HS(this,"_audioAbnormalTimestampMap",new Map),HS(this,"eventListenerMap",new Map),this._room=A.room,this.installEvents()}getRenderFreezeMap(){return this._renderFreezeMap}getDataFreezeMap(){return this._dataFreezeMap}installEvents(){this._eventMap.set(oG.LEAVE_SUCCESS,A=>{let{room:e}=A;this.hitTest(e)&&this.stop()}).set(oG.PLAY_TRACK_START,this.onPlayTrackStart).set(oG.UNSUBSCRIBE_SUCCESS,A=>{let{room:e,streamType:t,remotePublishedUser:i}=A;if(!this.hitTest(e))return;let{userId:o}=i,n="".concat(o,"_").concat(t);this.stopDataFreeze({key:n,userId:o,type:t})}).set(oG.REMOTE_PUBLISH_STATE_CHANGED,A=>{let{room:e,prevMuteState:t,muteState:i}=A;if(!this.hitTest(e))return;let{userId:o}=i;if(t.hasVideo&&!i.hasVideo){let A="main",e="".concat(i.userId,"_").concat(A);this.stopDataFreeze({key:e,userId:o,type:A})}if(t.hasAuxiliary&&!i.hasAuxiliary){let A="auxiliary",e="".concat(i.userId,"_").concat(A);this.stopDataFreeze({key:e,userId:o,type:A})}}).set(oG.PLAYER_STATE_CHANGED,A=>{let{track:e,state:t,reason:i,type:o}=A;if(e.isRemote&&e.room&&this.hitTest(e.room)&&o===WM.VIDEO){if("PLAYING"===t){let A="".concat(e.userId,"_").concat(e.streamType);this._isVideoPlayingEventFiredMap.set(A,!0)}i===WM.MUTE?this.onVideoTrackMuted(e):i===WM.UNMUTE&&this.onVideoTrackUnmuted(e)}}).set(oG.HEARTBEAT_REPORT,this.onHearBeatReport).set(oG.REMOTE_VIDEO_PLAY_START,this.onRemoteVideoPlayStart).set(oG.REMOTE_VIDEO_PLAY_FINISH,this.onRemoteVideoPlayEnd),this._eventMap.forEach((A,e)=>tG.on(e,A,this))}uninstallEvents(){this._eventMap.forEach((A,e)=>tG.off(e,A,this)),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(A){if(!A.isSubscribed)return;let{userId:e,streamType:t}=A,i="".concat(e,"_").concat(t),o=this._dataFreezeMap.get(i),n=new Yq;o?o.durationItemList.push(n):this._dataFreezeMap.set(i,{userId:e,type:t,durationItemList:[n],isFreezing(){let A=this.durationItemList[this.durationItemList.length-1];return A&&0===A.endTime}})}onVideoTrackUnmuted(A){if(!A.isSubscribed)return;let{userId:e,streamType:t}=A,i="".concat(e,"_").concat(t);this.stopDataFreeze({key:i,userId:e,type:t})}onHearBeatReport(A){let{room:e,report:t}=A;this.hitTest(e)&&(this.localMediaTrackDetector(t),this.remoteMediaTrackDetector(t))}remoteMediaTrackDetector(A){A.msg_down_stream_info.length>0&&A.msg_down_stream_info.forEach(A=>{var e;if(0===A.msg_video_status.length)return;let t=A.msg_user_info.str_identifier,i=null==(e=this._room.remotePublishedUserMap.get(t))?void 0:e.remoteVideoTrack;A.msg_video_status.forEach(A=>{let e=oT();if(void 0!==A.uint32_video_codec_bitrate&&A.uint32_video_codec_bitrate>0&&0===A.uint32_video_receive_fps&&null!=i&&i.muted)if(this._remoteVideoAbnormalTimestampMap.has("".concat(t,"-decode"))){let A=this._remoteVideoAbnormalTimestampMap.get("".concat(t,"-decode"));A&&e-A>this.ABNORMAL_TIME_LOWER_LIMIT&&e-A=this.ABNORMAL_TIME_UPPER_LIMIT&&(gU.uploadEvent({userId:this._room.userId,log:"stat-".concat(wR.VIDEO_DECODE_RESUME_DURING_CALL)}),this._remoteVideoAbnormalTimestampMap.delete("".concat(t,"-decode")))}if(void 0!==A.uint32_video_codec_bitrate&&A.uint32_video_codec_bitrate>5e5&&void 0!==A.uint32_video_dec_fps&&A.uint32_video_dec_fps<=5)if(this._remoteVideoAbnormalTimestampMap.has("".concat(t,"-hardware"))){let i=this._remoteVideoAbnormalTimestampMap.get("".concat(t,"-hardware"));if(i&&e-i>this.ABNORMAL_TIME_LOWER_LIMIT/2&&e-i<2*this.ABNORMAL_TIME_UPPER_LIMIT){gU.uploadEvent({userId:this._room.userId,log:"stat-".concat(wR.VIDEO_HARDWARE_DECODE_FAILED)});let e=this._room.remotePublishedUserMap.get(t);if(e){let t=2===A.uint32_video_stream_type?e.remoteVideoTrack:e.remoteAuxiliaryTrack;t&&(t.log.warn("decode failed during call"),t.emit("decode-failed-during-call"))}}}else this._remoteVideoAbnormalTimestampMap.set("".concat(t,"-hardware"),e);else{let A=this._remoteVideoAbnormalTimestampMap.get("".concat(t,"-hardware"));A&&e-A>=2*this.ABNORMAL_TIME_UPPER_LIMIT&&(gU.uploadEvent({userId:this._room.userId,log:"stat-".concat(wR.VIDEO_HARDWARE_DECODE_RESUME)}),this._remoteVideoAbnormalTimestampMap.delete("".concat(t,"-hardware")))}})})}localMediaTrackDetector(A){if(A.msg_up_stream_info.msg_video_status){let e=A.msg_up_stream_info.msg_video_status,t=Array.from(this._room.localTracks).find(A=>"video"===A.kind&&!A.isScreen),i=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||i<=0||null!=t&&t.isUseCustomSource)return;e.forEach(A=>{let e=oT();if(2===A.uint32_video_stream_type)if(0!==A.uint32_video_capture_fps&&0===A.uint32_video_codec_bitrate&&0===A.uint32_video_enc_fps&&null!=t&&t.isPublished)if(this._videoAbnormalTimestampMap.has("local-encode")){let A=this._videoAbnormalTimestampMap.get("local-encode");A&&e-A>this.ABNORMAL_TIME_LOWER_LIMIT&&e-A=this.ABNORMAL_TIME_UPPER_LIMIT&&gU.uploadEvent({userId:this._room.userId,log:"stat-".concat(wR.VIDEO_ENCODE_RESUME_DURING_CALL)}),this._videoAbnormalTimestampMap.delete("local-encode")}})}if(A.msg_up_stream_info.msg_audio_status){let e=A.msg_up_stream_info.msg_audio_status,t=Array.from(this._room.localTracks).find(A=>"audio"===A.kind),i=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||i<=0||null!=t&&t.isUseCustomSource)return;let o=oT();if(0===e.uint32_audio_codec_bitrate&&null!=t&&t.isPublished)if(this._audioAbnormalTimestampMap.has("local-encode")){let A=this._audioAbnormalTimestampMap.get("local-encode");A&&o-A>this.ABNORMAL_TIME_LOWER_LIMIT&&o-A=this.ABNORMAL_TIME_UPPER_LIMIT&&gU.uploadEvent({userId:this._room.userId,log:"stat-".concat(wR.AUDIO_ENCODE_RESUME_DURING_CALL)}),this._audioAbnormalTimestampMap.delete("local-encode")}}}stopDataFreeze(A){let{key:e,userId:t,type:i}=A,o=this._dataFreezeMap.get(e);if(!o||!o.isFreezing())return;let n=o.durationItemList[o.durationItemList.length-1];n.stop();let r=n.getDuration();if(r>kR){let A=this._monitorFreezeData.get(e,"data");this._monitorFreezeData.set(e,{userId:t,type:i,duration:A?A.duration+r:r},"data")}else o.durationItemList.pop()}getTotalDuration(A){return A.reduce((A,e)=>{let t=e.getDuration();return A+Math.min(t,5e3)},0)}onPlayTrackStart(A){let{track:e}=A;if(!e.isRemote||!this.hitTest(e.room)||e.kind!==WM.VIDEO||!e.isRemotePublished)return;let t="".concat(e.userId,"_").concat(e.streamType);this._isVideoPlayingEventFiredMap.has(t)||this._isVideoPlayingEventFiredMap.set(t,!1)}getDataFreezeDuration(A){let e={dataFreeze:0,count:0},t=this._dataFreezeMap.get(A);if(t){if(t.isFreezing()){let A=t.durationItemList[t.durationItemList.length-1];A.stop(),A.getDuration(){document.hidden||(o=0)};document.addEventListener("visibilitychange",n);let r=(A,i)=>{var n;if(o){let A=e.decodeFPS,t=A>0&&A<=5?600+1e3/A:600,n=i.presentationTime-o;if(n>t){n=Math.min(n,5e3);let A="".concat(e.userId,"_").concat(e.streamType),t=this._monitorFreezeData.get(A,"render");t?t.duration+=n:this._monitorFreezeData.set(A,{userId:e.userId,type:e.streamType,duration:n},"render");let i=this._renderFreezeMap.get(A);i?(i.totalDuration+=n,i.count+=1):this._renderFreezeMap.set(A,{userId:e.userId,type:e.streamType,totalDuration:n,count:1})}}o=i.presentationTime,null==(n=t.element)||n.requestVideoFrameCallback(r)};null==(i=t.element)||i.requestVideoFrameCallback(r),this.eventListenerMap.set("".concat(e.userId,"_").concat(e.streamType),{onVisibilityChange:n})}onRemoteVideoPlayEnd(A){let{track:e,player:t}=A,i="".concat(e.userId,"_").concat(e.streamType),o=this.eventListenerMap.get(i);o&&document.removeEventListener("visibilitychange",o.onVisibilityChange)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(A){return A===this._room}destroy(){this.uninstallEvents()}},Vq=YS(jS(),1),jq=class{constructor(A,e,t,i,o){let n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:4/3;this.vbMode=A,this.faceDetectorHash=t,this.visionTaskRegistry=i,this.logger=o,HS(this,"animationState"),HS(this,"originalAspect"),HS(this,"totalOffsetX",0),HS(this,"totalOffsetY",0),HS(this,"defaultScaleRatio",.1),HS(this,"isRecovering",!1),HS(this,"boundaryY",280),HS(this,"lastActionTime",0),HS(this,"restTime",400),this.animationState={current:null,target:null,animating:!1,debounceTimer:null,startTime:0,duration:3e3,debounceTime:150,movementThreshold:30,debounceThreshold:15},this.addEvent(this.vbMode,!!this.faceDetectorHash),this.originalAspect=n||4/3,this.visionTaskRegistry.setVideo(this.faceDetectorHash,e)}addEvent(A,e,t){let i=[{key:570704,error:null!=t?t:e?void 0:11},{key:570705,error:null!=t?t:e?void 0:22}][A-1];i&&(e?Gk.addSuccessEvent({key:i.key}):Gk.addFailedEvent({key:i.key,error:i.error}))}actionCentering(A){let e=Date.now();if(this.animation(),!this.faceDetectorHash||e-this.lastActionTimee/2?(o=e-t-i,n=t-o):(o=t,n=0),{min:o,offset:n}}calculateTargetPosition(A,e,t,i,o,n){let r,s,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.4,g=A+t/2,c=e+i/2,{min:l,offset:I}=this.calculateBoundary(g,o,A,t),{min:u,offset:E}=this.calculateBoundary(c,n,e,i);return r=2*l+t,s=2*u+i,r/s>this.originalAspect?(r=s*this.originalAspect,I=g-r/2):(s=r/this.originalAspect,E=c-s/2),t/o>a&&(I=0,E=0,r=o,s=n),I=Math.max(0,Math.min(I,o-r)),E=Math.max(0,Math.min(E,n-s)),{sx:I,sy:E,cropWidth:r,cropHeight:s,timestamp:Date.now()}}processFacePositionCrop(A,e,t){if(!this.animationState.current||!this.animationState.target){let A={sx:0,sy:0,cropWidth:e,cropHeight:t,timestamp:Date.now()};return this.animationState.current=A,void(this.animationState.target=A)}let i=this.positionDistance(this.animationState.target,A),o=this.positionDistance(this.animationState.current,A),n=this.animationState.current.cropWidth/e;i>this.animationState.debounceThreshold*n&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&o>this.animationState.movementThreshold*n&&(this.animationState.target=A,this.animationState.debounceTimer=setTimeout(()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0},this.animationState.debounceTime))}processFacePositionPortrait(A){if(!this.animationState.current||!this.animationState.target)return this.animationState.current=US({},A),void(this.animationState.target=US({},A));let e=this.positionDistance(this.animationState.current,A),t=this.positionDistance(this.animationState.target,A);e>this.animationState.debounceThreshold&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&t>this.animationState.movementThreshold&&(this.animationState.current=A,this.animationState.debounceTimer=setTimeout(()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0},this.animationState.debounceTime))}animation(){if(!this.animationState.animating)return;let A=Date.now()-this.animationState.startTime,e=Math.min(A/this.animationState.duration,1),t=A=>A<.5?2*A*A:(4-2*A)*A-1;if(this.animationState.current&&this.animationState.target){let A=(this.animationState.target.sx-this.animationState.current.sx)*t(e);this.animationState.current.sx+=A,this.totalOffsetX+=A;let i=(this.animationState.target.sy-this.animationState.current.sy)*t(e);if(this.animationState.current.sy+=i,this.totalOffsetY+=i,this.animationState.current.cropWidth+=(this.animationState.target.cropWidth-this.animationState.current.cropWidth)*t(e),this.animationState.current.cropHeight+=(this.animationState.target.cropHeight-this.animationState.current.cropHeight)*t(e),this.animationState.current.scaleRatio&&this.animationState.target.scaleRatio&&(this.animationState.current.scaleRatio+=(this.animationState.target.scaleRatio-this.animationState.current.scaleRatio)*t(e)),V_(this.animationState.current.scaleOffsetX)&&V_(this.animationState.target.scaleOffsetX)&&V_(this.animationState.current.scaleOffsetY)&&V_(this.animationState.target.scaleOffsetY)){let A=(this.animationState.target.scaleOffsetX-this.animationState.current.scaleOffsetX)*t(e);this.animationState.current.scaleOffsetX+=A;let i=(this.animationState.target.scaleOffsetY-this.animationState.current.scaleOffsetY)*t(e);this.animationState.current.scaleOffsetY+=i}}e>=1&&(this.animationState.animating=!1,this.animationState.current=this.animationState.target,this.isRecovering=!1)}positionDistance(A,e){return Math.sqrt(kS(A.sx-e.sx,2)+kS(A.sy-e.sy,2))}recoverOriginal(A,e){this.animationState.target={sx:0,sy:0,cropWidth:A,cropHeight:e,timestamp:Date.now()},this.animationState.animating=!0,this.animationState.startTime=Date.now(),this.isRecovering=!0}dualStageCropping(A,e,t,i,o,n){let r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.3;if(this.isRecovering)return;let s=this.calculateTargetPosition(t,i,o,n,A,e);this.processFacePositionCrop(s,A,e),o*n/s.cropWidth/s.cropHeight>r&&this.recoverOriginal(A,e)}movingPortrait(A,e,t,i,o,n){var r,s,a,g,c,l,I,u,E,d,h,C;let B={sx:t+o/2+this.totalOffsetX,sy:i+n/2+this.totalOffsetY,cropWidth:A,cropHeight:e,scaleRatio:null!=(s=null==(r=this.animationState.current)?void 0:r.scaleRatio)?s:1,scaleOffsetX:null!=(g=null==(a=this.animationState.current)?void 0:a.scaleOffsetX)?g:0,scaleOffsetY:null!=(l=null==(c=this.animationState.current)?void 0:c.scaleOffsetY)?l:0,timestamp:Date.now()};this.animationState.target={sx:A/2,sy:i+n/2,cropWidth:A,cropHeight:e,scaleRatio:null!=(u=null==(I=this.animationState.target)?void 0:I.scaleRatio)?u:1,scaleOffsetX:null!=(d=null==(E=this.animationState.target)?void 0:E.scaleOffsetX)?d:0,scaleOffsetY:null!=(C=null==(h=this.animationState.target)?void 0:h.scaleOffsetY)?C:0,timestamp:Date.now()},this.animationState.animating||(this.animationState.target.scaleRatio=Math.sqrt(o*n/A/e/this.defaultScaleRatio),this.animationState.target.scaleOffsetX=-this.animationState.target.scaleRatio/2+.5,this.animationState.target.scaleOffsetY=1-this.animationState.target.scaleRatio,(this.animationState.target.sy-this.animationState.target.scaleOffsetY*this.animationState.target.cropHeight)/this.animationState.target.scaleRatio{A.log.error(e),A.destroy(new rM({code:oM.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(e.message||e)})),this.resolvePreditReady()})}init(A){return VS(this,null,function*(){var e,t,i;this.predictReady=new Promise(A=>{this.resolvePreditReady=A});let o=A.Wasm,n=this.context.ctx;if(A.color&&(this._color=A.color),A.mat4&&(this._mat4=A.mat4),A.postProcessing&&(this._postProcessing=A.postProcessing),this._enableFaceCentering=null!=(e=A.enableFaceCentering)&&e,this._enableEffectOptimization=null!=(t=A.enableEffectOptimization)&&t,this.wasm=new o.AllIn1(n),this.wasm.blurRadius=A.blurRadius||3,this.wasm.mirror=!!A.mirror,this.wasm.rotation=A.rotation||0,this.wasm.vbMode="blur"===A.bg?1:A.bg instanceof HTMLImageElement?2:"color"===A.bg?3:0,this._onAbort=A.onAbort,A.bg||this.resolvePreditReady(),A.waterMark){let{x:e,y:t,width:i,height:o}=A.waterMark;this.wasm.setWaterMark(e,t,i,o)}if(A.beautyParams){let{beauty:e,brightness:t,ruddy:i}=A.beautyParams;this.wasm.setBeauty(e,t,i,null==A?void 0:A.width,null==A?void 0:A.height)}this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),A.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(A.bg)),A.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(A.waterMark.image));let r=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);if(this._textureMatrixLocation=n.getUniformLocation(this.program,"u_textureMatrix"),n.uniformMatrix4fv(this._textureMatrixLocation,!1,r),this._offsetMatrixLocation=n.getUniformLocation(this.program,"u_offsetMatrix"),n.uniformMatrix4fv(this._offsetMatrixLocation,!1,r),this._colorLocation=n.getUniformLocation(this.program,"u_color"),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){let A=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),e=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(e,A),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}!this._enableEffectOptimization||2!==this.wasm.vbMode&&3!==this.wasm.vbMode?this._postProcessing=void 0:Fb()?(this._postProcessing=void 0,this.log.warn("Virtual background post-processing isn't allowed on mobile.")):null==(i=this._postProcessing)||i.init(n,this.positionBuffer,this.texCoordBuffer,4/3),yield this.initVisionTasks(A)})}initVisionTasks(A){return VS(this,null,function*(){if(A.bg){if(this._visionTaskRegistry=yield window.VisionTaskRegistry.getInstance(),!window.VisionTaskRegistry||!this._visionTaskRegistry||!this._visionTaskRegistry.visionWasm)throw new Error("Virtual background assets not found. Please redeploy the assets of the npm package.");if(this._selfieSegmentationHash=yield this._visionTaskRegistry.register(window.VisionTaskType.ImageSegmenter,{canvas:this.context._canvas}),this._visionTaskRegistry.setVideo(this._selfieSegmentationHash,this.image),this._enableFaceCentering)try{this._visionTaskRegistry.models.has(window.VisionTaskType.FaceDetector)||(yield this._visionTaskRegistry.preloadModels([window.VisionTaskType.FaceDetector]));let A=yield this._visionTaskRegistry.register(window.VisionTaskType.FaceDetector);if(!A)return;this._centerFace=new jq(this.wasm.vbMode,this.image,A,this._visionTaskRegistry,this.context.log)}catch(e){this.log.error("Face detector model not found. Please redeploy the assets of the npm package.")}}})}onPredict(A){let e=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture)));let t=this.getMaskTexture(A);if(!t)return;let i=t;this._postProcessing&&(this._postProcessing.ratio=this.image.videoWidth/this.image.videoHeight,i=this._postProcessing.postProcessing(t)),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),this.useTexture(),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,i||null),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,this._bgTexture||null),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_2D,this._waterMarkTexture||null),3===this.wasm.vbMode&&e.uniform3fv(this._colorLocation,this._color),this.useBufferFrame(),this._segmentationMask=A,this.totalFrames++,this.centerFace(),RT(this.wasm.rotation)&&this.resize(this.image.height,this.image.width),e.viewport(0,0,e.canvas.width,e.canvas.height),e.drawArrays(e.TRIANGLE_STRIP,0,4),A.close()}getMaskTexture(A){return A.confidenceMasks?A.confidenceMasks[0].getAsWebGLTexture():void 0}onFirstFrame(){this.waitingFirstFrame=!1;let A=this.context.ctx;this.useTexture(),A.texImage2D(A.TEXTURE_2D,0,A.RGBA,A.RGBA,A.UNSIGNED_BYTE,this.image)}render(A){let e=this.context.ctx,{image:t}=this;this.tryVideoFrameCallback();let{videoWidth:i,videoHeight:o}=t;if(RT(this.wasm.rotation)&&!this._visionTaskRegistry&&([i,o]=[o,i]),0===i||0===o||!this.available)return!1;t.width=i,t.height=o;let n=!1;if(this.totalFrames)this.useTexture(),n=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),n=this._textureValid,this._textureValid=!0}if(this.width===i&&this.height===o&&n?e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,t):(this.resize(i,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)),this._weixin){if(e.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask){let A=this.getMaskTexture(this._segmentationMask);e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,A||null),e.bindFramebuffer(e.FRAMEBUFFER,this._lastMaskFbo||null)}e.drawArrays(e.TRIANGLE_STRIP,0,4),this.useTexture(),this._segmentationMask?e.copyTexSubImage2D(e.TEXTURE_2D,0,0,0,0,0,i,o):e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,i,o,0)}try{if(this._selfieSegmentationHash&&this._visionTaskRegistry){let A=this._visionTaskRegistry.getResult(this._selfieSegmentationHash);1===this.totalFrames&&this.context._canvas&&this.resolvePreditReady(),this.onPredict(A)}}catch(r){this._onAbort&&this._onAbort(r)}return this.totalFrames||(e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,this._bgTexture||null),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_2D,this._waterMarkTexture||null),e.drawArrays(e.TRIANGLE_STRIP,0,4)),this._visionTaskRegistry&&this._visionTaskRegistry.resetHashResults(),!1}centerFace(){if(!this._centerFace||!this._enableFaceCentering)return;let A=this.context.ctx;this._centerFace.aspectRatio=A.canvas.width/A.canvas.height,this._centerFace.actionCentering(this.image);let{current:e,offset:t}=this._centerFace;if(e&&(1===this.wasm.vbMode&&this.drawImage(e.sx,e.sy,e.cropWidth,e.cropHeight),t&&2===this.wasm.vbMode)){if(!this._mat4)return;let i=this._mat4.create(),{scaleRatio:o=1,scaleOffsetX:n=0,scaleOffsetY:r=0}=e;this._mat4.fromTranslation(i,[-t.offsetX/A.canvas.width+n,r,0]),this._mat4.scale(i,i,[o,o,1]),A.uniformMatrix4fv(this._offsetMatrixLocation,!1,i)}}drawImage(A,e,t,i){let o=this.context.ctx;if(!this._mat4)return;let{width:n,height:r}=o.canvas,s=this._mat4.create();this._mat4.fromTranslation(s,[A/n,1-(e+i)/r,0]),this._mat4.scale(s,s,[t/n,i/r,1]),o.uniformMatrix4fv(this._textureMatrixLocation,!1,s)}close(){var A;super.close();let e=this.context.ctx;this._bgTexture&&e.deleteTexture(this._bgTexture),this._waterMarkTexture&&e.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&e.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&e.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&e.deleteProgram(this._prePrograme),this._postProcessing&&this._postProcessing.close(),null==(A=this.wasm)||A.close()}},Wq=class extends RP{constructor(A){super(A,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:A.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}),HS(this,"yTextureRef"),HS(this,"uTextureRef"),HS(this,"vTextureRef"),HS(this,"Y"),HS(this,"U"),HS(this,"V"),this.useProgram();let e=this.context.ctx;e.pixelStorei(e.PACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_ALIGNMENT,1),this.setTexBuffer([0,1,1,1,0,0,1,0]),this.yTextureRef=this._initTexture("ySampler",0),this.uTextureRef=this._initTexture("uSampler",1),this.vTextureRef=this._initTexture("vSampler",2),this._canvas=A._canvas}_initTexture(A,e){let t=this.context.ctx,i=t.createTexture();return t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null),t.uniform1i(t.getUniformLocation(this.program,A),e),i}render(A){let e=this.context.ctx,t=this.width,i=this.height;return this.useProgram(),e.viewport(0,0,t,i),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.yTextureRef),e.texSubImage2D(e.TEXTURE_2D,0,0,0,t,i,e.LUMINANCE,e.UNSIGNED_BYTE,this.Y),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this.uTextureRef),e.texSubImage2D(e.TEXTURE_2D,0,0,0,t/2,i/2,e.LUMINANCE,e.UNSIGNED_BYTE,this.U),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,this.vTextureRef),e.texSubImage2D(e.TEXTURE_2D,0,0,0,t/2,i/2,e.LUMINANCE,e.UNSIGNED_BYTE,this.V),this.draw(),!0}resize(A,e){super.resize(A,e);let t=this.context.ctx;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texImage2D(t.TEXTURE_2D,0,t.LUMINANCE,A,e,0,t.LUMINANCE,t.UNSIGNED_BYTE,null),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texImage2D(t.TEXTURE_2D,0,t.LUMINANCE,A/2,e/2,0,t.LUMINANCE,t.UNSIGNED_BYTE,null),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texImage2D(t.TEXTURE_2D,0,t.LUMINANCE,A/2,e/2,0,t.LUMINANCE,t.UNSIGNED_BYTE,null)}},zq=(A,e)=>{switch(A){case"webCodecs":return"videoFrame"===e?514705:514706;case"wasm":return"webgl"===e?514707:"videoFrame"===e?514708:514709}throw new Error("decoder type not supported")},Zq=0,Xq=class{constructor(A){HS(this,"id",Zq++),HS(this,"trackDoneOB"),HS(this,"startOB"),HS(this,"stopOB"),HS(this,"decoder"),HS(this,"videoContext"),HS(this,"gop",0),HS(this,"gop_helper",0),HS(this,"waitFirstKeyFrame",!0),HS(this,"startTimestamp",0),HS(this,"startTime",0),HS(this,"startPerformanceTime",0),HS(this,"inputFrameCount",0),HS(this,"decodedFrameCount",0),HS(this,"decodeFrameCount",0),HS(this,"downgradeLevel",0),HS(this,"lastDowngradeTime",0),HS(this,"lastFrameDiff",0),HS(this,"lastDecodeFrameTimestamp",0),HS(this,"config"),HS(this,"gop_before_configure",[]),HS(this,"videoElement"),HS(this,"type","wasm"),HS(this,"goodType"),HS(this,"renderer","2d"),HS(this,"wasmOption"),HS(this,"createDecoder"),HS(this,"_decodeSink"),HS(this,"isReported",!1),HS(this,"track"),HS(this,"stateChangeOB"),HS(this,"failedReason");let{track:e,createDecoder:t}=A;if(this.stateChangeOB=MO(),this.track=e,this.createDecoder=t,this.wasmOption={yuvMode:"webgl"===A.renderer,wasmPath:A.wasmPath,workerMode:A.workerMode,canvas:A.canvas},this.config=A.config,this.videoElement=A.videoElement,this.renderer=A.renderer,this.trackDoneOB=PO(e.availableState,ZL.OFF),this.stopOB=MO(),"auto"===A.type){switch(A.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=A.type;this.changeRenderer(this.renderer),sO(this.stateChangeOB,Tx((A,t)=>(A!==t&&e.onDecodeDowngradeStateChanged({type:this.type,renderer:this.renderer,reason:this.failedReason,prevState:A,state:t}),t),"INITIALIZED"),gx(this.stopOB),cP()),this.start()}start(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");let e=sO(this.pipe(this.track),gx(this.stopOB),dO());sO(e,cP(()=>{this.track.stat.framesDecoded++},e=>{if(this.track.log.error("".concat(this.id," play failed: ").concat(e," retryCount: ").concat(A)),Gk.addFailedEvent({key:zq(this.type,this.renderer),error:e}),A>4)this.failedReason=e,this.stateChangeOB.next("FAILED"),Gk.addFailedEvent({key:514704});else{if(this.goodType)return void this.start(A);switch(this.type){case"webCodecs":this.type="wasm",this.changeRenderer("webgl");break;case"wasm":"webgl"===this.renderer&&this.changeRenderer("videoFrame")}this.start(A+1)}},()=>{this.track.log.warn("".concat(this.id," decoderOB completed")),Gk.addSuccessEvent({key:zq(this.type,this.renderer)}),Gk.addSuccessEvent({key:514704})})),sO(e,ax(1),cP(()=>{this.track.player.handlePlaying("canvas"),this.goodType=this.type,this.stateChangeOB.next("STARTED")}))}mock(A){this._decodeSink?this._decodeSink.error(A):this.start()}close(A){this.stopOB.next(A)}changeRenderer(A){this.renderer=A,"videoFrame"===this.renderer&&!Jk()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}decode(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var t,i;if(this.failedReason)return;this.inputFrameCount++;let o=new Uint8Array(A.data);if(0!==(n=o)[0]||0!==n[1]||0!==n[2]||1!==n[3]||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),A;var n;let r=!1;switch(31&o[4]){case 5:case 7:r=!0}if("configured"!==(null==(t=this.decoder)?void 0:t.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),r&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:A.data,timestamp:A.timestamp,type:A.type}),A;this.gop_before_configure.length>0&&!e&&(this.gop_before_configure.forEach(A=>this.decode(A,!0)),this.gop_before_configure=[]);let{timestamp:s}=A;if(r?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!r)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=s,this.startTime=Date.now(),this.startPerformanceTime=oT()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(s," ").concat(null==(i=A.getMetadata)?void 0:i.call(A).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=s,void this.decoder.decode({data:A.data,type:A.type,timestamp:this.lastDecodeFrameTimestamp})}return A}checkDowngradeByFrameDiff(){let A=this.downgradeLevel,e=this.decodeFrameCount-this.decodedFrameCount;e>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):e<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==A&&this.track.log.debug("downgrade level ".concat(A," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(e,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=e,this.lastDowngradeTime=Date.now()}checkDowngradeByTimestampDiff(A){let e=this.downgradeLevel;this.lastDecodeFrameTimestamp-A>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel))}pipe(A){return e=>VS(this,null,function*(){this._decodeSink=e;let t,i=A.mediaTrack;e.defer(()=>{var e;i&&(A.player.setCanvas(),A.setInputMediaStreamTrack(i)),null==t||t.close(),null==(e=this.videoContext)||e.destroy(),delete this._decodeSink});let{renderer:o,type:n}=this;A.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer));try{switch(n){case"wasm":t=this.createDecoder(n,this.wasmOption);break;case"webCodecs":t=this.createDecoder(n);break;default:throw new Error("not supported yet")}let i=0;if(t.on("videoFrame",t=>{this.decodedFrameCount++,i++,(i<=10||i%500==0)&&A.log.debug("frame ".concat(i," ").concat(this.decodedFrameCount,"/").concat(this.decodeFrameCount," decoded ").concat(t.timestamp)),Date.now()-this.lastDowngradeTime>5e3&&("webCodecs"===this.type?this.checkDowngradeByFrameDiff():"wasm"===this.type&&this.checkDowngradeByTimestampDiff(t.timestamp)),e.next(t)}),t.on("error",t=>{A.log.error(t),e.error("webCodecs"===n?4:8)}),yield t.initialize(this.videoElement),!this._decodeSink)return;if(t.configure(this.config),"wasm"===n&&"webgl"===o){this.videoContext=new YP({frameRate:15,logger:A.log,name:A.userId}),this.videoContext.create(),this.videoContext.on(YP.UNAVAILABLE,t=>{A.log.error(t),e.error(7)});let i=new Wq(this.videoContext);t.on("videoCodecInfo",A=>i.resize(A.width,A.height)),t.on("videoFrame",A=>{({y:i.Y,u:i.U,v:i.V}=A),1===this.downgradeLevel?this.decodedFrameCount%2==0&&i.render(this.decodedFrameCount):i.render(this.decodedFrameCount)}),A.source=i,A.player.setCanvas(this.videoContext._canvas,2)}else if("videoFrame"===o){A.player.setCanvas();let e=new MediaStreamTrackGenerator({kind:"video"}),i=e.writable.getWriter();A.setInputMediaStreamTrack(e),t.on("videoFrame",A=>i.write(A))}else{this.videoContext=new JP({frameRate:15,logger:A.log,name:A.userId}),this.videoContext.create({alpha:!1});let i=this.videoContext.createVideoImageSource();t.on("videoFrame",t=>{try{i.image=t,i.update()}catch(o){delete this.goodType,A.log.error(o),e.error(11)}});let o=new NP(this.videoContext,{name:"remotePlayer",logger:A.log});i.connect(o),A.source=i,A.player.setCanvas(this.videoContext._canvas,2)}this.decoder=t}catch(r){A.log.error(r),e.error("webCodecs"===n?2:6)}})}},$q=Promise.resolve(),AV=class extends Vq.EventEmitter{constructor(A){super(),this.room=A,HS(this,"videoContext"),HS(this,"_glVideoContext"),HS(this,"_2dVideoContext"),HS(this,"destination"),HS(this,"smallVideoContext"),HS(this,"smallDestination"),HS(this,"smallTrackSource"),HS(this,"smallImageSource"),HS(this,"_isMirror",!1),HS(this,"_rotation",0),HS(this,"cameraTrack"),HS(this,"cameraNode"),HS(this,"transformNode"),HS(this,"mixNode"),HS(this,"screenTrack"),HS(this,"screenNode"),HS(this,"selfModel",!1),HS(this,"blurRadius",3),HS(this,"arTrack"),HS(this,"_enableFaceCentering",!1),HS(this,"_enableEffectOptimization",!1),HS(this,"onAbort"),HS(this,"_color"),HS(this,"Wasm"),HS(this,"waterMarkNode"),HS(this,"_waterMarkOption"),HS(this,"watermarkImageList",[]),HS(this,"_beautyParams"),HS(this,"isUsingArTrack",!1),HS(this,"mixTrack"),HS(this,"_isMixScreen",!1),HS(this,"_virtualBackground"),HS(this,"_virtualBackgroundAbortCallback"),HS(this,"virtualBackgroundInstance"),HS(this,"_bgAssetPath"),HS(this,"log"),HS(this,"_mat4"),HS(this,"_postProcessing"),HS(this,"_checkId",0),HS(this,"_use2d",!1),HS(this,"_autoSwitchRenderMode",!0),HS(this,"encodePipeline",[]),HS(this,"decodePipeline",[]),HS(this,"updated",$q),HS(this,"_updateFlag",!1),this.log=sG.createLogger({parent:null==A?void 0:A.getLogger(),id:"vm",userId:null==A?void 0:A.userId,sdkAppId:null==A?void 0:A.sdkAppId}),this.smallVideoContext=new JP({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get smallMode(){var A;return(null==(A=this.room)?void 0:A.smallMode)||"canvas"}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get _isRotate(){return 0!==this._rotation}get _isTransform(){return this._isMirror||this._isRotate}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(A){if(this._autoSwitchRenderMode="auto"===A,this._autoSwitchRenderMode)return;let e="2d"===A;this._use2d!==e&&(this._use2d=e,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get cameraResolution(){var A;let{width:e,height:t}=(null==(A=this.cameraTrack)?void 0:A.settings)||{};return RT(this._rotation)?{width:t,height:e}:{width:e,height:t}}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new JP({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new YP({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}initializeGlVideoContext(){try{this._glVideoContext.create(pb<=22),this._glVideoContext.on(YP.UNAVAILABLE,A=>{var e;this.emit("error",A),this.log.warn("video context unavailable",A),null==(e=this._virtualBackgroundAbortCallback)||e.call(this,A),this.update().catch(A=>{this.log.error(A)})})}catch(A){this.emit("error",A)}}initVirtualBackground(A,e,t){this.onAbort=A,this._mat4=e,this._postProcessing=t}enablePrintDetail(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=iU.run("interval",()=>{this.destination&&this.log.debug(this.destination.getInfo())},{delay:A})}destroy(){var A,e;null==(A=this._2dVideoContext)||A.destroy(),null==(e=this._glVideoContext)||e.destroy(),this.smallVideoContext.destroy(),iU.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(mb||this._isMixScreen||this._isTransform||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}sendCreateResult(){let A=arguments.length>1?arguments[1]:void 0,e="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;A?Gk.addFailedEvent({key:e,error:A}):Gk.addSuccessEvent({key:e})}checkOrCreateVideoContext(){let A=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let e=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&A===this._hasVirtualBg)this.clear();else{if(!e)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new YP({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var A;return null==(A=this.smallDestination)?void 0:A.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var A;return null==(A=this.cameraTrack)?void 0:A.mediaTrack}setSmallVideo(A,e){if("api"!==this.smallMode)if(A){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new kP(this.smallVideoContext,A,this.log),this.smallVideoContext.on(YP.UNAVAILABLE,A=>{this.log.warn("small video context lost",A)})}if(this.smallVideoContext.frameRate=A.frameRate,this.smallDestination.resolution=A,e)this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=e:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(e),this.smallImageSource.resize(e.width,e.height),this.smallImageSource.connect(this.smallDestination));else if(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource)this.smallTrackSource.replaceTrack(this.initialTrack);else{this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource");let{width:A,height:e}=this.cameraTrack.settings;this.smallTrackSource.resize(A,e),this.smallTrackSource.connect(this.smallDestination)}}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}_setMainOutput(A){var e;try{let t=this.cameraTrack,{small:i,player:o}=t;mb&&o.setCanvas(A);let n=A&&(null==(e=this.destination)?void 0:e.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),n=this.arTrack),this.log.info("set main output ".concat(n?n.label:"no output track")),this.setSmallVideo(i,A),t.setOutputMediaStreamTrack(n)}catch(t){this.log.error("set main output failed",t)}}update(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return VS(this,null,function*(){var e;if(!this.cameraTrack||!this.initialTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:t,profile:i}=this.cameraTrack;if(this._use2d||!this._virtualBackground&&!this._beautyParams)this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(RP.RENDER,A=>{var e;null==(e=this.cameraTrack)||e.emit("render",A)})),16===Mb?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof FP?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof FP?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(t.width,t.height);else if(A&&this.cameraNode&&this.destination)this.cameraNode.replaceTrack(this.initialTrack);else{this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():(this.destination=new GP(this.videoContext,{name:"mainDestination",logger:this.log}),this.destination.on(RP.RENDER,A=>{var e;null==(e=this.cameraTrack)||e.emit("render",A)}));let{width:A,height:e}=this.cameraResolution,t=yield this.getWatermarkImage(A,e);this._waterMarkOption={x:0,y:0,width:t.width,height:t.height,image:t},this.cameraNode=new Kq(this.videoContext,{input:this.initialTrack,width:A,height:e,mirror:this._isMirror,rotation:this._rotation,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,Wasm:this.Wasm,enableFaceCentering:this._enableFaceCentering,enableEffectOptimization:this._enableEffectOptimization,onAbort:this.onAbort,mat4:this._mat4,postProcessing:this._postProcessing,color:this._color}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute(),yield this.cameraNode.predictReady}if(this.videoContext.frameRate=i.frameRate,this._use2d){let A=this.cameraNode;if(A.disconnect(),this._isTransform&&(this.transformNode?(this.transformNode.mirror=this._isMirror,this.transformNode.rotation=this._rotation):this.transformNode=new KP(this.videoContext,this.log,this._isMirror,this._rotation),A=A.connect(this.transformNode),A.disconnect(),this.log.info("start mirror ".concat(this._isMirror," rotate ").concat(this.rotation))),this.mixNode&&this.mixNode.close(),delete this.mixNode,this._isMixScreen||this._hasWaterMark){if(this.mixNode=new VP(this.videoContext,this.log),A.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption)this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y;else if(this.waterMarkNode){let{width:A,height:e}=this.cameraResolution;this.waterMarkNode.image=yield this.getWatermarkImage(A,e),A&&e&&this.waterMarkNode.resize(A,e)}null==(e=this.waterMarkNode)||e.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&(this.screenNode||(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource"),this.screenNode.resize(this.screenTrack.settings.width,this.screenTrack.settings.height)),this.screenNode.shouldUpdate=!1,this.screenNode.connect(this.mixNode,{zIndex:0})),A=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))}A.connect(this.destination)}return this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext.canvas)})}clearLastFrame(){var A;this.destination&&(null==(A=this.destination.ctx2d)||A.clearRect(0,0,this.destination.width,this.destination.height))}changeInput(A){var e,t,i,o,n;if(A instanceof XP)return this.log.info("change screen input",null==(e=A.mediaTrack)?void 0:e.label),this.setScreenTrack(A);if(A instanceof DP)return this.log.info("change video input",null==(t=A.mediaTrack)?void 0:t.label),this.setCameraTrack(A);if(A instanceof aY){this.log.info("change remote input",null==(i=A.mediaTrack)?void 0:i.label);let e=A.mediaTrack;return A.setOutputMediaStreamTrack(e)}if(A instanceof WP)return this.log.info("change mix input",null==(o=A.outMediaTrack)?void 0:o.label),this.setMixTrack(A);this.log.warn("change unknown input",null==(n=A.mediaTrack)?void 0:n.label)}removeInput(A){var e;A instanceof XP?(null==(e=this.screenNode)||e.close(),delete this.screenNode,delete this.screenTrack,this.update()):A instanceof DP?this._isMixScreen?(delete this.cameraNode,this.cameraTrack._inputTrack=null,this.update()):(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):A instanceof aY?A.source&&A.source.context.destroy():A instanceof WP&&(delete this.mixTrack,this.update())}setMixTrack(A){this.mixTrack=A}setCameraTrack(A){return this.cameraTrack=A,this.update(!0)}setScreenTrack(A){return VS(this,null,function*(){return this.screenTrack=A,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(A.mediaTrack):yield this.update()),A.setOutputMediaStreamTrack(A.mediaTrack)})}getWatermarkImage(A,e){return VS(this,null,function*(){let t=document.createElement("canvas");e&&A&&(t.height=e,t.width=A);let i=t.getContext("2d");if(!i)throw new rM({code:oM.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort((A,e)=>A.zIndex-e.zIndex),this.watermarkImageList.forEach(t=>{let{image:o,x:n,y:r,width:s,height:a,fillVideo:g}=t,c=g&&A||s,l=g&&e||a,I=g?0:n,u=g?0:r;i.drawImage(o,I,u,c,l)}),fT(t.toDataURL())})}pushWaterMarkImageList(A){let{type:e}=A;this.watermarkImageList.some(e=>e.imageUrl===A.imageUrl&&e.height===A.height&&e.width===A.width&&e.x===A.x&&e.y===A.y&&e.type===A.type&&e.zIndex===A.zIndex&&e.fillVideo===A.fillVideo)||(("mute"===e||"watermark"===e)&&(this.watermarkImageList=this.watermarkImageList.filter(A=>A.type!==e)),this.watermarkImageList.push(A))}setBeautyParams(A){return VS(this,null,function*(){this._beautyParams=A,this.update()})}stopBeauty(){return VS(this,null,function*(){this._beautyParams=void 0,this.update()})}setWatermark(A){return VS(this,null,function*(){let e;try{e=yield fT((null==A?void 0:A.imageElement)||A.imageUrl)}catch(g){throw new rM({code:oM.INVALID_PARAMETER,message:"load image failed, url: ".concat(A.imageUrl)})}let{x:t=0,y:i=0,width:o=e.width,height:n=e.height,type:r="watermark",zIndex:s=2,fillVideo:a=!1}=A;this.watermarkImageList.some(A=>A.type===r)?(this.watermarkImageList=this.watermarkImageList.filter(A=>A.type!==r),this.pushWaterMarkImageList({x:t,y:i,width:o,height:n,image:e,zIndex:s,type:r,imageUrl:A.imageUrl,fillVideo:a}),e=yield this.getWatermarkImage(this.cameraResolution.width,this.cameraResolution.height),this._waterMarkOption={x:0,y:0,width:e.width,height:e.height,image:e},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(e.width,e.height),this.waterMarkNode.image=e):this.update()):(this.pushWaterMarkImageList({x:t,y:i,width:o,height:n,image:e,zIndex:s,type:r,imageUrl:A.imageUrl,fillVideo:a}),yield this.freshWatermark()),this.log.info("set watermark",JSON.stringify(this.watermarkImageList,(A,e)=>"imageUrl"===A?void 0:e))})}deleteWatermark(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return VS(this,null,function*(){this.watermarkImageList=this.watermarkImageList.filter(e=>e.type!==A),this.log.info("delete watermark",A,JSON.stringify(this.watermarkImageList,(A,e)=>"imageUrl"===A?void 0:e)),yield this.freshWatermark()})}freshWatermark(){return VS(this,null,function*(){var A;null==(A=this.waterMarkNode)||A.close(),delete this.waterMarkNode,delete this._waterMarkOption;let{width:e,height:t}=this.cameraResolution,i=yield this.getWatermarkImage(e,t);this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update()})}setVirtualBackground(A){return VS(this,null,function*(){var e,t,i;if(A){if(A.onAbort&&(this._virtualBackgroundAbortCallback=A.onAbort),this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=A.assetPath,"image"===A.type?this._virtualBackground=yield fT(A.imageUrl):(this.blurRadius=A.blurLevel||this.blurRadius||3,this._virtualBackground=A.type),this._enableFaceCentering=null!=(e=A.enableFaceCentering)?e:this._enableFaceCentering,this._enableEffectOptimization=null!=(t=A.enableEffectOptimization)?t:this._enableEffectOptimization,this._color=null!=(i=A.color)?i:[0,1,0]}else delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;if(this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==A?void 0:A.type)||"",", ").concat(this.blurRadius||"")),yield this.update(),this._virtualBackground&&!this._glVideoContext.available)throw new rM({code:oM.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)})})}get mixScreen(){return this._isMixScreen}set mixScreen(A){var e;this._isMixScreen=A,this._isMixScreen||(null==(e=this.screenNode)||e.close(),delete this.screenNode),this.update()}set mirror(A){var e;this._isMirror!==A&&(this._isMirror=A,this._isTransform||(null==(e=this.transformNode)||e.close(),delete this.transformNode),this.update())}get mirror(){return this._isMirror}set rotation(A){var e;this._rotation!==A&&(this._rotation=A,this._isTransform||(null==(e=this.transformNode)||e.close(),delete this.transformNode),this.update())}get rotation(){return this._rotation}enableAr(A){this.arTrack=A,this.isUsingArTrack=!0,this.update()}updateAr(){return VS(this,null,function*(){var A;null!=(A=this.cameraTrack)&&A.mediaTrack&&(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))})}disableAr(){var A;this.isUsingArTrack=!1,null==(A=this.arTrack)||A.stop(),this.arTrack=void 0,this.update()}createDecodeContext(A){return new Xq(A)}clear(){var A,e;null==(A=this.videoContext)||A.disconnect(),null==(e=this.destination)||e.removeAllListeners(),delete this.destination,delete this.cameraNode,delete this.transformNode,delete this.screenNode,delete this.waterMarkNode}addEncodeProcessor(A){let{processor:e,type:t}=A;var i;this.encodePipeline.includes(e)||(this.encodePipeline[t]=e,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(A){let{processor:e,type:t}=A;var i;this.decodePipeline.includes(e)||(this.decodePipeline[t]=e,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(A){let{type:e}=A;this.encodePipeline[e]=void 0}removeDecodeProcessor(A){let{type:e}=A;this.decodePipeline[e]=void 0}};JS([OF(function(A){this.log.error("update failed",A)}),xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;i{A.apply(this,t).then(e,i),setTimeout(i,5e3,new rM({code:oM.API_CALL_TIMEOUT,message:"update timeout"}))}),this._updateFlag=!1,yield this.updated)})})],AV.prototype,"update",1);var eV=0,tV=class extends ZL{constructor(A){super("room"),HS(this,"seq",++eV),HS(this,"sdkAppId"),HS(this,"userId"),HS(this,"userSig"),HS(this,"privateMapKey"),HS(this,"latencyLevel"),HS(this,"tinyId"),HS(this,"scene"),HS(this,"roomId"),HS(this,"useStringRoomId"),HS(this,"role","anchor"),HS(this,"joinParams",null),HS(this,"localPublishFlag",0),HS(this,"localTracks",new Set),HS(this,"enableAutoPlayDialog",!0),HS(this,"autoReceiveAudio",!0),HS(this,"autoReceiveVideo",!0),HS(this,"proxy_ws"),HS(this,"proxy_wt"),HS(this,"proxy_unified"),HS(this,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0,isH265EncodeSupported:!0,isH265DecodeSupported:!0}}),HS(this,"keyPointManager"),HS(this,"audioManager"),HS(this,"videoManager"),HS(this,"callDurationCalculator"),HS(this,"badCaseDetector"),HS(this,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),HS(this,"videoDecodeFallbackType"),HS(this,"smallMode","canvas"),HS(this,"enableChorus",!1),HS(this,"_isUsingCachedSchedule",!1),HS(this,"_log"),HS(this,"_joinedTimestamp",0),HS(this,"_sdkType"),HS(this,"heartbeatReport"),HS(this,"heartbeatCount",0),HS(this,"quality"),HS(this,"enableSEI"),HS(this,"isDestroyed",!1),this._log=sG.createLogger({parent:A.logger,id:"r".concat(this.seq)}),this.useStringRoomId=!!A.useStringRoomId,j_(A.autoReceiveAudio)&&(this.autoReceiveAudio=A.autoReceiveAudio),j_(A.autoReceiveVideo)&&(this.autoReceiveVideo=A.autoReceiveVideo),j_(A.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=A.enableAutoPlayDialog),this._sdkType=A.sdkType,this.keyPointManager=new Pq({room:this,frameWorkType:A.frameWorkType,component:A.component,language:A.language}),this.callDurationCalculator=new Jq({room:this}),this.badCaseDetector=new qq({room:this}),this.audioManager=new tY(this),this.videoManager=new AV(this)}get videoCodec(){return"h264"}get scriptTransformWorker(){}get isMainStreamPublished(){for(let A of this.localTracks)if(4&A.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let A of this.localTracks)if(2&A.mediaType)return!0;return!1}get hasAuxStream(){for(let A of this.remotePublishedUserMap.values())if(A.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}get localMainAudioTrack(){for(let A of this.localTracks)if(1&A.mediaType)return A;return null}get localMainVideoTrack(){for(let A of this.localTracks)if(4&A.mediaType)return A;return null}get localAuxVideoTrack(){for(let A of this.localTracks)if(2&A.mediaType)return A;return null}get publishState(){let A={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};return this.localTracks.forEach(e=>{if(e.isPublished||e.isPublishing)switch(e.mediaType){case 1:A.audio=!0;break;case 4:A.bigVideo=!0,A.smallVideo=e.hasSmall;break;case 2:A.auxVideo=!0}}),A}get muteState(){var A,e,t;return{audio:!(null==(A=this.localMainAudioTrack)||!A.muted),bigVideo:!(null==(e=this.localMainVideoTrack)||!e.muted),auxVideo:!(null==(t=this.localAuxVideoTrack)||!t.muted)}}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(A){return VS(this,null,function*(){return this.publish(A)})}removeTrack(A){return VS(this,null,function*(){return this.unpublish(A)})}replaceTrack(A){return VS(this,null,function*(){})}setEncodedDataProcessingListener(A){throw new Error("Method not implemented.")}enableAIVoice(A){throw new Error("Method not implemented.")}setProxyServer(A){if(q_(A))/^wss?:\/\//i.test(A)?this.proxy_ws=A:/^https?:\/\//i.test(A)&&(this.proxy_wt=A);else if(O_(A)){let{websocketProxy:e,webtransportProxy:t,loggerProxy:i,scheduleProxy:o,unifiedProxy:n}=A;this.proxy_ws=e,this.proxy_wt=t,this.proxy_unified=n,n?(cJ([n,n]),vM("https://".concat(n))):(i&&vM(i),o&&cJ(o))}tG.once(oG.JOIN_RECEIVED_CMD_RES,()=>this.sendAbilityStatus({sched_domain:gJ.main,sched_back_domain:gJ.backup,signal_domain:this.proxy_ws||this.proxy_wt||""}))}getRemoteAudioStats(){return VS(this,null,function*(){let A={};return this.remotePublishedUserMap.forEach(e=>{A[e.userId]=e.remoteAudioTrack.stat}),A})}getTransportStats(){return VS(this,null,function*(){var A;let e={rtt:(null==(A=this.quality)?void 0:A.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let t of this.quality.downlinkInfo)e.downlinksRTT[t.userId]=t.rtt;return e})}getRemoteVideoStats(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let t={};return A.remotePublishedUserMap.forEach(A=>{let i="auxiliary"===e?A.remoteAuxiliaryTrack:A.remoteVideoTrack;t[A.userId]=i.stat}),t}()})}checkDestroy(){if(this.isDestroyed)throw new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(Qk.INVALID_DESTROY),new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,tG.emit(oG.ROOM_DESTROY,{room:this})}schedule(A,e){return VS(this,null,function*(){var t,i,o,n;let r=oT();try{let{isCached:s,result:a,detailCost:g}=yield aJ({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?A.strRoomId:A.roomId,useStringRoomId:this.useStringRoomId,version:CM,userSig:this.userSig,role:"live"===this.scene?A.role:void 0,frameWorkType:e,latencyLevel:A.latencyLevel});this._isUsingCachedSchedule=s,this._log.info("schedule cache:".concat(+s," ").concat(CT(a,{keysToExclude:["username","credential"]}))),s&&tG.once(oG.JOIN_RECEIVED_CMD_RES,()=>this.sendAbilityStatus({scheduleCache:1})),this.scheduleResult=US(US({},this.scheduleResult),a),V_(null==(t=a.config)?void 0:t.retryCount)&&mR(a.config.retryCount),q_(null==(i=a.config)?void 0:i.loggerDomain)&&vM(a.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=a.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,this.smallMode=(null==(n=a.config)?void 0:n.smallMode)||this.smallMode,tG.emit(oG.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:g}),Gk.addSuccessEvent({key:521700,cost:oT()-r})}catch(s){throw Gk.addFailedEvent({key:521700,error:s}),s}})}sendAbilityStatus(A){}enableInsertableStreams(){return Promise.resolve()}switchRoom(A){return Promise.reject()}isSwitchRoomSupported(){return!1}},iV=YS(jS()),oV=YS(eM());function nV(A){var e;let t=[];for(let i=0;ie.payload===A.rtp[i].payload)[0];t.push({payload:A.rtp[i].payload,codec:A.rtp[i].codec,fmtp:o?o.config:"",rate:A.rtp[i].rate,rtx:"rtx"===(null==(e=A.rtp[i+1])?void 0:e.codec)?A.rtp[i+1].payload:0,rtcpfb:((null==A?void 0:A.rtcpFb)||[]).filter(e=>e.payload===A.rtp[i].payload).map(A=>{let{type:e,subtype:t}=A;return{id:e,params:t?[t]:[]}})})}return t}var rV=(A,e,t)=>VS(null,null,function*(){var i;let o=Dq(A),n={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],decoders:[],extensions:[]},useDataChannel:t};n.ice.ufrag=String(o.media[0].iceUfrag),n.ice.password=o.media[0].icePwd||"",o.fingerprint&&(n.dtls.hash=o.fingerprint.type,n.dtls.fingerprint=o.fingerprint.hash,n.dtls.setup=o.setup||""),o.media[0].fingerprint&&(n.dtls.hash=o.media[0].fingerprint.type,n.dtls.fingerprint=o.media[0].fingerprint.hash),n.dtls.setup=o.media[0].setup||"";let r=o.media[0],s=o.media[1];r.ext&&(n.audio.extensions=r.ext.map(A=>({id:A.value,uri:A.uri}))),s.ext&&(n.video.extensions=s.ext.map(A=>({id:A.value,uri:A.uri})));for(let A of r.rtp){if("opus"!==A.codec)continue;let e=r.fmtp.find(e=>e.payload===A.payload);if(!e)continue;let t={codec:A.codec,fmtp:e.config,payload:e.payload,rate:A.rate,channels:A.encoding,rtcpfb:[],rtx:0};null==(i=r.rtcpFb)||i.forEach(A=>{let{payload:e,type:i,subtype:o}=A;if(e===t.payload){let A={id:i,params:[]};o&&A.params.push(o),t.rtcpfb.push(A)}}),n.audio.codecs.push(t);break}let a=["h264","vp8","h265"];return e&&a.shift(),n.video.codecs=[...nV(s)].filter(A=>a.includes(A.codec.toLocaleLowerCase())),n.video.decoders=(yield function(){return VS(this,null,function*(){let A=new RTCPeerConnection;A.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_RECVONLY});let e=yield A.createOffer();if(!e.sdp)return[];let t=nV(Dq(e.sdp).media[0]);return A.close(),t})}()).filter(A=>["h264","vp8","h265"].includes(A.codec.toLocaleLowerCase())),n}),sV=(A,e)=>{let t=(A||"").trim(),i=(e||"").trim(),o="profile-level-id",n="".concat(o,"=[0-9a-fA-F]{6}");if(new RegExp(n).test(t)){let A=new RegExp(n,"g");return t.replace(A,"".concat(o,"=").concat(i))}if(!t)return"".concat(o,"=").concat(i);let r=t.endsWith(";")?"":";";return"".concat(t).concat(r).concat(o,"=").concat(i)},aV=A=>{let{serverAbility:e,clientAbility:t,offerSDP:i,enableCustomMessage:o,profileLevelIdConfig:n}=A,r=Dq(i),s={extmapAllowMixed:"extmap-allow-mixed",groups:r.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},a={candidates:e.candidates.map(A=>({component:1,foundation:"1",generation:0,ip:A.ip,port:A.port,priority:A.priority,transport:A.foundation,type:A.type})),connection:{version:4,ip:"0.0.0.0"},direction:WM.TRANSCEIVER_DIRECTION_RECVONLY,ext:e.audio.extensions.map(A=>({value:A.id,uri:A.uri})),fingerprint:{type:e.dtls.hash,hash:e.dtls.fingerprint},fmtp:[{payload:e.audio.codecs[0].payload,config:e.audio.codecs[0].fmtp}],icePwd:e.ice.password,iceUfrag:e.ice.ufrag,mid:"0",payloads:String(e.audio.codecs[0].payload),port:r.media[0].port,protocol:r.media[0].protocol,type:WM.AUDIO,setup:e.dtls.setup,rtcpFb:e.audio.codecs[0].rtcpfb.map(A=>({payload:e.audio.codecs[0].payload,type:A.id,subtype:A.params[0]})),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:e.audio.codecs[0].payload,codec:e.audio.codecs[0].codec,rate:e.audio.codecs[0].rate,encoding:e.audio.codecs[0].channels}]};s.media.push(a);let g=[null==n?void 0:n.big,null==n?void 0:n.small,null==n?void 0:n.aux];return[1,2,3].forEach((A,i)=>{s.media.push(gV({mid:A,serverAbility:e,clientAbility:t,parsedOffer:r,profileLevelId:g[i]}))}),o&&s.media.push(r.media.find(A=>"dc"===A.mid)),vq(s)},gV=A=>{let{mid:e,serverAbility:t,clientAbility:i,parsedOffer:o,isDownlink:n=!1,profileLevelId:r}=A,s={candidates:t.candidates.map(A=>({component:1,foundation:"1",generation:0,ip:A.ip,port:A.port,priority:A.priority,transport:A.foundation,type:A.type})),connection:{version:4,ip:"0.0.0.0"},direction:WM.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.video.extensions.map(A=>({value:A.id,uri:A.uri})),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:String(e),payloads:"",port:o.media[0].port,protocol:o.media[0].protocol,type:WM.VIDEO,setup:t.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(n){let A=t.video.decoders;(!A||0===A.length)&&(A=t.video.codecs),(!A||0===A.length)&&(A=i.video.decoders),A.forEach(A=>{cV(s,A)})}else{let A;A=t.useH265?t.video.codecs.findIndex(A=>"h265"===A.codec.toLowerCase()):t.video.codecs.findIndex(A=>A.codec.toLowerCase()===(t.useVp8?"vp8":"h264"));let e=t.video.codecs[A]||i.video.codecs[0];cV(s,e)}if(!n&&r){let A=s.fmtp,e=s.rtp.find(A=>{var e;return"h264"===(null==(e=A.codec)?void 0:e.toLowerCase())});if(e){let t=A.find(A=>String(A.payload)===String(e.payload));t&&(t.config=sV(t.config,r))}}return s},cV=(A,e)=>{A.payloads="".concat(A.payloads," ").concat(e.payload).trim(),A.fmtp.push({payload:e.payload,config:e.fmtp}),A.rtcpFb=[...A.rtcpFb||[],...e.rtcpfb.map(A=>({payload:e.payload,type:A.id,subtype:A.params[0]}))],A.rtp.push({payload:e.payload,codec:e.codec.toUpperCase(),rate:e.rate}),e.rtx&&(A.payloads="".concat(A.payloads," ").concat(e.rtx),A.fmtp.push({payload:e.rtx,config:"apt=".concat(e.payload)}),A.rtp.push({payload:e.rtx,codec:"rtx",rate:e.rate}))},lV=(A,e,t)=>{let i=oV.default.parse(A);return i.media.forEach((A,o)=>{var n,r;if((A.type===WM.AUDIO||A.type===WM.VIDEO)&&(function(A){if(!A.rtcpFb)return;let e=[];A.rtcpFb.forEach((t,i)=>{var o;e.push(t),A.rtcpFb&&(null==(o=A.rtcpFb[i+1])?void 0:o.payload)!==t.payload&&"rrtr"!==t.type&&e.push({payload:t.payload,type:"rrtr"})}),A.rtcpFb=e}(A),(r=A).type===WM.VIDEO&&r.fmtp&&r.fmtp.forEach(A=>{A.config.includes("apt")||(A.config+=";sps-pps-idr-in-keyframe=1")}),function(A){A.type===WM.AUDIO&&A.fmtp&&A.fmtp.forEach(A=>{A.config+=";sprop-stereo=1;stereo=1"})}(A),function(A){let e=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);A.ext&&(A.ext=A.ext.filter(A=>!e.has(A.uri)))}(A),A.type===WM.VIDEO))if(o<4)A.payloads="",A.fmtp=[],A.rtp=[],A.rtcpFb=[],e.video.codecs.forEach(e=>cV(A,e));else if(t){A.payloads="",A.fmtp=[],A.rtp=[],A.rtcpFb=[];let i=t.video.decoders;(!i||0===i.length)&&(i=t.video.codecs),(!i||0===i.length)&&(i=e.video.decoders),i.forEach(e=>cV(A,e))}null!=(n=A.payloads)&&n.includes("datachannel")&&i.groups&&A.mid&&(i.groups[0].mids=i.groups[0].mids.replace(A.mid,"dc"),A.mid="dc")}),oV.default.write(i)};function IV(A){var e,t;let i=/profile-level-id=([0-9a-fA-F]{6})/.exec(A);return null!=(t=null==(e=null==i?void 0:i[1])?void 0:e.toLowerCase())?t:null}function uV(A){let e=A.toLowerCase();if(!/^[0-9a-f]{6}$/.test(e))return"unknown";let t=parseInt(e.slice(0,2),16);return 66===t?"baseline":77===t?"main":100===t?"high":"unknown"}function EV(A,e){if(!e)return"";let t=A.trim().toLowerCase().replace(/_/g,"-");if(!t)return"";if(/^[0-9a-f]{6}$/.test(t))return t;if("baseline"!==t&&"main"!==t&&"high"!==t)return"";for(let i of e.video.codecs){let A=IV(i.fmtp);if(A&&uV(A)===t)return A}return""}var dV=YS(jS()),hV=class extends dV.EventEmitter{constructor(A){super(),this.room=A,HS(this,"mainFpsHealth",1),HS(this,"mainBitrateHealth",1),HS(this,"badMainBitrateHealthCount",0),HS(this,"lastEmitBadHealthTime",0),HS(this,"log"),!lN&&Eb&&tG.on("262",this.onVideoCodecChanged,this),this.log=A.getLogger().createChild({id:"h-d"})}onVideoCodecChanged(A){let{remoteUserId:e,streamType:t,isHWCodec:i,codec:o}=A;if(!e&&7!==t&&"h264"===o){if(!i)return void this.room.off("heartbeat-report",this.onHeartbeatReport,this);this.room.listeners("heartbeat-report").includes(this.onHeartbeatReport)||this.room.on("heartbeat-report",this.onHeartbeatReport,this)}}onHeartbeatReport(A){Date.now()-this.lastEmitBadHealthTime<3e4||(A.msg_up_stream_info.msg_video_status.forEach(A=>{if(A.uint32_video_enc_fps&&A.uint32_video_capture_fps){let e=A.uint32_video_enc_fps/A.uint32_video_capture_fps;2===A.uint32_video_stream_type&&(this.mainFpsHealth=e)}if(A.uint32_video_codec_bitrate&&2===A.uint32_video_stream_type){let{localMainVideoTrack:e}=this.room;e&&(this.mainBitrateHealth=A.uint32_video_codec_bitrate/1e3/e.profile.bitrate)}}),this.log.debug("mainBitrateHealth: ".concat(this.mainBitrateHealth," mainFpsHealth: ").concat(this.mainFpsHealth)),this.mainBitrateHealth>.5&&(this.badMainBitrateHealthCount=0),this.mainFpsHealth>.9&&this.mainBitrateHealth<.5&&(this.badMainBitrateHealthCount++,this.badMainBitrateHealthCount>3&&(this.badMainBitrateHealthCount=0,this.lastEmitBadHealthTime=Date.now(),this.log.warn("bad main bitrate health: ".concat(this.mainBitrateHealth)),this.emit("1",{isAux:!1}))))}destroy(){tG.off("262",this.onVideoCodecChanged,this),this.room.off("heartbeat-report",this.onHeartbeatReport,this)}};HS(hV,"EVENT_BAD_HEALTH","bad_health");var CV=hV,BV=(A=>(A.TRACK="track",A.DATA_CHANNEL_MESSAGE="data_channel_msg",A[A.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",A[A.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",A.RECONNECTED="spc-reconnected",A.RECONNECT_FAILED="spc-reconnect-failed",A.ERROR="error",A.SEI_MESSAGE="sei-message",A.DUMP="dump",A))(BV||{}),QV=1,pV=class extends iV.default{constructor(A){let{signalChannel:e,room:t,enableDataChannel:i}=A;super(),HS(this,"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),HS(this,"isDestroyed",!1),HS(this,"currentState","DISCONNECTED"),HS(this,"_room"),HS(this,"_signalChannel"),HS(this,"_peerConnection",null),HS(this,"_datachannel",null),HS(this,"_enableDataChannel"),HS(this,"_log"),HS(this,"_downlinkMIDMap",new Map),HS(this,"_downlinkMIDUserIDMap",new Map),HS(this,"_reconnectionTimer",-1),HS(this,"reconnectionCount",0),HS(this,"clientAbility"),HS(this,"_serverAbility",null),HS(this,"addDownlinkQueue",new Set),HS(this,"removeDownlinkQueue",new Set),HS(this,"_parsedAnswer",null),HS(this,"_updateSDPPromise",null),HS(this,"_waitForPCConnectedPromise"),HS(this,"clearWaitForConnectedPromise"),HS(this,"clearConnectTimeout"),HS(this,"_isSDPLogged",!1),HS(this,"enableInsertableStreams",!1),HS(this,"insertableStreamsAbortMap",new Map),HS(this,"receiverRemoteTrackMap",new WeakMap),HS(this,"scriptTransformWorker"),HS(this,"_isRelayTried",!1),HS(this,"_rttOverCount",0),HS(this,"originOffer",null),HS(this,"autoSubscribedSsrcGroups",new Map),HS(this,"autoSubscribedUserMap",new Map),HS(this,"_h265DecodeFailed",!1),this._room=t,this._enableDataChannel=i,this._signalChannel=e,this._log=sG.createLogger({parent:this._room.getLogger(),id:"spc".concat(QV++),userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this._room.enableCodecPipeline&&(mL?this.enableInsertableStreams=!0:this.initScriptTransformWorker()),this._room.healthDetector.on("1",this.onBadHealth,this)}get isH264EncodeSupported(){let A=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(A=A&&!!this._serverAbility.video.codecs.find(A=>"h264"===A.codec.toLowerCase())),A}addAbortController(A,e){var t;null==(t=this.insertableStreamsAbortMap.get(A))||t.abort("destroy"),this.insertableStreamsAbortMap.set(A,e)}get isVP8EncodeSupported(){let A=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(A=A&&this._serverAbility.video.codecs.find(A=>"vp8"===A.codec.toLowerCase())),A}get isH265EncodeSupported(){let A=this._room.checkSystemResult.detail.isH265EncodeSupported;return this._serverAbility&&(A=A&&!!this._serverAbility.video.codecs.find(A=>"h265"===A.codec.toLowerCase())),A}get videoCodec(){var A,e,t;let i=null==(A=this._parsedAnswer)?void 0:A.media[1].rtp.find(A=>["h264","vp8","h265"].includes(A.codec.toLowerCase()));return i?i.codec.toLowerCase():null!=(e=this._serverAbility)&&e.useH265?"h265":null!=(t=this._serverAbility)&&t.useVp8?"vp8":"h264"}get downlinkVideoCodec(){var A,e,t;return null!=(A=this._serverAbility)&&A.useH265&&null!=(e=this._serverAbility)&&e.video.decoders.find(A=>"h265"===A.codec.toLowerCase())&&!this._h265DecodeFailed?"h265":null!=(t=this._serverAbility)&&t.video.decoders.find(A=>"h264"===A.codec.toLowerCase())?"h264":"vp8"}get isUsingH264(){return"h264"===this.videoCodec}get isUsingH265(){return"h265"===this.videoCodec}get isUsingVP8(){return"vp8"===this.videoCodec}get is42001fSupported(){return!!this.clientAbility&&!!this.clientAbility.video.codecs.find(A=>A.fmtp.includes("42001f"))}isProfileLevelIdSupported(A){return!!this.clientAbility&&!!this.clientAbility.video.codecs.find(e=>e.fmtp.includes(A))}get uplinkSSRC(){return this._peerConnection&&this._peerConnection.localDescription?(A=>{let e=Dq(A),t={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return e.media.forEach((A,e)=>{var i;if(A.ssrcs&&!H_(A.ssrcs[0].id)){let o=Number(A.ssrcs[0].id),n=Number(null==(i=A.ssrcs.filter(A=>"cname"===A.attribute)[1])?void 0:i.id);switch(e){case 0:t.audioSsrc=o;break;case 1:t.bigVideoSsrc=o,t.bigVideoRtxSsrc=n;break;case 2:t.smallVideoSsrc=o,t.smallVideoRtxSsrc=n;break;case 3:t.auxVideoSsrc=o,t.auxVideoRtxSsrc=n}}}),t})(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}onBadHealth(A){}initScriptTransformWorker(){yL&&(this.scriptTransformWorker=SJ({videoEncodePipeline:this._room.videoManager.encodePipeline,videoDecodePipeline:this._room.videoManager.decodePipeline,audioEncodePipeline:this._room.audioManager.encodePipeline,audioDecodePipeline:this._room.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=A=>{"sei"===A.data.type?this.emit("sei-message",A.data):A.data.type,"dump"===A.data.type&&this.emit("dump",A.data)},this.scriptTransformWorker.onerror=A=>{this._log.error("scriptTransformWorker error: ",A.message)})}get isReconnecting(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}get dtlsTransport(){if(!this._peerConnection)return null;let A=this._peerConnection.getSenders();return 0===A.length?null:A[0].transport}getPeerConnectionConfig(A){var e;let t={encodedInsertableStreams:this.enableInsertableStreams,offerExtmapAllowMixed:!0,iceServers:A,iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"},i=null==(e=this._peerConnection)?void 0:e.getConfiguration().encodedInsertableStreams;return jT(i)&&(t.encodedInsertableStreams=i),this._log.debug("getPeerConnectionConfig",JSON.stringify(t)),t}initialize(A){return VS(this,null,function*(){var e;let t;try{return this._peerConnection=new RTCPeerConnection(this.getPeerConnectionConfig(A)),this._peerConnection.oniceconnectionstatechange=()=>{if(!this._peerConnection)return;let A=this._peerConnection.iceConnectionState;this._log.debug("ice state: ".concat(A)),"checking"===A&&0===this.stat.iceStartTime?this.stat.iceStartTime=Date.now():"connected"===A&&0===this.stat.iceEndTime?(this.stat.iceEndTime=Date.now(),this._signalChannel.clearBakRelayIps(),Gk.addSuccessEvent({key:521711,cost:this.stat.iceEndTime-this.stat.iceStartTime})):"failed"===A&&Gk.addFailedEvent({key:521711})},this._peerConnection.onsignalingstatechange=()=>{var A;let e=(null==(A=this._peerConnection)?void 0:A.signalingState)||"";this._log["closed"===e?"debug":"info"]("signaling state: ".concat(e))},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=A=>this.emit("track",A),this._enableDataChannel&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=()=>{this._log.info("datachannel open")},this._datachannel.onclose=()=>{this._log.warn("datachannel close")},this._datachannel.onmessage=A=>{let e=new mV(A.data);this.emit("data_channel_msg",{data:e})},this._datachannel.onerror=A=>{this._log.warn("datachannel error",A)}),this._peerConnection.addTransceiver(WM.AUDIO,{direction:WM.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_SENDONLY}),t=yield this._peerConnection.createOffer(),this.clientAbility=yield rV(t.sdp,(null==(e=this._room.scheduleResult.config)?void 0:e.remove264FromSDP)||!1,this._enableDataChannel),this.originOffer=t,this.dtlsTransport&&(this.dtlsTransport.onstatechange=()=>{let{dtlsTransport:A}=this;A&&(this._log.debug("dtls state: ".concat(A.state)),"connecting"===A.state&&0===this.stat.dtlsStartTime?this.stat.dtlsStartTime=Date.now():"connected"===A.state&&0===this.stat.dtlsEndTime&&(this.stat.dtlsEndTime=Date.now()))}),Gk.addSuccessEvent({key:521707}),this.clientAbility}catch(i){throw Gk.addFailedEvent({key:521707,error:i}),this._log.error("initialize failed ".concat(i," \noffer: ").concat(null==t?void 0:t.sdp)),i}})}setIceServers(A){return VS(this,null,function*(){var e;if(this._peerConnection&&0!==A.length)try{if(this._log.info("setIceServers",JSON.stringify(A,(A,e)=>"username"===A||"credential"===A?"hided":e)),this._peerConnection.setConfiguration(this.getPeerConnectionConfig(A)),null!=(e=this._peerConnection)&&e.localDescription||!this.originOffer)return void this._log.warn("setIceServers already has localDescription or no origin Offer");yield this.setOffer(this.originOffer)}catch(t){this._log.warn("setIceServers error ",t)}})}setPriority(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"high";if(this._peerConnection)try{this._peerConnection.getSenders().forEach(e=>{let t=e.getParameters();t.encodings[0]&&(t.encodings[0].priority=A,t.encodings[0].networkPriority=A,e.setParameters(t).catch(A=>{this._log.warn("setPriority error ",A)}))})}catch(e){this._log.warn("setPriority error ",e)}}connect(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return VS(this,null,function*(){var t,i,o;try{if("CONNECTED"===this.currentState)return;(null==(t=this._peerConnection)||!t.localDescription)&&this.originOffer&&(yield this.setOffer(this.originOffer));let n=oT(),r=this.getProfileLevelIdConfig(),s={type:"answer",sdp:aV({serverAbility:A,clientAbility:this.clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableDataChannel,profileLevelIdConfig:r})};this._serverAbility=A,yield this.setAnswer(s),yield this.waitForPeerConnectionConnected(),this._room.firewallDetector.resetTimeoutCount();let a=(null==(i=this._room.scheduleResult.config)?void 0:i.priority)||(null==(o=this._room.joinParams)?void 0:o.priority)||new URLSearchParams(location.search).get("priority");a&&this.setPriority(a),e||Gk.addSuccessEvent({key:521703,cost:oT()-n})}catch(n){let e=n instanceof rM&&n.code===oM.API_CALL_ABORTED;throw e||this._log.error("connect failed: ".concat(n),A),this.reset(),!e&&!this.isReconnecting&&!this.isDestroyed&&(Gk.addFailedEvent({key:521703,error:n}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),n}})}reconnect(){return VS(this,null,function*(){if(-1===this._reconnectionTimer){if(!this._signalChannel.isConnected)return this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(MH,this.reconnect,this);try{this.reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset();let A=this._signalChannel.getBackupRelayIpPair(),e=yield this.initialize(this._room.getIceServers(null!=A&&A.iceServer?[A.iceServer]:[])),t=US({ability:e},A),i=yield this._signalChannel.sendWaitForResponse({command:rq,responseCommand:LH.REBUILD_PEER_CONNECTION_RES,data:t,enableLog:!1});if(0!==i.data.code)throw new rM({code:i.data.code,message:i.data.message});yield this.connect(i.data.data.ability,!0),Gk.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),tG.emit(oG.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected")}catch(A){if(!this.isReconnecting||this.isDestroyed)return;if(null!=A&&A.message.includes("timeout")){let A=P_(this.reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(A/1e3,"s")),yield DT(A,A=>{this._reconnectionTimer=A}),this.clearReconnectionTimer(),yield this.reconnect()}else this._log.error("reconnect() failed ".concat(null==A?void 0:A.code," ").concat(A)),Gk.addFailedEvent({key:521704,error:A}),this.reconnectionCount>=yR()&&this._log.warn("SDK has tried reconnect for ".concat(yR()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error")}}else this._log.warn("reconnect() is reconnecting, ignore current reconnection")})}getPeerConnection(){return this._peerConnection}startReconnection(){return VS(this,null,function*(){this.isReconnecting||(this._log.warn("start reconnect"),this._updateSDPPromise=null,this.emitConnectionStateChangedEvent("RECONNECTING"),yield this.reconnect())})}stopReconnection(){var A;this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),null==(A=this.clearConnectTimeout)||A.call(this),this._signalChannel.off(MH,this.reconnect,this),"RECONNECTING"===this.currentState&&this.emitConnectionStateChangedEvent("DISCONNECTED"))}checkPeerConnectionToReconnect(){var A;!this.isReconnecting&&(null==(A=this._peerConnection)?void 0:A.connectionState)===pR.CLOSED&&this.startReconnection()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onConnectionStateChange(A){var e;let t=(null==(e=this._peerConnection)?void 0:e.iceConnectionState)||"closed",i=this.getDTLSTransportState();this._log.info("connectionState: ".concat(A.target.connectionState," ICE: ").concat(t," DTLS: ").concat(i)),A.target.connectionState===pR.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(A.target.connectionState===pR.FAILED||A.target.connectionState===pR.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this._room.forceRelay?this.switchRelay(!1):this.startReconnection()),(A.target.connectionState===pR.CONNECTED||A.target.connectionState===pR.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),tG.emit(oG.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}getDTLSTransportState(){if(!this._peerConnection)return QR;let A=null;return cL()&&0!==this._peerConnection.getSenders().length?(A=this._peerConnection.getSenders()[0].transport,gL()&&0!==this._peerConnection.getReceivers().length&&A?A.state:QR):QR}emitConnectionStateChangedEvent(A){A!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===A||(this.emit(BV.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:A}),this.currentState=A))}logSelectedCandidate(){return VS(this,null,function*(){if(!this._peerConnection)return;let A=yield this._peerConnection.getStats();for(let[e,t]of A)if(AL(t)){let e=A.get(t.localCandidateId),i=A.get(t.remoteCandidateId);e&&(this._log.info("local candidate: ".concat(e.candidateType," ").concat(e.protocol,":").concat(e.ip||e.address,":").concat(e.port," ").concat(e.networkType||""," ").concat(e.relayProtocol?"relayProtocol:".concat(e.relayProtocol," url: ").concat(e.url):"")),e.networkType&&__(e.networkType)),i&&this._log.info("remote candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port));break}})}waitForPeerConnectionConnected(){return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise((A,e)=>{if("CONNECTED"===this.currentState)return A();let t=e=>{"CONNECTED"===e.state&&(clearTimeout(n),o(),A())},i=A=>{let{room:t}=A;t===this._room&&(clearTimeout(n),o(),e(new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.CONNECTION_ABORTED,data:"leave room"})})))},o=()=>{tG.off(oG.LEAVE_SUCCESS,i,this),this.off(BV.CONNECTION_STATE_CHANGED,t,this)},n=setTimeout(()=>{o();let A=new rM({code:oM.API_CALL_TIMEOUT,message:"connection timeout"});this._room.firewallDetector.increaseTimeoutCount(),e(A)},OR);this.clearConnectTimeout=()=>{o(),clearTimeout(n),delete this.clearConnectTimeout},this.clearWaitForConnectedPromise=()=>{this._waitForPCConnectedPromise=null,e(new rM({code:oM.API_CALL_TIMEOUT,message:"connection timeout"}))},tG.on(oG.LEAVE_SUCCESS,i,this),this.on(BV.CONNECTION_STATE_CHANGED,t,this)}),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally(()=>{this._waitForPCConnectedPromise=null,delete this.clearConnectTimeout})),this._waitForPCConnectedPromise}waitForReconnected(){return this.isReconnecting?new Promise((A,e)=>{this.once("spc-reconnected",A),this.once("error",e)}):Promise.resolve()}addDownlink(A){return VS(this,null,function*(){if(this._log.info("addDownlink(".concat(A.userId,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise),this.updateLocalAndRemoteSDPConfig(A),0===this.addDownlinkQueue.size)try{yield this.updateSDP(),this._log.info("addDownlink(".concat(A.userId,") done"))}catch(e){this._log.error("addDownlink(".concat(A.userId,") failed ").concat(e)),yield this.startReconnection()}})}updateLocalAndRemoteSDPConfig(A){let{ssrc:e,userId:t,tinyId:i}=A;if(!this._peerConnection)return;this._log.info("updateLocalAndRemoteSDPConfig ".concat(t," ").concat(JSON.stringify(e)));let o=this._peerConnection.getTransceivers().slice(4).filter(A=>"inactive"===A.direction).slice(0,3).map(A=>(A.direction=WM.TRANSCEIVER_DIRECTION_RECVONLY,Number(A.mid)));this._parsedAnswer||(this._parsedAnswer=Dq(this._peerConnection.remoteDescription.sdp));let n,r,s,a=this._parsedAnswer.media.filter(A=>{var e;return null==(e=A.ssrcs)?void 0:e.find(A=>{var e;return null==(e=A.value)?void 0:e.includes(i)})});if(3===a.length)n=a[0],r=a[1],s=a[2];else if(3===o.length)n=this._parsedAnswer.media.find(A=>Number(A.mid)===Number(o[0])),r=this._parsedAnswer.media.find(A=>Number(A.mid)===Number(o[1])),s=this._parsedAnswer.media.find(A=>Number(A.mid)===Number(o[2]));else if(0===o.length){this._peerConnection.addTransceiver(WM.AUDIO,{direction:WM.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(WM.VIDEO,{direction:WM.TRANSCEIVER_DIRECTION_RECVONLY}),n=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));let A=gV({mid:1,serverAbility:this._serverAbility,clientAbility:this.clientAbility,parsedOffer:Dq(this._peerConnection.localDescription.sdp),isDownlink:!0});r=JSON.parse(JSON.stringify(A)),s=JSON.parse(JSON.stringify(A)),n.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(n),r.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(r),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}n.direction=WM.TRANSCEIVER_DIRECTION_SENDONLY;let g="".concat(i,"-").concat(e.audio);n.ssrcs=[{id:e.audio,attribute:"cname",value:"".concat(g)},{id:e.audio,attribute:"msid",value:"".concat(g,"-").concat(WM.MAIN," ").concat(g,"-audio")}],r.direction=WM.TRANSCEIVER_DIRECTION_SENDONLY,r.ssrcs=[{id:e.video,attribute:"cname",value:"".concat(g)},{id:e.video,attribute:"msid",value:"".concat(g,"-").concat(WM.MAIN," ").concat(g,"-bigvideo")},{id:e.videoRtx,attribute:"cname",value:"".concat(g)},{id:e.videoRtx,attribute:"msid",value:"".concat(g,"-").concat(WM.MAIN," ").concat(g,"-bigvideo")}],r.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(e.video," ").concat(e.videoRtx)}],s.direction=WM.TRANSCEIVER_DIRECTION_SENDONLY;let c="".concat(g,"-aux");s.ssrcs=[{id:e.auxiliary,attribute:"cname",value:c},{id:e.auxiliary,attribute:"msid",value:"".concat(c," ").concat(g,"-aux").concat(WM.VIDEO)},{id:e.auxiliaryRtx,attribute:"cname",value:"".concat(c," ").concat(g,"-aux").concat(WM.VIDEO)},{id:e.auxiliaryRtx,attribute:"msid",value:"".concat(c," ").concat(g,"-aux").concat(WM.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(e.auxiliary," ").concat(e.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map(A=>A.mid).join(" ")),this._downlinkMIDMap.set(t,[n.mid,r.mid,s.mid]),this._downlinkMIDUserIDMap.set(n.mid,t),this._downlinkMIDUserIDMap.set(r.mid,t),this._downlinkMIDUserIDMap.set(s.mid,t)}removeDownlink(A){return VS(this,null,function*(){if(!this._downlinkMIDMap.has(A)||!this._peerConnection)return;this._log.info("removeDownlink(".concat(A,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise);let e=this._downlinkMIDMap.get(A),t=!1;this._peerConnection.getTransceivers().forEach(A=>{null!=e&&e.includes(Number(A.mid))&&(t=!0,A.direction="inactive")}),this._parsedAnswer||(this._parsedAnswer=Dq(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach(A=>{null!=e&&e.includes(Number(A.mid))&&(t=!0,A.direction="inactive",A.ssrcs=[],A.ssrcGroups=[])}),0===this.removeDownlinkQueue.size&&t&&(yield this.updateSDP()),this._downlinkMIDMap.delete(A),null==e||e.forEach(A=>this._downlinkMIDUserIDMap.delete(A)),this._log.info("removeDownlink(".concat(A,") done"))})}setBandwidth(A){return VS(this,null,function*(){if(!this._peerConnection)return;let{audio:e,bigVideo:t,smallVideo:i,auxVideo:o}=A;try{if(CL()){let A=this._peerConnection.getSenders().slice(0,4);for(let r=0;r5e3?5e3:e),0))}setSenderMaxBitrate(A,e){let t=A.getParameters();if((!t.encodings||0===t.encodings.length)&&(t.encodings=[{}]),"unlimited"===e)delete t.encodings[0].maxBitrate;else{if(t.encodings[0].maxBitrate===1e3*e)return;t.encodings[0].maxBitrate=1e3*e}return A.setParameters(t)}setBandwidthBySDP(A){let{audio:e,bigVideo:t,smallVideo:i,auxVideo:o}=A;if(!this._peerConnection||!this._peerConnection.localDescription)return;let n=Dq(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=Dq(this._peerConnection.remoteDescription.sdp));let r=dN?"TIAS":"AS";e&&(n.media[0].bandwidth=[{type:r,limit:dN?1e3*e:e}],this._parsedAnswer.media[0].bandwidth=[{type:r,limit:dN?1e3*e:e}]),t&&(n.media[1].bandwidth=[{type:r,limit:dN?1e3*t:t}],this._parsedAnswer.media[1].bandwidth=[{type:r,limit:dN?1e3*t:t}]),i&&(n.media[2].bandwidth=[{type:r,limit:dN?1e3*i:i}],this._parsedAnswer.media[2].bandwidth=[{type:r,limit:dN?1e3*i:i}]),o&&(n.media[3].bandwidth=[{type:r,limit:dN?1e3*o:o}],this._parsedAnswer.media[3].bandwidth=[{type:r,limit:dN?1e3*o:o}]);let s={type:"offer",sdp:vq(n)};return this.updateSDP({localDescription:s})}setScaleResolutionDownBy(A,e,t){let i=A.getParameters();(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]);let o=i.encodings[0].scaleResolutionDownBy;if(H_(o)?1===e:e===o)return;let n="setScaleResolutionDownBy ".concat(t," ").concat(e);return o&&(n+=" prevScale: ".concat(o)),this._log.warn(n),i.encodings[0].scaleResolutionDownBy=e,A.setParameters(i)}setDegradationPreference(A,e,t){if(Eb&&Cb<83||gN&&wb(vb,"12.1")||dN&&CN<138)return;let i=A.getParameters(),o="balanced";if("motion"===e?o="maintain-framerate":"detail"===e&&(o="maintain-resolution"),i.degradationPreference===o)return;let n="setDegradationPreference ".concat(t," ").concat(o);return this._log.info(n),i.degradationPreference=o,A.setParameters(i).catch(A=>this._log.warn("".concat(n," failed: ").concat(A)))}updateSDP(){let{localDescription:A}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._parsedAnswer)return Promise.resolve();let e=vq(this._parsedAnswer);return this._updateSDPPromise=new Promise((t,i)=>VS(this,null,function*(){var o,n;try{!A&&this._peerConnection&&(this._log.info("creating offer"),A=yield this._peerConnection.createOffer()),A&&(yield this.setOffer(A)),yield this.setAnswer({type:"answer",sdp:e}),this._updateSDPPromise=null,t()}catch(r){this._log.error(r),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.localDescription)?void 0:o.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==A?void 0:A.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(n=this._peerConnection.remoteDescription)?void 0:n.sdp)," \nnext answer: ").concat(this.filterSDPDirection(e))),this._log.warn("offer: ".concat(null==A?void 0:A.sdp)),this._log.warn("answer: ".concat(e)),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map(A=>{let{mid:e,currentDirection:t,direction:i,stopped:o}=A;return{mid:e,currentDirection:t,direction:i,stopped:o}})))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,i(r)}})),this._updateSDPPromise}setTransceiverDirection(A,e){return VS(this,null,function*(){if(!dN||!this._peerConnection||!this._parsedAnswer)return;this._log.info("setting transceiver ".concat(e.join(",")," direction to ").concat(A));let t=this._peerConnection.getTransceivers();e.forEach(e=>{t[e].direction!==A&&(t[e].direction=A)});for(let i of e){let e=this._parsedAnswer.media[i].direction;A===zM.INACTIVE&&e===zM.RECVONLY&&(this._parsedAnswer.media[i].direction=A),A===zM.SENDONLY&&e===zM.INACTIVE&&(this._parsedAnswer.media[i].direction=zM.RECVONLY)}yield this.updateSDP()})}filterSDPDirection(){return Dq(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map(A=>A.direction)}setOffer(A){this._log.info("setting offer");let e=lV(A.sdp,this.clientAbility,this._serverAbility);return this._log.debug(e),this._peerConnection.setLocalDescription({type:"offer",sdp:e})}setAnswer(A){return this._log.info("setting answer"),this._log.debug(A.sdp),this._peerConnection.setRemoteDescription(A)}switchVideoEncoder(A){return VS(this,null,function*(){if("h265"===A&&!this._parsedAnswer&&(this._parsedAnswer=Dq(this._peerConnection.remoteDescription.sdp)),!this._peerConnection||!this._parsedAnswer||!this._serverAbility)return;let e=!1;this._parsedAnswer.media.forEach(t=>{var i;if(t.type===WM.VIDEO){let o=this._serverAbility.video.codecs.find(e=>e.codec.toLowerCase()===A);o&&(null==(i=t.payloads)||!i.includes(String(o.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],cV(t,o),e=!0)}}),e&&(this._log.warn("switch video encoder to ".concat(A)),yield this.updateSDP())})}getScheduleProfileLevelId(A){var e;try{let t=null==(e=this._room.scheduleResult.config)?void 0:e.profileLevelId,i="";if(2===A?i=VT(null==t?void 0:t.big)?t.big:"":3===A?i=VT(null==t?void 0:t.small)?t.small:"":7===A&&(i=VT(null==t?void 0:t.aux)?t.aux:""),!i)return"";let o=EV(i,this.clientAbility);return o?this._log.info("use schedule profile level id: streamType=".concat(A,", raw=").concat(i,", resolved=").concat(o)):this._log.warn("schedule profile level id not resolved: streamType=".concat(A,", raw=").concat(i)),o}catch(t){return this._log.warn("getScheduleProfileLevelId error: ".concat(t)),""}}getProfileLevelIdConfig(){try{let A=new URLSearchParams(location.search).get("profileLevelId")||"",e=EV(A,this.clientAbility);if(e)return this._log.info("use url profile level id: raw=".concat(A,", resolved=").concat(e)),{big:e,small:e,aux:e};let t=this.getScheduleProfileLevelId(2),i=this.getScheduleProfileLevelId(3),o=this.getScheduleProfileLevelId(7);if(!t&&!i&&!o)return;let n={};return t&&(n.big=t),i&&(n.small=i),o&&(n.aux=o),n}catch(A){return void this._log.warn("getProfileLevelIdConfig error: ".concat(A))}}setH264ProfileLevelId(A,e){return VS(this,null,function*(){if(!this._peerConnection||!this._serverAbility)return;this._updateSDPPromise&&(yield this._updateSDPPromise),this._log.info("set H264 profile-level-id to ".concat(e?"high":"default"," for ").concat(A)),this._parsedAnswer||(this._parsedAnswer=Dq(this._peerConnection.remoteDescription.sdp));let t="main"===A?1:3,i=this._parsedAnswer.media[t];if(!i||i.type!==WM.VIDEO)return;let o=i.rtp||[],n=i.fmtp||[],r=o.find(A=>{var e;return"h264"===(null==(e=A.codec)?void 0:e.toLowerCase())});if(!r)return;let s=n.find(A=>String(A.payload)===String(r.payload));if(!s)return;let a=IV(s.config);if(!a)return;let g="high"===uV(a);if(e&&g||!e&&!g)return;let c=this._serverAbility.video.codecs.map(A=>IV(A.fmtp)).filter(Boolean).find(A=>{let t=uV(A);return e?"high"===t:"high"!==t});if(!c)return;let l=s.config;s.config=sV(s.config,c),s.config!==l&&(yield this.updateSDP(),this._log.info("set H264 profile-level-id to ".concat(e?"high":"default"," success")))})}useHWEncoder(){let A=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1?arguments[1]:void 0;return VS(this,null,function*(){if(!this._peerConnection||!this._parsedAnswer||!this._serverAbility)return;let t=!1,i=[];H_(e)?i=this._parsedAnswer.media.slice(1,4):2===e?i.push(this._parsedAnswer.media[1]):3===e?i.push(this._parsedAnswer.media[2]):7===e&&i.push(this._parsedAnswer.media[3]),i.forEach(e=>{var i;if(e.type===WM.VIDEO){let o;A&&this.is42001fSupported?o=this.clientAbility.video.codecs.find(A=>A.fmtp.includes("42001f")):A||(o=this._serverAbility.video.codecs.find(A=>A.codec.toLowerCase()===(this._serverAbility.useVp8?"vp8":"h264"))),o&&(null==(i=e.payloads)||!i.includes(String(o.payload)))&&(e.fmtp=[],e.payloads="",e.rtp=[],e.rtcpFb=[],cV(e,o),t=!0)}}),t&&(this._log.warn("use ".concat(A?"hw":"sw"," encoder")),yield this.updateSDP())})}sendDataChannelMessage(A){var e;null==(e=this._datachannel)||e.send(A)}reset(){var A;this._peerConnection&&(this._peerConnection.close(),this._peerConnection.removeEventListener("track",this._peerConnection._onaddstreampoly,this),this._peerConnection._onaddstreampoly=null,this._peerConnection=null),this._datachannel=null,null==(A=this.clearWaitForConnectedPromise)||A.call(this),this._parsedAnswer=null,this.originOffer=null}close(){this._log.info("close pc"),this.isDestroyed=!0,this.removeRTCListener(),this.insertableStreamsAbortMap.forEach(A=>HT(A.abort)&&A.abort("destroy")),this.insertableStreamsAbortMap.clear(),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners(),this._room.healthDetector.off("1",this.onBadHealth,this)}getReceiversByUserId(A){if(!this._peerConnection)return[];let e=this._peerConnection.getReceivers();return(this._downlinkMIDMap.get(A)||[]).map(A=>e[A])}get isUsingRelay(){return"relay"===this._room.getIceTransportPolicy()}detectTCPAndUDP(A){let{uplinkRTT:e,downlinkRTT:t}=A;var i;if("CONNECTED"!==this.currentState||this._isRelayTried&&!this._room.forceRelay||0===this._room.getIceServers().length)return;let o=this._signalChannel.rtt,n=Math.max(e,t),{rttRatioThreshold:r,rttThreshold:s}=(null==(i=this._room.scheduleResult.config)?void 0:i.useTurnTcpInfo)||{};if(!(r&&s&&o&&n))return;let a=Math.floor(n/o),g=(this._isRelayTried||a>r)&&n>s;g?++this._rttOverCount<5||(this._log.warn("detectTCPAndUDP ws-rtt: ".concat(o," upRTT: ").concat(e," downRTT: ").concat(t," ratio: ").concat(a," over-count: ").concat(this._rttOverCount," isOver: ").concat(g," isRelayTried: ").concat(this._isRelayTried," force-relay: ").concat(this._room.forceRelay)),this.isUsingRelay||this._isRelayTried?this._room.forceRelay&&this.switchRelay(!1):(this._isRelayTried=!0,this._rttOverCount=0,this.switchRelay(!0))):this._rttOverCount=0}switchRelay(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return VS(this,null,function*(){if(this.isUsingRelay===A)return;let t=A?"relay":"udp",i=A?521709:521710;try{this._room.forceRelay=A,this._log.warn("switchRelay ".concat(t));let e=Date.now();yield this.doSwitchRelay(t),this._log.warn("switchRelay ".concat(t," success")),Gk.addSuccessEvent({key:i,cost:Date.now()-e})}catch(o){this._log.warn("switchRelay ".concat(t," failed"),o),Gk.addFailedEvent({key:i,error:o}),e?this._room.reJoin():yield this.switchRelay(!A,!0)}})}doSwitchRelay(A){return new Promise((e,t)=>{let i=setTimeout(()=>{this.stopReconnection(),t(new Error("switch ".concat(A," timeout")))},1e4);this.startReconnection().then(e,t).finally(()=>clearTimeout(i))})}removeRTCListener(){this._peerConnection&&(this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.ontrack=null),this.dtlsTransport&&(this.dtlsTransport.onstatechange=null)}requestRemoteFallbackToH264(){this._log.warn("H265 decode failed, remote need to fallback h264"),this._h265DecodeFailed=!0,this._signalChannel.sendWaitForResponse({command:nq,data:{videoDecCodec:"h264"},responseCommand:LH.UPDATE_CONSTRAINT_CONFIG_RES}).then(A=>{0!==A.data.code&&this._log.warn(A.data.message)})}};JS([jF("reconnect")],pV.prototype,"startReconnection",1),JS([KF(A=>A.userId)],pV.prototype,"addDownlink",1),JS([KF(A=>A)],pV.prototype,"removeDownlink",1),JS([VF(!0)],pV.prototype,"updateSDP",1),JS([WF(521712,!1),iY(10,0)],pV.prototype,"setOffer",1),JS([WF(521713,!1),iY(10,0)],pV.prototype,"setAnswer",1),JS([xF((A,e)=>function(){for(var e=arguments.length,t=new Array(e),i=0;iclearTimeout(A)),this._checkPendingPromiseSet.clear()),A.apply(this,t)})],pV.prototype,"close",1);var fV=class{constructor(A){HS(this,"tag"),HS(this,"len"),HS(this,"data");let e=new DataView(A);this.tag=e.getUint16(),this.len=e.getUint16(2),this.data=new Uint8Array(A).slice(4,4+this.len).buffer}},mV=class{constructor(A){HS(this,"tinyId"),HS(this,"data");let e=new DataView(A),t=0,i=[];for(;t{1===A.tag?this.tinyId=(new TextDecoder).decode(A.data):2===A.tag&&o.push(A.data)});let n=o.reduce((A,e)=>A+e.byteLength,0),r=new Uint8Array(n),s=0;o.forEach(A=>{r.set(new Uint8Array(A),s),s+=A.byteLength}),this.data=r.buffer}},yV=new Set;function DV(){let A=Math.floor(4294967296*Math.random());return yV.has(A)?DV():(yV.add(A),A)}var vV=YS(jS()),wV=class extends vV.default{constructor(A){super(),HS(this,"userId"),HS(this,"tinyId"),HS(this,"_sdpSemantics"),HS(this,"_isUplink"),HS(this,"_room"),HS(this,"_log"),HS(this,"_currentState","DISCONNECTED"),HS(this,"_prevTime",-1),HS(this,"_blackSmallVideoDetectionId"),HS(this,"isDestroyed",!1),this.userId=A.userId,this.tinyId=A.tinyId,this._room=A.room,this._sdpSemantics=A.room.sdpSemantics,this._isUplink=A.isUplink,this._log=sG.createLogger({parent:this._room.getLogger(),id:"n",userId:this._room.userId,remoteUserId:this._isUplink?void 0:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink})}get _peerConnection(){var A;return(null==(A=this.singlePC)?void 0:A.getPeerConnection())||null}get singlePC(){return this._room.singlePC}get _signalChannel(){return this._room.signalChannel}close(A){this._log.info("close connection"),this.emit("closed",A)}destroy(){this.isDestroyed=!0}emitConnectionStateChangedEvent(A){return A!==this._currentState&&(tG.emit(oG.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:A,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:A}),this._currentState=A,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}getCurrentState(){return this._currentState}get isH264(){var A,e;return!(null==(e=null==(A=this._peerConnection)?void 0:A.remoteDescription)||!e.sdp.includes("H264"))}};function SV(A){let{when:e,onSkip:t}=A;return xF((A,i)=>function(){for(var o=arguments.length,n=new Array(o),r=0;rpostMessage({type:"log",message:"[worker] "+t.join(" ")});function startDetection(e,t,a){if(!tracks.has(e)){const c={reader:a.getReader(),blackCount:0,timeoutId:null,intervalId:null};tracks.set(e,c),c.timeoutId=setTimeout(()=>stopDetection(e,"timeout"),t),c.intervalId=setInterval(async()=>{try{await isFrameBlack(e)?(c.blackCount++,postMessage({type:"blackCount",trackId:e,count:c.blackCount}),3<=c.blackCount&&(postMessage({type:"black",trackId:e}),stopDetection(e,"black"))):c.blackCount=0}catch(t){log("check black video error:",t.message),stopDetection(e,"error")}},1e3)}}function stopDetection(t,e){var a=tracks.get(t);a&&(a.timeoutId&&clearTimeout(a.timeoutId),a.intervalId&&clearInterval(a.intervalId),a.reader&&a.reader.cancel(),tracks.delete(t),postMessage({type:e,trackId:t}))}async function isFrameBlack(t){t=tracks.get(t);if(!t)return!1;var t=t.reader,{done:t,value:e}=await t.read();if(!e||t)return!1;canvas||(canvas=new OffscreenCanvas(e.codedWidth,e.codedHeight),ctx=canvas.getContext("2d",{willReadFrequently:!0})),canvas.width===e.codedWidth&&canvas.height===e.codedHeight||(canvas.width=e.codedWidth,canvas.height=e.codedHeight,ctx=canvas.getContext("2d",{willReadFrequently:!0})),ctx.drawImage(e,0,0,canvas.width,canvas.height);t=getFrameBlackRatio(ctx.getImageData(0,0,canvas.width,canvas.height));return e.close(),1===t}function getFrameBlackRatio(t){var e=t.data;let a=0;for(let t=0;t<100;t++){var c=4*Math.floor(Math.random()*(e.length/4)),[c,r,n,o]=[e[c],e[1+c],e[2+c],e[3+c]];0{var{type:t,trackId:e,timeout:a,readable:c}=t.data;"addTrack"===t&&startDetection(e,a,c),"removeTrack"===t&&stopDetection(e)};\n '],{type:"application/javascript"}),e=URL.createObjectURL(A);this.worker=new Worker(e),URL.revokeObjectURL(e),this.worker.onerror=A=>this._log.warn("worker error:",A.message,A.filename||"unknown",A.lineno||"unknown"),this.worker.onmessage=A=>{var e;let{type:t,trackId:i,message:o,count:n}=A.data;if("black"===t)null==(e=this.callbacks.get(i))||e();else if("log"===t)this._log.warn(o);else if("blackCount"===t){let A=this.userIdMap.get(i);this._log.warn("".concat(A||i," black count: ").concat(n))}}}return this.worker}start(A){let{track:e,isUplink:t,room:i,userId:o,onBlack:n}=A;if(this._log.debug("start detect black video",e.id),!Jk()||!n||!e||"undefined"==typeof Worker)return void this._log.warn("black video detector not supported");let r=A=>{var i,n,r,s;let a;if(t)a=null==(n=null==(i=A.msg_up_stream_info)?void 0:i.msg_video_status)?void 0:n.filter(A=>3===A.uint32_video_stream_type)[0];else{let e=null==(r=A.msg_down_stream_info)?void 0:r.filter(A=>{var e;return(null==(e=A.msg_user_info)?void 0:e.str_identifier)===o})[0];a=null==(s=null==e?void 0:e.msg_video_status)?void 0:s.filter(A=>3===A.uint32_video_stream_type)[0]}if(a){let A=(a.uint32_video_codec_bitrate||0)/1e3;if(this.sleep[e.id]&&this.sleep[e.id]>0)return void(this.sleep[e.id]-=1);A>0&&A<10&&(this.sleep[e.id]=30,this._log.info("track bitrate",A,"start check"),this.checkOnce(e,3e4))}};return i.on("heartbeat-report",r),this.heartbeatListenerCleaner.set(e.id,()=>i.off("heartbeat-report",r)),this.callbacks.set(e.id,n),this.userIdMap.set(e.id,o),e.id}checkOnce(A,e){try{let t=this.getWorker();if(!t)throw new Error("Worker not available");let i=new MediaStreamTrackProcessor({track:A});t.postMessage({type:"addTrack",trackId:A.id,timeout:e,readable:i.readable},[i.readable])}catch(t){this._log.warn("check error:",t),this.stop(A.id)}}stop(A){if(A){this.worker&&this.worker.postMessage({type:"removeTrack",trackId:A}),this.callbacks.delete(A),delete this.sleep[A];let e=this.heartbeatListenerCleaner.get(A);e&&e(),this.heartbeatListenerCleaner.delete(A),this.userIdMap.delete(A)}}destroy(){this.callbacks.forEach((A,e)=>this.stop(e)),this.worker&&(this.worker.terminate(),this.worker=null)}},RV=class extends wV{constructor(A){super(FS(US({},A),{isUplink:!0})),HS(this,"localMainAudioTrack",null),HS(this,"localMainVideoTrack",null),HS(this,"localAuxAudioTrack",null),HS(this,"localAuxVideoTrack",null),HS(this,"_isPublishingAux",!1),HS(this,"_publishingLocalAudioTrack"),HS(this,"_publishingLocalVideoTrack"),HS(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,videoDecCodec:"",audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),HS(this,"_flag",0),HS(this,"_checkPublishStateTimeoutId",-1),this.initialize()}get videoCodec(){var A;return(null==(A=this.singlePC)?void 0:A.videoCodec)||"h264"}get ssrc(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};let{audioSsrc:A,bigVideoSsrc:e,bigVideoRtxSsrc:t,smallVideoSsrc:i,smallVideoRtxSsrc:o,auxVideoSsrc:n,auxVideoRtxSsrc:r}=this.singlePC.uplinkSSRC;return{audio:A||0,video:e||0,videoRtx:t||0,small:i||0,smallRtx:o||0,auxiliary:n||0,auxiliaryRtx:r||0}}get flag(){return this._flag}set flag(A){this._flag!==A&&(this._flag=A,this.checkPublishState())}checkPublishState(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{if(!A&&this._checkPublishStateTimeoutId>0)return;let{serverPublishState:e}=this,{publishState:t}=this._room,i=Object.keys(t).filter(A=>{if(t[A]!==e[A]&&t[A])switch(A){case"audio":return!(!this.localMainAudioTrack||!this.localMainAudioTrack.isMediaTrackActive);case"bigVideo":case"smallVideo":return!(!this.localMainVideoTrack||!this.localMainVideoTrack.isMediaTrackActive);case"auxVideo":return!(!this.localAuxVideoTrack||!this.localAuxVideoTrack.isMediaTrackActive)}return!1});if(i.length>0){if(!A)return void(this._checkPublishStateTimeoutId=iU.run("timeout",()=>this.checkPublishState(!0),{delay:1e4,count:1}));Gk.addCount({key:521e3}),i.forEach(A=>{this._log.warn("".concat(A," publish failed during call ").concat(Xb()," ").concat(Vb())),Gk.addEnum({key:521719,value:_V[A]})}),iU.clearTask(this._checkPublishStateTimeoutId),this._checkPublishStateTimeoutId=-1}}catch(e){this._log.warn("checkPublishState failed",e)}}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get serverPublishState(){return{audio:!!(this.flag&tR),bigVideo:!!(this.flag&$M),smallVideo:!!(this.flag&AR),auxVideo:!!(this.flag&eR)}}initialize(){this.installEvents()}close(A){var e;let t=(null==(e=this._peerConnection)?void 0:e.getSenders())||[];for(let i of t)i.replaceTrack(null);super.close(A),this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.installSPCEvents()}installSPCEvents(){var A,e;null!=(A=this.singlePC)&&A.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(e=this.singlePC)||e.on("spc-reconnected",this.onSinglePCReconnected,this)}uninstallSPCEvents(){var A;null==(A=this.singlePC)||A.off("spc-reconnected",this.onSinglePCReconnected,this)}uninstallEvents(){this.off("connection-state-changed",this.handleConnectionStateChange,this),this.uninstallSPCEvents()}emitConnectionStateChangedEvent(A,e){var t,i,o;let n=this._currentState,r=super.emitConnectionStateChangedEvent(A);return r&&n!==A&&(e?e.emit("connection-state-changed",{prevState:n,state:A}):(null==(t=this.localMainVideoTrack)||t.emit("connection-state-changed",{prevState:n,state:A}),null==(i=this.localAuxVideoTrack)||i.emit("connection-state-changed",{prevState:n,state:A}),null==(o=this._publishingLocalVideoTrack)||o.emit("connection-state-changed",{prevState:n,state:A}))),r}onVideoEncodeFailed(A){return VS(this,null,function*(){if(!A||!A.isMediaTrackActive)return;let{videoCodec:e,singlePC:t}=this;if(!t)return;let i={h265:{supported:t.isH264EncodeSupported,target:"h264",log:"h265 encoder not working"},h264:{supported:t.isVP8EncodeSupported,target:"vp8",log:"h264 encoder not working"},vp8:{supported:!1,target:"vp8",log:"vp8 encoder not working, no fallback available"}};if("vp9"===e||"av1"===e)return;let o=i[e];this._log.warn(o.log),null!=o&&o.supported&&(yield t.switchVideoEncoder(o.target))})}publish(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i,isAuxiliary:o}=A;return function*(){var A,n,r,s,a,g,c;if(!e.singlePC)return;if(e.installEvents(),e.installTrackMuteEvents(t,i),i&&(i.retryEncodeFailed=e.onVideoEncodeFailed.bind(e)),yield e.singlePC.waitForPeerConnectionConnected(),t&&(e._publishingLocalAudioTrack=t),i){if(!e.singlePC.isH264EncodeSupported&&!e.singlePC.isVP8EncodeSupported)throw new rM({code:oM.NOT_SUPPORTED_H264,message:mk({key:Bk.NOT_SUPPORTED_H264ENCODE})});e.singlePC.isUsingH264&&!e.singlePC.isH264EncodeSupported&&e.singlePC.isVP8EncodeSupported&&(e._log.warn("h264 encoder not supported"),yield e.singlePC.switchVideoEncoder("vp8")),lN&&115===Ib()&&i.profile.width*i.profile.height<=230400&&(e._log.warn("fallback video to defaultBigVideoProfile: ".concat(JSON.stringify(VM))),i.setProfile(VM),yield i.applyProfile()),e._publishingLocalVideoTrack=i}let l;if(e._isPublishingAux=o,i&&!o&&i.small&&(l=e._room.videoManager.smallTrack),yield e._signalChannel.sendWaitForResponseWithRetry({command:aq,responseCommand:LH.SPC_PUBLISH_RESULT,data:FS(US({},e.singlePC.uplinkSSRC),{state:e._room.publishState,muteState:e._room.muteState}),retries:3}),i&&(yield e.checkHighProfile({streamType:i.streamType,newWidth:i.settings.width,newHeight:i.settings.height})),yield e.publishByTransceiver({localAudioTrack:t,localVideoTrack:i,smallTrack:l,isAuxiliary:o}),e._publishingLocalAudioTrack=null,e._publishingLocalVideoTrack=null,e._isPublishingAux=!1,i){e[o?"localAuxVideoTrack":"localMainVideoTrack"]=i,yield e.singlePC.setDegradationPreference(e._peerConnection.getSenders()[o?3:1],i.contentHint,i.streamType);let{scaleResolutionDownBy:A}=i;yield e.singlePC.setScaleResolutionDownBy(e._peerConnection.getSenders()[o?3:1],A,i.streamType)}t&&(e[o?"localAuxAudioTrack":"localMainAudioTrack"]=t),yield e.singlePC.setBandwidth({audio:(null==(A=e.localMainAudioTrack)?void 0:A.profile.bitrate)||(null==(n=e.localAuxAudioTrack)?void 0:n.profile.bitrate),bigVideo:null==(r=e.localMainVideoTrack)?void 0:r.profile.bitrate,smallVideo:null==(a=null==(s=e.localMainVideoTrack)?void 0:s.small)?void 0:a.bitrate,auxVideo:null==(g=e.localAuxVideoTrack)?void 0:g.profile.bitrate}),e.sendMediaSettings();let I=o?7:2;(e._room.preferHW||null!=(c=e._room.scheduleResult.config)&&c.preferHW)&&i&&i.profile.width*i.profile.height>=921600&&e.singlePC.useHWEncoder(!0,I)}()})}publishByTransceiver(A){let{localAudioTrack:e,localVideoTrack:t,smallTrack:i,isAuxiliary:o}=A;if(!IL())return;this._log.info("publish by transceiver");let n=null==t?void 0:t.outMediaTrack,r=null==e?void 0:e.outMediaTrack,s=this._peerConnection.getTransceivers(),a=[],g=[],c=(A,e,t)=>{var i;let o=s[e].sender.replaceTrack(t);g.push(e),null!=(i=this.singlePC)&&i.enableInsertableStreams&&o.then(()=>this.createEncodedStreams(s[e].sender,A)),this.initSenderTransform(s[e].sender,A),a.push(o)};r&&c(e.mediaType,0,r),n&&c(t.mediaType,o?3:1,n),null!=t&&t.small&&a.push(this.publishSmall(this._room.videoManager.smallMode,t));let l=this.singlePC.setTransceiverDirection(zM.SENDONLY,g);return a.push(l),Promise.all(a)}getTrackByMediaType(A){switch(A){case 1:return this.localMainAudioTrack||this._room.localMainAudioTrack;case 4:case 8:return this.localMainVideoTrack||this._room.localMainVideoTrack;case 2:return this.localAuxVideoTrack||this._room.localAuxVideoTrack;default:return null}}createEncodedStreams(A,e){var t,i;if(this.singlePC.insertableStreamsAbortMap.has(A))return;let o=A.createEncodedStreams(),n=new AbortController;null==(t=this.singlePC)||t.addAbortController(A,n),(null!=(i=this.getTrackByMediaType(e))&&i.enableEncodeFrame?o.readable.pipeThrough(new TransformStream({transform:(A,t)=>{var i,o;let n=this.getTrackByMediaType(e);if(!n||!n.encodeFrame)return t.enqueue(A);n.isAudio?t.enqueue(n.enableEncodeFrame?n.encodeFrame(A):A):t.enqueue(null!=(i=this.singlePC)&&i.isUsingH264||null!=(o=this.singlePC)&&o.isUsingH265?n.encodeFrame(A,8===e):A)}}),n):o.readable).pipeTo(o.writable,n).catch(A=>{this._log.debug("encoded stream error",A),"destroy"!==A&&this._log.warn(A)})}initSenderTransform(A,e){if(!(this._peerConnection&&this.singlePC&&this.singlePC.scriptTransformWorker&&yL))return;let t=2!==e,i=8===e;A.transform||(A.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!1,isAudio:1===e,isMain:t,isSmall:i}))}enableSmall(A){return VS(this,null,function*(){A?yield this.publishSmall(this._room.videoManager.smallMode):yield this.unpublishSmall()})}publishSmall(A){return VS(this,arguments,function(A){var e=this;let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.localMainVideoTrack;return function*(){var i;if(!e.singlePC)return;if("canvas"===A&&!nL())return void e._log.warn("canvas mode small stream is not supported");let o=e._peerConnection.getTransceivers(),{sender:n}=o[2],r=yield e.doPublishSmall(A,t),s="canvas"===A?524700:524701;Gk.addSuccessEvent({key:s}),r?(null!=(i=e.singlePC)&&i.enableInsertableStreams&&e.createEncodedStreams(n,8),e.initSenderTransform(n,8),yield e.singlePC.setTransceiverDirection(zM.SENDONLY,[2]),e.updateMediaSettings(),yield e.doPublishChange(),n.track&&(e._blackSmallVideoDetectionId=MV.start({track:n.track,room:e._room,isUplink:!0,userId:e.userId,onBlack:()=>{e._log.warn("small video is black");let t="canvas"===A?524700:524701;Gk.addFailedEvent({key:t,error:10002}),MV.stop(e._blackSmallVideoDetectionId),e._blackSmallVideoDetectionId=void 0}}))):Gk.addFailedEvent({key:s,error:10001})}()})}doPublishSmall(A){return VS(this,arguments,function(A){var e=this;let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.localMainVideoTrack;return function*(){if(!e.singlePC)return null;e._log.info("publish small",A);let i=e._peerConnection.getTransceivers(),{sender:o}=i[2];if("canvas"===A&&e._room.videoManager.smallTrack)return yield o.replaceTrack(e._room.videoManager.smallTrack),"canvas";if("api"===A&&null!=t&&t.outMediaTrack&&null!=t&&t.small){yield o.replaceTrack(null==t?void 0:t.outMediaTrack);let A=o.getParameters(),i=MT(null==t?void 0:t.profile,null==t?void 0:t.small);return e._log.info("small scaleResolutionDownBy",i),A.encodings[0].scaleResolutionDownBy=i,o.setParameters(A),"api"}return e._log.warn("small track can not be enabled, smallMode: ".concat(e._room.videoManager.smallMode,", smallTrack: ").concat(!!e._room.videoManager.smallTrack,", bigVideoTrack: ").concat(!(null==t||!t.outMediaTrack))),null}()})}unpublishSmall(){return VS(this,null,function*(){this.singlePC&&(this._log.info("unpublish small"),yield this._peerConnection.getTransceivers()[2].sender.replaceTrack(null),yield this.singlePC.setTransceiverDirection(zM.INACTIVE,[2]),this.updateMediaSettings(),yield this.doPublishChange(),MV.stop(this._blackSmallVideoDetectionId),this._blackSmallVideoDetectionId=void 0)})}checkHighProfile(A){return VS(this,null,function*(){var e,t;if("high"!==((null==(e=this._room.scheduleResult.config)?void 0:e.profileLevelId)||{})["main"===A.streamType?"big":"aux"])return;let i=A.newWidth*A.newHeight>=921600&&!Jb();try{yield null==(t=this.singlePC)?void 0:t.setH264ProfileLevelId(A.streamType,i)}catch(o){this._log.warn("setH264ProfileLevelId failed, ignore",o)}})}installTrackMuteEvents(){for(var A=arguments.length,e=new Array(A),t=0;t{A&&(null==A||A.on("mute",this.sendMutedFlag,this),null==A||A.on("unmute",this.sendMutedFlag,this))})}uninstallTrackMuteEvents(){for(var A=arguments.length,e=new Array(A),t=0;t{A&&(null==A||A.off("mute",this.sendMutedFlag,this),null==A||A.off("unmute",this.sendMutedFlag,this))})}unpublish(A){return VS(this,arguments,function(A){var e=this;let{localAudioTrack:t,localVideoTrack:i}=A;return function*(){var A;yield null==(A=e.singlePC)?void 0:A.waitForPeerConnectionConnected();let o=i&&i===e.localAuxVideoTrack||t&&t===e.localAuxAudioTrack,n=null==i?void 0:i.outMediaTrack,r=e._peerConnection.getSenders(),s=[];t&&(o?e.localAuxAudioTrack=null:e.localMainAudioTrack=null,!e.localMainAudioTrack&&!e.localAuxAudioTrack&&(yield r[0].replaceTrack(null),s.push(0))),n&&(o?(yield r[3].replaceTrack(null),e.localAuxVideoTrack=null,e._mediaSettings=FS(US({},e._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield r[1].replaceTrack(null),yield r[2].replaceTrack(null),e.localMainVideoTrack=null,e._mediaSettings=FS(US({},e._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),e.isMainStreamPublished||e.isAuxStreamPublished?(yield e.singlePC.setTransceiverDirection(zM.INACTIVE,s),yield e.doPublishChange(!1)):yield e.doUnpublish(),e.uninstallTrackMuteEvents(t,i),null==i||i.emit("connection-state-changed",{prevState:e._currentState,state:"DISCONNECTED"})}()})}doPublishChange(){let A=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return VS(this,null,function*(){let e={state:this._room.publishState,constraintConfig:this._mediaSettings},t=yield this._signalChannel.sendWaitForResponseWithRetry({command:JH,data:e,responseCommand:LH.PUBLISH_STATE_CHANGE_RESULT,enableLog:A,retries:3});this.checkPublishResultCode(t.data.code,t.data.message)})}doUnpublish(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:HH,commandDesc:"unpublish",responseCommand:LH.UNPUBLISH_RESULT,enableLog:A}).catch(A=>{if(A.getCode()===oM.API_CALL_TIMEOUT||A.getCode()===oM.API_CALL_ABORTED)return Promise.resolve();throw A})}updateMediaSettings(){var A,e;this._mediaSettings.videoCodec=(null==(A=this.singlePC)?void 0:A.videoCodec)||"h264",this._mediaSettings.videoDecCodec=(null==(e=this.singlePC)?void 0:e.downlinkVideoCodec)||"h264";let t=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:i,localAuxVideoTrack:o}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?o=this._publishingLocalVideoTrack:i=this._publishingLocalVideoTrack),QL){if(t&&t.outMediaTrack){let A=t.outMediaTrack.getSettings();this._mediaSettings.audioChannel=A.channelCount||1,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=A.sampleRate||0}if(i&&i.outMediaTrack){let A=i.outMediaTrack.getSettings(),{scaleResolutionDownBy:e}=i;this._mediaSettings.videoWidth=(A.width||0)/e||0,this._mediaSettings.videoHeight=(A.height||0)/e||0,this._mediaSettings.videoFps=A.frameRate||0,this._mediaSettings.videoBps=1e3*i.profile.bitrate,i.small&&(this._mediaSettings.smallVideoWidth=i.small.width,this._mediaSettings.smallVideoHeight=i.small.height,this._mediaSettings.smallVideoFps=i.small.frameRate,this._mediaSettings.smallVideoBps=1e3*i.small.bitrate)}if(o&&o.outMediaTrack){let A=o.outMediaTrack.getSettings(),{scaleResolutionDownBy:e}=o;this._mediaSettings.auxVideoWidth=(A.width||0)/e||0,this._mediaSettings.auxVideoHeight=(A.height||0)/e||0,this._mediaSettings.auxVideoFps=A.frameRate||0,this._mediaSettings.auxVideoBps=1e3*o.profile.bitrate}}else t&&t.outMediaTrack&&(this._mediaSettings.audioChannel=t.profile.channelCount,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=t.profile.sampleRate),i&&i.outMediaTrack&&(this._mediaSettings.videoWidth=i.profile.width,this._mediaSettings.videoHeight=i.profile.height,this._mediaSettings.videoFps=i.profile.frameRate,this._mediaSettings.videoBps=1e3*i.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:nq,data:this._mediaSettings,responseCommand:LH.UPDATE_CONSTRAINT_CONFIG_RES}).then(A=>{0!==A.data.code&&this._log.warn(A.data.message)}).catch(()=>{})}addTrack(A){return VS(this,null,function*(){if(!this._peerConnection)return;let e=A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;this._log.info("is adding ".concat(A.kind," track to current published local ").concat(e?WM.AUXILIARY:WM.MAIN," stream")),lL()&&(yield this.addTrackByTransceiver(A,e))})}addTrackByTransceiver(A,e){return VS(this,null,function*(){var t;if(!A.mediaTrack)return;let i=this._peerConnection.getTransceivers();if(A.kind===WM.AUDIO)yield i[0].sender.replaceTrack(A.outMediaTrack);else{let o=e?3:1;yield i[o].sender.replaceTrack(A.outMediaTrack),1===o&&null!=(t=this.localMainVideoTrack)&&t.small&&this._room.videoManager.smallTrack&&(yield i[2].sender.replaceTrack(this._room.videoManager.smallTrack)),i[o].direction===zM.INACTIVE&&(yield this.singlePC.setTransceiverDirection(zM.SENDONLY,[o]))}this.updateMediaSettings(),yield this.doPublishChange()})}removeTrack(A){return VS(this,null,function*(){if(!this._peerConnection)return;let e=A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;this._log.info("is removing ".concat(A.kind," track from current published local ").concat(e?WM.AUXILIARY:WM.MAIN," stream")),lL()&&(yield this.removeTrackByTransceiver(A,e))})}removeTrackByTransceiver(A,e){return VS(this,null,function*(){if(!A.mediaTrack)return;let t=this._peerConnection.getTransceivers();if(A.kind===WM.AUDIO)yield t[0].sender.replaceTrack(null);else{let A=e?3:1;yield t[A].sender.replaceTrack(null),1===A&&this._room.videoManager.hasSmall&&(yield t[2].sender.replaceTrack(null)),yield this.singlePC.setTransceiverDirection(zM.INACTIVE,[A])}this.updateMediaSettings(),yield this.doPublishChange()})}replaceTrack(A){return VS(this,null,function*(){var e;let t=null==(e=this._peerConnection)?void 0:e.getSenders(),i=A.outMediaTrack||A.mediaTrack;if(!t||0===t.length||!i||t.find(A=>A.track===i))return!1;let o=2===A.mediaType||A===this.localAuxAudioTrack||A===this.localAuxVideoTrack;return this._log.info("is replacing ".concat(i.kind," track ").concat(i.id," ").concat(i.label," on ").concat(o?WM.AUXILIARY:WM.MAIN," stream")),i.kind===WM.AUDIO&&t[0]&&(yield t[0].replaceTrack(i)),i.kind===WM.VIDEO&&(!o&&t[1]&&(yield t[1].replaceTrack(i)),o&&t[3]&&(yield t[3].replaceTrack(i))),!0})}setBandwidth(A){return VS(this,arguments,function(A){var e=this;let{bandwidth:t,type:i,videoType:o}=A;return function*(){if(e.singlePC){let A={};i===WM.AUDIO?A.audio=t:"big"===o?A.bigVideo=t:"small"===o?A.smallVideo=t:A.auxVideo=t,yield e.singlePC.setBandwidth(A)}}()})}sendMutedFlag(A){A===this.localAuxAudioTrack||A===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this._room.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:PH,responseCommand:LH.MUTE_RESULT,data:this._room.muteState,retries:3}).catch(()=>{}))}handleConnectionStateChange(A){"CONNECTED"===A.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&tG.emit(oG.SEND_FIRST_VIDEO_FRAME,{room:this._room})}getVideoTrackId(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:WM.VIDEO;if(this._peerConnection){let e=this._peerConnection.getSenders();if(A===WM.AUXILIARY&&e[3]&&e[3].track)return e[3].track.id;if(A===WM.VIDEO&&e[1]&&e[1].track)return e[1].track.id}if(this.localMainVideoTrack&&A===WM.VIDEO){let A=this.localMainVideoTrack.mediaTrack;if(A)return A.id}if(this.localAuxVideoTrack&&A===WM.AUXILIARY){let A=this.localAuxVideoTrack.mediaTrack;if(A)return A.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(A,e){if(0!==A)throw A===bR?(this._log.error(Qk.NOT_SUPPORTED_H264ENCODE),new rM({code:oM.NOT_SUPPORTED_H264,message:mk({key:Bk.NOT_SUPPORTED_H264ENCODE})})):new rM({code:oM.UNKNOWN,message:mk({key:Bk.SIGNAL_RESPONSE_FAILED,data:{signalResponse:LH.PUBLISH_RESULT,code:A,message:e}})})}onSinglePCReconnected(){return VS(this,null,function*(){this.isMainStreamPublished&&(this._log.warn("republish main stream"),yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(this._log.warn("republish aux stream"),yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0}))})}};JS([FF(A=>{let{localVideoTrack:e}=A;null==e||delete e.retryEncodeFailed})],RV.prototype,"unpublish",1),JS([SV({when(){return this.isDestroyed}})],RV.prototype,"doPublishChange",1),JS([SV({when(){return this.isDestroyed}})],RV.prototype,"doUnpublish",1);var _V=(A=>(A[A.audio=1]="audio",A[A.bigVideo=2]="bigVideo",A[A.smallVideo=3]="smallVideo",A[A.auxVideo=4]="auxVideo",A))(_V||{}),TV=RV;function NV(A){return Object.keys(A).filter(e=>A[e])}var bV=class extends wV{constructor(A){super(FS(US({},A),{isUplink:!1})),HS(this,"_flag",0),HS(this,"isRobot",!1),HS(this,"role","anchor"),HS(this,"fromType"),HS(this,"remoteAudioTrack"),HS(this,"remoteVideoTrack"),HS(this,"remoteAuxiliaryTrack"),HS(this,"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),HS(this,"jitterBufferTimeoutId",-1),HS(this,"_videoCodec"),HS(this,"avPlayerStateSyncManager"),HS(this,"isDataChannelSubscribed",!1),this.flag=A.flag,this.isRobot=A.isRobot||!1,this.fromType=A.fromType,this.remoteAudioTrack=new rY(this._room,this),this.remoteVideoTrack=new aY(this._room,this),this.remoteAuxiliaryTrack=new gY(this._room,this),this.avPlayerStateSyncManager=new RJ({log:this._log,audioPlayer:this.remoteAudioTrack.player,videoPlayer:this.remoteVideoTrack.player}),this.initialize()}get videoCodec(){var A;return this._videoCodec||(null==(A=this.singlePC)?void 0:A.downlinkVideoCodec)||"h264"}set videoCodec(A){this._videoCodec=A}get subscribeState(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing,datachannel:this.isDataChannelSubscribed}}get muteState(){return gT(this.flag,this.userId)}get flag(){return this._flag}set flag(A){var e,t,i;A!==this._flag&&(this._flag=A,null==(e=this.remoteAudioTrack)||e.onFlagChanged(),null==(t=this.remoteVideoTrack)||t.onFlagChanged(),null==(i=this.remoteAuxiliaryTrack)||i.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(A){return A===WM.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){this.installEvents()}close(A){clearTimeout(this.jitterBufferTimeoutId),super.close(A),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.avPlayerStateSyncManager.destroy(),this.uninstallEvents(),this.removeDownlink()}installEvents(){this.singlePC&&(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this),this.remoteVideoTrack.on("decode-failed",this.onDecodeFailed,this))}uninstallEvents(){this.singlePC&&(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this),this.remoteVideoTrack.off("decode-failed",this.onDecodeFailed,this))}emitConnectionStateChangedEvent(A){var e,t;let i=this._currentState,o=super.emitConnectionStateChangedEvent(A);return o&&i!==A&&(null==(e=this.remoteVideoTrack)||e.emit("connection-state-changed",{prevState:i,state:A}),null==(t=this.remoteAuxiliaryTrack)||t.emit("connection-state-changed",{prevState:i,state:A})),o}onTrack(A){var e,t;let i=A.streams[0],{track:o,receiver:n}=A;if(!i.id.includes(this.tinyId))return;let r=i.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(r," ").concat(o.kind));let s=WM.AUDIO;o.kind===WM.VIDEO&&(s=r===WM.MAIN?WM.VIDEO:WM.AUXILIARY);let a=this.remoteAudioTrack;s===WM.VIDEO?a=this.remoteVideoTrack:s===WM.AUXILIARY&&(a=this.remoteAuxiliaryTrack),null==(e=this.singlePC)||e.receiverRemoteTrackMap.set(n,a),null!=(t=this.singlePC)&&t.scriptTransformWorker&&this.initReceiverTransform(n,r,o.kind===WM.AUDIO),this.singlePC.enableInsertableStreams&&this.createEncodedStreams(n),a.setInputMediaStreamTrack(o)}createEncodedStreams(A){if(!this.singlePC.insertableStreamsAbortMap.has(A)){let e=A.createEncodedStreams(),t=new AbortController,i={abortController:t,enqueue:e=>{var t,i,o;let n=null==(t=this.singlePC)?void 0:t.receiverRemoteTrackMap.get(A);return n&&("video"!==n.kind||null!=(i=this.singlePC)&&i.isUsingH264||null!=(o=this.singlePC)&&o.isUsingH265)?n.decodeFrame(e):e}};e.readable.pipeThrough(new TransformStream({transform:(A,e)=>{let t=i.enqueue(A);t&&e.enqueue(t)}})).pipeTo(e.writable,t).catch(A=>{"destroy"!==A&&this._log.warn(A)}),this.singlePC.addAbortController(A,t)}}initReceiverTransform(A,e,t){!this._peerConnection||!this.singlePC||!this.singlePC.scriptTransformWorker||A.transform||(A.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!0,isAudio:t,userId:this.userId,streamType:e}))}subscribe(A,e){return VS(this,null,function*(){var t,i;try{let o=!0;if(this._log.info("subscribe ".concat(e," ").concat(NV(A))),this.hasSSRC){let e="subscribe_change";Object.values(A).find(A=>!0===A)||(e="unsubscribe"),yield this.sendSubscription(e,A)}else{if(yield this._room.switchRoomSubedReq,null!=(t=this.singlePC)&&t.autoSubscribedUserMap.size){let A=this.singlePC.autoSubscribedUserMap.get(this.userId);if(A){this.singlePC.autoSubscribedUserMap.delete(this.userId);let e=null==(i=this.singlePC.autoSubscribedSsrcGroups.get(this._room.roomId))?void 0:i[A.groupIndex];e&&(this.ssrc={audio:e.audioSsrc,video:e.bigVideoSsrc,videoRtx:e.bigVideoRtxSsrc,auxiliary:e.auxVideoSsrc,auxiliaryRtx:e.auxVideoRtxSsrc},o=!1)}}yield this.doSubscribe(A,o),this.checkTrackEnded(A)}let{user:n,mediaTrack:r}=this.remoteVideoTrack;A.smallVideo&&r?(Gk.addSuccessEvent({key:524702}),this._blackSmallVideoDetectionId=MV.start({track:r,isUplink:!1,room:this._room,userId:this.userId,onBlack:()=>{this._log.warn("small video is black, auto change to big"),this._room.changeType(!1,n),Gk.addFailedEvent({key:524702}),MV.stop(this._blackSmallVideoDetectionId),this._blackSmallVideoDetectionId=void 0}})):(MV.stop(this._blackSmallVideoDetectionId),this._blackSmallVideoDetectionId=void 0)}catch(o){throw this._room.isJoined&&this.isStreamUnpublished(e)?(this._log.warn("".concat(o.message," ").concat(JSON.stringify(this.muteState))),new rM({code:oM.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):o}})}checkTrackEnded(A){var e,t,i;if((A.audio&&"ended"===(null==(e=this.remoteAudioTrack.mediaTrack)?void 0:e.readyState)||A.video&&"ended"===(null==(t=this.remoteVideoTrack.mediaTrack)?void 0:t.readyState)||A.auxiliary&&"ended"===(null==(i=this.remoteAuxiliaryTrack.mediaTrack)?void 0:i.readyState))&&this.singlePC&&!this.singlePC.isReconnecting){if(this._log.warn("remote track ended start spc reconnect"),Eb&&Cb<92)return;this.singlePC.startReconnection()}}unsubscribe(A){return VS(this,arguments,function(A){var e=this;let{remoteTracks:t,streamType:i}=A;return function*(){var A;if("main"===i&&!e.isMainStreamSubscribed||"auxiliary"===i&&!e.isAuxStreamSubscribed)return void e._log.info("".concat(i," stream already unsubscribed"));let o=US({},e.subscribeState);t.forEach(A=>{switch(A.mediaType){case 1:o.audio=!1;break;case 4:o.video=!1;break;case 8:o.smallVideo=!1;break;case 2:o.auxiliary=!1}});let n="subscribe_change";Object.values(o).find(A=>!0===A)||(n="unsubscribe"),e._log.info("".concat("unsubscribe"===n?n:"subscribe"," ").concat(i," [").concat(NV(o),"]")),"unsubscribe"===n&&(null==(A=e.singlePC)||A.removeDownlinkQueue.add(e.tinyId)),yield e.sendSubscription(n,o),"main"===i&&(MV.stop(e._blackSmallVideoDetectionId),e._blackSmallVideoDetectionId=void 0),"unsubscribe"===n&&(yield e.removeDownlink())}()})}subscribeDataChannel(){return VS(this,null,function*(){if(!this.singlePC)return;yield this.singlePC.waitForPeerConnectionConnected();let A=FS(US({},this.subscribeState),{datachannel:!0});yield this.doSubscribe(A)})}unsubscribeDataChannel(){return VS(this,null,function*(){let A=FS(US({},this.subscribeState),{datachannel:!1});yield this.sendSubscription("unsubscribe",A),yield this.removeDownlink()})}sendSubscription(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,t={srcTinyId:this.tinyId,srcUserId:this.userId},i=VH,o=LH.UNSUBSCRIBE_RESULT;return"subscribe_change"===A&&(t={audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo,customData:e.datachannel,srcTinyId:this.tinyId},i=jH,o=LH.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponseWithRetry({command:i,data:t,responseCommand:o,timeout:1e4,retries:3}).then(e=>{let{data:t}=e;if(0!==t.code){let e=new rM({code:t.code,message:mk({key:Bk.ERROR_MESSAGE,data:{type:A,message:t.message}})});throw this._log.error(e),e}})}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}setDelay(A){let{audioDelay:e,videoDelay:t}=A;this.remoteAudioTrack.stat.end2EndDelay=e,this.remoteVideoTrack.stat.end2EndDelay=t}onSinglePCReconnected(){return VS(this,null,function*(){(this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary||this.isDataChannelSubscribed)&&(this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),yield this.doSubscribe(this.subscribeState),this.remoteAudioTrack.checkDecodeResult(),this.remoteVideoTrack.checkDecodeResult(),this.remoteAuxiliaryTrack.checkDecodeResult())})}get hasSSRC(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}doSubscribe(){return VS(this,arguments,function(){var A=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){var i,o;if(A.singlePC){A.singlePC.addDownlinkQueue.add(A.tinyId),yield A.singlePC.waitForPeerConnectionConnected();try{if(t||!A.hasSSRC){let t={audioSsrc:DV(),bigVideoSsrc:DV(),bigVideoRtxSsrc:DV(),auxVideoSsrc:DV(),auxVideoRtxSsrc:DV()},{audioSsrc:r,bigVideoSsrc:s,bigVideoRtxSsrc:a,auxVideoSsrc:g,auxVideoRtxSsrc:c}=t;A.ssrc={audio:r,video:s,videoRtx:a,auxiliary:g,auxiliaryRtx:c},A.singlePC.addDownlinkQueue.delete(A.tinyId),yield A.singlePC.addDownlink({userId:A.userId,tinyId:A.tinyId,ssrc:A.ssrc});try{let n=yield A._signalChannel.sendWaitForResponseWithRetry({command:gq,responseCommand:LH.SPC_SUBSCRIBE_RESULT,data:{srcUserId:A.userId,srcTinyId:A.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo,customData:null!=(i=e.datachannel)&&i,ssrc:t},retries:3,retryTimeout:0});if(0!==n.data.code&&-10036!==n.data.code)throw new rM({code:n.data.code,message:n.data.message});A.isDataChannelSubscribed=null!=(o=e.datachannel)&&o}catch(n){throw yield A.removeDownlink(),n}return}A.singlePC.addDownlinkQueue.delete(A.tinyId),yield A.singlePC.addDownlink({userId:A.userId,tinyId:A.tinyId,ssrc:A.ssrc})}finally{if((e.audio||e.video||e.smallVideo||e.auxiliary||!e.datachannel)&&kL){let{main:e,aux:t}=A._room.jitterBufferDelay||{},{jitterDelay:i=e,jitterDelayAux:o=t}=A._room.scheduleResult.config||{};(V_(i)||V_(o))&&A.setJitterBufferDelay({mainDelay:i,auxDelay:o})}}}}()})}removeDownlink(){return VS(this,null,function*(){if(!this.singlePC)return;this.isDataChannelSubscribed=!1,this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId);let A=this._room.scheduleResult.config;(null!=A&&A.jitterDelay||null!=A&&A.jitterDelayAux)&&this.setJitterBufferDelay({mainDelay:0,auxDelay:0}),yield this.singlePC.removeDownlink(this.userId)})}setJitterBufferDelay(A){let{mainDelay:e,auxDelay:t}=A;if(!kL||!this.singlePC||!this._peerConnection||qT(e)&&qT(t))return Promise.resolve();this._log.info("set jitterBuffer main: ".concat(e," aux: ").concat(t));let i=this.singlePC.getReceiversByUserId(this.userId);return V_(e)&&(this.remoteAudioTrack.jitterBufferDelay=e,this.remoteVideoTrack.jitterBufferDelay=e),V_(t)&&(this.remoteAuxiliaryTrack.jitterBufferDelay=t,qT(e)&&(this.remoteAudioTrack.jitterBufferDelay=t)),new Promise(A=>{this.doSetJitterBufferDelay({mainDelay:e,auxDelay:t,receivers:i,resolve:A})})}doSetJitterBufferDelay(A){let{mainDelay:e,auxDelay:t,receivers:i,resolve:o}=A;try{if(0===e&&0===t)return i.forEach(A=>A.jitterBufferTarget=0),o();if(i.forEach(A=>{var i;let o=A.track===this.remoteAuxiliaryTrack.outMediaTrack||qT(e)&&A.track===this.remoteAudioTrack.outMediaTrack;if(o&&qT(t)||!o&&qT(e))return;let n=o?t||0:e,r=(A.jitterBufferTarget||0)+100;r>n||(A.jitterBufferTarget=r,this._log.debug("set ".concat(o?"aux ":"").concat(null==(i=null==A?void 0:A.track)?void 0:i.kind," jitterBuffer delay ").concat(r," -> ").concat(n)))}),!i.find(A=>{let i=A.track===this.remoteAuxiliaryTrack.outMediaTrack?t||0:e;return A.jitterBufferTarget{this.doSetJitterBufferDelay({mainDelay:e,auxDelay:t,receivers:i,resolve:o})},1e3)}catch(n){this._log.warn("set jitterBuffer delay error: ".concat(n)),clearTimeout(this.jitterBufferTimeoutId),o()}}get audioReceiver(){var A;return(null==(A=this.singlePC)?void 0:A.getReceiversByUserId(this.userId)[0])||null}onDecodeFailed(){"h265"===this._room.downlinkVideoCodec&&this._room.requestRemoteFallbackToH264()}};JS([VF(),xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;i{let o=A=>{this.off("closed",o),i(new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.CONNECTION_ABORTED,data:A})}))};this.on("closed",o),A.apply(this,t).then(e,i).finally(()=>{this.off("closed",o)})})})],bV.prototype,"subscribe",1),JS([VF()],bV.prototype,"unsubscribe",1),JS([KF(()=>"jitter")],bV.prototype,"setJitterBufferDelay",1);var GV=bV,kV=YS(jS()),LV=class A extends kV.EventEmitter{constructor(A,e){super(),this.room=A,this.signalChannel=e,HS(this,"log"),HS(this,"cmdIdSeqMap",new Map),HS(this,"messageMap",new Map),this.log=sG.createLogger({parent:A.getLogger(),id:"cmm",userId:A.userId}),this.onReceiveMsg=this.onReceiveMsg.bind(this),e.on(LH.RECEIVE_CUSTOM_MSG,this.onReceiveMsg),this.room.on("peer-leave",A=>{let{userId:e}=A;[...this.messageMap.keys()].forEach(A=>{A.split("_").slice(0,-1).join("_")===e&&this.messageMap.delete(A)})})}send(A){let{cmdId:e,data:t}=A,i=this.cmdIdSeqMap.get(e)||Math.floor(16383*Math.random()),o={cmdId:e,msg:btoa(String.fromCharCode(...new Uint8Array(t))),ordered:!0,reliable:!0,streamSeq:i};this.cmdIdSeqMap.set(e,i+1),this.signalChannel.send(Iq,o),this.log.debug("send custom msg: ".concat(JSON.stringify(o)))}onReceiveMsg(e){let{data:t}=e.data,i=this.room.tinyIdToUserIdMap.get(t.srcTinyId);if(i){let e={userId:i,cmdId:t.cmdId,seq:t.streamSeq,data:Uint8Array.from(atob(t.msg),A=>A.charCodeAt(0)).buffer};if(t.ordered){let t="".concat(i,"_").concat(e.cmdId),o=this.messageMap.get(t);if(o&&0!==o.lastSeq)if(Math.abs(o.lastSeq-e.seq)>A.SEQ_INTERVAL)this.messageMap.set(t,{lastSeq:e.seq,cachedMessageMap:new Map}),this.emitMessage(e);else if(e.seq>o.lastSeq){if(e.seq===o.lastSeq+1)this.emitMessage(e);else if(!o.cachedMessageMap.has(e.seq)){let A=setTimeout(()=>this.emitMessage(e,!0),5e3);o.cachedMessageMap.set(e.seq,{message:e,timeoutId:A})}}else this.log.debug("drop message ".concat(e.userId,"-").concat(e.cmdId,"-").concat(e.seq));else o||(o={lastSeq:0,cachedMessageMap:new Map},this.messageMap.set(t,o),setTimeout(()=>this.emitMessage(e,!0),100)),o.cachedMessageMap.set(e.seq,{message:e})}else this.emit("message",e)}else{this.log.warn("receive msg from unknown user, wait peer-join tinyId: ".concat(t.srcTinyId));let A=i=>{i.tinyId===t.srcTinyId&&(this.room.off("peer-join",A),this.onReceiveMsg(e))};this.room.on("peer-join",A),DT(2e3).then(()=>this.room.off("peer-join",A))}}emitMessage(A){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var t;let i=this.messageMap.get("".concat(A.userId,"_").concat(A.cmdId)),o=A;if(i){if(e){let A=[...i.cachedMessageMap.values()].sort((A,e)=>A.message.seq-e.message.seq);A[0]&&(o=A[0].message)}0!==i.lastSeq&&o.seq-i.lastSeq>1&&this.log.debug("msg lost userId: ".concat(o.userId," seq: ").concat(i.lastSeq," -> ").concat(o.seq)),i.lastSeq=o.seq,clearTimeout(null==(t=i.cachedMessageMap.get(o.seq))?void 0:t.timeoutId),i.cachedMessageMap.delete(o.seq)}this.log.debug("receive custom msg: ".concat(JSON.stringify(o))),this.emit("message",o);let n=null==i?void 0:i.cachedMessageMap.get(o.seq+1);n&&this.emitMessage(n.message)}};HS(LV,"SEQ_INTERVAL",300);var UV=LV,{isString:FV,isUndefined:OV,getNetworkType:xV,isEmpty:PV}=EM,YV=class extends tV{constructor(A){super(A),HS(this,"_businessInfo"),HS(this,"userManager"),HS(this,"_version"),HS(this,"_heartbeat",-1),HS(this,"_lastHeartBeatTime",-1),HS(this,"_stats"),HS(this,"_joinTimeout",-1),HS(this,"_firstPublishedList",null),HS(this,"_joinReject",null),HS(this,"_isRelayChanged",!1),HS(this,"sdpSemantics"),HS(this,"signalChannel",null),HS(this,"uplinkConnection",null),HS(this,"singlePC",null),HS(this,"enableSPC",uL),HS(this,"_changeBigSmallRecords",new Map),HS(this,"networkQuality"),HS(this,"_iceTransportPolicy"),HS(this,"forceRelay",!1),HS(this,"_turnServers",[]),HS(this,"_iceServersFromJoin"),HS(this,"_syncUserListInterval",-1),HS(this,"_smallStreamConfig",{bitrate:100,frameRate:15,height:120,width:160}),HS(this,"enableSEI",!1),HS(this,"_enableAudioVolumeEvaluation",!1),HS(this,"_audioVolumeIntervalId",0),HS(this,"_enableMultiAuxStream",!1),HS(this,"_pureAudioPushMode",!1),HS(this,"_customMessageManager"),HS(this,"_enableDataChannel",!1),HS(this,"preferHW",!1),HS(this,"healthDetector"),HS(this,"playoutDelay"),HS(this,"jitterBufferDelay"),HS(this,"_updateAudioLevelTaskId",-1),HS(this,"switchRoomSubedReq"),HS(this,"resolveSwitchRoomSubedReq"),HS(this,"enableVolumeControlInIOS"),HS(this,"capturedLocalMainAudioTrack"),HS(this,"capturedLocalMainVideoTrack"),HS(this,"capturedLocalAuxVideoTrack"),HS(this,"firewallDetector"),this.firewallDetector=new CY,this.firewallDetector.on("firewall-restriction",()=>{this._log.warn("firewall restriction"),this.emit("firewall-restriction")}),this._stats=new Nq(this,this._log),this.userManager=new dY(this.userId,this._log),this._version=CM,this.sdpSemantics=NR,OV(A.sdpSemantics)?cG.isUnifiedPlanDefault()&&(this.sdpSemantics=TR):this.sdpSemantics=A.sdpSemantics,this._log.info("sdpSemantics: ".concat(this.sdpSemantics,", netType: ").concat(xV())),A.iceTransportPolicy&&(this._iceTransportPolicy=A.iceTransportPolicy),this._enableMultiAuxStream=!OV(A.enableMultiAuxStream)&&A.enableMultiAuxStream,this.enableSEI=A.enableSEI&&uL,!OV(A.enableSPC)&&uL&&(this.enableSPC=A.enableSPC),this.preferHW=!!A.preferHW,this.enableVolumeControlInIOS=A.enableVolumeControlInIOS,this._initBusinessInfo(A),this.healthDetector=new CV(this)}get isMainStreamPublished(){var A;return!(null==(A=this.uplinkConnection)||!A.isMainStreamPublished)}get isMainAudioPublished(){var A;return!(null==(A=this.uplinkConnection)||!A.localMainAudioTrack)}get isAuxStreamPublished(){var A;return!(null==(A=this.uplinkConnection)||!A.isAuxStreamPublished)}get hasAuxStream(){return[...this.remotePublishedUserMap.values()].findIndex(A=>A.muteState.hasAuxiliary)>=0}get userMap(){return this.userManager.userMap}get remotePublishedUserMap(){return this.userManager.remotePublishedUserMap}get tinyIdToUserIdMap(){return new Map([...this.userMap.values()].map(A=>[A.tinyId,A.userId]))}get videoCodec(){var A;return(null==(A=this.singlePC)?void 0:A.videoCodec)||"h264"}get downlinkVideoCodec(){var A;return(null==(A=this.singlePC)?void 0:A.downlinkVideoCodec)||"h264"}join(A,e,t){return VS(this,null,function*(){return this.userManager.mySelfId=this.userId,this.userManager.on("1",A=>{this.emit("peer-join",A)}),this.userManager.on("8",A=>{this.emit("asr-robot-peer-join",A)}),this.userManager.on("9",A=>{this.emit("asr-robot-peer-leave",A)}),this.userManager.on("2",A=>{let{userId:e,reason:t}=A;this.closeDownLinkConnection(e,"remote user exitRoom"),this.emit("peer-leave",{userId:e,reason:t})}),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",A=>{var e=OS(A,[]);tG.emit(oG.REMOTE_PUBLISH_STATE_CHANGED,US({room:this},e)),this.emit("remote-publish-state-changed",US({},e))}),this.joinParams=A,j_(A.enableDataChannel)&&(this._enableDataChannel=A.enableDataChannel),new Promise((e,t)=>VS(this,null,function*(){var i,o;this._joinReject=t;try{this.checkDestroy();try{yield Promise.all([this.initialize(),this.initSinglePC()])}catch(n){if(!(n instanceof rM&&n.code===oM.SPC_INITIALIZED_FAILED))return t(n);null==(i=this.signalChannel)||i.destroy(),yield this.initialize()}let r=oT();yield this.doJoin(A,null==(o=this.singlePC)?void 0:o.clientAbility),Gk.addSuccessEvent({key:521708,cost:oT()-r}),e(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}})}catch(r){Gk.addFailedEvent({key:521708,error:r}),t(r)}this._joinReject=null}))})}initSinglePC(){return VS(this,null,function*(){if(this.enableSPC&&!this.singlePC){this.singlePC=new pV({signalChannel:this.signalChannel,room:this,enableDataChannel:this._enableDataChannel}),this.singlePC.on("sei-message",A=>this.emit("sei-message",A)),this.singlePC.on("dump",A=>this.emit("dump",A)),this.singlePC.once("error",()=>this.fallbackToMPC()),this.singlePC.on("data_channel_msg",A=>{let e=(new TextDecoder).decode(A.data.data||A.data);try{this.emit("data-channel-message",{data:JSON.parse(e)})}catch(t){}});try{return yield this.singlePC.initialize()}catch(A){throw this.fallbackToMPC(),new rM({code:oM.SPC_INITIALIZED_FAILED,message:null==A?void 0:A.message})}}})}doJoin(A,e){return new Promise((t,i)=>VS(this,null,function*(){var o,n,r,s,a,g,c,l;A.privateMapKey&&(this.privateMapKey=A.privateMapKey),A.latencyLevel&&(this.latencyLevel=A.latencyLevel),this.signalChannel.once(_H,A=>{this.clearJoinTimeout(),tG.emit(oG.JOIN_SIGNAL_CONNECTION_END,{room:this,error:A}),i(A)}),j_(null==(n=null==(o=this.scheduleResult)?void 0:o.config)?void 0:n.singlePC)&&uL&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2),(!(null==(s=null==(r=this.scheduleResult)?void 0:r.config)?void 0:s.jitterDelay)&&!(null==(g=null==(a=this.scheduleResult)?void 0:a.config)?void 0:g.jitterDelayAux)||!kL)&&e&&this.playoutDelay&&(this._log.info("set playoutDelay",JSON.stringify(this.playoutDelay)),e.playoutDelay=this.playoutDelay);let I={roomId:String(A.roomId||A.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel,trtcRole:A.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:$b(),netType:T_(),bussinessInfo:this._businessInfo,ability:e,sdkType:this._sdkType,userSig:this.userSig,receiveMix:!0,isChorus:!!this.enableChorus,enableNtpAudioFrame:!!this.enableChorus&&Ok(),transcription:this._enableDataChannel,downUseVp8:(null==(c=this.scheduleResult.config)?void 0:c.downUseVp8)||!1};this._log.debug("join room signal data: ".concat(JSON.stringify(I)));let u=5e3;null!=(l=this.scheduleResult.config)&&l.enterRoomTimeout&&this.scheduleResult.config.enterRoomTimeout>=1&&(u=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout(()=>{i(new rM({code:oM.JOIN_ROOM_FAILED,message:mk({key:Bk.JOIN_ROOM_TIMEOUT})}))},u),tG.emit(oG.JOIN_SEND_CMD,{room:this}),this.signalChannel.send(this.singlePC?sq:FH,I),this.signalChannel.once(LH.JOIN_ROOM_RESULT,e=>VS(this,null,function*(){this.clearJoinTimeout();let{code:o,message:n,data:r,tinyId:s}=e.data;tG.emit(oG.JOIN_RECEIVED_CMD_RES,{room:this,code:o}),0===o?(this._log.info("Join room success, start heartbeat"),s&&(this.tinyId=s),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=r.publishers,this._iceServersFromJoin=r.iceServer?[r.iceServer]:[],this.singlePC&&this.singlePC.setIceServers(this.getIceServers()).then(()=>{var e;null==(e=this.singlePC)||e.connect(FS(US({},r.ability),{useVp8:r.ability.useVp8||!!A.useVp8,useH265:r.ability.useH265&&!!A.useH265})).catch(()=>{})}),t()):(this._log.error("Join room failed result: ".concat(o," error: ").concat(n)),i(new rM({code:oM.JOIN_ROOM_FAILED,extraCode:o,message:mk({key:Bk.JOIN_ROOM_FAILED,data:{error:n,code:o}})})))}))}))}reJoin(){return VS(this,null,function*(){if(this.isJoined)try{this._log.warn("reJoin pending: ".concat(this.joinParams.roomId));let A,e=[];if(this.singlePC&&(this.singlePC.close(),this.singlePC=null,e.push(this.initSinglePC().then(e=>(A=e,e)))),this.signalChannel&&(this.signalChannel.close(),e.push(this.signalChannel.connect())),yield Promise.all(e),yield this.doJoin(FS(US({},this.joinParams),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel}),A),this._log.warn("reJoin success"),gU.logSuccessEvent({userId:this.userId,eventType:wR.REJOIN}),this.singlePC){let A=e=>{var t;"CONNECTED"===e.state&&(null==(t=this.singlePC)||t.off(BV.CONNECTION_STATE_CHANGED,A),this.uplinkConnection instanceof TV&&(this.uplinkConnection.installEvents(),this.uplinkConnection.onSinglePCReconnected()),this.remotePublishedUserMap.forEach(A=>{A.installEvents(),A.onSinglePCReconnected()}))};this.singlePC.on(BV.CONNECTION_STATE_CHANGED,A),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof Tq&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection()}}catch(A){this._log.warn("reJoin fail ".concat(A)),this.reset(),gU.logFailedEvent({userId:this.userId,eventType:wR.REJOIN,error:A}),this.emit("error",new rM({code:oM.JOIN_ROOM_FAILED,message:mk({key:Bk.REJOIN_ROOM_FAILED,data:{roomId:this.joinParams.roomId}})}))}else this._log.warn("reJoin abort")})}initialize(){return VS(this,null,function*(){let A,{mainUrl:e,backupUrl:t}=this.getSignalChannelUrl(),i=this.signalChannel||(n=this.userId,[...hq.values()].find(A=>A.room.userId===n&&!A.room.isJoined)||null),o=!!(i&&i.isConnected&&i.keepAlive&&i.userId===this.userId&&i.room===this);var n;return Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(A=this.scheduleResult.domains[0]),this._log.info("".concat(o?"reuse":"setup"," signal channel")),o?(i.url=e,i.backupUrl=t,i.room=this,this.signalChannel=i):(i&&i.close(),this.signalChannel=new Qq({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:e,backupUrl:t,room:this,signalDomainWhenUnifiedProxy:this.proxy_unified?A:void 0}),this._customMessageManager=new UV(this,this.signalChannel),this._customMessageManager.on("message",A=>{this.emit("custom-message",A)})),this.networkQuality||(this.networkQuality=new Lq({signalChannel:this.signalChannel,room:this}),this.networkQuality.on(Lq.EVENT_NETWORK_QUALITY,A=>{var e;this.emit("network-quality",A),null==(e=this.singlePC)||e.detectTCPAndUDP(A)})),sU(this,this.signalChannel).add(SH,A=>{tG.emit(oG.SIGNAL_CONNECTION_STATE_CHANGED,US({room:this},A)),this.emit("signal-connection-state-changed",A)}).add(RH,A=>{this.reset(),this.emit("error",A)}).add(LH.PEER_JOIN,A=>{let{srcTinyId:e,userId:t,role:i,fromType:o}=A.data.data;this.userManager.addUser({userId:t,tinyId:e,role:i,fromType:o})}).add(LH.PEER_LEAVE,A=>{let{userId:e,reason:t=0}=A.data.data;this.userManager.deleteUser(e,t)}).add(LH.UPDATE_REMOTE_MUTE_STAT,A=>{this._lastHeartBeatTime>0&&Date.now()-this._lastHeartBeatTime>=1e4&&this.doHeartbeat(),this.onPublishedUserList(A.data)}).add(LH.CLIENT_BANNED,A=>{let e=A.data.data,{reason:t}=e;if(gU.uploadEvent({log:"stat-banned:".concat(t),userId:this.userId}),"user_time_out"===t)return this._log.warn("".concat(t," last heart beat time: ").concat(this._lastHeartBeatTime," interval: ").concat(Date.now()-this._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void this.reJoin();this._log["kick"===t?"error":"info"]("user was banned because of [".concat(t,"]")),this.reset(),this.emit("banned",{reason:t})}).add(LH.SEND_SWITCH_ROOM_SUBED_REQ,A=>{if(!this.singlePC)return;let{subList:e}=A.data.data;this._log.info("auto subscribe ".concat(CT(e,{keysToInclude:["userId"]}))),e.forEach(A=>{this.singlePC.autoSubscribedUserMap.set(A.userId,A)}),this.resolveSwitchRoomSubedReq()}).add(LH.FALLBACK_CODEC,A=>VS(this,null,function*(){var e,t,i,o,n;let r=A.data.data;0===(null==(e=r.videoControlInfo)?void 0:e.enableH265Enc)&&"h265"===(null==(t=this.singlePC)?void 0:t.videoCodec)&&(this._log.warn("fallback codec enableH265Enc: ".concat(null==(i=r.videoControlInfo)?void 0:i.enableH265Enc)),Gk.addCount({key:513e3}),yield null==(o=this.singlePC)?void 0:o.switchVideoEncoder("h264"),yield null==(n=this.uplinkConnection)?void 0:n.sendMediaSettings())})),this.signalChannel.once(wH,A=>{this.tinyId=A.signalInfo.tinyId,tG.emit(oG.JOIN_SIGNAL_CONNECTION_END,{room:this})}),tG.emit(oG.JOIN_SIGNAL_CONNECTION_START,{room:this}),yield this.signalChannel.connect(),o&&tG.emit(oG.JOIN_SIGNAL_CONNECTION_END,{room:this}),o})}setSignalChannel(A){this.signalChannel=A,A||aU(this)}leave(){return VS(this,null,function*(){var A;try{yield this.doHeartbeat()}catch(e){}this._log.info("leave() => leaving room"),tG.emit(oG.LEAVE_SEND_CMD,{room:this}),null==(A=this.signalChannel)||A.send(OH),this.switchRoomSubedReq=void 0,this._changeBigSmallRecords.clear()})}clearNetworkQuality(){this.networkQuality&&(this.networkQuality.stop(),delete this.networkQuality)}closeConnections(){this.remotePublishedUserMap.forEach(A=>{this.closeDownLinkConnection(A.userId,"you exitRoom")})}clearJoinTimeout(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}startHeartbeat(){-1===this._heartbeat&&(this._heartbeat=iU.run("ric",this.doHeartbeat.bind(this),{delay:2e3}),this.enableChorus&&this.startUpdateNTPTime())}stopHeartbeat(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),iU.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}doHeartbeat(){return VS(this,null,function*(){var A;let e=this.badCaseDetector.getMonitorFreeze(),t=yield this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:e});this.badCaseDetector.resetMonitor();let i=null!=(A=this.signalChannel)&&A.isConnected?function(A){if(cY.has(A)){let e=cY.get(A).map(A=>({uint32_event_id:A.eventId,uint64_date:A.timestamp,str_userid:A.remoteUserId,uint32_param1:A.param1,uint32_param2:A.param2,uint32_video_stream_type:A.streamType}));return cY.delete(A),e}return[]}(this.userId):[],o=FS(US({str_sdk_version:hM,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_event_msg:i,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},t),{msg_device_info:US({uint32_terminal_type:15,str_device_name:Vb(),str_os_version:"",uint32_net_type:T_()},t.msg_device_info)});if(this.heartbeatReport=o,this.heartbeatCount++,tG.emit(oG.HEARTBEAT_REPORT,{room:this,report:o}),this.signalChannel){if(this.signalChannel.isConnected){this.signalChannel.send(xH,o);let A=Date.now();this._lastHeartBeatTime>0&&A-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(A-this._lastHeartBeatTime)),this._lastHeartBeatTime=A,this.signalChannel.isOnline||(this._log.warn("signal channel is not online"),this.signalChannel.startReconnection())}this.emit("heartbeat-report",FS(US({},o),{bytes_sent:this._stats.totalBytesSent+this.signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this.signalChannel.bytesReceived}))}!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0)})}onPublishedUserList(A){if(!this.isJoined)return;let e=!1,t=A.data.userList||[],i=A.data.mixRobotList||[],o=[];for(let r of t){if(r.flag===rR)continue;let{userId:A,srcTinyId:t,flag:i,fromType:n}=r;A===this.userId&&(e=!0,this.uplinkConnection&&(this.uplinkConnection.flag=i),this.localPublishFlag!==i&&(this.localPublishFlag=i,this.emit("local-publish-flag-changed",i))),o.push({userId:A,tinyId:t,flag:i,fromType:n})}let n=[...i.map(A=>{let{userId:e,srcTinyId:t,flag:i,mixUserList:o,fromType:n}=A;return{userId:e,tinyId:t,flag:i,isRobot:!0,mixUserList:o,fromType:n}}),...o];n.forEach(A=>{let{userId:e}=A,t=this.remotePublishedUserMap.get(e);t&&this.checkSubscribeBigSmallVideo(t)}),A.data.fakeMixUser&&(A.data.fakeMixUser.tinyId=A.data.fakeMixUser.srcTinyId,n.push(A.data.fakeMixUser)),tG.emit(oG.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:n}),e||(this.localPublishFlag=0,this.emit("local-publish-flag-changed",0)),this.userManager.setRemotePublishedUserList(n)}closeUplink(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish().catch(()=>{}),this.uplinkConnection.close(A),"you exitRoom"===A&&(this.uplinkConnection.destroy(),this.uplinkConnection=null),this.uplinkConnection instanceof Tq&&(this.uplinkConnection=null)),this.localTracks.forEach(A=>A.unpublish()),this.localTracks.clear()}createDownlinkConnection(A){let{userId:e,tinyId:t,flag:i,isRobot:o,fromType:n}=A,r=new(this.singlePC?GV:Mq)({userId:e,tinyId:t,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:i,isRobot:o,fromType:n});this.userManager.addRemotePublishedUser(r),this.installDownlinkEvents(r,e),this.emit("remote-published",r)}closeDownLinkConnection(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",t=this.remotePublishedUserMap.get(A);t&&(t.close(e),this.emit("remote-unpublished",t))}installDownlinkEvents(A,e){A.on("error",A=>{let t=A.getCode();t!==oM.ICE_TRANSPORT_ERROR&&(t===oM.DOWNLINK_RECONNECTION_FAILED&&this.closeDownLinkConnection(e),this.emit("error",A))}),A.on("connection-state-changed",e=>{this.emit("media-connection-state-changed",FS(US({},e),{userId:A.userId}))})}startSyncUserListInterval(){-1===this._syncUserListInterval&&(this._syncUserListInterval=iU.run("ric",this.syncUserList.bind(this)))}stopSyncUserListInterval(){iU.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}syncUserList(){return this.getUserList().then(A=>{this.userManager.setUserList(A)}).catch(A=>{this._log.debug("sync user list failed: ".concat(A))})}getUserList(){var A;return null!=(A=this.signalChannel)&&A.isConnected?this.signalChannel.sendWaitForResponse({command:iq,responseCommand:LH.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(A=>{let{data:e}=A,{code:t,message:i}=e;if(0===t)return(e.data&&e.data.userList||[]).map(A=>{let{userId:e,srcTinyId:t,role:i,fromType:o}=A;return{userId:e,tinyId:t,role:i,fromType:o}});throw mk({key:Bk.SIGNAL_RESPONSE_FAILED,data:{signalResponse:LH.USER_LIST_RES,code:t,message:i}})}):Promise.reject("not connected")}getAllConnections(){let A=[...this.remotePublishedUserMap.values()];return this.uplinkConnection&&A.push(this.uplinkConnection),A}isRelayMaybeFailed(){if(this.signalChannel&&!this.signalChannel.isOnline||!fq)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;let A=this.getAllConnections();if(0===A.length)return!1;for(let e=0;e{if(A instanceof mq&&!A.getIsReconnecting()){let e=A.getPeerConnection();e&&e.connectionState===pR.CLOSED&&(this._log.warn("[".concat(A.getUserId(),"] pc is closed but not reconnect")),A.startReconnection())}})}fallbackToMPC(){return VS(this,null,function*(){var A;if(this._log.warn("fallback to multi pc"),gU.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(A=this.singlePC)||A.close(),this.singlePC=null,this.isJoined&&(yield this.reJoin()),this.uplinkConnection){let A=this.uplinkConnection;this.uplinkConnection=new Tq({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),A.isMainStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:A.localMainAudioTrack,localVideoTrack:A.localMainVideoTrack,isAuxiliary:!1})),A.isAuxStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:A.localAuxAudioTrack,localVideoTrack:A.localAuxVideoTrack,isAuxiliary:!0})),A.close()}for(let e of[...this.remotePublishedUserMap.values()]){let A=new Mq({userId:e.userId,tinyId:e.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:e.flag,remoteAudioTrack:e.remoteAudioTrack,remoteVideoTrack:e.remoteVideoTrack,remoteAuxiliaryTrack:e.remoteAuxiliaryTrack});this.installDownlinkEvents(A,e.userId),this.remotePublishedUserMap.set(e.userId,A),e.isMainStreamSubscribed&&(yield A.subscribe(e.subscribeState,"main")),e.isAuxStreamSubscribed&&(yield A.subscribe(e.subscribeState,"auxiliary"))}})}destroy(){this.isDestroyed||(this.signalChannel&&(this._log.info("destroying SignalChannel"),this.signalChannel.close(),this.signalChannel=null),super.destroy(),this._joinReject&&(this._joinReject(new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.firewallDetector.destroy(),this.removeAllListeners(),this.healthDetector.destroy(),iU.clearTask(this._audioVolumeIntervalId))}switchRole(A){return VS(this,null,function*(){this.role!==A&&("audience"===A&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),yield this.doSwitchRole(A))})}doSwitchRole(A){let e={command:oq,data:{role:"anchor"===A?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel},responseCommand:LH.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(e.data))),this.signalChannel.sendWaitForResponseWithRetry(e).then(e=>{let{code:t,message:i}=e.data;if(0!==t)throw new rM({code:oM.SWITCH_ROLE_FAILED,message:mk({key:Bk.SWITCH_ROLE_FAILED,data:{message:i,code:t}})});this.role=A}).catch(A=>{throw A instanceof rM&&A.getCode()===oM.API_CALL_TIMEOUT&&(A=new rM({code:oM.SWITCH_ROLE_FAILED,message:mk({key:Bk.SWITCH_ROLE_TIMEOUT})})),this._log.error(A),A})}subscribeDataChannel(){return VS(this,null,function*(){if(0===this.remotePublishedUserMap.size)return;let A=[...this.remotePublishedUserMap.values()].filter(A=>A.fromType===$R);this._log.info("subscribeDataChannel",A.map(A=>A.userId)),yield Promise.all(A.map(A=>VS(this,null,function*(){try{yield A.subscribe(FS(US({},A.subscribeState),{datachannel:!0}),"main")}catch(e){this._log.error("subscribeDataChannel failed:",A.userId,e)}})))})}unsubscribeDataChannel(){return VS(this,null,function*(){if(0===this.remotePublishedUserMap.size)return;let A=[...this.remotePublishedUserMap.values()].filter(A=>A.fromType===$R);this._log.info("unsubscribeDataChannel",A.map(A=>A.userId)),yield Promise.all(A.map(A=>A.unsubscribeDataChannel()))})}_initUplinkConnection(){this.uplinkConnection=this.singlePC?new TV({userId:this.userId,tinyId:this.tinyId,room:this}):new Tq({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),this.uplinkConnection.on("connection-state-changed",A=>{this.emit("media-connection-state-changed",FS(US({},A),{userId:this.userId}))}),this.uplinkConnection.on("error",A=>{let e=A.getCode();e!==oM.ICE_TRANSPORT_ERROR&&(e===oM.UPLINK_RECONNECTION_FAILED&&this.closeUplink(),this.emit("error",A))})}publish(A){return VS(this,null,function*(){var e;this.uplinkConnection||this._initUplinkConnection();let t="".concat(A.streamType," ").concat(A.isAudio&&A.isScreen?"screen":"").concat(A.kind);this._log.info("publish() => ".concat(t)),yield null==(e=this.singlePC)?void 0:e.waitForPeerConnectionConnected(),yield this.uplinkConnection.publish({localAudioTrack:A instanceof BP?A:null,localVideoTrack:A instanceof DP?A:null,isAuxiliary:"auxiliary"===A.streamType})})}unpublish(A){return VS(this,null,function*(){if(("live"!==this.scene||"anchor"===this.role)&&(this.isMainStreamPublished||this.isAuxStreamPublished)&&this.uplinkConnection){try{let e="".concat(A.streamType," ").concat(A.isAudio&&A.isScreen?"screen":"").concat(A.kind);this._log.info("unpublish() => ".concat(e)),yield this.uplinkConnection.unpublish({localAudioTrack:A instanceof BP?A:null,localVideoTrack:A instanceof DP?A:null})}catch(e){}0===this.localTracks.size&&this.closeUplink("you unpublished")}})}addTrack(A){if(!this.uplinkConnection||!A.mediaTrack)return Promise.resolve();let e=this.uplinkConnection.addTrack(A);return A.publish(this,e),e}removeTrack(A){return this.uplinkConnection&&A.mediaTrack?(A.unpublish(),this.uplinkConnection.removeTrack(A)):Promise.resolve()}replaceTrack(A){return this.uplinkConnection&&A.mediaTrack&&hL()?this.uplinkConnection.replaceTrack(A).then(e=>{e&&tG.emit(oG.LOCAL_TRACK_REPLACED,{track:A})}):Promise.resolve()}setBandWidth(A){return VS(this,null,function*(){this.uplinkConnection&&(yield this.uplinkConnection.setBandwidth(A),yield this.uplinkConnection.sendMediaSettings())})}enableSmall(A){return VS(this,null,function*(){if(!this.uplinkConnection||!this.uplinkConnection.localMainVideoTrack)return Promise.resolve();A&&this.uplinkConnection.localMainVideoTrack.small&&(yield this.setBandWidth({type:WM.VIDEO,videoType:WM.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate})),yield this.uplinkConnection.enableSmall(A)})}subscribe(){for(var A=arguments.length,e=new Array(A),t=0;t!A.isSubscribed)).length)return;let{userId:A}=e[0],t=this.remotePublishedUserMap.get(A);if(!t)return;let i=e.find(A=>2===A.mediaType)?"auxiliary":"main";try{let o=US({},t.subscribeState);e.forEach(A=>{switch(A.mediaType){case 1:o.audio=!0;break;case 4:o.video=!0;break;case 8:o.smallVideo=!0;break;case 2:o.auxiliary=!0}});let n=this._changeBigSmallRecords.get(A);n&&n.options.smallVideo&&t.muteState.hasSmall&&o.video&&(o.video=!1,o.smallVideo=!0),tG.emit(oG.SUBSCRIBE_START,{room:this,streamType:i,remotePublishedUser:t,subscribeState:o}),this._log.info("subscribe() => ".concat(A," ").concat(i," ").concat(e.map(A=>A.strMediaType).join(",")," [").concat(wq(o),"] prev: [").concat(wq(t.subscribeState),"]")),yield t.subscribe(o,i),this._log.info("subscribe ".concat(A," ").concat(i," done"));for(let A of e)A.mediaTrack||(yield A.waitHasMediaTrack());tG.emit(oG.SUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:t})}catch(o){let e=o instanceof rM?o.getCode():oM.UNKNOWN,t=o;throw o instanceof rM?e===oM.REMOTE_STREAM_NOT_EXIST&&(t=new rM({code:oM.API_CALL_ABORTED,message:mk({key:Bk.API_CALL_ABORTED,data:{message:o.message,userId:A,streamType:i}})}),this._log.warn(t)):(t=new rM({code:e,message:mk({key:Bk.SUBSCRIBE_FAILED,data:{message:o.message,userId:A,streamType:i}})}),this._log.error(t)),t}})}unsubscribe(){for(var A=arguments.length,e=new Array(A),t=0;t2===A.mediaType)?"auxiliary":"main";this._log.info("unsubscribe() => ".concat(A," ").concat(i," ").concat(e.map(A=>A.strMediaType).join(",")));try{yield t.unsubscribe({remoteTracks:e,streamType:i})}catch(o){this._log.warn("unsubscribe() => failed ".concat(o))}e.forEach(A=>{A.unsubscribe(),8===A.mediaType&&A.setMediaType(4)}),tG.emit(oG.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:t})})}setEncodedDataProcessingListener(A){throw new Error("Method not implemented.")}enableAudioVolumeEvaluation(){let A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,e=arguments.length>1?arguments[1]:void 0;if(A<=0)return this._enableAudioVolumeEvaluation=!1,void iU.clearTask(this._audioVolumeIntervalId);A=Math.floor(Math.max(A,100)),tG.emit(oG.AUDIO_LEVEL_INTERVAL,{interval:A}),this._audioVolumeIntervalId&&iU.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=iU.run("intervalInWorker",()=>{var t;lF.isRunning?this.stopUpdateAudioLevelFromSenderStat():this.updateAudioLevelFromSenderStat(A,e);let i=[];null==(t=this.remotePublishedUserMap)||t.forEach(A=>{if(A.muteState.hasAudio){!lF.isRunning&&A.muteState.audioAvailable&&A.remoteAudioTrack.isSubscribed?this.updateDownlinkAudioLevelFromReceiver(A):A.remoteAudioTrack.volume=0;let e=Math.floor(100*A.remoteAudioTrack.getAudioLevel());i.push({userId:A.userId,volume:e,floatVolume:A.remoteAudioTrack.getInternalAudioLevel()})}}),this.emit("audio-volume",i)},{delay:A,backgroundTask:e})}updateAudioLevelFromSenderStat(A,e){return VS(this,null,function*(){var t;if(!this.uplinkConnection||!this.uplinkConnection.localMainAudioTrack||-1!==this._updateAudioLevelTaskId)return;let i=null==(t=this.uplinkConnection.getPeerConnection())?void 0:t.getSenders()[0];if(!i)return;let o=Math.max(A,500);this._log.warn("updateAudioLevelFromSenderStat ".concat(o)),this._updateAudioLevelTaskId=iU.run("intervalInWorker",()=>VS(this,null,function*(){if(!this.uplinkConnection||!this.uplinkConnection.localMainAudioTrack)return void this.stopUpdateAudioLevelFromSenderStat();let A=yield i.getStats();if(this._updateAudioLevelTaskId<0)return;let{localMainAudioTrack:e}=this.uplinkConnection;A.forEach(A=>{"media-source"===A.type&&A.audioLevel&&(e.volume=A.audioLevel)})}),{delay:o,backgroundTask:e})})}stopUpdateAudioLevelFromSenderStat(){var A;-1!==this._updateAudioLevelTaskId&&(this._log.warn("stopUpdateAudioLevelFromSenderStat"),iU.clearTask(this._updateAudioLevelTaskId),this._updateAudioLevelTaskId=-1,null!=(A=this.uplinkConnection)&&A.localMainAudioTrack&&(this.uplinkConnection.localMainAudioTrack.volume=0))}updateDownlinkAudioLevelFromReceiver(A){var e;let{audioReceiver:t}=A;if(!BL||!t)return;let i=null==(e=t.getSynchronizationSources()[0])?void 0:e.audioLevel;V_(i)?A.remoteAudioTrack.volume=Math.min(2*i,1):t.getStats().then(e=>{e.forEach(e=>{"inbound-rtp"===e.type&&V_(e.audioLevel)&&(A.remoteAudioTrack.volume=e.audioLevel)})})}getLocalAudioStats(){return VS(this,null,function*(){var A;let e={};return e[this.userId]={bytesSent:0,packetsSent:0,audioLevel:0},null!=(A=this.uplinkConnection)&&A.localMainAudioTrack&&(e[this.userId]=this.uplinkConnection.localMainAudioTrack.stat),e})}getLocalVideoStats(){return VS(this,null,function*(){var A,e;let t={};return t[this.userId]=(null==(e=null==(A=this.uplinkConnection)?void 0:A.localMainVideoTrack)?void 0:e.stat)||{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0},t})}getTransportStats(){return VS(this,null,function*(){let A={rtt:0,downlinksRTT:{}};if(this.uplinkConnection){let e=yield this._stats.getSenderStats(this.uplinkConnection);A.rtt=e.rtt}for(let[,e]of this.remotePublishedUserMap){let t=yield this._stats.getReceiverStats(e);A.downlinksRTT[t.userId]=t.rtt}return A})}getRemoteVideoStats(A){return VS(this,null,function*(){let e={};for(let[t,i]of this.remotePublishedUserMap)"main"===A&&i.muteState.hasVideo&&(e[t]=i.remoteVideoTrack.stat),"auxiliary"===A&&i.muteState.hasAuxiliary&&(e[t]=i.remoteAuxiliaryTrack.stat);return e})}getRemoteAudioStats(){return VS(this,null,function*(){let A={};for(let[e,t]of this.remotePublishedUserMap)t.muteState.hasAudio&&(A[e]=t.remoteAudioTrack.stat);return A})}setTurnServer(A,e){this._log.info("set turn server: ".concat(JSON.stringify(A)," ").concat(e||""));let t=[];Array.isArray(A)?A.forEach(A=>t.push(EM.getTurnServer(A))):EM.isPlainObject(A)&&t.push(EM.getTurnServer(A)),this._turnServers=t,e&&(this._iceTransportPolicy=e)}sendStartMixTranscode(A){return this.signalChannel.sendWaitForResponse({command:XH,data:A,timeout:5e3,responseCommand:LH.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendStopMixTranscode(A){return this.signalChannel.sendWaitForResponse({command:$H,data:A,timeout:5e3,responseCommand:LH.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendStartPublishCDN(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:e?KH:zH,data:A,timeout:5e3,responseCommand:e?LH.START_PUBLISH_TENCENT_CDN_RES:LH.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendStopPublishCDN(A){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:e?WH:ZH,data:A,timeout:5e3,responseCommand:e?LH.STOP_PUBLISH_TENCENT_CDN_RES:LH.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendStartPushStreamToRoom(A){return this.signalChannel.sendWaitForResponse({command:Aq,data:A,timeout:5e3,responseCommand:LH.START_PUBLISH_CDN_STREAM_RES,commandDesc:"startPublishCDNStream"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendUpdatePushStreamToRoom(A){return this.signalChannel.sendWaitForResponse({command:eq,data:A,timeout:5e3,responseCommand:LH.UPDATE_PUBLISH_CDN_STREAM_RES,commandDesc:"updatePublishCDNStream"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendStopPushStreamToRoom(A){return this.signalChannel.sendWaitForResponse({command:tq,data:A,timeout:5e3,responseCommand:LH.STOP_PUBLISH_CDN_STREAM_RES,commandDesc:"stopPublishCDNStream"}).catch(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A})}sendAbilityStatus(A){var e;null==(e=this.signalChannel)||e.sendWaitForResponse({command:cq,data:A,timeout:5e3,responseCommand:LH.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch(A=>{})}getIceServers(A){var e,t;return this._turnServers.length>0?this._turnServers:null!=(e=this.scheduleResult.iceServers)&&e.length?this.scheduleResult.iceServers:null!=A&&A.length?A:null!=(t=this._iceServersFromJoin)&&t.length?this._iceServersFromJoin:[]}getIceTransportPolicy(){return this.forceRelay?"relay":this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}getLogger(){return this._log}enableAIVoice(){throw new Error("Method not implemented.")}getSignalChannelUrl(){let A={mainUrl:"",backupUrl:""},e=EM.getEnv();return e?(A.mainUrl="wss://".concat(EM.getTestSignalDomain(e)),A.backupUrl=A.mainUrl):this.proxy_ws?(A.mainUrl=this.proxy_ws,A.backupUrl=A.mainUrl):this.proxy_unified?(A.mainUrl="wss://".concat(this.proxy_unified),A.backupUrl=A.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(A.mainUrl="wss://".concat(this.scheduleResult.domains[0]),A.backupUrl=A.mainUrl,this.scheduleResult.domains[1]&&(A.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),A}getSignalInfo(){var A;return(null==(A=this.signalChannel)?void 0:A.getSignalInfo())||{clientIp:"",relayIp:""}}reset(){let A=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this.signalChannel&&(A&&this.signalChannel.keepAlive&&this.signalChannel.isConnected?this.signalChannel.stopKeepAliveIn(3600):(this.signalChannel.close(),this.setSignalChannel(null))),this.localPublishFlag=0,this.heartbeatCount=0,this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}checkSubscribeBigSmallVideo(A){return VS(this,null,function*(){let{subscribeState:e,userId:t,muteState:{hasSmall:i,hasVideo:o}}=A;if(!i&&!o||!e.video&&!e.smallVideo)return;let n=this._changeBigSmallRecords.get(t);if(!n||n.isSubscribing||n.reSubscribeCount<=0)return;let{options:r,reSubscribeCount:s}=n;if(r.video&&e.video||r.smallVideo&&e.smallVideo&&i)return;let a={audio:A.remoteAudioTrack.isSubscribed||A.remoteAudioTrack.isSubscribing,auxiliary:A.remoteAuxiliaryTrack.isSubscribed||A.remoteAuxiliaryTrack.isSubscribing,video:r.video,smallVideo:r.smallVideo,datachannel:A.subscribeState.datachannel};try{if(!i&&a.smallVideo&&(a.video=!0,a.smallVideo=!1),a.smallVideo===e.smallVideo&&a.video===e.video)return;n.isSubscribing=!0,n.reSubscribeCount=s-1,yield A.subscribe(a,"main"),A.remoteVideoTrack.setMediaType(a.smallVideo?8:4),this._log.info("change [".concat(t,"] to ").concat(a.smallVideo?"small":"big"," video successfully. count ").concat(WR-n.reSubscribeCount,".")),n.isSubscribing=!1,n.reSubscribeCount=WR}catch(g){this._log.info("change [".concat(t,"] to ").concat(a.smallVideo?"small":"big"," video failed. count ").concat(WR-n.reSubscribeCount,". reason: ").concat(g)),n.isSubscribing=!1,0===n.reSubscribeCount&&this._changeBigSmallRecords.delete(t)}})}changeType(A,e){let t={options:{video:!A,smallVideo:A},isSubscribing:!1,reSubscribeCount:WR};this._changeBigSmallRecords.set(e.userId,t),this._log.info("set [".concat(e.userId,"] video prefer type: ").concat(A?"small":"big")),this.emit("subscribe-small-video-changed",{userId:e.userId,isSmall:A});let i=this.remotePublishedUserMap.get(e.userId);i&&this.checkSubscribeBigSmallVideo(i)}get smallStreamConfig(){return this._smallStreamConfig}_initBusinessInfo(A){this._businessInfo=A.businessInfo;let e={};if(FV(A.businessInfo)&&(e=JSON.parse(A.businessInfo)),!OV(A.pureAudioPushMode)){if(!Number.isInteger(Number(A.pureAudioPushMode)))throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_PURE_AUDIO})});this._pureAudioPushMode=A.pureAudioPushMode,e.Str_uc_params||(e.Str_uc_params={}),e.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!OV(A.userDefineRecordId)){let t=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===A.userDefineRecordId.match(t))throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_USER_DEFINE_RECORDID})});e.Str_uc_params||(e.Str_uc_params={}),e.Str_uc_params.userdefine_record_id=A.userDefineRecordId}if(!OV(A.userDefinePushArgs)){if(!(FV(A.userDefinePushArgs)&&String(A.userDefinePushArgs)&&String(A.userDefinePushArgs).length<=256))throw new rM({code:oM.INVALID_PARAMETER,message:mk({key:Bk.INVALID_USER_DEFINE_PUSH_ARGS})});e.Str_uc_params||(e.Str_uc_params={}),e.Str_uc_params.userdefine_push_args=A.userDefinePushArgs}PV(e)||(this._businessInfo=JSON.stringify(e))}sendCustomMessage(A){var e;null==(e=this._customMessageManager)||e.send(A)}enableInsertableStreams(){return VS(this,null,function*(){if(this.singlePC&&!this.singlePC.enableInsertableStreams&&mL)return this.singlePC.enableInsertableStreams=!0,yield this.singlePC.waitForPeerConnectionConnected(),yield this.singlePC.startReconnection()})}sendSignalMessage(A){var e;return this.signalChannel?null==(e=this.signalChannel)?void 0:e.sendWaitForResponseWithRetry(A):Promise.reject(new rM({code:oM.INVALID_OPERATION,message:"not join"}))}get enableCodecPipeline(){return this.videoManager.encodePipeline.length>0||this.videoManager.decodePipeline.length>0||this.audioManager.encodePipeline.length>0||this.audioManager.decodePipeline.length>0}get scriptTransformWorker(){var A;return null==(A=this.singlePC)?void 0:A.scriptTransformWorker}switchRoom(A){return VS(this,null,function*(){var e;if(!this.signalChannel||!this.singlePC)return;let{roomId:t,strRoomId:i,userSig:o,privateMapKey:n}=A,r=(null==(e=this.scheduleResult.config)?void 0:e.autoSubscribeCount)||(null==A?void 0:A.autoSubscribeCount)||1,s=String(this.useStringRoomId?i:t),a=[];for(let A=0;A{this.resolveSwitchRoomSubedReq=A,DT(5e3).then(A)}),tG.emit(oG.SWITCH_ROOM_START,{room:this}),yield this.singlePC.waitForPeerConnectionConnected();try{this.userManager.clear(),c=yield this.signalChannel.sendWaitForResponse({command:uq,responseCommand:LH.SEND_SWITCH_ROOM_RES,data:g});let{code:A,message:e}=c.data;if(0!==A){this._log.error("switch room failed. result: ".concat(A," error: ").concat(e));let t=new rM({code:oM.SWITCH_ROOM_FAILED,extraCode:A,message:e});throw tG.emit(oG.SWITCH_ROOM_FAILED,{room:this,error:t}),t}this.userSig=o,OV(n)||(this.privateMapKey=n),tG.emit(oG.SWITCH_ROOM_SUCCESS,{room:this,currentRoomId:l,targetRoomId:s})}catch(I){throw this.singlePC.autoSubscribedSsrcGroups.clear(),this.roomId=l,this.resolveSwitchRoomSubedReq(),I}})}isSwitchRoomSupported(){var A;let e="unable to use switchRoom API, fallback to exitRoom and enterRoom.";return!0!==(null==(A=this.scheduleResult.config)?void 0:A.switchRoom)?(this._log.warn("".concat(e," Reason: this sdkAppId is not supported, please contact us [https://trtc.io/contact] to enable it.")),!1):"live"!==this.scene?(this._log.warn("".concat(e," Reason: the scene is not 'live'.")),!1):"audience"!==this.role?(this._log.warn("".concat(e," Reason: the role is not 'audience'.")),!1):!!this.singlePC||(this._log.warn("".concat(e," Reason: is not using single peerConnection.")),!1)}requestRemoteFallbackToH264(){var A;null==(A=this.singlePC)||A.requestRemoteFallbackToH264()}startUpdateNTPTime(){if(!this.signalChannel)return;let A=[];for(let e=0;e<5;e++)A.push(this.updateNTPTime());return Promise.all(A).then(A=>{var e;let t=A[0].offset,i=A[0].offset;A.forEach(A=>{t=Math.min(A.offset,t),i=Math.max(A.offset,i)});let o=Math.floor(A.reduce((A,e)=>A+e.rtt,0)/A.length),n=Math.floor(A.reduce((A,e)=>A+e.offset,0)/A.length);(i-t>30||o>50)&&setTimeout(()=>this.startUpdateNTPTime(),5e3),gM(n),null==(e=this.scriptTransformWorker)||e.postMessage({type:"ntp-offset",data:n}),this._log.debug("ntp updated offset: ".concat(n)),this.emit("ntp-time-updated")}).catch(A=>{this._log.warn("ntp updated failed: ".concat(A))})}updateNTPTime(){let A=Date.now();return this.signalChannel.sendWaitForResponse({command:Eq,responseCommand:LH.UPDATE_NETWORK_TIME_RESULT,addReceiveTime:!0,data:{clientSendTime:String(A)},enableLog:!1}).then(e=>{let t=Number(e.data.data.serverSendTime),i=Number(e.data.data.serverRecvTime),o=e.data.receiveTime||Date.now();return{rtt:o-A-(i-t),offset:(i-A+(t-o))/2}})}};return JS([KL(["left",ZL.INIT],"joined"),lU({settings:{retries:1,timeout:0},onRetrying(A){this._log.warn("join retry ".concat(A))},onRetryFailed(A){this._log.error("join failed",A)},onError(A,e){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),sJ(!0),this.reset(),e()):this.signalChannel&&this.signalChannel.isConnected&&this.signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this.signalChannel.close(),this.reset(),e()):(this.reset(),e())}}),xF(A=>{let e=new yH;return function(t,i,o){return VS(this,null,function*(){let n=String(t.roomId||t.strRoomId);if(this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.userSig=t.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=i,t.privateMapKey=t.privateMapKey||"",this.isJoined)throw new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.INVALID_JOIN})});if(this.checkDestroy(),e.isJoined({userId:this.userId,roomId:n,sdkAppId:this.sdkAppId,room:this}))throw new rM({code:oM.INVALID_OPERATION,message:mk({key:Bk.REPEAT_JOIN,data:this.userId})});e.add({room:this,roomId:n}),this.role=21===t.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(n," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),tG.emit(oG.JOIN_START,{room:this,roomId:n,params:t});let r=EM.getEnv();r||(r=FM.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(ZM.OLD_CLOUD_LADDER)?r=FM.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(ZM.WEBRTC)&&(r=FM.WEBRTC))),gU.setConfig({env:r,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:n}),cG.checkSystemRequirementsInternal(o).then(A=>{this.checkSystemResult=A,DH.call(this)});try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!EM.getEnv()&&(yield this.schedule(t,o));let e=yield A.call(this,t,i,o);return this.roomId=n,this._joinedTimestamp=EM.performanceNow(),tG.emit(oG.JOIN_SUCCESS,{room:this}),30===o&&!t.component&&gU.uploadEvent({log:"stat-conv-".concat(Number(bb),"-").concat(location.hostname),userId:this.userId}),e}catch(s){throw e.delete({room:this,roomId:n}),tG.emit(oG.JOIN_FAILED,{room:this,error:s}),s}})}})],YV.prototype,"join",1),JS([KL("joined","left",{ignoreError:!0,success(){this.reset(!0)}}),xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;iA.mediaType),xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;iA.outMediaTrack&&"ready"===A.state)).length)return;tG.emit("61",{room:this});let e=A.apply(this,t);return Promise.all(t.map(A=>A.publish(this,e)))})}),lU({settings:{retries:yR,timeout:A=>P_(A)},onError(A,e,t,i){let[o]=i;var n;null!=(n=A.message)&&n.includes("timeout")?(this._log.warn("publish ".concat(o.strMediaType," timeout"),A),e()):(this._log.error("publish ".concat(o.strMediaType," failed: ").concat(A)),t(A),tG.emit(oG.PUBLISH_FAILED,{room:this}))}})],YV.prototype,"publish",1),JS([IU({fnName:"publish"}),KF(A=>A.mediaType),xF(A=>function(){for(var e=arguments.length,t=new Array(e),i=0;iA.unpublish()),o}),FF(function(){var A,e;0===this.localTracks.size&&cL()&&(null==(e=null==(A=this.singlePC)?void 0:A.getPeerConnection())||e.getSenders().forEach(A=>A.track&&A.replaceTrack(null)))})],YV.prototype,"unpublish",1),JS([OF(A=>{if(A.code!==oM.API_CALL_ABORTED)throw A}),KF(A=>A.userId)],YV.prototype,"replaceTrack",1),JS([KF(function(){for(var A=arguments.length,e=new Array(A),t=0;tfunction(){for(var e=arguments.length,t=new Array(e),i=0;i!A.isSubscribed&&A.subscribe(o)),o}),lU({settings:{retries:yR,timeout:A=>P_(A)},onError(A,e,t,i){if(A.message.includes("timeout"))this._log.warn("subscribe timeout"),e();else{let e=(null==A?void 0:A.code)===oM.API_CALL_ABORTED;this._log[e?"warn":"error"]("subscribe failed ".concat(i.map(A=>A.strMediaType).join(","),": ").concat(A)),t(A),tG.emit(oG.SUBSCRIBE_FAILED,{room:this,remoteTracks:i})}}})],YV.prototype,"subscribe",1),JS([IU({fnName:"subscribe",callback(){for(var A=arguments.length,e=new Array(A),t=0;t{let e=this.remotePublishedUserMap.get(A.userId);e&&!e.isMainStreamSubscribed&&!e.isAuxStreamSubscribed&&e.close("you unsubscribed")})}}),KF(function(){for(var A=arguments.length,e=new Array(A),t=0;te in A?JF(A,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[e]=t,zF=(A,e)=>{for(var t in e||(e={}))jF.call(e,t)&&WF(A,t,e[t]);if(VF)for(var t of VF(e))KF.call(e,t)&&WF(A,t,e[t]);return A},ZF=(A,e)=>HF(A,qF(e)),XF=(A,e,t)=>WF(A,"symbol"!=typeof e?e+"":e,t);var $F={sdkAppId:{required:!0,type:"number"},userId:{required:!0,type:"string"},userSig:{required:!0,type:"string"}};var AO,eO=(AO="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(A={}){var e,t,i=A;i.ready=new Promise((A,i)=>{e=A,t=i});var o=Object.assign({},i),n="";"undefined"!=typeof document&&document.currentScript&&(n=document.currentScript.src),AO&&(n=AO),n=0!==n.indexOf("blob:")?n.substr(0,n.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var r,s=i.print||console.log.bind(console),a=i.printErr||console.error.bind(console);Object.assign(i,o),o=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(r=i.wasmBinary),"object"!=typeof WebAssembly&&v("no native wasm support detected");var g,c,l,I,u,E,d,h,C=!1,B=[],Q=[],p=[];function f(A){B.unshift(A)}function m(A){p.unshift(A)}var y=0,D=null;function v(A){i.onAbort&&i.onAbort(A),a(A="Aborted("+A+")"),C=!0,A+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(A);throw t(e),e}var w,S,M="data:application/octet-stream;base64,",R=A=>A.startsWith(M);function _(A){return Promise.resolve().then(()=>function(A){if(A==w&&r)return new Uint8Array(r);var e=function(A){if(R(A))return function(A){for(var e=atob(A),t=new Uint8Array(e.length),i=0;i{for(;A.length>0;)A.shift()(i)};function N(A){this.excPtr=A,this.ptr=A-24,this.set_type=function(A){E[this.ptr+4>>2]=A},this.get_type=function(){return E[this.ptr+4>>2]},this.set_destructor=function(A){E[this.ptr+8>>2]=A},this.get_destructor=function(){return E[this.ptr+8>>2]},this.set_caught=function(A){A=A?1:0,g[this.ptr+12|0]=A},this.get_caught=function(){return 0!=g[this.ptr+12|0]},this.set_rethrown=function(A){A=A?1:0,g[this.ptr+13|0]=A},this.get_rethrown=function(){return 0!=g[this.ptr+13|0]},this.init=function(A,e){this.set_adjusted_ptr(0),this.set_type(A),this.set_destructor(e)},this.set_adjusted_ptr=function(A){E[this.ptr+16>>2]=A},this.get_adjusted_ptr=function(){return E[this.ptr+16>>2]},this.get_exception_ptr=function(){if(te(this.get_type()))return E[this.excPtr>>2];var A=this.get_adjusted_ptr();return 0!==A?A:this.excPtr}}i.noExitRuntime;var b,G,k,L=A=>{for(var e="",t=A;c[t];)e+=b[c[t++]];return e},U={},F={},O={},x=A=>{throw new G(A)},P=A=>{throw new k(A)},Y=(A,e,t)=>{function i(e){var i=t(e);i.length!==A.length&&P("Mismatched type converter count");for(var o=0;o{F.hasOwnProperty(A)?o[e]=F[A]:(n.push(A),U.hasOwnProperty(A)||(U[A]=[]),U[A].push(()=>{o[e]=F[A],++r===n.length&&i(o)}))}),0===n.length&&i(o)};function J(A,e,t={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(A,e,t={}){var i=e.name;if(A||x(`type "${i}" must have a positive integer typeid pointer`),F.hasOwnProperty(A)){if(t.ignoreDuplicateRegistrations)return;x(`Cannot register type '${i}' twice`)}if(F[A]=e,delete O[A],U.hasOwnProperty(A)){var o=U[A];delete U[A],o.forEach(A=>A())}}(A,e,t)}var H,q=A=>{x(A.$$.ptrType.registeredClass.name+" instance already deleted")},V=!1,j=A=>{},K=A=>{var e;A.count.value-=1,0===A.count.value&&((e=A).smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr))},W=(A,e,t)=>{if(e===t)return A;if(void 0===t.baseClass)return null;var i=W(A,e,t.baseClass);return null===i?null:t.downcast(i)},z={},Z=[],X=()=>{for(;Z.length;){var A=Z.pop();A.$$.deleteScheduled=!1,A.delete()}},$={},AA=(A,e)=>(e.ptrType&&e.ptr||P("makeClassHandle requires ptr and ptrType"),!!e.smartPtrType!=!!e.smartPtr&&P("Both smartPtrType and smartPtr must be specified"),e.count={value:1},eA(Object.create(A,{$$:{value:e}}))),eA=A=>"undefined"==typeof FinalizationRegistry?(eA=A=>A,A):(V=new FinalizationRegistry(A=>{K(A.$$)}),j=A=>V.unregister(A),(eA=A=>{var e=A.$$;if(e.smartPtr){var t={$$:e};V.register(A,t,A)}return A})(A));function tA(){}var iA=(A,e)=>Object.defineProperty(e,"name",{value:A}),oA=(A,e,t)=>{if(void 0===A[e].overloadTable){var i=A[e];A[e]=function(){return A[e].overloadTable.hasOwnProperty(arguments.length)||x(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${A[e].overloadTable})!`),A[e].overloadTable[arguments.length].apply(this,arguments)},A[e].overloadTable=[],A[e].overloadTable[i.argCount]=i}};function nA(A,e,t,i,o,n,r,s){this.name=A,this.constructor=e,this.instancePrototype=t,this.rawDestructor=i,this.baseClass=o,this.getActualType=n,this.upcast=r,this.downcast=s,this.pureVirtualFunctions=[]}var rA=(A,e,t)=>{for(;e!==t;)e.upcast||x(`Expected null or instance of ${t.name}, got an instance of ${e.name}`),A=e.upcast(A),e=e.baseClass;return A};function sA(A,e){if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),0;e.$$||x(`Cannot pass "${_A(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=e.$$.ptrType.registeredClass;return rA(e.$$.ptr,t,this.registeredClass)}function aA(A,e){var t;if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),null!==A&&A.push(this.rawDestructor,t),t):0;e.$$||x(`Cannot pass "${_A(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&x(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var i=e.$$.ptrType.registeredClass;if(t=rA(e.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===e.$$.smartPtr&&x("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?t=e.$$.smartPtr:x(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)t=e.$$.smartPtr;else{var o=e.clone();t=this.rawShare(t,wA.toHandle(()=>o.delete())),null!==A&&A.push(this.rawDestructor,t)}break;default:x("Unsupporting sharing policy")}return t}function gA(A,e){if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),0;e.$$||x(`Cannot pass "${_A(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&x(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var t=e.$$.ptrType.registeredClass;return rA(e.$$.ptr,t,this.registeredClass)}function cA(A){return this.fromWireType(E[A>>2])}function lA(A,e,t,i,o,n,r,s,a,g,c){this.name=A,this.registeredClass=e,this.isReference=t,this.isConst=i,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=r,this.rawGetPointee=s,this.rawConstructor=a,this.rawShare=g,this.rawDestructor=c,o||void 0!==e.baseClass?this.toWireType=aA:i?(this.toWireType=sA,this.destructorFunction=null):(this.toWireType=gA,this.destructorFunction=null)}var IA,uA,EA=[],dA=A=>{var e=EA[A];return e||(A>=EA.length&&(EA.length=A+1),EA[A]=e=IA.get(A)),e},hA=(A,e)=>{var t,o,n,r=(A=L(A)).includes("j")?(t=A,o=e,n=[],function(){return n.length=0,Object.assign(n,arguments),((A,e,t)=>{return A.includes("j")?(o=e,n=t,r=i["dynCall_"+A],n&&n.length?r.apply(null,[o].concat(n)):r.call(null,o)):dA(e).apply(null,t);var o,n,r})(t,o,n)}):dA(e);return"function"!=typeof r&&x(`unknown function pointer with signature ${A}: ${e}`),r},CA=A=>{var e=Ae(A),t=L(e);return ee(e),t},BA=(A,e)=>{var t=[],i={};throw e.forEach(function A(e){i[e]||F[e]||(O[e]?O[e].forEach(A):(t.push(e),i[e]=!0))}),new uA(`${A}: `+t.map(CA).join([", "]))},QA=(A,e)=>{for(var t=[],i=0;i>2]);return t},pA=A=>{for(;A.length;){var e=A.pop();A.pop()(e)}};function fA(A,e,t,i,o,n){var r=e.length;r<2&&x("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==e[1]&&null!==t,a=!1,g=1;g(A instanceof Object||x(`${t} with invalid "this": ${A}`),A instanceof e.registeredClass.constructor||x(`${t} incompatible with "this" of type ${A.constructor.name}`),A.$$.ptr||x(`cannot call emscripten binding method ${t} on deleted object`),rA(A.$$.ptr,A.$$.ptrType.registeredClass,e.registeredClass));function yA(){this.allocated=[void 0],this.freelist=[]}var DA=new yA,vA=A=>{A>=DA.reserved&&0===--DA.get(A).refcount&&DA.free(A)},wA={toValue:A=>(A||x("Cannot use deleted val. handle = "+A),DA.get(A).value),toHandle:A=>{switch(A){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return DA.allocate({refcount:1,value:A})}}};function SA(A){return this.fromWireType(u[A>>2])}var MA,RA,_A=A=>{if(null===A)return"null";var e=typeof A;return"object"===e||"array"===e||"function"===e?A.toString():""+A},TA=(A,e)=>{switch(e){case 4:return function(A){return this.fromWireType(d[A>>2])};case 8:return function(A){return this.fromWireType(h[A>>3])};default:throw new TypeError(`invalid float width (${e}): ${A}`)}},NA=(A,e,t)=>{switch(e){case 1:return t?A=>g[0|A]:A=>c[0|A];case 2:return t?A=>l[A>>1]:A=>I[A>>1];case 4:return t?A=>u[A>>2]:A=>E[A>>2];default:throw new TypeError(`invalid integer width (${e}): ${A}`)}},bA="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,GA=(A,e,t)=>{for(var i=e+t,o=e;A[o]&&!(o>=i);)++o;if(o-e>16&&A.buffer&&bA)return bA.decode(A.subarray(e,o));for(var n="";e>10,56320|1023&g)}}else n+=String.fromCharCode((31&r)<<6|s)}else n+=String.fromCharCode(r)}return n},kA=(A,e)=>A?GA(c,A,e):"",LA="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,UA=(A,e)=>{for(var t=A,i=t>>1,o=i+e/2;!(i>=o)&&I[i];)++i;if((t=i<<1)-A>32&&LA)return LA.decode(c.subarray(A,t));for(var n="",r=0;!(r>=e/2);++r){var s=l[A+2*r>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},FA=(A,e,t)=>{if(void 0===t&&(t=2147483647),t<2)return 0;for(var i=e,o=(t-=2)<2*A.length?t/2:A.length,n=0;n>1]=r,e+=2}return l[e>>1]=0,e-i},OA=A=>2*A.length,xA=(A,e)=>{for(var t=0,i="";!(t>=e/4);){var o=u[A+4*t>>2];if(0==o)break;if(++t,o>=65536){var n=o-65536;i+=String.fromCharCode(55296|n>>10,56320|1023&n)}else i+=String.fromCharCode(o)}return i},PA=(A,e,t)=>{if(void 0===t&&(t=2147483647),t<4)return 0;for(var i=e,o=i+t-4,n=0;n=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&A.charCodeAt(++n)),u[e>>2]=r,(e+=4)+4>o)break}return u[e>>2]=0,e-i},YA=A=>{for(var e=0,t=0;t=55296&&i<=57343&&++t,e+=4}return e},JA=(A,e)=>{var t=F[A];return void 0===t&&x(e+" has unknown type "+CA(A)),t},HA=(A,e,t)=>{var i=[],o=A.toWireType(i,t);return i.length&&(E[e>>2]=wA.toHandle(i)),o},qA={},VA=[],jA=Reflect.construct,KA=[null,[],[]],WA=(A,e)=>{var t=KA[A];0===e||10===e?((1===A?s:a)(GA(t,0)),t.length=0):t.push(e)};(()=>{for(var A=new Array(256),e=0;e<256;++e)A[e]=String.fromCharCode(e);b=A})(),G=i.BindingError=class extends Error{constructor(A){super(A),this.name="BindingError"}},k=i.InternalError=class extends Error{constructor(A){super(A),this.name="InternalError"}},Object.assign(tA.prototype,{isAliasOf(A){if(!(this instanceof tA))return!1;if(!(A instanceof tA))return!1;var e=this.$$.ptrType.registeredClass,t=this.$$.ptr;A.$$=A.$$;for(var i=A.$$.ptrType.registeredClass,o=A.$$.ptr;e.baseClass;)t=e.upcast(t),e=e.baseClass;for(;i.baseClass;)o=i.upcast(o),i=i.baseClass;return e===i&&t===o},clone(){if(this.$$.ptr||q(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var A,e=eA(Object.create(Object.getPrototypeOf(this),{$$:{value:(A=this.$$,{count:A.count,deleteScheduled:A.deleteScheduled,preservePointerOnDelete:A.preservePointerOnDelete,ptr:A.ptr,ptrType:A.ptrType,smartPtr:A.smartPtr,smartPtrType:A.smartPtrType})}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||q(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&x("Object already scheduled for deletion"),j(this),K(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||q(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&x("Object already scheduled for deletion"),Z.push(this),1===Z.length&&H&&H(X),this.$$.deleteScheduled=!0,this}}),i.getInheritedInstanceCount=()=>Object.keys($).length,i.getLiveInheritedInstances=()=>{var A=[];for(var e in $)$.hasOwnProperty(e)&&A.push($[e]);return A},i.flushPendingDeletes=X,i.setDelayFunction=A=>{H=A,Z.length&&H&&H(X)},Object.assign(lA.prototype,{getPointee(A){return this.rawGetPointee&&(A=this.rawGetPointee(A)),A},destructor(A){this.rawDestructor&&this.rawDestructor(A)},argPackAdvance:8,readValueFromPointer:cA,deleteObject(A){null!==A&&A.delete()},fromWireType:function(A){var e=this.getPointee(A);if(!e)return this.destructor(A),null;var t=((A,e)=>(e=((A,e)=>{for(void 0===e&&x("ptr should not be undefined");A.baseClass;)e=A.upcast(e),A=A.baseClass;return e})(A,e),$[e]))(this.registeredClass,e);if(void 0!==t){if(0===t.$$.count.value)return t.$$.ptr=e,t.$$.smartPtr=A,t.clone();var i=t.clone();return this.destructor(A),i}function o(){return this.isSmartPointer?AA(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:A}):AA(this.registeredClass.instancePrototype,{ptrType:this,ptr:A})}var n,r=this.registeredClass.getActualType(e),s=z[r];if(!s)return o.call(this);n=this.isConst?s.constPointerType:s.pointerType;var a=W(e,this.registeredClass,n.registeredClass);return null===a?o.call(this):this.isSmartPointer?AA(n.registeredClass.instancePrototype,{ptrType:n,ptr:a,smartPtrType:this,smartPtr:A}):AA(n.registeredClass.instancePrototype,{ptrType:n,ptr:a})}}),uA=i.UnboundTypeError=(MA=Error,(RA=iA("UnboundTypeError",function(A){this.name="UnboundTypeError",this.message=A;var e=new Error(A).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(MA.prototype),RA.prototype.constructor=RA,RA.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},RA),Object.assign(yA.prototype,{get(A){return this.allocated[A]},has(A){return void 0!==this.allocated[A]},allocate(A){var e=this.freelist.pop()||this.allocated.length;return this.allocated[e]=A,e},free(A){this.allocated[A]=void 0,this.freelist.push(A)}}),DA.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),DA.reserved=DA.allocated.length,i.count_emval_handles=()=>{for(var A=0,e=DA.reserved;e{throw new N(A).init(e,t),A},q:(A,e,t,i,o)=>{},u:(A,e,t,i)=>{J(A,{name:e=L(e),fromWireType:function(A){return!!A},toWireType:function(A,e){return e?t:i},argPackAdvance:8,readValueFromPointer:function(A){return this.fromWireType(c[A])},destructorFunction:null})},y:(A,e,t,o,n,r,s,a,g,c,l,I,u)=>{l=L(l),r=hA(n,r),a&&(a=hA(s,a)),c&&(c=hA(g,c)),u=hA(I,u);var E,d,h,C=(A=>{if(void 0===A)return"_unknown";var e=(A=A.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return e>=48&&e<=57?`_${A}`:A})(l);E=C,d=function(){BA(`Cannot construct ${l} due to unbound types`,[o])},i.hasOwnProperty(E)?(x(`Cannot register public name '${E}' twice`),oA(i,E,E),i.hasOwnProperty(h)&&x(`Cannot register multiple overloads of a function with the same number of arguments (${h})!`),i[E].overloadTable[h]=d):i[E]=d,Y([A,e,t],o?[o]:[],function(e){var t,n;e=e[0],n=o?(t=e.registeredClass).instancePrototype:tA.prototype;var s=iA(l,function(){if(Object.getPrototypeOf(this)!==g)throw new G("Use 'new' to construct "+l);if(void 0===I.constructor_body)throw new G(l+" has no accessible constructor");var A=I.constructor_body[arguments.length];if(void 0===A)throw new G(`Tried to invoke ctor of ${l} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(I.constructor_body).toString()}) parameters instead!`);return A.apply(this,arguments)}),g=Object.create(n,{constructor:{value:s}});s.prototype=g;var I=new nA(l,s,g,u,t,r,a,c);I.baseClass&&(void 0===I.baseClass.__derivedClasses&&(I.baseClass.__derivedClasses=[]),I.baseClass.__derivedClasses.push(I));var E=new lA(l,I,!0,!1,!1),d=new lA(l+"*",I,!1,!1,!1),h=new lA(l+" const*",I,!1,!0,!1);return z[A]={pointerType:d,constPointerType:h},((A,e,t)=>{i.hasOwnProperty(A)||P("Replacing nonexistant public symbol"),i[A].overloadTable,i[A]=e,i[A].argCount=t})(C,s),[E,d,h]})},x:(A,e,t,i,o,n)=>{var r=QA(e,t);o=hA(i,o),Y([],[A],function(A){var t=`constructor ${(A=A[0]).name}`;if(void 0===A.registeredClass.constructor_body&&(A.registeredClass.constructor_body=[]),void 0!==A.registeredClass.constructor_body[e-1])throw new G(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${A.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return A.registeredClass.constructor_body[e-1]=()=>{BA(`Cannot construct ${A.name} due to unbound types`,r)},Y([],r,i=>(i.splice(1,0,null),A.registeredClass.constructor_body[e-1]=fA(t,i,null,o,n),[])),[]})},i:(A,e,t,i,o,n,r,s,a)=>{var g=QA(t,i);e=(A=>{const e=(A=A.trim()).indexOf("(");return-1!==e?A.substr(0,e):A})(e=L(e)),n=hA(o,n),Y([],[A],function(A){var i=`${(A=A[0]).name}.${e}`;function o(){BA(`Cannot call ${i} due to unbound types`,g)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&A.registeredClass.pureVirtualFunctions.push(e);var a=A.registeredClass.instancePrototype,c=a[e];return void 0===c||void 0===c.overloadTable&&c.className!==A.name&&c.argCount===t-2?(o.argCount=t-2,o.className=A.name,a[e]=o):(oA(a,e,i),a[e].overloadTable[t-2]=o),Y([],g,function(o){var s=fA(i,o,A,n,r);return void 0===a[e].overloadTable?(s.argCount=t-2,a[e]=s):a[e].overloadTable[t-2]=s,[]}),[]})},k:(A,e,t,i,o,n,r,s,a,g)=>{e=L(e),o=hA(i,o),Y([],[A],function(A){var i=`${(A=A[0]).name}.${e}`,c={get(){BA(`Cannot access ${i} due to unbound types`,[t,r])},enumerable:!0,configurable:!0};return c.set=a?()=>BA(`Cannot access ${i} due to unbound types`,[t,r]):A=>x(i+" is a read-only property"),Object.defineProperty(A.registeredClass.instancePrototype,e,c),Y([],a?[t,r]:[t],function(t){var r=t[0],c={get(){var e=mA(this,A,i+" getter");return r.fromWireType(o(n,e))},enumerable:!0};if(a){a=hA(s,a);var l=t[1];c.set=function(e){var t=mA(this,A,i+" setter"),o=[];a(g,t,l.toWireType(o,e)),pA(o)}}return Object.defineProperty(A.registeredClass.instancePrototype,e,c),[]}),[]})},t:(A,e)=>{J(A,{name:e=L(e),fromWireType:A=>{var e=wA.toValue(A);return vA(A),e},toWireType:(A,e)=>wA.toHandle(e),argPackAdvance:8,readValueFromPointer:SA,destructorFunction:null})},p:(A,e,t)=>{J(A,{name:e=L(e),fromWireType:A=>A,toWireType:(A,e)=>e,argPackAdvance:8,readValueFromPointer:TA(e,t),destructorFunction:null})},g:(A,e,t,i,o)=>{e=L(e);var n=A=>A;if(0===i){var r=32-8*t;n=A=>A<>>r}var s=e.includes("unsigned");J(A,{name:e,fromWireType:n,toWireType:s?function(A,e){return this.name,e>>>0}:function(A,e){return this.name,e},argPackAdvance:8,readValueFromPointer:NA(e,t,0!==i),destructorFunction:null})},a:(A,e,t)=>{var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function o(A){var e=E[A>>2],t=E[A+4>>2];return new i(g.buffer,t,e)}J(A,{name:t=L(t),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},o:(A,e)=>{var t="std::string"===(e=L(e));J(A,{name:e,fromWireType(A){var e,i=E[A>>2],o=A+4;if(t)for(var n=o,r=0;r<=i;++r){var s=o+r;if(r==i||0==c[s]){var a=kA(n,s-n);void 0===e?e=a:(e+=String.fromCharCode(0),e+=a),n=s+1}}else{var g=new Array(i);for(r=0;r{for(var e=0,t=0;t=55296&&i<=57343?(e+=4,++t):e+=3}return e})(e):e.length;var n=$A(4+i+1),r=n+4;if(E[n>>2]=i,t&&o)((A,e,t,i)=>{if(!(i>0))return 0;for(var o=t+i-1,n=0;n=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&A.charCodeAt(++n)),r<=127){if(t>=o)break;e[t++]=r}else if(r<=2047){if(t+1>=o)break;e[t++]=192|r>>6,e[t++]=128|63&r}else if(r<=65535){if(t+2>=o)break;e[t++]=224|r>>12,e[t++]=128|r>>6&63,e[t++]=128|63&r}else{if(t+3>=o)break;e[t++]=240|r>>18,e[t++]=128|r>>12&63,e[t++]=128|r>>6&63,e[t++]=128|63&r}}e[t]=0})(e,c,r,i+1);else if(o)for(var s=0;s255&&(ee(r),x("String has UTF-16 code units that do not fit in 8 bits")),c[r+s]=a}else for(s=0;s{var i,o,n,r,s;t=L(t),2===e?(i=UA,o=FA,r=OA,n=()=>I,s=1):4===e&&(i=xA,o=PA,r=YA,n=()=>E,s=2),J(A,{name:t,fromWireType:A=>{for(var t,o=E[A>>2],r=n(),a=A+4,g=0;g<=o;++g){var c=A+4+g*e;if(g==o||0==r[c>>s]){var l=i(a,c-a);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),a=c+e}}return ee(A),t},toWireType:(A,i)=>{"string"!=typeof i&&x(`Cannot pass non-string to C++ string type ${t}`);var n=r(i),a=$A(4+n+e);return E[a>>2]=n>>s,o(i,a+4,n+e),null!==A&&A.push(ee,a),a},argPackAdvance:8,readValueFromPointer:SA,destructorFunction(A){ee(A)}})},v:(A,e)=>{J(A,{isVoid:!0,name:e=L(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(A,e)=>{}})},j:(A,e,t)=>(A=wA.toValue(A),e=JA(e,"emval::as"),HA(e,t,A)),e:(A,e,t,i,o)=>{var n,r;return(A=VA[A])(e=wA.toValue(e),e[t=void 0===(r=qA[n=t])?L(n):r],i,o)},d:vA,f:(A,e,t)=>{var i=((A,e)=>{for(var t=new Array(A),i=0;i>2],"parameter "+i);return t})(A,e),o=i.shift();A--;var n,r,s=new Array(A),a=`methodCaller<(${i.map(A=>A.name).join(", ")}) => ${o.name}>`;return n=iA(a,(e,n,r,a)=>{for(var g=0,c=0;c{A>4&&(DA.get(A).refcount+=1)},b:A=>{var e=wA.toValue(A);pA(e),vA(A)},h:(A,e)=>{var t=(A=JA(A,"_emval_take_value")).readValueFromPointer(e);return wA.toHandle(t)},m:()=>{v("")},s:(A,e,t)=>c.copyWithin(A,e,e+t),r:A=>{c.length,v("OOM")},n:(A,e,t,i)=>{for(var o=0,n=0;n>2],s=E[e+4>>2];e+=8;for(var a=0;a>2]=o,0}},XA=function(){var A={a:ZA};function e(A,e){var t,o;return XA=A.exports,t=XA.z.buffer,i.HEAP8=g=new Int8Array(t),i.HEAP16=l=new Int16Array(t),i.HEAPU8=c=new Uint8Array(t),i.HEAPU16=I=new Uint16Array(t),i.HEAP32=u=new Int32Array(t),i.HEAPU32=E=new Uint32Array(t),i.HEAPF32=d=new Float32Array(t),i.HEAPF64=h=new Float64Array(t),IA=XA.C,o=XA.A,Q.unshift(o),function(){if(y--,i.monitorRunDependencies&&i.monitorRunDependencies(y),0==y&&D){var A=D;D=null,A()}}(),XA}if(y++,i.monitorRunDependencies&&i.monitorRunDependencies(y),i.instantiateWasm)try{return i.instantiateWasm(A,e)}catch(o){a(`Module.instantiateWasm callback failed with error: ${o}`),t(o)}return function(A,e,t,i){return o=t,n=i,_(e).then(A=>WebAssembly.instantiate(A,o)).then(A=>A).then(n,A=>{a(`failed to asynchronously prepare wasm: ${A}`),v(A)});var o,n}(0,w,A,function(A){e(A.instance)}).catch(t),{}}(),$A=A=>($A=XA.B)(A),Ae=A=>(Ae=XA.D)(A),ee=A=>(ee=XA.E)(A),te=A=>(te=XA.F)(A);function ie(){function A(){zA||(zA=!0,i.calledRun=!0,C||(T(Q),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)m(i.postRun.shift());T(p)}()))}y>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)f(i.preRun.shift());T(B)}(),y>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),A()},1)):A()))}if(i.dynCall_jiji=(A,e,t,o,n)=>(i.dynCall_jiji=XA.G)(A,e,t,o,n),i._vertexShaderSource=10688,D=function A(){zA||ie(),zA||(D=A)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return ie(),A.ready}),tO=eO,iO="undefined"==typeof navigator?"":navigator.userAgent,oO=A=>new RegExp(A,"i").test(iO),nO=A=>{if(oO(A)){const e=new RegExp(`${A}\\/([\\d.]+)`),t=iO.match(e);if(t&&t[1])return t[1]}return""},rO=A=>{if(oO(A)){const e=new RegExp(`${A}\\/(\\d+)`),t=iO.match(e);if(t&&t[1])return parseFloat(t[1])}return NaN},sO=/AppleWebKit\/([\d.]+)/i.exec(iO);sO&&parseFloat(sO[1]);var aO=oO("iPad"),gO="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&oO("Macintosh"),cO=oO("iPhone")&&!aO,lO=oO("iPod"),IO=cO||aO||lO||gO,uO=oO("Android");!function(){if(uO){const A=iO.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(A){const e=A[1]&&parseFloat(A[1]),t=A[2]&&parseFloat(A[2]);if(e&&t)return parseFloat(`${A[1]}.${A[2]}`);if(e)return e}}}();uO&&oO("webkit");var EO=oO("Firefox"),dO=nO("Firefox");rO("Firefox");var hO=oO("Edge"),CO=nO("Edge"),BO=oO("Edg"),QO=nO("Edg");rO("Edg");var pO=oO("SogouMobileBrowser"),fO=nO("SogouMobileBrowser"),mO=oO("MetaSr\\s"),yO=nO("MetaSr\\s"),DO=oO("TBS"),vO=nO("TBS"),wO=oO("XWEB"),SO=nO("XWEB");oO("MSIE\\s8\\.0");var MO=oO("MSIE\\/\\d+");!function(){if(MO){const A=/MSIE\s(\d+)\.\d/.exec(iO);let e=A&&parseFloat(A[1]);return!e&&/Trident\/7.0/i.test(iO)&&/rv:11.0/.test(iO)&&(e=11),e}}();var RO=oO("(micromessenger|webbrowser)"),_O=nO("MicroMessenger"),TO=!DO&&oO("MQQBrowser")&&oO("COVC"),NO=!DO&&oO("MQQBrowser")&&!oO("COVC"),bO=NO||TO?nO("MQQBrowser"):"",GO=!DO&&oO(" QQBrowser"),kO=nO(" QQBrowser"),LO=!DO&&oO("QQBrowserLite"),UO=nO("QQBrowserLite"),FO=!DO&&oO("MQBHD"),OO=nO("MQBHD");oO("Windows"),!IO&&oO("MAC OS X"),!uO&&oO("Linux"),oO("CrOS"),oO("MicroMessenger"),oO("UCBrowser"),oO("Electron");var xO=oO("MiuiBrowser"),PO=nO("MiuiBrowser"),YO=oO("HuaweiBrowser");oO("Huawei")||oO("HUAWEI"),oO("Honor")||oO("HONOR");var JO=nO("HuaweiBrowser"),HO=oO("SamsungBrowser"),qO=nO("SamsungBrowser"),VO=oO("HeyTapBrowser"),jO=nO("HeyTapBrowser"),KO=oO("VivoBrowser"),WO=nO("VivoBrowser");oO("OpenHarmony"),nO("OpenHarmony");var zO=oO("CriOS"),ZO=oO("Chrome"),XO=!hO&&!mO&&!pO&&!DO&&!wO&&!BO&&!GO&&!xO&&!YO&&!HO&&!VO&&!KO&&ZO;oO("HeadlessChrome");var $O=rO("Chrome"),Ax=nO("Chrome");rO("Electron");var ex=!ZO&&!NO&&!TO&&!LO&&!FO&&oO("Safari"),tx=nO("Version"),ix=(()=>{if(gO)return tx;if(IO){const A=iO.match(/OS (\d+)_(\d+)/i);if(A&&A[1]){let e=A[1];return A[2]&&(e+=`.${A[2]}`),e}}return""})();Number(ix.split(".")[0]),(()=>{const A=Number(ix.split(".")[0])})(),function(){const A=new Map([[EO,["Firefox",dO]],[BO,["Edg",QO]],[XO,["Chrome",Ax]],[zO,["ChiOS",nO("CriOS")]],[ex&&!zO,["Safari",tx]],[DO,["TBS",vO]],[wO,["XWEB",SO]],[RO&&cO,["WeChat",_O]],[GO,["QQ(Win)",kO]],[NO,["QQ(Mobile)",bO]],[TO,["QQ(Mobile X5)",bO]],[LO,["QQ(Mac)",UO]],[FO,["QQ(iPad)",OO]],[xO,["MI",PO]],[YO,["HW",JO]],[HO,["Samsung",qO]],[VO,["OPPO",jO]],[KO,["VIVO",WO]],[hO,["EDGE",CO]],[pO,["SogouMobile",fO]],[mO,["Sogou",yO]]]);let e="unknown",t="unknown";A.has(!0)&&([e,t]=A.get(!0))}();var ox=1e-6,nx="undefined"!=typeof Float32Array?Float32Array:Array,rx={};function sx(){var A=new nx(16);return nx!=Float32Array&&(A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=0,A[12]=0,A[13]=0,A[14]=0),A[0]=1,A[5]=1,A[10]=1,A[15]=1,A}function ax(A){var e=new nx(16);return e[0]=A[0],e[1]=A[1],e[2]=A[2],e[3]=A[3],e[4]=A[4],e[5]=A[5],e[6]=A[6],e[7]=A[7],e[8]=A[8],e[9]=A[9],e[10]=A[10],e[11]=A[11],e[12]=A[12],e[13]=A[13],e[14]=A[14],e[15]=A[15],e}function gx(A,e){return A[0]=e[0],A[1]=e[1],A[2]=e[2],A[3]=e[3],A[4]=e[4],A[5]=e[5],A[6]=e[6],A[7]=e[7],A[8]=e[8],A[9]=e[9],A[10]=e[10],A[11]=e[11],A[12]=e[12],A[13]=e[13],A[14]=e[14],A[15]=e[15],A}function cx(A,e,t,i,o,n,r,s,a,g,c,l,I,u,E,d){var h=new nx(16);return h[0]=A,h[1]=e,h[2]=t,h[3]=i,h[4]=o,h[5]=n,h[6]=r,h[7]=s,h[8]=a,h[9]=g,h[10]=c,h[11]=l,h[12]=I,h[13]=u,h[14]=E,h[15]=d,h}function lx(A,e,t,i,o,n,r,s,a,g,c,l,I,u,E,d,h){return A[0]=e,A[1]=t,A[2]=i,A[3]=o,A[4]=n,A[5]=r,A[6]=s,A[7]=a,A[8]=g,A[9]=c,A[10]=l,A[11]=I,A[12]=u,A[13]=E,A[14]=d,A[15]=h,A}function Ix(A){return A[0]=1,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=1,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=1,A[11]=0,A[12]=0,A[13]=0,A[14]=0,A[15]=1,A}function ux(A,e){if(A===e){var t=e[1],i=e[2],o=e[3],n=e[6],r=e[7],s=e[11];A[1]=e[4],A[2]=e[8],A[3]=e[12],A[4]=t,A[6]=e[9],A[7]=e[13],A[8]=i,A[9]=n,A[11]=e[14],A[12]=o,A[13]=r,A[14]=s}else A[0]=e[0],A[1]=e[4],A[2]=e[8],A[3]=e[12],A[4]=e[1],A[5]=e[5],A[6]=e[9],A[7]=e[13],A[8]=e[2],A[9]=e[6],A[10]=e[10],A[11]=e[14],A[12]=e[3],A[13]=e[7],A[14]=e[11],A[15]=e[15];return A}function Ex(A,e){var t=e[0],i=e[1],o=e[2],n=e[3],r=e[4],s=e[5],a=e[6],g=e[7],c=e[8],l=e[9],I=e[10],u=e[11],E=e[12],d=e[13],h=e[14],C=e[15],B=t*s-i*r,Q=t*a-o*r,p=t*g-n*r,f=i*a-o*s,m=i*g-n*s,y=o*g-n*a,D=c*d-l*E,v=c*h-I*E,w=c*C-u*E,S=l*h-I*d,M=l*C-u*d,R=I*C-u*h,_=B*R-Q*M+p*S+f*w-m*v+y*D;return _?(_=1/_,A[0]=(s*R-a*M+g*S)*_,A[1]=(o*M-i*R-n*S)*_,A[2]=(d*y-h*m+C*f)*_,A[3]=(I*m-l*y-u*f)*_,A[4]=(a*w-r*R-g*v)*_,A[5]=(t*R-o*w+n*v)*_,A[6]=(h*p-E*y-C*Q)*_,A[7]=(c*y-I*p+u*Q)*_,A[8]=(r*M-s*w+g*D)*_,A[9]=(i*w-t*M-n*D)*_,A[10]=(E*m-d*p+C*B)*_,A[11]=(l*p-c*m-u*B)*_,A[12]=(s*v-r*S-a*D)*_,A[13]=(t*S-i*v+o*D)*_,A[14]=(d*Q-E*f-h*B)*_,A[15]=(c*f-l*Q+I*B)*_,A):null}function dx(A,e){var t=e[0],i=e[1],o=e[2],n=e[3],r=e[4],s=e[5],a=e[6],g=e[7],c=e[8],l=e[9],I=e[10],u=e[11],E=e[12],d=e[13],h=e[14],C=e[15],B=t*s-i*r,Q=t*a-o*r,p=t*g-n*r,f=i*a-o*s,m=i*g-n*s,y=o*g-n*a,D=c*d-l*E,v=c*h-I*E,w=c*C-u*E,S=l*h-I*d,M=l*C-u*d,R=I*C-u*h;return A[0]=s*R-a*M+g*S,A[1]=o*M-i*R-n*S,A[2]=d*y-h*m+C*f,A[3]=I*m-l*y-u*f,A[4]=a*w-r*R-g*v,A[5]=t*R-o*w+n*v,A[6]=h*p-E*y-C*Q,A[7]=c*y-I*p+u*Q,A[8]=r*M-s*w+g*D,A[9]=i*w-t*M-n*D,A[10]=E*m-d*p+C*B,A[11]=l*p-c*m-u*B,A[12]=s*v-r*S-a*D,A[13]=t*S-i*v+o*D,A[14]=d*Q-E*f-h*B,A[15]=c*f-l*Q+I*B,A}function hx(A){var e=A[0],t=A[1],i=A[2],o=A[3],n=A[4],r=A[5],s=A[6],a=A[7],g=A[8],c=A[9],l=A[10],I=A[11],u=A[12],E=A[13],d=A[14],h=e*r-t*n,C=e*s-i*n,B=t*s-i*r,Q=g*E-c*u,p=g*d-l*u,f=c*d-l*E;return a*(e*f-t*p+i*Q)-o*(n*f-r*p+s*Q)+A[15]*(g*B-c*C+l*h)-I*(u*B-E*C+d*h)}function Cx(A,e,t){var i=e[0],o=e[1],n=e[2],r=e[3],s=e[4],a=e[5],g=e[6],c=e[7],l=e[8],I=e[9],u=e[10],E=e[11],d=e[12],h=e[13],C=e[14],B=e[15],Q=t[0],p=t[1],f=t[2],m=t[3];return A[0]=Q*i+p*s+f*l+m*d,A[1]=Q*o+p*a+f*I+m*h,A[2]=Q*n+p*g+f*u+m*C,A[3]=Q*r+p*c+f*E+m*B,Q=t[4],p=t[5],f=t[6],m=t[7],A[4]=Q*i+p*s+f*l+m*d,A[5]=Q*o+p*a+f*I+m*h,A[6]=Q*n+p*g+f*u+m*C,A[7]=Q*r+p*c+f*E+m*B,Q=t[8],p=t[9],f=t[10],m=t[11],A[8]=Q*i+p*s+f*l+m*d,A[9]=Q*o+p*a+f*I+m*h,A[10]=Q*n+p*g+f*u+m*C,A[11]=Q*r+p*c+f*E+m*B,Q=t[12],p=t[13],f=t[14],m=t[15],A[12]=Q*i+p*s+f*l+m*d,A[13]=Q*o+p*a+f*I+m*h,A[14]=Q*n+p*g+f*u+m*C,A[15]=Q*r+p*c+f*E+m*B,A}function Bx(A,e,t){var i,o,n,r,s,a,g,c,l,I,u,E,d=t[0],h=t[1],C=t[2];return e===A?(A[12]=e[0]*d+e[4]*h+e[8]*C+e[12],A[13]=e[1]*d+e[5]*h+e[9]*C+e[13],A[14]=e[2]*d+e[6]*h+e[10]*C+e[14],A[15]=e[3]*d+e[7]*h+e[11]*C+e[15]):(i=e[0],o=e[1],n=e[2],r=e[3],s=e[4],a=e[5],g=e[6],c=e[7],l=e[8],I=e[9],u=e[10],E=e[11],A[0]=i,A[1]=o,A[2]=n,A[3]=r,A[4]=s,A[5]=a,A[6]=g,A[7]=c,A[8]=l,A[9]=I,A[10]=u,A[11]=E,A[12]=i*d+s*h+l*C+e[12],A[13]=o*d+a*h+I*C+e[13],A[14]=n*d+g*h+u*C+e[14],A[15]=r*d+c*h+E*C+e[15]),A}function Qx(A,e,t){var i=t[0],o=t[1],n=t[2];return A[0]=e[0]*i,A[1]=e[1]*i,A[2]=e[2]*i,A[3]=e[3]*i,A[4]=e[4]*o,A[5]=e[5]*o,A[6]=e[6]*o,A[7]=e[7]*o,A[8]=e[8]*n,A[9]=e[9]*n,A[10]=e[10]*n,A[11]=e[11]*n,A[12]=e[12],A[13]=e[13],A[14]=e[14],A[15]=e[15],A}function px(A,e,t,i){var o,n,r,s,a,g,c,l,I,u,E,d,h,C,B,Q,p,f,m,y,D,v,w,S,M=i[0],R=i[1],_=i[2],T=Math.sqrt(M*M+R*R+_*_);return T0?(t[0]=2*(s*r+c*i+a*n-g*o)/l,t[1]=2*(a*r+c*o+g*i-s*n)/l,t[2]=2*(g*r+c*n+s*o-a*i)/l):(t[0]=2*(s*r+c*i+a*n-g*o),t[1]=2*(a*r+c*o+g*i-s*n),t[2]=2*(g*r+c*n+s*o-a*i)),Tx(A,e,t),A}function bx(A,e){return A[0]=e[12],A[1]=e[13],A[2]=e[14],A}function Gx(A,e){var t=e[0],i=e[1],o=e[2],n=e[4],r=e[5],s=e[6],a=e[8],g=e[9],c=e[10];return A[0]=Math.sqrt(t*t+i*i+o*o),A[1]=Math.sqrt(n*n+r*r+s*s),A[2]=Math.sqrt(a*a+g*g+c*c),A}function kx(A,e){var t=new nx(3);Gx(t,e);var i=1/t[0],o=1/t[1],n=1/t[2],r=e[0]*i,s=e[1]*o,a=e[2]*n,g=e[4]*i,c=e[5]*o,l=e[6]*n,I=e[8]*i,u=e[9]*o,E=e[10]*n,d=r+c+E,h=0;return d>0?(h=2*Math.sqrt(d+1),A[3]=.25*h,A[0]=(l-u)/h,A[1]=(I-a)/h,A[2]=(s-g)/h):r>c&&r>E?(h=2*Math.sqrt(1+r-c-E),A[3]=(l-u)/h,A[0]=.25*h,A[1]=(s+g)/h,A[2]=(I+a)/h):c>E?(h=2*Math.sqrt(1+c-r-E),A[3]=(I-a)/h,A[0]=(s+g)/h,A[1]=.25*h,A[2]=(l+u)/h):(h=2*Math.sqrt(1+E-r-c),A[3]=(s-g)/h,A[0]=(I+a)/h,A[1]=(l+u)/h,A[2]=.25*h),A}function Lx(A,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];var o=i[0],n=i[1],r=i[2],s=i[4],a=i[5],g=i[6],c=i[8],l=i[9],I=i[10];t[0]=Math.sqrt(o*o+n*n+r*r),t[1]=Math.sqrt(s*s+a*a+g*g),t[2]=Math.sqrt(c*c+l*l+I*I);var u=1/t[0],E=1/t[1],d=1/t[2],h=o*u,C=n*E,B=r*d,Q=s*u,p=a*E,f=g*d,m=c*u,y=l*E,D=I*d,v=h+p+D,w=0;return v>0?(w=2*Math.sqrt(v+1),A[3]=.25*w,A[0]=(f-y)/w,A[1]=(m-B)/w,A[2]=(C-Q)/w):h>p&&h>D?(w=2*Math.sqrt(1+h-p-D),A[3]=(f-y)/w,A[0]=.25*w,A[1]=(C+Q)/w,A[2]=(m+B)/w):p>D?(w=2*Math.sqrt(1+p-h-D),A[3]=(m-B)/w,A[0]=(C+Q)/w,A[1]=.25*w,A[2]=(f+y)/w):(w=2*Math.sqrt(1+D-h-p),A[3]=(C-Q)/w,A[0]=(m+B)/w,A[1]=(f+y)/w,A[2]=.25*w),A}function Ux(A,e,t,i){var o=e[0],n=e[1],r=e[2],s=e[3],a=o+o,g=n+n,c=r+r,l=o*a,I=o*g,u=o*c,E=n*g,d=n*c,h=r*c,C=s*a,B=s*g,Q=s*c,p=i[0],f=i[1],m=i[2];return A[0]=(1-(E+h))*p,A[1]=(I+Q)*p,A[2]=(u-B)*p,A[3]=0,A[4]=(I-Q)*f,A[5]=(1-(l+h))*f,A[6]=(d+C)*f,A[7]=0,A[8]=(u+B)*m,A[9]=(d-C)*m,A[10]=(1-(l+E))*m,A[11]=0,A[12]=t[0],A[13]=t[1],A[14]=t[2],A[15]=1,A}function Fx(A,e,t,i,o){var n=e[0],r=e[1],s=e[2],a=e[3],g=n+n,c=r+r,l=s+s,I=n*g,u=n*c,E=n*l,d=r*c,h=r*l,C=s*l,B=a*g,Q=a*c,p=a*l,f=i[0],m=i[1],y=i[2],D=o[0],v=o[1],w=o[2],S=(1-(d+C))*f,M=(u+p)*f,R=(E-Q)*f,_=(u-p)*m,T=(1-(I+C))*m,N=(h+B)*m,b=(E+Q)*y,G=(h-B)*y,k=(1-(I+d))*y;return A[0]=S,A[1]=M,A[2]=R,A[3]=0,A[4]=_,A[5]=T,A[6]=N,A[7]=0,A[8]=b,A[9]=G,A[10]=k,A[11]=0,A[12]=t[0]+D-(S*D+_*v+b*w),A[13]=t[1]+v-(M*D+T*v+G*w),A[14]=t[2]+w-(R*D+N*v+k*w),A[15]=1,A}function Ox(A,e){var t=e[0],i=e[1],o=e[2],n=e[3],r=t+t,s=i+i,a=o+o,g=t*r,c=i*r,l=i*s,I=o*r,u=o*s,E=o*a,d=n*r,h=n*s,C=n*a;return A[0]=1-l-E,A[1]=c+C,A[2]=I-h,A[3]=0,A[4]=c-C,A[5]=1-g-E,A[6]=u+d,A[7]=0,A[8]=I+h,A[9]=u-d,A[10]=1-g-l,A[11]=0,A[12]=0,A[13]=0,A[14]=0,A[15]=1,A}function xx(A,e,t,i,o,n,r){var s=1/(t-e),a=1/(o-i),g=1/(n-r);return A[0]=2*n*s,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=2*n*a,A[6]=0,A[7]=0,A[8]=(t+e)*s,A[9]=(o+i)*a,A[10]=(r+n)*g,A[11]=-1,A[12]=0,A[13]=0,A[14]=r*n*2*g,A[15]=0,A}function Px(A,e,t,i,o){var n=1/Math.tan(e/2);if(A[0]=n/t,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=n,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=-1,A[12]=0,A[13]=0,A[15]=0,null!=o&&o!==1/0){var r=1/(i-o);A[10]=(o+i)*r,A[14]=2*o*i*r}else A[10]=-1,A[14]=-2*i;return A}((A,e)=>{for(var t in e)JF(A,t,{get:e[t],enumerable:!0})})(rx,{add:()=>Xx,adjoint:()=>dx,clone:()=>ax,copy:()=>gx,create:()=>sx,decompose:()=>Lx,determinant:()=>hx,equals:()=>iP,exactEquals:()=>tP,frob:()=>Zx,fromQuat:()=>Ox,fromQuat2:()=>Nx,fromRotation:()=>Sx,fromRotationTranslation:()=>Tx,fromRotationTranslationScale:()=>Ux,fromRotationTranslationScaleOrigin:()=>Fx,fromScaling:()=>vx,fromTranslation:()=>Dx,fromValues:()=>cx,fromXRotation:()=>Mx,fromYRotation:()=>Rx,fromZRotation:()=>_x,frustum:()=>xx,getRotation:()=>kx,getScaling:()=>Gx,getTranslation:()=>bx,identity:()=>Ix,invert:()=>Ex,lookAt:()=>Kx,mul:()=>oP,multiply:()=>Cx,multiplyScalar:()=>AP,multiplyScalarAndAdd:()=>eP,ortho:()=>Vx,orthoNO:()=>qx,orthoZO:()=>jx,perspective:()=>Yx,perspectiveFromFieldOfView:()=>Hx,perspectiveNO:()=>Px,perspectiveZO:()=>Jx,rotate:()=>px,rotateX:()=>fx,rotateY:()=>mx,rotateZ:()=>yx,scale:()=>Qx,set:()=>lx,str:()=>zx,sub:()=>nP,subtract:()=>$x,targetTo:()=>Wx,translate:()=>Bx,transpose:()=>ux});var Yx=Px;function Jx(A,e,t,i,o){var n=1/Math.tan(e/2);if(A[0]=n/t,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=n,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=-1,A[12]=0,A[13]=0,A[15]=0,null!=o&&o!==1/0){var r=1/(i-o);A[10]=o*r,A[14]=o*i*r}else A[10]=-1,A[14]=-i;return A}function Hx(A,e,t,i){var o=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),r=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),a=2/(r+s),g=2/(o+n);return A[0]=a,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=g,A[6]=0,A[7]=0,A[8]=-(r-s)*a*.5,A[9]=(o-n)*g*.5,A[10]=i/(t-i),A[11]=-1,A[12]=0,A[13]=0,A[14]=i*t/(t-i),A[15]=0,A}function qx(A,e,t,i,o,n,r){var s=1/(e-t),a=1/(i-o),g=1/(n-r);return A[0]=-2*s,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=-2*a,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=2*g,A[11]=0,A[12]=(e+t)*s,A[13]=(o+i)*a,A[14]=(r+n)*g,A[15]=1,A}var Vx=qx;function jx(A,e,t,i,o,n,r){var s=1/(e-t),a=1/(i-o),g=1/(n-r);return A[0]=-2*s,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=-2*a,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=g,A[11]=0,A[12]=(e+t)*s,A[13]=(o+i)*a,A[14]=n*g,A[15]=1,A}function Kx(A,e,t,i){var o,n,r,s,a,g,c,l,I,u,E=e[0],d=e[1],h=e[2],C=i[0],B=i[1],Q=i[2],p=t[0],f=t[1],m=t[2];return Math.abs(E-p)0&&(c*=u=1/Math.sqrt(u),l*=u,I*=u);var E=a*I-g*l,d=g*c-s*I,h=s*l-a*c;return(u=E*E+d*d+h*h)>0&&(E*=u=1/Math.sqrt(u),d*=u,h*=u),A[0]=E,A[1]=d,A[2]=h,A[3]=0,A[4]=l*h-I*d,A[5]=I*E-c*h,A[6]=c*d-l*E,A[7]=0,A[8]=c,A[9]=l,A[10]=I,A[11]=0,A[12]=o,A[13]=n,A[14]=r,A[15]=1,A}function zx(A){return"mat4("+A[0]+", "+A[1]+", "+A[2]+", "+A[3]+", "+A[4]+", "+A[5]+", "+A[6]+", "+A[7]+", "+A[8]+", "+A[9]+", "+A[10]+", "+A[11]+", "+A[12]+", "+A[13]+", "+A[14]+", "+A[15]+")"}function Zx(A){return Math.sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]+A[3]*A[3]+A[4]*A[4]+A[5]*A[5]+A[6]*A[6]+A[7]*A[7]+A[8]*A[8]+A[9]*A[9]+A[10]*A[10]+A[11]*A[11]+A[12]*A[12]+A[13]*A[13]+A[14]*A[14]+A[15]*A[15])}function Xx(A,e,t){return A[0]=e[0]+t[0],A[1]=e[1]+t[1],A[2]=e[2]+t[2],A[3]=e[3]+t[3],A[4]=e[4]+t[4],A[5]=e[5]+t[5],A[6]=e[6]+t[6],A[7]=e[7]+t[7],A[8]=e[8]+t[8],A[9]=e[9]+t[9],A[10]=e[10]+t[10],A[11]=e[11]+t[11],A[12]=e[12]+t[12],A[13]=e[13]+t[13],A[14]=e[14]+t[14],A[15]=e[15]+t[15],A}function $x(A,e,t){return A[0]=e[0]-t[0],A[1]=e[1]-t[1],A[2]=e[2]-t[2],A[3]=e[3]-t[3],A[4]=e[4]-t[4],A[5]=e[5]-t[5],A[6]=e[6]-t[6],A[7]=e[7]-t[7],A[8]=e[8]-t[8],A[9]=e[9]-t[9],A[10]=e[10]-t[10],A[11]=e[11]-t[11],A[12]=e[12]-t[12],A[13]=e[13]-t[13],A[14]=e[14]-t[14],A[15]=e[15]-t[15],A}function AP(A,e,t){return A[0]=e[0]*t,A[1]=e[1]*t,A[2]=e[2]*t,A[3]=e[3]*t,A[4]=e[4]*t,A[5]=e[5]*t,A[6]=e[6]*t,A[7]=e[7]*t,A[8]=e[8]*t,A[9]=e[9]*t,A[10]=e[10]*t,A[11]=e[11]*t,A[12]=e[12]*t,A[13]=e[13]*t,A[14]=e[14]*t,A[15]=e[15]*t,A}function eP(A,e,t,i){return A[0]=e[0]+t[0]*i,A[1]=e[1]+t[1]*i,A[2]=e[2]+t[2]*i,A[3]=e[3]+t[3]*i,A[4]=e[4]+t[4]*i,A[5]=e[5]+t[5]*i,A[6]=e[6]+t[6]*i,A[7]=e[7]+t[7]*i,A[8]=e[8]+t[8]*i,A[9]=e[9]+t[9]*i,A[10]=e[10]+t[10]*i,A[11]=e[11]+t[11]*i,A[12]=e[12]+t[12]*i,A[13]=e[13]+t[13]*i,A[14]=e[14]+t[14]*i,A[15]=e[15]+t[15]*i,A}function tP(A,e){return A[0]===e[0]&&A[1]===e[1]&&A[2]===e[2]&&A[3]===e[3]&&A[4]===e[4]&&A[5]===e[5]&&A[6]===e[6]&&A[7]===e[7]&&A[8]===e[8]&&A[9]===e[9]&&A[10]===e[10]&&A[11]===e[11]&&A[12]===e[12]&&A[13]===e[13]&&A[14]===e[14]&&A[15]===e[15]}function iP(A,e){var t=A[0],i=A[1],o=A[2],n=A[3],r=A[4],s=A[5],a=A[6],g=A[7],c=A[8],l=A[9],I=A[10],u=A[11],E=A[12],d=A[13],h=A[14],C=A[15],B=e[0],Q=e[1],p=e[2],f=e[3],m=e[4],y=e[5],D=e[6],v=e[7],w=e[8],S=e[9],M=e[10],R=e[11],_=e[12],T=e[13],N=e[14],b=e[15];return Math.abs(t-B)<=ox*Math.max(1,Math.abs(t),Math.abs(B))&&Math.abs(i-Q)<=ox*Math.max(1,Math.abs(i),Math.abs(Q))&&Math.abs(o-p)<=ox*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(n-f)<=ox*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(r-m)<=ox*Math.max(1,Math.abs(r),Math.abs(m))&&Math.abs(s-y)<=ox*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(a-D)<=ox*Math.max(1,Math.abs(a),Math.abs(D))&&Math.abs(g-v)<=ox*Math.max(1,Math.abs(g),Math.abs(v))&&Math.abs(c-w)<=ox*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(l-S)<=ox*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(I-M)<=ox*Math.max(1,Math.abs(I),Math.abs(M))&&Math.abs(u-R)<=ox*Math.max(1,Math.abs(u),Math.abs(R))&&Math.abs(E-_)<=ox*Math.max(1,Math.abs(E),Math.abs(_))&&Math.abs(d-T)<=ox*Math.max(1,Math.abs(d),Math.abs(T))&&Math.abs(h-N)<=ox*Math.max(1,Math.abs(h),Math.abs(N))&&Math.abs(C-b)<=ox*Math.max(1,Math.abs(C),Math.abs(b))}var oP=Cx,nP=$x,rP="#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}",sP=A=>`precision highp float;\nuniform sampler2D mask;in vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {${A}}`,aP=`#version 300 es\nuniform sampler2D lastMask;\n${sP("highp float current = texture(mask, v_texCoord).r;\n highp float previous = texture(lastMask, v_texCoord).r;\n highp float diff = abs(current - previous);\n const float smoothFactor = 0.05; \n const float threshold = 0.3;\n highp float blendedMask = diff < threshold \n ? previous * (1.0 - smoothFactor) + current * smoothFactor \n : current;\n outColor = vec4(blendedMask,0.0,0.0, 1.0);")}\n`,gP=`#version 300 es\n${sP(" vec2 o = 1.0 / vec2(textureSize(mask, 0)); \n float size = 3.0; \n int sizeDb = int(size*size);\n float samples[9];\n int idx = 0;\n float side = (size - 1.0) / 2.0;\n for (float x = -side; x <= side; x += 1.0) {\n for (float y = -side; y <= side; y += 1.0) {\n vec2 sampleCoord = v_texCoord + vec2(x, y) * o;\n int index = int((x + 1.0) * size + (y + 1.0));\n samples[index] = texture(mask, sampleCoord).r;\n }\n }\n for (int i = 0; i < sizeDb - 1; i++) {\n for (int j = 0; j < sizeDb - 1 - i; j++) {\n if (samples[j] > samples[j + 1]) {\n float temp = samples[j];\n samples[j] = samples[j + 1];\n samples[j + 1] = temp;\n }\n }\n }\n float endR=samples[sizeDb/2]>0.5?1.0:0.0;\n outColor = vec4(endR, 0.0, 0.0, 1.0);")}\n`,cP=`#version 300 es\n${sP(" vec2 o = 1.0 / vec2(textureSize(mask, 0));\n float size = 3.0; \n float side = (size - 1.0) / 2.0;\n float stronglyEroded = 1.0;\n for (float x = -side; x <= side; x += 1.0) {\n for (float y = -side; y <= side; y += 1.0) {\n vec2 sampleCoord = v_texCoord + vec2(x, y) * o;\n stronglyEroded = min(stronglyEroded, texture(mask, sampleCoord).r);\n }\n }\n outColor = vec4(stronglyEroded, 0.0, 0.0, 1.0);")}\n`,lP=new class{constructor(){XF(this,"gl"),XF(this,"positionBuffer"),XF(this,"texCoordBuffer"),XF(this,"ratio"),XF(this,"_tdProgram"),XF(this,"_kcProgram"),XF(this,"_mdProgram"),XF(this,"_edgeProgram"),XF(this,"_borderProgram"),XF(this,"_lastMaskTexture")}init(A,e,t,i){this.initParams(A,e,t,i),this.initPrograms()}initParams(A,e,t,i){this.gl=A,this.positionBuffer=e,this.texCoordBuffer=t,this.ratio=i}initPrograms(){this._tdProgram=this.createProgram(rP,aP,["mask","lastMask"]),this._mdProgram=this.createProgram(rP,gP,["mask"]),this._kcProgram=this.createProgram(rP,cP,["mask"]),this._borderProgram=this.createProgram(rP,"#version 300 es\nprecision highp float;\nuniform sampler2D mask;\nuniform sampler2D originalMask;\nuniform sampler2D maskEdge;\nin vec2 v_texCoord;\nout vec4 outColor;\nfloat u_highThreshold = 0.9; \nfloat u_smoothSigma = 2.0; \nfloat u_featherRadius = 4.0; \nfloat balancedTransition(float value) {\n return value * value * (3.0 - 2.0 * value);\n}\nfloat hybridBlur(sampler2D tex, vec2 uv, vec2 texelSize, float edgeIntensity, float sigma) {\n float edgeWeight = smoothstep(u_highThreshold * 0.8, u_highThreshold, edgeIntensity);\n if (edgeWeight < u_highThreshold * 0.8) {\n return texture(tex, uv).r; \n }\n float adaptiveRadius = mix(u_featherRadius * 0.5, u_featherRadius * 1.5, edgeWeight);\n int kernelSize = int(ceil(2.5 * sigma)); \n float sum = 0.0;\n float weightSum = 0.0;\n for (int i = -kernelSize; i <= kernelSize; i++) {\n for (int j = -kernelSize; j <= kernelSize; j++) {\n vec2 offset = vec2(float(i), float(j)) * texelSize * adaptiveRadius;\n vec2 sampleUV = uv + offset;\n float sampleValue = texture(originalMask, sampleUV).r;\n float dist = length(vec2(i, j)) / float(kernelSize);\n float weight = 1.0 - balancedTransition(dist);\n sum += sampleValue * weight;\n weightSum += weight;\n }\n }\n return sum / weightSum;\n}\nvoid main() {\n vec2 texelSize = 1.0 / vec2(textureSize(mask, 0));\n float edge = texture(maskEdge, v_texCoord).r;\n float centerValue = texture(mask, v_texCoord).r;\n float smoothedValue = hybridBlur(mask, v_texCoord, texelSize, edge, u_smoothSigma);\n float finalAlpha;\n if (edge == 1.0) {\n finalAlpha = smoothedValue;\n } else if (centerValue > 0.70) {\n finalAlpha = 1.0;\n } else if (centerValue < 0.30) {\n finalAlpha = 0.0;\n } else {\n float t = balancedTransition((centerValue - 0.30));\n finalAlpha = mix(centerValue, smoothedValue, 1.0 - t * 0.95);\n }\n outColor = vec4(finalAlpha, 0.0, 0.0, 1.0);\n}\n",["mask","maskEdge","originalMask"]),this._edgeProgram=this.createProgram(rP,"#version 300 es\nprecision highp float;\nuniform sampler2D mask;\nin vec2 v_texCoord;\nout vec4 outColor;\nfloat u_gradientScale = 0.25;\nconst float SOBEL_KERNEL_X[9] = float[9](\n -1.0, 0.0, 1.0,\n -2.0, 0.0, 2.0,\n -1.0, 0.0, 1.0\n);\nconst float SOBEL_KERNEL_Y[9] = float[9](\n -1.0, -2.0, -1.0,\n 0.0, 0.0, 0.0,\n 1.0, 2.0, 1.0\n);\nfloat nonMaxSuppression(float gradient, vec2 uv, vec2 texelSize, float angle) {\n vec2 dir = vec2(cos(angle), sin(angle));\n vec2 offset1 = dir * texelSize;\n vec2 offset2 = -dir * texelSize;\n float n1 = texture(mask, uv + offset1).r;\n float n2 = texture(mask, uv + offset2).r;\n return (gradient >= n1 && gradient >= n2) ? gradient : 0.0;\n}\nvoid main() {\n vec2 o = 1.0 / vec2(textureSize(mask, 0));\n float gx = 0.0, gy = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n vec2 offset = vec2(float(i), float(j)) * o;\n float maskValue = texture(mask, v_texCoord + offset).r;\n int idx = (i+1)*3 + (j+1);\n gx += maskValue * SOBEL_KERNEL_X[idx];\n gy += maskValue * SOBEL_KERNEL_Y[idx];\n }\n }\n float gradient = sqrt(gx*gx + gy*gy) * u_gradientScale;\n float angle = atan(gy, gx);\n float nmsEdge = nonMaxSuppression(gradient, v_texCoord, o, angle);\n float edge = nmsEdge > 0.0 ? 1.0 : 0.0;\n outColor = vec4(edge, 0.0, 0.0, 1.0);\n}\n",["mask"])}setAttributes(...A){const{gl:e}=this;A.forEach((A,t)=>{e.enableVertexAttribArray(t),e.bindBuffer(e.ARRAY_BUFFER,A),e.vertexAttribPointer(t,2,e.FLOAT,!1,0,0)})}createShader(A,e){const{gl:t}=this,i=t.createShader(A);return t.shaderSource(i,e),t.compileShader(i),i}createProgram(A,e,t){const{gl:i}=this,o=this.createShader(i.FRAGMENT_SHADER,e),n=this.createShader(i.VERTEX_SHADER,A),r=i.createProgram();if(i.attachShader(r,n),i.attachShader(r,o),i.linkProgram(r),!i.getProgramParameter(r,i.LINK_STATUS))throw new Error(`${i.getProgramInfoLog(r)}`);return i.useProgram(r),this.setAttributes(this.positionBuffer,this.texCoordBuffer),t.forEach((A,e)=>{i.uniform1i(i.getUniformLocation(r,A),1+e)}),r}createFramebuffer(A){const{gl:e}=this,t=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,A,0),t}getTempTexture(A,e,t=!0,i){const{gl:o}=this;let n,r;o.useProgram(A),this.ratio===16/9?(n=640,r=360):(n=640,r=480);const s=o.createTexture();o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.pixelStorei(o.PACK_ALIGNMENT,1),o.pixelStorei(o.UNPACK_ALIGNMENT,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,n,r,0,o.RGBA,o.UNSIGNED_BYTE,null);const a=this.createFramebuffer(s);return e.forEach((A,e)=>{A&&(o.activeTexture(o.TEXTURE1+e),o.bindTexture(o.TEXTURE_2D,A||null))}),this.setAttributes(this.positionBuffer,this.texCoordBuffer),o.viewport(0,0,n,r),o.drawArrays(o.TRIANGLE_STRIP,0,4),t&&e.forEach((A,e)=>{A&&i!==e&&o.deleteTexture(A)}),o.deleteFramebuffer(a),s}postProcessing(A){this._lastMaskTexture=this.getTempTexture(this._tdProgram,[A,this._lastMaskTexture]);let e=this.getTempTexture(this._kcProgram,[this._lastMaskTexture],!1);for(let t=0;t<3;t++){e=this.getTempTexture(this._mdProgram,[e]);const A=this.getTempTexture(this._edgeProgram,[e],!1);e=this.getTempTexture(this._borderProgram,[e,A,this._lastMaskTexture],!0,2)}return e}close(){const{gl:A}=this;this._borderProgram&&A.deleteProgram(this._borderProgram),this._edgeProgram&&A.deleteProgram(this._edgeProgram),this._kcProgram&&A.deleteProgram(this._kcProgram),this._mdProgram&&A.deleteProgram(this._mdProgram),this._tdProgram&&A.deleteProgram(this._tdProgram)}},IP=(A=>(A[A.TRACE=0]="TRACE",A[A.DEBUG=1]="DEBUG",A[A.INFO=2]="INFO",A[A.WARN=3]="WARN",A[A.ERROR=4]="ERROR",A[A.NONE=5]="NONE",A))(IP||{}),uP={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},EP=570703,dP=0,hP=class A{constructor(A){this.core=A,XF(this,"seq"),XF(this,"_core"),XF(this,"log"),XF(this,"preLoadPromise"),XF(this,"startResolve"),XF(this,"startReject"),XF(this,"mediaPipeSolutions"),XF(this,"assetsPath"),XF(this,"currentType"),XF(this,"onAbort"),XF(this,"isAborted",!1),dP+=1,this.seq=dP,this._core=A,this.log=A.log.createChild({id:`${this.getAlias()}${dP}`}),this.log.info("created"),A.assetsPath&&(this.preLoadPromise=this.preload(A.assetsPath))}static isSupported(){if($O<90)return!1;const A=document.createElement("canvas").getContext("webgl2",uP);return!!(A&&A instanceof WebGL2RenderingContext)}async preload(A){try{this._core.room.videoManager.Wasm||(this._core.room.videoManager.Wasm=await tO());const e=A=>{var e;this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!1,this.isAborted,"ABORT_IN_INFERENCE")}),this.isAborted=!0,this.log.error("mediaPipeSolutions abort",A),this.core.clearStarted(this,this.getGroup()),this.stop(),null==(e=this.onAbort)||e.call(this,A)};this._core.room.videoManager.initVirtualBackground(e,rx,lP),await this._core.initVisionTaskRegistry(A,["ImageSegmenter"])}catch(e){const{RtcError:A,ErrorCode:t}=this._core.errorModule;throw new A({code:t.INVALID_OPERATION,message:`VirtualBackground preload error, please redeploy the assets of the npm package. detail: ${e}`})}}getName(){return A.Name}getAlias(){return"vb"}getValidateRule(A){switch(A){case"start":return function(A){return{name:"VirtualBackgroundOptions",type:"object",required:!0,allowEmpty:!1,properties:ZF(zF({},$F),{type:{required:!1,type:"string",values:["image","blur","color"]},src:{required:!1,type:"string"},blurLevel:{required:!1,type:"number",min:1,max:10},onAbort:{required:!1},color:{required:!1,type:["array","string"]},enableFaceCentering:{required:!1,type:"boolean"},enableEffectOptimization:{required:!1,type:"boolean"}}),validate(e,t,i,o){var n;const{RtcError:r,ErrorCode:s,ErrorCodeDictionary:a}=A.errorModule;if(!e)return;const{type:g,src:c,onAbort:l}=e;if("image"===g&&!c)throw new r({code:s.INVALID_PARAMETER,extraCode:a.INVALID_PARAMETER_REQUIRED,fnName:i,messageParams:{key:"src"}});if(l&&!A.utils.isFunction(l))throw new r({code:s.INVALID_PARAMETER,extraCode:a.INVALID_PARAMETER_TYPE,fnName:i,messageParams:{key:"onAbort",value:typeof l,rule:{type:"Function"}}});if(!(null==(n=A.room.videoManager.cameraTrack)?void 0:n.mediaTrack))throw new r({code:s.INVALID_OPERATION,extraCode:a.INVALID_OPERATION_NEED_VIDEO,fnName:i})}}}(this._core);case"update":return function(A){return{name:"UpdateVirtualBackgroundOptions",type:"object",required:!0,allowEmpty:!1,properties:{type:{required:!0,type:"string",values:["image","blur","color"]},src:{required:!1,type:"string"},blurLevel:{required:!1,type:"number",min:1,max:10},color:{required:!1,type:["array","string"]},enableFaceCentering:{required:!1,type:"boolean"},enableEffectOptimization:{required:!1,type:"boolean"}},validate(e,t,i,o){if(!e)return;const{RtcError:n,ErrorCode:r,ErrorCodeDictionary:s}=A.errorModule,{type:a,src:g}=e;if("image"===a&&!g)throw new n({code:r.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_REQUIRED,fnName:i,messageParams:{key:"src"}})}}}(this._core);case"stop":return this._core,{name:"StopVirtualBackgroundOptions",required:!1}}}getGroup(){return"vb"}getKVTypeValue(A=!1,e=!1,t="NONE"){let i=0;switch(this.currentType){case"blur":i|=0;break;case"image":i|=1;break;case"color":i|=2}switch(A&&(i|=256),e&&(i|=512),t){case"ABORT_IN_INFERENCE":i|=4096;break;case"ABORT_IN_VIDEO_MANAGER":i|=8192;break;case"OTHER":i|=61440}return i}hexToRgb(A){const e=A.replace("#","");return[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255]}async start(A){const{type:e="blur",src:t,blurLevel:i=3,onAbort:o}=A;this.currentType=e,this.onAbort=o,"color"===e&&"string"==typeof A.color&&(A.color=this.hexToRgb(A.color));const{auth:n}=await async function({sdkAppId:A,userId:e,userSig:t,core:i}){var o;const n=Math.round((new Date).getTime()/1e3);try{const r=await i.schedule.getAbilityConfig(A,i.schedule.ScheduleRequestType.TRTC_AUTO_CONF,{sdkAppId:A,userId:e,userSig:t,timestamp:n});i.log.info(`virtual background ability response: ${JSON.stringify(r)}`);const{data:s}=r;return(null==(o=null==s?void 0:s.trtcAutoConf)?void 0:o.web_ar)?{auth:!0,timestamp:n}:{auth:!1}}catch(r){return i.log.error("virtual background fetch error",r),{auth:!1}}}({sdkAppId:A.sdkAppId,userId:A.userId,userSig:A.userSig,core:this._core}),{RtcError:r,ErrorCodeDictionary:s,ErrorCode:a}=this._core.errorModule;if(!n){const e=this._core.utils.isOverseaSdkAppId(A.sdkAppId)?"https://trtc.io/document/56025":"https://cloud.tencent.com/document/product/647/85386";throw new r({code:s.NEED_TO_BUY,messageParams:{value:"Virtual Background",url:e}})}if(!this.preLoadPromise){if(!this._core.assetsPath)throw new r({code:a.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});this.preLoadPromise=this.preload(this._core.assetsPath)}return await this.preLoadPromise,this.core.room.videoManager.setVirtualBackground({type:e,imageUrl:t,blurLevel:i,enableFaceCentering:A.enableFaceCentering,enableEffectOptimization:A.enableEffectOptimization,color:A.color,onAbort:A=>{var e;this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!0,this.isAborted,"ABORT_IN_VIDEO_MANAGER")}),this.isAborted=!0,this.core.clearStarted(this,this.getGroup()),this.stop(),delete this.preLoadPromise,null==(e=this.onAbort)||e.call(this,A)}}).then(()=>{this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!1,this.isAborted,"NONE")})}).catch(A=>{throw this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!0,this.isAborted,"OTHER")}),A})}async update(A){const{type:e,src:t}=A;return e!==this.currentType&&(this.currentType=e),"color"===e&&"string"==typeof A.color&&(A.color=this.hexToRgb(A.color)),this.core.room.videoManager.setVirtualBackground({type:e,imageUrl:t,blurLevel:A.blurLevel,enableFaceCentering:A.enableFaceCentering,enableEffectOptimization:A.enableEffectOptimization,color:A.color}).then(()=>{this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!1,!1,"NONE")})}).catch(()=>{this.core.kvStatManager.addEnum({key:EP,value:this.getKVTypeValue(!0,!1,"OTHER")})})}async stop(){return this.core.room.videoManager.setVirtualBackground()}};XF(hP,"Name","VirtualBackground");var CP=hP,BP=CP;const QP=_R(Object.freeze(Object.defineProperty({__proto__:null,VirtualBackground:CP,default:BP},Symbol.toStringTag,{value:"Module"})));var pP;function fP(){return pP||(pP=1,function(A,e,t){function i(A){return A&&"object"==typeof A&&"default"in A?A:{default:A}}var o=i(e),n=function(A,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,e){A.__proto__=e}||function(A,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t])})(A,e)},r=function(){return r=Object.assign||function(A){for(var e,t=1,i=arguments.length;t=0;s--)(o=A[s])&&(r=(n<3?o(r):n>3?o(e,t,r):o(e,t))||r);return n>3&&r&&Object.defineProperty(e,t,r),r}function a(A,e,t,i){return new(t||(t=Promise))(function(o,n){function r(A){try{a(i.next(A))}catch(e){n(e)}}function s(A){try{a(i.throw(A))}catch(e){n(e)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(r,s)}a((i=i.apply(A,e||[])).next())})}function g(A,e){var t,i,o,n,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function s(s){return function(a){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;n&&(n=0,s[0]&&(r=0)),r;)try{if(t=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=A.length&&(A=void 0),{value:A&&A[i++],done:!A}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(A,e,t){if(t||2===arguments.length)for(var i,o=0,n=e.length;o0&&pA[0]<4?1:+(pA[0]+pA[1])),!fA&&ee&&(!(pA=ee.match(/Edge\/(\d+)/))||pA[1]>=74)&&(pA=ee.match(/Chrome\/(\d+)/))&&(fA=+pA[1]);var re=fA,se=yA.String,ae=!!Object.getOwnPropertySymbols&&!DA(function(){var A=Symbol("symbol detection");return!se(A)||!(Object(A)instanceof Symbol)||!Symbol.sham&&re&&re<41}),ge=ae&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ce=Object,le=ge?function(A){return"symbol"==typeof A}:function(A){var e=$A("Symbol");return zA(e)&&Ae(e.prototype,ce(A))},Ie=String,ue=TypeError,Ee=function(A){if(zA(A))return A;throw ue(function(A){try{return Ie(A)}catch(e){return"Object"}}(A)+" is not a function")},de=function(A,e){var t=A[e];return JA(t)?void 0:Ee(t)},he=TypeError,Ce=Object.defineProperty,Be=function(A,e){try{Ce(yA,A,{value:e,configurable:!0,writable:!0})}catch(t){yA[A]=e}return e},Qe="__core-js_shared__",pe=yA[Qe]||Be(Qe,{}),fe=E(function(A){(A.exports=function(A,e){return pe[A]||(pe[A]=void 0!==e?e:{})})("versions",[]).push({version:"3.32.1",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE",source:"https://github.com/zloirock/core-js"})}),me=Object,ye=function(A){return me(qA(A))},De=LA({}.hasOwnProperty),ve=Object.hasOwn||function(A,e){return De(ye(A),e)},we=0,Se=Math.random(),Me=LA(1..toString),Re=function(A){return"Symbol("+(void 0===A?"":A)+")_"+Me(++we+Se,36)},_e=yA.Symbol,Te=fe("wks"),Ne=ge?_e.for||_e:_e&&_e.withoutSetter||Re,be=function(A){return ve(Te,A)||(Te[A]=ae&&ve(_e,A)?_e[A]:Ne("Symbol."+A)),Te[A]},Ge=TypeError,ke=be("toPrimitive"),Le=function(A,e){if(!XA(A)||le(A))return A;var t,i=de(A,ke);if(i){if(void 0===e&&(e="default"),t=MA(i,A,e),!XA(t)||le(t))return t;throw Ge("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(A,e){var t,i;if("string"===e&&zA(t=A.toString)&&!XA(i=MA(t,A)))return i;if(zA(t=A.valueOf)&&!XA(i=MA(t,A)))return i;if("string"!==e&&zA(t=A.toString)&&!XA(i=MA(t,A)))return i;throw he("Can't convert object to primitive value")}(A,e)},Ue=function(A){var e=Le(A,"string");return le(e)?e:e+""},Fe=yA.document,Oe=XA(Fe)&&XA(Fe.createElement),xe=function(A){return Oe?Fe.createElement(A):{}},Pe=!vA&&!DA(function(){return 7!==Object.defineProperty(xe("div"),"a",{get:function(){return 7}}).a}),Ye=Object.getOwnPropertyDescriptor,Je={f:vA?Ye:function(A,e){if(A=VA(A),e=Ue(e),Pe)try{return Ye(A,e)}catch(t){}if(ve(A,e))return NA(!MA(TA.f,A,e),A[e])}},He=vA&&DA(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),qe=String,Ve=TypeError,je=function(A){if(XA(A))return A;throw Ve(qe(A)+" is not an object")},Ke=TypeError,We=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Ze="enumerable",Xe="configurable",$e="writable",At={f:vA?He?function(A,e,t){if(je(A),e=Ue(e),je(t),"function"==typeof A&&"prototype"===e&&"value"in t&&$e in t&&!t[$e]){var i=ze(A,e);i&&i[$e]&&(A[e]=t.value,t={configurable:Xe in t?t[Xe]:i[Xe],enumerable:Ze in t?t[Ze]:i[Ze],writable:!1})}return We(A,e,t)}:We:function(A,e,t){if(je(A),e=Ue(e),je(t),Pe)try{return We(A,e,t)}catch(i){}if("get"in t||"set"in t)throw Ke("Accessors not supported");return"value"in t&&(A[e]=t.value),A}},et=vA?function(A,e,t){return At.f(A,e,NA(1,t))}:function(A,e,t){return A[e]=t,A},tt=Function.prototype,it=vA&&Object.getOwnPropertyDescriptor,ot=ve(tt,"name"),nt={EXISTS:ot,PROPER:ot&&"something"===function(){}.name,CONFIGURABLE:ot&&(!vA||vA&&it(tt,"name").configurable)},rt=LA(Function.toString);zA(pe.inspectSource)||(pe.inspectSource=function(A){return rt(A)});var st,at,gt,ct=pe.inspectSource,lt=yA.WeakMap,It=zA(lt)&&/native code/.test(String(lt)),ut=fe("keys"),Et=function(A){return ut[A]||(ut[A]=Re(A))},dt={},ht="Object already initialized",Ct=yA.TypeError,Bt=yA.WeakMap;if(It||pe.state){var Qt=pe.state||(pe.state=new Bt);Qt.get=Qt.get,Qt.has=Qt.has,Qt.set=Qt.set,st=function(A,e){if(Qt.has(A))throw Ct(ht);return e.facade=A,Qt.set(A,e),e},at=function(A){return Qt.get(A)||{}},gt=function(A){return Qt.has(A)}}else{var pt=Et("state");dt[pt]=!0,st=function(A,e){if(ve(A,pt))throw Ct(ht);return e.facade=A,et(A,pt,e),e},at=function(A){return ve(A,pt)?A[pt]:{}},gt=function(A){return ve(A,pt)}}var ft={set:st,get:at,has:gt,enforce:function(A){return gt(A)?at(A):st(A,{})},getterFor:function(A){return function(e){var t;if(!XA(e)||(t=at(e)).type!==A)throw Ct("Incompatible receiver, "+A+" required");return t}}},mt=E(function(A){var e=nt.CONFIGURABLE,t=ft.enforce,i=ft.get,o=String,n=Object.defineProperty,r=LA("".slice),s=LA("".replace),a=LA([].join),g=vA&&!DA(function(){return 8!==n(function(){},"length",{value:8}).length}),c=String(String).split("String"),l=A.exports=function(A,i,l){"Symbol("===r(o(i),0,7)&&(i="["+s(o(i),/^Symbol\(([^)]*)\)/,"$1")+"]"),l&&l.getter&&(i="get "+i),l&&l.setter&&(i="set "+i),(!ve(A,"name")||e&&A.name!==i)&&(vA?n(A,"name",{value:i,configurable:!0}):A.name=i),g&&l&&ve(l,"arity")&&A.length!==l.arity&&n(A,"length",{value:l.arity});try{l&&ve(l,"constructor")&&l.constructor?vA&&n(A,"prototype",{writable:!1}):A.prototype&&(A.prototype=void 0)}catch(u){}var I=t(A);return ve(I,"source")||(I.source=a(c,"string"==typeof i?i:"")),A};Function.prototype.toString=l(function(){return zA(this)&&i(this).source||ct(this)},"toString")}),yt=function(A,e,t,i){i||(i={});var o=i.enumerable,n=void 0!==i.name?i.name:e;if(zA(t)&&mt(t,n,i),i.global)o?A[e]=t:Be(e,t);else{try{i.unsafe?A[e]&&(o=!0):delete A[e]}catch(r){}o?A[e]=t:At.f(A,e,{value:t,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return A},Dt=Math.ceil,vt=Math.floor,wt=Math.trunc||function(A){var e=+A;return(e>0?vt:Dt)(e)},St=function(A){var e=+A;return e!=e||0===e?0:wt(e)},Mt=Math.max,Rt=Math.min,_t=Math.min,Tt=function(A){return A>0?_t(St(A),9007199254740991):0},Nt=function(A){return Tt(A.length)},bt=function(A){return function(e,t,i){var o,n,r,s=VA(e),a=Nt(s),g=(n=a,(r=St(i))<0?Mt(r+n,0):Rt(r,n));if(A&&t!=t){for(;a>g;)if((o=s[g++])!=o)return!0}else for(;a>g;g++)if((A||g in s)&&s[g]===t)return A||g||0;return!A&&-1}},Gt=(bt(!0),bt(!1)),kt=LA([].push),Lt=function(A,e){var t,i=VA(A),o=0,n=[];for(t in i)!ve(dt,t)&&ve(i,t)&&kt(n,t);for(;e.length>o;)ve(i,t=e[o++])&&(~Gt(n,t)||kt(n,t));return n},Ut=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ft=Ut.concat("length","prototype"),Ot={f:Object.getOwnPropertyNames||function(A){return Lt(A,Ft)}},xt={f:Object.getOwnPropertySymbols},Pt=LA([].concat),Yt=$A("Reflect","ownKeys")||function(A){var e=Ot.f(je(A)),t=xt.f;return t?Pt(e,t(A)):e},Jt=function(A,e,t){for(var i=Yt(e),o=At.f,n=Je.f,r=0;rr;)At.f(A,t=o[r++],i[t]);return A}},di=$A("document","documentElement"),hi="prototype",Ci="script",Bi=Et("IE_PROTO"),Qi=function(){},pi=function(A){return"<"+Ci+">"+A+""},fi=function(A){A.write(pi("")),A.close();var e=A.parentWindow.Object;return A=null,e},mi=function(){try{Ai=new ActiveXObject("htmlfile")}catch(o){}var A,e,t;mi="undefined"!=typeof document?document.domain&&Ai?fi(Ai):(e=xe("iframe"),t="java"+Ci+":",e.style.display="none",di.appendChild(e),e.src=String(t),(A=e.contentWindow.document).open(),A.write(pi("document.F=Object")),A.close(),A.F):fi(Ai);for(var i=Ut.length;i--;)delete mi[hi][Ut[i]];return mi()};dt[Bi]=!0;var yi,Di,vi=Object.create||function(A,e){var t;return null!==A?(Qi[hi]=je(A),t=new Qi,Qi[hi]=null,t[Bi]=A):t=mi(),void 0===e?t:Ei.f(t,e)},wi=yA.RegExp,Si=DA(function(){var A=wi(".","s");return!(A.dotAll&&A.exec("\n")&&"s"===A.flags)}),Mi=yA.RegExp,Ri=DA(function(){var A=Mi("(?b)","g");return"b"!==A.exec("b").groups.a||"bc"!=="b".replace(A,"$c")}),_i=ft.get,Ti=fe("native-string-replace",String.prototype.replace),Ni=RegExp.prototype.exec,bi=Ni,Gi=LA("".charAt),ki=LA("".indexOf),Li=LA("".replace),Ui=LA("".slice),Fi=(Di=/b*/g,MA(Ni,yi=/a/,"a"),MA(Ni,Di,"a"),0!==yi.lastIndex||0!==Di.lastIndex),Oi=Ii.BROKEN_CARET,xi=void 0!==/()??/.exec("")[1];(Fi||xi||Oi||Si||Ri)&&(bi=function(A){var e,t,i,o,n,r,s,a=this,g=_i(a),c=si(A),l=g.raw;if(l)return l.lastIndex=a.lastIndex,e=MA(bi,l,c),a.lastIndex=l.lastIndex,e;var I=g.groups,u=Oi&&a.sticky,E=MA(ai,a),d=a.source,h=0,C=c;if(u&&(E=Li(E,"y",""),-1===ki(E,"g")&&(E+="g"),C=Ui(c,a.lastIndex),a.lastIndex>0&&(!a.multiline||a.multiline&&"\n"!==Gi(c,a.lastIndex-1))&&(d="(?: "+d+")",C=" "+C,h++),t=new RegExp("^(?:"+d+")",E)),xi&&(t=new RegExp("^"+d+"$(?!\\s)",E)),Fi&&(i=a.lastIndex),o=MA(Ni,u?t:a,C),u?o?(o.input=Ui(o.input,h),o[0]=Ui(o[0],h),o.index=a.lastIndex,a.lastIndex+=o[0].length):a.lastIndex=0:Fi&&o&&(a.lastIndex=a.global?o.index+o[0].length:i),xi&&o&&o.length>1&&MA(Ti,o[0],t,function(){for(n=1;n=s?A?"":void 0:(i=io(n,r))<55296||i>56319||r+1===s||(o=io(n,r+1))<56320||o>57343?A?to(n,r):i:A?oo(n,r,r+2):o-56320+(i-55296<<10)+65536}},ro=(no(!1),no(!0)),so=function(A,e,t){return e+(t?ro(A,e).length:1)},ao=TypeError,go=function(A,e){var t=A.exec;if(zA(t)){var i=MA(t,A,e);return null!==i&&je(i),i}if("RegExp"===OA(A))return MA(Pi,A,e);throw ao("RegExp#exec called on incompatible receiver")};!function(A,e,t,i){var o=be(A),n=!DA(function(){var e={};return e[o]=function(){return 7},7!==""[A](e)}),r=n&&!DA(function(){var e=!1,t=/a/;return"split"===A&&((t={}).constructor={},t.constructor[Ao]=function(){return t},t.flags="",t[o]=/./[o]),t.exec=function(){return e=!0,null},t[o](""),!e});if(!n||!r||t){var s=$i(/./[o]),a=e(o,""[A],function(A,e,t,i,o){var r=$i(A),a=e.exec;return a===Pi||a===eo.exec?n&&!o?{done:!0,value:s(e,t,i)}:{done:!0,value:r(t,e,i)}:{done:!1}});yt(String.prototype,A,a[0]),yt(eo,o,a[1])}i&&et(eo[o],"sham",!0)}("match",function(A,e,t){return[function(e){var t=qA(this),i=JA(e)?void 0:de(e,A);return i?MA(i,e,t):new RegExp(e)[A](si(t))},function(A){var i=je(this),o=si(A),n=t(e,i,o);if(n.done)return n.value;if(!i.global)return go(i,o);var r=i.unicode;i.lastIndex=0;for(var s,a=[],g=0;null!==(s=go(i,o));){var c=si(s[0]);a[g]=c,""===c&&(i.lastIndex=so(o,Tt(i.lastIndex),r)),g++}return 0===g?null:a}]});var co=Array.isArray||function(A){return"Array"===OA(A)},lo=TypeError,Io=function(A){if(A>9007199254740991)throw lo("Maximum allowed index exceeded");return A},uo=function(A,e,t){var i=Ue(e);i in A?At.f(A,i,NA(0,t)):A[i]=t},Eo=function(){},ho=[],Co=$A("Reflect","construct"),Bo=/^\s*(?:class|function)\b/,Qo=LA(Bo.exec),po=!Bo.exec(Eo),fo=function(A){if(!zA(A))return!1;try{return Co(Eo,ho,A),!0}catch(e){return!1}},mo=function(A){if(!zA(A))return!1;switch(ni(A)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return po||!!Qo(Bo,ct(A))}catch(e){return!0}};mo.sham=!0;var yo,Do=!Co||DA(function(){var A;return fo(fo.call)||!fo(Object)||!fo(function(){A=!0})||A})?mo:fo,vo=be("species"),wo=Array,So=function(A,e){return new(co(t=A)&&(i=t.constructor,(Do(i)&&(i===wo||co(i.prototype))||XA(i)&&null===(i=i[vo]))&&(i=void 0)),void 0===i?wo:i)(0===e?0:e);var t,i},Mo=be("species"),Ro=be("isConcatSpreadable"),_o=re>=51||!DA(function(){var A=[];return A[Ro]=!1,A.concat()[0]!==A}),To=function(A){if(!XA(A))return!1;var e=A[Ro];return void 0!==e?!!e:co(A)};Xt({target:"Array",proto:!0,arity:1,forced:!(_o&&(yo="concat",re>=51||!DA(function(){var A=[];return(A.constructor={})[Mo]=function(){return{foo:1}},1!==A[yo](Boolean).foo})))},{concat:function(A){var e,t,i,o,n,r=ye(this),s=So(r,0),a=0;for(e=-1,i=arguments.length;ee in A?yn(A,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[e]=t,Tn=(A,e,t,i)=>{for(var o,n=i>1?void 0:i?Dn(e,t):e,r=A.length-1;r>=0;r--)(o=A[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&yn(e,t,n),n},Nn=(A,e,t)=>_n(A,"symbol"!=typeof e?e+"":e,t),bn=(sn={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(A,e){var t=Object.prototype.hasOwnProperty,i="~";function o(){}function n(A,e,t){this.fn=A,this.context=e,this.once=t||!1}function r(A,e,t,o,r){if("function"!=typeof t)throw new TypeError("The listener must be a function");var s=new n(t,o||A,r),a=i?i+e:e;return A._events[a]?A._events[a].fn?A._events[a]=[A._events[a],s]:A._events[a].push(s):(A._events[a]=s,A._eventsCount++),A}function s(A,e){0==--A._eventsCount?A._events=new o:delete A._events[e]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),a.prototype.eventNames=function(){var A,e,o=[];if(0===this._eventsCount)return o;for(e in A=this._events)t.call(A,e)&&o.push(i?e.slice(1):e);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(A)):o},a.prototype.listeners=function(A){var e=i?i+A:A,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var o=0,n=t.length,r=new Array(n);o{const e=A.split("\r\n"),t=[];e.forEach(A=>{const e=A.toLowerCase();e.includes("a=rtpmap")&&e.includes("h264")&&t.push(A)});const i=t.map(A=>{const e=/a=rtpmap:(\d+)\s/.exec(A);return e&&e.length>1?e[1]:null}).filter(A=>null!==A),o=[];return e.forEach(A=>{let e=A;if(A.includes("a=fmtp:111")&&(e=`${A};stereo=1`),A.includes("a=fmtp")){const t=/a=fmtp:(\d+)\s/.exec(A);t&&t.length>1&&i.includes(t[1])&&(e=`${A};sps-pps-idr-in-keyframe=1`)}o.push(e)}),(A=>{if(!navigator.userAgent.includes("Firefox"))return A;const e=A.split("\r\n"),t=[],i=[];e.forEach(A=>{const e=A.toLowerCase();e.includes("a=rtpmap")&&e.includes("h264")&&t.push(A)}),t.length>1&&i.push(...t.slice(1));const o=i.map(A=>{const e=/a=rtpmap:(\d+)\s/.exec(A);return e&&e.length>1?e[1]:null}).filter(A=>null!==A),n=[];return e.forEach(A=>{let e=A;if(A.includes("a=setup")&&(e="a=setup:passive"),(A.includes("m=audio")||A.includes("m=video"))&&(e=A.split(" ").filter((A,e)=>e<3||!o.includes(A)).join(" ")),A.includes("a=fmtp")||A.includes("a=rtcp-fb")||A.includes("a=rtpmap")){const e=/a=(?:fmtp|rtcp-fb|rtpmap):(\d+)\s/.exec(A);if(e&&e.length>1&&o.includes(e[1]))return}n.push(e)}),n.join("\r\n")})(o.join("\r\n"))},Ln=(A=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(A|=0));for(;A--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[A]];return e},Un=A=>"function"==typeof A,Fn=function({retryFunction:A,settings:e,onError:t,onRetrying:i,onRetryFailed:o,onRetrySuccess:n,context:r}){return function(...s){const{retries:a=5,timeout:g=1e3}=e;let c=0,l=-1,I=0;const u=async(e,E)=>{const d=r||this;try{const t=await A.apply(d,s);c>0&&n&&n.call(this,c),c=0,e(t)}catch(h){const A=()=>{clearTimeout(l),c=0,I=2,E(h)},n=()=>{2!==I&&c<(Un(a)?a():a)?(c++,I=1,Un(i)&&i.call(this,c,A),l=window.setTimeout(()=>{l=-1,u(e,E)},Un(g)?g(c):g)):(A(),Un(o)&&o.call(this,h))};Un(t)?t.call(this,{error:h,retry:n,reject:E,retryFuncArgs:s,retriedCount:c}):n()}};return new Promise(u)}},On=new WeakMap,xn=((A,e,t)=>(t=null!=A?mn(Sn(A)):{},((A,e,t,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of vn(e))Mn.call(A,o)||o===t||yn(A,o,{get:()=>e[o],enumerable:!(i=Dn(e,o))||i.enumerable});return A})(!e&&A&&A.__esModule?t:yn(t,"default",{value:A,enumerable:!0}),A)))(bn(),1),Pn=Symbol("instance"),Yn=Symbol("cacheResult"),Jn=class{constructor(A,e,t){this.oldState=A,this.newState=e,this.action=t,this.aborted=!1}abort(A){this.aborted=!0,Kn.call(A,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},Hn=class extends Error{constructor(A,e,t){super(e),this.state=A,this.message=e,this.cause=t}},qn=new Map;function Vn(A,e,t={}){return(i,o,n)=>{const r=t.action||o;if(!t.context){const t=qn.get(i)||[];qn.has(i)||qn.set(i,t),t.push({from:A,to:e,action:r})}const s=n.value;n.value=function(...i){let o=this;if(t.context&&(o=Wn.get("function"==typeof t.context?t.context.call(this,...i):t.context)),o.state===e)return t.sync?o[Yn]:Promise.resolve(o[Yn]);o.state instanceof Jn&&o.state.action==t.abortAction&&o.state.abort(o);let n=null;Array.isArray(A)?0==A.length?o.state instanceof Jn&&o.state.abort(o):"string"==typeof o.state&&A.includes(o.state)||(n=new Hn(o._state,`${o.name} ${r} to ${e} failed: current state ${o._state} not from ${A.join("|")}`)):A!==o.state&&(n=new Hn(o._state,`${o.name} ${r} to ${e} failed: current state ${o._state} not from ${A}`));const a=A=>{if(t.fail&&t.fail.call(this,A),t.sync){if(t.ignoreError)return A;throw A}return t.ignoreError?Promise.resolve(A):Promise.reject(A)};if(n)return a(n);const g=o.state,c=new Jn(g,e,r);Kn.call(o,c);const l=A=>{var i;return o[Yn]=A,c.aborted||(Kn.call(o,e),null===(i=t.success)||void 0===i||i.call(this,o[Yn])),A},I=A=>(Kn.call(o,g,A),a(A));try{const A=s.apply(this,i);return"object"==typeof(u=A)&&u&&"then"in u?A.then(l).catch(I):t.sync?l(A):Promise.resolve(l(A))}catch(E){return I(new Hn(o._state,`${o.name} ${r} from ${A} to ${e} failed: ${E}`,E instanceof Error?E:new Error(String(E))))}var u}}}var jn=(()=>{const A="undefined"!=typeof window&&window.__AFSM__,e="undefined"!=typeof importScripts;return A?(A,e)=>{window.dispatchEvent(new CustomEvent(A,{detail:e}))}:e?(A,e)=>{postMessage({type:A,payload:e})}:()=>{}})();function Kn(A,e){const t=this._state;this._state=A;const i=A.toString();A&&this.emit(i,t),this.emit(Wn.STATECHANGED,A,t,e),this.updateDevTools({value:A,old:t,err:e instanceof Error?e.message:String(e)})}var Wn=class A extends xn.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=A.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);const o=i[Pn];o?this.name=o.name+"-"+o.count++:i[Pn]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const A=Object.getPrototypeOf(this),e=qn.get(A)||[];let t=new Set,i=[],o=[];const n=new Set,r=Object.getPrototypeOf(A);qn.has(r)&&(r.stateDiagram.forEach(A=>t.add(A)),r.allStates.forEach(A=>n.add(A))),e.forEach(({from:A,to:e,action:t})=>{"string"==typeof A?i.push({from:A,to:e,action:t}):A.length?A.forEach(A=>{i.push({from:A,to:e,action:t})}):o.push({to:e,action:t})}),i.forEach(({from:A,to:e,action:i})=>{n.add(A),n.add(e),n.add(i+"ing"),t.add(`${A} --\x3e ${i}ing : ${i}`),t.add(`${i}ing --\x3e ${e} : ${i} 🟢`),t.add(`${i}ing --\x3e ${A} : ${i} 🔴`)}),o.forEach(({to:A,action:e})=>{t.add(`${e}ing --\x3e ${A} : ${e} 🟢`),n.forEach(i=>{i!==A&&t.add(`${i} --\x3e ${e}ing : ${e}`)})});const s=[...t];return Object.defineProperties(A,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(e){let t;return"string"==typeof e?(t=A.instances.get(e),t||A.instances.set(e,t=new A(e,void 0,Object.create(A.prototype)))):(t=A.instances2.get(e),t||A.instances2.set(e,t=new A(e.constructor.name,void 0,Object.create(A.prototype)))),t}static getState(e){var t;return null===(t=A.get(e))||void 0===t?void 0:t.state}updateDevTools(e={}){jn(A.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(A){Kn.call(this,A)}};Wn.STATECHANGED="stateChanged",Wn.UPDATEAFSM="updateAFSM",Wn.INIT="[*]",Wn.ON="on",Wn.OFF="off",Wn.instances=new Map,Wn.instances2=new WeakMap;var zn=class extends Wn{constructor(A,e){super(),this.core=A,Nn(this,"audioPlayer"),Nn(this,"videoPlayer"),Nn(this,"callback"),Nn(this,"avPlayerStateSyncManager"),Nn(this,"_log"),Nn(this,"lastPausedReason"),Nn(this,"muted",!1),this._log=e,this.videoPlayer=new A.VideoPlayer({id:"vp",log:this._log.createChild({id:"vp"}),track:null,muted:!1,container:null,enableLogTrackState:!0}),this.audioPlayer=new A.RemoteAudioPlayer({id:"ap",log:this._log.createChild({id:"ap"}),track:null,muted:!1,container:null,enableVolumeControlInIOS:!0,enableLogTrackState:!0}),this.videoPlayer.on(A.PlayerEvent.LOAD_START,()=>this.handleLoadStart("video")),this.audioPlayer.on(A.PlayerEvent.LOAD_START,()=>this.handleLoadStart("audio")),this.videoPlayer.on(A.PlayerEvent.PLAYER_STATE_CHANGED,this.handlePlayerStateChanged,this),this.audioPlayer.on(A.PlayerEvent.PLAYER_STATE_CHANGED,this.handlePlayerStateChanged,this),this.videoPlayer.on(A.PlayerEvent.ENTER_PICTURE_IN_PICTURE,this.handleEnterPictureInPicture,this),this.videoPlayer.on(A.PlayerEvent.LEAVE_PICTURE_IN_PICTURE,this.handleLeavePictureInPicture,this),this.videoPlayer.on(A.PlayerEvent.ENTER_FULL_SCREEN,this.handleEnterFullScreen,this),this.videoPlayer.on(A.PlayerEvent.LEAVE_FULL_SCREEN,this.handleLeaveFullScreen,this),this.avPlayerStateSyncManager=new A.AVPlayerStateSyncManager({log:this._log,audioPlayer:this.audioPlayer,videoPlayer:this.videoPlayer})}get isPlaying(){return this.videoPlayer.isPlaying&&this.audioPlayer.isPlaying}get isPaused(){return this.videoPlayer.isPaused&&this.audioPlayer.isPaused}get isStopped(){return this.videoPlayer.isStopped&&this.audioPlayer.isStopped}setCallback(A){this.callback=A}handleLoadStart(A){this.onLoadStart()}handlePlayerStateChanged(A){"PLAYING"===A.state&&this.isPlaying&&this.onPlaying(),"PAUSED"===A.state&&this.isPaused&&this.onPaused(A.reason),"STOPPED"===A.state&&this.isStopped&&this.onStopped()}async handleEnterPictureInPicture(){var A,e;await this.videoPlayer.enterPIPPromise,null==(e=null==(A=this.callback)?void 0:A.onPictureInPictureStateChanged)||e.call(A,{isPictureInPicture:!0,pictureInPictureWindow:this.videoPlayer.pipWindow})}handleLeavePictureInPicture(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onPictureInPictureStateChanged)||e.call(A,{isPictureInPicture:!1})}handleEnterFullScreen(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onFullScreenStateChanged)||e.call(A,{isFullScreen:!0})}handleLeaveFullScreen(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onFullScreenStateChanged)||e.call(A,{isFullScreen:!1})}onLoadStart(){}onPlaying(){}onPaused(A){this.lastPausedReason=A}onStopped(){}setVideoContainer(A){if(this.core.utils.isString(A)){const e=document.getElementById(A);e&&this.videoPlayer.setContainer(e)}else this.videoPlayer.setContainer(A)}setVolume(A){this.core.utils.isUndefined(A)||this.audioPlayer.setVolume(A/100)}setMuted(A){this.core.utils.isUndefined(A)||(this.muted=A,this.audioPlayer.setMuted(A))}setFillMode(A){A&&this.videoPlayer.setObjectFit(A)}setAudioTrack(A){this.audioPlayer.setTrack(A)}setVideoTrack(A){this.videoPlayer.setTrack(A)}async play(){const A=this.videoPlayer.play().catch(A=>{var e,t;this.handleAutoPlayFailed(this.videoPlayer,A),null==(t=null==(e=this.callback)?void 0:e.onAutoPlayFailed)||t.call(e,{type:"video",resume:()=>this.videoPlayer.resume()})}),e=this.audioPlayer.play().catch(A=>{var e,t;this.handleAutoPlayFailed(this.audioPlayer,A),null==(t=null==(e=this.callback)?void 0:e.onAutoPlayFailed)||t.call(e,{type:"audio",resume:()=>this.audioPlayer.resume()})});await Promise.all([A,e])}handleAutoPlayFailed(A,e){this._log.warn("handleAutoPlayFailed",e);const t=()=>{this.audioPlayer.resume().then(()=>{document.removeEventListener("click",t,!0)})};document.addEventListener("click",t,!0)}pause(){this.videoPlayer.pause(!1),this.audioPlayer.setMuted(!0),this.audioPlayer.pause()}resume(){this.videoPlayer.resume(!0),this.audioPlayer.setMuted(this.muted),this.audioPlayer.resume()}async enterFullscreen(){await this.videoPlayer.enterFullscreen()}async exitFullscreen(){await this.videoPlayer.exitFullscreen()}async enterPictureInPicture(){await this.videoPlayer.enterPictureInPicture()}async exitPictureInPicture(){await this.videoPlayer.exitPictureInPicture()}stop(){this.videoPlayer&&this.videoPlayer.stop(),this.audioPlayer&&(this.audioPlayer.stop(),this.audioPlayer.setMuted(!1))}};Tn([Vn([Wn.INIT,"PAUSED"],"LOADSTART",{ignoreError:!0,sync:!0,success(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onLoadStart)||e.call(A)},fail(A){this._log.warn("onLoadStart",A)}})],zn.prototype,"onLoadStart",1),Tn([Vn(["LOADSTART","PAUSED"],"PLAYING",{ignoreError:!0,sync:!0,success(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onPlaying)||e.call(A)},fail(A){this._log.warn("onPlaying",A)}})],zn.prototype,"onPlaying",1),Tn([Vn("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onPaused)||e.call(A,{reason:this.lastPausedReason})},fail(A){this._log.warn("onPaused",A)}})],zn.prototype,"onPaused",1),Tn([Vn([],Wn.INIT,{ignoreError:!0,sync:!0,success(){var A,e;null==(e=null==(A=this.callback)?void 0:A.onStopped)||e.call(A)},fail(A){this._log.warn("onStopped",A)}})],zn.prototype,"onStopped",1);var Zn=zn,Xn=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],$n=class A{constructor(A){this.core=A,Nn(this,"_sdkAppId"),Nn(this,"_userId"),Nn(this,"connectedRoomIdSet",new Set),Nn(this,"updateSeq",0),Nn(this,"_log"),Nn(this,"player"),Nn(this,"peerConnection"),Nn(this,"svrSig"),Nn(this,"streamURL"),Nn(this,"signalURL"),Nn(this,"insertableStreamsAbortMap",new Map),Nn(this,"scriptTransformWorker"),Nn(this,"connectionState","disconnected"),Nn(this,"isStarted",!1),Nn(this,"isStopped",!0),Nn(this,"isReconnecting",!1),Nn(this,"callback"),Nn(this,"isFireWallErrorEmitted",!1),Nn(this,"stat"),Nn(this,"isH264DecodeSupported"),Nn(this,"connectionTimeoutId"),A.loggerManager.startUpload(),this._log=this.core.log.createChild({id:`${this.getAlias()}`}),this.player=new Zn(A,this._log),A.innerEmitter.on(A.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}getName(){return A.Name}getAlias(){return"LEB"}getGroup(){return""}getValidateRule(A){switch(A){case"start":return Gn;case"update":case"stop":return{}}}get enableSEI(){return this.core.room.enableSEI&&(this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED||this.core.rtcDectection.IS_SCRIPT_TRANSFORM_SUPPORTED)}async start(A){var e;this.isStopped=!1;const{view:t,url:i,volume:o,muted:n,fillMode:r,loggerConfig:s,callback:a}=A;this.callback=a,this.player.setCallback(a);const{errorModule:{RtcError:g,ErrorCode:c,ErrorCodeDictionary:l},loggerManager:I,rtcDectection:u}=this.core;if(this._sdkAppId=s.sdkAppId,this._userId=s.userId,this._log.setSdkAppId(s.sdkAppId),this._log.setUserId(s.userId),I.addJoinedUser(s),!u.isWebRTCSupported()||!u.isAddTransceiverSupported())throw new g({code:c.ENV_NOT_SUPPORTED,extraCode:l.NOT_SUPPORTED_WEBRTC,message:"webrtc not supported"});if(!(await u.decodeSupportStatus()).isH264DecodeSupported||!1===this.isH264DecodeSupported)throw this.isH264DecodeSupported=!1,new g({code:c.ENV_NOT_SUPPORTED,extraCode:l.NOT_SUPPORTED_H264_DECODE,message:"h264 not supported"});!u.IS_SEI_SUPPORTED&&(null==a?void 0:a.onSEIMessage)&&(null==(e=a.onError)||e.call(a,new g({code:c.ENV_NOT_SUPPORTED,extraCode:l.NOT_SUPPORTED_SEI,message:"sei not supported"}))),this.player.setVideoContainer(t),this.player.setMuted(n),this.player.setFillMode(r),await this.connect(i),this.stat=new class{constructor(A,e){this.core=e,Nn(this,"peerConnection"),Nn(this,"audioTransceiver",null),Nn(this,"videoTransceiver",null),Nn(this,"timerId",null),Nn(this,"callback",null),Nn(this,"previousRawStats",null),Nn(this,"_prevReportTime",0),Nn(this,"_prevDecoderImplementation",""),Nn(this,"_decodeMap",new Map),this.peerConnection=A,this.findTransceivers()}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}findTransceivers(){const A=this.peerConnection.getTransceivers();for(const e of A)if(e.receiver&&e.receiver.track){const{track:A}=e.receiver;"audio"===A.kind?this.audioTransceiver=e:"video"===A.kind&&(this.videoTransceiver=e)}}start(A,e=2e3){this.stop(),this.callback=A,this.collectStats(),this.timerId=window.setInterval(()=>{this.collectStats()},e)}stop(){null!==this.timerId&&(clearInterval(this.timerId),this.timerId=null),this.callback=null,this.previousRawStats=null,this._prevReportTime=0}async collectStats(){if(this.callback)try{const A=await this.peerConnection.getStats(),e=new Set(["inbound-rtp","track","candidate-pair","media-source","codec"]),t=[];A.forEach(A=>e.has(A.type)&&t.push(A));const i=Date.now(),o=this.parseAudioStats(t),n=this.parseVideoStats(t),r=this.parseNetworkStats(t);this._prevReportTime=i,this.callback({audio:o,video:n,network:r})}catch(A){this.core.log.error("Failed to collect WebRTC stats:",A)}}getDifferenceValue(A,e){if(this.core.utils.isUndefined(A))return e;const t=(e||0)-A;return t<0?0:t}parseAudioStats(A){var e,t,i,o;const n={bitrate:0,volume:0,packetLossRate:0,jitterBufferDelay:0,bytesReceived:0,packetsReceived:0,packetsLost:0};for(const r of A){if("inbound-rtp"===r.type&&("audio"===r.mediaType||"audio"===r.kind)){if(n.bytesReceived=r.bytesReceived||0,n.packetsReceived=r.packetsReceived||0,n.packetsLost=r.packetsLost||0,this.previousRawStats&&this.previousRawStats.audio){const A=this.getDifferenceValue(this.previousRawStats.audio.bytesReceived,n.bytesReceived);n.bitrate=Math.round(8*A/this.statInterval/1e3)}const A=this.getDifferenceValue(null==(e=this.previousRawStats)?void 0:e.audio.packetsLost,n.packetsLost),o=this.getDifferenceValue(null==(t=this.previousRawStats)?void 0:t.audio.packetsReceived,n.packetsReceived)+A;if(o>0&&(n.packetLossRate=Math.round(A/o*100)),this.core.utils.isUndefined(r.audioLevel)||(n.volume=r.audioLevel||0),r.jitterBufferDelay&&r.jitterBufferEmittedCount){let{jitterBufferEmittedCount:A}=r,{jitterBufferDelay:e}=r;(null==(i=this.previousRawStats)?void 0:i.audio)&&(A=this.getDifferenceValue(this.previousRawStats.audio.jitterBufferEmittedCount,r.jitterBufferEmittedCount),e=this.getDifferenceValue(this.previousRawStats.audio.jitterBufferDelay,r.jitterBufferDelay)),A>0&&(n.jitterBufferDelay=Math.floor(e/A*1e3)),this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.audio.jitterBufferDelay=r.jitterBufferDelay,this.previousRawStats.audio.jitterBufferEmittedCount=r.jitterBufferEmittedCount}this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.audio.bytesReceived=n.bytesReceived,this.previousRawStats.audio.packetsReceived=n.packetsReceived,this.previousRawStats.audio.packetsLost=n.packetsLost}!this.core.utils.isUndefined(r.audioLevel)&&(null==(o=this.audioTransceiver)?void 0:o.receiver.track)&&r.trackIdentifier===this.audioTransceiver.receiver.track.id&&(n.volume=r.audioLevel||0)}return n}parseVideoStats(A){var e,t,i,o,n;const r={bitrate:0,frameRate:0,width:0,height:0,packetLossRate:0,jitterBufferDelay:0,bytesReceived:0,packetsReceived:0,packetsLost:0,framesDecoded:0};for(const s of A){if("codec"===s.type&&this._decodeMap.set(s.id,s),"inbound-rtp"===s.type&&("video"===s.mediaType||"video"===s.kind)){if(r.bytesReceived=s.bytesReceived||0,r.packetsReceived=s.packetsReceived||0,r.packetsLost=s.packetsLost||0,r.framesDecoded=s.framesDecoded||0,this.core.utils.isUndefined(s.framesPerSecond)||(r.frameRate=Math.round(s.framesPerSecond)),s.decoderImplementation&&this._prevDecoderImplementation!==s.decoderImplementation){const A=this._decodeMap.get(s.codecId),t=(null==(e=null==A?void 0:A.mimeType)?void 0:e.split("/")[1])||"unknown",i=s.powerEfficientDecoder;this.core.log.info(`decoderImplementation change to ${s.decoderImplementation}(${t}) HWDecoder: ${i}`),this._prevDecoderImplementation=s.decoderImplementation}if(this.previousRawStats&&this.previousRawStats.video){const A=this.getDifferenceValue(this.previousRawStats.video.bytesReceived,r.bytesReceived);r.bitrate=Math.round(8*A/this.statInterval/1e3)}const A=this.getDifferenceValue(null==(t=this.previousRawStats)?void 0:t.video.packetsLost,r.packetsLost),n=this.getDifferenceValue(null==(i=this.previousRawStats)?void 0:i.video.packetsReceived,r.packetsReceived)+A;if(n>0&&(r.packetLossRate=Math.round(A/n*100)),s.jitterBufferDelay&&s.jitterBufferEmittedCount){let{jitterBufferEmittedCount:A}=s,{jitterBufferDelay:e}=s;(null==(o=this.previousRawStats)?void 0:o.video)&&(A=this.getDifferenceValue(this.previousRawStats.video.jitterBufferEmittedCount,s.jitterBufferEmittedCount),e=this.getDifferenceValue(this.previousRawStats.video.jitterBufferDelay,s.jitterBufferDelay)),A>0&&(r.jitterBufferDelay=Math.floor(e/A*1e3)),this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.video.jitterBufferDelay=s.jitterBufferDelay,this.previousRawStats.video.jitterBufferEmittedCount=s.jitterBufferEmittedCount}this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.video.bytesReceived=r.bytesReceived,this.previousRawStats.video.packetsReceived=r.packetsReceived,this.previousRawStats.video.packetsLost=r.packetsLost}!this.core.utils.isUndefined(s.frameWidth)&&(null==(n=this.videoTransceiver)?void 0:n.receiver.track)&&s.trackIdentifier===this.videoTransceiver.receiver.track.id&&(r.width=s.frameWidth,r.height=s.frameHeight)}return r}parseNetworkStats(A){const e={rtt:0};for(const t of A)if("candidate-pair"===t.type&&(t.selected||"succeeded"===t.state)&&this.core.utils.isNumber(t.currentRoundTripTime)){e.rtt=Math.floor(1e3*t.currentRoundTripTime);break}return e}initPreviousRawStats(){this.previousRawStats={timestamp:Date.now(),audio:{bytesReceived:0,packetsReceived:0,packetsLost:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0}}}}(this.peerConnection,this.core),this.stat.start(A=>{var e,t;return null==(t=null==(e=this.callback)?void 0:e.onStats)?void 0:t.call(e,A)});const E=this.player.play();this.player.setVolume(o),await E,this.isStarted=!0}connect(A){return new Promise((e,t)=>{try{this.initScriptTransformWorker();const i={encodedInsertableStreams:this.enableSEI,iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"},o=new RTCPeerConnection(i);this.peerConnection=o,o.onconnectionstatechange=()=>{this.connectionState=o.connectionState,this._log.info("connectionState",o.connectionState),"failed"!==o.connectionState&&"closed"!==o.connectionState||(this.isStarted?this.reconnect(A):t(new Error(`connection is ${o.connectionState}`))),"connected"===o.connectionState&&(this.logSelectedCandidate(),e())},o.ontrack=A=>this.onTrack(A),o.addTransceiver("audio",{direction:"recvonly"}),o.addTransceiver("video",{direction:"recvonly"}),this._log.info("createOffer"),o.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1}).then(A=>(A.sdp=kn(A.sdp),this._log.info("setOffer"),o.setLocalDescription(A))).then(()=>{const e={sessionId:Ln(),streamurl:A,clientinfo:this.core.environment.getOSString(),localsdp:o.localDescription};return this.exchangeSDP(A,e)}).then(A=>(this._log.info("setAnswer"),o.setRemoteDescription(A))).catch(t)}catch(i){t(i)}this.connectionTimeoutId=setTimeout(()=>t(new Error("connection timeout")),1e4)})}async exchangeSDP(A,e){let t,i,o;try{this._log.info("exchangeSDP");const n=nr(A);if(!n)throw new Error("streamDomain is empty");const{signalDomain:r,cached:s}=await this.fetchSignalDomain(n);if(!r)throw new Error("signalDomain is empty");{this._log.info("try exchangeSDP signalDomain:",r,s);const A=await this.doExchangeSDP(`https://${r}`,e,3);t=A.url,i=A.remoteSdp,o=A.svrSig}}catch(n){this._log.warn("exchangeSDP failed, fallback",n);const A=await this.core.utils.promiseAny(Xn.map(A=>this.doExchangeSDP(`https://${A}`,e,3)));t=A.url,i=A.remoteSdp,o=A.svrSig}return this.streamURL=A,this.signalURL=t,this.svrSig=o,i}async reconnect(A){if(!this.isReconnecting){this.isReconnecting=!0;try{this._log.warn("start reconnect"),await this.connect(A),this._log.warn("reconnect success")}catch(e){this._log.error("reconnect error",e)}finally{this.isReconnecting=!1}}}async logSelectedCandidate(){if(!this.peerConnection)return;const A=await this.peerConnection.getStats();for(const[e,t]of A)if(this.core.rtcDectection.isSelectedCandidatePair(t)){const e=A.get(t.localCandidateId),i=A.get(t.remoteCandidateId);e&&this._log.info(`local candidate: ${e.candidateType} ${e.protocol}:${e.ip||e.address}:${e.port} ${e.networkType||""} ${e.relayProtocol?`relayProtocol:${e.relayProtocol} url: ${e.url}`:""}`),i&&this._log.info(`remote candidate: ${i.candidateType} ${i.protocol}:${i.ip||i.address}:${i.port}`);break}}async doExchangeSDP(A,e,t){const i=`${A}/webrtc/v1/pullstream`,o=await tr(i,e,{timeout:t}),{errcode:n,errmsg:r,remotesdp:s,svrsig:a}=o;if(0!==n){const A=new Error(`errCode:${n}, errMsg:${r}`);throw A.name="RequestSignalError",A}return{url:A,remoteSdp:s,svrSig:a}}createEncodedStreams(A){var e;if(this.enableSEI&&this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED)try{if(this._log.warn("enableSEI",this.enableSEI),!this.insertableStreamsAbortMap.has(A)){const t=A.createEncodedStreams(),i=new AbortController,o={abortController:i,enqueue:e=>"audio"===A.track.kind?e:this.decodeVideoFrame(e)};t.readable.pipeThrough(new TransformStream({transform:(A,e)=>{const t=o.enqueue(A);t&&e.enqueue(t)}})).pipeTo(t.writable,i).catch(A=>{"destroy"!==A&&this._log.warn(A)}),null==(e=this.insertableStreamsAbortMap.get(A))||e.abort("destroy"),this.insertableStreamsAbortMap.set(A,i)}}catch(t){this._log.warn(`createEncodedStreams ${A.track.kind} failed`,t)}}initReceiverTransform(A,e){this.peerConnection&&this.enableSEI&&this.scriptTransformWorker&&!A.transform&&(A.transform=new RTCRtpScriptTransform(this.scriptTransformWorker,{isReceiver:!0,isAudio:e,userId:"",streamType:this.core.enums.RemoteStreamType.Main}))}initScriptTransformWorker(){const{room:A,rtcDectection:e,createScriptTransformWorker:t,trtc:i,TRTC:o}=this.core;!this.enableSEI||e.IS_INSERTABLE_STREAM_SUPPORTED||this.scriptTransformWorker||e.IS_SCRIPT_TRANSFORM_SUPPORTED&&(this._log.info("initScriptTransformWorker"),this.scriptTransformWorker=t({videoEncodePipeline:A.videoManager.encodePipeline,videoDecodePipeline:A.videoManager.decodePipeline,audioEncodePipeline:A.audioManager.encodePipeline,audioDecodePipeline:A.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=A=>{var e,t;"sei"===A.data.type&&(null==(t=null==(e=this.callback)?void 0:e.onSEIMessage)||t.call(e,{data:A.data.data,seiPayloadType:A.data.seiPayloadType}))},this.scriptTransformWorker.onerror=A=>{this._log.error("scriptTransformWorker error: ",A.message)})}decodeVideoFrame(A){if(!this.core.room.videoManager)return A;for(const e of this.core.room.videoManager.decodePipeline)if(e&&!(A=e({frame:A})))return;return A}async fetchStopStream(){if(this.streamURL&&this.svrSig&&this.signalURL)try{const A=`${this.signalURL}/webrtc/v1/stopstream`,e=await tr(A,{streamurl:this.streamURL,svrsig:this.svrSig},{timeout:3}),{errcode:t,errmsg:i}=e;if(0!==t)throw new Error(`errCode:${t}, errmsg:${i}`);return e}catch(A){this._log.error("fetchStopStream error",A)}}onTrack(A){const{track:e}=A;this.createEncodedStreams(A.receiver),this.initReceiverTransform(A.receiver,"audio"===e.kind),"audio"===e.kind?this.player.setAudioTrack(e):this.player.setVideoTrack(e)}async update(A){const{view:e,volume:t,muted:i,fillMode:o,action:n,fullScreen:r,pictureInPicture:s}=A;this.player.setMuted(i),this.player.setVolume(t),this.player.setFillMode(o),e&&this.player.videoPlayer.setContainer(this.core.utils.isString(e)?document.getElementById(e):e),"pause"===n?this.player.pause():"resume"===n&&this.player.resume(),this.core.utils.isBoolean(r)&&(r?await this.player.enterFullscreen():await this.player.exitFullscreen()),this.core.utils.isBoolean(s)&&(s?await this.player.enterPictureInPicture():await this.player.exitPictureInPicture())}async stop(){this.isStopped=!0,this.player.stop(),this.peerConnection&&(clearTimeout(this.connectionTimeoutId),this.peerConnection.close(),this.peerConnection.getReceivers().forEach(A=>this.insertableStreamsAbortMap.delete(A)),delete this.peerConnection,await this.fetchStopStream(),delete this.streamURL,delete this.signalURL,delete this.svrSig),this.stat&&(this.stat.stop(),delete this.stat),this.core.room.keyPointManager.uploadKVStat(this.core.kvStatManager,this._sdkAppId)}destroy(){this.stop(),this.core.innerEmitter.off(this.core.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}onSEIMessage({room:A,nalu:e}){var t,i;A===this.core.room&&(null==(i=null==(t=this.callback)?void 0:t.onSEIMessage)||i.call(t,{data:e.seiPayload.buffer,seiPayloadType:e.seiPayloadType}))}async fetchSignalDomain(A,e=ir[0]){const t=`https://${e}/signal_query`;try{const e=window.localStorage.getItem(or);if(e){const t=JSON.parse(e);if(t[A].expire-(new Date).getTime()>0)return{signalDomain:t[A].signal,cached:!0}}const o=await tr(t,{domain:A,requestid:Ln(16),client_type:"Web",client_info:window.navigator.userAgent}),{errcode:n,data:r}=o;if(0===n){const{signal_domain:e,cache_time:t}=r;let o={};const n=window.localStorage.getItem(or);n&&(o=JSON.parse(n)),o[A]={signal:e,expire:(new Date).getTime()+1e3*t};try{window.localStorage.setItem(or,JSON.stringify(o))}catch(i){}return{signalDomain:e,cached:!1}}throw new Error(`errCode:${n}`)}catch(o){return this._log.error("fetchSignalDomain error",o),ir[1]&&e!==ir[1]?this.fetchSignalDomain(A,ir[1]):{signalDomain:"",cached:!1}}}};Nn($n,"Name","LEBPlayer"),Tn([function({settings:A={retries:5,timeout:2e3},onError:e,onRetrying:t,onRetryFailed:i}){return function(o,n,r){const s=Fn({retryFunction:r.value,settings:A,onError({error:A,retry:t,reject:i,retryFuncArgs:r}){var s;e?e.call(this,A,()=>{var e;(null==(e=On.get(o))?void 0:e.has(n))?t():i(A)},i,r):(null==(s=On.get(o))?void 0:s.has(n))?t():i(A)},onRetrying(A,e){var i;Un(t)&&t.call(this,A,e),(null==(i=On.get(o))?void 0:i.has(n))&&(On.get(o).get(n).stopRetry=e)},onRetryFailed:i});return r.value=function(...A){const e=On.get(o);return e?e.set(n,{args:A}):On.set(o,new Map([[n,{args:A}]])),s.apply(this,A).finally(()=>{var A;return null==(A=On.get(o))?void 0:A.delete(n)})},r}}({settings:{retries:1/0,timeout:2e3},onRetrying(A){var e;if(this._log.warn(`retry connect ${A}`),A>=3&&(null==(e=this.callback)?void 0:e.onError)&&!this.isFireWallErrorEmitted){const{RtcError:A,ErrorCode:e,ErrorCodeDictionary:t}=this.core.errorModule;this.isFireWallErrorEmitted=!0,this.callback.onError(new A({code:e.OPERATION_FAILED,extraCode:t.FIREWALL_RESTRICTION,message:"firewall restriction"}))}},onError(A,e,t,i){var o;if(this._log.warn("connect failed",A),this.peerConnection&&(this.peerConnection.close(),delete this.peerConnection),!this.isStopped&&(null==(o=A.message||A)?void 0:o.includes("connection")))e();else{const{RtcError:e,ErrorCode:i}=this.core.errorModule;t(new e({code:i.UNKNOWN_ERROR,message:A.message}))}}})],$n.prototype,"connect",1),Tn([function({fnName:A,callback:e,validateArgs:t=!0}){return function(i,o,n){const r=n.value;return n.value=function(...o){var n,s;if(null==(n=On.get(i))?void 0:n.has(A)){const{stopRetry:n,args:r}=On.get(i).get(A);let a=!0;if(t)for(const A of r)if(!o.find(e=>e===A)){a=!1;break}a&&(e&&e.apply(this,o),n&&n(),null==(s=On.get(i))||s.delete(A))}return r.apply(this,o)},n}}({fnName:"connect"})],$n.prototype,"stop",1);var Ar,er=$n,tr=async(A,e,t={})=>{const{timeout:i=10}=t;let o,n=0,r={};window.AbortController&&(o=new window.AbortController,r={signal:o.signal},n=window.setTimeout(()=>o.abort(),1e3*i));const s=await fetch(A,((A,e)=>{for(var t in e||(e={}))Mn.call(e,t)&&_n(A,t,e[t]);if(wn)for(var t of wn(e))Rn.call(e,t)&&_n(A,t,e[t]);return A})({body:JSON.stringify(e),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},r));if(n&&window.clearTimeout(n),200!==s.status)throw new Error(`Network Error, status code:${s.status}`);return s.json()},ir=["webrtc-signal-scheduler.tlivesource.com","bak-webrtc-signal-scheduler.tlivesource.com"],or="LEB_PLAYER_STORAGE_KEY",nr=A=>{const e=/^(?:webrtc:\/\/)([0-9.\-A-Za-z_]+)(?:\/)(?:[0-9.\-A-Za-z_=]+)(?:\/)(?:[^?#]*)(?:\?*)(?:[^?#]*)/.exec(A);return e?e[1]:""},rr=Object.defineProperty,sr=(A,e,t)=>{return n=t,(o="symbol"!=typeof e?e+"":e)in(i=A)?rr(i,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[o]=n;var i,o,n},ar=(Ar="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(A={}){var e,t,i=A;i.ready=new Promise((A,i)=>{e=A,t=i});var o=Object.assign({},i),n="";"undefined"!=typeof document&&document.currentScript&&(n=document.currentScript.src),Ar&&(n=Ar),n=0!==n.indexOf("blob:")?n.substr(0,n.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var r,s=i.print||console.log.bind(console),a=i.printErr||console.error.bind(console);Object.assign(i,o),o=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(r=i.wasmBinary),"object"!=typeof WebAssembly&&v("no native wasm support detected");var g,c,l,I,u,E,d,h,C=!1,B=[],Q=[],p=[];function f(A){B.unshift(A)}function m(A){p.unshift(A)}var y=0,D=null;function v(A){i.onAbort&&i.onAbort(A),a(A="Aborted("+A+")"),C=!0,A+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(A);throw t(e),e}var w,S,M="data:application/octet-stream;base64,",R=A=>A.startsWith(M);function _(A){return Promise.resolve().then(()=>function(A){if(A==w&&r)return new Uint8Array(r);var e=function(A){if(R(A))return function(A){for(var e=atob(A),t=new Uint8Array(e.length),i=0;i{for(;A.length>0;)A.shift()(i)};function N(A){this.excPtr=A,this.ptr=A-24,this.set_type=function(A){E[this.ptr+4>>2]=A},this.get_type=function(){return E[this.ptr+4>>2]},this.set_destructor=function(A){E[this.ptr+8>>2]=A},this.get_destructor=function(){return E[this.ptr+8>>2]},this.set_caught=function(A){A=A?1:0,g[this.ptr+12|0]=A},this.get_caught=function(){return 0!=g[this.ptr+12|0]},this.set_rethrown=function(A){A=A?1:0,g[this.ptr+13|0]=A},this.get_rethrown=function(){return 0!=g[this.ptr+13|0]},this.init=function(A,e){this.set_adjusted_ptr(0),this.set_type(A),this.set_destructor(e)},this.set_adjusted_ptr=function(A){E[this.ptr+16>>2]=A},this.get_adjusted_ptr=function(){return E[this.ptr+16>>2]},this.get_exception_ptr=function(){if(ie(this.get_type()))return E[this.excPtr>>2];var A=this.get_adjusted_ptr();return 0!==A?A:this.excPtr}}i.noExitRuntime;var b,G,k,L=A=>{for(var e="",t=A;c[t];)e+=b[c[t++]];return e},U={},F={},O={},x=A=>{throw new G(A)},P=A=>{throw new k(A)},Y=(A,e,t)=>{function i(e){var i=t(e);i.length!==A.length&&P("Mismatched type converter count");for(var o=0;o{F.hasOwnProperty(A)?o[e]=F[A]:(n.push(A),U.hasOwnProperty(A)||(U[A]=[]),U[A].push(()=>{o[e]=F[A],++r===n.length&&i(o)}))}),0===n.length&&i(o)};function J(A,e,t={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(A,e,t={}){var i=e.name;if(A||x(`type "${i}" must have a positive integer typeid pointer`),F.hasOwnProperty(A)){if(t.ignoreDuplicateRegistrations)return;x(`Cannot register type '${i}' twice`)}if(F[A]=e,delete O[A],U.hasOwnProperty(A)){var o=U[A];delete U[A],o.forEach(A=>A())}}(A,e,t)}var H,q=A=>{x(A.$$.ptrType.registeredClass.name+" instance already deleted")},V=!1,j=A=>{},K=A=>{var e;A.count.value-=1,0===A.count.value&&((e=A).smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr))},W=(A,e,t)=>{if(e===t)return A;if(void 0===t.baseClass)return null;var i=W(A,e,t.baseClass);return null===i?null:t.downcast(i)},z={},Z=[],X=()=>{for(;Z.length;){var A=Z.pop();A.$$.deleteScheduled=!1,A.delete()}},$={},AA=(A,e)=>(e.ptrType&&e.ptr||P("makeClassHandle requires ptr and ptrType"),!!e.smartPtrType!=!!e.smartPtr&&P("Both smartPtrType and smartPtr must be specified"),e.count={value:1},eA(Object.create(A,{$$:{value:e}}))),eA=A=>"undefined"==typeof FinalizationRegistry?(eA=A=>A,A):(V=new FinalizationRegistry(A=>{K(A.$$)}),j=A=>V.unregister(A),(eA=A=>{var e=A.$$;if(e.smartPtr){var t={$$:e};V.register(A,t,A)}return A})(A));function tA(){}var iA=(A,e)=>Object.defineProperty(e,"name",{value:A}),oA=(A,e,t)=>{if(void 0===A[e].overloadTable){var i=A[e];A[e]=function(){return A[e].overloadTable.hasOwnProperty(arguments.length)||x(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${A[e].overloadTable})!`),A[e].overloadTable[arguments.length].apply(this,arguments)},A[e].overloadTable=[],A[e].overloadTable[i.argCount]=i}};function nA(A,e,t,i,o,n,r,s){this.name=A,this.constructor=e,this.instancePrototype=t,this.rawDestructor=i,this.baseClass=o,this.getActualType=n,this.upcast=r,this.downcast=s,this.pureVirtualFunctions=[]}var rA=(A,e,t)=>{for(;e!==t;)e.upcast||x(`Expected null or instance of ${t.name}, got an instance of ${e.name}`),A=e.upcast(A),e=e.baseClass;return A};function sA(A,e){if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),0;e.$$||x(`Cannot pass "${TA(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=e.$$.ptrType.registeredClass;return rA(e.$$.ptr,t,this.registeredClass)}function aA(A,e){var t;if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),null!==A&&A.push(this.rawDestructor,t),t):0;e.$$||x(`Cannot pass "${TA(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&x(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var i=e.$$.ptrType.registeredClass;if(t=rA(e.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===e.$$.smartPtr&&x("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?t=e.$$.smartPtr:x(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)t=e.$$.smartPtr;else{var o=e.clone();t=this.rawShare(t,SA.toHandle(()=>o.delete())),null!==A&&A.push(this.rawDestructor,t)}break;default:x("Unsupporting sharing policy")}return t}function gA(A,e){if(null===e)return this.isReference&&x(`null is not a valid ${this.name}`),0;e.$$||x(`Cannot pass "${TA(e)}" as a ${this.name}`),e.$$.ptr||x(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&x(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var t=e.$$.ptrType.registeredClass;return rA(e.$$.ptr,t,this.registeredClass)}function cA(A){return this.fromWireType(E[A>>2])}function lA(A,e,t,i,o,n,r,s,a,g,c){this.name=A,this.registeredClass=e,this.isReference=t,this.isConst=i,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=r,this.rawGetPointee=s,this.rawConstructor=a,this.rawShare=g,this.rawDestructor=c,o||void 0!==e.baseClass?this.toWireType=aA:i?(this.toWireType=sA,this.destructorFunction=null):(this.toWireType=gA,this.destructorFunction=null)}var IA,uA,EA=[],dA=A=>{var e=EA[A];return e||(A>=EA.length&&(EA.length=A+1),EA[A]=e=IA.get(A)),e},hA=(A,e,t)=>{return A.includes("j")?(o=e,n=t,r=i["dynCall_"+A],n&&n.length?r.apply(null,[o].concat(n)):r.call(null,o)):dA(e).apply(null,t);var o,n,r},CA=(A,e)=>{var t,i,o,n=(A=L(A)).includes("j")?(t=A,i=e,o=[],function(){return o.length=0,Object.assign(o,arguments),hA(t,i,o)}):dA(e);return"function"!=typeof n&&x(`unknown function pointer with signature ${A}: ${e}`),n},BA=A=>{var e=ee(A),t=L(e);return te(e),t},QA=(A,e)=>{var t=[],i={};throw e.forEach(function A(e){i[e]||F[e]||(O[e]?O[e].forEach(A):(t.push(e),i[e]=!0))}),new uA(`${A}: `+t.map(BA).join([", "]))},pA=(A,e)=>{for(var t=[],i=0;i>2]);return t},fA=A=>{for(;A.length;){var e=A.pop();A.pop()(e)}};function mA(A,e,t,i,o,n){var r=e.length;r<2&&x("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==e[1]&&null!==t,a=!1,g=1;g(A instanceof Object||x(`${t} with invalid "this": ${A}`),A instanceof e.registeredClass.constructor||x(`${t} incompatible with "this" of type ${A.constructor.name}`),A.$$.ptr||x(`cannot call emscripten binding method ${t} on deleted object`),rA(A.$$.ptr,A.$$.ptrType.registeredClass,e.registeredClass));function DA(){this.allocated=[void 0],this.freelist=[]}var vA=new DA,wA=A=>{A>=vA.reserved&&0==--vA.get(A).refcount&&vA.free(A)},SA={toValue:A=>(A||x("Cannot use deleted val. handle = "+A),vA.get(A).value),toHandle:A=>{switch(A){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return vA.allocate({refcount:1,value:A})}}};function MA(A){return this.fromWireType(u[A>>2])}var RA,_A,TA=A=>{if(null===A)return"null";var e=typeof A;return"object"===e||"array"===e||"function"===e?A.toString():""+A},NA=(A,e)=>{switch(e){case 4:return function(A){return this.fromWireType(d[A>>2])};case 8:return function(A){return this.fromWireType(h[A>>3])};default:throw new TypeError(`invalid float width (${e}): ${A}`)}},bA=(A,e,t)=>{switch(e){case 1:return t?A=>g[0|A]:A=>c[0|A];case 2:return t?A=>l[A>>1]:A=>I[A>>1];case 4:return t?A=>u[A>>2]:A=>E[A>>2];default:throw new TypeError(`invalid integer width (${e}): ${A}`)}},GA="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,kA=(A,e,t)=>{for(var i=e+t,o=e;A[o]&&!(o>=i);)++o;if(o-e>16&&A.buffer&&GA)return GA.decode(A.subarray(e,o));for(var n="";e>10,56320|1023&g)}}else n+=String.fromCharCode((31&r)<<6|s)}else n+=String.fromCharCode(r)}return n},LA=(A,e)=>A?kA(c,A,e):"",UA="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,FA=(A,e)=>{for(var t=A,i=t>>1,o=i+e/2;!(i>=o)&&I[i];)++i;if((t=i<<1)-A>32&&UA)return UA.decode(c.subarray(A,t));for(var n="",r=0;!(r>=e/2);++r){var s=l[A+2*r>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},OA=(A,e,t)=>{if(void 0===t&&(t=2147483647),t<2)return 0;for(var i=e,o=(t-=2)<2*A.length?t/2:A.length,n=0;n>1]=r,e+=2}return l[e>>1]=0,e-i},xA=A=>2*A.length,PA=(A,e)=>{for(var t=0,i="";!(t>=e/4);){var o=u[A+4*t>>2];if(0==o)break;if(++t,o>=65536){var n=o-65536;i+=String.fromCharCode(55296|n>>10,56320|1023&n)}else i+=String.fromCharCode(o)}return i},YA=(A,e,t)=>{if(void 0===t&&(t=2147483647),t<4)return 0;for(var i=e,o=i+t-4,n=0;n=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&A.charCodeAt(++n)),u[e>>2]=r,(e+=4)+4>o)break}return u[e>>2]=0,e-i},JA=A=>{for(var e=0,t=0;t=55296&&i<=57343&&++t,e+=4}return e},HA=(A,e)=>{var t=F[A];return void 0===t&&x(e+" has unknown type "+BA(A)),t},qA=(A,e,t)=>{var i=[],o=A.toWireType(i,t);return i.length&&(E[e>>2]=SA.toHandle(i)),o},VA={},jA=[],KA=Reflect.construct,WA=[null,[],[]],zA=(A,e)=>{var t=WA[A];0===e||10===e?((1===A?s:a)(kA(t,0)),t.length=0):t.push(e)};(()=>{for(var A=new Array(256),e=0;e<256;++e)A[e]=String.fromCharCode(e);b=A})(),G=i.BindingError=class extends Error{constructor(A){super(A),this.name="BindingError"}},k=i.InternalError=class extends Error{constructor(A){super(A),this.name="InternalError"}},Object.assign(tA.prototype,{isAliasOf(A){if(!(this instanceof tA))return!1;if(!(A instanceof tA))return!1;var e=this.$$.ptrType.registeredClass,t=this.$$.ptr;A.$$=A.$$;for(var i=A.$$.ptrType.registeredClass,o=A.$$.ptr;e.baseClass;)t=e.upcast(t),e=e.baseClass;for(;i.baseClass;)o=i.upcast(o),i=i.baseClass;return e===i&&t===o},clone(){if(this.$$.ptr||q(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var A,e=eA(Object.create(Object.getPrototypeOf(this),{$$:{value:(A=this.$$,{count:A.count,deleteScheduled:A.deleteScheduled,preservePointerOnDelete:A.preservePointerOnDelete,ptr:A.ptr,ptrType:A.ptrType,smartPtr:A.smartPtr,smartPtrType:A.smartPtrType})}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||q(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&x("Object already scheduled for deletion"),j(this),K(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||q(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&x("Object already scheduled for deletion"),Z.push(this),1===Z.length&&H&&H(X),this.$$.deleteScheduled=!0,this}}),i.getInheritedInstanceCount=()=>Object.keys($).length,i.getLiveInheritedInstances=()=>{var A=[];for(var e in $)$.hasOwnProperty(e)&&A.push($[e]);return A},i.flushPendingDeletes=X,i.setDelayFunction=A=>{H=A,Z.length&&H&&H(X)},Object.assign(lA.prototype,{getPointee(A){return this.rawGetPointee&&(A=this.rawGetPointee(A)),A},destructor(A){this.rawDestructor&&this.rawDestructor(A)},argPackAdvance:8,readValueFromPointer:cA,deleteObject(A){null!==A&&A.delete()},fromWireType:function(A){var e=this.getPointee(A);if(!e)return this.destructor(A),null;var t,i,o=(t=this.registeredClass,i=((A,e)=>{for(void 0===e&&x("ptr should not be undefined");A.baseClass;)e=A.upcast(e),A=A.baseClass;return e})(t,i=e),$[i]);if(void 0!==o){if(0===o.$$.count.value)return o.$$.ptr=e,o.$$.smartPtr=A,o.clone();var n=o.clone();return this.destructor(A),n}function r(){return this.isSmartPointer?AA(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:A}):AA(this.registeredClass.instancePrototype,{ptrType:this,ptr:A})}var s,a=this.registeredClass.getActualType(e),g=z[a];if(!g)return r.call(this);s=this.isConst?g.constPointerType:g.pointerType;var c=W(e,this.registeredClass,s.registeredClass);return null===c?r.call(this):this.isSmartPointer?AA(s.registeredClass.instancePrototype,{ptrType:s,ptr:c,smartPtrType:this,smartPtr:A}):AA(s.registeredClass.instancePrototype,{ptrType:s,ptr:c})}}),uA=i.UnboundTypeError=(RA=Error,(_A=iA("UnboundTypeError",function(A){this.name="UnboundTypeError",this.message=A;var e=new Error(A).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(RA.prototype),_A.prototype.constructor=_A,_A.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},_A),Object.assign(DA.prototype,{get(A){return this.allocated[A]},has(A){return void 0!==this.allocated[A]},allocate(A){var e=this.freelist.pop()||this.allocated.length;return this.allocated[e]=A,e},free(A){this.allocated[A]=void 0,this.freelist.push(A)}}),vA.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),vA.reserved=vA.allocated.length,i.count_emval_handles=()=>{for(var A=0,e=vA.reserved;e{throw new N(A).init(e,t),A},q:(A,e,t,i,o)=>{},u:(A,e,t,i)=>{J(A,{name:e=L(e),fromWireType:function(A){return!!A},toWireType:function(A,e){return e?t:i},argPackAdvance:8,readValueFromPointer:function(A){return this.fromWireType(c[A])},destructorFunction:null})},y:(A,e,t,o,n,r,s,a,g,c,l,I,u)=>{l=L(l),r=CA(n,r),a&&(a=CA(s,a)),c&&(c=CA(g,c)),u=CA(I,u);var E,d,h,C=(A=>{if(void 0===A)return"_unknown";var e=(A=A.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return e>=48&&e<=57?`_${A}`:A})(l);E=C,d=function(){QA(`Cannot construct ${l} due to unbound types`,[o])},i.hasOwnProperty(E)?(x(`Cannot register public name '${E}' twice`),oA(i,E,E),i.hasOwnProperty(h)&&x(`Cannot register multiple overloads of a function with the same number of arguments (${h})!`),i[E].overloadTable[h]=d):i[E]=d,Y([A,e,t],o?[o]:[],function(e){var t,n;e=e[0],n=o?(t=e.registeredClass).instancePrototype:tA.prototype;var s=iA(l,function(){if(Object.getPrototypeOf(this)!==g)throw new G("Use 'new' to construct "+l);if(void 0===I.constructor_body)throw new G(l+" has no accessible constructor");var A=I.constructor_body[arguments.length];if(void 0===A)throw new G(`Tried to invoke ctor of ${l} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(I.constructor_body).toString()}) parameters instead!`);return A.apply(this,arguments)}),g=Object.create(n,{constructor:{value:s}});s.prototype=g;var I=new nA(l,s,g,u,t,r,a,c);I.baseClass&&(void 0===I.baseClass.__derivedClasses&&(I.baseClass.__derivedClasses=[]),I.baseClass.__derivedClasses.push(I));var E=new lA(l,I,!0,!1,!1),d=new lA(l+"*",I,!1,!1,!1),h=new lA(l+" const*",I,!1,!0,!1);return z[A]={pointerType:d,constPointerType:h},((A,e,t)=>{i.hasOwnProperty(A)||P("Replacing nonexistant public symbol"),i[A].overloadTable,i[A]=e,i[A].argCount=t})(C,s),[E,d,h]})},x:(A,e,t,i,o,n)=>{var r=pA(e,t);o=CA(i,o),Y([],[A],function(A){var t=`constructor ${(A=A[0]).name}`;if(void 0===A.registeredClass.constructor_body&&(A.registeredClass.constructor_body=[]),void 0!==A.registeredClass.constructor_body[e-1])throw new G(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${A.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return A.registeredClass.constructor_body[e-1]=()=>{QA(`Cannot construct ${A.name} due to unbound types`,r)},Y([],r,i=>(i.splice(1,0,null),A.registeredClass.constructor_body[e-1]=mA(t,i,null,o,n),[])),[]})},i:(A,e,t,i,o,n,r,s,a)=>{var g=pA(t,i);e=(A=>{const e=(A=A.trim()).indexOf("(");return-1!==e?A.substr(0,e):A})(e=L(e)),n=CA(o,n),Y([],[A],function(A){var i=`${(A=A[0]).name}.${e}`;function o(){QA(`Cannot call ${i} due to unbound types`,g)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&A.registeredClass.pureVirtualFunctions.push(e);var a=A.registeredClass.instancePrototype,c=a[e];return void 0===c||void 0===c.overloadTable&&c.className!==A.name&&c.argCount===t-2?(o.argCount=t-2,o.className=A.name,a[e]=o):(oA(a,e,i),a[e].overloadTable[t-2]=o),Y([],g,function(o){var s=mA(i,o,A,n,r);return void 0===a[e].overloadTable?(s.argCount=t-2,a[e]=s):a[e].overloadTable[t-2]=s,[]}),[]})},k:(A,e,t,i,o,n,r,s,a,g)=>{e=L(e),o=CA(i,o),Y([],[A],function(A){var i=`${(A=A[0]).name}.${e}`,c={get(){QA(`Cannot access ${i} due to unbound types`,[t,r])},enumerable:!0,configurable:!0};return c.set=a?()=>QA(`Cannot access ${i} due to unbound types`,[t,r]):A=>x(i+" is a read-only property"),Object.defineProperty(A.registeredClass.instancePrototype,e,c),Y([],a?[t,r]:[t],function(t){var r=t[0],c={get(){var e=yA(this,A,i+" getter");return r.fromWireType(o(n,e))},enumerable:!0};if(a){a=CA(s,a);var l=t[1];c.set=function(e){var t=yA(this,A,i+" setter"),o=[];a(g,t,l.toWireType(o,e)),fA(o)}}return Object.defineProperty(A.registeredClass.instancePrototype,e,c),[]}),[]})},t:(A,e)=>{J(A,{name:e=L(e),fromWireType:A=>{var e=SA.toValue(A);return wA(A),e},toWireType:(A,e)=>SA.toHandle(e),argPackAdvance:8,readValueFromPointer:MA,destructorFunction:null})},p:(A,e,t)=>{J(A,{name:e=L(e),fromWireType:A=>A,toWireType:(A,e)=>e,argPackAdvance:8,readValueFromPointer:NA(e,t),destructorFunction:null})},g:(A,e,t,i,o)=>{e=L(e);var n=A=>A;if(0===i){var r=32-8*t;n=A=>A<>>r}var s=e.includes("unsigned");J(A,{name:e,fromWireType:n,toWireType:s?function(A,e){return this.name,e>>>0}:function(A,e){return this.name,e},argPackAdvance:8,readValueFromPointer:bA(e,t,0!==i),destructorFunction:null})},a:(A,e,t)=>{var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function o(A){var e=E[A>>2],t=E[A+4>>2];return new i(g.buffer,t,e)}J(A,{name:t=L(t),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},o:(A,e)=>{var t="std::string"===(e=L(e));J(A,{name:e,fromWireType(A){var e,i=E[A>>2],o=A+4;if(t)for(var n=o,r=0;r<=i;++r){var s=o+r;if(r==i||0==c[s]){var a=LA(n,s-n);void 0===e?e=a:(e+=String.fromCharCode(0),e+=a),n=s+1}}else{var g=new Array(i);for(r=0;r{for(var e=0,t=0;t=55296&&i<=57343?(e+=4,++t):e+=3}return e})(e):e.length;var n=Ae(4+i+1),r=n+4;if(E[n>>2]=i,t&&o)((A,e,t,i)=>{if(!(i>0))return 0;for(var o=t+i-1,n=0;n=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&A.charCodeAt(++n)),r<=127){if(t>=o)break;e[t++]=r}else if(r<=2047){if(t+1>=o)break;e[t++]=192|r>>6,e[t++]=128|63&r}else if(r<=65535){if(t+2>=o)break;e[t++]=224|r>>12,e[t++]=128|r>>6&63,e[t++]=128|63&r}else{if(t+3>=o)break;e[t++]=240|r>>18,e[t++]=128|r>>12&63,e[t++]=128|r>>6&63,e[t++]=128|63&r}}e[t]=0})(e,c,r,i+1);else if(o)for(var s=0;s255&&(te(r),x("String has UTF-16 code units that do not fit in 8 bits")),c[r+s]=a}else for(s=0;s{var i,o,n,r,s;t=L(t),2===e?(i=FA,o=OA,r=xA,n=()=>I,s=1):4===e&&(i=PA,o=YA,r=JA,n=()=>E,s=2),J(A,{name:t,fromWireType:A=>{for(var t,o=E[A>>2],r=n(),a=A+4,g=0;g<=o;++g){var c=A+4+g*e;if(g==o||0==r[c>>s]){var l=i(a,c-a);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),a=c+e}}return te(A),t},toWireType:(A,i)=>{"string"!=typeof i&&x(`Cannot pass non-string to C++ string type ${t}`);var n=r(i),a=Ae(4+n+e);return E[a>>2]=n>>s,o(i,a+4,n+e),null!==A&&A.push(te,a),a},argPackAdvance:8,readValueFromPointer:MA,destructorFunction(A){te(A)}})},v:(A,e)=>{J(A,{isVoid:!0,name:e=L(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(A,e)=>{}})},j:(A,e,t)=>(A=SA.toValue(A),e=HA(e,"emval::as"),qA(e,t,A)),e:(A,e,t,i,o)=>{var n,r;return(A=jA[A])(e=SA.toValue(e),e[t=void 0===(r=VA[n=t])?L(n):r],i,o)},d:wA,f:(A,e,t)=>{var i=((A,e)=>{for(var t=new Array(A),i=0;i>2],"parameter "+i);return t})(A,e),o=i.shift();A--;var n,r,s=new Array(A),a=`methodCaller<(${i.map(A=>A.name).join(", ")}) => ${o.name}>`;return n=iA(a,(e,n,r,a)=>{for(var g=0,c=0;c{A>4&&(vA.get(A).refcount+=1)},b:A=>{var e=SA.toValue(A);fA(e),wA(A)},h:(A,e)=>{var t=(A=HA(A,"_emval_take_value")).readValueFromPointer(e);return SA.toHandle(t)},m:()=>{v("")},s:(A,e,t)=>c.copyWithin(A,e,e+t),r:A=>{c.length,v("OOM")},n:(A,e,t,i)=>{for(var o=0,n=0;n>2],s=E[e+4>>2];e+=8;for(var a=0;a>2]=o,0}},$A=function(){var A,e,o,n,r,s={a:XA};function C(A,e){var t,o;return t=($A=A.exports).z.buffer,i.HEAP8=g=new Int8Array(t),i.HEAP16=l=new Int16Array(t),i.HEAPU8=c=new Uint8Array(t),i.HEAPU16=I=new Uint16Array(t),i.HEAP32=u=new Int32Array(t),i.HEAPU32=E=new Uint32Array(t),i.HEAPF32=d=new Float32Array(t),i.HEAPF64=h=new Float64Array(t),IA=$A.C,o=$A.A,Q.unshift(o),function(){if(y--,i.monitorRunDependencies&&i.monitorRunDependencies(y),0==y&&D){var A=D;D=null,A()}}(),$A}if(y++,i.monitorRunDependencies&&i.monitorRunDependencies(y),i.instantiateWasm)try{return i.instantiateWasm(s,C)}catch(B){a(`Module.instantiateWasm callback failed with error: ${B}`),t(B)}return(A=w,e=s,o=function(A){C(A.instance)},n=e,r=o,_(A).then(A=>WebAssembly.instantiate(A,n)).then(A=>A).then(r,A=>{a(`failed to asynchronously prepare wasm: ${A}`),v(A)})).catch(t),{}}(),Ae=A=>(Ae=$A.B)(A),ee=A=>(ee=$A.D)(A),te=A=>(te=$A.E)(A),ie=A=>(ie=$A.F)(A);function oe(){function A(){ZA||(ZA=!0,i.calledRun=!0,C||(T(Q),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)m(i.postRun.shift());T(p)}()))}y>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)f(i.preRun.shift());T(B)}(),y>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),A()},1)):A()))}if(i.dynCall_jiji=(A,e,t,o,n)=>(i.dynCall_jiji=$A.G)(A,e,t,o,n),i._vertexShaderSource=10688,D=function A(){ZA||oe(),ZA||(D=A)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return oe(),A.ready}),gr=ar,cr=0,lr=class A{constructor(A){this.core=A,sr(this,"seq"),sr(this,"_core"),sr(this,"log"),sr(this,"beautyParams"),cr+=1,this.seq=cr,this._core=A,this.log=A.log.createChild({id:`${this.getAlias()}${cr}`}),this.log.info("created")}getName(){return A.Name}getAlias(){return"bb"}getValidateRule(A){switch(A){case"start":case"update":return function(A){return{name:"BasicBeautyOptions",type:"object",required:!0,allowEmpty:!1,properties:{beauty:{required:!1,type:"number"},brightness:{required:!1,type:"number"},ruddy:{required:!1,type:"number"}},validate(e,t,i,o){const{RtcError:n,ErrorCode:r,ErrorCodeDictionary:s}=A.errorModule;if(A.utils.isOverseaSdkAppId(e.sdkAppId))throw new n({code:r.INVALID_OPERATION,extraCode:s.INVALID_OPERATION,message:"This feature is not yet available in your country or region. If you have any questions, you can go to the community for consultation: https://zhiliao.qq.com/s/cWSPGIIM62CC/c3TPGIIM62CQ"})}}}(this._core);case"stop":return this._core,{name:"StopBasicBeautyOptions",required:!1}}}getGroup(){return"bb"}async start(A){this._core.room.videoManager.Wasm||(this._core.room.videoManager.Wasm=await gr()),this._core.room.videoManager.renderMode="webgl";const e=this._core.utils.isUndefined(A.beauty)?.5:A.beauty,t=this._core.utils.isUndefined(A.brightness)?.5:A.brightness,i=this._core.utils.isUndefined(A.ruddy)?.5:A.ruddy;return this._core.room.videoManager.setBeautyParams({beauty:e,brightness:t,ruddy:i})}async update(A){const e=this._core.utils.isUndefined(A.beauty)?.5:A.beauty,t=this._core.utils.isUndefined(A.brightness)?.5:A.brightness,i=this._core.utils.isUndefined(A.ruddy)?.5:A.ruddy;return this._core.room.videoManager.setBeautyParams({beauty:e,brightness:t,ruddy:i})}async stop(){return this._core.room.videoManager.renderMode="auto",this._core.room.videoManager.stopBeauty()}destroy(){this._core.room.videoManager.renderMode="auto"}};sr(lr,"Name","BasicBeauty");var Ir,ur,Er,dr=lr;A.TRTCMediaMixingErrorCode=void 0,(Ir=A.TRTCMediaMixingErrorCode||(A.TRTCMediaMixingErrorCode={}))[Ir.Success=0]="Success",Ir[Ir.Error=-1]="Error",Ir[Ir.InvalidParams=-2]="InvalidParams",Ir[Ir.NotFoundSource=-3]="NotFoundSource",Ir[Ir.ImageSourceLoadFailed=-4]="ImageSourceLoadFailed",Ir[Ir.CameraNotAuthorized=-5]="CameraNotAuthorized",Ir[Ir.CameraIsOccupied=-6]="CameraIsOccupied",Ir[Ir.CameraDisconnected=-7]="CameraDisconnected",A.TRTCMediaSourceType=void 0,(ur=A.TRTCMediaSourceType||(A.TRTCMediaSourceType={}))[ur.kCamera=0]="kCamera",ur[ur.kScreen=1]="kScreen",ur[ur.kImage=2]="kImage",ur[ur.kPhoneMirror=4]="kPhoneMirror",ur[ur.kText=5]="kText",ur[ur.kVideo=6]="kVideo",A.TRTCMediaMixingEvent=void 0,(Er=A.TRTCMediaMixingEvent||(A.TRTCMediaMixingEvent={})).onSourceSelected="onSourceSelected",Er.onSourceMoved="onSourceMoved",Er.onSourceResized="onSourceResized",Er.onRightButtonClicked="onRightButtonClicked",Er.onError="onError",Er.onSourcePlugged="onSourcePlugged",Er.onSourceConnected="onSourceConnected",Er.onSourceDisconnected="onSourceDisconnected",Er.onSourceUnplugged="onSourceUnplugged",Er.onMediaSourceSizeChanged="onMediaSourceSizeChanged";var hr,Cr=function(){function A(A,e){if(this.logRegion="tc",this.loggerManager=A,e){var t=e.sdkAppId,i=e.userId,o=e.seq;this.seq=o,A&&(this.logger=A.createLogger({id:"".concat(this.logRegion).concat(o),userId:i,sdkAppId:t}))}else this.logger=A;this.logger||(this.logger={debug:function(A){console.debug(A)},info:function(A){console.info(A)},warn:function(A){console.warn(A)},error:function(A){console.error(A)}})}return A.prototype.getLogMessage=function(A){var e=this;return A.map(function(A){return e.getStringifyMessage(A)}).join(" ")},A.prototype.getStringifyMessage=function(A){var e=this;if("object"!=typeof A)return A;if(A instanceof HTMLElement)return"".concat(A.tagName.toLocaleLowerCase(),"#").concat(A.id);if(A instanceof Array){var t=[];return Object.keys(A).forEach(function(i){return t[i]=e.getStringifyMessage(A[i])}),JSON.stringify(t)}if(A instanceof Object){var i={};return Object.keys(A).forEach(function(t){return i[t]=e.getStringifyMessage(A[t])}),JSON.stringify(i)}return A},A.prototype.update=function(A){var e=A.userId,t=A.sdkAppId;this.loggerManager&&this.loggerManager.createLogger&&(this.logger=this.loggerManager.createLogger({id:"".concat(this.logRegion).concat(this.seq),userId:e,sdkAppId:t}))},A.prototype.log=function(){for(var A=[],e=0;e=5||Math.abs(t)>=5?(document.removeEventListener("mousemove",this.onMouseMove5px,!1),document.removeEventListener("mouseup",this.onMouseUp5px,!1),document.addEventListener("mousemove",this.onMouseMove,!1),document.addEventListener("mouseup",this.onMouseUp,!1)):Br.debug("".concat(this.logPrefix,"on Movable mouse move less than 5px"))},A.prototype.onMouseUp5px=function(){document.removeEventListener("mousemove",this.onMouseMove5px,!1),document.removeEventListener("mouseup",this.onMouseUp5px,!1)},A.prototype.onMouseMove=function(A){if(this.movable&&this.container){var e=A.screenX-this.moveStartOfLeft,t=A.screenY-this.moveStartOfTop,i=this.originLeft+e,o=this.originTop+t,n=this.movable.offsetWidth,r=this.movable.offsetHeight,s=this.container.offsetWidth,a=this.container.offsetHeight;this.options.canExceedContainer||(i<0?i=0:i>s-n&&(i=s-n),o<0?o=0:o>a-r&&(o=a-r)),!this.options.calcPositionOnly&&this.movable&&(this.movable.style.left="".concat(i,"px"),this.movable.style.top="".concat(o,"px")),this.emit("move",i,o)}else Br.debug("".concat(this.logPrefix,"onMouseMove error:No 'movable' and 'container'."))},A.prototype.onMouseUp=function(){document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),this.originLeft=0,this.originTop=0,this.moveStartOfLeft=0,this.moveStartOfTop=0},A.prototype.on=function(A,e){var t=this.callbacksMap.get(A);t?t.push(e):this.callbacksMap.set(A,[e])},A.prototype.off=function(A,e){var t=this.callbacksMap.get(A);t&&(t=t.filter(function(A){return A!=e}),this.callbacksMap.set(A,t))},A.prototype.emit=function(A){for(var e=[],t=1;tthis.container.offsetWidth-this.originLeft&&(n=this.container.offsetWidth-this.originLeft,r=this.originHeight*n/this.originWidth,o=this.originTop+this.originHeight-r));break;case mr:o=(e=this._resizeTop(A)).top,r=e.height,n=this._resizeRight(A),this.options.keepRatio&&(n/this.originWidththis.container.offsetHeight-this.originTop&&(r=this.container.offsetHeight-this.originTop,n=this.originWidth*r/this.originHeight,i=this.originLeft+this.originWidth-n));break;case Dr:n=this._resizeRight(A),this.options.keepRatio&&((r=n*this.originHeight/this.originWidth)<20?n=(r=20)*this.originWidth/this.originHeight:!this.options.canExceedContainer&&r>this.container.offsetHeight-this.originTop&&(n=(r=this.container.offsetHeight-this.originTop)*this.originWidth/this.originHeight));break;case vr:r=this._resizeBottom(A),i=(e=this._resizeLeft(A)).left,n=e.width,this.options.keepRatio&&(n/this.originWidththis.container.offsetWidth-this.originLeft&&(r=(n=this.container.offsetWidth-this.originLeft)*this.originHeight/this.originWidth));break;case Sr:r=this._resizeBottom(A),n=this._resizeRight(A),this.options.keepRatio&&(n/this.originWidththis.originLeft+this.originWidth-20&&(t=this.originLeft+this.originWidth-20,i=20),{left:t,width:i}},A.prototype._resizeTop=function(A){var e=A.screenY-this.resizeStartTop,t=this.originTop+e,i=this.originHeight-e;return!this.options.canExceedContainer&&t<0?(t=0,i=this.originHeight+this.originTop):t>this.originTop+this.originHeight-20&&(t=this.originTop+this.originHeight-20,i=20),{top:t,height:i}},A.prototype._resizeRight=function(A){if(!this.container)return Br.debug("".concat(this.logPrefix,"_resizeRight error. No container:"),this.container),0;var e=A.screenX-this.resizeStartLeft,t=this.originWidth+e;return t<20?t=20:!this.options.canExceedContainer&&t>this.container.offsetWidth-this.originLeft&&(t=this.container.offsetWidth-this.originLeft),t},A.prototype._resizeBottom=function(A){if(!this.container)return Br.debug("".concat(this.logPrefix,"_resizeBottom error. No container:"),this.container),0;var e=A.screenY-this.resizeStartTop,t=this.originHeight+e;return t<20?t=20:!this.options.canExceedContainer&&t>this.container.offsetHeight-this.originTop&&(t=this.container.offsetHeight-this.originTop),t},A.prototype.mouseup=function(){document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),this.currentAnchor=null,this.resizeStartLeft=0,this.resizeStartTop=0,this.originLeft=0,this.originTop=0,this.originWidth=0,this.originHeight=0},A.prototype.on=function(A,e){var t=this.callbacksMap.get(A);t?t.push(e):this.callbacksMap.set(A,[e])},A.prototype.off=function(A,e){var t=this.callbacksMap.get(A);t&&(t=t.filter(function(A){return A!=e}),this.callbacksMap.set(A,t))},A.prototype.emit=function(A){for(var e=[],t=1;ti?t:i,this.previewWidth=this.mixingVideoWidth*this.previewScale,this.previewHeight=this.mixingVideoHeight*this.previewScale,this.previewLeft=(A-this.previewWidth)/2,this.previewTop=(e-this.previewHeight)/2}else console.debug("".concat(this.logPrefix,"calcPreviewScale failed, no HTML element to display"))},e.prototype.updateOverlay=function(){if(this.moveAndResizeOverlay){var A=void 0,e=void 0,t=void 0,i=void 0;if(this.selectedMediaIndex>=0){var o={left:this.mediaList[this.selectedMediaIndex].rect.left*this.previewScale,top:this.mediaList[this.selectedMediaIndex].rect.top*this.previewScale,right:this.mediaList[this.selectedMediaIndex].rect.right*this.previewScale,bottom:this.mediaList[this.selectedMediaIndex].rect.bottom*this.previewScale};A="".concat(o.left+this.previewLeft,"px"),e="".concat(o.top+this.previewTop,"px"),t="".concat(o.right-o.left,"px"),i="".concat(o.bottom-o.top,"px"),this.moveAndResizeOverlay.style.display="block"}else A="".concat(this.previewLeft,"px"),e="".concat(this.previewTop,"px"),t="0px",i="0px",this.moveAndResizeOverlay.style.display="none";this.moveAndResizeOverlay.style.left=A,this.moveAndResizeOverlay.style.top=e,this.moveAndResizeOverlay.style.width=t,this.moveAndResizeOverlay.style.height=i}},e.prototype.onMove=function(A,e){var t;console.debug("".concat(this.logPrefix,"onMove: ").concat(A," ").concat(e));var i=this.mediaList[this.selectedMediaIndex];if(i&&this.moveAndResizeOverlay){var o={left:A-this.previewLeft,top:e-this.previewTop,right:A-this.previewLeft+this.moveAndResizeOverlay.offsetWidth,bottom:e-this.previewTop+this.moveAndResizeOverlay.offsetHeight};this.doAdsorption(o);var n={left:Math.round(o.left/this.previewScale),top:Math.round(o.top/this.previewScale),right:Math.round(o.right/this.previewScale),bottom:Math.round(o.bottom/this.previewScale)};null===(t=this.eventEmitter)||void 0===t||t.emit("onSourceMoved",r({},i),n)}else console.debug("".concat(this.logPrefix,"onMove no selected media"))},e.prototype.doAdsorption=function(A){var e=this.BOUNDARY_ADSORPTION_THRESHOLD;Math.abs(A.left)=a.rect.left&&n<=a.rect.right&&r>=a.rect.top&&r<=a.rect.bottom&&(this.clickedMediaSources.push(a),this.mediaList[this.selectedMediaIndex]&&a.id===this.mediaList[this.selectedMediaIndex].id&&(this.oldSelectedIndex=this.clickedMediaSources.length-1))}this.mousedownLeft=A.screenX,this.mousedownTop=A.screenY}this.clickedMediaSources.length>0?2===this.eventButton&&-1===this.oldSelectedIndex?(this.newSelected=this.clickedMediaSources[0],console.debug("".concat(this.logPrefix,"onContainerMousedown find clicked media source:"),this.newSelected),this.emitOnSelect(this.newSelected),this.clickedMediaSources.splice(0,this.clickedMediaSources.length)):(document.addEventListener("mousemove",this.onContainerMousemove,!1),document.addEventListener("mouseup",this.onContainerMouseup,!1)):(this.newSelected=null,console.debug("".concat(this.logPrefix,"onContainerMousedown find clicked media source:"),this.newSelected),this.emitOnSelect(null),this.mousedownLeft=null,this.mousedownTop=null,this.eventButton=null)}},e.prototype.onContainerMousemove=function(A){var e;if(A.target&&this.container&&null!==this.mousedownLeft&&null!==this.mousedownTop){var t=A.screenX-this.mousedownLeft,i=A.screenY-this.mousedownTop;(Math.abs(t)>=5||Math.abs(i)>=5)&&(this.oldSelectedIndex>=0?(console.debug("".concat(this.logPrefix,"onContainerMousemove move or resize old selected media source, clear data:"),this.clickedMediaSources,this.oldSelectedIndex),this.clickedMediaSources.splice(0,this.clickedMediaSources.length),this.oldSelectedIndex=-1):this.clickedMediaSources.length>0&&(this.newSelected=this.clickedMediaSources[0],console.debug("".concat(this.logPrefix,"onContainerMousemove find clicked media source:"),this.newSelected),this.emitOnSelect(this.newSelected),this.clickedMediaSources.splice(0,this.clickedMediaSources.length),null===(e=this.moveAndResizeOverlay)||void 0===e||e.dispatchEvent(new MouseEvent("mousedown",{screenX:this.mousedownLeft,screenY:this.mousedownTop,button:this.eventButton}))))}},e.prototype.onContainerMouseup=function(A){if(document.removeEventListener("mousemove",this.onContainerMousemove,!1),document.removeEventListener("mouseup",this.onContainerMouseup,!1),console.debug("".concat(this.logPrefix,"onContainerMouseup data:"),this.clickedMediaSources,this.oldSelectedIndex),A.target&&this.container){if(this.clickedMediaSources.length>0)if(this.oldSelectedIndex>=0){if(0===this.eventButton){var e=(this.oldSelectedIndex+1)%this.clickedMediaSources.length;this.newSelected=this.clickedMediaSources[e],console.debug("".concat(this.logPrefix,"onContainerMouseup find clicked media source:"),this.newSelected),this.emitOnSelect(this.newSelected)}}else this.newSelected=this.clickedMediaSources[0],console.debug("".concat(this.logPrefix,"onContainerMouseup find clicked media source:"),this.newSelected),this.emitOnSelect(this.newSelected)}else console.debug("".concat(this.logPrefix,"onContainerMouseup click outside of mixing video image")),this.emitOnSelect(null);this.mousedownLeft=null,this.mousedownTop=null,this.clickedMediaSources.splice(0,this.clickedMediaSources.length),this.oldSelectedIndex=-1,this.newSelected=null,this.eventButton=null},e.prototype.onRightButtonClicked=function(A){var e;console.debug("".concat(this.logPrefix,"onRightButtonClicked:"),A.target,A.currentTarget,A.buttons),A.preventDefault(),null===(e=this.eventEmitter)||void 0===e||e.emit("onRightButtonClicked",r({},this.mediaList[this.selectedMediaIndex]))},e}(),br=function(){function e(t){if(this.logPrefix="[TRTCMediaMixingManager]",this.eventEmitter=new y,this.publishParams={videoEncoderParams:{videoResolution:A.TRTCVideoResolution.TRTCVideoResolution_1280_720,resMode:A.TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,videoFps:15,videoBitrate:1800},canvasColor:0},this.mediaMixingDesigner=null,this.sourceList=[],this.trtcSourceMap=new Map,this.mixVideoTrack=null,this.selectedSource=null,this.view=null,this.screensWithSystemAudio=new Set,e.mediaMixingManager)return e.mediaMixingManager;e.mediaMixingManager=this,this.logger=t.logger,this.trtc=t.trtc,this.trtcCloud=t.trtcCloud,this.onSourceSelected=this.onSourceSelected.bind(this),this.onSourceMoved=this.onSourceMoved.bind(this),this.onSourceResized=this.onSourceResized.bind(this),this.onRightButtonClicked=this.onRightButtonClicked.bind(this)}return e.prototype.destroy=function(){return a(this,void 0,Promise,function(){var A,t,i,o,n;return g(this,function(r){switch(r.label){case 0:this.view=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.trtc.stopPlugin("VideoMixer")];case 2:return r.sent(),[3,4];case 3:return A=r.sent(),this.logger.error("".concat(this.logPrefix," destroy and stopPlugin error:"),A),[3,4];case 4:if(!(this.screensWithSystemAudio.size>0))return[3,12];r.label=5;case 5:r.trys.push([5,10,,11]),t=0,i=Array.from(this.screensWithSystemAudio),r.label=6;case 6:return te in A?Gr(A,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[e]=t,Or=(A,e)=>{for(var t in e||(e={}))Lr.call(e,t)&&Fr(A,t,e[t]);if(kr)for(var t of kr(e))Ur.call(e,t)&&Fr(A,t,e[t]);return A},xr=(A,e,t)=>Fr(A,"symbol"!=typeof e?e+"":e,t),Pr={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"},hidden:{required:!1,type:"boolean"}},Yr=(A,e=!1)=>({type:"object",required:e,properties:{canvasColor:{required:!1,type:["string",CanvasGradient,CanvasPattern]},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},frameRate:{required:!1,type:"number",notLessThanZero:!0,min:1,max:60}},validate(e,t,i){const{RtcError:o,ErrorCode:n,ErrorCodeDictionary:r}=A.errorModule;if(!e)return;const{width:s,height:a}=e;if(s&&a&&s*a>8294400)throw new o({code:n.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}),Jr=A=>({required:!1,type:["string",HTMLElement,null],validate(e,t,i){const{RtcError:o,ErrorCode:n,ErrorCodeDictionary:r}=A.errorModule;if(A.utils.isString(e)&&!document.getElementById(e))throw new o({code:n.INVALID_PARAMETER,extraCode:r.INVALID_ELEMENT_ID,fnName:i,messageParams:{key:t}})}}),Hr=(A,e=!0)=>({type:"object",required:e,properties:Or({},Pr),validate(e,t,i){const{RtcError:o,ErrorCode:n,ErrorCodeDictionary:r}=A.errorModule;if(e){if(e.fillMode&&!["contain","cover","fill"].includes(e.fillMode))throw new o({code:n.INVALID_PARAMETER,extraCode:r.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:i});if(e.rotation&&![0,90,180,270].includes(e.rotation))throw new o({code:n.INVALID_PARAMETER,extraCode:r.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:i})}}}),qr=A=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:Or({},Hr(A))}}}),Vr=A=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:Or({},Hr(A))},validate(e,t,i){const{RtcError:o,ErrorCode:n,ErrorCodeDictionary:r}=A.errorModule;if(!A.rtcDectection.isScreenCaptureApiAvailable())throw new o({code:n.ENV_NOT_SUPPORTED,fnName:i,extraCode:r.NOT_SUPPORTED_SCREEN_SHARE})}}}),jr=A=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:Or({},Hr(A))}}}),Kr=A=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:Or({},Hr(A))}}}),Wr=A=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:Or({},Hr(A))}}}),zr=0,Zr=class A{constructor(A){this.core=A,xr(this,"seq"),xr(this,"log"),xr(this,"localMixVideoTrack",null),xr(this,"systemAudioTrackList",{}),xr(this,"_mixVideoConfig"),xr(this,"onScreenShareStop"),xr(this,"eventListeners",new Map),zr+=1,this.seq=zr,this.log=A.log.createChild({id:`${this.getAlias()}${zr}`}),this.log.info("created")}getName(){return A.Name}getAlias(){return"vmix"}getValidateRule(A){switch(A){case"start":return e=this.core,{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:Or({},Jr(e)),canvasInfo:Or({},Yr(e,!0)),camera:Or({},qr(e)),screen:Or({},Vr(e)),text:Or({},jr(e)),image:Or({},Kr(e)),video:Or({},Wr(e))},validate(A,t,i,o){const{RtcError:n,ErrorCode:r,ErrorCodeDictionary:s}=e.errorModule;if(e.environment.isMobile())throw new n({code:r.ENV_NOT_SUPPORTED,message:"VideoMixer is not supported on mobile devices currently"});const{onScreenShareStop:a}=A;if(a&&!e.utils.isFunction(a))throw new n({code:r.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,fnName:i,messageParams:{key:"onScreenShareStop",value:typeof a,rule:{type:"Function"}}})}};case"update":return function(A){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:Or({},Jr(A)),canvasInfo:Or({},Yr(A)),camera:Or({},qr(A)),screen:Or({},Vr(A)),text:Or({},jr(A)),image:Or({},Kr(A)),video:Or({},Wr(A))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var e}getGroup(){return"vmix"}async start(A){this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack(this.core.room.videoManager)),this._mixVideoConfig={canvasInfo:{width:1920,height:1080}},A=this.core.utils.deepCloneBasic(A);const{view:e,onScreenShareStop:t}=A,i=await this.parseMixOptions(A);return t&&(this.onScreenShareStop=t,this._mixVideoConfig.onScreenShareStop=t),this._updatePreview({view:e,track:this.localMixVideoTrack}),this.core.utils.isUndefined(e)||(this._mixVideoConfig.view=e),await this.localMixVideoTrack.startMix(),{track:this.localMixVideoTrack._outputTrack,systemAudioTrackList:this.systemAudioTrackList,result:i}}async update(A){const{RtcError:e,ErrorCode:t}=this.core.errorModule;if(!this.localMixVideoTrack)throw new e({code:t.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});A=this.core.utils.deepCloneBasic(A);const{view:i}=A,o=await this.parseMixOptions(A);return await this._updatePreview({view:i,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig}),this.core.utils.isUndefined(i)||(this._mixVideoConfig.view=i),{track:this.localMixVideoTrack._outputTrack,systemAudioTrackList:this.systemAudioTrackList,result:o}}stop(){var A;this.eventListeners.forEach((A,e)=>{this.removeEventListeners(e)}),this.eventListeners.clear(),null==(A=this.localMixVideoTrack)||A.close(),this.localMixVideoTrack=null,Object.values(this.systemAudioTrackList).forEach(A=>A.stop()),this.systemAudioTrackList={},delete this.onScreenShareStop,delete this._mixVideoConfig}async parseMixOptions(A){const{RtcError:e,ErrorCode:t}=this.core.errorModule;if(!this.localMixVideoTrack||!this._mixVideoConfig)return{successOptions:{},failedDetails:[]};const i=[],o=Or({},A),{canvasInfo:n,camera:r,screen:s,text:a,image:g,video:c}=A;n&&this.parseCanvasOptions(n);let l=0,I=0;const u=[{key:"camera",options:r,parser:this.parseCameraOptions.bind(this)},{key:"screen",options:s,parser:this.parseScreenOptions.bind(this)},{key:"text",options:a,parser:this.parseTextOptions.bind(this)},{key:"image",options:g,parser:this.parseImageOptions.bind(this)},{key:"video",options:c,parser:this.parseVideoOptions.bind(this)}];for(const{key:E,options:d,parser:h}of u)if(d){l++;const A=await h(this.localMixVideoTrack,d,this._mixVideoConfig[E]||[]);this._mixVideoConfig[E]=A.finalOptions,o[E]=A.finalOptions,A.errors.length>0&&(i.push(...A.errors),A.errors.length===d.length&&I++)}if(I>0&&I===l)throw new e({code:t.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:i}});return{successOptions:o,failedDetails:i}}parseCanvasOptions(A){if(!this.localMixVideoTrack||!this._mixVideoConfig)return;const{canvasColor:e,width:t,height:i,frameRate:o}=A;e&&this.localMixVideoTrack.setMixBackground(e),o&&this.localMixVideoTrack.setFps(o),this.localMixVideoTrack.resizeMixCanvas(t,i),this._mixVideoConfig.canvasInfo=A}prepareSourceOptions(A,e){const t=new Set(A.map(A=>A.id));return{removeIdList:e.filter(A=>!t.has(A.id)).map(A=>A.id),preOptionsMap:new Map(e.map(A=>[A.id,A]))}}recordSourceError(A,e,t,i,o){o.push({id:A,error:e}),t.has(A)&&i.push(t.get(A))}async parseCameraOptions(A,e,t=[]){const{removeIdList:i,preOptionsMap:o}=this.prepareSourceOptions(e,t);for(const a of i)A.removeCameraSource(a);const n=[],r=[];for(const a of e)try{await this.processSingleCameraSource(A,a),n.push(a)}catch(s){this.recordSourceError(a.id,s,o,n,r)}return{finalOptions:n,errors:r}}async processSingleCameraSource(A,e){var t;const{id:i,layout:o,profile:n,useInternalTrack:r}=e;r&&((null==(t=this.core.trtc.localVideoTrack)?void 0:t.sourceTrack)?e.videoTrack=this.core.trtc.localVideoTrack.sourceTrack:e.videoTrack=this.createPlaceholderVideoTrack()),this.log.info(`videomixer camera option ${JSON.stringify(e)}`),A.inputLocalVideoTracks.has(i)?await this.updateExistingCameraSource(A,e):await this.addNewCameraSource(A,e)}async updateExistingCameraSource(A,e){var t,i;const{id:o,layout:n,profile:r}=e,s=null==(t=A.inputLocalVideoTracks.get(o))?void 0:t.mediaTrack;await this.updateCameraProfile(e);const a=null==(i=A.inputLocalVideoTracks.get(o))?void 0:i.mediaTrack,g=this.resolveVideoProfile(r);a!==s?A.updateCameraSource(o,n,a,g):A.updateCameraSource(o,n,null,g)}async addNewCameraSource(A,e){const{id:t,layout:i,useInternalTrack:o}=e,n=await this.captureCamera(e);if(this.removeEventListeners(t),o){const e=e=>{var i,o;if(null==(i=e.track)?void 0:i.isScreen)return;this.log.info("videomixer camera LOCAL_TRACK_CAPTURE_SUCCESS");const n=A.inputLocalVideoTracks.get(t);n&&(null==(o=e.track)?void 0:o.sourceTrack)&&n.setInputMediaStreamTrack(e.track.sourceTrack)};this.core.innerEmitter.on("102",e),this.eventListeners.has(t)||this.eventListeners.set(t,{}),this.eventListeners.get(t).captureSuccess=()=>{this.core.innerEmitter.off("102",e)}}try{A.addCameraSource(t,n,i)}catch(r){throw n.close(),r}}resolveVideoProfile(A){if(!this.core.utils.isUndefined(A))return this.core.utils.isString(A)?this.core.constants.videoProfileMap[A]:A}async parseScreenOptions(A,e,t=[]){const{removeIdList:i,preOptionsMap:o}=this.prepareSourceOptions(e,t);for(const a of i)A.removeScreenSource(a),this.removeSystemAudioTrack(a);const n=[],r=[];for(const a of e)try{await this.processSingleScreenSource(A,a,o),n.push(a)}catch(s){this.recordSourceError(a.id,s,o,n,r)}return{finalOptions:n,errors:r}}async processSingleScreenSource(A,e,t){var i,o;const{id:n,layout:r,useInternalTrack:s}=e;s&&((null==(i=this.core.trtc.localScreenTrack)?void 0:i.mediaTrack)?(e.videoTrack=this.core.trtc.localScreenTrack.mediaTrack,(null==(o=this.core.trtc.localScreenAudioTrack)?void 0:o.mediaTrack)&&(e.audioTrack=this.core.trtc.localScreenAudioTrack.mediaTrack),delete e.captureElement,delete e.preferDisplaySurface,delete e.systemAudio):e.videoTrack=this.createPlaceholderVideoTrack()),this.log.info(`videomixer screen option ${JSON.stringify(e)}`);const a=t.get(n),g=A.inputLocalScreenTracks.has(n),c=!(null==a?void 0:a.systemAudio)&&e.systemAudio;g&&!c?this.updateExistingScreenSource(A,n,r,a,e):await this.addNewScreenSource(A,e,a)}updateExistingScreenSource(A,e,t,i,o){A.updateScreenSource(e,t),(null==i?void 0:i.systemAudio)&&!o.systemAudio&&this.removeSystemAudioTrack(e)}async addNewScreenSource(A,e,t){const{id:i,useInternalTrack:o}=e,n=await this.captureScreen(e);if(this.removeEventListeners(i),o){const e=e=>{var t,o,n;if(!(null==(t=e.track)?void 0:t.isScreen))return;this.log.info("videomixer screen LOCAL_TRACK_CAPTURE_SUCCESS");const r=A.inputLocalScreenTracks.get(i);r&&(null==(o=e.track)?void 0:o.mediaTrack)&&r.setInputMediaStreamTrack(e.track.mediaTrack),this.systemAudioTrackList[i]&&(null==(n=e.track)?void 0:n.mediaTrack)&&(this.systemAudioTrackList[i]=e.track.mediaTrack)};this.core.innerEmitter.on("102",e),this.eventListeners.has(i)||this.eventListeners.set(i,{}),this.eventListeners.get(i).captureSuccess=()=>{this.core.innerEmitter.off("102",e)}}!(null==t?void 0:t.systemAudio)&&e.systemAudio&&A.inputLocalScreenTracks.has(e.id)&&A.removeScreenSource(e.id);try{A.addScreenSource(e.id,n,e.layout)}catch(r){throw n.close(),r}}async parseTextOptions(A,e,t=[]){const{removeIdList:i,preOptionsMap:o}=this.prepareSourceOptions(e,t);for(const a of i)A.removeTextSource(a);const n=[],r=[];for(const a of e)try{o.has(a.id)?A.updateTextSource(a):A.addTextSource(a),n.push(a)}catch(s){this.recordSourceError(a.id,s,o,n,r)}return{finalOptions:n,errors:r}}async parseImageOptions(A,e,t=[]){const{removeIdList:i,preOptionsMap:o}=this.prepareSourceOptions(e,t);for(const a of i)A.removeImageSource(a);const n=[],r=[];for(const a of e)try{await this.processSingleImageSource(A,a,o),n.push(a)}catch(s){this.recordSourceError(a.id,s,o,n,r)}return{finalOptions:n,errors:r}}async processSingleImageSource(A,e,t){const{id:i,url:o,layout:n}=e,r=t.get(i);if(r){let e;r.url!==o&&(e=await this.core.utils.loadImage(o)),A.updateImageSource(i,n,e)}else{const e=await this.core.utils.loadImage(o);A.addImageSource(i,e,n)}}async parseVideoOptions(A,e,t=[]){const{removeIdList:i,preOptionsMap:o}=this.prepareSourceOptions(e,t);for(const a of i)A.removeVideoSource(a);const n=[],r=[];for(const a of e)try{await this.processSingleVideoSource(A,a,o),n.push(a)}catch(s){this.recordSourceError(a.id,s,o,n,r)}return{finalOptions:n,errors:r}}async processSingleVideoSource(A,e,t){const{id:i,url:o,layout:n}=e,r=t.get(i);if(r){let e;r.url!==o&&(e=await this.core.utils.loadVideo(o)),A.updateVideoSource(i,n,e)}else{const e=await this.core.utils.loadVideo(o);A.addVideoSource(i,e,n)}}createPlaceholderVideoTrack(){const A=document.createElement("canvas");A.width=640,A.height=480;const e=A.getContext("2d");return e&&(e.fillStyle="black",e.fillRect(0,0,A.width,A.height)),A.captureStream(1).getVideoTracks()[0]}removeEventListeners(A){const e=this.eventListeners.get(A);e&&(e.inputMediaTrackChanged&&e.inputMediaTrackChanged(),e.captureSuccess&&e.captureSuccess(),this.eventListeners.delete(A))}async captureCamera(A){const{id:e,cameraId:t,videoTrack:i,profile:o}=A,n=new this.core.LocalVideoTrack;n.log.id+=`-${e}`;const r={};if(t?r.deviceId=t:this.core.utils.isUndefined(i)||(r.customSource=i),!this.core.utils.isUndefined(o)){const A=this.resolveVideoProfile(o);A&&n.setProfile(A)}return await n.capture(r),n}async updateCameraProfile(A){var e;const{id:t,cameraId:i,videoTrack:o,profile:n}=A,r=null==(e=this.localMixVideoTrack)?void 0:e.inputLocalVideoTracks.get(t);if(r&&(i?await r.switchDevice(i):this.core.utils.isUndefined(o)||await r.setInputMediaStreamTrack(o),!this.core.utils.isUndefined(n))){const A=this.resolveVideoProfile(n);A&&r.setProfile(A),i&&r.isNeedToSwitchDevice(i)||await r.applyProfile()}}async captureScreen(A){const{id:e,profile:t,captureElement:i,preferDisplaySurface:o,systemAudio:n,videoTrack:r,audioTrack:s}=A,a=new this.core.LocalScreenTrack;a.log.id+=`-${e}`;const g={captureElement:i,preferDisplaySurface:o,systemAudio:n,videoTrack:r,audioTrack:s};if(!this.core.utils.isUndefined(t))if(this.core.utils.isString(t)){const A=this.core.constants.screenProfileMap[t];A&&a.setProfile(A)}else a.setProfile(t);const c=await a.capture(g);return n&&c.getAudioTracks().length>0?(this.systemAudioTrackList[e]=c.getAudioTracks()[0],this.log.info(`${e} system audio track captured`)):this.removeSystemAudioTrack(e),a.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,()=>{this.handleScreenShareEnded(e)}),a}handleScreenShareEnded(A){var e,t,i;null==(e=this.localMixVideoTrack)||e.removeScreenSource(A),(null==(t=this._mixVideoConfig)?void 0:t.screen)&&(this._mixVideoConfig.screen=this._mixVideoConfig.screen.filter(e=>e.id!==A)),null==(i=this.onScreenShareStop)||i.call(this,A)}async _updatePreview({view:A,track:e,prevConfig:t}){if(this.core.utils.isUndefined(A)&&(null==t?void 0:t.view)){const A=this.core.utils.getViewListFromView(t.view);A.length>0&&await e.play(A)}else if(!this.core.utils.isUndefined(A)){const t=this.core.utils.getViewListFromView(A);t.length>0?await e.play(t):e.stop()}}removeSystemAudioTrack(A){const e=this.systemAudioTrackList[A];e&&(e.stop(),this.log.info(`${A} system audio track stop`),delete this.systemAudioTrackList[A])}};xr(Zr,"Name","VideoMixer");var Xr=Zr,$r=function(){function A(){this.isRunning=!1,this.queue=[]}return Object.defineProperty(A.prototype,"length",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"lastQueueItem",{get:function(){return 0===this.length?null:this.queue[this.length-1]},enumerable:!1,configurable:!0}),A.prototype.push=function(A,e,t,i){var o,n;void 0===e&&(e=!1),void 0===t&&(t=!1);var s=r(r({},A),{functionName:i}),a=new Promise(function(A,e){s.resolve=A,s.reject=e});if(s.promise=a,e)this.length<=1?this.queue.push(s):null===(n=null===(o=this.lastQueueItem)||void 0===o?void 0:o.promise)||void 0===n||n.then(s.resolve,s.reject);else{if(t&&i&&this.queue.length>1){var g=[];this.queue=this.queue.filter(function(A,e){return 0===e||A.functionName!==i||(g.push(A),!1)}),g.forEach(function(A){A.reject(new Error("aborted by newer task"))})}this.queue.push(s)}return this.isRunning||this.callNext(),a},A.prototype.shift=function(){return this.queue.shift()},A.prototype.callNext=function(){var A=this;if(!this.isRunning&&0!==this.length){var e=this.queue[0],t=e.fn,i=e.args,o=e.context,n=e.resolve,r=e.reject;this.isRunning=!0,t.apply(o,i).then(n,r).finally(function(){A.isRunning=!1,A.shift(),A.callNext()})}},A}(),As=new WeakMap,es=new WeakMap,ts=new WeakMap;function is(A,e){return void 0===e&&(e={}),function(t,i,o){var n=o.value,r=e.deduplicate,s=void 0!==r&&r;return o.value=function(){for(var e=[],t=0;t0&&clearTimeout(ss),ss=window.setTimeout(function(){ns.apply(A,e),ss=-1},rs)}));var cs=new Map,ls=function(e){function i(t){void 0===t&&(t={});var n=e.call(this)||this;n._version="",n._frameWorkType=30,n._component=0,n._language=0,n._networkProxy={},n._localView=null,n._autoRecvAudio=!0,n._autoRecvVideo=!1,n._localTestView=null,n._isVideoPublish=!0,n._localRenderParams={rotation:A.TRTCVideoRotation.TRTCVideoRotation0,fillMode:A.TRTCVideoFillMode.TRTCVideoFillMode_Fill,mirrorType:A.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto},n._encoderMirror=void 0,n._videoProfile={},n._isAudioPublish=!0,n._audioMuteType=!1,n._audioProfile=o.default.TYPE.AUDIO_PROFILE_STANDARD,n._captureVolume=100,n._playoutVolume=100,n._isSharingScreen=!1,n._remoteStreamConfig=new Map,n._remoteStreamMap=new Map,n._cameraList=[],n._microphoneList=[],n._speakerList=[],n._currentCamera={},n._currentMicrophone={},n._currentSpeaker={},n._currentCameraId="",n._currentMicrophoneId="",n._currentSpeakerId="",n._screenShareParams={option:{}},n._isMobile=Fo,n._isFrontCamera=!0,n._cameraVideoTrack=null,n._smallStreamVideoProfile=void 0,n._qosPreference=void 0,n._defaultVideoProfile={width:640,height:480,frameRate:15,bitrate:900},n._defaultScreenProfile={width:1920,height:1080,frameRate:15,bitrate:1500},n._defaultSmallVideoProfile={width:160,height:120,frameRate:15,bitrate:200},n._isVirtualBackground=!1,n._isTestVirtualBackground=!1,n._isBeautyEnabled=!1,n._isTestBeautyEnabled=!1,n._remoteStatisticsUserIdList=[],n._hasJoinedRoom=!1,n._isExitingRoom=!1,n._version=fn;var r=t.frameWorkType,s=void 0===r?30:r,a=t.component,g=void 0===a?0:a,c=t.language,l=void 0===c?0:c;return n._frameWorkType=s,n._component=g,n._language=l,n._trtc=o.default.create({enableSEI:i.enableSEI,assetsPath:i.assetsPath,enableVolumeControlInIOS:!0,plugins:[Xr,er]}),n._testTrtc=o.default.create(),n._log=o.default._loggerManager,n.logger=new Cr(os,{seq:gs++}),n._echoCancellation=void 0,n._noiseSuppression=void 0,n._autoGainControl=void 0,n._addTRTCEvents(),n.handleDeviceChange=n.handleDeviceChange.bind(n),cs.set(n,{fn:n.handleDeviceChange,self:n}),n}var c;return function(A,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=A}n(A,e),A.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}(i,e),i.getPlugin=function(A){return"VirtualBackground"===A?t.VirtualBackground:"BasicBeauty"===A?dr:"VideoMixer"===A?Xr:null},i.getTRTCShareInstance=function(A){return i.shareInstance||(i.shareInstance=new i(A)),i.shareInstance},i.setLogLevel=function(e,t){var i,n=((i={})[A.TRTCLogLevel.TRTCLogLevelVerbose]=0,i[A.TRTCLogLevel.TRTCLogLevelDebug]=1,i[A.TRTCLogLevel.TRTCLogLevelInfo]=2,i[A.TRTCLogLevel.TRTCLogLevelWarn]=3,i[A.TRTCLogLevel.TRTCLogLevelError]=4,i[A.TRTCLogLevel.TRTCLogLevelFatal]=4,i[A.TRTCLogLevel.TRTCLogLevelNone]=5,i),r=n[e];uA(r)&&(r=n[A.TRTCLogLevel.TRTCLogLevelInfo]);var s=!dA(t)||t;o.default.setLogLevel(r,s)},i.destroyTRTCShareInstance=function(){i.shareInstance&&(i.shareInstance._destroy(),i.shareInstance=null),Array.from(i.subCloudMap.keys()).forEach(function(A){return A._destroy()})},i.callExperimentalAPI=function(A){console.log("static ".concat(as,".callExperimentalAPI"),A);var e=hA(A);if(e!==A){var t=e.api,o=e.params;if(t&&o)try{switch(t){case"enableSEI":i.enableSEI=o.enable;break;case"setAssetsPath":i.assetsPath=o.assetsPath}}catch(n){throw n}}},i.prototype.createSubCloud=function(){if(this!==i.shareInstance)return null;var A=new i;return this._inheritPropertiesToSubCloud(A),this._inheritEventsToSubCloud(A),i.subCloudMap.set(A,A),A},i.prototype.destroy=function(){this!==i.shareInstance?(i.subCloudMap.get(this)&&i.subCloudMap.delete(this),this._destroy()):i.destroyTRTCShareInstance()},i.prototype._destroy=function(){cs.delete(this),this.removeAllListeners(),this._trtc.off("*"),this._trtc.destroy(),this._trtc=null,this._testTrtc.off("*"),this._testTrtc.destroy(),this._testTrtc=null},i.prototype.getSDKVersion=function(){return this._version||""},i.prototype.enterRoom=function(A,e){return a(this,void 0,Promise,function(){var t,i,o,n,s,a,c,l,I,u,E,d,h,C,B,Q,p,f;return g(this,function(g){switch(g.label){case 0:if(t=A.sdkAppId,i=A.userId,o=A.userSig,n=A.roomId,s=A.strRoomId,a=A.role,c=A.privateMapKey,l=A.businessInfo,I=A.enableAutoPlayDialog,u=A.proxy,E=A.streamId,d=A.userDefineRecordId,this.logger.update({sdkAppId:t,userId:i}),this.logger.info("".concat(as,".enterRoom with params: "),A,e),u&&(this._networkProxy=u),!(t&&i&&o))return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),h={sdkAppId:t,userId:i,userSig:o,roomId:n,strRoomId:s,role:gA[a],scene:cA[e],autoReceiveAudio:this._autoRecvAudio,autoReceiveVideo:this._autoRecvVideo,frameWorkType:this._frameWorkType,component:this._component,language:this._language},h=c?r(r({},h),{privateMapKey:c}):h,h=l?r(r({},h),{businessInfo:l}):h,C=I||this._enableAutoPlayDialog,h=dA(C)?r(r({},h),{enableAutoPlayDialog:C}):h,h=this._networkProxy?r(r({},h),{proxy:this._networkProxy}):h,h=E?r(r({},h),{streamId:E}):h,h=d?r(r({},h),{userDefineRecordId:d}):h,h=void 0!==this._latencyLevel?r(r({},h),{latencyLevel:this._latencyLevel}):h,B=IA(),[4,this._trtc.enterRoom(h)];case 2:return g.sent(),this._hasJoinedRoom=!0,Q=IA()-B,this.emit("onEnterRoom",Q),[3,4];case 3:return p=g.sent(),f=(f=this._transformTRTCErrorCode(p,"enterRoom"))<0?f:-1,this.emit("onEnterRoom",f),this._callFunctionErrorManage(p,"enterRoom"),[3,4];case 4:return[3,6];case 5:this._emitError(Qn),g.label=6;case 6:return[2]}})})},i.prototype.exitRoom=function(){return a(this,void 0,Promise,function(){var A;return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.logger.info("".concat(as,".exitRoom")),this._isExitingRoom=!0,this._isSharingScreen&&this.stopScreenShare(),this.resetTRTCCloud(),this.stopLocalPreview(),this.stopLocalAudio(),[4,this._trtc.exitRoom()];case 1:return e.sent(),this._hasJoinedRoom=!1,this._isExitingRoom=!1,this._isVideoPublish=!0,this._isAudioPublish=!0,this.emit("onExitRoom",on.exitRoom),[3,3];case 2:return A=e.sent(),this._callFunctionErrorManage(A,"exitRoom"),[3,3];case 3:return[2]}})})},i.prototype.switchRole=function(A){return a(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:this.logger.info("".concat(as,".switchRole with param: "),A),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._trtc.switchRole(gA[A])];case 2:return t.sent(),this.emit("onSwitchRole",0,"switch role success, role = ".concat(A,", ").concat(gA[A])),[3,4];case 3:return e=t.sent(),this.emit("onSwitchRole",null==e?void 0:e.getCode(),e.message),[3,4];case 4:return[2]}})})},i.prototype.setDefaultStreamRecvMode=function(A,e){return a(this,void 0,void 0,function(){return g(this,function(t){return this.logger.info("".concat(as,".setDefaultStreamRecvMode with param: "),{autoRecvAudio:A,autoRecvVideo:e}),dA(A)&&(this._autoRecvAudio=A),dA(e)&&(this._autoRecvVideo=e),[2]})})},i.prototype.resetTRTCCloud=function(){this._setIsAudioPublish(!0),this._setAudioMuteType(!1),this._echoCancellation=void 0,this._noiseSuppression=void 0,this._autoGainControl=void 0,this._isVirtualBackground=!1,this._isTestVirtualBackground=!1,this._remoteStatisticsUserIdList=[],this._resetBeautyStyle()},i.prototype._updateLocalVideo=function(){return a(this,void 0,void 0,function(){var A;return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this._trtc.updateLocalVideo(this._generateLocalVideoData())];case 1:return e.sent(),[3,3];case 2:if((A=e.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT)throw A;return[3,3];case 3:return[2]}})})},i.prototype._updateLocalTestVideo=function(){return a(this,void 0,void 0,function(){var A;return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this._testTrtc.updateLocalVideo(this._generateLocalTestVideoData())];case 1:return e.sent(),[3,3];case 2:if((A=e.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT)throw A;return[3,3];case 3:return[2]}})})},i.prototype._updateLocalScreen=function(){return a(this,void 0,void 0,function(){var A;return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this._trtc.updateScreenShare(this._getScreenShareParams())];case 1:return e.sent(),[3,3];case 2:if((A=e.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT)throw A;return[3,3];case 3:return[2]}})})},i.prototype._updateRemoteVideo=function(A,e){return a(this,void 0,void 0,function(){var t;return g(this,function(i){switch(i.label){case 0:if(!this._hasJoinedRoom||this._isExitingRoom)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._trtc.updateRemoteVideo(this._generateRemoteVideoData(A,e))];case 2:return i.sent(),[3,4];case 3:if((t=i.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT)throw t;return[3,4];case 4:return[2]}})})},i.prototype.startLocalPreview=function(){for(var A=[],e=0;e9)throw new Error("beautyLevel must be between 0 and 9");if(o<0||o>9)throw new Error("whitenessLevel must be between 0 and 9");if(n<0||n>9)throw new Error("ruddinessLevel must be between 0 and 9");g.label=1;case 1:return g.trys.push([1,8,,9]),s=o/9,a=n/9,0==(t=i/9)&&0===s&&0===a?[4,A.stopPlugin(rA)]:[3,3];case 2:return g.sent(),r?this._isTestBeautyEnabled=!1:this._isBeautyEnabled=!1,[3,7];case 3:return c={beauty:t,brightness:s,ruddy:a},e?[3,5]:[4,A.startPlugin(rA,c)];case 4:return g.sent(),r?this._isTestBeautyEnabled=!0:this._isBeautyEnabled=!0,[3,7];case 5:return[4,A.updatePlugin(rA,c)];case 6:g.sent(),g.label=7;case 7:return[3,9];case 8:throw l=g.sent(),r?this.logger.error("".concat(as,".").concat("setTestBeautyStyle"," fail: "),l):this.logger.error("".concat(as,".").concat("setBeautyStyle"," fail: "),l),l;case 9:return[2]}})})},i.prototype._resetBeautyStyle=function(){return a(this,void 0,void 0,function(){return g(this,function(A){switch(A.label){case 0:return this._isBeautyEnabled?[4,this._trtc.stopPlugin(rA)]:[3,2];case 1:A.sent(),this._isBeautyEnabled=!1,A.label=2;case 2:return this._isTestBeautyEnabled?[4,this._testTrtc.stopPlugin(rA)]:[3,4];case 3:A.sent(),this._isTestBeautyEnabled=!1,A.label=4;case 4:return[2]}})})},i.prototype.getMicDevicesList=function(){return a(this,void 0,Promise,function(){var A,e,t;return g(this,function(i){switch(i.label){case 0:this.logger.info("".concat(as,".getMicDevicesList")),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,o.default.getMicrophoneList()];case 2:return A=i.sent(),e=A.map(function(A){return r(r({},A),{deviceName:A.label})}),this._microphoneList=A,"{}"!==JSON.stringify(this._currentMicrophone)?[3,4]:(this._currentMicrophone=this.getDefaultDeviceInfo(A),this._currentMicrophoneId=this._currentMicrophone.deviceId,[4,this.setCurrentMicDevice(this._currentMicrophoneId)]);case 3:i.sent(),i.label=4;case 4:return[2,Promise.resolve(e)];case 5:return t=i.sent(),this._callFunctionErrorManage(t,"getMicDevicesList"),[2,Promise.resolve([])];case 6:return[2]}})})},i.prototype.setCurrentMicDevice=function(A){var e;return a(this,void 0,Promise,function(){var t;return g(this,function(i){switch(i.label){case 0:this.logger.info("".concat(as,".setCurrentMicDevice with params: "),{micId:A}),i.label=1;case 1:return i.trys.push([1,4,,5]),A?(this._setCurrentMicrophoneId(A),[4,this._updateLocalAudio()]):[2,!1];case 2:return i.sent(),[4,this._updateLocalTestAudio()];case 3:return i.sent(),this._currentMicrophone=this._microphoneList.find(function(e){return e.deviceId===A})||{},[3,5];case 4:throw t=i.sent(),this._setCurrentMicrophoneId(null===(e=this._currentMicrophone)||void 0===e?void 0:e.deviceId),this._callFunctionErrorManage(t,"setCurrentMicDevice"),t;case 5:return[2]}})})},i.prototype.getCurrentMicDevice=function(){this.logger.info("".concat(as,".getCurrentMicDevice"));var A=this._currentMicrophone,e=A.deviceId,t=A.label,i=A.kind,o=A.groupId;return new w(e,t,i,t,o)},i.prototype.getSpeakerDevicesList=function(){return a(this,void 0,Promise,function(){var A,e,t;return g(this,function(i){switch(i.label){case 0:this.logger.info("".concat(as,".getSpeakerDevicesList")),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,o.default.getSpeakerList()];case 2:return A=i.sent(),e=A.map(function(A){return r(r({},A),{deviceName:A.label})}),this._speakerList=A,"{}"!==JSON.stringify(this._currentSpeaker)?[3,4]:(this._currentSpeaker=this.getDefaultDeviceInfo(A),this._currentSpeakerId=this._currentSpeaker.deviceId,[4,this.setCurrentSpeakerDevice(this._currentSpeakerId)]);case 3:i.sent(),i.label=4;case 4:return[2,Promise.resolve(e)];case 5:return t=i.sent(),this._callFunctionErrorManage(t,"getSpeakerDevicesList"),[2,Promise.resolve([])];case 6:return[2]}})})},i.prototype.setCurrentSpeakerDevice=function(A){return a(this,void 0,Promise,function(){var e;return g(this,function(t){switch(t.label){case 0:this.logger.info("".concat(as,".setCurrentSpeakerDevice with params: "),{speakerId:A}),t.label=1;case 1:return t.trys.push([1,3,,4]),A?[4,o.default.setCurrentSpeaker(A)]:[2,!1];case 2:return t.sent(),this._setCurrentSpeakerId(A),this._currentSpeaker=this._speakerList.find(function(e){return e.deviceId===A})||{},[3,4];case 3:throw e=t.sent(),this._callFunctionErrorManage(e,"setCurrentSpeakerDevice"),e;case 4:return[2]}})})},i.prototype.getCurrentSpeakerDevice=function(){this.logger.info("".concat(as,".getCurrentSpeakerDevice"));var A=this._currentSpeaker,e=A.deviceId,t=A.label,i=A.kind,o=A.groupId;return new w(e,t,i,t,o)},i.prototype.startCameraDeviceTest=function(A){return a(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:if(this.logger.info("".concat(as,".startCameraDeviceTest with params: "),A),!A)return[2];this._setLocalTestView(A),t.label=1;case 1:return t.trys.push([1,3,,7]),[4,this._testTrtc.startLocalVideo(this._generateLocalTestVideoData())];case 2:return t.sent(),[3,7];case 3:return(e=t.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT?[3,5]:[4,this._updateLocalTestVideo()];case 4:return t.sent(),[3,6];case 5:throw this._callFunctionErrorManage(e,"startCameraDeviceTest"),e;case 6:return[3,7];case 7:return[2]}})})},i.prototype.stopCameraDeviceTest=function(){return a(this,void 0,void 0,function(){return g(this,function(A){switch(A.label){case 0:return this.logger.info("".concat(as,".stopCameraDeviceTest")),this._setLocalTestView(null),[4,this._testTrtc.stopLocalVideo()];case 1:return A.sent(),[2]}})})},i.prototype.startMicDeviceTest=function(A){return a(this,void 0,void 0,function(){var e,t=this;return g(this,function(i){switch(i.label){case 0:this.logger.info("".concat(as,".startMicDeviceTest with params: "),A),i.label=1;case 1:return i.trys.push([1,3,,7]),[4,this._testTrtc.startLocalAudio(this._generateLocalTestAudioData())];case 2:return i.sent(),[3,7];case 3:return(e=i.sent()).code!==o.default.ERROR_CODE.OPERATION_ABORT?[3,5]:[4,this._updateLocalTestAudio()];case 4:return i.sent(),[3,6];case 5:throw this._callFunctionErrorManage(e,"startMicDeviceTest"),e;case 6:return[3,7];case 7:return this._testTrtc.on(o.default.EVENT.AUDIO_VOLUME,function(A){null==A||A.result.forEach(function(A){var e=A.userId,i=A.volume;""===e&&t.emit("onTestMicVolume",i)})}),[4,this._testTrtc.enableAudioVolumeEvaluation(A)];case 8:return i.sent(),[2]}})})},i.prototype.stopMicDeviceTest=function(){return a(this,void 0,void 0,function(){return g(this,function(A){switch(A.label){case 0:return this.logger.info("".concat(as,".stopMicDeviceTest")),[4,this._testTrtc.stopLocalAudio()];case 1:return A.sent(),[2]}})})},i.prototype.callExperimentalAPI=function(A){return a(this,void 0,void 0,function(){var e,t,i;return g(this,function(o){switch(o.label){case 0:if(this.logger.info("".concat(as,".callExperimentalAPI"),A),(e=hA(A))===A)return[2];if(t=e.api,i=e.params,!t||!i)return[2];o.label=1;case 1:switch(o.trys.push([1,25,,26]),t){case"setFramework":return[3,2];case"enableAudioAEC":return[3,3];case"enableAudioANS":return[3,4];case"enableAudioAGC":return[3,5];case"KeyMetricsStats":return[3,6];case"setNetworkProxy":return[3,7];case"enableVirtualBackground":return[3,8];case"enableTestVirtualBackground":return[3,10];case"enableTestBeautyStyle":return[3,12];case"setVideoEncodeParamEx":return[3,14];case"enableAutoPlayDialog":return[3,15];case"setAudienceLatencyLevel":return[3,16];case"switchPlaybackQuality":return[3,17];case"requestPictureInPicture":return[3,19];case"exitPictureInPicture":return[3,21]}return[3,23];case 2:return this._handleSetFrameWork(i),[3,24];case 3:return this._echoCancellation=Boolean(i.enable),[3,24];case 4:return this._noiseSuppression=Boolean(i.enable),[3,24];case 5:return this._autoGainControl=Boolean(i.enable),[3,24];case 6:return this._handleKeyMetricsStats(i),[3,24];case 7:return this._networkProxy=i,[3,24];case 8:return[4,this.setVirtualBackground(i)];case 9:return o.sent(),[3,24];case 10:return[4,this.setTestVirtualBackground(i)];case 11:return o.sent(),[3,24];case 12:return[4,this.setTestBeautyStyle(i.style,i.beautyLevel,i.whitenessLevel,i.ruddinessLevel)];case 13:return o.sent(),[3,24];case 14:return this._setVideoEncodeParamEx(i),[3,24];case 15:return this._enableAutoPlayDialog=Boolean(i.enable),[3,24];case 16:return this._latencyLevel=i.latencyLevel,[3,24];case 17:return[4,this._switchPlaybackQuality(i)];case 18:return o.sent(),[3,24];case 19:return[4,this._requestPictureInPicture()];case 20:return o.sent(),[3,24];case 21:return[4,this._exitPictureInPicture()];case 22:return o.sent(),[3,24];case 23:return[3,24];case 24:return[3,26];case 25:throw o.sent();case 26:return[2]}})})},i.prototype._handleSetFrameWork=function(A){var e=A.frameWork,t=A.component,i=A.language;EA(e)&&(this._frameWorkType=e),EA(t)&&(this._component=t),EA(i)&&(this._language=i)},i.prototype._handleKeyMetricsStats=function(A){var e=A.key,t=A.opt,i=A.value,n=A.version,r=t===lA;o.default._addKVStat({type:t,key:e,value:i,version:n,useUV:r,base:100})},i.prototype._setVideoEncodeParamEx=function(e){return a(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:switch(e.streamType){case A.TRTCVideoStreamType.TRTCVideoStreamTypeBig:return[3,1];case A.TRTCVideoStreamType.TRTCVideoStreamTypeSub:return[3,3]}return[3,5];case 1:return[4,this.setVideoEncoderParam(e)];case 2:case 4:return t.sent(),[3,6];case 3:return[4,this.setSubStreamEncoderParam(e)];case 5:return[3,6];case 6:return[2]}})})},i.prototype._switchPlaybackQuality=function(A){return a(this,void 0,void 0,function(){var e,t,i,o,n,r,s,a;return g(this,function(g){switch(g.label){case 0:if(t=(e=A||{}).quality,i=e.stream_list,o=void 0===i?[]:i,!t||0===o.length)return[2];for(n=null,r=0,s=o;r1&&t[1]),height:+(t.length>2&&t[2])}},i.prototype._getTRTCVideoProfile=function(e,t){void 0===t&&(t={});var i=t.videoWidth,o=t.videoHeight,n=t.videoResolution,r=t.videoFps,s=t.videoBitrate,a=t.resMode,g=t.resolutionMode,c={};switch(e){case A.TRTCVideoStreamType.TRTCVideoStreamTypeSub:c=this._defaultScreenProfile;break;case A.TRTCVideoStreamType.TRTCVideoStreamTypeSmall:c=this._defaultSmallVideoProfile;break;case A.TRTCVideoStreamType.TRTCVideoStreamTypeBig:default:c=this._defaultVideoProfile}if(uA(n))uA(i)||(c.width=i),uA(o)||(c.height=o);else{var l=this._getTRTCResolution(n);c.width=l.width,c.height=l.height}if(!uA(a)&&a===A.TRTCVideoResolutionMode.TRTCVideoResolutionModePortrait||!uA(g)&&g===A.TRTCVideoResolutionMode.TRTCVideoResolutionModePortrait){var I=c.height,u=c.width;c.width=I,c.height=u}return r&&(c.frameRate=r),s&&(c.bitrate=s),c},i.prototype._getTRTCStreamType=function(e){var t;return((t={})[A.TRTCVideoStreamType.TRTCVideoStreamTypeBig]=o.default.TYPE.STREAM_TYPE_MAIN,t[A.TRTCVideoStreamType.TRTCVideoStreamTypeSmall]=o.default.TYPE.STREAM_TYPE_MAIN,t[A.TRTCVideoStreamType.TRTCVideoStreamTypeSub]=o.default.TYPE.STREAM_TYPE_SUB,t)[e]},i.prototype._getTRTCFillMode=function(e){var t;return((t={})[A.TRTCVideoFillMode.TRTCVideoFillMode_Fill]=tn.COVER,t[A.TRTCVideoFillMode.TRTCVideoFillMode_Fit]=tn.CONTAIN,t)[e]},i.prototype._getTRTCCloudVideoFillMode=function(e){var t;return((t={})[tn.COVER]=A.TRTCVideoFillMode.TRTCVideoFillMode_Fill,t[tn.CONTAIN]=A.TRTCVideoFillMode.TRTCVideoFillMode_Fit,t)[e]},i.prototype._getTRTCCloudMirrorType=function(e){return!0===e?A.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable:A.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable},i.prototype._getLocalRenderMirror=function(e){var t;return e===A.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto?!this._getIsMobile()||this._getIsFrontCamera():((t={})[A.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable]=!0,t[A.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable]=!1,t)[e]},i.prototype._getTRTCLocalMirror=function(A,e){var t=this._getLocalRenderMirror(A);return uA(e)?!!t&&"both":t&&e?"both":t&&!e?"view":!t&&e?"publish":!(!t&&!e)&&"view"},i.prototype._getTRTCRemoteMirror=function(e){var t;return((t={})[A.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto]=!1,t[A.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable]=!0,t[A.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable]=!1,t)[e]},i.prototype._getTRTCQosPreference=function(e){var t;return((t={})[A.TRTCVideoQosPreference.TRTCVideoQosPreferenceSmooth]=o.default.TYPE.QOS_PREFERENCE_SMOOTH,t[A.TRTCVideoQosPreference.TRTCVideoQosPreferenceClear]=o.default.TYPE.QOS_PREFERENCE_CLEAR,t)[e]},i.prototype._getTRTCAudioQuality=function(e){var t;return((t={})[A.TRTCAudioQuality.TRTCAudioQualitySpeech]=o.default.TYPE.AUDIO_PROFILE_STANDARD,t[A.TRTCAudioQuality.TRTCAudioQualityDefault]=o.default.TYPE.AUDIO_PROFILE_STANDARD,t[A.TRTCAudioQuality.TRTCAudioQualityMusic]=o.default.TYPE.AUDIO_PROFILE_HIGH_STEREO,t)[e]},i.prototype._getTRTCCloudDeviceType=function(e){return{camera:A.TRTCDeviceType.TRTCDeviceTypeCamera,microphone:A.TRTCDeviceType.TRTCDeviceTypeMic,speaker:A.TRTCDeviceType.TRTCDeviceTypeSpeaker}[e]},i.prototype._getTRTCCloudDeviceState=function(e){return{add:A.TRTCDeviceState.TRTCDeviceStateAdd,remove:A.TRTCDeviceState.TRTCDeviceStateRemove,active:A.TRTCDeviceState.TRTCDeviceStateActive}[e]},i.prototype._getTRTCCloudQuality=function(e){return[A.TRTCQuality.TRTCQuality_Unknown,A.TRTCQuality.TRTCQuality_Excellent,A.TRTCQuality.TRTCQuality_Good,A.TRTCQuality.TRTCQuality_Poor,A.TRTCQuality.TRTCQuality_Bad,A.TRTCQuality.TRTCQuality_Vbad,A.TRTCQuality.TRTCQuality_Down][e]},i.prototype._generateLocalVideoData=function(){var A={view:this._getLocalView(),publish:this._getIsVideoPublish(),option:{profile:this._getVideoProfile(),small:this._getSmallStreamVideoProfile()||!1,mirror:this._getTRTCLocalMirror(this._localRenderParams.mirrorType,this._encoderMirror),fillMode:this._getTRTCFillMode(this._localRenderParams.fillMode)}};return this._cameraVideoTrack?A&&Object.assign(A.option,{videoTrack:this._cameraVideoTrack}):this._getIsMobile()?A&&Object.assign(A.option,{useFrontCamera:this._getIsFrontCamera()}):A&&Object.assign(A.option,{cameraId:this._getCurrentCameraId()}),this._getQosPreference()&&A&&Object.assign(A.option,{qosPreference:this._getQosPreference()}),A},i.prototype._generateLocalTestVideoData=function(){var A={view:this._getLocalTestView(),publish:!1,option:{profile:this._getVideoProfile(),mirror:this._getTRTCLocalMirror(this._localRenderParams.mirrorType,this._encoderMirror),fillMode:this._getTRTCFillMode(this._localRenderParams.fillMode)}};return this._getIsMobile()?A&&Object.assign(A.option,{useFrontCamera:this._getIsFrontCamera()}):A&&Object.assign(A.option,{cameraId:this._getCurrentCameraId()}),A},i.prototype._generateLocalAudioData=function(){var A={publish:this._getIsAudioPublish(),mute:this._getAudioMuteType(),muteKeepVolumeDetection:!0,option:{microphoneId:this._getCurrentMicrophoneId(),profile:this._getAudioProfile(),captureVolume:this._getCaptureVolume()}};return dA(this._echoCancellation)&&(A.option.echoCancellation=this._echoCancellation),dA(this._autoGainControl)&&(A.option.autoGainControl=this._autoGainControl),dA(this._noiseSuppression)&&(A.option.noiseSuppression=this._noiseSuppression),A},i.prototype._generateLocalTestAudioData=function(){return{publish:!1,option:{microphoneId:this._getCurrentMicrophoneId(),profile:this._getAudioProfile()}}},i.prototype._generateRemoteVideoData=function(A,e){return QA(this._remoteStreamConfig.get("".concat(A,"_").concat(this._getTRTCStreamType(e))))},i.prototype._addTRTCEvents=function(){var e=this;this._trtc.on(o.default.EVENT.ERROR,function(A){A&&e.emit("onError",A.code,A.message)}),this._trtc.on(o.default.EVENT.REMOTE_USER_ENTER,function(A){(null==A?void 0:A.userId)&&e.emit("onRemoteUserEnterRoom",A.userId)}),this._trtc.on(o.default.EVENT.REMOTE_USER_EXIT,function(A){(null==A?void 0:A.userId)&&e.emit("onRemoteUserLeaveRoom",A.userId)}),this._trtc.on(o.default.EVENT.REMOTE_AUDIO_AVAILABLE,function(A){(null==A?void 0:A.userId)&&e.emit("onUserAudioAvailable",A.userId,!0)}),this._trtc.on(o.default.EVENT.REMOTE_AUDIO_UNAVAILABLE,function(A){(null==A?void 0:A.userId)&&e.emit("onUserAudioAvailable",A.userId,!1)}),this._trtc.on(o.default.EVENT.REMOTE_VIDEO_AVAILABLE,function(A){e._emitVideoAvailable(A,!0)}),this._trtc.on(o.default.EVENT.REMOTE_VIDEO_UNAVAILABLE,function(A){e._emitVideoAvailable(A,!1)}),this._trtc.on(o.default.EVENT.AUDIO_VOLUME,function(A){(null==A?void 0:A.result)&&e.emit("onUserVoiceVolume",null==A?void 0:A.result,((null==A?void 0:A.result)||[]).length)}),this._trtc.on(o.default.EVENT.KICKED_OUT,function(A){var t={banned:on.banned,room_disband:on.roomDisband};EA(t[A.reason])&&e.emit("onExitRoom",t[A.reason])}),this._trtc.on(o.default.EVENT.NETWORK_QUALITY,function(A){var t=A.uplinkNetworkQuality,i=A.downlinkNetworkQuality,o=new k("",e._getTRTCCloudQuality(t)),n=[];e._remoteStatisticsUserIdList.length>0&&(n=e._remoteStatisticsUserIdList.map(function(A){return new k(A,e._getTRTCCloudQuality(i))})),e.emit("onNetworkQuality",o,n)}),this._trtc.on(o.default.EVENT.AUTOPLAY_FAILED,function(A){e.emit("onAutoPlayFailed",A)}),this._trtc.on(o.default.EVENT.SEI_MESSAGE,function(A){if(A.data&&"object"==typeof A.data&&A.data instanceof ArrayBuffer){for(var t=new Uint8Array(A.data),i="",o=0;o0?g.video.map(function(A){var e=new F;return e.width=A.width,e.height=A.height,e.frameRate=A.frameRate,e.videoBitrate=A.bitrate,e.audioBitrate=g.audio.bitrate||0,e.streamType=l[A.videoType],e}):[];if(0===I.length&&g.audio.bitrate>0){var u=new F;u.audioBitrate=g.audio.bitrate||0,I.push(u)}var E=[];c.forEach(function(A){var e=[],t=A.userId,i=A.audio.bitrate;if(A.video&&A.video.forEach(function(A){var o=new O;o.userId=t,o.width=A.width,o.height=A.height,o.frameRate=A.frameRate,o.videoBitrate=A.bitrate,o.audioBitrate=i||0,o.streamType=l[A.videoType],e.push(o)}),0===e.length){var o=new O;o.userId=t,o.audioBitrate=i||0,e.push(o)}E.push.apply(E,e)});var d=new x;d.upLoss=n,d.downLoss=r,d.rtt=o,d.sentBytes=s,d.receivedBytes=a,d.localStatisticsArray=I,d.localStatisticsArraySize=I.length,d.remoteStatisticsArray=E,d.remoteStatisticsArraySize=E.length,e.emit("onStatistics",d)}),this._trtc.on(o.default.EVENT.SCREEN_SHARE_STOPPED,function(){e.emit("onScreenCaptureStopped",0),e._clearScreenShareParams(),e._isSharingScreen=!1}),this._trtc.on(o.default.EVENT.PUBLISH_STATE_CHANGED,function(t){var i=t.mediaType;"started"===t.state&&("audio"===i?e.emit("onSendFirstLocalAudioFrame"):"video"===i?e.emit("onSendFirstLocalVideoFrame",A.TRTCVideoStreamType.TRTCVideoStreamTypeBig):"screen"===i&&e.emit("onSendFirstLocalVideoFrame",A.TRTCVideoStreamType.TRTCVideoStreamTypeSub))}),this._trtc.on(o.default.EVENT.FIRST_VIDEO_FRAME,function(A){var t=A.userId,i=A.streamType,o=A.width,n=A.height;e.emit("onFirstVideoFrame",t,i,o,n)}),this._trtc.on(o.default.EVENT.AUDIO_PLAY_STATE_CHANGED,function(A){var t=A.userId;"PLAYING"===A.state&&e.emit("onFirstAudioFrame",t)}),this._trtc.on(o.default.EVENT.DEVICE_CHANGED,function(A){var t=A.type,i=A.device,o=A.action,n=i.deviceId;if("active"===o){switch(t){case"camera":e._currentCameraId=n,e._currentCamera=i;break;case"microphone":e._currentMicrophoneId=n,e._currentMicrophone=i;break;case"speaker":e._currentSpeakerId=n,e._currentSpeaker=i}e.emitOnDeviceChange(n,e._getTRTCCloudDeviceType(t),e._getTRTCCloudDeviceState(o))}}),this._trtc.on(o.default.EVENT.CUSTOM_MESSAGE,function(A){A&&e.emit("onRecvCustomCmdMsg",A.userId,A.cmdId,A.seq,null==A?void 0:A.data)}),this._trtc.on(o.default.EVENT.CONNECTION_STATE_CHANGED,function(A){e._hasJoinedRoom&&!e._isExitingRoom&&("CONNECTED"===A.prevState&&"DISCONNECTED"===A.state?e.emit("onConnectionLost"):"DISCONNECTED"===A.prevState&&"CONNECTING"===A.state?e.emit("onTryToReconnect"):"CONNECTING"===A.prevState&&"CONNECTED"===A.state&&e.emit("onConnectionRecovery"))}),this._trtc.on(o.default.EVENT.PICTURE_IN_PICTURE_STATE_CHANGED,function(A){e.emit("onPictureInPictureStateChanged",A)})},i.prototype._removeTRTCEvents=function(){this._trtc.off("*")},i.prototype._emitVideoAvailable=function(A,e){var t=A.userId,i=A.streamType;e?this._remoteStreamMap.set("".concat(t,"_").concat(i),!0):this._remoteStreamMap.delete("".concat(t,"_").concat(i)),i===o.default.TYPE.STREAM_TYPE_SUB?t&&this.emit("onUserSubStreamAvailable",t,e):t&&this.emit("onUserVideoAvailable",t,e)},i.prototype._setLocalView=function(A){this._localView=A},i.prototype._getLocalView=function(){return this._localView},i.prototype._setIsMobile=function(A){this._isMobile=A},i.prototype._getIsMobile=function(){return this._isMobile},i.prototype._setIsFrontCamera=function(A){this._isFrontCamera=A},i.prototype._getIsFrontCamera=function(){return this._isFrontCamera},i.prototype._getSmallStreamVideoProfile=function(){return this._smallStreamVideoProfile},i.prototype._setSmallStreamVideoProfile=function(A){this._smallStreamVideoProfile=A},i.prototype._setIsVideoPublish=function(A){this._isVideoPublish=A},i.prototype._getIsVideoPublish=function(){return this._isVideoPublish},i.prototype._setVideoProfile=function(A){this._videoProfile=A},i.prototype._getVideoProfile=function(){return this._videoProfile},i.prototype._setQosPreference=function(A){this._qosPreference=A},i.prototype._getQosPreference=function(){return this._qosPreference},i.prototype._setLocalTestView=function(A){this._localTestView=A},i.prototype._getLocalTestView=function(){return this._localTestView},i.prototype._setScreenShareParams=function(A){var e=A.view,t=A.systemAudio,i=A.fillMode,o=A.profile,n=A.videoTrack,r=A.qosPreference;uA(e)||(this._screenShareParams.view=e),uA(t)||(this._screenShareParams.option.systemAudio=t),uA(i)||(this._screenShareParams.option.fillMode=i),uA(o)||(this._screenShareParams.option.profile=o),uA(n)||(this._screenShareParams.option.videoTrack=n),uA(r)||(this._screenShareParams.option.qosPreference=r)},i.prototype._clearScreenShareParams=function(){var A,e,t,i,o;(null===(A=this._screenShareParams)||void 0===A?void 0:A.view)&&delete this._screenShareParams.view,(null===(t=null===(e=this._screenShareParams)||void 0===e?void 0:e.option)||void 0===t?void 0:t.systemAudio)&&delete this._screenShareParams.option.systemAudio,(null===(o=null===(i=this._screenShareParams)||void 0===i?void 0:i.option)||void 0===o?void 0:o.videoTrack)&&delete this._screenShareParams.option.videoTrack},i.prototype._getScreenShareParams=function(){return this._screenShareParams},i.prototype._setIsAudioPublish=function(A){this._isAudioPublish=A},i.prototype._getIsAudioPublish=function(){return this._isAudioPublish},i.prototype._setAudioMuteType=function(A){this._audioMuteType=A},i.prototype._getAudioMuteType=function(){return this._audioMuteType},i.prototype._setAudioProfile=function(A){this._audioProfile=A},i.prototype._getAudioProfile=function(){return this._audioProfile},i.prototype._getCaptureVolume=function(){return this._captureVolume},i.prototype._setCaptureVolume=function(A){this._captureVolume=A},i.prototype._setCurrentCameraId=function(A){this._currentCameraId=A},i.prototype._getCurrentCameraId=function(){return this._currentCameraId},i.prototype._setCurrentMicrophoneId=function(A){this._currentMicrophoneId=A},i.prototype._getCurrentMicrophoneId=function(){return this._currentMicrophoneId},i.prototype._setCurrentSpeakerId=function(A){this._currentSpeakerId=A},i.prototype._getCurrentSpeakerId=function(){return this._currentSpeakerId},i.prototype._setRemoteStreamConfig=function(e,t,i){var o=this._remoteStreamConfig.get("".concat(e,"_").concat(this._getTRTCStreamType(t)));o||(o={userId:e,streamType:this._getTRTCStreamType(t),option:{mirror:this._getTRTCRemoteMirror(A.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable),fillMode:this._getTRTCFillMode(A.TRTCVideoFillMode.TRTCVideoFillMode_Fit)}});var n=i.view,r=i.mirrorType,s=i.fillMode,a=i.small;uA(n)||(o.view=n),uA(r)||(o.option.mirror=this._getTRTCRemoteMirror(r)),uA(s)||(o.option.fillMode=this._getTRTCFillMode(s)),uA(a)||(o.option.small=a),this._remoteStreamConfig.set("".concat(e,"_").concat(this._getTRTCStreamType(t)),o)},i.prototype._inheritPropertiesToSubCloud=function(A){A._frameWorkType=this._frameWorkType,A._component=this._component,A._language=this._language,A._networkProxy=r({},this._networkProxy),A._latencyLevel=this._latencyLevel,A._enableAutoPlayDialog=this._enableAutoPlayDialog},i.prototype._inheritEventsToSubCloud=function(A){var e=this;A._trtc.on(o.default.EVENT.AUTOPLAY_FAILED,function(A){e.emit("onAutoPlayFailed",A)}),A._trtc.on(o.default.EVENT.PICTURE_IN_PICTURE_STATE_CHANGED,function(A){e.emit("onPictureInPictureStateChanged",A)})},i.prototype.handleDeviceChange=function(){return a(this,void 0,void 0,function(){var e=this;return g(this,function(t){return o.default.getCameraList().then(function(t){return a(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return this._cameraList.length===t.length?[2]:[4,this.deviceChangeManage(this._cameraList,t,A.TRTCDeviceType.TRTCDeviceTypeCamera)];case 1:return e.sent(),this._cameraList=t,[2]}})})}),o.default.getMicrophoneList().then(function(t){return a(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.deviceChangeManage(this._microphoneList,t,A.TRTCDeviceType.TRTCDeviceTypeMic)];case 1:return e.sent(),this._microphoneList=t,[2]}})})}),o.default.getSpeakerList().then(function(t){return a(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.deviceChangeManage(this._speakerList,t,A.TRTCDeviceType.TRTCDeviceTypeSpeaker)];case 1:return e.sent(),this._speakerList=t,[2]}})})}),[2]})})},i.prototype.isSameDevice=function(A,e){var t=A&&A.deviceId&&A.groupId&&A.label,i=e&&e.deviceId&&e.groupId&&e.label;return!(!t||!i)&&A.deviceId===e.deviceId&&A.groupId===e.groupId&&A.label===e.label},i.prototype.deviceChangeManage=function(e,t,i){return a(this,void 0,void 0,function(){var o,n,r,s,a;return g(this,function(g){switch(g.label){case 0:return o=void 0,e.length!==t.length&&(n=(t||[]).map(function(A){return A.deviceId}),r=new w,e.length>t.length?(r=e.filter(function(A){return!n.includes(A.deviceId)})[0]||{},o=A.TRTCDeviceState.TRTCDeviceStateRemove):(n=(e||[]).map(function(A){return A.deviceId}),r=t.filter(function(A){return!n.includes(A.deviceId)})[0]||{},o=A.TRTCDeviceState.TRTCDeviceStateAdd),s=r.deviceId,this.emitOnDeviceChange(s,i,o)),a=this.getDefaultDeviceInfo(t),i!==A.TRTCDeviceType.TRTCDeviceTypeCamera||o!==A.TRTCDeviceState.TRTCDeviceStateRemove?[3,3]:this.isSameDevice(this._currentCamera,a)?[2]:a.deviceId?[4,this.autoChangeDevice(i,a)]:[3,2];case 1:g.sent(),g.label=2;case 2:g.label=3;case 3:return i!==A.TRTCDeviceType.TRTCDeviceTypeMic?[3,6]:this.isSameDevice(this._currentMicrophone,a)?[2]:a.deviceId?[4,this.autoChangeDevice(i,a)]:[3,5];case 4:g.sent(),g.label=5;case 5:g.label=6;case 6:return i!==A.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,9]:this.isSameDevice(this._currentSpeaker,a)?[2]:a.deviceId?[4,this.autoChangeDevice(i,a)]:[3,8];case 7:g.sent(),g.label=8;case 8:g.label=9;case 9:return[2]}})})},i.prototype.getDefaultDeviceInfo=function(A){var e=new w;if(0===A.length)return e;var t=A.filter(function(A){return"default"===A.deviceId});return t.length>0?t[0]:A[0]},i.prototype.autoChangeDevice=function(e,t){return a(this,void 0,void 0,function(){var i,n,r;return g(this,function(s){switch(s.label){case 0:return i=t.deviceId,e!==A.TRTCDeviceType.TRTCDeviceTypeCamera?[3,6]:(this._setCurrentCameraId(i),[4,this._updateLocalVideo()]);case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,4,,5]),[4,this._testTrtc.updateLocalVideo({option:{cameraId:i}})];case 3:return s.sent(),[3,5];case 4:return n=s.sent(),console.log("testTRTC error",JSON.stringify(n)),n.code,o.default.ERROR_CODE.OPERATION_ABORT,[3,5];case 5:this._currentCameraId=i,this._currentCamera=t,this.emitOnDeviceChange(i,e,A.TRTCDeviceState.TRTCDeviceStateActive),s.label=6;case 6:return e!==A.TRTCDeviceType.TRTCDeviceTypeMic?[3,12]:(this._setCurrentMicrophoneId(i),[4,this._updateLocalAudio()]);case 7:s.sent(),s.label=8;case 8:return s.trys.push([8,10,,11]),[4,this._testTrtc.updateLocalAudio({option:{microphoneId:i}})];case 9:return s.sent(),[3,11];case 10:return r=s.sent(),console.log("testTRTC error",JSON.stringify(r)),r.code,o.default.ERROR_CODE.OPERATION_ABORT,[3,11];case 11:this._currentMicrophoneId=i,this._currentMicrophone=t,this.emitOnDeviceChange(i,e,A.TRTCDeviceState.TRTCDeviceStateActive),s.label=12;case 12:return e!==A.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,14]:[4,o.default.setCurrentSpeaker(i)];case 13:s.sent(),this._currentSpeakerId=i,this._currentSpeaker=t,this.emitOnDeviceChange(i,e,A.TRTCDeviceState.TRTCDeviceStateActive),s.label=14;case 14:return[2]}})})},i.prototype.emitOnDeviceChange=function(A,e,t){this.emit("onDeviceChange",A,e,t)},i.prototype.getMediaMixingManager=function(){return new br({logger:this.logger,trtc:this._trtc,trtcCloud:this})},i.shareInstance=null,i.subCloudMap=new Map,i.enableSEI=!1,i.assetsPath="",s([(c="exitRoom",function(A,e,t){var i=t.value;return t.value=function(){for(var A,e,t,o,n=[],r=0;rA.length)&&(e=A.length);for(var t=0,i=new Array(e);t=0;--o){var n=this.tryEntries[o],r=n.completion;if("root"===n.tryLoc)return i("end");if(n.tryLoc<=this.prev){var s=t.call(n,"catchLoc"),a=t.call(n,"finallyLoc");if(s&&a){if(this.prev=0;--i){var o=this.tryEntries[i];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev=0;--e){var t=this.tryEntries[e];if(t.finallyLoc===A)return this.complete(t.completion,t.afterLoc),m(t),c}},catch:function(A){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.tryLoc===A){var i=t.completion;if("throw"===i.type){var o=i.arg;m(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(A,e,t){return this.delegate={iterator:D(A),resultName:e,nextLoc:t},"next"===this.method&&(this.arg=void 0),c}},A}(A.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}});var l,I,u=function(A){return A&&A.Math==Math&&A},E=u("object"==typeof globalThis&&globalThis)||u("object"==typeof window&&window)||u("object"==typeof self&&self)||u("object"==typeof g&&g)||function(){return this}()||Function("return this")(),d=function(A){try{return!!A()}catch(e){return!0}},h=!d(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),C={}.propertyIsEnumerable,B=Object.getOwnPropertyDescriptor,Q={f:B&&!C.call({1:2},1)?function(A){var e=B(this,A);return!!e&&e.enumerable}:C},p=function(A,e){return{enumerable:!(1&A),configurable:!(2&A),writable:!(4&A),value:e}},f={}.toString,m=function(A){return f.call(A).slice(8,-1)},y="".split,D=d(function(){return!Object("z").propertyIsEnumerable(0)})?function(A){return"String"==m(A)?y.call(A,""):Object(A)}:Object,v=function(A){if(null==A)throw TypeError("Can't call method on "+A);return A},w=function(A){return D(v(A))},S=function(A){return"function"==typeof A},M=function(A){return"object"==typeof A?null!==A:S(A)},R=function(A){return S(A)?A:void 0},_=function(A,e){return arguments.length<2?R(E[A]):E[A]&&E[A][e]},T=_("navigator","userAgent")||"",N=E.process,b=E.Deno,G=N&&N.versions||b&&b.version,k=G&&G.v8;k?I=(l=k.split("."))[0]<4?1:l[0]+l[1]:T&&(!(l=T.match(/Edge\/(\d+)/))||l[1]>=74)&&(l=T.match(/Chrome\/(\d+)/))&&(I=l[1]);var L=I&&+I,U=!!Object.getOwnPropertySymbols&&!d(function(){var A=Symbol();return!String(A)||!(Object(A)instanceof Symbol)||!Symbol.sham&&L&&L<41}),F=U&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,O=F?function(A){return"symbol"==typeof A}:function(A){var e=_("Symbol");return S(e)&&Object(A)instanceof e},x=function(A){try{return String(A)}catch(e){return"Object"}},P=function(A){if(S(A))return A;throw TypeError(x(A)+" is not a function")},Y=function(A,e){var t=A[e];return null==t?void 0:P(t)},J=function(A,e){try{Object.defineProperty(E,A,{value:e,configurable:!0,writable:!0})}catch(t){E[A]=e}return e},H=E["__core-js_shared__"]||J("__core-js_shared__",{}),q=c(function(A){(A.exports=function(A,e){return H[A]||(H[A]=void 0!==e?e:{})})("versions",[]).push({version:"3.18.2",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})}),V=function(A){return Object(v(A))},j={}.hasOwnProperty,K=Object.hasOwn||function(A,e){return j.call(V(A),e)},W=0,z=Math.random(),Z=function(A){return"Symbol("+String(void 0===A?"":A)+")_"+(++W+z).toString(36)},X=q("wks"),$=E.Symbol,AA=F?$:$&&$.withoutSetter||Z,eA=function(A){return K(X,A)&&(U||"string"==typeof X[A])||(U&&K($,A)?X[A]=$[A]:X[A]=AA("Symbol."+A)),X[A]},tA=eA("toPrimitive"),iA=function(A,e){if(!M(A)||O(A))return A;var t,i=Y(A,tA);if(i){if(void 0===e&&(e="default"),t=i.call(A,e),!M(t)||O(t))return t;throw TypeError("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(A,e){var t,i;if("string"===e&&S(t=A.toString)&&!M(i=t.call(A)))return i;if(S(t=A.valueOf)&&!M(i=t.call(A)))return i;if("string"!==e&&S(t=A.toString)&&!M(i=t.call(A)))return i;throw TypeError("Can't convert object to primitive value")}(A,e)},oA=function(A){var e=iA(A,"string");return O(e)?e:String(e)},nA=E.document,rA=M(nA)&&M(nA.createElement),sA=function(A){return rA?nA.createElement(A):{}},aA=!h&&!d(function(){return 7!=Object.defineProperty(sA("div"),"a",{get:function(){return 7}}).a}),gA=Object.getOwnPropertyDescriptor,cA={f:h?gA:function(A,e){if(A=w(A),e=oA(e),aA)try{return gA(A,e)}catch(t){}if(K(A,e))return p(!Q.f.call(A,e),A[e])}},lA=function(A){if(M(A))return A;throw TypeError(String(A)+" is not an object")},IA=Object.defineProperty,uA={f:h?IA:function(A,e,t){if(lA(A),e=oA(e),lA(t),aA)try{return IA(A,e,t)}catch(i){}if("get"in t||"set"in t)throw TypeError("Accessors not supported");return"value"in t&&(A[e]=t.value),A}},EA=h?function(A,e,t){return uA.f(A,e,p(1,t))}:function(A,e,t){return A[e]=t,A},dA=Function.toString;S(H.inspectSource)||(H.inspectSource=function(A){return dA.call(A)});var hA,CA,BA,QA=H.inspectSource,pA=E.WeakMap,fA=S(pA)&&/native code/.test(QA(pA)),mA=q("keys"),yA=function(A){return mA[A]||(mA[A]=Z(A))},DA={},vA=E.WeakMap;if(fA||H.state){var wA=H.state||(H.state=new vA),SA=wA.get,MA=wA.has,RA=wA.set;hA=function(A,e){if(MA.call(wA,A))throw new TypeError("Object already initialized");return e.facade=A,RA.call(wA,A,e),e},CA=function(A){return SA.call(wA,A)||{}},BA=function(A){return MA.call(wA,A)}}else{var _A=yA("state");DA[_A]=!0,hA=function(A,e){if(K(A,_A))throw new TypeError("Object already initialized");return e.facade=A,EA(A,_A,e),e},CA=function(A){return K(A,_A)?A[_A]:{}},BA=function(A){return K(A,_A)}}var TA={set:hA,get:CA,has:BA,enforce:function(A){return BA(A)?CA(A):hA(A,{})},getterFor:function(A){return function(e){var t;if(!M(e)||(t=CA(e)).type!==A)throw TypeError("Incompatible receiver, "+A+" required");return t}}},NA=Function.prototype,bA=h&&Object.getOwnPropertyDescriptor,GA=K(NA,"name"),kA={EXISTS:GA,PROPER:GA&&"something"===function(){}.name,CONFIGURABLE:GA&&(!h||h&&bA(NA,"name").configurable)},LA=c(function(A){var e=kA.CONFIGURABLE,t=TA.get,i=TA.enforce,o=String(String).split("String");(A.exports=function(A,t,n,r){var s,a=!!r&&!!r.unsafe,g=!!r&&!!r.enumerable,c=!!r&&!!r.noTargetGet,l=r&&void 0!==r.name?r.name:t;S(n)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!K(n,"name")||e&&n.name!==l)&&EA(n,"name",l),(s=i(n)).source||(s.source=o.join("string"==typeof l?l:""))),A!==E?(a?!c&&A[t]&&(g=!0):delete A[t],g?A[t]=n:EA(A,t,n)):g?A[t]=n:J(t,n)})(Function.prototype,"toString",function(){return S(this)&&t(this).source||QA(this)})}),UA=Math.ceil,FA=Math.floor,OA=function(A){var e=+A;return e!=e||0===e?0:(e>0?FA:UA)(e)},xA=Math.max,PA=Math.min,YA=Math.min,JA=function(A){return A>0?YA(OA(A),9007199254740991):0},HA=function(A){return JA(A.length)},qA=function(A){return function(e,t,i){var o,n,r,s=w(e),a=HA(s),g=(n=a,(r=OA(i))<0?xA(r+n,0):PA(r,n));if(A&&t!=t){for(;a>g;)if((o=s[g++])!=o)return!0}else for(;a>g;g++)if((A||g in s)&&s[g]===t)return A||g||0;return!A&&-1}},VA={includes:qA(!0),indexOf:qA(!1)},jA=VA.indexOf,KA=function(A,e){var t,i=w(A),o=0,n=[];for(t in i)!K(DA,t)&&K(i,t)&&n.push(t);for(;e.length>o;)K(i,t=e[o++])&&(~jA(n,t)||n.push(t));return n},WA=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],zA=WA.concat("length","prototype"),ZA={f:Object.getOwnPropertyNames||function(A){return KA(A,zA)}},XA={f:Object.getOwnPropertySymbols},$A=_("Reflect","ownKeys")||function(A){var e=ZA.f(lA(A)),t=XA.f;return t?e.concat(t(A)):e},Ae=function(A,e){for(var t=$A(e),i=uA.f,o=cA.f,n=0;n=51||!d(function(){var e=[];return(e.constructor={})[we]=function(){return{foo:1}},1!==e[A](Boolean).foo})},Me=eA("isConcatSpreadable"),Re=L>=51||!d(function(){var A=[];return A[Me]=!1,A.concat()[0]!==A}),_e=Se("concat"),Te=function(A){if(!M(A))return!1;var e=A[Me];return void 0!==e?!!e:ce(A)};ge({target:"Array",proto:!0,forced:!Re||!_e},{concat:function(A){var e,t,i,o,n,r=V(this),s=ve(r,0),a=0;for(e=-1,i=arguments.length;e9007199254740991)throw TypeError("Maximum allowed index exceeded");for(t=0;t=9007199254740991)throw TypeError("Maximum allowed index exceeded");le(s,a++,n)}return s.length=a,s}});var Ne,be=Object.keys||function(A){return KA(A,WA)},Ge=h?Object.defineProperties:function(A,e){lA(A);for(var t,i=be(e),o=i.length,n=0;o>n;)uA.f(A,t=i[n++],e[t]);return A},ke=_("document","documentElement"),Le=yA("IE_PROTO"),Ue=function(){},Fe=function(A){return"