@cloudflare/realtimekit-react 1.1.0-staging.20 → 1.1.0-staging.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -9,7 +9,7 @@
9
9
  `},Us=hf,XS=QS,qc=XS,bs=Us.parse;Us.parseParams;Us.parseFmtpConfig;Us.parsePayloads;Us.parseRemoteCandidates;Us.parseImageAttributes;Us.parseSimulcastStreamList;var ZS=Object.defineProperty,eE=Object.defineProperties,tE=Object.getOwnPropertyDescriptors,jd=Object.getOwnPropertySymbols,rE=Object.getPrototypeOf,pf=Object.prototype.hasOwnProperty,mf=Object.prototype.propertyIsEnumerable,iE=Reflect.get,sE=Math.pow,Vu=(t,e,r)=>e in t?ZS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V=(t,e)=>{for(var r in e||(e={}))pf.call(e,r)&&Vu(t,r,e[r]);if(jd)for(var r of jd(e))mf.call(e,r)&&Vu(t,r,e[r]);return t},q=(t,e)=>eE(t,tE(e)),vl=(t,e)=>{var r={};for(var i in t)pf.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&jd)for(var i of jd(t))e.indexOf(i)<0&&mf.call(t,i)&&(r[i]=t[i]);return r},p=(t,e,r)=>(Vu(t,typeof e!="symbol"?e+"":e,r),r),Qh=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},a=(t,e,r)=>(Qh(t,e,"read from private field"),r?r.call(t):e.get(t)),g=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},f=(t,e,r,i)=>(Qh(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),U=(t,e,r)=>(Qh(t,e,"access private method"),r),nE=(t,e,r)=>iE(rE(t),r,e),u=(t,e,r)=>new Promise((i,s)=>{var n=d=>{try{c(r.next(d))}catch(l){s(l)}},o=d=>{try{c(r.throw(d))}catch(l){s(l)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(n,o);c((r=r.apply(t,e)).next())});function aE(t){const{length:e}=this,r=t>=0?t:e+t;return r<0||r>=e?void 0:this[r]}Array.prototype.at||Object.assign(Array.prototype,{at:aE});function oE(t){const{length:e}=this,r=t>=0?t:e+t;return r<0||r>=e?void 0:this[r]}String.prototype.at||Object.assign(String.prototype,{at:oE});const cE=t=>{!navigator.isReactNative&&typeof window!="undefined"&&(window.addEventListener("error",e=>{var r;!((r=e.filename)!=null&&r.includes("localhost"))&&e.lineno!==0&&t.error("window::error",{error:e.error},!0)}),window.addEventListener("unhandledrejection",e=>{var r,i,s,n,o,c,d,l;t.error("window::unhandledrejection",{error:e==null?void 0:e.reason,networkCall:{url:(i=(r=e==null?void 0:e.reason)==null?void 0:r.config)==null?void 0:i.url,baseURL:(n=(s=e==null?void 0:e.reason)==null?void 0:s.config)==null?void 0:n.baseURL,method:(c=(o=e==null?void 0:e.reason)==null?void 0:o.config)==null?void 0:c.method,status:(d=e==null?void 0:e.reason)==null?void 0:d.status,statusText:(l=e==null?void 0:e.reason)==null?void 0:l.statusText}},!0)}),window.addEventListener("offline",()=>{t.info("window::offline")}),window.addEventListener("online",()=>{t.info("window::online")}))},Qo="chrome",gf="opera",ff="firefox",vf="iexplorer",yf="safari",Sf="nwjs",Ef="electron",kf="react-native",Xh="unknown",Hd={Chrome:Qo,Chromium:Qo,Opera:gf,Firefox:ff,"Internet Explorer":vf,Safari:yf};function dE(){const{userAgent:t}=navigator,e={name:Xh,version:void 0};if(t.match(/Chrome/)&&!t.match(/Edge/))if(t.match(/Edg(A?)/)){const r=t.match(/Chrome\/([\d.]+)/)[1];Number.parseInt(r,10)>72&&(e.name=Qo,e.version=r)}else e.name=Qo,e.version=t.match(/Chrome\/([\d.]+)/)[1];return e}function lE(){const{userAgent:t}=navigator;if(t.match(/Electron/)){const e=t.match(/Electron\/([\d.]+)/)[1];return{name:Ef,version:e}}return null}function uE(){const{userAgent:t}=navigator;if(t.match(/JitsiMeetNW/)){const e=t.match(/JitsiMeetNW\/([\d.]+)/)[1];return{name:Sf,version:e}}}function hE(){const t=navigator.userAgent.match(/\b(react[ \t_-]*native)(?:\/(\S+))?/i);let e;if(t||navigator.product==="ReactNative")return t&&t.length>2&&(t[1],e=t[2]),e||(e="unknown"),{name:kf,version:e}}function pE(t){let e;const r=[hE,lE,uE];for(let s=0;s<r.length;s+=1)if(e=r[s](),e)return e;const i=t.getBrowserName();return i in Hd?{name:Hd[i],version:t.getBrowserVersion()}:(e=dE(),e||{name:Xh,version:void 0})}class mE{constructor(){p(this,"_bowser"),p(this,"_name"),p(this,"_version"),p(this,"getDeviceInfo",()=>({isMobile:this.isMobile(),browserName:this._bowser.getBrowserName(),osName:this._bowser.getOSName(),browserVersion:this._bowser.getBrowserVersion(),osVersionName:this._bowser.getOSVersion(),engineName:this._bowser.getEngineName()}))}init(e){let r,i;if(this._bowser=rf.getParser(navigator.userAgent),typeof e=="undefined"){const s=pE(this._bowser);r=s.name,i=s.version}else e.name in Hd?(r=Hd[e.name],i=e.version):(r=Xh,i=void 0);this._name=r,this._version=i}getName(){return this._name}isChrome(){return this._name===Qo}isOpera(){return this._name===gf}isFirefox(){return this._name===ff}isIExplorer(){return this._name===vf}isSafari(){return this._name===yf}isNWJS(){return this._name===Sf}isElectron(){return this._name===Ef}isReactNative(){return this._name===kf||navigator.isReactNative===!0}getVersion(){return this._version}isMobile(){return this._bowser.getPlatformType()==="mobile"}_checkCondition(e){if(this._version)return this._bowser.satisfies(e)}isVersionGreaterThan(e){return this._checkCondition({[this._name]:`>${e}`})}isVersionLessThan(e){return this._checkCondition({[this._name]:`<${e}`})}isVersionEqualTo(e){return this._checkCondition({[this._name]:`~${e}`})}}class gE extends mE{doesVideoMuteByStreamRemove(){return this.isChromiumBased()||this.isWebKitBased()}supportsP2P(){return!this.usesUnifiedPlan()}isChromiumBased(){return this.isChrome()||this.isElectron()||this.isNWJS()||this.isOpera()}isWebKitBased(){return this._bowser.isEngine("webkit")&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"&&typeof window.RTCRtpTransceiver!="undefined"&&Object.keys(RTCRtpTransceiver.prototype).indexOf("currentDirection")>-1}isSupported(){return typeof RTCPeerConnection!="undefined"}isUserInteractionRequiredForUnmute(){return this.isFirefox()&&this.isVersionLessThan("68")}supportsVideoMuteOnConnInterrupted(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}supportsBandwidthStatistics(){return!this.isFirefox()&&!this.isWebKitBased()}supportsCodecPreferences(){return this.usesUnifiedPlan()&&typeof window.RTCRtpTransceiver!="undefined"&&Object.keys(window.RTCRtpTransceiver.prototype).indexOf("setCodecPreferences")>-1&&Object.keys(RTCRtpSender.prototype).indexOf("getCapabilities")>-1&&!this.isWebKitBased()}supportsDeviceChangeEvent(){return navigator.mediaDevices&&typeof navigator.mediaDevices.ondevicechange!="undefined"&&typeof navigator.mediaDevices.addEventListener!="undefined"}supportsLocalCandidateRttStatistics(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}supportsPerformanceObserver(){return typeof window.PerformanceObserver!="undefined"&&PerformanceObserver.supportedEntryTypes.indexOf("longtask")>-1}supportsReceiverStats(){return typeof window.RTCRtpReceiver!="undefined"&&Object.keys(RTCRtpReceiver.prototype).indexOf("getSynchronizationSources")>-1}supportsRTTStatistics(){return!this.isFirefox()}usesPlanB(){return!this.usesUnifiedPlan()}usesSdpMungingForSimulcast(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}usesUnifiedPlan(){return!!(this.isFirefox()||this.isWebKitBased())}usesNewGumFlow(){return!!(this.isChromiumBased()||this.isFirefox()||this.isWebKitBased())}usesAdapter(){return this.usesNewGumFlow()}usesRidsForSimulcast(){return!1}supportsGetDisplayMedia(){return typeof navigator.getDisplayMedia!="undefined"||typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getDisplayMedia!="undefined"}supportsInsertableStreams(){if(!(typeof window.RTCRtpSender!="undefined"&&(window.RTCRtpSender.prototype.createEncodedStreams||window.RTCRtpSender.prototype.createEncodedVideoStreams)))return!1;const e=new ReadableStream;try{return window.postMessage(e,"*",[e]),!0}catch{return!1}}supportsAudioRed(){return Boolean(window.RTCRtpSender&&window.RTCRtpSender.getCapabilities&&window.RTCRtpSender.getCapabilities("audio").codecs.some(e=>e.mimeType==="audio/red")&&window.RTCRtpReceiver&&window.RTCRtpReceiver.getCapabilities&&window.RTCRtpReceiver.getCapabilities("audio").codecs.some(e=>e.mimeType==="audio/red"))}supportsSdpSemantics(){return this.isChromiumBased()}_getChromiumBasedVersion(){if(this.isChromiumBased()){if(this.isNWJS())return Number.parseInt(process.versions.chromium,10);const e=navigator.userAgent;if(e.match(/Chrome/))return Number.parseInt(e.match(/Chrome\/([\d.]+)/)[1],10)}return-1}isIOSMobile(){return this.isMobile&&this._bowser.getOSName()==="iOS"}}const Ie=new gE;var mt={},fE={get exports(){return mt},set exports(t){mt=t}},qn=typeof Reflect=="object"?Reflect:null,jp=qn&&typeof qn.apply=="function"?qn.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)},$c;qn&&typeof qn.ownKeys=="function"?$c=qn.ownKeys:Object.getOwnPropertySymbols?$c=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:$c=function(t){return Object.getOwnPropertyNames(t)};function vE(t){console&&console.warn&&console.warn(t)}var Tf=Number.isNaN||function(t){return t!==t};function he(){he.init.call(this)}fE.exports=he;mt.once=kE;he.EventEmitter=he;he.prototype._events=void 0;he.prototype._eventsCount=0;he.prototype._maxListeners=void 0;var Hp=10;function yl(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(he,"defaultMaxListeners",{enumerable:!0,get:function(){return Hp},set:function(t){if(typeof t!="number"||t<0||Tf(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Hp=t}});he.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};he.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Tf(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function bf(t){return t._maxListeners===void 0?he.defaultMaxListeners:t._maxListeners}he.prototype.getMaxListeners=function(){return bf(this)};he.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var n;if(e.length>0&&(n=e[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")jp(c,this,e);else for(var d=c.length,l=Pf(c,d),r=0;r<d;++r)jp(l[r],this,e);return!0};function wf(t,e,r,i){var s,n,o;if(yl(r),n=t._events,n===void 0?(n=t._events=Object.create(null),t._eventsCount=0):(n.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),n=t._events),o=n[e]),o===void 0)o=n[e]=r,++t._eventsCount;else if(typeof o=="function"?o=n[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),s=bf(t),s>0&&o.length>s&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,vE(c)}return t}he.prototype.addListener=function(t,e){return wf(this,t,e,!1)};he.prototype.on=he.prototype.addListener;he.prototype.prependListener=function(t,e){return wf(this,t,e,!0)};function yE(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _f(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=yE.bind(i);return s.listener=r,i.wrapFn=s,s}he.prototype.once=function(t,e){return yl(e),this.on(t,_f(this,t,e)),this};he.prototype.prependOnceListener=function(t,e){return yl(e),this.prependListener(t,_f(this,t,e)),this};he.prototype.removeListener=function(t,e){var r,i,s,n,o;if(yl(e),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===e||r.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if(typeof r!="function"){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===e||r[n].listener===e){o=r[n].listener,s=n;break}if(s<0)return this;s===0?r.shift():SE(r,s),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};he.prototype.off=he.prototype.removeListener;he.prototype.removeAllListeners=function(t){var e,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var s=Object.keys(r),n;for(i=0;i<s.length;++i)n=s[i],n!=="removeListener"&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=r[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this};function If(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?EE(s):Pf(s,s.length)}he.prototype.listeners=function(t){return If(this,t,!0)};he.prototype.rawListeners=function(t){return If(this,t,!1)};he.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Cf.call(t,e)};he.prototype.listenerCount=Cf;function Cf(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}he.prototype.eventNames=function(){return this._eventsCount>0?$c(this._events):[]};function Pf(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function SE(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function EE(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function kE(t,e){return new Promise(function(r,i){function s(o){t.removeListener(e,n),i(o)}function n(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}Rf(t,e,n,{once:!0}),e!=="error"&&TE(t,s,{once:!0})})}function TE(t,e,r){typeof t.on=="function"&&Rf(t,"error",e,r)}function Rf(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function s(n){i.once&&t.removeEventListener(e,s),r(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var z;(function(t){t[t.MAJOR_EVENT=0]="MAJOR_EVENT",t[t.MINOR_EVENT=1]="MINOR_EVENT"})(z||(z={}));var L;(function(t){t.PRECALL_TEST_BEGIN="precall_begin",t.PRECALL_TEST_COMPLETE="precall_end",t.CALL_JOIN_BEGIN="call_join",t.NET_QUALITY_TEST_BEGIN="net_quality_test_begin",t.NET_QUALITY_TEST_END="net_quality_test_end",t.WEBSOCKET_CONNECTED="websocket_connected",t.TRANSPORT_CONNECTED="transport_connected",t.AUDIO_ON="audio_on",t.AUDIO_OFF="audio_off",t.VIDEO_ON="video_on",t.VIDEO_OFF="video_off",t.PARTICIPANT_ROLE="participant_role",t.PING_STAT="ping_stat",t.DISCONNECT="disconnect",t.RECONNECT_ATTEMPT="reconnect_attempt",t.SCREENSHARE_START_REQUESTED="screenshare_start_requested",t.SCREENSHARE_STARTED="screenshare_started",t.SCREENSHARE_STOPPED="screenshare_stopped",t.TAB_CHANGE="tab_change",t.BROWSER_BACKGROUNDED="browser_backgrounded",t.BROWSER_FOREGROUNDED="browser_foregrounded",t.DOMINANT_SPEAKER="dominant_speaker",t.AUDIO_DEVICES_UPDATES="audio_devices_updates",t.VIDEO_DEVICES_UPDATES="video_devices_updates",t.SPEAKER_DEVICES_UPDATES="speaker_devices_updates",t.SELECTED_MICROHPONE_UPDATE="selected_microphone_update",t.SELECTED_CAMERA_UPDATE="selected_camera_update",t.SELECTED_SPEAKER_UPDATE="selected_speaker_update",t.EXPECTED_VIDEO_RESOLUTION="expected_video_resolution",t.EXPECTED_SCREENSHARE_RESOLUTION="expected_screenshare_resolution",t.MEDIA_PERMISSION="media_permission",t.LEGACY_SWITCH="legacy_switch",t.AUDIO_PLAY_FAILED="audio_play_failed",t.VIDEO_PLAY_FAILED="video_play_failed",t.AUDIO_TRACK_MUTED="audio_track_muted",t.VIDEO_TRACK_MUTED="video_track_muted",t.IVS_PLAYER_REBUFFERING="ivs_player_rebuffering",t.IVS_PLAYER_AUDIO_BLOCKED="ivs_player_audio_blocked",t.IVS_PLAYER_PLAYBACK_BLOCKED="ivs_player_playback_blocked",t.IVS_PLAYER_ERROR="ivs_player_error",t.IVS_PLAYER_RECOVERABLE_ERROR="ivs_player_recoverable_error",t.IVS_PLAYER_WORKER_ERROR="ivs_player_worker_error",t.IVS_PLAYER_NETWORK_UNAVAILABLE="ivs_player_network_unavailable",t.LIVESTREAM_LATENCY="livestream_latency",t.IVS_PLAYER_ANALYTICS_EVENT="ivs_player_analytics_event",t.IVS_PLAYER_PLAYBACK_RATE_CHANGED="ivs_player_playback_rate_changed",t.IVS_PLAYER_QUALITY_CHANGED="ivs_player_quality_changed",t.IVS_PLAYER_INITIALIZED="ivs_player_initialized"})(L||(L={}));const bE=new Map([[L.PRECALL_TEST_BEGIN,z.MINOR_EVENT],[L.PRECALL_TEST_COMPLETE,z.MINOR_EVENT],[L.CALL_JOIN_BEGIN,z.MAJOR_EVENT],[L.NET_QUALITY_TEST_BEGIN,z.MINOR_EVENT],[L.NET_QUALITY_TEST_END,z.MINOR_EVENT],[L.WEBSOCKET_CONNECTED,z.MINOR_EVENT],[L.TRANSPORT_CONNECTED,z.MAJOR_EVENT],[L.AUDIO_ON,z.MINOR_EVENT],[L.AUDIO_OFF,z.MINOR_EVENT],[L.VIDEO_ON,z.MINOR_EVENT],[L.VIDEO_OFF,z.MINOR_EVENT],[L.PARTICIPANT_ROLE,z.MINOR_EVENT],[L.PING_STAT,z.MAJOR_EVENT],[L.DISCONNECT,z.MAJOR_EVENT],[L.RECONNECT_ATTEMPT,z.MAJOR_EVENT],[L.SCREENSHARE_START_REQUESTED,z.MINOR_EVENT],[L.SCREENSHARE_STARTED,z.MINOR_EVENT],[L.SCREENSHARE_STOPPED,z.MINOR_EVENT],[L.TAB_CHANGE,z.MINOR_EVENT],[L.BROWSER_BACKGROUNDED,z.MINOR_EVENT],[L.BROWSER_FOREGROUNDED,z.MINOR_EVENT],[L.DOMINANT_SPEAKER,z.MINOR_EVENT],[L.AUDIO_DEVICES_UPDATES,z.MINOR_EVENT],[L.VIDEO_DEVICES_UPDATES,z.MINOR_EVENT],[L.SPEAKER_DEVICES_UPDATES,z.MINOR_EVENT],[L.SELECTED_MICROHPONE_UPDATE,z.MINOR_EVENT],[L.SELECTED_CAMERA_UPDATE,z.MINOR_EVENT],[L.SELECTED_SPEAKER_UPDATE,z.MINOR_EVENT],[L.MEDIA_PERMISSION,z.MINOR_EVENT],[L.LEGACY_SWITCH,z.MINOR_EVENT],[L.AUDIO_PLAY_FAILED,z.MINOR_EVENT],[L.VIDEO_PLAY_FAILED,z.MINOR_EVENT],[L.AUDIO_TRACK_MUTED,z.MINOR_EVENT],[L.VIDEO_TRACK_MUTED,z.MINOR_EVENT],[L.IVS_PLAYER_REBUFFERING,z.MAJOR_EVENT],[L.IVS_PLAYER_AUDIO_BLOCKED,z.MAJOR_EVENT],[L.IVS_PLAYER_PLAYBACK_BLOCKED,z.MAJOR_EVENT],[L.IVS_PLAYER_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_RECOVERABLE_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_WORKER_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_NETWORK_UNAVAILABLE,z.MAJOR_EVENT],[L.LIVESTREAM_LATENCY,z.MAJOR_EVENT],[L.IVS_PLAYER_ANALYTICS_EVENT,z.MINOR_EVENT],[L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,z.MINOR_EVENT],[L.IVS_PLAYER_QUALITY_CHANGED,z.MINOR_EVENT],[L.IVS_PLAYER_INITIALIZED,z.MINOR_EVENT],[L.EXPECTED_VIDEO_RESOLUTION,z.MINOR_EVENT],[L.EXPECTED_SCREENSHARE_RESOLUTION,z.MINOR_EVENT]]);class wE{constructor(){p(this,"events"),this.events=[]}add(e){this.events.push(e)}flush(){return{entries:this.events.splice(0,25)}}}class _E extends mt{constructor({logger:e,peerId:r,apiHostnames:i}){super(),p(this,"logger"),p(this,"peerId"),p(this,"eventStore"),p(this,"apiEndpoint"),this.logger=e,this.peerId=r,this.apiEndpoint=`https://${i.daCollector}/api/v1/message`,this.eventStore=new wE}sendEventsChunkToServer(e){return u(this,null,function*(){var r;const i={payload:e,peerId:this.peerId};try{return yield fetch(this.apiEndpoint,{method:"POST",body:JSON.stringify(i)}),!0}catch(s){return this.logger.error("callStats::sendEventsChunkToServer::catch",{error:s}),(r=e.entries)==null||r.forEach(n=>{this.eventStore.add(n)}),!1}})}callEvent(e){e.timestamp=new Date,this.eventStore.add(e),this.emit(e.event,e.metaData),bE.get(e.event)===z.MAJOR_EVENT&&this.flush()}flush(){return u(this,null,function*(){var e;const r=this.eventStore.flush();return(e=r==null?void 0:r.entries)!=null&&e.length?(yield this.sendEventsChunkToServer(r),!0):!1})}}var Gp;(function(t){t.CHROMIUM="chromum",t.FIREFOX="firefox",t.SAFARI="safari"})(Gp||(Gp={}));const Vo={DEVEL:"devel",PREPROD:"preprod",PROD:"prod"};var or;(function(t){t.AUDIO="AUDIO",t.VIDEO="VIDEO",t.SPEAKER="SPEAKER",t.SCREENSHARE="SCREENSHARE"})(or||(or={}));var qp;(function(t){t[t.INIT=0]="INIT",t[t.ACCEPTED=1]="ACCEPTED",t[t.DENIED=2]="DENIED",t[t.SYS_DENIED=3]="SYS_DENIED",t[t.FAILED=4]="FAILED",t[t.NOTFOUND=5]="NOTFOUND",t[t.NOT_APPLICABLE=6]="NOT_APPLICABLE"})(qp||(qp={}));function Bi(t){return t?t.split(".").slice(0,2).concat(["0","0"]).join("."):""}function Gd({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function qd({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}const Mf=240,Af=720,Df=8,Of=3,Sl=10,El=.02,kl=.03;function oi({stat:t,weight:e,rangeMin:r,rangeMax:i,rangeRankingDirection:s}){return t==null?e:r===i?s==="UP"?t<=r?e:0:t>=i?e:0:s==="UP"?(1-Math.max(Math.min(i,Math.abs(t))-r,0)/(i-r))*e:s==="DOWN"?Math.max(Math.min(i,Math.abs(t))-r,0)/(i-r)*e:e}function Nf({isLowQualityVideo:t,isVideoStuck:e,isVideoLagging:r,jitterQuality:i,packetsLostQuality:s}){const n=.8*((t?.85:1)*(r?.7:1)*(e?.5:1))+.2*(i*s);return Math.round((n+Number.EPSILON)*100)/100}function Vf({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function Lf({packetsLost:t,packetsSent:e,jitter:r}){const i=oi({stat:Vf({packetsLost:t,packetsSent:e}),weight:.7,rangeMin:0,rangeMax:Sl,rangeRankingDirection:"UP"}),s=oi({stat:r,weight:.3,rangeMin:El,rangeMax:kl,rangeRankingDirection:"UP"});return i+s}function IE({frameWidth:t,isScreenShare:e}){return t<(e?Af:Mf)}function CE({framesPerSecond:t,isScreenShare:e}){return t<(e?Of:Df)}function PE({framesEncoded:t}){return t===0}function xf({frameWidth:t,framesPerSecond:e,packetsLost:r,packetsSent:i,jitter:s,isScreenShare:n,framesEncoded:o}){const c=oi({stat:Vf({packetsLost:r,packetsSent:i}),weight:1,rangeMin:0,rangeMax:Sl,rangeRankingDirection:"UP"}),d=oi({stat:s,weight:1,rangeMin:El,rangeMax:kl,rangeRankingDirection:"UP"}),l=IE({frameWidth:t,isScreenShare:n}),h=CE({framesPerSecond:e,isScreenShare:n}),m=PE({framesEncoded:o,isScreenShare:n});return Nf({isLowQualityVideo:l,isVideoLagging:h,isVideoStuck:m,jitterQuality:d,packetsLostQuality:c})}function Uf({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}function Ff({concealmentEvents:t,packetsLost:e,packetsReceived:r,jitter:i}){const s=oi({stat:t,weight:.2,rangeMin:0,rangeMax:3,rangeRankingDirection:"UP"}),n=.5,o=oi({stat:Uf({packetsLost:e,packetsReceived:r}),weight:n,rangeMin:0,rangeMax:Sl,rangeRankingDirection:"UP"}),c=oi({stat:i,weight:.3,rangeMin:El,rangeMax:kl,rangeRankingDirection:"UP"});return s+o+c}function RE({framesDecoded:t}){return t===0}function ME({framesPerSecond:t,isScreenShare:e}){return t<(e?Of:Df)}function AE({frameWidth:t,isScreenShare:e}){return t<(e?Af:Mf)}function Bf({frameWidth:t,framesPerSecond:e,packetsLost:r,packetsReceived:i,jitter:s,isScreenShare:n,framesDecoded:o}){const c=oi({stat:Uf({packetsLost:r,packetsReceived:i}),weight:1,rangeMin:0,rangeMax:Sl,rangeRankingDirection:"UP"}),d=oi({stat:s,weight:1,rangeMin:El,rangeMax:kl,rangeRankingDirection:"UP"}),l=AE({frameWidth:t,isScreenShare:n}),h=ME({framesPerSecond:e,isScreenShare:n}),m=RE({framesDecoded:o,isScreenShare:n});return Nf({isLowQualityVideo:l,isVideoLagging:h,isVideoStuck:m,jitterQuality:d,packetsLostQuality:c})}class ci{constructor(e){p(this,"pc1"),p(this,"pc2"),p(this,"constrainVideoBitrateKbps"),p(this,"constrainOfferToRemoveVideoFec",!1),p(this,"iceCandidateFilter");const r=new RTCPeerConnection(e),i=new RTCPeerConnection(e);this.pc1=r,this.pc2=i,this.iceCandidateFilter=ci.noFilter,this.pc1.addEventListener("icecandidate",this.onIceCandidate.bind(this,this.pc2)),this.pc2.addEventListener("icecandidate",this.onIceCandidate.bind(this,this.pc1))}static parseCandidate(e){const r="candidate:",i=e.indexOf(r)+r.length,s=e.substr(i).split(" ");return{type:s[7],protocol:s[2],address:s[4]}}static isNotHostCandidate(e){return e.type!=="host"}static isHost(e){return e.type==="host"}static isRelay(e){return e.type==="relay"}static isReflexive(e){return e.type==="srflx"}static noFilter(e){return!0}onIceCandidate(e,r){if(r.candidate){const i=ci.parseCandidate(r.candidate.candidate);this.iceCandidateFilter(i)&&e.addIceCandidate(r.candidate)}}setIceCandidateFilter(e){this.iceCandidateFilter=e}constrainVideoBitrate(e){this.constrainVideoBitrateKbps=e}disableVideoFec(){this.constrainOfferToRemoveVideoFec=!0}gotOffer(e){this.constrainOfferToRemoveVideoFec&&(e.sdp=e.sdp.replace(/(m=video 1 [^\r]+)(116 117)(\r\n)/g,`$1\r
10
10
  `),e.sdp=e.sdp.replace(/a=rtpmap:116 red\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:117 ulpfec\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:98 rtx\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=fmtp:98 apt=116\r\n/g,"")),this.pc1.setLocalDescription(e),this.pc2.setRemoteDescription(e),this.pc2.createAnswer().then(this.gotAnswer.bind(this),this.reportFatal.bind(this))}gotAnswer(e){this.constrainVideoBitrateKbps&&(e.sdp=e.sdp.replace(/a=mid:video\r\n/g,`a=mid:video\r
11
11
  b=AS:${this.constrainVideoBitrateKbps}\r
12
- `)),this.pc2.setLocalDescription(e),this.pc1.setRemoteDescription(e)}establishConnection(){this.pc1.createOffer().then(this.gotOffer.bind(this),this.reportFatal.bind(this))}reportFatal(e){console.error("Error:",e)}getRoundTripTime(){return u(this,null,function*(){const[e,r]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,s;if(e.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesSent>0&&(i=n)}),r.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesReceived>0&&(s=n)}),i&&s)try{if(i.currentRoundTripTime&&s.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:s.currentRoundTripTime};const n=(s.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:n,backendRTT:n}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class Wf extends mt{constructor(e){super(),p(this,"call"),p(this,"timeOut"),this.call=new ci(e)}start(e=1e4){this.call.establishConnection(),this.timeOut=setTimeout(this.testFailed.bind(this),e)}testComplete(e){clearTimeout(this.timeOut),this.call.close(),this.emit("done",e)}testFailed(e){this.call.close(),this.emit("failed",e)}}const DE=8,OE=1/1e3;class NE extends Wf{constructor(e){super(e),p(this,"senderChannel"),p(this,"recieveChannel"),p(this,"startTime"),p(this,"lastBitrateMeasureTime"),p(this,"sentPayloadBytes",0),p(this,"recievedPayloadBytes",0),p(this,"lastReceivedPayloadBytes",0),p(this,"stopSending",!1),p(this,"testProgress",0),p(this,"samplePacket",""),p(this,"finalBitrateSum",0),p(this,"bitRateSampels",0),p(this,"maxNumberOfPacketsToSend",0),p(this,"bytesToKeepBuffered",0),p(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(ci.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let r=0;r<1024*256;r+=1)this.samplePacket+="h";this.maxNumberOfPacketsToSend=1,this.bytesToKeepBuffered=1024*this.maxNumberOfPacketsToSend,this.testDurationSeconds=4,this.senderChannel.addEventListener("open",this.sendingStep.bind(this)),this.call.pc2.addEventListener("datachannel",this.onRecieverChannel.bind(this))}sendingStep(){const e=new Date;this.startTime||(this.startTime=e,this.lastBitrateMeasureTime=e);for(let i=0;i!==this.maxNumberOfPacketsToSend&&!(this.senderChannel.bufferedAmount>=this.bytesToKeepBuffered);i+=1){this.sentPayloadBytes+=this.samplePacket.length;try{this.senderChannel.send(this.samplePacket)}catch{}}const r=e.getTime()-this.startTime.getTime();r>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=r/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const r=new Date,i=r.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const s=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*DE/(i/1e3);this.finalBitrateSum+=s,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=r}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const s=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(s*OE)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:r,backendRTT:i})=>super.testComplete({RTT:r,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Zh extends Wf{constructor(e,r=ci.noFilter){super(e),p(this,"ch1"),p(this,"ch2"),this.call.setIceCandidateFilter(r);const i=this.call.pc1.createDataChannel(null);this.ch1=i,i.addEventListener("open",()=>{i.send("hello")}),i.addEventListener("message",this.onCh1Recieve.bind(this)),this.call.pc2.addEventListener("datachannel",this.dataChannelHandler.bind(this))}onCh1Recieve(e){e.data!=="world"?this.hangup("Invalid data transmitted."):this.testComplete({connectivity:!0})}onCh2Recieve(e){if(e.data!=="hello")this.hangup("Invalid data transmitted.");else try{this.ch2.send("world")}catch{}}dataChannelHandler(e){const r=e.channel;this.ch2=r,r.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class VE extends Zh{constructor(e){super(e,ci.isHost)}}class LE extends Zh{constructor(e){super(e,ci.isRelay)}}class xE extends Zh{constructor(e){super(e,ci.isReflexive)}}class UE{constructor(){p(this,"ipInformation",null)}getIPDetails(e){return u(this,arguments,function*({peerId:r,apiHostnames:i,logger:s}){var n,o,c;if(!this.ipInformation){try{const d=`https://${i.location}`,l=yield(yield fetch(d)).json();if(((n=l.loc)==null?void 0:n.length)>5)return this.ipInformation=l,(o=this.ipInformation)!=null&&o.ip&&(this.ipInformation.ip=Bi(this.ipInformation.ip)),l;throw Error("Insufficient data")}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${r}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=Bi(this.ipInformation.ip))}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const ep=new UE,$p=[{urls:"turn:turn.dyte.in:443?transport=tcp",username:"dyte",credential:"dytein",credentialType:"password"},{urls:"turn:turn.dyte.in:3478?transport=udp",username:"dyte",credential:"dytein",credentialType:"password"}];function Jp(t){const[e,r]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(r)}}}class jf{constructor(){p(this,"transport"),p(this,"candidatePair"),p(this,"outboundVideoRtp",new Map),p(this,"inboundVideoRtp",new Map),p(this,"outboundAudioRtp",new Map),p(this,"inboundAudioRtp",new Map),p(this,"remoteInboundRtp",new Map),p(this,"producerStreamMap",new Map),p(this,"consumerStreamMap",new Map),p(this,"staleProducerStreamMap",!1),p(this,"staleConsumerStreamMap",!1)}}class Hf extends mt{constructor(){super(),p(this,"observer"),p(this,"outboundProducerMap",new Map),p(this,"inboundConsumerMap",new Map),p(this,"consumerPeerIdMap",new Map),p(this,"pausedConsumerMap",new Map),p(this,"pausedProducerMap",new Map),p(this,"overallProducingTransportsStatsMap",{}),p(this,"overallConsumingTransportsStatsMap",{}),p(this,"overallConsumersStatsMap",{}),p(this,"overallProducersStatsMap",{}),p(this,"videoProducerToStatsMap",new Map),p(this,"audioProducerToStatsMap",new Map),p(this,"videoConsumerToStatsMap",new Map),p(this,"audioConsumerToStatsMap",new Map),p(this,"consumerIdsWithFreezedVideo",new Set),p(this,"consumerIdsWithFreezedAudio",new Set),p(this,"producerIdsWithFreezedVideo",new Set),p(this,"producerIdsWithFreezedAudio",new Set),p(this,"freezedProducingTransportIds",new Set),p(this,"freezedConsumingTransportIds",new Set),p(this,"screenShareProducers",new Set),p(this,"screenShareConsumers",new Set),p(this,"ipDetails"),p(this,"callStatsInstance"),this.observer=new mt}registerProducer(e){return u(this,null,function*(){yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}pauseProducer(e){this.pausedProducerMap.set(e,{lastReportCalculated:!1})}resumeProducer(e){this.pausedProducerMap.delete(e)}processInboundConsumerVideoStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(r.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(r.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(r.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(r.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{},{audio:o,video:c,screen:d}=n,l=o||c||d;r.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(r.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,r,i){var s,n;const o=!!Array.from(((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);r.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(r.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return u(this,null,function*(){yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}pauseConsumer(e){this.pausedConsumerMap.set(e,{lastReportCalculated:!1})}resumeConsumer(e){this.pausedConsumerMap.delete(e)}generateProducerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"outbound-rtp":{this.outboundProducerMap.set(n.id,e.id);break}}return s})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"inbound-rtp":{this.inboundConsumerMap.set(n.id,e.id);break}}return s})}deregisterProducer(e){this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(r=>{const i=r.framesEncoded>0,s=r.packetsSent>0,n=r.frameWidth&&r.frameHeight;return i&&s&&!!n})||e[e.length-1]}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,m,v,S,T,M,b,R,j;const W=e,w=new jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:E}=A,{selected:_}=A,B=A,oe={nominated:E!=null?E:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const E=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:E.bytesReceived,bytesSent:E.bytesSent,packetsSent:E.packetsSent,packetsReceived:E.packetsReceived,dtlsCipher:E.dtlsCipher,dtlsState:E.dtlsState,iceRole:E.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const E=A,_={jitter:E.jitter,fractionLost:E.fractionLost,roundTripTime:E.roundTripTime,roundTripTimeMeasurements:E.roundTripTimeMeasurements,totalRoundTripTime:E.totalRoundTripTime,packetsLost:E.packetsLost};w.remoteInboundRtp.set(E.localId,_);break}case"outbound-rtp":{const E=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:E.bytesSent,packetsSent:E.packetsSent,nackCount:E.nackCount,ssrc:E.ssrc,mid:E.mid,active:E.active,codecId:E.codecId,headerBytesSent:E.headerBytesSent||0,totalPacketSendDelay:E.totalPacketSendDelay||0};if(E.mediaType==="video"||E.kind==="video"){const C=E,ue=V({frameHeight:C.frameHeight,frameWidth:C.frameWidth,framesEncoded:C.framesEncoded,framesDropped:C.framesDropped,framesPerSecond:C.framesPerSecond,framesSent:C.framesSent,keyFramesEncoded:C.keyFramesEncoded,firCount:C.firCount,encoderImplementation:C.encoderImplementation,hugeFramesSent:C.hugeFramesSent,pliCount:C.pliCount,qpSum:C.qpSum,qualityLimitationDurations:C.qualityLimitationDurations,qualityLimitationReason:C.qualityLimitationReason,qualityLimitationResolutionChanges:C.qualityLimitationResolutionChanges,totalEncodeTime:C.targetBitrate,totalPacketSendDelay:C.totalPacketSendDelay,retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent,scalabilityMode:C.scalabilityMode,powerEfficientEncoder:C.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ue)}else if(E.mediaType==="audio"||E.kind==="audio"){const C=E,ue=V({retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ue)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}case"inbound-rtp":{const E=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(E.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:E.bytesReceived,packetsReceived:E.packetsReceived,packetsLost:E.packetsLost>=0?E.packetsLost:0,jitter:E.jitter,nackCount:E.nackCount,jitterBufferDelay:E.jitterBufferDelay,jitterBufferEmittedCount:E.jitterBufferEmittedCount,lastPacketReceivedTimestamp:E.lastPacketReceivedTimestamp,ssrc:E.ssrc,mid:E.mid,codecId:E.codecId,headerBytesReceived:E.headerBytesReceived||0,packetsDiscarded:E.packetsDiscarded||0,jitterBufferMinimumDelay:E.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:E.jitterBufferTargetDelay||0};if(E.mediaType==="video"||E.kind==="video"){const x=E,C=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped,framesPerSecond:x.framesPerSecond,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);C.score=Bf({frameWidth:C.frameWidth||0,framesDecoded:(C.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:C.framesPerSecond||0,packetsLost:(C.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(C.score*10).toFixed(),frameWidth:C.frameWidth||0,frameHeight:C.frameHeight||0,framesPerSecond:C.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((m=this.videoConsumerToStatsMap.get(_))==null?void 0:m.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,C),w.inboundVideoRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,C)}else if(E.mediaType==="audio"||E.kind==="audio"){const x=E,C=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);C.score=Ff({concealmentEvents:(C.concealmentEvents||0)-(((S=this.audioConsumerToStatsMap.get(_))==null?void 0:S.concealmentEvents)||0),packetsLost:(C.packetsLost||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((M=this.audioConsumerToStatsMap.get(_))==null?void 0:M.packetsReceived)||0),jitter:C.jitter||0}),jt.set(_,{score:+(C.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((R=this.audioConsumerToStatsMap.get(_))==null?void 0:R.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,C),w.inboundAudioRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,C)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}}}if(w.producerStreamMap.forEach((A,E)=>{var _,B,oe,He,x,C,ue,Ki,zi,qr,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa,Ea;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Fl=>{ge.push(w.outboundVideoRtp.get(Fl))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=xf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(E))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(E))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((C=this.videoProducerToStatsMap.get(E))==null?void 0:C.framesEncoded)||0)}),Xe.set(E,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ue=se.remoteData)==null?void 0:ue.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsLostPercentage:Gd({packetsSent:(se.packetsSent||0)-(((Ki=this.videoProducerToStatsMap.get(E))==null?void 0:Ki.packetsSent)||0),packetsLost:(((zi=se.remoteData)==null?void 0:zi.packetsLost)||0)-(((ca=(qr=this.videoProducerToStatsMap.get(E))==null?void 0:qr.remoteData)==null?void 0:ca.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((da=this.videoProducerToStatsMap.get(E))==null?void 0:da.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(E,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Lf({packetsSent:(ge.packetsSent||0)-(((la=this.audioProducerToStatsMap.get(E))==null?void 0:la.packetsSent)||0),packetsLost:(((ua=ge.remoteData)==null?void 0:ua.packetsLost)||0)-(((pa=(ha=this.audioProducerToStatsMap.get(E))==null?void 0:ha.remoteData)==null?void 0:pa.packetsLost)||0),jitter:((ma=ge.remoteData)==null?void 0:ma.jitter)||0}),Xe.set(E,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ga=this.audioProducerToStatsMap.get(E))==null?void 0:ga.bytesSent)||0))*8/7,packetsLostPercentage:Gd({packetsSent:(ge.packetsSent||0)-(((fa=this.audioProducerToStatsMap.get(E))==null?void 0:fa.packetsSent)||0),packetsLost:(((va=ge.remoteData)==null?void 0:va.packetsLost)||0)-(((Sa=(ya=this.audioProducerToStatsMap.get(E))==null?void 0:ya.remoteData)==null?void 0:Sa.packetsLost)||0)}),jitter:((Ea=ge.remoteData)==null?void 0:Ea.jitter)||0,isScreenShare:this.screenShareProducers.has(E)}),this.audioProducerToStatsMap.set(E,ge)}}),Me.forEach(A=>{const E=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);E&&(A.localCandidateType=E.type,A.localCandidateAddress=Bi(E.address),A.localCandidatePort=E.port,A.localCandidateProtocol=E.protocol,A.localCandidateUrl=E.url,A.localCandidateNetworkType=E.networkType,A.localCandidateRelatedAddress=Bi(E.relatedAddress),A.localCandidateRelatedPort=E.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=Bi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,E=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,E=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=E}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateProducerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getConsumersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateConsumerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getTransportReport(e){return u(this,null,function*(){return e.getStats()})}getProcessedStats(e,r,i){return u(this,null,function*(){const s=yield this.getTransportReport(e),n={producing:i,consuming:r,id:e.id},o=s,c=this.parseRTCReport(o,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,n);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:r,producing:i},l=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),h=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:l,consumerReport:h}})}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{var n,o;r.push({producerId:s,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((o=(n=this.callStatsInstance.producers)==null?void 0:n.get(s))==null?void 0:o.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return r}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(s);r.push({consumerId:s,peerId:n,producerId:o,appData:c,videoStats:i.inboundVideoRtpId.map(d=>e.inboundVideoRtp.get(d)),audioStats:i.inboundAudioRtpId.map(d=>e.inboundAudioRtp.get(d))})})}catch(i){console.error("getConsumersReport: ",i,e)}return r}getUserLocation(){return u(this,null,function*(){return new Promise((e,r)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):r()}catch(i){r(i)}})})}getConnectivity(e){return u(this,null,function*(){try{const r={iceServers:e||$p},i=new Promise((l,h)=>{try{const m=new VE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),s=new Promise((l,h)=>{try{const m=new LE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),n=new Promise((l,h)=>{try{const m=new xE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),[o,c,d]=yield Promise.all([i,s,n]);return{host:o==null?void 0:o.connectivity,relay:c==null?void 0:c.connectivity,reflexive:d==null?void 0:d.connectivity}}catch{return{host:!1,relay:!1,reflexive:!1}}})}getThroughput(e){return u(this,null,function*(){try{const r=yield new Promise((i,s)=>{try{const n={iceServers:e||$p},o=new NE(n);o.addListener("done",i),o.addListener("failed",s),o.start(1e4)}catch(n){s(n)}});return{throughput:r.throughput,fractionalLoss:0,RTT:r.RTT,jitter:0,backendRTT:r.backendRTT}}catch{return}})}getIPDetails(){return u(this,null,function*(){var e,r;try{return this.ipDetails||(this.ipDetails=yield ep.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(r=this.callStatsInstance)==null?void 0:r.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return u(this,null,function*(){const[r,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:r,throughput:i==null?void 0:i.throughput,fractionalLoss:i==null?void 0:i.fractionalLoss,RTT:i==null?void 0:i.RTT,jitter:i==null?void 0:i.jitter,backendRTT:i==null?void 0:i.backendRTT}})}getNetworkInfo(e,r=!1){return u(this,null,function*(){var i,s;if(r){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Jp(d==null?void 0:d.loc):void 0}}const[n,o,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(s=navigator.connection)==null?void 0:s.effectiveType,location:c!=null&&c.loc?Jp(c==null?void 0:c.loc):void 0,turnConnectivity:n?n.host||n.relay||n.reflexive:!1,connectivity:n,throughput:o==null?void 0:o.throughput,fractionalLoss:o==null?void 0:o.fractionalLoss,RTT:o==null?void 0:o.RTT,jitter:o==null?void 0:o.jitter,backendRTT:o==null?void 0:o.backendRTT}})}}class FE extends Hf{}class Gf extends Hf{constructor(){super(...arguments),p(this,"producerMap",new Map),p(this,"consumerMap",new Map)}registerProducer(e){return u(this,null,function*(){this.producerMap.set(e.id,e),yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}registerConsumer(e){return u(this,null,function*(){this.consumerMap.set(e.id,e),yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),n=[...s.consumerStreamMap.values()][0],o=r?this.getConsumerStatsFromParsedConsumerStats(s,n,e.id):void 0;for(const c of i.values())switch(c.type){case"inbound-rtp":{this.inboundConsumerMap.set(c.id,e.id);break}}return o})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.consumerMap.delete(e.id),this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,m,v,S,T,M,b,R,j;const W=e,w=new jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:E}=A,{selected:_}=A,B=A,oe={nominated:E!=null?E:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const E=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:E.bytesReceived,bytesSent:E.bytesSent,packetsSent:E.packetsSent,packetsReceived:E.packetsReceived,dtlsCipher:E.dtlsCipher,dtlsState:E.dtlsState,iceRole:E.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const E=A,_={jitter:E.jitter,fractionLost:E.fractionLost,roundTripTime:E.roundTripTime,roundTripTimeMeasurements:E.roundTripTimeMeasurements,totalRoundTripTime:E.totalRoundTripTime,packetsLost:E.packetsLost};w.remoteInboundRtp.set(E.localId,_);break}case"outbound-rtp":{const E=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:E.bytesSent,packetsSent:E.packetsSent,nackCount:E.nackCount,ssrc:E.ssrc,mid:E.mid,active:E.active,codecId:E.codecId,headerBytesSent:E.headerBytesSent||0,totalPacketSendDelay:E.totalPacketSendDelay||0};if(E.mediaType==="video"||E.kind==="video"){const C=E,ue=V({frameHeight:C.frameHeight,frameWidth:C.frameWidth,framesEncoded:C.framesEncoded,framesDropped:C.framesDropped?C.framesDropped:C.droppedFrames,framesPerSecond:C.framesPerSecond?C.framesPerSecond:C.framerateMean,framesSent:C.framesSent,keyFramesEncoded:C.keyFramesEncoded,firCount:C.firCount,encoderImplementation:C.encoderImplementation,hugeFramesSent:C.hugeFramesSent,pliCount:C.pliCount,qpSum:C.qpSum,qualityLimitationReason:C.qualityLimitationReason,qualityLimitationDurations:C.qualityLimitationDurations,qualityLimitationResolutionChanges:C.qualityLimitationResolutionChanges,totalEncodeTime:C.totalEncodeTime,totalPacketSendDelay:C.totalEncodeTime,retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent,scalabilityMode:C.scalabilityMode,powerEfficientEncoder:C.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ue)}else if(E.mediaType==="audio"||E.kind==="audio"){const C=E,ue=V({retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ue)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}case"inbound-rtp":{const E=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(E.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:E.bytesReceived,packetsReceived:E.packetsReceived,packetsLost:E.packetsLost>=0?E.packetsLost:0,jitter:E.jitter,nackCount:E.nackCount,jitterBufferDelay:E.jitterBufferDelay,jitterBufferEmittedCount:E.jitterBufferEmittedCount,lastPacketReceivedTimestamp:E.lastPacketReceivedTimestamp,ssrc:E.ssrc,mid:E.mid,codecId:E.codecId,headerBytesReceived:E.headerBytesReceived||0,packetsDiscarded:E.packetsDiscarded||0,jitterBufferMinimumDelay:E.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:E.jitterBufferTargetDelay||0};if(E.mediaType==="video"||E.kind==="video"){const x=E,C=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped?x.framesDropped:x.droppedFrames,framesPerSecond:x.framesPerSecond?x.framesPerSecond:x.framerateMean,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);C.score=Bf({frameWidth:C.frameWidth||0,framesDecoded:(C.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:C.framesPerSecond||0,packetsLost:(C.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(C.score*10).toFixed(),frameWidth:C.frameWidth||0,frameHeight:C.frameHeight||0,framesPerSecond:C.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((m=this.videoConsumerToStatsMap.get(_))==null?void 0:m.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,C),w.inboundVideoRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,C)}else if(E.mediaType==="audio"||E.kind==="audio"){const x=E,C=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);C.score=Ff({concealmentEvents:(C.concealmentEvents||0)-(((S=this.audioConsumerToStatsMap.get(_))==null?void 0:S.concealmentEvents)||0),packetsLost:(C.packetsLost||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((M=this.audioConsumerToStatsMap.get(_))==null?void 0:M.packetsReceived)||0),jitter:C.jitter||0}),jt.set(_,{score:+(C.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((R=this.audioConsumerToStatsMap.get(_))==null?void 0:R.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,C),w.inboundAudioRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,C)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}}}if(w.producerStreamMap.forEach((A,E)=>{var _,B,oe,He,x,C,ue,Ki,zi,qr,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa,Ea;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Fl=>{ge.push(w.outboundVideoRtp.get(Fl))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=xf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(E))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(E))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((C=this.videoProducerToStatsMap.get(E))==null?void 0:C.framesEncoded)||0)}),Xe.set(E,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ue=se.remoteData)==null?void 0:ue.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsLostPercentage:Gd({packetsSent:(se.packetsSent||0)-(((Ki=this.videoProducerToStatsMap.get(E))==null?void 0:Ki.packetsSent)||0),packetsLost:(((zi=se.remoteData)==null?void 0:zi.packetsLost)||0)-(((ca=(qr=this.videoProducerToStatsMap.get(E))==null?void 0:qr.remoteData)==null?void 0:ca.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((da=this.videoProducerToStatsMap.get(E))==null?void 0:da.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(E,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Lf({packetsSent:(ge.packetsSent||0)-(((la=this.audioProducerToStatsMap.get(E))==null?void 0:la.packetsSent)||0),packetsLost:(((ua=ge.remoteData)==null?void 0:ua.packetsLost)||0)-(((pa=(ha=this.audioProducerToStatsMap.get(E))==null?void 0:ha.remoteData)==null?void 0:pa.packetsLost)||0),jitter:((ma=ge.remoteData)==null?void 0:ma.jitter)||0}),Xe.set(E,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ga=this.audioProducerToStatsMap.get(E))==null?void 0:ga.bytesSent)||0))*8/7,packetsLostPercentage:Gd({packetsSent:(ge.packetsSent||0)-(((fa=this.audioProducerToStatsMap.get(E))==null?void 0:fa.packetsSent)||0),packetsLost:(((va=ge.remoteData)==null?void 0:va.packetsLost)||0)-(((Sa=(ya=this.audioProducerToStatsMap.get(E))==null?void 0:ya.remoteData)==null?void 0:Sa.packetsLost)||0)}),jitter:((Ea=ge.remoteData)==null?void 0:Ea.jitter)||0,isScreenShare:this.screenShareProducers.has(E)}),this.audioProducerToStatsMap.set(E,ge)}}),Me.forEach(A=>{const E=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);E&&(A.localCandidateType=E.type,A.localCandidateAddress=Bi(E.address),A.localCandidatePort=E.port,A.localCandidateProtocol=E.protocol,A.localCandidateUrl=E.url,A.localCandidateNetworkType=E.networkType,A.localCandidateRelatedAddress=Bi(E.relatedAddress),A.localCandidateRelatedPort=E.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=Bi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.bytesReceived=w.candidatePair.bytesReceived,w.transport.bytesSent=w.candidatePair.bytesSent,w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,E=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,E=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=E}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{const n=this.producerMap.get(s),o=n.track.getSettings(),c=i.outboundVideoRtpId.map(l=>{const h=e.outboundVideoRtp.get(l);return h.frameHeight||(h.frameHeight=o.height,h.frameWidth=o.width,h.framesPerSecond=o.frameRate),h}),d={producerId:s,appData:n.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(l=>e.outboundAudioRtp.get(l))};r.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return r}getConsumerStatsFromParsedConsumerStats(e,r,i){let s;try{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(i),d=r==null?void 0:r.inboundVideoRtpId.map(l=>{const h=this.consumerMap.get(i).track.getSettings(),m=e.inboundVideoRtp.get(l);return m.frameHeight||(m.frameHeight=h.height,m.frameWidth=h.width,m.framesPerSecond=h.frameRate),m});s={consumerId:i,peerId:n,producerId:o,appData:c,videoStats:d,audioStats:r==null?void 0:r.inboundAudioRtpId.map(l=>e.inboundAudioRtp.get(l))}}catch(n){console.error("getConsumerStatsFromParsedConsumerStats: ",n,e)}return s}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{r.push(this.getConsumerStatsFromParsedConsumerStats(e,i,s))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return r}}class BE extends Gf{}function $d(t,e,r,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof r=="function"&&i instanceof e)r.call(null,i,t);else throw i}function Kp(t,e,r){const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{$d(this,e,r,o)}):n}catch(n){$d(this,e,r,n)}return null},t}const X=(t,e)=>(r,i,s)=>{const n=s.value;return s.value=function(...o){try{const c=n.apply(this,o);return c&&c instanceof Promise?c.catch(d=>{$d(this,t,e,d)}):c}catch(c){$d(this,t,e,c)}return null},s},WE=(t,e)=>(r,i,s)=>{if(s)return Kp(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);o.value instanceof Function&&Object.defineProperty(r.prototype,n,Kp(o,t,e))}};var Y=globalThis&&globalThis.__decorate||function(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n};const Q=console;let K=class extends mt{constructor(t="https://api.testingv3.dyte.in",e="Blink",r=Vo.PROD,i,s,n,o){switch(super(),p(this,"observer"),p(this,"eventHandler"),p(this,"measurements"),p(this,"producingTransport"),p(this,"consumingTransport"),p(this,"producers",new Map),p(this,"consumers",new Map),p(this,"iceServers"),p(this,"connectionInfoPromise"),p(this,"pingStatsTimeout"),p(this,"logger"),p(this,"env"),p(this,"apiHostnames"),p(this,"peerId"),p(this,"consumerSharedMediaStatesMap",new Map),p(this,"currentUserMediaStates",{}),this.env=r,this.apiHostnames=o,this.logger=s,this.peerId=n,this.eventHandler=new _E({logger:s,peerId:n,apiHostnames:o}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new FE;break;case"Gecko":this.measurements=new Gf;break;case"WebKit":this.measurements=new BE;break;default:throw Error(`Unknown engineName! ${e}`)}this.measurements.callStatsInstance=this,this.registerProducer=this.registerProducer.bind(this),this.registerConsumer=this.registerConsumer.bind(this),this.observer=new mt,this.measurements.observer.on("consumer_score",c=>{s.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{s.debug(`callStats::producer_score ${[...c.entries()]}`),this.eventHandler.emit("producer_score",c)})}registerIceServers(t){this.iceServers=t}registerConsumer(t){var e;this.consumerSharedMediaStatesMap.has(t.id)||this.consumerSharedMediaStatesMap.set(t.id,{}),this.consumers.set(t.id,t),this.measurements.registerConsumer(t),this.logger.debug("callStats::registerConsumer",{consumerId:t.id,consumerkind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterConsumer.bind(this,t))}registerProducer(t){var e;this.producers.set(t.id,t),this.measurements.registerProducer(t),this.logger.debug("callStats::registerProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterProducer.bind(this,t))}sendConsumerSharedMediaStateEvent(t,e){this.consumerSharedMediaStatesMap.has(t)||this.consumerSharedMediaStatesMap.set(t,{});const r=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(r,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.on("close",this.disconnectProducingTransport.bind(this,t)),t.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(r=>{this.registerProducer(r)}),t.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.on("close",this.disconnectConsumingTransport.bind(this,t)),t.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(r=>{this.registerConsumer(r)}),t.on("newconsumer",this.registerConsumer)}deRegisterConsumer(t){this.consumers.delete(t.id)}deRegisterProducer(t){var e;this.producers.delete(t.id),this.logger.debug("callStats::deRegisterProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)})}disconnectConsumingTransport(){this.consumingTransport=void 0}disconnectProducingTransport(){this.producingTransport=void 0}callEvent(t){this.eventHandler.callEvent(t)}sendPreCallTestBeginEvent(t=!1,e){this.connectionInfoPromise=this.measurements.getNetworkInfo(this.iceServers,t),this.eventHandler.callEvent({event:L.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(r=>{this.eventHandler.callEvent({event:L.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:r},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,r){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?L.SCREENSHARE_STARTED:L.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:r})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:L.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:L.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_DEVICES_UPDATES||t===or.VIDEO&&L.VIDEO_DEVICES_UPDATES||t===or.SPEAKER&&L.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:r})}selectedDevice(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.SELECTED_MICROHPONE_UPDATE||t===or.VIDEO&&L.SELECTED_CAMERA_UPDATE||t===or.SPEAKER&&L.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:r})}mediaPermission(t,e,r){this.eventHandler.callEvent({event:L.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:r})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_PLAY_FAILED||t===or.VIDEO&&L.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_TRACK_MUTED||t===or.VIDEO&&L.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:L.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:L.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:L.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:L.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return u(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=q(V({},t),{meetingEnv:this.env}),t.deviceInfo=q(V({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:L.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((r,i)=>u(this,null,function*(){const s=[];try{for(const n of t)try{if(n.iceServers&&n.iceServers.length>0){const o=yield this.measurements.getNetworkQuality(n.iceServers);s.push(q(V({},n),{networkResults:o}))}}catch(o){console.warn("Error handling ",o)}r({regionData:s})}catch(n){console.warn("Error in callstats, ",n),i(n)}})).then(r=>{this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_END,timestamp:e,metaData:r})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:L.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:L.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let r;t?r=L.AUDIO_ON:r=L.AUDIO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let r;t?r=L.VIDEO_ON:r=L.VIDEO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:L.PARTICIPANT_ROLE,timestamp:e,metaData:t})}startPingStats(t=7e3){this.sendPingStatsEvent(!1,new Date),this.pingStatsTimeout=setInterval(this.sendPingStatsEvent.bind(this),t)}stopPingStats(){clearInterval(this.pingStatsTimeout)}sendPingStatsEvent(t=!0,e){return u(this,null,function*(){let r,i;if(this.producingTransport&&(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!r||!(r!=null&&r.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const n=yield this.measurements.getProducersReport([...this.producers.values()]);r&&n?r.producerReport=n:(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!r||!(r!=null&&r.producerReport))&&this.logger.debug("callStats::sendPingStatsEvent::noProducingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}if(this.consumingTransport&&(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),!i||!i.consumerReport)){this.logger.debug("callStats::sendPingStatsEvent::staleConsumingTransport",{disclaimer:"Stale consumer? Regenerating Stream Maps!"});const n=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&n?i.consumerReport=n:(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),(!i||!i.consumerReport)&&this.logger.debug("callStats::sendPingStatsEvent::noConsumingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}const s={producingTransportStats:r?r==null?void 0:r.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((r==null?void 0:r.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((r==null?void 0:r.consumerReport)||[])};if(t&&s.producerStats.length===0&&s.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:L.PING_STAT,metaData:s,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:L.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:L.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:L.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_VIDEO_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}};Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerIceServers",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendConsumerSharedMediaStateEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterConsumer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterProducer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectConsumingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectProducingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPreCallTestBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareRequestedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendActiveSpeakerEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"devices",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"selectedDevice",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPermission",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPlaybackFailed",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaTrackMuted",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"tabChanged",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserBackgrounded",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserForegrounded",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"legacySwitch",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"getPreCallTestResults",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendCallJoinBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendNetworkQualityTestBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendWebSocketConnectedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendTransportConnectedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendAudioToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendVideoToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendParticipantRoleToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"startPingStats",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"stopPingStats",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPingStatsEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRebufferEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAudioBlockEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerInitializedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerWorkerErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRecoverableErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAnalyticsEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerQualityChanged",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPlayerLiveLatency",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendDisconnectEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendReconnectEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedVideoResolution",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedScreenshareResolution",null);K=Y([WE(TypeError,(t,e)=>Q.error(e,t))],K);const jE=K;class qf extends mt{constructor(){super(...arguments),p(this,"stats"),p(this,"peerId"),p(this,"backend"),p(this,"iceServers"),p(this,"initialized",!1),p(this,"stalled",!1),p(this,"ipInformation"),p(this,"logger")}initialize(e){return u(this,arguments,function*({peerId:r,engineName:i,env:s=Vo.PROD,iceServers:n,apiBase:o="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:l,skipConnectivityChecks:h=!1}){var m,v,S;try{this.peerId=r,this.logger=d,this.ipInformation=yield ep.getIPDetails({peerId:r,apiHostnames:l,logger:d}),this.backend=new jE(o,i,s,c,d,r,l),this.iceServers=n,(m=this.backend)==null||m.registerIceServers(this.iceServers),this.initialized=!0,(S=(v=this.backend)==null?void 0:v.eventHandler)==null||S.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(h)}catch(T){this.logger.error("callStats::CallStatsIntegration: ",{error:T}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,r)}catch(s){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:s.reason}})}})})}roomJoined(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i,s;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,r),this.backend,(s=this.backend)==null||s.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var r,i;(r=this.backend)==null||r.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,r)})}consumerSharedMediaState(e,r){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,r)})}screenShareStop(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,r)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,r)})}devices(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.devices(e,r,i)})}selectedDevice(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.selectedDevice(e,r,i)})}mediaPermission(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.mediaPermission(e,r,i)})}mediaPlaybackFailed(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,r)})}mediaTrackMuted(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,r)})}tabChanged(e=!1){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,r)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserForegrounded(e)})}legacySwitch(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,r)})}startPreCallTest(e=!1){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,r)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const r=i=>{e(i,!0)};return this.once("initialized",r),r}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,r){const i=new Date;this.onSafeInitialization(()=>{var s,n,o,c,d,l,h,m,v,S,T;switch(e){case"PlayerRebuffering":(s=this.backend)==null||s.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(n=this.backend)==null||n.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(o=this.backend)==null||o.sendIVSPlayerPlaybackBlockedEvent(i);break;case"PlayerNetworkUnavailable":(c=this.backend)==null||c.sendIVSPlayerNetworkUnavailableEvent(i);break;case"PlayerInitialized":(d=this.backend)==null||d.sendIVSPlayerInitializedEvent(i);break;case"PlayerWorkerError":(l=this.backend)==null||l.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(h=this.backend)==null||h.sendIVSPlayerErrorEvent(r,i);break;case"PlayerRecoverableError":(m=this.backend)==null||m.sendIVSPlayerRecoverableErrorEvent(r,i);break;case"PlayerAnalyticsEvent":(v=this.backend)==null||v.sendIVSPlayerAnalyticsEvent(r,i);break;case"PlayerPlaybackRateChanged":(S=this.backend)==null||S.sendIVSPlayerPlaybackRateChangedEvent(r,i);break;case"PlayerQualityChanged":(T=this.backend)==null||T.sendIVSPlayerQualityChanged(r,i);break}})}livestreamLatency(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,r)})}expectedVideoResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedVideoResolution(e,r,i)})}expectedScreenshareResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedScreenshareResolution(e,r,i)})}}const HE=new qf;HE.setMaxListeners(30);function GE(){this.__data__=[],this.size=0}function tc(t,e){return t===e||t!==t&&e!==e}function Tl(t,e){for(var r=t.length;r--;)if(tc(t[r][0],e))return r;return-1}var qE=Array.prototype,$E=qE.splice;function JE(t){var e=this.__data__,r=Tl(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():$E.call(e,r,1),--this.size,!0}function KE(t){var e=this.__data__,r=Tl(e,t);return r<0?void 0:e[r][1]}function zE(t){return Tl(this.__data__,t)>-1}function YE(t,e){var r=this.__data__,i=Tl(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}function ui(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ui.prototype.clear=GE;ui.prototype.delete=JE;ui.prototype.get=KE;ui.prototype.has=zE;ui.prototype.set=YE;function QE(){this.__data__=new ui,this.size=0}function XE(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}function ZE(t){return this.__data__.get(t)}function ek(t){return this.__data__.has(t)}var tk=typeof global=="object"&&global&&global.Object===Object&&global;const $f=tk;var rk=typeof self=="object"&&self&&self.Object===Object&&self,ik=$f||rk||Function("return this")();const Cr=ik;var sk=Cr.Symbol;const ji=sk;var Jf=Object.prototype,nk=Jf.hasOwnProperty,ak=Jf.toString,Ta=ji?ji.toStringTag:void 0;function ok(t){var e=nk.call(t,Ta),r=t[Ta];try{t[Ta]=void 0;var i=!0}catch{}var s=ak.call(t);return i&&(e?t[Ta]=r:delete t[Ta]),s}var ck=Object.prototype,dk=ck.toString;function lk(t){return dk.call(t)}var uk="[object Null]",hk="[object Undefined]",zp=ji?ji.toStringTag:void 0;function Fs(t){return t==null?t===void 0?hk:uk:zp&&zp in Object(t)?ok(t):lk(t)}function Ir(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var pk="[object AsyncFunction]",mk="[object Function]",gk="[object GeneratorFunction]",fk="[object Proxy]";function tp(t){if(!Ir(t))return!1;var e=Fs(t);return e==mk||e==gk||e==pk||e==fk}var vk=Cr["__core-js_shared__"];const Gl=vk;var Yp=function(){var t=/[^.]+$/.exec(Gl&&Gl.keys&&Gl.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function yk(t){return!!Yp&&Yp in t}var Sk=Function.prototype,Ek=Sk.toString;function Bs(t){if(t!=null){try{return Ek.call(t)}catch{}try{return t+""}catch{}}return""}var kk=/[\\^$.*+?()[\]{}|]/g,Tk=/^\[object .+?Constructor\]$/,bk=Function.prototype,wk=Object.prototype,_k=bk.toString,Ik=wk.hasOwnProperty,Ck=RegExp("^"+_k.call(Ik).replace(kk,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Pk(t){if(!Ir(t)||yk(t))return!1;var e=tp(t)?Ck:Tk;return e.test(Bs(t))}function Rk(t,e){return t==null?void 0:t[e]}function Ws(t,e){var r=Rk(t,e);return Pk(r)?r:void 0}var Mk=Ws(Cr,"Map");const Xo=Mk;var Ak=Ws(Object,"create");const Zo=Ak;function Dk(){this.__data__=Zo?Zo(null):{},this.size=0}function Ok(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Nk="__lodash_hash_undefined__",Vk=Object.prototype,Lk=Vk.hasOwnProperty;function xk(t){var e=this.__data__;if(Zo){var r=e[t];return r===Nk?void 0:r}return Lk.call(e,t)?e[t]:void 0}var Uk=Object.prototype,Fk=Uk.hasOwnProperty;function Bk(t){var e=this.__data__;return Zo?e[t]!==void 0:Fk.call(e,t)}var Wk="__lodash_hash_undefined__";function jk(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Zo&&e===void 0?Wk:e,this}function Vs(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Vs.prototype.clear=Dk;Vs.prototype.delete=Ok;Vs.prototype.get=xk;Vs.prototype.has=Bk;Vs.prototype.set=jk;function Hk(){this.size=0,this.__data__={hash:new Vs,map:new(Xo||ui),string:new Vs}}function Gk(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function bl(t,e){var r=t.__data__;return Gk(e)?r[typeof e=="string"?"string":"hash"]:r.map}function qk(t){var e=bl(this,t).delete(t);return this.size-=e?1:0,e}function $k(t){return bl(this,t).get(t)}function Jk(t){return bl(this,t).has(t)}function Kk(t,e){var r=bl(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}function js(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}js.prototype.clear=Hk;js.prototype.delete=qk;js.prototype.get=$k;js.prototype.has=Jk;js.prototype.set=Kk;var zk=200;function Yk(t,e){var r=this.__data__;if(r instanceof ui){var i=r.__data__;if(!Xo||i.length<zk-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new js(i)}return r.set(t,e),this.size=r.size,this}function Hr(t){var e=this.__data__=new ui(t);this.size=e.size}Hr.prototype.clear=QE;Hr.prototype.delete=XE;Hr.prototype.get=ZE;Hr.prototype.has=ek;Hr.prototype.set=Yk;function Qk(t,e){for(var r=-1,i=t==null?0:t.length;++r<i&&e(t[r],r,t)!==!1;);return t}var Xk=function(){try{var t=Ws(Object,"defineProperty");return t({},"",{}),t}catch{}}();const Jd=Xk;function rp(t,e,r){e=="__proto__"&&Jd?Jd(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Zk=Object.prototype,eT=Zk.hasOwnProperty;function Kf(t,e,r){var i=t[e];(!(eT.call(t,e)&&tc(i,r))||r===void 0&&!(e in t))&&rp(t,e,r)}function rc(t,e,r,i){var s=!r;r||(r={});for(var n=-1,o=e.length;++n<o;){var c=e[n],d=i?i(r[c],t[c],c,r,t):void 0;d===void 0&&(d=t[c]),s?rp(r,c,d):Kf(r,c,d)}return r}function tT(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}function Gr(t){return t!=null&&typeof t=="object"}var rT="[object Arguments]";function Qp(t){return Gr(t)&&Fs(t)==rT}var zf=Object.prototype,iT=zf.hasOwnProperty,sT=zf.propertyIsEnumerable,nT=Qp(function(){return arguments}())?Qp:function(t){return Gr(t)&&iT.call(t,"callee")&&!sT.call(t,"callee")};const Kd=nT;var aT=Array.isArray;const Hi=aT;function oT(){return!1}var Yf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xp=Yf&&typeof module=="object"&&module&&!module.nodeType&&module,cT=Xp&&Xp.exports===Yf,Zp=cT?Cr.Buffer:void 0,dT=Zp?Zp.isBuffer:void 0,lT=dT||oT;const Qn=lT;var uT=9007199254740991,hT=/^(?:0|[1-9]\d*)$/;function Qf(t,e){var r=typeof t;return e=e==null?uT:e,!!e&&(r=="number"||r!="symbol"&&hT.test(t))&&t>-1&&t%1==0&&t<e}var pT=9007199254740991;function Xf(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pT}var mT="[object Arguments]",gT="[object Array]",fT="[object Boolean]",vT="[object Date]",yT="[object Error]",ST="[object Function]",ET="[object Map]",kT="[object Number]",TT="[object Object]",bT="[object RegExp]",wT="[object Set]",_T="[object String]",IT="[object WeakMap]",CT="[object ArrayBuffer]",PT="[object DataView]",RT="[object Float32Array]",MT="[object Float64Array]",AT="[object Int8Array]",DT="[object Int16Array]",OT="[object Int32Array]",NT="[object Uint8Array]",VT="[object Uint8ClampedArray]",LT="[object Uint16Array]",xT="[object Uint32Array]",_e={};_e[RT]=_e[MT]=_e[AT]=_e[DT]=_e[OT]=_e[NT]=_e[VT]=_e[LT]=_e[xT]=!0;_e[mT]=_e[gT]=_e[CT]=_e[fT]=_e[PT]=_e[vT]=_e[yT]=_e[ST]=_e[ET]=_e[kT]=_e[TT]=_e[bT]=_e[wT]=_e[_T]=_e[IT]=!1;function UT(t){return Gr(t)&&Xf(t.length)&&!!_e[Fs(t)]}function ip(t){return function(e){return t(e)}}var Zf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lo=Zf&&typeof module=="object"&&module&&!module.nodeType&&module,FT=Lo&&Lo.exports===Zf,ql=FT&&$f.process,BT=function(){try{var t=Lo&&Lo.require&&Lo.require("util").types;return t||ql&&ql.binding&&ql.binding("util")}catch{}}();const Xn=BT;var em=Xn&&Xn.isTypedArray,WT=em?ip(em):UT;const wl=WT;var jT=Object.prototype,HT=jT.hasOwnProperty;function ev(t,e){var r=Hi(t),i=!r&&Kd(t),s=!r&&!i&&Qn(t),n=!r&&!i&&!s&&wl(t),o=r||i||s||n,c=o?tT(t.length,String):[],d=c.length;for(var l in t)(e||HT.call(t,l))&&!(o&&(l=="length"||s&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Qf(l,d)))&&c.push(l);return c}var GT=Object.prototype;function _l(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||GT;return t===r}function tv(t,e){return function(r){return t(e(r))}}var qT=tv(Object.keys,Object);const $T=qT;var JT=Object.prototype,KT=JT.hasOwnProperty;function rv(t){if(!_l(t))return $T(t);var e=[];for(var r in Object(t))KT.call(t,r)&&r!="constructor"&&e.push(r);return e}function ic(t){return t!=null&&Xf(t.length)&&!tp(t)}function sp(t){return ic(t)?ev(t):rv(t)}function zT(t,e){return t&&rc(e,sp(e),t)}function YT(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var QT=Object.prototype,XT=QT.hasOwnProperty;function ZT(t){if(!Ir(t))return YT(t);var e=_l(t),r=[];for(var i in t)i=="constructor"&&(e||!XT.call(t,i))||r.push(i);return r}function sc(t){return ic(t)?ev(t,!0):ZT(t)}function eb(t,e){return t&&rc(e,sc(e),t)}var iv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tm=iv&&typeof module=="object"&&module&&!module.nodeType&&module,tb=tm&&tm.exports===iv,rm=tb?Cr.Buffer:void 0,im=rm?rm.allocUnsafe:void 0;function sv(t,e){if(e)return t.slice();var r=t.length,i=im?im(r):new t.constructor(r);return t.copy(i),i}function nv(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}function rb(t,e){for(var r=-1,i=t==null?0:t.length,s=0,n=[];++r<i;){var o=t[r];e(o,r,t)&&(n[s++]=o)}return n}function av(){return[]}var ib=Object.prototype,sb=ib.propertyIsEnumerable,sm=Object.getOwnPropertySymbols,nb=sm?function(t){return t==null?[]:(t=Object(t),rb(sm(t),function(e){return sb.call(t,e)}))}:av;const np=nb;function ab(t,e){return rc(t,np(t),e)}function ov(t,e){for(var r=-1,i=e.length,s=t.length;++r<i;)t[s+r]=e[r];return t}var ob=tv(Object.getPrototypeOf,Object);const ap=ob;var cb=Object.getOwnPropertySymbols,db=cb?function(t){for(var e=[];t;)ov(e,np(t)),t=ap(t);return e}:av;const cv=db;function lb(t,e){return rc(t,cv(t),e)}function dv(t,e,r){var i=e(t);return Hi(t)?i:ov(i,r(t))}function Lu(t){return dv(t,sp,np)}function ub(t){return dv(t,sc,cv)}var hb=Ws(Cr,"DataView");const xu=hb;var pb=Ws(Cr,"Promise");const Uu=pb;var mb=Ws(Cr,"Set");const Fu=mb;var gb=Ws(Cr,"WeakMap");const Bu=gb;var nm="[object Map]",fb="[object Object]",am="[object Promise]",om="[object Set]",cm="[object WeakMap]",dm="[object DataView]",vb=Bs(xu),yb=Bs(Xo),Sb=Bs(Uu),Eb=Bs(Fu),kb=Bs(Bu),cs=Fs;(xu&&cs(new xu(new ArrayBuffer(1)))!=dm||Xo&&cs(new Xo)!=nm||Uu&&cs(Uu.resolve())!=am||Fu&&cs(new Fu)!=om||Bu&&cs(new Bu)!=cm)&&(cs=function(t){var e=Fs(t),r=e==fb?t.constructor:void 0,i=r?Bs(r):"";if(i)switch(i){case vb:return dm;case yb:return nm;case Sb:return am;case Eb:return om;case kb:return cm}return e});const Zn=cs;var Tb=Object.prototype,bb=Tb.hasOwnProperty;function wb(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&bb.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var _b=Cr.Uint8Array;const zd=_b;function op(t){var e=new t.constructor(t.byteLength);return new zd(e).set(new zd(t)),e}function Ib(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cb=/\w*$/;function Pb(t){var e=new t.constructor(t.source,Cb.exec(t));return e.lastIndex=t.lastIndex,e}var lm=ji?ji.prototype:void 0,um=lm?lm.valueOf:void 0;function Rb(t){return um?Object(um.call(t)):{}}function lv(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Mb="[object Boolean]",Ab="[object Date]",Db="[object Map]",Ob="[object Number]",Nb="[object RegExp]",Vb="[object Set]",Lb="[object String]",xb="[object Symbol]",Ub="[object ArrayBuffer]",Fb="[object DataView]",Bb="[object Float32Array]",Wb="[object Float64Array]",jb="[object Int8Array]",Hb="[object Int16Array]",Gb="[object Int32Array]",qb="[object Uint8Array]",$b="[object Uint8ClampedArray]",Jb="[object Uint16Array]",Kb="[object Uint32Array]";function zb(t,e,r){var i=t.constructor;switch(e){case Ub:return op(t);case Mb:case Ab:return new i(+t);case Fb:return Ib(t,r);case Bb:case Wb:case jb:case Hb:case Gb:case qb:case $b:case Jb:case Kb:return lv(t,r);case Db:return new i;case Ob:case Lb:return new i(t);case Nb:return Pb(t);case Vb:return new i;case xb:return Rb(t)}}var hm=Object.create,Yb=function(){function t(){}return function(e){if(!Ir(e))return{};if(hm)return hm(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const Qb=Yb;function uv(t){return typeof t.constructor=="function"&&!_l(t)?Qb(ap(t)):{}}var Xb="[object Map]";function Zb(t){return Gr(t)&&Zn(t)==Xb}var pm=Xn&&Xn.isMap,ew=pm?ip(pm):Zb;const tw=ew;var rw="[object Set]";function iw(t){return Gr(t)&&Zn(t)==rw}var mm=Xn&&Xn.isSet,sw=mm?ip(mm):iw;const nw=sw;var aw=1,ow=2,cw=4,hv="[object Arguments]",dw="[object Array]",lw="[object Boolean]",uw="[object Date]",hw="[object Error]",pv="[object Function]",pw="[object GeneratorFunction]",mw="[object Map]",gw="[object Number]",mv="[object Object]",fw="[object RegExp]",vw="[object Set]",yw="[object String]",Sw="[object Symbol]",Ew="[object WeakMap]",kw="[object ArrayBuffer]",Tw="[object DataView]",bw="[object Float32Array]",ww="[object Float64Array]",_w="[object Int8Array]",Iw="[object Int16Array]",Cw="[object Int32Array]",Pw="[object Uint8Array]",Rw="[object Uint8ClampedArray]",Mw="[object Uint16Array]",Aw="[object Uint32Array]",Ee={};Ee[hv]=Ee[dw]=Ee[kw]=Ee[Tw]=Ee[lw]=Ee[uw]=Ee[bw]=Ee[ww]=Ee[_w]=Ee[Iw]=Ee[Cw]=Ee[mw]=Ee[gw]=Ee[mv]=Ee[fw]=Ee[vw]=Ee[yw]=Ee[Sw]=Ee[Pw]=Ee[Rw]=Ee[Mw]=Ee[Aw]=!0;Ee[hw]=Ee[pv]=Ee[Ew]=!1;function Jc(t,e,r,i,s,n){var o,c=e&aw,d=e&ow,l=e&cw;if(r&&(o=s?r(t,i,s,n):r(t)),o!==void 0)return o;if(!Ir(t))return t;var h=Hi(t);if(h){if(o=wb(t),!c)return nv(t,o)}else{var m=Zn(t),v=m==pv||m==pw;if(Qn(t))return sv(t,c);if(m==mv||m==hv||v&&!s){if(o=d||v?{}:uv(t),!c)return d?lb(t,eb(o,t)):ab(t,zT(o,t))}else{if(!Ee[m])return s?t:{};o=zb(t,m,c)}}n||(n=new Hr);var S=n.get(t);if(S)return S;n.set(t,o),nw(t)?t.forEach(function(b){o.add(Jc(b,e,r,b,t,n))}):tw(t)&&t.forEach(function(b,R){o.set(R,Jc(b,e,r,R,t,n))});var T=l?d?ub:Lu:d?sc:sp,M=h?void 0:T(t);return Qk(M||t,function(b,R){M&&(R=b,b=t[R]),Kf(o,R,Jc(b,e,r,R,t,n))}),o}var Dw=1,Ow=4;function cp(t){return Jc(t,Dw|Ow)}var Nw="[object Symbol]";function Vw(t){return typeof t=="symbol"||Gr(t)&&Fs(t)==Nw}var Lw=Object.defineProperty,xw=(t,e)=>{for(var r in e)Lw(t,r,{get:e[r],enumerable:!0})},Uw={};xw(Uw,{permissions:()=>Fw,theme:()=>Bw});var Ft=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Ft||{}),G=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(G||{}),Fw={view_type:"GROUP_CALL",accept_waiting_requests:!1,accept_present_requests:!1,request_produce:!1,can_allow_participant_audio:!1,can_allow_participant_screensharing:!1,can_allow_participant_video:!1,can_spotlight:!1,request_kick_participant:!1,kick_participant:!1,pin_participant:!1,can_edit_display_name:!1,can_record:!1,can_livestream:!1,can_present:!0,waiting_room_type:"SKIP_ON_ACCEPT",recorder_type:"NONE",plugins:{can_close:!0,can_start:!0},polls:{can_create:!0,can_vote:!0,can_view:!0},produce:{video:{allow:!0,quality:"vga",frame_rate:24},audio:!0,screenshare:{allow:!0,quality:"hd",frame_rate:5}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},reactions:!1,hidden_participant:!1,is_recorder:!1,show_participant_list:!0,can_change_participant_role:!1,can_change_theme:!1,max_screenshare_count:1},Bw={setup_screen:{is_enabled:!0},alone_here:{is_enabled:!0},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!0,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"multi"},controls:{pip_toggle:!1}},gv="hXgU8Wc8pwuGNq9ms5q9Hh",gm;typeof process!="undefined"&&(gm=process==null?void 0:process.env)!=null&&gm.FLAGSMITH_ENVIRONMENT_KEY&&(gv={}.FLAGSMITH_ENVIRONMENT_KEY);function Ww(t=[]){const e={};return t.forEach(r=>{e[r.feature.name]={enabled:r.enabled,value:r.feature_state_value}}),e}var fv=class{constructor(t=gv){p(this,"flags",{}),p(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return u(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:r,forceEvaluate:i,timeout:s,uniqueIdentifier:n,traitsObj:o,logger:c}){const d=JSON.parse(JSON.stringify(o)),l=Object.entries(d).map(m=>({trait_key:m[0],trait_value:m[1]})),h=[e,r,r];for(const m of h)try{const v=new AbortController,S=setTimeout(()=>v.abort(),s),T="_"+(Math.random()+1).toString(36).substring(2),M=yield fetch(`https://${m}/api/v1/identities/`,{method:"POST",headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},body:JSON.stringify({identifier:n+(i?T:""),traits:l}),signal:v.signal});if(clearTimeout(S),!M.ok)throw new Error(`Request failed with status ${M.status}`);const b=yield M.json();return Ww(b.flags||[])}catch(v){c.error("Flagsmith identify failed!!",{error:v,url:m})}return{}})}identify(t){return u(this,arguments,function*(e,r={},i=!1,s=5e3,n="edge.api.flagsmith.com",o=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:r,uniqueIdentifier:e,forceEvaluate:i,timeout:s,primaryEndpoint:n,secondaryEndpoint:"edge.api.flagsmith.com",logger:o}),this.flags})}getValue(t){return this.flags&&this.flags[t]&&this.flags[t].value}hasFeature(t){return this.flags&&this.flags[t]&&this.flags[t].enabled}getAllFlags(){return this.flags}},jw=new fv;function Hw(t){return new fv(t)}var vv=[-2,-1,0,1,2],Gw=[0,1,2,3,4];function qw(t){t=t.trim();let e="0",r="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],r="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],r="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+r,+i]}var $w=(t,e,r)=>{let i,s,n;if(e==0)i=s=n=r;else{const o=(l,h,m)=>(m<0&&(m+=1),m>1&&(m-=1),m<.16666666666666666?l+(h-l)*6*m:m<.5?h:m<.6666666666666666?l+(h-l)*(.6666666666666666-m)*6:l),c=r<.5?r*(1+e):r+e-r*e,d=2*r-c;i=o(d,c,t+1/3),s=o(d,c,t),n=o(d,c,t-1/3)}return[Math.round(i*255),Math.round(s*255),Math.round(n*255)]},Jw=(t,e,r)=>{t/=255,e/=255,r/=255;const i=Math.max(t,e,r),s=Math.min(t,e,r);let n,o;const c=(i+s)/2;if(i==s)n=o=0;else{const d=i-s;switch(o=c>.5?d/(2-i-s):d/(i+s),i){case t:n=(e-r)/d+(e<r?6:0);break;case e:n=(r-t)/d+2;break;case r:n=(t-e)/d+4;break}n/=6}return[n,o,c]},Kw=(t,e,r)=>{const i=s=>s.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(r)}`},yv=(t,e=vv,r=.4)=>{const i=[],[s,n,o]=qw(t),[c,d,l]=Jw(s,n,o),h=Math.round(l*100);h>70?r=.8:h>60?r=.9:h<10?r=.075:h<42&&(r=.3);const m=e.findIndex(b=>b===0);if(m===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const v=5-m,S=m+1,T=(100-h)/v,M=h/S;for(const b of e){let R;b<0?R=h+b*M*r:b>0?R=h+b*T*r:R=h;const[j,W,w]=$w(c,d,R/100);i.push(Kw(j,W,w))}return i},fm={dark:{background:{1e3:"#252525",900:"#2F2F2F",800:"#323232",700:"#3E3E3E",600:"#4A4A4A"},text:"#F5F5F5","video-bg":"#1C1C1C"},light:{background:{1e3:"#FFFFFF",900:"#F5F5F5",800:"#EBEBEB",700:"#E0E0E0",600:"#D6D6D6"},text:"#111111","text-on-brand":"#ffffff","video-bg":"#DADADA"}},zw=t=>{const[e,r,i,s,n]=yv(t,vv);return{300:e,400:r,500:i,600:s,700:n}},Yw=t=>{if(t==="#FFFFFF")return fm.light.background;if(t==="#000000")return fm.dark.background;const[e,r,i,s,n]=yv(t,Gw);return{1e3:e,900:r,800:i,700:s,600:n}},Qw={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:zw("#2160FD"),background:Yw("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function Sv(){return cp(Qw)}var Xw={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED",can_consume:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED",can_consume:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1},channel:{can_create:"ALL",can_delete:"ALL",can_update:"ALL",can_read_all:!1},message:{can_delete:"ALL",can_edit:"ALL",delete_cutoff_time_seconds:0,edit_cutoff_time_seconds:0}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{oldTheme:{setup_screen:{is_enabled:!1},alone_here:{is_enabled:!1},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!1,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,colors:{primary:"#2160FD",secondary:"#1A1A1A",text:"#EEEEEE",background:"#1A1A1A",textPrimary:"#EEEEEE",videoBackground:"#1A1A1A"},dimensions:{mode:"fillParent"},grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"MULTI"},controls:{pip_toggle:!1},plugins:[]},design_tokens:Sv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"hybrid"};function Zw(){return cp(Xw)}var e_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{design_tokens:Sv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"2.0.0"};function dp(){return cp(e_)}var Kc;class Ev{constructor(){g(this,Kc,void 0)}get telemetry(){var e;return(e=a(this,Kc))==null?void 0:e.getValue("telemetry")}init(e){f(this,Kc,e)}info(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("info",e,r,i)}error(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("error",e,r,i)}debug(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("debug",e,r,i)}log(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("log",e,r,i)}warn(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("warn",e,r,i)}}Kc=new WeakMap;var ki,Ti;const kv=class extends mt.EventEmitter{constructor(t){super(),g(this,ki,void 0),g(this,Ti,void 0),p(this,"asyncPromiseTimeout"),p(this,"logger"),this.logger=t,f(this,ki,new Map),f(this,Ti,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return u(this,null,function*(){a(this,ki).set(t,[]);const r=a(this,Ti).get(t).map(()=>new Promise(i=>{a(this,ki).get(t).push(i)}));nE(kv.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(r),new Promise((i,s)=>setTimeout(()=>s(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),a(this,ki).delete(t)})}onAsync(t,e){const r=a(this,ki),i=(...s)=>u(this,null,function*(){var n;try{yield e(...s)}catch(c){this.logger.error("[onAsync]",{error:c})}const o=(n=r.get(t))==null?void 0:n.shift();o==null||o()});return a(this,Ti).get(t)||a(this,Ti).set(t,[]),a(this,Ti).get(t).push(i),super.on(t,i)}reset(){f(this,ki,new Map),f(this,Ti,new Map),super.removeAllListeners()}};let t_=kv;ki=new WeakMap,Ti=new WeakMap;var r_=/\s/;function i_(t){for(var e=t.length;e--&&r_.test(t.charAt(e)););return e}var s_=/^\s+/;function n_(t){return t&&t.slice(0,i_(t)+1).replace(s_,"")}var vm=0/0,a_=/^[-+]0x[0-9a-f]+$/i,o_=/^0b[01]+$/i,c_=/^0o[0-7]+$/i,d_=parseInt;function ym(t){if(typeof t=="number")return t;if(Vw(t))return vm;if(Ir(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Ir(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=n_(t);var r=o_.test(t);return r||c_.test(t)?d_(t.slice(2),r?2:8):a_.test(t)?vm:+t}function Tv(t){return t}function l_(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var u_=800,h_=16,p_=Date.now;function m_(t){var e=0,r=0;return function(){var i=p_(),s=h_-(i-r);if(r=i,s>0){if(++e>=u_)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function g_(t){return function(){return t}}var f_=Jd?function(t,e){return Jd(t,"toString",{configurable:!0,enumerable:!1,value:g_(e),writable:!0})}:Tv;const v_=f_;var y_=m_(v_);const S_=y_;var Sm=Math.max;function E_(t,e,r){return e=Sm(e===void 0?t.length-1:e,0),function(){for(var i=arguments,s=-1,n=Sm(i.length-e,0),o=Array(n);++s<n;)o[s]=i[e+s];s=-1;for(var c=Array(e+1);++s<e;)c[s]=i[s];return c[e]=r(o),l_(t,this,c)}}function k_(t,e){return S_(E_(t,e,Tv),t+"")}function T_(t,e,r){if(!Ir(r))return!1;var i=typeof e;return(i=="number"?ic(r)&&Qf(e,r.length):i=="string"&&e in r)?tc(r[e],t):!1}function b_(t){return k_(function(e,r){var i=-1,s=r.length,n=s>1?r[s-1]:void 0,o=s>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(s--,n):void 0,o&&T_(r[0],r[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var c=r[i];c&&t(e,c,i,n)}return e})}var w_="[object Object]",__=Function.prototype,I_=Object.prototype,bv=__.toString,C_=I_.hasOwnProperty,P_=bv.call(Object);function R_(t){if(!Gr(t)||Fs(t)!=w_)return!1;var e=ap(t);if(e===null)return!0;var r=C_.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&bv.call(r)==P_}var M_="__lodash_hash_undefined__";function A_(t){return this.__data__.set(t,M_),this}function D_(t){return this.__data__.has(t)}function Yd(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new js;++e<r;)this.add(t[e])}Yd.prototype.add=Yd.prototype.push=A_;Yd.prototype.has=D_;function O_(t,e){for(var r=-1,i=t==null?0:t.length;++r<i;)if(e(t[r],r,t))return!0;return!1}function N_(t,e){return t.has(e)}var V_=1,L_=2;function wv(t,e,r,i,s,n){var o=r&V_,c=t.length,d=e.length;if(c!=d&&!(o&&d>c))return!1;var l=n.get(t),h=n.get(e);if(l&&h)return l==e&&h==t;var m=-1,v=!0,S=r&L_?new Yd:void 0;for(n.set(t,e),n.set(e,t);++m<c;){var T=t[m],M=e[m];if(i)var b=o?i(M,T,m,e,t,n):i(T,M,m,t,e,n);if(b!==void 0){if(b)continue;v=!1;break}if(S){if(!O_(e,function(R,j){if(!N_(S,j)&&(T===R||s(T,R,r,i,n)))return S.push(j)})){v=!1;break}}else if(!(T===M||s(T,M,r,i,n))){v=!1;break}}return n.delete(t),n.delete(e),v}function x_(t){var e=-1,r=Array(t.size);return t.forEach(function(i,s){r[++e]=[s,i]}),r}function U_(t){var e=-1,r=Array(t.size);return t.forEach(function(i){r[++e]=i}),r}var F_=1,B_=2,W_="[object Boolean]",j_="[object Date]",H_="[object Error]",G_="[object Map]",q_="[object Number]",$_="[object RegExp]",J_="[object Set]",K_="[object String]",z_="[object Symbol]",Y_="[object ArrayBuffer]",Q_="[object DataView]",Em=ji?ji.prototype:void 0,$l=Em?Em.valueOf:void 0;function X_(t,e,r,i,s,n,o){switch(r){case Q_:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Y_:return!(t.byteLength!=e.byteLength||!n(new zd(t),new zd(e)));case W_:case j_:case q_:return tc(+t,+e);case H_:return t.name==e.name&&t.message==e.message;case $_:case K_:return t==e+"";case G_:var c=x_;case J_:var d=i&F_;if(c||(c=U_),t.size!=e.size&&!d)return!1;var l=o.get(t);if(l)return l==e;i|=B_,o.set(t,e);var h=wv(c(t),c(e),i,s,n,o);return o.delete(t),h;case z_:if($l)return $l.call(t)==$l.call(e)}return!1}var Z_=1,e0=Object.prototype,t0=e0.hasOwnProperty;function r0(t,e,r,i,s,n){var o=r&Z_,c=Lu(t),d=c.length,l=Lu(e),h=l.length;if(d!=h&&!o)return!1;for(var m=d;m--;){var v=c[m];if(!(o?v in e:t0.call(e,v)))return!1}var S=n.get(t),T=n.get(e);if(S&&T)return S==e&&T==t;var M=!0;n.set(t,e),n.set(e,t);for(var b=o;++m<d;){v=c[m];var R=t[v],j=e[v];if(i)var W=o?i(j,R,v,e,t,n):i(R,j,v,t,e,n);if(!(W===void 0?R===j||s(R,j,r,i,n):W)){M=!1;break}b||(b=v=="constructor")}if(M&&!b){var w=t.constructor,te=e.constructor;w!=te&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof te=="function"&&te instanceof te)&&(M=!1)}return n.delete(t),n.delete(e),M}var i0=1,km="[object Arguments]",Tm="[object Array]",vc="[object Object]",s0=Object.prototype,bm=s0.hasOwnProperty;function n0(t,e,r,i,s,n){var o=Hi(t),c=Hi(e),d=o?Tm:Zn(t),l=c?Tm:Zn(e);d=d==km?vc:d,l=l==km?vc:l;var h=d==vc,m=l==vc,v=d==l;if(v&&Qn(t)){if(!Qn(e))return!1;o=!0,h=!1}if(v&&!h)return n||(n=new Hr),o||wl(t)?wv(t,e,r,i,s,n):X_(t,e,d,r,i,s,n);if(!(r&i0)){var S=h&&bm.call(t,"__wrapped__"),T=m&&bm.call(e,"__wrapped__");if(S||T){var M=S?t.value():t,b=T?e.value():e;return n||(n=new Hr),s(M,b,r,i,n)}}return v?(n||(n=new Hr),r0(t,e,r,i,s,n)):!1}function _v(t,e,r,i,s){return t===e?!0:t==null||e==null||!Gr(t)&&!Gr(e)?t!==t&&e!==e:n0(t,e,r,i,_v,s)}function a0(t){return function(e,r,i){for(var s=-1,n=Object(e),o=i(e),c=o.length;c--;){var d=o[t?c:++s];if(r(n[d],d,n)===!1)break}return e}}var o0=a0();const c0=o0;var d0=function(){return Cr.Date.now()};const Jl=d0;var l0="Expected a function",u0=Math.max,h0=Math.min;function lp(t,e,r){var i,s,n,o,c,d,l=0,h=!1,m=!1,v=!0;if(typeof t!="function")throw new TypeError(l0);e=ym(e)||0,Ir(r)&&(h=!!r.leading,m="maxWait"in r,n=m?u0(ym(r.maxWait)||0,e):n,v="trailing"in r?!!r.trailing:v);function S(re){var ae=i,Me=s;return i=s=void 0,l=re,o=t.apply(Me,ae),o}function T(re){return l=re,c=setTimeout(R,e),h?S(re):o}function M(re){var ae=re-d,Me=re-l,Xe=e-ae;return m?h0(Xe,n-Me):Xe}function b(re){var ae=re-d,Me=re-l;return d===void 0||ae>=e||ae<0||m&&Me>=n}function R(){var re=Jl();if(b(re))return j(re);c=setTimeout(R,M(re))}function j(re){return c=void 0,v&&i?S(re):(i=s=void 0,o)}function W(){c!==void 0&&clearTimeout(c),l=0,i=d=s=c=void 0}function w(){return c===void 0?o:j(Jl())}function te(){var re=Jl(),ae=b(re);if(i=arguments,s=this,d=re,ae){if(c===void 0)return T(d);if(m)return clearTimeout(c),c=setTimeout(R,e),S(d)}return c===void 0&&(c=setTimeout(R,e)),o}return te.cancel=W,te.flush=w,te}function Wu(t,e,r){(r!==void 0&&!tc(t[e],r)||r===void 0&&!(e in t))&&rp(t,e,r)}function p0(t){return Gr(t)&&ic(t)}function ju(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function m0(t){return rc(t,sc(t))}function g0(t,e,r,i,s,n,o){var c=ju(t,r),d=ju(e,r),l=o.get(d);if(l){Wu(t,r,l);return}var h=n?n(c,d,r+"",t,e,o):void 0,m=h===void 0;if(m){var v=Hi(d),S=!v&&Qn(d),T=!v&&!S&&wl(d);h=d,v||S||T?Hi(c)?h=c:p0(c)?h=nv(c):S?(m=!1,h=sv(d,!0)):T?(m=!1,h=lv(d,!0)):h=[]:R_(d)||Kd(d)?(h=c,Kd(c)?h=m0(c):(!Ir(c)||tp(c))&&(h=uv(d))):m=!1}m&&(o.set(d,h),s(h,d,i,n,o),o.delete(d)),Wu(t,r,h)}function Iv(t,e,r,i,s){t!==e&&c0(e,function(n,o){if(s||(s=new Hr),Ir(n))g0(t,e,o,r,Iv,i,s);else{var c=i?i(ju(t,o),n,o+"",t,e,s):void 0;c===void 0&&(c=n),Wu(t,o,c)}},sc)}var f0="[object Map]",v0="[object Set]",y0=Object.prototype,S0=y0.hasOwnProperty;function E0(t){if(t==null)return!0;if(ic(t)&&(Hi(t)||typeof t=="string"||typeof t.splice=="function"||Qn(t)||wl(t)||Kd(t)))return!t.length;var e=Zn(t);if(e==f0||e==v0)return!t.size;if(_l(t))return!rv(t).length;for(var r in t)if(S0.call(t,r))return!1;return!0}function k0(t,e){return _v(t,e)}var T0=b_(function(t,e,r){Iv(t,e,r)});const bi=T0;var Hu=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(Hu||{});const Z={PROPAGATE_KICK_ALL:"propagate_kick_across_rooms",REFRESH_ID_ON_DISCONNECTION:"refresh_id_on_disconnection",SIMULCAST:"simulcast",CHAT_SOCKET_SERVER:"chat_socket_server",POLL_SOCKET_SERVER:"poll_socket_server",PLUGIN_SOCKET_SERVER:"plugin_socket_server",NR_OTEL_WEB:"nr_otel_web",ICE_RESTART_ON_FAILED_STATE:"ice_restart_on_failed_state",ICE_RESTART_ON_DISCONNECTED_STATE:"ice_restart_on_disconnected_state",ENABLE_ICE_STATE_LOGGING:"enable_ice_state_logging",SUPPRESS_PEER_MUTE_UNMUTE_EMITS:"web_core_suppress_peer_mute_unmute_emits",SKIP_OTEL_TRACES:"skip_otel_traces",USE_USERIDS_IN_CHAT:"use_userids_in_chat",CUSTOM_PING_PONG:"custom_ping_pong",ENABLE_HIVE_SIMULCAST:"enable_hive_simulcast",ENABLE_HIVE_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_hive_transport_reconnection_on_ice_failed",ENABLE_HIVE_EXPERIMENTAL_FAIL_RECOVERY:"enable_hive_fail_recovery",ENABLE_HIVE_INFINITE_RETRIES:"enable_hive_infinite_retries",HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"hive_transport_force_relay_on_ice_failed",ENABLE_HIVE_CONSUME_OVER_DC:"enable_hive_consume_over_dc",ENABLE_CF_SIMULCAST:"enable_cf_simulcast",ENABLE_CF_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_cf_transport_reconnection_on_ice_failed",ENABLE_CF_EXPERIMENTAL_FAIL_RECOVERY:"enable_cf_fail_recovery",ENABLE_CF_INFINITE_RETRIES:"enable_cf_infinite_retries",CF_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"cf_transport_force_relay_on_ice_failed",BYPASS_LOG_EXCLUSION_LIST:"bypass_log_exclusion_list",LOG_LEVEL:"log_level",V1_PLUGINS:"v1_plugins",SCREENSHARE_DTX:"screenshare_dtx",SCREENSHARE_PRIORITY:"screenshare_priority",SCREENSHARE_MIN_BITRATE:"screenshare_minbitrate",SCREENSHARE_SIMULCAST:"screenshare_simulcast",DISABLE_WEBCAM_LAYERS_ON_SCREENSHARE:"disable_webcam_layers_on_screenshare",SCREENSHARE_FORCE_GOOG_CONFERENCE:"screenshare_force_goog_conference",LIVESTREAM:"feat_livestream",FETCH_RETRY:"fetch_retry",DISABLE_WEBCAM_SIMULCAST:"webcore_disable_webcam_simulcast",OVERRIDE_WEBCAM_SIMULCAST:"override_webcam_simulcast",SOCKET_POLLING:"socket_polling",FEAT_PAGINATED_CHAT:"feat_paginated_chat",VAL_MIN_FRAMERATE:"val_min_framerate",SCREEENSHARE_ERR_HACK:"screenshare_err_hack",SCREEENSHARE_CONSTRAINTS_RETRY:"screenshare_constraints_retry",TROUBLESHOOTING:"feat_troubleshooting",VIDEO_CONSTRAINTS:"video_constraints",SCREENSHARE_CONSTRAINTS:"screenshare_constraints",FEAT_CHAT_SDK:"feat_chat_sdk",FEAT_CHAT_SDK_SEARCH:"chat_search",OBS_QUALITY:"obs_quality",ALLOW_SAFARI_MEDIA_MIDDLEWARES:"allow_safari_media_middlewares",DYNAMIC_VIDEO_QUALITY:"dynamic_video_quality",EXP_RESHARE:"exp_reshare",LEAVE_STAGE_ON_END:"leave_stage_on_end",SKIP_SETTING_IN_USE_DEVICE:"skip_setting_in_use_device",PRECALL_BANDWIDTH_TEST:"precall_bandwidth_test",CONSUMER_BIND_NO_RETRY:"consumer_bind_no_retry",DEBUG_SOCKET_JOIN:"debug_socket_join",FORCE_RELAY:"force_relay",FORCE_VIDEO_CODEC:"force_video_codec",USE_EXPERIMENTAL_SFU_HANDLER:"use_experimental_sfu_handler",TRACK_HINT:"track_hint",OVERRIDE_HIVE_SIMULCAST_DYNAMIC:"override_hive_simulcast_dynamic",PRECREATE_PRODUCERS:"precreate_producers",DISABLE_OPUS_DTX_CF:"disable_opus_dtx_cf",ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS:"enable_audio_activity_debug_logs"};function zc(t){const e={};return typeof(t==null?void 0:t.code)=="number"&&(e.code=t.code),typeof(t==null?void 0:t.code)=="string"&&(e.code=t.code.substring(0,100)),typeof(t==null?void 0:t.name)=="string"&&(e.name=t.name.substring(0,500)),typeof(t==null?void 0:t.message)=="string"&&(e.message=t.message.substring(0,500)),typeof(t==null?void 0:t.reason)=="string"&&(e.reason=t.reason.substring(0,500)),typeof(t==null?void 0:t.stack)=="string"&&(e.stack=t.stack.substring(0,500)),e}function b0(t){var e,r,i,s;const n=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((r=window.location.host)==null?void 0:r.includes("dyte.io")),o=!!((s=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&s.logs);return n||o}function w0(t,e){var r;if(t!=null&&t.getValue("flagsmith").hasFeature(Z.LOG_LEVEL)){let i=((r=t.getValue("flagsmith").getValue(Z.LOG_LEVEL))==null?void 0:r.toString())||"all";if(i=i.toLowerCase().trim(),i==="off")return!1;if(i!=="all"){const s=["debug","log","info","warn","error"],n=s.indexOf(e),o=s.indexOf(i);if(n<o)return!1}}return!0}function Cv(t,e,r={}){return Object.getOwnPropertyNames(t).forEach(i=>{var s;if([null,void 0,NaN].includes(t[i])||e&&(((s=e.match(/\./g))==null?void 0:s.length)||0)>=10)return;const n=e?`${e}.${i}`:i;typeof t[i]=="object"?Cv(t[i],n,r):["number","string","boolean"].includes(typeof t[i])&&(r[n]=t[i])}),r}function wm(t,e,r={},i=""){const s={};try{const n=JSON.stringify(r),o=JSON.parse(n),c=Cv(o,i),d=JSON.stringify(c);return JSON.parse(d)}catch(n){const o=zc(n);s[`${i}.error.message`]=o.message||"",s[`${i}.error.stack`]=o.stack||"",s[`${i}.error.reason`]=o.reason||"",s[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return s}const _0={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},ba={baseURL:"http://localhost:5000",createdAt:"2021-08-05T10:49:56.602Z",description:"Develop plugins locally",id:"09259e3b-7be8-46f6-9801-106bf1866e1c",name:"Localhost Dev",organizationId:"4ad15a19-80e2-4105-bf43-48039fd2963e",picture:"https://dyte-uploads.s3.ap-south-1.amazonaws.com/dyte.png",private:!1,published:!0,staggered:!1,tags:["#localhost","#dev"],type:"self_hosted",updatedAt:"2021-08-05T10:50:07.681Z"},I0={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,connectedMeetings:!0,devTools:{logs:!1}};function ea(t,e){const r=t.getValue("overrides");return r&&r[e]?r[e]:!1}function C0({baseURI:t}){return t.includes("preprod.dyte")||t.includes("preprod.realtime")?Vo.PREPROD:t.includes("devel.dyte")||t.includes("devel.realtime")?Vo.DEVEL:Vo.PROD}function Ds({servicePrefix:t,baseURI:e}){return e.includes("preprod.realtime.cloudflare.com")||e.includes("devel.realtime.cloudflare.com")?`${t}-${e}`:`${t}.${e}`}function Pv(t){const e=t.getValue("baseURI");return{location:Ds({servicePrefix:"location",baseURI:e}),locationLegacy:Ds({servicePrefix:"location-legacy",baseURI:e}),daCollector:Ds({servicePrefix:"da-collector",baseURI:e.replace("realtime.cloudflare.com","dyte.io")})}}const P0='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m16.242 2.932 4.826 4.826a2.75 2.75 0 0 1-.715 4.404l-4.87 2.435a.75.75 0 0 0-.374.426l-1.44 4.166a1.25 1.25 0 0 1-2.065.476L8.5 16.561 4.06 21H3v-1.06l4.44-4.44-3.105-3.104a1.25 1.25 0 0 1 .476-2.066l4.166-1.44a.75.75 0 0 0 .426-.373l2.435-4.87a2.75 2.75 0 0 1 4.405-.715Zm3.766 5.886-4.826-4.826a1.25 1.25 0 0 0-2.002.325l-2.435 4.871a2.25 2.25 0 0 1-1.278 1.12l-3.789 1.31 6.705 6.704 1.308-3.789a2.25 2.25 0 0 1 1.12-1.277l4.872-2.436a1.25 1.25 0 0 0 .325-2.002Z" fill="currentColor"/></svg>',R0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 12.02c0 1.06.2 2.1.6 3.08l.6 1.42c.22.55.64 1.01 1.17 1.29.27.14.56.21.86.21h2.55c.77 0 1.49-.41 1.87-1.08.5-.87 1.02-1.7 1.72-2.43l1.32-1.39c.44-.46.97-.84 1.49-1.23l.59-.45a.6.6 0 0 0 .23-.47c0-.75-.54-1.57-1.22-1.79a3.34 3.34 0 0 0-2.78.29V4.5a1.5 1.5 0 0 0-2.05-1.4 1.5 1.5 0 0 0-2.9 0A1.5 1.5 0 0 0 6 4.5v.09A1.5 1.5 0 0 0 4 6v6.02ZM8 4.5v4a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0v5a.5.5 0 0 0 1 0v-4a.5.5 0 0 1 1 0v6a.5.5 0 0 0 .85.37h.01c.22-.22.44-.44.72-.58.7-.35 2.22-.57 2.4.5l-.53.4c-.52.4-1.04.78-1.48 1.24l-1.33 1.38c-.75.79-1.31 1.7-1.85 2.63-.21.36-.6.58-1.01.58H7.23a.87.87 0 0 1-.4-.1 1.55 1.55 0 0 1-.71-.78l-.59-1.42a7.09 7.09 0 0 1-.53-2.7V6a.5.5 0 0 1 1 0v3.5a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0Z" fill="currentColor"></path></svg>',yc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(s=>{s(t)});const e=new Blob([t],{type:"image/svg+xml"}),r=new Image,i=window.URL.createObjectURL(e);return new Promise((s,n)=>{r.onload=()=>{s(r),window.URL.revokeObjectURL(i)},r.onerror=()=>{n(),window.URL.revokeObjectURL(i)},r.src=i})},Rv=class{constructor(){p(this,"logsCache",[]),p(this,"logsProcessorTimer"),p(this,"tracingEnabled",!0),p(this,"initialized",!1),p(this,"logsProcessingInterval",7e3),p(this,"logExclusionList",["message","websocket/message","roomMessage","websocket/room-message","websocket/room-legacy-mode","chatMessage","websocket/new-chat-message","websocket/no-active-speaker","websocket/selected-peers","websocket/active-speaker","ping","websocket/new-consumer","websocket/producer-score","websocket/consumer-score","websocket/plugin-event","websocket/plugin-data","websocket/plugin-internal-data"]),p(this,"meetingMetadata",{})}get logsEndpoint(){const t=ni.getContext(this.meetingMetadata.peerId);return`https://${Ds({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}resetPeerId(t){this.meetingMetadata.peerId=t}init(t,e,r){this.tracingEnabled=!0,this.initialized=!1,this.logsCache=[];const i=t.getValue("peerId");this.meetingMetadata=e,this.tracingEnabled=r,this.meetingMetadata.peerId=i,this.meetingMetadata.sdkVersion=t.getValue("sdkVersion"),this.meetingMetadata.deviceInfo=Ie.getDeviceInfo(),this.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,navigator.isReactNative||document.addEventListener("visibilitychange",()=>{this.processCachedLogs.bind(this)}),this.logsProcessorTimer=setInterval(()=>{this.processCachedLogs.bind(this)},this.logsProcessingInterval),r&&(this.initialized=!0)}static trace(t,e=void 0){return(r,i,s)=>{const n=s.value;return s.value=function(...o){var c;const d=this==null?void 0:this.telemetry;if(!d||!d.initialized||navigator.isReactNative||!d.tracingEnabled||(c=ni.getContext(d.meetingMetadata.peerId))!=null&&c.getValue("flagsmith").hasFeature(Z.SKIP_OTEL_TRACES))return n.apply(this,o);d.addLogInCurrentSpan("info",t,e);const l=performance.now(),h=n.apply(this,o);return Promise.resolve(h).then(()=>{const m=performance.now();m-l>10&&d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:m-l,country:Rv.location.country})}).catch(()=>{const m=performance.now();d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:m-l})}),h},s}}injectContext(t){var e;const r=Ns().replace(/-/g,"").substring(0,16),i=(e=this.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${r}-01`}addLogInCurrentSpan(t,e,r={},i=!1){r!=null&&r.error&&Object.assign(r,{error:zc(r.error)});const s=ni.getContext(this.meetingMetadata.peerId);if(b0(s)&&(E0(r)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,r)),!!w0(s,t))try{const n=wm(s,e,r,"metadata"),o=new Date,c=q(V({message:e,level:t},n),{loggedAt:o.toISOString(),loggedAtTzOffset:o.getTimezoneOffset()});i?this.sendOtelLogsToNewRelic([c]):this.logsCache.push(c)}catch(n){this.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:zc(n)})}}sendOtelLogsToNewRelic(t){const e=ni.getContext(this.meetingMetadata.peerId);fetch(this.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:wm(e,"sendOtelLogsToNewRelic",this.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(r=>{this.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:zc(r)}),this.logsCache.push(...t)})}processCachedLogs(){const t=this.logsCache.splice(0,25);t!=null&&t.length&&this.sendOtelLogsToNewRelic(t)}destruct(){clearInterval(this.logsProcessorTimer),this.processCachedLogs(),navigator.isReactNative||document.removeEventListener("visibilitychange",()=>{this.processCachedLogs.bind(this)})}};let k=Rv;p(k,"location",{country:void 0});function M0(t){const e=V({},t),r=new Map,i=(o,c)=>(r.has(o)||r.set(o,new Set),r.get(o).add(c),()=>{var d;return(d=r.get(o))==null?void 0:d.delete(c)}),s=(o,c)=>{var d;(d=r.get(o))==null||d.delete(c)},n=o=>{var c;(c=r.get(o))==null||c.forEach(d=>{try{d(e[o])}catch{}})};return{subscribe:i,unsubscribe:s,notify:n,setValue:(o,c,d=!0)=>{e[o]=c,d&&n(o)},getValue:o=>e[o],getAllValues:()=>e}}class A0{constructor(){p(this,"contexts",new Map),p(this,"mostRecentPeerId",null)}createContext(e,r){if(this.contexts.has(e))return this.contexts.get(e);const i=new k,s=new Ev;this.contexts.set(e,M0(r)),this.contexts.get(e).setValue("peerSessionStore",new t_(s));const n=new qf;return n.setMaxListeners(50),this.contexts.get(e).setValue("logger",s),this.contexts.get(e).setValue("telemetry",i),this.contexts.get(e).setValue("callstats",n),this.contexts.get(e).setValue("flagsmith",Hw()),this.mostRecentPeerId=e,this.contexts.get(e)}remapContext(e,r){const i=r.getValue("peerId");i!==e&&(r.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,r),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ni=new A0,D0={"00":"DyteClient","01":"Controller","02":"RoomNodeClient","03":"HiveNodeClient","04":"SocketService","05":"Chat","06":"Plugin","07":"Polls","08":"Meta","09":"Preset",10:"Recording",11:"Self",12:"Participant",13:"Spotlight",14:"Remote Request",15:"Webinar",16:"LocalMediaHandler",17:"End-End Encryption",18:"AI",19:"Livestream",20:"Stage"},Yc={"0000":"Internal exception.","0001":"Failed to initialize.","0002":"Failed to join room.","0003":"Failed to leave room.","0004":"Invalid auth token","0010":"Browser not supported","0011":"HTTP Network Error","0012":"Websocket Network Error","0013":"Rate Limited","0100":"Internal exception","0101":"Permission denied","0102":"Prerequisite module missing","0200":"Internal exception.","0300":"Internal exception","0400":"Internal exception","0404":"Missing prerequisites to establish a websocket connection","0500":"Internal exception","0501":"Permission denied.","0502":"Invalid message body.","0503":"Text Message is too large","0504":"Message not found by the given id","0505":"Action not permitted without joining room","0506":"Message search is disabled","0510":"Invalid channel name.","0600":"Internal exception","0601":"Permission denied.","0602":"Auth token not set for plugin","0603":"Iframe was not provided","0700":"Internal exception","0705":"Action not permitted without joining room","0800":"Internal exception","0801":"Permission denied","0900":"Internal exception","0904":"Could not load preset",1e3:"Internal exception",1001:"Permission denied",1004:"Could not find specified recording",1005:"Action not permitted in given recording state",1100:"Internal exception",1101:"Permission denied",1102:"Unsupported",1103:"Name cannot be empty",1104:"No device selected while calling meeting.self.setDevice",1105:"Action not permitted without joining room",1106:"Can't set currently used device",1200:"Internal exception",1201:"Permission denied",1202:"Invalid page number was requested",1203:"Invalid participant count per page was requested",1204:"No participants exists with the given UserIds",1205:"Action not permitted without joining room",1206:"Manual Subscription Mode was not ACTIVATED",1207:"Invalid view mode",1208:"Manual Subscription not enabled for organization",1209:"Broadcast message type must be a non-empty string",1300:"Internal exception",1400:"Internal exception",1402:"No existing remote requests",1403:"No peer exists with given id",1500:"Internal exception",1600:"Internal exception",1601:"Failed to get audio track",1602:"Failed to get video track",1603:"Incorrect device",1604:"Failed to change device",1605:"Failed to get audio & video track",1606:"No audio input devices are available",1607:"No video input devices are available",1608:"No audio output devices (speakers) are available",1609:"Failed to fetch list of media devices",1610:"No media track exists",1611:"Failed to unmute track",1612:"Failed to get screenshare tracks",1701:"Crypto error",1800:"Internal exception",1801:"Can't fetch transcript file",1900:"Internal exception",1901:"Permission denied.",1902:"Livestream that has not yet started, can't be stopped",2e3:"Internal exception",2001:"Permission denied",2002:"Unsupported",2003:"Stage is disabled",2004:"Method not implemented",2005:"Action not permitted without joining room",2006:"Action not permitted in current stage status",9900:"Internal exception"};Object.keys(Yc).forEach(t=>{Yc[t]=`{${D0[t.slice(0,2)]}} ${Yc[t]}`});class I extends Error{constructor(e,r,i=void 0,s=!1){super(e),p(this,"code"),this.code=r,this.name="DyteError",this.message=`[ERR${this.code}]: ${Yc[this.code]}
12
+ `)),this.pc2.setLocalDescription(e),this.pc1.setRemoteDescription(e)}establishConnection(){this.pc1.createOffer().then(this.gotOffer.bind(this),this.reportFatal.bind(this))}reportFatal(e){console.error("Error:",e)}getRoundTripTime(){return u(this,null,function*(){const[e,r]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,s;if(e.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesSent>0&&(i=n)}),r.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesReceived>0&&(s=n)}),i&&s)try{if(i.currentRoundTripTime&&s.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:s.currentRoundTripTime};const n=(s.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:n,backendRTT:n}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class Wf extends mt{constructor(e){super(),p(this,"call"),p(this,"timeOut"),this.call=new ci(e)}start(e=1e4){this.call.establishConnection(),this.timeOut=setTimeout(this.testFailed.bind(this),e)}testComplete(e){clearTimeout(this.timeOut),this.call.close(),this.emit("done",e)}testFailed(e){this.call.close(),this.emit("failed",e)}}const DE=8,OE=1/1e3;class NE extends Wf{constructor(e){super(e),p(this,"senderChannel"),p(this,"recieveChannel"),p(this,"startTime"),p(this,"lastBitrateMeasureTime"),p(this,"sentPayloadBytes",0),p(this,"recievedPayloadBytes",0),p(this,"lastReceivedPayloadBytes",0),p(this,"stopSending",!1),p(this,"testProgress",0),p(this,"samplePacket",""),p(this,"finalBitrateSum",0),p(this,"bitRateSampels",0),p(this,"maxNumberOfPacketsToSend",0),p(this,"bytesToKeepBuffered",0),p(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(ci.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let r=0;r<1024*256;r+=1)this.samplePacket+="h";this.maxNumberOfPacketsToSend=1,this.bytesToKeepBuffered=1024*this.maxNumberOfPacketsToSend,this.testDurationSeconds=4,this.senderChannel.addEventListener("open",this.sendingStep.bind(this)),this.call.pc2.addEventListener("datachannel",this.onRecieverChannel.bind(this))}sendingStep(){const e=new Date;this.startTime||(this.startTime=e,this.lastBitrateMeasureTime=e);for(let i=0;i!==this.maxNumberOfPacketsToSend&&!(this.senderChannel.bufferedAmount>=this.bytesToKeepBuffered);i+=1){this.sentPayloadBytes+=this.samplePacket.length;try{this.senderChannel.send(this.samplePacket)}catch{}}const r=e.getTime()-this.startTime.getTime();r>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=r/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const r=new Date,i=r.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const s=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*DE/(i/1e3);this.finalBitrateSum+=s,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=r}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const s=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(s*OE)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:r,backendRTT:i})=>super.testComplete({RTT:r,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Zh extends Wf{constructor(e,r=ci.noFilter){super(e),p(this,"ch1"),p(this,"ch2"),this.call.setIceCandidateFilter(r);const i=this.call.pc1.createDataChannel(null);this.ch1=i,i.addEventListener("open",()=>{i.send("hello")}),i.addEventListener("message",this.onCh1Recieve.bind(this)),this.call.pc2.addEventListener("datachannel",this.dataChannelHandler.bind(this))}onCh1Recieve(e){e.data!=="world"?this.hangup("Invalid data transmitted."):this.testComplete({connectivity:!0})}onCh2Recieve(e){if(e.data!=="hello")this.hangup("Invalid data transmitted.");else try{this.ch2.send("world")}catch{}}dataChannelHandler(e){const r=e.channel;this.ch2=r,r.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class VE extends Zh{constructor(e){super(e,ci.isHost)}}class LE extends Zh{constructor(e){super(e,ci.isRelay)}}class xE extends Zh{constructor(e){super(e,ci.isReflexive)}}class UE{constructor(){p(this,"ipInformation",null)}getIPDetails(e){return u(this,arguments,function*({peerId:r,apiHostnames:i,logger:s}){var n,o,c;if(!this.ipInformation){try{const d=`https://${i.location}`,l=yield(yield fetch(d)).json();if(((n=l.loc)==null?void 0:n.length)>5)return this.ipInformation=l,(o=this.ipInformation)!=null&&o.ip&&(this.ipInformation.ip=Bi(this.ipInformation.ip)),l;throw Error("Insufficient data")}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${r}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=Bi(this.ipInformation.ip))}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const ep=new UE,$p=[{urls:"turn:turn.dyte.in:443?transport=tcp",username:"dyte",credential:"dytein",credentialType:"password"},{urls:"turn:turn.dyte.in:3478?transport=udp",username:"dyte",credential:"dytein",credentialType:"password"}];function Jp(t){const[e,r]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(r)}}}class jf{constructor(){p(this,"transport"),p(this,"candidatePair"),p(this,"outboundVideoRtp",new Map),p(this,"inboundVideoRtp",new Map),p(this,"outboundAudioRtp",new Map),p(this,"inboundAudioRtp",new Map),p(this,"remoteInboundRtp",new Map),p(this,"producerStreamMap",new Map),p(this,"consumerStreamMap",new Map),p(this,"staleProducerStreamMap",!1),p(this,"staleConsumerStreamMap",!1)}}class Hf extends mt{constructor(){super(),p(this,"observer"),p(this,"outboundProducerMap",new Map),p(this,"inboundConsumerMap",new Map),p(this,"consumerPeerIdMap",new Map),p(this,"pausedConsumerMap",new Map),p(this,"pausedProducerMap",new Map),p(this,"overallProducingTransportsStatsMap",{}),p(this,"overallConsumingTransportsStatsMap",{}),p(this,"overallConsumersStatsMap",{}),p(this,"overallProducersStatsMap",{}),p(this,"videoProducerToStatsMap",new Map),p(this,"audioProducerToStatsMap",new Map),p(this,"videoConsumerToStatsMap",new Map),p(this,"audioConsumerToStatsMap",new Map),p(this,"consumerIdsWithFreezedVideo",new Set),p(this,"consumerIdsWithFreezedAudio",new Set),p(this,"producerIdsWithFreezedVideo",new Set),p(this,"producerIdsWithFreezedAudio",new Set),p(this,"freezedProducingTransportIds",new Set),p(this,"freezedConsumingTransportIds",new Set),p(this,"screenShareProducers",new Set),p(this,"screenShareConsumers",new Set),p(this,"ipDetails"),p(this,"callStatsInstance"),this.observer=new mt}registerProducer(e){return u(this,null,function*(){yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}pauseProducer(e){this.pausedProducerMap.set(e,{lastReportCalculated:!1})}resumeProducer(e){this.pausedProducerMap.delete(e)}processInboundConsumerVideoStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(r.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(r.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(r.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(r.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{},{audio:o,video:c,screen:d}=n,l=o||c||d;r.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(r.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,r,i){var s,n;const o=!!Array.from(((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);r.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(r.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return u(this,null,function*(){yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}pauseConsumer(e){this.pausedConsumerMap.set(e,{lastReportCalculated:!1})}resumeConsumer(e){this.pausedConsumerMap.delete(e)}generateProducerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"outbound-rtp":{this.outboundProducerMap.set(n.id,e.id);break}}return s})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"inbound-rtp":{this.inboundConsumerMap.set(n.id,e.id);break}}return s})}deregisterProducer(e){this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(r=>{const i=r.framesEncoded>0,s=r.packetsSent>0,n=r.frameWidth&&r.frameHeight;return i&&s&&!!n})||e[e.length-1]}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,m,v,S,T,M,b,R,j;const W=e,w=new jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:E}=A,{selected:_}=A,B=A,oe={nominated:E!=null?E:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const E=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:E.bytesReceived,bytesSent:E.bytesSent,packetsSent:E.packetsSent,packetsReceived:E.packetsReceived,dtlsCipher:E.dtlsCipher,dtlsState:E.dtlsState,iceRole:E.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const E=A,_={jitter:E.jitter,fractionLost:E.fractionLost,roundTripTime:E.roundTripTime,roundTripTimeMeasurements:E.roundTripTimeMeasurements,totalRoundTripTime:E.totalRoundTripTime,packetsLost:E.packetsLost};w.remoteInboundRtp.set(E.localId,_);break}case"outbound-rtp":{const E=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:E.bytesSent,packetsSent:E.packetsSent,nackCount:E.nackCount,ssrc:E.ssrc,mid:E.mid,active:E.active,codecId:E.codecId,headerBytesSent:E.headerBytesSent||0,totalPacketSendDelay:E.totalPacketSendDelay||0};if(E.mediaType==="video"||E.kind==="video"){const C=E,ue=V({frameHeight:C.frameHeight,frameWidth:C.frameWidth,framesEncoded:C.framesEncoded,framesDropped:C.framesDropped,framesPerSecond:C.framesPerSecond,framesSent:C.framesSent,keyFramesEncoded:C.keyFramesEncoded,firCount:C.firCount,encoderImplementation:C.encoderImplementation,hugeFramesSent:C.hugeFramesSent,pliCount:C.pliCount,qpSum:C.qpSum,qualityLimitationDurations:C.qualityLimitationDurations,qualityLimitationReason:C.qualityLimitationReason,qualityLimitationResolutionChanges:C.qualityLimitationResolutionChanges,totalEncodeTime:C.targetBitrate,totalPacketSendDelay:C.totalPacketSendDelay,retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent,scalabilityMode:C.scalabilityMode,powerEfficientEncoder:C.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ue)}else if(E.mediaType==="audio"||E.kind==="audio"){const C=E,ue=V({retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ue)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}case"inbound-rtp":{const E=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(E.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:E.bytesReceived,packetsReceived:E.packetsReceived,packetsLost:E.packetsLost>=0?E.packetsLost:0,jitter:E.jitter,nackCount:E.nackCount,jitterBufferDelay:E.jitterBufferDelay,jitterBufferEmittedCount:E.jitterBufferEmittedCount,lastPacketReceivedTimestamp:E.lastPacketReceivedTimestamp,ssrc:E.ssrc,mid:E.mid,codecId:E.codecId,headerBytesReceived:E.headerBytesReceived||0,packetsDiscarded:E.packetsDiscarded||0,jitterBufferMinimumDelay:E.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:E.jitterBufferTargetDelay||0};if(E.mediaType==="video"||E.kind==="video"){const x=E,C=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped,framesPerSecond:x.framesPerSecond,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);C.score=Bf({frameWidth:C.frameWidth||0,framesDecoded:(C.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:C.framesPerSecond||0,packetsLost:(C.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(C.score*10).toFixed(),frameWidth:C.frameWidth||0,frameHeight:C.frameHeight||0,framesPerSecond:C.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((m=this.videoConsumerToStatsMap.get(_))==null?void 0:m.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,C),w.inboundVideoRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,C)}else if(E.mediaType==="audio"||E.kind==="audio"){const x=E,C=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);C.score=Ff({concealmentEvents:(C.concealmentEvents||0)-(((S=this.audioConsumerToStatsMap.get(_))==null?void 0:S.concealmentEvents)||0),packetsLost:(C.packetsLost||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((M=this.audioConsumerToStatsMap.get(_))==null?void 0:M.packetsReceived)||0),jitter:C.jitter||0}),jt.set(_,{score:+(C.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((R=this.audioConsumerToStatsMap.get(_))==null?void 0:R.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,C),w.inboundAudioRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,C)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}}}if(w.producerStreamMap.forEach((A,E)=>{var _,B,oe,He,x,C,ue,Ki,zi,qr,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa,Ea;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Fl=>{ge.push(w.outboundVideoRtp.get(Fl))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=xf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(E))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(E))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((C=this.videoProducerToStatsMap.get(E))==null?void 0:C.framesEncoded)||0)}),Xe.set(E,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ue=se.remoteData)==null?void 0:ue.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsLostPercentage:Gd({packetsSent:(se.packetsSent||0)-(((Ki=this.videoProducerToStatsMap.get(E))==null?void 0:Ki.packetsSent)||0),packetsLost:(((zi=se.remoteData)==null?void 0:zi.packetsLost)||0)-(((ca=(qr=this.videoProducerToStatsMap.get(E))==null?void 0:qr.remoteData)==null?void 0:ca.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((da=this.videoProducerToStatsMap.get(E))==null?void 0:da.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(E,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Lf({packetsSent:(ge.packetsSent||0)-(((la=this.audioProducerToStatsMap.get(E))==null?void 0:la.packetsSent)||0),packetsLost:(((ua=ge.remoteData)==null?void 0:ua.packetsLost)||0)-(((pa=(ha=this.audioProducerToStatsMap.get(E))==null?void 0:ha.remoteData)==null?void 0:pa.packetsLost)||0),jitter:((ma=ge.remoteData)==null?void 0:ma.jitter)||0}),Xe.set(E,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ga=this.audioProducerToStatsMap.get(E))==null?void 0:ga.bytesSent)||0))*8/7,packetsLostPercentage:Gd({packetsSent:(ge.packetsSent||0)-(((fa=this.audioProducerToStatsMap.get(E))==null?void 0:fa.packetsSent)||0),packetsLost:(((va=ge.remoteData)==null?void 0:va.packetsLost)||0)-(((Sa=(ya=this.audioProducerToStatsMap.get(E))==null?void 0:ya.remoteData)==null?void 0:Sa.packetsLost)||0)}),jitter:((Ea=ge.remoteData)==null?void 0:Ea.jitter)||0,isScreenShare:this.screenShareProducers.has(E)}),this.audioProducerToStatsMap.set(E,ge)}}),Me.forEach(A=>{const E=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);E&&(A.localCandidateType=E.type,A.localCandidateAddress=Bi(E.address),A.localCandidatePort=E.port,A.localCandidateProtocol=E.protocol,A.localCandidateUrl=E.url,A.localCandidateNetworkType=E.networkType,A.localCandidateRelatedAddress=Bi(E.relatedAddress),A.localCandidateRelatedPort=E.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=Bi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,E=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,E=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=E}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateProducerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getConsumersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateConsumerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getTransportReport(e){return u(this,null,function*(){return e.getStats()})}getProcessedStats(e,r,i){return u(this,null,function*(){const s=yield this.getTransportReport(e),n={producing:i,consuming:r,id:e.id},o=s,c=this.parseRTCReport(o,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,n);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:r,producing:i},l=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),h=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:l,consumerReport:h}})}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{var n,o;r.push({producerId:s,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((o=(n=this.callStatsInstance.producers)==null?void 0:n.get(s))==null?void 0:o.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return r}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(s);r.push({consumerId:s,peerId:n,producerId:o,appData:c,videoStats:i.inboundVideoRtpId.map(d=>e.inboundVideoRtp.get(d)),audioStats:i.inboundAudioRtpId.map(d=>e.inboundAudioRtp.get(d))})})}catch(i){console.error("getConsumersReport: ",i,e)}return r}getUserLocation(){return u(this,null,function*(){return new Promise((e,r)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):r()}catch(i){r(i)}})})}getConnectivity(e){return u(this,null,function*(){try{const r={iceServers:e||$p},i=new Promise((l,h)=>{try{const m=new VE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),s=new Promise((l,h)=>{try{const m=new LE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),n=new Promise((l,h)=>{try{const m=new xE(r);m.addListener("done",l),m.addListener("failed",()=>{l({connectivity:!1})}),m.start(2e3)}catch(m){h(m)}}),[o,c,d]=yield Promise.all([i,s,n]);return{host:o==null?void 0:o.connectivity,relay:c==null?void 0:c.connectivity,reflexive:d==null?void 0:d.connectivity}}catch{return{host:!1,relay:!1,reflexive:!1}}})}getThroughput(e){return u(this,null,function*(){try{const r=yield new Promise((i,s)=>{try{const n={iceServers:e||$p},o=new NE(n);o.addListener("done",i),o.addListener("failed",s),o.start(1e4)}catch(n){s(n)}});return{throughput:r.throughput,fractionalLoss:0,RTT:r.RTT,jitter:0,backendRTT:r.backendRTT}}catch{return}})}getIPDetails(){return u(this,null,function*(){var e,r;try{return this.ipDetails||(this.ipDetails=yield ep.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(r=this.callStatsInstance)==null?void 0:r.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return u(this,null,function*(){const[r,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:r,throughput:i==null?void 0:i.throughput,fractionalLoss:i==null?void 0:i.fractionalLoss,RTT:i==null?void 0:i.RTT,jitter:i==null?void 0:i.jitter,backendRTT:i==null?void 0:i.backendRTT}})}getNetworkInfo(e,r=!1){return u(this,null,function*(){var i,s;if(r){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Jp(d==null?void 0:d.loc):void 0}}const[n,o,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(s=navigator.connection)==null?void 0:s.effectiveType,location:c!=null&&c.loc?Jp(c==null?void 0:c.loc):void 0,turnConnectivity:n?n.host||n.relay||n.reflexive:!1,connectivity:n,throughput:o==null?void 0:o.throughput,fractionalLoss:o==null?void 0:o.fractionalLoss,RTT:o==null?void 0:o.RTT,jitter:o==null?void 0:o.jitter,backendRTT:o==null?void 0:o.backendRTT}})}}class FE extends Hf{}class Gf extends Hf{constructor(){super(...arguments),p(this,"producerMap",new Map),p(this,"consumerMap",new Map)}registerProducer(e){return u(this,null,function*(){this.producerMap.set(e.id,e),yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}registerConsumer(e){return u(this,null,function*(){this.consumerMap.set(e.id,e),yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),n=[...s.consumerStreamMap.values()][0],o=r?this.getConsumerStatsFromParsedConsumerStats(s,n,e.id):void 0;for(const c of i.values())switch(c.type){case"inbound-rtp":{this.inboundConsumerMap.set(c.id,e.id);break}}return o})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.consumerMap.delete(e.id),this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,m,v,S,T,M,b,R,j;const W=e,w=new jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:E}=A,{selected:_}=A,B=A,oe={nominated:E!=null?E:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const E=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:E.bytesReceived,bytesSent:E.bytesSent,packetsSent:E.packetsSent,packetsReceived:E.packetsReceived,dtlsCipher:E.dtlsCipher,dtlsState:E.dtlsState,iceRole:E.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const E=A,_={jitter:E.jitter,fractionLost:E.fractionLost,roundTripTime:E.roundTripTime,roundTripTimeMeasurements:E.roundTripTimeMeasurements,totalRoundTripTime:E.totalRoundTripTime,packetsLost:E.packetsLost};w.remoteInboundRtp.set(E.localId,_);break}case"outbound-rtp":{const E=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:E.bytesSent,packetsSent:E.packetsSent,nackCount:E.nackCount,ssrc:E.ssrc,mid:E.mid,active:E.active,codecId:E.codecId,headerBytesSent:E.headerBytesSent||0,totalPacketSendDelay:E.totalPacketSendDelay||0};if(E.mediaType==="video"||E.kind==="video"){const C=E,ue=V({frameHeight:C.frameHeight,frameWidth:C.frameWidth,framesEncoded:C.framesEncoded,framesDropped:C.framesDropped?C.framesDropped:C.droppedFrames,framesPerSecond:C.framesPerSecond?C.framesPerSecond:C.framerateMean,framesSent:C.framesSent,keyFramesEncoded:C.keyFramesEncoded,firCount:C.firCount,encoderImplementation:C.encoderImplementation,hugeFramesSent:C.hugeFramesSent,pliCount:C.pliCount,qpSum:C.qpSum,qualityLimitationReason:C.qualityLimitationReason,qualityLimitationDurations:C.qualityLimitationDurations,qualityLimitationResolutionChanges:C.qualityLimitationResolutionChanges,totalEncodeTime:C.totalEncodeTime,totalPacketSendDelay:C.totalEncodeTime,retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent,scalabilityMode:C.scalabilityMode,powerEfficientEncoder:C.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ue)}else if(E.mediaType==="audio"||E.kind==="audio"){const C=E,ue=V({retransmittedBytesSent:C.retransmittedBytesSent,retransmittedPacketsSent:C.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ue),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ue)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}case"inbound-rtp":{const E=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(E.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(E.mediaType)||["video","audio"].includes(E.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:E.bytesReceived,packetsReceived:E.packetsReceived,packetsLost:E.packetsLost>=0?E.packetsLost:0,jitter:E.jitter,nackCount:E.nackCount,jitterBufferDelay:E.jitterBufferDelay,jitterBufferEmittedCount:E.jitterBufferEmittedCount,lastPacketReceivedTimestamp:E.lastPacketReceivedTimestamp,ssrc:E.ssrc,mid:E.mid,codecId:E.codecId,headerBytesReceived:E.headerBytesReceived||0,packetsDiscarded:E.packetsDiscarded||0,jitterBufferMinimumDelay:E.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:E.jitterBufferTargetDelay||0};if(E.mediaType==="video"||E.kind==="video"){const x=E,C=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped?x.framesDropped:x.droppedFrames,framesPerSecond:x.framesPerSecond?x.framesPerSecond:x.framerateMean,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);C.score=Bf({frameWidth:C.frameWidth||0,framesDecoded:(C.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:C.framesPerSecond||0,packetsLost:(C.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(C.score*10).toFixed(),frameWidth:C.frameWidth||0,frameHeight:C.frameHeight||0,framesPerSecond:C.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((m=this.videoConsumerToStatsMap.get(_))==null?void 0:m.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,C),w.inboundVideoRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,C)}else if(E.mediaType==="audio"||E.kind==="audio"){const x=E,C=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);C.score=Ff({concealmentEvents:(C.concealmentEvents||0)-(((S=this.audioConsumerToStatsMap.get(_))==null?void 0:S.concealmentEvents)||0),packetsLost:(C.packetsLost||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((M=this.audioConsumerToStatsMap.get(_))==null?void 0:M.packetsReceived)||0),jitter:C.jitter||0}),jt.set(_,{score:+(C.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(C.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(C.packetsReceived||0)-(((R=this.audioConsumerToStatsMap.get(_))==null?void 0:R.packetsReceived)||0)}),jitter:C.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((C.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,C),w.inboundAudioRtp.set(A.id,C),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,C)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${E.mediaType} kind: ${E.kind}`);break}}}if(w.producerStreamMap.forEach((A,E)=>{var _,B,oe,He,x,C,ue,Ki,zi,qr,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa,Ea;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Fl=>{ge.push(w.outboundVideoRtp.get(Fl))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=xf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(E))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(E))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((C=this.videoProducerToStatsMap.get(E))==null?void 0:C.framesEncoded)||0)}),Xe.set(E,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ue=se.remoteData)==null?void 0:ue.jitter)||0,isScreenShare:this.screenShareProducers.has(E),packetsLostPercentage:Gd({packetsSent:(se.packetsSent||0)-(((Ki=this.videoProducerToStatsMap.get(E))==null?void 0:Ki.packetsSent)||0),packetsLost:(((zi=se.remoteData)==null?void 0:zi.packetsLost)||0)-(((ca=(qr=this.videoProducerToStatsMap.get(E))==null?void 0:qr.remoteData)==null?void 0:ca.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((da=this.videoProducerToStatsMap.get(E))==null?void 0:da.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(E,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Lf({packetsSent:(ge.packetsSent||0)-(((la=this.audioProducerToStatsMap.get(E))==null?void 0:la.packetsSent)||0),packetsLost:(((ua=ge.remoteData)==null?void 0:ua.packetsLost)||0)-(((pa=(ha=this.audioProducerToStatsMap.get(E))==null?void 0:ha.remoteData)==null?void 0:pa.packetsLost)||0),jitter:((ma=ge.remoteData)==null?void 0:ma.jitter)||0}),Xe.set(E,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ga=this.audioProducerToStatsMap.get(E))==null?void 0:ga.bytesSent)||0))*8/7,packetsLostPercentage:Gd({packetsSent:(ge.packetsSent||0)-(((fa=this.audioProducerToStatsMap.get(E))==null?void 0:fa.packetsSent)||0),packetsLost:(((va=ge.remoteData)==null?void 0:va.packetsLost)||0)-(((Sa=(ya=this.audioProducerToStatsMap.get(E))==null?void 0:ya.remoteData)==null?void 0:Sa.packetsLost)||0)}),jitter:((Ea=ge.remoteData)==null?void 0:Ea.jitter)||0,isScreenShare:this.screenShareProducers.has(E)}),this.audioProducerToStatsMap.set(E,ge)}}),Me.forEach(A=>{const E=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);E&&(A.localCandidateType=E.type,A.localCandidateAddress=Bi(E.address),A.localCandidatePort=E.port,A.localCandidateProtocol=E.protocol,A.localCandidateUrl=E.url,A.localCandidateNetworkType=E.networkType,A.localCandidateRelatedAddress=Bi(E.relatedAddress),A.localCandidateRelatedPort=E.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=Bi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.bytesReceived=w.candidatePair.bytesReceived,w.transport.bytesSent=w.candidatePair.bytesSent,w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,E=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,E=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=E}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{const n=this.producerMap.get(s),o=n.track.getSettings(),c=i.outboundVideoRtpId.map(l=>{const h=e.outboundVideoRtp.get(l);return h.frameHeight||(h.frameHeight=o.height,h.frameWidth=o.width,h.framesPerSecond=o.frameRate),h}),d={producerId:s,appData:n.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(l=>e.outboundAudioRtp.get(l))};r.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return r}getConsumerStatsFromParsedConsumerStats(e,r,i){let s;try{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(i),d=r==null?void 0:r.inboundVideoRtpId.map(l=>{const h=this.consumerMap.get(i).track.getSettings(),m=e.inboundVideoRtp.get(l);return m.frameHeight||(m.frameHeight=h.height,m.frameWidth=h.width,m.framesPerSecond=h.frameRate),m});s={consumerId:i,peerId:n,producerId:o,appData:c,videoStats:d,audioStats:r==null?void 0:r.inboundAudioRtpId.map(l=>e.inboundAudioRtp.get(l))}}catch(n){console.error("getConsumerStatsFromParsedConsumerStats: ",n,e)}return s}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{r.push(this.getConsumerStatsFromParsedConsumerStats(e,i,s))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return r}}class BE extends Gf{}function $d(t,e,r,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof r=="function"&&i instanceof e)r.call(null,i,t);else throw i}function Kp(t,e,r){const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{$d(this,e,r,o)}):n}catch(n){$d(this,e,r,n)}return null},t}const X=(t,e)=>(r,i,s)=>{const n=s.value;return s.value=function(...o){try{const c=n.apply(this,o);return c&&c instanceof Promise?c.catch(d=>{$d(this,t,e,d)}):c}catch(c){$d(this,t,e,c)}return null},s},WE=(t,e)=>(r,i,s)=>{if(s)return Kp(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);o.value instanceof Function&&Object.defineProperty(r.prototype,n,Kp(o,t,e))}};var Y=globalThis&&globalThis.__decorate||function(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n};const Q=console;let K=class extends mt{constructor(t="https://api.testingv3.dyte.in",e="Blink",r=Vo.PROD,i,s,n,o){switch(super(),p(this,"observer"),p(this,"eventHandler"),p(this,"measurements"),p(this,"producingTransport"),p(this,"consumingTransport"),p(this,"producers",new Map),p(this,"consumers",new Map),p(this,"iceServers"),p(this,"connectionInfoPromise"),p(this,"pingStatsTimeout"),p(this,"logger"),p(this,"env"),p(this,"apiHostnames"),p(this,"peerId"),p(this,"consumerSharedMediaStatesMap",new Map),p(this,"currentUserMediaStates",{}),this.env=r,this.apiHostnames=o,this.logger=s,this.peerId=n,this.eventHandler=new _E({logger:s,peerId:n,apiHostnames:o}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new FE;break;case"Gecko":this.measurements=new Gf;break;case"WebKit":this.measurements=new BE;break;default:throw Error(`Unknown engineName! ${e}`)}this.measurements.callStatsInstance=this,this.registerProducer=this.registerProducer.bind(this),this.registerConsumer=this.registerConsumer.bind(this),this.observer=new mt,this.measurements.observer.on("consumer_score",c=>{s.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{s.debug(`callStats::producer_score ${[...c.entries()]}`),this.eventHandler.emit("producer_score",c)})}registerIceServers(t){this.iceServers=t}registerConsumer(t){var e;this.consumerSharedMediaStatesMap.has(t.id)||this.consumerSharedMediaStatesMap.set(t.id,{}),this.consumers.set(t.id,t),this.measurements.registerConsumer(t),this.logger.debug("callStats::registerConsumer",{consumerId:t.id,consumerkind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterConsumer.bind(this,t))}registerProducer(t){var e;this.producers.set(t.id,t),this.measurements.registerProducer(t),this.logger.debug("callStats::registerProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterProducer.bind(this,t))}sendConsumerSharedMediaStateEvent(t,e){this.consumerSharedMediaStatesMap.has(t)||this.consumerSharedMediaStatesMap.set(t,{});const r=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(r,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.on("close",this.disconnectProducingTransport.bind(this,t)),t.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(r=>{this.registerProducer(r)}),t.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.on("close",this.disconnectConsumingTransport.bind(this,t)),t.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(r=>{this.registerConsumer(r)}),t.on("newconsumer",this.registerConsumer)}deRegisterConsumer(t){this.consumers.delete(t.id)}deRegisterProducer(t){var e;this.producers.delete(t.id),this.logger.debug("callStats::deRegisterProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)})}disconnectConsumingTransport(){this.consumingTransport=void 0}disconnectProducingTransport(){this.producingTransport=void 0}callEvent(t){this.eventHandler.callEvent(t)}sendPreCallTestBeginEvent(t=!1,e){this.connectionInfoPromise=this.measurements.getNetworkInfo(this.iceServers,t),this.eventHandler.callEvent({event:L.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(r=>{this.eventHandler.callEvent({event:L.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:r},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,r){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?L.SCREENSHARE_STARTED:L.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:r})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:L.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:L.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_DEVICES_UPDATES||t===or.VIDEO&&L.VIDEO_DEVICES_UPDATES||t===or.SPEAKER&&L.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:r})}selectedDevice(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.SELECTED_MICROHPONE_UPDATE||t===or.VIDEO&&L.SELECTED_CAMERA_UPDATE||t===or.SPEAKER&&L.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:r})}mediaPermission(t,e,r){this.eventHandler.callEvent({event:L.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:r})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_PLAY_FAILED||t===or.VIDEO&&L.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_TRACK_MUTED||t===or.VIDEO&&L.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:L.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:L.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:L.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:L.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return u(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=q(V({},t),{meetingEnv:this.env}),t.deviceInfo=q(V({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:L.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((r,i)=>u(this,null,function*(){const s=[];try{for(const n of t)try{if(n.iceServers&&n.iceServers.length>0){const o=yield this.measurements.getNetworkQuality(n.iceServers);s.push(q(V({},n),{networkResults:o}))}}catch(o){console.warn("Error handling ",o)}r({regionData:s})}catch(n){console.warn("Error in callstats, ",n),i(n)}})).then(r=>{this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_END,timestamp:e,metaData:r})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:L.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:L.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let r;t?r=L.AUDIO_ON:r=L.AUDIO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let r;t?r=L.VIDEO_ON:r=L.VIDEO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:L.PARTICIPANT_ROLE,timestamp:e,metaData:t})}startPingStats(t=7e3){this.sendPingStatsEvent(!1,new Date),this.pingStatsTimeout=setInterval(this.sendPingStatsEvent.bind(this),t)}stopPingStats(){clearInterval(this.pingStatsTimeout)}sendPingStatsEvent(t=!0,e){return u(this,null,function*(){let r,i;if(this.producingTransport&&(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!r||!(r!=null&&r.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const n=yield this.measurements.getProducersReport([...this.producers.values()]);r&&n?r.producerReport=n:(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!r||!(r!=null&&r.producerReport))&&this.logger.debug("callStats::sendPingStatsEvent::noProducingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}if(this.consumingTransport&&(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),!i||!i.consumerReport)){this.logger.debug("callStats::sendPingStatsEvent::staleConsumingTransport",{disclaimer:"Stale consumer? Regenerating Stream Maps!"});const n=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&n?i.consumerReport=n:(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),(!i||!i.consumerReport)&&this.logger.debug("callStats::sendPingStatsEvent::noConsumingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}const s={producingTransportStats:r?r==null?void 0:r.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((r==null?void 0:r.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((r==null?void 0:r.consumerReport)||[])};if(t&&s.producerStats.length===0&&s.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:L.PING_STAT,metaData:s,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:L.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:L.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:L.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_VIDEO_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}};Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerIceServers",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendConsumerSharedMediaStateEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterConsumer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterProducer",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectConsumingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectProducingTransport",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPreCallTestBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareRequestedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendActiveSpeakerEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"devices",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"selectedDevice",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPermission",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPlaybackFailed",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaTrackMuted",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"tabChanged",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserBackgrounded",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserForegrounded",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"legacySwitch",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"getPreCallTestResults",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendCallJoinBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendNetworkQualityTestBeginEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendWebSocketConnectedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendTransportConnectedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendAudioToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendVideoToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendParticipantRoleToggleEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"startPingStats",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"stopPingStats",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPingStatsEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRebufferEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAudioBlockEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerInitializedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerWorkerErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRecoverableErrorEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAnalyticsEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerQualityChanged",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPlayerLiveLatency",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendDisconnectEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendReconnectEvent",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedVideoResolution",null);Y([X(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedScreenshareResolution",null);K=Y([WE(TypeError,(t,e)=>Q.error(e,t))],K);const jE=K;class qf extends mt{constructor(){super(...arguments),p(this,"stats"),p(this,"peerId"),p(this,"backend"),p(this,"iceServers"),p(this,"initialized",!1),p(this,"stalled",!1),p(this,"ipInformation"),p(this,"logger")}initialize(e){return u(this,arguments,function*({peerId:r,engineName:i,env:s=Vo.PROD,iceServers:n,apiBase:o="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:l,skipConnectivityChecks:h=!1}){var m,v,S;try{this.peerId=r,this.logger=d,this.ipInformation=yield ep.getIPDetails({peerId:r,apiHostnames:l,logger:d}),this.backend=new jE(o,i,s,c,d,r,l),this.iceServers=n,(m=this.backend)==null||m.registerIceServers(this.iceServers),this.initialized=!0,(S=(v=this.backend)==null?void 0:v.eventHandler)==null||S.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(h)}catch(T){this.logger.error("callStats::CallStatsIntegration: ",{error:T}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,r)}catch(s){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:s.reason}})}})})}roomJoined(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i,s;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,r),this.backend,(s=this.backend)==null||s.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var r,i;(r=this.backend)==null||r.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,r)})}consumerSharedMediaState(e,r){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,r)})}screenShareStop(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,r)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,r)})}devices(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.devices(e,r,i)})}selectedDevice(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.selectedDevice(e,r,i)})}mediaPermission(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.mediaPermission(e,r,i)})}mediaPlaybackFailed(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,r)})}mediaTrackMuted(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,r)})}tabChanged(e=!1){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,r)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserForegrounded(e)})}legacySwitch(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,r)})}startPreCallTest(e=!1){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,r)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const r=i=>{e(i,!0)};return this.once("initialized",r),r}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,r){const i=new Date;this.onSafeInitialization(()=>{var s,n,o,c,d,l,h,m,v,S,T;switch(e){case"PlayerRebuffering":(s=this.backend)==null||s.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(n=this.backend)==null||n.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(o=this.backend)==null||o.sendIVSPlayerPlaybackBlockedEvent(i);break;case"PlayerNetworkUnavailable":(c=this.backend)==null||c.sendIVSPlayerNetworkUnavailableEvent(i);break;case"PlayerInitialized":(d=this.backend)==null||d.sendIVSPlayerInitializedEvent(i);break;case"PlayerWorkerError":(l=this.backend)==null||l.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(h=this.backend)==null||h.sendIVSPlayerErrorEvent(r,i);break;case"PlayerRecoverableError":(m=this.backend)==null||m.sendIVSPlayerRecoverableErrorEvent(r,i);break;case"PlayerAnalyticsEvent":(v=this.backend)==null||v.sendIVSPlayerAnalyticsEvent(r,i);break;case"PlayerPlaybackRateChanged":(S=this.backend)==null||S.sendIVSPlayerPlaybackRateChangedEvent(r,i);break;case"PlayerQualityChanged":(T=this.backend)==null||T.sendIVSPlayerQualityChanged(r,i);break}})}livestreamLatency(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,r)})}expectedVideoResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedVideoResolution(e,r,i)})}expectedScreenshareResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedScreenshareResolution(e,r,i)})}}const HE=new qf;HE.setMaxListeners(30);function GE(){this.__data__=[],this.size=0}function tc(t,e){return t===e||t!==t&&e!==e}function Tl(t,e){for(var r=t.length;r--;)if(tc(t[r][0],e))return r;return-1}var qE=Array.prototype,$E=qE.splice;function JE(t){var e=this.__data__,r=Tl(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():$E.call(e,r,1),--this.size,!0}function KE(t){var e=this.__data__,r=Tl(e,t);return r<0?void 0:e[r][1]}function zE(t){return Tl(this.__data__,t)>-1}function YE(t,e){var r=this.__data__,i=Tl(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}function ui(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ui.prototype.clear=GE;ui.prototype.delete=JE;ui.prototype.get=KE;ui.prototype.has=zE;ui.prototype.set=YE;function QE(){this.__data__=new ui,this.size=0}function XE(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}function ZE(t){return this.__data__.get(t)}function ek(t){return this.__data__.has(t)}var tk=typeof global=="object"&&global&&global.Object===Object&&global;const $f=tk;var rk=typeof self=="object"&&self&&self.Object===Object&&self,ik=$f||rk||Function("return this")();const Cr=ik;var sk=Cr.Symbol;const ji=sk;var Jf=Object.prototype,nk=Jf.hasOwnProperty,ak=Jf.toString,Ta=ji?ji.toStringTag:void 0;function ok(t){var e=nk.call(t,Ta),r=t[Ta];try{t[Ta]=void 0;var i=!0}catch{}var s=ak.call(t);return i&&(e?t[Ta]=r:delete t[Ta]),s}var ck=Object.prototype,dk=ck.toString;function lk(t){return dk.call(t)}var uk="[object Null]",hk="[object Undefined]",zp=ji?ji.toStringTag:void 0;function Fs(t){return t==null?t===void 0?hk:uk:zp&&zp in Object(t)?ok(t):lk(t)}function Ir(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var pk="[object AsyncFunction]",mk="[object Function]",gk="[object GeneratorFunction]",fk="[object Proxy]";function tp(t){if(!Ir(t))return!1;var e=Fs(t);return e==mk||e==gk||e==pk||e==fk}var vk=Cr["__core-js_shared__"];const Gl=vk;var Yp=function(){var t=/[^.]+$/.exec(Gl&&Gl.keys&&Gl.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function yk(t){return!!Yp&&Yp in t}var Sk=Function.prototype,Ek=Sk.toString;function Bs(t){if(t!=null){try{return Ek.call(t)}catch{}try{return t+""}catch{}}return""}var kk=/[\\^$.*+?()[\]{}|]/g,Tk=/^\[object .+?Constructor\]$/,bk=Function.prototype,wk=Object.prototype,_k=bk.toString,Ik=wk.hasOwnProperty,Ck=RegExp("^"+_k.call(Ik).replace(kk,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Pk(t){if(!Ir(t)||yk(t))return!1;var e=tp(t)?Ck:Tk;return e.test(Bs(t))}function Rk(t,e){return t==null?void 0:t[e]}function Ws(t,e){var r=Rk(t,e);return Pk(r)?r:void 0}var Mk=Ws(Cr,"Map");const Xo=Mk;var Ak=Ws(Object,"create");const Zo=Ak;function Dk(){this.__data__=Zo?Zo(null):{},this.size=0}function Ok(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Nk="__lodash_hash_undefined__",Vk=Object.prototype,Lk=Vk.hasOwnProperty;function xk(t){var e=this.__data__;if(Zo){var r=e[t];return r===Nk?void 0:r}return Lk.call(e,t)?e[t]:void 0}var Uk=Object.prototype,Fk=Uk.hasOwnProperty;function Bk(t){var e=this.__data__;return Zo?e[t]!==void 0:Fk.call(e,t)}var Wk="__lodash_hash_undefined__";function jk(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Zo&&e===void 0?Wk:e,this}function Vs(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Vs.prototype.clear=Dk;Vs.prototype.delete=Ok;Vs.prototype.get=xk;Vs.prototype.has=Bk;Vs.prototype.set=jk;function Hk(){this.size=0,this.__data__={hash:new Vs,map:new(Xo||ui),string:new Vs}}function Gk(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function bl(t,e){var r=t.__data__;return Gk(e)?r[typeof e=="string"?"string":"hash"]:r.map}function qk(t){var e=bl(this,t).delete(t);return this.size-=e?1:0,e}function $k(t){return bl(this,t).get(t)}function Jk(t){return bl(this,t).has(t)}function Kk(t,e){var r=bl(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}function js(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}js.prototype.clear=Hk;js.prototype.delete=qk;js.prototype.get=$k;js.prototype.has=Jk;js.prototype.set=Kk;var zk=200;function Yk(t,e){var r=this.__data__;if(r instanceof ui){var i=r.__data__;if(!Xo||i.length<zk-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new js(i)}return r.set(t,e),this.size=r.size,this}function Hr(t){var e=this.__data__=new ui(t);this.size=e.size}Hr.prototype.clear=QE;Hr.prototype.delete=XE;Hr.prototype.get=ZE;Hr.prototype.has=ek;Hr.prototype.set=Yk;function Qk(t,e){for(var r=-1,i=t==null?0:t.length;++r<i&&e(t[r],r,t)!==!1;);return t}var Xk=function(){try{var t=Ws(Object,"defineProperty");return t({},"",{}),t}catch{}}();const Jd=Xk;function rp(t,e,r){e=="__proto__"&&Jd?Jd(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Zk=Object.prototype,eT=Zk.hasOwnProperty;function Kf(t,e,r){var i=t[e];(!(eT.call(t,e)&&tc(i,r))||r===void 0&&!(e in t))&&rp(t,e,r)}function rc(t,e,r,i){var s=!r;r||(r={});for(var n=-1,o=e.length;++n<o;){var c=e[n],d=i?i(r[c],t[c],c,r,t):void 0;d===void 0&&(d=t[c]),s?rp(r,c,d):Kf(r,c,d)}return r}function tT(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}function Gr(t){return t!=null&&typeof t=="object"}var rT="[object Arguments]";function Qp(t){return Gr(t)&&Fs(t)==rT}var zf=Object.prototype,iT=zf.hasOwnProperty,sT=zf.propertyIsEnumerable,nT=Qp(function(){return arguments}())?Qp:function(t){return Gr(t)&&iT.call(t,"callee")&&!sT.call(t,"callee")};const Kd=nT;var aT=Array.isArray;const Hi=aT;function oT(){return!1}var Yf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xp=Yf&&typeof module=="object"&&module&&!module.nodeType&&module,cT=Xp&&Xp.exports===Yf,Zp=cT?Cr.Buffer:void 0,dT=Zp?Zp.isBuffer:void 0,lT=dT||oT;const Qn=lT;var uT=9007199254740991,hT=/^(?:0|[1-9]\d*)$/;function Qf(t,e){var r=typeof t;return e=e==null?uT:e,!!e&&(r=="number"||r!="symbol"&&hT.test(t))&&t>-1&&t%1==0&&t<e}var pT=9007199254740991;function Xf(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pT}var mT="[object Arguments]",gT="[object Array]",fT="[object Boolean]",vT="[object Date]",yT="[object Error]",ST="[object Function]",ET="[object Map]",kT="[object Number]",TT="[object Object]",bT="[object RegExp]",wT="[object Set]",_T="[object String]",IT="[object WeakMap]",CT="[object ArrayBuffer]",PT="[object DataView]",RT="[object Float32Array]",MT="[object Float64Array]",AT="[object Int8Array]",DT="[object Int16Array]",OT="[object Int32Array]",NT="[object Uint8Array]",VT="[object Uint8ClampedArray]",LT="[object Uint16Array]",xT="[object Uint32Array]",_e={};_e[RT]=_e[MT]=_e[AT]=_e[DT]=_e[OT]=_e[NT]=_e[VT]=_e[LT]=_e[xT]=!0;_e[mT]=_e[gT]=_e[CT]=_e[fT]=_e[PT]=_e[vT]=_e[yT]=_e[ST]=_e[ET]=_e[kT]=_e[TT]=_e[bT]=_e[wT]=_e[_T]=_e[IT]=!1;function UT(t){return Gr(t)&&Xf(t.length)&&!!_e[Fs(t)]}function ip(t){return function(e){return t(e)}}var Zf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lo=Zf&&typeof module=="object"&&module&&!module.nodeType&&module,FT=Lo&&Lo.exports===Zf,ql=FT&&$f.process,BT=function(){try{var t=Lo&&Lo.require&&Lo.require("util").types;return t||ql&&ql.binding&&ql.binding("util")}catch{}}();const Xn=BT;var em=Xn&&Xn.isTypedArray,WT=em?ip(em):UT;const wl=WT;var jT=Object.prototype,HT=jT.hasOwnProperty;function ev(t,e){var r=Hi(t),i=!r&&Kd(t),s=!r&&!i&&Qn(t),n=!r&&!i&&!s&&wl(t),o=r||i||s||n,c=o?tT(t.length,String):[],d=c.length;for(var l in t)(e||HT.call(t,l))&&!(o&&(l=="length"||s&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Qf(l,d)))&&c.push(l);return c}var GT=Object.prototype;function _l(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||GT;return t===r}function tv(t,e){return function(r){return t(e(r))}}var qT=tv(Object.keys,Object);const $T=qT;var JT=Object.prototype,KT=JT.hasOwnProperty;function rv(t){if(!_l(t))return $T(t);var e=[];for(var r in Object(t))KT.call(t,r)&&r!="constructor"&&e.push(r);return e}function ic(t){return t!=null&&Xf(t.length)&&!tp(t)}function sp(t){return ic(t)?ev(t):rv(t)}function zT(t,e){return t&&rc(e,sp(e),t)}function YT(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var QT=Object.prototype,XT=QT.hasOwnProperty;function ZT(t){if(!Ir(t))return YT(t);var e=_l(t),r=[];for(var i in t)i=="constructor"&&(e||!XT.call(t,i))||r.push(i);return r}function sc(t){return ic(t)?ev(t,!0):ZT(t)}function eb(t,e){return t&&rc(e,sc(e),t)}var iv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tm=iv&&typeof module=="object"&&module&&!module.nodeType&&module,tb=tm&&tm.exports===iv,rm=tb?Cr.Buffer:void 0,im=rm?rm.allocUnsafe:void 0;function sv(t,e){if(e)return t.slice();var r=t.length,i=im?im(r):new t.constructor(r);return t.copy(i),i}function nv(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}function rb(t,e){for(var r=-1,i=t==null?0:t.length,s=0,n=[];++r<i;){var o=t[r];e(o,r,t)&&(n[s++]=o)}return n}function av(){return[]}var ib=Object.prototype,sb=ib.propertyIsEnumerable,sm=Object.getOwnPropertySymbols,nb=sm?function(t){return t==null?[]:(t=Object(t),rb(sm(t),function(e){return sb.call(t,e)}))}:av;const np=nb;function ab(t,e){return rc(t,np(t),e)}function ov(t,e){for(var r=-1,i=e.length,s=t.length;++r<i;)t[s+r]=e[r];return t}var ob=tv(Object.getPrototypeOf,Object);const ap=ob;var cb=Object.getOwnPropertySymbols,db=cb?function(t){for(var e=[];t;)ov(e,np(t)),t=ap(t);return e}:av;const cv=db;function lb(t,e){return rc(t,cv(t),e)}function dv(t,e,r){var i=e(t);return Hi(t)?i:ov(i,r(t))}function Lu(t){return dv(t,sp,np)}function ub(t){return dv(t,sc,cv)}var hb=Ws(Cr,"DataView");const xu=hb;var pb=Ws(Cr,"Promise");const Uu=pb;var mb=Ws(Cr,"Set");const Fu=mb;var gb=Ws(Cr,"WeakMap");const Bu=gb;var nm="[object Map]",fb="[object Object]",am="[object Promise]",om="[object Set]",cm="[object WeakMap]",dm="[object DataView]",vb=Bs(xu),yb=Bs(Xo),Sb=Bs(Uu),Eb=Bs(Fu),kb=Bs(Bu),cs=Fs;(xu&&cs(new xu(new ArrayBuffer(1)))!=dm||Xo&&cs(new Xo)!=nm||Uu&&cs(Uu.resolve())!=am||Fu&&cs(new Fu)!=om||Bu&&cs(new Bu)!=cm)&&(cs=function(t){var e=Fs(t),r=e==fb?t.constructor:void 0,i=r?Bs(r):"";if(i)switch(i){case vb:return dm;case yb:return nm;case Sb:return am;case Eb:return om;case kb:return cm}return e});const Zn=cs;var Tb=Object.prototype,bb=Tb.hasOwnProperty;function wb(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&bb.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var _b=Cr.Uint8Array;const zd=_b;function op(t){var e=new t.constructor(t.byteLength);return new zd(e).set(new zd(t)),e}function Ib(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cb=/\w*$/;function Pb(t){var e=new t.constructor(t.source,Cb.exec(t));return e.lastIndex=t.lastIndex,e}var lm=ji?ji.prototype:void 0,um=lm?lm.valueOf:void 0;function Rb(t){return um?Object(um.call(t)):{}}function lv(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Mb="[object Boolean]",Ab="[object Date]",Db="[object Map]",Ob="[object Number]",Nb="[object RegExp]",Vb="[object Set]",Lb="[object String]",xb="[object Symbol]",Ub="[object ArrayBuffer]",Fb="[object DataView]",Bb="[object Float32Array]",Wb="[object Float64Array]",jb="[object Int8Array]",Hb="[object Int16Array]",Gb="[object Int32Array]",qb="[object Uint8Array]",$b="[object Uint8ClampedArray]",Jb="[object Uint16Array]",Kb="[object Uint32Array]";function zb(t,e,r){var i=t.constructor;switch(e){case Ub:return op(t);case Mb:case Ab:return new i(+t);case Fb:return Ib(t,r);case Bb:case Wb:case jb:case Hb:case Gb:case qb:case $b:case Jb:case Kb:return lv(t,r);case Db:return new i;case Ob:case Lb:return new i(t);case Nb:return Pb(t);case Vb:return new i;case xb:return Rb(t)}}var hm=Object.create,Yb=function(){function t(){}return function(e){if(!Ir(e))return{};if(hm)return hm(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const Qb=Yb;function uv(t){return typeof t.constructor=="function"&&!_l(t)?Qb(ap(t)):{}}var Xb="[object Map]";function Zb(t){return Gr(t)&&Zn(t)==Xb}var pm=Xn&&Xn.isMap,ew=pm?ip(pm):Zb;const tw=ew;var rw="[object Set]";function iw(t){return Gr(t)&&Zn(t)==rw}var mm=Xn&&Xn.isSet,sw=mm?ip(mm):iw;const nw=sw;var aw=1,ow=2,cw=4,hv="[object Arguments]",dw="[object Array]",lw="[object Boolean]",uw="[object Date]",hw="[object Error]",pv="[object Function]",pw="[object GeneratorFunction]",mw="[object Map]",gw="[object Number]",mv="[object Object]",fw="[object RegExp]",vw="[object Set]",yw="[object String]",Sw="[object Symbol]",Ew="[object WeakMap]",kw="[object ArrayBuffer]",Tw="[object DataView]",bw="[object Float32Array]",ww="[object Float64Array]",_w="[object Int8Array]",Iw="[object Int16Array]",Cw="[object Int32Array]",Pw="[object Uint8Array]",Rw="[object Uint8ClampedArray]",Mw="[object Uint16Array]",Aw="[object Uint32Array]",Ee={};Ee[hv]=Ee[dw]=Ee[kw]=Ee[Tw]=Ee[lw]=Ee[uw]=Ee[bw]=Ee[ww]=Ee[_w]=Ee[Iw]=Ee[Cw]=Ee[mw]=Ee[gw]=Ee[mv]=Ee[fw]=Ee[vw]=Ee[yw]=Ee[Sw]=Ee[Pw]=Ee[Rw]=Ee[Mw]=Ee[Aw]=!0;Ee[hw]=Ee[pv]=Ee[Ew]=!1;function Jc(t,e,r,i,s,n){var o,c=e&aw,d=e&ow,l=e&cw;if(r&&(o=s?r(t,i,s,n):r(t)),o!==void 0)return o;if(!Ir(t))return t;var h=Hi(t);if(h){if(o=wb(t),!c)return nv(t,o)}else{var m=Zn(t),v=m==pv||m==pw;if(Qn(t))return sv(t,c);if(m==mv||m==hv||v&&!s){if(o=d||v?{}:uv(t),!c)return d?lb(t,eb(o,t)):ab(t,zT(o,t))}else{if(!Ee[m])return s?t:{};o=zb(t,m,c)}}n||(n=new Hr);var S=n.get(t);if(S)return S;n.set(t,o),nw(t)?t.forEach(function(b){o.add(Jc(b,e,r,b,t,n))}):tw(t)&&t.forEach(function(b,R){o.set(R,Jc(b,e,r,R,t,n))});var T=l?d?ub:Lu:d?sc:sp,M=h?void 0:T(t);return Qk(M||t,function(b,R){M&&(R=b,b=t[R]),Kf(o,R,Jc(b,e,r,R,t,n))}),o}var Dw=1,Ow=4;function cp(t){return Jc(t,Dw|Ow)}var Nw="[object Symbol]";function Vw(t){return typeof t=="symbol"||Gr(t)&&Fs(t)==Nw}var Lw=Object.defineProperty,xw=(t,e)=>{for(var r in e)Lw(t,r,{get:e[r],enumerable:!0})},Uw={};xw(Uw,{permissions:()=>Fw,theme:()=>Bw});var Ft=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Ft||{}),G=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(G||{}),Fw={view_type:"GROUP_CALL",accept_waiting_requests:!1,accept_present_requests:!1,request_produce:!1,can_allow_participant_audio:!1,can_allow_participant_screensharing:!1,can_allow_participant_video:!1,can_spotlight:!1,request_kick_participant:!1,kick_participant:!1,pin_participant:!1,can_edit_display_name:!1,can_record:!1,can_livestream:!1,can_present:!0,waiting_room_type:"SKIP_ON_ACCEPT",recorder_type:"NONE",plugins:{can_close:!0,can_start:!0},polls:{can_create:!0,can_vote:!0,can_view:!0},produce:{video:{allow:!0,quality:"vga",frame_rate:24},audio:!0,screenshare:{allow:!0,quality:"hd",frame_rate:5}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},reactions:!1,hidden_participant:!1,is_recorder:!1,show_participant_list:!0,can_change_participant_role:!1,can_change_theme:!1,max_screenshare_count:1},Bw={setup_screen:{is_enabled:!0},alone_here:{is_enabled:!0},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!0,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"multi"},controls:{pip_toggle:!1}},gv="hXgU8Wc8pwuGNq9ms5q9Hh",gm;typeof process!="undefined"&&(gm=process==null?void 0:process.env)!=null&&gm.FLAGSMITH_ENVIRONMENT_KEY&&(gv={}.FLAGSMITH_ENVIRONMENT_KEY);function Ww(t=[]){const e={};return t.forEach(r=>{e[r.feature.name]={enabled:r.enabled,value:r.feature_state_value}}),e}var fv=class{constructor(t=gv){p(this,"flags",{}),p(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return u(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:r,forceEvaluate:i,timeout:s,uniqueIdentifier:n,traitsObj:o,logger:c}){const d=JSON.parse(JSON.stringify(o)),l=Object.entries(d).map(m=>({trait_key:m[0],trait_value:m[1]})),h=[e,r,r];for(const m of h)try{const v=new AbortController,S=setTimeout(()=>v.abort(),s),T="_"+(Math.random()+1).toString(36).substring(2),M=yield fetch(`https://${m}/api/v1/identities/`,{method:"POST",headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},body:JSON.stringify({identifier:n+(i?T:""),traits:l}),signal:v.signal});if(clearTimeout(S),!M.ok)throw new Error(`Request failed with status ${M.status}`);const b=yield M.json();return Ww(b.flags||[])}catch(v){c.error("Flagsmith identify failed!!",{error:v,url:m})}return{}})}identify(t){return u(this,arguments,function*(e,r={},i=!1,s=5e3,n="edge.api.flagsmith.com",o=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:r,uniqueIdentifier:e,forceEvaluate:i,timeout:s,primaryEndpoint:n,secondaryEndpoint:"edge.api.flagsmith.com",logger:o}),this.flags})}getValue(t){return this.flags&&this.flags[t]&&this.flags[t].value}hasFeature(t){return this.flags&&this.flags[t]&&this.flags[t].enabled}getAllFlags(){return this.flags}},jw=new fv;function Hw(t){return new fv(t)}var vv=[-2,-1,0,1,2],Gw=[0,1,2,3,4];function qw(t){t=t.trim();let e="0",r="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],r="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],r="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+r,+i]}var $w=(t,e,r)=>{let i,s,n;if(e==0)i=s=n=r;else{const o=(l,h,m)=>(m<0&&(m+=1),m>1&&(m-=1),m<.16666666666666666?l+(h-l)*6*m:m<.5?h:m<.6666666666666666?l+(h-l)*(.6666666666666666-m)*6:l),c=r<.5?r*(1+e):r+e-r*e,d=2*r-c;i=o(d,c,t+1/3),s=o(d,c,t),n=o(d,c,t-1/3)}return[Math.round(i*255),Math.round(s*255),Math.round(n*255)]},Jw=(t,e,r)=>{t/=255,e/=255,r/=255;const i=Math.max(t,e,r),s=Math.min(t,e,r);let n,o;const c=(i+s)/2;if(i==s)n=o=0;else{const d=i-s;switch(o=c>.5?d/(2-i-s):d/(i+s),i){case t:n=(e-r)/d+(e<r?6:0);break;case e:n=(r-t)/d+2;break;case r:n=(t-e)/d+4;break}n/=6}return[n,o,c]},Kw=(t,e,r)=>{const i=s=>s.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(r)}`},yv=(t,e=vv,r=.4)=>{const i=[],[s,n,o]=qw(t),[c,d,l]=Jw(s,n,o),h=Math.round(l*100);h>70?r=.8:h>60?r=.9:h<10?r=.075:h<42&&(r=.3);const m=e.findIndex(b=>b===0);if(m===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const v=5-m,S=m+1,T=(100-h)/v,M=h/S;for(const b of e){let R;b<0?R=h+b*M*r:b>0?R=h+b*T*r:R=h;const[j,W,w]=$w(c,d,R/100);i.push(Kw(j,W,w))}return i},fm={dark:{background:{1e3:"#252525",900:"#2F2F2F",800:"#323232",700:"#3E3E3E",600:"#4A4A4A"},text:"#F5F5F5","video-bg":"#1C1C1C"},light:{background:{1e3:"#FFFFFF",900:"#F5F5F5",800:"#EBEBEB",700:"#E0E0E0",600:"#D6D6D6"},text:"#111111","text-on-brand":"#ffffff","video-bg":"#DADADA"}},zw=t=>{const[e,r,i,s,n]=yv(t,vv);return{300:e,400:r,500:i,600:s,700:n}},Yw=t=>{if(t==="#FFFFFF")return fm.light.background;if(t==="#000000")return fm.dark.background;const[e,r,i,s,n]=yv(t,Gw);return{1e3:e,900:r,800:i,700:s,600:n}},Qw={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:zw("#2160FD"),background:Yw("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function Sv(){return cp(Qw)}var Xw={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED",can_consume:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED",can_consume:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1},channel:{can_create:"ALL",can_delete:"ALL",can_update:"ALL",can_read_all:!1},message:{can_delete:"ALL",can_edit:"ALL",delete_cutoff_time_seconds:0,edit_cutoff_time_seconds:0}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{oldTheme:{setup_screen:{is_enabled:!1},alone_here:{is_enabled:!1},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!1,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,colors:{primary:"#2160FD",secondary:"#1A1A1A",text:"#EEEEEE",background:"#1A1A1A",textPrimary:"#EEEEEE",videoBackground:"#1A1A1A"},dimensions:{mode:"fillParent"},grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"MULTI"},controls:{pip_toggle:!1},plugins:[]},design_tokens:Sv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"hybrid"};function Zw(){return cp(Xw)}var e_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{design_tokens:Sv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"2.0.0"};function dp(){return cp(e_)}var Kc;class Ev{constructor(){g(this,Kc,void 0)}get telemetry(){var e;return(e=a(this,Kc))==null?void 0:e.getValue("telemetry")}init(e){f(this,Kc,e)}info(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("info",e,r,i)}error(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("error",e,r,i)}debug(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("debug",e,r,i)}log(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("log",e,r,i)}warn(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("warn",e,r,i)}}Kc=new WeakMap;var ki,Ti;const kv=class extends mt.EventEmitter{constructor(t){super(),g(this,ki,void 0),g(this,Ti,void 0),p(this,"asyncPromiseTimeout"),p(this,"logger"),this.logger=t,f(this,ki,new Map),f(this,Ti,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return u(this,null,function*(){a(this,ki).set(t,[]);const r=a(this,Ti).get(t).map(()=>new Promise(i=>{a(this,ki).get(t).push(i)}));nE(kv.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(r),new Promise((i,s)=>setTimeout(()=>s(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),a(this,ki).delete(t)})}onAsync(t,e){const r=a(this,ki),i=(...s)=>u(this,null,function*(){var n;try{yield e(...s)}catch(c){this.logger.error("[onAsync]",{error:c})}const o=(n=r.get(t))==null?void 0:n.shift();o==null||o()});return a(this,Ti).get(t)||a(this,Ti).set(t,[]),a(this,Ti).get(t).push(i),super.on(t,i)}reset(){f(this,ki,new Map),f(this,Ti,new Map),super.removeAllListeners()}};let t_=kv;ki=new WeakMap,Ti=new WeakMap;var r_=/\s/;function i_(t){for(var e=t.length;e--&&r_.test(t.charAt(e)););return e}var s_=/^\s+/;function n_(t){return t&&t.slice(0,i_(t)+1).replace(s_,"")}var vm=0/0,a_=/^[-+]0x[0-9a-f]+$/i,o_=/^0b[01]+$/i,c_=/^0o[0-7]+$/i,d_=parseInt;function ym(t){if(typeof t=="number")return t;if(Vw(t))return vm;if(Ir(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Ir(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=n_(t);var r=o_.test(t);return r||c_.test(t)?d_(t.slice(2),r?2:8):a_.test(t)?vm:+t}function Tv(t){return t}function l_(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var u_=800,h_=16,p_=Date.now;function m_(t){var e=0,r=0;return function(){var i=p_(),s=h_-(i-r);if(r=i,s>0){if(++e>=u_)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function g_(t){return function(){return t}}var f_=Jd?function(t,e){return Jd(t,"toString",{configurable:!0,enumerable:!1,value:g_(e),writable:!0})}:Tv;const v_=f_;var y_=m_(v_);const S_=y_;var Sm=Math.max;function E_(t,e,r){return e=Sm(e===void 0?t.length-1:e,0),function(){for(var i=arguments,s=-1,n=Sm(i.length-e,0),o=Array(n);++s<n;)o[s]=i[e+s];s=-1;for(var c=Array(e+1);++s<e;)c[s]=i[s];return c[e]=r(o),l_(t,this,c)}}function k_(t,e){return S_(E_(t,e,Tv),t+"")}function T_(t,e,r){if(!Ir(r))return!1;var i=typeof e;return(i=="number"?ic(r)&&Qf(e,r.length):i=="string"&&e in r)?tc(r[e],t):!1}function b_(t){return k_(function(e,r){var i=-1,s=r.length,n=s>1?r[s-1]:void 0,o=s>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(s--,n):void 0,o&&T_(r[0],r[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var c=r[i];c&&t(e,c,i,n)}return e})}var w_="[object Object]",__=Function.prototype,I_=Object.prototype,bv=__.toString,C_=I_.hasOwnProperty,P_=bv.call(Object);function R_(t){if(!Gr(t)||Fs(t)!=w_)return!1;var e=ap(t);if(e===null)return!0;var r=C_.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&bv.call(r)==P_}var M_="__lodash_hash_undefined__";function A_(t){return this.__data__.set(t,M_),this}function D_(t){return this.__data__.has(t)}function Yd(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new js;++e<r;)this.add(t[e])}Yd.prototype.add=Yd.prototype.push=A_;Yd.prototype.has=D_;function O_(t,e){for(var r=-1,i=t==null?0:t.length;++r<i;)if(e(t[r],r,t))return!0;return!1}function N_(t,e){return t.has(e)}var V_=1,L_=2;function wv(t,e,r,i,s,n){var o=r&V_,c=t.length,d=e.length;if(c!=d&&!(o&&d>c))return!1;var l=n.get(t),h=n.get(e);if(l&&h)return l==e&&h==t;var m=-1,v=!0,S=r&L_?new Yd:void 0;for(n.set(t,e),n.set(e,t);++m<c;){var T=t[m],M=e[m];if(i)var b=o?i(M,T,m,e,t,n):i(T,M,m,t,e,n);if(b!==void 0){if(b)continue;v=!1;break}if(S){if(!O_(e,function(R,j){if(!N_(S,j)&&(T===R||s(T,R,r,i,n)))return S.push(j)})){v=!1;break}}else if(!(T===M||s(T,M,r,i,n))){v=!1;break}}return n.delete(t),n.delete(e),v}function x_(t){var e=-1,r=Array(t.size);return t.forEach(function(i,s){r[++e]=[s,i]}),r}function U_(t){var e=-1,r=Array(t.size);return t.forEach(function(i){r[++e]=i}),r}var F_=1,B_=2,W_="[object Boolean]",j_="[object Date]",H_="[object Error]",G_="[object Map]",q_="[object Number]",$_="[object RegExp]",J_="[object Set]",K_="[object String]",z_="[object Symbol]",Y_="[object ArrayBuffer]",Q_="[object DataView]",Em=ji?ji.prototype:void 0,$l=Em?Em.valueOf:void 0;function X_(t,e,r,i,s,n,o){switch(r){case Q_:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Y_:return!(t.byteLength!=e.byteLength||!n(new zd(t),new zd(e)));case W_:case j_:case q_:return tc(+t,+e);case H_:return t.name==e.name&&t.message==e.message;case $_:case K_:return t==e+"";case G_:var c=x_;case J_:var d=i&F_;if(c||(c=U_),t.size!=e.size&&!d)return!1;var l=o.get(t);if(l)return l==e;i|=B_,o.set(t,e);var h=wv(c(t),c(e),i,s,n,o);return o.delete(t),h;case z_:if($l)return $l.call(t)==$l.call(e)}return!1}var Z_=1,e0=Object.prototype,t0=e0.hasOwnProperty;function r0(t,e,r,i,s,n){var o=r&Z_,c=Lu(t),d=c.length,l=Lu(e),h=l.length;if(d!=h&&!o)return!1;for(var m=d;m--;){var v=c[m];if(!(o?v in e:t0.call(e,v)))return!1}var S=n.get(t),T=n.get(e);if(S&&T)return S==e&&T==t;var M=!0;n.set(t,e),n.set(e,t);for(var b=o;++m<d;){v=c[m];var R=t[v],j=e[v];if(i)var W=o?i(j,R,v,e,t,n):i(R,j,v,t,e,n);if(!(W===void 0?R===j||s(R,j,r,i,n):W)){M=!1;break}b||(b=v=="constructor")}if(M&&!b){var w=t.constructor,te=e.constructor;w!=te&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof te=="function"&&te instanceof te)&&(M=!1)}return n.delete(t),n.delete(e),M}var i0=1,km="[object Arguments]",Tm="[object Array]",vc="[object Object]",s0=Object.prototype,bm=s0.hasOwnProperty;function n0(t,e,r,i,s,n){var o=Hi(t),c=Hi(e),d=o?Tm:Zn(t),l=c?Tm:Zn(e);d=d==km?vc:d,l=l==km?vc:l;var h=d==vc,m=l==vc,v=d==l;if(v&&Qn(t)){if(!Qn(e))return!1;o=!0,h=!1}if(v&&!h)return n||(n=new Hr),o||wl(t)?wv(t,e,r,i,s,n):X_(t,e,d,r,i,s,n);if(!(r&i0)){var S=h&&bm.call(t,"__wrapped__"),T=m&&bm.call(e,"__wrapped__");if(S||T){var M=S?t.value():t,b=T?e.value():e;return n||(n=new Hr),s(M,b,r,i,n)}}return v?(n||(n=new Hr),r0(t,e,r,i,s,n)):!1}function _v(t,e,r,i,s){return t===e?!0:t==null||e==null||!Gr(t)&&!Gr(e)?t!==t&&e!==e:n0(t,e,r,i,_v,s)}function a0(t){return function(e,r,i){for(var s=-1,n=Object(e),o=i(e),c=o.length;c--;){var d=o[t?c:++s];if(r(n[d],d,n)===!1)break}return e}}var o0=a0();const c0=o0;var d0=function(){return Cr.Date.now()};const Jl=d0;var l0="Expected a function",u0=Math.max,h0=Math.min;function lp(t,e,r){var i,s,n,o,c,d,l=0,h=!1,m=!1,v=!0;if(typeof t!="function")throw new TypeError(l0);e=ym(e)||0,Ir(r)&&(h=!!r.leading,m="maxWait"in r,n=m?u0(ym(r.maxWait)||0,e):n,v="trailing"in r?!!r.trailing:v);function S(re){var ae=i,Me=s;return i=s=void 0,l=re,o=t.apply(Me,ae),o}function T(re){return l=re,c=setTimeout(R,e),h?S(re):o}function M(re){var ae=re-d,Me=re-l,Xe=e-ae;return m?h0(Xe,n-Me):Xe}function b(re){var ae=re-d,Me=re-l;return d===void 0||ae>=e||ae<0||m&&Me>=n}function R(){var re=Jl();if(b(re))return j(re);c=setTimeout(R,M(re))}function j(re){return c=void 0,v&&i?S(re):(i=s=void 0,o)}function W(){c!==void 0&&clearTimeout(c),l=0,i=d=s=c=void 0}function w(){return c===void 0?o:j(Jl())}function te(){var re=Jl(),ae=b(re);if(i=arguments,s=this,d=re,ae){if(c===void 0)return T(d);if(m)return clearTimeout(c),c=setTimeout(R,e),S(d)}return c===void 0&&(c=setTimeout(R,e)),o}return te.cancel=W,te.flush=w,te}function Wu(t,e,r){(r!==void 0&&!tc(t[e],r)||r===void 0&&!(e in t))&&rp(t,e,r)}function p0(t){return Gr(t)&&ic(t)}function ju(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function m0(t){return rc(t,sc(t))}function g0(t,e,r,i,s,n,o){var c=ju(t,r),d=ju(e,r),l=o.get(d);if(l){Wu(t,r,l);return}var h=n?n(c,d,r+"",t,e,o):void 0,m=h===void 0;if(m){var v=Hi(d),S=!v&&Qn(d),T=!v&&!S&&wl(d);h=d,v||S||T?Hi(c)?h=c:p0(c)?h=nv(c):S?(m=!1,h=sv(d,!0)):T?(m=!1,h=lv(d,!0)):h=[]:R_(d)||Kd(d)?(h=c,Kd(c)?h=m0(c):(!Ir(c)||tp(c))&&(h=uv(d))):m=!1}m&&(o.set(d,h),s(h,d,i,n,o),o.delete(d)),Wu(t,r,h)}function Iv(t,e,r,i,s){t!==e&&c0(e,function(n,o){if(s||(s=new Hr),Ir(n))g0(t,e,o,r,Iv,i,s);else{var c=i?i(ju(t,o),n,o+"",t,e,s):void 0;c===void 0&&(c=n),Wu(t,o,c)}},sc)}var f0="[object Map]",v0="[object Set]",y0=Object.prototype,S0=y0.hasOwnProperty;function E0(t){if(t==null)return!0;if(ic(t)&&(Hi(t)||typeof t=="string"||typeof t.splice=="function"||Qn(t)||wl(t)||Kd(t)))return!t.length;var e=Zn(t);if(e==f0||e==v0)return!t.size;if(_l(t))return!rv(t).length;for(var r in t)if(S0.call(t,r))return!1;return!0}function k0(t,e){return _v(t,e)}var T0=b_(function(t,e,r){Iv(t,e,r)});const bi=T0;var Hu=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(Hu||{});const Z={PROPAGATE_KICK_ALL:"propagate_kick_across_rooms",REFRESH_ID_ON_DISCONNECTION:"refresh_id_on_disconnection",SIMULCAST:"simulcast",CHAT_SOCKET_SERVER:"chat_socket_server",POLL_SOCKET_SERVER:"poll_socket_server",PLUGIN_SOCKET_SERVER:"plugin_socket_server",NR_OTEL_WEB:"nr_otel_web",ICE_RESTART_ON_FAILED_STATE:"ice_restart_on_failed_state",ICE_RESTART_ON_DISCONNECTED_STATE:"ice_restart_on_disconnected_state",ENABLE_ICE_STATE_LOGGING:"enable_ice_state_logging",SUPPRESS_PEER_MUTE_UNMUTE_EMITS:"web_core_suppress_peer_mute_unmute_emits",SKIP_OTEL_TRACES:"skip_otel_traces",USE_USERIDS_IN_CHAT:"use_userids_in_chat",CUSTOM_PING_PONG:"custom_ping_pong",ENABLE_HIVE_SIMULCAST:"enable_hive_simulcast",ENABLE_HIVE_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_hive_transport_reconnection_on_ice_failed",ENABLE_HIVE_EXPERIMENTAL_FAIL_RECOVERY:"enable_hive_fail_recovery",ENABLE_HIVE_INFINITE_RETRIES:"enable_hive_infinite_retries",HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"hive_transport_force_relay_on_ice_failed",ENABLE_HIVE_CONSUME_OVER_DC:"enable_hive_consume_over_dc",ENABLE_CF_SIMULCAST:"enable_cf_simulcast",ENABLE_CF_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_cf_transport_reconnection_on_ice_failed",ENABLE_CF_EXPERIMENTAL_FAIL_RECOVERY:"enable_cf_fail_recovery",ENABLE_CF_INFINITE_RETRIES:"enable_cf_infinite_retries",CF_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"cf_transport_force_relay_on_ice_failed",BYPASS_LOG_EXCLUSION_LIST:"bypass_log_exclusion_list",LOG_LEVEL:"log_level",V1_PLUGINS:"v1_plugins",SCREENSHARE_DTX:"screenshare_dtx",SCREENSHARE_PRIORITY:"screenshare_priority",SCREENSHARE_MIN_BITRATE:"screenshare_minbitrate",SCREENSHARE_SIMULCAST:"screenshare_simulcast",DISABLE_WEBCAM_LAYERS_ON_SCREENSHARE:"disable_webcam_layers_on_screenshare",SCREENSHARE_FORCE_GOOG_CONFERENCE:"screenshare_force_goog_conference",LIVESTREAM:"feat_livestream",FETCH_RETRY:"fetch_retry",DISABLE_WEBCAM_SIMULCAST:"webcore_disable_webcam_simulcast",OVERRIDE_WEBCAM_SIMULCAST:"override_webcam_simulcast",SOCKET_POLLING:"socket_polling",FEAT_PAGINATED_CHAT:"feat_paginated_chat",VAL_MIN_FRAMERATE:"val_min_framerate",SCREEENSHARE_ERR_HACK:"screenshare_err_hack",SCREEENSHARE_CONSTRAINTS_RETRY:"screenshare_constraints_retry",TROUBLESHOOTING:"feat_troubleshooting",VIDEO_CONSTRAINTS:"video_constraints",SCREENSHARE_CONSTRAINTS:"screenshare_constraints",FEAT_CHAT_SDK:"feat_chat_sdk",FEAT_CHAT_SDK_SEARCH:"chat_search",OBS_QUALITY:"obs_quality",ALLOW_SAFARI_MEDIA_MIDDLEWARES:"allow_safari_media_middlewares",DYNAMIC_VIDEO_QUALITY:"dynamic_video_quality",EXP_RESHARE:"exp_reshare",LEAVE_STAGE_ON_END:"leave_stage_on_end",SKIP_SETTING_IN_USE_DEVICE:"skip_setting_in_use_device",PRECALL_BANDWIDTH_TEST:"precall_bandwidth_test",CONSUMER_BIND_NO_RETRY:"consumer_bind_no_retry",DEBUG_SOCKET_JOIN:"debug_socket_join",FORCE_RELAY:"force_relay",FORCE_VIDEO_CODEC:"force_video_codec",USE_EXPERIMENTAL_SFU_HANDLER:"use_experimental_sfu_handler",TRACK_HINT:"track_hint",OVERRIDE_HIVE_SIMULCAST_DYNAMIC:"override_hive_simulcast_dynamic",PRECREATE_PRODUCERS:"precreate_producers",DISABLE_OPUS_DTX_CF:"disable_opus_dtx_cf",ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS:"enable_audio_activity_debug_logs"};function zc(t){const e={};return typeof(t==null?void 0:t.code)=="number"&&(e.code=t.code),typeof(t==null?void 0:t.code)=="string"&&(e.code=t.code.substring(0,100)),typeof(t==null?void 0:t.name)=="string"&&(e.name=t.name.substring(0,500)),typeof(t==null?void 0:t.message)=="string"&&(e.message=t.message.substring(0,500)),typeof(t==null?void 0:t.reason)=="string"&&(e.reason=t.reason.substring(0,500)),typeof(t==null?void 0:t.stack)=="string"&&(e.stack=t.stack.substring(0,500)),e}function b0(t){var e,r,i,s;const n=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((r=window.location.host)==null?void 0:r.includes("dyte.io")),o=!!((s=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&s.logs);return n||o}function w0(t,e){var r;if(t!=null&&t.getValue("flagsmith").hasFeature(Z.LOG_LEVEL)){let i=((r=t.getValue("flagsmith").getValue(Z.LOG_LEVEL))==null?void 0:r.toString())||"all";if(i=i.toLowerCase().trim(),i==="off")return!1;if(i!=="all"){const s=["debug","log","info","warn","error"],n=s.indexOf(e),o=s.indexOf(i);if(n<o)return!1}}return!0}function Cv(t,e,r={}){return Object.getOwnPropertyNames(t).forEach(i=>{var s;if([null,void 0,NaN].includes(t[i])||e&&(((s=e.match(/\./g))==null?void 0:s.length)||0)>=10)return;const n=e?`${e}.${i}`:i;typeof t[i]=="object"?Cv(t[i],n,r):["number","string","boolean"].includes(typeof t[i])&&(r[n]=t[i])}),r}function wm(t,e,r={},i=""){const s={};try{const n=JSON.stringify(r),o=JSON.parse(n),c=Cv(o,i),d=JSON.stringify(c);return JSON.parse(d)}catch(n){const o=zc(n);s[`${i}.error.message`]=o.message||"",s[`${i}.error.stack`]=o.stack||"",s[`${i}.error.reason`]=o.reason||"",s[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return s}const _0={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},ba={baseURL:"http://localhost:5000",createdAt:"2021-08-05T10:49:56.602Z",description:"Develop plugins locally",id:"09259e3b-7be8-46f6-9801-106bf1866e1c",name:"Localhost Dev",organizationId:"4ad15a19-80e2-4105-bf43-48039fd2963e",picture:"https://dyte-uploads.s3.ap-south-1.amazonaws.com/dyte.png",private:!1,published:!0,staggered:!1,tags:["#localhost","#dev"],type:"self_hosted",updatedAt:"2021-08-05T10:50:07.681Z"},I0={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,connectedMeetings:!0,devTools:{logs:!1}};function ea(t,e){const r=t.getValue("overrides");return r&&r[e]?r[e]:!1}function C0({baseURI:t}){return t.includes("preprod.dyte")||t.includes("preprod.realtime")?Vo.PREPROD:t.includes("devel.dyte")||t.includes("devel.realtime")?Vo.DEVEL:Vo.PROD}function Ds({servicePrefix:t,baseURI:e}){return e.includes("preprod.realtime.cloudflare.com")||e.includes("devel.realtime.cloudflare.com")?`${t}-${e}`:`${t}.${e}`}function Pv(t){const e=t.getValue("baseURI");return{location:Ds({servicePrefix:"location",baseURI:e}),locationLegacy:Ds({servicePrefix:"location-legacy",baseURI:e}),daCollector:Ds({servicePrefix:"da-collector",baseURI:e.replace("realtime.cloudflare.com","dyte.io")})}}const P0='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m16.242 2.932 4.826 4.826a2.75 2.75 0 0 1-.715 4.404l-4.87 2.435a.75.75 0 0 0-.374.426l-1.44 4.166a1.25 1.25 0 0 1-2.065.476L8.5 16.561 4.06 21H3v-1.06l4.44-4.44-3.105-3.104a1.25 1.25 0 0 1 .476-2.066l4.166-1.44a.75.75 0 0 0 .426-.373l2.435-4.87a2.75 2.75 0 0 1 4.405-.715Zm3.766 5.886-4.826-4.826a1.25 1.25 0 0 0-2.002.325l-2.435 4.871a2.25 2.25 0 0 1-1.278 1.12l-3.789 1.31 6.705 6.704 1.308-3.789a2.25 2.25 0 0 1 1.12-1.277l4.872-2.436a1.25 1.25 0 0 0 .325-2.002Z" fill="currentColor"/></svg>',R0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 12.02c0 1.06.2 2.1.6 3.08l.6 1.42c.22.55.64 1.01 1.17 1.29.27.14.56.21.86.21h2.55c.77 0 1.49-.41 1.87-1.08.5-.87 1.02-1.7 1.72-2.43l1.32-1.39c.44-.46.97-.84 1.49-1.23l.59-.45a.6.6 0 0 0 .23-.47c0-.75-.54-1.57-1.22-1.79a3.34 3.34 0 0 0-2.78.29V4.5a1.5 1.5 0 0 0-2.05-1.4 1.5 1.5 0 0 0-2.9 0A1.5 1.5 0 0 0 6 4.5v.09A1.5 1.5 0 0 0 4 6v6.02ZM8 4.5v4a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0v5a.5.5 0 0 0 1 0v-4a.5.5 0 0 1 1 0v6a.5.5 0 0 0 .85.37h.01c.22-.22.44-.44.72-.58.7-.35 2.22-.57 2.4.5l-.53.4c-.52.4-1.04.78-1.48 1.24l-1.33 1.38c-.75.79-1.31 1.7-1.85 2.63-.21.36-.6.58-1.01.58H7.23a.87.87 0 0 1-.4-.1 1.55 1.55 0 0 1-.71-.78l-.59-1.42a7.09 7.09 0 0 1-.53-2.7V6a.5.5 0 0 1 1 0v3.5a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0Z" fill="currentColor"></path></svg>',yc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(s=>{s(t)});const e=new Blob([t],{type:"image/svg+xml"}),r=new Image,i=window.URL.createObjectURL(e);return new Promise((s,n)=>{r.onload=()=>{s(r),window.URL.revokeObjectURL(i)},r.onerror=()=>{n(),window.URL.revokeObjectURL(i)},r.src=i})},Rv=class{constructor(){p(this,"logsCache",[]),p(this,"logsProcessorTimer"),p(this,"tracingEnabled",!0),p(this,"initialized",!1),p(this,"logsProcessingInterval",7e3),p(this,"logExclusionList",["message","websocket/message","roomMessage","websocket/room-message","websocket/room-legacy-mode","chatMessage","websocket/new-chat-message","websocket/no-active-speaker","websocket/selected-peers","websocket/active-speaker","ping","websocket/new-consumer","websocket/producer-score","websocket/consumer-score","websocket/plugin-event","websocket/plugin-data","websocket/plugin-internal-data"]),p(this,"meetingMetadata",{})}get logsEndpoint(){const t=ni.getContext(this.meetingMetadata.peerId);return`https://${Ds({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}resetPeerId(t){this.meetingMetadata.peerId=t}init(t,e,r){this.tracingEnabled=!0,this.initialized=!1,this.logsCache=[];const i=t.getValue("peerId");this.meetingMetadata=e,this.tracingEnabled=r,this.meetingMetadata.peerId=i,this.meetingMetadata.sdkVersion=t.getValue("sdkVersion"),this.meetingMetadata.deviceInfo=Ie.getDeviceInfo(),this.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,this.logsProcessorTimer=setInterval(this.processCachedLogs.bind(this),this.logsProcessingInterval),r&&(this.initialized=!0)}static trace(t,e=void 0){return(r,i,s)=>{const n=s.value;return s.value=function(...o){var c;const d=this==null?void 0:this.telemetry;if(!d||!d.initialized||navigator.isReactNative||!d.tracingEnabled||(c=ni.getContext(d.meetingMetadata.peerId))!=null&&c.getValue("flagsmith").hasFeature(Z.SKIP_OTEL_TRACES))return n.apply(this,o);d.addLogInCurrentSpan("info",t,e);const l=performance.now(),h=n.apply(this,o);return Promise.resolve(h).then(()=>{const m=performance.now();m-l>10&&d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:m-l,country:Rv.location.country})}).catch(()=>{const m=performance.now();d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:m-l})}),h},s}}injectContext(t){var e;const r=Ns().replace(/-/g,"").substring(0,16),i=(e=this.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${r}-01`}addLogInCurrentSpan(t,e,r={},i=!1){r!=null&&r.error&&Object.assign(r,{error:zc(r.error)});const s=ni.getContext(this.meetingMetadata.peerId);if(b0(s)&&(E0(r)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,r)),!!w0(s,t))try{const n=wm(s,e,r,"metadata"),o=new Date,c=q(V({message:e,level:t},n),{loggedAt:o.toISOString(),loggedAtTzOffset:o.getTimezoneOffset()});i?this.sendOtelLogsToNewRelic([c]):this.logsCache.push(c)}catch(n){this.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:zc(n)})}}sendOtelLogsToNewRelic(t){const e=ni.getContext(this.meetingMetadata.peerId);fetch(this.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:wm(e,"sendOtelLogsToNewRelic",this.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(r=>{this.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:zc(r)}),this.logsCache.push(...t)})}processCachedLogs(){const t=this.logsCache.splice(0,25);t!=null&&t.length&&this.sendOtelLogsToNewRelic(t)}destruct(){clearInterval(this.logsProcessorTimer),this.processCachedLogs()}};let k=Rv;p(k,"location",{country:void 0});function M0(t){const e=V({},t),r=new Map,i=(o,c)=>(r.has(o)||r.set(o,new Set),r.get(o).add(c),()=>{var d;return(d=r.get(o))==null?void 0:d.delete(c)}),s=(o,c)=>{var d;(d=r.get(o))==null||d.delete(c)},n=o=>{var c;(c=r.get(o))==null||c.forEach(d=>{try{d(e[o])}catch{}})};return{subscribe:i,unsubscribe:s,notify:n,setValue:(o,c,d=!0)=>{e[o]=c,d&&n(o)},getValue:o=>e[o],getAllValues:()=>e}}class A0{constructor(){p(this,"contexts",new Map),p(this,"mostRecentPeerId",null)}createContext(e,r){if(this.contexts.has(e))return this.contexts.get(e);const i=new k,s=new Ev;this.contexts.set(e,M0(r)),this.contexts.get(e).setValue("peerSessionStore",new t_(s));const n=new qf;return n.setMaxListeners(50),this.contexts.get(e).setValue("logger",s),this.contexts.get(e).setValue("telemetry",i),this.contexts.get(e).setValue("callstats",n),this.contexts.get(e).setValue("flagsmith",Hw()),this.mostRecentPeerId=e,this.contexts.get(e)}remapContext(e,r){const i=r.getValue("peerId");i!==e&&(r.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,r),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ni=new A0,D0={"00":"DyteClient","01":"Controller","02":"RoomNodeClient","03":"HiveNodeClient","04":"SocketService","05":"Chat","06":"Plugin","07":"Polls","08":"Meta","09":"Preset",10:"Recording",11:"Self",12:"Participant",13:"Spotlight",14:"Remote Request",15:"Webinar",16:"LocalMediaHandler",17:"End-End Encryption",18:"AI",19:"Livestream",20:"Stage"},Yc={"0000":"Internal exception.","0001":"Failed to initialize.","0002":"Failed to join room.","0003":"Failed to leave room.","0004":"Invalid auth token","0010":"Browser not supported","0011":"HTTP Network Error","0012":"Websocket Network Error","0013":"Rate Limited","0100":"Internal exception","0101":"Permission denied","0102":"Prerequisite module missing","0200":"Internal exception.","0300":"Internal exception","0400":"Internal exception","0404":"Missing prerequisites to establish a websocket connection","0500":"Internal exception","0501":"Permission denied.","0502":"Invalid message body.","0503":"Text Message is too large","0504":"Message not found by the given id","0505":"Action not permitted without joining room","0506":"Message search is disabled","0510":"Invalid channel name.","0600":"Internal exception","0601":"Permission denied.","0602":"Auth token not set for plugin","0603":"Iframe was not provided","0700":"Internal exception","0705":"Action not permitted without joining room","0800":"Internal exception","0801":"Permission denied","0900":"Internal exception","0904":"Could not load preset",1e3:"Internal exception",1001:"Permission denied",1004:"Could not find specified recording",1005:"Action not permitted in given recording state",1100:"Internal exception",1101:"Permission denied",1102:"Unsupported",1103:"Name cannot be empty",1104:"No device selected while calling meeting.self.setDevice",1105:"Action not permitted without joining room",1106:"Can't set currently used device",1200:"Internal exception",1201:"Permission denied",1202:"Invalid page number was requested",1203:"Invalid participant count per page was requested",1204:"No participants exists with the given UserIds",1205:"Action not permitted without joining room",1206:"Manual Subscription Mode was not ACTIVATED",1207:"Invalid view mode",1208:"Manual Subscription not enabled for organization",1209:"Broadcast message type must be a non-empty string",1300:"Internal exception",1400:"Internal exception",1402:"No existing remote requests",1403:"No peer exists with given id",1500:"Internal exception",1600:"Internal exception",1601:"Failed to get audio track",1602:"Failed to get video track",1603:"Incorrect device",1604:"Failed to change device",1605:"Failed to get audio & video track",1606:"No audio input devices are available",1607:"No video input devices are available",1608:"No audio output devices (speakers) are available",1609:"Failed to fetch list of media devices",1610:"No media track exists",1611:"Failed to unmute track",1612:"Failed to get screenshare tracks",1701:"Crypto error",1800:"Internal exception",1801:"Can't fetch transcript file",1900:"Internal exception",1901:"Permission denied.",1902:"Livestream that has not yet started, can't be stopped",2e3:"Internal exception",2001:"Permission denied",2002:"Unsupported",2003:"Stage is disabled",2004:"Method not implemented",2005:"Action not permitted without joining room",2006:"Action not permitted in current stage status",9900:"Internal exception"};Object.keys(Yc).forEach(t=>{Yc[t]=`{${D0[t.slice(0,2)]}} ${Yc[t]}`});class I extends Error{constructor(e,r,i=void 0,s=!1){super(e),p(this,"code"),this.code=r,this.name="DyteError",this.message=`[ERR${this.code}]: ${Yc[this.code]}
13
13
  ${this.message}`;try{let n=s&&!!i;r&&r.endsWith("00")&&i&&(n=!0),n&&i.error("DyteError",{error:{message:this.message,name:this.name,code:r}});const o=ni.getContext(ni.getMostRecentPeerId());if(o){const c=o.getValue("onError");try{c(this)}catch{}}typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("dyteError",{detail:this}))}catch{}}}function Sc(t,e,r,i){if(i instanceof I)throw i;if(i instanceof e){const s=new I(i.message,r);throw s.stack=i.stack,s}else throw i}function _m(t,e,r){if(!t.value){const s=t.get,n=t.set;return s&&(t.get=function(){try{return s.apply(this)}catch(o){Sc(this,e,r,o)}}),n&&(t.set=function(o){try{return n.apply(this,[o])}catch(c){Sc(this,e,r,c)}}),t}const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{Sc(this,e,r,o)}):n}catch(n){Sc(this,e,r,n)}},t}function O0(t,e){return(r,i,s)=>{if(s)return _m(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);(o.value instanceof Function||o.get instanceof Function||o.set instanceof Function)&&Object.defineProperty(r.prototype,n,_m(o,t,e))}}}const gt=t=>O0(Error,t);function N0(t){let e=0,r,i;if(!t)return e;for(r=0;r<t.length;r+=1)i=t.charCodeAt(r),e=(e<<5)-e+i,e|=0;return Math.abs(e)%100+1}function V0(){Ie.isElectron()&&window.dyteElectronGetDisplayMediaSource&&(navigator.mediaDevices.getDisplayMedia=()=>u(this,null,function*(){const t=yield window.dyteElectronGetDisplayMediaSource({types:["window","screen"]});let e=[];if(t&&(Array.isArray(t)?e=t:e=[t]),!(e!=null&&e.length))throw new Error("Couldn't find any media source for screen share.");let r=e.find(s=>{var n;return(n=s.id)==null?void 0:n.includes("screen")});r=r!=null?r:e[0];const i={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r.id}}};return yield navigator.mediaDevices.getUserMedia(i)}))}var P=(t=>(t.NEW_PRODUCER="NEW_PRODUCER",t.PRODUCER_TRACK_ENDED="PRODUCER_TRACK_ENDED",t.ROOM_NODE_CONNECTION_ERROR="ROOM_NODE_CONNECTION_ERROR",t.SOCKET_SERVICE_ROOM_JOINED="SOCKET_SERVICE_ROOM_JOINED",t.SOCKET_SERVICE_RECONNECTED="SOCKET_SERVICE_RECONNECTED",t.SOCKET_SERVICE_DISCONNECTED="SOCKET_SERVICE_DISCONNECTED",t.SOCKET_SERVICE_FAILED="SOCKET_SERVICE_FAILED",t.SOCKET_STATE_UPDATE="SOCKET_STATE_UPDATE",t.ROOM_NODE_RECONNECTED="ROOM_NODE_RECONNECTED",t.ROOM_NODE_DISCONNECTED="ROOM_NODE_DISCONNECTED",t.ROOM_NODE_FAILED="ROOM_NODE_FAILED",t.TRANSPORT_STATE_UPDATE="TRANSPORT_STATE_UPDATE",t.PRODUCER_SCORE_UPDATE="PRODUCER_SCORE_UPDATE",t.CONSUMER_SCORE_UPDATE="CONSUMER_SCORE_UPDATE",t.PRODUCER_STATUS_UPDATE="PRODUCER_STATUS_UPDATE",t.CONSUMER_STATUS_UPDATE="CONSUMER_STATUS_UPDATE",t.LOW_PRODUCER_SCORE="LOW_PRODUCER_SCORE",t.LOW_CONSUMER_SCORE="LOW_CONSUMER_SCORE",t.MEDIA_PERMISSION_ERROR="MEDIA_PERMISSION_ERROR",t.MEDIA_PERMISSION_UPDATE="MEDIA_PERMISSION_UPDATE",t.WAITLISTED="WAIT_LISTED",t.MESSAGE="websocket/message",t.ROOM_MESSAGE="websocket/room-message",t.PEER_JOINED_INTERNAL="peer/joined-internal",t.PEER_CLOSED="websocket/peer-closed",t.CONSUMER_CLOSED="websocket/consumer-closed",t.CONSUMER_PAUSED="websocket/consumer-paused",t.CONSUMER_RESUMED="websocket/consumer-resumed",t.PRODUCER_CLOSED="websocket/producer-closed",t.NEW_CONSUMER="websocket/new-consumer",t.PRODUCER_SCORE="websocket/producer-score",t.CONSUMER_SCORE="websocket/consumer-score",t.PRODUCER_TOGGLE="hive/producer-toggle",t.CONSUMER_TOGGLE="hive/consumer-toggle",t.SELECTED_PEERS_DIFF="hive/selected-peers-diff",t.UPDATE_ACTIVE="media/update-active",t.RESET_PRODUCER_STATE="hive/reset-producer-state",t.CF_TRANSPORT_STATE_CHANGED="cf/transport-state-changed",t.CF_ROOM_REJOINING="cf/room-rejoining",t.CF_ROOM_REJOIN_FAILED="cf/room-rejoining-failed",t.CF_ROOM_REJOINED="cf/room-rejoined",t.CF_TRANPSORT_RECONNECTING="cf/transport-reconnecting",t.ROOM_STATE="sockethub/room-state",t.PEER_DISPLAY_NAME_CHANGED="hive/display-name-changed",t.GET_STAGE_REQUESTS="GET_STAGE_REQUESTS",t.UPDATE_STAGE_REQUESTS="UPDATE_STAGE_REQUESTS",t.KICK_PEER="KICK_PEER",t.UPDATE_PEER_STAGE_STATUS="UPDATE_PEER_STAGE_STATUS",t.JOIN_MEDIA_ROOM="JOIN_MEDIA_ROOM",t.LEAVE_MEDIA_ROOM="LEAVE_MEDIA_ROOM",t.PIP_HANGUP="PIP_HANGUP",t.E2EE_ACTIVE_PRODUCER="E2EE_ACTIVE_PRODUCER",t.E2EE_INACTIVE_PRODUCER="E2EE_INACTIVE_PRODUCER",t.E2EE_ACTIVE_CONSUMER="E2EE_ACTIVE_CONSUMER",t.E2EE_INACTIVE_CONSUMER="E2EE_INACTIVE_CONSUMER",t.SOCKET_PEERS="SOCKET_PEERS",t.UPDATE_PERMISSIONS="UPDATE_PERMISSIONS",t.MAX_SPATIAL_LAYER_CHANGE="MAX_SPATIAL_LAYER_CHANGE",t.MUTE_SELF="MUTE_SELF",t.MUTE_SELF_VIDEO="MUTE_SELF_VIDEO",t))(P||{});class ia extends mt.EventEmitter{constructor(e){super(),p(this,"logger"),this.logger=e,super.setMaxListeners(25)}emit(e,...r){return super.emit("*",e,...r),super.emit(e,...r)}on(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.on(e,r)}addListener(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.addListener(e,r)}off(e,r){return super.off(e,r)}once(e,r){return super.once(e,r)}prependListener(e,r){return super.prependListener(e,r)}prependOnceListener(e,r){return super.prependOnceListener(e,r)}removeListener(e,r){return super.removeListener(e,r)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}class Xt extends mt.EventEmitter{constructor(e){super(),p(this,"logger"),this.logger=e,super.setMaxListeners(25)}emit(e,...r){return super.emit("*",e,...r),super.emit(e,...r)}on(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.on(e,r)}addListener(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.addListener(e,r)}off(e,r){return super.off(e,r)}once(e,r){return super.once(e,r)}prependListener(e,r){return super.prependListener(e,r)}prependOnceListener(e,r){return super.prependOnceListener(e,r)}removeListener(e,r){return super.removeListener(e,r)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}function L0(t,e=2){return t.replace(/[^\u00BF-\u1FFF\u2C00-\uD7FF\w\s]/g,"").trim().split(/\s+/).slice(0,e).map(r=>r.charAt(0)).join("").toUpperCase()}const Im=1080,Cm=1920,x0=(t,e,r,i,s,n)=>{let o=.5,c=.5;const d=s,l=n,h=Math.min(r/d,i/l);let m=d*h,v=l*h,S,T,M,b,R=1;return m<r&&(R=r/m),Math.abs(R-1)<1e-14&&v<i&&(R=i/v),m*=R,v*=R,M=d/(m/r),b=l/(v/i),S=(d-M)*o,T=(l-b)*c,S<0&&(S=0),T<0&&(T=0),M>d&&(M=d),b>l&&(b=l),[S,T,M,b,t,e,r,i]};var gr,vn,kt,fr,Fe,Or,wi,Vt,Je,so,no,_i,ao;const Mv=class extends Xt{constructor(t,e,r,i){const s=t.getValue("logger");super(s),g(this,gr,void 0),g(this,vn,void 0),g(this,kt,void 0),g(this,fr,void 0),g(this,Fe,{height:Im,width:Cm}),g(this,Or,{brand:"#2160FD",background:"#141414",text:"#000000",videoBackground:"#191919",textOnBrand:"#EEEEEE"}),g(this,wi,void 0),g(this,Vt,{}),g(this,Je,void 0),g(this,so,void 0),g(this,no,void 0),g(this,_i,void 0),g(this,ao,!1),p(this,"cleanupEventListeners",()=>{a(this,vn).unsubscribe("stageStatus",this.handlePipMediaControls),a(this,Je).removeListener("videoUpdate",this.onSelfVideoUpdateListener),a(this,Je).removeListener("audioUpdate",this.onSelfAudioUpdateListener),a(this,Je).removeListener("roomLeft",()=>this.disable())}),p(this,"enablePipMediaControls",()=>{this.mountAudioEvents(),this.mountVideoEvents()}),p(this,"onSelfVideoUpdateListener",({videoEnabled:n})=>{this.updateMediaSession("CAMERA",n)}),p(this,"onSelfAudioUpdateListener",({audioEnabled:n})=>{this.updateMediaSession("MIC",n)}),p(this,"handlePipMediaControls",n=>{n==="ON_STAGE"?this.enablePipMediaControls():this.unmountEvents()}),p(this,"eventCallback",n=>{n==="CAMERA"&&(a(this,Je).videoEnabled?a(this,Je).disableVideo():a(this,Je).enableVideo(),this.emit("cameraToggled")),n==="MIC"&&(a(this,Je).audioEnabled?a(this,Je).disableAudio():a(this,Je).enableAudio(),this.emit("micToggled")),n==="END"&&(a(this,vn).getValue("peerSessionStore").emit(P.PIP_HANGUP),this.cleanupEventListeners(),this.emit("hangup"),this.cleanup())}),p(this,"unmountEvents",()=>{navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("togglemicrophone",void 0),navigator.mediaSession.setActionHandler("togglecamera",void 0))}),p(this,"animate",()=>{if(!this.isActive&&a(this,_i)==="active"){this.disable(!0);return}a(this,Vt)!==void 0&&this.paintCanvas(),a(this,wi)!==void 0&&f(this,wi,requestAnimationFrame(()=>this.animate()))}),p(this,"disable",(n=!1)=>{f(this,_i,"idle"),this.cleanupEventListeners(),cancelAnimationFrame(a(this,wi)),n!==!0&&document.body.removeChild(a(this,kt)),f(this,wi,void 0),document.pictureInPictureElement&&document.exitPictureInPicture()}),f(this,vn,t),f(this,_i,"idle"),f(this,Je,e),f(this,Or,{brand:e.config.designTokens.colors.brand[500],background:e.config.designTokens.colors.background[1e3],text:e.config.designTokens.colors.text,videoBackground:e.config.designTokens.colors.videoBg,textOnBrand:e.config.designTokens.colors.textOnBrand}),r&&this.setupIcon("pin",r),i&&this.setupIcon("handRaise",i)}static _init(t,e){return u(this,null,function*(){let r,i;try{r=yield yc(P0),i=yield yc(R0)}catch{}return new Mv(t,e,r,i)})}setupIcon(t,e){return u(this,null,function*(){switch(t){case"handRaise":f(this,no,e);break;case"pin":f(this,so,e);break}})}overrideIcon(t,e){return u(this,null,function*(){switch(t){case"handRaise":f(this,no,yield yc(e));break;case"pin":f(this,so,yield yc(e));break}})}constructImage(t){const e=new Image,r=new Blob([t],{type:"image/svg+xml"}),i=window.URL.createObjectURL(r);return new Promise(s=>{e.onload=()=>{s(e),window.URL.revokeObjectURL(i)},e.src=i})}createVideoContainer(){f(this,kt,document.createElement("div")),a(this,kt).style.width="0.1px",a(this,kt).style.height="0.1px",a(this,kt).style.overflow="hidden",a(this,kt).style.position="absolute",a(this,kt).style.bottom="0",a(this,kt).style.right="0",a(this,kt).style.opacity="0",a(this,kt).appendChild(a(this,fr))}setupEventListeners(){a(this,vn).subscribe("stageStatus",this.handlePipMediaControls),a(this,Je).addListener("videoUpdate",this.onSelfVideoUpdateListener),a(this,Je).addListener("audioUpdate",this.onSelfAudioUpdateListener),a(this,Je).addListener("roomLeft",()=>this.disable())}createCanvas(){const t=document.createElement("canvas");t.height=a(this,Fe).height,t.width=a(this,Fe).width,f(this,gr,t)}setupMediaSessionEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("hangup",()=>{this.eventCallback("END")}),this.mountAudioEvents(),this.mountVideoEvents())}mountAudioEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setMicrophoneActive===void 0||a(this,Je).permissions.canProduceAudio&&navigator.mediaSession.setActionHandler("togglemicrophone",()=>{this.eventCallback("MIC")})}mountVideoEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||a(this,Je).permissions.canProduceVideo&&navigator.mediaSession.setActionHandler("togglecamera",()=>{this.eventCallback("CAMERA")})}getSources(){const t=Object.values(a(this,Vt)).reduce((e,r)=>(e[r.pinned?"pinned":"regular"].push(r),e),{pinned:[],regular:[]});return[...t.pinned,...t.regular]}drawEmptyTile(t,e,r,i){if(a(this,gr)===void 0)return;const s=a(this,gr).getContext("2d"),n=a(this,gr).width,o=0,c=0,d=e-o*2,l=r-o*2,h=Math.floor(n/d),m=Math.floor(t/h),v=t%h*(d+o)+o,S=m*(l+o)+o,{displayText:T,image:M}=i!=null?i:{};s.fillStyle=T||M?a(this,Or).videoBackground:a(this,Or).background,s.strokeStyle=a(this,Or).brand,s.beginPath(),s.moveTo(v+c,S),s.arcTo(v+d,S,v+d,S+c,c),s.arcTo(v+d,S+l,v+d-c,S+l,c),s.arcTo(v,S+l,v,S+l-c,c),s.arcTo(v,S,v+c,S,c),s.closePath(),s.fill(),s.stroke();const b=d/6,R=d/2+v,j=l/2+S;s.save(),(T||M)&&(s.beginPath(),s.arc(R,j,b,0,Math.PI*2),s.fillStyle=a(this,Or).brand,s.fill(),M?(s.clip(),s.drawImage(M,R-b,j-b,b*2,b*2),s.restore()):T&&(s.fillStyle=a(this,Or).textOnBrand,s.font=`${b/2}px sans-serif`,s.textAlign="center",s.textBaseline="middle",s.fillText(T,R,j)),this.drawIcons(i,v,S,Math.max(d,l)))}drawIcons(t,e,r,i){const s=Math.min(Math.max(i*.15,100),200),n=s*.2,o=s*.2;let c=e+n;const d=r+n,l=h=>{const m=a(this,gr).getContext("2d");m.save(),m.fillStyle=a(this,Or).background,m.beginPath(),m.moveTo(c+o,d),m.arcTo(c+s,d,c+s,d+o,o),m.arcTo(c+s,d+s,c+s-o,d+s,o),m.arcTo(c,d+s,c,d+s-o,o),m.arcTo(c,d,c+o,d,o),m.closePath(),m.fill(),typeof h=="string"?(m.font=`${s/1.5}px sans-serif`,m.fillStyle=a(this,Or).text,m.textAlign="center",m.textBaseline="top",m.fillText(h,s/2+c,d+n)):m.drawImage(h,c+n,d+n,s-n*2,s-n*2),c+=s+n,m.restore()};t.pinned&&l(a(this,so)),t.handRaised&&l(a(this,no))}drawTile(t,e,r){var i,s;if(a(this,gr)===void 0)return;const n=a(this,gr).getContext("2d"),o=this.getSources();let c=0,d=0;for(;c<a(this,Fe).height-5;){let l=0;for(;l<a(this,Fe).width-5&&d<r;){if((i=o[d])!=null&&i.enabled){const h=o[d].element,[m,v,S,T,M,b,R,j]=x0(l,c,t,e,h.videoWidth,h.videoHeight);(s=h==null?void 0:h.classList)!=null&&s.contains("mirror")?(n.save(),n.scale(-1,1),n.drawImage(h,m,v,S,T,-1*M,b,-1*R,j),n.restore()):n.drawImage(h,m,v,S,T,M,b,R,j),this.drawIcons(o[d],M,b,Math.max(R,j))}else this.drawEmptyTile(d,t,e,o[d]);d+=1,l+=t}c+=e}}calcGridElemSize(t){switch(t){case 0:case 1:return[a(this,Fe).width,a(this,Fe).height];case 2:return[Math.floor(a(this,Fe).width/2),a(this,Fe).height];case 3:case 4:return[Math.floor(a(this,Fe).width/2),Math.floor(a(this,Fe).height/2)];case 5:case 6:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/2)];case 7:case 8:case 9:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/3)];default:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/2)]}}paintCanvas(){let t=this.getSources().length;t!==1&&(t=t%2>0?t+1:t);const[e,r]=this.calcGridElemSize(t);this.drawTile(e,r,t)}isSupported(){var t;return!!window.chrome&&document.pictureInPictureEnabled&&((t=a(this,Je).config)==null?void 0:t.viewType)!=="LIVESTREAM"}get isActive(){return document.pictureInPictureElement!==null}cleanup(){if(f(this,ao,!1),this.isSupported()&&document.exitPictureInPicture!==void 0&&document.pictureInPictureElement!==null&&document.exitPictureInPicture(),a(this,kt))try{document.body.removeChild(a(this,kt))}catch{}this.removeAllSources(),f(this,gr,void 0),f(this,fr,void 0),f(this,wi,void 0)}init({height:t,width:e}={}){if(!this.isSupported())throw this.logger.error("DytePip.unsupported"),new Error("Picture-in-picture is not available in this environment");if(a(this,ao))return;f(this,ao,!0),this.createCanvas(),this.setupMediaSessionEvents();const r=document.createElement("video");f(this,Fe,{height:t!=null?t:Im,width:e!=null?e:Cm}),r.height=a(this,Fe).height,r.width=a(this,Fe).width,r.autoplay=!0,r.muted=!0,r.srcObject=a(this,gr).captureStream(24),f(this,fr,r),a(this,fr).onloadedmetadata=()=>{try{this.emit("pipStarted"),a(this,fr).onleavepictureinpicture=()=>{this.emit("pipEnded")}}catch{this.emit("pipEnded")}},this.createVideoContainer(),this.paintCanvas()}updateMediaSession(t,e){navigator.mediaSession!==void 0&&(t==="CAMERA"&&navigator.mediaSession.setCameraActive!==void 0&&navigator.mediaSession.setCameraActive(e),t==="MIC"&&navigator.mediaSession.setMicrophoneActive!==void 0&&navigator.mediaSession.setMicrophoneActive(e))}enableSource(t){a(this,Vt)[t]!==void 0&&(a(this,Vt)[t].enabled=!0)}disableSource(t){a(this,Vt)[t]!==void 0&&(a(this,Vt)[t].enabled=!1)}generateAvatar(t,e){return u(this,null,function*(){if(!e)return;const r=new Image;try{const i=yield(yield fetch(e)).blob(),s=window.URL.createObjectURL(i);r.onload=()=>{this.updateSource(t,{image:r}),window.URL.revokeObjectURL(s)},r.src=s}catch(i){this.logger.error("DytePip::GenerateAvatar",{error:i})}})}addSource(t,e,r,i=!1,s=void 0,n=void 0,o=!1){this.logger.debug("DytePIP::AddSource",{pip:{id:t,handRaised:o}}),a(this,Vt)[t]={id:t,element:e,enabled:r,pinned:i,displayText:s?L0(s):void 0,imageUrl:n,handRaised:o},n&&this.generateAvatar(t,n)}updateSource(t,e){this.logger.info("DytePIP::UpdateSource",{pip:{id:t,handRaised:e.handRaised}});const r=a(this,Vt)[t];r&&(a(this,Vt)[t]=V(V({},r),e))}removeSource(t){delete a(this,Vt)[t]}removePinnedSource(){Object.values(a(this,Vt)).forEach(t=>{t.pinned&&this.removeSource(t.id)})}removeAllSources(){f(this,Vt,{})}enable(){f(this,_i,"activating"),this.setupEventListeners(),this.updateMediaSession("CAMERA",a(this,Je).videoEnabled),this.updateMediaSession("MIC",a(this,Je).audioEnabled),document.body.appendChild(a(this,kt)),f(this,wi,requestAnimationFrame(()=>this.animate())),a(this,fr).onloadedmetadata=()=>{a(this,fr).requestPictureInPicture().then(()=>{f(this,_i,"active")})},a(this,fr).readyState===4&&a(this,fr).requestPictureInPicture().then(()=>{f(this,_i,"active")})}};let U0=Mv;gr=new WeakMap,vn=new WeakMap,kt=new WeakMap,fr=new WeakMap,Fe=new WeakMap,Or=new WeakMap,wi=new WeakMap,Vt=new WeakMap,Je=new WeakMap,so=new WeakMap,no=new WeakMap,_i=new WeakMap,ao=new WeakMap;var di;(function(t){t[t.PUBLISHER=0]="PUBLISHER",t[t.SUBSCRIBER=1]="SUBSCRIBER"})(di||(di={}));var Wr;(function(t){t[t.AUDIO=0]="AUDIO",t[t.VIDEO=1]="VIDEO"})(Wr||(Wr={}));class F0 extends y{constructor(){super("media.Codec",[{no:1,name:"channels",kind:"scalar",opt:!0,T:5},{no:2,name:"clock_rate",kind:"scalar",T:5},{no:3,name:"mime_type",kind:"scalar",T:9},{no:4,name:"sdp_fmtp_line",kind:"scalar",opt:!0,T:9},{no:5,name:"payload_type",kind:"scalar",opt:!0,T:13}])}}const Av=new F0;class B0 extends y{constructor(){super("media.HeaderExtension",[{no:1,name:"direction",kind:"scalar",opt:!0,T:9},{no:2,name:"uri",kind:"scalar",T:9}])}}const W0=new B0;class j0 extends y{constructor(){super("media.Fingerprint",[{no:1,name:"algorithm",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}])}}new j0;class H0 extends y{constructor(){super("media.SessionDescription",[{no:1,name:"target",kind:"enum",T:()=>["media.Target",di]},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"sdp",kind:"scalar",T:9}])}}const Pr=new H0;class G0 extends y{constructor(){super("media.ProducerPayload",[{no:1,name:"kind",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8},{no:4,name:"msid",kind:"scalar",T:9},{no:5,name:"app_data",kind:"scalar",opt:!0,T:9},{no:6,name:"mime_type",kind:"scalar",opt:!0,T:9}])}}const q0=new G0;class $0 extends y{constructor(){super("media.CreateTransportRequest",[{no:1,name:"consuming",kind:"scalar",T:8},{no:2,name:"force_tcp",kind:"scalar",opt:!0,T:8},{no:3,name:"description",kind:"message",T:()=>Pr},{no:4,name:"private_ice",kind:"scalar",opt:!0,T:8},{no:5,name:"producers",kind:"message",repeat:1,T:()=>q0}])}}const J0=new $0;class K0 extends y{constructor(){super("media.AudioActivityRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"energy",kind:"scalar",T:5},{no:3,name:"silent",kind:"scalar",T:8}])}}const z0=new K0;class Y0 extends y{constructor(){super("media.CreateTransportResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:4,name:"producer_ids",kind:"scalar",repeat:2,T:9}])}}const Dv=new Y0;class Q0 extends y{constructor(){super("media.RenegotiateRequest",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr}])}}const X0=new Q0;class Z0 extends y{constructor(){super("media.RenegotiateResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr}])}}new Z0;class eI extends y{constructor(){super("media.NestedScore",[{no:1,name:"encoding_idx",kind:"scalar",T:5},{no:2,name:"rid",kind:"scalar",T:9},{no:3,name:"score",kind:"scalar",T:5},{no:4,name:"ssrc",kind:"scalar",T:3,L:0}])}}const tI=new eI;class rI extends y{constructor(){super("media.ProducerTrack",[{no:1,name:"track_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9},{no:3,name:"stream_id",kind:"scalar",T:9}])}}const iI=new rI;class sI extends y{constructor(){super("media.ProducerEntry",[{no:1,name:"producing_transport_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9}])}}new sI;class nI extends y{constructor(){super("media.ConsumerEntry",[{no:1,name:"consuming_transport_id",kind:"scalar",T:9},{no:2,name:"consumer_id",kind:"scalar",T:9}])}}new nI;class aI extends y{constructor(){super("media.ProducerState",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:()=>["media.ProducerKind",Wr]},{no:3,name:"pause",kind:"scalar",T:8},{no:4,name:"screen_share",kind:"scalar",T:8},{no:5,name:"app_data",kind:"scalar",opt:!0,T:9},{no:6,name:"producing_transport_id",kind:"scalar",opt:!0,T:9},{no:7,name:"mime_type",kind:"scalar",opt:!0,T:9},{no:8,name:"codec",kind:"message",T:()=>Av}])}}const nc=new aI;class oI extends y{constructor(){super("media.ConsumerState",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>nc},{no:3,name:"producer_track",kind:"message",T:()=>iI},{no:4,name:"error_code",kind:"scalar",opt:!0,T:9}])}}const cI=new oI;class dI extends y{constructor(){super("media.ProducerIdToConsumerMap",[{no:1,name:"map",kind:"map",K:9,V:{kind:"message",T:()=>cI}}])}}const Ov=new dI;class lI extends y{constructor(){super("media.PeerRtpCapabilitites",[{no:1,name:"sender",kind:"message",T:()=>Rm},{no:2,name:"receiver",kind:"message",T:()=>Rm}])}}const Nv=new lI;class uI extends y{constructor(){super("media.RtpCapability",[{no:1,name:"codecs",kind:"message",repeat:1,T:()=>Av},{no:2,name:"header_extensions",kind:"message",repeat:1,T:()=>W0}])}}const Pm=new uI;class hI extends y{constructor(){super("media.RtpCapabilitites",[{no:1,name:"audio",kind:"message",T:()=>Pm},{no:2,name:"video",kind:"message",T:()=>Pm}])}}const Rm=new hI;class pI extends y{constructor(){super("media.PreferredCodec",[{no:1,name:"audio",kind:"scalar",opt:!0,T:9},{no:2,name:"video",kind:"scalar",opt:!0,T:9}])}}const mI=new pI;class gI extends y{constructor(){super("media.Simulcast",[{no:1,name:"preferred_rid",kind:"scalar",opt:!0,T:9},{no:2,name:"priority_ordering",kind:"scalar",opt:!0,T:9},{no:3,name:"rid_not_available",kind:"scalar",opt:!0,T:9}])}}const Vv=new gI;class fI extends y{constructor(){super("media.edge.GeoLocation",[{no:1,name:"latitude",kind:"scalar",T:2},{no:2,name:"longitude",kind:"scalar",T:2},{no:3,name:"region",kind:"scalar",opt:!0,T:9}])}}const vI=new fI;class yI extends y{constructor(){super("media.edge.PeerJoinRequest",[{no:1,name:"display_name",kind:"scalar",opt:!0,T:9},{no:2,name:"prejoined",kind:"scalar",T:8},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:5,name:"preset",kind:"scalar",opt:!0,T:12},{no:6,name:"user_id",kind:"scalar",opt:!0,T:9},{no:7,name:"organization_id",kind:"scalar",opt:!0,T:9},{no:8,name:"location",kind:"message",T:()=>vI},{no:9,name:"capabilities",kind:"message",T:()=>Nv}])}}const SI=new yI;class EI extends y{constructor(){super("media.edge.PeerJoinCompleteRequest",[])}}const kI=new EI;class TI extends y{constructor(){super("media.edge.PeerLeaveRequest",[{no:1,name:"close_room",kind:"scalar",T:8}])}}const bI=new TI;class wI extends y{constructor(){super("media.edge.ConsumeMultipleProducerRequest",[{no:1,name:"producer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"paused",kind:"scalar",opt:!0,T:8}])}}new wI;class _I extends y{constructor(){super("media.edge.ConsumePeerRequest",[{no:1,name:"producing_peer_id",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",opt:!0,T:8},{no:3,name:"producer_id",kind:"scalar",opt:!0,T:9},{no:4,name:"preferred_codec",kind:"message",T:()=>mI},{no:5,name:"producing_transport_id",kind:"scalar",opt:!0,T:9},{no:6,name:"simulcast",kind:"message",T:()=>Vv}])}}const II=new _I;class CI extends y{constructor(){super("media.edge.ConsumePeersRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>II},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const PI=new CI;class RI extends y{constructor(){super("media.edge.UpdateConsumerSimulcastConfigRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"simulcast",kind:"message",T:()=>Vv},{no:3,name:"producing_transport_id",kind:"scalar",T:9},{no:4,name:"mid",kind:"scalar",T:9}])}}const MI=new RI;class AI extends y{constructor(){super("media.edge.UpdateConsumersSimulcastConfigRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>MI},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const DI=new AI;class OI extends y{constructor(){super("media.edge.ProducerCreateRequest",[{no:1,name:"kind",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8},{no:4,name:"description",kind:"message",T:()=>Pr},{no:5,name:"msid",kind:"scalar",T:9},{no:6,name:"app_data",kind:"scalar",opt:!0,T:9},{no:7,name:"mime_type",kind:"scalar",opt:!0,T:9},{no:8,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const NI=new OI;class VI extends y{constructor(){super("media.edge.SelectedPeersRequest",[])}}new VI;class LI extends y{constructor(){super("media.edge.GlobalPeerPinningRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const xI=new LI;class UI extends y{constructor(){super("media.edge.ProducerToggleRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}const Ec=new UI;class FI extends y{constructor(){super("media.edge.ConsumerToggleRequest",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}new FI;class BI extends y{constructor(){super("media.edge.ProducerCloseRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const WI=new BI;class jI extends y{constructor(){super("media.edge.ConsumerCloseRequest",[{no:1,name:"consumer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const HI=new jI;class GI extends y{constructor(){super("media.edge.KickPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new GI;class qI extends y{constructor(){super("media.edge.KickAllPeersRequest",[{no:1,name:"propagate_kick_across_rooms",kind:"scalar",T:8}])}}const Lv=new qI;class $I extends y{constructor(){super("media.edge.PeerDisplayNameEditRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}const JI=new $I;class KI extends y{constructor(){super("media.edge.HostMediaControlForPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"audio",kind:"scalar",T:8},{no:3,name:"video",kind:"scalar",T:8},{no:4,name:"scree_share",kind:"scalar",T:8}])}}const zI=new KI;class YI extends y{constructor(){super("media.edge.HostMediaControlForAllPeerRequest",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8}])}}const QI=new YI;class XI extends y{constructor(){super("media.edge.GetRoomStateResponse",[{no:1,name:"display_title",kind:"scalar",T:9},{no:2,name:"locked_mode",kind:"scalar",T:8},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"room_name",kind:"scalar",T:9},{no:5,name:"current_peer_id",kind:"scalar",T:9},{no:6,name:"is_recording",kind:"scalar",opt:!0,T:8},{no:7,name:"recorder_participant_id",kind:"scalar",opt:!0,T:9},{no:8,name:"pinned_peer_ids",kind:"scalar",repeat:2,T:9}])}}const ZI=new XI;class eC extends y{constructor(){super("media.edge.ErrorResponse",[{no:1,name:"error_message",kind:"scalar",T:9},{no:2,name:"event_id",kind:"scalar",T:5}])}}const tC=new eC;class rC extends y{constructor(){super("media.edge.EmptyResponse",[])}}new rC;class iC extends y{constructor(){super("media.edge.RoomParticipants",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"producer_states",kind:"message",repeat:1,T:()=>nc},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"user_id",kind:"scalar",opt:!0,T:9},{no:5,name:"capabilities",kind:"message",T:()=>Nv}])}}const xv=new iC;class sC extends y{constructor(){super("media.edge.SelectedPeersResponse",[{no:1,name:"audio_peers",kind:"scalar",repeat:2,T:9},{no:2,name:"compulsory_peers",kind:"scalar",repeat:2,T:9}])}}const Gu=new sC;class nC extends y{constructor(){super("media.edge.SelectedPeersDiffEntry",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"priority",kind:"scalar",T:5}])}}const aC=new nC;class oC extends y{constructor(){super("media.edge.SelectedPeersDiffResponse",[{no:1,name:"entries",kind:"message",repeat:1,T:()=>aC}])}}const Mm=new oC;class cC extends y{constructor(){super("media.edge.PeerJoinResponse",[])}}new cC;class dC extends y{constructor(){super("media.edge.PeerJoinCompleteResponse",[{no:1,name:"room_state",kind:"message",T:()=>ZI},{no:2,name:"participants",kind:"message",repeat:1,T:()=>xv},{no:3,name:"selected_peers",kind:"message",T:()=>Gu},{no:4,name:"max_preferred_streams",kind:"scalar",T:5}])}}const qu=new dC;class lC extends y{constructor(){super("media.edge.PeerLeaveResponse",[{no:1,name:"closed",kind:"scalar",T:8}])}}const uC=new lC;class hC extends y{constructor(){super("media.edge.ConsumeMultipleProducerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>Ov}])}}new hC;class pC extends y{constructor(){super("media.edge.ConsumePeerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>Ov},{no:3,name:"description",kind:"message",T:()=>Pr}])}}const mC=new pC;class gC extends y{constructor(){super("media.edge.ProducerCreateResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"producer_id",kind:"scalar",T:9},{no:4,name:"description",kind:"message",T:()=>Pr}])}}const fC=new gC;class vC extends y{constructor(){super("media.edge.ProducerScoreResponse",[{no:1,name:"responseid",kind:"scalar",T:9},{no:2,name:"score",kind:"message",T:()=>tI}])}}new vC;class yC extends y{constructor(){super("media.edge.ActiveSpeakerResponse",[{no:1,name:"responsepeer_id",kind:"scalar",T:9},{no:2,name:"volume",kind:"scalar",T:5}])}}new yC;class SC extends y{constructor(){super("media.edge.NoActiveSpeakerResponse",[])}}new SC;class EC extends y{constructor(){super("media.edge.ProducerToggleResponse",[])}}new EC;class kC extends y{constructor(){super("media.edge.ConsumerToggleResponse",[])}}new kC;class TC extends y{constructor(){super("media.edge.ProducerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Pr}])}}const bC=new TC;class wC extends y{constructor(){super("media.edge.ConsumerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Pr}])}}const _C=new wC;class IC extends y{constructor(){super("media.edge.GlobalPeerPinningResponse",[])}}new IC;class CC extends y{constructor(){super("media.edge.KickPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new CC;class PC extends y{constructor(){super("media.edge.KickAllPeersResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new PC;class RC extends y{constructor(){super("media.edge.HostMediaControlForPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const MC=new RC;class AC extends y{constructor(){super("media.edge.HostMediaControlForAllPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const DC=new AC;class OC extends y{constructor(){super("media.edge.PeerDisplayNameEditResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const NC=new OC;class VC extends y{constructor(){super("media.edge.PeerJoinBroadcastResponse",[{no:1,name:"participant",kind:"message",T:()=>xv}])}}const Am=new VC;class LC extends y{constructor(){super("media.edge.TrackSubscriptionKind",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8}])}}const Dm=new LC;class xC extends y{constructor(){super("media.edge.TrackSubscription",[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"webcam",kind:"message",T:()=>Dm},{no:3,name:"screenshare",kind:"message",T:()=>Dm}])}}const UC=new xC;class FC extends y{constructor(){super("media.edge.PeerProducingTransportCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"transport_details",kind:"message",T:()=>Dv},{no:3,name:"track_subscriptions",kind:"message",repeat:1,T:()=>UC}])}}new FC;class BC extends y{constructor(){super("media.edge.PeerProducerCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>nc}])}}const WC=new BC;class jC extends y{constructor(){super("media.edge.PeerProducerToggleBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>nc},{no:3,name:"initiator_participant_id",kind:"scalar",opt:!0,T:9}])}}const Om=new jC;class HC extends y{constructor(){super("media.edge.PeerProducerCloseBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>nc}])}}const GC=new HC;class qC extends y{constructor(){super("media.edge.PeerLeaveBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const $u=new qC;class $C extends y{constructor(){super("media.edge.GlobalPeerPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const Nm=new $C;class JC extends y{constructor(){super("media.edge.GlobalPeerUnPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new JC;class KC extends y{constructor(){super("media.edge.RecordingStartedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new KC;class zC extends y{constructor(){super("media.edge.RecordingStoppedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new zC;class YC extends y{constructor(){super("media.edge.PeerDisplayNameEditBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}new YC;class QC extends y{constructor(){super("media.edge.PeerPingRequestBroadcastResponse",[{no:1,name:"password",kind:"scalar",T:9}])}}new QC;class XC extends y{constructor(){super("media.edge.MediaRoomTerminationBroadcastResponse",[{no:1,name:"reason",kind:"scalar",T:9}])}}new XC;class ZC extends y{constructor(){super("socket.ai.MeetingTranscript",[{no:1,name:"meeting_id",kind:"scalar",T:9},{no:2,name:"transcript",kind:"scalar",T:9},{no:3,name:"is_partial",kind:"scalar",T:8}])}}const Kl=new ZC;class eP extends y{constructor(){super("socket.api.BaseSocketHubMessage",[{no:1,name:"event",kind:"scalar",T:5},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9},{no:4,name:"room_id",kind:"scalar",T:9},{no:5,name:"user_id",kind:"scalar",T:9},{no:6,name:"payload",kind:"scalar",T:12},{no:7,name:"error",kind:"scalar",opt:!0,T:8},{no:8,name:"sid",kind:"scalar",opt:!0,T:9}])}}new eP;class tP extends y{constructor(){super("socket.api.ErrorMessage",[{no:1,name:"code",kind:"scalar",opt:!0,T:5},{no:2,name:"message",kind:"scalar",T:9}])}}const rP=new tP;var Os;(function(t){t[t.BROWSER=0]="BROWSER",t[t.TRACK=1]="TRACK",t[t.COMPOSITE=2]="COMPOSITE"})(Os||(Os={}));var ii;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ON_STAGE=1]="ON_STAGE",t[t.APPROVED_STAGE=2]="APPROVED_STAGE",t[t.REQUESTED_STAGE=3]="REQUESTED_STAGE",t[t.OFF_STAGE=4]="OFF_STAGE"})(ii||(ii={}));var Ju;(function(t){t[t.NONE=0]="NONE",t[t.RECORDER=1]="RECORDER",t[t.LIVESTREAMER=2]="LIVESTREAMER"})(Ju||(Ju={}));var Ku;(function(t){t[t.PEERS=0]="PEERS",t[t.ROOMS=1]="ROOMS"})(Ku||(Ku={}));var Qd;(function(t){t[t.HIVE=0]="HIVE",t[t.CHAT=1]="CHAT",t[t.PING=2]="PING"})(Qd||(Qd={}));class iP extends y{constructor(){super("socket.room.PeerFlags",[{no:1,name:"preset_name",kind:"scalar",T:9},{no:2,name:"recorder_type",kind:"scalar",T:9},{no:3,name:"hidden_participant",kind:"scalar",T:8}])}}const sP=new iP;class nP extends y{constructor(){super("socket.room.Peer",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"stage_type",kind:"enum",opt:!0,T:()=>["socket.room.StageType",ii,"STAGE_TYPE_"]},{no:5,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:6,name:"preset_id",kind:"scalar",opt:!0,T:9},{no:7,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:8,name:"waitlisted",kind:"scalar",T:8},{no:9,name:"flags",kind:"message",T:()=>sP}])}}const Il=new nP;class aP extends y{constructor(){super("socket.room.PeerInfoResponse",[{no:1,name:"peer",kind:"message",T:()=>Il}])}}const yn=new aP;class oP extends y{constructor(){super("socket.room.PeerStatusUpdate",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"stage_type",kind:"enum",opt:!0,T:()=>["socket.room.StageType",ii,"STAGE_TYPE_"]}])}}const Vm=new oP;class cP extends y{constructor(){super("socket.room.RoomPeersInfoRequest",[{no:1,name:"seach_query",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5},{no:3,name:"offset",kind:"scalar",T:5}])}}const dP=new cP;class lP extends y{constructor(){super("socket.room.RoomPeersInfoResponse",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>Il}])}}const zl=new lP;class uP extends y{constructor(){super("socket.room.RoomPeerCountResponse",[{no:1,name:"count",kind:"scalar",T:4,L:2}])}}const Lm=new uP;class hP extends y{constructor(){super("socket.room.Room",[{no:1,name:"room_id",kind:"scalar",T:9},{no:2,name:"title",kind:"scalar",T:9},{no:4,name:"created_at",kind:"scalar",T:4,L:2},{no:5,name:"active_recordings",kind:"message",repeat:1,T:()=>mP},{no:6,name:"room_uuid",kind:"scalar",opt:!0,T:9}])}}const Uv=new hP;class pP extends y{constructor(){super("socket.room.ActiveRecording",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",Os]},{no:3,name:"recording_status",kind:"scalar",T:9}])}}const mP=new pP;class gP extends y{constructor(){super("socket.room.RoomInfoResponse",[{no:1,name:"room",kind:"message",T:()=>Uv}])}}const xm=new gP;class fP extends y{constructor(){super("socket.room.GetPeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9}])}}const Fv=new fP;class vP extends y{constructor(){super("socket.room.UpdatePeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9}])}}new vP;class yP extends y{constructor(){super("socket.room.JoinRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>Il},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"organization_id",kind:"scalar",opt:!0,T:9},{no:5,name:"use_hive",kind:"scalar",opt:!0,T:8},{no:6,name:"preset",kind:"scalar",opt:!0,T:12},{no:7,name:"capabilities",kind:"enum",repeat:1,T:()=>["socket.room.Capabilities",Qd,"CAPABILITIES_"]},{no:8,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const SP=new yP;class EP extends y{constructor(){super("socket.room.LeaveRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>Il},{no:2,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const kP=new EP;class TP extends y{constructor(){super("socket.room.UpdateRoomInfoRequest",[{no:1,name:"room",kind:"message",T:()=>Uv}])}}new TP;class bP extends y{constructor(){super("socket.room.GetConnectedRoomsDumpRequest",[])}}new bP;class wP extends y{constructor(){super("socket.room.ServiceError",[{no:1,name:"message",kind:"scalar",opt:!0,T:9},{no:2,name:"code",kind:"scalar",opt:!0,T:9}])}}const up=new wP;class _P extends y{constructor(){super("socket.room.ConnectedMeetingPeer",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9},{no:3,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:4,name:"preset_id",kind:"scalar",opt:!0,T:9},{no:5,name:"display_picture_url",kind:"scalar",opt:!0,T:9}])}}const IP=new _P;class CP extends y{constructor(){super("socket.room.ConnectedMeetingDump",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9},{no:3,name:"participants",kind:"message",repeat:1,T:()=>IP}])}}const Um=new CP;class PP extends y{constructor(){super("socket.room.GetConnectedRoomsDumpResponse",[{no:1,name:"parent_meeting",kind:"message",T:()=>Um},{no:2,name:"meetings",kind:"message",repeat:1,T:()=>Um}])}}const RP=new PP;class MP extends y{constructor(){super("socket.room.CreateRoomRequestPayload",[{no:1,name:"title",kind:"scalar",opt:!0,T:9}])}}const AP=new MP;class DP extends y{constructor(){super("socket.room.CreateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>AP}])}}const OP=new DP;class NP extends y{constructor(){super("socket.room.CreateRoomResponsePayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9},{no:3,name:"error",kind:"message",T:()=>up}])}}const VP=new NP;class LP extends y{constructor(){super("socket.room.CreateConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>VP}])}}const Fm=new LP;class xP extends y{constructor(){super("socket.room.UpdateRoomRequestPayload",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9}])}}const UP=new xP;class FP extends y{constructor(){super("socket.room.UpdateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>UP}])}}new FP;class BP extends y{constructor(){super("socket.room.DisableRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9}])}}const WP=new BP;class jP extends y{constructor(){super("socket.room.DisableConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>WP}])}}const HP=new jP;class GP extends y{constructor(){super("socket.room.DisableConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>JP}])}}const qP=new GP;class $P extends y{constructor(){super("socket.room.DisableConnectedRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"status",kind:"scalar",opt:!0,T:9},{no:3,name:"title",kind:"scalar",opt:!0,T:9},{no:4,name:"error",kind:"message",T:()=>up}])}}const JP=new $P;class KP extends y{constructor(){super("socket.room.MovePeerPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"preset_id",kind:"scalar",opt:!0,T:9}])}}const zP=new KP;class YP extends y{constructor(){super("socket.room.MovePeersBetweenRoomsRequest",[{no:1,name:"source_meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"destination_meeting_id",kind:"scalar",opt:!0,T:9},{no:3,name:"participants",kind:"message",repeat:1,T:()=>zP}])}}const QP=new YP;class XP extends y{constructor(){super("socket.room.MovedPeer",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:3,name:"error",kind:"message",T:()=>up}])}}const Bv=new XP;class ZP extends y{constructor(){super("socket.room.MovePeersBetweenRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>Bv}])}}new ZP;class eR extends y{constructor(){super("socket.room.TransferPeer",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"auth_token",kind:"scalar",opt:!0,T:9}])}}const tR=new eR;class rR extends y{constructor(){super("socket.room.GetAllAddedParticipantsResponse",[{no:1,name:"participants",kind:"message",repeat:1,T:()=>nR}])}}const iR=new rR;class sR extends y{constructor(){super("socket.room.AddedParticipant",[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",opt:!0,T:9},{no:3,name:"picture",kind:"scalar",opt:!0,T:9},{no:4,name:"custom_participant_id",kind:"scalar",T:9}])}}const nR=new sR;class aR extends y{constructor(){super("socket.room.RemoveParticipantsRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const Wv=new aR;class oR extends y{constructor(){super("socket.room.BroadcastMessage",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"timestamp",kind:"scalar",T:4,L:2},{no:4,name:"ids",kind:"scalar",repeat:2,T:9},{no:5,name:"broadcast_type",kind:"enum",opt:!0,T:()=>["socket.room.BroadcastType",Ku,"BROADCAST_TYPE_"]}])}}const wa=new oR;class cR extends y{constructor(){super("socket.room.AcceptWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const dR=new cR;class lR extends y{constructor(){super("socket.room.DenyWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const uR=new lR;class hR extends y{constructor(){super("socket.room.WaitingRoomRequest",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"picture",kind:"scalar",opt:!0,T:9},{no:5,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:6,name:"preset_name",kind:"scalar",opt:!0,T:9}])}}const pR=new hR;class mR extends y{constructor(){super("socket.room.GetWaitingRoomRequests",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>pR}])}}const Bm=new mR;class gR extends y{constructor(){super("socket.room.GetRoomStageStateResponse",[{no:1,name:"on_stage_peers",kind:"scalar",repeat:2,T:9},{no:2,name:"approved_stage_peers",kind:"scalar",repeat:2,T:9},{no:3,name:"requested_stage_peers",kind:"scalar",repeat:2,T:9}])}}const Wm=new gR;var zu;(function(t){t[t.NONE=0]="NONE",t[t.SKIP=1]="SKIP",t[t.ON_PRIVILEGED_USER_ENTRY=2]="ON_PRIVILEGED_USER_ENTRY",t[t.SKIP_ON_ACCEPT=3]="SKIP_ON_ACCEPT"})(zu||(zu={}));var Ui;(function(t){t[t.NONE=0]="NONE",t[t.ALLOWED=1]="ALLOWED",t[t.NOT_ALLOWED=2]="NOT_ALLOWED",t[t.CAN_REQUEST=3]="CAN_REQUEST"})(Ui||(Ui={}));class fR extends y{constructor(){super("socket.preset.PollsPermissionUpdate",[{no:1,name:"can_create",kind:"scalar",opt:!0,T:8},{no:2,name:"can_vote",kind:"scalar",opt:!0,T:8},{no:3,name:"can_view",kind:"scalar",opt:!0,T:8}])}}const vR=new fR;class yR extends y{constructor(){super("socket.preset.PluginsPermissionsUpdate",[{no:1,name:"can_close",kind:"scalar",opt:!0,T:8},{no:2,name:"can_start",kind:"scalar",opt:!0,T:8}])}}const SR=new yR;class ER extends y{constructor(){super("socket.preset.PublicChatPermission",[{no:1,name:"can_send",kind:"scalar",opt:!0,T:8},{no:2,name:"text",kind:"scalar",opt:!0,T:8},{no:3,name:"files",kind:"scalar",opt:!0,T:8}])}}const kR=new ER;class TR extends y{constructor(){super("socket.preset.PrivateChatPermission",[{no:1,name:"can_send",kind:"scalar",opt:!0,T:8},{no:2,name:"can_receive",kind:"scalar",opt:!0,T:8},{no:3,name:"text",kind:"scalar",opt:!0,T:8},{no:4,name:"files",kind:"scalar",opt:!0,T:8}])}}const bR=new TR;class wR extends y{constructor(){super("socket.preset.ChatPermissionUpdate",[{no:1,name:"public",kind:"message",T:()=>kR},{no:2,name:"private",kind:"message",T:()=>bR}])}}const _R=new wR;class IR extends y{constructor(){super("socket.preset.ConnectedMeetingPermissionUpdate",[{no:1,name:"can_alter_connected_meetings",kind:"scalar",opt:!0,T:8},{no:2,name:"can_switch_to_parent_meeting",kind:"scalar",opt:!0,T:8},{no:3,name:"can_switch_connected_meetings",kind:"scalar",opt:!0,T:8}])}}const CR=new IR;class PR extends y{constructor(){super("socket.preset.StreamPermission",[{no:1,name:"can_produce",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",Ui,"STREAM_PERMISSION_TYPE_"]},{no:2,name:"can_consume",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",Ui,"STREAM_PERMISSION_TYPE_"]}])}}const Yl=new PR;class RR extends y{constructor(){super("socket.preset.MediaPermissionUpdate",[{no:1,name:"video",kind:"message",T:()=>Yl},{no:2,name:"audio",kind:"message",T:()=>Yl},{no:3,name:"screenshare",kind:"message",T:()=>Yl}])}}const MR=new RR;class AR extends y{constructor(){super("socket.preset.PresetUpdates",[{no:1,name:"polls",kind:"message",T:()=>vR},{no:2,name:"plugins",kind:"message",T:()=>SR},{no:3,name:"chat",kind:"message",T:()=>_R},{no:4,name:"accept_waiting_requests",kind:"scalar",opt:!0,T:8},{no:5,name:"can_accept_production_requests",kind:"scalar",opt:!0,T:8},{no:6,name:"can_edit_display_name",kind:"scalar",opt:!0,T:8},{no:7,name:"can_record",kind:"scalar",opt:!0,T:8},{no:8,name:"can_livestream",kind:"scalar",opt:!0,T:8},{no:9,name:"can_spotlight",kind:"scalar",opt:!0,T:8},{no:10,name:"disable_participant_audio",kind:"scalar",opt:!0,T:8},{no:11,name:"disable_participant_screensharing",kind:"scalar",opt:!0,T:8},{no:12,name:"disable_participant_video",kind:"scalar",opt:!0,T:8},{no:13,name:"kick_participant",kind:"scalar",opt:!0,T:8},{no:14,name:"pin_participant",kind:"scalar",opt:!0,T:8},{no:15,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:16,name:"waiting_room_type",kind:"enum",opt:!0,T:()=>["socket.preset.WaitingRoomType",zu,"WAITING_ROOM_TYPE_"]},{no:17,name:"is_recorder",kind:"scalar",opt:!0,T:8},{no:18,name:"recorder_type",kind:"enum",opt:!0,T:()=>["socket.room.RecorderType",Ju,"RECORDER_TYPE_"]},{no:19,name:"hidden_participant",kind:"scalar",opt:!0,T:8},{no:20,name:"show_participant_list",kind:"scalar",opt:!0,T:8},{no:21,name:"can_change_participant_permissions",kind:"scalar",opt:!0,T:8},{no:22,name:"connected_meetings",kind:"message",T:()=>CR},{no:23,name:"media",kind:"message",T:()=>MR}])}}const hp=new AR;class DR extends y{constructor(){super("socket.preset.ReadPeersPresetRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const OR=new DR;class NR extends y{constructor(){super("socket.preset.PeerPreset",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"preset",kind:"scalar",T:12}])}}const VR=new NR;class LR extends y{constructor(){super("socket.preset.ReadPeersPresetResponse",[{no:1,name:"peer_presets",kind:"message",repeat:1,T:()=>VR}])}}const xR=new LR;class UR extends y{constructor(){super("socket.preset.UpdatePeerPreset",[{no:1,name:"user_ids",kind:"scalar",T:9},{no:2,name:"patch",kind:"message",T:()=>hp}])}}const jv=new UR;class FR extends y{constructor(){super("socket.preset.UpdatePeersPresetRequest",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>jv}])}}const BR=new FR;class WR extends y{constructor(){super("socket.preset.UpdatePeersPresetResponse",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>jv}])}}const jm=new WR;class jR extends y{constructor(){super("socket.preset.PeerUserIDMap",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9}])}}const HR=new jR;class GR extends y{constructor(){super("socket.preset.BulkUpdatePeerPresetRequest",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>HR},{no:2,name:"patch",kind:"message",T:()=>hp}])}}new GR;class qR extends y{constructor(){super("socket.preset.BulkUpdatePeerPresetResponse",[{no:2,name:"patch",kind:"message",T:()=>hp}])}}new qR;class $R extends y{constructor(){super("socket.chat.ChatMessage",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"user_id",kind:"scalar",T:9},{no:4,name:"display_name",kind:"scalar",T:9},{no:5,name:"pinned",kind:"scalar",T:8},{no:6,name:"is_edited",kind:"scalar",T:8},{no:7,name:"payload_type",kind:"scalar",T:5},{no:8,name:"payload",kind:"scalar",T:9},{no:10,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:11,name:"created_at",kind:"scalar",T:4,L:2},{no:12,name:"created_at_ms",kind:"scalar",opt:!0,T:4,L:2},{no:13,name:"channel_id",kind:"scalar",opt:!0,T:9},{no:14,name:"channel_index",kind:"scalar",opt:!0,T:9}])}}const Hs=new $R;class JR extends y{constructor(){super("socket.chat.GetPaginatedChatMessageRoomRequest",[{no:1,name:"time_stamp",kind:"scalar",T:4,L:2},{no:2,name:"size",kind:"scalar",T:5},{no:3,name:"from",kind:"scalar",T:5},{no:4,name:"reversed",kind:"scalar",T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const KR=new JR;class zR extends y{constructor(){super("socket.chat.GetPaginatedChatMessageRoomResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Hs},{no:2,name:"next",kind:"scalar",T:8}])}}const YR=new zR;class QR extends y{constructor(){super("socket.chat.GetChatMessagesResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Hs}])}}const Hv=new QR;class XR extends y{constructor(){super("socket.chat.SendChatMessageToRoomRequest",[{no:1,name:"payload_type",kind:"scalar",T:5},{no:2,name:"payload",kind:"scalar",T:9}])}}const ZR=new XR;class eM extends y{constructor(){super("socket.chat.SendChatMessageToRoomResponse",[{no:1,name:"message",kind:"message",T:()=>Hs}])}}const Ql=new eM;class tM extends y{constructor(){super("socket.chat.SendChatMessageToPeersRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"payload_type",kind:"scalar",T:5},{no:3,name:"payload",kind:"scalar",T:9}])}}const rM=new tM;class iM extends y{constructor(){super("socket.chat.SendChatMessageToPeersResponse",[{no:1,name:"message",kind:"message",T:()=>Hs}])}}const Xl=new iM;class sM extends y{constructor(){super("socket.chat.SendChatMessageToChannelRequest",[{no:1,name:"channel_id",kind:"scalar",T:9},{no:2,name:"payload_type",kind:"scalar",T:5},{no:3,name:"payload",kind:"scalar",T:9}])}}const nM=new sM;class aM extends y{constructor(){super("socket.chat.SendChatMessageToChannelResponse",[{no:1,name:"message",kind:"message",T:()=>Hs}])}}new aM;class oM extends y{constructor(){super("socket.chat.EditChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"payload_type",kind:"scalar",opt:!0,T:5},{no:3,name:"payload",kind:"scalar",opt:!0,T:9},{no:4,name:"pinned",kind:"scalar",opt:!0,T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const cM=new oM;class dM extends y{constructor(){super("socket.chat.PinChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"pinned",kind:"scalar",T:8},{no:3,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const lM=new dM;class uM extends y{constructor(){super("socket.chat.PinChatMessageResponse",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"pinned",kind:"scalar",T:8},{no:3,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const kc=new uM;class hM extends y{constructor(){super("socket.chat.EditChatMessageResponse",[{no:1,name:"message",kind:"message",T:()=>Hs}])}}const Tc=new hM;class pM extends y{constructor(){super("socket.chat.DeleteChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const mM=new pM;class gM extends y{constructor(){super("socket.chat.DeleteChatMessageResponse",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const bc=new gM;class fM extends y{constructor(){super("socket.chat.SearchChatMessagesRequest",[{no:1,name:"time_stamp",kind:"scalar",T:4,L:2},{no:2,name:"size",kind:"scalar",T:5},{no:3,name:"from",kind:"scalar",T:5},{no:4,name:"reversed",kind:"scalar",T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9},{no:6,name:"search_term",kind:"scalar",T:9}])}}const vM=new fM;class yM extends y{constructor(){super("socket.chat.MarkChannelIndexAsReadRequest",[{no:1,name:"channel_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"channel_index",kind:"scalar",T:9}])}}const SM=new yM;class EM extends y{constructor(){super("socket.chat.MarkChannelIndexAsReadResponse",[{no:1,name:"channel_index",kind:"scalar",T:9}])}}const kM=new EM;class TM extends y{constructor(){super("socket.chat.CreateChatChannelRequest",[{no:1,name:"display_name",kind:"scalar",T:9},{no:2,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:3,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:4,name:"visibility",kind:"scalar",T:9},{no:5,name:"is_direct_message",kind:"scalar",T:8}])}}const bM=new TM;class wM extends y{constructor(){super("socket.chat.UpdateChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9},{no:3,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:4,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:5,name:"visibility",kind:"scalar",opt:!0,T:9},{no:6,name:"is_direct_message",kind:"scalar",opt:!0,T:8}])}}const _M=new wM;class IM extends y{constructor(){super("socket.chat.CreateChatChannelResponse",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}new IM;class CM extends y{constructor(){super("socket.chat.GetChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}const PM=new CM;class RM extends y{constructor(){super("socket.chat.LatestMessageAndUnreadCount",[{no:1,name:"message",kind:"message",T:()=>Hs},{no:2,name:"unread_count",kind:"scalar",T:4,L:2}])}}const MM=new RM;class AM extends y{constructor(){super("socket.chat.ChatChannel",[{no:1,name:"chat_channel_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9},{no:3,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:4,name:"visibility",kind:"scalar",T:9},{no:5,name:"is_direct_message",kind:"scalar",T:8},{no:6,name:"latest_message_and_unread_count",kind:"message",T:()=>MM},{no:7,name:"target_user_ids",kind:"scalar",repeat:2,T:9}])}}const DM=new AM;class OM extends y{constructor(){super("socket.chat.GetChatChannelResponse",[{no:1,name:"chat_channels",kind:"message",repeat:1,T:()=>DM}])}}const Jr=new OM;class NM extends y{constructor(){super("socket.chat.ChannelMember",[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",opt:!0,T:9},{no:3,name:"picture",kind:"scalar",opt:!0,T:9},{no:4,name:"custom_participant_id",kind:"scalar",T:9}])}}const VM=new NM;class LM extends y{constructor(){super("socket.chat.GetChatChannelMembersResponse",[{no:1,name:"channel_members",kind:"message",repeat:1,T:()=>VM}])}}const xM=new LM;class UM extends y{constructor(){super("socket.plugin.AddPluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const FM=new UM;class BM extends y{constructor(){super("socket.plugin.RemovePluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const WM=new BM;class jM extends y{constructor(){super("socket.plugin.EnablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const HM=new jM;class GM extends y{constructor(){super("socket.plugin.DisablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const qM=new GM;class $M extends y{constructor(){super("socket.plugin.EnablePluginForPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const JM=new $M;class KM extends y{constructor(){super("socket.plugin.DisablePluginForPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const zM=new KM;class YM extends y{constructor(){super("socket.plugin.PluginEventToRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const QM=new YM;class XM extends y{constructor(){super("socket.plugin.PluginEventToPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9},{no:3,name:"plugin_data",kind:"scalar",T:12}])}}const ZM=new XM;class eA extends y{constructor(){super("socket.plugin.StoreKeys",[{no:1,name:"store_key",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",opt:!0,T:12}])}}const pp=new eA;class tA extends y{constructor(){super("socket.plugin.PluginStoreInsertKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"insert_keys",kind:"message",repeat:1,T:()=>pp}])}}const Hm=new tA;class rA extends y{constructor(){super("socket.plugin.PluginStoreGetKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"get_keys",kind:"message",repeat:1,T:()=>pp}])}}const iA=new rA;class sA extends y{constructor(){super("socket.plugin.PluginStoreDeleteKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"delete_keys",kind:"message",repeat:1,T:()=>pp}])}}const nA=new sA;class aA extends y{constructor(){super("socket.plugin.PluginStoreDeleteRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9}])}}const oA=new aA;class cA extends y{constructor(){super("socket.plugin.EnablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"enabled_by",kind:"scalar",T:9}])}}const Yu=new cA;class dA extends y{constructor(){super("socket.plugin.EnablePluginsResponse",[{no:1,name:"plugins",kind:"message",repeat:1,T:()=>Yu}])}}const lA=new dA;class uA extends y{constructor(){super("socket.plugin.DisablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"disabled_by",kind:"scalar",T:9}])}}const Gm=new uA;class hA extends y{constructor(){super("socket.plugin.PluginStoreItem",[{no:1,name:"timestamp",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"store_key",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}])}}const pA=new hA;class mA extends y{constructor(){super("socket.plugin.PluginStoreResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"store_items",kind:"message",repeat:1,T:()=>pA}])}}const qm=new mA;class gA extends y{constructor(){super("socket.plugin.PluginEventResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const $m=new gA;class fA extends y{constructor(){super("socket.livestreaming.LiveStreamingEvent",[{no:1,name:"livestream_id",kind:"scalar",T:9},{no:2,name:"err_message",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"meeting_id",kind:"scalar",T:9},{no:5,name:"playback_url",kind:"scalar",T:9},{no:6,name:"org_id",kind:"scalar",T:9},{no:7,name:"room_name",kind:"scalar",T:9},{no:8,name:"room_uuid",kind:"scalar",T:9},{no:9,name:"status",kind:"scalar",T:9},{no:10,name:"manual_ingest",kind:"scalar",opt:!0,T:8}])}}const Jm=new fA;class vA extends y{constructor(){super("socket.livestreaming.GetStagePeersResponse",[{no:1,name:"stage_peers",kind:"scalar",repeat:2,T:9}])}}const Km=new vA;class yA extends y{constructor(){super("socket.livestreaming.StageRequest",[{no:1,name:"display_name",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9}])}}const SA=new yA;class EA extends y{constructor(){super("socket.livestreaming.GetStageRequestsResponse",[{no:1,name:"stage_requests",kind:"message",repeat:1,T:()=>SA}])}}const Zl=new EA;class kA extends y{constructor(){super("socket.livestreaming.GrantStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const TA=new kA;class bA extends y{constructor(){super("socket.livestreaming.DenyStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const wA=new bA;class _A extends y{constructor(){super("socket.livestreaming.LeaveStageRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const zm=new _A;class IA extends y{constructor(){super("socket.polls.Poll",[{no:1,name:"poll_id",kind:"scalar",T:9},{no:2,name:"created_by",kind:"scalar",T:9},{no:3,name:"created_by_user_id",kind:"scalar",T:9},{no:4,name:"question",kind:"scalar",T:9},{no:5,name:"options",kind:"message",repeat:1,T:()=>PA},{no:6,name:"hide_votes",kind:"scalar",T:8},{no:7,name:"anonymous",kind:"scalar",T:8},{no:8,name:"votes",kind:"scalar",repeat:2,T:9}])}}const Gv=new IA;class CA extends y{constructor(){super("socket.polls.PollOption",[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"count",kind:"scalar",opt:!0,T:4,L:2},{no:3,name:"votes",kind:"message",repeat:1,T:()=>MA}])}}const PA=new CA;class RA extends y{constructor(){super("socket.polls.PollVote",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9}])}}const MA=new RA;class AA extends y{constructor(){super("socket.polls.NewPollRequest",[{no:1,name:"question",kind:"scalar",T:9},{no:2,name:"options",kind:"scalar",repeat:2,T:9},{no:3,name:"anonymous",kind:"scalar",T:8},{no:4,name:"hide_votes",kind:"scalar",T:8},{no:5,name:"created_by",kind:"scalar",opt:!0,T:9},{no:6,name:"created_by_user_id",kind:"scalar",opt:!0,T:9}])}}const DA=new AA;class OA extends y{constructor(){super("socket.polls.VotePollRequest",[{no:1,name:"poll_id",kind:"scalar",T:9},{no:2,name:"index",kind:"scalar",T:4,L:2}])}}const NA=new OA;class VA extends y{constructor(){super("socket.polls.UpdatePollResponse",[{no:1,name:"poll",kind:"message",T:()=>Gv}])}}const eu=new VA;class LA extends y{constructor(){super("socket.polls.GetPollsResponse",[{no:1,name:"polls",kind:"message",repeat:1,T:()=>Gv}])}}const xA=new LA;class UA extends y{constructor(){super("socket.recording.RecordingEvent",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"err_message",kind:"scalar",T:9},{no:3,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",Os]}])}}const Ym=new UA;class FA extends y{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){const e=this.create(),r=Date.now();return e.seconds=ke.from(Math.floor(r/1e3)).toBigInt(),e.nanos=r%1e3*1e6,e}toDate(e){return new Date(ke.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){const r=this.create(),i=e.getTime();return r.seconds=ke.from(Math.floor(i/1e3)).toBigInt(),r.nanos=i%1e3*1e6,r}internalJsonWrite(e,r){let i=ke.from(e.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let s="Z";if(e.nanos>0){let n=(e.nanos+1e9).toString().substring(1);n.substring(3)==="000000"?s="."+n.substring(0,3)+"Z":n.substring(6)==="000"?s="."+n.substring(0,6)+"Z":s="."+n+"Z"}return new Date(i).toISOString().replace(".000Z",s)}internalJsonRead(e,r,i){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+Kh(e)+".");let s=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!s)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let n=Date.parse(s[1]+"-"+s[2]+"-"+s[3]+"T"+s[4]+":"+s[5]+":"+s[6]+(s[8]?s[8]:"Z"));if(Number.isNaN(n))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=ke.from(n/1e3).toBigInt(),i.nanos=0,s[7]&&(i.nanos=parseInt("1"+s[7]+"0".repeat(9-s[7].length))-1e9),i}}new FA;class BA extends y{constructor(){super("common.BaseHubMessage",[{no:1,name:"event",kind:"scalar",T:5},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9},{no:4,name:"room_id",kind:"scalar",T:9},{no:5,name:"user_id",kind:"scalar",T:9},{no:6,name:"payload",kind:"scalar",T:12},{no:7,name:"error",kind:"scalar",opt:!0,T:8},{no:8,name:"sid",kind:"scalar",opt:!0,T:9},{no:9,name:"room_object_id",kind:"scalar",opt:!0,T:9},{no:10,name:"preset",kind:"scalar",opt:!0,T:9},{no:11,name:"use_start_session",kind:"scalar",opt:!0,T:8}])}}const Qu=new BA;class WA extends y{constructor(){super("common.BulkedHubMessage",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Qu}])}}new WA;class jA extends y{constructor(){super("common.CFWorkersResponse",[{no:1,name:"responses",kind:"message",repeat:1,T:()=>Qu},{no:2,name:"broadcast_responses",kind:"message",repeat:1,T:()=>Qu}])}}new jA;const HA=0,GA=1,qA=2,$A=3,JA=4,KA=5,zA={getPeerInfo:0,updatePeerInfo:1,getRoomPeersInfo:2,joinRoom:3,leaveRoom:4,getRoomInfo:5,updateRoomInfo:6,closeRoom:7,startedLivestream:8,stoppedLivestream:9,erroredLivestream:10,getStagePeers:11,getStageRequests:12,requestStageAccess:13,cancelStageRequest:14,grantStageAccess:15,denyStageAccess:16,roomPeerCount:17,joinStage:18,leaveStage:19,getConnectedRoomsDump:20,createConnectedRooms:21,deleteConnectedRooms:22,movePeers:23,transferPeer:24,movedPeer:25,connectedRoomsUpdated:26,connectedRoomsDeleted:27,getAllAddedParticipants:28,broadcastMessage:29,kick:30,kickAll:31,transcript:32,getWaitingRoomRequests:33,acceptWaitingRoomRequests:34,waitingRoomRequestAccepted:35,denyWaitingRoomRequests:36,waitingRoomRequestDenied:37,peerStageStatusUpdate:38,broadcastToEntity:39,recordingStarted:40,recordingStopped:41,recordingPaused:42,getRoomStageState:43,livestreamingInvoked:44},YA={getMessages:0,sendMessageToRoom:1,sendMessageToPeers:2,editMessage:3,deleteMessage:4,getPaginatedMessages:5,sendMessageToChannel:6,searchChannelMessages:7,getAllChatChannels:8,markChannelIndexAsRead:9,pinMessage:10},QA={getPlugins:0,addPlugin:1,enablePluginForRoom:2,disablePluginForPeers:3,enablePluginForPeers:4,disablePluginForRoom:5,removePlugin:6,customPluginEventToRoom:7,customPluginEventToPeers:8,storeInsertKeys:9,storeGetKeys:10,storeDeleteKeys:11,storeDelete:12},XA={createPoll:0,getPolls:1,votePoll:2,updatePoll:3},qv={unknown:0,createWebRTCTransport:1,produce:2,consume:3,toggleProducer:4,toggleConsumer:5,closeProducer:6,closeConsumer:7,updateConsumersSimulcastConfig:8,joinRoom:16,leaveRoom:17,selectedPeer:18,globalPinPeer:19,selfJoinComplete:20,peerJoinedBroadcast:25,peerLeaveBroadcast:26,peerProducerCreateBroadcast:27,peerProducerToggleBroadcast:28,peerProducerCloseBroadcast:29,globalPeerPinBroadcast:30,recordingStartedBroadcast:31,recordingStoppedBroadcast:32,peerDisplayNameEditBroadcast:33,mediaRoomTerminationBroadcastResponse:36,selectedPeerDiff:40,renegotiateSessionDescription:50,errorResponse:60,kickPeer:90,kickAll:91,changeDisplayName:92,hostControlPeer:93,hostControlAllPeers:94,audioActivity:100},ZA={createChatChannel:0,getChatChannel:1,deprecatedGetAllChatChannels:2,getChannelMembers:3,updateChatChannel:4},eD={getUserPresets:0,updateUserPreset:1};function sa(t,e){return Object.keys(e).reduce((r,i)=>(r[i]=(t<<16)+e[i],r),{})}function $v(t,e){return Object.keys(t).reduce((r,i)=>(r[i]=e|t[i],r),{})}const F=sa(HA,zA),Ae=sa(GA,YA),$=sa(qA,QA),Zr=sa($A,XA),ws=sa(JA,ZA),cr=$v(qv,16777216),br=$v(qv,50331648),Qc=sa(KA,eD);var tD=Object.defineProperty,rD=Object.getOwnPropertyDescriptor,mp=(t,e,r,i)=>{for(var s=i>1?void 0:i?rD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&tD(e,r,s),s},Yi,_a,Qm;const Xu=(Qm=class{constructor(t,e){g(this,Yi,void 0),g(this,_a,void 0),f(this,Yi,e),f(this,_a,t)}get telemetry(){return a(this,_a).getValue("telemetry")}get logger(){return a(this,_a).getValue("logger")}createChannel(t,e,r,i="public",s=!1){return u(this,null,function*(){const n={displayName:t,targetUserIds:e,displayPictureUrl:r,visibility:i,isDirectMessage:s};s&&(n.visibility="private");const o=yield a(this,Yi).sendMessagePromise(ws.createChatChannel,bM.toBinary(n)),c=Jr.fromBinary(o.payload).chatChannels;return Xu.formatChannel(c[0])})}updateChannel(t,e){return u(this,null,function*(){const r=yield a(this,Yi).sendMessagePromise(ws.updateChatChannel,_M.toBinary({chatChannelId:t,targetUserIds:e.memberIds,displayName:e.displayName,displayPictureUrl:e.displayPictureUrl,visibility:e.visibility})),i=Jr.fromBinary(r.payload).chatChannels;return Xu.formatChannel(i[0])})}static formatChannel(t){var e;const{latestMessageAndUnreadCount:r}=t,i=q(V({},t),{id:t.chatChannelId,memberIds:t.targetUserIds,unreadCount:(e=r==null?void 0:r.unreadCount)!=null?e:0});return r!=null&&r.message&&(i.latestMessage=ai.formatSocketServiceMessage(r.message)),delete i.chatChannelId,delete i.targetUserIds,delete i.latestMessageAndUnreadCount,i}getChannelMembers(t){return u(this,null,function*(){try{const e=yield a(this,Yi).sendMessagePromise(ws.getChannelMembers,PM.toBinary({chatChannelId:t}));return xM.fromBinary(e.payload).channelMembers.map(r=>{var i=r,{id:s}=i,n=vl(i,["id"]);return q(V({},n),{userId:s})})}catch{return[]}})}on(t,e){let r,i;switch(t){case ws.createChatChannel:{r=Jr.fromBinary.bind(Jr),i=Jr.create();break}case ws.updateChatChannel:{r=Jr.fromBinary.bind(Jr),i=Jr.create();break}}if(!r){this.logger.warn(`ChatChannelSocketHandler::Event ${t} is not recognized`);return}a(this,Yi).on(t,({payload:s})=>{let n=i;try{n=r(s)}catch(o){this.logger.error("ChatChannelSocketHandler::on::binary_decode_error",{error:o})}return e(n)})}},Yi=new WeakMap,_a=new WeakMap,Qm);let Ls=Xu;mp([k.trace("ChatChannelHandler.createChannel")],Ls.prototype,"createChannel",1);mp([k.trace("ChatChannelHandler.updateChannel")],Ls.prototype,"updateChannel",1);mp([k.trace("ChatChannelHandler.getChannelMembers")],Ls.prototype,"getChannelMembers",1);var iD=Object.defineProperty,sD=Object.getOwnPropertyDescriptor,Rr=(t,e,r,i)=>{for(var s=i>1?void 0:i?sD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&iD(e,r,s),s},_t=(t=>(t[t.TEXT=0]="TEXT",t[t.IMAGE=1]="IMAGE",t[t.FILE=2]="FILE",t[t.CUSTOM=3]="CUSTOM",t))(_t||{}),Tt,oo;class dr{constructor(e,r){g(this,Tt,void 0),g(this,oo,void 0),f(this,Tt,r),f(this,oo,e)}get telemetry(){return a(this,oo).getValue("telemetry")}get logger(){return a(this,oo).getValue("logger")}getChatMessages(){return a(this,Tt).sendMessagePromise(Ae.getMessages)}getChatMessagesPaginated(e,r,i,s=0,n=""){return u(this,null,function*(){const o={timeStamp:e,size:r,from:s,reversed:i,channelId:n},c=yield a(this,Tt).sendMessagePromise(Ae.getPaginatedMessages,KR.toBinary(o));return c.payload?YR.fromBinary(c.payload):{messages:[],next:!1}})}sendMessageToRoom(e,r){const i={payloadType:r,payload:e};a(this,Tt).sendMessage(Ae.sendMessageToRoom,ZR.toBinary(i))}sendMessageToPeers(e,r,i){const s={payloadType:r,peerIds:i,payload:e};a(this,Tt).sendMessage(Ae.sendMessageToPeers,rM.toBinary(s))}sendMessageToChannel(e,r,i){const s={payloadType:r,channelId:i,payload:e};a(this,Tt).sendMessage(Ae.sendMessageToChannel,nM.toBinary(s))}sendMessage(e,r,i,s){if(s&&this.sendMessageToChannel(e,r,s),i&&i.length>0){this.sendMessageToPeers(e,r,i);return}this.sendMessageToRoom(e,r)}editMessage(e,r,i,s,n){return u(this,null,function*(){const o={chatId:e,payloadType:i,payload:r};s&&(o.channelId=s),n!==void 0&&(o.pinned=n);const c=yield a(this,Tt).sendMessagePromise(Ae.editMessage,cM.toBinary(o));return Tc.fromBinary(c.payload).message})}deleteMessage(e,r){return u(this,null,function*(){const i={chatId:e};r&&(i.channelId=r);const s=yield a(this,Tt).sendMessagePromise(Ae.deleteMessage,mM.toBinary(i)),n=bc.fromBinary(s.payload);return V({id:n.chatId},n.channelId?{channelId:n.channelId}:{})})}searchMessages(e,r){return u(this,null,function*(){var i,s,n;const o={searchTerm:e,timeStamp:(i=r.timestamp)!=null?i:Date.now(),size:(s=r.size)!=null?s:75,from:0,reversed:(n=r.reversed)!=null?n:!0};r.channelId&&(o.channelId=r.channelId);try{const c=yield a(this,Tt).sendMessagePromise(Ae.searchChannelMessages,vM.toBinary(o));return Hv.fromBinary(c.payload).messages}catch{return[]}})}getAllChannels(){return u(this,null,function*(){try{const e=yield a(this,Tt).sendMessagePromise(Ae.getAllChatChannels);return Jr.fromBinary(e.payload).chatChannels.map(Ls.formatChannel)}catch{return[]}})}markLastReadMessage(e,r){return u(this,null,function*(){const i=yield a(this,Tt).sendMessagePromise(Ae.markChannelIndexAsRead,SM.toBinary({channelId:e,userId:r.userId,channelIndex:r.channelIndex}));return kM.fromBinary(i.payload).channelIndex})}setPinState(e,r){return u(this,null,function*(){const i={chatId:e.id,pinned:r,channelId:e.channelId},s=yield a(this,Tt).sendMessagePromise(Ae.pinMessage,lM.toBinary(i));return kc.fromBinary(s.payload)})}on(e,r){let i,s;switch(e){case Ae.sendMessageToRoom:{i=Ql.fromBinary.bind(Ql),s=Ql.create();break}case Ae.sendMessageToPeers:{i=Xl.fromBinary.bind(Xl),s=Xl.create();break}case Ae.editMessage:{i=Tc.fromBinary.bind(Tc),s=Tc.create();break}case Ae.pinMessage:{i=kc.fromBinary.bind(kc),s=kc.create();break}case Ae.deleteMessage:{i=bc.fromBinary.bind(bc),s=bc.create();break}}if(!i){this.logger.warn(`ChatSocketHandler::Event ${e} is not recognized`);return}a(this,Tt).on(e,({payload:n})=>{let o=s;try{o=i(n)}catch(c){this.logger.error("chatSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}}Tt=new WeakMap,oo=new WeakMap;Rr([k.trace("SocketService.getChatMessages")],dr.prototype,"getChatMessages",1);Rr([k.trace("SocketService.getChatMessagesPaginated")],dr.prototype,"getChatMessagesPaginated",1);Rr([k.trace("SocketService.sendMessageToRoom")],dr.prototype,"sendMessageToRoom",1);Rr([k.trace("SocketService.sendMessageToPeers")],dr.prototype,"sendMessageToPeers",1);Rr([k.trace("SocketService.sendMessageToChannel")],dr.prototype,"sendMessageToChannel",1);Rr([k.trace("SocketService.sendMessage")],dr.prototype,"sendMessage",1);Rr([k.trace("SocketService.editMessage")],dr.prototype,"editMessage",1);Rr([k.trace("SocketService.deleteMessage")],dr.prototype,"deleteMessage",1);Rr([k.trace("SocketService.searchMessages")],dr.prototype,"searchMessages",1);Rr([k.trace("SocketService.getAllChannels")],dr.prototype,"getAllChannels",1);Rr([k.trace("SocketService.markLastReadMessage")],dr.prototype,"markLastReadMessage",1);function nD(t){return t.replace(/([-_]\w)/g,e=>e[1].toUpperCase())}function _r(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>_r(r));const e={};return Object.keys(t).forEach(r=>{const i=Jh(r)?r:nD(r);e[i]=_r(t[r])}),e}function aD(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Jv(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>Jv(r));const e={};return Object.keys(t).forEach(r=>{const i=Jh(r)?r:aD(r);e[i]=t[r]}),e}function Xd(t,e={}){return t==null?{}:(Object.getOwnPropertyNames(t).forEach(r=>{if(typeof t[r]!="function"){if(typeof t[r]=="object"){Xd(t[r],e[r]={});return}e[r]=t[r]}}),e)}class Xm{constructor(e){p(this,"defaults"),this.defaults={baseURL:e.baseURL,headers:{common:{}},timeout:e.timeout,retry:e.retry,retryDelay:e.retryDelay}}buildURL(e,r){const{baseURL:i}=this.defaults,s=e.startsWith("http")?e:`${i}${e.startsWith("/")?e:`/${e}`}`;if(r){const n=new URLSearchParams;return Object.entries(r).forEach(([o,c])=>{n.append(o,c)}),`${s}${s.includes("?")?"&":"?"}${n.toString()}`}return s}request(e){return u(this,null,function*(){var r;const i=((r=e.method)==null?void 0:r.toUpperCase())||"GET",s=this.buildURL(e.url||"",e.params),n=V(V({},this.defaults.headers.common),e.headers);i!=="GET"&&i!=="HEAD"&&e.data&&!n["Content-Type"]&&(n["Content-Type"]="application/json");const o=n["Content-Type"]==="application/json"?JSON.stringify(e.data):e.data,c={method:i,headers:n,body:i!=="GET"&&i!=="HEAD"&&e.data?o:void 0},d=e.timeout||this.defaults.timeout,l=e.retry!==void 0?e.retry:this.defaults.retry,h=e.retryDelay||this.defaults.retryDelay;try{const m=new AbortController,v=setTimeout(()=>m.abort(),d);c.signal=m.signal;const S=yield fetch(s,c);clearTimeout(v);let T=null;const M=S.headers.get("content-type");M&&M.includes("application/json")?T=yield S.json():T=yield S.text();const b={};S.headers.forEach((j,W)=>{b[W]=j});const R={data:T,status:S.status,statusText:S.statusText,headers:b,config:e};if(!S.ok)throw R;return R}catch(m){if(m instanceof Error&&l>0)return yield new Promise(v=>setTimeout(v,h)),this.defaults.baseURL==="https://api.dyte.io"?this.defaults.baseURL="https://api.cluster.dyte.in":this.defaults.baseURL==="https://api.cluster.dyte.in"&&(this.defaults.baseURL="https://api.dyte.io"),this.request(q(V({},e),{retry:l-1}));throw m}})}get(e){return u(this,arguments,function*(r,i={}){return this.request(q(V({},i),{method:"GET",url:r}))})}post(e,r){return u(this,arguments,function*(i,s,n={}){return this.request(q(V({},n),{method:"POST",url:i,data:s}))})}put(e,r){return u(this,arguments,function*(i,s,n={}){return this.request(q(V({},n),{method:"PUT",url:i,data:s}))})}}const oD=3,cD=30,dD=8e3;class lD{constructor(e,r){p(this,"ipInfo"),p(this,"fetchClient"),p(this,"requests"),p(this,"roomName"),p(this,"roomUUID"),p(this,"authToken"),p(this,"organizationId"),p(this,"iceServers"),p(this,"pluginInformation"),p(this,"userDetails"),p(this,"roomDetails"),p(this,"context"),this.context=e;const{timeout:i=dD,retry:s=oD,retryDelay:n=cD,baseURL:o="https://api.dyte.io",authToken:c,cachedUserDetails:d}=r||{};this.iceServers=d==null?void 0:d.iceServers,this.pluginInformation=d==null?void 0:d.pluginInformation,this.userDetails=d==null?void 0:d.userDetails,this.roomDetails=d==null?void 0:d.roomDetails,this.requests=new Xm({baseURL:o,timeout:i,retry:s,retryDelay:n,responseType:"json"}),this.fetchClient=new Xm({baseURL:"",timeout:i,retry:s,retryDelay:n,responseType:"json"}),this.setAuthToken(c,{bearer:!0});const l=this.requests.request.bind(this.requests);this.requests.request=h=>u(this,null,function*(){var m,v,S,T,M;const b=e.getValue("telemetry");try{b.injectContext(this.requests.defaults.headers.common);const R=yield l(h);return h.url!==b.logsEndpoint&&this.logger.debug("xhr::fetch",{networkCall:{status:R.status,statusText:R.statusText,baseURL:h.baseURL||this.requests.defaults.baseURL,url:h.url,method:h.method}}),R}catch(R){throw R?(((m=R.config)==null?void 0:m.url)!==b.logsEndpoint&&this.logger.error("xhr::fetch",{error:R,networkCall:{status:R.status,statusText:R.statusText,baseURL:((v=R.config)==null?void 0:v.baseURL)||this.requests.defaults.baseURL,url:(S=R.config)==null?void 0:S.url,retries:(T=R.config)==null?void 0:T.retry,method:(M=R.config)==null?void 0:M.method,isOnline:navigator.onLine?"online":"offline"}}),new I(R.message||"Network request failed","0011")):new I("Unknown network error occurred","0011")}})}get peerId(){return this.context.getValue("peerId")}get logger(){return this.context.getValue("logger")}setAuthToken(e,r){const{bearer:i}=r||{};this.authToken=e,this.requests.defaults.headers.common.Authorization=i?`Bearer ${e}`:e}setHeader(e,r){this.requests.defaults.headers.common[e]=r}setRoomName(e){this.roomName=e}setRoomUUID(e){this.roomUUID=e}setOrganizationId(e){this.organizationId=e}}var uD=Object.defineProperty,hD=Object.getOwnPropertyDescriptor,lr=(t,e,r,i)=>{for(var s=i>1?void 0:i?hD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&uD(e,r,s),s};class Zt extends lD{constructor(e,r){super(e,r),p(this,"telemetry"),this.telemetry=e.getValue("telemetry"),this.setHeader("x-dyte-web-core-version",e.getValue("sdkVersion"))}getIPDetails(){return u(this,null,function*(){var e;const{peerId:r}=this;try{const i=yield ep.getIPDetails({peerId:r,apiHostnames:Pv(this.context),logger:Ev});if(this.logger.log("ipInfo",{ipInfo:i}),((e=i==null?void 0:i.loc)==null?void 0:e.length)>5)return i;throw Error("Insufficient data")}catch(i){this.logger.warn("ApiClient.getRoomNodeLinkAndTitleV1 Failed to get ip details",{error:{name:i.name,message:i.message}});return}})}getICEServers(){return u(this,null,function*(){if(this.iceServers)return this.iceServers;const{success:e,iceServers:r}=(yield this.requests.get("/iceservers")).data;if(e)return(r==null?void 0:r.length)>0&&(this.iceServers=r),r})}getPlugins(){return u(this,null,function*(){var e,r,i,s,n,o,c;if(this.pluginInformation)return this.pluginInformation;const{plugins:d}=(yield this.requests.get("/v2/plugins/user")).data.data,l=((r=(e=this.context.getValue("flagsmith").getValue(Z.V1_PLUGINS))==null?void 0:e.toString())==null?void 0:r.split(","))||[],h=d.reduce((m,v)=>(m[l.includes(v.id)?"v1":"v2"].push(q(V({},v),{name:v.name.replace("v2","")})),m),{v1:[],v2:[]});return(n=(s=(i=this.context.getValue("modules"))==null?void 0:i.devTools)==null?void 0:s.plugins)!=null&&n.length&&((c=(o=this.context.getValue("modules"))==null?void 0:o.devTools)==null||c.plugins.forEach(m=>{var v,S,T;const M=q(V({},ba),{tags:[...ba.tags],baseUrl:`http://localhost:${m.port}`,name:m.name,picture:(v=m.picture)!=null?v:ba.picture,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),id:m.id,organizationId:this.organizationId,description:(S=m.description)!=null?S:ba.description,staggered:(T=m.staggered)!=null?T:ba.staggered});h.v2.push(M)})),h.v2})}getPluginDetails(e){return u(this,null,function*(){const{plugin:r}=(yield this.requests.get(`/v2/plugins/view/${e}`)).data.data;return r})}getPluginConfig(e){return u(this,null,function*(){return(yield this.fetchClient.get(`${e}/dyte-config.json`)).data})}authorizePlugin(e){return u(this,null,function*(){const r={peerId:this.peerId},{token:i}=(yield this.requests.post(`/v2/plugins/authorize/${e}`,r)).data.data;return i})}getPresignedUrls(e,r){return u(this,null,function*(){const i=ea(this.context,"chat_upload_expiry"),s={roomUUID:this.roomUUID,filename:e,expiry:typeof i=="number"?i:void 0};this.context.getValue("flagsmith").hasFeature(Z.FEAT_CHAT_SDK)&&(s.viewType=r);const{getLocation:n,putLocation:o}=(yield this.requests.post("/v1/meetings/genPreSignedUploadUrl",s)).data.data;return{getLocation:n,putLocation:o}})}uploadFile(e,r){return u(this,null,function*(){if(navigator.isReactNative&&"uri"in e)try{yield fetch(r,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:{uri:e.uri,name:e.name}})}catch(i){this.logger.error(`sendFileMessage::${i}`)}else yield this.fetchClient.put(r,e,{headers:{"Content-Type":e.type}})})}startLivestreaming(e){return u(this,arguments,function*({manualIngestion:r}){const i=_r(yield this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/livestreams`,{manual_ingest:!!r})).data.data;return{playbackUrl:i.playbackUrl,status:i.status,manualIngest:i.manualIngest,ingestionCredentials:i.streamKey?{ingestionServer:i.ingestServer,streamKey:i.streamKey}:null}})}stopLivestreaming(){return u(this,null,function*(){return this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream/stop`)})}getActiveLivestream(){return u(this,null,function*(){const e=_r((yield this.requests.get(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream`)).data.data);return{playbackUrl:e.playbackUrl,status:e.status,manualIngest:e.manualIngest,ingestionCredentials:e.streamKey?{ingestionServer:e.ingestServer,streamKey:e.streamKey}:null}})}getUserDetails(){return u(this,null,function*(){if(this.userDetails)return this.userDetails;const e=(yield this.requests.get("v2/internals/participant-details")).data.data;return _r(e)})}startRecording(e,r){return u(this,null,function*(){return(yield this.requests.post("/v2/recordings",q(V({},Jv(e)),{meeting_id:this.context.getValue("meetingId"),allow_multiple_recordings:!!r}))).data.data.id})}updateRecording(e,r){return u(this,null,function*(){return this.requests.put(`v2/recordings/${e}`,{action:r})})}getActiveRecording(){return u(this,null,function*(){const{status:e,id:r}=(yield this.requests.get(`v2/recordings/active-recording/${this.context.getValue("meetingId")}`)).data.data;return{status:e,id:r}})}getActiveTranscript(){return u(this,null,function*(){const{transcript_download_url:e}=(yield this.requests.get(`v2/meetings/${this.context.getValue("meetingId")}/active-transcript`)).data.data;try{return{transcript:(yield this.fetchClient.get(e)).data}}catch{throw new I("Cant fetch transcript s3 url","1801")}})}getRoomNodeData(){return u(this,null,function*(){const e=yield this.getIPDetails();if(this.ipInfo=e,this.roomDetails)return this.roomDetails;const{roomNodeLink:r,title:i,useHiveMedia:s,sfu:n}=_r((yield this.requests.post("v2/internals/rooms",{ip_information:e})).data.data);return{roomNodeUrl:r,meetingTitle:i,useHiveMedia:s!=null?s:!1,sfu:n}})}}lr([k.trace("APIClient.getIPDetails")],Zt.prototype,"getIPDetails",1);lr([k.trace("APIClient.getICEServers")],Zt.prototype,"getICEServers",1);lr([k.trace("APIClient.getPlugins")],Zt.prototype,"getPlugins",1);lr([k.trace("APIClient.startLivestreaming")],Zt.prototype,"startLivestreaming",1);lr([k.trace("APIClient.stopLivestreaming")],Zt.prototype,"stopLivestreaming",1);lr([k.trace("APIClient.getActiveLivestream")],Zt.prototype,"getActiveLivestream",1);lr([k.trace("APIClient.getUserDetails")],Zt.prototype,"getUserDetails",1);lr([k.trace("APIClient.startRecording")],Zt.prototype,"startRecording",1);lr([k.trace("APIClient.stopRecording")],Zt.prototype,"updateRecording",1);lr([k.trace("APIClient.getActiveRecording")],Zt.prototype,"getActiveRecording",1);lr([k.trace("APIClient.getActiveTranscript")],Zt.prototype,"getActiveTranscript",1);lr([k.trace("APIClient.getRoomNodeData")],Zt.prototype,"getRoomNodeData",1);let Zu;function pD(t,e){return Zu=new Zt(t,e),Zu}function ht(){return Zu}function mD(t,e){return`<blockquote>${e.replace(/<blockquote>[.\s\S]*<\/blockquote>\n\n/m,"")}</blockquote>
14
14
 
15
15
  ${t}`}const na={maxInvocations:5,period:1};function Bt(t,e){return function(r,i,s){const n=s.value;let o=0,c=Date.now();return s.value=function(...d){const l=Date.now(),h=e?this[e]:t;if(l-c>h.period*1e3&&(c=l,o=0),o>=h.maxInvocations)throw new I(`Method rate limit ${h.maxInvocations} invocations/${h.period}sec exceeded`,"0013");return o+=1,n.apply(this,d)},s}}var gD=Object.defineProperty,fD=Object.getOwnPropertyDescriptor,ft=(t,e,r,i)=>{for(var s=i>1?void 0:i?fD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&gD(e,r,s),s};const vD=["text","image","file","custom","poll"],Xc={maxInvocations:180,period:60};var ee,Js,ze,Ks,zs,tu,Zm,wc,ru,eg;let st=(eg=class extends Xt{constructor(t,e,r,i,s){const n=t.getValue("logger");super(n),g(this,tu),g(this,wc),p(this,"messages"),p(this,"channels",[]),g(this,ee,void 0),g(this,Js,void 0),g(this,ze,void 0),g(this,Ks,void 0),g(this,zs,void 0),p(this,"maxTextLimit",2e3),f(this,zs,t),f(this,ze,e),f(this,Ks,r),f(this,ee,i),f(this,Js,s),this.messages=[]}get telemetry(){return a(this,zs).getValue("telemetry")}setMaxTextLimit(t){this.maxTextLimit=t}sendMessageInternal(t,e,r){return u(this,arguments,function*(i,s,n,o={}){switch(i.type){case"text":{const c=o.replyTo&&o.replyTo.type==="text"?mD(i.message,o.replyTo.message):i.message;yield this.sendTextMessageInternal(c,s,n);break}case"image":yield this.sendImageMessageInternal(i.image,s,n);break;case"file":yield this.sendFileMessageInternal(i.file,s,n);break;default:this.logger.error("sendMessage::message_type_not_supported",{dyteChat:{messageType:i.type}});break}})}sendTextMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(t.length>this.maxTextLimit)throw new I("Max character limit breached","0503");if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.text))throw this.logger.error("sendTextMessage::private_chat_permission_denied"),new I("Could not send message to private chat.","0501")}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.text))throw this.logger.error("sendTextMessage::public_chat_permission_denied"),new I("Could not send message to public chat.","0501");if(!t)throw this.logger.error("sendTextMessage::message_can_not_be_empty"),new I("Message can not be empty.","0502");if(r){a(this,ze).sendMessageToChannel(t,_t.TEXT,r);return}let l=[];e&&e.length>0&&(e.push(a(this,ee).id),l=a(this,Js).joined.toArray().filter(h=>e.includes(h.id)).map(h=>h.userId),l.push(a(this,ee).userId)),a(this,ze).sendMessage(t,_t.TEXT,e)})}sendImageMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.files)){this.logger.error("sendImageMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){this.logger.error("sendImageMessage::permission_denied");return}if(!t){this.logger.error("sendImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(t.type)){this.logger.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:t.type}});return}try{const l=ht(),{getLocation:h,putLocation:m}=yield l.getPresignedUrls(t.name,a(this,ee).config.viewType);if(yield l.uploadFile(t,m),r){a(this,ze).sendMessageToChannel(h,_t.IMAGE,r);return}let v=[];e&&e.length>0&&(e.push(a(this,ee).id),v=a(this,Js).joined.toArray().filter(S=>e.includes(S.id)).map(S=>S.userId),v.push(a(this,ee).userId)),a(this,ze).sendMessage(h,_t.IMAGE,e)}catch{throw new I("Error sending image message.","0500",this.logger)}})}sendFileMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.files)){this.logger.error("sendFileMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){this.logger.error("sendFileMessage::permission_denied");return}if(!t){this.logger.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const l=ht(),{getLocation:h,putLocation:m}=yield l.getPresignedUrls(t.name,a(this,ee).config.viewType);if(yield l.uploadFile(t,m),r){a(this,ze).sendMessageToChannel(JSON.stringify({link:h,name:t.name,size:"size"in t?t.size:0}),_t.FILE,r);return}let v=[];e&&e.length>0&&(e.push(a(this,ee).id),v=a(this,Js).joined.toArray().filter(T=>e.includes(T.id)).map(T=>T.userId),v.push(a(this,ee).userId));const S=JSON.stringify({link:h,name:t.name,size:"size"in t?t.size:0});a(this,ze).sendMessage(S,_t.FILE,e)}catch{throw new I("Error sending file message.","0500",this.logger)}})}get rateLimits(){return Xc}updateRateLimits(t,e){Xc.maxInvocations=t,Xc.period=e}sendTextMessage(t,e){return u(this,null,function*(){return this.sendTextMessageInternal(t,e)})}sendCustomMessage(t,e){return u(this,null,function*(){var r,i,s,n,o,c,d,l,h,m,v,S,T,M,b;if(e&&e.length>0){if(!((r=a(this,ee).permissions)!=null&&r.chatPrivate.canSend)||!((i=a(this,ee).permissions)!=null&&i.chatPrivate.files)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.text)){this.logger.error("sendCustomMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)||!((h=(l=a(this,ee).permissions)==null?void 0:l.chatPublic)!=null&&h.text)){this.logger.error("sendCustomMessage::permission_denied");return}const R=W=>u(this,null,function*(){try{if(typeof W=="string")return{link:W};const w=ht(),{getLocation:te,putLocation:re}=yield w.getPresignedUrls(W.name,a(this,ee).config.viewType);return yield w.uploadFile(W,re),{link:te,type:W.type,name:W.name,size:W.size}}catch{throw new I("Error sending image message.","0500",this.logger)}}),j=q(V({},t),{files:yield Promise.all((v=(m=t.files)!=null?m:[])==null?void 0:v.map(W=>u(this,null,function*(){return R(W)}))),images:yield Promise.all((T=(S=t.images)!=null?S:[])==null?void 0:T.map(W=>u(this,null,function*(){return R(W)}))),videos:yield Promise.all((b=(M=t.videos)!=null?M:[])==null?void 0:b.map(W=>u(this,null,function*(){return R(W)})))});a(this,ze).sendMessage(JSON.stringify(j),_t.CUSTOM,e)})}sendImageMessage(t,e){return u(this,null,function*(){return this.sendImageMessageInternal(t,e)})}sendFileMessage(t,e){return u(this,null,function*(){return this.sendFileMessageInternal(t,e)})}sendMessage(t,e){return u(this,null,function*(){return this.sendMessageInternal(t,e)})}editTextMessage(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(((s=(i=a(this,ee).permissions)==null?void 0:i.chatMessage)==null?void 0:s.canEdit)==="NONE")throw new I("Not permitted to edit messages","0501");if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.text)){this.logger.error("editTextMessage::permission_denied");return}if(!e){this.logger.error("editTextMessage::message_can_not_be_empty");return}a(this,ze).editMessage(t,e,_t.TEXT,r)})}editImageMessage(t,e,r){return u(this,null,function*(){var i,s,n,o;if(!((s=(i=a(this,ee).permissions)==null?void 0:i.chatPublic)!=null&&s.canSend)||!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.files)){this.logger.error("editImageMessage::permission_denied");return}if(!e){this.logger.error("editImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(e.type)){this.logger.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:e.type}});return}try{const c=ht(),{getLocation:d,putLocation:l}=yield c.getPresignedUrls(e.name,a(this,ee).config.viewType);yield c.uploadFile(e,l),a(this,ze).editMessage(t,d,_t.IMAGE,r)}catch{throw new I("Error editing image message.","0500",this.logger)}})}editFileMessage(t,e,r){return u(this,null,function*(){var i,s,n,o;if(!((s=(i=a(this,ee).permissions)==null?void 0:i.chatPublic)!=null&&s.canSend)||!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.files)){this.logger.error("sendFileMessage::permission_denied");return}if(!e){this.logger.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const c=ht(),{getLocation:d,putLocation:l}=yield c.getPresignedUrls(e.name,a(this,ee).config.viewType);yield c.uploadFile(e,l),a(this,ze).editMessage(t,JSON.stringify({link:d,name:e.name,size:"size"in e?e.size:0}),_t.FILE,r)}catch{throw new I("Error editing file message.","0500",this.logger)}})}editMessage(t,e,r){return u(this,null,function*(){switch(e.type){case"text":{this.editTextMessage(t,e.message,r);break}case"image":{this.editImageMessage(t,e.image,r);break}case"file":{this.editFileMessage(t,e.file,r);break}default:{this.logger.error("editMessage::message_type_not_supported",{dyteChat:{messageType:e.type}});break}}})}deleteMessage(t,e){return u(this,null,function*(){var r,i;if(((i=(r=a(this,ee).permissions)==null?void 0:r.chatMessage)==null?void 0:i.canDelete)==="NONE")throw new I("Not permitted to delete messages","0501");a(this,ze).deleteMessage(t,e)})}getMessagesByUser(t){return this.messages.filter(e=>e.userId===t)}getMessagesByType(t){return this.messages.filter(e=>e.type===t)}pin(t){return u(this,null,function*(){if(!a(this,wc,ru))throw new I("Can`t pin message without joining room","0505");if(!a(this,ee).permissions.pinParticipant)throw new I("You do not have permission to pin messages.","0501");const e=this.messages.find(r=>r.id===t);if(e){a(this,ze).setPinState(e,!0);return}throw new I(`No message found with id: ${t}`,"0504")})}unpin(t){return u(this,null,function*(){if(!a(this,wc,ru))throw new I("Can`t unpin message without joining room","0505");if(!a(this,ee).permissions.pinParticipant)throw new I("You do not have permission to unpin messages.","0501");const e=this.messages.find(r=>r.id===t);if(e){a(this,ze).setPinState(e,!1);return}throw new I(`No message found with id: ${t}`,"0504")})}getMessages(t,e,r,i=0,s=void 0){return u(this,null,function*(){const n=yield a(this,ze).getChatMessagesPaginated(t,e,r,i,s);return{messages:n.messages.map(o=>ai.formatSocketServiceMessage(o)),next:n.next}})}createChannel(t,e){return u(this,arguments,function*(r,i,s={}){var n;const o=(n=a(this,ee).permissions)==null?void 0:n.chatChannel;if(o){if(o.canCreate==="NONE")throw new I("Not permitted to create channels","0501");if(s.visibility==="public"&&!(o.canCreate==="PUBLIC"||o.canCreate==="ALL"))throw new I("Not permitted to create public channels","0501");if(s.visibility==="private"&&!(o.canCreate==="PRIVATE"||o.canCreate==="ALL"))throw new I("Not permitted to create private channels","0501")}if(!r||r.trim().length===0)throw new I("channel name cannot be empty.","0510");const c=[...new Set([...i,a(this,ee).userId])];return yield a(this,Ks).createChannel(r.trim(),c,s.displayPictureUrl,s.visibility,s.isDirectMessage)})}updateChannel(t,e){var r,i,s,n,o;const c=this.channels.find(h=>h.id===t),d=(r=a(this,ee).permissions)==null?void 0:r.chatChannel;if(d){if(d.canUpdate==="NONE")throw new I("Not permitted to update channels","0501");if(c.visibility==="public"&&!(d.canUpdate==="PUBLIC"||d.canUpdate==="ALL"))throw new I("Not permitted to update public channels","0501");if(c.visibility==="private"&&!(d.canUpdate==="PRIVATE"||d.canUpdate==="ALL"))throw new I("Not permitted to update private channels","0501")}const l={memberIds:(i=e.memberIds)!=null?i:c.memberIds,displayName:(s=e.displayName)!=null?s:c.displayName,displayPictureUrl:(n=e.displayPictureUrl)!=null?n:c.displayPictureUrl,visibility:(o=e.visibility)!=null?o:c.visibility};return a(this,Ks).updateChannel(t,l)}sendMessageToChannel(t,e){return u(this,arguments,function*(r,i,s={}){return this.sendMessageInternal(r,null,i,s)})}getChannelMembers(t){return u(this,null,function*(){return a(this,Ks).getChannelMembers(t)})}searchMessages(t){return u(this,arguments,function*(e,r={}){if(!a(this,zs).getValue("flagsmith").hasFeature(Z.FEAT_CHAT_SDK_SEARCH))throw new I("searchMessages is temporarily disabled!","0506");return(yield a(this,ze).searchMessages(e,r)).map(ai.formatSocketServiceMessage)})}markLastReadMessage(t,e){return u(this,null,function*(){yield a(this,ze).markLastReadMessage(t,e);const r=this.channels.find(i=>i.id===t);if(r){const i=q(V({},r),{unreadCount:0});this.channels=this.channels.map(s=>s.id===t?i:s),this.emit("channelMessageUpdate",i)}})}get pinned(){return this.messages.filter(t=>t.pinned)}},ee=new WeakMap,Js=new WeakMap,ze=new WeakMap,Ks=new WeakMap,zs=new WeakMap,tu=new WeakSet,Zm=function(){return a(this,zs).getValue("connectionHandler")},wc=new WeakSet,ru=function(){return a(this,tu,Zm).socketJoined===!0},eg);ft([k.trace("DyteChat.sendTextMessage"),Bt(Xc)],st.prototype,"sendTextMessage",1);ft([k.trace("DyteChat.sendImageMessage"),Bt({maxInvocations:20,period:60})],st.prototype,"sendImageMessage",1);ft([k.trace("DyteChat.sendFileMessage"),Bt({maxInvocations:20,period:60})],st.prototype,"sendFileMessage",1);ft([k.trace("DyteChat.sendMessage"),Bt({maxInvocations:180,period:60})],st.prototype,"sendMessage",1);ft([k.trace("DyteChat.editTextMessage")],st.prototype,"editTextMessage",1);ft([k.trace("DyteChat.editImageMessage")],st.prototype,"editImageMessage",1);ft([k.trace("DyteChat.editFileMessage")],st.prototype,"editFileMessage",1);ft([k.trace("DyteChat.editMessage")],st.prototype,"editMessage",1);ft([k.trace("DyteChat.deleteMessage")],st.prototype,"deleteMessage",1);ft([k.trace("DyteChat.createChannel")],st.prototype,"createChannel",1);ft([k.trace("DyteChat.updateChannel")],st.prototype,"updateChannel",1);ft([k.trace("DyteChat.sendMessageToChannel")],st.prototype,"sendMessageToChannel",1);ft([k.trace("DyteChat.getChannelMembers")],st.prototype,"getChannelMembers",1);ft([k.trace("DyteChat.searchMessages")],st.prototype,"searchMessages",1);ft([k.trace("DyteChat.markLastReadMessage")],st.prototype,"markLastReadMessage",1);st=ft([gt("0500")],st);var yD=Object.defineProperty,SD=Object.getOwnPropertyDescriptor,ED=(t,e,r,i)=>{for(var s=i>1?void 0:i?SD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&yD(e,r,s),s},Qi,tg;const ds=(tg=class{constructor(t,e,r,i,s){p(this,"chat"),p(this,"chatSocketHandler"),p(this,"chatChannelSocketHandler"),p(this,"self"),g(this,Qi,void 0),f(this,Qi,t),this.chatSocketHandler=e,this.chatChannelSocketHandler=r,this.chat=new st(t,e,r,i,s),this.self=i,this.setupEvents()}get telemetry(){return a(this,Qi).getValue("telemetry")}get logger(){return a(this,Qi).getValue("logger")}static init(t,e,r,i,s){return u(this,null,function*(){return new ds(t,e,r,i,s)})}static formatMessage(t){return q(V({},t),{time:new Date(t.time),type:vD[t.type]})}static formatSocketServiceMessage(t){const e=t.createdAt*1e3,r={displayName:t.displayName,id:t.chatId,time:e,timeMs:t.createdAtMs,type:t.payloadType,isEdited:t.isEdited,userId:t.userId,targetUserIds:t.targetUserIds,channelId:t.channelId,channelIndex:t.channelIndex,message:"",link:"",name:"",html:"",images:[],videos:[],files:[],size:0,pinned:t.pinned};switch(r.type){case _t.TEXT:{r.message=t.payload;break}case _t.IMAGE:{r.link=t.payload;break}case _t.FILE:{const{link:i,name:s,size:n}=JSON.parse(t.payload);r.link=i,r.name=s,r.size=n;break}case _t.CUSTOM:{const{html:i,images:s,message:n,videos:o,files:c}=JSON.parse(t.payload);r.message=n,r.html=i,r.images=s,r.videos=o,r.files=c;break}}return ds.formatMessage(r)}getChatMessages(){return u(this,null,function*(){if(this.self.config.viewType==="LIVESTREAM"||this.self.config.viewType==="CHAT"||a(this,Qi).getValue("flagsmith").hasFeature(Z.FEAT_PAGINATED_CHAT))return;const t=yield this.chatSocketHandler.getChatMessages();if(!(t!=null&&t.payload))return;const e=Hv.fromBinary(t.payload).messages;this.chat.messages=e.map(r=>ds.formatSocketServiceMessage(r))})}setupEvents(){a(this,Qi).getValue("peerSessionStore").on(P.SOCKET_SERVICE_ROOM_JOINED,()=>u(this,null,function*(){this.getChatMessages()})),this.chatSocketHandler.on(Ae.sendMessageToRoom,t=>{const e=ds.formatSocketServiceMessage(t.message);if(!e.channelId)this.chat.messages=[...this.chat.messages,e];else{const r=this.chat.channels.find(i=>i.id===e.channelId);r&&(r.latestMessage=e,r.unreadCount+=1,this.chat.emit("channelMessageUpdate",r))}this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ae.sendMessageToPeers,t=>{const e=ds.formatSocketServiceMessage(t.message);this.chat.messages=[...this.chat.messages,e],this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ae.editMessage,t=>{const e=ds.formatSocketServiceMessage(t.message);if(e.channelId){this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages});return}const r=this.chat.messages.findIndex(i=>i.id===e.id);r!==-1&&(this.chat.messages[r]=e,this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages}))}),this.chatSocketHandler.on(Ae.deleteMessage,t=>{if(t.channelId){this.chat.emit("chatUpdate",{action:"delete",message:{id:t.chatId,channelId:t.channelId},messages:this.chat.messages});return}const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const[r]=this.chat.messages.splice(e,1);this.chat.emit("chatUpdate",{action:"delete",message:r,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ws.createChatChannel,t=>{const[e]=t.chatChannels,r=Ls.formatChannel(e);this.chat.channels.push(r),this.chat.emit("channelCreate",r)}),this.chatSocketHandler.on(Ae.pinMessage,t=>{const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const r=this.chat.messages[e];r.pinned=t.pinned,this.chat.messages[e]=r,this.chat.emit("chatUpdate",{action:"edit",message:r,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ws.updateChatChannel,t=>{const[e]=t.chatChannels,r=Ls.formatChannel(e);this.chat.channels=this.chat.channels.map(i=>i.id===r.id?r:i),this.chat.emit("channelUpdate",r)})}},Qi=new WeakMap,tg);let ai=ds;ED([k.trace("ChatController.setupEvents")],ai.prototype,"setupEvents",1);var kD=Object.defineProperty,TD=Object.getOwnPropertyDescriptor,bD=(t,e,r,i)=>{for(var s=i>1?void 0:i?TD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&kD(e,r,s),s},iu,rg,su,ig,Ia,Ca,_c,sg;let eh=(sg=class extends Xt{constructor(t,e,r){const i=t.getValue("logger");super(i),g(this,iu),g(this,su),p(this,"items"),g(this,Ia,void 0),g(this,Ca,void 0),g(this,_c,void 0),f(this,_c,t),f(this,Ia,e),f(this,Ca,r),this.items=[]}create(t,e,r=!1,i=!1){return u(this,null,function*(){if(!a(this,su,ig))throw new I("Can't create polls without joining room","0705");if(!a(this,Ia).permissions.polls.canCreate){this.logger.error("DytePolls::create::permission_denied");return}if(!t||!e){this.logger.error("DytePolls::question_and_options_can_not_be_empty",{dytePolls:{hasQuestion:!!t,optionsLength:e==null?void 0:e.length}});return}if(e.length<2){this.logger.error("DytePolls::there_must_be_at_least_two_options",{dytePolls:{hasQuestion:!!t,optionsLength:e.length}});return}yield a(this,Ca).createPoll(t,e,r,i)})}vote(t,e){return u(this,null,function*(){if(!a(this,Ia).permissions.polls.canVote){this.logger.error("DytePolls::vote::permission_denied");return}yield a(this,Ca).votePoll(t,e)})}},iu=new WeakSet,rg=function(){return a(this,_c).getValue("connectionHandler")},su=new WeakSet,ig=function(){var t;return((t=a(this,iu,rg))==null?void 0:t.socketJoined)===!0},Ia=new WeakMap,Ca=new WeakMap,_c=new WeakMap,sg);eh=bD([gt("0700")],eh);var wD=Object.defineProperty,_D=Object.getOwnPropertyDescriptor,ID=(t,e,r,i)=>{for(var s=i>1?void 0:i?_D(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&wD(e,r,s),s},Xi,Pa,Ys,ng;const Sn=(ng=class{constructor(t,e,r){p(this,"polls"),g(this,Xi,void 0),g(this,Pa,void 0),g(this,Ys,void 0),this.polls=new eh(t,e,r),f(this,Pa,e),f(this,Xi,t),f(this,Ys,r),this.setupEvents()}get telemetry(){return a(this,Xi).getValue("telemetry")}get logger(){return a(this,Xi).getValue("logger")}static init(t,e,r){return u(this,null,function*(){return new Sn(t,e,r)})}canViewPolls(){return a(this,Pa).permissions.polls.canView}setupEvents(){const t={[Zr.createPoll]:i=>{i.poll&&this.updatePoll(Sn.formatSocketServicePoll(i.poll))},[Zr.updatePoll]:i=>{i.poll&&this.updatePoll(Sn.formatSocketServicePoll(i.poll))},[Zr.votePoll]:i=>{i.poll&&this.updatePoll(Sn.formatSocketServicePoll(i.poll))}},e=()=>{a(this,Xi).getValue("peerSessionStore").on(P.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{a(this,Ys).on(i,t[i])})},r=()=>{a(this,Xi).getValue("peerSessionStore").on(P.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{a(this,Ys).removeListeners(i)})};a(this,Pa).permissions.on("permissionsUpdate",i=>u(this,null,function*(){var s;(s=i==null?void 0:i.polls)!=null&&s.canView?(yield this.getPolls(),e()):(this.polls.items=[],r())})),this.canViewPolls()&&e()}updatePoll(t){if(!this.canViewPolls())return;const e=this.polls.items.findIndex(r=>r.id===t.id);if(e>-1){const r=JSON.stringify(this.polls.items[e]);this.polls.items[e]=t,r!==JSON.stringify(t)&&this.polls.emit("pollsUpdate",{polls:this.polls.items,newPoll:!1});return}this.polls.items=[...this.polls.items,t],this.polls.emit("pollsUpdate",{polls:this.polls.items,newPoll:!0})}getPolls(){return u(this,null,function*(){const t=yield a(this,Ys).getPolls();if(!(t!=null&&t.payload))return;const{polls:e}=xA.fromBinary(t.payload);this.polls.items=e.map(r=>Sn.formatSocketServicePoll(r))})}static formatSocketServicePoll(t){const e=t.options.map(r=>({count:r.count,text:r.text,votes:r.votes.map(i=>({id:i.userId,name:i.name}))}));return{anonymous:t.anonymous,createdBy:t.createdBy,createdByUserId:t.createdByUserId,hideVotes:t.hideVotes,id:t.pollId,options:e,question:t.question,voted:t.votes}}},Xi=new WeakMap,Pa=new WeakMap,Ys=new WeakMap,ng);let Kv=Sn;ID([k.trace("PollController.setupEvents")],Kv.prototype,"setupEvents",1);var CD=Object.defineProperty,PD=Object.getOwnPropertyDescriptor,RD=(t,e,r,i)=>{for(var s=i>1?void 0:i?PD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&CD(e,r,s),s},zv=(t=>(t[t.User=0]="User",t[t.Meeting=1]="Meeting",t))(zv||{}),Ra,Ic,nu,Qs,Cc,ag;let th=(ag=class extends Xt{constructor(t,e,r,i,s){const n=t.getValue("logger");super(n),g(this,Ic),p(this,"selfActiveTab"),p(this,"broadcastTabChanges"),g(this,Ra,void 0),g(this,Qs,void 0),g(this,Cc,void 0),p(this,"viewType"),p(this,"meetingStartedTimestamp"),p(this,"meetingTitle"),p(this,"sessionId"),f(this,Ra,t),f(this,Qs,e),this.viewType=r,f(this,Cc,i),this.meetingTitle=s,this.broadcastTabChanges=e.permissions.canSpotlight}get socketState(){return a(this,Ic,nu).socketState}get mediaState(){return a(this,Ic,nu).mediaState}get meetingId(){return a(this,Ra).getValue("meetingId")}setBroadcastTabChanges(t){if(!a(this,Qs).permissions.canSpotlight)throw this.logger.error("DyteSpotlight::setSpotlighted::permission_denied"),new I("User does not have permission to toggle spotlight","0801");this.broadcastTabChanges=t,this.emit("broadcastTabChangesUpdate",this.broadcastTabChanges),this.broadcastTabChanges&&this.assertActiveTabToRoom()}setSelfActiveTab(t,e){var r;this.logger.info("DyteSpotlight::setActiveTab",{spotlight:{currentTab:{id:t.id,type:t.type}}}),this.selfActiveTab=t,e===0&&this.emit("selfTabUpdate",t),(r=a(this,Qs).permissions)!=null&&r.canSpotlight&&this.broadcastTabChanges&&e===0&&this.assertActiveTabToRoom()}assertActiveTabToRoom(){a(this,Cc).broadcastMessage("spotlight",{userId:a(this,Qs).userId,currentTab:this.selfActiveTab})}},Ra=new WeakMap,Ic=new WeakSet,nu=function(){return a(this,Ra).getValue("connectionHandler")},Qs=new WeakMap,Cc=new WeakMap,ag);th=RD([gt("0800")],th);function MD(t){let e="",r=[""];const i=[r];let s=0,n=0,o=!0,c;for(c of t)c==='"'?(o&&c===e&&(r[s]+=c),o=!o):c===","&&o?c=r[++s]="":c===`
package/dist/index.es.js CHANGED
@@ -9710,15 +9710,8 @@ const TC = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d=
9710
9710
  init(t, e, r) {
9711
9711
  this.tracingEnabled = true, this.initialized = false, this.logsCache = [];
9712
9712
  const i = t.getValue("peerId");
9713
- this.meetingMetadata = e, this.tracingEnabled = r, this.meetingMetadata.peerId = i, this.meetingMetadata.sdkVersion = t.getValue("sdkVersion"), this.meetingMetadata.deviceInfo = Te.getDeviceInfo(), this.meetingMetadata.visitedUrl = !navigator.isReactNative && typeof window != "undefined" && window.location.href, navigator.isReactNative || document.addEventListener(
9714
- "visibilitychange",
9715
- () => {
9716
- this.processCachedLogs.bind(this);
9717
- }
9718
- ), this.logsProcessorTimer = setInterval(
9719
- () => {
9720
- this.processCachedLogs.bind(this);
9721
- },
9713
+ this.meetingMetadata = e, this.tracingEnabled = r, this.meetingMetadata.peerId = i, this.meetingMetadata.sdkVersion = t.getValue("sdkVersion"), this.meetingMetadata.deviceInfo = Te.getDeviceInfo(), this.meetingMetadata.visitedUrl = !navigator.isReactNative && typeof window != "undefined" && window.location.href, this.logsProcessorTimer = setInterval(
9714
+ this.processCachedLogs.bind(this),
9722
9715
  this.logsProcessingInterval
9723
9716
  ), r && (this.initialized = true);
9724
9717
  }
@@ -9817,12 +9810,7 @@ const TC = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d=
9817
9810
  t != null && t.length && this.sendOtelLogsToNewRelic(t);
9818
9811
  }
9819
9812
  destruct() {
9820
- clearInterval(this.logsProcessorTimer), this.processCachedLogs(), navigator.isReactNative || document.removeEventListener(
9821
- "visibilitychange",
9822
- () => {
9823
- this.processCachedLogs.bind(this);
9824
- }
9825
- );
9813
+ clearInterval(this.logsProcessorTimer), this.processCachedLogs();
9826
9814
  }
9827
9815
  };
9828
9816
  let T = Kh;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/realtimekit-react",
3
- "version": "1.1.0-staging.20",
3
+ "version": "1.1.0-staging.22",
4
4
  "description": "A real-time video and audio SDK for building custom, collaborative communication experiences.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "private": false,
19
19
  "dependencies": {
20
- "@cloudflare/realtimekit": "1.1.0-staging.20"
20
+ "@cloudflare/realtimekit": "1.1.0-staging.22"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": ">=16.8.6"