New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

trtc-sdk-v5

Package Overview
Dependencies
Maintainers
0
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trtc-sdk-v5 - npm Package Compare versions

Comparing version 5.9.0-wasm.6 to 5.9.0-wasm.7

2

package.json
{
"name": "trtc-sdk-v5",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "Tencent Cloud RTC SDK for Web",

@@ -5,0 +5,0 @@ "module": "trtc.esm.js",

@@ -1,1 +0,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 Y=(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),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 E(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),512+128))}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 y(t){return E(R(t))}function J(t){return M(y(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?y(t):J(t)}typeof define=="function"&&define.amd?define(function(){return V}):typeof $=="object"&&$.exports?$.exports=V:c.md5=V})(re)});var te=Y(W(),1);var U=(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))(U||{}),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=Y(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=Y(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},j={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:_({},j)},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:_({},j)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},j),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:E,ErrorCodeDictionary:G}=c.errorModule;if(!s)throw new I({code:E.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:E.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let M=0,R=0,y=[];if(p.videoLayoutList.forEach((P,V)=>{y.push(P.fixedVideoUser.userId),P.width+P.locationX>M&&(M=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),y.indexOf(c.room.userId)<0)throw new I({code:E.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:E.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,U as PublishMode,K as TRTCStreamType,lr as default};
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 Y=(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 E(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 y(t){return E(R(t))}function J(t){return M(y(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?y(t):J(t)}typeof define=="function"&&define.amd?define(function(){return V}):typeof $=="object"&&$.exports?$.exports=V:c.md5=V})(re)});var te=Y(W(),1);var U=(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))(U||{}),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=Y(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=Y(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},j={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:_({},j)},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:_({},j)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:_({},j),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:E,ErrorCodeDictionary:G}=c.errorModule;if(!s)throw new I({code:E.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!p)throw new I({code:E.INVALID_PARAMETER,extraCode:G.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(p&&p.videoLayoutList){let M=0,R=0,y=[];if(p.videoLayoutList.forEach((P,V)=>{y.push(P.fixedVideoUser.userId),P.width+P.locationX>M&&(M=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),y.indexOf(c.room.userId)<0)throw new I({code:E.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:E.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,U as PublishMode,K as TRTCStreamType,lr as default};

@@ -1,1 +0,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 Y=(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)&&Y(c,r,e[r]);if(Q)for(var r of Q(e))Te.call(e,r)&&Y(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 j=(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)=>(Y(c,typeof e!="symbol"?e+"":e,r),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),512+128))}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 y(t){return M(R(t))}function z(t){return U(y(t))}function H(t,h){return V(R(t),R(h))}function P(t,h){return U(H(t,h))}function $(t,h,a){return h?a?H(h,t):P(h,t):a?y(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=j(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 E=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 E(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=j(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 E(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=j(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 U=0,R=0,y=[];if(p.videoLayoutList.forEach((P,$)=>{y.push(P.fixedVideoUser.userId),P.width+P.locationX>U&&(U=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),y.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<U||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;
"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 Y=(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)&&Y(c,r,e[r]);if(Q)for(var r of Q(e))Te.call(e,r)&&Y(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 j=(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)=>Y(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 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 y(t){return M(R(t))}function z(t){return U(y(t))}function H(t,h){return V(R(t),R(h))}function P(t,h){return U(H(t,h))}function $(t,h,a){return h?a?H(h,t):P(h,t):a?y(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=j(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 E=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 E(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=j(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 E(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=j(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 U=0,R=0,y=[];if(p.videoLayoutList.forEach((P,$)=>{y.push(P.fixedVideoUser.userId),P.width+P.locationX>U&&(U=P.width+P.locationX),P.height+P.locationY>R&&(R=P.height+P.locationY)}),y.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<U||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;
{
"name": "@rtc-plugin/cdn-streaming",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x CDN streaming plugin",

@@ -5,0 +5,0 @@ "main": "./cdn-streaming.esm.js",

@@ -1,1 +0,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=(s,e,r)=>e in s?C(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r,y=(s,e)=>{for(var r in e||(e={}))H.call(e,r)&&I(s,r,e[r]);if(_)for(var r of _(e))K.call(e,r)&&I(s,r,e[r]);return s},E=(s,e)=>G(s,W(e));var f=(s,e,r,o)=>{for(var t=o>1?void 0:o?w(e,r):e,a=s.length-1,n;a>=0;a--)(n=s[a])&&(t=(o?n(e,r,t):n(t))||t);return o&&t&&C(e,r,t),t};var b=(s,e,r)=>(I(s,typeof e!="symbol"?e+"":e,r),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=s=>typeof s=="function";var j=0,X=1,V=2;function q({retryFunction:s,settings:e,onError:r,onRetrying:o,onRetryFailed:t,onRetrySuccess:a,context:n}){return function(...d){let{retries:m=5,timeout:u=1e3}=e,i=0,l=-1,c=j,g=async(P,A)=>{let M=n||this;try{let R=await s.apply(M,d);i>0&&a&&a.call(this,i),i=0,P(R)}catch(R){let h=()=>{clearTimeout(l),i=0,c=V,A(R)},O=()=>{c!==V&&i<(p(m)?m():m)?(i++,c=X,p(o)&&o.call(this,i,h),l=window.setTimeout(()=>{l=-1,g(P,A)},p(u)?u(i):u)):(h(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:O,reject:A,retryFuncArgs:d,retriedCount:i}):O()}};return new Promise(g)}}var B=q;var T=new WeakMap;function U({settings:s={retries:5,timeout:2e3},onError:e,onRetrying:r,onRetryFailed:o}){return function(t,a,n){let d=B({retryFunction:n.value,settings:s,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(a)?u():i(m)},i,l):(c=T.get(t))!=null&&c.has(a)?u():i(m)},onRetrying(m,u){var i;p(r)&&r.call(this,m,u),(i=T.get(t))!=null&&i.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 i;return(i=T.get(t))==null?void 0:i.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:i,muteVideo:l,muteSubStream:c})=>({roomId:d||m,userId:u,muteAudio:i,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(s){this._log.warn(`retry start: ${s}`)}})],S.prototype,"start",1),f([U({settings:{retries:3,timeout:1e3},onRetrying(s){this._log.warn(`retry update: ${s}`)}})],S.prototype,"update",1);var x=S;var ne=x;export{x as CrossRoom,ne as default};
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(x,A)=>{let M=n||this;try{let R=await i.apply(M,d);s>0&&a&&a.call(this,s),s=0,x(R)}catch(R){let h=()=>{clearTimeout(l),s=0,c=V,A(R)},O=()=>{c!==V&&s<(p(m)?m():m)?(s++,c=F,p(o)&&o.call(this,s,h),l=window.setTimeout(()=>{l=-1,g(x,A)},p(u)?u(s):u)):(h(),p(t)&&t.call(this,R))};p(r)?r.call(this,{error:R,retry:O,reject:A,retryFuncArgs:d,retriedCount:s}):O()}};return new Promise(g)}}var B=X;var T=new WeakMap;function P({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([P({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),f([P({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 +0,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=(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)&&f(o,r,e[r]);if(C)for(var r of C(e))j.call(e,r)&&f(o,r,e[r]);return o},N=(o,e)=>W(o,H(e));var X=(o,e)=>{for(var r in e)y(o,r,{get:e[r],enumerable:!0})},q=(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 F=o=>q(y({},"__esModule",{value:!0}),o),U=(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)=>(f(o,typeof e!="symbol"?e+"":e,r),r);var Z={};X(Z,{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=o=>typeof o=="function";var v=0,Y=1,M=2;function J({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,E)=>{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 O=()=>{clearTimeout(l),i=0,c=M,E(R)},_=()=>{c!==M&&i<(p(m)?m():m)?(i++,c=Y,p(a)&&a.call(this,i,O),l=window.setTimeout(()=>{l=-1,g(h,E)},p(u)?u(i):u)):(O(),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=J;var T=new WeakMap;function P({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 x;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"),U([P({settings:{retries:3,timeout:1e3},onRetrying(o){this._log.warn(`retry start: ${o}`)}})],S.prototype,"start",1),U([P({settings:{retries:3,timeout:1e3},onRetrying(o){this._log.warn(`retry update: ${o}`)}})],S.prototype,"update",1);var I=S;var z=I;return F(Z);})().default;
"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),P=(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 Z={};F(Z,{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=a=>typeof a=="function";var v=0,Y=1,M=2;function J({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 O=()=>{clearTimeout(l),i=0,c=M,E(R)},_=()=>{c!==M&&i<(p(m)?m():m)?(i++,c=Y,p(o)&&o.call(this,i,O),l=window.setTimeout(()=>{l=-1,g(h,E)},p(u)?u(i):u)):(O(),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=J;var T=new WeakMap;function x({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 U;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"),P([x({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],S.prototype,"start",1),P([x({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(Z);})().default;
{
"name": "@rtc-plugin/cross-room",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x Cross Room plugin",

@@ -5,0 +5,0 @@ "main": "./cross-room.esm.js",

{
"name": "@rtc-plugin/custom-encryption",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"main": "./custom-encryption.esm.js",

@@ -5,0 +5,0 @@ "module": "./custom-encryption.esm.js",

{
"name": "@rtc-plugin/device-detector",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x device detector plugin",

@@ -5,0 +5,0 @@ "main": "./device-detector.esm.js",

{
"name": "@trtc/video-decoder",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "Video decoder plugin for TRTC",

@@ -5,0 +5,0 @@ "main": "./video-decoder.esm.js",

{
"name": "@rtc-plugin/basic-beauty",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x basic-beauty plugin",

@@ -5,0 +5,0 @@ "main": "./basic-beauty.esm.js",

{
"name": "@rtc-plugin/beauty",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x beauty plugin",

@@ -5,0 +5,0 @@ "main": "./beauty.esm.js",

{
"name": "@rtc-plugin/virtual-background",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x virtual background plugin",

@@ -5,0 +5,0 @@ "main": "./virtual-background.esm.js",

{
"name": "@rtc-plugin/watermark",
"version": "5.9.0-wasm.6",
"version": "5.9.0-wasm.7",
"description": "TRTC Web SDK 5.x watermark plugin",

@@ -5,0 +5,0 @@ "main": "./watermark.esm.js",

@@ -1,1 +0,1 @@

var x=Object.defineProperty;var O=(a,e,t)=>e in a?x(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var u=(a,e,t)=>(O(a,typeof e!="symbol"?e+"":e,t),t);function E(a){return{name:"WatermarkOptions",type:"object",required:!0,allowEmpty:!1,properties:{imageUrl:{required:!0,type:"string"},x:{required:!1,type:"number"},y:{required:!1,type:"number"},size:{required:!1,type:["string","object","number"]}},validate(e,t,o,T){var b;let{RtcError:r,ErrorCode:d,ErrorCodeDictionary:i}=a.errorModule;if(!e)return;let{imageUrl:m}=e,l=m.split("?")[0].split(".").pop();if((l==="jpg"||l==="jpeg")&&a.log.warn("The image format is not recommended to be jpg/jpeg, because the format does not support transparency."),!((b=a.room.videoManager.cameraTrack)!=null&&b.mediaTrack))throw new r({code:d.INVALID_OPERATION,extraCode:i.INVALID_OPERATION_NEED_VIDEO,fnName:o});if(a.utils.isString(e.size)&&e.size!=="contain"&&e.size!=="cover")throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_TYPE,message:"The size parameter must be 'contain' or 'cover'",fnName:o});if(a.utils.isNumber(e.size)&&(e.size<=0||e.size>1))throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o});if(a.utils.isObject(e.size)){if(!e.size.width||!e.size.height)throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_TYPE,message:"The size parameter must be an object with width and height properties",fnName:o});if(e.size.width<=0||e.size.height<=0)throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o})}}}}function h(a){return{name:"StopWatermarkOptions",required:!1}}var S=0,A=class A{constructor(e){this.core=e;u(this,"seq");u(this,"_core");u(this,"log");u(this,"startResolve");u(this,"startReject");S=S+1,this.seq=S,this._core=e,this.log=e.log.createChild({id:`${this.getAlias()}${S}`}),this.log.info("created")}getName(){return A.Name}getAlias(){return"w"}getValidateRule(e){switch(e){case"start":return E(this._core);case"update":return E(this._core);case"stop":return h(this._core)}}getGroup(){return"w"}async start(e){return this.doStart(e)}async update(e){this.doStart(e)}async stop(){return this._core.room.videoManager.deleteWatermark()}async doStart(e){let{x:t=0,y:o=0}=e,T=await this.processWatermark(e);return this._core.room.videoManager.setWatermark({x:t,y:o,imageUrl:T})}async processWatermark(e){let{imageUrl:t,x:o=0,y:T=0,size:r="cover"}=e,{settings:d}=this._core.room.videoManager.cameraTrack,i;try{i=await this._core.utils.loadImage(t)}catch(D){let{RtcError:U,ErrorCode:_}=this.core.errorModule;throw new U({code:_.INVALID_PARAMETER,message:`load image failed, url: ${t}`})}let{width:m,height:c}=d,{width:l,height:b}=i,s=l,n=b;this._core.utils.isObject(r)&&(s=(r==null?void 0:r.width)||s,n=(r==null?void 0:r.height)||n),this._core.utils.isNumber(r)&&(s=l*r,n=b*r);let p=l/b,P=m/c,N=p>P;r==="contain"&&(N?(s=m,n=m/p):(s=c*p,n=c)),r==="cover"&&(N?(n=c,s=c*p):(s=m,n=m/p));let g=document.createElement("canvas"),I=g.getContext("2d");return g.width=Math.min(m-o,s),g.height=Math.min(c-T,n),I==null||I.drawImage(i,0,0,s,n),g.toDataURL("image/png")}};u(A,"Name","Watermark");var R=A;var G=R;export{R as Watermark,G as default};
var x=Object.defineProperty;var O=(a,e,t)=>e in a?x(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var u=(a,e,t)=>O(a,typeof e!="symbol"?e+"":e,t);function E(a){return{name:"WatermarkOptions",type:"object",required:!0,allowEmpty:!1,properties:{imageUrl:{required:!0,type:"string"},x:{required:!1,type:"number"},y:{required:!1,type:"number"},size:{required:!1,type:["string","object","number"]}},validate(e,t,o,T){var b;let{RtcError:r,ErrorCode:d,ErrorCodeDictionary:i}=a.errorModule;if(!e)return;let{imageUrl:m}=e,l=m.split("?")[0].split(".").pop();if((l==="jpg"||l==="jpeg")&&a.log.warn("The image format is not recommended to be jpg/jpeg, because the format does not support transparency."),!((b=a.room.videoManager.cameraTrack)!=null&&b.mediaTrack))throw new r({code:d.INVALID_OPERATION,extraCode:i.INVALID_OPERATION_NEED_VIDEO,fnName:o});if(a.utils.isString(e.size)&&e.size!=="contain"&&e.size!=="cover")throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_TYPE,message:"The size parameter must be 'contain' or 'cover'",fnName:o});if(a.utils.isNumber(e.size)&&(e.size<=0||e.size>1))throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o});if(a.utils.isObject(e.size)){if(!e.size.width||!e.size.height)throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_TYPE,message:"The size parameter must be an object with width and height properties",fnName:o});if(e.size.width<=0||e.size.height<=0)throw new r({code:d.INVALID_PARAMETER,extraCode:i.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o})}}}}function h(a){return{name:"StopWatermarkOptions",required:!1}}var S=0,A=class A{constructor(e){this.core=e;u(this,"seq");u(this,"_core");u(this,"log");u(this,"startResolve");u(this,"startReject");S=S+1,this.seq=S,this._core=e,this.log=e.log.createChild({id:`${this.getAlias()}${S}`}),this.log.info("created")}getName(){return A.Name}getAlias(){return"w"}getValidateRule(e){switch(e){case"start":return E(this._core);case"update":return E(this._core);case"stop":return h(this._core)}}getGroup(){return"w"}async start(e){return this.doStart(e)}async update(e){this.doStart(e)}async stop(){return this._core.room.videoManager.deleteWatermark()}async doStart(e){let{x:t=0,y:o=0}=e,T=await this.processWatermark(e);return this._core.room.videoManager.setWatermark({x:t,y:o,imageUrl:T})}async processWatermark(e){let{imageUrl:t,x:o=0,y:T=0,size:r="cover"}=e,{settings:d}=this._core.room.videoManager.cameraTrack,i;try{i=await this._core.utils.loadImage(t)}catch(D){let{RtcError:P,ErrorCode:U}=this.core.errorModule;throw new P({code:U.INVALID_PARAMETER,message:`load image failed, url: ${t}`})}let{width:m,height:c}=d,{width:l,height:b}=i,s=l,n=b;this._core.utils.isObject(r)&&(s=(r==null?void 0:r.width)||s,n=(r==null?void 0:r.height)||n),this._core.utils.isNumber(r)&&(s=l*r,n=b*r);let p=l/b,_=m/c,N=p>_;r==="contain"&&(N?(s=m,n=m/p):(s=c*p,n=c)),r==="cover"&&(N?(n=c,s=c*p):(s=m,n=m/p));let g=document.createElement("canvas"),I=g.getContext("2d");return g.width=Math.min(m-o,s),g.height=Math.min(c-T,n),I==null||I.drawImage(i,0,0,s,n),g.toDataURL("image/png")}};u(A,"Name","Watermark");var R=A;var M=R;export{R as Watermark,M as default};

@@ -1,1 +0,1 @@

"use strict";var Watermark=(()=>{var S=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var f=(r,e,t)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var C=(r,e)=>{for(var t in e)S(r,t,{get:e[t],enumerable:!0})},k=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!y.call(r,i)&&i!==t&&S(r,i,{get:()=>e[i],enumerable:!(o=O(e,i))||o.enumerable});return r};var L=r=>k(S({},"__esModule",{value:!0}),r);var d=(r,e,t)=>(f(r,typeof e!="symbol"?e+"":e,t),t);var B={};C(B,{Watermark:()=>I,default:()=>V});function N(r){return{name:"WatermarkOptions",type:"object",required:!0,allowEmpty:!1,properties:{imageUrl:{required:!0,type:"string"},x:{required:!1,type:"number"},y:{required:!1,type:"number"},size:{required:!1,type:["string","object","number"]}},validate(e,t,o,i){var p;let{RtcError:a,ErrorCode:c,ErrorCodeDictionary:s}=r.errorModule;if(!e)return;let{imageUrl:u}=e,b=u.split("?")[0].split(".").pop();if((b==="jpg"||b==="jpeg")&&r.log.warn("The image format is not recommended to be jpg/jpeg, because the format does not support transparency."),!((p=r.room.videoManager.cameraTrack)!=null&&p.mediaTrack))throw new a({code:c.INVALID_OPERATION,extraCode:s.INVALID_OPERATION_NEED_VIDEO,fnName:o});if(r.utils.isString(e.size)&&e.size!=="contain"&&e.size!=="cover")throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The size parameter must be 'contain' or 'cover'",fnName:o});if(r.utils.isNumber(e.size)&&(e.size<=0||e.size>1))throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o});if(r.utils.isObject(e.size)){if(!e.size.width||!e.size.height)throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The size parameter must be an object with width and height properties",fnName:o});if(e.size.width<=0||e.size.height<=0)throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o})}}}}function P(r){return{name:"StopWatermarkOptions",required:!1}}var A=0,E=class E{constructor(e){this.core=e;d(this,"seq");d(this,"_core");d(this,"log");d(this,"startResolve");d(this,"startReject");A=A+1,this.seq=A,this._core=e,this.log=e.log.createChild({id:`${this.getAlias()}${A}`}),this.log.info("created")}getName(){return E.Name}getAlias(){return"w"}getValidateRule(e){switch(e){case"start":return N(this._core);case"update":return N(this._core);case"stop":return P(this._core)}}getGroup(){return"w"}async start(e){return this.doStart(e)}async update(e){this.doStart(e)}async stop(){return this._core.room.videoManager.deleteWatermark()}async doStart(e){let{x:t=0,y:o=0}=e,i=await this.processWatermark(e);return this._core.room.videoManager.setWatermark({x:t,y:o,imageUrl:i})}async processWatermark(e){let{imageUrl:t,x:o=0,y:i=0,size:a="cover"}=e,{settings:c}=this._core.room.videoManager.cameraTrack,s;try{s=await this._core.utils.loadImage(t)}catch(G){let{RtcError:_,ErrorCode:x}=this.core.errorModule;throw new _({code:x.INVALID_PARAMETER,message:`load image failed, url: ${t}`})}let{width:u,height:l}=c,{width:b,height:p}=s,n=b,m=p;this._core.utils.isObject(a)&&(n=(a==null?void 0:a.width)||n,m=(a==null?void 0:a.height)||m),this._core.utils.isNumber(a)&&(n=b*a,m=p*a);let T=b/p,U=u/l,h=T>U;a==="contain"&&(h?(n=u,m=u/T):(n=l*T,m=l)),a==="cover"&&(h?(m=l,n=l*T):(n=u,m=u/T));let g=document.createElement("canvas"),R=g.getContext("2d");return g.width=Math.min(u-o,n),g.height=Math.min(l-i,m),R==null||R.drawImage(s,0,0,n,m),g.toDataURL("image/png")}};d(E,"Name","Watermark");var I=E;var V=I;return L(B);})().default;
"use strict";var Watermark=(()=>{var S=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var f=(r,e,t)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var C=(r,e)=>{for(var t in e)S(r,t,{get:e[t],enumerable:!0})},k=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!y.call(r,i)&&i!==t&&S(r,i,{get:()=>e[i],enumerable:!(o=O(e,i))||o.enumerable});return r};var L=r=>k(S({},"__esModule",{value:!0}),r);var d=(r,e,t)=>f(r,typeof e!="symbol"?e+"":e,t);var B={};C(B,{Watermark:()=>I,default:()=>V});function N(r){return{name:"WatermarkOptions",type:"object",required:!0,allowEmpty:!1,properties:{imageUrl:{required:!0,type:"string"},x:{required:!1,type:"number"},y:{required:!1,type:"number"},size:{required:!1,type:["string","object","number"]}},validate(e,t,o,i){var p;let{RtcError:a,ErrorCode:c,ErrorCodeDictionary:s}=r.errorModule;if(!e)return;let{imageUrl:u}=e,b=u.split("?")[0].split(".").pop();if((b==="jpg"||b==="jpeg")&&r.log.warn("The image format is not recommended to be jpg/jpeg, because the format does not support transparency."),!((p=r.room.videoManager.cameraTrack)!=null&&p.mediaTrack))throw new a({code:c.INVALID_OPERATION,extraCode:s.INVALID_OPERATION_NEED_VIDEO,fnName:o});if(r.utils.isString(e.size)&&e.size!=="contain"&&e.size!=="cover")throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The size parameter must be 'contain' or 'cover'",fnName:o});if(r.utils.isNumber(e.size)&&(e.size<=0||e.size>1))throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o});if(r.utils.isObject(e.size)){if(!e.size.width||!e.size.height)throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The size parameter must be an object with width and height properties",fnName:o});if(e.size.width<=0||e.size.height<=0)throw new a({code:c.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_RANGE,message:"The size parameter must be greater than 0",fnName:o})}}}}function _(r){return{name:"StopWatermarkOptions",required:!1}}var A=0,E=class E{constructor(e){this.core=e;d(this,"seq");d(this,"_core");d(this,"log");d(this,"startResolve");d(this,"startReject");A=A+1,this.seq=A,this._core=e,this.log=e.log.createChild({id:`${this.getAlias()}${A}`}),this.log.info("created")}getName(){return E.Name}getAlias(){return"w"}getValidateRule(e){switch(e){case"start":return N(this._core);case"update":return N(this._core);case"stop":return _(this._core)}}getGroup(){return"w"}async start(e){return this.doStart(e)}async update(e){this.doStart(e)}async stop(){return this._core.room.videoManager.deleteWatermark()}async doStart(e){let{x:t=0,y:o=0}=e,i=await this.processWatermark(e);return this._core.room.videoManager.setWatermark({x:t,y:o,imageUrl:i})}async processWatermark(e){let{imageUrl:t,x:o=0,y:i=0,size:a="cover"}=e,{settings:c}=this._core.room.videoManager.cameraTrack,s;try{s=await this._core.utils.loadImage(t)}catch(M){let{RtcError:U,ErrorCode:x}=this.core.errorModule;throw new U({code:x.INVALID_PARAMETER,message:`load image failed, url: ${t}`})}let{width:u,height:l}=c,{width:b,height:p}=s,n=b,m=p;this._core.utils.isObject(a)&&(n=(a==null?void 0:a.width)||n,m=(a==null?void 0:a.height)||m),this._core.utils.isNumber(a)&&(n=b*a,m=p*a);let T=b/p,P=u/l,h=T>P;a==="contain"&&(h?(n=u,m=u/T):(n=l*T,m=l)),a==="cover"&&(h?(m=l,n=l*T):(n=u,m=u/T));let g=document.createElement("canvas"),R=g.getContext("2d");return g.width=Math.min(u-o,n),g.height=Math.min(l-i,m),R==null||R.drawImage(s,0,0,n,m),g.toDataURL("image/png")}};d(E,"Name","Watermark");var I=E;var V=I;return L(B);})().default;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc