1/* @license See /assets/vendor.LICENSE.txt */ 2var P=Object.defineProperty;var U=(h,e,a)=>e in h?P(h,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):h[e]=a;var s=(h,e,a)=>U(h,typeof e!="symbol"?e+"":e,a);import{a as A}from"./who-AgoraRTC_N-production.B4pfUb3a.js";import{j as O,X as F,et as N,a5 as f,V as B,eX as H,eY as M,eZ as J,e_ as x,e$ as Y,cE as w,cF as k,U as S,eh as R,ej as v,f0 as Q,f1 as j,f2 as W,f3 as G,f4 as K,f5 as q,f6 as z,ek as X,Q as $}from"./who-modals.COweCHuk.js";import{addBreadcrumb as _,captureException as p,captureMessage as D}from"./who-vendor-sentry.D6QQgNDm.js";(function(){try{var h=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new h.Error().stack;e&&(h._sentryDebugIds=h._sentryDebugIds||{},h._sentryDebugIds[e]="3aca64df-bede-44e2-8578-ff81d638818f",h._sentryDebugIdIdentifier="sentry-dbid-3aca64df-bede-44e2-8578-ff81d638818f")}catch{}})();const o=new $("3d306325"),Z="h264",ee=640,ae=480,te=1e4,re=500,L=4,ie=500,oe=2,se=600,le="PERMISSION_DENIED",ne="image/jpeg",ce=.8;O.WHO_PRODUCTION_BUILD==="true"&&A.setLogLevel(3);let C=null;class fe{constructor(e,a,r){s(this,"liveStore",F());s(this,"callStore",N());s(this,"client");s(this,"agoraId");s(this,"remoteElement");s(this,"localElement");s(this,"preferredFacingMode");s(this,"localAudio",null);s(this,"localVideo",null);s(this,"isBanubaPiped",!1);s(this,"emptyVideoInterval",null);s(this,"fakeCameraTimeoutID",null);s(this,"emptyVideo",null);s(this,"otherAgoraUid",null);s(this,"destroyed",!1);s(this,"cameraErrorLogTimerID",null);s(this,"channel");s(this,"isPrivateCall");s(this,"userJoinedCallback",()=>{});s(this,"audioCallback",()=>{});s(this,"videoCallback",()=>{});s(this,"firstRemoteVideoFrameCallback",()=>{});s(this,"userLeftCallback",()=>{});s(this,"remoteUserVideoStateCallback",()=>{});s(this,"remoteUserAudioStateCallback",()=>{});s(this,"subscribeFailedCallback",()=>{});const i=e??{mode:"rtc",codec:Z};C=this,this.remoteElement=a,this.localElement=r,this.preferredFacingMode=f.getItem(f.KEY.PreferredCameraFacingMode)==="environment"?"environment":"user";const t=A.createClient(i);t.enableAudioVolumeIndicator(),t.on("user-joined",this.userJoinedHandler.bind(this)),t.on("user-published",this.userPublishedHandler.bind(this)),t.on("user-left",this.userLeftHandler.bind(this)),t.on("user-info-updated",this.checkRemoteUserMedia.bind(this)),t.on("volume-indicator",this.volumeIndicatorHandler.bind(this)),t.on("network-quality",this.networkQualityHandler.bind(this)),t.on("connection-state-change",n=>{this.callStore.agoraConnectionState=n}),this.client=t}networkQualityHandler(e){var r;if(B().isAgoraQualityEnabled)try{this.liveStore.signalQuality.localUplink=e.uplinkNetworkQuality,this.liveStore.signalQuality.rttQuality=(r=navigator.connection)==null?void 0:r.rtt;const i=this.client.getRemoteNetworkQuality();if(this.otherAgoraUid&&i&&i[this.otherAgoraUid]){const t=i[this.otherAgoraUid];this.liveStore.signalQuality.remoteDownlink=t.downlinkNetworkQuality}}catch(i){o.error("networkQualityHandler error",i)}}volumeIndicatorHandler(e){var r,i;const a=e.filter(t=>t.UID===this.otherAgoraUid);(r=a[0])!=null&&r.UID&&this.remoteUserAudioStateCallback(a[0].UID,((i=a[0])==null?void 0:i.LEVEL)!==0)}checkRemoteUserMedia(e,a){a==="mute-video"?this.remoteUserVideoStateCallback(e,!1):a==="unmute-video"&&this.remoteUserVideoStateCallback(e,!0),a==="mute-audio"?this.remoteUserAudioStateCallback(e,!1):a==="unmute-audio"&&this.remoteUserAudioStateCallback(e,!0)}async join(e,a,r,i,t,n=!1){var c;_({category:"camera.agoraManager",message:"join",level:"info"}),this.channel=a,this.isPrivateCall=t,H(a,t);try{const u=f.getItem(f.KEY.PreferredCameraEnableStatus)!==M.EMPTY||i,g=this.client.join(e,a,null,r).then(d=>(this.agoraId=d,d!==r&&o.warn("AgoraManager: Client used a different agoraId when joining channel",d,r),d)),V=J().then(d=>(this.localAudio=d,d)).catch(d=>{throw p(d,{extra:{debugInfo:"agoraManager createMicrophoneAudioTrack error"}}),o.error("agoraManager createMicrophoneAudioTrack error",d),d}),[,y]=await Promise.all([g,V]);let m=null;u&&(x(a,t),m=this.createCameraTrackWithRetry(oe,se),m.catch(()=>{}));try{await this.client.publish(y)}catch(d){throw await this.discardPendingCameraTrack(m),d}return m?await this.publishCameraVideo(a,t,m):await this.publishEmptyVideo(),Y(a,t),n&&this.botUserJoinEvent(),this.agoraId}catch(u){throw o.error("agoraManager join failed",u),w({code:t?k.PRIVATE_CALL_JOIN_FAILURE:k.AGORA_JOIN_FAILURE,description:JSON.stringify({uid:((c=S().user)==null?void 0:c.profile.uid)??this.agoraId??"",roomid:a,is_private_call:t})}),u}}cameraTrackConfig(){return{facingMode:this.preferredFacingMode,encoderConfig:{width:ee,height:ae},optimizationMode:"motion"}}async createCameraTrackWithRetry(e,a){let r;for(let i=1;i<=e;i++){if(this.destroyed)throw new Error("AgoraManager destroyed during camera acquisition");try{return await A.createCameraVideoTrack(this.cameraTrackConfig())}catch(t){if(r=t,(t==null?void 0:t.code)===le)throw t;o.error("camera.agoraManager createCameraVideoTrack attempt failed",i,t),i<e&&await new Promise(c=>setTimeout(c,a))}}throw r}async publishCameraVideo(e,a,r){const i=R();try{const t=await r;if(this.destroyed){this.safeReleaseVideoTrack(t);return}this.localVideo=t;try{i.banubaAgoraData&&i.isLoadedBanuba&&(t.pipe(i.banubaAgoraData).pipe(t.processorDestination),this.isBanubaPiped=!0)}catch(c){o.error("agoraManager pipe error",c)}t.play(this.localElement,{mirror:v||!i.isLoadedBanuba});const n=this.localElement.querySelector("video");n?(this.cameraErrorLogTimerID=setTimeout(()=>{D("camera.agoraManager loadedmetadata timeout","error"),o.error("camera.agoraManager loadedmetadata timeout")},te),n.addEventListener("loadedmetadata",()=>{_({category:"camera.agoraManager",message:"join loadedmetadata",level:"info"}),Q(e,a),this.cameraErrorLogTimerID&&clearTimeout(this.cameraErrorLogTimerID)},{once:!0})):(D("camera.agoraManager Failed to attach to videoElement","error"),o.error("camera.agoraManager Failed to attach to videoElement")),await this.client.publish(t)}catch(t){if(this.cameraErrorLogTimerID&&(clearTimeout(this.cameraErrorLogTimerID),this.cameraErrorLogTimerID=null),this.localVideo&&(this.safeReleaseVideoTrack(this.localVideo),this.localVideo=null),this.destroyed)return;p(t,{extra:{debugInfo:"agoraManager publishCameraVideo error"}}),o.error("agoraManager publishCameraVideo error",t),j(e,a),await this.publishEmptyVideo()}}async publishEmptyVideo(){const[e,a]=this.getEmptyVideoTrack();this.emptyVideo=e,this.emptyVideoInterval=a,await this.client.publish(e),this.fakeCameraTimeoutID=setInterval(()=>{this.client.getLocalVideoStats().sendJitterMs>0&&this.client.unpublish(e)},re)}async discardPendingCameraTrack(e){if(!e)return;let a;try{a=await e}catch{return}this.safeReleaseVideoTrack(a)}safeReleaseVideoTrack(e){try{e.stop()}catch(a){o.error("agoraManager safeReleaseVideoTrack stop error",a)}try{e.close()}catch(a){o.error("agoraManager safeReleaseVideoTrack close error",a)}}botUserJoinEvent(){const e=`user-${Date.now()}`;return this.otherAgoraUid=e,this.userJoinedCallback(e),this.audioCallback(e),this.videoCallback(e),this.remoteUserAudioStateCallback(e,!1),this.remoteUserVideoStateCallback(e,!1),e}async userJoinedHandler(e){this.otherAgoraUid=e.uid,this.userJoinedCallback(e.uid)}async subscribeWithRetry(e,a){for(let r=1;r<=L;r++){if(this.destroyed)return!1;try{return await this.client.subscribe(e,a),!0}catch(i){o.error("AgoraManager: subscribe failed",a,r,i),r<L&&!this.destroyed&&await new Promise(t=>setTimeout(t,ie*r))}}return!1}async userPublishedHandler(e,a){var i;if(!await this.subscribeWithRetry(e,a)){if(this.destroyed)return;w({code:this.isPrivateCall?k.PRIVATE_CALL_SUBSCRIBE_FAILURE:k.MATCH_SUBSCRIBE_FAILURE,description:JSON.stringify({uid:((i=S().user)==null?void 0:i.profile.uid)??this.agoraId??"",roomid:this.channel,media_type:a,is_private_call:this.isPrivateCall})}),a==="audio"&&this.subscribeFailedCallback();return}if(a==="audio"){if(e.audioTrack)try{e.audioTrack.play()}catch(t){o.error("An error occurred while playing the remote audio track:",t)}if(this.audioCallback(e.uid),this.localAudio)try{await W(this.localAudio)}catch(t){o.error("An error occurred while setting the audio input device:",t)}}else a==="video"&&e.videoTrack&&(e.videoTrack.play(this.remoteElement),e.videoTrack.on("first-frame-decoded",()=>{this.firstRemoteVideoFrameCallback(),G(this.channel,this.isPrivateCall)}),this.videoCallback(e.uid));this.remoteUserVideoStateCallback(e.uid,e.hasVideo),this.remoteUserAudioStateCallback(e.uid,e.hasAudio)}async userLeftHandler(){this.userLeftCallback()}detectLocalBlackVideo(){var t;if(this.emptyVideo!==null||this.localVideo===null||!this.localVideo.isPlaying)return o.warn("AgoraManager: captureSnapshot called while camera is disabled",(t=this.localVideo)==null?void 0:t.isPlaying),null;let e;if(!this.localVideo)return null;try{e=this.localVideo.getCurrentFrameData().data}catch(n){return o.error("AgoraManager: Failed to get image data",n),null}const a=e.length,i=(Math.floor(a/(4*1e3))-1)*4;
2for(let n=0;n<a;n+=i)if(e[n+0]+e[n+1]+e[n+2]>0)return!1;return!0}captureRemoteSnapshot(){var r,i,t,n;const e=((i=(r=this.client)==null?void 0:r.remoteUsers)==null?void 0:i.find(c=>c.uid===this.otherAgoraUid))??((n=(t=this.client)==null?void 0:t.remoteUsers)==null?void 0:n[0]),a=e==null?void 0:e.videoTrack;if(!(a!=null&&a.isPlaying))return o.warn("AgoraManager: captureRemoteSnapshot called without a playing remote video track"),null;try{const c=a.getCurrentFrameData();if(!(c!=null&&c.width)||!(c!=null&&c.height))return null;const u=document.createElement("canvas");u.width=c.width,u.height=c.height;const g=u.getContext("2d");return g?(g.putImageData(c,0,0),u.toDataURL(ne,ce)):null}catch(c){return o.error("AgoraManager: Failed to capture remote snapshot",c),null}}getEmptyVideoTrack(){const e=document.createElement("canvas");e.width=360,e.height=640;const a=e.getContext("2d");a.fillStyle="black",a.fillRect(0,0,e.width,e.height);const r=document.createElement("img");r.src=K,r.width=108,r.height=104;const i=A.createCustomVideoTrack({mediaStreamTrack:e.captureStream(15).getVideoTracks()[0]}),t=setInterval(()=>{a.fillRect(0,0,e.width,e.height),a.drawImage(r,(e.width-r.width)/2,(e.height-r.height)/2,r.width,r.height),this.client.getLocalAudioStats().sendPackets>=50&&t&&clearInterval(t)},1e3);return[i,t]}async muteMic(e){var a;await((a=this.localAudio)==null?void 0:a.setMuted(!e))}async swapRealAndEmptyCamera(e){if(this.cameraErrorLogTimerID&&clearTimeout(this.cameraErrorLogTimerID),this.emptyVideoInterval&&clearInterval(this.emptyVideoInterval),this.fakeCameraTimeoutID&&clearTimeout(this.fakeCameraTimeoutID),e){if(this.localVideo!==null){o.warn("AgoraManager: swapRealAndEmptyCamera localVideo already enabled");return}this.emptyVideo!==null?(await this.client.unpublish(this.emptyVideo),this.emptyVideo=null):o.warn("AgoraManager: swapRealAndEmptyCamera emptyVideo was already null"),this.localVideo=await A.createCameraVideoTrack({facingMode:this.preferredFacingMode,optimizationMode:"motion"}),await this.client.publish(this.localVideo),this.localVideo.play(this.localElement),f.setItem(f.KEY.PreferredCameraEnableStatus,M.DEFAULT)}else{if(this.emptyVideo!==null){o.warn("AgoraManager: swapRealAndEmptyCamera emptyVideo already enabled");return}this.localVideo?(await this.client.unpublish(this.localVideo),this.localVideo.stop(),this.localVideo.getMediaStreamTrack().stop(),this.localVideo.close(),this.localVideo=null):o.warn("AgoraManager: swapRealAndEmptyCamera localVideo was already null");const[a,r]=this.getEmptyVideoTrack();this.emptyVideo=a,this.emptyVideoInterval=r,await this.client.publish(a),this.fakeCameraTimeoutID=setInterval(()=>{this.client.getLocalVideoStats().sendJitterMs>0&&this.client.unpublish&&this.client.unpublish(a)},500),f.setItem(f.KEY.PreferredCameraEnableStatus,M.EMPTY)}}async switchBackAndFrontCameras(){if(!this.localVideo)return;const e=R();if(this.preferredFacingMode=this.preferredFacingMode==="user"?"environment":"user",e.isLoadedBanuba){await this.client.unpublish(this.localVideo),this.localVideo.unpipe(),this.localVideo.stop(),this.localVideo.close(),this.localVideo=null;const a=await A.createCameraVideoTrack({facingMode:this.preferredFacingMode,encoderConfig:{width:640,height:480},optimizationMode:"motion"});try{e.banubaAgoraData&&e.isLoadedBanuba&&a.pipe(e.banubaAgoraData).pipe(a.processorDestination)}catch(r){o.error("pipe error",r)}a.play(this.localElement,{mirror:v||!e.isLoadedBanuba}),await this.client.publish(a),this.localVideo=a;return}await this.localVideo.setDevice({facingMode:this.preferredFacingMode})}async destroy(){if(this.destroyed)return;this.destroyed=!0;const e=this.teardown();q(e),await e}async teardown(){var e,a,r,i,t,n,c,u,g,V,y,m,d,T,E,I;if((e=this.localVideo)==null||e.unpipe(),z(this.channel,this.isPrivateCall),this.cameraErrorLogTimerID&&clearTimeout(this.cameraErrorLogTimerID),C===this&&(C=null),this.emptyVideoInterval&&clearInterval(this.emptyVideoInterval),this.fakeCameraTimeoutID&&clearTimeout(this.fakeCameraTimeoutID),this.localAudio!==null){try{(r=(a=this.localAudio)==null?void 0:a.stop)==null||r.call(a)}catch(l){p(l,{extra:{debugInfo:"agoraManager localAudio.stop error"}}),o.error("AgoraManager.destroy: localAudio.stop()",l)}try{(t=(i=this.localAudio)==null?void 0:i.close)==null||t.call(i)}catch(l){p(l,{extra:{debugInfo:"agoraManager localAudio.close error"}}),o.error("AgoraManager.destroy: localAudio.close()",l)}this.localAudio=null}if(this.localVideo){try{const l=(c=(n=this.localVideo)==null?void 0:n.getMediaStreamTrack)==null?void 0:c.call(n);l&&((u=l.stop)==null||u.call(l))}catch(l){p(l,{extra:{debugInfo:"agoraManager localVideo.getMediaStreamTrack.stop error"}}),o.error("AgoraManager.destroy: localVideo.getMediaStreamTrack().stop()",l)}try{(V=(g=this.localVideo)==null?void 0:g.stop)==null||V.call(g)}catch(l){p(l,{extra:{debugInfo:"agoraManager localVideo.stop error"}}),o.error("AgoraManager.destroy: localVideo.stop()",l)}try{(m=(y=this.localVideo)==null?void 0:y.close)==null||m.call(y)}catch(l){p(l,{extra:{debugInfo:"agoraManager localVideo.close error"}}),o.error("AgoraManager.destroy: localVideo.close()",l)}this.localVideo=null}if(this.emptyVideo){try{(T=(d=this.emptyVideo)==null?void 0:d.stop)==null||T.call(d)}catch(l){o.error("AgoraManager.destroy: emptyVideo.stop()",l)}
2try{(I=(E=this.emptyVideo)==null?void 0:E.close)==null||I.call(E)}catch(l){o.error("AgoraManager.destroy: emptyVideo.close()",l)}this.emptyVideo=null}if(this.client!==void 0){try{this.client.removeAllListeners()}catch(b){o.error("AgoraManager.destroy: client.removeAllListeners()",b)}const l=this.client.connectionState;(l==="CONNECTED"||l==="CONNECTING")&&(await this.client.unpublish().catch(b=>{b.code!=="INVALID_OPERATION"&&o.error("AgoraManager.destroy: client.unpublish()",b)}),await this.client.leave().catch(b=>{o.error("AgoraManager.destroy: client.leave()",b)}))}this.callStore.agoraConnectionState=X,this.userJoinedCallback=()=>{},this.audioCallback=()=>{},this.videoCallback=()=>{},this.firstRemoteVideoFrameCallback=()=>{},this.userLeftCallback=()=>{},this.remoteUserVideoStateCallback=()=>{},this.remoteUserAudioStateCallback=()=>{},this.subscribeFailedCallback=()=>{}}get cameraEnabled(){return this.localVideo!==null}}const pe=()=>(C==null?void 0:C.captureRemoteSnapshot())??null;export{fe as A,Z as a,pe as c};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.