trtc-sdk-v5 5.9.2-beta.8 → 5.9.2-osm.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -390,6 +390,7 @@ export declare interface RemoteVideoConfig {
390
390
  receiveWhenViewVisible?: boolean;
391
391
  viewRoot?: HTMLElement;
392
392
  canvasRender?: boolean;
393
+ poster?: string;
393
394
  };
394
395
  }
395
396
  export declare interface StopRemoteVideoConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.9.2-beta.8",
3
+ "version": "5.9.2-osm.1",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1 +1 @@
1
- var le=Object.create;var z=Object.defineProperty,ce=Object.defineProperties,he=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,be=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var X=(c,e,r)=>e in c?z(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r,_=(c,e)=>{for(var r in e||(e={}))ee.call(e,r)&&X(c,r,e[r]);if(Q)for(var r of Q(e))Se.call(e,r)&&X(c,r,e[r]);return c},H=(c,e)=>ce(c,pe(e));var Te=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var _e=(c,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ge(e))!ee.call(c,i)&&i!==r&&z(c,i,{get:()=>e[i],enumerable:!(o=he(e,i))||o.enumerable});return c};var j=(c,e,r)=>(r=c!=null?le(be(c)):{},_e(e||!c||!c.__esModule?z(r,"default",{value:c,enumerable:!0}):r,c));var g=(c,e,r)=>X(c,typeof e!="symbol"?e+"":e,r);var W=Te((re,$)=>{"use strict";(function(c){"use strict";function e(t,h){var a=(t&65535)+(h&65535),b=(t>>16)+(h>>16)+(a>>16);return b<<16|a&65535}function r(t,h){return t<<h|t>>>32-h}function o(t,h,a,b,T,D){return e(r(e(e(h,t),e(b,D)),T),a)}function i(t,h,a,b,T,D,f){return o(h&a|~h&b,t,h,T,D,f)}function l(t,h,a,b,T,D,f){return o(h&b|a&~b,t,h,T,D,f)}function s(t,h,a,b,T,D,f){return o(h^a^b,t,h,T,D,f)}function p(t,h,a,b,T,D,f){return o(a^(h|~b),t,h,T,D,f)}function S(t,h){t[h>>5]|=128<<h%32,t[(h+64>>>9<<4)+14]=h;var a,b,T,D,f,n=1732584193,m=-271733879,d=-1732584194,u=271733878;for(a=0;a<t.length;a+=16)b=n,T=m,D=d,f=u,n=i(n,m,d,u,t[a],7,-680876936),u=i(u,n,m,d,t[a+1],12,-389564586),d=i(d,u,n,m,t[a+2],17,606105819),m=i(m,d,u,n,t[a+3],22,-1044525330),n=i(n,m,d,u,t[a+4],7,-176418897),u=i(u,n,m,d,t[a+5],12,1200080426),d=i(d,u,n,m,t[a+6],17,-1473231341),m=i(m,d,u,n,t[a+7],22,-45705983),n=i(n,m,d,u,t[a+8],7,1770035416),u=i(u,n,m,d,t[a+9],12,-1958414417),d=i(d,u,n,m,t[a+10],17,-42063),m=i(m,d,u,n,t[a+11],22,-1990404162),n=i(n,m,d,u,t[a+12],7,1804603682),u=i(u,n,m,d,t[a+13],12,-40341101),d=i(d,u,n,m,t[a+14],17,-1502002290),m=i(m,d,u,n,t[a+15],22,1236535329),n=l(n,m,d,u,t[a+1],5,-165796510),u=l(u,n,m,d,t[a+6],9,-1069501632),d=l(d,u,n,m,t[a+11],14,643717713),m=l(m,d,u,n,t[a],20,-373897302),n=l(n,m,d,u,t[a+5],5,-701558691),u=l(u,n,m,d,t[a+10],9,38016083),d=l(d,u,n,m,t[a+15],14,-660478335),m=l(m,d,u,n,t[a+4],20,-405537848),n=l(n,m,d,u,t[a+9],5,568446438),u=l(u,n,m,d,t[a+14],9,-1019803690),d=l(d,u,n,m,t[a+3],14,-187363961),m=l(m,d,u,n,t[a+8],20,1163531501),n=l(n,m,d,u,t[a+13],5,-1444681467),u=l(u,n,m,d,t[a+2],9,-51403784),d=l(d,u,n,m,t[a+7],14,1735328473),m=l(m,d,u,n,t[a+12],20,-1926607734),n=s(n,m,d,u,t[a+5],4,-378558),u=s(u,n,m,d,t[a+8],11,-2022574463),d=s(d,u,n,m,t[a+11],16,1839030562),m=s(m,d,u,n,t[a+14],23,-35309556),n=s(n,m,d,u,t[a+1],4,-1530992060),u=s(u,n,m,d,t[a+4],11,1272893353),d=s(d,u,n,m,t[a+7],16,-155497632),m=s(m,d,u,n,t[a+10],23,-1094730640),n=s(n,m,d,u,t[a+13],4,681279174),u=s(u,n,m,d,t[a],11,-358537222),d=s(d,u,n,m,t[a+3],16,-722521979),m=s(m,d,u,n,t[a+6],23,76029189),n=s(n,m,d,u,t[a+9],4,-640364487),u=s(u,n,m,d,t[a+12],11,-421815835),d=s(d,u,n,m,t[a+15],16,530742520),m=s(m,d,u,n,t[a+2],23,-995338651),n=p(n,m,d,u,t[a],6,-198630844),u=p(u,n,m,d,t[a+7],10,1126891415),d=p(d,u,n,m,t[a+14],15,-1416354905),m=p(m,d,u,n,t[a+5],21,-57434055),n=p(n,m,d,u,t[a+12],6,1700485571),u=p(u,n,m,d,t[a+3],10,-1894986606),d=p(d,u,n,m,t[a+10],15,-1051523),m=p(m,d,u,n,t[a+1],21,-2054922799),n=p(n,m,d,u,t[a+8],6,1873313359),u=p(u,n,m,d,t[a+15],10,-30611744),d=p(d,u,n,m,t[a+6],15,-1560198380),m=p(m,d,u,n,t[a+13],21,1309151649),n=p(n,m,d,u,t[a+4],6,-145523070),u=p(u,n,m,d,t[a+11],10,-1120210379),d=p(d,u,n,m,t[a+2],15,718787259),m=p(m,d,u,n,t[a+9],21,-343485551),n=e(n,b),m=e(m,T),d=e(d,D),u=e(u,f);return[n,m,d,u]}function C(t){var h,a="",b=t.length*32;for(h=0;h<b;h+=8)a+=String.fromCharCode(t[h>>5]>>>h%32&255);return a}function I(t){var h,a=[];for(a[(t.length>>2)-1]=void 0,h=0;h<a.length;h+=1)a[h]=0;var b=t.length*8;for(h=0;h<b;h+=8)a[h>>5]|=(t.charCodeAt(h/8)&255)<<h%32;return a}function U(t){return C(S(I(t),t.length*8))}function G(t,h){var a,b=I(t),T=[],D=[],f;for(T[15]=D[15]=void 0,b.length>16&&(b=S(b,t.length*8)),a=0;a<16;a+=1)T[a]=b[a]^909522486,D[a]=b[a]^1549556828;return f=S(T.concat(I(h)),512+h.length*8),C(S(D.concat(f),640))}function M(t){var h="0123456789abcdef",a="",b,T;for(T=0;T<t.length;T+=1)b=t.charCodeAt(T),a+=h.charAt(b>>>4&15)+h.charAt(b&15);return a}function R(t){return unescape(encodeURIComponent(t))}function E(t){return U(R(t))}function J(t){return M(E(t))}function B(t,h){return G(R(t),R(h))}function P(t,h){return M(B(t,h))}function V(t,h,a){return h?a?B(h,t):P(h,t):a?E(t):J(t)}typeof define=="function"&&define.amd?define(function(){return V}):typeof $=="object"&&$.exports?$.exports=V:c.md5=V})(re)});var te=j(W(),1);var y=(i=>(i.PublishMainStreamToCDN="publish-main-stream-to-cdn",i.PublishSubStreamToCDN="publish-sub-stream-to-cdn",i.PublishMixStreamToCDN="publish-mix-stream-to-cdn",i.PublishMixStreamToRoom="publish-mix-stream-to-room",i))(y||{}),K=(r=>(r.Main="main",r.Sub="sub",r))(K||{});var F={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5};var O=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_params");g(this,"_publishGivenCDNData",null);this._core=e,this._room=e.room,this._log=r}get isPublishingGivenCDN(){return!!this._params}async startPublishGivenCDN(e){if(this._log.info(`[CDNStreaming] startPublishGivenCDN() current: ${JSON.stringify(this._params)}, params: ${JSON.stringify(e)}`),this.isPublishingGivenCDN){let{appId:r,bizId:o,url:i}=this._params||{};if(r===e.appId&&o===e.bizId&&i===e.url)return;await this.stopPublishGivenCDN()}this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(e==null?void 0:e.publishMode),pushStreamId:e.streamId};try{let r=await this._room.sendStartPublishCDN(this._publishGivenCDNData,!1),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: start given cdn.");else throw this.resetGivenCDN(),this._log.error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i} options: ${JSON.stringify(e)}`),new Error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i}`)}catch(r){throw this.resetGivenCDN(),r}}async stopPublishGivenCDN(){if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),!this.isPublishingGivenCDN||!this._publishGivenCDNData){this.resetGivenCDN();return}let{pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l}=this._publishGivenCDNData,s={pushRequestTime:Date.now(),pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l},p=await this._room.sendStopPublishCDN(s,!1),{code:S,message:C}=p.data;if(S===0)this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN();else throw this._log.error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C} data: ${JSON.stringify(s)}`),new Error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C}`)}resetGivenCDN(){this._publishGivenCDNData=null,this._params=void 0}convertStreamType(e){return e==="publish-sub-stream-to-cdn"?"aux":"main"}};var x=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_config",null);g(this,"_data",null);g(this,"_givenCDNManager");this._core=e,this._room=e.room,this._log=r,this.reset()}get isMixing(){return!!this._data}get isStarted(){return!!this._config}get hasCustomCDN(){var e,r,o;return((e=this._config)==null?void 0:e.target.appId)&&((r=this._config)==null?void 0:r.target.bizId)&&((o=this._config)==null?void 0:o.target.url)}async startMixTranscode(e){if(this._log.info(`startMixTranscode: ${JSON.stringify(e)}`),this._config=e,this.installEvents(),!!this._core.room.isJoined)try{let r=this.getInputParam(e),o=this.getOutputParam(e),i=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&i!==this._data.outputSessionId&&(this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),await this.doStopMixTranscode()),await this.doStartMixTranscode({outputSessionId:i,inputParam:r,outputParam:o});let{appId:l,bizId:s,url:p,streamId:S=""}=e.target;l&&s&&p&&(this._givenCDNManager||(this._givenCDNManager=new O(this._core,this._log)),await this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:l,bizId:s,url:p,streamId:S}))}catch(r){throw this.reset(),r}}async doStartMixTranscode({outputSessionId:e,inputParam:r,outputParam:o}){let i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:e,inputParam:r,outputParam:o};this._log.info(`[CDNStreaming] doStartMixTranscode: ${JSON.stringify(i)}`);let l=await this._room.sendStartMixTranscode(i),{code:s}=l.data,{message:p}=l.data;if(s===0)this._log.info("[CDNStreaming] server success: start mix"),this._data=i;else throw s===-102083&&(p=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`),new Error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`)}async stopMixTranscode(){this._log.info("[CDNStreaming] stopMixTranscode");try{this.isStarted&&this.isMixing&&(await this.doStopMixTranscode(),this._config&&this.hasCustomCDN&&this._givenCDNManager&&await this._givenCDNManager.stopPublishGivenCDN())}catch(e){throw e}this.reset()}async doStopMixTranscode(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info(`[CDNStreaming] doStopMixTranscode: ${JSON.stringify(e)}`);let r=await this._room.sendStopMixTranscode(e),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: stop mix"),this.reset();else throw this._log.error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`),new Error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`)}reset(){this._config=null,this._data=null,this.uninstallEvents()}installEvents(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}async handleRoomJoined(){this._log.info(`[CDNStreaming] handleJoined: ${JSON.stringify(this._config)}`),this.isStarted&&this._config&&await this.startMixTranscode(this._config)}async handleRoomLeft(){this._log.info(`[CDNStreaming] handleRoomLeft: ${JSON.stringify(this._config)}`),this._data=null}getOutputSessionId({config:e,userId:r,roomId:o}){return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,te.default)(`${o}_${r}_main`)}getStringRoomId(e,r){return e?String(e):r}getInputParam(e){let{mix:r={}}=e,{audioMixUserList:o=[],videoLayoutList:i=[]}=r,l=i.map(s=>({userId:s.fixedVideoUser.userId,roomId:this.getStringRoomId(s.fixedVideoUser.roomId,s.fixedVideoUser.strRoomId)||this._core.room.roomId,width:s.width||0,height:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,zOrder:s.zOrder||1,streamType:s.fixedVideoStreamType==="sub"?1:0,inputType:F.IT_PURE_VIDEO,renderMode:s.fillMode||0}));return o.forEach(s=>{let p=this._core.room.roomId;(s.roomId||s.strRoomId)&&(p=this.getStringRoomId(s.roomId,s.strRoomId));let S=l.findIndex(C=>C.userId===s.userId&&C.roomId===p);S!==-1?l[S].inputType=F.IT_AUDIO_VIDEO:l.push({userId:s.userId,roomId:s.roomId||s.strRoomId||this._core.room.roomId,inputType:F.IT_PURE_AUDIO})}),l}getOutputParam(e){let r=e.target.streamId||"",{encoding:o={},mix:i={}}=e;return{streamId:r,streamType:r.length>0?1:0,width:this._core.utils.isUndefined(o.videoWidth)?640:o.videoWidth,height:this._core.utils.isUndefined(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}};var q=j(W(),1);var L=class{constructor(e,r){g(this,"_room");g(this,"_core");g(this,"_log");g(this,"_paramsForTencentCDN");g(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1});this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}installEvents(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}async handlePublished({track:e}){var i;if(e.room!==this._room||(this._log.info(`[CDNStreaming] handlePublished: mediaType ${e.mediaType}, roomID ${(i=e==null?void 0:e.room)==null?void 0:i.roomId}`),e.mediaType===1))return;let r=e.mediaType===4?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",o=this._paramsForTencentCDN.get(r)||null;o!=null&&o.target&&o.isStarted&&await this.startPublishTencentCDN(o.target)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1})}isStreamPublished(e){return e==="publish-main-stream-to-cdn"&&!this._room.isMainStreamPublished?(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1):e==="publish-sub-stream-to-cdn"&&!this._room.isAuxStreamPublished?(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):!0}changeDataStatus(e,r){let o=this._paramsForTencentCDN.get(e),i=_(_({},o),r);this._paramsForTencentCDN.set(e,i)}async startPublishTencentCDN(e){if(this._log.info(`[CDNStreaming] startPublishTencentCDN ${JSON.stringify(e)}`),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),!this.isStreamPublished(e.publishMode))return;let r=e.streamId||"",o=this.generatePublishCDNStreamId(r,e.publishMode),i=this.generatePublishCDNSessionId(e.publishMode),l=e.publishMode==="publish-sub-stream-to-cdn"?1:0,s={requestTime:Date.now(),sessionId:i,streamId:o,streamType:l};await this.doStartPublishTencentCDN(s,e.publishMode);let{appId:p,bizId:S,url:C}=e;if(p&&S&&C){let I=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN;I!=null&&I.givenCDNManager||(I.givenCDNManager=new O(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,I)),await I.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:p,bizId:S,url:C,streamId:o})}}async doStartPublishTencentCDN(e,r){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let o=6,i=500,l=0;for(;;){let s=await this._room.sendStartPublishCDN(e,!0),{code:p}=s.data,{message:S}=s.data;if(p===0){this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0});break}else if(p===-10006&&l<o)this._log.warn(`[CDNStreaming] doStartPublishTencentCDN: retry...${l+1}/6, reason: ${S}`),l+=1,await new Promise(C=>setTimeout(C,i));else throw this.changeDataStatus(r,{isPublished:!1}),p===-102083&&(S=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`),new Error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`)}}async stopPublishTencentCDN(e){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN;if(r.isPublished){let{target:o}=r;o!=null&&o.bizId&&o.appId&&o.url&&(r!=null&&r.givenCDNManager)&&await(r==null?void 0:r.givenCDNManager.stopPublishGivenCDN()),await this.doStopPublishTencentCDN(e)}this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}async doStopPublishTencentCDN(e){let r={requestTime:Date.now(),sessionId:(0,q.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)};this._log.info(`[CDNStreaming] doStopPublishTencentCDN: ${JSON.stringify(r)}`);let o=await this._room.sendStopPublishCDN(r,!0),{code:i}=o.data,{message:l}=o.data;if(i===0)this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e);else throw i===-102069&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),l=`can not stop in auto relayed-push mode ${l}`),this._log.error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`),new Error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`)}reset(e){this.uninstallEvents(),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}generatePublishCDNStreamId(e,r){if(e===""){let o=`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(r)}`;return/^[A-Za-z\d_-]*$/.test(o)||(o=(0,q.default)(o)),`${this._room.sdkAppId}_${o}`}return e}convertPublishModeToStreamType(e){return e==="publish-main-stream-to-cdn"?"main":"aux"}generatePublishCDNSessionId(e){return(0,q.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)}};var ae=j(W(),1);var v=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_seq");g(this,"_taskId",null);g(this,"_startData",null);g(this,"_updateData",null);g(this,"_stopData",null);this._core=e,this._room=e.room,this._log=r,this._seq=0}async startPushStreamToRoom(e){var l,s;this._seq+=1,this._startData=_({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,ae.default)(`${this._room.roomId}_${this._room.userId}_start`),agentParam:{cdnRobotUserid:`mcu_robot_${this._room.roomId}_${this._room.userId}`}},this.getCommonParams(e)),this._log.info(`startPushStreamToRoom: ${JSON.stringify(this._startData)}`);let r=await this._room.sendStartPushStreamToRoom(this._startData),{code:o,message:i}=r.data;o===0?(this._taskId=(s=(l=r.data)==null?void 0:l.data)==null?void 0:s.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",o,`can't resolve task id: ${JSON.stringify(r.data)}`),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",o,i)}async updatePushStreamToRoom(e){this._seq+=1,this._updateData=H(_({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info(`updatePushStreamToRoom: ${JSON.stringify(this._updateData)}`);let r=await this._room.sendUpdatePushStreamToRoom(this._updateData),{code:o,message:i}=r.data;o===0?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",o,i)}async stopPushStreamToRoom(){this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info(`stopPushStreamToRoom: ${JSON.stringify(this._stopData)}`);let e=await this._room.sendStopPushStreamToRoom(this._stopData),{code:r,message:o}=e.data;r===0?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",r,o)}reportServerError(e,r,o){let i=`server failed: ${e} errCode: ${r} errMsg: ${o}`;throw this._log.error(i),new Error(i)}getPushRtcRoomParams(e){let{robotUser:r}=e.target;return r?[{roomid:String((r==null?void 0:r.roomId)||(r==null?void 0:r.strRoomId))||this._room.roomId,roomType:r!=null&&r.roomId?0:1,pushRobotUserid:r==null?void 0:r.userId}]:[]}getCommonParams(e){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(e),videoParam:this.getVideoParam(e),pushRtcRoomParams:this.getPushRtcRoomParams(e),sequenceNumber:this._seq}}getAudioParam(e){let{mix:r={},encoding:o={}}=e,i={audioSamplerate:o.audioSampleRate||48e3,audioBitrateKbps:o.audioBitrate||64,audioChannels:o.audioChannels||1},{audioMixUserList:l}=r;return{audioEncodeParam:i,mixAudioUsers:(l==null?void 0:l.map(s=>({roomid:String(s.roomId||s.strRoomId)||this._room.roomId,userid:s.userId,roomType:s.roomId?0:1})))||[]}}getVideoParam(e){let{mix:r={},encoding:o={}}=e,i={videoCodec:2,videoWidth:o.videoWidth||640,videoHeight:o.videoHeight||480,videoFramerate:o.videoFramerate||15,videoGop:o.videoGOP||2,videoBitrateKbps:o.videoBitrate||800},{videoLayoutList:l}=r;return{videoEncodeParam:i,layoutParams:(l==null?void 0:l.map(s=>({userMediaStream:{userInfo:{roomid:String(s.fixedVideoUser.roomId||s.fixedVideoUser.strRoomId)||this._room.roomId,userid:s.fixedVideoUser.userId,roomType:s.fixedVideoUser.roomId?0:1},streamType:s.fixedVideoStreamType==="sub"?1:0},imageWidth:s.width||0,imageHeight:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,imageZorder:s.zOrder||1,renderMode:s.fillMode||0})))||[],backgroundColor:r.backgroundColor||0,backgroundImageUrl:r.backgroundImage||""}}};var oe=c=>typeof c=="string";var A;function De(c,e,r,o){if(!/^[A-Za-z\d_-]*$/.test(c)){let{RtcError:l,ErrorCode:s,ErrorCodeDictionary:p}=A;throw new l({code:s.INVALID_PARAMETER,extraCode:p.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}function Ie(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(oe(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(c===void 0)return;if(!(/^[1-9]\d*$/.test(String(c))&&c<4294967295))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}function fe(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}var N={type:"number",notLessThanZero:!0},Y={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:Ie},strRoomId:{type:"string",validate:fe}}},ie={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:De},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:_({},Y)},validate(c,e,r,o){let{publishMode:i,robotUser:l}=c;if(i==="publish-mix-stream-to-room"&&!l){let{RtcError:s,ErrorCode:p}=A;throw new s({code:p.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},se={required:!1,type:"object",properties:{videoWidth:N,videoHeight:N,videoBitrate:H(_({},N),{allowEmpty:!1}),videoFramerate:{type:"number",validate(c,e,r,o){if(c<=0||c>30){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate(c,e,r,o){if(c<1||c>8){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:N,audioBitrate:{type:"number",validate(c,e,r,o){if(c<32||c>192){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},ne={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:_({},Y)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},Y),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate(c,e,r,o){if(c<1||c>15){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:N,height:N,locationX:N,locationY:N}}}}};function me(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},ie),encoding:_({},se),mix:_({},ne)},validate(e,r,o,i){var S,C;let{publishMode:l}=e.target,{encoding:s,mix:p}=e;if(l==="publish-mix-stream-to-cdn"){let{RtcError:I,ErrorCode:U,ErrorCodeDictionary:G}=c.errorModule;if(!s)throw new I({code:U.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:U.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let M=0,R=0,E=[];if(p.videoLayoutList.forEach((P,V)=>{E.push(P.fixedVideoUser.userId),P.width+P.locationX>M&&(M=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),E.indexOf(c.room.userId)<0)throw new I({code:U.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});let J=(S=s==null?void 0:s.videoWidth)!=null?S:640,B=(C=s==null?void 0:s.videoHeight)!=null?C:480;if(J<M||B<R)throw new I({code:U.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}}}function de(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},ie),encoding:_({},se),mix:_({},ne)}}}function ue(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}var k=0,w=class w{constructor(e){this.core=e;g(this,"_mixTranscodeManager");g(this,"_publishCDNManager");g(this,"_pushStreamToRoomManager");g(this,"_core");g(this,"_modeOptions");g(this,"seq");g(this,"_log");k=k+1,this.seq=k,this._log=e.log.createChild({id:`${this.getAlias()}${k}`}),this._log.info(`[CDNStreaming] created id=${this.getAlias()}${k}`),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new x(e,this._log),this._publishCDNManager=new L(e,this._log),this._pushStreamToRoomManager=new v(e,this._log)}getName(){return w.Name}getAlias(){return"cdn"}getValidateRule(e){switch(e){case"start":return me(this._core);case"update":return de(this._core);case"stop":return ue(this._core)}}getGroup(e){return e.target.publishMode}async start(e){return this._modeOptions.set(e.target.publishMode,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.startPushStreamToRoom(e):await this.doStart(e)}async update(e){let r=this._modeOptions.get(e.target.publishMode);return this._core.utils.deepMerge(r,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.updatePushStreamToRoom(r):await this.doStart(r)}async stop(e){switch(e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.stopMixTranscode();break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);break}case"publish-mix-stream-to-room":{this._pushStreamToRoomManager.stopPushStreamToRoom();break}}this._modeOptions.delete(e.target.publishMode)}async doStart(e){switch(this._log.info(`[CDNStreaming] doStart: ${JSON.stringify(e)}`),e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.startMixTranscode(e);break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.startPublishTencentCDN(e.target);break}}}};g(w,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),g(w,"Name","CDNStreaming");var Z=w;var lr=Z;export{Z as CDNStreaming,y as PublishMode,K as TRTCStreamType,lr as default};
1
+ var le=Object.create;var z=Object.defineProperty,ce=Object.defineProperties,he=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,be=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var X=(c,e,r)=>e in c?z(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r,_=(c,e)=>{for(var r in e||(e={}))ee.call(e,r)&&X(c,r,e[r]);if(Q)for(var r of Q(e))Se.call(e,r)&&X(c,r,e[r]);return c},H=(c,e)=>ce(c,pe(e));var Te=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var _e=(c,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ge(e))!ee.call(c,i)&&i!==r&&z(c,i,{get:()=>e[i],enumerable:!(o=he(e,i))||o.enumerable});return c};var j=(c,e,r)=>(r=c!=null?le(be(c)):{},_e(e||!c||!c.__esModule?z(r,"default",{value:c,enumerable:!0}):r,c));var g=(c,e,r)=>X(c,typeof e!="symbol"?e+"":e,r);var W=Te((re,$)=>{"use strict";(function(c){"use strict";function e(t,h){var a=(t&65535)+(h&65535),b=(t>>16)+(h>>16)+(a>>16);return b<<16|a&65535}function r(t,h){return t<<h|t>>>32-h}function o(t,h,a,b,T,D){return e(r(e(e(h,t),e(b,D)),T),a)}function i(t,h,a,b,T,D,f){return o(h&a|~h&b,t,h,T,D,f)}function l(t,h,a,b,T,D,f){return o(h&b|a&~b,t,h,T,D,f)}function s(t,h,a,b,T,D,f){return o(h^a^b,t,h,T,D,f)}function p(t,h,a,b,T,D,f){return o(a^(h|~b),t,h,T,D,f)}function S(t,h){t[h>>5]|=128<<h%32,t[(h+64>>>9<<4)+14]=h;var a,b,T,D,f,n=1732584193,m=-271733879,u=-1732584194,d=271733878;for(a=0;a<t.length;a+=16)b=n,T=m,D=u,f=d,n=i(n,m,u,d,t[a],7,-680876936),d=i(d,n,m,u,t[a+1],12,-389564586),u=i(u,d,n,m,t[a+2],17,606105819),m=i(m,u,d,n,t[a+3],22,-1044525330),n=i(n,m,u,d,t[a+4],7,-176418897),d=i(d,n,m,u,t[a+5],12,1200080426),u=i(u,d,n,m,t[a+6],17,-1473231341),m=i(m,u,d,n,t[a+7],22,-45705983),n=i(n,m,u,d,t[a+8],7,1770035416),d=i(d,n,m,u,t[a+9],12,-1958414417),u=i(u,d,n,m,t[a+10],17,-42063),m=i(m,u,d,n,t[a+11],22,-1990404162),n=i(n,m,u,d,t[a+12],7,1804603682),d=i(d,n,m,u,t[a+13],12,-40341101),u=i(u,d,n,m,t[a+14],17,-1502002290),m=i(m,u,d,n,t[a+15],22,1236535329),n=l(n,m,u,d,t[a+1],5,-165796510),d=l(d,n,m,u,t[a+6],9,-1069501632),u=l(u,d,n,m,t[a+11],14,643717713),m=l(m,u,d,n,t[a],20,-373897302),n=l(n,m,u,d,t[a+5],5,-701558691),d=l(d,n,m,u,t[a+10],9,38016083),u=l(u,d,n,m,t[a+15],14,-660478335),m=l(m,u,d,n,t[a+4],20,-405537848),n=l(n,m,u,d,t[a+9],5,568446438),d=l(d,n,m,u,t[a+14],9,-1019803690),u=l(u,d,n,m,t[a+3],14,-187363961),m=l(m,u,d,n,t[a+8],20,1163531501),n=l(n,m,u,d,t[a+13],5,-1444681467),d=l(d,n,m,u,t[a+2],9,-51403784),u=l(u,d,n,m,t[a+7],14,1735328473),m=l(m,u,d,n,t[a+12],20,-1926607734),n=s(n,m,u,d,t[a+5],4,-378558),d=s(d,n,m,u,t[a+8],11,-2022574463),u=s(u,d,n,m,t[a+11],16,1839030562),m=s(m,u,d,n,t[a+14],23,-35309556),n=s(n,m,u,d,t[a+1],4,-1530992060),d=s(d,n,m,u,t[a+4],11,1272893353),u=s(u,d,n,m,t[a+7],16,-155497632),m=s(m,u,d,n,t[a+10],23,-1094730640),n=s(n,m,u,d,t[a+13],4,681279174),d=s(d,n,m,u,t[a],11,-358537222),u=s(u,d,n,m,t[a+3],16,-722521979),m=s(m,u,d,n,t[a+6],23,76029189),n=s(n,m,u,d,t[a+9],4,-640364487),d=s(d,n,m,u,t[a+12],11,-421815835),u=s(u,d,n,m,t[a+15],16,530742520),m=s(m,u,d,n,t[a+2],23,-995338651),n=p(n,m,u,d,t[a],6,-198630844),d=p(d,n,m,u,t[a+7],10,1126891415),u=p(u,d,n,m,t[a+14],15,-1416354905),m=p(m,u,d,n,t[a+5],21,-57434055),n=p(n,m,u,d,t[a+12],6,1700485571),d=p(d,n,m,u,t[a+3],10,-1894986606),u=p(u,d,n,m,t[a+10],15,-1051523),m=p(m,u,d,n,t[a+1],21,-2054922799),n=p(n,m,u,d,t[a+8],6,1873313359),d=p(d,n,m,u,t[a+15],10,-30611744),u=p(u,d,n,m,t[a+6],15,-1560198380),m=p(m,u,d,n,t[a+13],21,1309151649),n=p(n,m,u,d,t[a+4],6,-145523070),d=p(d,n,m,u,t[a+11],10,-1120210379),u=p(u,d,n,m,t[a+2],15,718787259),m=p(m,u,d,n,t[a+9],21,-343485551),n=e(n,b),m=e(m,T),u=e(u,D),d=e(d,f);return[n,m,u,d]}function C(t){var h,a="",b=t.length*32;for(h=0;h<b;h+=8)a+=String.fromCharCode(t[h>>5]>>>h%32&255);return a}function I(t){var h,a=[];for(a[(t.length>>2)-1]=void 0,h=0;h<a.length;h+=1)a[h]=0;var b=t.length*8;for(h=0;h<b;h+=8)a[h>>5]|=(t.charCodeAt(h/8)&255)<<h%32;return a}function y(t){return C(S(I(t),t.length*8))}function G(t,h){var a,b=I(t),T=[],D=[],f;for(T[15]=D[15]=void 0,b.length>16&&(b=S(b,t.length*8)),a=0;a<16;a+=1)T[a]=b[a]^909522486,D[a]=b[a]^1549556828;return f=S(T.concat(I(h)),512+h.length*8),C(S(D.concat(f),640))}function U(t){var h="0123456789abcdef",a="",b,T;for(T=0;T<t.length;T+=1)b=t.charCodeAt(T),a+=h.charAt(b>>>4&15)+h.charAt(b&15);return a}function R(t){return unescape(encodeURIComponent(t))}function x(t){return y(R(t))}function J(t){return U(x(t))}function B(t,h){return G(R(t),R(h))}function P(t,h){return U(B(t,h))}function V(t,h,a){return h?a?B(h,t):P(h,t):a?x(t):J(t)}typeof define=="function"&&define.amd?define(function(){return V}):typeof $=="object"&&$.exports?$.exports=V:c.md5=V})(re)});var te=j(W(),1);var M=(i=>(i.PublishMainStreamToCDN="publish-main-stream-to-cdn",i.PublishSubStreamToCDN="publish-sub-stream-to-cdn",i.PublishMixStreamToCDN="publish-mix-stream-to-cdn",i.PublishMixStreamToRoom="publish-mix-stream-to-room",i))(M||{}),K=(r=>(r.Main="main",r.Sub="sub",r))(K||{});var F={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5};var O=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_params");g(this,"_publishGivenCDNData",null);this._core=e,this._room=e.room,this._log=r}get isPublishingGivenCDN(){return!!this._params}async startPublishGivenCDN(e){if(this._log.info(`[CDNStreaming] startPublishGivenCDN() current: ${JSON.stringify(this._params)}, params: ${JSON.stringify(e)}`),this.isPublishingGivenCDN){let{appId:r,bizId:o,url:i}=this._params||{};if(r===e.appId&&o===e.bizId&&i===e.url)return;await this.stopPublishGivenCDN()}this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(e==null?void 0:e.publishMode),pushStreamId:e.streamId};try{let r=await this._room.sendStartPublishCDN(this._publishGivenCDNData,!1),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: start given cdn.");else throw this.resetGivenCDN(),this._log.error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i} options: ${JSON.stringify(e)}`),new Error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i}`)}catch(r){throw this.resetGivenCDN(),r}}async stopPublishGivenCDN(){if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),!this.isPublishingGivenCDN||!this._publishGivenCDNData){this.resetGivenCDN();return}let{pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l}=this._publishGivenCDNData,s={pushRequestTime:Date.now(),pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l},p=await this._room.sendStopPublishCDN(s,!1),{code:S,message:C}=p.data;if(S===0)this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN();else throw this._log.error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C} data: ${JSON.stringify(s)}`),new Error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C}`)}resetGivenCDN(){this._publishGivenCDNData=null,this._params=void 0}convertStreamType(e){return e==="publish-sub-stream-to-cdn"?"aux":"main"}};var E=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_config",null);g(this,"_data",null);g(this,"_givenCDNManager");this._core=e,this._room=e.room,this._log=r,this.reset()}get isMixing(){return!!this._data}get isStarted(){return!!this._config}get hasCustomCDN(){var e,r,o;return((e=this._config)==null?void 0:e.target.appId)&&((r=this._config)==null?void 0:r.target.bizId)&&((o=this._config)==null?void 0:o.target.url)}async startMixTranscode(e){if(this._log.info(`startMixTranscode: ${JSON.stringify(e)}`),this._config=e,this.installEvents(),!!this._core.room.isJoined)try{let r=this.getInputParam(e),o=this.getOutputParam(e),i=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&i!==this._data.outputSessionId&&(this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),await this.doStopMixTranscode()),await this.doStartMixTranscode({outputSessionId:i,inputParam:r,outputParam:o});let{appId:l,bizId:s,url:p,streamId:S=""}=e.target;l&&s&&p&&(this._givenCDNManager||(this._givenCDNManager=new O(this._core,this._log)),await this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:l,bizId:s,url:p,streamId:S}))}catch(r){throw this.reset(),r}}async doStartMixTranscode({outputSessionId:e,inputParam:r,outputParam:o}){let i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:e,inputParam:r,outputParam:o};this._log.info(`[CDNStreaming] doStartMixTranscode: ${JSON.stringify(i)}`);let l=await this._room.sendStartMixTranscode(i),{code:s}=l.data,{message:p}=l.data;if(s===0)this._log.info("[CDNStreaming] server success: start mix"),this._data=i;else throw s===-102083&&(p=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`),new Error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`)}async stopMixTranscode(){this._log.info("[CDNStreaming] stopMixTranscode");try{this.isStarted&&this.isMixing&&(await this.doStopMixTranscode(),this._config&&this.hasCustomCDN&&this._givenCDNManager&&await this._givenCDNManager.stopPublishGivenCDN())}catch(e){throw e}this.reset()}async doStopMixTranscode(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info(`[CDNStreaming] doStopMixTranscode: ${JSON.stringify(e)}`);let r=await this._room.sendStopMixTranscode(e),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: stop mix"),this.reset();else throw this._log.error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`),new Error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`)}reset(){this._config=null,this._data=null,this.uninstallEvents()}installEvents(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}async handleRoomJoined(){this._log.info(`[CDNStreaming] handleJoined: ${JSON.stringify(this._config)}`),this.isStarted&&this._config&&await this.startMixTranscode(this._config)}async handleRoomLeft(){this._log.info(`[CDNStreaming] handleRoomLeft: ${JSON.stringify(this._config)}`),this._data=null}getOutputSessionId({config:e,userId:r,roomId:o}){return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,te.default)(`${o}_${r}_main`)}getStringRoomId(e,r){return e?String(e):r}getInputParam(e){let{mix:r={}}=e,{audioMixUserList:o=[],videoLayoutList:i=[]}=r,l=i.map(s=>({userId:s.fixedVideoUser.userId,roomId:this.getStringRoomId(s.fixedVideoUser.roomId,s.fixedVideoUser.strRoomId)||this._core.room.roomId,width:s.width||0,height:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,zOrder:s.zOrder||1,streamType:s.fixedVideoStreamType==="sub"?1:0,inputType:F.IT_PURE_VIDEO,renderMode:s.fillMode||0}));return o.forEach(s=>{let p=this._core.room.roomId;(s.roomId||s.strRoomId)&&(p=this.getStringRoomId(s.roomId,s.strRoomId));let S=l.findIndex(C=>C.userId===s.userId&&C.roomId===p);S!==-1?l[S].inputType=F.IT_AUDIO_VIDEO:l.push({userId:s.userId,roomId:s.roomId||s.strRoomId||this._core.room.roomId,inputType:F.IT_PURE_AUDIO})}),l}getOutputParam(e){let r=e.target.streamId||"",{encoding:o={},mix:i={}}=e;return{streamId:r,streamType:r.length>0?1:0,width:this._core.utils.isUndefined(o.videoWidth)?640:o.videoWidth,height:this._core.utils.isUndefined(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}};var q=j(W(),1);var L=class{constructor(e,r){g(this,"_room");g(this,"_core");g(this,"_log");g(this,"_paramsForTencentCDN");g(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1});this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}installEvents(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}async handlePublished({track:e}){var i;if(e.room!==this._room||(this._log.info(`[CDNStreaming] handlePublished: mediaType ${e.mediaType}, roomID ${(i=e==null?void 0:e.room)==null?void 0:i.roomId}`),e.mediaType===1))return;let r=e.mediaType===4?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",o=this._paramsForTencentCDN.get(r)||null;o!=null&&o.target&&o.isStarted&&await this.startPublishTencentCDN(o.target)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1})}isStreamPublished(e){return e==="publish-main-stream-to-cdn"&&!this._room.isMainStreamPublished?(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1):e==="publish-sub-stream-to-cdn"&&!this._room.isAuxStreamPublished?(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):!0}changeDataStatus(e,r){let o=this._paramsForTencentCDN.get(e),i=_(_({},o),r);this._paramsForTencentCDN.set(e,i)}async startPublishTencentCDN(e){if(this._log.info(`[CDNStreaming] startPublishTencentCDN ${JSON.stringify(e)}`),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),!this.isStreamPublished(e.publishMode))return;let r=e.streamId||"",o=this.generatePublishCDNStreamId(r,e.publishMode),i=this.generatePublishCDNSessionId(e.publishMode),l=e.publishMode==="publish-sub-stream-to-cdn"?1:0,s={requestTime:Date.now(),sessionId:i,streamId:o,streamType:l};await this.doStartPublishTencentCDN(s,e.publishMode);let{appId:p,bizId:S,url:C}=e;if(p&&S&&C){let I=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN;I!=null&&I.givenCDNManager||(I.givenCDNManager=new O(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,I)),await I.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:p,bizId:S,url:C,streamId:o})}}async doStartPublishTencentCDN(e,r){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let o=6,i=500,l=0;for(;;){let s=await this._room.sendStartPublishCDN(e,!0),{code:p}=s.data,{message:S}=s.data;if(p===0){this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0});break}else if(p===-10006&&l<o)this._log.warn(`[CDNStreaming] doStartPublishTencentCDN: retry...${l+1}/6, reason: ${S}`),l+=1,await new Promise(C=>setTimeout(C,i));else throw this.changeDataStatus(r,{isPublished:!1}),p===-102083&&(S=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`),new Error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`)}}async stopPublishTencentCDN(e){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN;if(r.isPublished){let{target:o}=r;o!=null&&o.bizId&&o.appId&&o.url&&(r!=null&&r.givenCDNManager)&&await(r==null?void 0:r.givenCDNManager.stopPublishGivenCDN()),await this.doStopPublishTencentCDN(e)}this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}async doStopPublishTencentCDN(e){let r={requestTime:Date.now(),sessionId:(0,q.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)};this._log.info(`[CDNStreaming] doStopPublishTencentCDN: ${JSON.stringify(r)}`);let o=await this._room.sendStopPublishCDN(r,!0),{code:i}=o.data,{message:l}=o.data;if(i===0)this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e);else throw i===-102069&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),l=`can not stop in auto relayed-push mode ${l}`),this._log.error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`),new Error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`)}reset(e){this.uninstallEvents(),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}generatePublishCDNStreamId(e,r){if(e===""){let o=`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(r)}`;return/^[A-Za-z\d_-]*$/.test(o)||(o=(0,q.default)(o)),`${this._room.sdkAppId}_${o}`}return e}convertPublishModeToStreamType(e){return e==="publish-main-stream-to-cdn"?"main":"aux"}generatePublishCDNSessionId(e){return(0,q.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)}};var ae=j(W(),1);var v=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_seq");g(this,"_taskId",null);g(this,"_startData",null);g(this,"_updateData",null);g(this,"_stopData",null);this._core=e,this._room=e.room,this._log=r,this._seq=0}async startPushStreamToRoom(e){var l,s;this._seq+=1,this._startData=_({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,ae.default)(`${this._room.roomId}_${this._room.userId}_start`),agentParam:{cdnRobotUserid:`mcu_robot_${this._room.roomId}_${this._room.userId}`}},this.getCommonParams(e)),this._log.info(`startPushStreamToRoom: ${JSON.stringify(this._startData)}`);let r=await this._room.sendStartPushStreamToRoom(this._startData),{code:o,message:i}=r.data;o===0?(this._taskId=(s=(l=r.data)==null?void 0:l.data)==null?void 0:s.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",o,`can't resolve task id: ${JSON.stringify(r.data)}`),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",o,i)}async updatePushStreamToRoom(e){this._seq+=1,this._updateData=H(_({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info(`updatePushStreamToRoom: ${JSON.stringify(this._updateData)}`);let r=await this._room.sendUpdatePushStreamToRoom(this._updateData),{code:o,message:i}=r.data;o===0?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",o,i)}async stopPushStreamToRoom(){this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info(`stopPushStreamToRoom: ${JSON.stringify(this._stopData)}`);let e=await this._room.sendStopPushStreamToRoom(this._stopData),{code:r,message:o}=e.data;r===0?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",r,o)}reportServerError(e,r,o){let i=`server failed: ${e} errCode: ${r} errMsg: ${o}`;throw this._log.error(i),new Error(i)}getPushRtcRoomParams(e){let{robotUser:r}=e.target;return r?[{roomid:String((r==null?void 0:r.roomId)||(r==null?void 0:r.strRoomId))||this._room.roomId,roomType:r!=null&&r.roomId?0:1,pushRobotUserid:r==null?void 0:r.userId}]:[]}getCommonParams(e){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(e),videoParam:this.getVideoParam(e),pushRtcRoomParams:this.getPushRtcRoomParams(e),sequenceNumber:this._seq}}getAudioParam(e){let{mix:r={},encoding:o={}}=e,i={audioSamplerate:o.audioSampleRate||48e3,audioBitrateKbps:o.audioBitrate||64,audioChannels:o.audioChannels||1},{audioMixUserList:l}=r;return{audioEncodeParam:i,mixAudioUsers:(l==null?void 0:l.map(s=>({roomid:String(s.roomId||s.strRoomId)||this._room.roomId,userid:s.userId,roomType:s.roomId?0:1})))||[]}}getVideoParam(e){let{mix:r={},encoding:o={}}=e,i={videoCodec:2,videoWidth:o.videoWidth||640,videoHeight:o.videoHeight||480,videoFramerate:o.videoFramerate||15,videoGop:o.videoGOP||2,videoBitrateKbps:o.videoBitrate||800},{videoLayoutList:l}=r;return{videoEncodeParam:i,layoutParams:(l==null?void 0:l.map(s=>({userMediaStream:{userInfo:{roomid:String(s.fixedVideoUser.roomId||s.fixedVideoUser.strRoomId)||this._room.roomId,userid:s.fixedVideoUser.userId,roomType:s.fixedVideoUser.roomId?0:1},streamType:s.fixedVideoStreamType==="sub"?1:0},imageWidth:s.width||0,imageHeight:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,imageZorder:s.zOrder||1,renderMode:s.fillMode||0})))||[],backgroundColor:r.backgroundColor||0,backgroundImageUrl:r.backgroundImage||""}}};var oe=c=>typeof c=="string";var A;function De(c,e,r,o){if(!/^[A-Za-z\d_-]*$/.test(c)){let{RtcError:l,ErrorCode:s,ErrorCodeDictionary:p}=A;throw new l({code:s.INVALID_PARAMETER,extraCode:p.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}function Ie(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(oe(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(c===void 0)return;if(!(/^[1-9]\d*$/.test(String(c))&&c<4294967295))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}function fe(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}var N={type:"number",notLessThanZero:!0},Y={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:Ie},strRoomId:{type:"string",validate:fe}}},ie={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:De},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:_({},Y)},validate(c,e,r,o){let{publishMode:i,robotUser:l}=c;if(i==="publish-mix-stream-to-room"&&!l){let{RtcError:s,ErrorCode:p}=A;throw new s({code:p.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},se={required:!1,type:"object",properties:{videoWidth:N,videoHeight:N,videoBitrate:H(_({},N),{allowEmpty:!1}),videoFramerate:{type:"number",validate(c,e,r,o){if(c<=0||c>30){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate(c,e,r,o){if(c<1||c>8){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:N,audioBitrate:{type:"number",validate(c,e,r,o){if(c<32||c>192){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},ne={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:_({},Y)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},Y),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate(c,e,r,o){if(c<1||c>15){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:N,height:N,locationX:N,locationY:N}}}}};function me(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},ie),encoding:_({},se),mix:_({},ne)},validate(e,r,o,i){var S,C;let{publishMode:l}=e.target,{encoding:s,mix:p}=e;if(l==="publish-mix-stream-to-cdn"){let{RtcError:I,ErrorCode:y,ErrorCodeDictionary:G}=c.errorModule;if(!s)throw new I({code:y.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:y.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let U=0,R=0,x=[];if(p.videoLayoutList.forEach((P,V)=>{x.push(P.fixedVideoUser.userId),P.width+P.locationX>U&&(U=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),x.indexOf(c.room.userId)<0)throw new I({code:y.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});let J=(S=s==null?void 0:s.videoWidth)!=null?S:640,B=(C=s==null?void 0:s.videoHeight)!=null?C:480;if(J<U||B<R)throw new I({code:y.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}}}function ue(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},ie),encoding:_({},se),mix:_({},ne)}}}function de(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}var k=0,w=class w{constructor(e){this.core=e;g(this,"_mixTranscodeManager");g(this,"_publishCDNManager");g(this,"_pushStreamToRoomManager");g(this,"_core");g(this,"_modeOptions");g(this,"seq");g(this,"_log");k=k+1,this.seq=k,this._log=e.log.createChild({id:`${this.getAlias()}${k}`}),this._log.info(`[CDNStreaming] created id=${this.getAlias()}${k}`),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new E(e,this._log),this._publishCDNManager=new L(e,this._log),this._pushStreamToRoomManager=new v(e,this._log)}getName(){return w.Name}getAlias(){return"cdn"}getValidateRule(e){switch(e){case"start":return me(this._core);case"update":return ue(this._core);case"stop":return de(this._core)}}getGroup(e){return e.target.publishMode}async start(e){return this._modeOptions.set(e.target.publishMode,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.startPushStreamToRoom(e):await this.doStart(e)}async update(e){let r=this._modeOptions.get(e.target.publishMode);return this._core.utils.deepMerge(r,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.updatePushStreamToRoom(r):await this.doStart(r)}async stop(e){switch(e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.stopMixTranscode();break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);break}case"publish-mix-stream-to-room":{this._pushStreamToRoomManager.stopPushStreamToRoom();break}}this._modeOptions.delete(e.target.publishMode)}async doStart(e){switch(this._log.info(`[CDNStreaming] doStart: ${JSON.stringify(e)}`),e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.startMixTranscode(e);break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.startPublishTencentCDN(e.target);break}}}};g(w,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),g(w,"Name","CDNStreaming");var Z=w;var lr=Z;export{Z as CDNStreaming,M as PublishMode,K as TRTCStreamType,lr as default};
@@ -1 +1 @@
1
- "use strict";var CDNStreaming=(()=>{var ce=Object.create;var x=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,Se=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var j=(c,e,r)=>e in c?x(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r,_=(c,e)=>{for(var r in e||(e={}))ee.call(e,r)&&j(c,r,e[r]);if(Q)for(var r of Q(e))Te.call(e,r)&&j(c,r,e[r]);return c},W=(c,e)=>he(c,ge(e));var _e=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports),Ce=(c,e)=>{for(var r in e)x(c,r,{get:e[r],enumerable:!0})},re=(c,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of be(e))!ee.call(c,i)&&i!==r&&x(c,i,{get:()=>e[i],enumerable:!(o=pe(e,i))||o.enumerable});return c};var Y=(c,e,r)=>(r=c!=null?ce(Se(c)):{},re(e||!c||!c.__esModule?x(r,"default",{value:c,enumerable:!0}):r,c)),De=c=>re(x({},"__esModule",{value:!0}),c);var g=(c,e,r)=>j(c,typeof e!="symbol"?e+"":e,r);var F=_e((te,K)=>{"use strict";(function(c){"use strict";function e(t,h){var a=(t&65535)+(h&65535),b=(t>>16)+(h>>16)+(a>>16);return b<<16|a&65535}function r(t,h){return t<<h|t>>>32-h}function o(t,h,a,b,T,D){return e(r(e(e(h,t),e(b,D)),T),a)}function i(t,h,a,b,T,D,f){return o(h&a|~h&b,t,h,T,D,f)}function l(t,h,a,b,T,D,f){return o(h&b|a&~b,t,h,T,D,f)}function s(t,h,a,b,T,D,f){return o(h^a^b,t,h,T,D,f)}function p(t,h,a,b,T,D,f){return o(a^(h|~b),t,h,T,D,f)}function S(t,h){t[h>>5]|=128<<h%32,t[(h+64>>>9<<4)+14]=h;var a,b,T,D,f,n=1732584193,m=-271733879,d=-1732584194,u=271733878;for(a=0;a<t.length;a+=16)b=n,T=m,D=d,f=u,n=i(n,m,d,u,t[a],7,-680876936),u=i(u,n,m,d,t[a+1],12,-389564586),d=i(d,u,n,m,t[a+2],17,606105819),m=i(m,d,u,n,t[a+3],22,-1044525330),n=i(n,m,d,u,t[a+4],7,-176418897),u=i(u,n,m,d,t[a+5],12,1200080426),d=i(d,u,n,m,t[a+6],17,-1473231341),m=i(m,d,u,n,t[a+7],22,-45705983),n=i(n,m,d,u,t[a+8],7,1770035416),u=i(u,n,m,d,t[a+9],12,-1958414417),d=i(d,u,n,m,t[a+10],17,-42063),m=i(m,d,u,n,t[a+11],22,-1990404162),n=i(n,m,d,u,t[a+12],7,1804603682),u=i(u,n,m,d,t[a+13],12,-40341101),d=i(d,u,n,m,t[a+14],17,-1502002290),m=i(m,d,u,n,t[a+15],22,1236535329),n=l(n,m,d,u,t[a+1],5,-165796510),u=l(u,n,m,d,t[a+6],9,-1069501632),d=l(d,u,n,m,t[a+11],14,643717713),m=l(m,d,u,n,t[a],20,-373897302),n=l(n,m,d,u,t[a+5],5,-701558691),u=l(u,n,m,d,t[a+10],9,38016083),d=l(d,u,n,m,t[a+15],14,-660478335),m=l(m,d,u,n,t[a+4],20,-405537848),n=l(n,m,d,u,t[a+9],5,568446438),u=l(u,n,m,d,t[a+14],9,-1019803690),d=l(d,u,n,m,t[a+3],14,-187363961),m=l(m,d,u,n,t[a+8],20,1163531501),n=l(n,m,d,u,t[a+13],5,-1444681467),u=l(u,n,m,d,t[a+2],9,-51403784),d=l(d,u,n,m,t[a+7],14,1735328473),m=l(m,d,u,n,t[a+12],20,-1926607734),n=s(n,m,d,u,t[a+5],4,-378558),u=s(u,n,m,d,t[a+8],11,-2022574463),d=s(d,u,n,m,t[a+11],16,1839030562),m=s(m,d,u,n,t[a+14],23,-35309556),n=s(n,m,d,u,t[a+1],4,-1530992060),u=s(u,n,m,d,t[a+4],11,1272893353),d=s(d,u,n,m,t[a+7],16,-155497632),m=s(m,d,u,n,t[a+10],23,-1094730640),n=s(n,m,d,u,t[a+13],4,681279174),u=s(u,n,m,d,t[a],11,-358537222),d=s(d,u,n,m,t[a+3],16,-722521979),m=s(m,d,u,n,t[a+6],23,76029189),n=s(n,m,d,u,t[a+9],4,-640364487),u=s(u,n,m,d,t[a+12],11,-421815835),d=s(d,u,n,m,t[a+15],16,530742520),m=s(m,d,u,n,t[a+2],23,-995338651),n=p(n,m,d,u,t[a],6,-198630844),u=p(u,n,m,d,t[a+7],10,1126891415),d=p(d,u,n,m,t[a+14],15,-1416354905),m=p(m,d,u,n,t[a+5],21,-57434055),n=p(n,m,d,u,t[a+12],6,1700485571),u=p(u,n,m,d,t[a+3],10,-1894986606),d=p(d,u,n,m,t[a+10],15,-1051523),m=p(m,d,u,n,t[a+1],21,-2054922799),n=p(n,m,d,u,t[a+8],6,1873313359),u=p(u,n,m,d,t[a+15],10,-30611744),d=p(d,u,n,m,t[a+6],15,-1560198380),m=p(m,d,u,n,t[a+13],21,1309151649),n=p(n,m,d,u,t[a+4],6,-145523070),u=p(u,n,m,d,t[a+11],10,-1120210379),d=p(d,u,n,m,t[a+2],15,718787259),m=p(m,d,u,n,t[a+9],21,-343485551),n=e(n,b),m=e(m,T),d=e(d,D),u=e(u,f);return[n,m,d,u]}function C(t){var h,a="",b=t.length*32;for(h=0;h<b;h+=8)a+=String.fromCharCode(t[h>>5]>>>h%32&255);return a}function I(t){var h,a=[];for(a[(t.length>>2)-1]=void 0,h=0;h<a.length;h+=1)a[h]=0;var b=t.length*8;for(h=0;h<b;h+=8)a[h>>5]|=(t.charCodeAt(h/8)&255)<<h%32;return a}function M(t){return C(S(I(t),t.length*8))}function V(t,h){var a,b=I(t),T=[],D=[],f;for(T[15]=D[15]=void 0,b.length>16&&(b=S(b,t.length*8)),a=0;a<16;a+=1)T[a]=b[a]^909522486,D[a]=b[a]^1549556828;return f=S(T.concat(I(h)),512+h.length*8),C(S(D.concat(f),640))}function y(t){var h="0123456789abcdef",a="",b,T;for(T=0;T<t.length;T+=1)b=t.charCodeAt(T),a+=h.charAt(b>>>4&15)+h.charAt(b&15);return a}function R(t){return unescape(encodeURIComponent(t))}function E(t){return M(R(t))}function z(t){return y(E(t))}function H(t,h){return V(R(t),R(h))}function P(t,h){return y(H(t,h))}function $(t,h,a){return h?a?H(h,t):P(h,t):a?E(t):z(t)}typeof define=="function"&&define.amd?define(function(){return $}):typeof K=="object"&&K.exports?K.exports=$:c.md5=$})(te)});var Re={};Ce(Re,{CDNStreaming:()=>X,PublishMode:()=>O,TRTCStreamType:()=>L,default:()=>Ne});var ae=Y(F(),1);var O=(i=>(i.PublishMainStreamToCDN="publish-main-stream-to-cdn",i.PublishSubStreamToCDN="publish-sub-stream-to-cdn",i.PublishMixStreamToCDN="publish-mix-stream-to-cdn",i.PublishMixStreamToRoom="publish-mix-stream-to-room",i))(O||{}),L=(r=>(r.Main="main",r.Sub="sub",r))(L||{});var q={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5};var U=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_params");g(this,"_publishGivenCDNData",null);this._core=e,this._room=e.room,this._log=r}get isPublishingGivenCDN(){return!!this._params}async startPublishGivenCDN(e){if(this._log.info(`[CDNStreaming] startPublishGivenCDN() current: ${JSON.stringify(this._params)}, params: ${JSON.stringify(e)}`),this.isPublishingGivenCDN){let{appId:r,bizId:o,url:i}=this._params||{};if(r===e.appId&&o===e.bizId&&i===e.url)return;await this.stopPublishGivenCDN()}this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(e==null?void 0:e.publishMode),pushStreamId:e.streamId};try{let r=await this._room.sendStartPublishCDN(this._publishGivenCDNData,!1),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: start given cdn.");else throw this.resetGivenCDN(),this._log.error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i} options: ${JSON.stringify(e)}`),new Error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i}`)}catch(r){throw this.resetGivenCDN(),r}}async stopPublishGivenCDN(){if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),!this.isPublishingGivenCDN||!this._publishGivenCDNData){this.resetGivenCDN();return}let{pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l}=this._publishGivenCDNData,s={pushRequestTime:Date.now(),pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l},p=await this._room.sendStopPublishCDN(s,!1),{code:S,message:C}=p.data;if(S===0)this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN();else throw this._log.error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C} data: ${JSON.stringify(s)}`),new Error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C}`)}resetGivenCDN(){this._publishGivenCDNData=null,this._params=void 0}convertStreamType(e){return e==="publish-sub-stream-to-cdn"?"aux":"main"}};var v=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_config",null);g(this,"_data",null);g(this,"_givenCDNManager");this._core=e,this._room=e.room,this._log=r,this.reset()}get isMixing(){return!!this._data}get isStarted(){return!!this._config}get hasCustomCDN(){var e,r,o;return((e=this._config)==null?void 0:e.target.appId)&&((r=this._config)==null?void 0:r.target.bizId)&&((o=this._config)==null?void 0:o.target.url)}async startMixTranscode(e){if(this._log.info(`startMixTranscode: ${JSON.stringify(e)}`),this._config=e,this.installEvents(),!!this._core.room.isJoined)try{let r=this.getInputParam(e),o=this.getOutputParam(e),i=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&i!==this._data.outputSessionId&&(this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),await this.doStopMixTranscode()),await this.doStartMixTranscode({outputSessionId:i,inputParam:r,outputParam:o});let{appId:l,bizId:s,url:p,streamId:S=""}=e.target;l&&s&&p&&(this._givenCDNManager||(this._givenCDNManager=new U(this._core,this._log)),await this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:l,bizId:s,url:p,streamId:S}))}catch(r){throw this.reset(),r}}async doStartMixTranscode({outputSessionId:e,inputParam:r,outputParam:o}){let i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:e,inputParam:r,outputParam:o};this._log.info(`[CDNStreaming] doStartMixTranscode: ${JSON.stringify(i)}`);let l=await this._room.sendStartMixTranscode(i),{code:s}=l.data,{message:p}=l.data;if(s===0)this._log.info("[CDNStreaming] server success: start mix"),this._data=i;else throw s===-102083&&(p=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`),new Error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`)}async stopMixTranscode(){this._log.info("[CDNStreaming] stopMixTranscode");try{this.isStarted&&this.isMixing&&(await this.doStopMixTranscode(),this._config&&this.hasCustomCDN&&this._givenCDNManager&&await this._givenCDNManager.stopPublishGivenCDN())}catch(e){throw e}this.reset()}async doStopMixTranscode(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info(`[CDNStreaming] doStopMixTranscode: ${JSON.stringify(e)}`);let r=await this._room.sendStopMixTranscode(e),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: stop mix"),this.reset();else throw this._log.error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`),new Error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`)}reset(){this._config=null,this._data=null,this.uninstallEvents()}installEvents(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}async handleRoomJoined(){this._log.info(`[CDNStreaming] handleJoined: ${JSON.stringify(this._config)}`),this.isStarted&&this._config&&await this.startMixTranscode(this._config)}async handleRoomLeft(){this._log.info(`[CDNStreaming] handleRoomLeft: ${JSON.stringify(this._config)}`),this._data=null}getOutputSessionId({config:e,userId:r,roomId:o}){return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,ae.default)(`${o}_${r}_main`)}getStringRoomId(e,r){return e?String(e):r}getInputParam(e){let{mix:r={}}=e,{audioMixUserList:o=[],videoLayoutList:i=[]}=r,l=i.map(s=>({userId:s.fixedVideoUser.userId,roomId:this.getStringRoomId(s.fixedVideoUser.roomId,s.fixedVideoUser.strRoomId)||this._core.room.roomId,width:s.width||0,height:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,zOrder:s.zOrder||1,streamType:s.fixedVideoStreamType==="sub"?1:0,inputType:q.IT_PURE_VIDEO,renderMode:s.fillMode||0}));return o.forEach(s=>{let p=this._core.room.roomId;(s.roomId||s.strRoomId)&&(p=this.getStringRoomId(s.roomId,s.strRoomId));let S=l.findIndex(C=>C.userId===s.userId&&C.roomId===p);S!==-1?l[S].inputType=q.IT_AUDIO_VIDEO:l.push({userId:s.userId,roomId:s.roomId||s.strRoomId||this._core.room.roomId,inputType:q.IT_PURE_AUDIO})}),l}getOutputParam(e){let r=e.target.streamId||"",{encoding:o={},mix:i={}}=e;return{streamId:r,streamType:r.length>0?1:0,width:this._core.utils.isUndefined(o.videoWidth)?640:o.videoWidth,height:this._core.utils.isUndefined(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}};var J=Y(F(),1);var k=class{constructor(e,r){g(this,"_room");g(this,"_core");g(this,"_log");g(this,"_paramsForTencentCDN");g(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1});this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}installEvents(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}async handlePublished({track:e}){var i;if(e.room!==this._room||(this._log.info(`[CDNStreaming] handlePublished: mediaType ${e.mediaType}, roomID ${(i=e==null?void 0:e.room)==null?void 0:i.roomId}`),e.mediaType===1))return;let r=e.mediaType===4?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",o=this._paramsForTencentCDN.get(r)||null;o!=null&&o.target&&o.isStarted&&await this.startPublishTencentCDN(o.target)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1})}isStreamPublished(e){return e==="publish-main-stream-to-cdn"&&!this._room.isMainStreamPublished?(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1):e==="publish-sub-stream-to-cdn"&&!this._room.isAuxStreamPublished?(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):!0}changeDataStatus(e,r){let o=this._paramsForTencentCDN.get(e),i=_(_({},o),r);this._paramsForTencentCDN.set(e,i)}async startPublishTencentCDN(e){if(this._log.info(`[CDNStreaming] startPublishTencentCDN ${JSON.stringify(e)}`),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),!this.isStreamPublished(e.publishMode))return;let r=e.streamId||"",o=this.generatePublishCDNStreamId(r,e.publishMode),i=this.generatePublishCDNSessionId(e.publishMode),l=e.publishMode==="publish-sub-stream-to-cdn"?1:0,s={requestTime:Date.now(),sessionId:i,streamId:o,streamType:l};await this.doStartPublishTencentCDN(s,e.publishMode);let{appId:p,bizId:S,url:C}=e;if(p&&S&&C){let I=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN;I!=null&&I.givenCDNManager||(I.givenCDNManager=new U(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,I)),await I.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:p,bizId:S,url:C,streamId:o})}}async doStartPublishTencentCDN(e,r){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let o=6,i=500,l=0;for(;;){let s=await this._room.sendStartPublishCDN(e,!0),{code:p}=s.data,{message:S}=s.data;if(p===0){this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0});break}else if(p===-10006&&l<o)this._log.warn(`[CDNStreaming] doStartPublishTencentCDN: retry...${l+1}/6, reason: ${S}`),l+=1,await new Promise(C=>setTimeout(C,i));else throw this.changeDataStatus(r,{isPublished:!1}),p===-102083&&(S=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`),new Error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`)}}async stopPublishTencentCDN(e){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN;if(r.isPublished){let{target:o}=r;o!=null&&o.bizId&&o.appId&&o.url&&(r!=null&&r.givenCDNManager)&&await(r==null?void 0:r.givenCDNManager.stopPublishGivenCDN()),await this.doStopPublishTencentCDN(e)}this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}async doStopPublishTencentCDN(e){let r={requestTime:Date.now(),sessionId:(0,J.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)};this._log.info(`[CDNStreaming] doStopPublishTencentCDN: ${JSON.stringify(r)}`);let o=await this._room.sendStopPublishCDN(r,!0),{code:i}=o.data,{message:l}=o.data;if(i===0)this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e);else throw i===-102069&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),l=`can not stop in auto relayed-push mode ${l}`),this._log.error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`),new Error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`)}reset(e){this.uninstallEvents(),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}generatePublishCDNStreamId(e,r){if(e===""){let o=`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(r)}`;return/^[A-Za-z\d_-]*$/.test(o)||(o=(0,J.default)(o)),`${this._room.sdkAppId}_${o}`}return e}convertPublishModeToStreamType(e){return e==="publish-main-stream-to-cdn"?"main":"aux"}generatePublishCDNSessionId(e){return(0,J.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)}};var oe=Y(F(),1);var w=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_seq");g(this,"_taskId",null);g(this,"_startData",null);g(this,"_updateData",null);g(this,"_stopData",null);this._core=e,this._room=e.room,this._log=r,this._seq=0}async startPushStreamToRoom(e){var l,s;this._seq+=1,this._startData=_({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,oe.default)(`${this._room.roomId}_${this._room.userId}_start`),agentParam:{cdnRobotUserid:`mcu_robot_${this._room.roomId}_${this._room.userId}`}},this.getCommonParams(e)),this._log.info(`startPushStreamToRoom: ${JSON.stringify(this._startData)}`);let r=await this._room.sendStartPushStreamToRoom(this._startData),{code:o,message:i}=r.data;o===0?(this._taskId=(s=(l=r.data)==null?void 0:l.data)==null?void 0:s.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",o,`can't resolve task id: ${JSON.stringify(r.data)}`),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",o,i)}async updatePushStreamToRoom(e){this._seq+=1,this._updateData=W(_({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info(`updatePushStreamToRoom: ${JSON.stringify(this._updateData)}`);let r=await this._room.sendUpdatePushStreamToRoom(this._updateData),{code:o,message:i}=r.data;o===0?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",o,i)}async stopPushStreamToRoom(){this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info(`stopPushStreamToRoom: ${JSON.stringify(this._stopData)}`);let e=await this._room.sendStopPushStreamToRoom(this._stopData),{code:r,message:o}=e.data;r===0?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",r,o)}reportServerError(e,r,o){let i=`server failed: ${e} errCode: ${r} errMsg: ${o}`;throw this._log.error(i),new Error(i)}getPushRtcRoomParams(e){let{robotUser:r}=e.target;return r?[{roomid:String((r==null?void 0:r.roomId)||(r==null?void 0:r.strRoomId))||this._room.roomId,roomType:r!=null&&r.roomId?0:1,pushRobotUserid:r==null?void 0:r.userId}]:[]}getCommonParams(e){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(e),videoParam:this.getVideoParam(e),pushRtcRoomParams:this.getPushRtcRoomParams(e),sequenceNumber:this._seq}}getAudioParam(e){let{mix:r={},encoding:o={}}=e,i={audioSamplerate:o.audioSampleRate||48e3,audioBitrateKbps:o.audioBitrate||64,audioChannels:o.audioChannels||1},{audioMixUserList:l}=r;return{audioEncodeParam:i,mixAudioUsers:(l==null?void 0:l.map(s=>({roomid:String(s.roomId||s.strRoomId)||this._room.roomId,userid:s.userId,roomType:s.roomId?0:1})))||[]}}getVideoParam(e){let{mix:r={},encoding:o={}}=e,i={videoCodec:2,videoWidth:o.videoWidth||640,videoHeight:o.videoHeight||480,videoFramerate:o.videoFramerate||15,videoGop:o.videoGOP||2,videoBitrateKbps:o.videoBitrate||800},{videoLayoutList:l}=r;return{videoEncodeParam:i,layoutParams:(l==null?void 0:l.map(s=>({userMediaStream:{userInfo:{roomid:String(s.fixedVideoUser.roomId||s.fixedVideoUser.strRoomId)||this._room.roomId,userid:s.fixedVideoUser.userId,roomType:s.fixedVideoUser.roomId?0:1},streamType:s.fixedVideoStreamType==="sub"?1:0},imageWidth:s.width||0,imageHeight:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,imageZorder:s.zOrder||1,renderMode:s.fillMode||0})))||[],backgroundColor:r.backgroundColor||0,backgroundImageUrl:r.backgroundImage||""}}};var ie=c=>typeof c=="string";var A;function fe(c,e,r,o){if(!/^[A-Za-z\d_-]*$/.test(c)){let{RtcError:l,ErrorCode:s,ErrorCodeDictionary:p}=A;throw new l({code:s.INVALID_PARAMETER,extraCode:p.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}function Pe(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(ie(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(c===void 0)return;if(!(/^[1-9]\d*$/.test(String(c))&&c<4294967295))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}function Ae(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}var N={type:"number",notLessThanZero:!0},Z={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:Pe},strRoomId:{type:"string",validate:Ae}}},se={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:fe},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:_({},Z)},validate(c,e,r,o){let{publishMode:i,robotUser:l}=c;if(i==="publish-mix-stream-to-room"&&!l){let{RtcError:s,ErrorCode:p}=A;throw new s({code:p.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},ne={required:!1,type:"object",properties:{videoWidth:N,videoHeight:N,videoBitrate:W(_({},N),{allowEmpty:!1}),videoFramerate:{type:"number",validate(c,e,r,o){if(c<=0||c>30){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate(c,e,r,o){if(c<1||c>8){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:N,audioBitrate:{type:"number",validate(c,e,r,o){if(c<32||c>192){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},me={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:_({},Z)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},Z),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate(c,e,r,o){if(c<1||c>15){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:N,height:N,locationX:N,locationY:N}}}}};function de(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},se),encoding:_({},ne),mix:_({},me)},validate(e,r,o,i){var S,C;let{publishMode:l}=e.target,{encoding:s,mix:p}=e;if(l==="publish-mix-stream-to-cdn"){let{RtcError:I,ErrorCode:M,ErrorCodeDictionary:V}=c.errorModule;if(!s)throw new I({code:M.INVALID_PARAMETER,extraCode:V.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:M.INVALID_PARAMETER,extraCode:V.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let y=0,R=0,E=[];if(p.videoLayoutList.forEach((P,$)=>{E.push(P.fixedVideoUser.userId),P.width+P.locationX>y&&(y=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),E.indexOf(c.room.userId)<0)throw new I({code:M.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});let z=(S=s==null?void 0:s.videoWidth)!=null?S:640,H=(C=s==null?void 0:s.videoHeight)!=null?C:480;if(z<y||H<R)throw new I({code:M.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}}}function ue(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},se),encoding:_({},ne),mix:_({},me)}}}function le(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}var G=0,B=class B{constructor(e){this.core=e;g(this,"_mixTranscodeManager");g(this,"_publishCDNManager");g(this,"_pushStreamToRoomManager");g(this,"_core");g(this,"_modeOptions");g(this,"seq");g(this,"_log");G=G+1,this.seq=G,this._log=e.log.createChild({id:`${this.getAlias()}${G}`}),this._log.info(`[CDNStreaming] created id=${this.getAlias()}${G}`),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new v(e,this._log),this._publishCDNManager=new k(e,this._log),this._pushStreamToRoomManager=new w(e,this._log)}getName(){return B.Name}getAlias(){return"cdn"}getValidateRule(e){switch(e){case"start":return de(this._core);case"update":return ue(this._core);case"stop":return le(this._core)}}getGroup(e){return e.target.publishMode}async start(e){return this._modeOptions.set(e.target.publishMode,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.startPushStreamToRoom(e):await this.doStart(e)}async update(e){let r=this._modeOptions.get(e.target.publishMode);return this._core.utils.deepMerge(r,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.updatePushStreamToRoom(r):await this.doStart(r)}async stop(e){switch(e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.stopMixTranscode();break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);break}case"publish-mix-stream-to-room":{this._pushStreamToRoomManager.stopPushStreamToRoom();break}}this._modeOptions.delete(e.target.publishMode)}async doStart(e){switch(this._log.info(`[CDNStreaming] doStart: ${JSON.stringify(e)}`),e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.startMixTranscode(e);break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.startPublishTencentCDN(e.target);break}}}};g(B,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),g(B,"Name","CDNStreaming");var X=B;var Ne=X;return De(Re);})().default;
1
+ "use strict";var CDNStreaming=(()=>{var ce=Object.create;var E=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,Se=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var j=(c,e,r)=>e in c?E(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r,_=(c,e)=>{for(var r in e||(e={}))ee.call(e,r)&&j(c,r,e[r]);if(Q)for(var r of Q(e))Te.call(e,r)&&j(c,r,e[r]);return c},W=(c,e)=>he(c,ge(e));var _e=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports),Ce=(c,e)=>{for(var r in e)E(c,r,{get:e[r],enumerable:!0})},re=(c,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of be(e))!ee.call(c,i)&&i!==r&&E(c,i,{get:()=>e[i],enumerable:!(o=pe(e,i))||o.enumerable});return c};var Y=(c,e,r)=>(r=c!=null?ce(Se(c)):{},re(e||!c||!c.__esModule?E(r,"default",{value:c,enumerable:!0}):r,c)),De=c=>re(E({},"__esModule",{value:!0}),c);var g=(c,e,r)=>j(c,typeof e!="symbol"?e+"":e,r);var F=_e((te,K)=>{"use strict";(function(c){"use strict";function e(t,h){var a=(t&65535)+(h&65535),b=(t>>16)+(h>>16)+(a>>16);return b<<16|a&65535}function r(t,h){return t<<h|t>>>32-h}function o(t,h,a,b,T,D){return e(r(e(e(h,t),e(b,D)),T),a)}function i(t,h,a,b,T,D,f){return o(h&a|~h&b,t,h,T,D,f)}function l(t,h,a,b,T,D,f){return o(h&b|a&~b,t,h,T,D,f)}function s(t,h,a,b,T,D,f){return o(h^a^b,t,h,T,D,f)}function p(t,h,a,b,T,D,f){return o(a^(h|~b),t,h,T,D,f)}function S(t,h){t[h>>5]|=128<<h%32,t[(h+64>>>9<<4)+14]=h;var a,b,T,D,f,n=1732584193,m=-271733879,u=-1732584194,d=271733878;for(a=0;a<t.length;a+=16)b=n,T=m,D=u,f=d,n=i(n,m,u,d,t[a],7,-680876936),d=i(d,n,m,u,t[a+1],12,-389564586),u=i(u,d,n,m,t[a+2],17,606105819),m=i(m,u,d,n,t[a+3],22,-1044525330),n=i(n,m,u,d,t[a+4],7,-176418897),d=i(d,n,m,u,t[a+5],12,1200080426),u=i(u,d,n,m,t[a+6],17,-1473231341),m=i(m,u,d,n,t[a+7],22,-45705983),n=i(n,m,u,d,t[a+8],7,1770035416),d=i(d,n,m,u,t[a+9],12,-1958414417),u=i(u,d,n,m,t[a+10],17,-42063),m=i(m,u,d,n,t[a+11],22,-1990404162),n=i(n,m,u,d,t[a+12],7,1804603682),d=i(d,n,m,u,t[a+13],12,-40341101),u=i(u,d,n,m,t[a+14],17,-1502002290),m=i(m,u,d,n,t[a+15],22,1236535329),n=l(n,m,u,d,t[a+1],5,-165796510),d=l(d,n,m,u,t[a+6],9,-1069501632),u=l(u,d,n,m,t[a+11],14,643717713),m=l(m,u,d,n,t[a],20,-373897302),n=l(n,m,u,d,t[a+5],5,-701558691),d=l(d,n,m,u,t[a+10],9,38016083),u=l(u,d,n,m,t[a+15],14,-660478335),m=l(m,u,d,n,t[a+4],20,-405537848),n=l(n,m,u,d,t[a+9],5,568446438),d=l(d,n,m,u,t[a+14],9,-1019803690),u=l(u,d,n,m,t[a+3],14,-187363961),m=l(m,u,d,n,t[a+8],20,1163531501),n=l(n,m,u,d,t[a+13],5,-1444681467),d=l(d,n,m,u,t[a+2],9,-51403784),u=l(u,d,n,m,t[a+7],14,1735328473),m=l(m,u,d,n,t[a+12],20,-1926607734),n=s(n,m,u,d,t[a+5],4,-378558),d=s(d,n,m,u,t[a+8],11,-2022574463),u=s(u,d,n,m,t[a+11],16,1839030562),m=s(m,u,d,n,t[a+14],23,-35309556),n=s(n,m,u,d,t[a+1],4,-1530992060),d=s(d,n,m,u,t[a+4],11,1272893353),u=s(u,d,n,m,t[a+7],16,-155497632),m=s(m,u,d,n,t[a+10],23,-1094730640),n=s(n,m,u,d,t[a+13],4,681279174),d=s(d,n,m,u,t[a],11,-358537222),u=s(u,d,n,m,t[a+3],16,-722521979),m=s(m,u,d,n,t[a+6],23,76029189),n=s(n,m,u,d,t[a+9],4,-640364487),d=s(d,n,m,u,t[a+12],11,-421815835),u=s(u,d,n,m,t[a+15],16,530742520),m=s(m,u,d,n,t[a+2],23,-995338651),n=p(n,m,u,d,t[a],6,-198630844),d=p(d,n,m,u,t[a+7],10,1126891415),u=p(u,d,n,m,t[a+14],15,-1416354905),m=p(m,u,d,n,t[a+5],21,-57434055),n=p(n,m,u,d,t[a+12],6,1700485571),d=p(d,n,m,u,t[a+3],10,-1894986606),u=p(u,d,n,m,t[a+10],15,-1051523),m=p(m,u,d,n,t[a+1],21,-2054922799),n=p(n,m,u,d,t[a+8],6,1873313359),d=p(d,n,m,u,t[a+15],10,-30611744),u=p(u,d,n,m,t[a+6],15,-1560198380),m=p(m,u,d,n,t[a+13],21,1309151649),n=p(n,m,u,d,t[a+4],6,-145523070),d=p(d,n,m,u,t[a+11],10,-1120210379),u=p(u,d,n,m,t[a+2],15,718787259),m=p(m,u,d,n,t[a+9],21,-343485551),n=e(n,b),m=e(m,T),u=e(u,D),d=e(d,f);return[n,m,u,d]}function C(t){var h,a="",b=t.length*32;for(h=0;h<b;h+=8)a+=String.fromCharCode(t[h>>5]>>>h%32&255);return a}function I(t){var h,a=[];for(a[(t.length>>2)-1]=void 0,h=0;h<a.length;h+=1)a[h]=0;var b=t.length*8;for(h=0;h<b;h+=8)a[h>>5]|=(t.charCodeAt(h/8)&255)<<h%32;return a}function U(t){return C(S(I(t),t.length*8))}function V(t,h){var a,b=I(t),T=[],D=[],f;for(T[15]=D[15]=void 0,b.length>16&&(b=S(b,t.length*8)),a=0;a<16;a+=1)T[a]=b[a]^909522486,D[a]=b[a]^1549556828;return f=S(T.concat(I(h)),512+h.length*8),C(S(D.concat(f),640))}function M(t){var h="0123456789abcdef",a="",b,T;for(T=0;T<t.length;T+=1)b=t.charCodeAt(T),a+=h.charAt(b>>>4&15)+h.charAt(b&15);return a}function R(t){return unescape(encodeURIComponent(t))}function x(t){return U(R(t))}function z(t){return M(x(t))}function H(t,h){return V(R(t),R(h))}function P(t,h){return M(H(t,h))}function $(t,h,a){return h?a?H(h,t):P(h,t):a?x(t):z(t)}typeof define=="function"&&define.amd?define(function(){return $}):typeof K=="object"&&K.exports?K.exports=$:c.md5=$})(te)});var Re={};Ce(Re,{CDNStreaming:()=>X,PublishMode:()=>O,TRTCStreamType:()=>L,default:()=>Ne});var ae=Y(F(),1);var O=(i=>(i.PublishMainStreamToCDN="publish-main-stream-to-cdn",i.PublishSubStreamToCDN="publish-sub-stream-to-cdn",i.PublishMixStreamToCDN="publish-mix-stream-to-cdn",i.PublishMixStreamToRoom="publish-mix-stream-to-room",i))(O||{}),L=(r=>(r.Main="main",r.Sub="sub",r))(L||{});var q={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5};var y=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_params");g(this,"_publishGivenCDNData",null);this._core=e,this._room=e.room,this._log=r}get isPublishingGivenCDN(){return!!this._params}async startPublishGivenCDN(e){if(this._log.info(`[CDNStreaming] startPublishGivenCDN() current: ${JSON.stringify(this._params)}, params: ${JSON.stringify(e)}`),this.isPublishingGivenCDN){let{appId:r,bizId:o,url:i}=this._params||{};if(r===e.appId&&o===e.bizId&&i===e.url)return;await this.stopPublishGivenCDN()}this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(e==null?void 0:e.publishMode),pushStreamId:e.streamId};try{let r=await this._room.sendStartPublishCDN(this._publishGivenCDNData,!1),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: start given cdn.");else throw this.resetGivenCDN(),this._log.error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i} options: ${JSON.stringify(e)}`),new Error(`[CDNStreaming] server failed: start given cdn errCode: ${o} errMsg: ${i}`)}catch(r){throw this.resetGivenCDN(),r}}async stopPublishGivenCDN(){if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),!this.isPublishingGivenCDN||!this._publishGivenCDNData){this.resetGivenCDN();return}let{pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l}=this._publishGivenCDNData,s={pushRequestTime:Date.now(),pushAppId:e,pushBizId:r,pushCdnUrl:o,pushStreamType:i,pushStreamId:l},p=await this._room.sendStopPublishCDN(s,!1),{code:S,message:C}=p.data;if(S===0)this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN();else throw this._log.error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C} data: ${JSON.stringify(s)}`),new Error(`[CDNStreaming] server failed: stop given cdn errCode: ${S} errMsg: ${C}`)}resetGivenCDN(){this._publishGivenCDNData=null,this._params=void 0}convertStreamType(e){return e==="publish-sub-stream-to-cdn"?"aux":"main"}};var v=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_config",null);g(this,"_data",null);g(this,"_givenCDNManager");this._core=e,this._room=e.room,this._log=r,this.reset()}get isMixing(){return!!this._data}get isStarted(){return!!this._config}get hasCustomCDN(){var e,r,o;return((e=this._config)==null?void 0:e.target.appId)&&((r=this._config)==null?void 0:r.target.bizId)&&((o=this._config)==null?void 0:o.target.url)}async startMixTranscode(e){if(this._log.info(`startMixTranscode: ${JSON.stringify(e)}`),this._config=e,this.installEvents(),!!this._core.room.isJoined)try{let r=this.getInputParam(e),o=this.getOutputParam(e),i=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&i!==this._data.outputSessionId&&(this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),await this.doStopMixTranscode()),await this.doStartMixTranscode({outputSessionId:i,inputParam:r,outputParam:o});let{appId:l,bizId:s,url:p,streamId:S=""}=e.target;l&&s&&p&&(this._givenCDNManager||(this._givenCDNManager=new y(this._core,this._log)),await this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:l,bizId:s,url:p,streamId:S}))}catch(r){throw this.reset(),r}}async doStartMixTranscode({outputSessionId:e,inputParam:r,outputParam:o}){let i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:e,inputParam:r,outputParam:o};this._log.info(`[CDNStreaming] doStartMixTranscode: ${JSON.stringify(i)}`);let l=await this._room.sendStartMixTranscode(i),{code:s}=l.data,{message:p}=l.data;if(s===0)this._log.info("[CDNStreaming] server success: start mix"),this._data=i;else throw s===-102083&&(p=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`),new Error(`[CDNStreaming] server failed: start mix errCode: ${s} errMsg: ${p}`)}async stopMixTranscode(){this._log.info("[CDNStreaming] stopMixTranscode");try{this.isStarted&&this.isMixing&&(await this.doStopMixTranscode(),this._config&&this.hasCustomCDN&&this._givenCDNManager&&await this._givenCDNManager.stopPublishGivenCDN())}catch(e){throw e}this.reset()}async doStopMixTranscode(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info(`[CDNStreaming] doStopMixTranscode: ${JSON.stringify(e)}`);let r=await this._room.sendStopMixTranscode(e),{code:o,message:i}=r.data;if(o===0)this._log.info("[CDNStreaming] server success: stop mix"),this.reset();else throw this._log.error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`),new Error(`[CDNStreaming] server failed: stop mix errCode: ${o} errMsg: ${i}`)}reset(){this._config=null,this._data=null,this.uninstallEvents()}installEvents(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}async handleRoomJoined(){this._log.info(`[CDNStreaming] handleJoined: ${JSON.stringify(this._config)}`),this.isStarted&&this._config&&await this.startMixTranscode(this._config)}async handleRoomLeft(){this._log.info(`[CDNStreaming] handleRoomLeft: ${JSON.stringify(this._config)}`),this._data=null}getOutputSessionId({config:e,userId:r,roomId:o}){return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,ae.default)(`${o}_${r}_main`)}getStringRoomId(e,r){return e?String(e):r}getInputParam(e){let{mix:r={}}=e,{audioMixUserList:o=[],videoLayoutList:i=[]}=r,l=i.map(s=>({userId:s.fixedVideoUser.userId,roomId:this.getStringRoomId(s.fixedVideoUser.roomId,s.fixedVideoUser.strRoomId)||this._core.room.roomId,width:s.width||0,height:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,zOrder:s.zOrder||1,streamType:s.fixedVideoStreamType==="sub"?1:0,inputType:q.IT_PURE_VIDEO,renderMode:s.fillMode||0}));return o.forEach(s=>{let p=this._core.room.roomId;(s.roomId||s.strRoomId)&&(p=this.getStringRoomId(s.roomId,s.strRoomId));let S=l.findIndex(C=>C.userId===s.userId&&C.roomId===p);S!==-1?l[S].inputType=q.IT_AUDIO_VIDEO:l.push({userId:s.userId,roomId:s.roomId||s.strRoomId||this._core.room.roomId,inputType:q.IT_PURE_AUDIO})}),l}getOutputParam(e){let r=e.target.streamId||"",{encoding:o={},mix:i={}}=e;return{streamId:r,streamType:r.length>0?1:0,width:this._core.utils.isUndefined(o.videoWidth)?640:o.videoWidth,height:this._core.utils.isUndefined(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}};var J=Y(F(),1);var k=class{constructor(e,r){g(this,"_room");g(this,"_core");g(this,"_log");g(this,"_paramsForTencentCDN");g(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1});this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}installEvents(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}async handlePublished({track:e}){var i;if(e.room!==this._room||(this._log.info(`[CDNStreaming] handlePublished: mediaType ${e.mediaType}, roomID ${(i=e==null?void 0:e.room)==null?void 0:i.roomId}`),e.mediaType===1))return;let r=e.mediaType===4?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",o=this._paramsForTencentCDN.get(r)||null;o!=null&&o.target&&o.isStarted&&await this.startPublishTencentCDN(o.target)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1})}isStreamPublished(e){return e==="publish-main-stream-to-cdn"&&!this._room.isMainStreamPublished?(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1):e==="publish-sub-stream-to-cdn"&&!this._room.isAuxStreamPublished?(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):!0}changeDataStatus(e,r){let o=this._paramsForTencentCDN.get(e),i=_(_({},o),r);this._paramsForTencentCDN.set(e,i)}async startPublishTencentCDN(e){if(this._log.info(`[CDNStreaming] startPublishTencentCDN ${JSON.stringify(e)}`),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),!this.isStreamPublished(e.publishMode))return;let r=e.streamId||"",o=this.generatePublishCDNStreamId(r,e.publishMode),i=this.generatePublishCDNSessionId(e.publishMode),l=e.publishMode==="publish-sub-stream-to-cdn"?1:0,s={requestTime:Date.now(),sessionId:i,streamId:o,streamType:l};await this.doStartPublishTencentCDN(s,e.publishMode);let{appId:p,bizId:S,url:C}=e;if(p&&S&&C){let I=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN;I!=null&&I.givenCDNManager||(I.givenCDNManager=new y(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,I)),await I.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:p,bizId:S,url:C,streamId:o})}}async doStartPublishTencentCDN(e,r){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let o=6,i=500,l=0;for(;;){let s=await this._room.sendStartPublishCDN(e,!0),{code:p}=s.data,{message:S}=s.data;if(p===0){this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0});break}else if(p===-10006&&l<o)this._log.warn(`[CDNStreaming] doStartPublishTencentCDN: retry...${l+1}/6, reason: ${S}`),l+=1,await new Promise(C=>setTimeout(C,i));else throw this.changeDataStatus(r,{isPublished:!1}),p===-102083&&(S=`Please enable relayed-push in ${this._core.constants.CLOUD_CONSOLE_URL} and try later, refer to ${this._core.constants.DOC_URL}tutorial-26-advanced-publish-cdn-stream.html`),this._log.error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`),new Error(`[CDNStreaming] server failed: start tencent cdn errCode: ${p} errMsg: ${S}`)}}async stopPublishTencentCDN(e){this._log.info(`[CDNStreaming] doStartPublishTencentCDN: ${JSON.stringify(e)}`);let r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN;if(r.isPublished){let{target:o}=r;o!=null&&o.bizId&&o.appId&&o.url&&(r!=null&&r.givenCDNManager)&&await(r==null?void 0:r.givenCDNManager.stopPublishGivenCDN()),await this.doStopPublishTencentCDN(e)}this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}async doStopPublishTencentCDN(e){let r={requestTime:Date.now(),sessionId:(0,J.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)};this._log.info(`[CDNStreaming] doStopPublishTencentCDN: ${JSON.stringify(r)}`);let o=await this._room.sendStopPublishCDN(r,!0),{code:i}=o.data,{message:l}=o.data;if(i===0)this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e);else throw i===-102069&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),l=`can not stop in auto relayed-push mode ${l}`),this._log.error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`),new Error(`[CDNStreaming] server failed: stop tencent cdn errCode: ${i} errMsg: ${l}`)}reset(e){this.uninstallEvents(),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}generatePublishCDNStreamId(e,r){if(e===""){let o=`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(r)}`;return/^[A-Za-z\d_-]*$/.test(o)||(o=(0,J.default)(o)),`${this._room.sdkAppId}_${o}`}return e}convertPublishModeToStreamType(e){return e==="publish-main-stream-to-cdn"?"main":"aux"}generatePublishCDNSessionId(e){return(0,J.default)(`${this._room.roomId}_${this._room.userId}_${this.convertPublishModeToStreamType(e)}`)}};var oe=Y(F(),1);var w=class{constructor(e,r){g(this,"_core");g(this,"_room");g(this,"_log");g(this,"_seq");g(this,"_taskId",null);g(this,"_startData",null);g(this,"_updateData",null);g(this,"_stopData",null);this._core=e,this._room=e.room,this._log=r,this._seq=0}async startPushStreamToRoom(e){var l,s;this._seq+=1,this._startData=_({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,oe.default)(`${this._room.roomId}_${this._room.userId}_start`),agentParam:{cdnRobotUserid:`mcu_robot_${this._room.roomId}_${this._room.userId}`}},this.getCommonParams(e)),this._log.info(`startPushStreamToRoom: ${JSON.stringify(this._startData)}`);let r=await this._room.sendStartPushStreamToRoom(this._startData),{code:o,message:i}=r.data;o===0?(this._taskId=(s=(l=r.data)==null?void 0:l.data)==null?void 0:s.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",o,`can't resolve task id: ${JSON.stringify(r.data)}`),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",o,i)}async updatePushStreamToRoom(e){this._seq+=1,this._updateData=W(_({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info(`updatePushStreamToRoom: ${JSON.stringify(this._updateData)}`);let r=await this._room.sendUpdatePushStreamToRoom(this._updateData),{code:o,message:i}=r.data;o===0?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",o,i)}async stopPushStreamToRoom(){this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info(`stopPushStreamToRoom: ${JSON.stringify(this._stopData)}`);let e=await this._room.sendStopPushStreamToRoom(this._stopData),{code:r,message:o}=e.data;r===0?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",r,o)}reportServerError(e,r,o){let i=`server failed: ${e} errCode: ${r} errMsg: ${o}`;throw this._log.error(i),new Error(i)}getPushRtcRoomParams(e){let{robotUser:r}=e.target;return r?[{roomid:String((r==null?void 0:r.roomId)||(r==null?void 0:r.strRoomId))||this._room.roomId,roomType:r!=null&&r.roomId?0:1,pushRobotUserid:r==null?void 0:r.userId}]:[]}getCommonParams(e){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(e),videoParam:this.getVideoParam(e),pushRtcRoomParams:this.getPushRtcRoomParams(e),sequenceNumber:this._seq}}getAudioParam(e){let{mix:r={},encoding:o={}}=e,i={audioSamplerate:o.audioSampleRate||48e3,audioBitrateKbps:o.audioBitrate||64,audioChannels:o.audioChannels||1},{audioMixUserList:l}=r;return{audioEncodeParam:i,mixAudioUsers:(l==null?void 0:l.map(s=>({roomid:String(s.roomId||s.strRoomId)||this._room.roomId,userid:s.userId,roomType:s.roomId?0:1})))||[]}}getVideoParam(e){let{mix:r={},encoding:o={}}=e,i={videoCodec:2,videoWidth:o.videoWidth||640,videoHeight:o.videoHeight||480,videoFramerate:o.videoFramerate||15,videoGop:o.videoGOP||2,videoBitrateKbps:o.videoBitrate||800},{videoLayoutList:l}=r;return{videoEncodeParam:i,layoutParams:(l==null?void 0:l.map(s=>({userMediaStream:{userInfo:{roomid:String(s.fixedVideoUser.roomId||s.fixedVideoUser.strRoomId)||this._room.roomId,userid:s.fixedVideoUser.userId,roomType:s.fixedVideoUser.roomId?0:1},streamType:s.fixedVideoStreamType==="sub"?1:0},imageWidth:s.width||0,imageHeight:s.height||0,locationX:s.locationX||0,locationY:s.locationY||0,imageZorder:s.zOrder||1,renderMode:s.fillMode||0})))||[],backgroundColor:r.backgroundColor||0,backgroundImageUrl:r.backgroundImage||""}}};var ie=c=>typeof c=="string";var A;function fe(c,e,r,o){if(!/^[A-Za-z\d_-]*$/.test(c)){let{RtcError:l,ErrorCode:s,ErrorCodeDictionary:p}=A;throw new l({code:s.INVALID_PARAMETER,extraCode:p.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}function Pe(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(ie(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(c===void 0)return;if(!(/^[1-9]\d*$/.test(String(c))&&c<4294967295))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}function Ae(c,e,r,o){let{RtcError:i,ErrorCode:l,ErrorCodeDictionary:s}=A;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(c))throw new i({code:l.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}var N={type:"number",notLessThanZero:!0},Z={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:Pe},strRoomId:{type:"string",validate:Ae}}},se={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:fe},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:_({},Z)},validate(c,e,r,o){let{publishMode:i,robotUser:l}=c;if(i==="publish-mix-stream-to-room"&&!l){let{RtcError:s,ErrorCode:p}=A;throw new s({code:p.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},ne={required:!1,type:"object",properties:{videoWidth:N,videoHeight:N,videoBitrate:W(_({},N),{allowEmpty:!1}),videoFramerate:{type:"number",validate(c,e,r,o){if(c<=0||c>30){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate(c,e,r,o){if(c<1||c>8){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:N,audioBitrate:{type:"number",validate(c,e,r,o){if(c<32||c>192){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},me={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:_({},Z)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},Z),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate(c,e,r,o){if(c<1||c>15){let{RtcError:i,ErrorCode:l}=A;throw new i({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:N,height:N,locationX:N,locationY:N}}}}};function ue(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},se),encoding:_({},ne),mix:_({},me)},validate(e,r,o,i){var S,C;let{publishMode:l}=e.target,{encoding:s,mix:p}=e;if(l==="publish-mix-stream-to-cdn"){let{RtcError:I,ErrorCode:U,ErrorCodeDictionary:V}=c.errorModule;if(!s)throw new I({code:U.INVALID_PARAMETER,extraCode:V.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:U.INVALID_PARAMETER,extraCode:V.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let M=0,R=0,x=[];if(p.videoLayoutList.forEach((P,$)=>{x.push(P.fixedVideoUser.userId),P.width+P.locationX>M&&(M=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),x.indexOf(c.room.userId)<0)throw new I({code:U.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});let z=(S=s==null?void 0:s.videoWidth)!=null?S:640,H=(C=s==null?void 0:s.videoHeight)!=null?C:480;if(z<M||H<R)throw new I({code:U.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}}}function de(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:_({},se),encoding:_({},ne),mix:_({},me)}}}function le(c){return A=c.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}var G=0,B=class B{constructor(e){this.core=e;g(this,"_mixTranscodeManager");g(this,"_publishCDNManager");g(this,"_pushStreamToRoomManager");g(this,"_core");g(this,"_modeOptions");g(this,"seq");g(this,"_log");G=G+1,this.seq=G,this._log=e.log.createChild({id:`${this.getAlias()}${G}`}),this._log.info(`[CDNStreaming] created id=${this.getAlias()}${G}`),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new v(e,this._log),this._publishCDNManager=new k(e,this._log),this._pushStreamToRoomManager=new w(e,this._log)}getName(){return B.Name}getAlias(){return"cdn"}getValidateRule(e){switch(e){case"start":return ue(this._core);case"update":return de(this._core);case"stop":return le(this._core)}}getGroup(e){return e.target.publishMode}async start(e){return this._modeOptions.set(e.target.publishMode,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.startPushStreamToRoom(e):await this.doStart(e)}async update(e){let r=this._modeOptions.get(e.target.publishMode);return this._core.utils.deepMerge(r,e),e.target.publishMode==="publish-mix-stream-to-room"?this._pushStreamToRoomManager.updatePushStreamToRoom(r):await this.doStart(r)}async stop(e){switch(e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.stopMixTranscode();break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);break}case"publish-mix-stream-to-room":{this._pushStreamToRoomManager.stopPushStreamToRoom();break}}this._modeOptions.delete(e.target.publishMode)}async doStart(e){switch(this._log.info(`[CDNStreaming] doStart: ${JSON.stringify(e)}`),e.target.publishMode){case"publish-mix-stream-to-cdn":{await this._mixTranscodeManager.startMixTranscode(e);break}case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":{await this._publishCDNManager.startPublishTencentCDN(e.target);break}}}};g(B,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),g(B,"Name","CDNStreaming");var X=B;var Ne=X;return De(Re);})().default;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.9.2-beta.8",
3
+ "version": "5.9.2-osm.1",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "author": "longyuqi <longyuqi@tencent.com>",
@@ -1 +1 @@
1
- var C=Object.defineProperty,G=Object.defineProperties,w=Object.getOwnPropertyDescriptor,W=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var I=(i,e,r)=>e in i?C(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,y=(i,e)=>{for(var r in e||(e={}))H.call(e,r)&&I(i,r,e[r]);if(_)for(var r of _(e))K.call(e,r)&&I(i,r,e[r]);return i},E=(i,e)=>G(i,W(e));var f=(i,e,r,o)=>{for(var t=o>1?void 0:o?w(e,r):e,a=i.length-1,n;a>=0;a--)(n=i[a])&&(t=(o?n(e,r,t):n(t))||t);return o&&t&&C(e,r,t),t};var b=(i,e,r)=>I(i,typeof e!="symbol"?e+"":e,r);var D={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},N={name:"option",required:!0,properties:E(y({},D.properties),{userId:{type:"string"}})},k={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:E(y({},N.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},L={name:"option",properties:y({},D.properties)};var p=i=>typeof i=="function";var j=0,F=1,V=2;function X({retryFunction:i,settings:e,onError:r,onRetrying:o,onRetryFailed:t,onRetrySuccess:a,context:n}){return function(...d){let{retries:m=5,timeout:u=1e3}=e,s=0,l=-1,c=j,g=async(O,A)=>{let M=n||this;try{let R=await i.apply(M,d);s>0&&a&&a.call(this,s),s=0,O(R)}catch(R){let h=()=>{clearTimeout(l),s=0,c=V,A(R)},P=()=>{c!==V&&s<(p(m)?m():m)?(s++,c=F,p(o)&&o.call(this,s,h),l=window.setTimeout(()=>{l=-1,g(O,A)},p(u)?u(s):u)):(h(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:P,reject:A,retryFuncArgs:d,retriedCount:s}):P()}};return new Promise(g)}}var B=X;var T=new WeakMap;function U({settings:i={retries:5,timeout:2e3},onError:e,onRetrying:r,onRetryFailed:o}){return function(t,a,n){let d=B({retryFunction:n.value,settings:i,onError({error:m,retry:u,reject:s,retryFuncArgs:l}){var c;e?e.call(this,m,()=>{var g;(g=T.get(t))!=null&&g.has(a)?u():s(m)},s,l):(c=T.get(t))!=null&&c.has(a)?u():s(m)},onRetrying(m,u){var s;p(r)&&r.call(this,m,u),(s=T.get(t))!=null&&s.has(a)&&(T.get(t).get(a).stopRetry=u)},onRetryFailed:o});return n.value=function(...m){let u=T.get(t);return u?u.set(a,{args:m}):T.set(t,new Map([[a,{args:m}]])),d.apply(this,m).finally(()=>{var s;return(s=T.get(t))==null?void 0:s.delete(a)})},n}}var S=class S{constructor(e){this.core=e;b(this,"disableRandomCall",!0);b(this,"connectedRoomIdSet",new Set);b(this,"updateSeq",0);b(this,"_log");this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return S.Name}getAlias(){return"crs-r"}getGroup(e){var o;let r=(e==null?void 0:e.userId)||((o=e==null?void 0:e.updateList)==null?void 0:o[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return N;case"update":return k;case"stop":return L}}async start({roomId:e,strRoomId:r,userId:o}){let{RtcError:t,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:a.ENV_NOT_SUPPORTED});let n=e||r,d=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:o,localRoomId:o?void 0:this.core.room.roomId},retries:3});if(d.data.code!==0)throw new t({code:a.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});o||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=e.find(d=>d.userId)?0:1,a=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:d,strRoomId:m,userId:u,muteAudio:s,muteVideo:l,muteSubStream:c})=>({roomId:d||m,userId:u,muteAudio:s,muteVideo:l,muteSubStream:c}))},retries:3});if(a.data.data.expectSeq)return this.updateSeq=a.data.data.expectSeq,this.update({updateList:e});if(a.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});if(((n=a.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:o.UNKNOWN_ERROR,message:a.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let o=e||r;if(o)await this.doStop(o);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};b(S,"Name","CrossRoom"),f([U({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),f([U({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],S.prototype,"update",1);var x=S;var ne=x;export{x as CrossRoom,ne as default};
1
+ var C=Object.defineProperty,G=Object.defineProperties,w=Object.getOwnPropertyDescriptor,W=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var I=(i,e,r)=>e in i?C(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,y=(i,e)=>{for(var r in e||(e={}))H.call(e,r)&&I(i,r,e[r]);if(_)for(var r of _(e))K.call(e,r)&&I(i,r,e[r]);return i},f=(i,e)=>G(i,W(e));var E=(i,e,r,a)=>{for(var t=a>1?void 0:a?w(e,r):e,o=i.length-1,n;o>=0;o--)(n=i[o])&&(t=(a?n(e,r,t):n(t))||t);return a&&t&&C(e,r,t),t};var b=(i,e,r)=>I(i,typeof e!="symbol"?e+"":e,r);var D={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},N={name:"option",required:!0,properties:f(y({},D.properties),{userId:{type:"string"}})},k={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:f(y({},N.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},L={name:"option",properties:y({},D.properties)};var p=i=>typeof i=="function";var j=0,F=1,V=2;function X({retryFunction:i,settings:e,onError:r,onRetrying:a,onRetryFailed:t,onRetrySuccess:o,context:n}){return function(...d){let{retries:m=5,timeout:u=1e3}=e,s=0,l=-1,c=j,g=async(O,A)=>{let M=n||this;try{let R=await i.apply(M,d);s>0&&o&&o.call(this,s),s=0,O(R)}catch(R){let h=()=>{clearTimeout(l),s=0,c=V,A(R)},P=()=>{c!==V&&s<(p(m)?m():m)?(s++,c=F,p(a)&&a.call(this,s,h),l=window.setTimeout(()=>{l=-1,g(O,A)},p(u)?u(s):u)):(h(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:P,reject:A,retryFuncArgs:d,retriedCount:s}):P()}};return new Promise(g)}}var B=X;var T=new WeakMap;function x({settings:i={retries:5,timeout:2e3},onError:e,onRetrying:r,onRetryFailed:a}){return function(t,o,n){let d=B({retryFunction:n.value,settings:i,onError({error:m,retry:u,reject:s,retryFuncArgs:l}){var c;e?e.call(this,m,()=>{var g;(g=T.get(t))!=null&&g.has(o)?u():s(m)},s,l):(c=T.get(t))!=null&&c.has(o)?u():s(m)},onRetrying(m,u){var s;p(r)&&r.call(this,m,u),(s=T.get(t))!=null&&s.has(o)&&(T.get(t).get(o).stopRetry=u)},onRetryFailed:a});return n.value=function(...m){let u=T.get(t);return u?u.set(o,{args:m}):T.set(t,new Map([[o,{args:m}]])),d.apply(this,m).finally(()=>{var s;return(s=T.get(t))==null?void 0:s.delete(o)})},n}}var S=class S{constructor(e){this.core=e;b(this,"disableRandomCall",!0);b(this,"connectedRoomIdSet",new Set);b(this,"updateSeq",0);b(this,"_log");this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return S.Name}getAlias(){return"crs-r"}getGroup(e){var a;let r=(e==null?void 0:e.userId)||((a=e==null?void 0:e.updateList)==null?void 0:a[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return N;case"update":return k;case"stop":return L}}async start({roomId:e,strRoomId:r,userId:a}){let{RtcError:t,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:o.ENV_NOT_SUPPORTED});let n=e||r,d=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});if(d.data.code!==0)throw new t({code:o.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});a||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=e.find(d=>d.userId)?0:1,o=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:d,strRoomId:m,userId:u,muteAudio:s,muteVideo:l,muteSubStream:c})=>({roomId:d||m,userId:u,muteAudio:s,muteVideo:l,muteSubStream:c}))},retries:3});if(o.data.data.expectSeq)return this.updateSeq=o.data.data.expectSeq,this.update({updateList:e});if(o.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:o.data.code,message:o.data.message});if(((n=o.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:a.UNKNOWN_ERROR,message:o.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let a=e||r;if(a)await this.doStop(a);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};b(S,"Name","CrossRoom"),E([x({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),E([x({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],S.prototype,"update",1);var U=S;var ne=U;export{U as CrossRoom,ne as default};
@@ -1 +1 @@
1
- "use strict";var CrossRoom=(()=>{var y=Object.defineProperty,W=Object.defineProperties,D=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var f=(a,e,r)=>e in a?y(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,A=(a,e)=>{for(var r in e||(e={}))k.call(e,r)&&f(a,r,e[r]);if(C)for(var r of C(e))j.call(e,r)&&f(a,r,e[r]);return a},N=(a,e)=>W(a,H(e));var F=(a,e)=>{for(var r in e)y(a,r,{get:e[r],enumerable:!0})},X=(a,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of K(e))!k.call(a,t)&&t!==r&&y(a,t,{get:()=>e[t],enumerable:!(o=D(e,t))||o.enumerable});return a};var q=a=>X(y({},"__esModule",{value:!0}),a),U=(a,e,r,o)=>{for(var t=o>1?void 0:o?D(e,r):e,s=a.length-1,n;s>=0;s--)(n=a[s])&&(t=(o?n(e,r,t):n(t))||t);return o&&t&&y(e,r,t),t};var b=(a,e,r)=>f(a,typeof e!="symbol"?e+"":e,r);var $={};F($,{CrossRoom:()=>I,default:()=>Z});var L={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},x={name:"option",required:!0,properties:N(A({},L.properties),{userId:{type:"string"}})},V={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:N(A({},x.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},B={name:"option",properties:A({},L.properties)};var p=a=>typeof a=="function";var v=0,J=1,M=2;function z({retryFunction:a,settings:e,onError:r,onRetrying:o,onRetryFailed:t,onRetrySuccess:s,context:n}){return function(...d){let{retries:m=5,timeout:u=1e3}=e,i=0,l=-1,c=v,g=async(h,E)=>{let w=n||this;try{let R=await a.apply(w,d);i>0&&s&&s.call(this,i),i=0,h(R)}catch(R){let P=()=>{clearTimeout(l),i=0,c=M,E(R)},_=()=>{c!==M&&i<(p(m)?m():m)?(i++,c=J,p(o)&&o.call(this,i,P),l=window.setTimeout(()=>{l=-1,g(h,E)},p(u)?u(i):u)):(P(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:_,reject:E,retryFuncArgs:d,retriedCount:i}):_()}};return new Promise(g)}}var G=z;var T=new WeakMap;function O({settings:a={retries:5,timeout:2e3},onError:e,onRetrying:r,onRetryFailed:o}){return function(t,s,n){let d=G({retryFunction:n.value,settings:a,onError({error:m,retry:u,reject:i,retryFuncArgs:l}){var c;e?e.call(this,m,()=>{var g;(g=T.get(t))!=null&&g.has(s)?u():i(m)},i,l):(c=T.get(t))!=null&&c.has(s)?u():i(m)},onRetrying(m,u){var i;p(r)&&r.call(this,m,u),(i=T.get(t))!=null&&i.has(s)&&(T.get(t).get(s).stopRetry=u)},onRetryFailed:o});return n.value=function(...m){let u=T.get(t);return u?u.set(s,{args:m}):T.set(t,new Map([[s,{args:m}]])),d.apply(this,m).finally(()=>{var i;return(i=T.get(t))==null?void 0:i.delete(s)})},n}}var S=class S{constructor(e){this.core=e;b(this,"disableRandomCall",!0);b(this,"connectedRoomIdSet",new Set);b(this,"updateSeq",0);b(this,"_log");this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return S.Name}getAlias(){return"crs-r"}getGroup(e){var o;let r=(e==null?void 0:e.userId)||((o=e==null?void 0:e.updateList)==null?void 0:o[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return x;case"update":return V;case"stop":return B}}async start({roomId:e,strRoomId:r,userId:o}){let{RtcError:t,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:s.ENV_NOT_SUPPORTED});let n=e||r,d=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:o,localRoomId:o?void 0:this.core.room.roomId},retries:3});if(d.data.code!==0)throw new t({code:s.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});o||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=e.find(d=>d.userId)?0:1,s=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:d,strRoomId:m,userId:u,muteAudio:i,muteVideo:l,muteSubStream:c})=>({roomId:d||m,userId:u,muteAudio:i,muteVideo:l,muteSubStream:c}))},retries:3});if(s.data.data.expectSeq)return this.updateSeq=s.data.data.expectSeq,this.update({updateList:e});if(s.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});if(((n=s.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:o.UNKNOWN_ERROR,message:s.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let o=e||r;if(o)await this.doStop(o);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};b(S,"Name","CrossRoom"),U([O({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),U([O({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],S.prototype,"update",1);var I=S;var Z=I;return q($);})().default;
1
+ "use strict";var CrossRoom=(()=>{var y=Object.defineProperty,W=Object.defineProperties,D=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var E=(o,e,r)=>e in o?y(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,A=(o,e)=>{for(var r in e||(e={}))k.call(e,r)&&E(o,r,e[r]);if(C)for(var r of C(e))j.call(e,r)&&E(o,r,e[r]);return o},N=(o,e)=>W(o,H(e));var F=(o,e)=>{for(var r in e)y(o,r,{get:e[r],enumerable:!0})},X=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of K(e))!k.call(o,t)&&t!==r&&y(o,t,{get:()=>e[t],enumerable:!(a=D(e,t))||a.enumerable});return o};var q=o=>X(y({},"__esModule",{value:!0}),o),x=(o,e,r,a)=>{for(var t=a>1?void 0:a?D(e,r):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(t=(a?n(e,r,t):n(t))||t);return a&&t&&y(e,r,t),t};var b=(o,e,r)=>E(o,typeof e!="symbol"?e+"":e,r);var $={};F($,{CrossRoom:()=>I,default:()=>Z});var L={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},U={name:"option",required:!0,properties:N(A({},L.properties),{userId:{type:"string"}})},V={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:N(A({},U.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},B={name:"option",properties:A({},L.properties)};var p=o=>typeof o=="function";var v=0,J=1,M=2;function z({retryFunction:o,settings:e,onError:r,onRetrying:a,onRetryFailed:t,onRetrySuccess:s,context:n}){return function(...d){let{retries:m=5,timeout:u=1e3}=e,i=0,l=-1,c=v,g=async(h,f)=>{let w=n||this;try{let R=await o.apply(w,d);i>0&&s&&s.call(this,i),i=0,h(R)}catch(R){let P=()=>{clearTimeout(l),i=0,c=M,f(R)},_=()=>{c!==M&&i<(p(m)?m():m)?(i++,c=J,p(a)&&a.call(this,i,P),l=window.setTimeout(()=>{l=-1,g(h,f)},p(u)?u(i):u)):(P(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:_,reject:f,retryFuncArgs:d,retriedCount:i}):_()}};return new Promise(g)}}var G=z;var T=new WeakMap;function O({settings:o={retries:5,timeout:2e3},onError:e,onRetrying:r,onRetryFailed:a}){return function(t,s,n){let d=G({retryFunction:n.value,settings:o,onError({error:m,retry:u,reject:i,retryFuncArgs:l}){var c;e?e.call(this,m,()=>{var g;(g=T.get(t))!=null&&g.has(s)?u():i(m)},i,l):(c=T.get(t))!=null&&c.has(s)?u():i(m)},onRetrying(m,u){var i;p(r)&&r.call(this,m,u),(i=T.get(t))!=null&&i.has(s)&&(T.get(t).get(s).stopRetry=u)},onRetryFailed:a});return n.value=function(...m){let u=T.get(t);return u?u.set(s,{args:m}):T.set(t,new Map([[s,{args:m}]])),d.apply(this,m).finally(()=>{var i;return(i=T.get(t))==null?void 0:i.delete(s)})},n}}var S=class S{constructor(e){this.core=e;b(this,"disableRandomCall",!0);b(this,"connectedRoomIdSet",new Set);b(this,"updateSeq",0);b(this,"_log");this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return S.Name}getAlias(){return"crs-r"}getGroup(e){var a;let r=(e==null?void 0:e.userId)||((a=e==null?void 0:e.updateList)==null?void 0:a[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return U;case"update":return V;case"stop":return B}}async start({roomId:e,strRoomId:r,userId:a}){let{RtcError:t,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:s.ENV_NOT_SUPPORTED});let n=e||r,d=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});if(d.data.code!==0)throw new t({code:s.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});a||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=e.find(d=>d.userId)?0:1,s=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:d,strRoomId:m,userId:u,muteAudio:i,muteVideo:l,muteSubStream:c})=>({roomId:d||m,userId:u,muteAudio:i,muteVideo:l,muteSubStream:c}))},retries:3});if(s.data.data.expectSeq)return this.updateSeq=s.data.data.expectSeq,this.update({updateList:e});if(s.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});if(((n=s.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:a.UNKNOWN_ERROR,message:s.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let a=e||r;if(a)await this.doStop(a);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};b(S,"Name","CrossRoom"),x([O({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),x([O({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],S.prototype,"update",1);var I=S;var Z=I;return q($);})().default;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.9.2-beta.8",
3
+ "version": "5.9.2-osm.1",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "author": "rychouwei <rychouwei@tencent.com>",
@@ -1,4 +1,4 @@
1
- var ws=Object.create;var ct=Object.defineProperty,xs=Object.defineProperties,Ts=Object.getOwnPropertyDescriptor,ys=Object.getOwnPropertyDescriptors,Us=Object.getOwnPropertyNames,Mi=Object.getOwnPropertySymbols,Rs=Object.getPrototypeOf,wi=Object.prototype.hasOwnProperty,Ds=Object.prototype.propertyIsEnumerable;var qt=(t,e,i)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,j=(t,e)=>{for(var i in e||(e={}))wi.call(e,i)&&qt(t,i,e[i]);if(Mi)for(var i of Mi(e))Ds.call(e,i)&&qt(t,i,e[i]);return t},H=(t,e)=>xs(t,ys(e));var a=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var bs=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let V of Us(e))!wi.call(t,V)&&V!==i&&ct(t,V,{get:()=>e[V],enumerable:!(r=Ts(e,V))||r.enumerable});return t};var ks=(t,e,i)=>(i=t!=null?ws(Rs(t)):{},bs(e||!t||!t.__esModule?ct(i,"default",{value:t,enumerable:!0}):i,t));var h=(t,e,i)=>qt(t,typeof e!="symbol"?e+"":e,i);var C=a((lt,xi)=>{"use strict";var se=function(t){return t&&t.Math===Math&&t};xi.exports=se(typeof globalThis=="object"&&globalThis)||se(typeof window=="object"&&window)||se(typeof self=="object"&&self)||se(typeof global=="object"&&global)||se(typeof lt=="object"&&lt)||function(){return this}()||Function("return this")()});var D=a((Aq,Ti)=>{"use strict";Ti.exports=function(t){try{return!!t()}catch(e){return!0}}});var B=a((nq,yi)=>{"use strict";var Ns=D();yi.exports=!Ns(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var pt=a((aq,Ui)=>{"use strict";var Bs=D();Ui.exports=!Bs(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var xe=a((qq,Ri)=>{"use strict";var Os=pt(),we=Function.prototype.call;Ri.exports=Os?we.bind(we):function(){return we.apply(we,arguments)}});var Ni=a(ki=>{"use strict";var Di={}.propertyIsEnumerable,bi=Object.getOwnPropertyDescriptor,Qs=bi&&!Di.call({1:2},1);ki.f=Qs?function(e){var i=bi(this,e);return!!i&&i.enumerable}:Di});var dt=a((lq,Bi)=>{"use strict";Bi.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var R=a((pq,Fi)=>{"use strict";var Oi=pt(),Qi=Function.prototype,ht=Qi.call,Fs=Oi&&Qi.bind.bind(ht,ht);Fi.exports=Oi?Fs:function(t){return function(){return ht.apply(t,arguments)}}});var Gi=a((dq,Ki)=>{"use strict";var Li=R(),Ls=Li({}.toString),Ks=Li("".slice);Ki.exports=function(t){return Ks(Ls(t),8,-1)}});var Wi=a((hq,Yi)=>{"use strict";var Gs=R(),Ys=D(),Ws=Gi(),ut=Object,Zs=Gs("".split);Yi.exports=Ys(function(){return!ut("z").propertyIsEnumerable(0)})?function(t){return Ws(t)==="String"?Zs(t,""):ut(t)}:ut});var gt=a((uq,Zi)=>{"use strict";Zi.exports=function(t){return t==null}});var mt=a((gq,Ji)=>{"use strict";var Js=gt(),Ps=TypeError;Ji.exports=function(t){if(Js(t))throw new Ps("Can't call method on "+t);return t}});var Te=a((mq,Pi)=>{"use strict";var zs=Wi(),js=mt();Pi.exports=function(t){return zs(js(t))}});var T=a((fq,zi)=>{"use strict";var ft=typeof document=="object"&&document.all;zi.exports=typeof ft=="undefined"&&ft!==void 0?function(t){return typeof t=="function"||t===ft}:function(t){return typeof t=="function"}});var X=a((Sq,ji)=>{"use strict";var Hs=T();ji.exports=function(t){return typeof t=="object"?t!==null:Hs(t)}});var It=a((Iq,Hi)=>{"use strict";var St=C(),Xs=T(),_s=function(t){return Xs(t)?t:void 0};Hi.exports=function(t,e){return arguments.length<2?_s(St[t]):St[t]&&St[t][e]}});var _i=a((vq,Xi)=>{"use strict";var $s=R();Xi.exports=$s({}.isPrototypeOf)});var ir=a((Eq,tr)=>{"use strict";var eA=C(),$i=eA.navigator,er=$i&&$i.userAgent;tr.exports=er?String(er):""});var ar=a((Cq,nr)=>{"use strict";var Ar=C(),vt=ir(),rr=Ar.process,Vr=Ar.Deno,or=rr&&rr.versions||Vr&&Vr.version,sr=or&&or.v8,y,ye;sr&&(y=sr.split("."),ye=y[0]>0&&y[0]<4?1:+(y[0]+y[1]));!ye&&vt&&(y=vt.match(/Edge\/(\d+)/),(!y||y[1]>=74)&&(y=vt.match(/Chrome\/(\d+)/),y&&(ye=+y[1])));nr.exports=ye});var Et=a((Mq,cr)=>{"use strict";var qr=ar(),tA=D(),iA=C(),rA=iA.String;cr.exports=!!Object.getOwnPropertySymbols&&!tA(function(){var t=Symbol("symbol detection");return!rA(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&qr&&qr<41})});var Ct=a((wq,lr)=>{"use strict";var VA=Et();lr.exports=VA&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Mt=a((xq,pr)=>{"use strict";var oA=It(),sA=T(),AA=_i(),nA=Ct(),aA=Object;pr.exports=nA?function(t){return typeof t=="symbol"}:function(t){var e=oA("Symbol");return sA(e)&&AA(e.prototype,aA(t))}});var hr=a((Tq,dr)=>{"use strict";var qA=String;dr.exports=function(t){try{return qA(t)}catch(e){return"Object"}}});var gr=a((yq,ur)=>{"use strict";var cA=T(),lA=hr(),pA=TypeError;ur.exports=function(t){if(cA(t))return t;throw new pA(lA(t)+" is not a function")}});var fr=a((Uq,mr)=>{"use strict";var dA=gr(),hA=gt();mr.exports=function(t,e){var i=t[e];return hA(i)?void 0:dA(i)}});var Ir=a((Rq,Sr)=>{"use strict";var wt=xe(),xt=T(),Tt=X(),uA=TypeError;Sr.exports=function(t,e){var i,r;if(e==="string"&&xt(i=t.toString)&&!Tt(r=wt(i,t))||xt(i=t.valueOf)&&!Tt(r=wt(i,t))||e!=="string"&&xt(i=t.toString)&&!Tt(r=wt(i,t)))return r;throw new uA("Can't convert object to primitive value")}});var Er=a((Dq,vr)=>{"use strict";vr.exports=!1});var Ue=a((bq,Mr)=>{"use strict";var Cr=C(),gA=Object.defineProperty;Mr.exports=function(t,e){try{gA(Cr,t,{value:e,configurable:!0,writable:!0})}catch(i){Cr[t]=e}return e}});var Re=a((kq,Tr)=>{"use strict";var mA=Er(),fA=C(),SA=Ue(),wr="__core-js_shared__",xr=Tr.exports=fA[wr]||SA(wr,{});(xr.versions||(xr.versions=[])).push({version:"3.38.1",mode:mA?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"})});var yt=a((Nq,Ur)=>{"use strict";var yr=Re();Ur.exports=function(t,e){return yr[t]||(yr[t]=e||{})}});var Dr=a((Bq,Rr)=>{"use strict";var IA=mt(),vA=Object;Rr.exports=function(t){return vA(IA(t))}});var O=a((Oq,br)=>{"use strict";var EA=R(),CA=Dr(),MA=EA({}.hasOwnProperty);br.exports=Object.hasOwn||function(e,i){return MA(CA(e),i)}});var Ut=a((Qq,kr)=>{"use strict";var wA=R(),xA=0,TA=Math.random(),yA=wA(1 .toString);kr.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+yA(++xA+TA,36)}});var Or=a((Fq,Br)=>{"use strict";var UA=C(),RA=yt(),Nr=O(),DA=Ut(),bA=Et(),kA=Ct(),_=UA.Symbol,Rt=RA("wks"),NA=kA?_.for||_:_&&_.withoutSetter||DA;Br.exports=function(t){return Nr(Rt,t)||(Rt[t]=bA&&Nr(_,t)?_[t]:NA("Symbol."+t)),Rt[t]}});var Kr=a((Lq,Lr)=>{"use strict";var BA=xe(),Qr=X(),Fr=Mt(),OA=fr(),QA=Ir(),FA=Or(),LA=TypeError,KA=FA("toPrimitive");Lr.exports=function(t,e){if(!Qr(t)||Fr(t))return t;var i=OA(t,KA),r;if(i){if(e===void 0&&(e="default"),r=BA(i,t,e),!Qr(r)||Fr(r))return r;throw new LA("Can't convert object to primitive value")}return e===void 0&&(e="number"),QA(t,e)}});var Dt=a((Kq,Gr)=>{"use strict";var GA=Kr(),YA=Mt();Gr.exports=function(t){var e=GA(t,"string");return YA(e)?e:e+""}});var Zr=a((Gq,Wr)=>{"use strict";var WA=C(),Yr=X(),bt=WA.document,ZA=Yr(bt)&&Yr(bt.createElement);Wr.exports=function(t){return ZA?bt.createElement(t):{}}});var kt=a((Yq,Jr)=>{"use strict";var JA=B(),PA=D(),zA=Zr();Jr.exports=!JA&&!PA(function(){return Object.defineProperty(zA("div"),"a",{get:function(){return 7}}).a!==7})});var Nt=a(zr=>{"use strict";var jA=B(),HA=xe(),XA=Ni(),_A=dt(),$A=Te(),en=Dt(),tn=O(),rn=kt(),Pr=Object.getOwnPropertyDescriptor;zr.f=jA?Pr:function(e,i){if(e=$A(e),i=en(i),rn)try{return Pr(e,i)}catch(r){}if(tn(e,i))return _A(!HA(XA.f,e,i),e[i])}});var Hr=a((Zq,jr)=>{"use strict";var Vn=B(),on=D();jr.exports=Vn&&on(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Bt=a((Jq,Xr)=>{"use strict";var sn=X(),An=String,nn=TypeError;Xr.exports=function(t){if(sn(t))return t;throw new nn(An(t)+" is not an object")}});var be=a($r=>{"use strict";var an=B(),qn=kt(),cn=Hr(),De=Bt(),_r=Dt(),ln=TypeError,Ot=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,Qt="enumerable",Ft="configurable",Lt="writable";$r.f=an?cn?function(e,i,r){if(De(e),i=_r(i),De(r),typeof e=="function"&&i==="prototype"&&"value"in r&&Lt in r&&!r[Lt]){var V=pn(e,i);V&&V[Lt]&&(e[i]=r.value,r={configurable:Ft in r?r[Ft]:V[Ft],enumerable:Qt in r?r[Qt]:V[Qt],writable:!1})}return Ot(e,i,r)}:Ot:function(e,i,r){if(De(e),i=_r(i),De(r),qn)try{return Ot(e,i,r)}catch(V){}if("get"in r||"set"in r)throw new ln("Accessors not supported");return"value"in r&&(e[i]=r.value),e}});var Kt=a((zq,eV)=>{"use strict";var dn=B(),hn=be(),un=dt();eV.exports=dn?function(t,e,i){return hn.f(t,e,un(1,i))}:function(t,e,i){return t[e]=i,t}});var rV=a((jq,iV)=>{"use strict";var Gt=B(),gn=O(),tV=Function.prototype,mn=Gt&&Object.getOwnPropertyDescriptor,Yt=gn(tV,"name"),fn=Yt&&function(){}.name==="something",Sn=Yt&&(!Gt||Gt&&mn(tV,"name").configurable);iV.exports={EXISTS:Yt,PROPER:fn,CONFIGURABLE:Sn}});var oV=a((Hq,VV)=>{"use strict";var In=R(),vn=T(),Wt=Re(),En=In(Function.toString);vn(Wt.inspectSource)||(Wt.inspectSource=function(t){return En(t)});VV.exports=Wt.inspectSource});var nV=a((Xq,AV)=>{"use strict";var Cn=C(),Mn=T(),sV=Cn.WeakMap;AV.exports=Mn(sV)&&/native code/.test(String(sV))});var cV=a((_q,qV)=>{"use strict";var wn=yt(),xn=Ut(),aV=wn("keys");qV.exports=function(t){return aV[t]||(aV[t]=xn(t))}});var Zt=a(($q,lV)=>{"use strict";lV.exports={}});var uV=a((ec,hV)=>{"use strict";var Tn=nV(),dV=C(),yn=X(),Un=Kt(),Jt=O(),Pt=Re(),Rn=cV(),Dn=Zt(),pV="Object already initialized",zt=dV.TypeError,bn=dV.WeakMap,ke,Ae,Ne,kn=function(t){return Ne(t)?Ae(t):ke(t,{})},Nn=function(t){return function(e){var i;if(!yn(e)||(i=Ae(e)).type!==t)throw new zt("Incompatible receiver, "+t+" required");return i}};Tn||Pt.state?(U=Pt.state||(Pt.state=new bn),U.get=U.get,U.has=U.has,U.set=U.set,ke=function(t,e){if(U.has(t))throw new zt(pV);return e.facade=t,U.set(t,e),e},Ae=function(t){return U.get(t)||{}},Ne=function(t){return U.has(t)}):(K=Rn("state"),Dn[K]=!0,ke=function(t,e){if(Jt(t,K))throw new zt(pV);return e.facade=t,Un(t,K,e),e},Ae=function(t){return Jt(t,K)?t[K]:{}},Ne=function(t){return Jt(t,K)});var U,K;hV.exports={set:ke,get:Ae,has:Ne,enforce:kn,getterFor:Nn}});var SV=a((tc,fV)=>{"use strict";var Ht=R(),Bn=D(),On=T(),Be=O(),jt=B(),Qn=rV().CONFIGURABLE,Fn=oV(),mV=uV(),Ln=mV.enforce,Kn=mV.get,gV=String,Oe=Object.defineProperty,Gn=Ht("".slice),Yn=Ht("".replace),Wn=Ht([].join),Zn=jt&&!Bn(function(){return Oe(function(){},"length",{value:8}).length!==8}),Jn=String(String).split("String"),Pn=fV.exports=function(t,e,i){Gn(gV(e),0,7)==="Symbol("&&(e="["+Yn(gV(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!Be(t,"name")||Qn&&t.name!==e)&&(jt?Oe(t,"name",{value:e,configurable:!0}):t.name=e),Zn&&i&&Be(i,"arity")&&t.length!==i.arity&&Oe(t,"length",{value:i.arity});try{i&&Be(i,"constructor")&&i.constructor?jt&&Oe(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(V){}var r=Ln(t);return Be(r,"source")||(r.source=Wn(Jn,typeof e=="string"?e:"")),t};Function.prototype.toString=Pn(function(){return On(this)&&Kn(this).source||Fn(this)},"toString")});var vV=a((ic,IV)=>{"use strict";var zn=T(),jn=be(),Hn=SV(),Xn=Ue();IV.exports=function(t,e,i,r){r||(r={});var V=r.enumerable,o=r.name!==void 0?r.name:e;if(zn(i)&&Hn(i,o,r),r.global)V?t[e]=i:Xn(e,i);else{try{r.unsafe?t[e]&&(V=!0):delete t[e]}catch(s){}V?t[e]=i:jn.f(t,e,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t}});var CV=a((rc,EV)=>{"use strict";var _n=Math.ceil,$n=Math.floor;EV.exports=Math.trunc||function(e){var i=+e;return(i>0?$n:_n)(i)}});var Xt=a((Vc,MV)=>{"use strict";var ea=CV();MV.exports=function(t){var e=+t;return e!==e||e===0?0:ea(e)}});var xV=a((oc,wV)=>{"use strict";var ta=Xt(),ia=Math.max,ra=Math.min;wV.exports=function(t,e){var i=ta(t);return i<0?ia(i+e,0):ra(i,e)}});var yV=a((sc,TV)=>{"use strict";var Va=Xt(),oa=Math.min;TV.exports=function(t){var e=Va(t);return e>0?oa(e,9007199254740991):0}});var RV=a((Ac,UV)=>{"use strict";var sa=yV();UV.exports=function(t){return sa(t.length)}});var kV=a((nc,bV)=>{"use strict";var Aa=Te(),na=xV(),aa=RV(),DV=function(t){return function(e,i,r){var V=Aa(e),o=aa(V);if(o===0)return!t&&-1;var s=na(r,o),A;if(t&&i!==i){for(;o>s;)if(A=V[s++],A!==A)return!0}else for(;o>s;s++)if((t||s in V)&&V[s]===i)return t||s||0;return!t&&-1}};bV.exports={includes:DV(!0),indexOf:DV(!1)}});var OV=a((ac,BV)=>{"use strict";var qa=R(),_t=O(),ca=Te(),la=kV().indexOf,pa=Zt(),NV=qa([].push);BV.exports=function(t,e){var i=ca(t),r=0,V=[],o;for(o in i)!_t(pa,o)&&_t(i,o)&&NV(V,o);for(;e.length>r;)_t(i,o=e[r++])&&(~la(V,o)||NV(V,o));return V}});var FV=a((qc,QV)=>{"use strict";QV.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var KV=a(LV=>{"use strict";var da=OV(),ha=FV(),ua=ha.concat("length","prototype");LV.f=Object.getOwnPropertyNames||function(e){return da(e,ua)}});var YV=a(GV=>{"use strict";GV.f=Object.getOwnPropertySymbols});var ZV=a((pc,WV)=>{"use strict";var ga=It(),ma=R(),fa=KV(),Sa=YV(),Ia=Bt(),va=ma([].concat);WV.exports=ga("Reflect","ownKeys")||function(e){var i=fa.f(Ia(e)),r=Sa.f;return r?va(i,r(e)):i}});var zV=a((dc,PV)=>{"use strict";var JV=O(),Ea=ZV(),Ca=Nt(),Ma=be();PV.exports=function(t,e,i){for(var r=Ea(e),V=Ma.f,o=Ca.f,s=0;s<r.length;s++){var A=r[s];!JV(t,A)&&!(i&&JV(i,A))&&V(t,A,o(e,A))}}});var HV=a((hc,jV)=>{"use strict";var wa=D(),xa=T(),Ta=/#|\.prototype\./,ne=function(t,e){var i=Ua[ya(t)];return i===Da?!0:i===Ra?!1:xa(e)?wa(e):!!e},ya=ne.normalize=function(t){return String(t).replace(Ta,".").toLowerCase()},Ua=ne.data={},Ra=ne.NATIVE="N",Da=ne.POLYFILL="P";jV.exports=ne});var _V=a((uc,XV)=>{"use strict";var Qe=C(),ba=Nt().f,ka=Kt(),Na=vV(),Ba=Ue(),Oa=zV(),Qa=HV();XV.exports=function(t,e){var i=t.target,r=t.global,V=t.stat,o,s,A,n,d,l;if(r?s=Qe:V?s=Qe[i]||Ba(i,{}):s=Qe[i]&&Qe[i].prototype,s)for(A in e){if(d=e[A],t.dontCallGetSet?(l=ba(s,A),n=l&&l.value):n=s[A],o=Qa(r?A:i+(V?".":"#")+A,t.forced),!o&&n!==void 0){if(typeof d==typeof n)continue;Oa(d,n)}(t.sham||n&&n.sham)&&ka(d,"sham",!0),Na(s,A,d,t)}}});var $V=a(()=>{"use strict";var Fa=_V(),$t=C();Fa({global:!0,forced:$t.globalThis!==$t},{globalThis:$t})});var to=a((fc,eo)=>{"use strict";$V();eo.exports=C()});var cd=ks(to(),1);function io(t){return{name:"DeviceDetectorOptions",type:"object",required:!1,allowEmpty:!1,properties:{networkDetect:{required:!1,type:"object",properties:{sdkAppId:{required:!0,type:"number"},userId:{required:!0,type:"string"},userSig:{required:!0,type:"string"},downlinkUserId:{required:!1,type:"string"},downlinkUserSig:{required:!1,type:"string"},roomId:{required:!1,type:"number"}},async validate(e,i,r,V){let{RtcError:o,ErrorCode:s,ErrorCodeDictionary:A}=t.errorModule;if(!e)return;let{sdkAppId:n,userId:d,userSig:l,downlinkUserId:u,downlinkUserSig:g,roomId:p}=e;p=p||8080;let w=t.TRTC.create(),N=t.TRTC.create();await w.enterRoom({roomId:p,sdkAppId:n,userId:d,userSig:l}),await w.exitRoom(),w.destroy(),u&&g&&(await N.enterRoom({roomId:p,sdkAppId:n,userId:u,userSig:g}),await N.exitRoom(),N.destroy())}},cameraDetect:{required:!1,type:"object",properties:{mirror:{required:!1,type:"boolean"}}}}}}function ei(t){return{name:"StopDeviceDetectorOptions",required:!1}}var Fe=globalThis,Ke=Fe.ShadowRoot&&(Fe.ShadyCSS===void 0||Fe.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vo=Symbol(),ro=new WeakMap,Le=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==Vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(Ke&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=ro.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&ro.set(i,e))}return e}toString(){return this.cssText}},oo=t=>new Le(typeof t=="string"?t:t+"",void 0,Vo);var ti=(t,e)=>{if(Ke)t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of e){let r=document.createElement("style"),V=Fe.litNonce;V!==void 0&&r.setAttribute("nonce",V),r.textContent=i.cssText,t.appendChild(r)}},Ge=Ke?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return oo(i)})(t):t;var{is:La,defineProperty:Ka,getOwnPropertyDescriptor:Ga,getOwnPropertyNames:Ya,getOwnPropertySymbols:Wa,getPrototypeOf:Za}=Object,Q=globalThis,so=Q.trustedTypes,Ja=so?so.emptyScript:"",ii=Q.reactiveElementPolyfillSupport,ae=(t,e)=>t,ri={toAttribute(t,e){switch(e){case Boolean:t=t?Ja:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(r){i=null}}return i}},co=(t,e)=>!La(t,e),Ao={attribute:!0,type:String,converter:ri,reflect:!1,hasChanged:co},no,ao;(no=Symbol.metadata)!=null||(Symbol.metadata=Symbol("metadata")),(ao=Q.litPropertyMetadata)!=null||(Q.litPropertyMetadata=new WeakMap);var b=class extends HTMLElement{static addInitializer(e){var i;this._$Ei(),((i=this.l)!=null?i:this.l=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,i=Ao){if(i.state&&(i.attribute=!1),this._$Ei(),this.elementProperties.set(e,i),!i.noAccessor){let r=Symbol(),V=this.getPropertyDescriptor(e,r,i);V!==void 0&&Ka(this.prototype,e,V)}}static getPropertyDescriptor(e,i,r){var s;let{get:V,set:o}=(s=Ga(this.prototype,e))!=null?s:{get(){return this[i]},set(A){this[i]=A}};return{get(){return V==null?void 0:V.call(this)},set(A){let n=V==null?void 0:V.call(this);o.call(this,A),this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){var i;return(i=this.elementProperties.get(e))!=null?i:Ao}static _$Ei(){if(this.hasOwnProperty(ae("elementProperties")))return;let e=Za(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ae("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ae("properties"))){let i=this.properties,r=[...Ya(i),...Wa(i)];for(let V of r)this.createProperty(V,i[V])}let e=this[Symbol.metadata];if(e!==null){let i=litPropertyMetadata.get(e);if(i!==void 0)for(let[r,V]of i)this.elementProperties.set(r,V)}this._$Eh=new Map;for(let[i,r]of this.elementProperties){let V=this._$Eu(i,r);V!==void 0&&this._$Eh.set(V,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let V of r)i.unshift(Ge(V))}else e!==void 0&&i.push(Ge(e));return i}static _$Eu(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$EO)!=null?i:this._$EO=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)==null||r.call(e))}removeController(e){var i;(i=this._$EO)==null||i.delete(e)}_$E_(){let e=new Map,i=this.constructor.elementProperties;for(let r of i.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){var i;let e=(i=this.shadowRoot)!=null?i:this.attachShadow(this.constructor.shadowRootOptions);return ti(e,this.constructor.elementStyles),e}connectedCallback(){var e,i;(e=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(i=this._$EO)==null||i.forEach(r=>{var V;return(V=r.hostConnected)==null?void 0:V.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(i=>{var r;return(r=i.hostDisconnected)==null?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EC(e,i){var o;let r=this.constructor.elementProperties.get(e),V=this.constructor._$Eu(e,r);if(V!==void 0&&r.reflect===!0){let s=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:ri).toAttribute(i,r.type);this._$Em=e,s==null?this.removeAttribute(V):this.setAttribute(V,s),this._$Em=null}}_$AK(e,i){var o;let r=this.constructor,V=r._$Eh.get(e);if(V!==void 0&&this._$Em!==V){let s=r.getPropertyOptions(V),A=typeof s.converter=="function"?{fromAttribute:s.converter}:((o=s.converter)==null?void 0:o.fromAttribute)!==void 0?s.converter:ri;this._$Em=V,this[V]=A.fromAttribute(i,s.type),this._$Em=null}}requestUpdate(e,i,r){var V;if(e!==void 0){if(r!=null||(r=this.constructor.getPropertyOptions(e)),!((V=r.hasChanged)!=null?V:co)(this[e],i))return;this.P(e,i,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,i,r){var V;this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$Em!==e&&((V=this._$Ej)!=null?V:this._$Ej=new Set).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r,V;if(!this.isUpdatePending)return;if(!this.hasUpdated){if((r=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[s,A]of this._$Ep)this[s]=A;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[s,A]of o)A.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],A)}let e=!1,i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(V=this._$EO)==null||V.forEach(o=>{var s;return(s=o.hostUpdate)==null?void 0:s.call(o)}),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(e){}_$AE(e){var i;(i=this._$EO)==null||i.forEach(r=>{var V;return(V=r.hostUpdated)==null?void 0:V.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(i=>this._$EC(i,this[i]))),this._$EU()}updated(e){}firstUpdated(e){}},qo;b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[ae("elementProperties")]=new Map,b[ae("finalized")]=new Map,ii==null||ii({ReactiveElement:b}),((qo=Q.reactiveElementVersions)!=null?qo:Q.reactiveElementVersions=[]).push("2.0.4");var ce=globalThis,Ye=ce.trustedTypes,lo=Ye?Ye.createPolicy("lit-html",{createHTML:t=>t}):void 0,So="$lit$",F=`lit$${Math.random().toFixed(9).slice(2)}$`,Io="?"+F,Pa=`<${Io}>`,W=document,le=()=>W.createComment(""),pe=t=>t===null||typeof t!="object"&&typeof t!="function",ci=Array.isArray,za=t=>ci(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Vi=`[
1
+ var ws=Object.create;var ct=Object.defineProperty,xs=Object.defineProperties,Ts=Object.getOwnPropertyDescriptor,ys=Object.getOwnPropertyDescriptors,Us=Object.getOwnPropertyNames,Mi=Object.getOwnPropertySymbols,Rs=Object.getPrototypeOf,wi=Object.prototype.hasOwnProperty,Ds=Object.prototype.propertyIsEnumerable;var qt=(t,e,i)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,j=(t,e)=>{for(var i in e||(e={}))wi.call(e,i)&&qt(t,i,e[i]);if(Mi)for(var i of Mi(e))Ds.call(e,i)&&qt(t,i,e[i]);return t},H=(t,e)=>xs(t,ys(e));var a=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var bs=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let V of Us(e))!wi.call(t,V)&&V!==i&&ct(t,V,{get:()=>e[V],enumerable:!(r=Ts(e,V))||r.enumerable});return t};var ks=(t,e,i)=>(i=t!=null?ws(Rs(t)):{},bs(e||!t||!t.__esModule?ct(i,"default",{value:t,enumerable:!0}):i,t));var h=(t,e,i)=>qt(t,typeof e!="symbol"?e+"":e,i);var C=a((lt,xi)=>{"use strict";var se=function(t){return t&&t.Math===Math&&t};xi.exports=se(typeof globalThis=="object"&&globalThis)||se(typeof window=="object"&&window)||se(typeof self=="object"&&self)||se(typeof global=="object"&&global)||se(typeof lt=="object"&&lt)||function(){return this}()||Function("return this")()});var D=a((Aq,Ti)=>{"use strict";Ti.exports=function(t){try{return!!t()}catch(e){return!0}}});var B=a((nq,yi)=>{"use strict";var Ns=D();yi.exports=!Ns(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var pt=a((aq,Ui)=>{"use strict";var Bs=D();Ui.exports=!Bs(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var xe=a((qq,Ri)=>{"use strict";var Os=pt(),we=Function.prototype.call;Ri.exports=Os?we.bind(we):function(){return we.apply(we,arguments)}});var Ni=a(ki=>{"use strict";var Di={}.propertyIsEnumerable,bi=Object.getOwnPropertyDescriptor,Qs=bi&&!Di.call({1:2},1);ki.f=Qs?function(e){var i=bi(this,e);return!!i&&i.enumerable}:Di});var dt=a((lq,Bi)=>{"use strict";Bi.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var R=a((pq,Fi)=>{"use strict";var Oi=pt(),Qi=Function.prototype,ht=Qi.call,Fs=Oi&&Qi.bind.bind(ht,ht);Fi.exports=Oi?Fs:function(t){return function(){return ht.apply(t,arguments)}}});var Gi=a((dq,Ki)=>{"use strict";var Li=R(),Ls=Li({}.toString),Ks=Li("".slice);Ki.exports=function(t){return Ks(Ls(t),8,-1)}});var Wi=a((hq,Yi)=>{"use strict";var Gs=R(),Ys=D(),Ws=Gi(),ut=Object,Zs=Gs("".split);Yi.exports=Ys(function(){return!ut("z").propertyIsEnumerable(0)})?function(t){return Ws(t)==="String"?Zs(t,""):ut(t)}:ut});var gt=a((uq,Zi)=>{"use strict";Zi.exports=function(t){return t==null}});var mt=a((gq,Ji)=>{"use strict";var Js=gt(),Ps=TypeError;Ji.exports=function(t){if(Js(t))throw new Ps("Can't call method on "+t);return t}});var Te=a((mq,Pi)=>{"use strict";var zs=Wi(),js=mt();Pi.exports=function(t){return zs(js(t))}});var T=a((fq,zi)=>{"use strict";var ft=typeof document=="object"&&document.all;zi.exports=typeof ft=="undefined"&&ft!==void 0?function(t){return typeof t=="function"||t===ft}:function(t){return typeof t=="function"}});var X=a((Sq,ji)=>{"use strict";var Hs=T();ji.exports=function(t){return typeof t=="object"?t!==null:Hs(t)}});var It=a((Iq,Hi)=>{"use strict";var St=C(),Xs=T(),_s=function(t){return Xs(t)?t:void 0};Hi.exports=function(t,e){return arguments.length<2?_s(St[t]):St[t]&&St[t][e]}});var _i=a((vq,Xi)=>{"use strict";var $s=R();Xi.exports=$s({}.isPrototypeOf)});var ir=a((Eq,tr)=>{"use strict";var eA=C(),$i=eA.navigator,er=$i&&$i.userAgent;tr.exports=er?String(er):""});var ar=a((Cq,nr)=>{"use strict";var Ar=C(),vt=ir(),rr=Ar.process,Vr=Ar.Deno,or=rr&&rr.versions||Vr&&Vr.version,sr=or&&or.v8,y,ye;sr&&(y=sr.split("."),ye=y[0]>0&&y[0]<4?1:+(y[0]+y[1]));!ye&&vt&&(y=vt.match(/Edge\/(\d+)/),(!y||y[1]>=74)&&(y=vt.match(/Chrome\/(\d+)/),y&&(ye=+y[1])));nr.exports=ye});var Et=a((Mq,cr)=>{"use strict";var qr=ar(),tA=D(),iA=C(),rA=iA.String;cr.exports=!!Object.getOwnPropertySymbols&&!tA(function(){var t=Symbol("symbol detection");return!rA(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&qr&&qr<41})});var Ct=a((wq,lr)=>{"use strict";var VA=Et();lr.exports=VA&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Mt=a((xq,pr)=>{"use strict";var oA=It(),sA=T(),AA=_i(),nA=Ct(),aA=Object;pr.exports=nA?function(t){return typeof t=="symbol"}:function(t){var e=oA("Symbol");return sA(e)&&AA(e.prototype,aA(t))}});var hr=a((Tq,dr)=>{"use strict";var qA=String;dr.exports=function(t){try{return qA(t)}catch(e){return"Object"}}});var gr=a((yq,ur)=>{"use strict";var cA=T(),lA=hr(),pA=TypeError;ur.exports=function(t){if(cA(t))return t;throw new pA(lA(t)+" is not a function")}});var fr=a((Uq,mr)=>{"use strict";var dA=gr(),hA=gt();mr.exports=function(t,e){var i=t[e];return hA(i)?void 0:dA(i)}});var Ir=a((Rq,Sr)=>{"use strict";var wt=xe(),xt=T(),Tt=X(),uA=TypeError;Sr.exports=function(t,e){var i,r;if(e==="string"&&xt(i=t.toString)&&!Tt(r=wt(i,t))||xt(i=t.valueOf)&&!Tt(r=wt(i,t))||e!=="string"&&xt(i=t.toString)&&!Tt(r=wt(i,t)))return r;throw new uA("Can't convert object to primitive value")}});var Er=a((Dq,vr)=>{"use strict";vr.exports=!1});var Ue=a((bq,Mr)=>{"use strict";var Cr=C(),gA=Object.defineProperty;Mr.exports=function(t,e){try{gA(Cr,t,{value:e,configurable:!0,writable:!0})}catch(i){Cr[t]=e}return e}});var Re=a((kq,Tr)=>{"use strict";var mA=Er(),fA=C(),SA=Ue(),wr="__core-js_shared__",xr=Tr.exports=fA[wr]||SA(wr,{});(xr.versions||(xr.versions=[])).push({version:"3.40.0",mode:mA?"pure":"global",copyright:"\xA9 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var yt=a((Nq,Ur)=>{"use strict";var yr=Re();Ur.exports=function(t,e){return yr[t]||(yr[t]=e||{})}});var Dr=a((Bq,Rr)=>{"use strict";var IA=mt(),vA=Object;Rr.exports=function(t){return vA(IA(t))}});var O=a((Oq,br)=>{"use strict";var EA=R(),CA=Dr(),MA=EA({}.hasOwnProperty);br.exports=Object.hasOwn||function(e,i){return MA(CA(e),i)}});var Ut=a((Qq,kr)=>{"use strict";var wA=R(),xA=0,TA=Math.random(),yA=wA(1 .toString);kr.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+yA(++xA+TA,36)}});var Or=a((Fq,Br)=>{"use strict";var UA=C(),RA=yt(),Nr=O(),DA=Ut(),bA=Et(),kA=Ct(),_=UA.Symbol,Rt=RA("wks"),NA=kA?_.for||_:_&&_.withoutSetter||DA;Br.exports=function(t){return Nr(Rt,t)||(Rt[t]=bA&&Nr(_,t)?_[t]:NA("Symbol."+t)),Rt[t]}});var Kr=a((Lq,Lr)=>{"use strict";var BA=xe(),Qr=X(),Fr=Mt(),OA=fr(),QA=Ir(),FA=Or(),LA=TypeError,KA=FA("toPrimitive");Lr.exports=function(t,e){if(!Qr(t)||Fr(t))return t;var i=OA(t,KA),r;if(i){if(e===void 0&&(e="default"),r=BA(i,t,e),!Qr(r)||Fr(r))return r;throw new LA("Can't convert object to primitive value")}return e===void 0&&(e="number"),QA(t,e)}});var Dt=a((Kq,Gr)=>{"use strict";var GA=Kr(),YA=Mt();Gr.exports=function(t){var e=GA(t,"string");return YA(e)?e:e+""}});var Zr=a((Gq,Wr)=>{"use strict";var WA=C(),Yr=X(),bt=WA.document,ZA=Yr(bt)&&Yr(bt.createElement);Wr.exports=function(t){return ZA?bt.createElement(t):{}}});var kt=a((Yq,Jr)=>{"use strict";var JA=B(),PA=D(),zA=Zr();Jr.exports=!JA&&!PA(function(){return Object.defineProperty(zA("div"),"a",{get:function(){return 7}}).a!==7})});var Nt=a(zr=>{"use strict";var jA=B(),HA=xe(),XA=Ni(),_A=dt(),$A=Te(),en=Dt(),tn=O(),rn=kt(),Pr=Object.getOwnPropertyDescriptor;zr.f=jA?Pr:function(e,i){if(e=$A(e),i=en(i),rn)try{return Pr(e,i)}catch(r){}if(tn(e,i))return _A(!HA(XA.f,e,i),e[i])}});var Hr=a((Zq,jr)=>{"use strict";var Vn=B(),on=D();jr.exports=Vn&&on(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Bt=a((Jq,Xr)=>{"use strict";var sn=X(),An=String,nn=TypeError;Xr.exports=function(t){if(sn(t))return t;throw new nn(An(t)+" is not an object")}});var be=a($r=>{"use strict";var an=B(),qn=kt(),cn=Hr(),De=Bt(),_r=Dt(),ln=TypeError,Ot=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,Qt="enumerable",Ft="configurable",Lt="writable";$r.f=an?cn?function(e,i,r){if(De(e),i=_r(i),De(r),typeof e=="function"&&i==="prototype"&&"value"in r&&Lt in r&&!r[Lt]){var V=pn(e,i);V&&V[Lt]&&(e[i]=r.value,r={configurable:Ft in r?r[Ft]:V[Ft],enumerable:Qt in r?r[Qt]:V[Qt],writable:!1})}return Ot(e,i,r)}:Ot:function(e,i,r){if(De(e),i=_r(i),De(r),qn)try{return Ot(e,i,r)}catch(V){}if("get"in r||"set"in r)throw new ln("Accessors not supported");return"value"in r&&(e[i]=r.value),e}});var Kt=a((zq,eV)=>{"use strict";var dn=B(),hn=be(),un=dt();eV.exports=dn?function(t,e,i){return hn.f(t,e,un(1,i))}:function(t,e,i){return t[e]=i,t}});var rV=a((jq,iV)=>{"use strict";var Gt=B(),gn=O(),tV=Function.prototype,mn=Gt&&Object.getOwnPropertyDescriptor,Yt=gn(tV,"name"),fn=Yt&&function(){}.name==="something",Sn=Yt&&(!Gt||Gt&&mn(tV,"name").configurable);iV.exports={EXISTS:Yt,PROPER:fn,CONFIGURABLE:Sn}});var oV=a((Hq,VV)=>{"use strict";var In=R(),vn=T(),Wt=Re(),En=In(Function.toString);vn(Wt.inspectSource)||(Wt.inspectSource=function(t){return En(t)});VV.exports=Wt.inspectSource});var nV=a((Xq,AV)=>{"use strict";var Cn=C(),Mn=T(),sV=Cn.WeakMap;AV.exports=Mn(sV)&&/native code/.test(String(sV))});var cV=a((_q,qV)=>{"use strict";var wn=yt(),xn=Ut(),aV=wn("keys");qV.exports=function(t){return aV[t]||(aV[t]=xn(t))}});var Zt=a(($q,lV)=>{"use strict";lV.exports={}});var uV=a((ec,hV)=>{"use strict";var Tn=nV(),dV=C(),yn=X(),Un=Kt(),Jt=O(),Pt=Re(),Rn=cV(),Dn=Zt(),pV="Object already initialized",zt=dV.TypeError,bn=dV.WeakMap,ke,Ae,Ne,kn=function(t){return Ne(t)?Ae(t):ke(t,{})},Nn=function(t){return function(e){var i;if(!yn(e)||(i=Ae(e)).type!==t)throw new zt("Incompatible receiver, "+t+" required");return i}};Tn||Pt.state?(U=Pt.state||(Pt.state=new bn),U.get=U.get,U.has=U.has,U.set=U.set,ke=function(t,e){if(U.has(t))throw new zt(pV);return e.facade=t,U.set(t,e),e},Ae=function(t){return U.get(t)||{}},Ne=function(t){return U.has(t)}):(K=Rn("state"),Dn[K]=!0,ke=function(t,e){if(Jt(t,K))throw new zt(pV);return e.facade=t,Un(t,K,e),e},Ae=function(t){return Jt(t,K)?t[K]:{}},Ne=function(t){return Jt(t,K)});var U,K;hV.exports={set:ke,get:Ae,has:Ne,enforce:kn,getterFor:Nn}});var SV=a((tc,fV)=>{"use strict";var Ht=R(),Bn=D(),On=T(),Be=O(),jt=B(),Qn=rV().CONFIGURABLE,Fn=oV(),mV=uV(),Ln=mV.enforce,Kn=mV.get,gV=String,Oe=Object.defineProperty,Gn=Ht("".slice),Yn=Ht("".replace),Wn=Ht([].join),Zn=jt&&!Bn(function(){return Oe(function(){},"length",{value:8}).length!==8}),Jn=String(String).split("String"),Pn=fV.exports=function(t,e,i){Gn(gV(e),0,7)==="Symbol("&&(e="["+Yn(gV(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!Be(t,"name")||Qn&&t.name!==e)&&(jt?Oe(t,"name",{value:e,configurable:!0}):t.name=e),Zn&&i&&Be(i,"arity")&&t.length!==i.arity&&Oe(t,"length",{value:i.arity});try{i&&Be(i,"constructor")&&i.constructor?jt&&Oe(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(V){}var r=Ln(t);return Be(r,"source")||(r.source=Wn(Jn,typeof e=="string"?e:"")),t};Function.prototype.toString=Pn(function(){return On(this)&&Kn(this).source||Fn(this)},"toString")});var vV=a((ic,IV)=>{"use strict";var zn=T(),jn=be(),Hn=SV(),Xn=Ue();IV.exports=function(t,e,i,r){r||(r={});var V=r.enumerable,o=r.name!==void 0?r.name:e;if(zn(i)&&Hn(i,o,r),r.global)V?t[e]=i:Xn(e,i);else{try{r.unsafe?t[e]&&(V=!0):delete t[e]}catch(s){}V?t[e]=i:jn.f(t,e,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t}});var CV=a((rc,EV)=>{"use strict";var _n=Math.ceil,$n=Math.floor;EV.exports=Math.trunc||function(e){var i=+e;return(i>0?$n:_n)(i)}});var Xt=a((Vc,MV)=>{"use strict";var ea=CV();MV.exports=function(t){var e=+t;return e!==e||e===0?0:ea(e)}});var xV=a((oc,wV)=>{"use strict";var ta=Xt(),ia=Math.max,ra=Math.min;wV.exports=function(t,e){var i=ta(t);return i<0?ia(i+e,0):ra(i,e)}});var yV=a((sc,TV)=>{"use strict";var Va=Xt(),oa=Math.min;TV.exports=function(t){var e=Va(t);return e>0?oa(e,9007199254740991):0}});var RV=a((Ac,UV)=>{"use strict";var sa=yV();UV.exports=function(t){return sa(t.length)}});var kV=a((nc,bV)=>{"use strict";var Aa=Te(),na=xV(),aa=RV(),DV=function(t){return function(e,i,r){var V=Aa(e),o=aa(V);if(o===0)return!t&&-1;var s=na(r,o),A;if(t&&i!==i){for(;o>s;)if(A=V[s++],A!==A)return!0}else for(;o>s;s++)if((t||s in V)&&V[s]===i)return t||s||0;return!t&&-1}};bV.exports={includes:DV(!0),indexOf:DV(!1)}});var OV=a((ac,BV)=>{"use strict";var qa=R(),_t=O(),ca=Te(),la=kV().indexOf,pa=Zt(),NV=qa([].push);BV.exports=function(t,e){var i=ca(t),r=0,V=[],o;for(o in i)!_t(pa,o)&&_t(i,o)&&NV(V,o);for(;e.length>r;)_t(i,o=e[r++])&&(~la(V,o)||NV(V,o));return V}});var FV=a((qc,QV)=>{"use strict";QV.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var KV=a(LV=>{"use strict";var da=OV(),ha=FV(),ua=ha.concat("length","prototype");LV.f=Object.getOwnPropertyNames||function(e){return da(e,ua)}});var YV=a(GV=>{"use strict";GV.f=Object.getOwnPropertySymbols});var ZV=a((pc,WV)=>{"use strict";var ga=It(),ma=R(),fa=KV(),Sa=YV(),Ia=Bt(),va=ma([].concat);WV.exports=ga("Reflect","ownKeys")||function(e){var i=fa.f(Ia(e)),r=Sa.f;return r?va(i,r(e)):i}});var zV=a((dc,PV)=>{"use strict";var JV=O(),Ea=ZV(),Ca=Nt(),Ma=be();PV.exports=function(t,e,i){for(var r=Ea(e),V=Ma.f,o=Ca.f,s=0;s<r.length;s++){var A=r[s];!JV(t,A)&&!(i&&JV(i,A))&&V(t,A,o(e,A))}}});var HV=a((hc,jV)=>{"use strict";var wa=D(),xa=T(),Ta=/#|\.prototype\./,ne=function(t,e){var i=Ua[ya(t)];return i===Da?!0:i===Ra?!1:xa(e)?wa(e):!!e},ya=ne.normalize=function(t){return String(t).replace(Ta,".").toLowerCase()},Ua=ne.data={},Ra=ne.NATIVE="N",Da=ne.POLYFILL="P";jV.exports=ne});var _V=a((uc,XV)=>{"use strict";var Qe=C(),ba=Nt().f,ka=Kt(),Na=vV(),Ba=Ue(),Oa=zV(),Qa=HV();XV.exports=function(t,e){var i=t.target,r=t.global,V=t.stat,o,s,A,n,d,l;if(r?s=Qe:V?s=Qe[i]||Ba(i,{}):s=Qe[i]&&Qe[i].prototype,s)for(A in e){if(d=e[A],t.dontCallGetSet?(l=ba(s,A),n=l&&l.value):n=s[A],o=Qa(r?A:i+(V?".":"#")+A,t.forced),!o&&n!==void 0){if(typeof d==typeof n)continue;Oa(d,n)}(t.sham||n&&n.sham)&&ka(d,"sham",!0),Na(s,A,d,t)}}});var $V=a(()=>{"use strict";var Fa=_V(),$t=C();Fa({global:!0,forced:$t.globalThis!==$t},{globalThis:$t})});var to=a((fc,eo)=>{"use strict";$V();eo.exports=C()});var cd=ks(to(),1);function io(t){return{name:"DeviceDetectorOptions",type:"object",required:!1,allowEmpty:!1,properties:{networkDetect:{required:!1,type:"object",properties:{sdkAppId:{required:!0,type:"number"},userId:{required:!0,type:"string"},userSig:{required:!0,type:"string"},downlinkUserId:{required:!1,type:"string"},downlinkUserSig:{required:!1,type:"string"},roomId:{required:!1,type:"number"}},async validate(e,i,r,V){let{RtcError:o,ErrorCode:s,ErrorCodeDictionary:A}=t.errorModule;if(!e)return;let{sdkAppId:n,userId:d,userSig:l,downlinkUserId:u,downlinkUserSig:g,roomId:p}=e;p=p||8080;let w=t.TRTC.create(),N=t.TRTC.create();await w.enterRoom({roomId:p,sdkAppId:n,userId:d,userSig:l}),await w.exitRoom(),w.destroy(),u&&g&&(await N.enterRoom({roomId:p,sdkAppId:n,userId:u,userSig:g}),await N.exitRoom(),N.destroy())}},cameraDetect:{required:!1,type:"object",properties:{mirror:{required:!1,type:"boolean"}}}}}}function ei(t){return{name:"StopDeviceDetectorOptions",required:!1}}var Fe=globalThis,Ke=Fe.ShadowRoot&&(Fe.ShadyCSS===void 0||Fe.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vo=Symbol(),ro=new WeakMap,Le=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==Vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(Ke&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=ro.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&ro.set(i,e))}return e}toString(){return this.cssText}},oo=t=>new Le(typeof t=="string"?t:t+"",void 0,Vo);var ti=(t,e)=>{if(Ke)t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of e){let r=document.createElement("style"),V=Fe.litNonce;V!==void 0&&r.setAttribute("nonce",V),r.textContent=i.cssText,t.appendChild(r)}},Ge=Ke?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return oo(i)})(t):t;var{is:La,defineProperty:Ka,getOwnPropertyDescriptor:Ga,getOwnPropertyNames:Ya,getOwnPropertySymbols:Wa,getPrototypeOf:Za}=Object,Q=globalThis,so=Q.trustedTypes,Ja=so?so.emptyScript:"",ii=Q.reactiveElementPolyfillSupport,ae=(t,e)=>t,ri={toAttribute(t,e){switch(e){case Boolean:t=t?Ja:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(r){i=null}}return i}},co=(t,e)=>!La(t,e),Ao={attribute:!0,type:String,converter:ri,reflect:!1,hasChanged:co},no,ao;(no=Symbol.metadata)!=null||(Symbol.metadata=Symbol("metadata")),(ao=Q.litPropertyMetadata)!=null||(Q.litPropertyMetadata=new WeakMap);var b=class extends HTMLElement{static addInitializer(e){var i;this._$Ei(),((i=this.l)!=null?i:this.l=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,i=Ao){if(i.state&&(i.attribute=!1),this._$Ei(),this.elementProperties.set(e,i),!i.noAccessor){let r=Symbol(),V=this.getPropertyDescriptor(e,r,i);V!==void 0&&Ka(this.prototype,e,V)}}static getPropertyDescriptor(e,i,r){var s;let{get:V,set:o}=(s=Ga(this.prototype,e))!=null?s:{get(){return this[i]},set(A){this[i]=A}};return{get(){return V==null?void 0:V.call(this)},set(A){let n=V==null?void 0:V.call(this);o.call(this,A),this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){var i;return(i=this.elementProperties.get(e))!=null?i:Ao}static _$Ei(){if(this.hasOwnProperty(ae("elementProperties")))return;let e=Za(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ae("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ae("properties"))){let i=this.properties,r=[...Ya(i),...Wa(i)];for(let V of r)this.createProperty(V,i[V])}let e=this[Symbol.metadata];if(e!==null){let i=litPropertyMetadata.get(e);if(i!==void 0)for(let[r,V]of i)this.elementProperties.set(r,V)}this._$Eh=new Map;for(let[i,r]of this.elementProperties){let V=this._$Eu(i,r);V!==void 0&&this._$Eh.set(V,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let V of r)i.unshift(Ge(V))}else e!==void 0&&i.push(Ge(e));return i}static _$Eu(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$EO)!=null?i:this._$EO=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)==null||r.call(e))}removeController(e){var i;(i=this._$EO)==null||i.delete(e)}_$E_(){let e=new Map,i=this.constructor.elementProperties;for(let r of i.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){var i;let e=(i=this.shadowRoot)!=null?i:this.attachShadow(this.constructor.shadowRootOptions);return ti(e,this.constructor.elementStyles),e}connectedCallback(){var e,i;(e=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(i=this._$EO)==null||i.forEach(r=>{var V;return(V=r.hostConnected)==null?void 0:V.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(i=>{var r;return(r=i.hostDisconnected)==null?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EC(e,i){var o;let r=this.constructor.elementProperties.get(e),V=this.constructor._$Eu(e,r);if(V!==void 0&&r.reflect===!0){let s=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:ri).toAttribute(i,r.type);this._$Em=e,s==null?this.removeAttribute(V):this.setAttribute(V,s),this._$Em=null}}_$AK(e,i){var o;let r=this.constructor,V=r._$Eh.get(e);if(V!==void 0&&this._$Em!==V){let s=r.getPropertyOptions(V),A=typeof s.converter=="function"?{fromAttribute:s.converter}:((o=s.converter)==null?void 0:o.fromAttribute)!==void 0?s.converter:ri;this._$Em=V,this[V]=A.fromAttribute(i,s.type),this._$Em=null}}requestUpdate(e,i,r){var V;if(e!==void 0){if(r!=null||(r=this.constructor.getPropertyOptions(e)),!((V=r.hasChanged)!=null?V:co)(this[e],i))return;this.P(e,i,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,i,r){var V;this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$Em!==e&&((V=this._$Ej)!=null?V:this._$Ej=new Set).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r,V;if(!this.isUpdatePending)return;if(!this.hasUpdated){if((r=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[s,A]of this._$Ep)this[s]=A;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[s,A]of o)A.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],A)}let e=!1,i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(V=this._$EO)==null||V.forEach(o=>{var s;return(s=o.hostUpdate)==null?void 0:s.call(o)}),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(e){}_$AE(e){var i;(i=this._$EO)==null||i.forEach(r=>{var V;return(V=r.hostUpdated)==null?void 0:V.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(i=>this._$EC(i,this[i]))),this._$EU()}updated(e){}firstUpdated(e){}},qo;b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[ae("elementProperties")]=new Map,b[ae("finalized")]=new Map,ii==null||ii({ReactiveElement:b}),((qo=Q.reactiveElementVersions)!=null?qo:Q.reactiveElementVersions=[]).push("2.0.4");var ce=globalThis,Ye=ce.trustedTypes,lo=Ye?Ye.createPolicy("lit-html",{createHTML:t=>t}):void 0,So="$lit$",F=`lit$${Math.random().toFixed(9).slice(2)}$`,Io="?"+F,Pa=`<${Io}>`,W=document,le=()=>W.createComment(""),pe=t=>t===null||typeof t!="object"&&typeof t!="function",ci=Array.isArray,za=t=>ci(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Vi=`[
2
2
  \f\r]`,qe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,po=/-->/g,ho=/>/g,G=RegExp(`>|${Vi}(?:([^\\s"'>=/]+)(${Vi}*=${Vi}*(?:[^
3
3
  \f\r"'\`<>=]|("|')|))|$)`,"g"),uo=/'/g,go=/"/g,vo=/^(?:script|style|textarea|title)$/i,li=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),c=li(1),Uc=li(2),Rc=li(3),Z=Symbol.for("lit-noChange"),I=Symbol.for("lit-nothing"),mo=new WeakMap,Y=W.createTreeWalker(W,129);function Eo(t,e){if(!ci(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return lo!==void 0?lo.createHTML(e):e}var ja=(t,e)=>{let i=t.length-1,r=[],V,o=e===2?"<svg>":e===3?"<math>":"",s=qe;for(let A=0;A<i;A++){let n=t[A],d,l,u=-1,g=0;for(;g<n.length&&(s.lastIndex=g,l=s.exec(n),l!==null);)g=s.lastIndex,s===qe?l[1]==="!--"?s=po:l[1]!==void 0?s=ho:l[2]!==void 0?(vo.test(l[2])&&(V=RegExp("</"+l[2],"g")),s=G):l[3]!==void 0&&(s=G):s===G?l[0]===">"?(s=V!=null?V:qe,u=-1):l[1]===void 0?u=-2:(u=s.lastIndex-l[2].length,d=l[1],s=l[3]===void 0?G:l[3]==='"'?go:uo):s===go||s===uo?s=G:s===po||s===ho?s=qe:(s=G,V=void 0);let p=s===G&&t[A+1].startsWith("/>")?" ":"";o+=s===qe?n+Pa:u>=0?(r.push(d),n.slice(0,u)+So+n.slice(u)+F+p):n+F+(u===-2?A:p)}return[Eo(t,o+(t[i]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},de=class t{constructor({strings:e,_$litType$:i},r){let V;this.parts=[];let o=0,s=0,A=e.length-1,n=this.parts,[d,l]=ja(e,i);if(this.el=t.createElement(d,r),Y.currentNode=this.el.content,i===2||i===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(V=Y.nextNode())!==null&&n.length<A;){if(V.nodeType===1){if(V.hasAttributes())for(let u of V.getAttributeNames())if(u.endsWith(So)){let g=l[s++],p=V.getAttribute(u).split(F),w=/([.?@])?(.*)/.exec(g);n.push({type:1,index:o,name:w[2],strings:p,ctor:w[1]==="."?Ai:w[1]==="?"?ni:w[1]==="@"?ai:ee}),V.removeAttribute(u)}else u.startsWith(F)&&(n.push({type:6,index:o}),V.removeAttribute(u));if(vo.test(V.tagName)){let u=V.textContent.split(F),g=u.length-1;if(g>0){V.textContent=Ye?Ye.emptyScript:"";for(let p=0;p<g;p++)V.append(u[p],le()),Y.nextNode(),n.push({type:2,index:++o});V.append(u[g],le())}}}else if(V.nodeType===8)if(V.data===Io)n.push({type:2,index:o});else{let u=-1;for(;(u=V.data.indexOf(F,u+1))!==-1;)n.push({type:7,index:o}),u+=F.length-1}o++}}static createElement(e,i){let r=W.createElement("template");return r.innerHTML=e,r}};function $(t,e,i=t,r){var s,A,n;if(e===Z)return e;let V=r!==void 0?(s=i._$Co)==null?void 0:s[r]:i._$Cl,o=pe(e)?void 0:e._$litDirective$;return(V==null?void 0:V.constructor)!==o&&((A=V==null?void 0:V._$AO)==null||A.call(V,!1),o===void 0?V=void 0:(V=new o(t),V._$AT(t,i,r)),r!==void 0?((n=i._$Co)!=null?n:i._$Co=[])[r]=V:i._$Cl=V),V!==void 0&&(e=$(t,V._$AS(t,e.values),V,r)),e}var si=class{constructor(e,i){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var d;let{el:{content:i},parts:r}=this._$AD,V=((d=e==null?void 0:e.creationScope)!=null?d:W).importNode(i,!0);Y.currentNode=V;let o=Y.nextNode(),s=0,A=0,n=r[0];for(;n!==void 0;){if(s===n.index){let l;n.type===2?l=new he(o,o.nextSibling,this,e):n.type===1?l=new n.ctor(o,n.name,n.strings,this,e):n.type===6&&(l=new qi(o,this,e)),this._$AV.push(l),n=r[++A]}s!==(n==null?void 0:n.index)&&(o=Y.nextNode(),s++)}return Y.currentNode=W,V}p(e){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,i),i+=r.strings.length-2):r._$AI(e[i])),i++}},he=class t{get _$AU(){var e,i;return(i=(e=this._$AM)==null?void 0:e._$AU)!=null?i:this._$Cv}constructor(e,i,r,V){var o;this.type=2,this._$AH=I,this._$AN=void 0,this._$AA=e,this._$AB=i,this._$AM=r,this.options=V,this._$Cv=(o=V==null?void 0:V.isConnected)!=null?o:!0}get parentNode(){let e=this._$AA.parentNode,i=this._$AM;return i!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=i.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,i=this){e=$(this,e,i),pe(e)?e===I||e==null||e===""?(this._$AH!==I&&this._$AR(),this._$AH=I):e!==this._$AH&&e!==Z&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):za(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==I&&pe(this._$AH)?this._$AA.nextSibling.data=e:this.T(W.createTextNode(e)),this._$AH=e}$(e){var o;let{values:i,_$litType$:r}=e,V=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=de.createElement(Eo(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===V)this._$AH.p(i);else{let s=new si(V,this),A=s.u(this.options);s.p(i),this.T(A),this._$AH=s}}_$AC(e){let i=mo.get(e.strings);return i===void 0&&mo.set(e.strings,i=new de(e)),i}k(e){ci(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,V=0;for(let o of e)V===i.length?i.push(r=new t(this.O(le()),this.O(le()),this,this.options)):r=i[V],r._$AI(o),V++;V<i.length&&(this._$AR(r&&r._$AB.nextSibling,V),i.length=V)}_$AR(e=this._$AA.nextSibling,i){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,i);e&&e!==this._$AB;){let V=e.nextSibling;e.remove(),e=V}}setConnected(e){var i;this._$AM===void 0&&(this._$Cv=e,(i=this._$AP)==null||i.call(this,e))}},ee=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,i,r,V,o){this.type=1,this._$AH=I,this._$AN=void 0,this.element=e,this.name=i,this._$AM=V,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=I}_$AI(e,i=this,r,V){let o=this.strings,s=!1;if(o===void 0)e=$(this,e,i,0),s=!pe(e)||e!==this._$AH&&e!==Z,s&&(this._$AH=e);else{let A=e,n,d;for(e=o[0],n=0;n<o.length-1;n++)d=$(this,A[r+n],i,n),d===Z&&(d=this._$AH[n]),s||(s=!pe(d)||d!==this._$AH[n]),d===I?e=I:e!==I&&(e+=(d!=null?d:"")+o[n+1]),this._$AH[n]=d}s&&!V&&this.j(e)}j(e){e===I?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e!=null?e:"")}},Ai=class extends ee{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===I?void 0:e}},ni=class extends ee{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==I)}},ai=class extends ee{constructor(e,i,r,V,o){super(e,i,r,V,o),this.type=5}_$AI(e,i=this){var s;if((e=(s=$(this,e,i,0))!=null?s:I)===Z)return;let r=this._$AH,V=e===I&&r!==I||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==I&&(r===I||V);V&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var i,r;typeof this._$AH=="function"?this._$AH.call((r=(i=this.options)==null?void 0:i.host)!=null?r:this.element,e):this._$AH.handleEvent(e)}},qi=class{constructor(e,i,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){$(this,e)}};var oi=ce.litHtmlPolyfillSupport,fo;oi==null||oi(de,he),((fo=ce.litHtmlVersions)!=null?fo:ce.litHtmlVersions=[]).push("3.2.1");var Co=(t,e,i)=>{var o,s;let r=(o=i==null?void 0:i.renderBefore)!=null?o:e,V=r._$litPart$;if(V===void 0){let A=(s=i==null?void 0:i.renderBefore)!=null?s:null;r._$litPart$=V=new he(e.insertBefore(le(),A),A,void 0,i!=null?i:{})}return V._$AI(t),V};var f=class extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var i,r;let e=super.createRenderRoot();return(r=(i=this.renderOptions).renderBefore)!=null||(i.renderBefore=e.firstChild),e}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Co(i,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Z}},Mo;f._$litElement$=!0,f.finalized=!0,(Mo=globalThis.litElementHydrateSupport)==null||Mo.call(globalThis,{LitElement:f});var pi=globalThis.litElementPolyfillSupport;pi==null||pi({LitElement:f});var wo;((wo=globalThis.litElementVersions)!=null?wo:globalThis.litElementVersions=[]).push("4.1.1");var ue=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(this.createTemplate()),this.buttonEle=this.shadowRoot.querySelector("button")}createTemplate(){let e=document.createElement("template");return e.innerHTML=`
4
4
  <style>