UNPKG

@tencentcloud/chat-cs-uniapp

Version:

TCCC uniapp UIKit

3 lines 592 kB
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function t(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){s(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function n(){ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ n=function(){return e};var e={},t=Object.prototype,o=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,o){var r=t&&t.prototype instanceof p?t:p,a=Object.create(r.prototype),s=new C(o||[]);return a._invoke=function(e,t,n){var o="suspendedStart";return function(r,a){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===r)throw a;return A()}for(n.method=r,n.arg=a;;){var s=n.delegate;if(s){var i=I(s,n);if(i){if(i===d)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===o)throw o="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o="executing";var c=l(e,t,n);if("normal"===c.type){if(o=n.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o="completed",n.method="throw",n.arg=c.arg)}}}(e,n,s),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d={};function p(){}function g(){}function h(){}var _={};c(_,a,(function(){return this}));var f=Object.getPrototypeOf,m=f&&f(f(S([])));m&&m!==t&&o.call(m,a)&&(_=m);var v=h.prototype=p.prototype=Object.create(_);function M(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function n(r,a,s,i){var c=l(e[r],e,a);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&o.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,i)}),(function(e){n("throw",e,s,i)})):t.resolve(d).then((function(e){u.value=e,s(u)}),(function(e){return n("throw",e,s,i)}))}i(c.arg)}var r;this._invoke=function(e,o){function a(){return new t((function(t,r){n(e,o,t,r)}))}return r=r?r.then(a,a):a()}}function I(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,I(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,d;var r=o.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function S(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(o.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:A}}function A(){return{value:void 0,done:!0}}return g.prototype=h,c(v,"constructor",h),c(h,"constructor",g),g.displayName=c(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},M(y.prototype),c(y.prototype,s,(function(){return this})),e.AsyncIterator=y,e.async=function(t,n,o,r,a){void 0===a&&(a=Promise);var s=new y(u(t,n,o,r),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},M(v),c(v,i,"Generator"),c(v,a,(function(){return this})),c(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var o=t.pop();if(o in e)return n.value=o,n.done=!1,n}return n.done=!0,n}},e.values=S,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&o.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,o){return s.type="throw",s.arg=e,t.next=n,o&&(t.method="next",t.arg=void 0),!!o}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var i=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var o=n.completion;if("throw"===o.type){var r=o.arg;T(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t,n,o,r,a,s){try{var i=e[a](s),c=i.value}catch(e){return void n(e)}i.done?t(c):Promise.resolve(c).then(o,r)}function a(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var s=e.apply(t,n);function i(e){r(s,o,a,i,c,"next",e)}function c(e){r(s,o,a,i,c,"throw",e)}i(void 0)}))}}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},c={exports:{}},u=c.exports=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function n(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(){var e=(new Date).getTime(),t=new Date(e),n=t.getHours(),o=t.getMinutes(),r=t.getSeconds(),a=t.getMilliseconds();return n=n<10?"0".concat(n):n,o=o<10?"0".concat(o):o,r=r<10?"0".concat(r):r,"".concat(n,":").concat(o,":").concat(r,".").concat(a)}var i="TRTC-WX",c=0,u=1,l=new(function(){function t(){e(this,t),this.logLevel=0}return n(t,[{key:"setLogLevel",value:function(e){this.logLevel=e}},{key:"log",value:function(){var e;this.logLevel===c&&(e=console).log.apply(e,[i,s()].concat(Array.prototype.slice.call(arguments)))}},{key:"warn",value:function(){var e;this.logLevel<=u&&(e=console).warn.apply(e,[i,s()].concat(Array.prototype.slice.call(arguments)))}},{key:"error",value:function(){var e;(e=console).error.apply(e,[i,s()].concat(Array.prototype.slice.call(arguments)))}}]),t}()),d=function(e){var t=/[\u4e00-\u9fa5]/;return e.sdkAppID?void 0===e.roomID&&void 0===e.strRoomID?(l.error("未设置 roomID"),!1):!e.strRoomID&&(e.roomID<1||e.roomID>4294967296)?(l.error("roomID 超出取值范围 1 ~ 4294967295"),!1):e.strRoomID&&t.test(e.strRoomID)?(l.error("strRoomID 请勿使用中文字符"),!1):e.userID?e.userID&&t.test(e.userID)?(l.error("userID 请勿使用中文字符"),!1):!!e.userSig||(l.error("未设置 userSig"),!1):(l.error("未设置 userID"),!1):(l.error("未设置 sdkAppID"),!1)},p={LOCAL_JOIN:"LOCAL_JOIN",LOCAL_LEAVE:"LOCAL_LEAVE",KICKED_OUT:"KICKED_OUT",REMOTE_USER_JOIN:"REMOTE_USER_JOIN",REMOTE_USER_LEAVE:"REMOTE_USER_LEAVE",REMOTE_VIDEO_ADD:"REMOTE_VIDEO_ADD",REMOTE_VIDEO_REMOVE:"REMOTE_VIDEO_REMOVE",REMOTE_AUDIO_ADD:"REMOTE_AUDIO_ADD",REMOTE_AUDIO_REMOVE:"REMOTE_AUDIO_REMOVE",REMOTE_STATE_UPDATE:"REMOTE_STATE_UPDATE",LOCAL_NET_STATE_UPDATE:"LOCAL_NET_STATE_UPDATE",REMOTE_NET_STATE_UPDATE:"REMOTE_NET_STATE_UPDATE",LOCAL_AUDIO_VOLUME_UPDATE:"LOCAL_AUDIO_VOLUME_UPDATE",REMOTE_AUDIO_VOLUME_UPDATE:"REMOTE_AUDIO_VOLUME_UPDATE",VIDEO_FULLSCREEN_UPDATE:"VIDEO_FULLSCREEN_UPDATE",BGM_PLAY_START:"BGM_PLAY_START",BGM_PLAY_FAIL:"BGM_PLAY_FAIL",BGM_PLAY_PROGRESS:"BGM_PLAY_PROGRESS",BGM_PLAY_COMPLETE:"BGM_PLAY_COMPLETE",ERROR:"ERROR",IM_READY:"IM_READY",IM_MESSAGE_RECEIVED:"IM_MESSAGE_RECEIVED",IM_NOT_READY:"IM_NOT_READY",IM_KICKED_OUT:"IM_KICKED_OUT",IM_ERROR:"IM_ERROR"},g={url:"",mode:"RTC",autopush:!1,enableCamera:!1,enableMic:!1,enableAgc:!1,enableAns:!1,enableEarMonitor:!1,enableAutoFocus:!0,enableZoom:!1,minBitrate:600,maxBitrate:900,videoWidth:360,videoHeight:640,beautyLevel:0,whitenessLevel:0,videoOrientation:"vertical",videoAspect:"9:16",frontCamera:"front",enableRemoteMirror:!1,localMirror:"auto",enableBackgroundMute:!1,audioQuality:"high",audioVolumeType:"voicecall",audioReverbType:0,waitingImage:"",waitingImageHash:"",beautyStyle:"smooth",filter:"",netStatus:{}},h={src:"",mode:"RTC",autoplay:!0,muteAudio:!0,muteVideo:!0,orientation:"vertical",objectFit:"fillCrop",enableBackgroundMute:!1,minCache:1,maxCache:2,soundMode:"speaker",enableRecvMessage:!1,autoPauseIfNavigate:!0,autoPauseIfOpenNative:!0,isVisible:!0,_definitionType:"main",netStatus:{}};function _(){var e=new Date;return e.setTime((new Date).getTime()+0),e.toLocaleString()}(new Date).getTime();var f=function(e){var t=[];if(e&&e.TUIScene&&t.push(e.TUIScene),e&&"test"===e.env)return"default";if(wx&&wx.TUIScene&&t.push(wx.TUIScene),wx&&"function"==typeof getApp){var n=getApp().globalData;n&&n.TUIScene&&t.push(n.TUIScene)}return wx&&wx.getStorage({key:"TUIScene",success:function(e){t.push(e.data)}}),t[0]||"default"},m=new(function(){function t(){e(this,t),this.sdkAppId="",this.userId="",this.version="",this.common={}}return n(t,[{key:"setConfig",value:function(e){this.sdkAppId="".concat(e.sdkAppId),this.userId="".concat(e.userId),this.version="".concat(e.version),this.common.TUIScene=f(e)}},{key:"log",value:function(e){wx.request({url:"https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log",method:"POST",header:{"content-type":"application/json"},data:{timestamp:_(),sdkAppId:this.sdkAppId,userId:this.userId,version:this.version,log:JSON.stringify(a(a({},e),this.common))}})}}]),t}()),v="enterRoom",M="exitRoom",y="setPusherAttributes",I="setPlayerAttributes",E="init",T="error",C="connectServer",S="startPusher",A="openCamera",D="screenCap",O="pusherResolution",N="pusherCodeRate",R="collectionFirstFrame",L="encoderStart",k="enterRoomSuccess",P="exitRoomSuccess",G="kicked_out",b="renderFirstFrame",w="miniAppHang",U="closeSuspension",F="other",q="update",V="addUser",x="remove_user",K="update_user_video",H="update_user_audio",B="pusherStart",j="pusherStop",Y="pusherPause",W="pusherResume",z=function(){function t(n,o){e(this,t),this.context=wx.createLivePusherContext(o),this.pusherAttributes={},Object.assign(this.pusherAttributes,g,n)}return n(t,[{key:"setPusherAttributes",value:function(e){return Object.assign(this.pusherAttributes,e),this.pusherAttributes}},{key:"start",value:function(e){l.log("[apiLog][pusherStart]"),m.log({name:B,options:e}),this.context.start(e)}},{key:"stop",value:function(e){l.log("[apiLog][pusherStop]"),m.log({name:j,options:e}),this.context.stop(e)}},{key:"pause",value:function(e){l.log("[apiLog] pusherPause()"),m.log({name:Y,options:e}),this.context.pause(e)}},{key:"resume",value:function(e){l.log("[apiLog][pusherResume]"),m.log({name:W,options:e}),this.context.resume(e)}},{key:"switchCamera",value:function(e){return l.log("[apiLog][switchCamera]"),this.pusherAttributes.frontCamera="front"===this.pusherAttributes.frontCamera?"back":"front",this.context.switchCamera(e),this.pusherAttributes}},{key:"sendMessage",value:function(e){l.log("[apiLog][sendMessage]",e.msg),this.context.sendMessage(e)}},{key:"snapshot",value:function(){var e=this;return l.log("[apiLog][pusherSnapshot]"),new Promise((function(t,n){e.context.snapshot({quality:"raw",complete:function(e){e.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:e.tempImagePath,success:function(n){t(e)},fail:function(e){l.error("[error] pusher截图失败: ",e),n(new Error("截图失败"))}}),t(e)):(l.error("[error] snapShot 回调失败",e),n(new Error("截图失败")))}})}))}},{key:"toggleTorch",value:function(e){this.context.toggleTorch(e)}},{key:"startDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"stopDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"playBGM",value:function(e){l.log("[apiLog] playBGM() url: ",e.url),this.context.playBGM(e)}},{key:"pauseBGM",value:function(e){l.log("[apiLog] pauseBGM()"),this.context.pauseBGM(e)}},{key:"resumeBGM",value:function(e){l.log("[apiLog] resumeBGM()"),this.context.resumeBGM(e)}},{key:"stopBGM",value:function(e){l.log("[apiLog] stopBGM()"),this.context.stopBGM(e)}},{key:"setBGMVolume",value:function(e){l.log("[apiLog] setBGMVolume() volume:",e.volume),this.context.setBGMVolume(e.volume)}},{key:"setMICVolume",value:function(e){l.log("[apiLog] setMICVolume() volume:",e.volume),this.context.setMICVolume(e.volume)}},{key:"startPreview",value:function(e){l.log("[apiLog] startPreview()"),this.context.startPreview(e)}},{key:"stopPreview",value:function(e){l.log("[apiLog] stopPreview()"),this.context.stopPreview(e)}},{key:"reset",value:function(){return this.pusherConfig={},this.context&&(this.stop({success:function(){}}),this.context=null),this.pusherAttributes}}]),t}(),J=function t(n){e(this,t),Object.assign(this,{userID:"",streams:{}},n)},X=function(){function t(n,o){e(this,t),this.ctx=o,this.playerAttributes={},Object.assign(this.playerAttributes,h,{userID:"",streamType:"",streamID:"",id:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0},n)}return n(t,[{key:"play",value:function(e){this.getPlayerContext().play(e)}},{key:"stop",value:function(e){this.getPlayerContext().stop(e)}},{key:"mute",value:function(e){this.getPlayerContext().mute(e)}},{key:"pause",value:function(e){this.getPlayerContext().pause(e)}},{key:"resume",value:function(e){this.getPlayerContext().resume(e)}},{key:"requestFullScreen",value:function(e){var t=this;return new Promise((function(n,o){t.getPlayerContext().requestFullScreen({direction:e.direction,success:function(e){n(e)},fail:function(e){o(e)}})}))}},{key:"requestExitFullScreen",value:function(){var e=this;return new Promise((function(t,n){e.getPlayerContext().exitFullScreen({success:function(e){t(e)},fail:function(e){n(e)}})}))}},{key:"snapshot",value:function(e){var t=this;return l.log("[playerSnapshot]",e),new Promise((function(e,n){t.getPlayerContext().snapshot({quality:"raw",complete:function(t){t.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:t.tempImagePath,success:function(n){l.log("save photo is success",n),e(t)},fail:function(e){l.error("save photo is fail",e),n(e)}}),e(t)):(l.error("snapShot 回调失败",t),n(new Error("截图失败")))}})}))}},{key:"setPlayerAttributes",value:function(e){Object.assign(this.playerAttributes,e)}},{key:"getPlayerContext",value:function(){return this.playerContext||(this.playerContext=wx.createLivePlayerContext(this.playerAttributes.id,this.ctx)),this.playerContext}},{key:"reset",value:function(){this.playerContext&&(this.playerContext.stop(),this.playerContext=void 0),Object.assign(this.playerAttributes,h,{userID:"",streamType:"",streamID:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0})}}]),t}(),Q="UserController",Z=function(){function t(n,o){e(this,t),this.ctx=o,this.userMap=new Map,this.userList=[],this.streamList=[],this.emitter=n}return n(t,[{key:"userEventHandler",value:function(e){var t=e.detail.code,n=e.detail.message,o={name:F,code:t,message:n,data:""};switch(t){case 0:l.log(n,t);break;case 1001:l.log("已经连接推流服务器",t),o.name=C;break;case 1002:l.log("已经与服务器握手完毕,开始推流",t),o.name=S;break;case 1003:l.log("打开摄像头成功",t),o.name=A;break;case 1004:l.log("录屏启动成功",t),o.name=D;break;case 1005:l.log("推流动态调整分辨率",t),o.name=O;break;case 1006:l.log("推流动态调整码率",t),o.name=N;break;case 1007:l.log("首帧画面采集完成",t),o.name=R;break;case 1008:l.log("编码器启动",t),o.name=L;break;case 1018:l.log("进房成功",t),o.name=k,o.data="event enterRoom success",this.emitter.emit(p.LOCAL_JOIN);break;case 1019:l.log("退出房间",t),n.indexOf("reason[0]")>-1?(o.name=P,o.data="event exitRoom success"):(o.name=G,o.data="event abnormal exitRoom",this.emitter.emit(p.KICKED_OUT));break;case 2003:l.log("渲染首帧视频",t),o.name=b;break;case-1301:l.error("打开摄像头失败: ",t),o.name=T,o.data="event start camera failed",this.emitter.emit(p.ERROR,{code:t,message:n});break;case-1302:o.name=T,o.data="event start microphone failed",l.error("打开麦克风失败: ",t),this.emitter.emit(p.ERROR,{code:t,message:n});break;case-1303:l.error("视频编码失败: ",t),o.name=T,o.data="event video encode failed",this.emitter.emit(p.ERROR,{code:t,message:n});break;case-1304:l.error("音频编码失败: ",t),o.name=T,o.data="event audio encode failed",this.emitter.emit(p.ERROR,{code:t,message:n});break;case-1307:l.error("推流连接断开: ",t),o.name=T,o.data="event pusher stream failed",this.emitter.emit(p.ERROR,{code:t,message:n});break;case-100018:l.error("进房失败: userSig 校验失败,请检查 userSig 是否填写正确",t,n),o.name=T,o.data="event userSig is error",this.emitter.emit(p.ERROR,{code:t,message:n});break;case 5e3:l.log("小程序被挂起: ",t),o.name=w,o.data="miniApp is hang";break;case 5001:l.log("小程序悬浮窗被关闭: ",t),o.name=U;break;case 1021:l.log("网络类型发生变化,需要重新进房",t);break;case 2007:l.log("本地视频播放loading: ",t);break;case 2004:l.log("本地视频播放开始: ",t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e)}m.log(o)}},{key:"_handleUserEvent",value:function(e){var t,n=e.detail.code,o=e.detail.message;if(!e.detail.message||"string"!=typeof o)return l.warn(Q,"userEventHandler 数据格式错误"),!1;try{t=JSON.parse(e.detail.message)}catch(e){return l.warn(Q,"userEventHandler 数据格式错误",e),!1}switch(this.emitter.emit(p.LOCAL_STATE_UPDATE,e),m.log({name:q,code:n,message:o,data:t}),n){case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t)}}},{key:"addUser",value:function(e){var t=this;l.log("addUser",e);var n=e.userlist;Array.isArray(n)&&n.length>0&&n.forEach((function(e){var n=e.userid,o=t.getUser(n);o||(o=new J({userID:n}),t.userList.push({userID:n})),t.userMap.set(n,o),t.emitter.emit(p.REMOTE_USER_JOIN,{userID:n,userList:t.userList,playerList:t.getPlayerList()}),m.log({name:V,userID:n,userList:t.userList,playerList:t.getPlayerList()})}))}},{key:"removeUser",value:function(e){var t=this,n=e.userlist;Array.isArray(n)&&n.length>0&&n.forEach((function(e){var n=e.userid,o=t.getUser(n);o&&o.streams&&(t._removeUserAndStream(n),o.streams.main&&o.streams.main.reset(),o.streams.aux&&o.streams.aux.reset(),t.emitter.emit(p.REMOTE_USER_LEAVE,{userID:n,userList:t.userList,playerList:t.getPlayerList()}),m.log({name:x,userID:n,userList:t.userList,playerList:t.getPlayerList()}),o=void 0,t.userMap.delete(n))}))}},{key:"updateUserVideo",value:function(e){var t=this;l.log(Q,"updateUserVideo",e);var n=e.userlist;Array.isArray(n)&&n.length>0&&n.forEach((function(e){var n=e.userid,o=e.streamtype,r="".concat(n,"_").concat(o),a=r,s=e.hasvideo,i=e.playurl,c=t.getUser(n);if(c){var u=c.streams[o];l.log(Q,"updateUserVideo start",c,o,u),u?(u.setPlayerAttributes({hasVideo:s}),s||u.playerAttributes.hasAudio||t._removeStream(u)):(u=new X({userID:n,streamID:r,hasVideo:s,src:i,streamType:o,id:a},t.ctx),c.streams[o]=u,t._addStream(u)),"aux"===o&&(s?(u.objectFit="contain",t._addStream(u)):t._removeStream(u)),t.userList.find((function(e){if(e.userID===n)return e["has".concat(o.replace(/^\S/,(function(e){return e.toUpperCase()})),"Video")]=s,!0})),l.log(Q,"updateUserVideo end",c,o,u);var d=s?p.REMOTE_VIDEO_ADD:p.REMOTE_VIDEO_REMOVE;t.emitter.emit(d,{player:u.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),m.log({name:K,player:u.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"updateUserAudio",value:function(e){var t=this,n=e.userlist;Array.isArray(n)&&n.length>0&&n.forEach((function(e){var n=e.userid,o="main",r="".concat(n,"_").concat(o),a=r,s=e.hasaudio,i=e.playurl,c=t.getUser(n);if(c){var u=c.streams.main;u?(u.setPlayerAttributes({hasAudio:s}),s||u.playerAttributes.hasVideo||t._removeStream(u)):(u=new X({userID:n,streamID:r,hasAudio:s,src:i,streamType:o,id:a},t.ctx),c.streams.main=u,t._addStream(u)),t.userList.find((function(e){if(e.userID===n)return e["has".concat(o.replace(/^\S/,(function(e){return e.toUpperCase()})),"Audio")]=s,!0}));var l=s?p.REMOTE_AUDIO_ADD:p.REMOTE_AUDIO_REMOVE;t.emitter.emit(l,{player:u.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),m.log({name:H,player:u.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"getUser",value:function(e){return this.userMap.get(e)}},{key:"getStream",value:function(e){var t=e.userID,n=e.streamType,o=this.userMap.get(t);if(o)return o.streams[n]}},{key:"getUserList",value:function(){return this.userList}},{key:"getStreamList",value:function(){return this.streamList}},{key:"getPlayerList",value:function(){for(var e=this.getStreamList(),t=[],n=0;n<e.length;n++)t.push(e[n].playerAttributes);return t}},{key:"reset",value:function(){return this.streamList.forEach((function(e){e.reset()})),this.streamList=[],this.userList=[],this.userMap.clear(),{userList:this.userList,streamList:this.streamList}}},{key:"_removeUserAndStream",value:function(e){this.streamList=this.streamList.filter((function(t){return t.playerAttributes.userID!==e&&""!==t.playerAttributes.userID})),this.userList=this.userList.filter((function(t){return t.userID!==e}))}},{key:"_addStream",value:function(e){this.streamList.includes(e)||this.streamList.push(e)}},{key:"_removeStream",value:function(e){this.streamList=this.streamList.filter((function(t){return t.playerAttributes.userID!==e.playerAttributes.userID||t.playerAttributes.streamType!==e.playerAttributes.streamType})),this.getUser(e.playerAttributes.userID).streams[e.playerAttributes.streamType]=void 0}}]),t}(),$=function(){function t(){e(this,t)}return n(t,[{key:"on",value:function(e,t,n){"function"==typeof t&&(this._stores=this._stores||{},(this._stores[e]=this._stores[e]||[]).push({cb:t,ctx:n}))}},{key:"emit",value:function(e){this._stores=this._stores||{};var t,n=this._stores[e];if(n){n=n.slice(0),(t=[].slice.call(arguments,1))[0]={eventCode:e,data:t[0]};for(var o=0,r=n.length;o<r;o++)n[o].cb.apply(n[o].ctx,t)}}},{key:"off",value:function(e,t){if(this._stores=this._stores||{},arguments.length){var n=this._stores[e];if(n)if(1!==arguments.length){for(var o=0,r=n.length;o<r;o++)if(n[o].cb===t){n.splice(o,1);break}}else delete this._stores[e]}else this._stores={}}}]),t}();return function(){function t(n,o){var r=this;e(this,t),this.env="prod",this.ctx=n,this.eventEmitter=new $,this.pusherInstance=null,this.userController=new Z(this.eventEmitter,this.ctx),this.EVENT=p,this.TUIScene=null==o?void 0:o.TUIScene,"test"!==(null==o?void 0:o.env)?wx.getSystemInfo({success:function(e){return r.systemInfo=e}}):(this.env="test",m.log=function(){},l.log=function(){},l.warn=function(){})}return n(t,[{key:"initLog",value:function(e){m.setConfig({sdkAppId:e.sdkAppID,userId:e.userID,version:"wechat-mini",TUIScene:this.TUIScene,env:this.env})}},{key:"on",value:function(e,t,n){l.log("[on] 事件订阅: ".concat(e)),this.eventEmitter.on(e,t,n)}},{key:"off",value:function(e,t){l.log("[off] 取消订阅: ".concat(e)),this.eventEmitter.off(e,t)}},{key:"createPusher",value:function(e){return this.pusherInstance=new z(e,this.ctx),this.pusherInstance}},{key:"getPusherInstance",value:function(){return this.pusherInstance}},{key:"enterRoom",value:function(e){l.log("[apiLog] [enterRoom]",e);var t=function(e){if(!d(e))return null;e.scene=e.scene&&"rtc"!==e.scene?e.scene:"videocall",e.enableBlackStream=e.enableBlackStream||"",e.encsmall=e.encsmall||0,e.cloudenv=e.cloudenv||"PRO",e.streamID=e.streamID||"",e.userDefineRecordID=e.userDefineRecordID||"",e.privateMapKey=e.privateMapKey||"",e.pureAudioMode=e.pureAudioMode||"",e.recvMode=e.recvMode||1;var t="";return t=e.strRoomID?"&strroomid=".concat(e.strRoomID):"&roomid=".concat(e.roomID),"room://cloud.tencent.com/rtc?sdkappid=".concat(e.sdkAppID).concat(t,"&userid=").concat(e.userID,"&usersig=").concat(e.userSig,"&appscene=").concat(e.scene,"&encsmall=").concat(e.encsmall,"&cloudenv=").concat(e.cloudenv,"&enableBlackStream=").concat(e.enableBlackStream,"&streamid=").concat(e.streamID,"&userdefinerecordid=").concat(e.userDefineRecordID,"&privatemapkey=").concat(e.privateMapKey,"&pureaudiomode=").concat(e.pureAudioMode,"&recvmode=").concat(e.recvMode,"&component=").concat(function(){var e=wx.TUIScene;switch(e=(e=e||wx.getStorageSync("TUIScene"))||getApp().globalData.TUIScene){case"sampleDemo":return 2;case"TUICalling":return 3;case"TUIRoom":return 5;case"TUIVoiceRoom":return 6;default:return 1}}())}(e);return this.initLog(a(a({},e),{},{env:this.env})),m.log({name:E}),t||(this.eventEmitter.emit(p.ERROR,{message:"进房参数错误"}),m.log({name:T,message:"进房参数错误",data:e})),this.pusherInstance.setPusherAttributes(a(a({},e),{},{url:t})),l.warn("[statusLog] [enterRoom]",this.pusherInstance.pusherAttributes),m.log({name:v,pusherConfig:this.pusherInstance.pusherAttributes}),this.getPusherAttributes()}},{key:"exitRoom",value:function(){this.userController.reset();var e=Object.assign({pusher:this.pusherInstance.reset()},{playerList:this.userController.getPlayerList()});return this.eventEmitter.emit(p.LOCAL_LEAVE),m.log({name:M,data:e}),e}},{key:"getPlayerList",value:function(){var e=this.userController.getPlayerList();return l.log("[apiLog][getStreamList]",e),e}},{key:"setPusherAttributes",value:function(e){return l.log("[apiLog] [setPusherAttributes], ",e),this.pusherInstance.setPusherAttributes(e),l.warn("[statusLog] [setPusherAttributes]",this.pusherInstance.pusherAttributes),m.log({name:y,options:e,pusherConfig:this.pusherInstance.pusherAttributes}),this.pusherInstance.pusherAttributes}},{key:"getPusherAttributes",value:function(){return l.log("[apiLog] [getPusherConfig]"),this.pusherInstance.pusherAttributes}},{key:"setPlayerAttributes",value:function(e,t){l.log("[apiLog] [setPlayerAttributes] id",e,"options: ",t);var n=this._transformStreamID(e),o=n.userID,r=n.streamType,a=this.userController.getStream({userID:o,streamType:r});return a?(a.setPlayerAttributes(t),m.log({name:I,id:e,options:t,playerList:this.getPlayerList()}),this.getPlayerList()):this.getPlayerList()}},{key:"getPlayerInstance",value:function(e){var t=this._transformStreamID(e),n=t.userID,o=t.streamType;return l.log("[api][getPlayerInstance] id:",e),this.userController.getStream({userID:n,streamType:o})}},{key:"switchStreamType",value:function(e){l.log("[apiLog] [switchStreamType] id: ",e);var t=this._transformStreamID(e),n=t.userID,o=t.streamType,r=this.userController.getStream({userID:n,streamType:o});return"main"===r._definitionType?(r.src=r.src.replace("main","small"),r._definitionType="small"):(r.src=r.src.replace("small","main"),r._definitionType="main"),this.getPlayerList()}},{key:"pusherEventHandler",value:function(e){this.userController.userEventHandler(e)}},{key:"pusherNetStatusHandler",value:function(e){var t=e.detail.info;this.pusherInstance.setPusherAttributes(t),this.eventEmitter.emit(p.LOCAL_NET_STATE_UPDATE,{pusher:this.pusherInstance.pusherAttributes})}},{key:"pusherErrorHandler",value:function(e){try{var t=e.detail.errCode,n=e.detail.errMsg;this.eventEmitter.emit(p.ERROR,{code:t,message:n}),m.log({name:T,code:t,message:n})}catch(t){l.error("pusher error data parser exception",e,t)}}},{key:"pusherBGMStartHandler",value:function(e){this.eventEmitter.emit(p.BGM_PLAY_START)}},{key:"pusherBGMProgressHandler",value:function(e){var t,n,o,r;this.eventEmitter.emit(p.BGM_PLAY_PROGRESS,{progress:null===(t=e.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.progress,duration:null===(o=e.data)||void 0===o||null===(r=o.detail)||void 0===r?void 0:r.duration})}},{key:"pusherBGMCompleteHandler",value:function(e){this.eventEmitter.emit(p.BGM_PLAY_COMPLETE)}},{key:"pusherAudioVolumeNotify",value:function(e){this.pusherInstance.pusherAttributes.volume=e.detail.volume,this.eventEmitter.emit(p.LOCAL_AUDIO_VOLUME_UPDATE,{pusher:this.pusherInstance.pusherAttributes})}},{key:"playerEventHandler",value:function(e){l.log("[statusLog][playerStateChange]",e),this.eventEmitter.emit(p.REMOTE_STATE_UPDATE,e)}},{key:"playerFullscreenChange",value:function(e){this.eventEmitter.emit(p.VIDEO_FULLSCREEN_UPDATE)}},{key:"playerNetStatus",value:function(e){var t=this._transformStreamID(e.currentTarget.dataset.streamid),n=t.userID,o=t.streamType,r=this.userController.getStream({userID:n,streamType:o});!r||r.videoWidth===e.detail.info.videoWidth&&r.videoHeight===e.detail.info.videoHeight||(r.setPlayerAttributes({netStatus:e.detail.info}),this.eventEmitter.emit(p.REMOTE_NET_STATE_UPDATE,{playerList:this.userController.getPlayerList()}))}},{key:"playerAudioVolumeNotify",value:function(e){var t=this._transformStreamID(e.currentTarget.dataset.streamid),n=t.userID,o=t.streamType,r=this.userController.getStream({userID:n,streamType:o}),a=e.detail.volume;r.setPlayerAttributes({volume:a}),this.eventEmitter.emit(p.REMOTE_AUDIO_VOLUME_UPDATE,{playerList:this.userController.getPlayerList()})}},{key:"_transformStreamID",value:function(e){var t=e.lastIndexOf("_");return{userID:e.slice(0,t),streamType:e.slice(t+1)}}}]),t}()}();function l(e,t,n){var o,r=n||{},a=r.noTrailing,s=void 0!==a&&a,i=r.noLeading,c=void 0!==i&&i,u=r.debounceMode,l=void 0===u?void 0:u,d=!1,p=0;function g(){o&&clearTimeout(o)}function h(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];var i=this,u=Date.now()-p;function h(){p=Date.now(),t.apply(i,r)}function _(){o=void 0}d||(c||!l||o||h(),g(),void 0===l&&u>e?c?(p=Date.now(),s||(o=setTimeout(l?_:h,e))):h():!0!==s&&(o=setTimeout(l?_:h,void 0===l?e-u:e)))}return h.cancel=function(){g(),d=!0},h}function d(e){try{wx.setStorageSync("cookies",e)}catch(e){console.error("saveCookiesToStorage失败:",e)}}function p(e){var t=e.name,n=e.value,o=e.expires,r=e.maxAge;return void 0===t||void 0===n?(console.error("输入不合法@getStandardCookieItem"),{}):{name:t,value:n,expires:o||g(r)}}function g(e){var t=1e3*(e||31536e3);return new Date((new Date).getTime()+t).toGMTString()}function h(e){void 0===e&&(e="");var t=_()[e],n="";return t?n=decodeURIComponent(t.value):(console.warn("该cookie项不存在,或者已过期:",e),n=""),n}function _(){var e;try{e=wx.getStorageSync("cookies")}catch(e){console.error("cookies初始化失败:",e)}return v(e,"Object")||(e={}),function(e){var t=e,n=!1,o=new Date;Object.keys(t).forEach((function(e){new Date(t[e].expires)<=o&&(n=!0,delete t[e])})),n&&d(Object.assign({},t))}(e),e}function f(e){var t=_();delete t[e],d(Object.assign({},t))}function m(e){if(e){var t=[],n={};0!==(t=e.replace(/(Expires=[A-Za-z]{3}),/gi,"$1_").split(",").map((function(e){return e.replace(/(Expires=[A-Za-z]{3})_/gi,"$1,")}))).length&&(t.forEach((function(e){var t=function(e){var t=e.split(";"),n={},o=t.shift(),r=o.indexOf("=");if(-1===r)return console.error("cookie value error ",e);var a=[o.slice(0,r),o.slice(r+1)];return a.length<2?console.error("cookie value error ",e):(n.name=a[0],n.value=a[1],t.forEach((function(e){e.match(/^\s*Expires=/i)&&(n.expires=new Date(e.split("=")[1]).toGMTString()),e.match(/^\s*Max-age=/i)&&(n.maxAge=+e.split("=")[1])})),n)}(e);t&&t.name&&(n[t.name]=t)})),function(e){if(!v(e,"Object"))return console.error("输入不合法@setCookie");var t=_(),n={};Object.keys(e).forEach((function(t){if(v(e[t],"Object")){var o=e[t],r=o.value,a=o.expires,s=o.maxAge;n[t]=p({name:t,value:r,expires:a,maxAge:s})}else n[t]=p({name:t,value:e[t]})})),d(Object.assign({},t,n))}(n))}}function v(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}!function(e){var t,n=Object.prototype,r=n.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,n,o){var r=t&&t.prototype instanceof f?t:f,a=Object.create(r.prototype),s=new O(o||[]);return a._invoke=function(e,t,n){var o=d;return function(r,a){if(o===g)throw new Error("Generator is already running");if(o===h){if("throw"===r)throw a;return R()}for(n.method=r,n.arg=a;;){var s=n.delegate;if(s){var i=S(s,n);if(i){if(i===_)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=g;var c=l(e,t,n);if("normal"===c.type){if(o=n.done?h:p,c.arg===_)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=h,n.method="throw",n.arg=c.arg)}}}(e,n,s),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d="suspendedStart",p="suspendedYield",g="executing",h="completed",_={};function f(){}function m(){}function v(){}var M={};M[s]=function(){return this};var y=Object.getPrototypeOf,I=y&&y(y(N([])));I&&I!==n&&r.call(I,s)&&(M=I);var E=v.prototype=f.prototype=Object.create(M);function T(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e){function t(n,a,s,i){var c=l(e[n],e,a);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"===o(d)&&r.call(d,"__await")?Promise.resolve(d.__await).then((function(e){t("next",e,s,i)}),(function(e){t("throw",e,s,i)})):Promise.resolve(d).then((function(e){u.value=e,s(u)}),(function(e){return t("throw",e,s,i)}))}i(c.arg)}var n;this._invoke=function(e,o){function r(){return new Promise((function(n,r){t(e,o,n,r)}))}return n=n?n.then(r,r):r()}}function S(e,n){var o=e.iterator[n.method];if(o===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,S(e,n),"throw"===n.method))return _;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var r=l(o,e.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,_;var a=r.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,_):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function N(e){if(e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}return{next:R}}function R(){return{value:t,done:!0}}m.prototype=E.constructor=v,v.constructor=m,v[c]=m.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c in e||(e[c]="GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},T(C.prototype),C.prototype[i]=function(){return this},e.AsyncIterator=C,e.async=function(t,n,o,r){var a=new C(u(t,n,o,r));return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(E),E[c]="Generator",E[s]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var o=t.pop();if(o in e)return n.value=o,n.done=!1,n}return n.done=!0,n}},e.values=N,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(D),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(o,r){return i.type="throw",i.arg=e,n.next=o,r&&(n.method="next",n.arg=t),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var o=n.completion;if("throw"===o.type){var r=o.arg;D(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,o){return this.delegate={iterator:N(e),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=t),_}}}({});var M=function(e,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},M(e,t)};var y=function(){return y=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},y.apply(this,arguments)};function I(e,t,n,o){return new(n||(n=Promise))((function(r,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function i(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}c((o=o.apply(e,t||[])).next())}))}function E(e,t){var n,o,r,a,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function T(e,t,n){if(n||2===arguments.length)for(var o,r=0,a=t.length;r<a;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var C=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++)e[n]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("")},S={};if(wx.canIUse("getDeviceInfo"))Object.assign(S,wx.getDeviceInfo());else if(wx.canIUse("getSystemInfoSync")){var A=wx.getSystemInfoSync(),D=A.brand,O=A.model,N=A.system,R=A.platform;Object.assign(S,{brand:D,model:O,system:N,platform:R})}var L=function(){return{deviceInfo:S,version:"0.1.0"}},k=function(){function e(e){var t=this;this.now=function(){var e=new Date;return"".concat([e.getFullYear(),e.getMonth()+1,e.getDate()].join("-")," ").concat([e.getHours(),e.getMinutes()<10?"0".concat(e.getMinutes()):e.getMinutes(),e.getSeconds()<10?"0".concat(e.getSeconds()):e.getSeconds()].join(":"))},this.convertAnyTypeToString=function(e){try{switch(typeof e){case"object":return e instanceof Error?"".concat(e.name," ").concat(e.message):JSON.stringify(e);case"function":return"";default:return"".concat(e)}}catch(e){return"convert failed"}},this.request=function(e,n){var o=uni.getAccountInfoSync().miniProgram,r=o.version,a=o.envVersion;return new Promise((function(o,s){wx.request({url:"https://api.tccc.qcloud.com/ccc/debug/seatLog",method:"POST",enableHttp2:!0,data:y(y({log:"[".concat(t.now(),"] [").concat(r||a,"] ").concat(e),level:n,timestamp:Date.now()},L()),{staff:{userId:h("openId"),sdkAppId:t.sdkAppId}}),success:o,fail:s})}))},this.log=function(e,n){void 0===n&&(n="debug"),h("sdkAppId")?t.sdkAppId=h("sdkAppId"):t.sdkAppId=uni.getAccountInfoSync().miniProgram.appId,t.request("[".concat(n.toUpperCase(),"] [").concat(e,"]"),n).then((function(){console.debug(e)})).catch((function(){return console.warn("log failed")}))},this.level=e||"debug",this.sdkAppId=uni.getAccountInfoSync().miniProgram.appId}return e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.map(this.convertAnyTypeToString).join(" ");this.log(n,"info")},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.map(this.convertAnyTypeToString).join(" ");this.log(n,"debug")},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.map(this.convertAnyTypeToString).join(" ");this.log(n,"warn")},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.map(this.convertAnyTypeToString).join(" ");this.log(n,"error")},e}(),P=new k,G=["/tccclogin/visitor/miniappLogin","/ccc/wxlogin"],b=function(e){var t=h("userKey"),n="";return!G.includes(e)&&t&&(n="Bearer ".concat(t)),n?{Authorization:n}:{}},w={development:{http:"https://api.tccc.qcloud.com",socket:"wss://test.cccstate.pstn.avc.qcloud.com/staff"},preproduction:{http:"https://pre.ccclogic.pstn.avc.qcloud.com",socket:"wss://pre.cccstate.pstn.avc.qcloud.com/staff"},production:{http:"https://api.tccc.qcloud.com",socket:"wss://api.tccc.qcloud.com/staff"}},U=function(){var e=wx.getEnterOptionsSync().query;if("string"==typeof e.scene){var t=e.scene.toUpperCase();if(t.startsWith("DEV-"))return w.development;if(t.startsWith("TEST-"))return w.preproduction}return w.production};function F(e,t){void 0===t&&(t={});var n=C();return new Promise((function(o,r){var a,s;wx.request({url:"".concat(U().http,"/").concat(e.replace(/^\//,"")),method:"POST",header:y({Cookie:(a=[],s=_(),Object.keys(s).forEach((function(e){a.push("".concat(e,"=").concat(s[e].value))})),a.join(";"))},b(e)),enableHttp2:!0,data:y(y({nonce:n,requestId:n,timestamp:"".concat(Date.now()),clientType:"3"},L()),t),success:function(t){var a=t.data,s=t.header,i=a;if(m(s["Set-Cookie"]||s["set-cookie"]||""),"0"===i.errorCode)return o(i);P.error("url: ".concat(e),"nonce: ".concat(n),t),"-2015"===i.errorCode&&(f("openId"),f("userKey")),r(y(y({},i),{message:null==i?void 0:i.msg}))},fail:function(e){r(e)}})}))}var q,V={exports:{}},x=V.exports=function(){function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function t(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){s(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,n){return(p=d()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&l(r,n.prototype),r}).apply(null,arguments)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return p(e,arguments,u(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),l(o,e)})(e)}function h(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}function m(e){var t=d();return function(){var n,o=u(e);if(t){var r=u(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments