@cloudflare/realtimekit-react 0.5.0-staging.101 → 0.5.0-staging.102

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
@@ -1,30 +1,29 @@
1
- "use strict";var DS=Object.defineProperty;var NS=(t,e,n)=>e in t?DS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Pc=(t,e,n)=>(NS(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var zt=require("react");function LS(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var xS=LS(zt),Ac,VS=new Uint8Array(16);function US(){if(!Ac&&(Ac=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ac))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ac(VS)}var BS=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Op(t){return typeof t=="string"&&BS.test(t)}var Rt=[];for(var cu=0;cu<256;++cu)Rt.push((cu+256).toString(16).substr(1));function FS(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Rt[t[e+0]]+Rt[t[e+1]]+Rt[t[e+2]]+Rt[t[e+3]]+"-"+Rt[t[e+4]]+Rt[t[e+5]]+"-"+Rt[t[e+6]]+Rt[t[e+7]]+"-"+Rt[t[e+8]]+Rt[t[e+9]]+"-"+Rt[t[e+10]]+Rt[t[e+11]]+Rt[t[e+12]]+Rt[t[e+13]]+Rt[t[e+14]]+Rt[t[e+15]]).toLowerCase();if(!Op(n))throw TypeError("Stringified UUID is invalid");return n}function Ca(t,e,n){t=t||{};var i=t.random||(t.rng||US)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){n=n||0;for(var r=0;r<16;++r)e[n+r]=i[r];return e}return FS(i)}const jS={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},av={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},tt={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},Ft={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},Yi={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class j{static getFirstMatch(e,n){const i=n.match(e);return i&&i.length>0&&i[1]||""}static getSecondMatch(e,n){const i=n.match(e);return i&&i.length>1&&i[2]||""}static matchAndReturnConst(e,n,i){if(e.test(n))return i}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(e){const n=e.split(".").splice(0,2).map(i=>parseInt(i,10)||0);if(n.push(0),n[0]===10)switch(n[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(e){const n=e.split(".").splice(0,2).map(i=>parseInt(i,10)||0);if(n.push(0),!(n[0]===1&&n[1]<5)){if(n[0]===1&&n[1]<6)return"Cupcake";if(n[0]===1&&n[1]>=6)return"Donut";if(n[0]===2&&n[1]<2)return"Eclair";if(n[0]===2&&n[1]===2)return"Froyo";if(n[0]===2&&n[1]>2)return"Gingerbread";if(n[0]===3)return"Honeycomb";if(n[0]===4&&n[1]<1)return"Ice Cream Sandwich";if(n[0]===4&&n[1]<4)return"Jelly Bean";if(n[0]===4&&n[1]>=4)return"KitKat";if(n[0]===5)return"Lollipop";if(n[0]===6)return"Marshmallow";if(n[0]===7)return"Nougat";if(n[0]===8)return"Oreo";if(n[0]===9)return"Pie"}}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,n,i=!1){const r=j.getVersionPrecision(e),s=j.getVersionPrecision(n);let a=Math.max(r,s),c=0;const d=j.map([e,n],h=>{const u=a-j.getVersionPrecision(h),g=h+new Array(u+1).join(".0");return j.map(g.split("."),E=>new Array(20-E.length).join("0")+E).reverse()});for(i&&(c=a-Math.min(r,s)),a-=1;a>=c;){if(d[0][a]>d[1][a])return 1;if(d[0][a]===d[1][a]){if(a===c)return 0;a-=1}else if(d[0][a]<d[1][a])return-1}}static map(e,n){const i=[];let r;if(Array.prototype.map)return Array.prototype.map.call(e,n);for(r=0;r<e.length;r+=1)i.push(n(e[r]));return i}static find(e,n){let i,r;if(Array.prototype.find)return Array.prototype.find.call(e,n);for(i=0,r=e.length;i<r;i+=1){const s=e[i];if(n(s,i))return s}}static assign(e,...n){const i=e;let r,s;if(Object.assign)return Object.assign(e,...n);for(r=0,s=n.length;r<s;r+=1){const a=n[r];typeof a=="object"&&a!==null&&Object.keys(a).forEach(d=>{i[d]=a[d]})}return e}static getBrowserAlias(e){return jS[e]}static getBrowserTypeByAlias(e){return av[e]||""}}const Ce=/version\/(\d+(\.?_?\d+)+)/i,WS=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},n=j.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opr\/|opios/i],describe(t){const e={name:"Opera"},n=j.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Whale/i],describe(t){const e={name:"NAVER Whale Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MZBrowser/i],describe(t){const e={name:"MZ Browser"},n=j.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/focus/i],describe(t){const e={name:"Focus"},n=j.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/swing/i],describe(t){const e={name:"Swing"},n=j.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(t){const e={name:"Opera Touch"},n=j.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/yabrowser/i],describe(t){const e={name:"Yandex Browser"},n=j.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Maxthon|mxios/i],describe(t){const e={name:"Maxthon"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/epiphany/i],describe(t){const e={name:"Epiphany"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/puffin/i],describe(t){const e={name:"Puffin"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sleipnir/i],describe(t){const e={name:"Sleipnir"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/k-meleon/i],describe(t){const e={name:"K-Meleon"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/micromessenger/i],describe(t){const e={name:"WeChat"},n=j.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/qqbrowser/i],describe(t){const e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},n=j.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/msie|trident/i],describe(t){const e={name:"Internet Explorer"},n=j.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/\sedg\//i],describe(t){const e={name:"Microsoft Edge"},n=j.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe(t){const e={name:"Microsoft Edge"},n=j.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/vivaldi/i],describe(t){const e={name:"Vivaldi"},n=j.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/seamonkey/i],describe(t){const e={name:"SeaMonkey"},n=j.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sailfish/i],describe(t){const e={name:"Sailfish"},n=j.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return n&&(e.version=n),e}},{test:[/silk/i],describe(t){const e={name:"Amazon Silk"},n=j.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/phantom/i],describe(t){const e={name:"PhantomJS"},n=j.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/slimerjs/i],describe(t){const e={name:"SlimerJS"},n=j.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e={name:"BlackBerry"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(web|hpw)[o0]s/i],describe(t){const e={name:"WebOS Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/bada/i],describe(t){const e={name:"Bada"},n=j.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/tizen/i],describe(t){const e={name:"Tizen"},n=j.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/qupzilla/i],describe(t){const e={name:"QupZilla"},n=j.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe(t){const e={name:"Firefox"},n=j.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/electron/i],describe(t){const e={name:"Electron"},n=j.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MiuiBrowser/i],describe(t){const e={name:"Miui"},n=j.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe(t){const e={name:"Chromium"},n=j.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe(t){const e={name:"Chrome"},n=j.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/GSA/i],describe(t){const e={name:"Google Search"},n=j.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){const e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe(t){const e={name:"Android Browser"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/.*/i],describe(t){const e=/^(.*)\/(.*) /,n=/^(.*)\/(.*)[ \t]\((.*)/,r=t.search("\\(")!==-1?n:e;return{name:j.getFirstMatch(r,t),version:j.getSecondMatch(r,t)}}}];var HS=[{test:[/Roku\/DVP/],describe(t){const e=j.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:Ft.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=j.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:Ft.WindowsPhone,version:e}}},{test:[/windows /i],describe(t){const e=j.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),n=j.getWindowsVersionName(e);return{name:Ft.Windows,version:e,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:Ft.iOS},n=j.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return n&&(e.version=n),e}},{test:[/macintosh/i],describe(t){const e=j.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),n=j.getMacOSVersionName(e),i={name:Ft.MacOS,version:e};return n&&(i.versionName=n),i}},{test:[/(ipod|iphone|ipad)/i],describe(t){const e=j.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:Ft.iOS,version:e}}},{test(t){const e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe(t){const e=j.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),n=j.getAndroidVersionName(e),i={name:Ft.Android,version:e};return n&&(i.versionName=n),i}},{test:[/(web|hpw)[o0]s/i],describe(t){const e=j.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),n={name:Ft.WebOS};return e&&e.length&&(n.version=e),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e=j.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||j.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||j.getFirstMatch(/\bbb(\d+)/i,t);return{name:Ft.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=j.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:Ft.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=j.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:Ft.Tizen,version:e}}},{test:[/linux/i],describe(){return{name:Ft.Linux}}},{test:[/CrOS/],describe(){return{name:Ft.ChromeOS}}},{test:[/PlayStation 4/],describe(t){const e=j.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:Ft.PlayStation4,version:e}}}],qS=[{test:[/googlebot/i],describe(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe(t){const e=j.getFirstMatch(/(can-l01)/i,t)&&"Nova",n={type:tt.mobile,vendor:"Huawei"};return e&&(n.model=e),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe(){return{type:tt.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe(){return{type:tt.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(){return{type:tt.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe(){return{type:tt.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe(){return{type:tt.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe(){return{type:tt.tablet}}},{test(t){const e=t.test(/ipod|iphone/i),n=t.test(/like (ipod|iphone)/i);return e&&!n},describe(t){const e=j.getFirstMatch(/(ipod|iphone)/i,t);return{type:tt.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe(){return{type:tt.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe(){return{type:tt.mobile}}},{test(t){return t.getBrowserName(!0)==="blackberry"},describe(){return{type:tt.mobile,vendor:"BlackBerry"}}},{test(t){return t.getBrowserName(!0)==="bada"},describe(){return{type:tt.mobile}}},{test(t){return t.getBrowserName()==="windows phone"},describe(){return{type:tt.mobile,vendor:"Microsoft"}}},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return t.getOSName(!0)==="android"&&e>=3},describe(){return{type:tt.tablet}}},{test(t){return t.getOSName(!0)==="android"},describe(){return{type:tt.mobile}}},{test(t){return t.getOSName(!0)==="macos"},describe(){return{type:tt.desktop,vendor:"Apple"}}},{test(t){return t.getOSName(!0)==="windows"},describe(){return{type:tt.desktop}}},{test(t){return t.getOSName(!0)==="linux"},describe(){return{type:tt.desktop}}},{test(t){return t.getOSName(!0)==="playstation 4"},describe(){return{type:tt.tv}}},{test(t){return t.getOSName(!0)==="roku"},describe(){return{type:tt.tv}}}],GS=[{test(t){return t.getBrowserName(!0)==="microsoft edge"},describe(t){if(/\sedg\//i.test(t))return{name:Yi.Blink};const n=j.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:Yi.EdgeHTML,version:n}}},{test:[/trident/i],describe(t){const e={name:Yi.Trident},n=j.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){return t.test(/presto/i)},describe(t){const e={name:Yi.Presto},n=j.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){const e=t.test(/gecko/i),n=t.test(/like gecko/i);return e&&!n},describe(t){const e={name:Yi.Gecko},n=j.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(apple)?webkit\/537\.36/i],describe(){return{name:Yi.Blink}}},{test:[/(apple)?webkit/i],describe(t){const e={name:Yi.WebKit},n=j.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}}];class km{constructor(e,n=!1){if(e==null||e==="")throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},n!==!0&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=j.find(WS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=j.find(HS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:n}=this.getOS();return e?String(n).toLowerCase()||"":n||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:n}=this.getPlatform();return e?String(n).toLowerCase()||"":n||""}parsePlatform(){this.parsedResult.platform={};const e=j.find(qS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=j.find(GS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return j.assign({},this.parsedResult)}satisfies(e){const n={};let i=0;const r={};let s=0;if(Object.keys(e).forEach(c=>{const d=e[c];typeof d=="string"?(r[c]=d,s+=1):typeof d=="object"&&(n[c]=d,i+=1)}),i>0){const c=Object.keys(n),d=j.find(c,u=>this.isOS(u));if(d){const u=this.satisfies(n[d]);if(u!==void 0)return u}const h=j.find(c,u=>this.isPlatform(u));if(h){const u=this.satisfies(n[h]);if(u!==void 0)return u}}if(s>0){const c=Object.keys(r),d=j.find(c,h=>this.isBrowser(h,!0));if(d!==void 0)return this.compareVersion(r[d])}}isBrowser(e,n=!1){const i=this.getBrowserName().toLowerCase();let r=e.toLowerCase();const s=j.getBrowserTypeByAlias(r);return n&&s&&(r=s.toLowerCase()),r===i}compareVersion(e){let n=[0],i=e,r=!1;const s=this.getBrowserVersion();if(typeof s=="string")return e[0]===">"||e[0]==="<"?(i=e.substr(1),e[1]==="="?(r=!0,i=e.substr(2)):n=[],e[0]===">"?n.push(1):n.push(-1)):e[0]==="="?i=e.substr(1):e[0]==="~"&&(r=!0,i=e.substr(1)),n.indexOf(j.compareVersions(s,i,r))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,n=!1){return this.isBrowser(e,n)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(n=>this.is(n))}}/*!
1
+ "use strict";var OS=Object.defineProperty;var DS=(t,e,n)=>e in t?OS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Pc=(t,e,n)=>(DS(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var zt=require("react");function NS(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var LS=NS(zt),Ac,xS=new Uint8Array(16);function VS(){if(!Ac&&(Ac=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ac))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ac(xS)}var US=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Op(t){return typeof t=="string"&&US.test(t)}var Rt=[];for(var cu=0;cu<256;++cu)Rt.push((cu+256).toString(16).substr(1));function BS(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Rt[t[e+0]]+Rt[t[e+1]]+Rt[t[e+2]]+Rt[t[e+3]]+"-"+Rt[t[e+4]]+Rt[t[e+5]]+"-"+Rt[t[e+6]]+Rt[t[e+7]]+"-"+Rt[t[e+8]]+Rt[t[e+9]]+"-"+Rt[t[e+10]]+Rt[t[e+11]]+Rt[t[e+12]]+Rt[t[e+13]]+Rt[t[e+14]]+Rt[t[e+15]]).toLowerCase();if(!Op(n))throw TypeError("Stringified UUID is invalid");return n}function Ca(t,e,n){t=t||{};var i=t.random||(t.rng||VS)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){n=n||0;for(var r=0;r<16;++r)e[n+r]=i[r];return e}return BS(i)}const FS={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},av={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},tt={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},Ft={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},Yi={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class j{static getFirstMatch(e,n){const i=n.match(e);return i&&i.length>0&&i[1]||""}static getSecondMatch(e,n){const i=n.match(e);return i&&i.length>1&&i[2]||""}static matchAndReturnConst(e,n,i){if(e.test(n))return i}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(e){const n=e.split(".").splice(0,2).map(i=>parseInt(i,10)||0);if(n.push(0),n[0]===10)switch(n[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(e){const n=e.split(".").splice(0,2).map(i=>parseInt(i,10)||0);if(n.push(0),!(n[0]===1&&n[1]<5)){if(n[0]===1&&n[1]<6)return"Cupcake";if(n[0]===1&&n[1]>=6)return"Donut";if(n[0]===2&&n[1]<2)return"Eclair";if(n[0]===2&&n[1]===2)return"Froyo";if(n[0]===2&&n[1]>2)return"Gingerbread";if(n[0]===3)return"Honeycomb";if(n[0]===4&&n[1]<1)return"Ice Cream Sandwich";if(n[0]===4&&n[1]<4)return"Jelly Bean";if(n[0]===4&&n[1]>=4)return"KitKat";if(n[0]===5)return"Lollipop";if(n[0]===6)return"Marshmallow";if(n[0]===7)return"Nougat";if(n[0]===8)return"Oreo";if(n[0]===9)return"Pie"}}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,n,i=!1){const r=j.getVersionPrecision(e),s=j.getVersionPrecision(n);let a=Math.max(r,s),c=0;const d=j.map([e,n],h=>{const u=a-j.getVersionPrecision(h),g=h+new Array(u+1).join(".0");return j.map(g.split("."),E=>new Array(20-E.length).join("0")+E).reverse()});for(i&&(c=a-Math.min(r,s)),a-=1;a>=c;){if(d[0][a]>d[1][a])return 1;if(d[0][a]===d[1][a]){if(a===c)return 0;a-=1}else if(d[0][a]<d[1][a])return-1}}static map(e,n){const i=[];let r;if(Array.prototype.map)return Array.prototype.map.call(e,n);for(r=0;r<e.length;r+=1)i.push(n(e[r]));return i}static find(e,n){let i,r;if(Array.prototype.find)return Array.prototype.find.call(e,n);for(i=0,r=e.length;i<r;i+=1){const s=e[i];if(n(s,i))return s}}static assign(e,...n){const i=e;let r,s;if(Object.assign)return Object.assign(e,...n);for(r=0,s=n.length;r<s;r+=1){const a=n[r];typeof a=="object"&&a!==null&&Object.keys(a).forEach(d=>{i[d]=a[d]})}return e}static getBrowserAlias(e){return FS[e]}static getBrowserTypeByAlias(e){return av[e]||""}}const Ce=/version\/(\d+(\.?_?\d+)+)/i,jS=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},n=j.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opr\/|opios/i],describe(t){const e={name:"Opera"},n=j.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Whale/i],describe(t){const e={name:"NAVER Whale Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MZBrowser/i],describe(t){const e={name:"MZ Browser"},n=j.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/focus/i],describe(t){const e={name:"Focus"},n=j.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/swing/i],describe(t){const e={name:"Swing"},n=j.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(t){const e={name:"Opera Touch"},n=j.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/yabrowser/i],describe(t){const e={name:"Yandex Browser"},n=j.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Maxthon|mxios/i],describe(t){const e={name:"Maxthon"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/epiphany/i],describe(t){const e={name:"Epiphany"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/puffin/i],describe(t){const e={name:"Puffin"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sleipnir/i],describe(t){const e={name:"Sleipnir"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/k-meleon/i],describe(t){const e={name:"K-Meleon"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/micromessenger/i],describe(t){const e={name:"WeChat"},n=j.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/qqbrowser/i],describe(t){const e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},n=j.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/msie|trident/i],describe(t){const e={name:"Internet Explorer"},n=j.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/\sedg\//i],describe(t){const e={name:"Microsoft Edge"},n=j.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe(t){const e={name:"Microsoft Edge"},n=j.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/vivaldi/i],describe(t){const e={name:"Vivaldi"},n=j.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/seamonkey/i],describe(t){const e={name:"SeaMonkey"},n=j.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sailfish/i],describe(t){const e={name:"Sailfish"},n=j.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return n&&(e.version=n),e}},{test:[/silk/i],describe(t){const e={name:"Amazon Silk"},n=j.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/phantom/i],describe(t){const e={name:"PhantomJS"},n=j.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/slimerjs/i],describe(t){const e={name:"SlimerJS"},n=j.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e={name:"BlackBerry"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(web|hpw)[o0]s/i],describe(t){const e={name:"WebOS Browser"},n=j.getFirstMatch(Ce,t)||j.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/bada/i],describe(t){const e={name:"Bada"},n=j.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/tizen/i],describe(t){const e={name:"Tizen"},n=j.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/qupzilla/i],describe(t){const e={name:"QupZilla"},n=j.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe(t){const e={name:"Firefox"},n=j.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/electron/i],describe(t){const e={name:"Electron"},n=j.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MiuiBrowser/i],describe(t){const e={name:"Miui"},n=j.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe(t){const e={name:"Chromium"},n=j.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe(t){const e={name:"Chrome"},n=j.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/GSA/i],describe(t){const e={name:"Google Search"},n=j.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){const e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe(t){const e={name:"Android Browser"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},n=j.getFirstMatch(Ce,t);return n&&(e.version=n),e}},{test:[/.*/i],describe(t){const e=/^(.*)\/(.*) /,n=/^(.*)\/(.*)[ \t]\((.*)/,r=t.search("\\(")!==-1?n:e;return{name:j.getFirstMatch(r,t),version:j.getSecondMatch(r,t)}}}];var WS=[{test:[/Roku\/DVP/],describe(t){const e=j.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:Ft.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=j.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:Ft.WindowsPhone,version:e}}},{test:[/windows /i],describe(t){const e=j.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),n=j.getWindowsVersionName(e);return{name:Ft.Windows,version:e,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:Ft.iOS},n=j.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return n&&(e.version=n),e}},{test:[/macintosh/i],describe(t){const e=j.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),n=j.getMacOSVersionName(e),i={name:Ft.MacOS,version:e};return n&&(i.versionName=n),i}},{test:[/(ipod|iphone|ipad)/i],describe(t){const e=j.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:Ft.iOS,version:e}}},{test(t){const e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe(t){const e=j.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),n=j.getAndroidVersionName(e),i={name:Ft.Android,version:e};return n&&(i.versionName=n),i}},{test:[/(web|hpw)[o0]s/i],describe(t){const e=j.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),n={name:Ft.WebOS};return e&&e.length&&(n.version=e),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e=j.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||j.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||j.getFirstMatch(/\bbb(\d+)/i,t);return{name:Ft.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=j.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:Ft.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=j.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:Ft.Tizen,version:e}}},{test:[/linux/i],describe(){return{name:Ft.Linux}}},{test:[/CrOS/],describe(){return{name:Ft.ChromeOS}}},{test:[/PlayStation 4/],describe(t){const e=j.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:Ft.PlayStation4,version:e}}}],HS=[{test:[/googlebot/i],describe(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe(t){const e=j.getFirstMatch(/(can-l01)/i,t)&&"Nova",n={type:tt.mobile,vendor:"Huawei"};return e&&(n.model=e),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe(){return{type:tt.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe(){return{type:tt.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(){return{type:tt.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe(){return{type:tt.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe(){return{type:tt.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe(){return{type:tt.tablet}}},{test(t){const e=t.test(/ipod|iphone/i),n=t.test(/like (ipod|iphone)/i);return e&&!n},describe(t){const e=j.getFirstMatch(/(ipod|iphone)/i,t);return{type:tt.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe(){return{type:tt.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe(){return{type:tt.mobile}}},{test(t){return t.getBrowserName(!0)==="blackberry"},describe(){return{type:tt.mobile,vendor:"BlackBerry"}}},{test(t){return t.getBrowserName(!0)==="bada"},describe(){return{type:tt.mobile}}},{test(t){return t.getBrowserName()==="windows phone"},describe(){return{type:tt.mobile,vendor:"Microsoft"}}},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return t.getOSName(!0)==="android"&&e>=3},describe(){return{type:tt.tablet}}},{test(t){return t.getOSName(!0)==="android"},describe(){return{type:tt.mobile}}},{test(t){return t.getOSName(!0)==="macos"},describe(){return{type:tt.desktop,vendor:"Apple"}}},{test(t){return t.getOSName(!0)==="windows"},describe(){return{type:tt.desktop}}},{test(t){return t.getOSName(!0)==="linux"},describe(){return{type:tt.desktop}}},{test(t){return t.getOSName(!0)==="playstation 4"},describe(){return{type:tt.tv}}},{test(t){return t.getOSName(!0)==="roku"},describe(){return{type:tt.tv}}}],qS=[{test(t){return t.getBrowserName(!0)==="microsoft edge"},describe(t){if(/\sedg\//i.test(t))return{name:Yi.Blink};const n=j.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:Yi.EdgeHTML,version:n}}},{test:[/trident/i],describe(t){const e={name:Yi.Trident},n=j.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){return t.test(/presto/i)},describe(t){const e={name:Yi.Presto},n=j.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test(t){const e=t.test(/gecko/i),n=t.test(/like gecko/i);return e&&!n},describe(t){const e={name:Yi.Gecko},n=j.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(apple)?webkit\/537\.36/i],describe(){return{name:Yi.Blink}}},{test:[/(apple)?webkit/i],describe(t){const e={name:Yi.WebKit},n=j.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}}];class km{constructor(e,n=!1){if(e==null||e==="")throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},n!==!0&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=j.find(jS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=j.find(WS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:n}=this.getOS();return e?String(n).toLowerCase()||"":n||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:n}=this.getPlatform();return e?String(n).toLowerCase()||"":n||""}parsePlatform(){this.parsedResult.platform={};const e=j.find(HS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=j.find(qS,n=>{if(typeof n.test=="function")return n.test(this);if(n.test instanceof Array)return n.test.some(i=>this.test(i));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return j.assign({},this.parsedResult)}satisfies(e){const n={};let i=0;const r={};let s=0;if(Object.keys(e).forEach(c=>{const d=e[c];typeof d=="string"?(r[c]=d,s+=1):typeof d=="object"&&(n[c]=d,i+=1)}),i>0){const c=Object.keys(n),d=j.find(c,u=>this.isOS(u));if(d){const u=this.satisfies(n[d]);if(u!==void 0)return u}const h=j.find(c,u=>this.isPlatform(u));if(h){const u=this.satisfies(n[h]);if(u!==void 0)return u}}if(s>0){const c=Object.keys(r),d=j.find(c,h=>this.isBrowser(h,!0));if(d!==void 0)return this.compareVersion(r[d])}}isBrowser(e,n=!1){const i=this.getBrowserName().toLowerCase();let r=e.toLowerCase();const s=j.getBrowserTypeByAlias(r);return n&&s&&(r=s.toLowerCase()),r===i}compareVersion(e){let n=[0],i=e,r=!1;const s=this.getBrowserVersion();if(typeof s=="string")return e[0]===">"||e[0]==="<"?(i=e.substr(1),e[1]==="="?(r=!0,i=e.substr(2)):n=[],e[0]===">"?n.push(1):n.push(-1)):e[0]==="="?i=e.substr(1):e[0]==="~"&&(r=!0,i=e.substr(1)),n.indexOf(j.compareVersions(s,i,r))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,n=!1){return this.isBrowser(e,n)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(n=>this.is(n))}}/*!
2
2
  * Bowser - a browser detector
3
3
  * https://github.com/lancedikson/bowser
4
4
  * MIT License | (c) Dustin Diaz 2012-2015
5
5
  * MIT License | (c) Denis Demchenko 2015-2019
6
- */class ov{static getParser(e,n=!1){if(typeof e!="string")throw new Error("UserAgent should be a string");return new km(e,n)}static parse(e){return new km(e).getResult()}static get BROWSER_MAP(){return av}static get ENGINE_MAP(){return Yi}static get OS_MAP(){return Ft}static get PLATFORMS_MAP(){return tt}}function Dp(t){let e=typeof t;if(e=="object"){if(Array.isArray(t))return"array";if(t===null)return"null"}return e}function $S(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}let ki="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Pl=[];for(let t=0;t<ki.length;t++)Pl[ki[t].charCodeAt(0)]=t;Pl["-".charCodeAt(0)]=ki.indexOf("+");Pl["_".charCodeAt(0)]=ki.indexOf("/");function JS(t){let e=t.length*3/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n=new Uint8Array(e),i=0,r=0,s,a=0;for(let c=0;c<t.length;c++){if(s=Pl[t.charCodeAt(c)],s===void 0)switch(t[c]){case"=":r=0;case`
7
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:a=s,r=1;break;case 1:n[i++]=a<<2|(s&48)>>4,a=s,r=2;break;case 2:n[i++]=(a&15)<<4|(s&60)>>2,a=s,r=3;break;case 3:n[i++]=(a&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,i)}function KS(t){let e="",n=0,i,r=0;for(let s=0;s<t.length;s++)switch(i=t[s],n){case 0:e+=ki[i>>2],r=(i&3)<<4,n=1;break;case 1:e+=ki[r|i>>4],r=(i&15)<<2,n=2;break;case 2:e+=ki[r|i>>6],e+=ki[i&63],n=0;break}return n&&(e+=ki[r],e+="=",n==1&&(e+="=")),e}var Kd;(function(t){t.symbol=Symbol.for("protobuf-ts/unknown"),t.onRead=(n,i,r,s,a)=>{(e(i)?i[t.symbol]:i[t.symbol]=[]).push({no:r,wireType:s,data:a})},t.onWrite=(n,i,r)=>{for(let{no:s,wireType:a,data:c}of t.list(i))r.tag(s,a).raw(c)},t.list=(n,i)=>{if(e(n)){let r=n[t.symbol];return i?r.filter(s=>s.no==i):r}return[]},t.last=(n,i)=>t.list(n,i).slice(-1)[0];const e=n=>n&&Array.isArray(n[t.symbol])})(Kd||(Kd={}));var it;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(it||(it={}));function zS(){let t=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function du(t,e,n){for(let s=0;s<28;s=s+7){const a=t>>>s,c=!(a>>>7==0&&e==0),d=(c?a|128:a)&255;if(n.push(d),!c)return}const i=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const a=e>>>s,c=a>>>7!=0,d=(c?a|128:a)&255;if(n.push(d),!c)return}n.push(e>>>31&1)}}const dd=(1<<16)*(1<<16);function cv(t){let e=t[0]=="-";e&&(t=t.slice(1));const n=1e6;let i=0,r=0;function s(a,c){const d=Number(t.slice(a,c));r*=n,i=i*n+d,i>=dd&&(r=r+(i/dd|0),i=i%dd)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,i,r]}function rh(t,e){if(e>>>0<=2097151)return""+(dd*e+(t>>>0));let n=t&16777215,i=(t>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=n+i*6777216+r*6710656,a=i+r*8147497,c=r*2,d=1e7;s>=d&&(a+=Math.floor(s/d),s%=d),a>=d&&(c+=Math.floor(a/d),a%=d);function h(u,g){let E=u?String(u):"";return g?"0000000".slice(E.length)+E:E}return h(c,0)+h(a,c)+h(s,1)}function wm(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function YS(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let Re;function QS(){const t=new DataView(new ArrayBuffer(8));Re=globalThis.BigInt!==void 0&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:t}:void 0}QS();function dv(t){if(!t)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const lv=/^-?[0-9]+$/,zd=4294967296,Mc=2147483648;class uv{constructor(e,n){this.lo=e|0,this.hi=n|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*zd+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class Dt extends uv{static from(e){if(Re)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=Re.C(e);case"number":if(e===0)return this.ZERO;e=Re.C(e);case"bigint":if(!e)return this.ZERO;if(e<Re.UMIN)throw new Error("signed value for ulong");if(e>Re.UMAX)throw new Error("ulong too large");return Re.V.setBigUint64(0,e,!0),new Dt(Re.V.getInt32(0,!0),Re.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!lv.test(e))throw new Error("string is no integer");let[n,i,r]=cv(e);if(n)throw new Error("signed value for ulong");return new Dt(i,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new Dt(e,e/zd)}throw new Error("unknown value "+typeof e)}toString(){return Re?this.toBigInt().toString():rh(this.lo,this.hi)}toBigInt(){return dv(Re),Re.V.setInt32(0,this.lo,!0),Re.V.setInt32(4,this.hi,!0),Re.V.getBigUint64(0,!0)}}Dt.ZERO=new Dt(0,0);class xe extends uv{static from(e){if(Re)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=Re.C(e);case"number":if(e===0)return this.ZERO;e=Re.C(e);case"bigint":if(!e)return this.ZERO;if(e<Re.MIN)throw new Error("signed long too small");if(e>Re.MAX)throw new Error("signed long too large");return Re.V.setBigInt64(0,e,!0),new xe(Re.V.getInt32(0,!0),Re.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!lv.test(e))throw new Error("string is no integer");let[n,i,r]=cv(e);if(n){if(r>Mc||r==Mc&&i!=0)throw new Error("signed long too small")}else if(r>=Mc)throw new Error("signed long too large");let s=new xe(i,r);return n?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new xe(e,e/zd):new xe(-e,-e/zd).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Mc)!==0}negate(){let e=~this.hi,n=this.lo;return n?n=~n+1:e+=1,new xe(n,e)}toString(){if(Re)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+rh(e.lo,e.hi)}return rh(this.lo,this.hi)}toBigInt(){return dv(Re),Re.V.setInt32(0,this.lo,!0),Re.V.setInt32(4,this.hi,!0),Re.V.getBigInt64(0,!0)}}xe.ZERO=new xe(0,0);const _m={readUnknownField:!0,readerFactory:t=>new ZS(t)};function XS(t){return t?Object.assign(Object.assign({},_m),t):_m}class ZS{constructor(e,n){this.varint64=zS,this.uint32=YS,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n!=null?n:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),n=e>>>3,i=e&7;if(n<=0||i<0||i>5)throw new Error("illegal tag: field no "+n+" wire type "+i);return[n,i]}skip(e){let n=this.pos;switch(e){case it.Varint:for(;this.buf[this.pos++]&128;);break;case it.Bit64:this.pos+=4;case it.Bit32:this.pos+=4;break;case it.LengthDelimited:let i=this.uint32();this.pos+=i;break;case it.StartGroup:let r;for(;(r=this.tag()[1])!==it.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new xe(...this.varint64())}uint64(){return new Dt(...this.varint64())}sint64(){let[e,n]=this.varint64(),i=-(e&1);return e=(e>>>1|(n&1)<<31)^i,n=n>>>1^i,new xe(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new Dt(this.sfixed32(),this.sfixed32())}sfixed64(){return new xe(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function Ee(t,e){if(!t)throw new Error(e)}const eT=34028234663852886e22,tT=-34028234663852886e22,nT=4294967295,iT=2147483647,rT=-2147483648;function qo(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>iT||t<rT)throw new Error("invalid int 32: "+t)}function Yd(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>nT||t<0)throw new Error("invalid uint 32: "+t)}function Np(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(!!Number.isFinite(t)&&(t>eT||t<tT))throw new Error("invalid float 32: "+t)}const Im={writeUnknownFields:!0,writerFactory:()=>new aT};function sT(t){return t?Object.assign(Object.assign({},Im),t):Im}class aT{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Yd(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return qo(e),wm(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){Np(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Yd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){qo(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return qo(e),e=(e<<1^e>>31)>>>0,wm(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=xe.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=Dt.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=xe.from(e);return du(n.lo,n.hi,this.buf),this}sint64(e){let n=xe.from(e),i=n.hi>>31,r=n.lo<<1^i,s=(n.hi<<1|n.lo>>>31)^i;return du(r,s,this.buf),this}uint64(e){let n=Dt.from(e);return du(n.lo,n.hi,this.buf),this}}const Cm={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Rm={ignoreUnknownFields:!1};function oT(t){return t?Object.assign(Object.assign({},Rm),t):Rm}function cT(t){return t?Object.assign(Object.assign({},Cm),t):Cm}const hv=Symbol.for("protobuf-ts/message-type");function Pm(t){let e=!1;const n=[];for(let i=0;i<t.length;i++){let r=t.charAt(i);r=="_"?e=!0:/\d/.test(r)?(n.push(r),e=!0):e?(n.push(r.toUpperCase()),e=!1):i==0?n.push(r.toLowerCase()):n.push(r)}return n.join("")}var F;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(F||(F={}));var li;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER"})(li||(li={}));var Qd;(function(t){t[t.NO=0]="NO",t[t.PACKED=1]="PACKED",t[t.UNPACKED=2]="UNPACKED"})(Qd||(Qd={}));function dT(t){var e,n,i,r;return t.localName=(e=t.localName)!==null&&e!==void 0?e:Pm(t.name),t.jsonName=(n=t.jsonName)!==null&&n!==void 0?n:Pm(t.name),t.repeat=(i=t.repeat)!==null&&i!==void 0?i:Qd.NO,t.opt=(r=t.opt)!==null&&r!==void 0?r:t.repeat||t.oneof?!1:t.kind=="message",t}function lT(t){if(typeof t!="object"||t===null||!t.hasOwnProperty("oneofKind"))return!1;switch(typeof t.oneofKind){case"string":return t[t.oneofKind]===void 0?!1:Object.keys(t).length==2;case"undefined":return Object.keys(t).length==1;default:return!1}}class uT{constructor(e){var n;this.fields=(n=e.fields)!==null&&n!==void 0?n:[]}prepare(){if(this.data)return;const e=[],n=[],i=[];for(let r of this.fields)if(r.oneof)i.includes(r.oneof)||(i.push(r.oneof),e.push(r.oneof),n.push(r.oneof));else switch(n.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:n,oneofs:Object.values(i)}}is(e,n,i=!1){if(n<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(a=>!r.includes(a))||!i&&r.some(a=>!s.known.includes(a)))return!1;if(n<1)return!0;for(const a of s.oneofs){const c=e[a];if(!lT(c))return!1;if(c.oneofKind===void 0)continue;const d=this.fields.find(h=>h.localName===c.oneofKind);if(!d||!this.field(c[c.oneofKind],d,i,n))return!1}for(const a of this.fields)if(a.oneof===void 0&&!this.field(e[a.localName],a,i,n))return!1;return!0}field(e,n,i,r){let s=n.repeat;switch(n.kind){case"scalar":return e===void 0?n.opt:s?this.scalars(e,n.T,r,n.L):this.scalar(e,n.T,n.L);case"enum":return e===void 0?n.opt:s?this.scalars(e,F.INT32,r):this.scalar(e,F.INT32);case"message":return e===void 0?!0:s?this.messages(e,n.T(),i,r):this.message(e,n.T(),i,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,n.K,r))return!1;switch(n.V.kind){case"scalar":return this.scalars(Object.values(e),n.V.T,r,n.V.L);case"enum":return this.scalars(Object.values(e),F.INT32,r);case"message":return this.messages(Object.values(e),n.V.T(),i,r)}break}return!0}message(e,n,i,r){return i?n.isAssignable(e,r):n.is(e,r)}messages(e,n,i,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(i){for(let s=0;s<e.length&&s<r;s++)if(!n.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!n.is(e[s],r-1))return!1;return!0}scalar(e,n,i){let r=typeof e;switch(n){case F.UINT64:case F.FIXED64:case F.INT64:case F.SFIXED64:case F.SINT64:switch(i){case li.BIGINT:return r=="bigint";case li.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case F.BOOL:return r=="boolean";case F.STRING:return r=="string";case F.BYTES:return e instanceof Uint8Array;case F.DOUBLE:case F.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,n,i,r){if(!Array.isArray(e))return!1;if(i<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<i;s++)if(!this.scalar(e[s],n,r))return!1}return!0}mapKeys(e,n,i){let r=Object.keys(e);switch(n){case F.INT32:case F.FIXED32:case F.SFIXED32:case F.SINT32:case F.UINT32:return this.scalars(r.slice(0,i).map(s=>parseInt(s)),n,i);case F.BOOL:return this.scalars(r.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),n,i);default:return this.scalars(r,n,i,li.STRING)}}}function qn(t,e){switch(e){case li.BIGINT:return t.toBigInt();case li.NUMBER:return t.toNumber();default:return t.toString()}}class hT{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const n=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const i of n)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(e,n,i){if(!e){let r=Dp(i);throw(r=="number"||r=="boolean")&&(r=i.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${n}`)}}read(e,n,i){this.prepare();const r=[];for(const[s,a]of Object.entries(e)){const c=this.fMap[s];if(!c){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const d=c.localName;let h;if(c.oneof){if(a===null&&(c.kind!=="enum"||c.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(c.oneof))throw new Error(`Multiple members of the oneof group "${c.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(c.oneof),h=n[c.oneof]={oneofKind:d}}else h=n;if(c.kind=="map"){if(a===null)continue;this.assert($S(a),c.name,a);const u=h[d];for(const[g,E]of Object.entries(a)){this.assert(E!==null,c.name+" map value",null);let b;switch(c.V.kind){case"message":b=c.V.T().internalJsonRead(E,i);break;case"enum":if(b=this.enum(c.V.T(),E,c.name,i.ignoreUnknownFields),b===!1)continue;break;case"scalar":b=this.scalar(E,c.V.T,c.V.L,c.name);break}this.assert(b!==void 0,c.name+" map value",E);let k=g;c.K==F.BOOL&&(k=k=="true"?!0:k=="false"?!1:k),k=this.scalar(k,c.K,li.STRING,c.name).toString(),u[k]=b}}else if(c.repeat){if(a===null)continue;this.assert(Array.isArray(a),c.name,a);const u=h[d];for(const g of a){this.assert(g!==null,c.name,null);let E;switch(c.kind){case"message":E=c.T().internalJsonRead(g,i);break;case"enum":if(E=this.enum(c.T(),g,c.name,i.ignoreUnknownFields),E===!1)continue;break;case"scalar":E=this.scalar(g,c.T,c.L,c.name);break}this.assert(E!==void 0,c.name,a),u.push(E)}}else switch(c.kind){case"message":if(a===null&&c.T().typeName!="google.protobuf.Value"){this.assert(c.oneof===void 0,c.name+" (oneof member)",null);continue}h[d]=c.T().internalJsonRead(a,i,h[d]);break;case"enum":if(a===null)continue;let u=this.enum(c.T(),a,c.name,i.ignoreUnknownFields);if(u===!1)continue;h[d]=u;break;case"scalar":if(a===null)continue;h[d]=this.scalar(a,c.T,c.L,c.name);break}}}enum(e,n,i,r){if(e[0]=="google.protobuf.NullValue"&&Ee(n===null||n==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} only accepts null.`),n===null)return 0;switch(typeof n){case"number":return Ee(Number.isInteger(n),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${n}.`),n;case"string":let s=n;e[2]&&n.substring(0,e[2].length)===e[2]&&(s=n.substring(e[2].length));let a=e[1][s];return typeof a=="undefined"&&r?!1:(Ee(typeof a=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} has no value for "${n}".`),a)}Ee(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof n}".`)}scalar(e,n,i,r){let s;try{switch(n){case F.DOUBLE:case F.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let a=Number(e);if(Number.isNaN(a)){s="not a number";break}if(!Number.isFinite(a)){s="too large or small";break}return n==F.FLOAT&&Np(a),a;case F.INT32:case F.FIXED32:case F.SFIXED32:case F.SINT32:case F.UINT32:if(e===null)return 0;let c;if(typeof e=="number"?c=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":c=Number(e)),c===void 0)break;return n==F.UINT32?Yd(c):qo(c),c;case F.INT64:case F.SFIXED64:case F.SINT64:if(e===null)return qn(xe.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return qn(xe.from(e),i);case F.FIXED64:case F.UINT64:if(e===null)return qn(Dt.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return qn(Dt.from(e),i);case F.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case F.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(d){d="invalid UTF8";break}return e;case F.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return JS(e)}}catch(a){s=a.message}this.assert(!1,r+(s?" - "+s:""),e)}}class pT{constructor(e){var n;this.fields=(n=e.fields)!==null&&n!==void 0?n:[]}write(e,n){const i={},r=e;for(const s of this.fields){if(!s.oneof){let h=this.field(s,r[s.localName],n);h!==void 0&&(i[n.useProtoFieldName?s.name:s.jsonName]=h);continue}const a=r[s.oneof];if(a.oneofKind!==s.localName)continue;const c=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},n),{emitDefaultValues:!0}):n;let d=this.field(s,a[s.localName],c);Ee(d!==void 0),i[n.useProtoFieldName?s.name:s.jsonName]=d}return i}field(e,n,i){let r;if(e.kind=="map"){Ee(typeof n=="object"&&n!==null);const s={};switch(e.V.kind){case"scalar":for(const[d,h]of Object.entries(n)){const u=this.scalar(e.V.T,h,e.name,!1,!0);Ee(u!==void 0),s[d.toString()]=u}break;case"message":const a=e.V.T();for(const[d,h]of Object.entries(n)){const u=this.message(a,h,e.name,i);Ee(u!==void 0),s[d.toString()]=u}break;case"enum":const c=e.V.T();for(const[d,h]of Object.entries(n)){Ee(h===void 0||typeof h=="number");const u=this.enum(c,h,e.name,!1,!0,i.enumAsInteger);Ee(u!==void 0),s[d.toString()]=u}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){Ee(Array.isArray(n));const s=[];switch(e.kind){case"scalar":for(let d=0;d<n.length;d++){const h=this.scalar(e.T,n[d],e.name,e.opt,!0);Ee(h!==void 0),s.push(h)}break;case"enum":const a=e.T();for(let d=0;d<n.length;d++){Ee(n[d]===void 0||typeof n[d]=="number");const h=this.enum(a,n[d],e.name,e.opt,!0,i.enumAsInteger);Ee(h!==void 0),s.push(h)}break;case"message":const c=e.T();for(let d=0;d<n.length;d++){const h=this.message(c,n[d],e.name,i);Ee(h!==void 0),s.push(h)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,n,e.name,e.opt,i.emitDefaultValues);break;case"enum":r=this.enum(e.T(),n,e.name,e.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":r=this.message(e.T(),n,e.name,i);break}return r}enum(e,n,i,r,s,a){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(n===void 0){Ee(r);return}if(!(n===0&&!s&&!r))return Ee(typeof n=="number"),Ee(Number.isInteger(n)),a||!e[1].hasOwnProperty(n)?n:e[2]?e[2]+e[1][n]:e[1][n]}message(e,n,i,r){return n===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(n,r)}scalar(e,n,i,r,s){if(n===void 0){Ee(r);return}const a=s||r;switch(e){case F.INT32:case F.SFIXED32:case F.SINT32:return n===0?a?0:void 0:(qo(n),n);case F.FIXED32:case F.UINT32:return n===0?a?0:void 0:(Yd(n),n);case F.FLOAT:Np(n);case F.DOUBLE:return n===0?a?0:void 0:(Ee(typeof n=="number"),Number.isNaN(n)?"NaN":n===Number.POSITIVE_INFINITY?"Infinity":n===Number.NEGATIVE_INFINITY?"-Infinity":n);case F.STRING:return n===""?a?"":void 0:(Ee(typeof n=="string"),n);case F.BOOL:return n===!1?a?!1:void 0:(Ee(typeof n=="boolean"),n);case F.UINT64:case F.FIXED64:Ee(typeof n=="number"||typeof n=="string"||typeof n=="bigint");let c=Dt.from(n);return c.isZero()&&!a?void 0:c.toString();case F.INT64:case F.SFIXED64:case F.SINT64:Ee(typeof n=="number"||typeof n=="string"||typeof n=="bigint");let d=xe.from(n);return d.isZero()&&!a?void 0:d.toString();case F.BYTES:return Ee(n instanceof Uint8Array),n.byteLength?KS(n):a?"":void 0}}}function sh(t,e=li.STRING){switch(t){case F.BOOL:return!1;case F.UINT64:case F.FIXED64:return qn(Dt.ZERO,e);case F.INT64:case F.SFIXED64:case F.SINT64:return qn(xe.ZERO,e);case F.DOUBLE:case F.FLOAT:return 0;case F.BYTES:return new Uint8Array(0);case F.STRING:return"";default:return 0}}class mT{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const n=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(n.map(i=>[i.no,i]))}}read(e,n,i,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[a,c]=e.tag(),d=this.fieldNoToField.get(a);if(!d){let E=i.readUnknownField;if(E=="throw")throw new Error(`Unknown field ${a} (wire type ${c}) for ${this.info.typeName}`);let b=e.skip(c);E!==!1&&(E===!0?Kd.onRead:E)(this.info.typeName,n,a,c,b);continue}let h=n,u=d.repeat,g=d.localName;switch(d.oneof&&(h=h[d.oneof],h.oneofKind!==g&&(h=n[d.oneof]={oneofKind:g})),d.kind){case"scalar":case"enum":let E=d.kind=="enum"?F.INT32:d.T,b=d.kind=="scalar"?d.L:void 0;if(u){let M=h[g];if(c==it.LengthDelimited&&E!=F.STRING&&E!=F.BYTES){let B=e.uint32()+e.pos;for(;e.pos<B;)M.push(this.scalar(e,E,b))}else M.push(this.scalar(e,E,b))}else h[g]=this.scalar(e,E,b);break;case"message":if(u){let M=h[g],B=d.T().internalBinaryRead(e,e.uint32(),i);M.push(B)}else h[g]=d.T().internalBinaryRead(e,e.uint32(),i,h[g]);break;case"map":let[k,A]=this.mapEntry(d,e,i);h[g][k]=A;break}}}mapEntry(e,n,i){let r=n.uint32(),s=n.pos+r,a,c;for(;n.pos<s;){let[d,h]=n.tag();switch(d){case 1:e.K==F.BOOL?a=n.bool().toString():a=this.scalar(n,e.K,li.STRING);break;case 2:switch(e.V.kind){case"scalar":c=this.scalar(n,e.V.T,e.V.L);break;case"enum":c=n.int32();break;case"message":c=e.V.T().internalBinaryRead(n,n.uint32(),i);break}break;default:throw new Error(`Unknown field ${d} (wire type ${h}) in map entry for ${this.info.typeName}#${e.name}`)}}if(a===void 0){let d=sh(e.K);a=e.K==F.BOOL?d.toString():d}if(c===void 0)switch(e.V.kind){case"scalar":c=sh(e.V.T,e.V.L);break;case"enum":c=0;break;case"message":c=e.V.T().create();break}return[a,c]}scalar(e,n,i){switch(n){case F.INT32:return e.int32();case F.STRING:return e.string();case F.BOOL:return e.bool();case F.DOUBLE:return e.double();case F.FLOAT:return e.float();case F.INT64:return qn(e.int64(),i);case F.UINT64:return qn(e.uint64(),i);case F.FIXED64:return qn(e.fixed64(),i);case F.FIXED32:return e.fixed32();case F.BYTES:return e.bytes();case F.UINT32:return e.uint32();case F.SFIXED32:return e.sfixed32();case F.SFIXED64:return qn(e.sfixed64(),i);case F.SINT32:return e.sint32();case F.SINT64:return qn(e.sint64(),i)}}}class fT{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((n,i)=>n.no-i.no)}}write(e,n,i){this.prepare();for(const s of this.fields){let a,c,d=s.repeat,h=s.localName;if(s.oneof){const u=e[s.oneof];if(u.oneofKind!==h)continue;a=u[h],c=!0}else a=e[h],c=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?F.INT32:s.T;if(d)if(Ee(Array.isArray(a)),d==Qd.PACKED)this.packed(n,u,s.no,a);else for(const g of a)this.scalar(n,u,s.no,g,!0);else a===void 0?Ee(s.opt):this.scalar(n,u,s.no,a,c||s.opt);break;case"message":if(d){Ee(Array.isArray(a));for(const g of a)this.message(n,i,s.T(),s.no,g)}else this.message(n,i,s.T(),s.no,a);break;case"map":Ee(typeof a=="object"&&a!==null);for(const[g,E]of Object.entries(a))this.mapEntry(n,i,s,g,E);break}}let r=i.writeUnknownFields;r!==!1&&(r===!0?Kd.onWrite:r)(this.info.typeName,e,n)}mapEntry(e,n,i,r,s){e.tag(i.no,it.LengthDelimited),e.fork();let a=r;switch(i.K){case F.INT32:case F.FIXED32:case F.UINT32:case F.SFIXED32:case F.SINT32:a=Number.parseInt(r);break;case F.BOOL:Ee(r=="true"||r=="false"),a=r=="true";break}switch(this.scalar(e,i.K,1,a,!0),i.V.kind){case"scalar":this.scalar(e,i.V.T,2,s,!0);break;case"enum":this.scalar(e,F.INT32,2,s,!0);break;case"message":this.message(e,n,i.V.T(),2,s);break}e.join()}message(e,n,i,r,s){s!==void 0&&(i.internalBinaryWrite(s,e.tag(r,it.LengthDelimited).fork(),n),e.join())}scalar(e,n,i,r,s){let[a,c,d]=this.scalarInfo(n,r);(!d||s)&&(e.tag(i,a),e[c](r))}packed(e,n,i,r){if(!r.length)return;Ee(n!==F.BYTES&&n!==F.STRING),e.tag(i,it.LengthDelimited),e.fork();let[,s]=this.scalarInfo(n);for(let a=0;a<r.length;a++)e[s](r[a]);e.join()}scalarInfo(e,n){let i=it.Varint,r,s=n===void 0,a=n===0;switch(e){case F.INT32:r="int32";break;case F.STRING:a=s||!n.length,i=it.LengthDelimited,r="string";break;case F.BOOL:a=n===!1,r="bool";break;case F.UINT32:r="uint32";break;case F.DOUBLE:i=it.Bit64,r="double";break;case F.FLOAT:i=it.Bit32,r="float";break;case F.INT64:a=s||xe.from(n).isZero(),r="int64";break;case F.UINT64:a=s||Dt.from(n).isZero(),r="uint64";break;case F.FIXED64:a=s||Dt.from(n).isZero(),i=it.Bit64,r="fixed64";break;case F.BYTES:a=s||!n.byteLength,i=it.LengthDelimited,r="bytes";break;case F.FIXED32:i=it.Bit32,r="fixed32";break;case F.SFIXED32:i=it.Bit32,r="sfixed32";break;case F.SFIXED64:a=s||xe.from(n).isZero(),i=it.Bit64,r="sfixed64";break;case F.SINT32:r="sint32";break;case F.SINT64:a=s||xe.from(n).isZero(),r="sint64";break}return[i,r,s||a]}}function gT(t){const e=t.messagePrototype?Object.create(t.messagePrototype):Object.defineProperty({},hv,{value:t});for(let n of t.fields){let i=n.localName;if(!n.opt)if(n.oneof)e[n.oneof]={oneofKind:void 0};else if(n.repeat)e[i]=[];else switch(n.kind){case"scalar":e[i]=sh(n.T,n.L);break;case"enum":e[i]=0;break;case"map":e[i]={};break}}return e}function lu(t,e,n){let i,r=n,s;for(let a of t.fields){let c=a.localName;if(a.oneof){const d=r[a.oneof];if((d==null?void 0:d.oneofKind)==null)continue;if(i=d[c],s=e[a.oneof],s.oneofKind=d.oneofKind,i==null){delete s[c];continue}}else if(i=r[c],s=e,i==null)continue;switch(a.repeat&&(s[c].length=i.length),a.kind){case"scalar":case"enum":if(a.repeat)for(let h=0;h<i.length;h++)s[c][h]=i[h];else s[c]=i;break;case"message":let d=a.T();if(a.repeat)for(let h=0;h<i.length;h++)s[c][h]=d.create(i[h]);else s[c]===void 0?s[c]=d.create(i):d.mergePartial(s[c],i);break;case"map":switch(a.V.kind){case"scalar":case"enum":Object.assign(s[c],i);break;case"message":let h=a.V.T();for(let u of Object.keys(i))s[c][u]=h.create(i[u]);break}break}}}function vT(t,e,n){if(e===n)return!0;if(!e||!n)return!1;for(let i of t.fields){let r=i.localName,s=i.oneof?e[i.oneof][r]:e[r],a=i.oneof?n[i.oneof][r]:n[r];switch(i.kind){case"enum":case"scalar":let c=i.kind=="enum"?F.INT32:i.T;if(!(i.repeat?Am(c,s,a):pv(c,s,a)))return!1;break;case"map":if(!(i.V.kind=="message"?Mm(i.V.T(),Oc(s),Oc(a)):Am(i.V.kind=="enum"?F.INT32:i.V.T,Oc(s),Oc(a))))return!1;break;case"message":let d=i.T();if(!(i.repeat?Mm(d,s,a):d.equals(s,a)))return!1;break}}return!0}const Oc=Object.values;function pv(t,e,n){if(e===n)return!0;if(t!==F.BYTES)return!1;let i=e,r=n;if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=r[s])return!1;return!0}function Am(t,e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(!pv(t,e[i],n[i]))return!1;return!0}function Mm(t,e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(!t.equals(e[i],n[i]))return!1;return!0}const yT=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class _{constructor(e,n,i){this.defaultCheckDepth=16,this.typeName=e,this.fields=n.map(dT),this.options=i!=null?i:{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},yT),{[hv]:{value:this}})),this.refTypeCheck=new uT(this),this.refJsonReader=new hT(this),this.refJsonWriter=new pT(this),this.refBinReader=new mT(this),this.refBinWriter=new fT(this)}create(e){let n=gT(this);return e!==void 0&&lu(this,n,e),n}clone(e){let n=this.create();return lu(this,n,e),n}equals(e,n){return vT(this,e,n)}is(e,n=this.defaultCheckDepth){return this.refTypeCheck.is(e,n,!1)}isAssignable(e,n=this.defaultCheckDepth){return this.refTypeCheck.is(e,n,!0)}mergePartial(e,n){lu(this,e,n)}fromBinary(e,n){let i=XS(n);return this.internalBinaryRead(i.readerFactory(e),e.byteLength,i)}fromJson(e,n){return this.internalJsonRead(e,oT(n))}fromJsonString(e,n){let i=JSON.parse(e);return this.fromJson(i,n)}toJson(e,n){return this.internalJsonWrite(e,cT(n))}toJsonString(e,n){var i;let r=this.toJson(e,n);return JSON.stringify(r,null,(i=n==null?void 0:n.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(e,n){let i=sT(n);return this.internalBinaryWrite(e,i.writerFactory(),i).finish()}internalJsonRead(e,n,i){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=i!=null?i:this.create();return this.refJsonReader.read(e,r,n),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Dp(e)}.`)}internalJsonWrite(e,n){return this.refJsonWriter.write(e,n)}internalBinaryWrite(e,n,i){return this.refBinWriter.write(e,n,i),n}internalBinaryRead(e,n,i,r){let s=r!=null?r:this.create();return this.refBinReader.read(e,s,i,n),s}}const ET=t=>(e,n)=>(t.set(e,n),n),Om=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,mv=536870912,Dm=mv*2,ST=(t,e)=>n=>{const i=e.get(n);let r=i===void 0?n.size:i<Dm?i+1:0;if(!n.has(r))return t(n,r);if(n.size<mv){for(;n.has(r);)r=Math.floor(Math.random()*Dm);return t(n,r)}if(n.size>Om)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(r);)r=Math.floor(Math.random()*Om);return t(n,r)},fv=new WeakMap,TT=ET(fv),Dc=ST(TT,fv),bT=t=>t.method!==void 0&&t.method==="call",kT=t=>t.error===null&&typeof t.id=="number",wT=t=>{const e=new Map([[0,()=>{}]]),n=new Map([[0,()=>{}]]),i=new Map,r=new Worker(t);return r.addEventListener("message",({data:h})=>{if(bT(h)){const{params:{timerId:u,timerType:g}}=h;if(g==="interval"){const E=e.get(u);if(typeof E=="number"){const b=i.get(E);if(b===void 0||b.timerId!==u||b.timerType!==g)throw new Error("The timer is in an undefined state.")}else if(typeof E!="undefined")E();else throw new Error("The timer is in an undefined state.")}else if(g==="timeout"){const E=n.get(u);if(typeof E=="number"){const b=i.get(E);if(b===void 0||b.timerId!==u||b.timerType!==g)throw new Error("The timer is in an undefined state.")}else if(typeof E!="undefined")E(),n.delete(u);else throw new Error("The timer is in an undefined state.")}}else if(kT(h)){const{id:u}=h,g=i.get(u);if(g===void 0)throw new Error("The timer is in an undefined state.");const{timerId:E,timerType:b}=g;i.delete(u),b==="interval"?e.delete(E):n.delete(E)}else{const{error:{message:u}}=h;throw new Error(u)}}),{clearInterval:h=>{const u=Dc(i);i.set(u,{timerId:h,timerType:"interval"}),e.set(h,u),r.postMessage({id:u,method:"clear",params:{timerId:h,timerType:"interval"}})},clearTimeout:h=>{const u=Dc(i);i.set(u,{timerId:h,timerType:"timeout"}),n.set(h,u),r.postMessage({id:u,method:"clear",params:{timerId:h,timerType:"timeout"}})},setInterval:(h,u=0)=>{const g=Dc(e);return e.set(g,()=>{h(),typeof e.get(g)=="function"&&r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"interval"}})}),r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"interval"}}),g},setTimeout:(h,u=0)=>{const g=Dc(n);return n.set(g,h),r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"timeout"}}),g}}},_T=(t,e)=>{let n=null;return()=>{if(n!==null)return n;const i=new Blob([e],{type:"application/javascript; charset=utf-8"}),r=URL.createObjectURL(i);return n=t(r),setTimeout(()=>URL.revokeObjectURL(r)),n}},IT=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`,Al=_T(wT,IT),la=t=>Al().clearInterval(t),CT=t=>Al().clearTimeout(t),Xd=(t,e)=>Al().setInterval(t,e),RT=(t,e)=>Al().setTimeout(t,e);var PT=Object.freeze(Object.defineProperty({__proto__:null,clearInterval:la,clearTimeout:CT,setInterval:Xd,setTimeout:RT},Symbol.toStringTag,{value:"Module"})),gv={},Lp={exports:{}},Nm=Lp.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(t){return t.encoding?"rtpmap:%d %s/%s/%s":t.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(t){return t.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(t){return t.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(t){return"extmap:%d"+(t.direction?"/%s":"%v")+(t["encrypt-uri"]?" %s":"%v")+" %s"+(t.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(t){return t.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(t){var e="candidate:%s %d %s %d %s %d typ %s";return e+=t.raddr!=null?" raddr %s rport %d":"%v%v",e+=t.tcptype!=null?" tcptype %s":"%v",t.generation!=null&&(e+=" generation %d"),e+=t["network-id"]!=null?" network-id %d":"%v",e+=t["network-cost"]!=null?" network-cost %d":"%v",e}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(t){var e="ssrc:%d";return t.attribute!=null&&(e+=" %s",t.value!=null&&(e+=":%s")),e}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(t){return t.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(t){return t.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(t){return"imageattr:%s %s %s"+(t.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(t){return"simulcast:%s %s"+(t.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(t){return"ts-refclk:%s"+(t.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(t){var e="mediaclk:";return e+=t.id!=null?"id=%s %s":"%v%s",e+=t.mediaClockValue!=null?"=%s":"",e+=t.rateNumerator!=null?" rate=%s":"",e+=t.rateDenominator!=null?"/%s":"",e}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Nm).forEach(function(t){var e=Nm[t];e.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});(function(t){var e=function(c){return String(Number(c))===c?Number(c):c},n=function(c,d,h,u){if(u&&!h)d[u]=e(c[1]);else for(var g=0;g<h.length;g+=1)c[g+1]!=null&&(d[h[g]]=e(c[g+1]))},i=function(c,d,h){var u=c.name&&c.names;c.push&&!d[c.push]?d[c.push]=[]:u&&!d[c.name]&&(d[c.name]={});var g=c.push?{}:u?d[c.name]:d;n(h.match(c.reg),g,c.names,c.name),c.push&&d[c.push].push(g)},r=Lp.exports,s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(c){var d={},h=[],u=d;return c.split(/(\r\n|\r|\n)/).filter(s).forEach(function(g){var E=g[0],b=g.slice(2);E==="m"&&(h.push({rtp:[],fmtp:[]}),u=h[h.length-1]);for(var k=0;k<(r[E]||[]).length;k+=1){var A=r[E][k];if(A.reg.test(b))return i(A,u,b)}}),d.media=h,d};var a=function(c,d){var h=d.split(/=(.+)/,2);return h.length===2?c[h[0]]=e(h[1]):h.length===1&&d.length>1&&(c[h[0]]=void 0),c};t.parseParams=function(c){return c.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(c){return c.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(c){for(var d=[],h=c.split(" ").map(e),u=0;u<h.length;u+=3)d.push({component:h[u],ip:h[u+1],port:h[u+2]});return d},t.parseImageAttributes=function(c){return c.split(" ").map(function(d){return d.substring(1,d.length-1).split(",").reduce(a,{})})},t.parseSimulcastStreamList=function(c){return c.split(";").map(function(d){return d.split(",").map(function(h){var u,g=!1;return h[0]!=="~"?u=e(h):(u=e(h.substring(1,h.length)),g=!0),{scid:u,paused:g}})})}})(gv);var uu=Lp.exports,AT=/%[sdv%]/g,MT=function(t){var e=1,n=arguments,i=n.length;return t.replace(AT,function(r){if(e>=i)return r;var s=n[e];switch(e+=1,r){case"%%":return"%";case"%s":return String(s);case"%d":return Number(s);case"%v":return""}})},Na=function(t,e,n){var i=e.format instanceof Function?e.format(e.push?n:n[e.name]):e.format,r=[t+"="+i];if(e.names)for(var s=0;s<e.names.length;s+=1){var a=e.names[s];e.name?r.push(n[e.name][a]):r.push(n[e.names[s]])}else r.push(n[e.name]);return MT.apply(null,r)},OT=["v","o","s","i","u","e","p","c","b","t","r","z","a"],DT=["i","c","b","a"],NT=function(t,e){e=e||{},t.version==null&&(t.version=0),t.name==null&&(t.name=" "),t.media.forEach(function(s){s.payloads==null&&(s.payloads="")});var n=e.outerOrder||OT,i=e.innerOrder||DT,r=[];return n.forEach(function(s){uu[s].forEach(function(a){a.name in t&&t[a.name]!=null?r.push(Na(s,a,t)):a.push in t&&t[a.push]!=null&&t[a.push].forEach(function(c){r.push(Na(s,a,c))})})}),t.media.forEach(function(s){r.push(Na("m",uu.m[0],s)),i.forEach(function(a){uu[a].forEach(function(c){c.name in s&&s[c.name]!=null?r.push(Na(a,c,s)):c.push in s&&s[c.push]!=null&&s[c.push].forEach(function(d){r.push(Na(a,c,d))})})})}),r.join(`\r
6
+ */class ov{static getParser(e,n=!1){if(typeof e!="string")throw new Error("UserAgent should be a string");return new km(e,n)}static parse(e){return new km(e).getResult()}static get BROWSER_MAP(){return av}static get ENGINE_MAP(){return Yi}static get OS_MAP(){return Ft}static get PLATFORMS_MAP(){return tt}}function Dp(t){let e=typeof t;if(e=="object"){if(Array.isArray(t))return"array";if(t===null)return"null"}return e}function GS(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}let ki="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Pl=[];for(let t=0;t<ki.length;t++)Pl[ki[t].charCodeAt(0)]=t;Pl["-".charCodeAt(0)]=ki.indexOf("+");Pl["_".charCodeAt(0)]=ki.indexOf("/");function JS(t){let e=t.length*3/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n=new Uint8Array(e),i=0,r=0,s,a=0;for(let c=0;c<t.length;c++){if(s=Pl[t.charCodeAt(c)],s===void 0)switch(t[c]){case"=":r=0;case`
7
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:a=s,r=1;break;case 1:n[i++]=a<<2|(s&48)>>4,a=s,r=2;break;case 2:n[i++]=(a&15)<<4|(s&60)>>2,a=s,r=3;break;case 3:n[i++]=(a&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,i)}function $S(t){let e="",n=0,i,r=0;for(let s=0;s<t.length;s++)switch(i=t[s],n){case 0:e+=ki[i>>2],r=(i&3)<<4,n=1;break;case 1:e+=ki[r|i>>4],r=(i&15)<<2,n=2;break;case 2:e+=ki[r|i>>6],e+=ki[i&63],n=0;break}return n&&(e+=ki[r],e+="=",n==1&&(e+="=")),e}var Kd;(function(t){t.symbol=Symbol.for("protobuf-ts/unknown"),t.onRead=(n,i,r,s,a)=>{(e(i)?i[t.symbol]:i[t.symbol]=[]).push({no:r,wireType:s,data:a})},t.onWrite=(n,i,r)=>{for(let{no:s,wireType:a,data:c}of t.list(i))r.tag(s,a).raw(c)},t.list=(n,i)=>{if(e(n)){let r=n[t.symbol];return i?r.filter(s=>s.no==i):r}return[]},t.last=(n,i)=>t.list(n,i).slice(-1)[0];const e=n=>n&&Array.isArray(n[t.symbol])})(Kd||(Kd={}));var it;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(it||(it={}));function KS(){let t=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function du(t,e,n){for(let s=0;s<28;s=s+7){const a=t>>>s,c=!(a>>>7==0&&e==0),d=(c?a|128:a)&255;if(n.push(d),!c)return}const i=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const a=e>>>s,c=a>>>7!=0,d=(c?a|128:a)&255;if(n.push(d),!c)return}n.push(e>>>31&1)}}const dd=(1<<16)*(1<<16);function cv(t){let e=t[0]=="-";e&&(t=t.slice(1));const n=1e6;let i=0,r=0;function s(a,c){const d=Number(t.slice(a,c));r*=n,i=i*n+d,i>=dd&&(r=r+(i/dd|0),i=i%dd)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,i,r]}function rh(t,e){if(e>>>0<=2097151)return""+(dd*e+(t>>>0));let n=t&16777215,i=(t>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=n+i*6777216+r*6710656,a=i+r*8147497,c=r*2,d=1e7;s>=d&&(a+=Math.floor(s/d),s%=d),a>=d&&(c+=Math.floor(a/d),a%=d);function h(u,g){let E=u?String(u):"";return g?"0000000".slice(E.length)+E:E}return h(c,0)+h(a,c)+h(s,1)}function wm(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function zS(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let Re;function YS(){const t=new DataView(new ArrayBuffer(8));Re=globalThis.BigInt!==void 0&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:t}:void 0}YS();function dv(t){if(!t)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const lv=/^-?[0-9]+$/,zd=4294967296,Mc=2147483648;class uv{constructor(e,n){this.lo=e|0,this.hi=n|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*zd+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class Dt extends uv{static from(e){if(Re)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=Re.C(e);case"number":if(e===0)return this.ZERO;e=Re.C(e);case"bigint":if(!e)return this.ZERO;if(e<Re.UMIN)throw new Error("signed value for ulong");if(e>Re.UMAX)throw new Error("ulong too large");return Re.V.setBigUint64(0,e,!0),new Dt(Re.V.getInt32(0,!0),Re.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!lv.test(e))throw new Error("string is no integer");let[n,i,r]=cv(e);if(n)throw new Error("signed value for ulong");return new Dt(i,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new Dt(e,e/zd)}throw new Error("unknown value "+typeof e)}toString(){return Re?this.toBigInt().toString():rh(this.lo,this.hi)}toBigInt(){return dv(Re),Re.V.setInt32(0,this.lo,!0),Re.V.setInt32(4,this.hi,!0),Re.V.getBigUint64(0,!0)}}Dt.ZERO=new Dt(0,0);class xe extends uv{static from(e){if(Re)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=Re.C(e);case"number":if(e===0)return this.ZERO;e=Re.C(e);case"bigint":if(!e)return this.ZERO;if(e<Re.MIN)throw new Error("signed long too small");if(e>Re.MAX)throw new Error("signed long too large");return Re.V.setBigInt64(0,e,!0),new xe(Re.V.getInt32(0,!0),Re.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!lv.test(e))throw new Error("string is no integer");let[n,i,r]=cv(e);if(n){if(r>Mc||r==Mc&&i!=0)throw new Error("signed long too small")}else if(r>=Mc)throw new Error("signed long too large");let s=new xe(i,r);return n?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new xe(e,e/zd):new xe(-e,-e/zd).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Mc)!==0}negate(){let e=~this.hi,n=this.lo;return n?n=~n+1:e+=1,new xe(n,e)}toString(){if(Re)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+rh(e.lo,e.hi)}return rh(this.lo,this.hi)}toBigInt(){return dv(Re),Re.V.setInt32(0,this.lo,!0),Re.V.setInt32(4,this.hi,!0),Re.V.getBigInt64(0,!0)}}xe.ZERO=new xe(0,0);const _m={readUnknownField:!0,readerFactory:t=>new XS(t)};function QS(t){return t?Object.assign(Object.assign({},_m),t):_m}class XS{constructor(e,n){this.varint64=KS,this.uint32=zS,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n!=null?n:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),n=e>>>3,i=e&7;if(n<=0||i<0||i>5)throw new Error("illegal tag: field no "+n+" wire type "+i);return[n,i]}skip(e){let n=this.pos;switch(e){case it.Varint:for(;this.buf[this.pos++]&128;);break;case it.Bit64:this.pos+=4;case it.Bit32:this.pos+=4;break;case it.LengthDelimited:let i=this.uint32();this.pos+=i;break;case it.StartGroup:let r;for(;(r=this.tag()[1])!==it.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new xe(...this.varint64())}uint64(){return new Dt(...this.varint64())}sint64(){let[e,n]=this.varint64(),i=-(e&1);return e=(e>>>1|(n&1)<<31)^i,n=n>>>1^i,new xe(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new Dt(this.sfixed32(),this.sfixed32())}sfixed64(){return new xe(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function Ee(t,e){if(!t)throw new Error(e)}const ZS=34028234663852886e22,eT=-34028234663852886e22,tT=4294967295,nT=2147483647,iT=-2147483648;function qo(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>nT||t<iT)throw new Error("invalid int 32: "+t)}function Yd(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>tT||t<0)throw new Error("invalid uint 32: "+t)}function Np(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(!!Number.isFinite(t)&&(t>ZS||t<eT))throw new Error("invalid float 32: "+t)}const Im={writeUnknownFields:!0,writerFactory:()=>new sT};function rT(t){return t?Object.assign(Object.assign({},Im),t):Im}class sT{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Yd(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return qo(e),wm(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){Np(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Yd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){qo(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return qo(e),e=(e<<1^e>>31)>>>0,wm(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=xe.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=Dt.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=xe.from(e);return du(n.lo,n.hi,this.buf),this}sint64(e){let n=xe.from(e),i=n.hi>>31,r=n.lo<<1^i,s=(n.hi<<1|n.lo>>>31)^i;return du(r,s,this.buf),this}uint64(e){let n=Dt.from(e);return du(n.lo,n.hi,this.buf),this}}const Cm={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Rm={ignoreUnknownFields:!1};function aT(t){return t?Object.assign(Object.assign({},Rm),t):Rm}function oT(t){return t?Object.assign(Object.assign({},Cm),t):Cm}const hv=Symbol.for("protobuf-ts/message-type");function Pm(t){let e=!1;const n=[];for(let i=0;i<t.length;i++){let r=t.charAt(i);r=="_"?e=!0:/\d/.test(r)?(n.push(r),e=!0):e?(n.push(r.toUpperCase()),e=!1):i==0?n.push(r.toLowerCase()):n.push(r)}return n.join("")}var F;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(F||(F={}));var li;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER"})(li||(li={}));var Qd;(function(t){t[t.NO=0]="NO",t[t.PACKED=1]="PACKED",t[t.UNPACKED=2]="UNPACKED"})(Qd||(Qd={}));function cT(t){var e,n,i,r;return t.localName=(e=t.localName)!==null&&e!==void 0?e:Pm(t.name),t.jsonName=(n=t.jsonName)!==null&&n!==void 0?n:Pm(t.name),t.repeat=(i=t.repeat)!==null&&i!==void 0?i:Qd.NO,t.opt=(r=t.opt)!==null&&r!==void 0?r:t.repeat||t.oneof?!1:t.kind=="message",t}function dT(t){if(typeof t!="object"||t===null||!t.hasOwnProperty("oneofKind"))return!1;switch(typeof t.oneofKind){case"string":return t[t.oneofKind]===void 0?!1:Object.keys(t).length==2;case"undefined":return Object.keys(t).length==1;default:return!1}}class lT{constructor(e){var n;this.fields=(n=e.fields)!==null&&n!==void 0?n:[]}prepare(){if(this.data)return;const e=[],n=[],i=[];for(let r of this.fields)if(r.oneof)i.includes(r.oneof)||(i.push(r.oneof),e.push(r.oneof),n.push(r.oneof));else switch(n.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:n,oneofs:Object.values(i)}}is(e,n,i=!1){if(n<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(a=>!r.includes(a))||!i&&r.some(a=>!s.known.includes(a)))return!1;if(n<1)return!0;for(const a of s.oneofs){const c=e[a];if(!dT(c))return!1;if(c.oneofKind===void 0)continue;const d=this.fields.find(h=>h.localName===c.oneofKind);if(!d||!this.field(c[c.oneofKind],d,i,n))return!1}for(const a of this.fields)if(a.oneof===void 0&&!this.field(e[a.localName],a,i,n))return!1;return!0}field(e,n,i,r){let s=n.repeat;switch(n.kind){case"scalar":return e===void 0?n.opt:s?this.scalars(e,n.T,r,n.L):this.scalar(e,n.T,n.L);case"enum":return e===void 0?n.opt:s?this.scalars(e,F.INT32,r):this.scalar(e,F.INT32);case"message":return e===void 0?!0:s?this.messages(e,n.T(),i,r):this.message(e,n.T(),i,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,n.K,r))return!1;switch(n.V.kind){case"scalar":return this.scalars(Object.values(e),n.V.T,r,n.V.L);case"enum":return this.scalars(Object.values(e),F.INT32,r);case"message":return this.messages(Object.values(e),n.V.T(),i,r)}break}return!0}message(e,n,i,r){return i?n.isAssignable(e,r):n.is(e,r)}messages(e,n,i,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(i){for(let s=0;s<e.length&&s<r;s++)if(!n.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!n.is(e[s],r-1))return!1;return!0}scalar(e,n,i){let r=typeof e;switch(n){case F.UINT64:case F.FIXED64:case F.INT64:case F.SFIXED64:case F.SINT64:switch(i){case li.BIGINT:return r=="bigint";case li.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case F.BOOL:return r=="boolean";case F.STRING:return r=="string";case F.BYTES:return e instanceof Uint8Array;case F.DOUBLE:case F.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,n,i,r){if(!Array.isArray(e))return!1;if(i<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<i;s++)if(!this.scalar(e[s],n,r))return!1}return!0}mapKeys(e,n,i){let r=Object.keys(e);switch(n){case F.INT32:case F.FIXED32:case F.SFIXED32:case F.SINT32:case F.UINT32:return this.scalars(r.slice(0,i).map(s=>parseInt(s)),n,i);case F.BOOL:return this.scalars(r.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),n,i);default:return this.scalars(r,n,i,li.STRING)}}}function qn(t,e){switch(e){case li.BIGINT:return t.toBigInt();case li.NUMBER:return t.toNumber();default:return t.toString()}}class uT{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const n=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const i of n)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(e,n,i){if(!e){let r=Dp(i);throw(r=="number"||r=="boolean")&&(r=i.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${n}`)}}read(e,n,i){this.prepare();const r=[];for(const[s,a]of Object.entries(e)){const c=this.fMap[s];if(!c){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const d=c.localName;let h;if(c.oneof){if(a===null&&(c.kind!=="enum"||c.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(c.oneof))throw new Error(`Multiple members of the oneof group "${c.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(c.oneof),h=n[c.oneof]={oneofKind:d}}else h=n;if(c.kind=="map"){if(a===null)continue;this.assert(GS(a),c.name,a);const u=h[d];for(const[g,E]of Object.entries(a)){this.assert(E!==null,c.name+" map value",null);let b;switch(c.V.kind){case"message":b=c.V.T().internalJsonRead(E,i);break;case"enum":if(b=this.enum(c.V.T(),E,c.name,i.ignoreUnknownFields),b===!1)continue;break;case"scalar":b=this.scalar(E,c.V.T,c.V.L,c.name);break}this.assert(b!==void 0,c.name+" map value",E);let k=g;c.K==F.BOOL&&(k=k=="true"?!0:k=="false"?!1:k),k=this.scalar(k,c.K,li.STRING,c.name).toString(),u[k]=b}}else if(c.repeat){if(a===null)continue;this.assert(Array.isArray(a),c.name,a);const u=h[d];for(const g of a){this.assert(g!==null,c.name,null);let E;switch(c.kind){case"message":E=c.T().internalJsonRead(g,i);break;case"enum":if(E=this.enum(c.T(),g,c.name,i.ignoreUnknownFields),E===!1)continue;break;case"scalar":E=this.scalar(g,c.T,c.L,c.name);break}this.assert(E!==void 0,c.name,a),u.push(E)}}else switch(c.kind){case"message":if(a===null&&c.T().typeName!="google.protobuf.Value"){this.assert(c.oneof===void 0,c.name+" (oneof member)",null);continue}h[d]=c.T().internalJsonRead(a,i,h[d]);break;case"enum":if(a===null)continue;let u=this.enum(c.T(),a,c.name,i.ignoreUnknownFields);if(u===!1)continue;h[d]=u;break;case"scalar":if(a===null)continue;h[d]=this.scalar(a,c.T,c.L,c.name);break}}}enum(e,n,i,r){if(e[0]=="google.protobuf.NullValue"&&Ee(n===null||n==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} only accepts null.`),n===null)return 0;switch(typeof n){case"number":return Ee(Number.isInteger(n),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${n}.`),n;case"string":let s=n;e[2]&&n.substring(0,e[2].length)===e[2]&&(s=n.substring(e[2].length));let a=e[1][s];return typeof a=="undefined"&&r?!1:(Ee(typeof a=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} has no value for "${n}".`),a)}Ee(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof n}".`)}scalar(e,n,i,r){let s;try{switch(n){case F.DOUBLE:case F.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let a=Number(e);if(Number.isNaN(a)){s="not a number";break}if(!Number.isFinite(a)){s="too large or small";break}return n==F.FLOAT&&Np(a),a;case F.INT32:case F.FIXED32:case F.SFIXED32:case F.SINT32:case F.UINT32:if(e===null)return 0;let c;if(typeof e=="number"?c=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":c=Number(e)),c===void 0)break;return n==F.UINT32?Yd(c):qo(c),c;case F.INT64:case F.SFIXED64:case F.SINT64:if(e===null)return qn(xe.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return qn(xe.from(e),i);case F.FIXED64:case F.UINT64:if(e===null)return qn(Dt.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return qn(Dt.from(e),i);case F.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case F.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(d){d="invalid UTF8";break}return e;case F.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return JS(e)}}catch(a){s=a.message}this.assert(!1,r+(s?" - "+s:""),e)}}class hT{constructor(e){var n;this.fields=(n=e.fields)!==null&&n!==void 0?n:[]}write(e,n){const i={},r=e;for(const s of this.fields){if(!s.oneof){let h=this.field(s,r[s.localName],n);h!==void 0&&(i[n.useProtoFieldName?s.name:s.jsonName]=h);continue}const a=r[s.oneof];if(a.oneofKind!==s.localName)continue;const c=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},n),{emitDefaultValues:!0}):n;let d=this.field(s,a[s.localName],c);Ee(d!==void 0),i[n.useProtoFieldName?s.name:s.jsonName]=d}return i}field(e,n,i){let r;if(e.kind=="map"){Ee(typeof n=="object"&&n!==null);const s={};switch(e.V.kind){case"scalar":for(const[d,h]of Object.entries(n)){const u=this.scalar(e.V.T,h,e.name,!1,!0);Ee(u!==void 0),s[d.toString()]=u}break;case"message":const a=e.V.T();for(const[d,h]of Object.entries(n)){const u=this.message(a,h,e.name,i);Ee(u!==void 0),s[d.toString()]=u}break;case"enum":const c=e.V.T();for(const[d,h]of Object.entries(n)){Ee(h===void 0||typeof h=="number");const u=this.enum(c,h,e.name,!1,!0,i.enumAsInteger);Ee(u!==void 0),s[d.toString()]=u}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){Ee(Array.isArray(n));const s=[];switch(e.kind){case"scalar":for(let d=0;d<n.length;d++){const h=this.scalar(e.T,n[d],e.name,e.opt,!0);Ee(h!==void 0),s.push(h)}break;case"enum":const a=e.T();for(let d=0;d<n.length;d++){Ee(n[d]===void 0||typeof n[d]=="number");const h=this.enum(a,n[d],e.name,e.opt,!0,i.enumAsInteger);Ee(h!==void 0),s.push(h)}break;case"message":const c=e.T();for(let d=0;d<n.length;d++){const h=this.message(c,n[d],e.name,i);Ee(h!==void 0),s.push(h)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,n,e.name,e.opt,i.emitDefaultValues);break;case"enum":r=this.enum(e.T(),n,e.name,e.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":r=this.message(e.T(),n,e.name,i);break}return r}enum(e,n,i,r,s,a){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(n===void 0){Ee(r);return}if(!(n===0&&!s&&!r))return Ee(typeof n=="number"),Ee(Number.isInteger(n)),a||!e[1].hasOwnProperty(n)?n:e[2]?e[2]+e[1][n]:e[1][n]}message(e,n,i,r){return n===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(n,r)}scalar(e,n,i,r,s){if(n===void 0){Ee(r);return}const a=s||r;switch(e){case F.INT32:case F.SFIXED32:case F.SINT32:return n===0?a?0:void 0:(qo(n),n);case F.FIXED32:case F.UINT32:return n===0?a?0:void 0:(Yd(n),n);case F.FLOAT:Np(n);case F.DOUBLE:return n===0?a?0:void 0:(Ee(typeof n=="number"),Number.isNaN(n)?"NaN":n===Number.POSITIVE_INFINITY?"Infinity":n===Number.NEGATIVE_INFINITY?"-Infinity":n);case F.STRING:return n===""?a?"":void 0:(Ee(typeof n=="string"),n);case F.BOOL:return n===!1?a?!1:void 0:(Ee(typeof n=="boolean"),n);case F.UINT64:case F.FIXED64:Ee(typeof n=="number"||typeof n=="string"||typeof n=="bigint");let c=Dt.from(n);return c.isZero()&&!a?void 0:c.toString();case F.INT64:case F.SFIXED64:case F.SINT64:Ee(typeof n=="number"||typeof n=="string"||typeof n=="bigint");let d=xe.from(n);return d.isZero()&&!a?void 0:d.toString();case F.BYTES:return Ee(n instanceof Uint8Array),n.byteLength?$S(n):a?"":void 0}}}function sh(t,e=li.STRING){switch(t){case F.BOOL:return!1;case F.UINT64:case F.FIXED64:return qn(Dt.ZERO,e);case F.INT64:case F.SFIXED64:case F.SINT64:return qn(xe.ZERO,e);case F.DOUBLE:case F.FLOAT:return 0;case F.BYTES:return new Uint8Array(0);case F.STRING:return"";default:return 0}}class pT{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const n=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(n.map(i=>[i.no,i]))}}read(e,n,i,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[a,c]=e.tag(),d=this.fieldNoToField.get(a);if(!d){let E=i.readUnknownField;if(E=="throw")throw new Error(`Unknown field ${a} (wire type ${c}) for ${this.info.typeName}`);let b=e.skip(c);E!==!1&&(E===!0?Kd.onRead:E)(this.info.typeName,n,a,c,b);continue}let h=n,u=d.repeat,g=d.localName;switch(d.oneof&&(h=h[d.oneof],h.oneofKind!==g&&(h=n[d.oneof]={oneofKind:g})),d.kind){case"scalar":case"enum":let E=d.kind=="enum"?F.INT32:d.T,b=d.kind=="scalar"?d.L:void 0;if(u){let M=h[g];if(c==it.LengthDelimited&&E!=F.STRING&&E!=F.BYTES){let B=e.uint32()+e.pos;for(;e.pos<B;)M.push(this.scalar(e,E,b))}else M.push(this.scalar(e,E,b))}else h[g]=this.scalar(e,E,b);break;case"message":if(u){let M=h[g],B=d.T().internalBinaryRead(e,e.uint32(),i);M.push(B)}else h[g]=d.T().internalBinaryRead(e,e.uint32(),i,h[g]);break;case"map":let[k,A]=this.mapEntry(d,e,i);h[g][k]=A;break}}}mapEntry(e,n,i){let r=n.uint32(),s=n.pos+r,a,c;for(;n.pos<s;){let[d,h]=n.tag();switch(d){case 1:e.K==F.BOOL?a=n.bool().toString():a=this.scalar(n,e.K,li.STRING);break;case 2:switch(e.V.kind){case"scalar":c=this.scalar(n,e.V.T,e.V.L);break;case"enum":c=n.int32();break;case"message":c=e.V.T().internalBinaryRead(n,n.uint32(),i);break}break;default:throw new Error(`Unknown field ${d} (wire type ${h}) in map entry for ${this.info.typeName}#${e.name}`)}}if(a===void 0){let d=sh(e.K);a=e.K==F.BOOL?d.toString():d}if(c===void 0)switch(e.V.kind){case"scalar":c=sh(e.V.T,e.V.L);break;case"enum":c=0;break;case"message":c=e.V.T().create();break}return[a,c]}scalar(e,n,i){switch(n){case F.INT32:return e.int32();case F.STRING:return e.string();case F.BOOL:return e.bool();case F.DOUBLE:return e.double();case F.FLOAT:return e.float();case F.INT64:return qn(e.int64(),i);case F.UINT64:return qn(e.uint64(),i);case F.FIXED64:return qn(e.fixed64(),i);case F.FIXED32:return e.fixed32();case F.BYTES:return e.bytes();case F.UINT32:return e.uint32();case F.SFIXED32:return e.sfixed32();case F.SFIXED64:return qn(e.sfixed64(),i);case F.SINT32:return e.sint32();case F.SINT64:return qn(e.sint64(),i)}}}class mT{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((n,i)=>n.no-i.no)}}write(e,n,i){this.prepare();for(const s of this.fields){let a,c,d=s.repeat,h=s.localName;if(s.oneof){const u=e[s.oneof];if(u.oneofKind!==h)continue;a=u[h],c=!0}else a=e[h],c=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?F.INT32:s.T;if(d)if(Ee(Array.isArray(a)),d==Qd.PACKED)this.packed(n,u,s.no,a);else for(const g of a)this.scalar(n,u,s.no,g,!0);else a===void 0?Ee(s.opt):this.scalar(n,u,s.no,a,c||s.opt);break;case"message":if(d){Ee(Array.isArray(a));for(const g of a)this.message(n,i,s.T(),s.no,g)}else this.message(n,i,s.T(),s.no,a);break;case"map":Ee(typeof a=="object"&&a!==null);for(const[g,E]of Object.entries(a))this.mapEntry(n,i,s,g,E);break}}let r=i.writeUnknownFields;r!==!1&&(r===!0?Kd.onWrite:r)(this.info.typeName,e,n)}mapEntry(e,n,i,r,s){e.tag(i.no,it.LengthDelimited),e.fork();let a=r;switch(i.K){case F.INT32:case F.FIXED32:case F.UINT32:case F.SFIXED32:case F.SINT32:a=Number.parseInt(r);break;case F.BOOL:Ee(r=="true"||r=="false"),a=r=="true";break}switch(this.scalar(e,i.K,1,a,!0),i.V.kind){case"scalar":this.scalar(e,i.V.T,2,s,!0);break;case"enum":this.scalar(e,F.INT32,2,s,!0);break;case"message":this.message(e,n,i.V.T(),2,s);break}e.join()}message(e,n,i,r,s){s!==void 0&&(i.internalBinaryWrite(s,e.tag(r,it.LengthDelimited).fork(),n),e.join())}scalar(e,n,i,r,s){let[a,c,d]=this.scalarInfo(n,r);(!d||s)&&(e.tag(i,a),e[c](r))}packed(e,n,i,r){if(!r.length)return;Ee(n!==F.BYTES&&n!==F.STRING),e.tag(i,it.LengthDelimited),e.fork();let[,s]=this.scalarInfo(n);for(let a=0;a<r.length;a++)e[s](r[a]);e.join()}scalarInfo(e,n){let i=it.Varint,r,s=n===void 0,a=n===0;switch(e){case F.INT32:r="int32";break;case F.STRING:a=s||!n.length,i=it.LengthDelimited,r="string";break;case F.BOOL:a=n===!1,r="bool";break;case F.UINT32:r="uint32";break;case F.DOUBLE:i=it.Bit64,r="double";break;case F.FLOAT:i=it.Bit32,r="float";break;case F.INT64:a=s||xe.from(n).isZero(),r="int64";break;case F.UINT64:a=s||Dt.from(n).isZero(),r="uint64";break;case F.FIXED64:a=s||Dt.from(n).isZero(),i=it.Bit64,r="fixed64";break;case F.BYTES:a=s||!n.byteLength,i=it.LengthDelimited,r="bytes";break;case F.FIXED32:i=it.Bit32,r="fixed32";break;case F.SFIXED32:i=it.Bit32,r="sfixed32";break;case F.SFIXED64:a=s||xe.from(n).isZero(),i=it.Bit64,r="sfixed64";break;case F.SINT32:r="sint32";break;case F.SINT64:a=s||xe.from(n).isZero(),r="sint64";break}return[i,r,s||a]}}function fT(t){const e=t.messagePrototype?Object.create(t.messagePrototype):Object.defineProperty({},hv,{value:t});for(let n of t.fields){let i=n.localName;if(!n.opt)if(n.oneof)e[n.oneof]={oneofKind:void 0};else if(n.repeat)e[i]=[];else switch(n.kind){case"scalar":e[i]=sh(n.T,n.L);break;case"enum":e[i]=0;break;case"map":e[i]={};break}}return e}function lu(t,e,n){let i,r=n,s;for(let a of t.fields){let c=a.localName;if(a.oneof){const d=r[a.oneof];if((d==null?void 0:d.oneofKind)==null)continue;if(i=d[c],s=e[a.oneof],s.oneofKind=d.oneofKind,i==null){delete s[c];continue}}else if(i=r[c],s=e,i==null)continue;switch(a.repeat&&(s[c].length=i.length),a.kind){case"scalar":case"enum":if(a.repeat)for(let h=0;h<i.length;h++)s[c][h]=i[h];else s[c]=i;break;case"message":let d=a.T();if(a.repeat)for(let h=0;h<i.length;h++)s[c][h]=d.create(i[h]);else s[c]===void 0?s[c]=d.create(i):d.mergePartial(s[c],i);break;case"map":switch(a.V.kind){case"scalar":case"enum":Object.assign(s[c],i);break;case"message":let h=a.V.T();for(let u of Object.keys(i))s[c][u]=h.create(i[u]);break}break}}}function gT(t,e,n){if(e===n)return!0;if(!e||!n)return!1;for(let i of t.fields){let r=i.localName,s=i.oneof?e[i.oneof][r]:e[r],a=i.oneof?n[i.oneof][r]:n[r];switch(i.kind){case"enum":case"scalar":let c=i.kind=="enum"?F.INT32:i.T;if(!(i.repeat?Am(c,s,a):pv(c,s,a)))return!1;break;case"map":if(!(i.V.kind=="message"?Mm(i.V.T(),Oc(s),Oc(a)):Am(i.V.kind=="enum"?F.INT32:i.V.T,Oc(s),Oc(a))))return!1;break;case"message":let d=i.T();if(!(i.repeat?Mm(d,s,a):d.equals(s,a)))return!1;break}}return!0}const Oc=Object.values;function pv(t,e,n){if(e===n)return!0;if(t!==F.BYTES)return!1;let i=e,r=n;if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=r[s])return!1;return!0}function Am(t,e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(!pv(t,e[i],n[i]))return!1;return!0}function Mm(t,e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(!t.equals(e[i],n[i]))return!1;return!0}const vT=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class _{constructor(e,n,i){this.defaultCheckDepth=16,this.typeName=e,this.fields=n.map(cT),this.options=i!=null?i:{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},vT),{[hv]:{value:this}})),this.refTypeCheck=new lT(this),this.refJsonReader=new uT(this),this.refJsonWriter=new hT(this),this.refBinReader=new pT(this),this.refBinWriter=new mT(this)}create(e){let n=fT(this);return e!==void 0&&lu(this,n,e),n}clone(e){let n=this.create();return lu(this,n,e),n}equals(e,n){return gT(this,e,n)}is(e,n=this.defaultCheckDepth){return this.refTypeCheck.is(e,n,!1)}isAssignable(e,n=this.defaultCheckDepth){return this.refTypeCheck.is(e,n,!0)}mergePartial(e,n){lu(this,e,n)}fromBinary(e,n){let i=QS(n);return this.internalBinaryRead(i.readerFactory(e),e.byteLength,i)}fromJson(e,n){return this.internalJsonRead(e,aT(n))}fromJsonString(e,n){let i=JSON.parse(e);return this.fromJson(i,n)}toJson(e,n){return this.internalJsonWrite(e,oT(n))}toJsonString(e,n){var i;let r=this.toJson(e,n);return JSON.stringify(r,null,(i=n==null?void 0:n.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(e,n){let i=rT(n);return this.internalBinaryWrite(e,i.writerFactory(),i).finish()}internalJsonRead(e,n,i){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=i!=null?i:this.create();return this.refJsonReader.read(e,r,n),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Dp(e)}.`)}internalJsonWrite(e,n){return this.refJsonWriter.write(e,n)}internalBinaryWrite(e,n,i){return this.refBinWriter.write(e,n,i),n}internalBinaryRead(e,n,i,r){let s=r!=null?r:this.create();return this.refBinReader.read(e,s,i,n),s}}const yT=t=>(e,n)=>(t.set(e,n),n),Om=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,mv=536870912,Dm=mv*2,ET=(t,e)=>n=>{const i=e.get(n);let r=i===void 0?n.size:i<Dm?i+1:0;if(!n.has(r))return t(n,r);if(n.size<mv){for(;n.has(r);)r=Math.floor(Math.random()*Dm);return t(n,r)}if(n.size>Om)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(r);)r=Math.floor(Math.random()*Om);return t(n,r)},fv=new WeakMap,ST=yT(fv),Dc=ET(ST,fv),TT=t=>t.method!==void 0&&t.method==="call",bT=t=>t.error===null&&typeof t.id=="number",kT=t=>{const e=new Map([[0,()=>{}]]),n=new Map([[0,()=>{}]]),i=new Map,r=new Worker(t);return r.addEventListener("message",({data:h})=>{if(TT(h)){const{params:{timerId:u,timerType:g}}=h;if(g==="interval"){const E=e.get(u);if(typeof E=="number"){const b=i.get(E);if(b===void 0||b.timerId!==u||b.timerType!==g)throw new Error("The timer is in an undefined state.")}else if(typeof E!="undefined")E();else throw new Error("The timer is in an undefined state.")}else if(g==="timeout"){const E=n.get(u);if(typeof E=="number"){const b=i.get(E);if(b===void 0||b.timerId!==u||b.timerType!==g)throw new Error("The timer is in an undefined state.")}else if(typeof E!="undefined")E(),n.delete(u);else throw new Error("The timer is in an undefined state.")}}else if(bT(h)){const{id:u}=h,g=i.get(u);if(g===void 0)throw new Error("The timer is in an undefined state.");const{timerId:E,timerType:b}=g;i.delete(u),b==="interval"?e.delete(E):n.delete(E)}else{const{error:{message:u}}=h;throw new Error(u)}}),{clearInterval:h=>{const u=Dc(i);i.set(u,{timerId:h,timerType:"interval"}),e.set(h,u),r.postMessage({id:u,method:"clear",params:{timerId:h,timerType:"interval"}})},clearTimeout:h=>{const u=Dc(i);i.set(u,{timerId:h,timerType:"timeout"}),n.set(h,u),r.postMessage({id:u,method:"clear",params:{timerId:h,timerType:"timeout"}})},setInterval:(h,u=0)=>{const g=Dc(e);return e.set(g,()=>{h(),typeof e.get(g)=="function"&&r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"interval"}})}),r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"interval"}}),g},setTimeout:(h,u=0)=>{const g=Dc(n);return n.set(g,h),r.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:g,timerType:"timeout"}}),g}}},wT=(t,e)=>{let n=null;return()=>{if(n!==null)return n;const i=new Blob([e],{type:"application/javascript; charset=utf-8"}),r=URL.createObjectURL(i);return n=t(r),setTimeout(()=>URL.revokeObjectURL(r)),n}},_T=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`,Al=wT(kT,_T),la=t=>Al().clearInterval(t),IT=t=>Al().clearTimeout(t),Xd=(t,e)=>Al().setInterval(t,e),CT=(t,e)=>Al().setTimeout(t,e);var RT=Object.freeze(Object.defineProperty({__proto__:null,clearInterval:la,clearTimeout:IT,setInterval:Xd,setTimeout:CT},Symbol.toStringTag,{value:"Module"})),gv={},Lp={exports:{}},Nm=Lp.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(t){return t.encoding?"rtpmap:%d %s/%s/%s":t.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(t){return t.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(t){return t.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(t){return"extmap:%d"+(t.direction?"/%s":"%v")+(t["encrypt-uri"]?" %s":"%v")+" %s"+(t.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(t){return t.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(t){var e="candidate:%s %d %s %d %s %d typ %s";return e+=t.raddr!=null?" raddr %s rport %d":"%v%v",e+=t.tcptype!=null?" tcptype %s":"%v",t.generation!=null&&(e+=" generation %d"),e+=t["network-id"]!=null?" network-id %d":"%v",e+=t["network-cost"]!=null?" network-cost %d":"%v",e}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(t){var e="ssrc:%d";return t.attribute!=null&&(e+=" %s",t.value!=null&&(e+=":%s")),e}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(t){return t.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(t){return t.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(t){return"imageattr:%s %s %s"+(t.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(t){return"simulcast:%s %s"+(t.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(t){return"ts-refclk:%s"+(t.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(t){var e="mediaclk:";return e+=t.id!=null?"id=%s %s":"%v%s",e+=t.mediaClockValue!=null?"=%s":"",e+=t.rateNumerator!=null?" rate=%s":"",e+=t.rateDenominator!=null?"/%s":"",e}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Nm).forEach(function(t){var e=Nm[t];e.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});(function(t){var e=function(c){return String(Number(c))===c?Number(c):c},n=function(c,d,h,u){if(u&&!h)d[u]=e(c[1]);else for(var g=0;g<h.length;g+=1)c[g+1]!=null&&(d[h[g]]=e(c[g+1]))},i=function(c,d,h){var u=c.name&&c.names;c.push&&!d[c.push]?d[c.push]=[]:u&&!d[c.name]&&(d[c.name]={});var g=c.push?{}:u?d[c.name]:d;n(h.match(c.reg),g,c.names,c.name),c.push&&d[c.push].push(g)},r=Lp.exports,s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(c){var d={},h=[],u=d;return c.split(/(\r\n|\r|\n)/).filter(s).forEach(function(g){var E=g[0],b=g.slice(2);E==="m"&&(h.push({rtp:[],fmtp:[]}),u=h[h.length-1]);for(var k=0;k<(r[E]||[]).length;k+=1){var A=r[E][k];if(A.reg.test(b))return i(A,u,b)}}),d.media=h,d};var a=function(c,d){var h=d.split(/=(.+)/,2);return h.length===2?c[h[0]]=e(h[1]):h.length===1&&d.length>1&&(c[h[0]]=void 0),c};t.parseParams=function(c){return c.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(c){return c.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(c){for(var d=[],h=c.split(" ").map(e),u=0;u<h.length;u+=3)d.push({component:h[u],ip:h[u+1],port:h[u+2]});return d},t.parseImageAttributes=function(c){return c.split(" ").map(function(d){return d.substring(1,d.length-1).split(",").reduce(a,{})})},t.parseSimulcastStreamList=function(c){return c.split(";").map(function(d){return d.split(",").map(function(h){var u,g=!1;return h[0]!=="~"?u=e(h):(u=e(h.substring(1,h.length)),g=!0),{scid:u,paused:g}})})}})(gv);var uu=Lp.exports,PT=/%[sdv%]/g,AT=function(t){var e=1,n=arguments,i=n.length;return t.replace(PT,function(r){if(e>=i)return r;var s=n[e];switch(e+=1,r){case"%%":return"%";case"%s":return String(s);case"%d":return Number(s);case"%v":return""}})},Na=function(t,e,n){var i=e.format instanceof Function?e.format(e.push?n:n[e.name]):e.format,r=[t+"="+i];if(e.names)for(var s=0;s<e.names.length;s+=1){var a=e.names[s];e.name?r.push(n[e.name][a]):r.push(n[e.names[s]])}else r.push(n[e.name]);return AT.apply(null,r)},MT=["v","o","s","i","u","e","p","c","b","t","r","z","a"],OT=["i","c","b","a"],DT=function(t,e){e=e||{},t.version==null&&(t.version=0),t.name==null&&(t.name=" "),t.media.forEach(function(s){s.payloads==null&&(s.payloads="")});var n=e.outerOrder||MT,i=e.innerOrder||OT,r=[];return n.forEach(function(s){uu[s].forEach(function(a){a.name in t&&t[a.name]!=null?r.push(Na(s,a,t)):a.push in t&&t[a.push]!=null&&t[a.push].forEach(function(c){r.push(Na(s,a,c))})})}),t.media.forEach(function(s){r.push(Na("m",uu.m[0],s)),i.forEach(function(a){uu[a].forEach(function(c){c.name in s&&s[c.name]!=null?r.push(Na(a,c,s)):c.push in s&&s[c.push]!=null&&s[c.push].forEach(function(d){r.push(Na(a,c,d))})})})}),r.join(`\r
8
8
  `)+`\r
9
- `},Ts=gv,LT=NT,ah=LT,Go=Ts.parse;Ts.parseParams;Ts.parseFmtpConfig;Ts.parsePayloads;Ts.parseRemoteCandidates;Ts.parseImageAttributes;Ts.parseSimulcastStreamList;var xT=Object.defineProperty,VT=Object.defineProperties,UT=Object.getOwnPropertyDescriptors,Zd=Object.getOwnPropertySymbols,BT=Object.getPrototypeOf,vv=Object.prototype.hasOwnProperty,yv=Object.prototype.propertyIsEnumerable,FT=Reflect.get,Oe=Math.pow,oh=(t,e,n)=>e in t?xT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e)=>{for(var n in e||(e={}))vv.call(e,n)&&oh(t,n,e[n]);if(Zd)for(var n of Zd(e))yv.call(e,n)&&oh(t,n,e[n]);return t},ee=(t,e)=>VT(t,UT(e)),Ml=(t,e)=>{var n={};for(var i in t)vv.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&Zd)for(var i of Zd(t))e.indexOf(i)<0&&yv.call(t,i)&&(n[i]=t[i]);return n},y=(t,e,n)=>(oh(t,typeof e!="symbol"?e+"":e,n),n),xp=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},o=(t,e,n)=>(xp(t,e,"read from private field"),n?n.call(t):e.get(t)),S=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},T=(t,e,n,i)=>(xp(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),Q=(t,e,n)=>(xp(t,e,"access private method"),n),jT=(t,e,n)=>FT(BT(t),n,e),p=(t,e,n)=>new Promise((i,r)=>{var s=d=>{try{c(n.next(d))}catch(h){r(h)}},a=d=>{try{c(n.throw(d))}catch(h){r(h)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(s,a);c((n=n.apply(t,e)).next())});function WT(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Nt={},HT={get exports(){return Nt},set exports(t){Nt=t}},ma=typeof Reflect=="object"?Reflect:null,Lm=ma&&typeof ma.apply=="function"?ma.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},ld;ma&&typeof ma.ownKeys=="function"?ld=ma.ownKeys:Object.getOwnPropertySymbols?ld=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ld=function(t){return Object.getOwnPropertyNames(t)};function qT(t){console&&console.warn&&console.warn(t)}var Ev=Number.isNaN||function(t){return t!==t};function we(){we.init.call(this)}HT.exports=we;Nt.once=KT;we.EventEmitter=we;we.prototype._events=void 0;we.prototype._eventsCount=0;we.prototype._maxListeners=void 0;var xm=10;function Ol(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(we,"defaultMaxListeners",{enumerable:!0,get:function(){return xm},set:function(t){if(typeof t!="number"||t<0||Ev(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");xm=t}});we.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};we.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Ev(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 Sv(t){return t._maxListeners===void 0?we.defaultMaxListeners:t._maxListeners}we.prototype.getMaxListeners=function(){return Sv(this)};we.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[t];if(c===void 0)return!1;if(typeof c=="function")Lm(c,this,e);else for(var d=c.length,h=_v(c,d),n=0;n<d;++n)Lm(h[n],this,e);return!0};function Tv(t,e,n,i){var r,s,a;if(Ol(n),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),a===void 0)a=s[e]=n,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),r=Sv(t),r>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,qT(c)}return t}we.prototype.addListener=function(t,e){return Tv(this,t,e,!1)};we.prototype.on=we.prototype.addListener;we.prototype.prependListener=function(t,e){return Tv(this,t,e,!0)};function GT(){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 bv(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=GT.bind(i);return r.listener=n,i.wrapFn=r,r}we.prototype.once=function(t,e){return Ol(e),this.on(t,bv(this,t,e)),this};we.prototype.prependOnceListener=function(t,e){return Ol(e),this.prependListener(t,bv(this,t,e)),this};we.prototype.removeListener=function(t,e){var n,i,r,s,a;if(Ol(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():$T(n,r),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};we.prototype.off=we.prototype.removeListener;we.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[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 kv(t,e,n){var i=t._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?JT(r):_v(r,r.length)}we.prototype.listeners=function(t){return kv(this,t,!0)};we.prototype.rawListeners=function(t){return kv(this,t,!1)};we.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):wv.call(t,e)};we.prototype.listenerCount=wv;function wv(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}we.prototype.eventNames=function(){return this._eventsCount>0?ld(this._events):[]};function _v(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function $T(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function JT(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function KT(t,e){return new Promise(function(n,i){function r(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",r),n([].slice.call(arguments))}Iv(t,e,s,{once:!0}),e!=="error"&&zT(t,r,{once:!0})})}function zT(t,e,n){typeof t.on=="function"&&Iv(t,"error",e,n)}function Iv(t,e,n,i){if(typeof t.on=="function")i.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function r(s){i.once&&t.removeEventListener(e,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var oe;(function(t){t[t.MAJOR_EVENT=0]="MAJOR_EVENT",t[t.MINOR_EVENT=1]="MINOR_EVENT"})(oe||(oe={}));var G;(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"})(G||(G={}));const YT=new Map([[G.PRECALL_TEST_BEGIN,oe.MINOR_EVENT],[G.PRECALL_TEST_COMPLETE,oe.MINOR_EVENT],[G.CALL_JOIN_BEGIN,oe.MAJOR_EVENT],[G.NET_QUALITY_TEST_BEGIN,oe.MINOR_EVENT],[G.NET_QUALITY_TEST_END,oe.MINOR_EVENT],[G.WEBSOCKET_CONNECTED,oe.MINOR_EVENT],[G.TRANSPORT_CONNECTED,oe.MAJOR_EVENT],[G.AUDIO_ON,oe.MINOR_EVENT],[G.AUDIO_OFF,oe.MINOR_EVENT],[G.VIDEO_ON,oe.MINOR_EVENT],[G.VIDEO_OFF,oe.MINOR_EVENT],[G.PARTICIPANT_ROLE,oe.MINOR_EVENT],[G.PING_STAT,oe.MAJOR_EVENT],[G.DISCONNECT,oe.MAJOR_EVENT],[G.RECONNECT_ATTEMPT,oe.MAJOR_EVENT],[G.SCREENSHARE_START_REQUESTED,oe.MINOR_EVENT],[G.SCREENSHARE_STARTED,oe.MINOR_EVENT],[G.SCREENSHARE_STOPPED,oe.MINOR_EVENT],[G.TAB_CHANGE,oe.MINOR_EVENT],[G.BROWSER_BACKGROUNDED,oe.MINOR_EVENT],[G.BROWSER_FOREGROUNDED,oe.MINOR_EVENT],[G.DOMINANT_SPEAKER,oe.MINOR_EVENT],[G.AUDIO_DEVICES_UPDATES,oe.MINOR_EVENT],[G.VIDEO_DEVICES_UPDATES,oe.MINOR_EVENT],[G.SPEAKER_DEVICES_UPDATES,oe.MINOR_EVENT],[G.SELECTED_MICROHPONE_UPDATE,oe.MINOR_EVENT],[G.SELECTED_CAMERA_UPDATE,oe.MINOR_EVENT],[G.SELECTED_SPEAKER_UPDATE,oe.MINOR_EVENT],[G.MEDIA_PERMISSION,oe.MINOR_EVENT],[G.LEGACY_SWITCH,oe.MINOR_EVENT],[G.AUDIO_PLAY_FAILED,oe.MINOR_EVENT],[G.VIDEO_PLAY_FAILED,oe.MINOR_EVENT],[G.AUDIO_TRACK_MUTED,oe.MINOR_EVENT],[G.VIDEO_TRACK_MUTED,oe.MINOR_EVENT],[G.IVS_PLAYER_REBUFFERING,oe.MAJOR_EVENT],[G.IVS_PLAYER_AUDIO_BLOCKED,oe.MAJOR_EVENT],[G.IVS_PLAYER_PLAYBACK_BLOCKED,oe.MAJOR_EVENT],[G.IVS_PLAYER_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_RECOVERABLE_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_WORKER_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_NETWORK_UNAVAILABLE,oe.MAJOR_EVENT],[G.LIVESTREAM_LATENCY,oe.MAJOR_EVENT],[G.IVS_PLAYER_ANALYTICS_EVENT,oe.MINOR_EVENT],[G.IVS_PLAYER_PLAYBACK_RATE_CHANGED,oe.MINOR_EVENT],[G.IVS_PLAYER_QUALITY_CHANGED,oe.MINOR_EVENT],[G.IVS_PLAYER_INITIALIZED,oe.MINOR_EVENT],[G.EXPECTED_VIDEO_RESOLUTION,oe.MINOR_EVENT],[G.EXPECTED_SCREENSHARE_RESOLUTION,oe.MINOR_EVENT]]);class QT{constructor(){y(this,"events"),this.events=[]}add(e){this.events.push(e)}flush(){return{entries:this.events.splice(0,25)}}}class XT extends Nt{constructor({logger:e,peerId:n,apiHostnames:i}){super(),y(this,"logger"),y(this,"peerId"),y(this,"eventStore"),y(this,"apiEndpoint"),this.logger=e,this.peerId=n,this.apiEndpoint=`https://${i.daCollector}/api/v1/message`,this.eventStore=new QT}sendEventsChunkToServer(e){return p(this,null,function*(){var n;const i={payload:e,peerId:this.peerId};try{return yield fetch(this.apiEndpoint,{method:"POST",body:JSON.stringify(i)}),!0}catch(r){return this.logger.error("callStats::sendEventsChunkToServer::catch",{error:r}),(n=e.entries)==null||n.forEach(s=>{this.eventStore.add(s)}),!1}})}callEvent(e){e.timestamp=new Date,this.eventStore.add(e),this.emit(e.event,e.metaData),YT.get(e.event)===oe.MAJOR_EVENT&&this.flush()}flush(){return p(this,null,function*(){var e;const n=this.eventStore.flush();return(e=n==null?void 0:n.entries)!=null&&e.length?(yield this.sendEventsChunkToServer(n),!0):!1})}}var Vm;(function(t){t.CHROMIUM="chromum",t.FIREFOX="firefox",t.SAFARI="safari"})(Vm||(Vm={}));const $o={DEVEL:"devel",PREPROD:"preprod",PROD:"prod"};var wn;(function(t){t.AUDIO="AUDIO",t.VIDEO="VIDEO",t.SPEAKER="SPEAKER",t.SCREENSHARE="SCREENSHARE"})(wn||(wn={}));var Um;(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"})(Um||(Um={}));function Sr(t){return t?t.split(".").slice(0,2).concat(["0","0"]).join("."):""}function el({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function tl({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}const Cv=240,Rv=720,Pv=8,Av=3,Dl=10,Nl=.02,Ll=.03;function Ri({stat:t,weight:e,rangeMin:n,rangeMax:i,rangeRankingDirection:r}){return t==null?e:n===i?r==="UP"?t<=n?e:0:t>=i?e:0:r==="UP"?(1-Math.max(Math.min(i,Math.abs(t))-n,0)/(i-n))*e:r==="DOWN"?Math.max(Math.min(i,Math.abs(t))-n,0)/(i-n)*e:e}function Mv({isLowQualityVideo:t,isVideoStuck:e,isVideoLagging:n,jitterQuality:i,packetsLostQuality:r}){const s=.8*((t?.85:1)*(n?.7:1)*(e?.5:1))+.2*(i*r);return Math.round((s+Number.EPSILON)*100)/100}function Ov({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function Dv({packetsLost:t,packetsSent:e,jitter:n}){const i=Ri({stat:Ov({packetsLost:t,packetsSent:e}),weight:.7,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),r=Ri({stat:n,weight:.3,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"});return i+r}function ZT({frameWidth:t,isScreenShare:e}){return t<(e?Rv:Cv)}function eb({framesPerSecond:t,isScreenShare:e}){return t<(e?Av:Pv)}function tb({framesEncoded:t}){return t===0}function Nv({frameWidth:t,framesPerSecond:e,packetsLost:n,packetsSent:i,jitter:r,isScreenShare:s,framesEncoded:a}){const c=Ri({stat:Ov({packetsLost:n,packetsSent:i}),weight:1,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),d=Ri({stat:r,weight:1,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"}),h=ZT({frameWidth:t,isScreenShare:s}),u=eb({framesPerSecond:e,isScreenShare:s}),g=tb({framesEncoded:a,isScreenShare:s});return Mv({isLowQualityVideo:h,isVideoLagging:u,isVideoStuck:g,jitterQuality:d,packetsLostQuality:c})}function Lv({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}function xv({concealmentEvents:t,packetsLost:e,packetsReceived:n,jitter:i}){const r=Ri({stat:t,weight:.2,rangeMin:0,rangeMax:3,rangeRankingDirection:"UP"}),s=.5,a=Ri({stat:Lv({packetsLost:e,packetsReceived:n}),weight:s,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),c=Ri({stat:i,weight:.3,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"});return r+a+c}function nb({framesDecoded:t}){return t===0}function ib({framesPerSecond:t,isScreenShare:e}){return t<(e?Av:Pv)}function rb({frameWidth:t,isScreenShare:e}){return t<(e?Rv:Cv)}function Vv({frameWidth:t,framesPerSecond:e,packetsLost:n,packetsReceived:i,jitter:r,isScreenShare:s,framesDecoded:a}){const c=Ri({stat:Lv({packetsLost:n,packetsReceived:i}),weight:1,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),d=Ri({stat:r,weight:1,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"}),h=rb({frameWidth:t,isScreenShare:s}),u=ib({framesPerSecond:e,isScreenShare:s}),g=nb({framesDecoded:a,isScreenShare:s});return Mv({isLowQualityVideo:h,isVideoLagging:u,isVideoStuck:g,jitterQuality:d,packetsLostQuality:c})}class Pi{constructor(e){y(this,"pc1"),y(this,"pc2"),y(this,"constrainVideoBitrateKbps"),y(this,"constrainOfferToRemoveVideoFec",!1),y(this,"iceCandidateFilter");const n=new RTCPeerConnection(e),i=new RTCPeerConnection(e);this.pc1=n,this.pc2=i,this.iceCandidateFilter=Pi.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 n="candidate:",i=e.indexOf(n)+n.length,r=e.substr(i).split(" ");return{type:r[7],protocol:r[2],address:r[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,n){if(n.candidate){const i=Pi.parseCandidate(n.candidate.candidate);this.iceCandidateFilter(i)&&e.addIceCandidate(n.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
9
+ `},Ts=gv,NT=DT,ah=NT,Go=Ts.parse;Ts.parseParams;Ts.parseFmtpConfig;Ts.parsePayloads;Ts.parseRemoteCandidates;Ts.parseImageAttributes;Ts.parseSimulcastStreamList;var LT=Object.defineProperty,xT=Object.defineProperties,VT=Object.getOwnPropertyDescriptors,Zd=Object.getOwnPropertySymbols,UT=Object.getPrototypeOf,vv=Object.prototype.hasOwnProperty,yv=Object.prototype.propertyIsEnumerable,BT=Reflect.get,Oe=Math.pow,oh=(t,e,n)=>e in t?LT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e)=>{for(var n in e||(e={}))vv.call(e,n)&&oh(t,n,e[n]);if(Zd)for(var n of Zd(e))yv.call(e,n)&&oh(t,n,e[n]);return t},ee=(t,e)=>xT(t,VT(e)),Ml=(t,e)=>{var n={};for(var i in t)vv.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&Zd)for(var i of Zd(t))e.indexOf(i)<0&&yv.call(t,i)&&(n[i]=t[i]);return n},y=(t,e,n)=>(oh(t,typeof e!="symbol"?e+"":e,n),n),xp=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},o=(t,e,n)=>(xp(t,e,"read from private field"),n?n.call(t):e.get(t)),S=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},T=(t,e,n,i)=>(xp(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),Q=(t,e,n)=>(xp(t,e,"access private method"),n),FT=(t,e,n)=>BT(UT(t),n,e),p=(t,e,n)=>new Promise((i,r)=>{var s=d=>{try{c(n.next(d))}catch(h){r(h)}},a=d=>{try{c(n.throw(d))}catch(h){r(h)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(s,a);c((n=n.apply(t,e)).next())});function jT(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Nt={},WT={get exports(){return Nt},set exports(t){Nt=t}},ma=typeof Reflect=="object"?Reflect:null,Lm=ma&&typeof ma.apply=="function"?ma.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},ld;ma&&typeof ma.ownKeys=="function"?ld=ma.ownKeys:Object.getOwnPropertySymbols?ld=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ld=function(t){return Object.getOwnPropertyNames(t)};function HT(t){console&&console.warn&&console.warn(t)}var Ev=Number.isNaN||function(t){return t!==t};function we(){we.init.call(this)}WT.exports=we;Nt.once=$T;we.EventEmitter=we;we.prototype._events=void 0;we.prototype._eventsCount=0;we.prototype._maxListeners=void 0;var xm=10;function Ol(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(we,"defaultMaxListeners",{enumerable:!0,get:function(){return xm},set:function(t){if(typeof t!="number"||t<0||Ev(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");xm=t}});we.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};we.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Ev(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 Sv(t){return t._maxListeners===void 0?we.defaultMaxListeners:t._maxListeners}we.prototype.getMaxListeners=function(){return Sv(this)};we.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[t];if(c===void 0)return!1;if(typeof c=="function")Lm(c,this,e);else for(var d=c.length,h=_v(c,d),n=0;n<d;++n)Lm(h[n],this,e);return!0};function Tv(t,e,n,i){var r,s,a;if(Ol(n),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),a===void 0)a=s[e]=n,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),r=Sv(t),r>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,HT(c)}return t}we.prototype.addListener=function(t,e){return Tv(this,t,e,!1)};we.prototype.on=we.prototype.addListener;we.prototype.prependListener=function(t,e){return Tv(this,t,e,!0)};function qT(){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 bv(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=qT.bind(i);return r.listener=n,i.wrapFn=r,r}we.prototype.once=function(t,e){return Ol(e),this.on(t,bv(this,t,e)),this};we.prototype.prependOnceListener=function(t,e){return Ol(e),this.prependListener(t,bv(this,t,e)),this};we.prototype.removeListener=function(t,e){var n,i,r,s,a;if(Ol(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():GT(n,r),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};we.prototype.off=we.prototype.removeListener;we.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[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 kv(t,e,n){var i=t._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?JT(r):_v(r,r.length)}we.prototype.listeners=function(t){return kv(this,t,!0)};we.prototype.rawListeners=function(t){return kv(this,t,!1)};we.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):wv.call(t,e)};we.prototype.listenerCount=wv;function wv(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}we.prototype.eventNames=function(){return this._eventsCount>0?ld(this._events):[]};function _v(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function GT(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function JT(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function $T(t,e){return new Promise(function(n,i){function r(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",r),n([].slice.call(arguments))}Iv(t,e,s,{once:!0}),e!=="error"&&KT(t,r,{once:!0})})}function KT(t,e,n){typeof t.on=="function"&&Iv(t,"error",e,n)}function Iv(t,e,n,i){if(typeof t.on=="function")i.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function r(s){i.once&&t.removeEventListener(e,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var oe;(function(t){t[t.MAJOR_EVENT=0]="MAJOR_EVENT",t[t.MINOR_EVENT=1]="MINOR_EVENT"})(oe||(oe={}));var G;(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"})(G||(G={}));const zT=new Map([[G.PRECALL_TEST_BEGIN,oe.MINOR_EVENT],[G.PRECALL_TEST_COMPLETE,oe.MINOR_EVENT],[G.CALL_JOIN_BEGIN,oe.MAJOR_EVENT],[G.NET_QUALITY_TEST_BEGIN,oe.MINOR_EVENT],[G.NET_QUALITY_TEST_END,oe.MINOR_EVENT],[G.WEBSOCKET_CONNECTED,oe.MINOR_EVENT],[G.TRANSPORT_CONNECTED,oe.MAJOR_EVENT],[G.AUDIO_ON,oe.MINOR_EVENT],[G.AUDIO_OFF,oe.MINOR_EVENT],[G.VIDEO_ON,oe.MINOR_EVENT],[G.VIDEO_OFF,oe.MINOR_EVENT],[G.PARTICIPANT_ROLE,oe.MINOR_EVENT],[G.PING_STAT,oe.MAJOR_EVENT],[G.DISCONNECT,oe.MAJOR_EVENT],[G.RECONNECT_ATTEMPT,oe.MAJOR_EVENT],[G.SCREENSHARE_START_REQUESTED,oe.MINOR_EVENT],[G.SCREENSHARE_STARTED,oe.MINOR_EVENT],[G.SCREENSHARE_STOPPED,oe.MINOR_EVENT],[G.TAB_CHANGE,oe.MINOR_EVENT],[G.BROWSER_BACKGROUNDED,oe.MINOR_EVENT],[G.BROWSER_FOREGROUNDED,oe.MINOR_EVENT],[G.DOMINANT_SPEAKER,oe.MINOR_EVENT],[G.AUDIO_DEVICES_UPDATES,oe.MINOR_EVENT],[G.VIDEO_DEVICES_UPDATES,oe.MINOR_EVENT],[G.SPEAKER_DEVICES_UPDATES,oe.MINOR_EVENT],[G.SELECTED_MICROHPONE_UPDATE,oe.MINOR_EVENT],[G.SELECTED_CAMERA_UPDATE,oe.MINOR_EVENT],[G.SELECTED_SPEAKER_UPDATE,oe.MINOR_EVENT],[G.MEDIA_PERMISSION,oe.MINOR_EVENT],[G.LEGACY_SWITCH,oe.MINOR_EVENT],[G.AUDIO_PLAY_FAILED,oe.MINOR_EVENT],[G.VIDEO_PLAY_FAILED,oe.MINOR_EVENT],[G.AUDIO_TRACK_MUTED,oe.MINOR_EVENT],[G.VIDEO_TRACK_MUTED,oe.MINOR_EVENT],[G.IVS_PLAYER_REBUFFERING,oe.MAJOR_EVENT],[G.IVS_PLAYER_AUDIO_BLOCKED,oe.MAJOR_EVENT],[G.IVS_PLAYER_PLAYBACK_BLOCKED,oe.MAJOR_EVENT],[G.IVS_PLAYER_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_RECOVERABLE_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_WORKER_ERROR,oe.MAJOR_EVENT],[G.IVS_PLAYER_NETWORK_UNAVAILABLE,oe.MAJOR_EVENT],[G.LIVESTREAM_LATENCY,oe.MAJOR_EVENT],[G.IVS_PLAYER_ANALYTICS_EVENT,oe.MINOR_EVENT],[G.IVS_PLAYER_PLAYBACK_RATE_CHANGED,oe.MINOR_EVENT],[G.IVS_PLAYER_QUALITY_CHANGED,oe.MINOR_EVENT],[G.IVS_PLAYER_INITIALIZED,oe.MINOR_EVENT],[G.EXPECTED_VIDEO_RESOLUTION,oe.MINOR_EVENT],[G.EXPECTED_SCREENSHARE_RESOLUTION,oe.MINOR_EVENT]]);class YT{constructor(){y(this,"events"),this.events=[]}add(e){this.events.push(e)}flush(){return{entries:this.events.splice(0,25)}}}class QT extends Nt{constructor({logger:e,peerId:n,apiHostnames:i}){super(),y(this,"logger"),y(this,"peerId"),y(this,"eventStore"),y(this,"apiEndpoint"),this.logger=e,this.peerId=n,this.apiEndpoint=`https://${i.daCollector}/api/v1/message`,this.eventStore=new YT}sendEventsChunkToServer(e){return p(this,null,function*(){var n;const i={payload:e,peerId:this.peerId};try{return yield fetch(this.apiEndpoint,{method:"POST",body:JSON.stringify(i)}),!0}catch(r){return this.logger.error("callStats::sendEventsChunkToServer::catch",{error:r}),(n=e.entries)==null||n.forEach(s=>{this.eventStore.add(s)}),!1}})}callEvent(e){e.timestamp=new Date,this.eventStore.add(e),this.emit(e.event,e.metaData),zT.get(e.event)===oe.MAJOR_EVENT&&this.flush()}flush(){return p(this,null,function*(){var e;const n=this.eventStore.flush();return(e=n==null?void 0:n.entries)!=null&&e.length?(yield this.sendEventsChunkToServer(n),!0):!1})}}var Vm;(function(t){t.CHROMIUM="chromum",t.FIREFOX="firefox",t.SAFARI="safari"})(Vm||(Vm={}));const Jo={DEVEL:"devel",PREPROD:"preprod",PROD:"prod"};var wn;(function(t){t.AUDIO="AUDIO",t.VIDEO="VIDEO",t.SPEAKER="SPEAKER",t.SCREENSHARE="SCREENSHARE"})(wn||(wn={}));var Um;(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"})(Um||(Um={}));function Sr(t){return t?t.split(".").slice(0,2).concat(["0","0"]).join("."):""}function el({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function tl({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}const Cv=240,Rv=720,Pv=8,Av=3,Dl=10,Nl=.02,Ll=.03;function Ri({stat:t,weight:e,rangeMin:n,rangeMax:i,rangeRankingDirection:r}){return t==null?e:n===i?r==="UP"?t<=n?e:0:t>=i?e:0:r==="UP"?(1-Math.max(Math.min(i,Math.abs(t))-n,0)/(i-n))*e:r==="DOWN"?Math.max(Math.min(i,Math.abs(t))-n,0)/(i-n)*e:e}function Mv({isLowQualityVideo:t,isVideoStuck:e,isVideoLagging:n,jitterQuality:i,packetsLostQuality:r}){const s=.8*((t?.85:1)*(n?.7:1)*(e?.5:1))+.2*(i*r);return Math.round((s+Number.EPSILON)*100)/100}function Ov({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function Dv({packetsLost:t,packetsSent:e,jitter:n}){const i=Ri({stat:Ov({packetsLost:t,packetsSent:e}),weight:.7,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),r=Ri({stat:n,weight:.3,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"});return i+r}function XT({frameWidth:t,isScreenShare:e}){return t<(e?Rv:Cv)}function ZT({framesPerSecond:t,isScreenShare:e}){return t<(e?Av:Pv)}function eb({framesEncoded:t}){return t===0}function Nv({frameWidth:t,framesPerSecond:e,packetsLost:n,packetsSent:i,jitter:r,isScreenShare:s,framesEncoded:a}){const c=Ri({stat:Ov({packetsLost:n,packetsSent:i}),weight:1,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),d=Ri({stat:r,weight:1,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"}),h=XT({frameWidth:t,isScreenShare:s}),u=ZT({framesPerSecond:e,isScreenShare:s}),g=eb({framesEncoded:a,isScreenShare:s});return Mv({isLowQualityVideo:h,isVideoLagging:u,isVideoStuck:g,jitterQuality:d,packetsLostQuality:c})}function Lv({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}function xv({concealmentEvents:t,packetsLost:e,packetsReceived:n,jitter:i}){const r=Ri({stat:t,weight:.2,rangeMin:0,rangeMax:3,rangeRankingDirection:"UP"}),s=.5,a=Ri({stat:Lv({packetsLost:e,packetsReceived:n}),weight:s,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),c=Ri({stat:i,weight:.3,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"});return r+a+c}function tb({framesDecoded:t}){return t===0}function nb({framesPerSecond:t,isScreenShare:e}){return t<(e?Av:Pv)}function ib({frameWidth:t,isScreenShare:e}){return t<(e?Rv:Cv)}function Vv({frameWidth:t,framesPerSecond:e,packetsLost:n,packetsReceived:i,jitter:r,isScreenShare:s,framesDecoded:a}){const c=Ri({stat:Lv({packetsLost:n,packetsReceived:i}),weight:1,rangeMin:0,rangeMax:Dl,rangeRankingDirection:"UP"}),d=Ri({stat:r,weight:1,rangeMin:Nl,rangeMax:Ll,rangeRankingDirection:"UP"}),h=ib({frameWidth:t,isScreenShare:s}),u=nb({framesPerSecond:e,isScreenShare:s}),g=tb({framesDecoded:a,isScreenShare:s});return Mv({isLowQualityVideo:h,isVideoLagging:u,isVideoStuck:g,jitterQuality:d,packetsLostQuality:c})}class Pi{constructor(e){y(this,"pc1"),y(this,"pc2"),y(this,"constrainVideoBitrateKbps"),y(this,"constrainOfferToRemoveVideoFec",!1),y(this,"iceCandidateFilter");const n=new RTCPeerConnection(e),i=new RTCPeerConnection(e);this.pc1=n,this.pc2=i,this.iceCandidateFilter=Pi.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 n="candidate:",i=e.indexOf(n)+n.length,r=e.substr(i).split(" ");return{type:r[7],protocol:r[2],address:r[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,n){if(n.candidate){const i=Pi.parseCandidate(n.candidate.candidate);this.iceCandidateFilter(i)&&e.addIceCandidate(n.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 p(this,null,function*(){const[e,n]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,r;if(e.forEach(s=>{s.type==="candidate-pair"&&s.nominated===!0&&s.bytesSent>0&&(i=s)}),n.forEach(s=>{s.type==="candidate-pair"&&s.nominated===!0&&s.bytesReceived>0&&(r=s)}),i&&r)try{if(i.currentRoundTripTime&&r.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:r.currentRoundTripTime};const s=(r.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:s,backendRTT:s}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class Uv extends Nt{constructor(e){super(),y(this,"call"),y(this,"timeOut"),this.call=new Pi(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 sb=8,ab=1/1e3;class ob extends Uv{constructor(e){super(e),y(this,"senderChannel"),y(this,"recieveChannel"),y(this,"startTime"),y(this,"lastBitrateMeasureTime"),y(this,"sentPayloadBytes",0),y(this,"recievedPayloadBytes",0),y(this,"lastReceivedPayloadBytes",0),y(this,"stopSending",!1),y(this,"testProgress",0),y(this,"samplePacket",""),y(this,"finalBitrateSum",0),y(this,"bitRateSampels",0),y(this,"maxNumberOfPacketsToSend",0),y(this,"bytesToKeepBuffered",0),y(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(Pi.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let n=0;n<1024*256;n+=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 n=e.getTime()-this.startTime.getTime();n>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=n/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const n=new Date,i=n.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const r=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*sb/(i/1e3);this.finalBitrateSum+=r,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=n}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const r=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(r*ab)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:n,backendRTT:i})=>super.testComplete({RTT:n,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Vp extends Uv{constructor(e,n=Pi.noFilter){super(e),y(this,"ch1"),y(this,"ch2"),this.call.setIceCandidateFilter(n);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 n=e.channel;this.ch2=n,n.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class cb extends Vp{constructor(e){super(e,Pi.isHost)}}class db extends Vp{constructor(e){super(e,Pi.isRelay)}}class lb extends Vp{constructor(e){super(e,Pi.isReflexive)}}class ub{constructor(){y(this,"ipInformation",null)}getIPDetails(e){return p(this,arguments,function*({peerId:n,apiHostnames:i,logger:r}){var s,a,c;if(!this.ipInformation){try{const d=`https://${i.location}`,h=yield(yield fetch(d)).json();if(((s=h.loc)==null?void 0:s.length)>5)return this.ipInformation=h,(a=this.ipInformation)!=null&&a.ip&&(this.ipInformation.ip=Sr(this.ipInformation.ip)),h;throw Error("Insufficient data")}catch(d){r.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${n}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=Sr(this.ipInformation.ip))}catch(d){r.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const Up=new ub,Bm=[{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 Fm(t){const[e,n]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(n)}}}class Bv{constructor(){y(this,"transport"),y(this,"candidatePair"),y(this,"outboundVideoRtp",new Map),y(this,"inboundVideoRtp",new Map),y(this,"outboundAudioRtp",new Map),y(this,"inboundAudioRtp",new Map),y(this,"remoteInboundRtp",new Map),y(this,"producerStreamMap",new Map),y(this,"consumerStreamMap",new Map),y(this,"staleProducerStreamMap",!1),y(this,"staleConsumerStreamMap",!1)}}class Fv extends Nt{constructor(){super(),y(this,"observer"),y(this,"outboundProducerMap",new Map),y(this,"inboundConsumerMap",new Map),y(this,"consumerPeerIdMap",new Map),y(this,"pausedConsumerMap",new Map),y(this,"pausedProducerMap",new Map),y(this,"overallProducingTransportsStatsMap",{}),y(this,"overallConsumingTransportsStatsMap",{}),y(this,"overallConsumersStatsMap",{}),y(this,"overallProducersStatsMap",{}),y(this,"videoProducerToStatsMap",new Map),y(this,"audioProducerToStatsMap",new Map),y(this,"videoConsumerToStatsMap",new Map),y(this,"audioConsumerToStatsMap",new Map),y(this,"consumerIdsWithFreezedVideo",new Set),y(this,"consumerIdsWithFreezedAudio",new Set),y(this,"producerIdsWithFreezedVideo",new Set),y(this,"producerIdsWithFreezedAudio",new Set),y(this,"freezedProducingTransportIds",new Set),y(this,"freezedConsumingTransportIds",new Set),y(this,"screenShareProducers",new Set),y(this,"screenShareConsumers",new Set),y(this,"ipDetails"),y(this,"callStatsInstance"),this.observer=new Nt}registerProducer(e){return p(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,n,i){var r,s;const a=((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.get(e))||{};n.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&a.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(n.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&a.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,n,i){var r,s;const a=((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.get(e))||{};n.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&a.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(n.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&a.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{};n.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&s.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(n.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&s.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{};n.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&s.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(n.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&s.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{},{audio:a,video:c,screen:d}=s,h=a||c||d;n.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&h&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(n.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&h&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,n,i){var r,s;const a=!!Array.from(((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);n.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&a&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(n.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&a&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return p(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,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=n?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const s of i.values())switch(s.type){case"outbound-rtp":{this.outboundProducerMap.set(s.id,e.id);break}}return r})}generateConsumerStreamMap(e,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=n?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const s of i.values())switch(s.type){case"inbound-rtp":{this.inboundConsumerMap.set(s.id,e.id);break}}return r})}deregisterProducer(e){this.outboundProducerMap.forEach((n,i)=>{n===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((n,i)=>{n===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var n;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(n=e.relayProtocol)!=null?n:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(n=>{const i=n.framesEncoded>0,r=n.packetsSent>0,s=n.frameWidth&&n.frameHeight;return i&&r&&!!s})||e[e.length-1]}parseRTCReport(e,n=[],i=!1,r=void 0,s=void 0){var a,c,d,h,u,g,E,b,k,A,M,B,K;const X=e,O=new Bv,$=n.length?new Set(n):void 0,me=[],Ie=[],fe=[],Je=new Map,ht=new Map;for(const V of X.values()){if($){if($.size===0)break;if($.has(V.type))i&&$.delete(V.type);else continue}switch(V.type){case"local-candidate":{me.push(this.getIceCandidateStats(V));break}case"remote-candidate":{Ie.push(this.getIceCandidateStats(V));break}case"candidate-pair":{const{nominated:I}=V,{selected:P}=V,z=V,ye={nominated:I!=null?I:P,currentRoundTripTime:z.currentRoundTripTime,totalRoundTripTime:z.totalRoundTripTime,bytesReceived:z.bytesReceived,bytesSent:z.bytesSent,availableOutgoingBitrate:z.availableOutgoingBitrate,availableIncomingBitrate:z.availableIncomingBitrate,lastPacketReceivedTimestamp:z.lastPacketReceivedTimestamp,lastPacketSentTimestamp:z.lastPacketSentTimestamp,localCandidateId:z.localCandidateId,remoteCandidateId:z.remoteCandidateId,bytesDiscardedOnSend:z.bytesDiscardedOnSend,packetsSent:z.packetsSent,packetsReceived:z.packetsReceived,packetsDiscardedOnSend:z.packetsDiscardedOnSend};fe.push(ye),(V.nominated===!0||V.selected===!0)&&(O.candidatePair=ye);break}case"transport":{const I=V;s&&(s.producing&&(this.overallProducingTransportsStatsMap[s.id]||(this.overallProducingTransportsStatsMap[s.id]={totalPacketsSent:0})),s.consuming&&(this.overallConsumingTransportsStatsMap[s.id]||(this.overallConsumingTransportsStatsMap[s.id]={totalPacketsReceived:0})));const P={bytesReceived:I.bytesReceived,bytesSent:I.bytesSent,packetsSent:I.packetsSent,packetsReceived:I.packetsReceived,dtlsCipher:I.dtlsCipher,dtlsState:I.dtlsState,iceRole:I.iceRole};if(O.transport=P,s){if(s.producing){const z=this.overallProducingTransportsStatsMap[s.id];this.processProducingTransportStats(s.id,z,P)}if(s.consuming){const z=this.overallConsumingTransportsStatsMap[s.id];this.processConsumingTransportStats(s.id,z,P)}}break}case"remote-inbound-rtp":{const I=V,P={jitter:I.jitter,fractionLost:I.fractionLost,roundTripTime:I.roundTripTime,roundTripTimeMeasurements:I.roundTripTimeMeasurements,totalRoundTripTime:I.totalRoundTripTime,packetsLost:I.packetsLost};O.remoteInboundRtp.set(I.localId,P);break}case"outbound-rtp":{const I=V,P=r||this.outboundProducerMap.get(V.id),z=this.pausedProducerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedProducerMap.set(P,{lastReportCalculated:!0})}this.overallProducersStatsMap[P]||(this.overallProducersStatsMap[P]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const ye=this.overallProducersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.outboundProducerMap.has(V.id)){O.staleProducerStreamMap=!0;break}const Xe=this.callStatsInstance.producers.get(P);if(((a=Xe==null?void 0:Xe.track)==null?void 0:a.readyState)==="ended")break;O.producerStreamMap.has(P)||O.producerStreamMap.set(P,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const q={bytesSent:I.bytesSent,packetsSent:I.packetsSent,nackCount:I.nackCount,ssrc:I.ssrc,mid:I.mid,active:I.active,codecId:I.codecId,headerBytesSent:I.headerBytesSent||0,totalPacketSendDelay:I.totalPacketSendDelay||0};if(I.mediaType==="video"||I.kind==="video"){const N=I,Ze=H({frameHeight:N.frameHeight,frameWidth:N.frameWidth,framesEncoded:N.framesEncoded,framesDropped:N.framesDropped,framesPerSecond:N.framesPerSecond,framesSent:N.framesSent,keyFramesEncoded:N.keyFramesEncoded,firCount:N.firCount,encoderImplementation:N.encoderImplementation,hugeFramesSent:N.hugeFramesSent,pliCount:N.pliCount,qpSum:N.qpSum,qualityLimitationDurations:N.qualityLimitationDurations,qualityLimitationReason:N.qualityLimitationReason,qualityLimitationResolutionChanges:N.qualityLimitationResolutionChanges,totalEncodeTime:N.targetBitrate,totalPacketSendDelay:N.totalPacketSendDelay,retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent,scalabilityMode:N.scalabilityMode,powerEfficientEncoder:N.powerEfficientEncoder},q);O.outboundVideoRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundVideoRtpId.push(V.id),this.processOutboundProducerVideoStats(P,ye,Ze)}else if(I.mediaType==="audio"||I.kind==="audio"){const N=I,Ze=H({retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent},q);O.outboundAudioRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundAudioRtpId.push(V.id),this.processOutboundProducerAudioStats(P,ye,Ze)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}case"inbound-rtp":{const I=V,P=r||this.inboundConsumerMap.get(V.id),z=this.pausedConsumerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedConsumerMap.set(P,{lastReportCalculated:!0})}if(I.ssrc===1234)break;this.overallConsumersStatsMap[P]||(this.overallConsumersStatsMap[P]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const ye=this.overallConsumersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.inboundConsumerMap.has(V.id)){O.staleConsumerStreamMap=!0;break}O.consumerStreamMap.has(P)||O.consumerStreamMap.set(P,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const Xe={bytesReceived:I.bytesReceived,packetsReceived:I.packetsReceived,packetsLost:I.packetsLost>=0?I.packetsLost:0,jitter:I.jitter,nackCount:I.nackCount,jitterBufferDelay:I.jitterBufferDelay,jitterBufferEmittedCount:I.jitterBufferEmittedCount,lastPacketReceivedTimestamp:I.lastPacketReceivedTimestamp,ssrc:I.ssrc,mid:I.mid,codecId:I.codecId,headerBytesReceived:I.headerBytesReceived||0,packetsDiscarded:I.packetsDiscarded||0,jitterBufferMinimumDelay:I.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:I.jitterBufferTargetDelay||0};if(I.mediaType==="video"||I.kind==="video"){const q=I,N=H({frameHeight:q.frameHeight,frameWidth:q.frameWidth,framesDecoded:q.framesDecoded,framesDropped:q.framesDropped,framesPerSecond:q.framesPerSecond,framesReceived:q.framesReceived,keyFramesDecoded:q.keyFramesDecoded,firCount:q.firCount,decoderImplementation:q.decoderImplementation,pliCount:q.pliCount,totalProcessingDelay:q.totalProcessingDelay,qpSum:q.qpSum||0,totalAssemblyTime:q.totalAssemblyTime||0,totalDecodeTime:q.totalDecodeTime||0,totalFreezesDuration:q.totalFreezesDuration||0,totalInterFrameDelay:q.totalInterFrameDelay||0,totalPausesDuration:q.totalPausesDuration||0,totalSquaredInterFrameDelay:q.totalSquaredInterFrameDelay||0,freezeCount:q.freezeCount||0,pauseCount:q.pauseCount||0,powerEfficientDecoder:q.powerEfficientDecoder},Xe);N.score=Vv({frameWidth:N.frameWidth||0,framesDecoded:(N.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(P))==null?void 0:c.framesDecoded)||0),framesPerSecond:N.framesPerSecond||0,packetsLost:(N.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(P))==null?void 0:d.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((h=this.videoConsumerToStatsMap.get(P))==null?void 0:h.packetsReceived)||0),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P)}),ht.set(P,{score:+(N.score*10).toFixed(),frameWidth:N.frameWidth||0,frameHeight:N.frameHeight||0,framesPerSecond:N.framesPerSecond||0,packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((u=this.videoConsumerToStatsMap.get(P))==null?void 0:u.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((g=this.videoConsumerToStatsMap.get(P))==null?void 0:g.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((E=this.videoConsumerToStatsMap.get(P))==null?void 0:E.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(P,N),O.inboundVideoRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundVideoRtpId.push(V.id),this.processInboundConsumerVideoStats(P,ye,N)}else if(I.mediaType==="audio"||I.kind==="audio"){const q=I,N=H({audioLevel:q.audioLevel,concealedSamples:q.concealedSamples,concealmentEvents:q.concealmentEvents,totalAudioEnergy:q.totalAudioEnergy,totalSamplesDuration:q.totalSamplesDuration,totalSamplesReceived:q.totalSamplesReceived,fecPacketsDiscarded:q.fecPacketsDiscarded||0,fecPacketsReceived:q.fecPacketsReceived||0,insertedSamplesForDeceleration:q.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:q.removedSamplesForAcceleration||0,silentConcealedSamples:q.silentConcealedSamples||0,playoutId:q.playoutId},Xe);N.score=xv({concealmentEvents:(N.concealmentEvents||0)-(((b=this.audioConsumerToStatsMap.get(P))==null?void 0:b.concealmentEvents)||0),packetsLost:(N.packetsLost||0)-(((k=this.audioConsumerToStatsMap.get(P))==null?void 0:k.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((A=this.audioConsumerToStatsMap.get(P))==null?void 0:A.packetsReceived)||0),jitter:N.jitter||0}),ht.set(P,{score:+(N.score*10).toFixed(),packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((M=this.audioConsumerToStatsMap.get(P))==null?void 0:M.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((B=this.audioConsumerToStatsMap.get(P))==null?void 0:B.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((K=this.audioConsumerToStatsMap.get(P))==null?void 0:K.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(P,N),O.inboundAudioRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundAudioRtpId.push(V.id),this.processInboundConsumerAudioStats(P,ye,N)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}}}if(O.producerStreamMap.forEach((V,I)=>{var P,z,ye,Xe,q,N,Ze,Pn,Ar,Mr,Or,Fe,at,Li,xi,Vi,Ui,Bi,Sn,pi,Fi,Dr,ji;if(V.outboundVideoRtpId.length>0){const ge=[];V.outboundVideoRtpId.forEach(Da=>{ge.push(O.outboundVideoRtp.get(Da))});const pe=this.getWorkingSimulcastVideoStats(ge);pe.score=Nv({frameWidth:pe.frameWidth||0,framesPerSecond:pe.framesPerSecond||0,jitter:((P=pe.remoteData)==null?void 0:P.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsSent:(pe.packetsSent||0)-(((z=this.videoProducerToStatsMap.get(I))==null?void 0:z.packetsSent)||0),packetsLost:(((ye=pe.remoteData)==null?void 0:ye.packetsLost)||0)-(((q=(Xe=this.videoProducerToStatsMap.get(I))==null?void 0:Xe.remoteData)==null?void 0:q.packetsLost)||0),framesEncoded:(pe.framesEncoded||0)-(((N=this.videoProducerToStatsMap.get(I))==null?void 0:N.framesEncoded)||0)}),Je.set(I,{score:+(pe.score*10).toFixed(),frameWidth:pe.frameWidth||0,frameHeight:pe.frameHeight||0,framesPerSecond:pe.framesPerSecond||0,jitter:((Ze=pe.remoteData)==null?void 0:Ze.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsLostPercentage:el({packetsSent:(pe.packetsSent||0)-(((Pn=this.videoProducerToStatsMap.get(I))==null?void 0:Pn.packetsSent)||0),packetsLost:(((Ar=pe.remoteData)==null?void 0:Ar.packetsLost)||0)-(((Or=(Mr=this.videoProducerToStatsMap.get(I))==null?void 0:Mr.remoteData)==null?void 0:Or.packetsLost)||0)}),bitrate:((pe.bytesSent||0)-(((Fe=this.videoProducerToStatsMap.get(I))==null?void 0:Fe.bytesSent)||0))*8/7,cpuLimitations:pe.qualityLimitationReason==="cpu",bandwidthLimitations:pe.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(I,pe)}else if(V.outboundAudioRtpId.length>0){const ge=O.outboundAudioRtp.get(V.outboundAudioRtpId[0]);ge.score=Dv({packetsSent:(ge.packetsSent||0)-(((at=this.audioProducerToStatsMap.get(I))==null?void 0:at.packetsSent)||0),packetsLost:(((Li=ge.remoteData)==null?void 0:Li.packetsLost)||0)-(((Vi=(xi=this.audioProducerToStatsMap.get(I))==null?void 0:xi.remoteData)==null?void 0:Vi.packetsLost)||0),jitter:((Ui=ge.remoteData)==null?void 0:Ui.jitter)||0}),Je.set(I,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((Bi=this.audioProducerToStatsMap.get(I))==null?void 0:Bi.bytesSent)||0))*8/7,packetsLostPercentage:el({packetsSent:(ge.packetsSent||0)-(((Sn=this.audioProducerToStatsMap.get(I))==null?void 0:Sn.packetsSent)||0),packetsLost:(((pi=ge.remoteData)==null?void 0:pi.packetsLost)||0)-(((Dr=(Fi=this.audioProducerToStatsMap.get(I))==null?void 0:Fi.remoteData)==null?void 0:Dr.packetsLost)||0)}),jitter:((ji=ge.remoteData)==null?void 0:ji.jitter)||0,isScreenShare:this.screenShareProducers.has(I)}),this.audioProducerToStatsMap.set(I,ge)}}),fe.forEach(V=>{const I=me.find(z=>z.id===V.localCandidateId?(V.localCandidateId=z.id,z):null),P=Ie.find(z=>z.id===V.remoteCandidateId?(V.remoteCandidateId=z.id,z):null);I&&(V.localCandidateType=I.type,V.localCandidateAddress=Sr(I.address),V.localCandidatePort=I.port,V.localCandidateProtocol=I.protocol,V.localCandidateUrl=I.url,V.localCandidateNetworkType=I.networkType,V.localCandidateRelatedAddress=Sr(I.relatedAddress),V.localCandidateRelatedPort=I.relatedPort),P&&(V.remoteCandidateType=P.type,V.remoteCandidateAddress=Sr(P.address),V.remoteCandidatePort=P.port,V.remoteCandidateProtocol=P.protocol,V.remoteCandidateUrl=P.url)}),O.candidatePair&&(O.transport?(O.transport.totalRoundTripTime=O.candidatePair.totalRoundTripTime,O.transport.availableOutgoingBitrate=O.candidatePair.availableOutgoingBitrate,O.transport.availableIncomingBitrate=O.candidatePair.availableIncomingBitrate,O.transport.roundTripTime=O.candidatePair.currentRoundTripTime):O.transport={bytesReceived:O.candidatePair.bytesReceived,bytesSent:O.candidatePair.bytesSent,totalRoundTripTime:O.candidatePair.totalRoundTripTime,availableOutgoingBitrate:O.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:O.candidatePair.availableIncomingBitrate,roundTripTime:O.candidatePair.currentRoundTripTime}),O.transport&&(O.transport.candidatePairs=fe),O.transport&&!O.transport.roundTripTime){let V=0,I=0;O.remoteInboundRtp.forEach((P,z)=>{P.roundTripTime&&P.roundTripTime>V&&(V=P.roundTripTime,I=P.totalRoundTripTime)}),O.transport.roundTripTime=V,O.transport.totalRoundTripTime=I}if(ht.size>0)try{this.observer.emit("consumer_score",ht)}catch{}if(Je.size>0)try{this.observer.emit("producer_score",Je)}catch{}return O}getProducersReport(e){return p(this,null,function*(){const n=e.map(i=>this.generateProducerStreamMap(i,!0));return n.length>0?Promise.all(n):void 0})}getConsumersReport(e){return p(this,null,function*(){const n=e.map(i=>this.generateConsumerStreamMap(i,!0));return n.length>0?Promise.all(n):void 0})}getTransportReport(e){return p(this,null,function*(){return e.getStats()})}getProcessedStats(e,n,i){return p(this,null,function*(){const r=yield this.getTransportReport(e),s={producing:i,consuming:n,id:e.id},a=r,c=this.parseRTCReport(a,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,s);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:n,producing:i},h=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),u=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:h,consumerReport:u}})}getProducerStatsFromReport(e){const n=[];try{e.producerStreamMap.forEach((i,r)=>{var s,a;n.push({producerId:r,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((a=(s=this.callStatsInstance.producers)==null?void 0:s.get(r))==null?void 0:a.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return n}getConsumerStatsFromReport(e){const n=[];try{e.consumerStreamMap.forEach((i,r)=>{const{peerId:s,producerId:a,appData:c}=this.consumerPeerIdMap.get(r);n.push({consumerId:r,peerId:s,producerId:a,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 n}getUserLocation(){return p(this,null,function*(){return new Promise((e,n)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):n()}catch(i){n(i)}})})}getConnectivity(e){return p(this,null,function*(){try{const n={iceServers:e||Bm},i=new Promise((h,u)=>{try{const g=new cb(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),r=new Promise((h,u)=>{try{const g=new db(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),s=new Promise((h,u)=>{try{const g=new lb(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),[a,c,d]=yield Promise.all([i,r,s]);return{host:a==null?void 0:a.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 p(this,null,function*(){try{const n=yield new Promise((i,r)=>{try{const s={iceServers:e||Bm},a=new ob(s);a.addListener("done",i),a.addListener("failed",r),a.start(1e4)}catch(s){r(s)}});return{throughput:n.throughput,fractionalLoss:0,RTT:n.RTT,jitter:0,backendRTT:n.backendRTT}}catch{return}})}getIPDetails(){return p(this,null,function*(){var e,n;try{return this.ipDetails||(this.ipDetails=yield Up.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(n=this.callStatsInstance)==null?void 0:n.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return p(this,null,function*(){const[n,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:n,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,n=!1){return p(this,null,function*(){var i,r;if(n){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Fm(d==null?void 0:d.loc):void 0}}const[s,a,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(r=navigator.connection)==null?void 0:r.effectiveType,location:c!=null&&c.loc?Fm(c==null?void 0:c.loc):void 0,turnConnectivity:s?s.host||s.relay||s.reflexive:!1,connectivity:s,throughput:a==null?void 0:a.throughput,fractionalLoss:a==null?void 0:a.fractionalLoss,RTT:a==null?void 0:a.RTT,jitter:a==null?void 0:a.jitter,backendRTT:a==null?void 0:a.backendRTT}})}}class hb extends Fv{}class jv extends Fv{constructor(){super(...arguments),y(this,"producerMap",new Map),y(this,"consumerMap",new Map)}registerProducer(e){return p(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 p(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,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),s=[...r.consumerStreamMap.values()][0],a=n?this.getConsumerStatsFromParsedConsumerStats(r,s,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 a})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((n,i)=>{n===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((n,i)=>{n===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var n;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(n=e.relayProtocol)!=null?n:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,n=[],i=!1,r=void 0,s=void 0){var a,c,d,h,u,g,E,b,k,A,M,B,K;const X=e,O=new Bv,$=n.length?new Set(n):void 0,me=[],Ie=[],fe=[],Je=new Map,ht=new Map;for(const V of X.values()){if($){if($.size===0)break;if($.has(V.type))i&&$.delete(V.type);else continue}switch(V.type){case"local-candidate":{me.push(this.getIceCandidateStats(V));break}case"remote-candidate":{Ie.push(this.getIceCandidateStats(V));break}case"candidate-pair":{const{nominated:I}=V,{selected:P}=V,z=V,ye={nominated:I!=null?I:P,currentRoundTripTime:z.currentRoundTripTime,totalRoundTripTime:z.totalRoundTripTime,bytesReceived:z.bytesReceived,bytesSent:z.bytesSent,availableOutgoingBitrate:z.availableOutgoingBitrate,availableIncomingBitrate:z.availableIncomingBitrate,lastPacketReceivedTimestamp:z.lastPacketReceivedTimestamp,lastPacketSentTimestamp:z.lastPacketSentTimestamp,localCandidateId:z.localCandidateId,remoteCandidateId:z.remoteCandidateId,bytesDiscardedOnSend:z.bytesDiscardedOnSend,packetsSent:z.packetsSent,packetsReceived:z.packetsReceived,packetsDiscardedOnSend:z.packetsDiscardedOnSend};fe.push(ye),(V.nominated===!0||V.selected===!0)&&(O.candidatePair=ye);break}case"transport":{const I=V;s&&(s.producing&&(this.overallProducingTransportsStatsMap[s.id]||(this.overallProducingTransportsStatsMap[s.id]={totalPacketsSent:0})),s.consuming&&(this.overallConsumingTransportsStatsMap[s.id]||(this.overallConsumingTransportsStatsMap[s.id]={totalPacketsReceived:0})));const P={bytesReceived:I.bytesReceived,bytesSent:I.bytesSent,packetsSent:I.packetsSent,packetsReceived:I.packetsReceived,dtlsCipher:I.dtlsCipher,dtlsState:I.dtlsState,iceRole:I.iceRole};if(O.transport=P,s){if(s.producing){const z=this.overallProducingTransportsStatsMap[s.id];this.processProducingTransportStats(s.id,z,P)}if(s.consuming){const z=this.overallConsumingTransportsStatsMap[s.id];this.processConsumingTransportStats(s.id,z,P)}}break}case"remote-inbound-rtp":{const I=V,P={jitter:I.jitter,fractionLost:I.fractionLost,roundTripTime:I.roundTripTime,roundTripTimeMeasurements:I.roundTripTimeMeasurements,totalRoundTripTime:I.totalRoundTripTime,packetsLost:I.packetsLost};O.remoteInboundRtp.set(I.localId,P);break}case"outbound-rtp":{const I=V,P=r||this.outboundProducerMap.get(V.id),z=this.pausedProducerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedProducerMap.set(P,{lastReportCalculated:!0})}this.overallProducersStatsMap[P]||(this.overallProducersStatsMap[P]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const ye=this.overallProducersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.outboundProducerMap.has(V.id)){O.staleProducerStreamMap=!0;break}const Xe=this.callStatsInstance.producers.get(P);if(((a=Xe==null?void 0:Xe.track)==null?void 0:a.readyState)==="ended")break;O.producerStreamMap.has(P)||O.producerStreamMap.set(P,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const q={bytesSent:I.bytesSent,packetsSent:I.packetsSent,nackCount:I.nackCount,ssrc:I.ssrc,mid:I.mid,active:I.active,codecId:I.codecId,headerBytesSent:I.headerBytesSent||0,totalPacketSendDelay:I.totalPacketSendDelay||0};if(I.mediaType==="video"||I.kind==="video"){const N=I,Ze=H({frameHeight:N.frameHeight,frameWidth:N.frameWidth,framesEncoded:N.framesEncoded,framesDropped:N.framesDropped?N.framesDropped:N.droppedFrames,framesPerSecond:N.framesPerSecond?N.framesPerSecond:N.framerateMean,framesSent:N.framesSent,keyFramesEncoded:N.keyFramesEncoded,firCount:N.firCount,encoderImplementation:N.encoderImplementation,hugeFramesSent:N.hugeFramesSent,pliCount:N.pliCount,qpSum:N.qpSum,qualityLimitationReason:N.qualityLimitationReason,qualityLimitationDurations:N.qualityLimitationDurations,qualityLimitationResolutionChanges:N.qualityLimitationResolutionChanges,totalEncodeTime:N.totalEncodeTime,totalPacketSendDelay:N.totalEncodeTime,retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent,scalabilityMode:N.scalabilityMode,powerEfficientEncoder:N.powerEfficientEncoder},q);O.outboundVideoRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundVideoRtpId.push(V.id),this.processOutboundProducerVideoStats(P,ye,Ze)}else if(I.mediaType==="audio"||I.kind==="audio"){const N=I,Ze=H({retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent},q);O.outboundAudioRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundAudioRtpId.push(V.id),this.processOutboundProducerAudioStats(P,ye,Ze)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}case"inbound-rtp":{const I=V,P=r||this.inboundConsumerMap.get(V.id),z=this.pausedConsumerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedConsumerMap.set(P,{lastReportCalculated:!0})}if(I.ssrc===1234)break;this.overallConsumersStatsMap[P]||(this.overallConsumersStatsMap[P]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const ye=this.overallConsumersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.inboundConsumerMap.has(V.id)){O.staleConsumerStreamMap=!0;break}O.consumerStreamMap.has(P)||O.consumerStreamMap.set(P,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const Xe={bytesReceived:I.bytesReceived,packetsReceived:I.packetsReceived,packetsLost:I.packetsLost>=0?I.packetsLost:0,jitter:I.jitter,nackCount:I.nackCount,jitterBufferDelay:I.jitterBufferDelay,jitterBufferEmittedCount:I.jitterBufferEmittedCount,lastPacketReceivedTimestamp:I.lastPacketReceivedTimestamp,ssrc:I.ssrc,mid:I.mid,codecId:I.codecId,headerBytesReceived:I.headerBytesReceived||0,packetsDiscarded:I.packetsDiscarded||0,jitterBufferMinimumDelay:I.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:I.jitterBufferTargetDelay||0};if(I.mediaType==="video"||I.kind==="video"){const q=I,N=H({frameHeight:q.frameHeight,frameWidth:q.frameWidth,framesDecoded:q.framesDecoded,framesDropped:q.framesDropped?q.framesDropped:q.droppedFrames,framesPerSecond:q.framesPerSecond?q.framesPerSecond:q.framerateMean,framesReceived:q.framesReceived,keyFramesDecoded:q.keyFramesDecoded,firCount:q.firCount,decoderImplementation:q.decoderImplementation,pliCount:q.pliCount,totalProcessingDelay:q.totalProcessingDelay,qpSum:q.qpSum||0,totalAssemblyTime:q.totalAssemblyTime||0,totalDecodeTime:q.totalDecodeTime||0,totalFreezesDuration:q.totalFreezesDuration||0,totalInterFrameDelay:q.totalInterFrameDelay||0,totalPausesDuration:q.totalPausesDuration||0,totalSquaredInterFrameDelay:q.totalSquaredInterFrameDelay||0,freezeCount:q.freezeCount||0,pauseCount:q.pauseCount||0,powerEfficientDecoder:q.powerEfficientDecoder},Xe);N.score=Vv({frameWidth:N.frameWidth||0,framesDecoded:(N.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(P))==null?void 0:c.framesDecoded)||0),framesPerSecond:N.framesPerSecond||0,packetsLost:(N.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(P))==null?void 0:d.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((h=this.videoConsumerToStatsMap.get(P))==null?void 0:h.packetsReceived)||0),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P)}),ht.set(P,{score:+(N.score*10).toFixed(),frameWidth:N.frameWidth||0,frameHeight:N.frameHeight||0,framesPerSecond:N.framesPerSecond||0,packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((u=this.videoConsumerToStatsMap.get(P))==null?void 0:u.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((g=this.videoConsumerToStatsMap.get(P))==null?void 0:g.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((E=this.videoConsumerToStatsMap.get(P))==null?void 0:E.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(P,N),O.inboundVideoRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundVideoRtpId.push(V.id),this.processInboundConsumerVideoStats(P,ye,N)}else if(I.mediaType==="audio"||I.kind==="audio"){const q=I,N=H({audioLevel:q.audioLevel,concealedSamples:q.concealedSamples,concealmentEvents:q.concealmentEvents,totalAudioEnergy:q.totalAudioEnergy,totalSamplesDuration:q.totalSamplesDuration,totalSamplesReceived:q.totalSamplesReceived,fecPacketsDiscarded:q.fecPacketsDiscarded||0,fecPacketsReceived:q.fecPacketsReceived||0,insertedSamplesForDeceleration:q.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:q.removedSamplesForAcceleration||0,silentConcealedSamples:q.silentConcealedSamples||0,playoutId:q.playoutId},Xe);N.score=xv({concealmentEvents:(N.concealmentEvents||0)-(((b=this.audioConsumerToStatsMap.get(P))==null?void 0:b.concealmentEvents)||0),packetsLost:(N.packetsLost||0)-(((k=this.audioConsumerToStatsMap.get(P))==null?void 0:k.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((A=this.audioConsumerToStatsMap.get(P))==null?void 0:A.packetsReceived)||0),jitter:N.jitter||0}),ht.set(P,{score:+(N.score*10).toFixed(),packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((M=this.audioConsumerToStatsMap.get(P))==null?void 0:M.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((B=this.audioConsumerToStatsMap.get(P))==null?void 0:B.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((K=this.audioConsumerToStatsMap.get(P))==null?void 0:K.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(P,N),O.inboundAudioRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundAudioRtpId.push(V.id),this.processInboundConsumerAudioStats(P,ye,N)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}}}if(O.producerStreamMap.forEach((V,I)=>{var P,z,ye,Xe,q,N,Ze,Pn,Ar,Mr,Or,Fe,at,Li,xi,Vi,Ui,Bi,Sn,pi,Fi,Dr,ji;if(V.outboundVideoRtpId.length>0){const ge=[];V.outboundVideoRtpId.forEach(Da=>{ge.push(O.outboundVideoRtp.get(Da))});const pe=this.getWorkingSimulcastVideoStats(ge);pe.score=Nv({frameWidth:pe.frameWidth||0,framesPerSecond:pe.framesPerSecond||0,jitter:((P=pe.remoteData)==null?void 0:P.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsSent:(pe.packetsSent||0)-(((z=this.videoProducerToStatsMap.get(I))==null?void 0:z.packetsSent)||0),packetsLost:(((ye=pe.remoteData)==null?void 0:ye.packetsLost)||0)-(((q=(Xe=this.videoProducerToStatsMap.get(I))==null?void 0:Xe.remoteData)==null?void 0:q.packetsLost)||0),framesEncoded:(pe.framesEncoded||0)-(((N=this.videoProducerToStatsMap.get(I))==null?void 0:N.framesEncoded)||0)}),Je.set(I,{score:+(pe.score*10).toFixed(),frameWidth:pe.frameWidth||0,frameHeight:pe.frameHeight||0,framesPerSecond:pe.framesPerSecond||0,jitter:((Ze=pe.remoteData)==null?void 0:Ze.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsLostPercentage:el({packetsSent:(pe.packetsSent||0)-(((Pn=this.videoProducerToStatsMap.get(I))==null?void 0:Pn.packetsSent)||0),packetsLost:(((Ar=pe.remoteData)==null?void 0:Ar.packetsLost)||0)-(((Or=(Mr=this.videoProducerToStatsMap.get(I))==null?void 0:Mr.remoteData)==null?void 0:Or.packetsLost)||0)}),bitrate:((pe.bytesSent||0)-(((Fe=this.videoProducerToStatsMap.get(I))==null?void 0:Fe.bytesSent)||0))*8/7,cpuLimitations:pe.qualityLimitationReason==="cpu",bandwidthLimitations:pe.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(I,pe)}else if(V.outboundAudioRtpId.length>0){const ge=O.outboundAudioRtp.get(V.outboundAudioRtpId[0]);ge.score=Dv({packetsSent:(ge.packetsSent||0)-(((at=this.audioProducerToStatsMap.get(I))==null?void 0:at.packetsSent)||0),packetsLost:(((Li=ge.remoteData)==null?void 0:Li.packetsLost)||0)-(((Vi=(xi=this.audioProducerToStatsMap.get(I))==null?void 0:xi.remoteData)==null?void 0:Vi.packetsLost)||0),jitter:((Ui=ge.remoteData)==null?void 0:Ui.jitter)||0}),Je.set(I,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((Bi=this.audioProducerToStatsMap.get(I))==null?void 0:Bi.bytesSent)||0))*8/7,packetsLostPercentage:el({packetsSent:(ge.packetsSent||0)-(((Sn=this.audioProducerToStatsMap.get(I))==null?void 0:Sn.packetsSent)||0),packetsLost:(((pi=ge.remoteData)==null?void 0:pi.packetsLost)||0)-(((Dr=(Fi=this.audioProducerToStatsMap.get(I))==null?void 0:Fi.remoteData)==null?void 0:Dr.packetsLost)||0)}),jitter:((ji=ge.remoteData)==null?void 0:ji.jitter)||0,isScreenShare:this.screenShareProducers.has(I)}),this.audioProducerToStatsMap.set(I,ge)}}),fe.forEach(V=>{const I=me.find(z=>z.id===V.localCandidateId?(V.localCandidateId=z.id,z):null),P=Ie.find(z=>z.id===V.remoteCandidateId?(V.remoteCandidateId=z.id,z):null);I&&(V.localCandidateType=I.type,V.localCandidateAddress=Sr(I.address),V.localCandidatePort=I.port,V.localCandidateProtocol=I.protocol,V.localCandidateUrl=I.url,V.localCandidateNetworkType=I.networkType,V.localCandidateRelatedAddress=Sr(I.relatedAddress),V.localCandidateRelatedPort=I.relatedPort),P&&(V.remoteCandidateType=P.type,V.remoteCandidateAddress=Sr(P.address),V.remoteCandidatePort=P.port,V.remoteCandidateProtocol=P.protocol,V.remoteCandidateUrl=P.url)}),O.candidatePair&&(O.transport?(O.transport.bytesReceived=O.candidatePair.bytesReceived,O.transport.bytesSent=O.candidatePair.bytesSent,O.transport.totalRoundTripTime=O.candidatePair.totalRoundTripTime,O.transport.availableOutgoingBitrate=O.candidatePair.availableOutgoingBitrate,O.transport.availableIncomingBitrate=O.candidatePair.availableIncomingBitrate,O.transport.roundTripTime=O.candidatePair.currentRoundTripTime):O.transport={bytesReceived:O.candidatePair.bytesReceived,bytesSent:O.candidatePair.bytesSent,totalRoundTripTime:O.candidatePair.totalRoundTripTime,availableOutgoingBitrate:O.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:O.candidatePair.availableIncomingBitrate,roundTripTime:O.candidatePair.currentRoundTripTime}),O.transport&&(O.transport.candidatePairs=fe),O.transport&&!O.transport.roundTripTime){let V=0,I=0;O.remoteInboundRtp.forEach((P,z)=>{P.roundTripTime&&P.roundTripTime>V&&(V=P.roundTripTime,I=P.totalRoundTripTime)}),O.transport.roundTripTime=V,O.transport.totalRoundTripTime=I}if(ht.size>0)try{this.observer.emit("consumer_score",ht)}catch{}if(Je.size>0)try{this.observer.emit("producer_score",Je)}catch{}return O}getProducerStatsFromReport(e){const n=[];try{e.producerStreamMap.forEach((i,r)=>{const s=this.producerMap.get(r),a=s.track.getSettings(),c=i.outboundVideoRtpId.map(h=>{const u=e.outboundVideoRtp.get(h);return u.frameHeight||(u.frameHeight=a.height,u.frameWidth=a.width,u.framesPerSecond=a.frameRate),u}),d={producerId:r,appData:s.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(h=>e.outboundAudioRtp.get(h))};n.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return n}getConsumerStatsFromParsedConsumerStats(e,n,i){let r;try{const{peerId:s,producerId:a,appData:c}=this.consumerPeerIdMap.get(i),d=n==null?void 0:n.inboundVideoRtpId.map(h=>{const u=this.consumerMap.get(i).track.getSettings(),g=e.inboundVideoRtp.get(h);return g.frameHeight||(g.frameHeight=u.height,g.frameWidth=u.width,g.framesPerSecond=u.frameRate),g});r={consumerId:i,peerId:s,producerId:a,appData:c,videoStats:d,audioStats:n==null?void 0:n.inboundAudioRtpId.map(h=>e.inboundAudioRtp.get(h))}}catch(s){console.error("getConsumerStatsFromParsedConsumerStats: ",s,e)}return r}getConsumerStatsFromReport(e){const n=[];try{e.consumerStreamMap.forEach((i,r)=>{n.push(this.getConsumerStatsFromParsedConsumerStats(e,i,r))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return n}}class pb extends jv{}function nl(t,e,n,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof n=="function"&&i instanceof e)n.call(null,i,t);else throw i}function jm(t,e,n){const i=t.value;return t.value=function(...r){try{const s=i.apply(this,r);return s&&s instanceof Promise?s.catch(a=>{nl(this,e,n,a)}):s}catch(s){nl(this,e,n,s)}return null},t}const le=(t,e)=>(n,i,r)=>{const s=r.value;return r.value=function(...a){try{const c=s.apply(this,a);return c&&c instanceof Promise?c.catch(d=>{nl(this,t,e,d)}):c}catch(c){nl(this,t,e,c)}return null},r},mb=(t,e)=>(n,i,r)=>{if(r)return jm(r,t,e);for(const s of Reflect.ownKeys(n.prototype).filter(a=>a!=="constructor")){const a=Object.getOwnPropertyDescriptor(n.prototype,s);a.value instanceof Function&&Object.defineProperty(n.prototype,s,jm(a,t,e))}};var ce=globalThis&&globalThis.__decorate||function(t,e,n,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(r<3?a(s):r>3?a(e,n,s):a(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s};const de=console;let ae=class extends Nt{constructor(t="https://api.testingv3.dyte.in",e="Blink",n=$o.PROD,i,r,s,a){switch(super(),y(this,"observer"),y(this,"eventHandler"),y(this,"measurements"),y(this,"producingTransport"),y(this,"consumingTransport"),y(this,"producers",new Map),y(this,"consumers",new Map),y(this,"iceServers"),y(this,"connectionInfoPromise"),y(this,"pingStatsTimeout"),y(this,"logger"),y(this,"env"),y(this,"apiHostnames"),y(this,"peerId"),y(this,"consumerSharedMediaStatesMap",new Map),y(this,"currentUserMediaStates",{}),this.env=n,this.apiHostnames=a,this.logger=r,this.peerId=s,this.eventHandler=new XT({logger:r,peerId:s,apiHostnames:a}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new hb;break;case"Gecko":this.measurements=new jv;break;case"WebKit":this.measurements=new pb;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 Nt,this.measurements.observer.on("consumer_score",c=>{r.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{r.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 n=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(n,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.observer.on("close",this.disconnectProducingTransport.bind(this,t)),t.observer.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(n=>{this.registerProducer(n)}),t.observer.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.observer.on("close",this.disconnectConsumingTransport.bind(this,t)),t.observer.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(n=>{this.registerConsumer(n)}),t.observer.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:G.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(n=>{this.eventHandler.callEvent({event:G.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:n},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,n){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?G.SCREENSHARE_STARTED:G.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:n})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:G.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:G.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,n){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_DEVICES_UPDATES||t===wn.VIDEO&&G.VIDEO_DEVICES_UPDATES||t===wn.SPEAKER&&G.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:n})}selectedDevice(t,e,n){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.SELECTED_MICROHPONE_UPDATE||t===wn.VIDEO&&G.SELECTED_CAMERA_UPDATE||t===wn.SPEAKER&&G.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:n})}mediaPermission(t,e,n){this.eventHandler.callEvent({event:G.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:n})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_PLAY_FAILED||t===wn.VIDEO&&G.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_TRACK_MUTED||t===wn.VIDEO&&G.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:G.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:G.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:G.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:G.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return p(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=ee(H({},t),{meetingEnv:this.env}),t.deviceInfo=ee(H({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:G.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:G.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((n,i)=>p(this,null,function*(){const r=[];try{for(const s of t)try{if(s.iceServers&&s.iceServers.length>0){const a=yield this.measurements.getNetworkQuality(s.iceServers);r.push(ee(H({},s),{networkResults:a}))}}catch(a){console.warn("Error handling ",a)}n({regionData:r})}catch(s){console.warn("Error in callstats, ",s),i(s)}})).then(n=>{this.eventHandler.callEvent({event:G.NET_QUALITY_TEST_END,timestamp:e,metaData:n})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:G.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:G.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let n;t?n=G.AUDIO_ON:n=G.AUDIO_OFF,this.eventHandler.callEvent({event:n,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let n;t?n=G.VIDEO_ON:n=G.VIDEO_OFF,this.eventHandler.callEvent({event:n,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:G.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 p(this,null,function*(){let n,i;if(this.producingTransport&&(n=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!n||!(n!=null&&n.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const s=yield this.measurements.getProducersReport([...this.producers.values()]);n&&s?n.producerReport=s:(n=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!n||!(n!=null&&n.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 s=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&s?i.consumerReport=s:(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 r={producingTransportStats:n?n==null?void 0:n.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((n==null?void 0:n.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((n==null?void 0:n.consumerReport)||[])};if(t&&r.producerStats.length===0&&r.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:G.PING_STAT,metaData:r,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:G.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:G.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:G.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,n){this.eventHandler.callEvent({event:G.EXPECTED_VIDEO_RESOLUTION,timestamp:n,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,n){this.eventHandler.callEvent({event:G.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:n,metaData:{frameWidth:t,frameHeight:e}})}};ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerIceServers",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerConsumer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerProducer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendConsumerSharedMediaStateEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerProducingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerConsumingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"deRegisterConsumer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"deRegisterProducer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"disconnectConsumingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"disconnectProducingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPreCallTestBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendScreenShareToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendScreenShareRequestedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendActiveSpeakerEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"devices",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"selectedDevice",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaPermission",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaPlaybackFailed",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaTrackMuted",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"tabChanged",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"browserBackgrounded",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"browserForegrounded",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"legacySwitch",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"getPreCallTestResults",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendCallJoinBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendNetworkQualityTestBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendWebSocketConnectedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendTransportConnectedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendAudioToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendVideoToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendParticipantRoleToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"startPingStats",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"stopPingStats",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPingStatsEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerRebufferEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerAudioBlockEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerInitializedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerWorkerErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerRecoverableErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerAnalyticsEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerQualityChanged",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPlayerLiveLatency",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendDisconnectEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendReconnectEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"expectedVideoResolution",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"expectedScreenshareResolution",null);ae=ce([mb(TypeError,(t,e)=>de.error(e,t))],ae);const fb=ae;class gb extends Nt{constructor(){super(...arguments),y(this,"stats"),y(this,"peerId"),y(this,"backend"),y(this,"iceServers"),y(this,"initialized",!1),y(this,"stalled",!1),y(this,"ipInformation"),y(this,"logger")}initialize(e){return p(this,arguments,function*({peerId:n,engineName:i,env:r=$o.PROD,iceServers:s,apiBase:a="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:h,skipConnectivityChecks:u=!1}){var g,E,b;try{this.peerId=n,this.logger=d,this.ipInformation=yield Up.getIPDetails({peerId:n,apiHostnames:h,logger:d}),this.backend=new fb(a,i,r,c,d,n,h),this.iceServers=s,(g=this.backend)==null||g.registerIceServers(this.iceServers),this.initialized=!0,(b=(E=this.backend)==null?void 0:E.eventHandler)==null||b.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(u)}catch(k){this.logger.error("callStats::CallStatsIntegration: ",{error:k}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,n)}catch(r){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:r.reason}})}})})}roomJoined(e){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i,r;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,n),this.backend,(r=this.backend)==null||r.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var n,i;(n=this.backend)==null||n.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,n)})}consumerSharedMediaState(e,n){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,n)})}screenShareStop(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,n)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,n)})}devices(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.devices(e,n,i)})}selectedDevice(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.selectedDevice(e,n,i)})}mediaPermission(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.mediaPermission(e,n,i)})}mediaPlaybackFailed(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,n)})}mediaTrackMuted(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,n)})}tabChanged(e=!1){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,n)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.browserForegrounded(e)})}legacySwitch(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,n)})}startPreCallTest(e=!1){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,n)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const n=i=>{e(i,!0)};return this.once("initialized",n),n}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,n){const i=new Date;this.onSafeInitialization(()=>{var r,s,a,c,d,h,u,g,E,b,k;switch(e){case"PlayerRebuffering":(r=this.backend)==null||r.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(s=this.backend)==null||s.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(a=this.backend)==null||a.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":(h=this.backend)==null||h.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(u=this.backend)==null||u.sendIVSPlayerErrorEvent(n,i);break;case"PlayerRecoverableError":(g=this.backend)==null||g.sendIVSPlayerRecoverableErrorEvent(n,i);break;case"PlayerAnalyticsEvent":(E=this.backend)==null||E.sendIVSPlayerAnalyticsEvent(n,i);break;case"PlayerPlaybackRateChanged":(b=this.backend)==null||b.sendIVSPlayerPlaybackRateChangedEvent(n,i);break;case"PlayerQualityChanged":(k=this.backend)==null||k.sendIVSPlayerQualityChanged(n,i);break}})}livestreamLatency(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,n)})}expectedVideoResolution(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.expectedVideoResolution(e,n,i)})}expectedScreenshareResolution(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.expectedScreenshareResolution(e,n,i)})}}const ne=new gb;ne.setMaxListeners(30);function vb(t){const{length:e}=this,n=t>=0?t:e+t;return n<0||n>=e?void 0:this[n]}Array.prototype.at||Object.assign(Array.prototype,{at:vb});function yb(t){const{length:e}=this,n=t>=0?t:e+t;return n<0||n>=e?void 0:this[n]}String.prototype.at||Object.assign(String.prototype,{at:yb});function Eb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wv={exports:{}},st=Wv.exports={},ii,ri;function ch(){throw new Error("setTimeout has not been defined")}function dh(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ii=setTimeout:ii=ch}catch{ii=ch}try{typeof clearTimeout=="function"?ri=clearTimeout:ri=dh}catch{ri=dh}})();function Hv(t){if(ii===setTimeout)return setTimeout(t,0);if((ii===ch||!ii)&&setTimeout)return ii=setTimeout,setTimeout(t,0);try{return ii(t,0)}catch{try{return ii.call(null,t,0)}catch{return ii.call(this,t,0)}}}function Sb(t){if(ri===clearTimeout)return clearTimeout(t);if((ri===dh||!ri)&&clearTimeout)return ri=clearTimeout,clearTimeout(t);try{return ri(t)}catch{try{return ri.call(null,t)}catch{return ri.call(this,t)}}}var Ii=[],fa=!1,ds,ud=-1;function Tb(){!fa||!ds||(fa=!1,ds.length?Ii=ds.concat(Ii):ud=-1,Ii.length&&qv())}function qv(){if(!fa){var t=Hv(Tb);fa=!0;for(var e=Ii.length;e;){for(ds=Ii,Ii=[];++ud<e;)ds&&ds[ud].run();ud=-1,e=Ii.length}ds=null,fa=!1,Sb(t)}}st.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ii.push(new Gv(t,e)),Ii.length===1&&!fa&&Hv(qv)};function Gv(t,e){this.fun=t,this.array=e}Gv.prototype.run=function(){this.fun.apply(null,this.array)};st.title="browser";st.browser=!0;st.env={};st.argv=[];st.version="";st.versions={};function Oi(){}st.on=Oi;st.addListener=Oi;st.once=Oi;st.off=Oi;st.removeListener=Oi;st.removeAllListeners=Oi;st.emit=Oi;st.prependListener=Oi;st.prependOnceListener=Oi;st.listeners=function(t){return[]};st.binding=function(t){throw new Error("process.binding is not supported")};st.cwd=function(){return"/"};st.chdir=function(t){throw new Error("process.chdir is not supported")};st.umask=function(){return 0};var bb=Wv.exports;const ls=Eb(bb);var lh={},kb={get exports(){return lh},set exports(t){lh=t}},il={},wb={get exports(){return il},set exports(t){il=t}},$v=function(t,e){return function(){return t.apply(e,arguments)}},_b=$v,Bp=Object.prototype.toString,Fp=function(t){return function(e){var n=Bp.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())}}(Object.create(null));function Ir(t){return t=t.toLowerCase(),function(e){return Fp(e)===t}}function xl(t){return Array.isArray(t)}function uh(t){return typeof t=="undefined"}function Ib(t){return t!==null&&!uh(t)&&t.constructor!==null&&!uh(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}var Jv=Ir("ArrayBuffer");function Cb(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Jv(t.buffer),e}function Rb(t){return typeof t=="string"}function Kv(t){return typeof t=="number"}function zv(t){return t!==null&&typeof t=="object"}function hd(t){if(Fp(t)!=="object")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Pb(t){return t&&Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}var Ab=Ir("Date"),Mb=Ir("File"),Ob=Ir("Blob"),Db=Ir("FileList");function jp(t){return Bp.call(t)==="[object Function]"}function Nb(t){return zv(t)&&jp(t.pipe)}function Lb(t){var e="[object FormData]";return t&&(typeof FormData=="function"&&t instanceof FormData||Bp.call(t)===e||jp(t.toString)&&t.toString()===e)}var xb=Ir("URLSearchParams");function Vb(t){return t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function Ub(){var t;return typeof navigator!="undefined"&&((t=navigator.product)==="ReactNative"||t==="NativeScript"||t==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Wp(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),xl(t))for(var n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.call(null,t[r],r,t)}function hh(){var t={};function e(r,s){hd(t[s])&&hd(r)?t[s]=hh(t[s],r):hd(r)?t[s]=hh({},r):xl(r)?t[s]=r.slice():t[s]=r}for(var n=0,i=arguments.length;n<i;n++)Wp(arguments[n],e);return t}function Bb(t,e,n){return Wp(e,function(i,r){n&&typeof i=="function"?t[r]=_b(i,n):t[r]=i}),t}function Fb(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}function jb(t,e,n,i){t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,n&&Object.assign(t.prototype,n)}function Wb(t,e,n,i){var r,s,a,c={};if(e=e||{},t==null)return e;do{for(r=Object.getOwnPropertyNames(t),s=r.length;s-- >0;)a=r[s],(!i||i(a,t,e))&&!c[a]&&(e[a]=t[a],c[a]=!0);t=n!==!1&&Object.getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e}function Hb(t,e,n){t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;var i=t.indexOf(e,n);return i!==-1&&i===n}function qb(t){if(!t)return null;if(xl(t))return t;var e=t.length;if(!Kv(e))return null;for(var n=new Array(e);e-- >0;)n[e]=t[e];return n}var Gb=function(t){return function(e){return t&&e instanceof t}}(typeof Uint8Array!="undefined"&&Object.getPrototypeOf(Uint8Array));function $b(t,e){for(var n=t&&t[Symbol.iterator],i=n.call(t),r;(r=i.next())&&!r.done;){var s=r.value;e.call(t,s[0],s[1])}}function Jb(t,e){for(var n,i=[];(n=t.exec(e))!==null;)i.push(n);return i}var Kb=Ir("HTMLFormElement"),zb=function(t){return function(e,n){return t.call(e,n)}}(Object.prototype.hasOwnProperty),gt={isArray:xl,isArrayBuffer:Jv,isBuffer:Ib,isFormData:Lb,isArrayBufferView:Cb,isString:Rb,isNumber:Kv,isObject:zv,isPlainObject:hd,isEmptyObject:Pb,isUndefined:uh,isDate:Ab,isFile:Mb,isBlob:Ob,isFunction:jp,isStream:Nb,isURLSearchParams:xb,isStandardBrowserEnv:Ub,forEach:Wp,merge:hh,extend:Bb,trim:Vb,stripBOM:Fb,inherits:jb,toFlatObject:Wb,kindOf:Fp,kindOfTest:Ir,endsWith:Hb,toArray:qb,isTypedArray:Gb,isFileList:Db,forEachEntry:$b,matchAll:Jb,isHTMLForm:Kb,hasOwnProperty:zb},vt={},Vl={};Vl.byteLength=Xb;Vl.toByteArray=ek;Vl.fromByteArray=ik;var ai=[],_n=[],Yb=typeof Uint8Array!="undefined"?Uint8Array:Array,hu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ms=0,Qb=hu.length;Ms<Qb;++Ms)ai[Ms]=hu[Ms],_n[hu.charCodeAt(Ms)]=Ms;_n["-".charCodeAt(0)]=62;_n["_".charCodeAt(0)]=63;function Yv(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var i=n===e?0:4-n%4;return[n,i]}function Xb(t){var e=Yv(t),n=e[0],i=e[1];return(n+i)*3/4-i}function Zb(t,e,n){return(e+n)*3/4-n}function ek(t){var e,n=Yv(t),i=n[0],r=n[1],s=new Yb(Zb(t,i,r)),a=0,c=r>0?i-4:i,d;for(d=0;d<c;d+=4)e=_n[t.charCodeAt(d)]<<18|_n[t.charCodeAt(d+1)]<<12|_n[t.charCodeAt(d+2)]<<6|_n[t.charCodeAt(d+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=e&255;return r===2&&(e=_n[t.charCodeAt(d)]<<2|_n[t.charCodeAt(d+1)]>>4,s[a++]=e&255),r===1&&(e=_n[t.charCodeAt(d)]<<10|_n[t.charCodeAt(d+1)]<<4|_n[t.charCodeAt(d+2)]>>2,s[a++]=e>>8&255,s[a++]=e&255),s}function tk(t){return ai[t>>18&63]+ai[t>>12&63]+ai[t>>6&63]+ai[t&63]}function nk(t,e,n){for(var i,r=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),r.push(tk(i));return r.join("")}function ik(t){for(var e,n=t.length,i=n%3,r=[],s=16383,a=0,c=n-i;a<c;a+=s)r.push(nk(t,a,a+s>c?c:a+s));return i===1?(e=t[n-1],r.push(ai[e>>2]+ai[e<<4&63]+"==")):i===2&&(e=(t[n-2]<<8)+t[n-1],r.push(ai[e>>10]+ai[e>>4&63]+ai[e<<2&63]+"=")),r.join("")}var Hp={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Hp.read=function(t,e,n,i,r){var s,a,c=r*8-i-1,d=(1<<c)-1,h=d>>1,u=-7,g=n?r-1:0,E=n?-1:1,b=t[e+g];for(g+=E,s=b&(1<<-u)-1,b>>=-u,u+=c;u>0;s=s*256+t[e+g],g+=E,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;u>0;a=a*256+t[e+g],g+=E,u-=8);if(s===0)s=1-h;else{if(s===d)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-h}return(b?-1:1)*a*Math.pow(2,s-i)};Hp.write=function(t,e,n,i,r,s){var a,c,d,h=s*8-r-1,u=(1<<h)-1,g=u>>1,E=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=i?0:s-1,k=i?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-a))<1&&(a--,d*=2),a+g>=1?e+=E/d:e+=E*Math.pow(2,1-g),e*d>=2&&(a++,d/=2),a+g>=u?(c=0,a=u):a+g>=1?(c=(e*d-1)*Math.pow(2,r),a=a+g):(c=e*Math.pow(2,g-1)*Math.pow(2,r),a=0));r>=8;t[n+b]=c&255,b+=k,c/=256,r-=8);for(a=a<<r|c,h+=r;h>0;t[n+b]=a&255,b+=k,a/=256,h-=8);t[n+b-k]|=A*128};/*!
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 p(this,null,function*(){const[e,n]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,r;if(e.forEach(s=>{s.type==="candidate-pair"&&s.nominated===!0&&s.bytesSent>0&&(i=s)}),n.forEach(s=>{s.type==="candidate-pair"&&s.nominated===!0&&s.bytesReceived>0&&(r=s)}),i&&r)try{if(i.currentRoundTripTime&&r.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:r.currentRoundTripTime};const s=(r.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:s,backendRTT:s}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class Uv extends Nt{constructor(e){super(),y(this,"call"),y(this,"timeOut"),this.call=new Pi(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 rb=8,sb=1/1e3;class ab extends Uv{constructor(e){super(e),y(this,"senderChannel"),y(this,"recieveChannel"),y(this,"startTime"),y(this,"lastBitrateMeasureTime"),y(this,"sentPayloadBytes",0),y(this,"recievedPayloadBytes",0),y(this,"lastReceivedPayloadBytes",0),y(this,"stopSending",!1),y(this,"testProgress",0),y(this,"samplePacket",""),y(this,"finalBitrateSum",0),y(this,"bitRateSampels",0),y(this,"maxNumberOfPacketsToSend",0),y(this,"bytesToKeepBuffered",0),y(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(Pi.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let n=0;n<1024*256;n+=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 n=e.getTime()-this.startTime.getTime();n>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=n/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const n=new Date,i=n.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const r=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*rb/(i/1e3);this.finalBitrateSum+=r,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=n}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const r=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(r*sb)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:n,backendRTT:i})=>super.testComplete({RTT:n,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Vp extends Uv{constructor(e,n=Pi.noFilter){super(e),y(this,"ch1"),y(this,"ch2"),this.call.setIceCandidateFilter(n);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 n=e.channel;this.ch2=n,n.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class ob extends Vp{constructor(e){super(e,Pi.isHost)}}class cb extends Vp{constructor(e){super(e,Pi.isRelay)}}class db extends Vp{constructor(e){super(e,Pi.isReflexive)}}class lb{constructor(){y(this,"ipInformation",null)}getIPDetails(e){return p(this,arguments,function*({peerId:n,apiHostnames:i,logger:r}){var s,a,c;if(!this.ipInformation){try{const d=`https://${i.location}`,h=yield(yield fetch(d)).json();if(((s=h.loc)==null?void 0:s.length)>5)return this.ipInformation=h,(a=this.ipInformation)!=null&&a.ip&&(this.ipInformation.ip=Sr(this.ipInformation.ip)),h;throw Error("Insufficient data")}catch(d){r.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${n}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=Sr(this.ipInformation.ip))}catch(d){r.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const Up=new lb,Bm=[{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 Fm(t){const[e,n]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(n)}}}class Bv{constructor(){y(this,"transport"),y(this,"candidatePair"),y(this,"outboundVideoRtp",new Map),y(this,"inboundVideoRtp",new Map),y(this,"outboundAudioRtp",new Map),y(this,"inboundAudioRtp",new Map),y(this,"remoteInboundRtp",new Map),y(this,"producerStreamMap",new Map),y(this,"consumerStreamMap",new Map),y(this,"staleProducerStreamMap",!1),y(this,"staleConsumerStreamMap",!1)}}class Fv extends Nt{constructor(){super(),y(this,"observer"),y(this,"outboundProducerMap",new Map),y(this,"inboundConsumerMap",new Map),y(this,"consumerPeerIdMap",new Map),y(this,"pausedConsumerMap",new Map),y(this,"pausedProducerMap",new Map),y(this,"overallProducingTransportsStatsMap",{}),y(this,"overallConsumingTransportsStatsMap",{}),y(this,"overallConsumersStatsMap",{}),y(this,"overallProducersStatsMap",{}),y(this,"videoProducerToStatsMap",new Map),y(this,"audioProducerToStatsMap",new Map),y(this,"videoConsumerToStatsMap",new Map),y(this,"audioConsumerToStatsMap",new Map),y(this,"consumerIdsWithFreezedVideo",new Set),y(this,"consumerIdsWithFreezedAudio",new Set),y(this,"producerIdsWithFreezedVideo",new Set),y(this,"producerIdsWithFreezedAudio",new Set),y(this,"freezedProducingTransportIds",new Set),y(this,"freezedConsumingTransportIds",new Set),y(this,"screenShareProducers",new Set),y(this,"screenShareConsumers",new Set),y(this,"ipDetails"),y(this,"callStatsInstance"),this.observer=new Nt}registerProducer(e){return p(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,n,i){var r,s;const a=((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.get(e))||{};n.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&a.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(n.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&a.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,n,i){var r,s;const a=((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.get(e))||{};n.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&a.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(n.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&a.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{};n.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&s.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(n.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&s.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{};n.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&s.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(n.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&s.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,n,i){var r;const s=((r=this==null?void 0:this.callStatsInstance)==null?void 0:r.currentUserMediaStates)||{},{audio:a,video:c,screen:d}=s,h=a||c||d;n.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&h&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(n.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&h&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,n,i){var r,s;const a=!!Array.from(((s=(r=this==null?void 0:this.callStatsInstance)==null?void 0:r.consumerSharedMediaStatesMap)==null?void 0:s.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);n.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&a&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(n.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&a&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return p(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,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=n?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const s of i.values())switch(s.type){case"outbound-rtp":{this.outboundProducerMap.set(s.id,e.id);break}}return r})}generateConsumerStreamMap(e,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=n?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const s of i.values())switch(s.type){case"inbound-rtp":{this.inboundConsumerMap.set(s.id,e.id);break}}return r})}deregisterProducer(e){this.outboundProducerMap.forEach((n,i)=>{n===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((n,i)=>{n===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var n;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(n=e.relayProtocol)!=null?n:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(n=>{const i=n.framesEncoded>0,r=n.packetsSent>0,s=n.frameWidth&&n.frameHeight;return i&&r&&!!s})||e[e.length-1]}parseRTCReport(e,n=[],i=!1,r=void 0,s=void 0){var a,c,d,h,u,g,E,b,k,A,M,B,K;const X=e,O=new Bv,J=n.length?new Set(n):void 0,me=[],Ie=[],fe=[],$e=new Map,ht=new Map;for(const V of X.values()){if(J){if(J.size===0)break;if(J.has(V.type))i&&J.delete(V.type);else continue}switch(V.type){case"local-candidate":{me.push(this.getIceCandidateStats(V));break}case"remote-candidate":{Ie.push(this.getIceCandidateStats(V));break}case"candidate-pair":{const{nominated:I}=V,{selected:P}=V,z=V,ye={nominated:I!=null?I:P,currentRoundTripTime:z.currentRoundTripTime,totalRoundTripTime:z.totalRoundTripTime,bytesReceived:z.bytesReceived,bytesSent:z.bytesSent,availableOutgoingBitrate:z.availableOutgoingBitrate,availableIncomingBitrate:z.availableIncomingBitrate,lastPacketReceivedTimestamp:z.lastPacketReceivedTimestamp,lastPacketSentTimestamp:z.lastPacketSentTimestamp,localCandidateId:z.localCandidateId,remoteCandidateId:z.remoteCandidateId,bytesDiscardedOnSend:z.bytesDiscardedOnSend,packetsSent:z.packetsSent,packetsReceived:z.packetsReceived,packetsDiscardedOnSend:z.packetsDiscardedOnSend};fe.push(ye),(V.nominated===!0||V.selected===!0)&&(O.candidatePair=ye);break}case"transport":{const I=V;s&&(s.producing&&(this.overallProducingTransportsStatsMap[s.id]||(this.overallProducingTransportsStatsMap[s.id]={totalPacketsSent:0})),s.consuming&&(this.overallConsumingTransportsStatsMap[s.id]||(this.overallConsumingTransportsStatsMap[s.id]={totalPacketsReceived:0})));const P={bytesReceived:I.bytesReceived,bytesSent:I.bytesSent,packetsSent:I.packetsSent,packetsReceived:I.packetsReceived,dtlsCipher:I.dtlsCipher,dtlsState:I.dtlsState,iceRole:I.iceRole};if(O.transport=P,s){if(s.producing){const z=this.overallProducingTransportsStatsMap[s.id];this.processProducingTransportStats(s.id,z,P)}if(s.consuming){const z=this.overallConsumingTransportsStatsMap[s.id];this.processConsumingTransportStats(s.id,z,P)}}break}case"remote-inbound-rtp":{const I=V,P={jitter:I.jitter,fractionLost:I.fractionLost,roundTripTime:I.roundTripTime,roundTripTimeMeasurements:I.roundTripTimeMeasurements,totalRoundTripTime:I.totalRoundTripTime,packetsLost:I.packetsLost};O.remoteInboundRtp.set(I.localId,P);break}case"outbound-rtp":{const I=V,P=r||this.outboundProducerMap.get(V.id),z=this.pausedProducerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedProducerMap.set(P,{lastReportCalculated:!0})}this.overallProducersStatsMap[P]||(this.overallProducersStatsMap[P]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const ye=this.overallProducersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.outboundProducerMap.has(V.id)){O.staleProducerStreamMap=!0;break}const Xe=this.callStatsInstance.producers.get(P);if(((a=Xe==null?void 0:Xe.track)==null?void 0:a.readyState)==="ended")break;O.producerStreamMap.has(P)||O.producerStreamMap.set(P,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const q={bytesSent:I.bytesSent,packetsSent:I.packetsSent,nackCount:I.nackCount,ssrc:I.ssrc,mid:I.mid,active:I.active,codecId:I.codecId,headerBytesSent:I.headerBytesSent||0,totalPacketSendDelay:I.totalPacketSendDelay||0};if(I.mediaType==="video"||I.kind==="video"){const N=I,Ze=H({frameHeight:N.frameHeight,frameWidth:N.frameWidth,framesEncoded:N.framesEncoded,framesDropped:N.framesDropped,framesPerSecond:N.framesPerSecond,framesSent:N.framesSent,keyFramesEncoded:N.keyFramesEncoded,firCount:N.firCount,encoderImplementation:N.encoderImplementation,hugeFramesSent:N.hugeFramesSent,pliCount:N.pliCount,qpSum:N.qpSum,qualityLimitationDurations:N.qualityLimitationDurations,qualityLimitationReason:N.qualityLimitationReason,qualityLimitationResolutionChanges:N.qualityLimitationResolutionChanges,totalEncodeTime:N.targetBitrate,totalPacketSendDelay:N.totalPacketSendDelay,retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent,scalabilityMode:N.scalabilityMode,powerEfficientEncoder:N.powerEfficientEncoder},q);O.outboundVideoRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundVideoRtpId.push(V.id),this.processOutboundProducerVideoStats(P,ye,Ze)}else if(I.mediaType==="audio"||I.kind==="audio"){const N=I,Ze=H({retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent},q);O.outboundAudioRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundAudioRtpId.push(V.id),this.processOutboundProducerAudioStats(P,ye,Ze)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}case"inbound-rtp":{const I=V,P=r||this.inboundConsumerMap.get(V.id),z=this.pausedConsumerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedConsumerMap.set(P,{lastReportCalculated:!0})}if(I.ssrc===1234)break;this.overallConsumersStatsMap[P]||(this.overallConsumersStatsMap[P]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const ye=this.overallConsumersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.inboundConsumerMap.has(V.id)){O.staleConsumerStreamMap=!0;break}O.consumerStreamMap.has(P)||O.consumerStreamMap.set(P,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const Xe={bytesReceived:I.bytesReceived,packetsReceived:I.packetsReceived,packetsLost:I.packetsLost>=0?I.packetsLost:0,jitter:I.jitter,nackCount:I.nackCount,jitterBufferDelay:I.jitterBufferDelay,jitterBufferEmittedCount:I.jitterBufferEmittedCount,lastPacketReceivedTimestamp:I.lastPacketReceivedTimestamp,ssrc:I.ssrc,mid:I.mid,codecId:I.codecId,headerBytesReceived:I.headerBytesReceived||0,packetsDiscarded:I.packetsDiscarded||0,jitterBufferMinimumDelay:I.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:I.jitterBufferTargetDelay||0};if(I.mediaType==="video"||I.kind==="video"){const q=I,N=H({frameHeight:q.frameHeight,frameWidth:q.frameWidth,framesDecoded:q.framesDecoded,framesDropped:q.framesDropped,framesPerSecond:q.framesPerSecond,framesReceived:q.framesReceived,keyFramesDecoded:q.keyFramesDecoded,firCount:q.firCount,decoderImplementation:q.decoderImplementation,pliCount:q.pliCount,totalProcessingDelay:q.totalProcessingDelay,qpSum:q.qpSum||0,totalAssemblyTime:q.totalAssemblyTime||0,totalDecodeTime:q.totalDecodeTime||0,totalFreezesDuration:q.totalFreezesDuration||0,totalInterFrameDelay:q.totalInterFrameDelay||0,totalPausesDuration:q.totalPausesDuration||0,totalSquaredInterFrameDelay:q.totalSquaredInterFrameDelay||0,freezeCount:q.freezeCount||0,pauseCount:q.pauseCount||0,powerEfficientDecoder:q.powerEfficientDecoder},Xe);N.score=Vv({frameWidth:N.frameWidth||0,framesDecoded:(N.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(P))==null?void 0:c.framesDecoded)||0),framesPerSecond:N.framesPerSecond||0,packetsLost:(N.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(P))==null?void 0:d.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((h=this.videoConsumerToStatsMap.get(P))==null?void 0:h.packetsReceived)||0),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P)}),ht.set(P,{score:+(N.score*10).toFixed(),frameWidth:N.frameWidth||0,frameHeight:N.frameHeight||0,framesPerSecond:N.framesPerSecond||0,packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((u=this.videoConsumerToStatsMap.get(P))==null?void 0:u.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((g=this.videoConsumerToStatsMap.get(P))==null?void 0:g.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((E=this.videoConsumerToStatsMap.get(P))==null?void 0:E.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(P,N),O.inboundVideoRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundVideoRtpId.push(V.id),this.processInboundConsumerVideoStats(P,ye,N)}else if(I.mediaType==="audio"||I.kind==="audio"){const q=I,N=H({audioLevel:q.audioLevel,concealedSamples:q.concealedSamples,concealmentEvents:q.concealmentEvents,totalAudioEnergy:q.totalAudioEnergy,totalSamplesDuration:q.totalSamplesDuration,totalSamplesReceived:q.totalSamplesReceived,fecPacketsDiscarded:q.fecPacketsDiscarded||0,fecPacketsReceived:q.fecPacketsReceived||0,insertedSamplesForDeceleration:q.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:q.removedSamplesForAcceleration||0,silentConcealedSamples:q.silentConcealedSamples||0,playoutId:q.playoutId},Xe);N.score=xv({concealmentEvents:(N.concealmentEvents||0)-(((b=this.audioConsumerToStatsMap.get(P))==null?void 0:b.concealmentEvents)||0),packetsLost:(N.packetsLost||0)-(((k=this.audioConsumerToStatsMap.get(P))==null?void 0:k.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((A=this.audioConsumerToStatsMap.get(P))==null?void 0:A.packetsReceived)||0),jitter:N.jitter||0}),ht.set(P,{score:+(N.score*10).toFixed(),packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((M=this.audioConsumerToStatsMap.get(P))==null?void 0:M.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((B=this.audioConsumerToStatsMap.get(P))==null?void 0:B.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((K=this.audioConsumerToStatsMap.get(P))==null?void 0:K.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(P,N),O.inboundAudioRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundAudioRtpId.push(V.id),this.processInboundConsumerAudioStats(P,ye,N)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}}}if(O.producerStreamMap.forEach((V,I)=>{var P,z,ye,Xe,q,N,Ze,Pn,Ar,Mr,Or,Fe,at,Li,xi,Vi,Ui,Bi,Sn,pi,Fi,Dr,ji;if(V.outboundVideoRtpId.length>0){const ge=[];V.outboundVideoRtpId.forEach(Da=>{ge.push(O.outboundVideoRtp.get(Da))});const pe=this.getWorkingSimulcastVideoStats(ge);pe.score=Nv({frameWidth:pe.frameWidth||0,framesPerSecond:pe.framesPerSecond||0,jitter:((P=pe.remoteData)==null?void 0:P.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsSent:(pe.packetsSent||0)-(((z=this.videoProducerToStatsMap.get(I))==null?void 0:z.packetsSent)||0),packetsLost:(((ye=pe.remoteData)==null?void 0:ye.packetsLost)||0)-(((q=(Xe=this.videoProducerToStatsMap.get(I))==null?void 0:Xe.remoteData)==null?void 0:q.packetsLost)||0),framesEncoded:(pe.framesEncoded||0)-(((N=this.videoProducerToStatsMap.get(I))==null?void 0:N.framesEncoded)||0)}),$e.set(I,{score:+(pe.score*10).toFixed(),frameWidth:pe.frameWidth||0,frameHeight:pe.frameHeight||0,framesPerSecond:pe.framesPerSecond||0,jitter:((Ze=pe.remoteData)==null?void 0:Ze.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsLostPercentage:el({packetsSent:(pe.packetsSent||0)-(((Pn=this.videoProducerToStatsMap.get(I))==null?void 0:Pn.packetsSent)||0),packetsLost:(((Ar=pe.remoteData)==null?void 0:Ar.packetsLost)||0)-(((Or=(Mr=this.videoProducerToStatsMap.get(I))==null?void 0:Mr.remoteData)==null?void 0:Or.packetsLost)||0)}),bitrate:((pe.bytesSent||0)-(((Fe=this.videoProducerToStatsMap.get(I))==null?void 0:Fe.bytesSent)||0))*8/7,cpuLimitations:pe.qualityLimitationReason==="cpu",bandwidthLimitations:pe.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(I,pe)}else if(V.outboundAudioRtpId.length>0){const ge=O.outboundAudioRtp.get(V.outboundAudioRtpId[0]);ge.score=Dv({packetsSent:(ge.packetsSent||0)-(((at=this.audioProducerToStatsMap.get(I))==null?void 0:at.packetsSent)||0),packetsLost:(((Li=ge.remoteData)==null?void 0:Li.packetsLost)||0)-(((Vi=(xi=this.audioProducerToStatsMap.get(I))==null?void 0:xi.remoteData)==null?void 0:Vi.packetsLost)||0),jitter:((Ui=ge.remoteData)==null?void 0:Ui.jitter)||0}),$e.set(I,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((Bi=this.audioProducerToStatsMap.get(I))==null?void 0:Bi.bytesSent)||0))*8/7,packetsLostPercentage:el({packetsSent:(ge.packetsSent||0)-(((Sn=this.audioProducerToStatsMap.get(I))==null?void 0:Sn.packetsSent)||0),packetsLost:(((pi=ge.remoteData)==null?void 0:pi.packetsLost)||0)-(((Dr=(Fi=this.audioProducerToStatsMap.get(I))==null?void 0:Fi.remoteData)==null?void 0:Dr.packetsLost)||0)}),jitter:((ji=ge.remoteData)==null?void 0:ji.jitter)||0,isScreenShare:this.screenShareProducers.has(I)}),this.audioProducerToStatsMap.set(I,ge)}}),fe.forEach(V=>{const I=me.find(z=>z.id===V.localCandidateId?(V.localCandidateId=z.id,z):null),P=Ie.find(z=>z.id===V.remoteCandidateId?(V.remoteCandidateId=z.id,z):null);I&&(V.localCandidateType=I.type,V.localCandidateAddress=Sr(I.address),V.localCandidatePort=I.port,V.localCandidateProtocol=I.protocol,V.localCandidateUrl=I.url,V.localCandidateNetworkType=I.networkType,V.localCandidateRelatedAddress=Sr(I.relatedAddress),V.localCandidateRelatedPort=I.relatedPort),P&&(V.remoteCandidateType=P.type,V.remoteCandidateAddress=Sr(P.address),V.remoteCandidatePort=P.port,V.remoteCandidateProtocol=P.protocol,V.remoteCandidateUrl=P.url)}),O.candidatePair&&(O.transport?(O.transport.totalRoundTripTime=O.candidatePair.totalRoundTripTime,O.transport.availableOutgoingBitrate=O.candidatePair.availableOutgoingBitrate,O.transport.availableIncomingBitrate=O.candidatePair.availableIncomingBitrate,O.transport.roundTripTime=O.candidatePair.currentRoundTripTime):O.transport={bytesReceived:O.candidatePair.bytesReceived,bytesSent:O.candidatePair.bytesSent,totalRoundTripTime:O.candidatePair.totalRoundTripTime,availableOutgoingBitrate:O.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:O.candidatePair.availableIncomingBitrate,roundTripTime:O.candidatePair.currentRoundTripTime}),O.transport&&(O.transport.candidatePairs=fe),O.transport&&!O.transport.roundTripTime){let V=0,I=0;O.remoteInboundRtp.forEach((P,z)=>{P.roundTripTime&&P.roundTripTime>V&&(V=P.roundTripTime,I=P.totalRoundTripTime)}),O.transport.roundTripTime=V,O.transport.totalRoundTripTime=I}if(ht.size>0)try{this.observer.emit("consumer_score",ht)}catch{}if($e.size>0)try{this.observer.emit("producer_score",$e)}catch{}return O}getProducersReport(e){return p(this,null,function*(){const n=e.map(i=>this.generateProducerStreamMap(i,!0));return n.length>0?Promise.all(n):void 0})}getConsumersReport(e){return p(this,null,function*(){const n=e.map(i=>this.generateConsumerStreamMap(i,!0));return n.length>0?Promise.all(n):void 0})}getTransportReport(e){return p(this,null,function*(){return e.getStats()})}getProcessedStats(e,n,i){return p(this,null,function*(){const r=yield this.getTransportReport(e),s={producing:i,consuming:n,id:e.id},a=r,c=this.parseRTCReport(a,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,s);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:n,producing:i},h=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),u=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:h,consumerReport:u}})}getProducerStatsFromReport(e){const n=[];try{e.producerStreamMap.forEach((i,r)=>{var s,a;n.push({producerId:r,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((a=(s=this.callStatsInstance.producers)==null?void 0:s.get(r))==null?void 0:a.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return n}getConsumerStatsFromReport(e){const n=[];try{e.consumerStreamMap.forEach((i,r)=>{const{peerId:s,producerId:a,appData:c}=this.consumerPeerIdMap.get(r);n.push({consumerId:r,peerId:s,producerId:a,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 n}getUserLocation(){return p(this,null,function*(){return new Promise((e,n)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):n()}catch(i){n(i)}})})}getConnectivity(e){return p(this,null,function*(){try{const n={iceServers:e||Bm},i=new Promise((h,u)=>{try{const g=new ob(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),r=new Promise((h,u)=>{try{const g=new cb(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),s=new Promise((h,u)=>{try{const g=new db(n);g.addListener("done",h),g.addListener("failed",()=>{h({connectivity:!1})}),g.start(2e3)}catch(g){u(g)}}),[a,c,d]=yield Promise.all([i,r,s]);return{host:a==null?void 0:a.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 p(this,null,function*(){try{const n=yield new Promise((i,r)=>{try{const s={iceServers:e||Bm},a=new ab(s);a.addListener("done",i),a.addListener("failed",r),a.start(1e4)}catch(s){r(s)}});return{throughput:n.throughput,fractionalLoss:0,RTT:n.RTT,jitter:0,backendRTT:n.backendRTT}}catch{return}})}getIPDetails(){return p(this,null,function*(){var e,n;try{return this.ipDetails||(this.ipDetails=yield Up.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(n=this.callStatsInstance)==null?void 0:n.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return p(this,null,function*(){const[n,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:n,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,n=!1){return p(this,null,function*(){var i,r;if(n){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Fm(d==null?void 0:d.loc):void 0}}const[s,a,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(r=navigator.connection)==null?void 0:r.effectiveType,location:c!=null&&c.loc?Fm(c==null?void 0:c.loc):void 0,turnConnectivity:s?s.host||s.relay||s.reflexive:!1,connectivity:s,throughput:a==null?void 0:a.throughput,fractionalLoss:a==null?void 0:a.fractionalLoss,RTT:a==null?void 0:a.RTT,jitter:a==null?void 0:a.jitter,backendRTT:a==null?void 0:a.backendRTT}})}}class ub extends Fv{}class jv extends Fv{constructor(){super(...arguments),y(this,"producerMap",new Map),y(this,"consumerMap",new Map)}registerProducer(e){return p(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 p(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,n=!1){return p(this,null,function*(){const i=yield e.getStats(),r=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),s=[...r.consumerStreamMap.values()][0],a=n?this.getConsumerStatsFromParsedConsumerStats(r,s,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 a})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((n,i)=>{n===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((n,i)=>{n===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var n;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(n=e.relayProtocol)!=null?n:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,n=[],i=!1,r=void 0,s=void 0){var a,c,d,h,u,g,E,b,k,A,M,B,K;const X=e,O=new Bv,J=n.length?new Set(n):void 0,me=[],Ie=[],fe=[],$e=new Map,ht=new Map;for(const V of X.values()){if(J){if(J.size===0)break;if(J.has(V.type))i&&J.delete(V.type);else continue}switch(V.type){case"local-candidate":{me.push(this.getIceCandidateStats(V));break}case"remote-candidate":{Ie.push(this.getIceCandidateStats(V));break}case"candidate-pair":{const{nominated:I}=V,{selected:P}=V,z=V,ye={nominated:I!=null?I:P,currentRoundTripTime:z.currentRoundTripTime,totalRoundTripTime:z.totalRoundTripTime,bytesReceived:z.bytesReceived,bytesSent:z.bytesSent,availableOutgoingBitrate:z.availableOutgoingBitrate,availableIncomingBitrate:z.availableIncomingBitrate,lastPacketReceivedTimestamp:z.lastPacketReceivedTimestamp,lastPacketSentTimestamp:z.lastPacketSentTimestamp,localCandidateId:z.localCandidateId,remoteCandidateId:z.remoteCandidateId,bytesDiscardedOnSend:z.bytesDiscardedOnSend,packetsSent:z.packetsSent,packetsReceived:z.packetsReceived,packetsDiscardedOnSend:z.packetsDiscardedOnSend};fe.push(ye),(V.nominated===!0||V.selected===!0)&&(O.candidatePair=ye);break}case"transport":{const I=V;s&&(s.producing&&(this.overallProducingTransportsStatsMap[s.id]||(this.overallProducingTransportsStatsMap[s.id]={totalPacketsSent:0})),s.consuming&&(this.overallConsumingTransportsStatsMap[s.id]||(this.overallConsumingTransportsStatsMap[s.id]={totalPacketsReceived:0})));const P={bytesReceived:I.bytesReceived,bytesSent:I.bytesSent,packetsSent:I.packetsSent,packetsReceived:I.packetsReceived,dtlsCipher:I.dtlsCipher,dtlsState:I.dtlsState,iceRole:I.iceRole};if(O.transport=P,s){if(s.producing){const z=this.overallProducingTransportsStatsMap[s.id];this.processProducingTransportStats(s.id,z,P)}if(s.consuming){const z=this.overallConsumingTransportsStatsMap[s.id];this.processConsumingTransportStats(s.id,z,P)}}break}case"remote-inbound-rtp":{const I=V,P={jitter:I.jitter,fractionLost:I.fractionLost,roundTripTime:I.roundTripTime,roundTripTimeMeasurements:I.roundTripTimeMeasurements,totalRoundTripTime:I.totalRoundTripTime,packetsLost:I.packetsLost};O.remoteInboundRtp.set(I.localId,P);break}case"outbound-rtp":{const I=V,P=r||this.outboundProducerMap.get(V.id),z=this.pausedProducerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedProducerMap.set(P,{lastReportCalculated:!0})}this.overallProducersStatsMap[P]||(this.overallProducersStatsMap[P]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const ye=this.overallProducersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.outboundProducerMap.has(V.id)){O.staleProducerStreamMap=!0;break}const Xe=this.callStatsInstance.producers.get(P);if(((a=Xe==null?void 0:Xe.track)==null?void 0:a.readyState)==="ended")break;O.producerStreamMap.has(P)||O.producerStreamMap.set(P,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const q={bytesSent:I.bytesSent,packetsSent:I.packetsSent,nackCount:I.nackCount,ssrc:I.ssrc,mid:I.mid,active:I.active,codecId:I.codecId,headerBytesSent:I.headerBytesSent||0,totalPacketSendDelay:I.totalPacketSendDelay||0};if(I.mediaType==="video"||I.kind==="video"){const N=I,Ze=H({frameHeight:N.frameHeight,frameWidth:N.frameWidth,framesEncoded:N.framesEncoded,framesDropped:N.framesDropped?N.framesDropped:N.droppedFrames,framesPerSecond:N.framesPerSecond?N.framesPerSecond:N.framerateMean,framesSent:N.framesSent,keyFramesEncoded:N.keyFramesEncoded,firCount:N.firCount,encoderImplementation:N.encoderImplementation,hugeFramesSent:N.hugeFramesSent,pliCount:N.pliCount,qpSum:N.qpSum,qualityLimitationReason:N.qualityLimitationReason,qualityLimitationDurations:N.qualityLimitationDurations,qualityLimitationResolutionChanges:N.qualityLimitationResolutionChanges,totalEncodeTime:N.totalEncodeTime,totalPacketSendDelay:N.totalEncodeTime,retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent,scalabilityMode:N.scalabilityMode,powerEfficientEncoder:N.powerEfficientEncoder},q);O.outboundVideoRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundVideoRtpId.push(V.id),this.processOutboundProducerVideoStats(P,ye,Ze)}else if(I.mediaType==="audio"||I.kind==="audio"){const N=I,Ze=H({retransmittedBytesSent:N.retransmittedBytesSent,retransmittedPacketsSent:N.retransmittedPacketsSent},q);O.outboundAudioRtp.set(V.id,Ze),O.producerStreamMap.get(P).outboundAudioRtpId.push(V.id),this.processOutboundProducerAudioStats(P,ye,Ze)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}case"inbound-rtp":{const I=V,P=r||this.inboundConsumerMap.get(V.id),z=this.pausedConsumerMap.get(P);if(z){if(z.lastReportCalculated===!0)break;this.pausedConsumerMap.set(P,{lastReportCalculated:!0})}if(I.ssrc===1234)break;this.overallConsumersStatsMap[P]||(this.overallConsumersStatsMap[P]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const ye=this.overallConsumersStatsMap[P];if(["video","audio"].includes(I.mediaType)||["video","audio"].includes(I.kind)){if(!this.inboundConsumerMap.has(V.id)){O.staleConsumerStreamMap=!0;break}O.consumerStreamMap.has(P)||O.consumerStreamMap.set(P,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const Xe={bytesReceived:I.bytesReceived,packetsReceived:I.packetsReceived,packetsLost:I.packetsLost>=0?I.packetsLost:0,jitter:I.jitter,nackCount:I.nackCount,jitterBufferDelay:I.jitterBufferDelay,jitterBufferEmittedCount:I.jitterBufferEmittedCount,lastPacketReceivedTimestamp:I.lastPacketReceivedTimestamp,ssrc:I.ssrc,mid:I.mid,codecId:I.codecId,headerBytesReceived:I.headerBytesReceived||0,packetsDiscarded:I.packetsDiscarded||0,jitterBufferMinimumDelay:I.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:I.jitterBufferTargetDelay||0};if(I.mediaType==="video"||I.kind==="video"){const q=I,N=H({frameHeight:q.frameHeight,frameWidth:q.frameWidth,framesDecoded:q.framesDecoded,framesDropped:q.framesDropped?q.framesDropped:q.droppedFrames,framesPerSecond:q.framesPerSecond?q.framesPerSecond:q.framerateMean,framesReceived:q.framesReceived,keyFramesDecoded:q.keyFramesDecoded,firCount:q.firCount,decoderImplementation:q.decoderImplementation,pliCount:q.pliCount,totalProcessingDelay:q.totalProcessingDelay,qpSum:q.qpSum||0,totalAssemblyTime:q.totalAssemblyTime||0,totalDecodeTime:q.totalDecodeTime||0,totalFreezesDuration:q.totalFreezesDuration||0,totalInterFrameDelay:q.totalInterFrameDelay||0,totalPausesDuration:q.totalPausesDuration||0,totalSquaredInterFrameDelay:q.totalSquaredInterFrameDelay||0,freezeCount:q.freezeCount||0,pauseCount:q.pauseCount||0,powerEfficientDecoder:q.powerEfficientDecoder},Xe);N.score=Vv({frameWidth:N.frameWidth||0,framesDecoded:(N.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(P))==null?void 0:c.framesDecoded)||0),framesPerSecond:N.framesPerSecond||0,packetsLost:(N.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(P))==null?void 0:d.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((h=this.videoConsumerToStatsMap.get(P))==null?void 0:h.packetsReceived)||0),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P)}),ht.set(P,{score:+(N.score*10).toFixed(),frameWidth:N.frameWidth||0,frameHeight:N.frameHeight||0,framesPerSecond:N.framesPerSecond||0,packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((u=this.videoConsumerToStatsMap.get(P))==null?void 0:u.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((g=this.videoConsumerToStatsMap.get(P))==null?void 0:g.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((E=this.videoConsumerToStatsMap.get(P))==null?void 0:E.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(P,N),O.inboundVideoRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundVideoRtpId.push(V.id),this.processInboundConsumerVideoStats(P,ye,N)}else if(I.mediaType==="audio"||I.kind==="audio"){const q=I,N=H({audioLevel:q.audioLevel,concealedSamples:q.concealedSamples,concealmentEvents:q.concealmentEvents,totalAudioEnergy:q.totalAudioEnergy,totalSamplesDuration:q.totalSamplesDuration,totalSamplesReceived:q.totalSamplesReceived,fecPacketsDiscarded:q.fecPacketsDiscarded||0,fecPacketsReceived:q.fecPacketsReceived||0,insertedSamplesForDeceleration:q.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:q.removedSamplesForAcceleration||0,silentConcealedSamples:q.silentConcealedSamples||0,playoutId:q.playoutId},Xe);N.score=xv({concealmentEvents:(N.concealmentEvents||0)-(((b=this.audioConsumerToStatsMap.get(P))==null?void 0:b.concealmentEvents)||0),packetsLost:(N.packetsLost||0)-(((k=this.audioConsumerToStatsMap.get(P))==null?void 0:k.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((A=this.audioConsumerToStatsMap.get(P))==null?void 0:A.packetsReceived)||0),jitter:N.jitter||0}),ht.set(P,{score:+(N.score*10).toFixed(),packetsLostPercentage:tl({packetsLost:(N.packetsLost||0)-(((M=this.audioConsumerToStatsMap.get(P))==null?void 0:M.packetsLost)||0),packetsReceived:(N.packetsReceived||0)-(((B=this.audioConsumerToStatsMap.get(P))==null?void 0:B.packetsReceived)||0)}),jitter:N.jitter||0,isScreenShare:this.screenShareConsumers.has(P),bitrate:((N.bytesReceived||0)-(((K=this.audioConsumerToStatsMap.get(P))==null?void 0:K.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(P,N),O.inboundAudioRtp.set(V.id,N),O.consumerStreamMap.get(P).inboundAudioRtpId.push(V.id),this.processInboundConsumerAudioStats(P,ye,N)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${I.mediaType} kind: ${I.kind}`);break}}}if(O.producerStreamMap.forEach((V,I)=>{var P,z,ye,Xe,q,N,Ze,Pn,Ar,Mr,Or,Fe,at,Li,xi,Vi,Ui,Bi,Sn,pi,Fi,Dr,ji;if(V.outboundVideoRtpId.length>0){const ge=[];V.outboundVideoRtpId.forEach(Da=>{ge.push(O.outboundVideoRtp.get(Da))});const pe=this.getWorkingSimulcastVideoStats(ge);pe.score=Nv({frameWidth:pe.frameWidth||0,framesPerSecond:pe.framesPerSecond||0,jitter:((P=pe.remoteData)==null?void 0:P.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsSent:(pe.packetsSent||0)-(((z=this.videoProducerToStatsMap.get(I))==null?void 0:z.packetsSent)||0),packetsLost:(((ye=pe.remoteData)==null?void 0:ye.packetsLost)||0)-(((q=(Xe=this.videoProducerToStatsMap.get(I))==null?void 0:Xe.remoteData)==null?void 0:q.packetsLost)||0),framesEncoded:(pe.framesEncoded||0)-(((N=this.videoProducerToStatsMap.get(I))==null?void 0:N.framesEncoded)||0)}),$e.set(I,{score:+(pe.score*10).toFixed(),frameWidth:pe.frameWidth||0,frameHeight:pe.frameHeight||0,framesPerSecond:pe.framesPerSecond||0,jitter:((Ze=pe.remoteData)==null?void 0:Ze.jitter)||0,isScreenShare:this.screenShareProducers.has(I),packetsLostPercentage:el({packetsSent:(pe.packetsSent||0)-(((Pn=this.videoProducerToStatsMap.get(I))==null?void 0:Pn.packetsSent)||0),packetsLost:(((Ar=pe.remoteData)==null?void 0:Ar.packetsLost)||0)-(((Or=(Mr=this.videoProducerToStatsMap.get(I))==null?void 0:Mr.remoteData)==null?void 0:Or.packetsLost)||0)}),bitrate:((pe.bytesSent||0)-(((Fe=this.videoProducerToStatsMap.get(I))==null?void 0:Fe.bytesSent)||0))*8/7,cpuLimitations:pe.qualityLimitationReason==="cpu",bandwidthLimitations:pe.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(I,pe)}else if(V.outboundAudioRtpId.length>0){const ge=O.outboundAudioRtp.get(V.outboundAudioRtpId[0]);ge.score=Dv({packetsSent:(ge.packetsSent||0)-(((at=this.audioProducerToStatsMap.get(I))==null?void 0:at.packetsSent)||0),packetsLost:(((Li=ge.remoteData)==null?void 0:Li.packetsLost)||0)-(((Vi=(xi=this.audioProducerToStatsMap.get(I))==null?void 0:xi.remoteData)==null?void 0:Vi.packetsLost)||0),jitter:((Ui=ge.remoteData)==null?void 0:Ui.jitter)||0}),$e.set(I,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((Bi=this.audioProducerToStatsMap.get(I))==null?void 0:Bi.bytesSent)||0))*8/7,packetsLostPercentage:el({packetsSent:(ge.packetsSent||0)-(((Sn=this.audioProducerToStatsMap.get(I))==null?void 0:Sn.packetsSent)||0),packetsLost:(((pi=ge.remoteData)==null?void 0:pi.packetsLost)||0)-(((Dr=(Fi=this.audioProducerToStatsMap.get(I))==null?void 0:Fi.remoteData)==null?void 0:Dr.packetsLost)||0)}),jitter:((ji=ge.remoteData)==null?void 0:ji.jitter)||0,isScreenShare:this.screenShareProducers.has(I)}),this.audioProducerToStatsMap.set(I,ge)}}),fe.forEach(V=>{const I=me.find(z=>z.id===V.localCandidateId?(V.localCandidateId=z.id,z):null),P=Ie.find(z=>z.id===V.remoteCandidateId?(V.remoteCandidateId=z.id,z):null);I&&(V.localCandidateType=I.type,V.localCandidateAddress=Sr(I.address),V.localCandidatePort=I.port,V.localCandidateProtocol=I.protocol,V.localCandidateUrl=I.url,V.localCandidateNetworkType=I.networkType,V.localCandidateRelatedAddress=Sr(I.relatedAddress),V.localCandidateRelatedPort=I.relatedPort),P&&(V.remoteCandidateType=P.type,V.remoteCandidateAddress=Sr(P.address),V.remoteCandidatePort=P.port,V.remoteCandidateProtocol=P.protocol,V.remoteCandidateUrl=P.url)}),O.candidatePair&&(O.transport?(O.transport.bytesReceived=O.candidatePair.bytesReceived,O.transport.bytesSent=O.candidatePair.bytesSent,O.transport.totalRoundTripTime=O.candidatePair.totalRoundTripTime,O.transport.availableOutgoingBitrate=O.candidatePair.availableOutgoingBitrate,O.transport.availableIncomingBitrate=O.candidatePair.availableIncomingBitrate,O.transport.roundTripTime=O.candidatePair.currentRoundTripTime):O.transport={bytesReceived:O.candidatePair.bytesReceived,bytesSent:O.candidatePair.bytesSent,totalRoundTripTime:O.candidatePair.totalRoundTripTime,availableOutgoingBitrate:O.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:O.candidatePair.availableIncomingBitrate,roundTripTime:O.candidatePair.currentRoundTripTime}),O.transport&&(O.transport.candidatePairs=fe),O.transport&&!O.transport.roundTripTime){let V=0,I=0;O.remoteInboundRtp.forEach((P,z)=>{P.roundTripTime&&P.roundTripTime>V&&(V=P.roundTripTime,I=P.totalRoundTripTime)}),O.transport.roundTripTime=V,O.transport.totalRoundTripTime=I}if(ht.size>0)try{this.observer.emit("consumer_score",ht)}catch{}if($e.size>0)try{this.observer.emit("producer_score",$e)}catch{}return O}getProducerStatsFromReport(e){const n=[];try{e.producerStreamMap.forEach((i,r)=>{const s=this.producerMap.get(r),a=s.track.getSettings(),c=i.outboundVideoRtpId.map(h=>{const u=e.outboundVideoRtp.get(h);return u.frameHeight||(u.frameHeight=a.height,u.frameWidth=a.width,u.framesPerSecond=a.frameRate),u}),d={producerId:r,appData:s.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(h=>e.outboundAudioRtp.get(h))};n.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return n}getConsumerStatsFromParsedConsumerStats(e,n,i){let r;try{const{peerId:s,producerId:a,appData:c}=this.consumerPeerIdMap.get(i),d=n==null?void 0:n.inboundVideoRtpId.map(h=>{const u=this.consumerMap.get(i).track.getSettings(),g=e.inboundVideoRtp.get(h);return g.frameHeight||(g.frameHeight=u.height,g.frameWidth=u.width,g.framesPerSecond=u.frameRate),g});r={consumerId:i,peerId:s,producerId:a,appData:c,videoStats:d,audioStats:n==null?void 0:n.inboundAudioRtpId.map(h=>e.inboundAudioRtp.get(h))}}catch(s){console.error("getConsumerStatsFromParsedConsumerStats: ",s,e)}return r}getConsumerStatsFromReport(e){const n=[];try{e.consumerStreamMap.forEach((i,r)=>{n.push(this.getConsumerStatsFromParsedConsumerStats(e,i,r))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return n}}class hb extends jv{}function nl(t,e,n,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof n=="function"&&i instanceof e)n.call(null,i,t);else throw i}function jm(t,e,n){const i=t.value;return t.value=function(...r){try{const s=i.apply(this,r);return s&&s instanceof Promise?s.catch(a=>{nl(this,e,n,a)}):s}catch(s){nl(this,e,n,s)}return null},t}const le=(t,e)=>(n,i,r)=>{const s=r.value;return r.value=function(...a){try{const c=s.apply(this,a);return c&&c instanceof Promise?c.catch(d=>{nl(this,t,e,d)}):c}catch(c){nl(this,t,e,c)}return null},r},pb=(t,e)=>(n,i,r)=>{if(r)return jm(r,t,e);for(const s of Reflect.ownKeys(n.prototype).filter(a=>a!=="constructor")){const a=Object.getOwnPropertyDescriptor(n.prototype,s);a.value instanceof Function&&Object.defineProperty(n.prototype,s,jm(a,t,e))}};var ce=globalThis&&globalThis.__decorate||function(t,e,n,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(r<3?a(s):r>3?a(e,n,s):a(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s};const de=console;let ae=class extends Nt{constructor(t="https://api.testingv3.dyte.in",e="Blink",n=Jo.PROD,i,r,s,a){switch(super(),y(this,"observer"),y(this,"eventHandler"),y(this,"measurements"),y(this,"producingTransport"),y(this,"consumingTransport"),y(this,"producers",new Map),y(this,"consumers",new Map),y(this,"iceServers"),y(this,"connectionInfoPromise"),y(this,"pingStatsTimeout"),y(this,"logger"),y(this,"env"),y(this,"apiHostnames"),y(this,"peerId"),y(this,"consumerSharedMediaStatesMap",new Map),y(this,"currentUserMediaStates",{}),this.env=n,this.apiHostnames=a,this.logger=r,this.peerId=s,this.eventHandler=new QT({logger:r,peerId:s,apiHostnames:a}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new ub;break;case"Gecko":this.measurements=new jv;break;case"WebKit":this.measurements=new hb;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 Nt,this.measurements.observer.on("consumer_score",c=>{r.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{r.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 n=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(n,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.observer.on("close",this.disconnectProducingTransport.bind(this,t)),t.observer.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(n=>{this.registerProducer(n)}),t.observer.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.observer.on("close",this.disconnectConsumingTransport.bind(this,t)),t.observer.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(n=>{this.registerConsumer(n)}),t.observer.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:G.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(n=>{this.eventHandler.callEvent({event:G.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:n},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,n){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?G.SCREENSHARE_STARTED:G.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:n})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:G.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:G.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,n){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_DEVICES_UPDATES||t===wn.VIDEO&&G.VIDEO_DEVICES_UPDATES||t===wn.SPEAKER&&G.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:n})}selectedDevice(t,e,n){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.SELECTED_MICROHPONE_UPDATE||t===wn.VIDEO&&G.SELECTED_CAMERA_UPDATE||t===wn.SPEAKER&&G.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:n})}mediaPermission(t,e,n){this.eventHandler.callEvent({event:G.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:n})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_PLAY_FAILED||t===wn.VIDEO&&G.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===wn.AUDIO&&G.AUDIO_TRACK_MUTED||t===wn.VIDEO&&G.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:G.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:G.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:G.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:G.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return p(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=ee(H({},t),{meetingEnv:this.env}),t.deviceInfo=ee(H({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:G.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:G.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((n,i)=>p(this,null,function*(){const r=[];try{for(const s of t)try{if(s.iceServers&&s.iceServers.length>0){const a=yield this.measurements.getNetworkQuality(s.iceServers);r.push(ee(H({},s),{networkResults:a}))}}catch(a){console.warn("Error handling ",a)}n({regionData:r})}catch(s){console.warn("Error in callstats, ",s),i(s)}})).then(n=>{this.eventHandler.callEvent({event:G.NET_QUALITY_TEST_END,timestamp:e,metaData:n})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:G.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:G.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let n;t?n=G.AUDIO_ON:n=G.AUDIO_OFF,this.eventHandler.callEvent({event:n,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let n;t?n=G.VIDEO_ON:n=G.VIDEO_OFF,this.eventHandler.callEvent({event:n,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:G.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 p(this,null,function*(){let n,i;if(this.producingTransport&&(n=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!n||!(n!=null&&n.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const s=yield this.measurements.getProducersReport([...this.producers.values()]);n&&s?n.producerReport=s:(n=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!n||!(n!=null&&n.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 s=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&s?i.consumerReport=s:(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 r={producingTransportStats:n?n==null?void 0:n.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((n==null?void 0:n.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((n==null?void 0:n.consumerReport)||[])};if(t&&r.producerStats.length===0&&r.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:G.PING_STAT,metaData:r,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:G.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:G.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:G.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:G.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:G.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,n){this.eventHandler.callEvent({event:G.EXPECTED_VIDEO_RESOLUTION,timestamp:n,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,n){this.eventHandler.callEvent({event:G.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:n,metaData:{frameWidth:t,frameHeight:e}})}};ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerIceServers",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerConsumer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerProducer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendConsumerSharedMediaStateEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerProducingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"registerConsumingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"deRegisterConsumer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"deRegisterProducer",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"disconnectConsumingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"disconnectProducingTransport",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPreCallTestBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendScreenShareToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendScreenShareRequestedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendActiveSpeakerEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"devices",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"selectedDevice",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaPermission",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaPlaybackFailed",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"mediaTrackMuted",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"tabChanged",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"browserBackgrounded",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"browserForegrounded",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"legacySwitch",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"getPreCallTestResults",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendCallJoinBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendNetworkQualityTestBeginEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendWebSocketConnectedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendTransportConnectedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendAudioToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendVideoToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendParticipantRoleToggleEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"startPingStats",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"stopPingStats",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPingStatsEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerRebufferEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerAudioBlockEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerInitializedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerWorkerErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerRecoverableErrorEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerAnalyticsEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendIVSPlayerQualityChanged",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendPlayerLiveLatency",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendDisconnectEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"sendReconnectEvent",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"expectedVideoResolution",null);ce([le(TypeError,(t,e)=>de.error(e,t))],ae.prototype,"expectedScreenshareResolution",null);ae=ce([pb(TypeError,(t,e)=>de.error(e,t))],ae);const mb=ae;class fb extends Nt{constructor(){super(...arguments),y(this,"stats"),y(this,"peerId"),y(this,"backend"),y(this,"iceServers"),y(this,"initialized",!1),y(this,"stalled",!1),y(this,"ipInformation"),y(this,"logger")}initialize(e){return p(this,arguments,function*({peerId:n,engineName:i,env:r=Jo.PROD,iceServers:s,apiBase:a="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:h,skipConnectivityChecks:u=!1}){var g,E,b;try{this.peerId=n,this.logger=d,this.ipInformation=yield Up.getIPDetails({peerId:n,apiHostnames:h,logger:d}),this.backend=new mb(a,i,r,c,d,n,h),this.iceServers=s,(g=this.backend)==null||g.registerIceServers(this.iceServers),this.initialized=!0,(b=(E=this.backend)==null?void 0:E.eventHandler)==null||b.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(u)}catch(k){this.logger.error("callStats::CallStatsIntegration: ",{error:k}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,n)}catch(r){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:r.reason}})}})})}roomJoined(e){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i,r;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,n),this.backend,(r=this.backend)==null||r.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var n,i;(n=this.backend)==null||n.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,n)})}consumerSharedMediaState(e,n){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,n)})}screenShareStop(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,n)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,n)})}devices(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.devices(e,n,i)})}selectedDevice(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.selectedDevice(e,n,i)})}mediaPermission(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.mediaPermission(e,n,i)})}mediaPlaybackFailed(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,n)})}mediaTrackMuted(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,n)})}tabChanged(e=!1){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,n)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.browserForegrounded(e)})}legacySwitch(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,n)})}startPreCallTest(e=!1){return p(this,null,function*(){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,n)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var n;(n=this.backend)==null||n.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const n=i=>{e(i,!0)};return this.once("initialized",n),n}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,n){const i=new Date;this.onSafeInitialization(()=>{var r,s,a,c,d,h,u,g,E,b,k;switch(e){case"PlayerRebuffering":(r=this.backend)==null||r.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(s=this.backend)==null||s.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(a=this.backend)==null||a.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":(h=this.backend)==null||h.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(u=this.backend)==null||u.sendIVSPlayerErrorEvent(n,i);break;case"PlayerRecoverableError":(g=this.backend)==null||g.sendIVSPlayerRecoverableErrorEvent(n,i);break;case"PlayerAnalyticsEvent":(E=this.backend)==null||E.sendIVSPlayerAnalyticsEvent(n,i);break;case"PlayerPlaybackRateChanged":(b=this.backend)==null||b.sendIVSPlayerPlaybackRateChangedEvent(n,i);break;case"PlayerQualityChanged":(k=this.backend)==null||k.sendIVSPlayerQualityChanged(n,i);break}})}livestreamLatency(e){const n=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,n)})}expectedVideoResolution(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.expectedVideoResolution(e,n,i)})}expectedScreenshareResolution(e,n){const i=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.expectedScreenshareResolution(e,n,i)})}}const ne=new fb;ne.setMaxListeners(30);function gb(t){const{length:e}=this,n=t>=0?t:e+t;return n<0||n>=e?void 0:this[n]}Array.prototype.at||Object.assign(Array.prototype,{at:gb});function vb(t){const{length:e}=this,n=t>=0?t:e+t;return n<0||n>=e?void 0:this[n]}String.prototype.at||Object.assign(String.prototype,{at:vb});function yb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wv={exports:{}},st=Wv.exports={},ii,ri;function ch(){throw new Error("setTimeout has not been defined")}function dh(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ii=setTimeout:ii=ch}catch{ii=ch}try{typeof clearTimeout=="function"?ri=clearTimeout:ri=dh}catch{ri=dh}})();function Hv(t){if(ii===setTimeout)return setTimeout(t,0);if((ii===ch||!ii)&&setTimeout)return ii=setTimeout,setTimeout(t,0);try{return ii(t,0)}catch{try{return ii.call(null,t,0)}catch{return ii.call(this,t,0)}}}function Eb(t){if(ri===clearTimeout)return clearTimeout(t);if((ri===dh||!ri)&&clearTimeout)return ri=clearTimeout,clearTimeout(t);try{return ri(t)}catch{try{return ri.call(null,t)}catch{return ri.call(this,t)}}}var Ii=[],fa=!1,ds,ud=-1;function Sb(){!fa||!ds||(fa=!1,ds.length?Ii=ds.concat(Ii):ud=-1,Ii.length&&qv())}function qv(){if(!fa){var t=Hv(Sb);fa=!0;for(var e=Ii.length;e;){for(ds=Ii,Ii=[];++ud<e;)ds&&ds[ud].run();ud=-1,e=Ii.length}ds=null,fa=!1,Eb(t)}}st.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ii.push(new Gv(t,e)),Ii.length===1&&!fa&&Hv(qv)};function Gv(t,e){this.fun=t,this.array=e}Gv.prototype.run=function(){this.fun.apply(null,this.array)};st.title="browser";st.browser=!0;st.env={};st.argv=[];st.version="";st.versions={};function Oi(){}st.on=Oi;st.addListener=Oi;st.once=Oi;st.off=Oi;st.removeListener=Oi;st.removeAllListeners=Oi;st.emit=Oi;st.prependListener=Oi;st.prependOnceListener=Oi;st.listeners=function(t){return[]};st.binding=function(t){throw new Error("process.binding is not supported")};st.cwd=function(){return"/"};st.chdir=function(t){throw new Error("process.chdir is not supported")};st.umask=function(){return 0};var Tb=Wv.exports;const ls=yb(Tb);var lh={},bb={get exports(){return lh},set exports(t){lh=t}},il={},kb={get exports(){return il},set exports(t){il=t}},Jv=function(t,e){return function(){return t.apply(e,arguments)}},wb=Jv,Bp=Object.prototype.toString,Fp=function(t){return function(e){var n=Bp.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())}}(Object.create(null));function Ir(t){return t=t.toLowerCase(),function(e){return Fp(e)===t}}function xl(t){return Array.isArray(t)}function uh(t){return typeof t=="undefined"}function _b(t){return t!==null&&!uh(t)&&t.constructor!==null&&!uh(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}var $v=Ir("ArrayBuffer");function Ib(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&$v(t.buffer),e}function Cb(t){return typeof t=="string"}function Kv(t){return typeof t=="number"}function zv(t){return t!==null&&typeof t=="object"}function hd(t){if(Fp(t)!=="object")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Rb(t){return t&&Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}var Pb=Ir("Date"),Ab=Ir("File"),Mb=Ir("Blob"),Ob=Ir("FileList");function jp(t){return Bp.call(t)==="[object Function]"}function Db(t){return zv(t)&&jp(t.pipe)}function Nb(t){var e="[object FormData]";return t&&(typeof FormData=="function"&&t instanceof FormData||Bp.call(t)===e||jp(t.toString)&&t.toString()===e)}var Lb=Ir("URLSearchParams");function xb(t){return t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function Vb(){var t;return typeof navigator!="undefined"&&((t=navigator.product)==="ReactNative"||t==="NativeScript"||t==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Wp(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),xl(t))for(var n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.call(null,t[r],r,t)}function hh(){var t={};function e(r,s){hd(t[s])&&hd(r)?t[s]=hh(t[s],r):hd(r)?t[s]=hh({},r):xl(r)?t[s]=r.slice():t[s]=r}for(var n=0,i=arguments.length;n<i;n++)Wp(arguments[n],e);return t}function Ub(t,e,n){return Wp(e,function(i,r){n&&typeof i=="function"?t[r]=wb(i,n):t[r]=i}),t}function Bb(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}function Fb(t,e,n,i){t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,n&&Object.assign(t.prototype,n)}function jb(t,e,n,i){var r,s,a,c={};if(e=e||{},t==null)return e;do{for(r=Object.getOwnPropertyNames(t),s=r.length;s-- >0;)a=r[s],(!i||i(a,t,e))&&!c[a]&&(e[a]=t[a],c[a]=!0);t=n!==!1&&Object.getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e}function Wb(t,e,n){t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;var i=t.indexOf(e,n);return i!==-1&&i===n}function Hb(t){if(!t)return null;if(xl(t))return t;var e=t.length;if(!Kv(e))return null;for(var n=new Array(e);e-- >0;)n[e]=t[e];return n}var qb=function(t){return function(e){return t&&e instanceof t}}(typeof Uint8Array!="undefined"&&Object.getPrototypeOf(Uint8Array));function Gb(t,e){for(var n=t&&t[Symbol.iterator],i=n.call(t),r;(r=i.next())&&!r.done;){var s=r.value;e.call(t,s[0],s[1])}}function Jb(t,e){for(var n,i=[];(n=t.exec(e))!==null;)i.push(n);return i}var $b=Ir("HTMLFormElement"),Kb=function(t){return function(e,n){return t.call(e,n)}}(Object.prototype.hasOwnProperty),gt={isArray:xl,isArrayBuffer:$v,isBuffer:_b,isFormData:Nb,isArrayBufferView:Ib,isString:Cb,isNumber:Kv,isObject:zv,isPlainObject:hd,isEmptyObject:Rb,isUndefined:uh,isDate:Pb,isFile:Ab,isBlob:Mb,isFunction:jp,isStream:Db,isURLSearchParams:Lb,isStandardBrowserEnv:Vb,forEach:Wp,merge:hh,extend:Ub,trim:xb,stripBOM:Bb,inherits:Fb,toFlatObject:jb,kindOf:Fp,kindOfTest:Ir,endsWith:Wb,toArray:Hb,isTypedArray:qb,isFileList:Ob,forEachEntry:Gb,matchAll:Jb,isHTMLForm:$b,hasOwnProperty:Kb},vt={},Vl={};Vl.byteLength=Qb;Vl.toByteArray=Zb;Vl.fromByteArray=nk;var ai=[],_n=[],zb=typeof Uint8Array!="undefined"?Uint8Array:Array,hu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ms=0,Yb=hu.length;Ms<Yb;++Ms)ai[Ms]=hu[Ms],_n[hu.charCodeAt(Ms)]=Ms;_n["-".charCodeAt(0)]=62;_n["_".charCodeAt(0)]=63;function Yv(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var i=n===e?0:4-n%4;return[n,i]}function Qb(t){var e=Yv(t),n=e[0],i=e[1];return(n+i)*3/4-i}function Xb(t,e,n){return(e+n)*3/4-n}function Zb(t){var e,n=Yv(t),i=n[0],r=n[1],s=new zb(Xb(t,i,r)),a=0,c=r>0?i-4:i,d;for(d=0;d<c;d+=4)e=_n[t.charCodeAt(d)]<<18|_n[t.charCodeAt(d+1)]<<12|_n[t.charCodeAt(d+2)]<<6|_n[t.charCodeAt(d+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=e&255;return r===2&&(e=_n[t.charCodeAt(d)]<<2|_n[t.charCodeAt(d+1)]>>4,s[a++]=e&255),r===1&&(e=_n[t.charCodeAt(d)]<<10|_n[t.charCodeAt(d+1)]<<4|_n[t.charCodeAt(d+2)]>>2,s[a++]=e>>8&255,s[a++]=e&255),s}function ek(t){return ai[t>>18&63]+ai[t>>12&63]+ai[t>>6&63]+ai[t&63]}function tk(t,e,n){for(var i,r=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),r.push(ek(i));return r.join("")}function nk(t){for(var e,n=t.length,i=n%3,r=[],s=16383,a=0,c=n-i;a<c;a+=s)r.push(tk(t,a,a+s>c?c:a+s));return i===1?(e=t[n-1],r.push(ai[e>>2]+ai[e<<4&63]+"==")):i===2&&(e=(t[n-2]<<8)+t[n-1],r.push(ai[e>>10]+ai[e>>4&63]+ai[e<<2&63]+"=")),r.join("")}var Hp={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Hp.read=function(t,e,n,i,r){var s,a,c=r*8-i-1,d=(1<<c)-1,h=d>>1,u=-7,g=n?r-1:0,E=n?-1:1,b=t[e+g];for(g+=E,s=b&(1<<-u)-1,b>>=-u,u+=c;u>0;s=s*256+t[e+g],g+=E,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;u>0;a=a*256+t[e+g],g+=E,u-=8);if(s===0)s=1-h;else{if(s===d)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-h}return(b?-1:1)*a*Math.pow(2,s-i)};Hp.write=function(t,e,n,i,r,s){var a,c,d,h=s*8-r-1,u=(1<<h)-1,g=u>>1,E=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=i?0:s-1,k=i?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-a))<1&&(a--,d*=2),a+g>=1?e+=E/d:e+=E*Math.pow(2,1-g),e*d>=2&&(a++,d/=2),a+g>=u?(c=0,a=u):a+g>=1?(c=(e*d-1)*Math.pow(2,r),a=a+g):(c=e*Math.pow(2,g-1)*Math.pow(2,r),a=0));r>=8;t[n+b]=c&255,b+=k,c/=256,r-=8);for(a=a<<r|c,h+=r;h>0;t[n+b]=a&255,b+=k,a/=256,h-=8);t[n+b-k]|=A*128};/*!
13
13
  * The buffer module from node.js, for the browser.
14
14
  *
15
15
  * @author Feross Aboukhadijeh <https://feross.org>
16
16
  * @license MIT
17
- */(function(t){const e=Vl,n=Hp,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=$,t.INSPECT_MAX_BYTES=50;const r=2147483647;t.kMaxLength=r;const{Uint8Array:s,ArrayBuffer:a,SharedArrayBuffer:c}=globalThis;u.TYPED_ARRAY_SUPPORT=d(),!u.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{const l=new s(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,s.prototype),Object.setPrototypeOf(l,f),l.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function h(l){if(l>r)throw new RangeError('The value "'+l+'" is invalid for option "size"');const f=new s(l);return Object.setPrototypeOf(f,u.prototype),f}function u(l,f,v){if(typeof l=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return k(l)}return g(l,f,v)}u.poolSize=8192;function g(l,f,v){if(typeof l=="string")return A(l,f);if(a.isView(l))return B(l);if(l==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l);if(Qn(l,a)||l&&Qn(l.buffer,a)||typeof c!="undefined"&&(Qn(l,c)||l&&Qn(l.buffer,c)))return K(l,f,v);if(typeof l=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const C=l.valueOf&&l.valueOf();if(C!=null&&C!==l)return u.from(C,f,v);const R=X(l);if(R)return R;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof l[Symbol.toPrimitive]=="function")return u.from(l[Symbol.toPrimitive]("string"),f,v);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l)}u.from=function(l,f,v){return g(l,f,v)},Object.setPrototypeOf(u.prototype,s.prototype),Object.setPrototypeOf(u,s);function E(l){if(typeof l!="number")throw new TypeError('"size" argument must be of type number');if(l<0)throw new RangeError('The value "'+l+'" is invalid for option "size"')}function b(l,f,v){return E(l),l<=0?h(l):f!==void 0?typeof v=="string"?h(l).fill(f,v):h(l).fill(f):h(l)}u.alloc=function(l,f,v){return b(l,f,v)};function k(l){return E(l),h(l<0?0:O(l)|0)}u.allocUnsafe=function(l){return k(l)},u.allocUnsafeSlow=function(l){return k(l)};function A(l,f){if((typeof f!="string"||f==="")&&(f="utf8"),!u.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const v=me(l,f)|0;let C=h(v);const R=C.write(l,f);return R!==v&&(C=C.slice(0,R)),C}function M(l){const f=l.length<0?0:O(l.length)|0,v=h(f);for(let C=0;C<f;C+=1)v[C]=l[C]&255;return v}function B(l){if(Qn(l,s)){const f=new s(l);return K(f.buffer,f.byteOffset,f.byteLength)}return M(l)}function K(l,f,v){if(f<0||l.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(l.byteLength<f+(v||0))throw new RangeError('"length" is outside of buffer bounds');let C;return f===void 0&&v===void 0?C=new s(l):v===void 0?C=new s(l,f):C=new s(l,f,v),Object.setPrototypeOf(C,u.prototype),C}function X(l){if(u.isBuffer(l)){const f=O(l.length)|0,v=h(f);return v.length===0||l.copy(v,0,0,f),v}if(l.length!==void 0)return typeof l.length!="number"||ou(l.length)?h(0):M(l);if(l.type==="Buffer"&&Array.isArray(l.data))return M(l.data)}function O(l){if(l>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return l|0}function $(l){return+l!=l&&(l=0),u.alloc(+l)}u.isBuffer=function(l){return l!=null&&l._isBuffer===!0&&l!==u.prototype},u.compare=function(l,f){if(Qn(l,s)&&(l=u.from(l,l.offset,l.byteLength)),Qn(f,s)&&(f=u.from(f,f.offset,f.byteLength)),!u.isBuffer(l)||!u.isBuffer(f))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(l===f)return 0;let v=l.length,C=f.length;for(let R=0,U=Math.min(v,C);R<U;++R)if(l[R]!==f[R]){v=l[R],C=f[R];break}return v<C?-1:C<v?1:0},u.isEncoding=function(l){switch(String(l).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(l,f){if(!Array.isArray(l))throw new TypeError('"list" argument must be an Array of Buffers');if(l.length===0)return u.alloc(0);let v;if(f===void 0)for(f=0,v=0;v<l.length;++v)f+=l[v].length;const C=u.allocUnsafe(f);let R=0;for(v=0;v<l.length;++v){let U=l[v];if(Qn(U,s))R+U.length>C.length?(u.isBuffer(U)||(U=u.from(U)),U.copy(C,R)):s.prototype.set.call(C,U,R);else if(u.isBuffer(U))U.copy(C,R);else throw new TypeError('"list" argument must be an Array of Buffers');R+=U.length}return C};function me(l,f){if(u.isBuffer(l))return l.length;if(a.isView(l)||Qn(l,a))return l.byteLength;if(typeof l!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof l);const v=l.length,C=arguments.length>2&&arguments[2]===!0;if(!C&&v===0)return 0;let R=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return v;case"utf8":case"utf-8":return au(l).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v*2;case"hex":return v>>>1;case"base64":return bm(l).length;default:if(R)return C?-1:au(l).length;f=(""+f).toLowerCase(),R=!0}}u.byteLength=me;function Ie(l,f,v){let C=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((v===void 0||v>this.length)&&(v=this.length),v<=0)||(v>>>=0,f>>>=0,v<=f))return"";for(l||(l="utf8");;)switch(l){case"hex":return Mr(this,f,v);case"utf8":case"utf-8":return q(this,f,v);case"ascii":return Pn(this,f,v);case"latin1":case"binary":return Ar(this,f,v);case"base64":return Xe(this,f,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Or(this,f,v);default:if(C)throw new TypeError("Unknown encoding: "+l);l=(l+"").toLowerCase(),C=!0}}u.prototype._isBuffer=!0;function fe(l,f,v){const C=l[f];l[f]=l[v],l[v]=C}u.prototype.swap16=function(){const l=this.length;if(l%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let f=0;f<l;f+=2)fe(this,f,f+1);return this},u.prototype.swap32=function(){const l=this.length;if(l%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let f=0;f<l;f+=4)fe(this,f,f+3),fe(this,f+1,f+2);return this},u.prototype.swap64=function(){const l=this.length;if(l%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let f=0;f<l;f+=8)fe(this,f,f+7),fe(this,f+1,f+6),fe(this,f+2,f+5),fe(this,f+3,f+4);return this},u.prototype.toString=function(){const l=this.length;return l===0?"":arguments.length===0?q(this,0,l):Ie.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(l){if(!u.isBuffer(l))throw new TypeError("Argument must be a Buffer");return this===l?!0:u.compare(this,l)===0},u.prototype.inspect=function(){let l="";const f=t.INSPECT_MAX_BYTES;return l=this.toString("hex",0,f).replace(/(.{2})/g,"$1 ").trim(),this.length>f&&(l+=" ... "),"<Buffer "+l+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(l,f,v,C,R){if(Qn(l,s)&&(l=u.from(l,l.offset,l.byteLength)),!u.isBuffer(l))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof l);if(f===void 0&&(f=0),v===void 0&&(v=l?l.length:0),C===void 0&&(C=0),R===void 0&&(R=this.length),f<0||v>l.length||C<0||R>this.length)throw new RangeError("out of range index");if(C>=R&&f>=v)return 0;if(C>=R)return-1;if(f>=v)return 1;if(f>>>=0,v>>>=0,C>>>=0,R>>>=0,this===l)return 0;let U=R-C,J=v-f;const Pe=Math.min(U,J),_t=this.slice(C,R),je=l.slice(f,v);for(let Ae=0;Ae<Pe;++Ae)if(_t[Ae]!==je[Ae]){U=_t[Ae],J=je[Ae];break}return U<J?-1:J<U?1:0};function Je(l,f,v,C,R){if(l.length===0)return-1;if(typeof v=="string"?(C=v,v=0):v>2147483647?v=2147483647:v<-2147483648&&(v=-2147483648),v=+v,ou(v)&&(v=R?0:l.length-1),v<0&&(v=l.length+v),v>=l.length){if(R)return-1;v=l.length-1}else if(v<0)if(R)v=0;else return-1;if(typeof f=="string"&&(f=u.from(f,C)),u.isBuffer(f))return f.length===0?-1:ht(l,f,v,C,R);if(typeof f=="number")return f=f&255,typeof s.prototype.indexOf=="function"?R?s.prototype.indexOf.call(l,f,v):s.prototype.lastIndexOf.call(l,f,v):ht(l,[f],v,C,R);throw new TypeError("val must be string, number or Buffer")}function ht(l,f,v,C,R){let U=1,J=l.length,Pe=f.length;if(C!==void 0&&(C=String(C).toLowerCase(),C==="ucs2"||C==="ucs-2"||C==="utf16le"||C==="utf-16le")){if(l.length<2||f.length<2)return-1;U=2,J/=2,Pe/=2,v/=2}function _t(Ae,ot){return U===1?Ae[ot]:Ae.readUInt16BE(ot*U)}let je;if(R){let Ae=-1;for(je=v;je<J;je++)if(_t(l,je)===_t(f,Ae===-1?0:je-Ae)){if(Ae===-1&&(Ae=je),je-Ae+1===Pe)return Ae*U}else Ae!==-1&&(je-=je-Ae),Ae=-1}else for(v+Pe>J&&(v=J-Pe),je=v;je>=0;je--){let Ae=!0;for(let ot=0;ot<Pe;ot++)if(_t(l,je+ot)!==_t(f,ot)){Ae=!1;break}if(Ae)return je}return-1}u.prototype.includes=function(l,f,v){return this.indexOf(l,f,v)!==-1},u.prototype.indexOf=function(l,f,v){return Je(this,l,f,v,!0)},u.prototype.lastIndexOf=function(l,f,v){return Je(this,l,f,v,!1)};function V(l,f,v,C){v=Number(v)||0;const R=l.length-v;C?(C=Number(C),C>R&&(C=R)):C=R;const U=f.length;C>U/2&&(C=U/2);let J;for(J=0;J<C;++J){const Pe=parseInt(f.substr(J*2,2),16);if(ou(Pe))return J;l[v+J]=Pe}return J}function I(l,f,v,C){return Rc(au(f,l.length-v),l,v,C)}function P(l,f,v,C){return Rc(PS(f),l,v,C)}function z(l,f,v,C){return Rc(bm(f),l,v,C)}function ye(l,f,v,C){return Rc(AS(f,l.length-v),l,v,C)}u.prototype.write=function(l,f,v,C){if(f===void 0)C="utf8",v=this.length,f=0;else if(v===void 0&&typeof f=="string")C=f,v=this.length,f=0;else if(isFinite(f))f=f>>>0,isFinite(v)?(v=v>>>0,C===void 0&&(C="utf8")):(C=v,v=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const R=this.length-f;if((v===void 0||v>R)&&(v=R),l.length>0&&(v<0||f<0)||f>this.length)throw new RangeError("Attempt to write outside buffer bounds");C||(C="utf8");let U=!1;for(;;)switch(C){case"hex":return V(this,l,f,v);case"utf8":case"utf-8":return I(this,l,f,v);case"ascii":case"latin1":case"binary":return P(this,l,f,v);case"base64":return z(this,l,f,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ye(this,l,f,v);default:if(U)throw new TypeError("Unknown encoding: "+C);C=(""+C).toLowerCase(),U=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(l,f,v){return f===0&&v===l.length?e.fromByteArray(l):e.fromByteArray(l.slice(f,v))}function q(l,f,v){v=Math.min(l.length,v);const C=[];let R=f;for(;R<v;){const U=l[R];let J=null,Pe=U>239?4:U>223?3:U>191?2:1;if(R+Pe<=v){let _t,je,Ae,ot;switch(Pe){case 1:U<128&&(J=U);break;case 2:_t=l[R+1],(_t&192)===128&&(ot=(U&31)<<6|_t&63,ot>127&&(J=ot));break;case 3:_t=l[R+1],je=l[R+2],(_t&192)===128&&(je&192)===128&&(ot=(U&15)<<12|(_t&63)<<6|je&63,ot>2047&&(ot<55296||ot>57343)&&(J=ot));break;case 4:_t=l[R+1],je=l[R+2],Ae=l[R+3],(_t&192)===128&&(je&192)===128&&(Ae&192)===128&&(ot=(U&15)<<18|(_t&63)<<12|(je&63)<<6|Ae&63,ot>65535&&ot<1114112&&(J=ot))}}J===null?(J=65533,Pe=1):J>65535&&(J-=65536,C.push(J>>>10&1023|55296),J=56320|J&1023),C.push(J),R+=Pe}return Ze(C)}const N=4096;function Ze(l){const f=l.length;if(f<=N)return String.fromCharCode.apply(String,l);let v="",C=0;for(;C<f;)v+=String.fromCharCode.apply(String,l.slice(C,C+=N));return v}function Pn(l,f,v){let C="";v=Math.min(l.length,v);for(let R=f;R<v;++R)C+=String.fromCharCode(l[R]&127);return C}function Ar(l,f,v){let C="";v=Math.min(l.length,v);for(let R=f;R<v;++R)C+=String.fromCharCode(l[R]);return C}function Mr(l,f,v){const C=l.length;(!f||f<0)&&(f=0),(!v||v<0||v>C)&&(v=C);let R="";for(let U=f;U<v;++U)R+=MS[l[U]];return R}function Or(l,f,v){const C=l.slice(f,v);let R="";for(let U=0;U<C.length-1;U+=2)R+=String.fromCharCode(C[U]+C[U+1]*256);return R}u.prototype.slice=function(l,f){const v=this.length;l=~~l,f=f===void 0?v:~~f,l<0?(l+=v,l<0&&(l=0)):l>v&&(l=v),f<0?(f+=v,f<0&&(f=0)):f>v&&(f=v),f<l&&(f=l);const C=this.subarray(l,f);return Object.setPrototypeOf(C,u.prototype),C};function Fe(l,f,v){if(l%1!==0||l<0)throw new RangeError("offset is not uint");if(l+f>v)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l],R=1,U=0;for(;++U<f&&(R*=256);)C+=this[l+U]*R;return C},u.prototype.readUintBE=u.prototype.readUIntBE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l+--f],R=1;for(;f>0&&(R*=256);)C+=this[l+--f]*R;return C},u.prototype.readUint8=u.prototype.readUInt8=function(l,f){return l=l>>>0,f||Fe(l,1,this.length),this[l]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(l,f){return l=l>>>0,f||Fe(l,2,this.length),this[l]|this[l+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(l,f){return l=l>>>0,f||Fe(l,2,this.length),this[l]<<8|this[l+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),(this[l]|this[l+1]<<8|this[l+2]<<16)+this[l+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]*16777216+(this[l+1]<<16|this[l+2]<<8|this[l+3])},u.prototype.readBigUInt64LE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=f+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+this[++l]*Oe(2,24),R=this[++l]+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+v*Oe(2,24);return BigInt(C)+(BigInt(R)<<BigInt(32))}),u.prototype.readBigUInt64BE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=f*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+this[++l],R=this[++l]*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+v;return(BigInt(C)<<BigInt(32))+BigInt(R)}),u.prototype.readIntLE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l],R=1,U=0;for(;++U<f&&(R*=256);)C+=this[l+U]*R;return R*=128,C>=R&&(C-=Math.pow(2,8*f)),C},u.prototype.readIntBE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=f,R=1,U=this[l+--C];for(;C>0&&(R*=256);)U+=this[l+--C]*R;return R*=128,U>=R&&(U-=Math.pow(2,8*f)),U},u.prototype.readInt8=function(l,f){return l=l>>>0,f||Fe(l,1,this.length),this[l]&128?(255-this[l]+1)*-1:this[l]},u.prototype.readInt16LE=function(l,f){l=l>>>0,f||Fe(l,2,this.length);const v=this[l]|this[l+1]<<8;return v&32768?v|4294901760:v},u.prototype.readInt16BE=function(l,f){l=l>>>0,f||Fe(l,2,this.length);const v=this[l+1]|this[l]<<8;return v&32768?v|4294901760:v},u.prototype.readInt32LE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]|this[l+1]<<8|this[l+2]<<16|this[l+3]<<24},u.prototype.readInt32BE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]<<24|this[l+1]<<16|this[l+2]<<8|this[l+3]},u.prototype.readBigInt64LE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=this[l+4]+this[l+5]*Oe(2,8)+this[l+6]*Oe(2,16)+(v<<24);return(BigInt(C)<<BigInt(32))+BigInt(f+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+this[++l]*Oe(2,24))}),u.prototype.readBigInt64BE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=(f<<24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+this[++l];return(BigInt(C)<<BigInt(32))+BigInt(this[++l]*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+v)}),u.prototype.readFloatLE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),n.read(this,l,!0,23,4)},u.prototype.readFloatBE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),n.read(this,l,!1,23,4)},u.prototype.readDoubleLE=function(l,f){return l=l>>>0,f||Fe(l,8,this.length),n.read(this,l,!0,52,8)},u.prototype.readDoubleBE=function(l,f){return l=l>>>0,f||Fe(l,8,this.length),n.read(this,l,!1,52,8)};function at(l,f,v,C,R,U){if(!u.isBuffer(l))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>R||f<U)throw new RangeError('"value" argument is out of bounds');if(v+C>l.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(l,f,v,C){if(l=+l,f=f>>>0,v=v>>>0,!C){const J=Math.pow(2,8*v)-1;at(this,l,f,v,J,0)}let R=1,U=0;for(this[f]=l&255;++U<v&&(R*=256);)this[f+U]=l/R&255;return f+v},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(l,f,v,C){if(l=+l,f=f>>>0,v=v>>>0,!C){const J=Math.pow(2,8*v)-1;at(this,l,f,v,J,0)}let R=v-1,U=1;for(this[f+R]=l&255;--R>=0&&(U*=256);)this[f+R]=l/U&255;return f+v},u.prototype.writeUint8=u.prototype.writeUInt8=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,1,255,0),this[f]=l&255,f+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,65535,0),this[f]=l&255,this[f+1]=l>>>8,f+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,65535,0),this[f]=l>>>8,this[f+1]=l&255,f+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,4294967295,0),this[f+3]=l>>>24,this[f+2]=l>>>16,this[f+1]=l>>>8,this[f]=l&255,f+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,4294967295,0),this[f]=l>>>24,this[f+1]=l>>>16,this[f+2]=l>>>8,this[f+3]=l&255,f+4};function Li(l,f,v,C,R){ji(f,C,R,l,v,7);let U=Number(f&BigInt(4294967295));l[v++]=U,U=U>>8,l[v++]=U,U=U>>8,l[v++]=U,U=U>>8,l[v++]=U;let J=Number(f>>BigInt(32)&BigInt(4294967295));return l[v++]=J,J=J>>8,l[v++]=J,J=J>>8,l[v++]=J,J=J>>8,l[v++]=J,v}function xi(l,f,v,C,R){ji(f,C,R,l,v,7);let U=Number(f&BigInt(4294967295));l[v+7]=U,U=U>>8,l[v+6]=U,U=U>>8,l[v+5]=U,U=U>>8,l[v+4]=U;let J=Number(f>>BigInt(32)&BigInt(4294967295));return l[v+3]=J,J=J>>8,l[v+2]=J,J=J>>8,l[v+1]=J,J=J>>8,l[v]=J,v+8}u.prototype.writeBigUInt64LE=Wi(function(l,f=0){return Li(this,l,f,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Wi(function(l,f=0){return xi(this,l,f,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(l,f,v,C){if(l=+l,f=f>>>0,!C){const Pe=Math.pow(2,8*v-1);at(this,l,f,v,Pe-1,-Pe)}let R=0,U=1,J=0;for(this[f]=l&255;++R<v&&(U*=256);)l<0&&J===0&&this[f+R-1]!==0&&(J=1),this[f+R]=(l/U>>0)-J&255;return f+v},u.prototype.writeIntBE=function(l,f,v,C){if(l=+l,f=f>>>0,!C){const Pe=Math.pow(2,8*v-1);at(this,l,f,v,Pe-1,-Pe)}let R=v-1,U=1,J=0;for(this[f+R]=l&255;--R>=0&&(U*=256);)l<0&&J===0&&this[f+R+1]!==0&&(J=1),this[f+R]=(l/U>>0)-J&255;return f+v},u.prototype.writeInt8=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,1,127,-128),l<0&&(l=255+l+1),this[f]=l&255,f+1},u.prototype.writeInt16LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,32767,-32768),this[f]=l&255,this[f+1]=l>>>8,f+2},u.prototype.writeInt16BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,32767,-32768),this[f]=l>>>8,this[f+1]=l&255,f+2},u.prototype.writeInt32LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,2147483647,-2147483648),this[f]=l&255,this[f+1]=l>>>8,this[f+2]=l>>>16,this[f+3]=l>>>24,f+4},u.prototype.writeInt32BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,2147483647,-2147483648),l<0&&(l=4294967295+l+1),this[f]=l>>>24,this[f+1]=l>>>16,this[f+2]=l>>>8,this[f+3]=l&255,f+4},u.prototype.writeBigInt64LE=Wi(function(l,f=0){return Li(this,l,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Wi(function(l,f=0){return xi(this,l,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vi(l,f,v,C,R,U){if(v+C>l.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("Index out of range")}function Ui(l,f,v,C,R){return f=+f,v=v>>>0,R||Vi(l,f,v,4),n.write(l,f,v,C,23,4),v+4}u.prototype.writeFloatLE=function(l,f,v){return Ui(this,l,f,!0,v)},u.prototype.writeFloatBE=function(l,f,v){return Ui(this,l,f,!1,v)};function Bi(l,f,v,C,R){return f=+f,v=v>>>0,R||Vi(l,f,v,8),n.write(l,f,v,C,52,8),v+8}u.prototype.writeDoubleLE=function(l,f,v){return Bi(this,l,f,!0,v)},u.prototype.writeDoubleBE=function(l,f,v){return Bi(this,l,f,!1,v)},u.prototype.copy=function(l,f,v,C){if(!u.isBuffer(l))throw new TypeError("argument should be a Buffer");if(v||(v=0),!C&&C!==0&&(C=this.length),f>=l.length&&(f=l.length),f||(f=0),C>0&&C<v&&(C=v),C===v||l.length===0||this.length===0)return 0;if(f<0)throw new RangeError("targetStart out of bounds");if(v<0||v>=this.length)throw new RangeError("Index out of range");if(C<0)throw new RangeError("sourceEnd out of bounds");C>this.length&&(C=this.length),l.length-f<C-v&&(C=l.length-f+v);const R=C-v;return this===l&&typeof s.prototype.copyWithin=="function"?this.copyWithin(f,v,C):s.prototype.set.call(l,this.subarray(v,C),f),R},u.prototype.fill=function(l,f,v,C){if(typeof l=="string"){if(typeof f=="string"?(C=f,f=0,v=this.length):typeof v=="string"&&(C=v,v=this.length),C!==void 0&&typeof C!="string")throw new TypeError("encoding must be a string");if(typeof C=="string"&&!u.isEncoding(C))throw new TypeError("Unknown encoding: "+C);if(l.length===1){const U=l.charCodeAt(0);(C==="utf8"&&U<128||C==="latin1")&&(l=U)}}else typeof l=="number"?l=l&255:typeof l=="boolean"&&(l=Number(l));if(f<0||this.length<f||this.length<v)throw new RangeError("Out of range index");if(v<=f)return this;f=f>>>0,v=v===void 0?this.length:v>>>0,l||(l=0);let R;if(typeof l=="number")for(R=f;R<v;++R)this[R]=l;else{const U=u.isBuffer(l)?l:u.from(l,C),J=U.length;if(J===0)throw new TypeError('The value "'+l+'" is invalid for argument "value"');for(R=0;R<v-f;++R)this[R+f]=U[R%J]}return this};const Sn={};function pi(l,f,v){Sn[l]=class extends v{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${l}]`,this.stack,delete this.name}get code(){return l}set code(C){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:C,writable:!0})}toString(){return`${this.name} [${l}]: ${this.message}`}}}pi("ERR_BUFFER_OUT_OF_BOUNDS",function(l){return l?`${l} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),pi("ERR_INVALID_ARG_TYPE",function(l,f){return`The "${l}" argument must be of type number. Received type ${typeof f}`},TypeError),pi("ERR_OUT_OF_RANGE",function(l,f,v){let C=`The value of "${l}" is out of range.`,R=v;return Number.isInteger(v)&&Math.abs(v)>Oe(2,32)?R=Fi(String(v)):typeof v=="bigint"&&(R=String(v),(v>Oe(BigInt(2),BigInt(32))||v<-Oe(BigInt(2),BigInt(32)))&&(R=Fi(R)),R+="n"),C+=` It must be ${f}. Received ${R}`,C},RangeError);function Fi(l){let f="",v=l.length;const C=l[0]==="-"?1:0;for(;v>=C+4;v-=3)f=`_${l.slice(v-3,v)}${f}`;return`${l.slice(0,v)}${f}`}function Dr(l,f,v){ge(f,"offset"),(l[f]===void 0||l[f+v]===void 0)&&pe(f,l.length-(v+1))}function ji(l,f,v,C,R,U){if(l>v||l<f){const J=typeof f=="bigint"?"n":"";let Pe;throw U>3?f===0||f===BigInt(0)?Pe=`>= 0${J} and < 2${J} ** ${(U+1)*8}${J}`:Pe=`>= -(2${J} ** ${(U+1)*8-1}${J}) and < 2 ** ${(U+1)*8-1}${J}`:Pe=`>= ${f}${J} and <= ${v}${J}`,new Sn.ERR_OUT_OF_RANGE("value",Pe,l)}Dr(C,R,U)}function ge(l,f){if(typeof l!="number")throw new Sn.ERR_INVALID_ARG_TYPE(f,"number",l)}function pe(l,f,v){throw Math.floor(l)!==l?(ge(l,v),new Sn.ERR_OUT_OF_RANGE(v||"offset","an integer",l)):f<0?new Sn.ERR_BUFFER_OUT_OF_BOUNDS:new Sn.ERR_OUT_OF_RANGE(v||"offset",`>= ${v?1:0} and <= ${f}`,l)}const Da=/[^+/0-9A-Za-z-_]/g;function RS(l){if(l=l.split("=")[0],l=l.trim().replace(Da,""),l.length<2)return"";for(;l.length%4!==0;)l=l+"=";return l}function au(l,f){f=f||1/0;let v;const C=l.length;let R=null;const U=[];for(let J=0;J<C;++J){if(v=l.charCodeAt(J),v>55295&&v<57344){if(!R){if(v>56319){(f-=3)>-1&&U.push(239,191,189);continue}else if(J+1===C){(f-=3)>-1&&U.push(239,191,189);continue}R=v;continue}if(v<56320){(f-=3)>-1&&U.push(239,191,189),R=v;continue}v=(R-55296<<10|v-56320)+65536}else R&&(f-=3)>-1&&U.push(239,191,189);if(R=null,v<128){if((f-=1)<0)break;U.push(v)}else if(v<2048){if((f-=2)<0)break;U.push(v>>6|192,v&63|128)}else if(v<65536){if((f-=3)<0)break;U.push(v>>12|224,v>>6&63|128,v&63|128)}else if(v<1114112){if((f-=4)<0)break;U.push(v>>18|240,v>>12&63|128,v>>6&63|128,v&63|128)}else throw new Error("Invalid code point")}return U}function PS(l){const f=[];for(let v=0;v<l.length;++v)f.push(l.charCodeAt(v)&255);return f}function AS(l,f){let v,C,R;const U=[];for(let J=0;J<l.length&&!((f-=2)<0);++J)v=l.charCodeAt(J),C=v>>8,R=v%256,U.push(R),U.push(C);return U}function bm(l){return e.toByteArray(RS(l))}function Rc(l,f,v,C){let R;for(R=0;R<C&&!(R+v>=f.length||R>=l.length);++R)f[R+v]=l[R];return R}function Qn(l,f){return l instanceof f||l!=null&&l.constructor!=null&&l.constructor.name!=null&&l.constructor.name===f.name}function ou(l){return l!==l}const MS=function(){const l="0123456789abcdef",f=new Array(256);for(let v=0;v<16;++v){const C=v*16;for(let R=0;R<16;++R)f[C+R]=l[v]+l[R]}return f}();function Wi(l){return typeof BigInt=="undefined"?OS:l}function OS(){throw new Error("BigInt not supported")}})(vt);const rk=vt.Buffer;vt.Blob;vt.BlobOptions;vt.Buffer;vt.File;vt.FileOptions;vt.INSPECT_MAX_BYTES;vt.SlowBuffer;vt.TranscodeEncoding;vt.atob;vt.btoa;vt.constants;vt.isAscii;vt.isUtf8;vt.kMaxLength;vt.kStringMaxLength;vt.resolveObjectURL;vt.transcode;var Qv=gt;function Ta(t,e,n,i,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),i&&(this.request=i),r&&(this.response=r)}Qv.inherits(Ta,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Xv=Ta.prototype,Zv={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(t){Zv[t]={value:t}});Object.defineProperties(Ta,Zv);Object.defineProperty(Xv,"isAxiosError",{value:!0});Ta.from=function(t,e,n,i,r,s){var a=Object.create(Xv);return Qv.toFlatObject(t,a,function(c){return c!==Error.prototype}),Ta.call(a,t.message,e,n,i,r),a.cause=t,a.name=t.name,s&&Object.assign(a,s),a};var bs=Ta,ph={},sk={get exports(){return ph},set exports(t){ph=t}},ak=typeof self=="object"?self.FormData:window.FormData;(function(t){t.exports=ak})(sk);var Le=gt,ok=bs,ck=ph;function mh(t){return Le.isPlainObject(t)||Le.isArray(t)}function ey(t){return Le.endsWith(t,"[]")?t.slice(0,-2):t}function Wm(t,e,n){return t?t.concat(e).map(function(i,r){return i=ey(i),!n&&r?"["+i+"]":i}).join(n?".":""):e}function dk(t){return Le.isArray(t)&&!t.some(mh)}var lk=Le.toFlatObject(Le,{},null,function(t){return/^is[A-Z]/.test(t)});function uk(t){return t&&Le.isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator]}function hk(t,e,n){if(!Le.isObject(t))throw new TypeError("target must be an object");e=e||new(ck||FormData),n=Le.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,A){return!Le.isUndefined(A[k])});var i=n.metaTokens,r=n.visitor||u,s=n.dots,a=n.indexes,c=n.Blob||typeof Blob!="undefined"&&Blob,d=c&&uk(e);if(!Le.isFunction(r))throw new TypeError("visitor must be a function");function h(k){if(k===null)return"";if(Le.isDate(k))return k.toISOString();if(!d&&Le.isBlob(k))throw new ok("Blob is not supported. Use a Buffer instead.");return Le.isArrayBuffer(k)||Le.isTypedArray(k)?d&&typeof Blob=="function"?new Blob([k]):rk.from(k):k}function u(k,A,M){var B=k;if(k&&!M&&typeof k=="object"){if(Le.endsWith(A,"{}"))A=i?A:A.slice(0,-2),k=JSON.stringify(k);else if(Le.isArray(k)&&dk(k)||Le.isFileList(k)||Le.endsWith(A,"[]")&&(B=Le.toArray(k)))return A=ey(A),B.forEach(function(K,X){!Le.isUndefined(K)&&e.append(a===!0?Wm([A],X,s):a===null?A:A+"[]",h(K))}),!1}return mh(k)?!0:(e.append(Wm(M,A,s),h(k)),!1)}var g=[],E=Object.assign(lk,{defaultVisitor:u,convertValue:h,isVisitable:mh});function b(k,A){if(!Le.isUndefined(k)){if(g.indexOf(k)!==-1)throw Error("Circular reference detected in "+A.join("."));g.push(k),Le.forEach(k,function(M,B){var K=!Le.isUndefined(M)&&r.call(e,M,Le.isString(B)?B.trim():B,A,E);K===!0&&b(M,A?A.concat(B):[B])}),g.pop()}}if(!Le.isObject(t))throw new TypeError("data must be an object");return b(t),e}var Ul=hk,pk=Ul;function Hm(t){var e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'\(\)~]|%20|%00/g,function(n){return e[n]})}function ty(t,e){this._pairs=[],t&&pk(t,this,e)}var ny=ty.prototype;ny.append=function(t,e){this._pairs.push([t,e])};ny.toString=function(t){var e=t?function(n){return t.call(this,n,Hm)}:Hm;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};var iy=ty,mk=gt,fk=iy;function gk(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ry=function(t,e,n){if(!e)return t;var i=t.indexOf("#");i!==-1&&(t=t.slice(0,i));var r=n&&n.encode||gk,s=n&&n.serialize,a;return s?a=s(e,n):a=mk.isURLSearchParams(e)?e.toString():new fk(e,n).toString(r),a&&(t+=(t.indexOf("?")===-1?"?":"&")+a),t},vk=gt;function gc(){this.handlers=[]}gc.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};gc.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)};gc.prototype.clear=function(){this.handlers&&(this.handlers=[])};gc.prototype.forEach=function(t){vk.forEach(this.handlers,function(e){e!==null&&t(e)})};var yk=gc,Ek=gt,sy=function(t,e){Ek.forEach(t,function(n,i){i!==e&&i.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[i])})},ay={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},lc={},Sk={get exports(){return lc},set exports(t){lc=t}},Tk=iy,bk=typeof URLSearchParams!="undefined"?URLSearchParams:Tk,kk=FormData,wk={isBrowser:!0,classes:{URLSearchParams:bk,FormData:kk,Blob},protocols:["http","https","file","blob","url","data"]};(function(t){t.exports=wk})(Sk);var _k=gt,Ik=Ul,qm=lc,Ck=function(t,e){return Ik(t,new qm.classes.URLSearchParams,Object.assign({visitor:function(n,i,r,s){return qm.isNode&&_k.isBuffer(n)?(this.append(i,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))},Qi=gt;function Rk(t){return Qi.matchAll(/\w+|\[(\w*)]/g,t).map(function(e){return e[0]==="[]"?"":e[1]||e[0]})}function Pk(t){var e={},n=Object.keys(t),i,r=n.length,s;for(i=0;i<r;i++)s=n[i],e[s]=t[s];return e}function Ak(t){function e(i,r,s,a){var c=i[a++],d=Number.isFinite(+c),h=a>=i.length;if(c=!c&&Qi.isArray(s)?s.length:c,h)return Qi.hasOwnProperty(s,c)?s[c]=[s[c],r]:s[c]=r,!d;(!s[c]||!Qi.isObject(s[c]))&&(s[c]=[]);var u=e(i,r,s[c],a);return u&&Qi.isArray(s[c])&&(s[c]=Pk(s[c])),!d}if(Qi.isFormData(t)&&Qi.isFunction(t.entries)){var n={};return Qi.forEachEntry(t,function(i,r){e(Rk(i),r,n,0)}),n}return null}var oy=Ak,pu,Gm;function Mk(){if(Gm)return pu;Gm=1;var t=bs;return pu=function(e,n,i){var r=i.config.validateStatus;!i.status||!r||r(i.status)?e(i):n(new t("Request failed with status code "+i.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))},pu}var mu,$m;function Ok(){if($m)return mu;$m=1;var t=gt;return mu=t.isStandardBrowserEnv()?function(){return{write:function(e,n,i,r,s,a){var c=[];c.push(e+"="+encodeURIComponent(n)),t.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),t.isString(r)&&c.push("path="+r),t.isString(s)&&c.push("domain="+s),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(e){var n=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),mu}var Dk=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},Nk=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Lk=Dk,xk=Nk,cy=function(t,e){return t&&!Lk(e)?xk(t,e):e},fu,Jm;function Vk(){if(Jm)return fu;Jm=1;var t=gt,e=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return fu=function(n){var i={},r,s,a;return n&&t.forEach(n.split(`
18
- `),function(c){if(a=c.indexOf(":"),r=t.trim(c.slice(0,a)).toLowerCase(),s=t.trim(c.slice(a+1)),r){if(i[r]&&e.indexOf(r)>=0)return;r==="set-cookie"?i[r]=(i[r]?i[r]:[]).concat([s]):i[r]=i[r]?i[r]+", "+s:s}}),i},fu}var gu,Km;function Uk(){if(Km)return gu;Km=1;var t=gt;return gu=t.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),i;function r(s){var a=s;return e&&(n.setAttribute("href",a),a=n.href),n.setAttribute("href",a),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=r(window.location.href),function(s){var a=t.isString(s)?r(s):s;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}(),gu}var vu,zm;function Bl(){if(zm)return vu;zm=1;var t=bs,e=gt;function n(i,r,s){t.call(this,i==null?"canceled":i,t.ERR_CANCELED,r,s),this.name="CanceledError"}return e.inherits(n,t,{__CANCEL__:!0}),vu=n,vu}var Ym,Qm;function Bk(){return Qm||(Qm=1,Ym=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}),Ym}var yu,Xm;function Fk(){if(Xm)return yu;Xm=1;var t=gt,e=Mk(),n=Ok(),i=ry,r=cy,s=Vk(),a=Uk(),c=ay,d=bs,h=Bl(),u=Bk(),g=lc;return yu=function(E){return new Promise(function(b,k){var A=E.data,M=E.headers,B=E.responseType,K=E.withXSRFToken,X;function O(){E.cancelToken&&E.cancelToken.unsubscribe(X),E.signal&&E.signal.removeEventListener("abort",X)}t.isFormData(A)&&t.isStandardBrowserEnv()&&delete M["Content-Type"];var $=new XMLHttpRequest;if(E.auth){var me=E.auth.username||"",Ie=E.auth.password?unescape(encodeURIComponent(E.auth.password)):"";M.Authorization="Basic "+btoa(me+":"+Ie)}var fe=r(E.baseURL,E.url);$.open(E.method.toUpperCase(),i(fe,E.params,E.paramsSerializer),!0),$.timeout=E.timeout;function Je(){if($){var I="getAllResponseHeaders"in $?s($.getAllResponseHeaders()):null,P=!B||B==="text"||B==="json"?$.responseText:$.response,z={data:P,status:$.status,statusText:$.statusText,headers:I,config:E,request:$};e(function(ye){b(ye),O()},function(ye){k(ye),O()},z),$=null}}if("onloadend"in $?$.onloadend=Je:$.onreadystatechange=function(){!$||$.readyState!==4||$.status===0&&!($.responseURL&&$.responseURL.indexOf("file:")===0)||setTimeout(Je)},$.onabort=function(){$&&(k(new d("Request aborted",d.ECONNABORTED,E,$)),$=null)},$.onerror=function(){k(new d("Network Error",d.ERR_NETWORK,E,$)),$=null},$.ontimeout=function(){var I=E.timeout?"timeout of "+E.timeout+"ms exceeded":"timeout exceeded",P=E.transitional||c;E.timeoutErrorMessage&&(I=E.timeoutErrorMessage),k(new d(I,P.clarifyTimeoutError?d.ETIMEDOUT:d.ECONNABORTED,E,$)),$=null},t.isStandardBrowserEnv()&&(K&&t.isFunction(K)&&(K=K(E)),K||K!==!1&&a(fe))){var ht=E.xsrfHeaderName&&E.xsrfCookieName&&n.read(E.xsrfCookieName);ht&&(M[E.xsrfHeaderName]=ht)}"setRequestHeader"in $&&t.forEach(M,function(I,P){typeof A=="undefined"&&P.toLowerCase()==="content-type"?delete M[P]:$.setRequestHeader(P,I)}),t.isUndefined(E.withCredentials)||($.withCredentials=!!E.withCredentials),B&&B!=="json"&&($.responseType=E.responseType),typeof E.onDownloadProgress=="function"&&$.addEventListener("progress",E.onDownloadProgress),typeof E.onUploadProgress=="function"&&$.upload&&$.upload.addEventListener("progress",E.onUploadProgress),(E.cancelToken||E.signal)&&(X=function(I){$&&(k(!I||I.type?new h(null,E,$):I),$.abort(),$=null)},E.cancelToken&&E.cancelToken.subscribe(X),E.signal&&(E.signal.aborted?X():E.signal.addEventListener("abort",X))),!A&&A!==!1&&A!==0&&A!==""&&(A=null);var V=u(fe);if(V&&g.protocols.indexOf(V)===-1){k(new d("Unsupported protocol "+V+":",d.ERR_BAD_REQUEST,E));return}$.send(A)})},yu}var ft=gt,Zm=sy,ef=bs,jk=ay,Wk=Ul,Hk=Ck,tf=lc,qk=oy,Gk={"Content-Type":"application/x-www-form-urlencoded"};function nf(t,e){!ft.isUndefined(t)&&ft.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function $k(){var t;return(typeof XMLHttpRequest!="undefined"||typeof ls!="undefined"&&Object.prototype.toString.call(ls)==="[object process]")&&(t=Fk()),t}function Jk(t,e,n){if(ft.isString(t))try{return(e||JSON.parse)(t),ft.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(n||JSON.stringify)(t)}var Fl={transitional:jk,adapter:$k(),transformRequest:[function(t,e){Zm(e,"Accept"),Zm(e,"Content-Type");var n=e&&e["Content-Type"]||"",i=n.indexOf("application/json")>-1,r=ft.isObject(t);r&&ft.isHTMLForm(t)&&(t=new FormData(t));var s=ft.isFormData(t);if(s)return i?JSON.stringify(qk(t)):t;if(ft.isArrayBuffer(t)||ft.isBuffer(t)||ft.isStream(t)||ft.isFile(t)||ft.isBlob(t))return t;if(ft.isArrayBufferView(t))return t.buffer;if(ft.isURLSearchParams(t))return nf(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();var a;if(r){if(n.indexOf("application/x-www-form-urlencoded")!==-1)return Hk(t,this.formSerializer).toString();if((a=ft.isFileList(t))||n.indexOf("multipart/form-data")>-1){var c=this.env&&this.env.FormData;return Wk(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return r||i?(nf(e,"application/json"),Jk(t)):t}],transformResponse:[function(t){var e=this.transitional||Fl.transitional,n=e&&e.forcedJSONParsing,i=this.responseType==="json";if(t&&ft.isString(t)&&(n&&!this.responseType||i)){var r=e&&e.silentJSONParsing,s=!r&&i;try{return JSON.parse(t)}catch(a){if(s)throw a.name==="SyntaxError"?ef.from(a,ef.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:tf.classes.FormData,Blob:tf.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ft.forEach(["delete","get","head"],function(t){Fl.headers[t]={}});ft.forEach(["post","put","patch"],function(t){Fl.headers[t]=ft.merge(Gk)});var qp=Fl,Kk=gt,zk=qp,Yk=function(t,e,n,i){var r=this||zk;return Kk.forEach(i,function(s){t=s.call(r,t,e,n)}),t},rf,sf;function dy(){return sf||(sf=1,rf=function(t){return!!(t&&t.__CANCEL__)}),rf}var af=gt,Eu=Yk,Qk=dy(),Xk=qp,Zk=Bl(),of=sy;function Su(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Zk}var ew=function(t){Su(t),t.headers=t.headers||{},t.data=Eu.call(t,t.data,t.headers,null,t.transformRequest),of(t.headers,"Accept"),of(t.headers,"Content-Type"),t.headers=af.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),af.forEach(["delete","get","head","post","put","patch","common"],function(n){delete t.headers[n]});var e=t.adapter||Xk.adapter;return e(t).then(function(n){return Su(t),n.data=Eu.call(t,n.data,n.headers,n.status,t.transformResponse),n},function(n){return Qk(n)||(Su(t),n&&n.response&&(n.response.data=Eu.call(t,n.response.data,n.response.headers,n.response.status,t.transformResponse))),Promise.reject(n)})},Vt=gt,ly=function(t,e){e=e||{};var n={};function i(h,u){return Vt.isPlainObject(h)&&Vt.isPlainObject(u)?Vt.merge(h,u):Vt.isEmptyObject(u)?Vt.merge({},h):Vt.isPlainObject(u)?Vt.merge({},u):Vt.isArray(u)?u.slice():u}function r(h){if(Vt.isUndefined(e[h])){if(!Vt.isUndefined(t[h]))return i(void 0,t[h])}else return i(t[h],e[h])}function s(h){if(!Vt.isUndefined(e[h]))return i(void 0,e[h])}function a(h){if(Vt.isUndefined(e[h])){if(!Vt.isUndefined(t[h]))return i(void 0,t[h])}else return i(void 0,e[h])}function c(h){if(h in e)return i(t[h],e[h]);if(h in t)return i(void 0,t[h])}var d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return Vt.forEach(Object.keys(t).concat(Object.keys(e)),function(h){var u=d[h]||r,g=u(h);Vt.isUndefined(g)&&u!==c||(n[h]=g)}),n},cf,df;function uy(){return df||(df=1,cf={version:"0.28.1"}),cf}var tw=uy().version,pr=bs,Gp={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){Gp[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var lf={};Gp.transitional=function(t,e,n){function i(r,s){return"[Axios v"+tw+"] Transitional option '"+r+"'"+s+(n?". "+n:"")}return function(r,s,a){if(t===!1)throw new pr(i(s," has been removed"+(e?" in "+e:"")),pr.ERR_DEPRECATED);return e&&!lf[s]&&(lf[s]=!0,console.warn(i(s," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(r,s,a):!0}};function nw(t,e,n){if(typeof t!="object")throw new pr("options must be an object",pr.ERR_BAD_OPTION_VALUE);for(var i=Object.keys(t),r=i.length;r-- >0;){var s=i[r],a=e[s];if(a){var c=t[s],d=c===void 0||a(c,s,t);if(d!==!0)throw new pr("option "+s+" must be "+d,pr.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new pr("Unknown option "+s,pr.ERR_BAD_OPTION)}}var iw={assertOptions:nw,validators:Gp},$p=gt,rw=ry,uf=yk,hf=ew,jl=ly,sw=cy,fh=iw,Hi=fh.validators;function ba(t){this.defaults=t,this.interceptors={request:new uf,response:new uf}}ba.prototype.request=function(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=jl(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var n=e.transitional;n!==void 0&&fh.assertOptions(n,{silentJSONParsing:Hi.transitional(Hi.boolean),forcedJSONParsing:Hi.transitional(Hi.boolean),clarifyTimeoutError:Hi.transitional(Hi.boolean)},!1);var i=e.paramsSerializer;i!==void 0&&fh.assertOptions(i,{encode:Hi.function,serialize:Hi.function},!0),$p.isFunction(i)&&(e.paramsSerializer={serialize:i});var r=[],s=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(e)===!1||(s=s&&E.synchronous,r.unshift(E.fulfilled,E.rejected))});var a=[];this.interceptors.response.forEach(function(E){a.push(E.fulfilled,E.rejected)});var c;if(!s){var d=[hf,void 0];for(Array.prototype.unshift.apply(d,r),d=d.concat(a),c=Promise.resolve(e);d.length;)c=c.then(d.shift(),d.shift());return c}for(var h=e;r.length;){var u=r.shift(),g=r.shift();try{h=u(h)}catch(E){g(E);break}}try{c=hf(h)}catch(E){return Promise.reject(E)}for(;a.length;)c=c.then(a.shift(),a.shift());return c};ba.prototype.getUri=function(t){t=jl(this.defaults,t);var e=sw(t.baseURL,t.url);return rw(e,t.params,t.paramsSerializer)};$p.forEach(["delete","get","head","options"],function(t){ba.prototype[t]=function(e,n){return this.request(jl(n||{},{method:t,url:e,data:(n||{}).data}))}});$p.forEach(["post","put","patch"],function(t){function e(n){return function(i,r,s){return this.request(jl(s||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:r}))}}ba.prototype[t]=e(),ba.prototype[t+"Form"]=e(!0)});var aw=ba,Tu,pf;function ow(){if(pf)return Tu;pf=1;var t=Bl();function e(n){if(typeof n!="function")throw new TypeError("executor must be a function.");var i;this.promise=new Promise(function(s){i=s});var r=this;this.promise.then(function(s){if(r._listeners){for(var a=r._listeners.length;a-- >0;)r._listeners[a](s);r._listeners=null}}),this.promise.then=function(s){var a,c=new Promise(function(d){r.subscribe(d),a=d}).then(s);return c.cancel=function(){r.unsubscribe(a)},c},n(function(s,a,c){r.reason||(r.reason=new t(s,a,c),i(r.reason))})}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},e.prototype.unsubscribe=function(n){if(this._listeners){var i=this._listeners.indexOf(n);i!==-1&&this._listeners.splice(i,1)}},e.source=function(){var n,i=new e(function(r){n=r});return{token:i,cancel:n}},Tu=e,Tu}var mf,ff;function cw(){return ff||(ff=1,mf=function(t){return function(e){return t.apply(null,e)}}),mf}var bu,gf;function dw(){if(gf)return bu;gf=1;var t=gt;return bu=function(e){return t.isObject(e)&&e.isAxiosError===!0},bu}var gh=gt,lw=$v,pd=aw,uw=ly,hw=qp,pw=oy;function hy(t){var e=new pd(t),n=lw(pd.prototype.request,e);return gh.extend(n,pd.prototype,e),gh.extend(n,e),n.create=function(i){return hy(uw(t,i))},n}var Qt=hy(hw);Qt.Axios=pd;Qt.CanceledError=Bl();Qt.CancelToken=ow();Qt.isCancel=dy();Qt.VERSION=uy().version;Qt.toFormData=Ul;Qt.AxiosError=bs;Qt.Cancel=Qt.CanceledError;Qt.all=function(t){return Promise.all(t)};Qt.spread=cw();Qt.isAxiosError=dw();Qt.formToJSON=function(t){return pw(gh.isHTMLForm(t)?new FormData(t):t)};wb.exports=Qt;il.default=Qt;(function(t){t.exports=il})(kb);const mw=WT(lh);function fw(){this.__data__=[],this.size=0}function vc(t,e){return t===e||t!==t&&e!==e}function Wl(t,e){for(var n=t.length;n--;)if(vc(t[n][0],e))return n;return-1}var gw=Array.prototype,vw=gw.splice;function yw(t){var e=this.__data__,n=Wl(e,t);if(n<0)return!1;var i=e.length-1;return n==i?e.pop():vw.call(e,n,1),--this.size,!0}function Ew(t){var e=this.__data__,n=Wl(e,t);return n<0?void 0:e[n][1]}function Sw(t){return Wl(this.__data__,t)>-1}function Tw(t,e){var n=this.__data__,i=Wl(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}function Di(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Di.prototype.clear=fw;Di.prototype.delete=yw;Di.prototype.get=Ew;Di.prototype.has=Sw;Di.prototype.set=Tw;function bw(){this.__data__=new Di,this.size=0}function kw(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function ww(t){return this.__data__.get(t)}function _w(t){return this.__data__.has(t)}const Nc=globalThis||void 0||self;var Iw=typeof Nc=="object"&&Nc&&Nc.Object===Object&&Nc;const py=Iw;var Cw=typeof self=="object"&&self&&self.Object===Object&&self,Rw=py||Cw||Function("return this")();const Jn=Rw;var Pw=Jn.Symbol;const br=Pw;var my=Object.prototype,Aw=my.hasOwnProperty,Mw=my.toString,La=br?br.toStringTag:void 0;function Ow(t){var e=Aw.call(t,La),n=t[La];try{t[La]=void 0;var i=!0}catch{}var r=Mw.call(t);return i&&(e?t[La]=n:delete t[La]),r}var Dw=Object.prototype,Nw=Dw.toString;function Lw(t){return Nw.call(t)}var xw="[object Null]",Vw="[object Undefined]",vf=br?br.toStringTag:void 0;function ks(t){return t==null?t===void 0?Vw:xw:vf&&vf in Object(t)?Ow(t):Lw(t)}function $n(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Uw="[object AsyncFunction]",Bw="[object Function]",Fw="[object GeneratorFunction]",jw="[object Proxy]";function Jp(t){if(!$n(t))return!1;var e=ks(t);return e==Bw||e==Fw||e==Uw||e==jw}var Ww=Jn["__core-js_shared__"];const ku=Ww;var yf=function(){var t=/[^.]+$/.exec(ku&&ku.keys&&ku.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Hw(t){return!!yf&&yf in t}var qw=Function.prototype,Gw=qw.toString;function ws(t){if(t!=null){try{return Gw.call(t)}catch{}try{return t+""}catch{}}return""}var $w=/[\\^$.*+?()[\]{}|]/g,Jw=/^\[object .+?Constructor\]$/,Kw=Function.prototype,zw=Object.prototype,Yw=Kw.toString,Qw=zw.hasOwnProperty,Xw=RegExp("^"+Yw.call(Qw).replace($w,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zw(t){if(!$n(t)||Hw(t))return!1;var e=Jp(t)?Xw:Jw;return e.test(ws(t))}function e0(t,e){return t==null?void 0:t[e]}function _s(t,e){var n=e0(t,e);return Zw(n)?n:void 0}var t0=_s(Jn,"Map");const uc=t0;var n0=_s(Object,"create");const hc=n0;function i0(){this.__data__=hc?hc(null):{},this.size=0}function r0(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var s0="__lodash_hash_undefined__",a0=Object.prototype,o0=a0.hasOwnProperty;function c0(t){var e=this.__data__;if(hc){var n=e[t];return n===s0?void 0:n}return o0.call(e,t)?e[t]:void 0}var d0=Object.prototype,l0=d0.hasOwnProperty;function u0(t){var e=this.__data__;return hc?e[t]!==void 0:l0.call(e,t)}var h0="__lodash_hash_undefined__";function p0(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=hc&&e===void 0?h0:e,this}function ys(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}ys.prototype.clear=i0;ys.prototype.delete=r0;ys.prototype.get=c0;ys.prototype.has=u0;ys.prototype.set=p0;function m0(){this.size=0,this.__data__={hash:new ys,map:new(uc||Di),string:new ys}}function f0(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Hl(t,e){var n=t.__data__;return f0(e)?n[typeof e=="string"?"string":"hash"]:n.map}function g0(t){var e=Hl(this,t).delete(t);return this.size-=e?1:0,e}function v0(t){return Hl(this,t).get(t)}function y0(t){return Hl(this,t).has(t)}function E0(t,e){var n=Hl(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}function Is(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Is.prototype.clear=m0;Is.prototype.delete=g0;Is.prototype.get=v0;Is.prototype.has=y0;Is.prototype.set=E0;var S0=200;function T0(t,e){var n=this.__data__;if(n instanceof Di){var i=n.__data__;if(!uc||i.length<S0-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Is(i)}return n.set(t,e),this.size=n.size,this}function ui(t){var e=this.__data__=new Di(t);this.size=e.size}ui.prototype.clear=bw;ui.prototype.delete=kw;ui.prototype.get=ww;ui.prototype.has=_w;ui.prototype.set=T0;function b0(t,e){for(var n=-1,i=t==null?0:t.length;++n<i&&e(t[n],n,t)!==!1;);return t}var k0=function(){try{var t=_s(Object,"defineProperty");return t({},"",{}),t}catch{}}();const rl=k0;function Kp(t,e,n){e=="__proto__"&&rl?rl(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var w0=Object.prototype,_0=w0.hasOwnProperty;function fy(t,e,n){var i=t[e];(!(_0.call(t,e)&&vc(i,n))||n===void 0&&!(e in t))&&Kp(t,e,n)}function yc(t,e,n,i){var r=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var c=e[s],d=i?i(n[c],t[c],c,n,t):void 0;d===void 0&&(d=t[c]),r?Kp(n,c,d):fy(n,c,d)}return n}function I0(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}function hi(t){return t!=null&&typeof t=="object"}var C0="[object Arguments]";function Ef(t){return hi(t)&&ks(t)==C0}var gy=Object.prototype,R0=gy.hasOwnProperty,P0=gy.propertyIsEnumerable,A0=Ef(function(){return arguments}())?Ef:function(t){return hi(t)&&R0.call(t,"callee")&&!P0.call(t,"callee")};const sl=A0;var M0=Array.isArray;const kr=M0;function O0(){return!1}var vy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sf=vy&&typeof module=="object"&&module&&!module.nodeType&&module,D0=Sf&&Sf.exports===vy,Tf=D0?Jn.Buffer:void 0,N0=Tf?Tf.isBuffer:void 0,L0=N0||O0;const ka=L0;var x0=9007199254740991,V0=/^(?:0|[1-9]\d*)$/;function yy(t,e){var n=typeof t;return e=e==null?x0:e,!!e&&(n=="number"||n!="symbol"&&V0.test(t))&&t>-1&&t%1==0&&t<e}var U0=9007199254740991;function Ey(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=U0}var B0="[object Arguments]",F0="[object Array]",j0="[object Boolean]",W0="[object Date]",H0="[object Error]",q0="[object Function]",G0="[object Map]",$0="[object Number]",J0="[object Object]",K0="[object RegExp]",z0="[object Set]",Y0="[object String]",Q0="[object WeakMap]",X0="[object ArrayBuffer]",Z0="[object DataView]",e_="[object Float32Array]",t_="[object Float64Array]",n_="[object Int8Array]",i_="[object Int16Array]",r_="[object Int32Array]",s_="[object Uint8Array]",a_="[object Uint8ClampedArray]",o_="[object Uint16Array]",c_="[object Uint32Array]",Ue={};Ue[e_]=Ue[t_]=Ue[n_]=Ue[i_]=Ue[r_]=Ue[s_]=Ue[a_]=Ue[o_]=Ue[c_]=!0;Ue[B0]=Ue[F0]=Ue[X0]=Ue[j0]=Ue[Z0]=Ue[W0]=Ue[H0]=Ue[q0]=Ue[G0]=Ue[$0]=Ue[J0]=Ue[K0]=Ue[z0]=Ue[Y0]=Ue[Q0]=!1;function d_(t){return hi(t)&&Ey(t.length)&&!!Ue[ks(t)]}function zp(t){return function(e){return t(e)}}var Sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Jo=Sy&&typeof module=="object"&&module&&!module.nodeType&&module,l_=Jo&&Jo.exports===Sy,wu=l_&&py.process,u_=function(){try{var t=Jo&&Jo.require&&Jo.require("util").types;return t||wu&&wu.binding&&wu.binding("util")}catch{}}();const wa=u_;var bf=wa&&wa.isTypedArray,h_=bf?zp(bf):d_;const ql=h_;var p_=Object.prototype,m_=p_.hasOwnProperty;function Ty(t,e){var n=kr(t),i=!n&&sl(t),r=!n&&!i&&ka(t),s=!n&&!i&&!r&&ql(t),a=n||i||r||s,c=a?I0(t.length,String):[],d=c.length;for(var h in t)(e||m_.call(t,h))&&!(a&&(h=="length"||r&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||yy(h,d)))&&c.push(h);return c}var f_=Object.prototype;function Gl(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||f_;return t===n}function by(t,e){return function(n){return t(e(n))}}var g_=by(Object.keys,Object);const v_=g_;var y_=Object.prototype,E_=y_.hasOwnProperty;function ky(t){if(!Gl(t))return v_(t);var e=[];for(var n in Object(t))E_.call(t,n)&&n!="constructor"&&e.push(n);return e}function Ec(t){return t!=null&&Ey(t.length)&&!Jp(t)}function Yp(t){return Ec(t)?Ty(t):ky(t)}function S_(t,e){return t&&yc(e,Yp(e),t)}function T_(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var b_=Object.prototype,k_=b_.hasOwnProperty;function w_(t){if(!$n(t))return T_(t);var e=Gl(t),n=[];for(var i in t)i=="constructor"&&(e||!k_.call(t,i))||n.push(i);return n}function Sc(t){return Ec(t)?Ty(t,!0):w_(t)}function __(t,e){return t&&yc(e,Sc(e),t)}var wy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kf=wy&&typeof module=="object"&&module&&!module.nodeType&&module,I_=kf&&kf.exports===wy,wf=I_?Jn.Buffer:void 0,_f=wf?wf.allocUnsafe:void 0;function _y(t,e){if(e)return t.slice();var n=t.length,i=_f?_f(n):new t.constructor(n);return t.copy(i),i}function Iy(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}function C_(t,e){for(var n=-1,i=t==null?0:t.length,r=0,s=[];++n<i;){var a=t[n];e(a,n,t)&&(s[r++]=a)}return s}function Cy(){return[]}var R_=Object.prototype,P_=R_.propertyIsEnumerable,If=Object.getOwnPropertySymbols,A_=If?function(t){return t==null?[]:(t=Object(t),C_(If(t),function(e){return P_.call(t,e)}))}:Cy;const Qp=A_;function M_(t,e){return yc(t,Qp(t),e)}function Ry(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var O_=by(Object.getPrototypeOf,Object);const Xp=O_;var D_=Object.getOwnPropertySymbols,N_=D_?function(t){for(var e=[];t;)Ry(e,Qp(t)),t=Xp(t);return e}:Cy;const Py=N_;function L_(t,e){return yc(t,Py(t),e)}function Ay(t,e,n){var i=e(t);return kr(t)?i:Ry(i,n(t))}function vh(t){return Ay(t,Yp,Qp)}function x_(t){return Ay(t,Sc,Py)}var V_=_s(Jn,"DataView");const yh=V_;var U_=_s(Jn,"Promise");const Eh=U_;var B_=_s(Jn,"Set");const Sh=B_;var F_=_s(Jn,"WeakMap");const Th=F_;var Cf="[object Map]",j_="[object Object]",Rf="[object Promise]",Pf="[object Set]",Af="[object WeakMap]",Mf="[object DataView]",W_=ws(yh),H_=ws(uc),q_=ws(Eh),G_=ws(Sh),$_=ws(Th),jr=ks;(yh&&jr(new yh(new ArrayBuffer(1)))!=Mf||uc&&jr(new uc)!=Cf||Eh&&jr(Eh.resolve())!=Rf||Sh&&jr(new Sh)!=Pf||Th&&jr(new Th)!=Af)&&(jr=function(t){var e=ks(t),n=e==j_?t.constructor:void 0,i=n?ws(n):"";if(i)switch(i){case W_:return Mf;case H_:return Cf;case q_:return Rf;case G_:return Pf;case $_:return Af}return e});const _a=jr;var J_=Object.prototype,K_=J_.hasOwnProperty;function z_(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&K_.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var Y_=Jn.Uint8Array;const al=Y_;function Zp(t){var e=new t.constructor(t.byteLength);return new al(e).set(new al(t)),e}function Q_(t,e){var n=e?Zp(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}var X_=/\w*$/;function Z_(t){var e=new t.constructor(t.source,X_.exec(t));return e.lastIndex=t.lastIndex,e}var Of=br?br.prototype:void 0,Df=Of?Of.valueOf:void 0;function eI(t){return Df?Object(Df.call(t)):{}}function My(t,e){var n=e?Zp(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var tI="[object Boolean]",nI="[object Date]",iI="[object Map]",rI="[object Number]",sI="[object RegExp]",aI="[object Set]",oI="[object String]",cI="[object Symbol]",dI="[object ArrayBuffer]",lI="[object DataView]",uI="[object Float32Array]",hI="[object Float64Array]",pI="[object Int8Array]",mI="[object Int16Array]",fI="[object Int32Array]",gI="[object Uint8Array]",vI="[object Uint8ClampedArray]",yI="[object Uint16Array]",EI="[object Uint32Array]";function SI(t,e,n){var i=t.constructor;switch(e){case dI:return Zp(t);case tI:case nI:return new i(+t);case lI:return Q_(t,n);case uI:case hI:case pI:case mI:case fI:case gI:case vI:case yI:case EI:return My(t,n);case iI:return new i;case rI:case oI:return new i(t);case sI:return Z_(t);case aI:return new i;case cI:return eI(t)}}var Nf=Object.create,TI=function(){function t(){}return function(e){if(!$n(e))return{};if(Nf)return Nf(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();const bI=TI;function Oy(t){return typeof t.constructor=="function"&&!Gl(t)?bI(Xp(t)):{}}var kI="[object Map]";function wI(t){return hi(t)&&_a(t)==kI}var Lf=wa&&wa.isMap,_I=Lf?zp(Lf):wI;const II=_I;var CI="[object Set]";function RI(t){return hi(t)&&_a(t)==CI}var xf=wa&&wa.isSet,PI=xf?zp(xf):RI;const AI=PI;var MI=1,OI=2,DI=4,Dy="[object Arguments]",NI="[object Array]",LI="[object Boolean]",xI="[object Date]",VI="[object Error]",Ny="[object Function]",UI="[object GeneratorFunction]",BI="[object Map]",FI="[object Number]",Ly="[object Object]",jI="[object RegExp]",WI="[object Set]",HI="[object String]",qI="[object Symbol]",GI="[object WeakMap]",$I="[object ArrayBuffer]",JI="[object DataView]",KI="[object Float32Array]",zI="[object Float64Array]",YI="[object Int8Array]",QI="[object Int16Array]",XI="[object Int32Array]",ZI="[object Uint8Array]",eC="[object Uint8ClampedArray]",tC="[object Uint16Array]",nC="[object Uint32Array]",Ne={};Ne[Dy]=Ne[NI]=Ne[$I]=Ne[JI]=Ne[LI]=Ne[xI]=Ne[KI]=Ne[zI]=Ne[YI]=Ne[QI]=Ne[XI]=Ne[BI]=Ne[FI]=Ne[Ly]=Ne[jI]=Ne[WI]=Ne[HI]=Ne[qI]=Ne[ZI]=Ne[eC]=Ne[tC]=Ne[nC]=!0;Ne[VI]=Ne[Ny]=Ne[GI]=!1;function md(t,e,n,i,r,s){var a,c=e&MI,d=e&OI,h=e&DI;if(n&&(a=r?n(t,i,r,s):n(t)),a!==void 0)return a;if(!$n(t))return t;var u=kr(t);if(u){if(a=z_(t),!c)return Iy(t,a)}else{var g=_a(t),E=g==Ny||g==UI;if(ka(t))return _y(t,c);if(g==Ly||g==Dy||E&&!r){if(a=d||E?{}:Oy(t),!c)return d?L_(t,__(a,t)):M_(t,S_(a,t))}else{if(!Ne[g])return r?t:{};a=SI(t,g,c)}}s||(s=new ui);var b=s.get(t);if(b)return b;s.set(t,a),AI(t)?t.forEach(function(M){a.add(md(M,e,n,M,t,s))}):II(t)&&t.forEach(function(M,B){a.set(B,md(M,e,n,B,t,s))});var k=h?d?x_:vh:d?Sc:Yp,A=u?void 0:k(t);return b0(A||t,function(M,B){A&&(B=M,M=t[B]),fy(a,B,md(M,e,n,B,t,s))}),a}var iC=1,rC=4;function em(t){return md(t,iC|rC)}var sC="[object Symbol]";function aC(t){return typeof t=="symbol"||hi(t)&&ks(t)==sC}var oC=Object.defineProperty,cC=(t,e)=>{for(var n in e)oC(t,n,{get:e[n],enumerable:!0})},dC={};cC(dC,{permissions:()=>lC,theme:()=>uC});var Yt=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Yt||{}),re=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(re||{}),lC={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},uC={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}},xy="hXgU8Wc8pwuGNq9ms5q9Hh",Vf;typeof ls!="undefined"&&(Vf=ls==null?void 0:ls.env)!=null&&Vf.FLAGSMITH_ENVIRONMENT_KEY&&(xy=ls.env.FLAGSMITH_ENVIRONMENT_KEY);function hC(t=[]){const e={};return t.forEach(n=>{e[n.feature.name]={enabled:n.enabled,value:n.feature_state_value}}),e}var pC=class{constructor(t=xy){y(this,"flags",{}),y(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return p(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:n,forceEvaluate:i,timeout:r,uniqueIdentifier:s,traitsObj:a,logger:c}){const d=JSON.parse(JSON.stringify(a)),h=Object.entries(d).map(g=>({trait_key:g[0],trait_value:g[1]})),u=[e,n,n];for(const g of u)try{const E="_"+(Math.random()+1).toString(36).substring(2),b=yield mw.post(`https://${g}/api/v1/identities/`,{identifier:s+(i?E:""),traits:h},{headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},timeout:r});return hC(b.data.flags||[])}catch(E){c.error("Flagsmith identify failed!!",{error:E,url:g})}return{}})}identify(t){return p(this,arguments,function*(e,n={},i=!1,r=5e3,s="edge.api.flagsmith.com",a=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:n,uniqueIdentifier:e,forceEvaluate:i,timeout:r,primaryEndpoint:s,secondaryEndpoint:"edge.api.flagsmith.com",logger:a}),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}},se=new pC,Vy=[-2,-1,0,1,2],mC=[0,1,2,3,4];function fC(t){t=t.trim();let e="0",n="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+n,+i]}var gC=(t,e,n)=>{let i,r,s;if(e==0)i=r=s=n;else{const a=(h,u,g)=>(g<0&&(g+=1),g>1&&(g-=1),g<.16666666666666666?h+(u-h)*6*g:g<.5?u:g<.6666666666666666?h+(u-h)*(.6666666666666666-g)*6:h),c=n<.5?n*(1+e):n+e-n*e,d=2*n-c;i=a(d,c,t+1/3),r=a(d,c,t),s=a(d,c,t-1/3)}return[Math.round(i*255),Math.round(r*255),Math.round(s*255)]},vC=(t,e,n)=>{t/=255,e/=255,n/=255;const i=Math.max(t,e,n),r=Math.min(t,e,n);let s,a;const c=(i+r)/2;if(i==r)s=a=0;else{const d=i-r;switch(a=c>.5?d/(2-i-r):d/(i+r),i){case t:s=(e-n)/d+(e<n?6:0);break;case e:s=(n-t)/d+2;break;case n:s=(t-e)/d+4;break}s/=6}return[s,a,c]},yC=(t,e,n)=>{const i=r=>r.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`},Uy=(t,e=Vy,n=.4)=>{const i=[],[r,s,a]=fC(t),[c,d,h]=vC(r,s,a),u=Math.round(h*100);u>70?n=.8:u>60?n=.9:u<10?n=.075:u<42&&(n=.3);const g=e.findIndex(M=>M===0);if(g===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const E=5-g,b=g+1,k=(100-u)/E,A=u/b;for(const M of e){let B;M<0?B=u+M*A*n:M>0?B=u+M*k*n:B=u;const[K,X,O]=gC(c,d,B/100);i.push(yC(K,X,O))}return i},Uf={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"}},EC=t=>{const[e,n,i,r,s]=Uy(t,Vy);return{300:e,400:n,500:i,600:r,700:s}},SC=t=>{if(t==="#FFFFFF")return Uf.light.background;if(t==="#000000")return Uf.dark.background;const[e,n,i,r,s]=Uy(t,mC);return{1e3:e,900:n,800:i,700:r,600:s}},TC={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:EC("#2160FD"),background:SC("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function By(){return em(TC)}var bC={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:By(),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 kC(){return em(bC)}var wC={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:By(),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 tm(){return em(wC)}var _C=/\s/;function IC(t){for(var e=t.length;e--&&_C.test(t.charAt(e)););return e}var CC=/^\s+/;function RC(t){return t&&t.slice(0,IC(t)+1).replace(CC,"")}var Bf=0/0,PC=/^[-+]0x[0-9a-f]+$/i,AC=/^0b[01]+$/i,MC=/^0o[0-7]+$/i,OC=parseInt;function Ff(t){if(typeof t=="number")return t;if(aC(t))return Bf;if($n(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=$n(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=RC(t);var n=AC.test(t);return n||MC.test(t)?OC(t.slice(2),n?2:8):PC.test(t)?Bf:+t}function Fy(t){return t}function DC(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var NC=800,LC=16,xC=Date.now;function VC(t){var e=0,n=0;return function(){var i=xC(),r=LC-(i-n);if(n=i,r>0){if(++e>=NC)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function UC(t){return function(){return t}}var BC=rl?function(t,e){return rl(t,"toString",{configurable:!0,enumerable:!1,value:UC(e),writable:!0})}:Fy;const FC=BC;var jC=VC(FC);const WC=jC;var jf=Math.max;function HC(t,e,n){return e=jf(e===void 0?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=jf(i.length-e,0),a=Array(s);++r<s;)a[r]=i[e+r];r=-1;for(var c=Array(e+1);++r<e;)c[r]=i[r];return c[e]=n(a),DC(t,this,c)}}function qC(t,e){return WC(HC(t,e,Fy),t+"")}function GC(t,e,n){if(!$n(n))return!1;var i=typeof e;return(i=="number"?Ec(n)&&yy(e,n.length):i=="string"&&e in n)?vc(n[e],t):!1}function $C(t){return qC(function(e,n){var i=-1,r=n.length,s=r>1?n[r-1]:void 0,a=r>2?n[2]:void 0;for(s=t.length>3&&typeof s=="function"?(r--,s):void 0,a&&GC(n[0],n[1],a)&&(s=r<3?void 0:s,r=1),e=Object(e);++i<r;){var c=n[i];c&&t(e,c,i,s)}return e})}var JC="[object Object]",KC=Function.prototype,zC=Object.prototype,jy=KC.toString,YC=zC.hasOwnProperty,QC=jy.call(Object);function XC(t){if(!hi(t)||ks(t)!=JC)return!1;var e=Xp(t);if(e===null)return!0;var n=YC.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&jy.call(n)==QC}var ZC="__lodash_hash_undefined__";function eR(t){return this.__data__.set(t,ZC),this}function tR(t){return this.__data__.has(t)}function ol(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Is;++e<n;)this.add(t[e])}ol.prototype.add=ol.prototype.push=eR;ol.prototype.has=tR;function nR(t,e){for(var n=-1,i=t==null?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}function iR(t,e){return t.has(e)}var rR=1,sR=2;function Wy(t,e,n,i,r,s){var a=n&rR,c=t.length,d=e.length;if(c!=d&&!(a&&d>c))return!1;var h=s.get(t),u=s.get(e);if(h&&u)return h==e&&u==t;var g=-1,E=!0,b=n&sR?new ol:void 0;for(s.set(t,e),s.set(e,t);++g<c;){var k=t[g],A=e[g];if(i)var M=a?i(A,k,g,e,t,s):i(k,A,g,t,e,s);if(M!==void 0){if(M)continue;E=!1;break}if(b){if(!nR(e,function(B,K){if(!iR(b,K)&&(k===B||r(k,B,n,i,s)))return b.push(K)})){E=!1;break}}else if(!(k===A||r(k,A,n,i,s))){E=!1;break}}return s.delete(t),s.delete(e),E}function aR(t){var e=-1,n=Array(t.size);return t.forEach(function(i,r){n[++e]=[r,i]}),n}function oR(t){var e=-1,n=Array(t.size);return t.forEach(function(i){n[++e]=i}),n}var cR=1,dR=2,lR="[object Boolean]",uR="[object Date]",hR="[object Error]",pR="[object Map]",mR="[object Number]",fR="[object RegExp]",gR="[object Set]",vR="[object String]",yR="[object Symbol]",ER="[object ArrayBuffer]",SR="[object DataView]",Wf=br?br.prototype:void 0,_u=Wf?Wf.valueOf:void 0;function TR(t,e,n,i,r,s,a){switch(n){case SR:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ER:return!(t.byteLength!=e.byteLength||!s(new al(t),new al(e)));case lR:case uR:case mR:return vc(+t,+e);case hR:return t.name==e.name&&t.message==e.message;case fR:case vR:return t==e+"";case pR:var c=aR;case gR:var d=i&cR;if(c||(c=oR),t.size!=e.size&&!d)return!1;var h=a.get(t);if(h)return h==e;i|=dR,a.set(t,e);var u=Wy(c(t),c(e),i,r,s,a);return a.delete(t),u;case yR:if(_u)return _u.call(t)==_u.call(e)}return!1}var bR=1,kR=Object.prototype,wR=kR.hasOwnProperty;function _R(t,e,n,i,r,s){var a=n&bR,c=vh(t),d=c.length,h=vh(e),u=h.length;if(d!=u&&!a)return!1;for(var g=d;g--;){var E=c[g];if(!(a?E in e:wR.call(e,E)))return!1}var b=s.get(t),k=s.get(e);if(b&&k)return b==e&&k==t;var A=!0;s.set(t,e),s.set(e,t);for(var M=a;++g<d;){E=c[g];var B=t[E],K=e[E];if(i)var X=a?i(K,B,E,e,t,s):i(B,K,E,t,e,s);if(!(X===void 0?B===K||r(B,K,n,i,s):X)){A=!1;break}M||(M=E=="constructor")}if(A&&!M){var O=t.constructor,$=e.constructor;O!=$&&"constructor"in t&&"constructor"in e&&!(typeof O=="function"&&O instanceof O&&typeof $=="function"&&$ instanceof $)&&(A=!1)}return s.delete(t),s.delete(e),A}var IR=1,Hf="[object Arguments]",qf="[object Array]",Lc="[object Object]",CR=Object.prototype,Gf=CR.hasOwnProperty;function RR(t,e,n,i,r,s){var a=kr(t),c=kr(e),d=a?qf:_a(t),h=c?qf:_a(e);d=d==Hf?Lc:d,h=h==Hf?Lc:h;var u=d==Lc,g=h==Lc,E=d==h;if(E&&ka(t)){if(!ka(e))return!1;a=!0,u=!1}if(E&&!u)return s||(s=new ui),a||ql(t)?Wy(t,e,n,i,r,s):TR(t,e,d,n,i,r,s);if(!(n&IR)){var b=u&&Gf.call(t,"__wrapped__"),k=g&&Gf.call(e,"__wrapped__");if(b||k){var A=b?t.value():t,M=k?e.value():e;return s||(s=new ui),r(A,M,n,i,s)}}return E?(s||(s=new ui),_R(t,e,n,i,r,s)):!1}function Hy(t,e,n,i,r){return t===e?!0:t==null||e==null||!hi(t)&&!hi(e)?t!==t&&e!==e:RR(t,e,n,i,Hy,r)}function PR(t){return function(e,n,i){for(var r=-1,s=Object(e),a=i(e),c=a.length;c--;){var d=a[t?c:++r];if(n(s[d],d,s)===!1)break}return e}}var AR=PR();const MR=AR;var OR=function(){return Jn.Date.now()};const Iu=OR;var DR="Expected a function",NR=Math.max,LR=Math.min;function cl(t,e,n){var i,r,s,a,c,d,h=0,u=!1,g=!1,E=!0;if(typeof t!="function")throw new TypeError(DR);e=Ff(e)||0,$n(n)&&(u=!!n.leading,g="maxWait"in n,s=g?NR(Ff(n.maxWait)||0,e):s,E="trailing"in n?!!n.trailing:E);function b(me){var Ie=i,fe=r;return i=r=void 0,h=me,a=t.apply(fe,Ie),a}function k(me){return h=me,c=setTimeout(B,e),u?b(me):a}function A(me){var Ie=me-d,fe=me-h,Je=e-Ie;return g?LR(Je,s-fe):Je}function M(me){var Ie=me-d,fe=me-h;return d===void 0||Ie>=e||Ie<0||g&&fe>=s}function B(){var me=Iu();if(M(me))return K(me);c=setTimeout(B,A(me))}function K(me){return c=void 0,E&&i?b(me):(i=r=void 0,a)}function X(){c!==void 0&&clearTimeout(c),h=0,i=d=r=c=void 0}function O(){return c===void 0?a:K(Iu())}function $(){var me=Iu(),Ie=M(me);if(i=arguments,r=this,d=me,Ie){if(c===void 0)return k(d);if(g)return clearTimeout(c),c=setTimeout(B,e),b(d)}return c===void 0&&(c=setTimeout(B,e)),a}return $.cancel=X,$.flush=O,$}function bh(t,e,n){(n!==void 0&&!vc(t[e],n)||n===void 0&&!(e in t))&&Kp(t,e,n)}function xR(t){return hi(t)&&Ec(t)}function kh(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function VR(t){return yc(t,Sc(t))}function UR(t,e,n,i,r,s,a){var c=kh(t,n),d=kh(e,n),h=a.get(d);if(h){bh(t,n,h);return}var u=s?s(c,d,n+"",t,e,a):void 0,g=u===void 0;if(g){var E=kr(d),b=!E&&ka(d),k=!E&&!b&&ql(d);u=d,E||b||k?kr(c)?u=c:xR(c)?u=Iy(c):b?(g=!1,u=_y(d,!0)):k?(g=!1,u=My(d,!0)):u=[]:XC(d)||sl(d)?(u=c,sl(c)?u=VR(c):(!$n(c)||Jp(c))&&(u=Oy(d))):g=!1}g&&(a.set(d,u),r(u,d,i,s,a),a.delete(d)),bh(t,n,u)}function qy(t,e,n,i,r){t!==e&&MR(e,function(s,a){if(r||(r=new ui),$n(s))UR(t,e,a,n,qy,i,r);else{var c=i?i(kh(t,a),s,a+"",t,e,r):void 0;c===void 0&&(c=s),bh(t,a,c)}},Sc)}var BR="[object Map]",FR="[object Set]",jR=Object.prototype,WR=jR.hasOwnProperty;function HR(t){if(t==null)return!0;if(Ec(t)&&(kr(t)||typeof t=="string"||typeof t.splice=="function"||ka(t)||ql(t)||sl(t)))return!t.length;var e=_a(t);if(e==BR||e==FR)return!t.size;if(Gl(t))return!ky(t).length;for(var n in t)if(WR.call(t,n))return!1;return!0}function qR(t,e){return Hy(t,e)}var GR=$C(function(t,e,n){qy(t,e,n)});const Xi=GR;var wh=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(wh||{});const ue={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 fd(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 Gy(t){var e,n,i,r;const s=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((n=window.location.host)==null?void 0:n.includes("dyte.io")),a=!!((r=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&r.logs);return s||a}function $R(t){var e;if(se.hasFeature(ue.LOG_LEVEL)){let n=((e=se.getValue(ue.LOG_LEVEL))==null?void 0:e.toString())||"all";if(n=n.toLowerCase().trim(),n==="off")return!1;if(n!=="all"){const i=["debug","log","info","warn","error"],r=i.indexOf(t),s=i.indexOf(n);if(r<s)return!1}}return!0}function $y(t,e,n={}){return Object.getOwnPropertyNames(t).forEach(i=>{var r;if([null,void 0,NaN].includes(t[i])||e&&(((r=e.match(/\./g))==null?void 0:r.length)||0)>=10)return;const s=e?`${e}.${i}`:i;typeof t[i]=="object"?$y(t[i],s,n):["number","string","boolean"].includes(typeof t[i])&&(n[s]=t[i])}),n}function $f(t,e,n={},i=""){const r={};try{const s=JSON.stringify(n),a=JSON.parse(s),c=$y(a,i),d=JSON.stringify(c);if(d.length>5e3){const h=`Log named: "${e}" is trying to log an flattened object of size
19
- ${d.length} chars that is beyond permitted limit of 5000 chars. Please optimize.`;throw Gy(t)&&console.error(h,{log:n,flattened:d}),new Error(h)}return JSON.parse(d)}catch(s){const a=fd(s);r[`${i}.error.message`]=a.message||"",r[`${i}.error.stack`]=a.stack||"",r[`${i}.error.reason`]=a.reason||"",r[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return r}const pc="chrome",Jy="opera",Ky="firefox",zy="iexplorer",Yy="safari",Qy="nwjs",Xy="electron",Zy="react-native",nm="unknown",dl={Chrome:pc,Chromium:pc,Opera:Jy,Firefox:Ky,"Internet Explorer":zy,Safari:Yy};function JR(){const{userAgent:t}=navigator,e={name:nm,version:void 0};if(t.match(/Chrome/)&&!t.match(/Edge/))if(t.match(/Edg(A?)/)){const n=t.match(/Chrome\/([\d.]+)/)[1];Number.parseInt(n,10)>72&&(e.name=pc,e.version=n)}else e.name=pc,e.version=t.match(/Chrome\/([\d.]+)/)[1];return e}function KR(){const{userAgent:t}=navigator;if(t.match(/Electron/)){const e=t.match(/Electron\/([\d.]+)/)[1];return{name:Xy,version:e}}return null}function zR(){const{userAgent:t}=navigator;if(t.match(/JitsiMeetNW/)){const e=t.match(/JitsiMeetNW\/([\d.]+)/)[1];return{name:Qy,version:e}}}function YR(){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:Zy,version:e}}function QR(t){let e;const n=[YR,KR,zR];for(let r=0;r<n.length;r+=1)if(e=n[r](),e)return e;const i=t.getBrowserName();return i in dl?{name:dl[i],version:t.getBrowserVersion()}:(e=JR(),e||{name:nm,version:void 0})}class XR{constructor(){y(this,"_bowser"),y(this,"_name"),y(this,"_version"),y(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 n,i;if(this._bowser=ov.getParser(navigator.userAgent),typeof e=="undefined"){const r=QR(this._bowser);n=r.name,i=r.version}else e.name in dl?(n=dl[e.name],i=e.version):(n=nm,i=void 0);this._name=n,this._version=i}getName(){return this._name}isChrome(){return this._name===pc}isOpera(){return this._name===Jy}isFirefox(){return this._name===Ky}isIExplorer(){return this._name===zy}isSafari(){return this._name===Yy}isNWJS(){return this._name===Qy}isElectron(){return this._name===Xy}isReactNative(){return this._name===Zy||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 ZR extends XR{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(ls.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 Be=new ZR,eP={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},xa={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"},tP={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,devTools:{logs:!1}};function ll(t,e){const n=t.getValue("overrides");return n&&n[e]?n[e]:!1}function nP({baseURI:t}){return t!=null&&t.includes("preprod.dyte")?$o.PREPROD:t!=null&&t.includes("devel.dyte")?$o.DEVEL:$o.PROD}function ga({servicePrefix:t,baseURI:e}){return`${t}.${e}`}function eE(t){const e=t.getValue("baseURI");return{location:ga({servicePrefix:"location",baseURI:e}),locationLegacy:ga({servicePrefix:"location-legacy",baseURI:e}),daCollector:ga({servicePrefix:"da-collector",baseURI:e})}}const iP='<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>',rP='<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>',xc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(r=>{r(t)});const e=new Blob([t],{type:"image/svg+xml"}),n=new Image,i=window.URL.createObjectURL(e);return new Promise((r,s)=>{n.onload=()=>{r(n),window.URL.revokeObjectURL(i)},n.onerror=()=>{s(),window.URL.revokeObjectURL(i)},n.src=i})};function sP(t){const e=H({},t),n=new Map,i=(a,c)=>(n.has(a)||n.set(a,new Set),n.get(a).add(c),()=>{var d;return(d=n.get(a))==null?void 0:d.delete(c)}),r=(a,c)=>{var d;(d=n.get(a))==null||d.delete(c)},s=a=>{var c;(c=n.get(a))==null||c.forEach(d=>{try{d(e[a])}catch(h){m.error(`Error in notifying for "${a.toString()}"`,h)}})};return{subscribe:i,unsubscribe:r,notify:s,setValue:(a,c,d=!0)=>{e[a]=c,d&&s(a)},getValue:a=>e[a],getAllValues:()=>e}}class aP{constructor(){y(this,"contexts",new Map),y(this,"mostRecentPeerId",null)}createContext(e,n){return this.contexts.has(e)?this.contexts.get(e):(this.contexts.set(e,sP(n)),this.mostRecentPeerId=e,this.contexts.get(e))}remapContext(e,n){const i=n.getValue("peerId");i!==e&&(n.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,n),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ms=new aP,ve=class{static get logsEndpoint(){const t=ms.getContext(ve.meetingMetadata.peerId);return`https://${ga({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}static resetPeerId(t){ve.meetingMetadata.peerId=t}static init(t,e){const n=t.getValue("peerId");ve.tracingEnabled=e,ve.meetingMetadata.peerId=n,ve.meetingMetadata.sdkVersion=t.getValue("sdkVersion"),ve.meetingMetadata.deviceInfo=Be.getDeviceInfo(),ve.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,navigator.isReactNative||document.addEventListener("visibilitychange",ve.processCachedLogs),ve.logsProcessorTimer=setInterval(ve.processCachedLogs,ve.logsProcessingInterval),e&&(ve.initialized=!0)}static trace(t,e=void 0){return(n,i,r)=>{const s=r.value;return r.value=function(...a){if(!ve.initialized||navigator.isReactNative||!ve.tracingEnabled||se.hasFeature(ue.SKIP_OTEL_TRACES))return s.apply(this,a);ve.addLogInCurrentSpan("info",t,e);const c=performance.now(),d=s.apply(this,a);return Promise.resolve(d).then(()=>{const h=performance.now();h-c>10&&ve.addLogInCurrentSpan("info",`${t}_timing`,{execTime:h-c,country:ve.location.country})}).catch(()=>{const h=performance.now();ve.addLogInCurrentSpan("info",`${t}_timing`,{execTime:h-c})}),d},r}}static injectContext(t){var e;const n=Ca().replace(/-/g,"").substring(0,16),i=(e=ve.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${n}-01`}static addLogInCurrentSpan(t,e,n={},i=!1){n!=null&&n.error&&Object.assign(n,{error:fd(n.error)});const r=ms.getContext(ve.meetingMetadata.peerId);if(Gy(r)&&(HR(n)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,n)),!!$R(t))try{const s=$f(r,e,n,"metadata"),a=new Date,c=ee(H({message:e,level:t},s),{loggedAt:a.toISOString(),loggedAtTzOffset:a.getTimezoneOffset()});i?ve.sendOtelLogsToNewRelic([c]):ve.logsCache.push(c)}catch(s){ve.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:fd(s)})}}static sendOtelLogsToNewRelic(t){const e=ms.getContext(ve.meetingMetadata.peerId);fetch(ve.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:$f(e,"sendOtelLogsToNewRelic",ve.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(n=>{ve.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:fd(n)}),ve.logsCache.push(...t)})}static processCachedLogs(){const t=ve.logsCache.splice(0,25);t!=null&&t.length&&ve.sendOtelLogsToNewRelic(t)}static destruct(){clearInterval(ve.logsProcessorTimer),ve.processCachedLogs(),navigator.isReactNative||document.removeEventListener("visibilitychange",ve.processCachedLogs)}};let w=ve;y(w,"logsCache",[]),y(w,"logsProcessorTimer"),y(w,"location",{country:void 0}),y(w,"tracingEnabled",!0),y(w,"initialized",!1),y(w,"logsProcessingInterval",7e3),y(w,"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"]),y(w,"meetingMetadata",{});class m{static info(e,n,i){w.addLogInCurrentSpan("info",e,n,i)}static error(e,n,i){w.addLogInCurrentSpan("error",e,n,i)}static debug(e,n,i){w.addLogInCurrentSpan("debug",e,n,i)}static log(e,n,i){w.addLogInCurrentSpan("log",e,n,i)}static warn(e,n,i){w.addLogInCurrentSpan("warn",e,n,i)}}const oP=()=>{!navigator.isReactNative&&typeof window!="undefined"&&(window.addEventListener("error",t=>{var e;!((e=t.filename)!=null&&e.includes("localhost"))&&t.lineno!==0&&m.error("window::error",{error:t.error},!0)}),window.addEventListener("unhandledrejection",t=>{var e,n,i,r,s,a,c,d;m.error("window::unhandledrejection",{error:t==null?void 0:t.reason,networkCall:{url:(n=(e=t==null?void 0:t.reason)==null?void 0:e.config)==null?void 0:n.url,baseURL:(r=(i=t==null?void 0:t.reason)==null?void 0:i.config)==null?void 0:r.baseURL,method:(a=(s=t==null?void 0:t.reason)==null?void 0:s.config)==null?void 0:a.method,status:(c=t==null?void 0:t.reason)==null?void 0:c.status,statusText:(d=t==null?void 0:t.reason)==null?void 0:d.statusText}},!0)}),window.addEventListener("offline",()=>{m.info("window::offline")}),window.addEventListener("online",()=>{m.info("window::online")}))},cP={"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"},gd={"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(gd).forEach(t=>{gd[t]=`{${cP[t.slice(0,2)]}} ${gd[t]}`});class D extends Error{constructor(e,n,i=!1){super(e),y(this,"code"),this.code=n,this.name="DyteError",this.message=`[ERR${this.code}]: ${gd[this.code]}
20
- ${this.message}`;try{let r=i;n&&n.endsWith("00")&&(r=!0),r&&m.error("DyteError",{error:{message:this.message,name:this.name,code:n}});const s=ms.getContext(ms.getMostRecentPeerId());if(s){const a=s.getValue("onError");try{a(this)}catch{}}typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("dyteError",{detail:this}))}catch{}}}function Vc(t,e,n,i){if(i instanceof D)throw i;if(i instanceof e){const r=new D(i.message,n);throw r.stack=i.stack,r}else throw i}function Jf(t,e,n){if(!t.value){const r=t.get,s=t.set;return r&&(t.get=function(){try{return r.apply(this)}catch(a){Vc(this,e,n,a)}}),s&&(t.set=function(a){try{return s.apply(this,[a])}catch(c){Vc(this,e,n,c)}}),t}const i=t.value;return t.value=function(...r){try{const s=i.apply(this,r);return s&&s instanceof Promise?s.catch(a=>{Vc(this,e,n,a)}):s}catch(s){Vc(this,e,n,s)}},t}function dP(t,e){return(n,i,r)=>{if(r)return Jf(r,t,e);for(const s of Reflect.ownKeys(n.prototype).filter(a=>a!=="constructor")){const a=Object.getOwnPropertyDescriptor(n.prototype,s);(a.value instanceof Function||a.get instanceof Function||a.set instanceof Function)&&Object.defineProperty(n.prototype,s,Jf(a,t,e))}}}const Lt=t=>dP(Error,t);function lP(t){let e=0,n,i;if(!t)return e;for(n=0;n<t.length;n+=1)i=t.charCodeAt(n),e=(e<<5)-e+i,e|=0;return Math.abs(e)%100+1}var Zi,er;const tE=class extends Nt.EventEmitter{constructor(){super(),S(this,Zi,void 0),S(this,er,void 0),y(this,"asyncPromiseTimeout"),T(this,Zi,new Map),T(this,er,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return p(this,null,function*(){o(this,Zi).set(t,[]);const n=o(this,er).get(t).map(()=>new Promise(i=>{o(this,Zi).get(t).push(i)}));jT(tE.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(n),new Promise((i,r)=>setTimeout(()=>r(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),o(this,Zi).delete(t)})}onAsync(t,e){const n=o(this,Zi),i=(...r)=>p(this,null,function*(){var s;try{yield e(...r)}catch(c){m.error("[onAsync]",{error:c})}const a=(s=n.get(t))==null?void 0:s.shift();a==null||a()});return o(this,er).get(t)||o(this,er).set(t,[]),o(this,er).get(t).push(i),super.on(t,i)}reset(){T(this,Zi,new Map),T(this,er,new Map),super.removeAllListeners()}};let uP=tE;Zi=new WeakMap,er=new WeakMap;const L=new uP;function hP(){Be.isElectron()&&window.dyteElectronGetDisplayMediaSource&&(navigator.mediaDevices.getDisplayMedia=()=>p(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 n=e.find(r=>{var s;return(s=r.id)==null?void 0:s.includes("screen")});n=n!=null?n:e[0];const i={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n.id}}};return yield navigator.mediaDevices.getUserMedia(i)}))}var x=(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))(x||{});class Ra extends Nt.EventEmitter{constructor(){super(),super.setMaxListeners(25)}emit(e,...n){return super.emit("*",e,...n),super.emit(e,...n)}on(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.on(e,n)}addListener(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.addListener(e,n)}off(e,n){return super.off(e,n)}once(e,n){return super.once(e,n)}prependListener(e,n){return super.prependListener(e,n)}prependOnceListener(e,n){return super.prependOnceListener(e,n)}removeListener(e,n){return super.removeListener(e,n)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}class gn extends Nt.EventEmitter{constructor(){super(),super.setMaxListeners(25)}emit(e,...n){return super.emit("*",e,...n),super.emit(e,...n)}on(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.on(e,n)}addListener(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.addListener(e,n)}off(e,n){return super.off(e,n)}once(e,n){return super.once(e,n)}prependListener(e,n){return super.prependListener(e,n)}prependOnceListener(e,n){return super.prependOnceListener(e,n)}removeListener(e,n){return super.removeListener(e,n)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}function pP(t,e=2){return t.replace(/[^\u00BF-\u1FFF\u2C00-\uD7FF\w\s]/g,"").trim().split(/\s+/).slice(0,e).map(n=>n.charAt(0)).join("").toUpperCase()}const Kf=1080,zf=1920,mP=(t,e,n,i,r,s)=>{let a=.5,c=.5;const d=r,h=s,u=Math.min(n/d,i/h);let g=d*u,E=h*u,b,k,A,M,B=1;return g<n&&(B=n/g),Math.abs(B-1)<1e-14&&E<i&&(B=i/E),g*=B,E*=B,A=d/(g/n),M=h/(E/i),b=(d-A)*a,k=(h-M)*c,b<0&&(b=0),k<0&&(k=0),A>d&&(A=d),M>h&&(M=h),[b,k,A,M,t,e,n,i]};var xn,po,jt,Vn,nt,ei,tr,tn,dt,mo,fo,nr,go;const nE=class extends gn{constructor(t,e,n,i){super(),S(this,xn,void 0),S(this,po,void 0),S(this,jt,void 0),S(this,Vn,void 0),S(this,nt,{height:Kf,width:zf}),S(this,ei,{brand:"#2160FD",background:"#141414",text:"#000000",videoBackground:"#191919",textOnBrand:"#EEEEEE"}),S(this,tr,void 0),S(this,tn,{}),S(this,dt,void 0),S(this,mo,void 0),S(this,fo,void 0),S(this,nr,void 0),S(this,go,!1),y(this,"cleanupEventListeners",()=>{o(this,po).unsubscribe("stageStatus",this.handlePipMediaControls),o(this,dt).removeListener("videoUpdate",this.onSelfVideoUpdateListener),o(this,dt).removeListener("audioUpdate",this.onSelfAudioUpdateListener),o(this,dt).removeListener("roomLeft",()=>this.disable())}),y(this,"enablePipMediaControls",()=>{this.mountAudioEvents(),this.mountVideoEvents()}),y(this,"onSelfVideoUpdateListener",({videoEnabled:r})=>{this.updateMediaSession("CAMERA",r)}),y(this,"onSelfAudioUpdateListener",({audioEnabled:r})=>{this.updateMediaSession("MIC",r)}),y(this,"handlePipMediaControls",r=>{r==="ON_STAGE"?this.enablePipMediaControls():this.unmountEvents()}),y(this,"eventCallback",r=>{r==="CAMERA"&&(o(this,dt).videoEnabled?o(this,dt).disableVideo():o(this,dt).enableVideo(),this.emit("cameraToggled")),r==="MIC"&&(o(this,dt).audioEnabled?o(this,dt).disableAudio():o(this,dt).enableAudio(),this.emit("micToggled")),r==="END"&&(L.emit(x.PIP_HANGUP),this.cleanupEventListeners(),this.emit("hangup"),this.cleanup())}),y(this,"unmountEvents",()=>{navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("togglemicrophone",void 0),navigator.mediaSession.setActionHandler("togglecamera",void 0))}),y(this,"animate",()=>{if(!this.isActive&&o(this,nr)==="active"){this.disable(!0);return}o(this,tn)!==void 0&&this.paintCanvas(),o(this,tr)!==void 0&&T(this,tr,requestAnimationFrame(()=>this.animate()))}),y(this,"disable",(r=!1)=>{T(this,nr,"idle"),this.cleanupEventListeners(),cancelAnimationFrame(o(this,tr)),r!==!0&&document.body.removeChild(o(this,jt)),T(this,tr,void 0),document.pictureInPictureElement&&document.exitPictureInPicture()}),T(this,po,t),T(this,nr,"idle"),T(this,dt,e),T(this,ei,{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}),n&&this.setupIcon("pin",n),i&&this.setupIcon("handRaise",i)}static _init(t,e){return p(this,null,function*(){let n,i;try{n=yield xc(iP),i=yield xc(rP)}catch{}return new nE(t,e,n,i)})}setupIcon(t,e){return p(this,null,function*(){switch(t){case"handRaise":T(this,fo,e);break;case"pin":T(this,mo,e);break}})}overrideIcon(t,e){return p(this,null,function*(){switch(t){case"handRaise":T(this,fo,yield xc(e));break;case"pin":T(this,mo,yield xc(e));break}})}constructImage(t){const e=new Image,n=new Blob([t],{type:"image/svg+xml"}),i=window.URL.createObjectURL(n);return new Promise(r=>{e.onload=()=>{r(e),window.URL.revokeObjectURL(i)},e.src=i})}createVideoContainer(){T(this,jt,document.createElement("div")),o(this,jt).style.width="0.1px",o(this,jt).style.height="0.1px",o(this,jt).style.overflow="hidden",o(this,jt).style.position="absolute",o(this,jt).style.bottom="0",o(this,jt).style.right="0",o(this,jt).style.opacity="0",o(this,jt).appendChild(o(this,Vn))}setupEventListeners(){o(this,po).subscribe("stageStatus",this.handlePipMediaControls),o(this,dt).addListener("videoUpdate",this.onSelfVideoUpdateListener),o(this,dt).addListener("audioUpdate",this.onSelfAudioUpdateListener),o(this,dt).addListener("roomLeft",()=>this.disable())}createCanvas(){const t=document.createElement("canvas");t.height=o(this,nt).height,t.width=o(this,nt).width,T(this,xn,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||o(this,dt).permissions.canProduceAudio&&navigator.mediaSession.setActionHandler("togglemicrophone",()=>{this.eventCallback("MIC")})}mountVideoEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||o(this,dt).permissions.canProduceVideo&&navigator.mediaSession.setActionHandler("togglecamera",()=>{this.eventCallback("CAMERA")})}getSources(){const t=Object.values(o(this,tn)).reduce((e,n)=>(e[n.pinned?"pinned":"regular"].push(n),e),{pinned:[],regular:[]});return[...t.pinned,...t.regular]}drawEmptyTile(t,e,n,i){if(o(this,xn)===void 0)return;const r=o(this,xn).getContext("2d"),s=o(this,xn).width,a=0,c=0,d=e-a*2,h=n-a*2,u=Math.floor(s/d),g=Math.floor(t/u),E=t%u*(d+a)+a,b=g*(h+a)+a,{displayText:k,image:A}=i!=null?i:{};r.fillStyle=k||A?o(this,ei).videoBackground:o(this,ei).background,r.strokeStyle=o(this,ei).brand,r.beginPath(),r.moveTo(E+c,b),r.arcTo(E+d,b,E+d,b+c,c),r.arcTo(E+d,b+h,E+d-c,b+h,c),r.arcTo(E,b+h,E,b+h-c,c),r.arcTo(E,b,E+c,b,c),r.closePath(),r.fill(),r.stroke();const M=d/6,B=d/2+E,K=h/2+b;r.save(),(k||A)&&(r.beginPath(),r.arc(B,K,M,0,Math.PI*2),r.fillStyle=o(this,ei).brand,r.fill(),A?(r.clip(),r.drawImage(A,B-M,K-M,M*2,M*2),r.restore()):k&&(r.fillStyle=o(this,ei).textOnBrand,r.font=`${M/2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(k,B,K)),this.drawIcons(i,E,b,Math.max(d,h)))}drawIcons(t,e,n,i){const r=Math.min(Math.max(i*.15,100),200),s=r*.2,a=r*.2;let c=e+s;const d=n+s,h=u=>{const g=o(this,xn).getContext("2d");g.save(),g.fillStyle=o(this,ei).background,g.beginPath(),g.moveTo(c+a,d),g.arcTo(c+r,d,c+r,d+a,a),g.arcTo(c+r,d+r,c+r-a,d+r,a),g.arcTo(c,d+r,c,d+r-a,a),g.arcTo(c,d,c+a,d,a),g.closePath(),g.fill(),typeof u=="string"?(g.font=`${r/1.5}px sans-serif`,g.fillStyle=o(this,ei).text,g.textAlign="center",g.textBaseline="top",g.fillText(u,r/2+c,d+s)):g.drawImage(u,c+s,d+s,r-s*2,r-s*2),c+=r+s,g.restore()};t.pinned&&h(o(this,mo)),t.handRaised&&h(o(this,fo))}drawTile(t,e,n){var i,r;if(o(this,xn)===void 0)return;const s=o(this,xn).getContext("2d"),a=this.getSources();let c=0,d=0;for(;c<o(this,nt).height-5;){let h=0;for(;h<o(this,nt).width-5&&d<n;){if((i=a[d])!=null&&i.enabled){const u=a[d].element,[g,E,b,k,A,M,B,K]=mP(h,c,t,e,u.videoWidth,u.videoHeight);(r=u==null?void 0:u.classList)!=null&&r.contains("mirror")?(s.save(),s.scale(-1,1),s.drawImage(u,g,E,b,k,-1*A,M,-1*B,K),s.restore()):s.drawImage(u,g,E,b,k,A,M,B,K),this.drawIcons(a[d],A,M,Math.max(B,K))}else this.drawEmptyTile(d,t,e,a[d]);d+=1,h+=t}c+=e}}calcGridElemSize(t){switch(t){case 0:case 1:return[o(this,nt).width,o(this,nt).height];case 2:return[Math.floor(o(this,nt).width/2),o(this,nt).height];case 3:case 4:return[Math.floor(o(this,nt).width/2),Math.floor(o(this,nt).height/2)];case 5:case 6:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/2)];case 7:case 8:case 9:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/3)];default:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/2)]}}paintCanvas(){let t=this.getSources().length;t!==1&&(t=t%2>0?t+1:t);const[e,n]=this.calcGridElemSize(t);this.drawTile(e,n,t)}isSupported(){var t;return!!window.chrome&&document.pictureInPictureEnabled&&((t=o(this,dt).config)==null?void 0:t.viewType)!=="LIVESTREAM"}get isActive(){return document.pictureInPictureElement!==null}cleanup(){if(T(this,go,!1),this.isSupported()&&document.exitPictureInPicture!==void 0&&document.pictureInPictureElement!==null&&document.exitPictureInPicture(),o(this,jt))try{document.body.removeChild(o(this,jt))}catch{}this.removeAllSources(),T(this,xn,void 0),T(this,Vn,void 0),T(this,tr,void 0)}init({height:t,width:e}={}){if(!this.isSupported())throw m.error("DytePip.unsupported"),new Error("Picture-in-picture is not available in this environment");if(o(this,go))return;T(this,go,!0),this.createCanvas(),this.setupMediaSessionEvents();const n=document.createElement("video");T(this,nt,{height:t!=null?t:Kf,width:e!=null?e:zf}),n.height=o(this,nt).height,n.width=o(this,nt).width,n.autoplay=!0,n.muted=!0,n.srcObject=o(this,xn).captureStream(24),T(this,Vn,n),o(this,Vn).onloadedmetadata=()=>{try{this.emit("pipStarted"),o(this,Vn).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){o(this,tn)[t]!==void 0&&(o(this,tn)[t].enabled=!0)}disableSource(t){o(this,tn)[t]!==void 0&&(o(this,tn)[t].enabled=!1)}generateAvatar(t,e){return p(this,null,function*(){if(!e)return;const n=new Image;try{const i=yield(yield fetch(e)).blob(),r=window.URL.createObjectURL(i);n.onload=()=>{this.updateSource(t,{image:n}),window.URL.revokeObjectURL(r)},n.src=r}catch(i){m.error("DytePip::GenerateAvatar",{error:i})}})}addSource(t,e,n,i=!1,r=void 0,s=void 0,a=!1){m.debug("DytePIP::AddSource",{pip:{id:t,handRaised:a}}),o(this,tn)[t]={id:t,element:e,enabled:n,pinned:i,displayText:r?pP(r):void 0,imageUrl:s,handRaised:a},s&&this.generateAvatar(t,s)}updateSource(t,e){m.info("DytePIP::UpdateSource",{pip:{id:t,handRaised:e.handRaised}});const n=o(this,tn)[t];n&&(o(this,tn)[t]=H(H({},n),e))}removeSource(t){delete o(this,tn)[t]}removePinnedSource(){Object.values(o(this,tn)).forEach(t=>{t.pinned&&this.removeSource(t.id)})}removeAllSources(){T(this,tn,{})}enable(){T(this,nr,"activating"),this.setupEventListeners(),this.updateMediaSession("CAMERA",o(this,dt).videoEnabled),this.updateMediaSession("MIC",o(this,dt).audioEnabled),document.body.appendChild(o(this,jt)),T(this,tr,requestAnimationFrame(()=>this.animate())),o(this,Vn).onloadedmetadata=()=>{o(this,Vn).requestPictureInPicture().then(()=>{T(this,nr,"active")})},o(this,Vn).readyState===4&&o(this,Vn).requestPictureInPicture().then(()=>{T(this,nr,"active")})}};let fP=nE;xn=new WeakMap,po=new WeakMap,jt=new WeakMap,Vn=new WeakMap,nt=new WeakMap,ei=new WeakMap,tr=new WeakMap,tn=new WeakMap,dt=new WeakMap,mo=new WeakMap,fo=new WeakMap,nr=new WeakMap,go=new WeakMap;var Ai;(function(t){t[t.PUBLISHER=0]="PUBLISHER",t[t.SUBSCRIBER=1]="SUBSCRIBER"})(Ai||(Ai={}));var di;(function(t){t[t.AUDIO=0]="AUDIO",t[t.VIDEO=1]="VIDEO"})(di||(di={}));class gP extends _{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 iE=new gP;class vP extends _{constructor(){super("media.HeaderExtension",[{no:1,name:"direction",kind:"scalar",opt:!0,T:9},{no:2,name:"uri",kind:"scalar",T:9}])}}const yP=new vP;class EP extends _{constructor(){super("media.Fingerprint",[{no:1,name:"algorithm",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}])}}new EP;class SP extends _{constructor(){super("media.SessionDescription",[{no:1,name:"target",kind:"enum",T:()=>["media.Target",Ai]},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"sdp",kind:"scalar",T:9}])}}const Kn=new SP;class TP extends _{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 bP=new TP;class kP extends _{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:()=>Kn},{no:4,name:"private_ice",kind:"scalar",opt:!0,T:8},{no:5,name:"producers",kind:"message",repeat:1,T:()=>bP}])}}const wP=new kP;class _P extends _{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 IP=new _P;class CP extends _{constructor(){super("media.CreateTransportResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:4,name:"producer_ids",kind:"scalar",repeat:2,T:9}])}}const rE=new CP;class RP extends _{constructor(){super("media.RenegotiateRequest",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn}])}}const PP=new RP;class AP extends _{constructor(){super("media.RenegotiateResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn}])}}new AP;class MP extends _{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 OP=new MP;class DP extends _{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 NP=new DP;class LP extends _{constructor(){super("media.ProducerEntry",[{no:1,name:"producing_transport_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9}])}}new LP;class xP extends _{constructor(){super("media.ConsumerEntry",[{no:1,name:"consuming_transport_id",kind:"scalar",T:9},{no:2,name:"consumer_id",kind:"scalar",T:9}])}}new xP;class VP extends _{constructor(){super("media.ProducerState",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:()=>["media.ProducerKind",di]},{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:()=>iE}])}}const Tc=new VP;class UP extends _{constructor(){super("media.ConsumerState",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc},{no:3,name:"producer_track",kind:"message",T:()=>NP},{no:4,name:"error_code",kind:"scalar",opt:!0,T:9}])}}const BP=new UP;class FP extends _{constructor(){super("media.ProducerIdToConsumerMap",[{no:1,name:"map",kind:"map",K:9,V:{kind:"message",T:()=>BP}}])}}const sE=new FP;class jP extends _{constructor(){super("media.PeerRtpCapabilitites",[{no:1,name:"sender",kind:"message",T:()=>Qf},{no:2,name:"receiver",kind:"message",T:()=>Qf}])}}const aE=new jP;class WP extends _{constructor(){super("media.RtpCapability",[{no:1,name:"codecs",kind:"message",repeat:1,T:()=>iE},{no:2,name:"header_extensions",kind:"message",repeat:1,T:()=>yP}])}}const Yf=new WP;class HP extends _{constructor(){super("media.RtpCapabilitites",[{no:1,name:"audio",kind:"message",T:()=>Yf},{no:2,name:"video",kind:"message",T:()=>Yf}])}}const Qf=new HP;class qP extends _{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 GP=new qP;class $P extends _{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 JP=new $P;class KP extends _{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:()=>JP},{no:9,name:"capabilities",kind:"message",T:()=>aE}])}}const zP=new KP;class YP extends _{constructor(){super("media.edge.PeerJoinCompleteRequest",[])}}const QP=new YP;class XP extends _{constructor(){super("media.edge.PeerLeaveRequest",[{no:1,name:"close_room",kind:"scalar",T:8}])}}const ZP=new XP;class eA extends _{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 eA;class tA extends _{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:()=>GP},{no:5,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const nA=new tA;class iA extends _{constructor(){super("media.edge.ConsumePeersRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>nA},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const rA=new iA;class sA extends _{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:()=>Kn},{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 aA=new sA;class oA extends _{constructor(){super("media.edge.SelectedPeersRequest",[])}}new oA;class cA extends _{constructor(){super("media.edge.GlobalPeerPinningRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const dA=new cA;class lA extends _{constructor(){super("media.edge.ProducerToggleRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}const Uc=new lA;class uA extends _{constructor(){super("media.edge.ConsumerToggleRequest",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}new uA;class hA extends _{constructor(){super("media.edge.ProducerCloseRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const pA=new hA;class mA extends _{constructor(){super("media.edge.ConsumerCloseRequest",[{no:1,name:"consumer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const fA=new mA;class gA extends _{constructor(){super("media.edge.KickPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new gA;class vA extends _{constructor(){super("media.edge.KickAllPeersRequest",[{no:1,name:"propagate_kick_across_rooms",kind:"scalar",T:8}])}}const oE=new vA;class yA extends _{constructor(){super("media.edge.PeerDisplayNameEditRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}const EA=new yA;class SA extends _{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 TA=new SA;class bA extends _{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 kA=new bA;class wA extends _{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 _A=new wA;class IA extends _{constructor(){super("media.edge.ErrorResponse",[{no:1,name:"error_message",kind:"scalar",T:9},{no:2,name:"event_id",kind:"scalar",T:5}])}}const CA=new IA;class RA extends _{constructor(){super("media.edge.EmptyResponse",[])}}new RA;class PA extends _{constructor(){super("media.edge.RoomParticipants",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"producer_states",kind:"message",repeat:1,T:()=>Tc},{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:()=>aE}])}}const cE=new PA;class AA extends _{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 _h=new AA;class MA extends _{constructor(){super("media.edge.SelectedPeersDiffEntry",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"priority",kind:"scalar",T:5}])}}const OA=new MA;class DA extends _{constructor(){super("media.edge.SelectedPeersDiffResponse",[{no:1,name:"entries",kind:"message",repeat:1,T:()=>OA}])}}const Xf=new DA;class NA extends _{constructor(){super("media.edge.PeerJoinResponse",[])}}new NA;class LA extends _{constructor(){super("media.edge.PeerJoinCompleteResponse",[{no:1,name:"room_state",kind:"message",T:()=>_A},{no:2,name:"participants",kind:"message",repeat:1,T:()=>cE},{no:3,name:"selected_peers",kind:"message",T:()=>_h},{no:4,name:"max_preferred_streams",kind:"scalar",T:5}])}}const Ih=new LA;class xA extends _{constructor(){super("media.edge.PeerLeaveResponse",[{no:1,name:"closed",kind:"scalar",T:8}])}}const VA=new xA;class UA extends _{constructor(){super("media.edge.ConsumeMultipleProducerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>sE}])}}new UA;class BA extends _{constructor(){super("media.edge.ConsumePeerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>sE},{no:3,name:"description",kind:"message",T:()=>Kn}])}}const FA=new BA;class jA extends _{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:()=>Kn}])}}const WA=new jA;class HA extends _{constructor(){super("media.edge.ProducerScoreResponse",[{no:1,name:"responseid",kind:"scalar",T:9},{no:2,name:"score",kind:"message",T:()=>OP}])}}new HA;class qA extends _{constructor(){super("media.edge.ActiveSpeakerResponse",[{no:1,name:"responsepeer_id",kind:"scalar",T:9},{no:2,name:"volume",kind:"scalar",T:5}])}}new qA;class GA extends _{constructor(){super("media.edge.NoActiveSpeakerResponse",[])}}new GA;class $A extends _{constructor(){super("media.edge.ProducerToggleResponse",[])}}new $A;class JA extends _{constructor(){super("media.edge.ConsumerToggleResponse",[])}}new JA;class KA extends _{constructor(){super("media.edge.ProducerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Kn}])}}const zA=new KA;class YA extends _{constructor(){super("media.edge.ConsumerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Kn}])}}const QA=new YA;class XA extends _{constructor(){super("media.edge.GlobalPeerPinningResponse",[])}}new XA;class ZA extends _{constructor(){super("media.edge.KickPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new ZA;class eM extends _{constructor(){super("media.edge.KickAllPeersResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new eM;class tM extends _{constructor(){super("media.edge.HostMediaControlForPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const nM=new tM;class iM extends _{constructor(){super("media.edge.HostMediaControlForAllPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const rM=new iM;class sM extends _{constructor(){super("media.edge.PeerDisplayNameEditResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const aM=new sM;class oM extends _{constructor(){super("media.edge.PeerJoinBroadcastResponse",[{no:1,name:"participant",kind:"message",T:()=>cE}])}}const Zf=new oM;class cM extends _{constructor(){super("media.edge.TrackSubscriptionKind",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8}])}}const eg=new cM;class dM extends _{constructor(){super("media.edge.TrackSubscription",[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"webcam",kind:"message",T:()=>eg},{no:3,name:"screenshare",kind:"message",T:()=>eg}])}}const lM=new dM;class uM extends _{constructor(){super("media.edge.PeerProducingTransportCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"transport_details",kind:"message",T:()=>rE},{no:3,name:"track_subscriptions",kind:"message",repeat:1,T:()=>lM}])}}new uM;class hM extends _{constructor(){super("media.edge.PeerProducerCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc}])}}const pM=new hM;class mM extends _{constructor(){super("media.edge.PeerProducerToggleBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc},{no:3,name:"initiator_participant_id",kind:"scalar",opt:!0,T:9}])}}const tg=new mM;class fM extends _{constructor(){super("media.edge.PeerProducerCloseBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc}])}}const gM=new fM;class vM extends _{constructor(){super("media.edge.PeerLeaveBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const Ch=new vM;class yM extends _{constructor(){super("media.edge.GlobalPeerPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const ng=new yM;class EM extends _{constructor(){super("media.edge.GlobalPeerUnPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new EM;class SM extends _{constructor(){super("media.edge.RecordingStartedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new SM;class TM extends _{constructor(){super("media.edge.RecordingStoppedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new TM;class bM extends _{constructor(){super("media.edge.PeerDisplayNameEditBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}new bM;class kM extends _{constructor(){super("media.edge.PeerPingRequestBroadcastResponse",[{no:1,name:"password",kind:"scalar",T:9}])}}new kM;class wM extends _{constructor(){super("media.edge.MediaRoomTerminationBroadcastResponse",[{no:1,name:"reason",kind:"scalar",T:9}])}}new wM;class _M extends _{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 Cu=new _M;class IM extends _{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 IM;class CM extends _{constructor(){super("socket.api.ErrorMessage",[{no:1,name:"code",kind:"scalar",opt:!0,T:5},{no:2,name:"message",kind:"scalar",T:9}])}}const RM=new CM;var fs;(function(t){t[t.BROWSER=0]="BROWSER",t[t.TRACK=1]="TRACK",t[t.COMPOSITE=2]="COMPOSITE"})(fs||(fs={}));var wi;(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"})(wi||(wi={}));var Rh;(function(t){t[t.NONE=0]="NONE",t[t.RECORDER=1]="RECORDER",t[t.LIVESTREAMER=2]="LIVESTREAMER"})(Rh||(Rh={}));var Ph;(function(t){t[t.PEERS=0]="PEERS",t[t.ROOMS=1]="ROOMS"})(Ph||(Ph={}));var ul;(function(t){t[t.HIVE=0]="HIVE",t[t.CHAT=1]="CHAT",t[t.PING=2]="PING"})(ul||(ul={}));class PM extends _{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 AM=new PM;class MM extends _{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",wi,"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:()=>AM}])}}const $l=new MM;class OM extends _{constructor(){super("socket.room.PeerInfoResponse",[{no:1,name:"peer",kind:"message",T:()=>$l}])}}const Gs=new OM;class DM extends _{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",wi,"STAGE_TYPE_"]}])}}const ig=new DM;class NM extends _{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 LM=new NM;class xM extends _{constructor(){super("socket.room.RoomPeersInfoResponse",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>$l}])}}const Ru=new xM;class VM extends _{constructor(){super("socket.room.RoomPeerCountResponse",[{no:1,name:"count",kind:"scalar",T:4,L:2}])}}const rg=new VM;class UM extends _{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:()=>FM},{no:6,name:"room_uuid",kind:"scalar",opt:!0,T:9}])}}const dE=new UM;class BM extends _{constructor(){super("socket.room.ActiveRecording",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",fs]},{no:3,name:"recording_status",kind:"scalar",T:9}])}}const FM=new BM;class jM extends _{constructor(){super("socket.room.RoomInfoResponse",[{no:1,name:"room",kind:"message",T:()=>dE}])}}const sg=new jM;class WM extends _{constructor(){super("socket.room.GetPeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9}])}}const lE=new WM;class HM extends _{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 HM;class qM extends _{constructor(){super("socket.room.JoinRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>$l},{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",ul,"CAPABILITIES_"]},{no:8,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const GM=new qM;class $M extends _{constructor(){super("socket.room.LeaveRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>$l},{no:2,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const JM=new $M;class KM extends _{constructor(){super("socket.room.UpdateRoomInfoRequest",[{no:1,name:"room",kind:"message",T:()=>dE}])}}new KM;class zM extends _{constructor(){super("socket.room.GetConnectedRoomsDumpRequest",[])}}new zM;class YM extends _{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 im=new YM;class QM extends _{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 XM=new QM;class ZM extends _{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:()=>XM}])}}const ag=new ZM;class e1 extends _{constructor(){super("socket.room.GetConnectedRoomsDumpResponse",[{no:1,name:"parent_meeting",kind:"message",T:()=>ag},{no:2,name:"meetings",kind:"message",repeat:1,T:()=>ag}])}}const t1=new e1;class n1 extends _{constructor(){super("socket.room.CreateRoomRequestPayload",[{no:1,name:"title",kind:"scalar",opt:!0,T:9}])}}const i1=new n1;class r1 extends _{constructor(){super("socket.room.CreateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>i1}])}}const s1=new r1;class a1 extends _{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:()=>im}])}}const o1=new a1;class c1 extends _{constructor(){super("socket.room.CreateConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>o1}])}}const og=new c1;class d1 extends _{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 l1=new d1;class u1 extends _{constructor(){super("socket.room.UpdateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>l1}])}}new u1;class h1 extends _{constructor(){super("socket.room.DisableRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9}])}}const p1=new h1;class m1 extends _{constructor(){super("socket.room.DisableConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>p1}])}}const f1=new m1;class g1 extends _{constructor(){super("socket.room.DisableConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>E1}])}}const v1=new g1;class y1 extends _{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:()=>im}])}}const E1=new y1;class S1 extends _{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 T1=new S1;class b1 extends _{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:()=>T1}])}}const k1=new b1;class w1 extends _{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:()=>im}])}}const uE=new w1;class _1 extends _{constructor(){super("socket.room.MovePeersBetweenRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>uE}])}}new _1;class I1 extends _{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 C1=new I1;class R1 extends _{constructor(){super("socket.room.GetAllAddedParticipantsResponse",[{no:1,name:"participants",kind:"message",repeat:1,T:()=>M1}])}}const P1=new R1;class A1 extends _{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 M1=new A1;class O1 extends _{constructor(){super("socket.room.RemoveParticipantsRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const hE=new O1;class D1 extends _{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",Ph,"BROADCAST_TYPE_"]}])}}const Va=new D1;class N1 extends _{constructor(){super("socket.room.AcceptWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const L1=new N1;class x1 extends _{constructor(){super("socket.room.DenyWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const V1=new x1;class U1 extends _{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 B1=new U1;class F1 extends _{constructor(){super("socket.room.GetWaitingRoomRequests",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>B1}])}}const cg=new F1;class j1 extends _{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 dg=new j1;var Ah;(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"})(Ah||(Ah={}));var yr;(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"})(yr||(yr={}));class W1 extends _{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 H1=new W1;class q1 extends _{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 G1=new q1;class $1 extends _{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 J1=new $1;class K1 extends _{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 z1=new K1;class Y1 extends _{constructor(){super("socket.preset.ChatPermissionUpdate",[{no:1,name:"public",kind:"message",T:()=>J1},{no:2,name:"private",kind:"message",T:()=>z1}])}}const Q1=new Y1;class X1 extends _{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 Z1=new X1;class eO extends _{constructor(){super("socket.preset.StreamPermission",[{no:1,name:"can_produce",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",yr,"STREAM_PERMISSION_TYPE_"]},{no:2,name:"can_consume",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",yr,"STREAM_PERMISSION_TYPE_"]}])}}const Pu=new eO;class tO extends _{constructor(){super("socket.preset.MediaPermissionUpdate",[{no:1,name:"video",kind:"message",T:()=>Pu},{no:2,name:"audio",kind:"message",T:()=>Pu},{no:3,name:"screenshare",kind:"message",T:()=>Pu}])}}const nO=new tO;class iO extends _{constructor(){super("socket.preset.PresetUpdates",[{no:1,name:"polls",kind:"message",T:()=>H1},{no:2,name:"plugins",kind:"message",T:()=>G1},{no:3,name:"chat",kind:"message",T:()=>Q1},{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",Ah,"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",Rh,"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:()=>Z1},{no:23,name:"media",kind:"message",T:()=>nO}])}}const rm=new iO;class rO extends _{constructor(){super("socket.preset.ReadPeersPresetRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const sO=new rO;class aO extends _{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 oO=new aO;class cO extends _{constructor(){super("socket.preset.ReadPeersPresetResponse",[{no:1,name:"peer_presets",kind:"message",repeat:1,T:()=>oO}])}}const dO=new cO;class lO extends _{constructor(){super("socket.preset.UpdatePeerPreset",[{no:1,name:"user_ids",kind:"scalar",T:9},{no:2,name:"patch",kind:"message",T:()=>rm}])}}const pE=new lO;class uO extends _{constructor(){super("socket.preset.UpdatePeersPresetRequest",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>pE}])}}const hO=new uO;class pO extends _{constructor(){super("socket.preset.UpdatePeersPresetResponse",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>pE}])}}const lg=new pO;class mO extends _{constructor(){super("socket.preset.PeerUserIDMap",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9}])}}const fO=new mO;class gO extends _{constructor(){super("socket.preset.BulkUpdatePeerPresetRequest",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>fO},{no:2,name:"patch",kind:"message",T:()=>rm}])}}new gO;class vO extends _{constructor(){super("socket.preset.BulkUpdatePeerPresetResponse",[{no:2,name:"patch",kind:"message",T:()=>rm}])}}new vO;class yO extends _{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 Cs=new yO;class EO extends _{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 SO=new EO;class TO extends _{constructor(){super("socket.chat.GetPaginatedChatMessageRoomResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Cs},{no:2,name:"next",kind:"scalar",T:8}])}}const bO=new TO;class kO extends _{constructor(){super("socket.chat.GetChatMessagesResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Cs}])}}const mE=new kO;class wO extends _{constructor(){super("socket.chat.SendChatMessageToRoomRequest",[{no:1,name:"payload_type",kind:"scalar",T:5},{no:2,name:"payload",kind:"scalar",T:9}])}}const _O=new wO;class IO extends _{constructor(){super("socket.chat.SendChatMessageToRoomResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Au=new IO;class CO extends _{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 RO=new CO;class PO extends _{constructor(){super("socket.chat.SendChatMessageToPeersResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Mu=new PO;class AO extends _{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 MO=new AO;class OO extends _{constructor(){super("socket.chat.SendChatMessageToChannelResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}new OO;class DO extends _{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 NO=new DO;class LO extends _{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 xO=new LO;class VO extends _{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 Bc=new VO;class UO extends _{constructor(){super("socket.chat.EditChatMessageResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Fc=new UO;class BO extends _{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 FO=new BO;class jO extends _{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 jc=new jO;class WO extends _{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 HO=new WO;class qO extends _{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 GO=new qO;class $O extends _{constructor(){super("socket.chat.MarkChannelIndexAsReadResponse",[{no:1,name:"channel_index",kind:"scalar",T:9}])}}const JO=new $O;class KO extends _{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 zO=new KO;class YO extends _{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 QO=new YO;class XO extends _{constructor(){super("socket.chat.CreateChatChannelResponse",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}new XO;class ZO extends _{constructor(){super("socket.chat.GetChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}const eD=new ZO;class tD extends _{constructor(){super("socket.chat.LatestMessageAndUnreadCount",[{no:1,name:"message",kind:"message",T:()=>Cs},{no:2,name:"unread_count",kind:"scalar",T:4,L:2}])}}const nD=new tD;class iD extends _{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:()=>nD},{no:7,name:"target_user_ids",kind:"scalar",repeat:2,T:9}])}}const rD=new iD;class sD extends _{constructor(){super("socket.chat.GetChatChannelResponse",[{no:1,name:"chat_channels",kind:"message",repeat:1,T:()=>rD}])}}const fi=new sD;class aD extends _{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 oD=new aD;class cD extends _{constructor(){super("socket.chat.GetChatChannelMembersResponse",[{no:1,name:"channel_members",kind:"message",repeat:1,T:()=>oD}])}}const dD=new cD;class lD extends _{constructor(){super("socket.plugin.AddPluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const uD=new lD;class hD extends _{constructor(){super("socket.plugin.RemovePluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const pD=new hD;class mD extends _{constructor(){super("socket.plugin.EnablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const fD=new mD;class gD extends _{constructor(){super("socket.plugin.DisablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const vD=new gD;class yD extends _{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 ED=new yD;class SD extends _{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 TD=new SD;class bD extends _{constructor(){super("socket.plugin.PluginEventToRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const kD=new bD;class wD extends _{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 _D=new wD;class ID extends _{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 sm=new ID;class CD extends _{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:()=>sm}])}}const ug=new CD;class RD extends _{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:()=>sm}])}}const PD=new RD;class AD extends _{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:()=>sm}])}}const MD=new AD;class OD extends _{constructor(){super("socket.plugin.PluginStoreDeleteRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9}])}}const DD=new OD;class ND extends _{constructor(){super("socket.plugin.EnablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"enabled_by",kind:"scalar",T:9}])}}const Mh=new ND;class LD extends _{constructor(){super("socket.plugin.EnablePluginsResponse",[{no:1,name:"plugins",kind:"message",repeat:1,T:()=>Mh}])}}const xD=new LD;class VD extends _{constructor(){super("socket.plugin.DisablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"disabled_by",kind:"scalar",T:9}])}}const hg=new VD;class UD extends _{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 BD=new UD;class FD extends _{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:()=>BD}])}}const pg=new FD;class jD extends _{constructor(){super("socket.plugin.PluginEventResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const mg=new jD;class WD extends _{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 fg=new WD;class HD extends _{constructor(){super("socket.livestreaming.GetStagePeersResponse",[{no:1,name:"stage_peers",kind:"scalar",repeat:2,T:9}])}}const gg=new HD;class qD extends _{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 GD=new qD;class $D extends _{constructor(){super("socket.livestreaming.GetStageRequestsResponse",[{no:1,name:"stage_requests",kind:"message",repeat:1,T:()=>GD}])}}const Ou=new $D;class JD extends _{constructor(){super("socket.livestreaming.GrantStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const KD=new JD;class zD extends _{constructor(){super("socket.livestreaming.DenyStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const YD=new zD;class QD extends _{constructor(){super("socket.livestreaming.LeaveStageRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const vg=new QD;class XD extends _{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:()=>eN},{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 fE=new XD;class ZD extends _{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:()=>nN}])}}const eN=new ZD;class tN extends _{constructor(){super("socket.polls.PollVote",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9}])}}const nN=new tN;class iN extends _{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 rN=new iN;class sN extends _{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 aN=new sN;class oN extends _{constructor(){super("socket.polls.UpdatePollResponse",[{no:1,name:"poll",kind:"message",T:()=>fE}])}}const Du=new oN;class cN extends _{constructor(){super("socket.polls.GetPollsResponse",[{no:1,name:"polls",kind:"message",repeat:1,T:()=>fE}])}}const dN=new cN;class lN extends _{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",fs]}])}}const yg=new lN;class uN extends _{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(),n=Date.now();return e.seconds=xe.from(Math.floor(n/1e3)).toBigInt(),e.nanos=n%1e3*1e6,e}toDate(e){return new Date(xe.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){const n=this.create(),i=e.getTime();return n.seconds=xe.from(Math.floor(i/1e3)).toBigInt(),n.nanos=i%1e3*1e6,n}internalJsonWrite(e,n){let i=xe.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 r="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",r)}internalJsonRead(e,n,i){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+Dp(e)+".");let r=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(!r)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>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=xe.from(s/1e3).toBigInt(),i.nanos=0,r[7]&&(i.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),i}}new uN;class hN extends _{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}])}}const Oh=new hN;class pN extends _{constructor(){super("common.BulkedHubMessage",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Oh}])}}new pN;class mN extends _{constructor(){super("common.CFWorkersResponse",[{no:1,name:"responses",kind:"message",repeat:1,T:()=>Oh},{no:2,name:"broadcast_responses",kind:"message",repeat:1,T:()=>Oh}])}}new mN;const fN=0,gN=1,vN=2,yN=3,EN=4,SN=5,TN={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},bN={getMessages:0,sendMessageToRoom:1,sendMessageToPeers:2,editMessage:3,deleteMessage:4,getPaginatedMessages:5,sendMessageToChannel:6,searchChannelMessages:7,getAllChatChannels:8,markChannelIndexAsRead:9,pinMessage:10},kN={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},wN={createPoll:0,getPolls:1,votePoll:2,updatePoll:3},gE={unknown:0,createWebRTCTransport:1,produce:2,consume:3,toggleProducer:4,toggleConsumer:5,closeProducer:6,closeConsumer:7,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},_N={createChatChannel:0,getChatChannel:1,deprecatedGetAllChatChannels:2,getChannelMembers:3,updateChatChannel:4},IN={getUserPresets:0,updateUserPreset:1};function Pa(t,e){return Object.keys(e).reduce((n,i)=>(n[i]=(t<<16)+e[i],n),{})}function vE(t,e){return Object.keys(t).reduce((n,i)=>(n[i]=e|t[i],n),{})}const Y=Pa(fN,TN),Ge=Pa(gN,bN),ie=Pa(vN,kN),Si=Pa(yN,wN),ss=Pa(EN,_N),In=vE(gE,16777216),Hn=vE(gE,50331648),vd=Pa(SN,IN);var CN=Object.defineProperty,RN=Object.getOwnPropertyDescriptor,am=(t,e,n,i)=>{for(var r=i>1?void 0:i?RN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&CN(e,n,r),r},Nr,Eg;const Dh=(Eg=class{constructor(t){S(this,Nr,void 0),T(this,Nr,t)}createChannel(t,e,n,i="public",r=!1){return p(this,null,function*(){const s={displayName:t,targetUserIds:e,displayPictureUrl:n,visibility:i,isDirectMessage:r};r&&(s.visibility="private");const a=yield o(this,Nr).sendMessagePromise(ss.createChatChannel,zO.toBinary(s)),c=fi.fromBinary(a.payload).chatChannels;return Dh.formatChannel(c[0])})}updateChannel(t,e){return p(this,null,function*(){const n=yield o(this,Nr).sendMessagePromise(ss.updateChatChannel,QO.toBinary({chatChannelId:t,targetUserIds:e.memberIds,displayName:e.displayName,displayPictureUrl:e.displayPictureUrl,visibility:e.visibility})),i=fi.fromBinary(n.payload).chatChannels;return Dh.formatChannel(i[0])})}static formatChannel(t){var e;const{latestMessageAndUnreadCount:n}=t,i=ee(H({},t),{id:t.chatChannelId,memberIds:t.targetUserIds,unreadCount:(e=n==null?void 0:n.unreadCount)!=null?e:0});return n!=null&&n.message&&(i.latestMessage=Ci.formatSocketServiceMessage(n.message)),delete i.chatChannelId,delete i.targetUserIds,delete i.latestMessageAndUnreadCount,i}getChannelMembers(t){return p(this,null,function*(){try{const e=yield o(this,Nr).sendMessagePromise(ss.getChannelMembers,eD.toBinary({chatChannelId:t}));return dD.fromBinary(e.payload).channelMembers.map(n=>{var i=n,{id:r}=i,s=Ml(i,["id"]);return ee(H({},s),{userId:r})})}catch{return[]}})}on(t,e){let n,i;switch(t){case ss.createChatChannel:{n=fi.fromBinary.bind(fi),i=fi.create();break}case ss.updateChatChannel:{n=fi.fromBinary.bind(fi),i=fi.create();break}}if(!n){m.warn(`ChatChannelSocketHandler::Event ${t} is not recognized`);return}o(this,Nr).on(t,({payload:r})=>{let s=i;try{s=n(r)}catch(a){m.error("ChatChannelSocketHandler::on::binary_decode_error",{error:a})}return e(s)})}},Nr=new WeakMap,Eg);let Es=Dh;am([w.trace("ChatChannelHandler.createChannel")],Es.prototype,"createChannel",1);am([w.trace("ChatChannelHandler.updateChannel")],Es.prototype,"updateChannel",1);am([w.trace("ChatChannelHandler.getChannelMembers")],Es.prototype,"getChannelMembers",1);var PN=Object.defineProperty,AN=Object.getOwnPropertyDescriptor,zn=(t,e,n,i)=>{for(var r=i>1?void 0:i?AN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&PN(e,n,r),r},$t=(t=>(t[t.TEXT=0]="TEXT",t[t.IMAGE=1]="IMAGE",t[t.FILE=2]="FILE",t[t.CUSTOM=3]="CUSTOM",t))($t||{}),Wt;class Cn{constructor(e){S(this,Wt,void 0),T(this,Wt,e)}getChatMessages(){return o(this,Wt).sendMessagePromise(Ge.getMessages)}getChatMessagesPaginated(e,n,i,r=0,s=""){return p(this,null,function*(){const a={timeStamp:e,size:n,from:r,reversed:i,channelId:s},c=yield o(this,Wt).sendMessagePromise(Ge.getPaginatedMessages,SO.toBinary(a));return c.payload?bO.fromBinary(c.payload):{messages:[],next:!1}})}sendMessageToRoom(e,n){const i={payloadType:n,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToRoom,_O.toBinary(i))}sendMessageToPeers(e,n,i){const r={payloadType:n,peerIds:i,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToPeers,RO.toBinary(r))}sendMessageToChannel(e,n,i){const r={payloadType:n,channelId:i,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToChannel,MO.toBinary(r))}sendMessage(e,n,i,r){if(r&&this.sendMessageToChannel(e,n,r),i&&i.length>0){this.sendMessageToPeers(e,n,i);return}this.sendMessageToRoom(e,n)}editMessage(e,n,i,r,s){return p(this,null,function*(){const a={chatId:e,payloadType:i,payload:n};r&&(a.channelId=r),s!==void 0&&(a.pinned=s);const c=yield o(this,Wt).sendMessagePromise(Ge.editMessage,NO.toBinary(a));return Fc.fromBinary(c.payload).message})}deleteMessage(e,n){return p(this,null,function*(){const i={chatId:e};n&&(i.channelId=n);const r=yield o(this,Wt).sendMessagePromise(Ge.deleteMessage,FO.toBinary(i)),s=jc.fromBinary(r.payload);return H({id:s.chatId},s.channelId?{channelId:s.channelId}:{})})}searchMessages(e,n){return p(this,null,function*(){var i,r,s;const a={searchTerm:e,timeStamp:(i=n.timestamp)!=null?i:Date.now(),size:(r=n.size)!=null?r:75,from:0,reversed:(s=n.reversed)!=null?s:!0};n.channelId&&(a.channelId=n.channelId);try{const c=yield o(this,Wt).sendMessagePromise(Ge.searchChannelMessages,HO.toBinary(a));return mE.fromBinary(c.payload).messages}catch{return[]}})}getAllChannels(){return p(this,null,function*(){try{const e=yield o(this,Wt).sendMessagePromise(Ge.getAllChatChannels);return fi.fromBinary(e.payload).chatChannels.map(Es.formatChannel)}catch{return[]}})}markLastReadMessage(e,n){return p(this,null,function*(){const i=yield o(this,Wt).sendMessagePromise(Ge.markChannelIndexAsRead,GO.toBinary({channelId:e,userId:n.userId,channelIndex:n.channelIndex}));return JO.fromBinary(i.payload).channelIndex})}setPinState(e,n){return p(this,null,function*(){const i={chatId:e.id,pinned:n,channelId:e.channelId},r=yield o(this,Wt).sendMessagePromise(Ge.pinMessage,xO.toBinary(i));return Bc.fromBinary(r.payload)})}on(e,n){let i,r;switch(e){case Ge.sendMessageToRoom:{i=Au.fromBinary.bind(Au),r=Au.create();break}case Ge.sendMessageToPeers:{i=Mu.fromBinary.bind(Mu),r=Mu.create();break}case Ge.editMessage:{i=Fc.fromBinary.bind(Fc),r=Fc.create();break}case Ge.pinMessage:{i=Bc.fromBinary.bind(Bc),r=Bc.create();break}case Ge.deleteMessage:{i=jc.fromBinary.bind(jc),r=jc.create();break}}if(!i){m.warn(`ChatSocketHandler::Event ${e} is not recognized`);return}o(this,Wt).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("chatSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}}Wt=new WeakMap;zn([w.trace("SocketService.getChatMessages")],Cn.prototype,"getChatMessages",1);zn([w.trace("SocketService.getChatMessagesPaginated")],Cn.prototype,"getChatMessagesPaginated",1);zn([w.trace("SocketService.sendMessageToRoom")],Cn.prototype,"sendMessageToRoom",1);zn([w.trace("SocketService.sendMessageToPeers")],Cn.prototype,"sendMessageToPeers",1);zn([w.trace("SocketService.sendMessageToChannel")],Cn.prototype,"sendMessageToChannel",1);zn([w.trace("SocketService.sendMessage")],Cn.prototype,"sendMessage",1);zn([w.trace("SocketService.editMessage")],Cn.prototype,"editMessage",1);zn([w.trace("SocketService.deleteMessage")],Cn.prototype,"deleteMessage",1);zn([w.trace("SocketService.searchMessages")],Cn.prototype,"searchMessages",1);zn([w.trace("SocketService.getAllChannels")],Cn.prototype,"getAllChannels",1);zn([w.trace("SocketService.markLastReadMessage")],Cn.prototype,"markLastReadMessage",1);function MN(t){return t.replace(/([-_]\w)/g,e=>e[1].toUpperCase())}function Gn(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>Gn(n));const e={};return Object.keys(t).forEach(n=>{const i=Op(n)?n:MN(n);e[i]=Gn(t[n])}),e}function ON(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function yE(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>yE(n));const e={};return Object.keys(t).forEach(n=>{const i=Op(n)?n:ON(n);e[i]=t[n]}),e}function hl(t,e={}){return t==null?{}:(Object.getOwnPropertyNames(t).forEach(n=>{if(typeof t[n]!="function"){if(typeof t[n]=="object"){hl(t[n],e[n]={});return}e[n]=t[n]}}),e)}class Sg{constructor(e){y(this,"defaults"),this.defaults={baseURL:e.baseURL,headers:{common:{}},timeout:e.timeout,retry:e.retry,retryDelay:e.retryDelay}}buildURL(e,n){const{baseURL:i}=this.defaults,r=e.startsWith("http")?e:`${i}${e.startsWith("/")?e:`/${e}`}`;if(n){const s=new URLSearchParams;return Object.entries(n).forEach(([a,c])=>{s.append(a,c)}),`${r}${r.includes("?")?"&":"?"}${s.toString()}`}return r}request(e){return p(this,null,function*(){var n;const i=((n=e.method)==null?void 0:n.toUpperCase())||"GET",r=this.buildURL(e.url||"",e.params),s=H(H({},this.defaults.headers.common),e.headers);i!=="GET"&&i!=="HEAD"&&e.data&&!s["Content-Type"]&&(s["Content-Type"]="application/json");const a=s["Content-Type"]==="application/json"?JSON.stringify(e.data):e.data,c={method:i,headers:s,body:i!=="GET"&&i!=="HEAD"&&e.data?a:void 0},d=e.timeout||this.defaults.timeout,h=e.retry!==void 0?e.retry:this.defaults.retry,u=e.retryDelay||this.defaults.retryDelay;try{const g=new AbortController,E=setTimeout(()=>g.abort(),d);c.signal=g.signal;const b=yield fetch(r,c);clearTimeout(E);let k=null;const A=b.headers.get("content-type");A&&A.includes("application/json")?k=yield b.json():k=yield b.text();const M={};b.headers.forEach((K,X)=>{M[X]=K});const B={data:k,status:b.status,statusText:b.statusText,headers:M,config:e};if(!b.ok)throw B;return B}catch(g){if(g instanceof Error&&h>0)return yield new Promise(E=>setTimeout(E,u)),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(ee(H({},e),{retry:h-1}));throw g}})}get(e){return p(this,arguments,function*(n,i={}){return this.request(ee(H({},i),{method:"GET",url:n}))})}post(e,n){return p(this,arguments,function*(i,r,s={}){return this.request(ee(H({},s),{method:"POST",url:i,data:r}))})}put(e,n){return p(this,arguments,function*(i,r,s={}){return this.request(ee(H({},s),{method:"PUT",url:i,data:r}))})}}const DN=3,NN=30,LN=8e3;class xN{constructor(e,n){y(this,"ipInfo"),y(this,"fetchClient"),y(this,"requests"),y(this,"roomName"),y(this,"roomUUID"),y(this,"authToken"),y(this,"organizationId"),y(this,"iceServers"),y(this,"pluginInformation"),y(this,"userDetails"),y(this,"roomDetails"),y(this,"context"),this.context=e;const{timeout:i=LN,retry:r=DN,retryDelay:s=NN,baseURL:a="https://api.dyte.io",authToken:c,cachedUserDetails:d}=n||{};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 Sg({baseURL:a,timeout:i,retry:r,retryDelay:s,responseType:"json"}),this.fetchClient=new Sg({baseURL:"",timeout:i,retry:r,retryDelay:s,responseType:"json"}),this.setAuthToken(c,{bearer:!0});const h=this.requests.request.bind(this.requests);this.requests.request=u=>p(this,null,function*(){var g,E,b,k,A;try{w.injectContext(this.requests.defaults.headers.common);const M=yield h(u);return u.url!==w.logsEndpoint&&m.debug("xhr::fetch",{networkCall:{status:M.status,statusText:M.statusText,baseURL:u.baseURL||this.requests.defaults.baseURL,url:u.url,method:u.method}}),M}catch(M){throw M?(((g=M.config)==null?void 0:g.url)!==w.logsEndpoint&&m.error("xhr::fetch",{error:M,networkCall:{status:M.status,statusText:M.statusText,baseURL:((E=M.config)==null?void 0:E.baseURL)||this.requests.defaults.baseURL,url:(b=M.config)==null?void 0:b.url,retries:(k=M.config)==null?void 0:k.retry,method:(A=M.config)==null?void 0:A.method,isOnline:navigator.onLine?"online":"offline"}}),new D(M.message||"Network request failed","0011")):new D("Unknown network error occurred","0011")}})}get peerId(){return this.context.getValue("peerId")}setAuthToken(e,n){const{bearer:i}=n||{};this.authToken=e,this.requests.defaults.headers.common.Authorization=i?`Bearer ${e}`:e}setHeader(e,n){this.requests.defaults.headers.common[e]=n}setRoomName(e){this.roomName=e}setRoomUUID(e){this.roomUUID=e}setOrganizationId(e){this.organizationId=e}}var VN=Object.defineProperty,UN=Object.getOwnPropertyDescriptor,Rn=(t,e,n,i)=>{for(var r=i>1?void 0:i?UN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&VN(e,n,r),r};class vn extends xN{constructor(e,n){super(e,n),this.setHeader("x-dyte-web-core-version",e.getValue("sdkVersion"))}getIPDetails(){return p(this,null,function*(){var e;const{peerId:n}=this;try{const i=yield Up.getIPDetails({peerId:n,apiHostnames:eE(this.context),logger:m});if(m.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){m.warn("ApiClient.getRoomNodeLinkAndTitleV1 Failed to get ip details",{error:{name:i.name,message:i.message}});return}})}getICEServers(){return p(this,null,function*(){if(this.iceServers)return this.iceServers;const{success:e,iceServers:n}=(yield this.requests.get("/iceservers")).data;if(e)return(n==null?void 0:n.length)>0&&(this.iceServers=n),n})}getPlugins(){return p(this,null,function*(){var e,n,i,r,s,a,c;if(this.pluginInformation)return this.pluginInformation;const{plugins:d}=(yield this.requests.get("/v2/plugins/user")).data.data,h=((n=(e=se.getValue(ue.V1_PLUGINS))==null?void 0:e.toString())==null?void 0:n.split(","))||[],u=d.reduce((g,E)=>(g[h.includes(E.id)?"v1":"v2"].push(ee(H({},E),{name:E.name.replace("v2","")})),g),{v1:[],v2:[]});return(s=(r=(i=this.context.getValue("modules"))==null?void 0:i.devTools)==null?void 0:r.plugins)!=null&&s.length&&((c=(a=this.context.getValue("modules"))==null?void 0:a.devTools)==null||c.plugins.forEach(g=>{var E,b,k;const A=ee(H({},xa),{tags:[...xa.tags],baseUrl:`http://localhost:${g.port}`,name:g.name,picture:(E=g.picture)!=null?E:xa.picture,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),id:g.id,organizationId:this.organizationId,description:(b=g.description)!=null?b:xa.description,staggered:(k=g.staggered)!=null?k:xa.staggered});u.v2.push(A)})),u.v2})}getPluginDetails(e){return p(this,null,function*(){const{plugin:n}=(yield this.requests.get(`/v2/plugins/view/${e}`)).data.data;return n})}getPluginConfig(e){return p(this,null,function*(){return(yield this.fetchClient.get(`${e}/dyte-config.json`)).data})}authorizePlugin(e){return p(this,null,function*(){const n={peerId:this.peerId},{token:i}=(yield this.requests.post(`/v2/plugins/authorize/${e}`,n)).data.data;return i})}getPresignedUrls(e,n){return p(this,null,function*(){const i=ll(this.context,"chat_upload_expiry"),r={roomUUID:this.roomUUID,filename:e,expiry:typeof i=="number"?i:void 0};se.hasFeature(ue.FEAT_CHAT_SDK)&&(r.viewType=n);const{getLocation:s,putLocation:a}=(yield this.requests.post("/v1/meetings/genPreSignedUploadUrl",r)).data.data;return{getLocation:s,putLocation:a}})}uploadFile(e,n){return p(this,null,function*(){if(navigator.isReactNative&&"uri"in e)try{yield fetch(n,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:{uri:e.uri,name:e.name}})}catch(i){m.error(`sendFileMessage::${i}`)}else yield this.fetchClient.put(n,e,{headers:{"Content-Type":e.type}})})}startLivestreaming(e){return p(this,arguments,function*({manualIngestion:n}){const i=Gn(yield this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/livestreams`,{manual_ingest:!!n})).data.data;return{playbackUrl:i.playbackUrl,status:i.status,manualIngest:i.manualIngest,ingestionCredentials:i.streamKey?{ingestionServer:i.ingestServer,streamKey:i.streamKey}:null}})}stopLivestreaming(){return p(this,null,function*(){return this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream/stop`)})}getActiveLivestream(){return p(this,null,function*(){const e=Gn((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 p(this,null,function*(){if(this.userDetails)return this.userDetails;const e=(yield this.requests.get("v2/internals/participant-details")).data.data;return Gn(e)})}startRecording(e,n){return p(this,null,function*(){return(yield this.requests.post("/v2/recordings",ee(H({},yE(e)),{meeting_id:this.context.getValue("meetingId"),allow_multiple_recordings:!!n}))).data.data.id})}updateRecording(e,n){return p(this,null,function*(){return this.requests.put(`v2/recordings/${e}`,{action:n})})}getActiveRecording(){return p(this,null,function*(){const{status:e,id:n}=(yield this.requests.get(`v2/recordings/active-recording/${this.context.getValue("meetingId")}`)).data.data;return{status:e,id:n}})}getActiveTranscript(){return p(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 D("Cant fetch transcript s3 url","1801")}})}getRoomNodeData(){return p(this,null,function*(){const e=yield this.getIPDetails();if(this.ipInfo=e,this.roomDetails)return this.roomDetails;const{roomNodeLink:n,title:i,useHiveMedia:r,sfu:s}=Gn((yield this.requests.post("v2/internals/rooms",{ip_information:e})).data.data);return{roomNodeUrl:n,meetingTitle:i,useHiveMedia:r!=null?r:!1,sfu:s}})}}Rn([w.trace("APIClient.getIPDetails")],vn.prototype,"getIPDetails",1);Rn([w.trace("APIClient.getICEServers")],vn.prototype,"getICEServers",1);Rn([w.trace("APIClient.getPlugins")],vn.prototype,"getPlugins",1);Rn([w.trace("APIClient.startLivestreaming")],vn.prototype,"startLivestreaming",1);Rn([w.trace("APIClient.stopLivestreaming")],vn.prototype,"stopLivestreaming",1);Rn([w.trace("APIClient.getActiveLivestream")],vn.prototype,"getActiveLivestream",1);Rn([w.trace("APIClient.getUserDetails")],vn.prototype,"getUserDetails",1);Rn([w.trace("APIClient.startRecording")],vn.prototype,"startRecording",1);Rn([w.trace("APIClient.stopRecording")],vn.prototype,"updateRecording",1);Rn([w.trace("APIClient.getActiveRecording")],vn.prototype,"getActiveRecording",1);Rn([w.trace("APIClient.getActiveTranscript")],vn.prototype,"getActiveTranscript",1);Rn([w.trace("APIClient.getRoomNodeData")],vn.prototype,"getRoomNodeData",1);let Nh;function BN(t,e){return Nh=new vn(t,e),Nh}function Pt(){return Nh}function FN(t,e){return`<blockquote>${e.replace(/<blockquote>[.\s\S]*<\/blockquote>\n\n/m,"")}</blockquote>
17
+ */(function(t){const e=Vl,n=Hp,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=J,t.INSPECT_MAX_BYTES=50;const r=2147483647;t.kMaxLength=r;const{Uint8Array:s,ArrayBuffer:a,SharedArrayBuffer:c}=globalThis;u.TYPED_ARRAY_SUPPORT=d(),!u.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{const l=new s(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,s.prototype),Object.setPrototypeOf(l,f),l.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function h(l){if(l>r)throw new RangeError('The value "'+l+'" is invalid for option "size"');const f=new s(l);return Object.setPrototypeOf(f,u.prototype),f}function u(l,f,v){if(typeof l=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return k(l)}return g(l,f,v)}u.poolSize=8192;function g(l,f,v){if(typeof l=="string")return A(l,f);if(a.isView(l))return B(l);if(l==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l);if(Qn(l,a)||l&&Qn(l.buffer,a)||typeof c!="undefined"&&(Qn(l,c)||l&&Qn(l.buffer,c)))return K(l,f,v);if(typeof l=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const C=l.valueOf&&l.valueOf();if(C!=null&&C!==l)return u.from(C,f,v);const R=X(l);if(R)return R;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof l[Symbol.toPrimitive]=="function")return u.from(l[Symbol.toPrimitive]("string"),f,v);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l)}u.from=function(l,f,v){return g(l,f,v)},Object.setPrototypeOf(u.prototype,s.prototype),Object.setPrototypeOf(u,s);function E(l){if(typeof l!="number")throw new TypeError('"size" argument must be of type number');if(l<0)throw new RangeError('The value "'+l+'" is invalid for option "size"')}function b(l,f,v){return E(l),l<=0?h(l):f!==void 0?typeof v=="string"?h(l).fill(f,v):h(l).fill(f):h(l)}u.alloc=function(l,f,v){return b(l,f,v)};function k(l){return E(l),h(l<0?0:O(l)|0)}u.allocUnsafe=function(l){return k(l)},u.allocUnsafeSlow=function(l){return k(l)};function A(l,f){if((typeof f!="string"||f==="")&&(f="utf8"),!u.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const v=me(l,f)|0;let C=h(v);const R=C.write(l,f);return R!==v&&(C=C.slice(0,R)),C}function M(l){const f=l.length<0?0:O(l.length)|0,v=h(f);for(let C=0;C<f;C+=1)v[C]=l[C]&255;return v}function B(l){if(Qn(l,s)){const f=new s(l);return K(f.buffer,f.byteOffset,f.byteLength)}return M(l)}function K(l,f,v){if(f<0||l.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(l.byteLength<f+(v||0))throw new RangeError('"length" is outside of buffer bounds');let C;return f===void 0&&v===void 0?C=new s(l):v===void 0?C=new s(l,f):C=new s(l,f,v),Object.setPrototypeOf(C,u.prototype),C}function X(l){if(u.isBuffer(l)){const f=O(l.length)|0,v=h(f);return v.length===0||l.copy(v,0,0,f),v}if(l.length!==void 0)return typeof l.length!="number"||ou(l.length)?h(0):M(l);if(l.type==="Buffer"&&Array.isArray(l.data))return M(l.data)}function O(l){if(l>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return l|0}function J(l){return+l!=l&&(l=0),u.alloc(+l)}u.isBuffer=function(l){return l!=null&&l._isBuffer===!0&&l!==u.prototype},u.compare=function(l,f){if(Qn(l,s)&&(l=u.from(l,l.offset,l.byteLength)),Qn(f,s)&&(f=u.from(f,f.offset,f.byteLength)),!u.isBuffer(l)||!u.isBuffer(f))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(l===f)return 0;let v=l.length,C=f.length;for(let R=0,U=Math.min(v,C);R<U;++R)if(l[R]!==f[R]){v=l[R],C=f[R];break}return v<C?-1:C<v?1:0},u.isEncoding=function(l){switch(String(l).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(l,f){if(!Array.isArray(l))throw new TypeError('"list" argument must be an Array of Buffers');if(l.length===0)return u.alloc(0);let v;if(f===void 0)for(f=0,v=0;v<l.length;++v)f+=l[v].length;const C=u.allocUnsafe(f);let R=0;for(v=0;v<l.length;++v){let U=l[v];if(Qn(U,s))R+U.length>C.length?(u.isBuffer(U)||(U=u.from(U)),U.copy(C,R)):s.prototype.set.call(C,U,R);else if(u.isBuffer(U))U.copy(C,R);else throw new TypeError('"list" argument must be an Array of Buffers');R+=U.length}return C};function me(l,f){if(u.isBuffer(l))return l.length;if(a.isView(l)||Qn(l,a))return l.byteLength;if(typeof l!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof l);const v=l.length,C=arguments.length>2&&arguments[2]===!0;if(!C&&v===0)return 0;let R=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return v;case"utf8":case"utf-8":return au(l).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v*2;case"hex":return v>>>1;case"base64":return bm(l).length;default:if(R)return C?-1:au(l).length;f=(""+f).toLowerCase(),R=!0}}u.byteLength=me;function Ie(l,f,v){let C=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((v===void 0||v>this.length)&&(v=this.length),v<=0)||(v>>>=0,f>>>=0,v<=f))return"";for(l||(l="utf8");;)switch(l){case"hex":return Mr(this,f,v);case"utf8":case"utf-8":return q(this,f,v);case"ascii":return Pn(this,f,v);case"latin1":case"binary":return Ar(this,f,v);case"base64":return Xe(this,f,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Or(this,f,v);default:if(C)throw new TypeError("Unknown encoding: "+l);l=(l+"").toLowerCase(),C=!0}}u.prototype._isBuffer=!0;function fe(l,f,v){const C=l[f];l[f]=l[v],l[v]=C}u.prototype.swap16=function(){const l=this.length;if(l%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let f=0;f<l;f+=2)fe(this,f,f+1);return this},u.prototype.swap32=function(){const l=this.length;if(l%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let f=0;f<l;f+=4)fe(this,f,f+3),fe(this,f+1,f+2);return this},u.prototype.swap64=function(){const l=this.length;if(l%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let f=0;f<l;f+=8)fe(this,f,f+7),fe(this,f+1,f+6),fe(this,f+2,f+5),fe(this,f+3,f+4);return this},u.prototype.toString=function(){const l=this.length;return l===0?"":arguments.length===0?q(this,0,l):Ie.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(l){if(!u.isBuffer(l))throw new TypeError("Argument must be a Buffer");return this===l?!0:u.compare(this,l)===0},u.prototype.inspect=function(){let l="";const f=t.INSPECT_MAX_BYTES;return l=this.toString("hex",0,f).replace(/(.{2})/g,"$1 ").trim(),this.length>f&&(l+=" ... "),"<Buffer "+l+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(l,f,v,C,R){if(Qn(l,s)&&(l=u.from(l,l.offset,l.byteLength)),!u.isBuffer(l))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof l);if(f===void 0&&(f=0),v===void 0&&(v=l?l.length:0),C===void 0&&(C=0),R===void 0&&(R=this.length),f<0||v>l.length||C<0||R>this.length)throw new RangeError("out of range index");if(C>=R&&f>=v)return 0;if(C>=R)return-1;if(f>=v)return 1;if(f>>>=0,v>>>=0,C>>>=0,R>>>=0,this===l)return 0;let U=R-C,$=v-f;const Pe=Math.min(U,$),_t=this.slice(C,R),je=l.slice(f,v);for(let Ae=0;Ae<Pe;++Ae)if(_t[Ae]!==je[Ae]){U=_t[Ae],$=je[Ae];break}return U<$?-1:$<U?1:0};function $e(l,f,v,C,R){if(l.length===0)return-1;if(typeof v=="string"?(C=v,v=0):v>2147483647?v=2147483647:v<-2147483648&&(v=-2147483648),v=+v,ou(v)&&(v=R?0:l.length-1),v<0&&(v=l.length+v),v>=l.length){if(R)return-1;v=l.length-1}else if(v<0)if(R)v=0;else return-1;if(typeof f=="string"&&(f=u.from(f,C)),u.isBuffer(f))return f.length===0?-1:ht(l,f,v,C,R);if(typeof f=="number")return f=f&255,typeof s.prototype.indexOf=="function"?R?s.prototype.indexOf.call(l,f,v):s.prototype.lastIndexOf.call(l,f,v):ht(l,[f],v,C,R);throw new TypeError("val must be string, number or Buffer")}function ht(l,f,v,C,R){let U=1,$=l.length,Pe=f.length;if(C!==void 0&&(C=String(C).toLowerCase(),C==="ucs2"||C==="ucs-2"||C==="utf16le"||C==="utf-16le")){if(l.length<2||f.length<2)return-1;U=2,$/=2,Pe/=2,v/=2}function _t(Ae,ot){return U===1?Ae[ot]:Ae.readUInt16BE(ot*U)}let je;if(R){let Ae=-1;for(je=v;je<$;je++)if(_t(l,je)===_t(f,Ae===-1?0:je-Ae)){if(Ae===-1&&(Ae=je),je-Ae+1===Pe)return Ae*U}else Ae!==-1&&(je-=je-Ae),Ae=-1}else for(v+Pe>$&&(v=$-Pe),je=v;je>=0;je--){let Ae=!0;for(let ot=0;ot<Pe;ot++)if(_t(l,je+ot)!==_t(f,ot)){Ae=!1;break}if(Ae)return je}return-1}u.prototype.includes=function(l,f,v){return this.indexOf(l,f,v)!==-1},u.prototype.indexOf=function(l,f,v){return $e(this,l,f,v,!0)},u.prototype.lastIndexOf=function(l,f,v){return $e(this,l,f,v,!1)};function V(l,f,v,C){v=Number(v)||0;const R=l.length-v;C?(C=Number(C),C>R&&(C=R)):C=R;const U=f.length;C>U/2&&(C=U/2);let $;for($=0;$<C;++$){const Pe=parseInt(f.substr($*2,2),16);if(ou(Pe))return $;l[v+$]=Pe}return $}function I(l,f,v,C){return Rc(au(f,l.length-v),l,v,C)}function P(l,f,v,C){return Rc(RS(f),l,v,C)}function z(l,f,v,C){return Rc(bm(f),l,v,C)}function ye(l,f,v,C){return Rc(PS(f,l.length-v),l,v,C)}u.prototype.write=function(l,f,v,C){if(f===void 0)C="utf8",v=this.length,f=0;else if(v===void 0&&typeof f=="string")C=f,v=this.length,f=0;else if(isFinite(f))f=f>>>0,isFinite(v)?(v=v>>>0,C===void 0&&(C="utf8")):(C=v,v=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const R=this.length-f;if((v===void 0||v>R)&&(v=R),l.length>0&&(v<0||f<0)||f>this.length)throw new RangeError("Attempt to write outside buffer bounds");C||(C="utf8");let U=!1;for(;;)switch(C){case"hex":return V(this,l,f,v);case"utf8":case"utf-8":return I(this,l,f,v);case"ascii":case"latin1":case"binary":return P(this,l,f,v);case"base64":return z(this,l,f,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ye(this,l,f,v);default:if(U)throw new TypeError("Unknown encoding: "+C);C=(""+C).toLowerCase(),U=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(l,f,v){return f===0&&v===l.length?e.fromByteArray(l):e.fromByteArray(l.slice(f,v))}function q(l,f,v){v=Math.min(l.length,v);const C=[];let R=f;for(;R<v;){const U=l[R];let $=null,Pe=U>239?4:U>223?3:U>191?2:1;if(R+Pe<=v){let _t,je,Ae,ot;switch(Pe){case 1:U<128&&($=U);break;case 2:_t=l[R+1],(_t&192)===128&&(ot=(U&31)<<6|_t&63,ot>127&&($=ot));break;case 3:_t=l[R+1],je=l[R+2],(_t&192)===128&&(je&192)===128&&(ot=(U&15)<<12|(_t&63)<<6|je&63,ot>2047&&(ot<55296||ot>57343)&&($=ot));break;case 4:_t=l[R+1],je=l[R+2],Ae=l[R+3],(_t&192)===128&&(je&192)===128&&(Ae&192)===128&&(ot=(U&15)<<18|(_t&63)<<12|(je&63)<<6|Ae&63,ot>65535&&ot<1114112&&($=ot))}}$===null?($=65533,Pe=1):$>65535&&($-=65536,C.push($>>>10&1023|55296),$=56320|$&1023),C.push($),R+=Pe}return Ze(C)}const N=4096;function Ze(l){const f=l.length;if(f<=N)return String.fromCharCode.apply(String,l);let v="",C=0;for(;C<f;)v+=String.fromCharCode.apply(String,l.slice(C,C+=N));return v}function Pn(l,f,v){let C="";v=Math.min(l.length,v);for(let R=f;R<v;++R)C+=String.fromCharCode(l[R]&127);return C}function Ar(l,f,v){let C="";v=Math.min(l.length,v);for(let R=f;R<v;++R)C+=String.fromCharCode(l[R]);return C}function Mr(l,f,v){const C=l.length;(!f||f<0)&&(f=0),(!v||v<0||v>C)&&(v=C);let R="";for(let U=f;U<v;++U)R+=AS[l[U]];return R}function Or(l,f,v){const C=l.slice(f,v);let R="";for(let U=0;U<C.length-1;U+=2)R+=String.fromCharCode(C[U]+C[U+1]*256);return R}u.prototype.slice=function(l,f){const v=this.length;l=~~l,f=f===void 0?v:~~f,l<0?(l+=v,l<0&&(l=0)):l>v&&(l=v),f<0?(f+=v,f<0&&(f=0)):f>v&&(f=v),f<l&&(f=l);const C=this.subarray(l,f);return Object.setPrototypeOf(C,u.prototype),C};function Fe(l,f,v){if(l%1!==0||l<0)throw new RangeError("offset is not uint");if(l+f>v)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l],R=1,U=0;for(;++U<f&&(R*=256);)C+=this[l+U]*R;return C},u.prototype.readUintBE=u.prototype.readUIntBE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l+--f],R=1;for(;f>0&&(R*=256);)C+=this[l+--f]*R;return C},u.prototype.readUint8=u.prototype.readUInt8=function(l,f){return l=l>>>0,f||Fe(l,1,this.length),this[l]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(l,f){return l=l>>>0,f||Fe(l,2,this.length),this[l]|this[l+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(l,f){return l=l>>>0,f||Fe(l,2,this.length),this[l]<<8|this[l+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),(this[l]|this[l+1]<<8|this[l+2]<<16)+this[l+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]*16777216+(this[l+1]<<16|this[l+2]<<8|this[l+3])},u.prototype.readBigUInt64LE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=f+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+this[++l]*Oe(2,24),R=this[++l]+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+v*Oe(2,24);return BigInt(C)+(BigInt(R)<<BigInt(32))}),u.prototype.readBigUInt64BE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=f*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+this[++l],R=this[++l]*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+v;return(BigInt(C)<<BigInt(32))+BigInt(R)}),u.prototype.readIntLE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=this[l],R=1,U=0;for(;++U<f&&(R*=256);)C+=this[l+U]*R;return R*=128,C>=R&&(C-=Math.pow(2,8*f)),C},u.prototype.readIntBE=function(l,f,v){l=l>>>0,f=f>>>0,v||Fe(l,f,this.length);let C=f,R=1,U=this[l+--C];for(;C>0&&(R*=256);)U+=this[l+--C]*R;return R*=128,U>=R&&(U-=Math.pow(2,8*f)),U},u.prototype.readInt8=function(l,f){return l=l>>>0,f||Fe(l,1,this.length),this[l]&128?(255-this[l]+1)*-1:this[l]},u.prototype.readInt16LE=function(l,f){l=l>>>0,f||Fe(l,2,this.length);const v=this[l]|this[l+1]<<8;return v&32768?v|4294901760:v},u.prototype.readInt16BE=function(l,f){l=l>>>0,f||Fe(l,2,this.length);const v=this[l+1]|this[l]<<8;return v&32768?v|4294901760:v},u.prototype.readInt32LE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]|this[l+1]<<8|this[l+2]<<16|this[l+3]<<24},u.prototype.readInt32BE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),this[l]<<24|this[l+1]<<16|this[l+2]<<8|this[l+3]},u.prototype.readBigInt64LE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=this[l+4]+this[l+5]*Oe(2,8)+this[l+6]*Oe(2,16)+(v<<24);return(BigInt(C)<<BigInt(32))+BigInt(f+this[++l]*Oe(2,8)+this[++l]*Oe(2,16)+this[++l]*Oe(2,24))}),u.prototype.readBigInt64BE=Wi(function(l){l=l>>>0,ge(l,"offset");const f=this[l],v=this[l+7];(f===void 0||v===void 0)&&pe(l,this.length-8);const C=(f<<24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+this[++l];return(BigInt(C)<<BigInt(32))+BigInt(this[++l]*Oe(2,24)+this[++l]*Oe(2,16)+this[++l]*Oe(2,8)+v)}),u.prototype.readFloatLE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),n.read(this,l,!0,23,4)},u.prototype.readFloatBE=function(l,f){return l=l>>>0,f||Fe(l,4,this.length),n.read(this,l,!1,23,4)},u.prototype.readDoubleLE=function(l,f){return l=l>>>0,f||Fe(l,8,this.length),n.read(this,l,!0,52,8)},u.prototype.readDoubleBE=function(l,f){return l=l>>>0,f||Fe(l,8,this.length),n.read(this,l,!1,52,8)};function at(l,f,v,C,R,U){if(!u.isBuffer(l))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>R||f<U)throw new RangeError('"value" argument is out of bounds');if(v+C>l.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(l,f,v,C){if(l=+l,f=f>>>0,v=v>>>0,!C){const $=Math.pow(2,8*v)-1;at(this,l,f,v,$,0)}let R=1,U=0;for(this[f]=l&255;++U<v&&(R*=256);)this[f+U]=l/R&255;return f+v},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(l,f,v,C){if(l=+l,f=f>>>0,v=v>>>0,!C){const $=Math.pow(2,8*v)-1;at(this,l,f,v,$,0)}let R=v-1,U=1;for(this[f+R]=l&255;--R>=0&&(U*=256);)this[f+R]=l/U&255;return f+v},u.prototype.writeUint8=u.prototype.writeUInt8=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,1,255,0),this[f]=l&255,f+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,65535,0),this[f]=l&255,this[f+1]=l>>>8,f+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,65535,0),this[f]=l>>>8,this[f+1]=l&255,f+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,4294967295,0),this[f+3]=l>>>24,this[f+2]=l>>>16,this[f+1]=l>>>8,this[f]=l&255,f+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,4294967295,0),this[f]=l>>>24,this[f+1]=l>>>16,this[f+2]=l>>>8,this[f+3]=l&255,f+4};function Li(l,f,v,C,R){ji(f,C,R,l,v,7);let U=Number(f&BigInt(4294967295));l[v++]=U,U=U>>8,l[v++]=U,U=U>>8,l[v++]=U,U=U>>8,l[v++]=U;let $=Number(f>>BigInt(32)&BigInt(4294967295));return l[v++]=$,$=$>>8,l[v++]=$,$=$>>8,l[v++]=$,$=$>>8,l[v++]=$,v}function xi(l,f,v,C,R){ji(f,C,R,l,v,7);let U=Number(f&BigInt(4294967295));l[v+7]=U,U=U>>8,l[v+6]=U,U=U>>8,l[v+5]=U,U=U>>8,l[v+4]=U;let $=Number(f>>BigInt(32)&BigInt(4294967295));return l[v+3]=$,$=$>>8,l[v+2]=$,$=$>>8,l[v+1]=$,$=$>>8,l[v]=$,v+8}u.prototype.writeBigUInt64LE=Wi(function(l,f=0){return Li(this,l,f,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Wi(function(l,f=0){return xi(this,l,f,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(l,f,v,C){if(l=+l,f=f>>>0,!C){const Pe=Math.pow(2,8*v-1);at(this,l,f,v,Pe-1,-Pe)}let R=0,U=1,$=0;for(this[f]=l&255;++R<v&&(U*=256);)l<0&&$===0&&this[f+R-1]!==0&&($=1),this[f+R]=(l/U>>0)-$&255;return f+v},u.prototype.writeIntBE=function(l,f,v,C){if(l=+l,f=f>>>0,!C){const Pe=Math.pow(2,8*v-1);at(this,l,f,v,Pe-1,-Pe)}let R=v-1,U=1,$=0;for(this[f+R]=l&255;--R>=0&&(U*=256);)l<0&&$===0&&this[f+R+1]!==0&&($=1),this[f+R]=(l/U>>0)-$&255;return f+v},u.prototype.writeInt8=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,1,127,-128),l<0&&(l=255+l+1),this[f]=l&255,f+1},u.prototype.writeInt16LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,32767,-32768),this[f]=l&255,this[f+1]=l>>>8,f+2},u.prototype.writeInt16BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,2,32767,-32768),this[f]=l>>>8,this[f+1]=l&255,f+2},u.prototype.writeInt32LE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,2147483647,-2147483648),this[f]=l&255,this[f+1]=l>>>8,this[f+2]=l>>>16,this[f+3]=l>>>24,f+4},u.prototype.writeInt32BE=function(l,f,v){return l=+l,f=f>>>0,v||at(this,l,f,4,2147483647,-2147483648),l<0&&(l=4294967295+l+1),this[f]=l>>>24,this[f+1]=l>>>16,this[f+2]=l>>>8,this[f+3]=l&255,f+4},u.prototype.writeBigInt64LE=Wi(function(l,f=0){return Li(this,l,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Wi(function(l,f=0){return xi(this,l,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vi(l,f,v,C,R,U){if(v+C>l.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("Index out of range")}function Ui(l,f,v,C,R){return f=+f,v=v>>>0,R||Vi(l,f,v,4),n.write(l,f,v,C,23,4),v+4}u.prototype.writeFloatLE=function(l,f,v){return Ui(this,l,f,!0,v)},u.prototype.writeFloatBE=function(l,f,v){return Ui(this,l,f,!1,v)};function Bi(l,f,v,C,R){return f=+f,v=v>>>0,R||Vi(l,f,v,8),n.write(l,f,v,C,52,8),v+8}u.prototype.writeDoubleLE=function(l,f,v){return Bi(this,l,f,!0,v)},u.prototype.writeDoubleBE=function(l,f,v){return Bi(this,l,f,!1,v)},u.prototype.copy=function(l,f,v,C){if(!u.isBuffer(l))throw new TypeError("argument should be a Buffer");if(v||(v=0),!C&&C!==0&&(C=this.length),f>=l.length&&(f=l.length),f||(f=0),C>0&&C<v&&(C=v),C===v||l.length===0||this.length===0)return 0;if(f<0)throw new RangeError("targetStart out of bounds");if(v<0||v>=this.length)throw new RangeError("Index out of range");if(C<0)throw new RangeError("sourceEnd out of bounds");C>this.length&&(C=this.length),l.length-f<C-v&&(C=l.length-f+v);const R=C-v;return this===l&&typeof s.prototype.copyWithin=="function"?this.copyWithin(f,v,C):s.prototype.set.call(l,this.subarray(v,C),f),R},u.prototype.fill=function(l,f,v,C){if(typeof l=="string"){if(typeof f=="string"?(C=f,f=0,v=this.length):typeof v=="string"&&(C=v,v=this.length),C!==void 0&&typeof C!="string")throw new TypeError("encoding must be a string");if(typeof C=="string"&&!u.isEncoding(C))throw new TypeError("Unknown encoding: "+C);if(l.length===1){const U=l.charCodeAt(0);(C==="utf8"&&U<128||C==="latin1")&&(l=U)}}else typeof l=="number"?l=l&255:typeof l=="boolean"&&(l=Number(l));if(f<0||this.length<f||this.length<v)throw new RangeError("Out of range index");if(v<=f)return this;f=f>>>0,v=v===void 0?this.length:v>>>0,l||(l=0);let R;if(typeof l=="number")for(R=f;R<v;++R)this[R]=l;else{const U=u.isBuffer(l)?l:u.from(l,C),$=U.length;if($===0)throw new TypeError('The value "'+l+'" is invalid for argument "value"');for(R=0;R<v-f;++R)this[R+f]=U[R%$]}return this};const Sn={};function pi(l,f,v){Sn[l]=class extends v{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${l}]`,this.stack,delete this.name}get code(){return l}set code(C){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:C,writable:!0})}toString(){return`${this.name} [${l}]: ${this.message}`}}}pi("ERR_BUFFER_OUT_OF_BOUNDS",function(l){return l?`${l} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),pi("ERR_INVALID_ARG_TYPE",function(l,f){return`The "${l}" argument must be of type number. Received type ${typeof f}`},TypeError),pi("ERR_OUT_OF_RANGE",function(l,f,v){let C=`The value of "${l}" is out of range.`,R=v;return Number.isInteger(v)&&Math.abs(v)>Oe(2,32)?R=Fi(String(v)):typeof v=="bigint"&&(R=String(v),(v>Oe(BigInt(2),BigInt(32))||v<-Oe(BigInt(2),BigInt(32)))&&(R=Fi(R)),R+="n"),C+=` It must be ${f}. Received ${R}`,C},RangeError);function Fi(l){let f="",v=l.length;const C=l[0]==="-"?1:0;for(;v>=C+4;v-=3)f=`_${l.slice(v-3,v)}${f}`;return`${l.slice(0,v)}${f}`}function Dr(l,f,v){ge(f,"offset"),(l[f]===void 0||l[f+v]===void 0)&&pe(f,l.length-(v+1))}function ji(l,f,v,C,R,U){if(l>v||l<f){const $=typeof f=="bigint"?"n":"";let Pe;throw U>3?f===0||f===BigInt(0)?Pe=`>= 0${$} and < 2${$} ** ${(U+1)*8}${$}`:Pe=`>= -(2${$} ** ${(U+1)*8-1}${$}) and < 2 ** ${(U+1)*8-1}${$}`:Pe=`>= ${f}${$} and <= ${v}${$}`,new Sn.ERR_OUT_OF_RANGE("value",Pe,l)}Dr(C,R,U)}function ge(l,f){if(typeof l!="number")throw new Sn.ERR_INVALID_ARG_TYPE(f,"number",l)}function pe(l,f,v){throw Math.floor(l)!==l?(ge(l,v),new Sn.ERR_OUT_OF_RANGE(v||"offset","an integer",l)):f<0?new Sn.ERR_BUFFER_OUT_OF_BOUNDS:new Sn.ERR_OUT_OF_RANGE(v||"offset",`>= ${v?1:0} and <= ${f}`,l)}const Da=/[^+/0-9A-Za-z-_]/g;function CS(l){if(l=l.split("=")[0],l=l.trim().replace(Da,""),l.length<2)return"";for(;l.length%4!==0;)l=l+"=";return l}function au(l,f){f=f||1/0;let v;const C=l.length;let R=null;const U=[];for(let $=0;$<C;++$){if(v=l.charCodeAt($),v>55295&&v<57344){if(!R){if(v>56319){(f-=3)>-1&&U.push(239,191,189);continue}else if($+1===C){(f-=3)>-1&&U.push(239,191,189);continue}R=v;continue}if(v<56320){(f-=3)>-1&&U.push(239,191,189),R=v;continue}v=(R-55296<<10|v-56320)+65536}else R&&(f-=3)>-1&&U.push(239,191,189);if(R=null,v<128){if((f-=1)<0)break;U.push(v)}else if(v<2048){if((f-=2)<0)break;U.push(v>>6|192,v&63|128)}else if(v<65536){if((f-=3)<0)break;U.push(v>>12|224,v>>6&63|128,v&63|128)}else if(v<1114112){if((f-=4)<0)break;U.push(v>>18|240,v>>12&63|128,v>>6&63|128,v&63|128)}else throw new Error("Invalid code point")}return U}function RS(l){const f=[];for(let v=0;v<l.length;++v)f.push(l.charCodeAt(v)&255);return f}function PS(l,f){let v,C,R;const U=[];for(let $=0;$<l.length&&!((f-=2)<0);++$)v=l.charCodeAt($),C=v>>8,R=v%256,U.push(R),U.push(C);return U}function bm(l){return e.toByteArray(CS(l))}function Rc(l,f,v,C){let R;for(R=0;R<C&&!(R+v>=f.length||R>=l.length);++R)f[R+v]=l[R];return R}function Qn(l,f){return l instanceof f||l!=null&&l.constructor!=null&&l.constructor.name!=null&&l.constructor.name===f.name}function ou(l){return l!==l}const AS=function(){const l="0123456789abcdef",f=new Array(256);for(let v=0;v<16;++v){const C=v*16;for(let R=0;R<16;++R)f[C+R]=l[v]+l[R]}return f}();function Wi(l){return typeof BigInt=="undefined"?MS:l}function MS(){throw new Error("BigInt not supported")}})(vt);const ik=vt.Buffer;vt.Blob;vt.BlobOptions;vt.Buffer;vt.File;vt.FileOptions;vt.INSPECT_MAX_BYTES;vt.SlowBuffer;vt.TranscodeEncoding;vt.atob;vt.btoa;vt.constants;vt.isAscii;vt.isUtf8;vt.kMaxLength;vt.kStringMaxLength;vt.resolveObjectURL;vt.transcode;var Qv=gt;function Ta(t,e,n,i,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),i&&(this.request=i),r&&(this.response=r)}Qv.inherits(Ta,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Xv=Ta.prototype,Zv={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(t){Zv[t]={value:t}});Object.defineProperties(Ta,Zv);Object.defineProperty(Xv,"isAxiosError",{value:!0});Ta.from=function(t,e,n,i,r,s){var a=Object.create(Xv);return Qv.toFlatObject(t,a,function(c){return c!==Error.prototype}),Ta.call(a,t.message,e,n,i,r),a.cause=t,a.name=t.name,s&&Object.assign(a,s),a};var bs=Ta,ph={},rk={get exports(){return ph},set exports(t){ph=t}},sk=typeof self=="object"?self.FormData:window.FormData;(function(t){t.exports=sk})(rk);var Le=gt,ak=bs,ok=ph;function mh(t){return Le.isPlainObject(t)||Le.isArray(t)}function ey(t){return Le.endsWith(t,"[]")?t.slice(0,-2):t}function Wm(t,e,n){return t?t.concat(e).map(function(i,r){return i=ey(i),!n&&r?"["+i+"]":i}).join(n?".":""):e}function ck(t){return Le.isArray(t)&&!t.some(mh)}var dk=Le.toFlatObject(Le,{},null,function(t){return/^is[A-Z]/.test(t)});function lk(t){return t&&Le.isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator]}function uk(t,e,n){if(!Le.isObject(t))throw new TypeError("target must be an object");e=e||new(ok||FormData),n=Le.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,A){return!Le.isUndefined(A[k])});var i=n.metaTokens,r=n.visitor||u,s=n.dots,a=n.indexes,c=n.Blob||typeof Blob!="undefined"&&Blob,d=c&&lk(e);if(!Le.isFunction(r))throw new TypeError("visitor must be a function");function h(k){if(k===null)return"";if(Le.isDate(k))return k.toISOString();if(!d&&Le.isBlob(k))throw new ak("Blob is not supported. Use a Buffer instead.");return Le.isArrayBuffer(k)||Le.isTypedArray(k)?d&&typeof Blob=="function"?new Blob([k]):ik.from(k):k}function u(k,A,M){var B=k;if(k&&!M&&typeof k=="object"){if(Le.endsWith(A,"{}"))A=i?A:A.slice(0,-2),k=JSON.stringify(k);else if(Le.isArray(k)&&ck(k)||Le.isFileList(k)||Le.endsWith(A,"[]")&&(B=Le.toArray(k)))return A=ey(A),B.forEach(function(K,X){!Le.isUndefined(K)&&e.append(a===!0?Wm([A],X,s):a===null?A:A+"[]",h(K))}),!1}return mh(k)?!0:(e.append(Wm(M,A,s),h(k)),!1)}var g=[],E=Object.assign(dk,{defaultVisitor:u,convertValue:h,isVisitable:mh});function b(k,A){if(!Le.isUndefined(k)){if(g.indexOf(k)!==-1)throw Error("Circular reference detected in "+A.join("."));g.push(k),Le.forEach(k,function(M,B){var K=!Le.isUndefined(M)&&r.call(e,M,Le.isString(B)?B.trim():B,A,E);K===!0&&b(M,A?A.concat(B):[B])}),g.pop()}}if(!Le.isObject(t))throw new TypeError("data must be an object");return b(t),e}var Ul=uk,hk=Ul;function Hm(t){var e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'\(\)~]|%20|%00/g,function(n){return e[n]})}function ty(t,e){this._pairs=[],t&&hk(t,this,e)}var ny=ty.prototype;ny.append=function(t,e){this._pairs.push([t,e])};ny.toString=function(t){var e=t?function(n){return t.call(this,n,Hm)}:Hm;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};var iy=ty,pk=gt,mk=iy;function fk(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ry=function(t,e,n){if(!e)return t;var i=t.indexOf("#");i!==-1&&(t=t.slice(0,i));var r=n&&n.encode||fk,s=n&&n.serialize,a;return s?a=s(e,n):a=pk.isURLSearchParams(e)?e.toString():new mk(e,n).toString(r),a&&(t+=(t.indexOf("?")===-1?"?":"&")+a),t},gk=gt;function gc(){this.handlers=[]}gc.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};gc.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)};gc.prototype.clear=function(){this.handlers&&(this.handlers=[])};gc.prototype.forEach=function(t){gk.forEach(this.handlers,function(e){e!==null&&t(e)})};var vk=gc,yk=gt,sy=function(t,e){yk.forEach(t,function(n,i){i!==e&&i.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[i])})},ay={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},lc={},Ek={get exports(){return lc},set exports(t){lc=t}},Sk=iy,Tk=typeof URLSearchParams!="undefined"?URLSearchParams:Sk,bk=FormData,kk={isBrowser:!0,classes:{URLSearchParams:Tk,FormData:bk,Blob},protocols:["http","https","file","blob","url","data"]};(function(t){t.exports=kk})(Ek);var wk=gt,_k=Ul,qm=lc,Ik=function(t,e){return _k(t,new qm.classes.URLSearchParams,Object.assign({visitor:function(n,i,r,s){return qm.isNode&&wk.isBuffer(n)?(this.append(i,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))},Qi=gt;function Ck(t){return Qi.matchAll(/\w+|\[(\w*)]/g,t).map(function(e){return e[0]==="[]"?"":e[1]||e[0]})}function Rk(t){var e={},n=Object.keys(t),i,r=n.length,s;for(i=0;i<r;i++)s=n[i],e[s]=t[s];return e}function Pk(t){function e(i,r,s,a){var c=i[a++],d=Number.isFinite(+c),h=a>=i.length;if(c=!c&&Qi.isArray(s)?s.length:c,h)return Qi.hasOwnProperty(s,c)?s[c]=[s[c],r]:s[c]=r,!d;(!s[c]||!Qi.isObject(s[c]))&&(s[c]=[]);var u=e(i,r,s[c],a);return u&&Qi.isArray(s[c])&&(s[c]=Rk(s[c])),!d}if(Qi.isFormData(t)&&Qi.isFunction(t.entries)){var n={};return Qi.forEachEntry(t,function(i,r){e(Ck(i),r,n,0)}),n}return null}var oy=Pk,pu,Gm;function Ak(){if(Gm)return pu;Gm=1;var t=bs;return pu=function(e,n,i){var r=i.config.validateStatus;!i.status||!r||r(i.status)?e(i):n(new t("Request failed with status code "+i.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))},pu}var mu,Jm;function Mk(){if(Jm)return mu;Jm=1;var t=gt;return mu=t.isStandardBrowserEnv()?function(){return{write:function(e,n,i,r,s,a){var c=[];c.push(e+"="+encodeURIComponent(n)),t.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),t.isString(r)&&c.push("path="+r),t.isString(s)&&c.push("domain="+s),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(e){var n=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),mu}var Ok=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},Dk=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Nk=Ok,Lk=Dk,cy=function(t,e){return t&&!Nk(e)?Lk(t,e):e},fu,$m;function xk(){if($m)return fu;$m=1;var t=gt,e=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return fu=function(n){var i={},r,s,a;return n&&t.forEach(n.split(`
18
+ `),function(c){if(a=c.indexOf(":"),r=t.trim(c.slice(0,a)).toLowerCase(),s=t.trim(c.slice(a+1)),r){if(i[r]&&e.indexOf(r)>=0)return;r==="set-cookie"?i[r]=(i[r]?i[r]:[]).concat([s]):i[r]=i[r]?i[r]+", "+s:s}}),i},fu}var gu,Km;function Vk(){if(Km)return gu;Km=1;var t=gt;return gu=t.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),i;function r(s){var a=s;return e&&(n.setAttribute("href",a),a=n.href),n.setAttribute("href",a),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=r(window.location.href),function(s){var a=t.isString(s)?r(s):s;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}(),gu}var vu,zm;function Bl(){if(zm)return vu;zm=1;var t=bs,e=gt;function n(i,r,s){t.call(this,i==null?"canceled":i,t.ERR_CANCELED,r,s),this.name="CanceledError"}return e.inherits(n,t,{__CANCEL__:!0}),vu=n,vu}var Ym,Qm;function Uk(){return Qm||(Qm=1,Ym=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}),Ym}var yu,Xm;function Bk(){if(Xm)return yu;Xm=1;var t=gt,e=Ak(),n=Mk(),i=ry,r=cy,s=xk(),a=Vk(),c=ay,d=bs,h=Bl(),u=Uk(),g=lc;return yu=function(E){return new Promise(function(b,k){var A=E.data,M=E.headers,B=E.responseType,K=E.withXSRFToken,X;function O(){E.cancelToken&&E.cancelToken.unsubscribe(X),E.signal&&E.signal.removeEventListener("abort",X)}t.isFormData(A)&&t.isStandardBrowserEnv()&&delete M["Content-Type"];var J=new XMLHttpRequest;if(E.auth){var me=E.auth.username||"",Ie=E.auth.password?unescape(encodeURIComponent(E.auth.password)):"";M.Authorization="Basic "+btoa(me+":"+Ie)}var fe=r(E.baseURL,E.url);J.open(E.method.toUpperCase(),i(fe,E.params,E.paramsSerializer),!0),J.timeout=E.timeout;function $e(){if(J){var I="getAllResponseHeaders"in J?s(J.getAllResponseHeaders()):null,P=!B||B==="text"||B==="json"?J.responseText:J.response,z={data:P,status:J.status,statusText:J.statusText,headers:I,config:E,request:J};e(function(ye){b(ye),O()},function(ye){k(ye),O()},z),J=null}}if("onloadend"in J?J.onloadend=$e:J.onreadystatechange=function(){!J||J.readyState!==4||J.status===0&&!(J.responseURL&&J.responseURL.indexOf("file:")===0)||setTimeout($e)},J.onabort=function(){J&&(k(new d("Request aborted",d.ECONNABORTED,E,J)),J=null)},J.onerror=function(){k(new d("Network Error",d.ERR_NETWORK,E,J)),J=null},J.ontimeout=function(){var I=E.timeout?"timeout of "+E.timeout+"ms exceeded":"timeout exceeded",P=E.transitional||c;E.timeoutErrorMessage&&(I=E.timeoutErrorMessage),k(new d(I,P.clarifyTimeoutError?d.ETIMEDOUT:d.ECONNABORTED,E,J)),J=null},t.isStandardBrowserEnv()&&(K&&t.isFunction(K)&&(K=K(E)),K||K!==!1&&a(fe))){var ht=E.xsrfHeaderName&&E.xsrfCookieName&&n.read(E.xsrfCookieName);ht&&(M[E.xsrfHeaderName]=ht)}"setRequestHeader"in J&&t.forEach(M,function(I,P){typeof A=="undefined"&&P.toLowerCase()==="content-type"?delete M[P]:J.setRequestHeader(P,I)}),t.isUndefined(E.withCredentials)||(J.withCredentials=!!E.withCredentials),B&&B!=="json"&&(J.responseType=E.responseType),typeof E.onDownloadProgress=="function"&&J.addEventListener("progress",E.onDownloadProgress),typeof E.onUploadProgress=="function"&&J.upload&&J.upload.addEventListener("progress",E.onUploadProgress),(E.cancelToken||E.signal)&&(X=function(I){J&&(k(!I||I.type?new h(null,E,J):I),J.abort(),J=null)},E.cancelToken&&E.cancelToken.subscribe(X),E.signal&&(E.signal.aborted?X():E.signal.addEventListener("abort",X))),!A&&A!==!1&&A!==0&&A!==""&&(A=null);var V=u(fe);if(V&&g.protocols.indexOf(V)===-1){k(new d("Unsupported protocol "+V+":",d.ERR_BAD_REQUEST,E));return}J.send(A)})},yu}var ft=gt,Zm=sy,ef=bs,Fk=ay,jk=Ul,Wk=Ik,tf=lc,Hk=oy,qk={"Content-Type":"application/x-www-form-urlencoded"};function nf(t,e){!ft.isUndefined(t)&&ft.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Gk(){var t;return(typeof XMLHttpRequest!="undefined"||typeof ls!="undefined"&&Object.prototype.toString.call(ls)==="[object process]")&&(t=Bk()),t}function Jk(t,e,n){if(ft.isString(t))try{return(e||JSON.parse)(t),ft.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(n||JSON.stringify)(t)}var Fl={transitional:Fk,adapter:Gk(),transformRequest:[function(t,e){Zm(e,"Accept"),Zm(e,"Content-Type");var n=e&&e["Content-Type"]||"",i=n.indexOf("application/json")>-1,r=ft.isObject(t);r&&ft.isHTMLForm(t)&&(t=new FormData(t));var s=ft.isFormData(t);if(s)return i?JSON.stringify(Hk(t)):t;if(ft.isArrayBuffer(t)||ft.isBuffer(t)||ft.isStream(t)||ft.isFile(t)||ft.isBlob(t))return t;if(ft.isArrayBufferView(t))return t.buffer;if(ft.isURLSearchParams(t))return nf(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();var a;if(r){if(n.indexOf("application/x-www-form-urlencoded")!==-1)return Wk(t,this.formSerializer).toString();if((a=ft.isFileList(t))||n.indexOf("multipart/form-data")>-1){var c=this.env&&this.env.FormData;return jk(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return r||i?(nf(e,"application/json"),Jk(t)):t}],transformResponse:[function(t){var e=this.transitional||Fl.transitional,n=e&&e.forcedJSONParsing,i=this.responseType==="json";if(t&&ft.isString(t)&&(n&&!this.responseType||i)){var r=e&&e.silentJSONParsing,s=!r&&i;try{return JSON.parse(t)}catch(a){if(s)throw a.name==="SyntaxError"?ef.from(a,ef.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:tf.classes.FormData,Blob:tf.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ft.forEach(["delete","get","head"],function(t){Fl.headers[t]={}});ft.forEach(["post","put","patch"],function(t){Fl.headers[t]=ft.merge(qk)});var qp=Fl,$k=gt,Kk=qp,zk=function(t,e,n,i){var r=this||Kk;return $k.forEach(i,function(s){t=s.call(r,t,e,n)}),t},rf,sf;function dy(){return sf||(sf=1,rf=function(t){return!!(t&&t.__CANCEL__)}),rf}var af=gt,Eu=zk,Yk=dy(),Qk=qp,Xk=Bl(),of=sy;function Su(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Xk}var Zk=function(t){Su(t),t.headers=t.headers||{},t.data=Eu.call(t,t.data,t.headers,null,t.transformRequest),of(t.headers,"Accept"),of(t.headers,"Content-Type"),t.headers=af.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),af.forEach(["delete","get","head","post","put","patch","common"],function(n){delete t.headers[n]});var e=t.adapter||Qk.adapter;return e(t).then(function(n){return Su(t),n.data=Eu.call(t,n.data,n.headers,n.status,t.transformResponse),n},function(n){return Yk(n)||(Su(t),n&&n.response&&(n.response.data=Eu.call(t,n.response.data,n.response.headers,n.response.status,t.transformResponse))),Promise.reject(n)})},Vt=gt,ly=function(t,e){e=e||{};var n={};function i(h,u){return Vt.isPlainObject(h)&&Vt.isPlainObject(u)?Vt.merge(h,u):Vt.isEmptyObject(u)?Vt.merge({},h):Vt.isPlainObject(u)?Vt.merge({},u):Vt.isArray(u)?u.slice():u}function r(h){if(Vt.isUndefined(e[h])){if(!Vt.isUndefined(t[h]))return i(void 0,t[h])}else return i(t[h],e[h])}function s(h){if(!Vt.isUndefined(e[h]))return i(void 0,e[h])}function a(h){if(Vt.isUndefined(e[h])){if(!Vt.isUndefined(t[h]))return i(void 0,t[h])}else return i(void 0,e[h])}function c(h){if(h in e)return i(t[h],e[h]);if(h in t)return i(void 0,t[h])}var d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return Vt.forEach(Object.keys(t).concat(Object.keys(e)),function(h){var u=d[h]||r,g=u(h);Vt.isUndefined(g)&&u!==c||(n[h]=g)}),n},cf,df;function uy(){return df||(df=1,cf={version:"0.28.1"}),cf}var ew=uy().version,pr=bs,Gp={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){Gp[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var lf={};Gp.transitional=function(t,e,n){function i(r,s){return"[Axios v"+ew+"] Transitional option '"+r+"'"+s+(n?". "+n:"")}return function(r,s,a){if(t===!1)throw new pr(i(s," has been removed"+(e?" in "+e:"")),pr.ERR_DEPRECATED);return e&&!lf[s]&&(lf[s]=!0,console.warn(i(s," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(r,s,a):!0}};function tw(t,e,n){if(typeof t!="object")throw new pr("options must be an object",pr.ERR_BAD_OPTION_VALUE);for(var i=Object.keys(t),r=i.length;r-- >0;){var s=i[r],a=e[s];if(a){var c=t[s],d=c===void 0||a(c,s,t);if(d!==!0)throw new pr("option "+s+" must be "+d,pr.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new pr("Unknown option "+s,pr.ERR_BAD_OPTION)}}var nw={assertOptions:tw,validators:Gp},Jp=gt,iw=ry,uf=vk,hf=Zk,jl=ly,rw=cy,fh=nw,Hi=fh.validators;function ba(t){this.defaults=t,this.interceptors={request:new uf,response:new uf}}ba.prototype.request=function(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=jl(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var n=e.transitional;n!==void 0&&fh.assertOptions(n,{silentJSONParsing:Hi.transitional(Hi.boolean),forcedJSONParsing:Hi.transitional(Hi.boolean),clarifyTimeoutError:Hi.transitional(Hi.boolean)},!1);var i=e.paramsSerializer;i!==void 0&&fh.assertOptions(i,{encode:Hi.function,serialize:Hi.function},!0),Jp.isFunction(i)&&(e.paramsSerializer={serialize:i});var r=[],s=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(e)===!1||(s=s&&E.synchronous,r.unshift(E.fulfilled,E.rejected))});var a=[];this.interceptors.response.forEach(function(E){a.push(E.fulfilled,E.rejected)});var c;if(!s){var d=[hf,void 0];for(Array.prototype.unshift.apply(d,r),d=d.concat(a),c=Promise.resolve(e);d.length;)c=c.then(d.shift(),d.shift());return c}for(var h=e;r.length;){var u=r.shift(),g=r.shift();try{h=u(h)}catch(E){g(E);break}}try{c=hf(h)}catch(E){return Promise.reject(E)}for(;a.length;)c=c.then(a.shift(),a.shift());return c};ba.prototype.getUri=function(t){t=jl(this.defaults,t);var e=rw(t.baseURL,t.url);return iw(e,t.params,t.paramsSerializer)};Jp.forEach(["delete","get","head","options"],function(t){ba.prototype[t]=function(e,n){return this.request(jl(n||{},{method:t,url:e,data:(n||{}).data}))}});Jp.forEach(["post","put","patch"],function(t){function e(n){return function(i,r,s){return this.request(jl(s||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:r}))}}ba.prototype[t]=e(),ba.prototype[t+"Form"]=e(!0)});var sw=ba,Tu,pf;function aw(){if(pf)return Tu;pf=1;var t=Bl();function e(n){if(typeof n!="function")throw new TypeError("executor must be a function.");var i;this.promise=new Promise(function(s){i=s});var r=this;this.promise.then(function(s){if(r._listeners){for(var a=r._listeners.length;a-- >0;)r._listeners[a](s);r._listeners=null}}),this.promise.then=function(s){var a,c=new Promise(function(d){r.subscribe(d),a=d}).then(s);return c.cancel=function(){r.unsubscribe(a)},c},n(function(s,a,c){r.reason||(r.reason=new t(s,a,c),i(r.reason))})}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},e.prototype.unsubscribe=function(n){if(this._listeners){var i=this._listeners.indexOf(n);i!==-1&&this._listeners.splice(i,1)}},e.source=function(){var n,i=new e(function(r){n=r});return{token:i,cancel:n}},Tu=e,Tu}var mf,ff;function ow(){return ff||(ff=1,mf=function(t){return function(e){return t.apply(null,e)}}),mf}var bu,gf;function cw(){if(gf)return bu;gf=1;var t=gt;return bu=function(e){return t.isObject(e)&&e.isAxiosError===!0},bu}var gh=gt,dw=Jv,pd=sw,lw=ly,uw=qp,hw=oy;function hy(t){var e=new pd(t),n=dw(pd.prototype.request,e);return gh.extend(n,pd.prototype,e),gh.extend(n,e),n.create=function(i){return hy(lw(t,i))},n}var Qt=hy(uw);Qt.Axios=pd;Qt.CanceledError=Bl();Qt.CancelToken=aw();Qt.isCancel=dy();Qt.VERSION=uy().version;Qt.toFormData=Ul;Qt.AxiosError=bs;Qt.Cancel=Qt.CanceledError;Qt.all=function(t){return Promise.all(t)};Qt.spread=ow();Qt.isAxiosError=cw();Qt.formToJSON=function(t){return hw(gh.isHTMLForm(t)?new FormData(t):t)};kb.exports=Qt;il.default=Qt;(function(t){t.exports=il})(bb);const pw=jT(lh);function mw(){this.__data__=[],this.size=0}function vc(t,e){return t===e||t!==t&&e!==e}function Wl(t,e){for(var n=t.length;n--;)if(vc(t[n][0],e))return n;return-1}var fw=Array.prototype,gw=fw.splice;function vw(t){var e=this.__data__,n=Wl(e,t);if(n<0)return!1;var i=e.length-1;return n==i?e.pop():gw.call(e,n,1),--this.size,!0}function yw(t){var e=this.__data__,n=Wl(e,t);return n<0?void 0:e[n][1]}function Ew(t){return Wl(this.__data__,t)>-1}function Sw(t,e){var n=this.__data__,i=Wl(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}function Di(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Di.prototype.clear=mw;Di.prototype.delete=vw;Di.prototype.get=yw;Di.prototype.has=Ew;Di.prototype.set=Sw;function Tw(){this.__data__=new Di,this.size=0}function bw(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function kw(t){return this.__data__.get(t)}function ww(t){return this.__data__.has(t)}const Nc=globalThis||void 0||self;var _w=typeof Nc=="object"&&Nc&&Nc.Object===Object&&Nc;const py=_w;var Iw=typeof self=="object"&&self&&self.Object===Object&&self,Cw=py||Iw||Function("return this")();const $n=Cw;var Rw=$n.Symbol;const br=Rw;var my=Object.prototype,Pw=my.hasOwnProperty,Aw=my.toString,La=br?br.toStringTag:void 0;function Mw(t){var e=Pw.call(t,La),n=t[La];try{t[La]=void 0;var i=!0}catch{}var r=Aw.call(t);return i&&(e?t[La]=n:delete t[La]),r}var Ow=Object.prototype,Dw=Ow.toString;function Nw(t){return Dw.call(t)}var Lw="[object Null]",xw="[object Undefined]",vf=br?br.toStringTag:void 0;function ks(t){return t==null?t===void 0?xw:Lw:vf&&vf in Object(t)?Mw(t):Nw(t)}function Jn(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Vw="[object AsyncFunction]",Uw="[object Function]",Bw="[object GeneratorFunction]",Fw="[object Proxy]";function $p(t){if(!Jn(t))return!1;var e=ks(t);return e==Uw||e==Bw||e==Vw||e==Fw}var jw=$n["__core-js_shared__"];const ku=jw;var yf=function(){var t=/[^.]+$/.exec(ku&&ku.keys&&ku.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ww(t){return!!yf&&yf in t}var Hw=Function.prototype,qw=Hw.toString;function ws(t){if(t!=null){try{return qw.call(t)}catch{}try{return t+""}catch{}}return""}var Gw=/[\\^$.*+?()[\]{}|]/g,Jw=/^\[object .+?Constructor\]$/,$w=Function.prototype,Kw=Object.prototype,zw=$w.toString,Yw=Kw.hasOwnProperty,Qw=RegExp("^"+zw.call(Yw).replace(Gw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xw(t){if(!Jn(t)||Ww(t))return!1;var e=$p(t)?Qw:Jw;return e.test(ws(t))}function Zw(t,e){return t==null?void 0:t[e]}function _s(t,e){var n=Zw(t,e);return Xw(n)?n:void 0}var e0=_s($n,"Map");const uc=e0;var t0=_s(Object,"create");const hc=t0;function n0(){this.__data__=hc?hc(null):{},this.size=0}function i0(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var r0="__lodash_hash_undefined__",s0=Object.prototype,a0=s0.hasOwnProperty;function o0(t){var e=this.__data__;if(hc){var n=e[t];return n===r0?void 0:n}return a0.call(e,t)?e[t]:void 0}var c0=Object.prototype,d0=c0.hasOwnProperty;function l0(t){var e=this.__data__;return hc?e[t]!==void 0:d0.call(e,t)}var u0="__lodash_hash_undefined__";function h0(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=hc&&e===void 0?u0:e,this}function ys(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}ys.prototype.clear=n0;ys.prototype.delete=i0;ys.prototype.get=o0;ys.prototype.has=l0;ys.prototype.set=h0;function p0(){this.size=0,this.__data__={hash:new ys,map:new(uc||Di),string:new ys}}function m0(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Hl(t,e){var n=t.__data__;return m0(e)?n[typeof e=="string"?"string":"hash"]:n.map}function f0(t){var e=Hl(this,t).delete(t);return this.size-=e?1:0,e}function g0(t){return Hl(this,t).get(t)}function v0(t){return Hl(this,t).has(t)}function y0(t,e){var n=Hl(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}function Is(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Is.prototype.clear=p0;Is.prototype.delete=f0;Is.prototype.get=g0;Is.prototype.has=v0;Is.prototype.set=y0;var E0=200;function S0(t,e){var n=this.__data__;if(n instanceof Di){var i=n.__data__;if(!uc||i.length<E0-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Is(i)}return n.set(t,e),this.size=n.size,this}function ui(t){var e=this.__data__=new Di(t);this.size=e.size}ui.prototype.clear=Tw;ui.prototype.delete=bw;ui.prototype.get=kw;ui.prototype.has=ww;ui.prototype.set=S0;function T0(t,e){for(var n=-1,i=t==null?0:t.length;++n<i&&e(t[n],n,t)!==!1;);return t}var b0=function(){try{var t=_s(Object,"defineProperty");return t({},"",{}),t}catch{}}();const rl=b0;function Kp(t,e,n){e=="__proto__"&&rl?rl(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var k0=Object.prototype,w0=k0.hasOwnProperty;function fy(t,e,n){var i=t[e];(!(w0.call(t,e)&&vc(i,n))||n===void 0&&!(e in t))&&Kp(t,e,n)}function yc(t,e,n,i){var r=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var c=e[s],d=i?i(n[c],t[c],c,n,t):void 0;d===void 0&&(d=t[c]),r?Kp(n,c,d):fy(n,c,d)}return n}function _0(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}function hi(t){return t!=null&&typeof t=="object"}var I0="[object Arguments]";function Ef(t){return hi(t)&&ks(t)==I0}var gy=Object.prototype,C0=gy.hasOwnProperty,R0=gy.propertyIsEnumerable,P0=Ef(function(){return arguments}())?Ef:function(t){return hi(t)&&C0.call(t,"callee")&&!R0.call(t,"callee")};const sl=P0;var A0=Array.isArray;const kr=A0;function M0(){return!1}var vy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sf=vy&&typeof module=="object"&&module&&!module.nodeType&&module,O0=Sf&&Sf.exports===vy,Tf=O0?$n.Buffer:void 0,D0=Tf?Tf.isBuffer:void 0,N0=D0||M0;const ka=N0;var L0=9007199254740991,x0=/^(?:0|[1-9]\d*)$/;function yy(t,e){var n=typeof t;return e=e==null?L0:e,!!e&&(n=="number"||n!="symbol"&&x0.test(t))&&t>-1&&t%1==0&&t<e}var V0=9007199254740991;function Ey(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=V0}var U0="[object Arguments]",B0="[object Array]",F0="[object Boolean]",j0="[object Date]",W0="[object Error]",H0="[object Function]",q0="[object Map]",G0="[object Number]",J0="[object Object]",$0="[object RegExp]",K0="[object Set]",z0="[object String]",Y0="[object WeakMap]",Q0="[object ArrayBuffer]",X0="[object DataView]",Z0="[object Float32Array]",e_="[object Float64Array]",t_="[object Int8Array]",n_="[object Int16Array]",i_="[object Int32Array]",r_="[object Uint8Array]",s_="[object Uint8ClampedArray]",a_="[object Uint16Array]",o_="[object Uint32Array]",Ue={};Ue[Z0]=Ue[e_]=Ue[t_]=Ue[n_]=Ue[i_]=Ue[r_]=Ue[s_]=Ue[a_]=Ue[o_]=!0;Ue[U0]=Ue[B0]=Ue[Q0]=Ue[F0]=Ue[X0]=Ue[j0]=Ue[W0]=Ue[H0]=Ue[q0]=Ue[G0]=Ue[J0]=Ue[$0]=Ue[K0]=Ue[z0]=Ue[Y0]=!1;function c_(t){return hi(t)&&Ey(t.length)&&!!Ue[ks(t)]}function zp(t){return function(e){return t(e)}}var Sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$o=Sy&&typeof module=="object"&&module&&!module.nodeType&&module,d_=$o&&$o.exports===Sy,wu=d_&&py.process,l_=function(){try{var t=$o&&$o.require&&$o.require("util").types;return t||wu&&wu.binding&&wu.binding("util")}catch{}}();const wa=l_;var bf=wa&&wa.isTypedArray,u_=bf?zp(bf):c_;const ql=u_;var h_=Object.prototype,p_=h_.hasOwnProperty;function Ty(t,e){var n=kr(t),i=!n&&sl(t),r=!n&&!i&&ka(t),s=!n&&!i&&!r&&ql(t),a=n||i||r||s,c=a?_0(t.length,String):[],d=c.length;for(var h in t)(e||p_.call(t,h))&&!(a&&(h=="length"||r&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||yy(h,d)))&&c.push(h);return c}var m_=Object.prototype;function Gl(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||m_;return t===n}function by(t,e){return function(n){return t(e(n))}}var f_=by(Object.keys,Object);const g_=f_;var v_=Object.prototype,y_=v_.hasOwnProperty;function ky(t){if(!Gl(t))return g_(t);var e=[];for(var n in Object(t))y_.call(t,n)&&n!="constructor"&&e.push(n);return e}function Ec(t){return t!=null&&Ey(t.length)&&!$p(t)}function Yp(t){return Ec(t)?Ty(t):ky(t)}function E_(t,e){return t&&yc(e,Yp(e),t)}function S_(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var T_=Object.prototype,b_=T_.hasOwnProperty;function k_(t){if(!Jn(t))return S_(t);var e=Gl(t),n=[];for(var i in t)i=="constructor"&&(e||!b_.call(t,i))||n.push(i);return n}function Sc(t){return Ec(t)?Ty(t,!0):k_(t)}function w_(t,e){return t&&yc(e,Sc(e),t)}var wy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kf=wy&&typeof module=="object"&&module&&!module.nodeType&&module,__=kf&&kf.exports===wy,wf=__?$n.Buffer:void 0,_f=wf?wf.allocUnsafe:void 0;function _y(t,e){if(e)return t.slice();var n=t.length,i=_f?_f(n):new t.constructor(n);return t.copy(i),i}function Iy(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}function I_(t,e){for(var n=-1,i=t==null?0:t.length,r=0,s=[];++n<i;){var a=t[n];e(a,n,t)&&(s[r++]=a)}return s}function Cy(){return[]}var C_=Object.prototype,R_=C_.propertyIsEnumerable,If=Object.getOwnPropertySymbols,P_=If?function(t){return t==null?[]:(t=Object(t),I_(If(t),function(e){return R_.call(t,e)}))}:Cy;const Qp=P_;function A_(t,e){return yc(t,Qp(t),e)}function Ry(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var M_=by(Object.getPrototypeOf,Object);const Xp=M_;var O_=Object.getOwnPropertySymbols,D_=O_?function(t){for(var e=[];t;)Ry(e,Qp(t)),t=Xp(t);return e}:Cy;const Py=D_;function N_(t,e){return yc(t,Py(t),e)}function Ay(t,e,n){var i=e(t);return kr(t)?i:Ry(i,n(t))}function vh(t){return Ay(t,Yp,Qp)}function L_(t){return Ay(t,Sc,Py)}var x_=_s($n,"DataView");const yh=x_;var V_=_s($n,"Promise");const Eh=V_;var U_=_s($n,"Set");const Sh=U_;var B_=_s($n,"WeakMap");const Th=B_;var Cf="[object Map]",F_="[object Object]",Rf="[object Promise]",Pf="[object Set]",Af="[object WeakMap]",Mf="[object DataView]",j_=ws(yh),W_=ws(uc),H_=ws(Eh),q_=ws(Sh),G_=ws(Th),jr=ks;(yh&&jr(new yh(new ArrayBuffer(1)))!=Mf||uc&&jr(new uc)!=Cf||Eh&&jr(Eh.resolve())!=Rf||Sh&&jr(new Sh)!=Pf||Th&&jr(new Th)!=Af)&&(jr=function(t){var e=ks(t),n=e==F_?t.constructor:void 0,i=n?ws(n):"";if(i)switch(i){case j_:return Mf;case W_:return Cf;case H_:return Rf;case q_:return Pf;case G_:return Af}return e});const _a=jr;var J_=Object.prototype,$_=J_.hasOwnProperty;function K_(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&$_.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var z_=$n.Uint8Array;const al=z_;function Zp(t){var e=new t.constructor(t.byteLength);return new al(e).set(new al(t)),e}function Y_(t,e){var n=e?Zp(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}var Q_=/\w*$/;function X_(t){var e=new t.constructor(t.source,Q_.exec(t));return e.lastIndex=t.lastIndex,e}var Of=br?br.prototype:void 0,Df=Of?Of.valueOf:void 0;function Z_(t){return Df?Object(Df.call(t)):{}}function My(t,e){var n=e?Zp(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var eI="[object Boolean]",tI="[object Date]",nI="[object Map]",iI="[object Number]",rI="[object RegExp]",sI="[object Set]",aI="[object String]",oI="[object Symbol]",cI="[object ArrayBuffer]",dI="[object DataView]",lI="[object Float32Array]",uI="[object Float64Array]",hI="[object Int8Array]",pI="[object Int16Array]",mI="[object Int32Array]",fI="[object Uint8Array]",gI="[object Uint8ClampedArray]",vI="[object Uint16Array]",yI="[object Uint32Array]";function EI(t,e,n){var i=t.constructor;switch(e){case cI:return Zp(t);case eI:case tI:return new i(+t);case dI:return Y_(t,n);case lI:case uI:case hI:case pI:case mI:case fI:case gI:case vI:case yI:return My(t,n);case nI:return new i;case iI:case aI:return new i(t);case rI:return X_(t);case sI:return new i;case oI:return Z_(t)}}var Nf=Object.create,SI=function(){function t(){}return function(e){if(!Jn(e))return{};if(Nf)return Nf(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();const TI=SI;function Oy(t){return typeof t.constructor=="function"&&!Gl(t)?TI(Xp(t)):{}}var bI="[object Map]";function kI(t){return hi(t)&&_a(t)==bI}var Lf=wa&&wa.isMap,wI=Lf?zp(Lf):kI;const _I=wI;var II="[object Set]";function CI(t){return hi(t)&&_a(t)==II}var xf=wa&&wa.isSet,RI=xf?zp(xf):CI;const PI=RI;var AI=1,MI=2,OI=4,Dy="[object Arguments]",DI="[object Array]",NI="[object Boolean]",LI="[object Date]",xI="[object Error]",Ny="[object Function]",VI="[object GeneratorFunction]",UI="[object Map]",BI="[object Number]",Ly="[object Object]",FI="[object RegExp]",jI="[object Set]",WI="[object String]",HI="[object Symbol]",qI="[object WeakMap]",GI="[object ArrayBuffer]",JI="[object DataView]",$I="[object Float32Array]",KI="[object Float64Array]",zI="[object Int8Array]",YI="[object Int16Array]",QI="[object Int32Array]",XI="[object Uint8Array]",ZI="[object Uint8ClampedArray]",eC="[object Uint16Array]",tC="[object Uint32Array]",Ne={};Ne[Dy]=Ne[DI]=Ne[GI]=Ne[JI]=Ne[NI]=Ne[LI]=Ne[$I]=Ne[KI]=Ne[zI]=Ne[YI]=Ne[QI]=Ne[UI]=Ne[BI]=Ne[Ly]=Ne[FI]=Ne[jI]=Ne[WI]=Ne[HI]=Ne[XI]=Ne[ZI]=Ne[eC]=Ne[tC]=!0;Ne[xI]=Ne[Ny]=Ne[qI]=!1;function md(t,e,n,i,r,s){var a,c=e&AI,d=e&MI,h=e&OI;if(n&&(a=r?n(t,i,r,s):n(t)),a!==void 0)return a;if(!Jn(t))return t;var u=kr(t);if(u){if(a=K_(t),!c)return Iy(t,a)}else{var g=_a(t),E=g==Ny||g==VI;if(ka(t))return _y(t,c);if(g==Ly||g==Dy||E&&!r){if(a=d||E?{}:Oy(t),!c)return d?N_(t,w_(a,t)):A_(t,E_(a,t))}else{if(!Ne[g])return r?t:{};a=EI(t,g,c)}}s||(s=new ui);var b=s.get(t);if(b)return b;s.set(t,a),PI(t)?t.forEach(function(M){a.add(md(M,e,n,M,t,s))}):_I(t)&&t.forEach(function(M,B){a.set(B,md(M,e,n,B,t,s))});var k=h?d?L_:vh:d?Sc:Yp,A=u?void 0:k(t);return T0(A||t,function(M,B){A&&(B=M,M=t[B]),fy(a,B,md(M,e,n,B,t,s))}),a}var nC=1,iC=4;function em(t){return md(t,nC|iC)}var rC="[object Symbol]";function sC(t){return typeof t=="symbol"||hi(t)&&ks(t)==rC}var aC=Object.defineProperty,oC=(t,e)=>{for(var n in e)aC(t,n,{get:e[n],enumerable:!0})},cC={};oC(cC,{permissions:()=>dC,theme:()=>lC});var Yt=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Yt||{}),re=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(re||{}),dC={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},lC={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}},xy="hXgU8Wc8pwuGNq9ms5q9Hh",Vf;typeof ls!="undefined"&&(Vf=ls==null?void 0:ls.env)!=null&&Vf.FLAGSMITH_ENVIRONMENT_KEY&&(xy=ls.env.FLAGSMITH_ENVIRONMENT_KEY);function uC(t=[]){const e={};return t.forEach(n=>{e[n.feature.name]={enabled:n.enabled,value:n.feature_state_value}}),e}var hC=class{constructor(t=xy){y(this,"flags",{}),y(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return p(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:n,forceEvaluate:i,timeout:r,uniqueIdentifier:s,traitsObj:a,logger:c}){const d=JSON.parse(JSON.stringify(a)),h=Object.entries(d).map(g=>({trait_key:g[0],trait_value:g[1]})),u=[e,n,n];for(const g of u)try{const E="_"+(Math.random()+1).toString(36).substring(2),b=yield pw.post(`https://${g}/api/v1/identities/`,{identifier:s+(i?E:""),traits:h},{headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},timeout:r});return uC(b.data.flags||[])}catch(E){c.error("Flagsmith identify failed!!",{error:E,url:g})}return{}})}identify(t){return p(this,arguments,function*(e,n={},i=!1,r=5e3,s="edge.api.flagsmith.com",a=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:n,uniqueIdentifier:e,forceEvaluate:i,timeout:r,primaryEndpoint:s,secondaryEndpoint:"edge.api.flagsmith.com",logger:a}),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}},se=new hC,Vy=[-2,-1,0,1,2],pC=[0,1,2,3,4];function mC(t){t=t.trim();let e="0",n="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+n,+i]}var fC=(t,e,n)=>{let i,r,s;if(e==0)i=r=s=n;else{const a=(h,u,g)=>(g<0&&(g+=1),g>1&&(g-=1),g<.16666666666666666?h+(u-h)*6*g:g<.5?u:g<.6666666666666666?h+(u-h)*(.6666666666666666-g)*6:h),c=n<.5?n*(1+e):n+e-n*e,d=2*n-c;i=a(d,c,t+1/3),r=a(d,c,t),s=a(d,c,t-1/3)}return[Math.round(i*255),Math.round(r*255),Math.round(s*255)]},gC=(t,e,n)=>{t/=255,e/=255,n/=255;const i=Math.max(t,e,n),r=Math.min(t,e,n);let s,a;const c=(i+r)/2;if(i==r)s=a=0;else{const d=i-r;switch(a=c>.5?d/(2-i-r):d/(i+r),i){case t:s=(e-n)/d+(e<n?6:0);break;case e:s=(n-t)/d+2;break;case n:s=(t-e)/d+4;break}s/=6}return[s,a,c]},vC=(t,e,n)=>{const i=r=>r.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`},Uy=(t,e=Vy,n=.4)=>{const i=[],[r,s,a]=mC(t),[c,d,h]=gC(r,s,a),u=Math.round(h*100);u>70?n=.8:u>60?n=.9:u<10?n=.075:u<42&&(n=.3);const g=e.findIndex(M=>M===0);if(g===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const E=5-g,b=g+1,k=(100-u)/E,A=u/b;for(const M of e){let B;M<0?B=u+M*A*n:M>0?B=u+M*k*n:B=u;const[K,X,O]=fC(c,d,B/100);i.push(vC(K,X,O))}return i},Uf={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"}},yC=t=>{const[e,n,i,r,s]=Uy(t,Vy);return{300:e,400:n,500:i,600:r,700:s}},EC=t=>{if(t==="#FFFFFF")return Uf.light.background;if(t==="#000000")return Uf.dark.background;const[e,n,i,r,s]=Uy(t,pC);return{1e3:e,900:n,800:i,700:r,600:s}},SC={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:yC("#2160FD"),background:EC("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function By(){return em(SC)}var TC={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:By(),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 bC(){return em(TC)}var kC={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:By(),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 tm(){return em(kC)}var wC=/\s/;function _C(t){for(var e=t.length;e--&&wC.test(t.charAt(e)););return e}var IC=/^\s+/;function CC(t){return t&&t.slice(0,_C(t)+1).replace(IC,"")}var Bf=0/0,RC=/^[-+]0x[0-9a-f]+$/i,PC=/^0b[01]+$/i,AC=/^0o[0-7]+$/i,MC=parseInt;function Ff(t){if(typeof t=="number")return t;if(sC(t))return Bf;if(Jn(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Jn(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=CC(t);var n=PC.test(t);return n||AC.test(t)?MC(t.slice(2),n?2:8):RC.test(t)?Bf:+t}function Fy(t){return t}function OC(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var DC=800,NC=16,LC=Date.now;function xC(t){var e=0,n=0;return function(){var i=LC(),r=NC-(i-n);if(n=i,r>0){if(++e>=DC)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function VC(t){return function(){return t}}var UC=rl?function(t,e){return rl(t,"toString",{configurable:!0,enumerable:!1,value:VC(e),writable:!0})}:Fy;const BC=UC;var FC=xC(BC);const jC=FC;var jf=Math.max;function WC(t,e,n){return e=jf(e===void 0?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=jf(i.length-e,0),a=Array(s);++r<s;)a[r]=i[e+r];r=-1;for(var c=Array(e+1);++r<e;)c[r]=i[r];return c[e]=n(a),OC(t,this,c)}}function HC(t,e){return jC(WC(t,e,Fy),t+"")}function qC(t,e,n){if(!Jn(n))return!1;var i=typeof e;return(i=="number"?Ec(n)&&yy(e,n.length):i=="string"&&e in n)?vc(n[e],t):!1}function GC(t){return HC(function(e,n){var i=-1,r=n.length,s=r>1?n[r-1]:void 0,a=r>2?n[2]:void 0;for(s=t.length>3&&typeof s=="function"?(r--,s):void 0,a&&qC(n[0],n[1],a)&&(s=r<3?void 0:s,r=1),e=Object(e);++i<r;){var c=n[i];c&&t(e,c,i,s)}return e})}var JC="[object Object]",$C=Function.prototype,KC=Object.prototype,jy=$C.toString,zC=KC.hasOwnProperty,YC=jy.call(Object);function QC(t){if(!hi(t)||ks(t)!=JC)return!1;var e=Xp(t);if(e===null)return!0;var n=zC.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&jy.call(n)==YC}var XC="__lodash_hash_undefined__";function ZC(t){return this.__data__.set(t,XC),this}function eR(t){return this.__data__.has(t)}function ol(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Is;++e<n;)this.add(t[e])}ol.prototype.add=ol.prototype.push=ZC;ol.prototype.has=eR;function tR(t,e){for(var n=-1,i=t==null?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}function nR(t,e){return t.has(e)}var iR=1,rR=2;function Wy(t,e,n,i,r,s){var a=n&iR,c=t.length,d=e.length;if(c!=d&&!(a&&d>c))return!1;var h=s.get(t),u=s.get(e);if(h&&u)return h==e&&u==t;var g=-1,E=!0,b=n&rR?new ol:void 0;for(s.set(t,e),s.set(e,t);++g<c;){var k=t[g],A=e[g];if(i)var M=a?i(A,k,g,e,t,s):i(k,A,g,t,e,s);if(M!==void 0){if(M)continue;E=!1;break}if(b){if(!tR(e,function(B,K){if(!nR(b,K)&&(k===B||r(k,B,n,i,s)))return b.push(K)})){E=!1;break}}else if(!(k===A||r(k,A,n,i,s))){E=!1;break}}return s.delete(t),s.delete(e),E}function sR(t){var e=-1,n=Array(t.size);return t.forEach(function(i,r){n[++e]=[r,i]}),n}function aR(t){var e=-1,n=Array(t.size);return t.forEach(function(i){n[++e]=i}),n}var oR=1,cR=2,dR="[object Boolean]",lR="[object Date]",uR="[object Error]",hR="[object Map]",pR="[object Number]",mR="[object RegExp]",fR="[object Set]",gR="[object String]",vR="[object Symbol]",yR="[object ArrayBuffer]",ER="[object DataView]",Wf=br?br.prototype:void 0,_u=Wf?Wf.valueOf:void 0;function SR(t,e,n,i,r,s,a){switch(n){case ER:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case yR:return!(t.byteLength!=e.byteLength||!s(new al(t),new al(e)));case dR:case lR:case pR:return vc(+t,+e);case uR:return t.name==e.name&&t.message==e.message;case mR:case gR:return t==e+"";case hR:var c=sR;case fR:var d=i&oR;if(c||(c=aR),t.size!=e.size&&!d)return!1;var h=a.get(t);if(h)return h==e;i|=cR,a.set(t,e);var u=Wy(c(t),c(e),i,r,s,a);return a.delete(t),u;case vR:if(_u)return _u.call(t)==_u.call(e)}return!1}var TR=1,bR=Object.prototype,kR=bR.hasOwnProperty;function wR(t,e,n,i,r,s){var a=n&TR,c=vh(t),d=c.length,h=vh(e),u=h.length;if(d!=u&&!a)return!1;for(var g=d;g--;){var E=c[g];if(!(a?E in e:kR.call(e,E)))return!1}var b=s.get(t),k=s.get(e);if(b&&k)return b==e&&k==t;var A=!0;s.set(t,e),s.set(e,t);for(var M=a;++g<d;){E=c[g];var B=t[E],K=e[E];if(i)var X=a?i(K,B,E,e,t,s):i(B,K,E,t,e,s);if(!(X===void 0?B===K||r(B,K,n,i,s):X)){A=!1;break}M||(M=E=="constructor")}if(A&&!M){var O=t.constructor,J=e.constructor;O!=J&&"constructor"in t&&"constructor"in e&&!(typeof O=="function"&&O instanceof O&&typeof J=="function"&&J instanceof J)&&(A=!1)}return s.delete(t),s.delete(e),A}var _R=1,Hf="[object Arguments]",qf="[object Array]",Lc="[object Object]",IR=Object.prototype,Gf=IR.hasOwnProperty;function CR(t,e,n,i,r,s){var a=kr(t),c=kr(e),d=a?qf:_a(t),h=c?qf:_a(e);d=d==Hf?Lc:d,h=h==Hf?Lc:h;var u=d==Lc,g=h==Lc,E=d==h;if(E&&ka(t)){if(!ka(e))return!1;a=!0,u=!1}if(E&&!u)return s||(s=new ui),a||ql(t)?Wy(t,e,n,i,r,s):SR(t,e,d,n,i,r,s);if(!(n&_R)){var b=u&&Gf.call(t,"__wrapped__"),k=g&&Gf.call(e,"__wrapped__");if(b||k){var A=b?t.value():t,M=k?e.value():e;return s||(s=new ui),r(A,M,n,i,s)}}return E?(s||(s=new ui),wR(t,e,n,i,r,s)):!1}function Hy(t,e,n,i,r){return t===e?!0:t==null||e==null||!hi(t)&&!hi(e)?t!==t&&e!==e:CR(t,e,n,i,Hy,r)}function RR(t){return function(e,n,i){for(var r=-1,s=Object(e),a=i(e),c=a.length;c--;){var d=a[t?c:++r];if(n(s[d],d,s)===!1)break}return e}}var PR=RR();const AR=PR;var MR=function(){return $n.Date.now()};const Iu=MR;var OR="Expected a function",DR=Math.max,NR=Math.min;function cl(t,e,n){var i,r,s,a,c,d,h=0,u=!1,g=!1,E=!0;if(typeof t!="function")throw new TypeError(OR);e=Ff(e)||0,Jn(n)&&(u=!!n.leading,g="maxWait"in n,s=g?DR(Ff(n.maxWait)||0,e):s,E="trailing"in n?!!n.trailing:E);function b(me){var Ie=i,fe=r;return i=r=void 0,h=me,a=t.apply(fe,Ie),a}function k(me){return h=me,c=setTimeout(B,e),u?b(me):a}function A(me){var Ie=me-d,fe=me-h,$e=e-Ie;return g?NR($e,s-fe):$e}function M(me){var Ie=me-d,fe=me-h;return d===void 0||Ie>=e||Ie<0||g&&fe>=s}function B(){var me=Iu();if(M(me))return K(me);c=setTimeout(B,A(me))}function K(me){return c=void 0,E&&i?b(me):(i=r=void 0,a)}function X(){c!==void 0&&clearTimeout(c),h=0,i=d=r=c=void 0}function O(){return c===void 0?a:K(Iu())}function J(){var me=Iu(),Ie=M(me);if(i=arguments,r=this,d=me,Ie){if(c===void 0)return k(d);if(g)return clearTimeout(c),c=setTimeout(B,e),b(d)}return c===void 0&&(c=setTimeout(B,e)),a}return J.cancel=X,J.flush=O,J}function bh(t,e,n){(n!==void 0&&!vc(t[e],n)||n===void 0&&!(e in t))&&Kp(t,e,n)}function LR(t){return hi(t)&&Ec(t)}function kh(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function xR(t){return yc(t,Sc(t))}function VR(t,e,n,i,r,s,a){var c=kh(t,n),d=kh(e,n),h=a.get(d);if(h){bh(t,n,h);return}var u=s?s(c,d,n+"",t,e,a):void 0,g=u===void 0;if(g){var E=kr(d),b=!E&&ka(d),k=!E&&!b&&ql(d);u=d,E||b||k?kr(c)?u=c:LR(c)?u=Iy(c):b?(g=!1,u=_y(d,!0)):k?(g=!1,u=My(d,!0)):u=[]:QC(d)||sl(d)?(u=c,sl(c)?u=xR(c):(!Jn(c)||$p(c))&&(u=Oy(d))):g=!1}g&&(a.set(d,u),r(u,d,i,s,a),a.delete(d)),bh(t,n,u)}function qy(t,e,n,i,r){t!==e&&AR(e,function(s,a){if(r||(r=new ui),Jn(s))VR(t,e,a,n,qy,i,r);else{var c=i?i(kh(t,a),s,a+"",t,e,r):void 0;c===void 0&&(c=s),bh(t,a,c)}},Sc)}var UR="[object Map]",BR="[object Set]",FR=Object.prototype,jR=FR.hasOwnProperty;function WR(t){if(t==null)return!0;if(Ec(t)&&(kr(t)||typeof t=="string"||typeof t.splice=="function"||ka(t)||ql(t)||sl(t)))return!t.length;var e=_a(t);if(e==UR||e==BR)return!t.size;if(Gl(t))return!ky(t).length;for(var n in t)if(jR.call(t,n))return!1;return!0}function HR(t,e){return Hy(t,e)}var qR=GC(function(t,e,n){qy(t,e,n)});const Xi=qR;var wh=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(wh||{});const ue={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 fd(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 GR(t){var e,n,i,r;const s=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((n=window.location.host)==null?void 0:n.includes("dyte.io")),a=!!((r=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&r.logs);return s||a}function JR(t){var e;if(se.hasFeature(ue.LOG_LEVEL)){let n=((e=se.getValue(ue.LOG_LEVEL))==null?void 0:e.toString())||"all";if(n=n.toLowerCase().trim(),n==="off")return!1;if(n!=="all"){const i=["debug","log","info","warn","error"],r=i.indexOf(t),s=i.indexOf(n);if(r<s)return!1}}return!0}function Gy(t,e,n={}){return Object.getOwnPropertyNames(t).forEach(i=>{var r;if([null,void 0,NaN].includes(t[i])||e&&(((r=e.match(/\./g))==null?void 0:r.length)||0)>=10)return;const s=e?`${e}.${i}`:i;typeof t[i]=="object"?Gy(t[i],s,n):["number","string","boolean"].includes(typeof t[i])&&(n[s]=t[i])}),n}function Jf(t,e,n={},i=""){const r={};try{const s=JSON.stringify(n),a=JSON.parse(s),c=Gy(a,i),d=JSON.stringify(c);return JSON.parse(d)}catch(s){const a=fd(s);r[`${i}.error.message`]=a.message||"",r[`${i}.error.stack`]=a.stack||"",r[`${i}.error.reason`]=a.reason||"",r[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return r}const pc="chrome",Jy="opera",$y="firefox",Ky="iexplorer",zy="safari",Yy="nwjs",Qy="electron",Xy="react-native",nm="unknown",dl={Chrome:pc,Chromium:pc,Opera:Jy,Firefox:$y,"Internet Explorer":Ky,Safari:zy};function $R(){const{userAgent:t}=navigator,e={name:nm,version:void 0};if(t.match(/Chrome/)&&!t.match(/Edge/))if(t.match(/Edg(A?)/)){const n=t.match(/Chrome\/([\d.]+)/)[1];Number.parseInt(n,10)>72&&(e.name=pc,e.version=n)}else e.name=pc,e.version=t.match(/Chrome\/([\d.]+)/)[1];return e}function KR(){const{userAgent:t}=navigator;if(t.match(/Electron/)){const e=t.match(/Electron\/([\d.]+)/)[1];return{name:Qy,version:e}}return null}function zR(){const{userAgent:t}=navigator;if(t.match(/JitsiMeetNW/)){const e=t.match(/JitsiMeetNW\/([\d.]+)/)[1];return{name:Yy,version:e}}}function YR(){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:Xy,version:e}}function QR(t){let e;const n=[YR,KR,zR];for(let r=0;r<n.length;r+=1)if(e=n[r](),e)return e;const i=t.getBrowserName();return i in dl?{name:dl[i],version:t.getBrowserVersion()}:(e=$R(),e||{name:nm,version:void 0})}class XR{constructor(){y(this,"_bowser"),y(this,"_name"),y(this,"_version"),y(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 n,i;if(this._bowser=ov.getParser(navigator.userAgent),typeof e=="undefined"){const r=QR(this._bowser);n=r.name,i=r.version}else e.name in dl?(n=dl[e.name],i=e.version):(n=nm,i=void 0);this._name=n,this._version=i}getName(){return this._name}isChrome(){return this._name===pc}isOpera(){return this._name===Jy}isFirefox(){return this._name===$y}isIExplorer(){return this._name===Ky}isSafari(){return this._name===zy}isNWJS(){return this._name===Yy}isElectron(){return this._name===Qy}isReactNative(){return this._name===Xy||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 ZR extends XR{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(ls.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 Be=new ZR,eP={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},xa={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"},tP={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,devTools:{logs:!1}};function ll(t,e){const n=t.getValue("overrides");return n&&n[e]?n[e]:!1}function nP({baseURI:t}){return t!=null&&t.includes("preprod.dyte")?Jo.PREPROD:t!=null&&t.includes("devel.dyte")?Jo.DEVEL:Jo.PROD}function ga({servicePrefix:t,baseURI:e}){return`${t}.${e}`}function Zy(t){const e=t.getValue("baseURI");return{location:ga({servicePrefix:"location",baseURI:e}),locationLegacy:ga({servicePrefix:"location-legacy",baseURI:e}),daCollector:ga({servicePrefix:"da-collector",baseURI:e})}}const iP='<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>',rP='<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>',xc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(r=>{r(t)});const e=new Blob([t],{type:"image/svg+xml"}),n=new Image,i=window.URL.createObjectURL(e);return new Promise((r,s)=>{n.onload=()=>{r(n),window.URL.revokeObjectURL(i)},n.onerror=()=>{s(),window.URL.revokeObjectURL(i)},n.src=i})};function sP(t){const e=H({},t),n=new Map,i=(a,c)=>(n.has(a)||n.set(a,new Set),n.get(a).add(c),()=>{var d;return(d=n.get(a))==null?void 0:d.delete(c)}),r=(a,c)=>{var d;(d=n.get(a))==null||d.delete(c)},s=a=>{var c;(c=n.get(a))==null||c.forEach(d=>{try{d(e[a])}catch(h){m.error(`Error in notifying for "${a.toString()}"`,h)}})};return{subscribe:i,unsubscribe:r,notify:s,setValue:(a,c,d=!0)=>{e[a]=c,d&&s(a)},getValue:a=>e[a],getAllValues:()=>e}}class aP{constructor(){y(this,"contexts",new Map),y(this,"mostRecentPeerId",null)}createContext(e,n){return this.contexts.has(e)?this.contexts.get(e):(this.contexts.set(e,sP(n)),this.mostRecentPeerId=e,this.contexts.get(e))}remapContext(e,n){const i=n.getValue("peerId");i!==e&&(n.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,n),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ms=new aP,ve=class{static get logsEndpoint(){const t=ms.getContext(ve.meetingMetadata.peerId);return`https://${ga({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}static resetPeerId(t){ve.meetingMetadata.peerId=t}static init(t,e){const n=t.getValue("peerId");ve.tracingEnabled=e,ve.meetingMetadata.peerId=n,ve.meetingMetadata.sdkVersion=t.getValue("sdkVersion"),ve.meetingMetadata.deviceInfo=Be.getDeviceInfo(),ve.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,navigator.isReactNative||document.addEventListener("visibilitychange",ve.processCachedLogs),ve.logsProcessorTimer=setInterval(ve.processCachedLogs,ve.logsProcessingInterval),e&&(ve.initialized=!0)}static trace(t,e=void 0){return(n,i,r)=>{const s=r.value;return r.value=function(...a){if(!ve.initialized||navigator.isReactNative||!ve.tracingEnabled||se.hasFeature(ue.SKIP_OTEL_TRACES))return s.apply(this,a);ve.addLogInCurrentSpan("info",t,e);const c=performance.now(),d=s.apply(this,a);return Promise.resolve(d).then(()=>{const h=performance.now();h-c>10&&ve.addLogInCurrentSpan("info",`${t}_timing`,{execTime:h-c,country:ve.location.country})}).catch(()=>{const h=performance.now();ve.addLogInCurrentSpan("info",`${t}_timing`,{execTime:h-c})}),d},r}}static injectContext(t){var e;const n=Ca().replace(/-/g,"").substring(0,16),i=(e=ve.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${n}-01`}static addLogInCurrentSpan(t,e,n={},i=!1){n!=null&&n.error&&Object.assign(n,{error:fd(n.error)});const r=ms.getContext(ve.meetingMetadata.peerId);if(GR(r)&&(WR(n)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,n)),!!JR(t))try{const s=Jf(r,e,n,"metadata"),a=new Date,c=ee(H({message:e,level:t},s),{loggedAt:a.toISOString(),loggedAtTzOffset:a.getTimezoneOffset()});i?ve.sendOtelLogsToNewRelic([c]):ve.logsCache.push(c)}catch(s){ve.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:fd(s)})}}static sendOtelLogsToNewRelic(t){const e=ms.getContext(ve.meetingMetadata.peerId);fetch(ve.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:Jf(e,"sendOtelLogsToNewRelic",ve.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(n=>{ve.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:fd(n)}),ve.logsCache.push(...t)})}static processCachedLogs(){const t=ve.logsCache.splice(0,25);t!=null&&t.length&&ve.sendOtelLogsToNewRelic(t)}static destruct(){clearInterval(ve.logsProcessorTimer),ve.processCachedLogs(),navigator.isReactNative||document.removeEventListener("visibilitychange",ve.processCachedLogs)}};let w=ve;y(w,"logsCache",[]),y(w,"logsProcessorTimer"),y(w,"location",{country:void 0}),y(w,"tracingEnabled",!0),y(w,"initialized",!1),y(w,"logsProcessingInterval",7e3),y(w,"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"]),y(w,"meetingMetadata",{});class m{static info(e,n,i){w.addLogInCurrentSpan("info",e,n,i)}static error(e,n,i){w.addLogInCurrentSpan("error",e,n,i)}static debug(e,n,i){w.addLogInCurrentSpan("debug",e,n,i)}static log(e,n,i){w.addLogInCurrentSpan("log",e,n,i)}static warn(e,n,i){w.addLogInCurrentSpan("warn",e,n,i)}}const oP=()=>{!navigator.isReactNative&&typeof window!="undefined"&&(window.addEventListener("error",t=>{var e;!((e=t.filename)!=null&&e.includes("localhost"))&&t.lineno!==0&&m.error("window::error",{error:t.error},!0)}),window.addEventListener("unhandledrejection",t=>{var e,n,i,r,s,a,c,d;m.error("window::unhandledrejection",{error:t==null?void 0:t.reason,networkCall:{url:(n=(e=t==null?void 0:t.reason)==null?void 0:e.config)==null?void 0:n.url,baseURL:(r=(i=t==null?void 0:t.reason)==null?void 0:i.config)==null?void 0:r.baseURL,method:(a=(s=t==null?void 0:t.reason)==null?void 0:s.config)==null?void 0:a.method,status:(c=t==null?void 0:t.reason)==null?void 0:c.status,statusText:(d=t==null?void 0:t.reason)==null?void 0:d.statusText}},!0)}),window.addEventListener("offline",()=>{m.info("window::offline")}),window.addEventListener("online",()=>{m.info("window::online")}))},cP={"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"},gd={"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(gd).forEach(t=>{gd[t]=`{${cP[t.slice(0,2)]}} ${gd[t]}`});class D extends Error{constructor(e,n,i=!1){super(e),y(this,"code"),this.code=n,this.name="DyteError",this.message=`[ERR${this.code}]: ${gd[this.code]}
19
+ ${this.message}`;try{let r=i;n&&n.endsWith("00")&&(r=!0),r&&m.error("DyteError",{error:{message:this.message,name:this.name,code:n}});const s=ms.getContext(ms.getMostRecentPeerId());if(s){const a=s.getValue("onError");try{a(this)}catch{}}typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("dyteError",{detail:this}))}catch{}}}function Vc(t,e,n,i){if(i instanceof D)throw i;if(i instanceof e){const r=new D(i.message,n);throw r.stack=i.stack,r}else throw i}function $f(t,e,n){if(!t.value){const r=t.get,s=t.set;return r&&(t.get=function(){try{return r.apply(this)}catch(a){Vc(this,e,n,a)}}),s&&(t.set=function(a){try{return s.apply(this,[a])}catch(c){Vc(this,e,n,c)}}),t}const i=t.value;return t.value=function(...r){try{const s=i.apply(this,r);return s&&s instanceof Promise?s.catch(a=>{Vc(this,e,n,a)}):s}catch(s){Vc(this,e,n,s)}},t}function dP(t,e){return(n,i,r)=>{if(r)return $f(r,t,e);for(const s of Reflect.ownKeys(n.prototype).filter(a=>a!=="constructor")){const a=Object.getOwnPropertyDescriptor(n.prototype,s);(a.value instanceof Function||a.get instanceof Function||a.set instanceof Function)&&Object.defineProperty(n.prototype,s,$f(a,t,e))}}}const Lt=t=>dP(Error,t);function lP(t){let e=0,n,i;if(!t)return e;for(n=0;n<t.length;n+=1)i=t.charCodeAt(n),e=(e<<5)-e+i,e|=0;return Math.abs(e)%100+1}var Zi,er;const eE=class extends Nt.EventEmitter{constructor(){super(),S(this,Zi,void 0),S(this,er,void 0),y(this,"asyncPromiseTimeout"),T(this,Zi,new Map),T(this,er,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return p(this,null,function*(){o(this,Zi).set(t,[]);const n=o(this,er).get(t).map(()=>new Promise(i=>{o(this,Zi).get(t).push(i)}));FT(eE.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(n),new Promise((i,r)=>setTimeout(()=>r(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),o(this,Zi).delete(t)})}onAsync(t,e){const n=o(this,Zi),i=(...r)=>p(this,null,function*(){var s;try{yield e(...r)}catch(c){m.error("[onAsync]",{error:c})}const a=(s=n.get(t))==null?void 0:s.shift();a==null||a()});return o(this,er).get(t)||o(this,er).set(t,[]),o(this,er).get(t).push(i),super.on(t,i)}reset(){T(this,Zi,new Map),T(this,er,new Map),super.removeAllListeners()}};let uP=eE;Zi=new WeakMap,er=new WeakMap;const L=new uP;function hP(){Be.isElectron()&&window.dyteElectronGetDisplayMediaSource&&(navigator.mediaDevices.getDisplayMedia=()=>p(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 n=e.find(r=>{var s;return(s=r.id)==null?void 0:s.includes("screen")});n=n!=null?n:e[0];const i={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n.id}}};return yield navigator.mediaDevices.getUserMedia(i)}))}var x=(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))(x||{});class Ra extends Nt.EventEmitter{constructor(){super(),super.setMaxListeners(25)}emit(e,...n){return super.emit("*",e,...n),super.emit(e,...n)}on(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.on(e,n)}addListener(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.addListener(e,n)}off(e,n){return super.off(e,n)}once(e,n){return super.once(e,n)}prependListener(e,n){return super.prependListener(e,n)}prependOnceListener(e,n){return super.prependOnceListener(e,n)}removeListener(e,n){return super.removeListener(e,n)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}class gn extends Nt.EventEmitter{constructor(){super(),super.setMaxListeners(25)}emit(e,...n){return super.emit("*",e,...n),super.emit(e,...n)}on(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.on(e,n)}addListener(e,n){try{const i=this.listenerCount(e);i>25&&i%25===0&&m.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}})}catch{}return super.addListener(e,n)}off(e,n){return super.off(e,n)}once(e,n){return super.once(e,n)}prependListener(e,n){return super.prependListener(e,n)}prependOnceListener(e,n){return super.prependOnceListener(e,n)}removeListener(e,n){return super.removeListener(e,n)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}function pP(t,e=2){return t.replace(/[^\u00BF-\u1FFF\u2C00-\uD7FF\w\s]/g,"").trim().split(/\s+/).slice(0,e).map(n=>n.charAt(0)).join("").toUpperCase()}const Kf=1080,zf=1920,mP=(t,e,n,i,r,s)=>{let a=.5,c=.5;const d=r,h=s,u=Math.min(n/d,i/h);let g=d*u,E=h*u,b,k,A,M,B=1;return g<n&&(B=n/g),Math.abs(B-1)<1e-14&&E<i&&(B=i/E),g*=B,E*=B,A=d/(g/n),M=h/(E/i),b=(d-A)*a,k=(h-M)*c,b<0&&(b=0),k<0&&(k=0),A>d&&(A=d),M>h&&(M=h),[b,k,A,M,t,e,n,i]};var xn,po,jt,Vn,nt,ei,tr,tn,dt,mo,fo,nr,go;const tE=class extends gn{constructor(t,e,n,i){super(),S(this,xn,void 0),S(this,po,void 0),S(this,jt,void 0),S(this,Vn,void 0),S(this,nt,{height:Kf,width:zf}),S(this,ei,{brand:"#2160FD",background:"#141414",text:"#000000",videoBackground:"#191919",textOnBrand:"#EEEEEE"}),S(this,tr,void 0),S(this,tn,{}),S(this,dt,void 0),S(this,mo,void 0),S(this,fo,void 0),S(this,nr,void 0),S(this,go,!1),y(this,"cleanupEventListeners",()=>{o(this,po).unsubscribe("stageStatus",this.handlePipMediaControls),o(this,dt).removeListener("videoUpdate",this.onSelfVideoUpdateListener),o(this,dt).removeListener("audioUpdate",this.onSelfAudioUpdateListener),o(this,dt).removeListener("roomLeft",()=>this.disable())}),y(this,"enablePipMediaControls",()=>{this.mountAudioEvents(),this.mountVideoEvents()}),y(this,"onSelfVideoUpdateListener",({videoEnabled:r})=>{this.updateMediaSession("CAMERA",r)}),y(this,"onSelfAudioUpdateListener",({audioEnabled:r})=>{this.updateMediaSession("MIC",r)}),y(this,"handlePipMediaControls",r=>{r==="ON_STAGE"?this.enablePipMediaControls():this.unmountEvents()}),y(this,"eventCallback",r=>{r==="CAMERA"&&(o(this,dt).videoEnabled?o(this,dt).disableVideo():o(this,dt).enableVideo(),this.emit("cameraToggled")),r==="MIC"&&(o(this,dt).audioEnabled?o(this,dt).disableAudio():o(this,dt).enableAudio(),this.emit("micToggled")),r==="END"&&(L.emit(x.PIP_HANGUP),this.cleanupEventListeners(),this.emit("hangup"),this.cleanup())}),y(this,"unmountEvents",()=>{navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("togglemicrophone",void 0),navigator.mediaSession.setActionHandler("togglecamera",void 0))}),y(this,"animate",()=>{if(!this.isActive&&o(this,nr)==="active"){this.disable(!0);return}o(this,tn)!==void 0&&this.paintCanvas(),o(this,tr)!==void 0&&T(this,tr,requestAnimationFrame(()=>this.animate()))}),y(this,"disable",(r=!1)=>{T(this,nr,"idle"),this.cleanupEventListeners(),cancelAnimationFrame(o(this,tr)),r!==!0&&document.body.removeChild(o(this,jt)),T(this,tr,void 0),document.pictureInPictureElement&&document.exitPictureInPicture()}),T(this,po,t),T(this,nr,"idle"),T(this,dt,e),T(this,ei,{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}),n&&this.setupIcon("pin",n),i&&this.setupIcon("handRaise",i)}static _init(t,e){return p(this,null,function*(){let n,i;try{n=yield xc(iP),i=yield xc(rP)}catch{}return new tE(t,e,n,i)})}setupIcon(t,e){return p(this,null,function*(){switch(t){case"handRaise":T(this,fo,e);break;case"pin":T(this,mo,e);break}})}overrideIcon(t,e){return p(this,null,function*(){switch(t){case"handRaise":T(this,fo,yield xc(e));break;case"pin":T(this,mo,yield xc(e));break}})}constructImage(t){const e=new Image,n=new Blob([t],{type:"image/svg+xml"}),i=window.URL.createObjectURL(n);return new Promise(r=>{e.onload=()=>{r(e),window.URL.revokeObjectURL(i)},e.src=i})}createVideoContainer(){T(this,jt,document.createElement("div")),o(this,jt).style.width="0.1px",o(this,jt).style.height="0.1px",o(this,jt).style.overflow="hidden",o(this,jt).style.position="absolute",o(this,jt).style.bottom="0",o(this,jt).style.right="0",o(this,jt).style.opacity="0",o(this,jt).appendChild(o(this,Vn))}setupEventListeners(){o(this,po).subscribe("stageStatus",this.handlePipMediaControls),o(this,dt).addListener("videoUpdate",this.onSelfVideoUpdateListener),o(this,dt).addListener("audioUpdate",this.onSelfAudioUpdateListener),o(this,dt).addListener("roomLeft",()=>this.disable())}createCanvas(){const t=document.createElement("canvas");t.height=o(this,nt).height,t.width=o(this,nt).width,T(this,xn,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||o(this,dt).permissions.canProduceAudio&&navigator.mediaSession.setActionHandler("togglemicrophone",()=>{this.eventCallback("MIC")})}mountVideoEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||o(this,dt).permissions.canProduceVideo&&navigator.mediaSession.setActionHandler("togglecamera",()=>{this.eventCallback("CAMERA")})}getSources(){const t=Object.values(o(this,tn)).reduce((e,n)=>(e[n.pinned?"pinned":"regular"].push(n),e),{pinned:[],regular:[]});return[...t.pinned,...t.regular]}drawEmptyTile(t,e,n,i){if(o(this,xn)===void 0)return;const r=o(this,xn).getContext("2d"),s=o(this,xn).width,a=0,c=0,d=e-a*2,h=n-a*2,u=Math.floor(s/d),g=Math.floor(t/u),E=t%u*(d+a)+a,b=g*(h+a)+a,{displayText:k,image:A}=i!=null?i:{};r.fillStyle=k||A?o(this,ei).videoBackground:o(this,ei).background,r.strokeStyle=o(this,ei).brand,r.beginPath(),r.moveTo(E+c,b),r.arcTo(E+d,b,E+d,b+c,c),r.arcTo(E+d,b+h,E+d-c,b+h,c),r.arcTo(E,b+h,E,b+h-c,c),r.arcTo(E,b,E+c,b,c),r.closePath(),r.fill(),r.stroke();const M=d/6,B=d/2+E,K=h/2+b;r.save(),(k||A)&&(r.beginPath(),r.arc(B,K,M,0,Math.PI*2),r.fillStyle=o(this,ei).brand,r.fill(),A?(r.clip(),r.drawImage(A,B-M,K-M,M*2,M*2),r.restore()):k&&(r.fillStyle=o(this,ei).textOnBrand,r.font=`${M/2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(k,B,K)),this.drawIcons(i,E,b,Math.max(d,h)))}drawIcons(t,e,n,i){const r=Math.min(Math.max(i*.15,100),200),s=r*.2,a=r*.2;let c=e+s;const d=n+s,h=u=>{const g=o(this,xn).getContext("2d");g.save(),g.fillStyle=o(this,ei).background,g.beginPath(),g.moveTo(c+a,d),g.arcTo(c+r,d,c+r,d+a,a),g.arcTo(c+r,d+r,c+r-a,d+r,a),g.arcTo(c,d+r,c,d+r-a,a),g.arcTo(c,d,c+a,d,a),g.closePath(),g.fill(),typeof u=="string"?(g.font=`${r/1.5}px sans-serif`,g.fillStyle=o(this,ei).text,g.textAlign="center",g.textBaseline="top",g.fillText(u,r/2+c,d+s)):g.drawImage(u,c+s,d+s,r-s*2,r-s*2),c+=r+s,g.restore()};t.pinned&&h(o(this,mo)),t.handRaised&&h(o(this,fo))}drawTile(t,e,n){var i,r;if(o(this,xn)===void 0)return;const s=o(this,xn).getContext("2d"),a=this.getSources();let c=0,d=0;for(;c<o(this,nt).height-5;){let h=0;for(;h<o(this,nt).width-5&&d<n;){if((i=a[d])!=null&&i.enabled){const u=a[d].element,[g,E,b,k,A,M,B,K]=mP(h,c,t,e,u.videoWidth,u.videoHeight);(r=u==null?void 0:u.classList)!=null&&r.contains("mirror")?(s.save(),s.scale(-1,1),s.drawImage(u,g,E,b,k,-1*A,M,-1*B,K),s.restore()):s.drawImage(u,g,E,b,k,A,M,B,K),this.drawIcons(a[d],A,M,Math.max(B,K))}else this.drawEmptyTile(d,t,e,a[d]);d+=1,h+=t}c+=e}}calcGridElemSize(t){switch(t){case 0:case 1:return[o(this,nt).width,o(this,nt).height];case 2:return[Math.floor(o(this,nt).width/2),o(this,nt).height];case 3:case 4:return[Math.floor(o(this,nt).width/2),Math.floor(o(this,nt).height/2)];case 5:case 6:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/2)];case 7:case 8:case 9:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/3)];default:return[Math.floor(o(this,nt).width/3),Math.floor(o(this,nt).height/2)]}}paintCanvas(){let t=this.getSources().length;t!==1&&(t=t%2>0?t+1:t);const[e,n]=this.calcGridElemSize(t);this.drawTile(e,n,t)}isSupported(){var t;return!!window.chrome&&document.pictureInPictureEnabled&&((t=o(this,dt).config)==null?void 0:t.viewType)!=="LIVESTREAM"}get isActive(){return document.pictureInPictureElement!==null}cleanup(){if(T(this,go,!1),this.isSupported()&&document.exitPictureInPicture!==void 0&&document.pictureInPictureElement!==null&&document.exitPictureInPicture(),o(this,jt))try{document.body.removeChild(o(this,jt))}catch{}this.removeAllSources(),T(this,xn,void 0),T(this,Vn,void 0),T(this,tr,void 0)}init({height:t,width:e}={}){if(!this.isSupported())throw m.error("DytePip.unsupported"),new Error("Picture-in-picture is not available in this environment");if(o(this,go))return;T(this,go,!0),this.createCanvas(),this.setupMediaSessionEvents();const n=document.createElement("video");T(this,nt,{height:t!=null?t:Kf,width:e!=null?e:zf}),n.height=o(this,nt).height,n.width=o(this,nt).width,n.autoplay=!0,n.muted=!0,n.srcObject=o(this,xn).captureStream(24),T(this,Vn,n),o(this,Vn).onloadedmetadata=()=>{try{this.emit("pipStarted"),o(this,Vn).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){o(this,tn)[t]!==void 0&&(o(this,tn)[t].enabled=!0)}disableSource(t){o(this,tn)[t]!==void 0&&(o(this,tn)[t].enabled=!1)}generateAvatar(t,e){return p(this,null,function*(){if(!e)return;const n=new Image;try{const i=yield(yield fetch(e)).blob(),r=window.URL.createObjectURL(i);n.onload=()=>{this.updateSource(t,{image:n}),window.URL.revokeObjectURL(r)},n.src=r}catch(i){m.error("DytePip::GenerateAvatar",{error:i})}})}addSource(t,e,n,i=!1,r=void 0,s=void 0,a=!1){m.debug("DytePIP::AddSource",{pip:{id:t,handRaised:a}}),o(this,tn)[t]={id:t,element:e,enabled:n,pinned:i,displayText:r?pP(r):void 0,imageUrl:s,handRaised:a},s&&this.generateAvatar(t,s)}updateSource(t,e){m.info("DytePIP::UpdateSource",{pip:{id:t,handRaised:e.handRaised}});const n=o(this,tn)[t];n&&(o(this,tn)[t]=H(H({},n),e))}removeSource(t){delete o(this,tn)[t]}removePinnedSource(){Object.values(o(this,tn)).forEach(t=>{t.pinned&&this.removeSource(t.id)})}removeAllSources(){T(this,tn,{})}enable(){T(this,nr,"activating"),this.setupEventListeners(),this.updateMediaSession("CAMERA",o(this,dt).videoEnabled),this.updateMediaSession("MIC",o(this,dt).audioEnabled),document.body.appendChild(o(this,jt)),T(this,tr,requestAnimationFrame(()=>this.animate())),o(this,Vn).onloadedmetadata=()=>{o(this,Vn).requestPictureInPicture().then(()=>{T(this,nr,"active")})},o(this,Vn).readyState===4&&o(this,Vn).requestPictureInPicture().then(()=>{T(this,nr,"active")})}};let fP=tE;xn=new WeakMap,po=new WeakMap,jt=new WeakMap,Vn=new WeakMap,nt=new WeakMap,ei=new WeakMap,tr=new WeakMap,tn=new WeakMap,dt=new WeakMap,mo=new WeakMap,fo=new WeakMap,nr=new WeakMap,go=new WeakMap;var Ai;(function(t){t[t.PUBLISHER=0]="PUBLISHER",t[t.SUBSCRIBER=1]="SUBSCRIBER"})(Ai||(Ai={}));var di;(function(t){t[t.AUDIO=0]="AUDIO",t[t.VIDEO=1]="VIDEO"})(di||(di={}));class gP extends _{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 nE=new gP;class vP extends _{constructor(){super("media.HeaderExtension",[{no:1,name:"direction",kind:"scalar",opt:!0,T:9},{no:2,name:"uri",kind:"scalar",T:9}])}}const yP=new vP;class EP extends _{constructor(){super("media.Fingerprint",[{no:1,name:"algorithm",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}])}}new EP;class SP extends _{constructor(){super("media.SessionDescription",[{no:1,name:"target",kind:"enum",T:()=>["media.Target",Ai]},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"sdp",kind:"scalar",T:9}])}}const Kn=new SP;class TP extends _{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 bP=new TP;class kP extends _{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:()=>Kn},{no:4,name:"private_ice",kind:"scalar",opt:!0,T:8},{no:5,name:"producers",kind:"message",repeat:1,T:()=>bP}])}}const wP=new kP;class _P extends _{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 IP=new _P;class CP extends _{constructor(){super("media.CreateTransportResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:4,name:"producer_ids",kind:"scalar",repeat:2,T:9}])}}const iE=new CP;class RP extends _{constructor(){super("media.RenegotiateRequest",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn}])}}const PP=new RP;class AP extends _{constructor(){super("media.RenegotiateResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn}])}}new AP;class MP extends _{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 OP=new MP;class DP extends _{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 NP=new DP;class LP extends _{constructor(){super("media.ProducerEntry",[{no:1,name:"producing_transport_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9}])}}new LP;class xP extends _{constructor(){super("media.ConsumerEntry",[{no:1,name:"consuming_transport_id",kind:"scalar",T:9},{no:2,name:"consumer_id",kind:"scalar",T:9}])}}new xP;class VP extends _{constructor(){super("media.ProducerState",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:()=>["media.ProducerKind",di]},{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:()=>nE}])}}const Tc=new VP;class UP extends _{constructor(){super("media.ConsumerState",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc},{no:3,name:"producer_track",kind:"message",T:()=>NP},{no:4,name:"error_code",kind:"scalar",opt:!0,T:9}])}}const BP=new UP;class FP extends _{constructor(){super("media.ProducerIdToConsumerMap",[{no:1,name:"map",kind:"map",K:9,V:{kind:"message",T:()=>BP}}])}}const rE=new FP;class jP extends _{constructor(){super("media.PeerRtpCapabilitites",[{no:1,name:"sender",kind:"message",T:()=>Qf},{no:2,name:"receiver",kind:"message",T:()=>Qf}])}}const sE=new jP;class WP extends _{constructor(){super("media.RtpCapability",[{no:1,name:"codecs",kind:"message",repeat:1,T:()=>nE},{no:2,name:"header_extensions",kind:"message",repeat:1,T:()=>yP}])}}const Yf=new WP;class HP extends _{constructor(){super("media.RtpCapabilitites",[{no:1,name:"audio",kind:"message",T:()=>Yf},{no:2,name:"video",kind:"message",T:()=>Yf}])}}const Qf=new HP;class qP extends _{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 GP=new qP;class JP extends _{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 $P=new JP;class KP extends _{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:()=>$P},{no:9,name:"capabilities",kind:"message",T:()=>sE}])}}const zP=new KP;class YP extends _{constructor(){super("media.edge.PeerJoinCompleteRequest",[])}}const QP=new YP;class XP extends _{constructor(){super("media.edge.PeerLeaveRequest",[{no:1,name:"close_room",kind:"scalar",T:8}])}}const ZP=new XP;class eA extends _{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 eA;class tA extends _{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:()=>GP},{no:5,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const nA=new tA;class iA extends _{constructor(){super("media.edge.ConsumePeersRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>nA},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const rA=new iA;class sA extends _{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:()=>Kn},{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 aA=new sA;class oA extends _{constructor(){super("media.edge.SelectedPeersRequest",[])}}new oA;class cA extends _{constructor(){super("media.edge.GlobalPeerPinningRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const dA=new cA;class lA extends _{constructor(){super("media.edge.ProducerToggleRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}const Uc=new lA;class uA extends _{constructor(){super("media.edge.ConsumerToggleRequest",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}new uA;class hA extends _{constructor(){super("media.edge.ProducerCloseRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const pA=new hA;class mA extends _{constructor(){super("media.edge.ConsumerCloseRequest",[{no:1,name:"consumer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"description",kind:"message",T:()=>Kn},{no:3,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const fA=new mA;class gA extends _{constructor(){super("media.edge.KickPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new gA;class vA extends _{constructor(){super("media.edge.KickAllPeersRequest",[{no:1,name:"propagate_kick_across_rooms",kind:"scalar",T:8}])}}const aE=new vA;class yA extends _{constructor(){super("media.edge.PeerDisplayNameEditRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}const EA=new yA;class SA extends _{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 TA=new SA;class bA extends _{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 kA=new bA;class wA extends _{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 _A=new wA;class IA extends _{constructor(){super("media.edge.ErrorResponse",[{no:1,name:"error_message",kind:"scalar",T:9},{no:2,name:"event_id",kind:"scalar",T:5}])}}const CA=new IA;class RA extends _{constructor(){super("media.edge.EmptyResponse",[])}}new RA;class PA extends _{constructor(){super("media.edge.RoomParticipants",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"producer_states",kind:"message",repeat:1,T:()=>Tc},{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:()=>sE}])}}const oE=new PA;class AA extends _{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 _h=new AA;class MA extends _{constructor(){super("media.edge.SelectedPeersDiffEntry",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"priority",kind:"scalar",T:5}])}}const OA=new MA;class DA extends _{constructor(){super("media.edge.SelectedPeersDiffResponse",[{no:1,name:"entries",kind:"message",repeat:1,T:()=>OA}])}}const Xf=new DA;class NA extends _{constructor(){super("media.edge.PeerJoinResponse",[])}}new NA;class LA extends _{constructor(){super("media.edge.PeerJoinCompleteResponse",[{no:1,name:"room_state",kind:"message",T:()=>_A},{no:2,name:"participants",kind:"message",repeat:1,T:()=>oE},{no:3,name:"selected_peers",kind:"message",T:()=>_h},{no:4,name:"max_preferred_streams",kind:"scalar",T:5}])}}const Ih=new LA;class xA extends _{constructor(){super("media.edge.PeerLeaveResponse",[{no:1,name:"closed",kind:"scalar",T:8}])}}const VA=new xA;class UA extends _{constructor(){super("media.edge.ConsumeMultipleProducerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>rE}])}}new UA;class BA extends _{constructor(){super("media.edge.ConsumePeerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>rE},{no:3,name:"description",kind:"message",T:()=>Kn}])}}const FA=new BA;class jA extends _{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:()=>Kn}])}}const WA=new jA;class HA extends _{constructor(){super("media.edge.ProducerScoreResponse",[{no:1,name:"responseid",kind:"scalar",T:9},{no:2,name:"score",kind:"message",T:()=>OP}])}}new HA;class qA extends _{constructor(){super("media.edge.ActiveSpeakerResponse",[{no:1,name:"responsepeer_id",kind:"scalar",T:9},{no:2,name:"volume",kind:"scalar",T:5}])}}new qA;class GA extends _{constructor(){super("media.edge.NoActiveSpeakerResponse",[])}}new GA;class JA extends _{constructor(){super("media.edge.ProducerToggleResponse",[])}}new JA;class $A extends _{constructor(){super("media.edge.ConsumerToggleResponse",[])}}new $A;class KA extends _{constructor(){super("media.edge.ProducerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Kn}])}}const zA=new KA;class YA extends _{constructor(){super("media.edge.ConsumerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Kn}])}}const QA=new YA;class XA extends _{constructor(){super("media.edge.GlobalPeerPinningResponse",[])}}new XA;class ZA extends _{constructor(){super("media.edge.KickPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new ZA;class eM extends _{constructor(){super("media.edge.KickAllPeersResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new eM;class tM extends _{constructor(){super("media.edge.HostMediaControlForPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const nM=new tM;class iM extends _{constructor(){super("media.edge.HostMediaControlForAllPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const rM=new iM;class sM extends _{constructor(){super("media.edge.PeerDisplayNameEditResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const aM=new sM;class oM extends _{constructor(){super("media.edge.PeerJoinBroadcastResponse",[{no:1,name:"participant",kind:"message",T:()=>oE}])}}const Zf=new oM;class cM extends _{constructor(){super("media.edge.TrackSubscriptionKind",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8}])}}const eg=new cM;class dM extends _{constructor(){super("media.edge.TrackSubscription",[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"webcam",kind:"message",T:()=>eg},{no:3,name:"screenshare",kind:"message",T:()=>eg}])}}const lM=new dM;class uM extends _{constructor(){super("media.edge.PeerProducingTransportCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"transport_details",kind:"message",T:()=>iE},{no:3,name:"track_subscriptions",kind:"message",repeat:1,T:()=>lM}])}}new uM;class hM extends _{constructor(){super("media.edge.PeerProducerCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc}])}}const pM=new hM;class mM extends _{constructor(){super("media.edge.PeerProducerToggleBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc},{no:3,name:"initiator_participant_id",kind:"scalar",opt:!0,T:9}])}}const tg=new mM;class fM extends _{constructor(){super("media.edge.PeerProducerCloseBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>Tc}])}}const gM=new fM;class vM extends _{constructor(){super("media.edge.PeerLeaveBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const Ch=new vM;class yM extends _{constructor(){super("media.edge.GlobalPeerPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const ng=new yM;class EM extends _{constructor(){super("media.edge.GlobalPeerUnPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new EM;class SM extends _{constructor(){super("media.edge.RecordingStartedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new SM;class TM extends _{constructor(){super("media.edge.RecordingStoppedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new TM;class bM extends _{constructor(){super("media.edge.PeerDisplayNameEditBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}new bM;class kM extends _{constructor(){super("media.edge.PeerPingRequestBroadcastResponse",[{no:1,name:"password",kind:"scalar",T:9}])}}new kM;class wM extends _{constructor(){super("media.edge.MediaRoomTerminationBroadcastResponse",[{no:1,name:"reason",kind:"scalar",T:9}])}}new wM;class _M extends _{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 Cu=new _M;class IM extends _{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 IM;class CM extends _{constructor(){super("socket.api.ErrorMessage",[{no:1,name:"code",kind:"scalar",opt:!0,T:5},{no:2,name:"message",kind:"scalar",T:9}])}}const RM=new CM;var fs;(function(t){t[t.BROWSER=0]="BROWSER",t[t.TRACK=1]="TRACK",t[t.COMPOSITE=2]="COMPOSITE"})(fs||(fs={}));var wi;(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"})(wi||(wi={}));var Rh;(function(t){t[t.NONE=0]="NONE",t[t.RECORDER=1]="RECORDER",t[t.LIVESTREAMER=2]="LIVESTREAMER"})(Rh||(Rh={}));var Ph;(function(t){t[t.PEERS=0]="PEERS",t[t.ROOMS=1]="ROOMS"})(Ph||(Ph={}));var ul;(function(t){t[t.HIVE=0]="HIVE",t[t.CHAT=1]="CHAT",t[t.PING=2]="PING"})(ul||(ul={}));class PM extends _{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 AM=new PM;class MM extends _{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",wi,"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:()=>AM}])}}const Jl=new MM;class OM extends _{constructor(){super("socket.room.PeerInfoResponse",[{no:1,name:"peer",kind:"message",T:()=>Jl}])}}const Gs=new OM;class DM extends _{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",wi,"STAGE_TYPE_"]}])}}const ig=new DM;class NM extends _{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 LM=new NM;class xM extends _{constructor(){super("socket.room.RoomPeersInfoResponse",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>Jl}])}}const Ru=new xM;class VM extends _{constructor(){super("socket.room.RoomPeerCountResponse",[{no:1,name:"count",kind:"scalar",T:4,L:2}])}}const rg=new VM;class UM extends _{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:()=>FM},{no:6,name:"room_uuid",kind:"scalar",opt:!0,T:9}])}}const cE=new UM;class BM extends _{constructor(){super("socket.room.ActiveRecording",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",fs]},{no:3,name:"recording_status",kind:"scalar",T:9}])}}const FM=new BM;class jM extends _{constructor(){super("socket.room.RoomInfoResponse",[{no:1,name:"room",kind:"message",T:()=>cE}])}}const sg=new jM;class WM extends _{constructor(){super("socket.room.GetPeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9}])}}const dE=new WM;class HM extends _{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 HM;class qM extends _{constructor(){super("socket.room.JoinRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>Jl},{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",ul,"CAPABILITIES_"]},{no:8,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const GM=new qM;class JM extends _{constructor(){super("socket.room.LeaveRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>Jl},{no:2,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const $M=new JM;class KM extends _{constructor(){super("socket.room.UpdateRoomInfoRequest",[{no:1,name:"room",kind:"message",T:()=>cE}])}}new KM;class zM extends _{constructor(){super("socket.room.GetConnectedRoomsDumpRequest",[])}}new zM;class YM extends _{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 im=new YM;class QM extends _{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 XM=new QM;class ZM extends _{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:()=>XM}])}}const ag=new ZM;class e1 extends _{constructor(){super("socket.room.GetConnectedRoomsDumpResponse",[{no:1,name:"parent_meeting",kind:"message",T:()=>ag},{no:2,name:"meetings",kind:"message",repeat:1,T:()=>ag}])}}const t1=new e1;class n1 extends _{constructor(){super("socket.room.CreateRoomRequestPayload",[{no:1,name:"title",kind:"scalar",opt:!0,T:9}])}}const i1=new n1;class r1 extends _{constructor(){super("socket.room.CreateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>i1}])}}const s1=new r1;class a1 extends _{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:()=>im}])}}const o1=new a1;class c1 extends _{constructor(){super("socket.room.CreateConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>o1}])}}const og=new c1;class d1 extends _{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 l1=new d1;class u1 extends _{constructor(){super("socket.room.UpdateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>l1}])}}new u1;class h1 extends _{constructor(){super("socket.room.DisableRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9}])}}const p1=new h1;class m1 extends _{constructor(){super("socket.room.DisableConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>p1}])}}const f1=new m1;class g1 extends _{constructor(){super("socket.room.DisableConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>E1}])}}const v1=new g1;class y1 extends _{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:()=>im}])}}const E1=new y1;class S1 extends _{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 T1=new S1;class b1 extends _{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:()=>T1}])}}const k1=new b1;class w1 extends _{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:()=>im}])}}const lE=new w1;class _1 extends _{constructor(){super("socket.room.MovePeersBetweenRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>lE}])}}new _1;class I1 extends _{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 C1=new I1;class R1 extends _{constructor(){super("socket.room.GetAllAddedParticipantsResponse",[{no:1,name:"participants",kind:"message",repeat:1,T:()=>M1}])}}const P1=new R1;class A1 extends _{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 M1=new A1;class O1 extends _{constructor(){super("socket.room.RemoveParticipantsRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const uE=new O1;class D1 extends _{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",Ph,"BROADCAST_TYPE_"]}])}}const Va=new D1;class N1 extends _{constructor(){super("socket.room.AcceptWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const L1=new N1;class x1 extends _{constructor(){super("socket.room.DenyWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const V1=new x1;class U1 extends _{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 B1=new U1;class F1 extends _{constructor(){super("socket.room.GetWaitingRoomRequests",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>B1}])}}const cg=new F1;class j1 extends _{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 dg=new j1;var Ah;(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"})(Ah||(Ah={}));var yr;(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"})(yr||(yr={}));class W1 extends _{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 H1=new W1;class q1 extends _{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 G1=new q1;class J1 extends _{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 $1=new J1;class K1 extends _{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 z1=new K1;class Y1 extends _{constructor(){super("socket.preset.ChatPermissionUpdate",[{no:1,name:"public",kind:"message",T:()=>$1},{no:2,name:"private",kind:"message",T:()=>z1}])}}const Q1=new Y1;class X1 extends _{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 Z1=new X1;class eO extends _{constructor(){super("socket.preset.StreamPermission",[{no:1,name:"can_produce",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",yr,"STREAM_PERMISSION_TYPE_"]},{no:2,name:"can_consume",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",yr,"STREAM_PERMISSION_TYPE_"]}])}}const Pu=new eO;class tO extends _{constructor(){super("socket.preset.MediaPermissionUpdate",[{no:1,name:"video",kind:"message",T:()=>Pu},{no:2,name:"audio",kind:"message",T:()=>Pu},{no:3,name:"screenshare",kind:"message",T:()=>Pu}])}}const nO=new tO;class iO extends _{constructor(){super("socket.preset.PresetUpdates",[{no:1,name:"polls",kind:"message",T:()=>H1},{no:2,name:"plugins",kind:"message",T:()=>G1},{no:3,name:"chat",kind:"message",T:()=>Q1},{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",Ah,"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",Rh,"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:()=>Z1},{no:23,name:"media",kind:"message",T:()=>nO}])}}const rm=new iO;class rO extends _{constructor(){super("socket.preset.ReadPeersPresetRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const sO=new rO;class aO extends _{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 oO=new aO;class cO extends _{constructor(){super("socket.preset.ReadPeersPresetResponse",[{no:1,name:"peer_presets",kind:"message",repeat:1,T:()=>oO}])}}const dO=new cO;class lO extends _{constructor(){super("socket.preset.UpdatePeerPreset",[{no:1,name:"user_ids",kind:"scalar",T:9},{no:2,name:"patch",kind:"message",T:()=>rm}])}}const hE=new lO;class uO extends _{constructor(){super("socket.preset.UpdatePeersPresetRequest",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>hE}])}}const hO=new uO;class pO extends _{constructor(){super("socket.preset.UpdatePeersPresetResponse",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>hE}])}}const lg=new pO;class mO extends _{constructor(){super("socket.preset.PeerUserIDMap",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9}])}}const fO=new mO;class gO extends _{constructor(){super("socket.preset.BulkUpdatePeerPresetRequest",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>fO},{no:2,name:"patch",kind:"message",T:()=>rm}])}}new gO;class vO extends _{constructor(){super("socket.preset.BulkUpdatePeerPresetResponse",[{no:2,name:"patch",kind:"message",T:()=>rm}])}}new vO;class yO extends _{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 Cs=new yO;class EO extends _{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 SO=new EO;class TO extends _{constructor(){super("socket.chat.GetPaginatedChatMessageRoomResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Cs},{no:2,name:"next",kind:"scalar",T:8}])}}const bO=new TO;class kO extends _{constructor(){super("socket.chat.GetChatMessagesResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Cs}])}}const pE=new kO;class wO extends _{constructor(){super("socket.chat.SendChatMessageToRoomRequest",[{no:1,name:"payload_type",kind:"scalar",T:5},{no:2,name:"payload",kind:"scalar",T:9}])}}const _O=new wO;class IO extends _{constructor(){super("socket.chat.SendChatMessageToRoomResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Au=new IO;class CO extends _{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 RO=new CO;class PO extends _{constructor(){super("socket.chat.SendChatMessageToPeersResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Mu=new PO;class AO extends _{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 MO=new AO;class OO extends _{constructor(){super("socket.chat.SendChatMessageToChannelResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}new OO;class DO extends _{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 NO=new DO;class LO extends _{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 xO=new LO;class VO extends _{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 Bc=new VO;class UO extends _{constructor(){super("socket.chat.EditChatMessageResponse",[{no:1,name:"message",kind:"message",T:()=>Cs}])}}const Fc=new UO;class BO extends _{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 FO=new BO;class jO extends _{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 jc=new jO;class WO extends _{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 HO=new WO;class qO extends _{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 GO=new qO;class JO extends _{constructor(){super("socket.chat.MarkChannelIndexAsReadResponse",[{no:1,name:"channel_index",kind:"scalar",T:9}])}}const $O=new JO;class KO extends _{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 zO=new KO;class YO extends _{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 QO=new YO;class XO extends _{constructor(){super("socket.chat.CreateChatChannelResponse",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}new XO;class ZO extends _{constructor(){super("socket.chat.GetChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}const eD=new ZO;class tD extends _{constructor(){super("socket.chat.LatestMessageAndUnreadCount",[{no:1,name:"message",kind:"message",T:()=>Cs},{no:2,name:"unread_count",kind:"scalar",T:4,L:2}])}}const nD=new tD;class iD extends _{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:()=>nD},{no:7,name:"target_user_ids",kind:"scalar",repeat:2,T:9}])}}const rD=new iD;class sD extends _{constructor(){super("socket.chat.GetChatChannelResponse",[{no:1,name:"chat_channels",kind:"message",repeat:1,T:()=>rD}])}}const fi=new sD;class aD extends _{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 oD=new aD;class cD extends _{constructor(){super("socket.chat.GetChatChannelMembersResponse",[{no:1,name:"channel_members",kind:"message",repeat:1,T:()=>oD}])}}const dD=new cD;class lD extends _{constructor(){super("socket.plugin.AddPluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const uD=new lD;class hD extends _{constructor(){super("socket.plugin.RemovePluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const pD=new hD;class mD extends _{constructor(){super("socket.plugin.EnablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const fD=new mD;class gD extends _{constructor(){super("socket.plugin.DisablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const vD=new gD;class yD extends _{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 ED=new yD;class SD extends _{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 TD=new SD;class bD extends _{constructor(){super("socket.plugin.PluginEventToRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const kD=new bD;class wD extends _{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 _D=new wD;class ID extends _{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 sm=new ID;class CD extends _{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:()=>sm}])}}const ug=new CD;class RD extends _{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:()=>sm}])}}const PD=new RD;class AD extends _{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:()=>sm}])}}const MD=new AD;class OD extends _{constructor(){super("socket.plugin.PluginStoreDeleteRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9}])}}const DD=new OD;class ND extends _{constructor(){super("socket.plugin.EnablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"enabled_by",kind:"scalar",T:9}])}}const Mh=new ND;class LD extends _{constructor(){super("socket.plugin.EnablePluginsResponse",[{no:1,name:"plugins",kind:"message",repeat:1,T:()=>Mh}])}}const xD=new LD;class VD extends _{constructor(){super("socket.plugin.DisablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"disabled_by",kind:"scalar",T:9}])}}const hg=new VD;class UD extends _{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 BD=new UD;class FD extends _{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:()=>BD}])}}const pg=new FD;class jD extends _{constructor(){super("socket.plugin.PluginEventResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const mg=new jD;class WD extends _{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 fg=new WD;class HD extends _{constructor(){super("socket.livestreaming.GetStagePeersResponse",[{no:1,name:"stage_peers",kind:"scalar",repeat:2,T:9}])}}const gg=new HD;class qD extends _{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 GD=new qD;class JD extends _{constructor(){super("socket.livestreaming.GetStageRequestsResponse",[{no:1,name:"stage_requests",kind:"message",repeat:1,T:()=>GD}])}}const Ou=new JD;class $D extends _{constructor(){super("socket.livestreaming.GrantStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const KD=new $D;class zD extends _{constructor(){super("socket.livestreaming.DenyStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const YD=new zD;class QD extends _{constructor(){super("socket.livestreaming.LeaveStageRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const vg=new QD;class XD extends _{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:()=>eN},{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 mE=new XD;class ZD extends _{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:()=>nN}])}}const eN=new ZD;class tN extends _{constructor(){super("socket.polls.PollVote",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9}])}}const nN=new tN;class iN extends _{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 rN=new iN;class sN extends _{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 aN=new sN;class oN extends _{constructor(){super("socket.polls.UpdatePollResponse",[{no:1,name:"poll",kind:"message",T:()=>mE}])}}const Du=new oN;class cN extends _{constructor(){super("socket.polls.GetPollsResponse",[{no:1,name:"polls",kind:"message",repeat:1,T:()=>mE}])}}const dN=new cN;class lN extends _{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",fs]}])}}const yg=new lN;class uN extends _{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(),n=Date.now();return e.seconds=xe.from(Math.floor(n/1e3)).toBigInt(),e.nanos=n%1e3*1e6,e}toDate(e){return new Date(xe.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){const n=this.create(),i=e.getTime();return n.seconds=xe.from(Math.floor(i/1e3)).toBigInt(),n.nanos=i%1e3*1e6,n}internalJsonWrite(e,n){let i=xe.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 r="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",r)}internalJsonRead(e,n,i){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+Dp(e)+".");let r=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(!r)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>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=xe.from(s/1e3).toBigInt(),i.nanos=0,r[7]&&(i.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),i}}new uN;class hN extends _{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}])}}const Oh=new hN;class pN extends _{constructor(){super("common.BulkedHubMessage",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Oh}])}}new pN;class mN extends _{constructor(){super("common.CFWorkersResponse",[{no:1,name:"responses",kind:"message",repeat:1,T:()=>Oh},{no:2,name:"broadcast_responses",kind:"message",repeat:1,T:()=>Oh}])}}new mN;const fN=0,gN=1,vN=2,yN=3,EN=4,SN=5,TN={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},bN={getMessages:0,sendMessageToRoom:1,sendMessageToPeers:2,editMessage:3,deleteMessage:4,getPaginatedMessages:5,sendMessageToChannel:6,searchChannelMessages:7,getAllChatChannels:8,markChannelIndexAsRead:9,pinMessage:10},kN={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},wN={createPoll:0,getPolls:1,votePoll:2,updatePoll:3},fE={unknown:0,createWebRTCTransport:1,produce:2,consume:3,toggleProducer:4,toggleConsumer:5,closeProducer:6,closeConsumer:7,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},_N={createChatChannel:0,getChatChannel:1,deprecatedGetAllChatChannels:2,getChannelMembers:3,updateChatChannel:4},IN={getUserPresets:0,updateUserPreset:1};function Pa(t,e){return Object.keys(e).reduce((n,i)=>(n[i]=(t<<16)+e[i],n),{})}function gE(t,e){return Object.keys(t).reduce((n,i)=>(n[i]=e|t[i],n),{})}const Y=Pa(fN,TN),Ge=Pa(gN,bN),ie=Pa(vN,kN),Si=Pa(yN,wN),ss=Pa(EN,_N),In=gE(fE,16777216),Hn=gE(fE,50331648),vd=Pa(SN,IN);var CN=Object.defineProperty,RN=Object.getOwnPropertyDescriptor,am=(t,e,n,i)=>{for(var r=i>1?void 0:i?RN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&CN(e,n,r),r},Nr,Eg;const Dh=(Eg=class{constructor(t){S(this,Nr,void 0),T(this,Nr,t)}createChannel(t,e,n,i="public",r=!1){return p(this,null,function*(){const s={displayName:t,targetUserIds:e,displayPictureUrl:n,visibility:i,isDirectMessage:r};r&&(s.visibility="private");const a=yield o(this,Nr).sendMessagePromise(ss.createChatChannel,zO.toBinary(s)),c=fi.fromBinary(a.payload).chatChannels;return Dh.formatChannel(c[0])})}updateChannel(t,e){return p(this,null,function*(){const n=yield o(this,Nr).sendMessagePromise(ss.updateChatChannel,QO.toBinary({chatChannelId:t,targetUserIds:e.memberIds,displayName:e.displayName,displayPictureUrl:e.displayPictureUrl,visibility:e.visibility})),i=fi.fromBinary(n.payload).chatChannels;return Dh.formatChannel(i[0])})}static formatChannel(t){var e;const{latestMessageAndUnreadCount:n}=t,i=ee(H({},t),{id:t.chatChannelId,memberIds:t.targetUserIds,unreadCount:(e=n==null?void 0:n.unreadCount)!=null?e:0});return n!=null&&n.message&&(i.latestMessage=Ci.formatSocketServiceMessage(n.message)),delete i.chatChannelId,delete i.targetUserIds,delete i.latestMessageAndUnreadCount,i}getChannelMembers(t){return p(this,null,function*(){try{const e=yield o(this,Nr).sendMessagePromise(ss.getChannelMembers,eD.toBinary({chatChannelId:t}));return dD.fromBinary(e.payload).channelMembers.map(n=>{var i=n,{id:r}=i,s=Ml(i,["id"]);return ee(H({},s),{userId:r})})}catch{return[]}})}on(t,e){let n,i;switch(t){case ss.createChatChannel:{n=fi.fromBinary.bind(fi),i=fi.create();break}case ss.updateChatChannel:{n=fi.fromBinary.bind(fi),i=fi.create();break}}if(!n){m.warn(`ChatChannelSocketHandler::Event ${t} is not recognized`);return}o(this,Nr).on(t,({payload:r})=>{let s=i;try{s=n(r)}catch(a){m.error("ChatChannelSocketHandler::on::binary_decode_error",{error:a})}return e(s)})}},Nr=new WeakMap,Eg);let Es=Dh;am([w.trace("ChatChannelHandler.createChannel")],Es.prototype,"createChannel",1);am([w.trace("ChatChannelHandler.updateChannel")],Es.prototype,"updateChannel",1);am([w.trace("ChatChannelHandler.getChannelMembers")],Es.prototype,"getChannelMembers",1);var PN=Object.defineProperty,AN=Object.getOwnPropertyDescriptor,zn=(t,e,n,i)=>{for(var r=i>1?void 0:i?AN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&PN(e,n,r),r},Jt=(t=>(t[t.TEXT=0]="TEXT",t[t.IMAGE=1]="IMAGE",t[t.FILE=2]="FILE",t[t.CUSTOM=3]="CUSTOM",t))(Jt||{}),Wt;class Cn{constructor(e){S(this,Wt,void 0),T(this,Wt,e)}getChatMessages(){return o(this,Wt).sendMessagePromise(Ge.getMessages)}getChatMessagesPaginated(e,n,i,r=0,s=""){return p(this,null,function*(){const a={timeStamp:e,size:n,from:r,reversed:i,channelId:s},c=yield o(this,Wt).sendMessagePromise(Ge.getPaginatedMessages,SO.toBinary(a));return c.payload?bO.fromBinary(c.payload):{messages:[],next:!1}})}sendMessageToRoom(e,n){const i={payloadType:n,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToRoom,_O.toBinary(i))}sendMessageToPeers(e,n,i){const r={payloadType:n,peerIds:i,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToPeers,RO.toBinary(r))}sendMessageToChannel(e,n,i){const r={payloadType:n,channelId:i,payload:e};o(this,Wt).sendMessage(Ge.sendMessageToChannel,MO.toBinary(r))}sendMessage(e,n,i,r){if(r&&this.sendMessageToChannel(e,n,r),i&&i.length>0){this.sendMessageToPeers(e,n,i);return}this.sendMessageToRoom(e,n)}editMessage(e,n,i,r,s){return p(this,null,function*(){const a={chatId:e,payloadType:i,payload:n};r&&(a.channelId=r),s!==void 0&&(a.pinned=s);const c=yield o(this,Wt).sendMessagePromise(Ge.editMessage,NO.toBinary(a));return Fc.fromBinary(c.payload).message})}deleteMessage(e,n){return p(this,null,function*(){const i={chatId:e};n&&(i.channelId=n);const r=yield o(this,Wt).sendMessagePromise(Ge.deleteMessage,FO.toBinary(i)),s=jc.fromBinary(r.payload);return H({id:s.chatId},s.channelId?{channelId:s.channelId}:{})})}searchMessages(e,n){return p(this,null,function*(){var i,r,s;const a={searchTerm:e,timeStamp:(i=n.timestamp)!=null?i:Date.now(),size:(r=n.size)!=null?r:75,from:0,reversed:(s=n.reversed)!=null?s:!0};n.channelId&&(a.channelId=n.channelId);try{const c=yield o(this,Wt).sendMessagePromise(Ge.searchChannelMessages,HO.toBinary(a));return pE.fromBinary(c.payload).messages}catch{return[]}})}getAllChannels(){return p(this,null,function*(){try{const e=yield o(this,Wt).sendMessagePromise(Ge.getAllChatChannels);return fi.fromBinary(e.payload).chatChannels.map(Es.formatChannel)}catch{return[]}})}markLastReadMessage(e,n){return p(this,null,function*(){const i=yield o(this,Wt).sendMessagePromise(Ge.markChannelIndexAsRead,GO.toBinary({channelId:e,userId:n.userId,channelIndex:n.channelIndex}));return $O.fromBinary(i.payload).channelIndex})}setPinState(e,n){return p(this,null,function*(){const i={chatId:e.id,pinned:n,channelId:e.channelId},r=yield o(this,Wt).sendMessagePromise(Ge.pinMessage,xO.toBinary(i));return Bc.fromBinary(r.payload)})}on(e,n){let i,r;switch(e){case Ge.sendMessageToRoom:{i=Au.fromBinary.bind(Au),r=Au.create();break}case Ge.sendMessageToPeers:{i=Mu.fromBinary.bind(Mu),r=Mu.create();break}case Ge.editMessage:{i=Fc.fromBinary.bind(Fc),r=Fc.create();break}case Ge.pinMessage:{i=Bc.fromBinary.bind(Bc),r=Bc.create();break}case Ge.deleteMessage:{i=jc.fromBinary.bind(jc),r=jc.create();break}}if(!i){m.warn(`ChatSocketHandler::Event ${e} is not recognized`);return}o(this,Wt).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("chatSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}}Wt=new WeakMap;zn([w.trace("SocketService.getChatMessages")],Cn.prototype,"getChatMessages",1);zn([w.trace("SocketService.getChatMessagesPaginated")],Cn.prototype,"getChatMessagesPaginated",1);zn([w.trace("SocketService.sendMessageToRoom")],Cn.prototype,"sendMessageToRoom",1);zn([w.trace("SocketService.sendMessageToPeers")],Cn.prototype,"sendMessageToPeers",1);zn([w.trace("SocketService.sendMessageToChannel")],Cn.prototype,"sendMessageToChannel",1);zn([w.trace("SocketService.sendMessage")],Cn.prototype,"sendMessage",1);zn([w.trace("SocketService.editMessage")],Cn.prototype,"editMessage",1);zn([w.trace("SocketService.deleteMessage")],Cn.prototype,"deleteMessage",1);zn([w.trace("SocketService.searchMessages")],Cn.prototype,"searchMessages",1);zn([w.trace("SocketService.getAllChannels")],Cn.prototype,"getAllChannels",1);zn([w.trace("SocketService.markLastReadMessage")],Cn.prototype,"markLastReadMessage",1);function MN(t){return t.replace(/([-_]\w)/g,e=>e[1].toUpperCase())}function Gn(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>Gn(n));const e={};return Object.keys(t).forEach(n=>{const i=Op(n)?n:MN(n);e[i]=Gn(t[n])}),e}function ON(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function vE(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>vE(n));const e={};return Object.keys(t).forEach(n=>{const i=Op(n)?n:ON(n);e[i]=t[n]}),e}function hl(t,e={}){return t==null?{}:(Object.getOwnPropertyNames(t).forEach(n=>{if(typeof t[n]!="function"){if(typeof t[n]=="object"){hl(t[n],e[n]={});return}e[n]=t[n]}}),e)}class Sg{constructor(e){y(this,"defaults"),this.defaults={baseURL:e.baseURL,headers:{common:{}},timeout:e.timeout,retry:e.retry,retryDelay:e.retryDelay}}buildURL(e,n){const{baseURL:i}=this.defaults,r=e.startsWith("http")?e:`${i}${e.startsWith("/")?e:`/${e}`}`;if(n){const s=new URLSearchParams;return Object.entries(n).forEach(([a,c])=>{s.append(a,c)}),`${r}${r.includes("?")?"&":"?"}${s.toString()}`}return r}request(e){return p(this,null,function*(){var n;const i=((n=e.method)==null?void 0:n.toUpperCase())||"GET",r=this.buildURL(e.url||"",e.params),s=H(H({},this.defaults.headers.common),e.headers);i!=="GET"&&i!=="HEAD"&&e.data&&!s["Content-Type"]&&(s["Content-Type"]="application/json");const a=s["Content-Type"]==="application/json"?JSON.stringify(e.data):e.data,c={method:i,headers:s,body:i!=="GET"&&i!=="HEAD"&&e.data?a:void 0},d=e.timeout||this.defaults.timeout,h=e.retry!==void 0?e.retry:this.defaults.retry,u=e.retryDelay||this.defaults.retryDelay;try{const g=new AbortController,E=setTimeout(()=>g.abort(),d);c.signal=g.signal;const b=yield fetch(r,c);clearTimeout(E);let k=null;const A=b.headers.get("content-type");A&&A.includes("application/json")?k=yield b.json():k=yield b.text();const M={};b.headers.forEach((K,X)=>{M[X]=K});const B={data:k,status:b.status,statusText:b.statusText,headers:M,config:e};if(!b.ok)throw B;return B}catch(g){if(g instanceof Error&&h>0)return yield new Promise(E=>setTimeout(E,u)),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(ee(H({},e),{retry:h-1}));throw g}})}get(e){return p(this,arguments,function*(n,i={}){return this.request(ee(H({},i),{method:"GET",url:n}))})}post(e,n){return p(this,arguments,function*(i,r,s={}){return this.request(ee(H({},s),{method:"POST",url:i,data:r}))})}put(e,n){return p(this,arguments,function*(i,r,s={}){return this.request(ee(H({},s),{method:"PUT",url:i,data:r}))})}}const DN=3,NN=30,LN=8e3;class xN{constructor(e,n){y(this,"ipInfo"),y(this,"fetchClient"),y(this,"requests"),y(this,"roomName"),y(this,"roomUUID"),y(this,"authToken"),y(this,"organizationId"),y(this,"iceServers"),y(this,"pluginInformation"),y(this,"userDetails"),y(this,"roomDetails"),y(this,"context"),this.context=e;const{timeout:i=LN,retry:r=DN,retryDelay:s=NN,baseURL:a="https://api.dyte.io",authToken:c,cachedUserDetails:d}=n||{};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 Sg({baseURL:a,timeout:i,retry:r,retryDelay:s,responseType:"json"}),this.fetchClient=new Sg({baseURL:"",timeout:i,retry:r,retryDelay:s,responseType:"json"}),this.setAuthToken(c,{bearer:!0});const h=this.requests.request.bind(this.requests);this.requests.request=u=>p(this,null,function*(){var g,E,b,k,A;try{w.injectContext(this.requests.defaults.headers.common);const M=yield h(u);return u.url!==w.logsEndpoint&&m.debug("xhr::fetch",{networkCall:{status:M.status,statusText:M.statusText,baseURL:u.baseURL||this.requests.defaults.baseURL,url:u.url,method:u.method}}),M}catch(M){throw M?(((g=M.config)==null?void 0:g.url)!==w.logsEndpoint&&m.error("xhr::fetch",{error:M,networkCall:{status:M.status,statusText:M.statusText,baseURL:((E=M.config)==null?void 0:E.baseURL)||this.requests.defaults.baseURL,url:(b=M.config)==null?void 0:b.url,retries:(k=M.config)==null?void 0:k.retry,method:(A=M.config)==null?void 0:A.method,isOnline:navigator.onLine?"online":"offline"}}),new D(M.message||"Network request failed","0011")):new D("Unknown network error occurred","0011")}})}get peerId(){return this.context.getValue("peerId")}setAuthToken(e,n){const{bearer:i}=n||{};this.authToken=e,this.requests.defaults.headers.common.Authorization=i?`Bearer ${e}`:e}setHeader(e,n){this.requests.defaults.headers.common[e]=n}setRoomName(e){this.roomName=e}setRoomUUID(e){this.roomUUID=e}setOrganizationId(e){this.organizationId=e}}var VN=Object.defineProperty,UN=Object.getOwnPropertyDescriptor,Rn=(t,e,n,i)=>{for(var r=i>1?void 0:i?UN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&VN(e,n,r),r};class vn extends xN{constructor(e,n){super(e,n),this.setHeader("x-dyte-web-core-version",e.getValue("sdkVersion"))}getIPDetails(){return p(this,null,function*(){var e;const{peerId:n}=this;try{const i=yield Up.getIPDetails({peerId:n,apiHostnames:Zy(this.context),logger:m});if(m.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){m.warn("ApiClient.getRoomNodeLinkAndTitleV1 Failed to get ip details",{error:{name:i.name,message:i.message}});return}})}getICEServers(){return p(this,null,function*(){if(this.iceServers)return this.iceServers;const{success:e,iceServers:n}=(yield this.requests.get("/iceservers")).data;if(e)return(n==null?void 0:n.length)>0&&(this.iceServers=n),n})}getPlugins(){return p(this,null,function*(){var e,n,i,r,s,a,c;if(this.pluginInformation)return this.pluginInformation;const{plugins:d}=(yield this.requests.get("/v2/plugins/user")).data.data,h=((n=(e=se.getValue(ue.V1_PLUGINS))==null?void 0:e.toString())==null?void 0:n.split(","))||[],u=d.reduce((g,E)=>(g[h.includes(E.id)?"v1":"v2"].push(ee(H({},E),{name:E.name.replace("v2","")})),g),{v1:[],v2:[]});return(s=(r=(i=this.context.getValue("modules"))==null?void 0:i.devTools)==null?void 0:r.plugins)!=null&&s.length&&((c=(a=this.context.getValue("modules"))==null?void 0:a.devTools)==null||c.plugins.forEach(g=>{var E,b,k;const A=ee(H({},xa),{tags:[...xa.tags],baseUrl:`http://localhost:${g.port}`,name:g.name,picture:(E=g.picture)!=null?E:xa.picture,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),id:g.id,organizationId:this.organizationId,description:(b=g.description)!=null?b:xa.description,staggered:(k=g.staggered)!=null?k:xa.staggered});u.v2.push(A)})),u.v2})}getPluginDetails(e){return p(this,null,function*(){const{plugin:n}=(yield this.requests.get(`/v2/plugins/view/${e}`)).data.data;return n})}getPluginConfig(e){return p(this,null,function*(){return(yield this.fetchClient.get(`${e}/dyte-config.json`)).data})}authorizePlugin(e){return p(this,null,function*(){const n={peerId:this.peerId},{token:i}=(yield this.requests.post(`/v2/plugins/authorize/${e}`,n)).data.data;return i})}getPresignedUrls(e,n){return p(this,null,function*(){const i=ll(this.context,"chat_upload_expiry"),r={roomUUID:this.roomUUID,filename:e,expiry:typeof i=="number"?i:void 0};se.hasFeature(ue.FEAT_CHAT_SDK)&&(r.viewType=n);const{getLocation:s,putLocation:a}=(yield this.requests.post("/v1/meetings/genPreSignedUploadUrl",r)).data.data;return{getLocation:s,putLocation:a}})}uploadFile(e,n){return p(this,null,function*(){if(navigator.isReactNative&&"uri"in e)try{yield fetch(n,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:{uri:e.uri,name:e.name}})}catch(i){m.error(`sendFileMessage::${i}`)}else yield this.fetchClient.put(n,e,{headers:{"Content-Type":e.type}})})}startLivestreaming(e){return p(this,arguments,function*({manualIngestion:n}){const i=Gn(yield this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/livestreams`,{manual_ingest:!!n})).data.data;return{playbackUrl:i.playbackUrl,status:i.status,manualIngest:i.manualIngest,ingestionCredentials:i.streamKey?{ingestionServer:i.ingestServer,streamKey:i.streamKey}:null}})}stopLivestreaming(){return p(this,null,function*(){return this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream/stop`)})}getActiveLivestream(){return p(this,null,function*(){const e=Gn((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 p(this,null,function*(){if(this.userDetails)return this.userDetails;const e=(yield this.requests.get("v2/internals/participant-details")).data.data;return Gn(e)})}startRecording(e,n){return p(this,null,function*(){return(yield this.requests.post("/v2/recordings",ee(H({},vE(e)),{meeting_id:this.context.getValue("meetingId"),allow_multiple_recordings:!!n}))).data.data.id})}updateRecording(e,n){return p(this,null,function*(){return this.requests.put(`v2/recordings/${e}`,{action:n})})}getActiveRecording(){return p(this,null,function*(){const{status:e,id:n}=(yield this.requests.get(`v2/recordings/active-recording/${this.context.getValue("meetingId")}`)).data.data;return{status:e,id:n}})}getActiveTranscript(){return p(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 D("Cant fetch transcript s3 url","1801")}})}getRoomNodeData(){return p(this,null,function*(){const e=yield this.getIPDetails();if(this.ipInfo=e,this.roomDetails)return this.roomDetails;const{roomNodeLink:n,title:i,useHiveMedia:r,sfu:s}=Gn((yield this.requests.post("v2/internals/rooms",{ip_information:e})).data.data);return{roomNodeUrl:n,meetingTitle:i,useHiveMedia:r!=null?r:!1,sfu:s}})}}Rn([w.trace("APIClient.getIPDetails")],vn.prototype,"getIPDetails",1);Rn([w.trace("APIClient.getICEServers")],vn.prototype,"getICEServers",1);Rn([w.trace("APIClient.getPlugins")],vn.prototype,"getPlugins",1);Rn([w.trace("APIClient.startLivestreaming")],vn.prototype,"startLivestreaming",1);Rn([w.trace("APIClient.stopLivestreaming")],vn.prototype,"stopLivestreaming",1);Rn([w.trace("APIClient.getActiveLivestream")],vn.prototype,"getActiveLivestream",1);Rn([w.trace("APIClient.getUserDetails")],vn.prototype,"getUserDetails",1);Rn([w.trace("APIClient.startRecording")],vn.prototype,"startRecording",1);Rn([w.trace("APIClient.stopRecording")],vn.prototype,"updateRecording",1);Rn([w.trace("APIClient.getActiveRecording")],vn.prototype,"getActiveRecording",1);Rn([w.trace("APIClient.getActiveTranscript")],vn.prototype,"getActiveTranscript",1);Rn([w.trace("APIClient.getRoomNodeData")],vn.prototype,"getRoomNodeData",1);let Nh;function BN(t,e){return Nh=new vn(t,e),Nh}function Pt(){return Nh}function FN(t,e){return`<blockquote>${e.replace(/<blockquote>[.\s\S]*<\/blockquote>\n\n/m,"")}</blockquote>
21
20
 
22
- ${t}`}const Aa={maxInvocations:5,period:1};function on(t,e){return function(n,i,r){const s=r.value;let a=0,c=Date.now();return r.value=function(...d){const h=Date.now(),u=e?this[e]:t;if(h-c>u.period*1e3&&(c=h,a=0),a>=u.maxInvocations)throw new D(`Method rate limit ${u.maxInvocations} invocations/${u.period}sec exceeded`,"0013");return a+=1,s.apply(this,d)},r}}var jN=Object.defineProperty,WN=Object.getOwnPropertyDescriptor,xt=(t,e,n,i)=>{for(var r=i>1?void 0:i?WN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&jN(e,n,r),r};const HN=["text","image","file","custom","poll"],yd={maxInvocations:180,period:60};var he,Os,pt,Ds,Wc,Nu,Tg,Hc,Lu,bg;let kt=(bg=class extends gn{constructor(t,e,n,i,r){super(),S(this,Nu),S(this,Hc),y(this,"messages"),y(this,"channels",[]),S(this,he,void 0),S(this,Os,void 0),S(this,pt,void 0),S(this,Ds,void 0),S(this,Wc,void 0),y(this,"maxTextLimit",2e3),T(this,Wc,t),T(this,pt,e),T(this,Ds,n),T(this,he,i),T(this,Os,r),this.messages=[]}setMaxTextLimit(t){this.maxTextLimit=t}sendMessageInternal(t,e,n){return p(this,arguments,function*(i,r,s,a={}){switch(i.type){case"text":{const c=a.replyTo&&a.replyTo.type==="text"?FN(i.message,a.replyTo.message):i.message;yield this.sendTextMessageInternal(c,r,s);break}case"image":yield this.sendImageMessageInternal(i.image,r,s);break;case"file":yield this.sendFileMessageInternal(i.file,r,s);break;default:m.error("sendMessage::message_type_not_supported",{dyteChat:{messageType:i.type}});break}})}sendTextMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(t.length>this.maxTextLimit)throw new D("Max character limit breached","0503");if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.text))throw m.error("sendTextMessage::private_chat_permission_denied"),new D("Could not send message to private chat.","0501")}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.text))throw m.error("sendTextMessage::public_chat_permission_denied"),new D("Could not send message to public chat.","0501");if(!t)throw m.error("sendTextMessage::message_can_not_be_empty"),new D("Message can not be empty.","0502");if(n){o(this,pt).sendMessageToChannel(t,$t.TEXT,n);return}let h=[];e&&e.length>0&&(e.push(o(this,he).id),h=o(this,Os).joined.toArray().filter(u=>e.includes(u.id)).map(u=>u.userId),h.push(o(this,he).userId)),o(this,pt).sendMessage(t,$t.TEXT,e)})}sendImageMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.files)){m.error("sendImageMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){m.error("sendImageMessage::permission_denied");return}if(!t){m.error("sendImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(t.type)){m.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:t.type}});return}try{const h=Pt(),{getLocation:u,putLocation:g}=yield h.getPresignedUrls(t.name,o(this,he).config.viewType);if(yield h.uploadFile(t,g),n){o(this,pt).sendMessageToChannel(u,$t.IMAGE,n);return}let E=[];e&&e.length>0&&(e.push(o(this,he).id),E=o(this,Os).joined.toArray().filter(b=>e.includes(b.id)).map(b=>b.userId),E.push(o(this,he).userId)),o(this,pt).sendMessage(u,$t.IMAGE,e)}catch{throw new D("Error sending image message.","0500")}})}sendFileMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.files)){m.error("sendFileMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){m.error("sendFileMessage::permission_denied");return}if(!t){m.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const h=Pt(),{getLocation:u,putLocation:g}=yield h.getPresignedUrls(t.name,o(this,he).config.viewType);if(yield h.uploadFile(t,g),n){o(this,pt).sendMessageToChannel(JSON.stringify({link:u,name:t.name,size:"size"in t?t.size:0}),$t.FILE,n);return}let E=[];e&&e.length>0&&(e.push(o(this,he).id),E=o(this,Os).joined.toArray().filter(k=>e.includes(k.id)).map(k=>k.userId),E.push(o(this,he).userId));const b=JSON.stringify({link:u,name:t.name,size:"size"in t?t.size:0});o(this,pt).sendMessage(b,$t.FILE,e)}catch{throw new D("Error sending file message.","0500")}})}get rateLimits(){return yd}updateRateLimits(t,e){yd.maxInvocations=t,yd.period=e}sendTextMessage(t,e){return p(this,null,function*(){return this.sendTextMessageInternal(t,e)})}sendCustomMessage(t,e){return p(this,null,function*(){var n,i,r,s,a,c,d,h,u,g,E,b,k,A,M;if(e&&e.length>0){if(!((n=o(this,he).permissions)!=null&&n.chatPrivate.canSend)||!((i=o(this,he).permissions)!=null&&i.chatPrivate.files)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.text)){m.error("sendCustomMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)||!((u=(h=o(this,he).permissions)==null?void 0:h.chatPublic)!=null&&u.text)){m.error("sendCustomMessage::permission_denied");return}const B=X=>p(this,null,function*(){try{if(typeof X=="string")return{link:X};const O=Pt(),{getLocation:$,putLocation:me}=yield O.getPresignedUrls(X.name,o(this,he).config.viewType);return yield O.uploadFile(X,me),{link:$,type:X.type,name:X.name,size:X.size}}catch{throw new D("Error sending image message.","0500")}}),K=ee(H({},t),{files:yield Promise.all((E=(g=t.files)!=null?g:[])==null?void 0:E.map(X=>p(this,null,function*(){return B(X)}))),images:yield Promise.all((k=(b=t.images)!=null?b:[])==null?void 0:k.map(X=>p(this,null,function*(){return B(X)}))),videos:yield Promise.all((M=(A=t.videos)!=null?A:[])==null?void 0:M.map(X=>p(this,null,function*(){return B(X)})))});o(this,pt).sendMessage(JSON.stringify(K),$t.CUSTOM,e)})}sendImageMessage(t,e){return p(this,null,function*(){return this.sendImageMessageInternal(t,e)})}sendFileMessage(t,e){return p(this,null,function*(){return this.sendFileMessageInternal(t,e)})}sendMessage(t,e){return p(this,null,function*(){return this.sendMessageInternal(t,e)})}editTextMessage(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(((r=(i=o(this,he).permissions)==null?void 0:i.chatMessage)==null?void 0:r.canEdit)==="NONE")throw new D("Not permitted to edit messages","0501");if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.text)){m.error("editTextMessage::permission_denied");return}if(!e){m.error("editTextMessage::message_can_not_be_empty");return}o(this,pt).editMessage(t,e,$t.TEXT,n)})}editImageMessage(t,e,n){return p(this,null,function*(){var i,r,s,a;if(!((r=(i=o(this,he).permissions)==null?void 0:i.chatPublic)!=null&&r.canSend)||!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.files)){m.error("editImageMessage::permission_denied");return}if(!e){m.error("editImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(e.type)){m.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:e.type}});return}try{const c=Pt(),{getLocation:d,putLocation:h}=yield c.getPresignedUrls(e.name,o(this,he).config.viewType);yield c.uploadFile(e,h),o(this,pt).editMessage(t,d,$t.IMAGE,n)}catch{throw new D("Error editing image message.","0500")}})}editFileMessage(t,e,n){return p(this,null,function*(){var i,r,s,a;if(!((r=(i=o(this,he).permissions)==null?void 0:i.chatPublic)!=null&&r.canSend)||!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.files)){m.error("sendFileMessage::permission_denied");return}if(!e){m.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const c=Pt(),{getLocation:d,putLocation:h}=yield c.getPresignedUrls(e.name,o(this,he).config.viewType);yield c.uploadFile(e,h),o(this,pt).editMessage(t,JSON.stringify({link:d,name:e.name,size:"size"in e?e.size:0}),$t.FILE,n)}catch{throw new D("Error editing file message.","0500")}})}editMessage(t,e,n){return p(this,null,function*(){switch(e.type){case"text":{this.editTextMessage(t,e.message,n);break}case"image":{this.editImageMessage(t,e.image,n);break}case"file":{this.editFileMessage(t,e.file,n);break}default:{m.error("editMessage::message_type_not_supported",{dyteChat:{messageType:e.type}});break}}})}deleteMessage(t,e){return p(this,null,function*(){var n,i;if(((i=(n=o(this,he).permissions)==null?void 0:n.chatMessage)==null?void 0:i.canDelete)==="NONE")throw new D("Not permitted to delete messages","0501");o(this,pt).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 p(this,null,function*(){if(!o(this,Hc,Lu))throw new D("Can`t pin message without joining room","0505");if(!o(this,he).permissions.pinParticipant)throw new D("You do not have permission to pin messages.","0501");const e=this.messages.find(n=>n.id===t);if(e){o(this,pt).setPinState(e,!0);return}throw new D(`No message found with id: ${t}`,"0504")})}unpin(t){return p(this,null,function*(){if(!o(this,Hc,Lu))throw new D("Can`t unpin message without joining room","0505");if(!o(this,he).permissions.pinParticipant)throw new D("You do not have permission to unpin messages.","0501");const e=this.messages.find(n=>n.id===t);if(e){o(this,pt).setPinState(e,!1);return}throw new D(`No message found with id: ${t}`,"0504")})}getMessages(t,e,n,i=0,r=void 0){return p(this,null,function*(){const s=yield o(this,pt).getChatMessagesPaginated(t,e,n,i,r);return{messages:s.messages.map(a=>Ci.formatSocketServiceMessage(a)),next:s.next}})}createChannel(t,e){return p(this,arguments,function*(n,i,r={}){var s;const a=(s=o(this,he).permissions)==null?void 0:s.chatChannel;if(a){if(a.canCreate==="NONE")throw new D("Not permitted to create channels","0501");if(r.visibility==="public"&&!(a.canCreate==="PUBLIC"||a.canCreate==="ALL"))throw new D("Not permitted to create public channels","0501");if(r.visibility==="private"&&!(a.canCreate==="PRIVATE"||a.canCreate==="ALL"))throw new D("Not permitted to create private channels","0501")}if(!n||n.trim().length===0)throw new D("channel name cannot be empty.","0510");const c=[...new Set([...i,o(this,he).userId])];return yield o(this,Ds).createChannel(n.trim(),c,r.displayPictureUrl,r.visibility,r.isDirectMessage)})}updateChannel(t,e){var n,i,r,s,a;const c=this.channels.find(u=>u.id===t),d=(n=o(this,he).permissions)==null?void 0:n.chatChannel;if(d){if(d.canUpdate==="NONE")throw new D("Not permitted to update channels","0501");if(c.visibility==="public"&&!(d.canUpdate==="PUBLIC"||d.canUpdate==="ALL"))throw new D("Not permitted to update public channels","0501");if(c.visibility==="private"&&!(d.canUpdate==="PRIVATE"||d.canUpdate==="ALL"))throw new D("Not permitted to update private channels","0501")}const h={memberIds:(i=e.memberIds)!=null?i:c.memberIds,displayName:(r=e.displayName)!=null?r:c.displayName,displayPictureUrl:(s=e.displayPictureUrl)!=null?s:c.displayPictureUrl,visibility:(a=e.visibility)!=null?a:c.visibility};return o(this,Ds).updateChannel(t,h)}sendMessageToChannel(t,e){return p(this,arguments,function*(n,i,r={}){return this.sendMessageInternal(n,null,i,r)})}getChannelMembers(t){return p(this,null,function*(){return o(this,Ds).getChannelMembers(t)})}searchMessages(t){return p(this,arguments,function*(e,n={}){if(!se.hasFeature(ue.FEAT_CHAT_SDK_SEARCH))throw new D("searchMessages is temporarily disabled!","0506");return(yield o(this,pt).searchMessages(e,n)).map(Ci.formatSocketServiceMessage)})}markLastReadMessage(t,e){return p(this,null,function*(){yield o(this,pt).markLastReadMessage(t,e);const n=this.channels.find(i=>i.id===t);if(n){const i=ee(H({},n),{unreadCount:0});this.channels=this.channels.map(r=>r.id===t?i:r),this.emit("channelMessageUpdate",i)}})}get pinned(){return this.messages.filter(t=>t.pinned)}},he=new WeakMap,Os=new WeakMap,pt=new WeakMap,Ds=new WeakMap,Wc=new WeakMap,Nu=new WeakSet,Tg=function(){return o(this,Wc).getValue("connectionHandler")},Hc=new WeakSet,Lu=function(){return o(this,Nu,Tg).socketJoined===!0},bg);xt([w.trace("DyteChat.sendTextMessage"),on(yd)],kt.prototype,"sendTextMessage",1);xt([w.trace("DyteChat.sendImageMessage"),on({maxInvocations:20,period:60})],kt.prototype,"sendImageMessage",1);xt([w.trace("DyteChat.sendFileMessage"),on({maxInvocations:20,period:60})],kt.prototype,"sendFileMessage",1);xt([w.trace("DyteChat.sendMessage"),on({maxInvocations:180,period:60})],kt.prototype,"sendMessage",1);xt([w.trace("DyteChat.editTextMessage")],kt.prototype,"editTextMessage",1);xt([w.trace("DyteChat.editImageMessage")],kt.prototype,"editImageMessage",1);xt([w.trace("DyteChat.editFileMessage")],kt.prototype,"editFileMessage",1);xt([w.trace("DyteChat.editMessage")],kt.prototype,"editMessage",1);xt([w.trace("DyteChat.deleteMessage")],kt.prototype,"deleteMessage",1);xt([w.trace("DyteChat.createChannel")],kt.prototype,"createChannel",1);xt([w.trace("DyteChat.updateChannel")],kt.prototype,"updateChannel",1);xt([w.trace("DyteChat.sendMessageToChannel")],kt.prototype,"sendMessageToChannel",1);xt([w.trace("DyteChat.getChannelMembers")],kt.prototype,"getChannelMembers",1);xt([w.trace("DyteChat.searchMessages")],kt.prototype,"searchMessages",1);xt([w.trace("DyteChat.markLastReadMessage")],kt.prototype,"markLastReadMessage",1);kt=xt([Lt("0500")],kt);var qN=Object.defineProperty,GN=Object.getOwnPropertyDescriptor,$N=(t,e,n,i)=>{for(var r=i>1?void 0:i?GN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&qN(e,n,r),r},xu,kg;const Wr=(kg=class{constructor(t,e,n,i,r){y(this,"chat"),y(this,"chatSocketHandler"),y(this,"chatChannelSocketHandler"),y(this,"self"),S(this,xu,void 0),T(this,xu,t),this.chatSocketHandler=e,this.chatChannelSocketHandler=n,this.chat=new kt(t,e,n,i,r),this.self=i,this.setupEvents()}static init(t,e,n,i,r){return p(this,null,function*(){return new Wr(t,e,n,i,r)})}static formatMessage(t){return ee(H({},t),{time:new Date(t.time),type:HN[t.type]})}static formatSocketServiceMessage(t){const e=t.createdAt*1e3,n={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(n.type){case $t.TEXT:{n.message=t.payload;break}case $t.IMAGE:{n.link=t.payload;break}case $t.FILE:{const{link:i,name:r,size:s}=JSON.parse(t.payload);n.link=i,n.name=r,n.size=s;break}case $t.CUSTOM:{const{html:i,images:r,message:s,videos:a,files:c}=JSON.parse(t.payload);n.message=s,n.html=i,n.images=r,n.videos=a,n.files=c;break}}return Wr.formatMessage(n)}getChatMessages(){return p(this,null,function*(){if(this.self.config.viewType==="LIVESTREAM"||this.self.config.viewType==="CHAT"||se.hasFeature(ue.FEAT_PAGINATED_CHAT))return;const t=yield this.chatSocketHandler.getChatMessages();if(!(t!=null&&t.payload))return;const e=mE.fromBinary(t.payload).messages;this.chat.messages=e.map(n=>Wr.formatSocketServiceMessage(n))})}setupEvents(){L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){this.getChatMessages()})),this.chatSocketHandler.on(Ge.sendMessageToRoom,t=>{const e=Wr.formatSocketServiceMessage(t.message);if(!e.channelId)this.chat.messages=[...this.chat.messages,e];else{const n=this.chat.channels.find(i=>i.id===e.channelId);n&&(n.latestMessage=e,n.unreadCount+=1,this.chat.emit("channelMessageUpdate",n))}this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ge.sendMessageToPeers,t=>{const e=Wr.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(Ge.editMessage,t=>{const e=Wr.formatSocketServiceMessage(t.message);if(e.channelId){this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages});return}const n=this.chat.messages.findIndex(i=>i.id===e.id);n!==-1&&(this.chat.messages[n]=e,this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages}))}),this.chatSocketHandler.on(Ge.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[n]=this.chat.messages.splice(e,1);this.chat.emit("chatUpdate",{action:"delete",message:n,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ss.createChatChannel,t=>{const[e]=t.chatChannels,n=Es.formatChannel(e);this.chat.channels.push(n),this.chat.emit("channelCreate",n)}),this.chatSocketHandler.on(Ge.pinMessage,t=>{const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const n=this.chat.messages[e];n.pinned=t.pinned,this.chat.messages[e]=n,this.chat.emit("chatUpdate",{action:"edit",message:n,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ss.updateChatChannel,t=>{const[e]=t.chatChannels,n=Es.formatChannel(e);this.chat.channels=this.chat.channels.map(i=>i.id===n.id?n:i),this.chat.emit("channelUpdate",n)})}},xu=new WeakMap,kg);let Ci=Wr;$N([w.trace("ChatController.setupEvents")],Ci.prototype,"setupEvents",1);var JN=Object.defineProperty,KN=Object.getOwnPropertyDescriptor,zN=(t,e,n,i)=>{for(var r=i>1?void 0:i?KN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&JN(e,n,r),r},Vu,wg,Uu,_g,Ua,Ba,qc,Ig;let Lh=(Ig=class extends gn{constructor(t,e,n){super(),S(this,Vu),S(this,Uu),y(this,"items"),S(this,Ua,void 0),S(this,Ba,void 0),S(this,qc,void 0),T(this,qc,t),T(this,Ua,e),T(this,Ba,n),this.items=[]}create(t,e,n=!1,i=!1){return p(this,null,function*(){if(!o(this,Uu,_g))throw new D("Can't create polls without joining room","0705");if(!o(this,Ua).permissions.polls.canCreate){m.error("DytePolls::create::permission_denied");return}if(!t||!e){m.error("DytePolls::question_and_options_can_not_be_empty",{dytePolls:{hasQuestion:!!t,optionsLength:e==null?void 0:e.length}});return}if(e.length<2){m.error("DytePolls::there_must_be_at_least_two_options",{dytePolls:{hasQuestion:!!t,optionsLength:e.length}});return}yield o(this,Ba).createPoll(t,e,n,i)})}vote(t,e){return p(this,null,function*(){if(!o(this,Ua).permissions.polls.canVote){m.error("DytePolls::vote::permission_denied");return}yield o(this,Ba).votePoll(t,e)})}},Vu=new WeakSet,wg=function(){return o(this,qc).getValue("connectionHandler")},Uu=new WeakSet,_g=function(){var t;return((t=o(this,Vu,wg))==null?void 0:t.socketJoined)===!0},Ua=new WeakMap,Ba=new WeakMap,qc=new WeakMap,Ig);Lh=zN([Lt("0700")],Lh);var YN=Object.defineProperty,QN=Object.getOwnPropertyDescriptor,XN=(t,e,n,i)=>{for(var r=i>1?void 0:i?QN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&YN(e,n,r),r},Fa,Ns,Cg;const $s=(Cg=class{constructor(t,e,n){y(this,"polls"),S(this,Fa,void 0),S(this,Ns,void 0),this.polls=new Lh(t,e,n),T(this,Fa,e),T(this,Ns,n),this.setupEvents()}static init(t,e,n){return p(this,null,function*(){return new $s(t,e,n)})}canViewPolls(){return o(this,Fa).permissions.polls.canView}setupEvents(){const t={[Si.createPoll]:i=>{i.poll&&this.updatePoll($s.formatSocketServicePoll(i.poll))},[Si.updatePoll]:i=>{i.poll&&this.updatePoll($s.formatSocketServicePoll(i.poll))},[Si.votePoll]:i=>{i.poll&&this.updatePoll($s.formatSocketServicePoll(i.poll))}},e=()=>{L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{o(this,Ns).on(i,t[i])})},n=()=>{L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{o(this,Ns).removeListeners(i)})};o(this,Fa).permissions.on("permissionsUpdate",i=>p(this,null,function*(){var r;(r=i==null?void 0:i.polls)!=null&&r.canView?(yield this.getPolls(),e()):(this.polls.items=[],n())})),this.canViewPolls()&&e()}updatePoll(t){if(!this.canViewPolls())return;const e=this.polls.items.findIndex(n=>n.id===t.id);if(e>-1){const n=JSON.stringify(this.polls.items[e]);this.polls.items[e]=t,n!==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 p(this,null,function*(){const t=yield o(this,Ns).getPolls();if(!(t!=null&&t.payload))return;const{polls:e}=dN.fromBinary(t.payload);this.polls.items=e.map(n=>$s.formatSocketServicePoll(n))})}static formatSocketServicePoll(t){const e=t.options.map(n=>({count:n.count,text:n.text,votes:n.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}}},Fa=new WeakMap,Ns=new WeakMap,Cg);let EE=$s;XN([w.trace("PollController.setupEvents")],EE.prototype,"setupEvents",1);var ZN=Object.defineProperty,eL=Object.getOwnPropertyDescriptor,tL=(t,e,n,i)=>{for(var r=i>1?void 0:i?eL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ZN(e,n,r),r},SE=(t=>(t[t.User=0]="User",t[t.Meeting=1]="Meeting",t))(SE||{}),ja,Gc,Bu,Ls,$c,Rg;let xh=(Rg=class extends gn{constructor(t,e,n,i,r){super(),S(this,Gc),y(this,"selfActiveTab"),y(this,"broadcastTabChanges"),S(this,ja,void 0),S(this,Ls,void 0),S(this,$c,void 0),y(this,"viewType"),y(this,"meetingStartedTimestamp"),y(this,"meetingTitle"),y(this,"sessionId"),T(this,ja,t),T(this,Ls,e),this.viewType=n,T(this,$c,i),this.meetingTitle=r,this.broadcastTabChanges=e.permissions.canSpotlight}get socketState(){return o(this,Gc,Bu).socketState}get mediaState(){return o(this,Gc,Bu).mediaState}get meetingId(){return o(this,ja).getValue("meetingId")}setBroadcastTabChanges(t){if(!o(this,Ls).permissions.canSpotlight)throw m.error("DyteSpotlight::setSpotlighted::permission_denied"),new D("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 n;m.info("DyteSpotlight::setActiveTab",{spotlight:{currentTab:{id:t.id,type:t.type}}}),this.selfActiveTab=t,e===0&&this.emit("selfTabUpdate",t),(n=o(this,Ls).permissions)!=null&&n.canSpotlight&&this.broadcastTabChanges&&e===0&&this.assertActiveTabToRoom()}assertActiveTabToRoom(){o(this,$c).broadcastMessage("spotlight",{userId:o(this,Ls).userId,currentTab:this.selfActiveTab})}},ja=new WeakMap,Gc=new WeakSet,Bu=function(){return o(this,ja).getValue("connectionHandler")},Ls=new WeakMap,$c=new WeakMap,Rg);xh=tL([Lt("0800")],xh);function nL(t){let e="",n=[""];const i=[n];let r=0,s=0,a=!0,c;for(c of t)c==='"'?(a&&c===e&&(n[r]+=c),a=!a):c===","&&a?c=n[++r]="":c===`
23
- `&&a?(e==="\r"&&(n[r]=n[r].slice(0,-1)),n=i[++s]=[c=""],r=0):n[r]+=c,e=c;return i}var iL=Object.defineProperty,rL=Object.getOwnPropertyDescriptor,TE=(t,e,n,i)=>{for(var r=i>1?void 0:i?rL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&iL(e,n,r),r};let Tr=class extends gn{constructor(){super(),y(this,"transcripts"),this.transcripts=[]}static init(t){return p(this,null,function*(){const e=new Tr;try{t&&e.getActiveTranscript()}catch(n){m.error("Error fetching active transcriptions ",n)}return e})}static parseTranscript(t,e=!1){try{if(!t)return;const[[n,i,r,s,a,c]]=nL(t);return{id:Ca(),name:a,peerId:i,userId:r,customParticipantId:s,transcript:c,isPartialTranscript:e,date:new Date(parseInt(n,10)*1e3)}}catch(n){m.error(`Failed to parse transcript: ${t}`,n);return}}static parseTranscripts(t){return t?t.split(`
24
- `).map(e=>Tr.parseTranscript(e,!1)).filter(Boolean):[]}getActiveTranscript(){return p(this,null,function*(){try{const t=Pt(),{transcript:e}=yield t.getActiveTranscript();this.transcripts=Tr.parseTranscripts(e)}catch{}})}onTranscript(t){return p(this,null,function*(){var e;const n=this.transcripts.filter(({peerId:i})=>i===t.peerId);if((e=n==null?void 0:n.at(-1))!=null&&e.isPartialTranscript){const i=n.at(-1);i.transcript=t.transcript,i.isPartialTranscript=t.isPartialTranscript,this.emit("transcript",i);return}this.transcripts=[...this.transcripts,t],this.emit("transcript",t)})}};TE([w.trace("DyteAi.getActiveTranscript")],Tr.prototype,"getActiveTranscript",1);Tr=TE([Lt("0000")],Tr);var sL=Object.defineProperty,aL=Object.getOwnPropertyDescriptor,oL=(t,e,n,i)=>{for(var r=i>1?void 0:i?aL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&sL(e,n,r),r},Lr,Wa,Fu,Pg;const bE=(Pg=class{constructor(t,e,n,i,r,s){y(this,"meta"),y(this,"ai"),S(this,Lr,void 0),S(this,Wa,void 0),y(this,"aiSocketHandler"),S(this,Fu,void 0),T(this,Fu,t),this.meta=new xh(t,e,e.config.viewType,n,s),this.ai=i,T(this,Lr,e),T(this,Wa,n),this.aiSocketHandler=r,e.config.viewType!==Yt.Chat&&this.setupEvents()}static init(t,e,n,i,r){return p(this,null,function*(){const s=yield Tr.init(e.permissions.transcriptionEnabled);return new bE(t,e,n,s,i,r)})}conditionallySetActiveTab(t){var e;t!=null&&t.currentTab&&((e=this.meta.selfActiveTab)==null?void 0:e.id)!==t.currentTab.id&&(this.meta.setSelfActiveTab(t.currentTab,SE.Meeting),this.meta.emit("activeTabUpdate",t.currentTab))}setupEvents(){L.on(x.TRANSPORT_STATE_UPDATE,t=>{this.meta.emit("mediaConnectionUpdate",t)}),L.on(x.SOCKET_STATE_UPDATE,t=>{this.meta.emit("socketConnectionUpdate",t)}),L.on(x.ROOM_STATE,({createdAt:t,roomUuid:e})=>{const n=this.meta.meetingStartedTimestamp;if(e&&(this.meta.sessionId=e),t&&!n){const i=new Date(t*1e3);this.meta.meetingStartedTimestamp=i,this.meta.emit("meetingStartTimeUpdate",{meetingStartedTimestamp:this.meta.meetingStartedTimestamp})}}),L.on(x.PRODUCER_SCORE_UPDATE,({score:t})=>{t<5&&this.meta.emit("poorConnection",{score:t})}),o(this,Lr).permissions.canSpotlight&&(m.info("DyteMetaController::Asserting Spotlight"),this.meta.selfActiveTab&&o(this,Wa).broadcastMessage("spotlight",{userId:o(this,Lr).userId,currentTab:this.meta.selfActiveTab})),L.on(x.PEER_JOINED_INTERNAL,t=>p(this,null,function*(){o(this,Lr).permissions.canSpotlight&&this.meta.selfActiveTab&&o(this,Wa).broadcastToPeers("spotlight",[t.id],{userId:o(this,Lr).userId,currentTab:this.meta.selfActiveTab})})),L.on(x.ROOM_MESSAGE,t=>{var e,n;let i;if("type"in t){if(t.type!=="spotlight")return;i=H(H({},t),t.payload)}else if("roomMessageType"in t){if(t.roomMessageType!=="spotlight")return;i=t}else return;m.info("Spotlight Assertion Received",{spotlight:{spotlighter:{id:i.userId},currentTab:{id:(e=i.currentTab)==null?void 0:e.id,type:(n=i.currentTab)==null?void 0:n.type}}}),this.conditionallySetActiveTab(i)}),L.on(x.MESSAGE,t=>{var e,n;let i;if("type"in t){if(t.type!=="spotlight")return;i=H(H({},t),t.payload)}else if("roomMessageType"in t){if(t.roomMessageType!=="spotlight")return;i=t}else return;m.info("Spotlight Assertion Received",{spotlight:{spotlighter:{id:i.userId},currentTab:{id:(e=i.currentTab)==null?void 0:e.id,type:(n=i.currentTab)==null?void 0:n.type}}}),this.conditionallySetActiveTab(i)}),this.aiSocketHandler.on(Y.transcript,t=>{const{meetingId:e,transcript:n,isPartial:i}=t,r=Tr.parseTranscript(n,i);if(!r){m.warn("Received empty transcript data");return}this.ai.onTranscript(r),this.meta.emit("transcript",r);const{peerId:s,name:a,transcript:c}=r;m.debug(`${e} Received transcript for peer ${s} - ${a}: ${c}`)})}},Lr=new WeakMap,Wa=new WeakMap,Fu=new WeakMap,Pg);let kE=bE;oL([w.trace("MetaController.setupEvents")],kE.prototype,"setupEvents",1);var cL=Object.defineProperty,dL=Object.getOwnPropertyDescriptor,Rs=(t,e,n,i)=>{for(var r=i>1?void 0:i?dL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&cL(e,n,r),r},Un,vo,be,Ed,gi,si,Sd,Vh,yo,Td;class Cr extends gn{constructor(e,n,i,r,s){super(),S(this,Sd),S(this,yo),S(this,Un,void 0),S(this,vo,void 0),S(this,be,void 0),S(this,Ed,void 0),S(this,gi,void 0),S(this,si,void 0),T(this,si,e),T(this,Un,r),T(this,vo,s),T(this,be,n),T(this,Ed,i),T(this,gi,[]),this.setupEvents()}get status(){return o(this,si).getValue("stageStatus")}setupEvents(){const e={[x.GET_STAGE_REQUESTS]:r=>p(this,null,function*(){T(this,gi,r)}),[x.UPDATE_STAGE_REQUESTS]:r=>p(this,[r],function*({add:s}){const a=o(this,gi).length,{stageRequests:c}=this.getAccessRequests();(s||c.length>a)&&this.emit("newStageRequest",{count:c.length}),this.emit("stageAccessRequestUpdate",c)})},n=()=>{Object.entries(e).forEach(([r,s])=>{L.onAsync(r,s)})},i=()=>{Object.entries(e).forEach(([r,s])=>{L.removeListener(r,s)})};o(this,be).permissions.on("permissionsUpdate",r=>{const{canAcceptProductionRequests:s}=r;s!==void 0&&(o(this,be).permissions.acceptStageRequests?(n(),o(this,Un).getStageRequests()):(i(),T(this,gi,[]),this.emit("stageAccessRequestUpdate",o(this,gi))))}),o(this,be).permissions.acceptStageRequests&&n()}getAccessRequests(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::get_access_request::permission_denied"),new D("You do not have permission to perform this action","2001");const e=o(this,Ed).joined.toArray().filter(n=>n.stageStatus==="REQUESTED_TO_JOIN_STAGE").map(n=>({displayName:n.name,userId:n.userId,peerId:n.id}));return T(this,gi,e),{stageRequests:o(this,gi)}}requestAccess(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(this.status!=="OFF_STAGE")throw new D(`Unable to request access you are currently ${this.status}`,"2006");if(o(this,be).permissions.stageAccess===re.Allowed){Q(this,yo,Td).call(this,"ACCEPTED_TO_JOIN_STAGE");return}o(this,Un).requestAccess(),Q(this,yo,Td).call(this,"REQUESTED_TO_JOIN_STAGE")})}cancelRequestAccess(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");o(this,Un).cancelRequestAccess(),Q(this,yo,Td).call(this,"OFF_STAGE")})}grantAccess(e){if(!o(this,be).roomJoined)throw new D("Can`t grant for participant without joining room");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::grant_access::permission_denied"),new D("You do not have permission to perform this action","2001");return o(this,Un).grantAccess(e)}denyAccess(e){if(!o(this,be).roomJoined)throw new D("Can`t rejectRequestToJoinStage for participant without joining room","2005");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::deny_access::permission_denied"),new D("You do not have permission to perform this action","2001");return o(this,Un).denyAccess(e)}join(){return p(this,null,function*(){const e=o(this,si).getValue("viewType");if(this.status==="ON_STAGE")throw new D("You are already on stage.","2006");if(this.status!=="ACCEPTED_TO_JOIN_STAGE"||o(this,be).permissions.stageAccess===re.NotAllowed)throw new D(`Unable to join stage you are currently ${this.status}`,"2006");if(yield o(this,Un).joinStage(),e===Yt.Livestream){yield o(this,vo).joinRoom(o(this,be));const{peers:n}=yield o(this,vo).getStagePeers();L.emit(x.SOCKET_PEERS,n)}o(this,si).setValue("stageStatus","ON_STAGE"),o(this,be).audioEnabled&&o(this,Sd,Vh).shareMic(o(this,be).audioTrack),o(this,be).videoEnabled&&o(this,Sd,Vh).shareWebcam(o(this,be).videoTrack)})}leave(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!(this.status==="ON_STAGE"||this.status==="ACCEPTED_TO_JOIN_STAGE"))throw new D(`Unable to leave stage you are currently ${this.status}`,"2006");o(this,be).setIsPinned(!1),yield o(this,Un).leaveStage(o(this,be).userId),o(this,si).setValue("stageStatus","OFF_STAGE",!1),yield L.emitAsync(x.LEAVE_MEDIA_ROOM,"stageLeft"),o(this,si).notify("stageStatus")})}kick(e){return p(this,null,function*(){if(!o(this,be).roomJoined)throw new D("Can`t kick participant without joining room","2005");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::kick::permission_denied"),new D("You do not have permissions for kick","2001");return o(this,Un).kick(e)})}}Un=new WeakMap,vo=new WeakMap,be=new WeakMap,Ed=new WeakMap,gi=new WeakMap,si=new WeakMap,Sd=new WeakSet,Vh=function(){return o(this,si).getValue("roomNodeClient")},yo=new WeakSet,Td=function(t){return p(this,null,function*(){this.status!==t&&o(this,si).setValue("stageStatus",t)})};Rs([w.trace("DyteStage.getStageRequests")],Cr.prototype,"getAccessRequests",1);Rs([w.trace("DyteStage.requestAccess")],Cr.prototype,"requestAccess",1);Rs([w.trace("DyteStage.cancelRequestAccess")],Cr.prototype,"cancelRequestAccess",1);Rs([w.trace("DyteStage.grantAccess")],Cr.prototype,"grantAccess",1);Rs([w.trace("DyteStage.denyAccess")],Cr.prototype,"denyAccess",1);Rs([w.trace("DyteStage.joinStage")],Cr.prototype,"join",1);Rs([w.trace("DyteStage.leaveStage")],Cr.prototype,"leave",1);function lL(t){return!(t.viewType==="LIVESTREAM"||t.viewType==="CHAT")}function om(t){switch(t){case wi.UNSPECIFIED:return"OFF_STAGE";case wi.REQUESTED_STAGE:return"REQUESTED_TO_JOIN_STAGE";case wi.APPROVED_STAGE:return"ACCEPTED_TO_JOIN_STAGE";case wi.OFF_STAGE:return"OFF_STAGE";case wi.ON_STAGE:return"ON_STAGE";default:return"OFF_STAGE"}}var uL=Object.defineProperty,hL=Object.getOwnPropertyDescriptor,pL=(t,e,n,i)=>{for(var r=i>1?void 0:i?hL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&uL(e,n,r),r},Hr,Js,qr,bd,ir;class wE{constructor(e,n,i,r,s){y(this,"stage"),S(this,Hr,void 0),S(this,Js,void 0),S(this,qr,void 0),S(this,bd,0),S(this,ir,void 0),T(this,ir,e),this.stage=new Cr(e,r,s,n,i),T(this,qr,n),T(this,Hr,r),T(this,Js,s),this.setupEvents()}setupEvents(){o(this,ir).subscribe("stageStatus",e=>{this.stage.emit("stageStatusUpdate",e)}),o(this,qr).on(Y.grantStageAccess,()=>{o(this,Hr).permissions.stageAccess!==re.Allowed&&(this.stage.emit("stageRequestApproved"),this.setStageStatus("ACCEPTED_TO_JOIN_STAGE"))}),o(this,qr).on(Y.peerStageStatusUpdate,e=>{e!==void 0&&(e.peerId===o(this,Hr).id?this.selfStageStatusHandler(e):this.peerStageStatusHandler(e))}),o(this,qr).on(Y.denyStageAccess,()=>{o(this,Hr).permissions.stageAccess!==re.Allowed&&(this.stage.emit("stageRequestRejected"),this.setStageStatus("OFF_STAGE"))}),o(this,qr).on(Y.getStageRequests,e=>p(this,null,function*(){var n;if(o(this,Hr).permissions.stageAccess!==re.Allowed)return;const i=(n=e==null?void 0:e.stageRequests)!=null?n:[];yield L.emitAsync(x.GET_STAGE_REQUESTS,i),o(this,bd)<i.length&&i.length>0&&this.stage.emit("newStageRequest",{count:i.length}),T(this,bd,i.length),this.stage.emit("stageAccessRequestUpdate",i)}))}getCurrentStageRequests(){return o(this,Js).joined.toArray().filter(e=>e.stageStatus==="REQUESTED_TO_JOIN_STAGE").map(e=>({displayName:e.name,userId:e.userId,peerId:e.id}))}setStageStatus(e){return p(this,null,function*(){this.stage.status!==e&&o(this,ir).setValue("stageStatus",e)})}selfStageStatusHandler(e){const n=om(e.stageType),i=o(this,ir).getValue("stageStatus");if(i!==n)switch(e.stageType){case 1:o(this,ir).setValue("stageStatus","ACCEPTED_TO_JOIN_STAGE",!1),this.stage.join();break;case 2:case 3:this.setStageStatus(i);break;case 0:case 4:default:o(this,ir).setValue("stageStatus","ACCEPTED_TO_JOIN_STAGE",!1),this.stage.leave();break}}peerStageStatusHandler(e){return p(this,null,function*(){const n=o(this,Js).joined.get(e.peerId),i=o(this,Js).viewMode==="ACTIVE_GRID";if(!n){m.warn("err::peerStageStatusUpdate: participant not found");return}switch(e.stageType){case 1:n.setStageStatus("ON_STAGE"),i&&L.emit(x.UPDATE_ACTIVE);break;case 2:n.setStageStatus("ACCEPTED_TO_JOIN_STAGE");break;case 3:n.setStageStatus("REQUESTED_TO_JOIN_STAGE");break;case 0:case 4:default:n.setStageStatus("OFF_STAGE"),i&&L.emit(x.UPDATE_ACTIVE);break}L.emit(x.UPDATE_PEER_STAGE_STATUS,{id:n.id,status:n.stageStatus})})}}Hr=new WeakMap,Js=new WeakMap,qr=new WeakMap,bd=new WeakMap,ir=new WeakMap;pL([w.trace("DyteStage.setupEvents")],wE.prototype,"setupEvents",1);var mL=Object.defineProperty,fL=Object.getOwnPropertyDescriptor,Jl=(t,e,n,i)=>{for(var r=i>1?void 0:i?fL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&mL(e,n,r),r};const Ye={getPeer:14,getPeers:15,chatMessage:16,getRoomName:17,getDisplayTitle:18,getPluginInitiator:19,customPluginEventToParent:20,peerJoined:22,peerLeft:23,sendData:24,stageStatusUpdate:25,peerStageStatusUpdate:26};var Ut,Tn,Ha,qa,qi,Ga,xs,$a,Ag;let Ia=(Ag=class extends Ra{constructor(t,{baseURL:e,createdAt:n,description:i,id:r,name:s,organizationId:a,picture:c,private:d,published:h,staggered:u,tags:g,type:E,updatedAt:b},k,A,M,B,K){super(),S(this,Ut,void 0),y(this,"baseURL"),y(this,"createdAt"),y(this,"description"),y(this,"id"),y(this,"name"),S(this,Tn,void 0),S(this,Ha,void 0),S(this,qa,void 0),y(this,"organizationId"),y(this,"picture"),y(this,"private"),y(this,"published"),y(this,"staggered"),y(this,"tags"),y(this,"type"),y(this,"updatedAt"),S(this,qi,void 0),y(this,"config"),S(this,Ga,void 0),y(this,"active"),y(this,"iframes"),y(this,"enabledBy"),S(this,xs,void 0),S(this,$a,void 0),T(this,xs,t),this.baseURL=e,this.createdAt=new Date(n),this.description=i,this.id=r,this.name=s,T(this,Tn,A),this.organizationId=a,this.picture=c,this.private=d,this.published=h,this.staggered=u,this.tags=g,this.type=E,this.updatedAt=new Date(b),this.active=!1,this.iframes=new Map,T(this,Ut,k),T(this,Ha,M),T(this,qa,B),this.enabledBy="",T(this,$a,K)}sendIframeEvent(t){this.iframes.size&&this.iframes.forEach(e=>{const{iframe:n}=e;n&&(navigator.isReactNative?n.postMessage(JSON.stringify(t)):n.contentWindow.postMessage(t,"*"))})}handleIframeMessage(t){return p(this,null,function*(){var e;if(!this.active)return;const n=t,{payload:i,uuid:r,type:s}=n;switch(s){case ie.customPluginEventToRoom:{o(this,Ut).customPluginEventToRoom(this.id,i,r);break}case ie.customPluginEventToPeers:{o(this,Ut).customPluginEventToPeers(this.id,i.peerIds,i,r);break}case ie.enablePluginForRoom:{o(this,Ut).enablePluginForRoom(this.id,r);break}case ie.enablePluginForPeers:{o(this,Ut).enablePluginForPeers(this.id,i.peerIds,r);break}case ie.disablePluginForRoom:{o(this,Ut).disablePluginForRoom(this.id,r);break}case ie.disablePluginForPeers:{o(this,Ut).disablePluginForPeers(this.id,i.peerIds,r);break}case ie.storeInsertKeys:{o(this,Ut).storeInsertKeys(this.id,i.store,i.insertKeys,r);break}case ie.storeGetKeys:{o(this,Ut).storeGetKeys(this.id,i.store,i.getKeys,r);break}case ie.storeDeleteKeys:{o(this,Ut).storeDeleteKeys(this.id,i.store,i.deleteKeys,r);break}case ie.storeDelete:{o(this,Ut).storeDelete(this.id,i.store,r);break}case Ye.chatMessage:{const{messagePayload:a,peerIds:c}=i;if(!o(this,qa)){this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{error:"Chat is disabled for this room."}});return}try{yield o(this,qa).sendMessage(a,c),this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{success:!0}})}catch(d){this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{error:d}})}break}case Ye.getPeer:{let a;const{peerId:c}=i,d=ee(H({},o(this,Tn)),{id:o(this,Tn).id,isRecorder:(e=o(this,Tn).permissions)==null?void 0:e.isRecorder,isHidden:o(this,Tn).permissions.hiddenParticipant,stageStatus:o(this,Tn).stageStatus});c?(a=o(this,Ha).joined.get(i.peerId),o(this,Tn).id===c&&(a=d)):a=d,this.sendIframeEvent({type:Ye.getPeer,payload:{peer:a&&hl(a)},uuid:n.uuid});break}case Ye.getPeers:{const a=o(this,Ha).joined.toArray().map(c=>hl(c));this.sendIframeEvent({type:Ye.getPeers,payload:{peers:a},uuid:n.uuid});break}case Ye.getPluginInitiator:{this.sendIframeEvent({type:Ye.getPluginInitiator,payload:{enabledBy:this.enabledBy},uuid:n.uuid});break}case Ye.getDisplayTitle:{this.sendIframeEvent({type:Ye.getDisplayTitle,payload:{displayTitle:o(this,$a)},uuid:n.uuid});break}case Ye.getRoomName:{this.sendIframeEvent({type:Ye.getRoomName,payload:{roomName:o(this,xs).getValue("meetingId")},uuid:n.uuid});break}case Ye.customPluginEventToParent:{this.emit(n.payload.eventName,n.payload.data);break}}})}sendData(t){this.active&&(m.info("DytePlugin::SendData",{plugin:{id:this.id,name:this.name,data:{eventName:t.eventName}}}),this.sendIframeEvent({type:Ye.sendData,uuid:"",payload:t}))}removePluginView(t="default"){var e;const{iframe:n,listener:i}=(e=this.iframes.get(t))!=null?e:{};(n||i)&&(navigator.isReactNative?n.props.onMessage=void 0:window.removeEventListener("message",i),this.iframes.delete(t))}addPluginView(t,e="default"){var n;if(!o(this,Ga))throw m.error("DytePlugin::addPluginView::no_auth_token_set_for_plugin"),new D("No auth token set for plugin.","0602");if(!t)throw m.error("DytePlugin::addPluginView::iframe_was_not_provided"),new D("Iframe was not provided.","0603");this.removePluginView(e);const i=t,r=new URL(this.baseURL),s={auth:o(this,Ga),parent:navigator.isReactNative?this.baseURL:window.location.origin,backend:o(this,xs).getValue("apiBase"),pluginId:this.id,roomName:(n=o(this,xs).getValue("meetingId"))!=null?n:"",displayTitle:o(this,$a)};if(Object.keys(s).forEach(a=>{r.searchParams.set(a,s[a])}),i.src=r.href,i.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",i.title=e,navigator.isReactNative)i.props.onMessage=a=>{this.handleIframeMessage(JSON.parse(a.nativeEvent.data))},this.iframes.set(e,{iframe:i});else{const a=c=>p(this,null,function*(){c.source===t.contentWindow&&(yield this.handleIframeMessage(c.data))});window.addEventListener("message",a),this.iframes.set(e,{iframe:i,listener:a})}}setActive(t){var e,n;if(this.active=t,t){this.emit("stateUpdate",{active:this.active,pluginId:this.id,bind:this.addPluginView.bind(this),views:(e=this.config)==null?void 0:e.views});return}this.active=!1,this.emit("stateUpdate",{active:this.active,pluginId:this.id,views:(n=this.config)==null?void 0:n.views})}activateForSelf(){return p(this,null,function*(){const t=Pt(),e=yield t.authorizePlugin(this.id);T(this,Ga,e),T(this,qi,new Date);try{const n=yield t.getPluginConfig(this.baseURL);this.config=n}catch(n){m.error("DytePlugin::activateForSelf",{error:n})}this.setActive(!0),this.emit("enabled")})}deactivateForSelf(){Array.from(this.iframes.keys()).forEach(t=>{this.removePluginView(t)}),T(this,qi,void 0),this.iframes.clear(),this.setActive(!1),this.emit("closed")}enable(){return p(this,null,function*(){return this.activateForSelf()})}disable(){return this.deactivateForSelf()}activate(){return p(this,null,function*(){var t,e;this.active||(e=(t=o(this,Tn).permissions)==null?void 0:t.plugins)!=null&&e.canStart&&(o(this,Ut).addPlugin(this.id,this.staggered),T(this,qi,new Date),m.info("plugin::activated",{plugin:{id:this.id,enabledBy:this.enabledBy,name:this.name}}))})}deactivate(){return p(this,null,function*(){var t,e;this.active&&(!((e=(t=o(this,Tn).permissions)==null?void 0:t.plugins)!=null&&e.canClose)&&this.enabledBy!==o(this,Tn).id||(o(this,Ut).removePlugin(this.id),m.info("plugin::deactivated",{plugin:{id:this.id,name:this.name,duration:o(this,qi)?new Date().getTime()-o(this,qi).getTime():0}}),T(this,qi,void 0)))})}},Ut=new WeakMap,Tn=new WeakMap,Ha=new WeakMap,qa=new WeakMap,qi=new WeakMap,Ga=new WeakMap,xs=new WeakMap,$a=new WeakMap,Ag);Jl([on({maxInvocations:5,period:1})],Ia.prototype,"sendData",1);Jl([w.trace("DytePlugin.activatePlugin")],Ia.prototype,"activate",1);Jl([w.trace("DytePlugin.deactivatePlugin")],Ia.prototype,"deactivate",1);Ia=Jl([Lt("0600")],Ia);var lt,Ks;class _E extends Map{constructor(e){const{onAddEvent:n,onDeleteEvent:i,onClearEvent:r}=e;super(),S(this,lt,void 0),S(this,Ks,void 0),y(this,"onAddEvent"),y(this,"onDeleteEvent"),y(this,"onClearEvent"),T(this,lt,new Ra),this.onAddEvent=n,this.onDeleteEvent=i,this.onClearEvent=r,T(this,Ks,new Map)}emit(e,...n){return o(this,lt).emit(e,...n)}on(e,n){return o(this,lt).on(e,n)}addListener(e,n){return o(this,lt).addListener(e,n)}off(e,n){return o(this,lt).off(e,n)}once(e,n){return o(this,lt).once(e,n)}prependListener(e,n){return o(this,lt).prependListener(e,n)}prependOnceListener(e,n){return o(this,lt).prependOnceListener(e,n)}removeListener(e,n){return o(this,lt).removeListener(e,n)}removeAllListeners(e){return o(this,lt).removeAllListeners(e)}listeners(e){return o(this,lt).listeners(e)}listenerCount(e){return o(this,lt).listenerCount(e)}getMaxListeners(){return o(this,lt).getMaxListeners()}setMaxListeners(e){return o(this,lt).setMaxListeners(e)}eventNames(){return o(this,lt).eventNames()}add(e,n=!0){return this.set(e.id,e,n)}set(e,n,i=!0){const r=super.set(e,n),s=(a,...c)=>{this.emit(a,n,...c)};return o(this,Ks).set(e,s),n.on("*",s),i&&o(this,lt).emit(this.onAddEvent,n),r}delete(e,n=!0,i=!1){const r=this.get(e);if(!r)return!1;r.removeListener("*",o(this,Ks).get(e));const s=super.delete(e);return i&&r.removeAllListeners(),n&&o(this,lt).emit(this.onDeleteEvent,r),s}clear(e=!0,n=!1){this.forEach(r=>{r.removeListener("*",o(this,Ks).get(r.id)),n&&r.removeAllListeners()});const i=super.clear();return e&&o(this,lt).emit(this.onClearEvent),i}toArray(){return Array.from(this.values())}}lt=new WeakMap,Ks=new WeakMap;class Mg extends _E{constructor(){super({onAddEvent:"pluginAdded",onDeleteEvent:"pluginDeleted"})}add(e,n=!0){return super.add(e,n)}delete(e,n=!0,i=!1){return super.delete(e,n,i)}}var gL=Object.defineProperty,vL=Object.getOwnPropertyDescriptor,yL=(t,e,n,i)=>{for(var r=i>1?void 0:i?vL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&gL(e,n,r),r};let Uh=class{constructor(){y(this,"all"),y(this,"active"),this.all=new Mg,this.active=new Mg}};Uh=yL([Lt("0600")],Uh);var EL=Object.defineProperty,SL=Object.getOwnPropertyDescriptor,Kl=(t,e,n,i)=>{for(var r=i>1?void 0:i?SL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&EL(e,n,r),r},An,Ja,Jc,Og;const IE=(Og=class{constructor(t,e,n,i){y(this,"plugins"),S(this,An,void 0),S(this,Ja,void 0),S(this,Jc,void 0),T(this,An,e),T(this,Ja,n),T(this,Jc,t),this.plugins=i,this.setupEvents()}static init(t,e,n,i,r,s,a,c){return p(this,null,function*(){const d=new Uh;return e.forEach(h=>{const u=new Ia(t,h,n,s,a,r,c);d.all.add(u)}),new IE(t,n,i,d)})}getRoomPlugins(){return p(this,null,function*(){var t;const{plugins:e}=yield o(this,An).getActivePlugins();(t=this.plugins.active)==null||t.toArray().forEach(n=>{this.disablePlugin({id:n.id})}),yield Promise.all(e.map(n=>this.enablePlugin({id:n.pluginId,enabledBy:n.enabledBy})))})}enablePlugin(t){return p(this,arguments,function*({id:e,enabledBy:n}){const i=this.plugins.all.get(e);i&&(yield i.activateForSelf(),i.enabledBy=n)})}disablePlugin(t){return p(this,arguments,function*({id:e}){const n=this.plugins.all.get(e);n&&n.deactivateForSelf()})}sendIframeEvent(t,e,n,i){const r=this.plugins.all.get(e);r&&r.sendIframeEvent({type:t,uuid:n,payload:i})}broadcastIframeEvent(t,e){this.plugins.active.forEach(n=>{this.sendIframeEvent(t,n.id,"",e)})}setupEvents(){this.plugins.all.on("stateUpdate",({active:t,id:e})=>{if(t){this.plugins.active.add(this.plugins.all.get(e));return}this.plugins.active.delete(e)}),L.onAsync(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){yield this.getRoomPlugins(),m.debug("[SOCKET_SERVICE_ROOM_JOINED] resolved request to fetch plugins.")})),o(this,An).on(ie.addPlugin,t=>p(this,null,function*(){var e;const n=t.pluginId;(e=this.plugins.all.get(n))!=null&&e.active||(yield this.enablePlugin({id:n,enabledBy:t.enabledBy}))})),o(this,An).on(ie.removePlugin,t=>p(this,null,function*(){var e;const n=t.pluginId;(e=this.plugins.all.get(n))!=null&&e.active&&(yield this.disablePlugin({id:n}))})),[ie.enablePluginForPeers,ie.enablePluginForRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{enabledBy:e.enabledBy})}))}),[ie.disablePluginForPeers,ie.disablePluginForRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{disabledBy:e.disabledBy})}))}),[ie.customPluginEventToPeers,ie.customPluginEventToRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{data:JSON.parse(new TextDecoder().decode(e.pluginData))})}))}),[ie.storeInsertKeys,ie.storeGetKeys,ie.storeDeleteKeys].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){var i;const r=(i=e.storeItems)==null?void 0:i.map(s=>{var a;return{timestamp:s.timestamp,peerId:s.peerId,payload:JSON.parse((a=s.payload)!=null&&a.length?new TextDecoder().decode(s.payload):"{}"),key:s.storeKey}});this.sendIframeEvent(t,e.pluginId,n,{storeName:e.storeName,storeItems:r})}))}),o(this,An).on(ie.storeDelete,(t,e)=>p(this,null,function*(){this.sendIframeEvent(ie.storeDelete,t.pluginId,e,{storeName:t.storeName})})),o(this,Ja).on(Ge.sendMessageToPeers,t=>{const e=Ci==null?void 0:Ci.formatSocketServiceMessage(t.message);this.broadcastIframeEvent(Ye.chatMessage,{message:e})}),o(this,Ja).on(Ge.sendMessageToRoom,t=>{const e=Ci==null?void 0:Ci.formatSocketServiceMessage(t.message);this.broadcastIframeEvent(Ye.chatMessage,{message:e})}),L.on(x.PEER_JOINED_INTERNAL,t=>{const e=hl(t);this.broadcastIframeEvent(Ye.peerJoined,e)}),L.on(x.PEER_CLOSED,t=>{this.broadcastIframeEvent(Ye.peerLeft,t)}),L.on(x.UPDATE_PEER_STAGE_STATUS,t=>{this.broadcastIframeEvent(Ye.peerStageStatusUpdate,t)}),o(this,Jc).subscribe("stageStatus",t=>{this.broadcastIframeEvent(Ye.stageStatusUpdate,t)})}},An=new WeakMap,Ja=new WeakMap,Jc=new WeakMap,Og);let bc=IE;Kl([w.trace("PluginController.getRoomPlugins")],bc.prototype,"getRoomPlugins",1);Kl([w.trace("PluginController.enableForSelf")],bc.prototype,"enablePlugin",1);Kl([w.trace("PluginController.disableForSelf")],bc.prototype,"disablePlugin",1);Kl([w.trace("PluginController.setupEvents")],bc.prototype,"setupEvents",1);class TL{constructor(){y(this,"mediaJoined"),y(this,"socketJoined"),y(this,"socketJoinAttempted"),y(this,"mediaJoinAttempted"),y(this,"socketState"),y(this,"mediaState"),this.mediaJoined=!1,this.socketJoined=!1,this.socketJoinAttempted=!1,this.mediaJoinAttempted=!1,this.socketState={state:void 0,reconnected:!1,reconnectionAttempt:void 0},this.mediaState={recv:void 0,send:void 0}}get joinAttempted(){return this.mediaJoinAttempted||this.socketJoinAttempted}get roomJoined(){return this.mediaJoined&&this.socketJoined}updateSocketConnectionState(e,n){let i;const{reconnected:r}=this.socketState;switch(e){case"connected":i={state:"connected",reconnected:r,reconnectionAttempt:void 0};break;case"disconnected":i={state:"disconnected",reconnected:!1,reconnectionAttempt:0},this.socketJoined=!1;break;case"reconnected":i={state:"connected",reconnected:!0,reconnectionAttempt:void 0};break;case"reconnecting":i={state:"reconnecting",reconnected:r,reconnectionAttempt:0};break;case"reconnectAttempt":i={state:"reconnecting",reconnected:r,reconnectionAttempt:n};break;case"failed":i={state:"failed",reconnected:r,reconnectionAttempt:void 0},this.socketJoined=!1;break}i&&(L.emit(x.SOCKET_STATE_UPDATE,i),this.socketState=i)}}var bL=Object.defineProperty,kL=Object.getOwnPropertyDescriptor,kc=(t,e,n,i)=>{for(var r=i>1?void 0:i?kL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&bL(e,n,r),r},Ka,Kc,za,zc,Dg;let Ss=(Dg=class extends gn{constructor(t,e){super(),S(this,za),S(this,Ka,void 0),S(this,Kc,void 0),y(this,"recordingPeerIds",[]),y(this,"recordings",[]),T(this,Kc,t),T(this,Ka,e)}get recordingState(){return this.recordings.some(t=>t.state==="RECORDING")?"RECORDING":this.recordings.some(t=>t.state==="PAUSED")?"PAUSED":this.recordings.some(t=>t.state==="STARTING")?"STARTING":this.recordings.some(t=>t.state==="STOPPING")?"STOPPING":"IDLE"}updateRecordings(t){this.recordings=t,this.emit("recordingUpdate",this.recordingState)}start(t){return p(this,null,function*(){if(!o(this,Ka).permissions.canRecord)throw m.error("DyteRecording::start::permission_denied"),new D("User does not have permission to start recording","1001");if((t==null?void 0:t.allowMultiple)!==!0&&(this.recordingState==="STARTING"||this.recordingState==="RECORDING"||this.recordingState==="STOPPING"))throw m.error("DyteRecording::start::recording_in_progress",{recording:{state:this.recordingState}}),new D(`Cant start recording, recordingState irregular: ${this.recordingState}`,"1005");try{const e=Pt(),{recording:n={}}=o(this,Kc).getValue("defaults"),i=yield e.startRecording(n,t==null?void 0:t.allowMultiple);this.updateRecordings([...this.recordings,{id:i,state:"STARTING",type:"BROWSER"}])}catch(e){throw m.error("DyteRecording::stop::recording_failed_to_start",{error:e}),new D("Error while starting recording","1000")}})}stop(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"stop",["RECORDING","PAUSED"],t)})}pause(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"pause",["RECORDING"],t)})}resume(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"resume",["PAUSED"],t)})}},Ka=new WeakMap,Kc=new WeakMap,za=new WeakSet,zc=function(t,e,n){return p(this,null,function*(){if(!o(this,Ka).permissions.canRecord)throw m.error("DyteRecording::stop::permission_denied"),new D("User does not have permission to stop recording","1001");let i=[];if(n!==void 0){const r=this.recordings.find(s=>s.id===n);if(r===void 0)throw new D("Could not find the specified recording","1004");if(e.includes(r.state)){m.error("DyteRecording::stop::recording_not_in_expected_state",{recording:{state:r.state}});return}i.push(r)}else i=this.recordings.filter(r=>e.includes(r.state));i.forEach(r=>p(this,null,function*(){const s=r.state;t==="stop"&&(r.state="STOPPING",this.emit("recordingUpdate","STOPPING"));try{yield Pt().updateRecording(r.id,t)}catch(a){throw m.error("DyteRecording::stop::recording_failed_to_stop",{error:a}),r.state!==s&&(r.state=s,this.emit("recordingUpdate",s)),new D("Error while stopping recording","1000")}}))})},Dg);kc([w.trace("DyteRecording.start")],Ss.prototype,"start",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"stop",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"pause",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"resume",1);Ss=kc([Lt("1000")],Ss);var wL=Object.defineProperty,_L=Object.getOwnPropertyDescriptor,IL=(t,e,n,i)=>{for(var r=i>1?void 0:i?_L(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&wL(e,n,r),r},Bh;class CE{constructor(e,n,i){y(this,"recording"),y(this,"room"),S(this,Bh,void 0),T(this,Bh,e),this.recording=new Ss(e,n),this.room=i,this.setupEvents()}getRecordingTypeFromProtoType(e){let n;switch(e){case fs.BROWSER:n="BROWSER";break;case fs.COMPOSITE:n="COMPOSITE";break;case fs.TRACK:n="TRACK";break;default:n="BROWSER"}return n}setupEvents(){L.on(x.ROOM_STATE,e=>{e.activeRecordings.length!==0?this.recording.updateRecordings(e.activeRecordings.map(n=>{const i=this.getRecordingTypeFromProtoType(n.recordingType);return{id:n.recordingId,state:n.recordingStatus,type:i}})):this.recording.recordings.length&&this.recording.updateRecordings([])}),this.room.on(Y.recordingStarted,e=>{let n=!1;const i=[...this.recording.recordings];if(i.forEach(r=>{r.id===e.recordingId&&(n=!0,r.state="RECORDING")}),n===!1){const r=this.getRecordingTypeFromProtoType(e.recordingType);i.push({id:e.recordingId,state:"RECORDING",type:r})}this.recording.updateRecordings(i)}),this.room.on(Y.recordingPaused,e=>{const n=[...this.recording.recordings];n.forEach(i=>{i.id===e.recordingId&&(i.state="PAUSED")}),this.recording.updateRecordings(n)}),this.room.on(Y.recordingStopped,e=>{const n=[...this.recording.recordings.filter(i=>i.id!==e.recordingId)];this.recording.updateRecordings(n)})}}Bh=new WeakMap;IL([w.trace("RecordingController.setupEvents")],CE.prototype,"setupEvents",1);class CL{static hasFeature(e){var n;return(n=se.hasFeature(e))!=null?n:!1}static getFeatureValue(e){return se.getValue(e)}static getAllFeatures(){return se.getAllFlags()}}class cm{constructor(e,n,i){y(this,"logger"),y(this,"features"),y(this,"browserSpecs"),y(this,"callStats"),this.logger=e,this.features=n,this.browserSpecs=Be,this.callStats=i}static init(e){return new cm(m,CL,e)}}class dm{constructor(e){y(this,"internals"),this.internals=e}static init(){return p(this,null,function*(){const e=cm.init(ne);return new dm(e)})}}var RL=Object.defineProperty,PL=Object.getOwnPropertyDescriptor,yn=(t,e,n,i)=>{for(var r=i>1?void 0:i?PL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&RL(e,n,r),r},Et,ut,We,vi,Bn,kd,Fh;class cn extends Ra{constructor(e,n,i=jh,r=!0){super(),S(this,Et,void 0),S(this,ut,void 0),S(this,We,void 0),S(this,vi,void 0),S(this,Bn,void 0),S(this,kd,void 0),S(this,Fh,void 0),y(this,"audioUpdateInProgress"),y(this,"videoUpdateInProgress"),T(this,Fh,e),this.audioUpdateInProgress=!1,this.videoUpdateInProgress=!1,T(this,Et,new RE(e,n)),T(this,ut,new QL(o(this,Et),void 0,i)),T(this,We,new r2(o(this,Et),void 0,i)),T(this,Bn,new t2(o(this,Et))),T(this,vi,new ZL(o(this,Et))),T(this,kd,r),o(this,ut).on("trackMuted",this.onAudioTrackMuted.bind(this)),o(this,ut).on("trackChanged",this.onAudioTrackChanged.bind(this)),o(this,We).on("trackChanged",this.onVideoTrackChanged.bind(this)),o(this,We).on("trackEnded",this.onVideoTrackEnded.bind(this)),o(this,Bn).on("trackEnded",this.onScreenShareEnded.bind(this)),this.onVisibilityChange=this.onVisibilityChange.bind(this),document.addEventListener("visibilitychange",this.onVisibilityChange)}onVisibilityChange(){return p(this,null,function*(){ne.tabChanged(document.visibilityState==="visible"),document.visibilityState!=="visible"?ne.browserBackgrounded():(ne.browserForegrounded(),yield this.setupSpeaker())})}repopulateAvailableDevices(){return p(this,null,function*(){return!0})}setupStreams(e){return p(this,arguments,function*({audio:n,video:i}){var r;n?ne.audioOn():ne.audioOff(),i?ne.videoOn():ne.videoOff();let s,a;if(n&&i)try{const c=yield o(this,Et).getAudioAndVideoTrack(o(this,ut).userSelectedDevice,o(this,We).userSelectedDevice);s=c.audioTrack,a=c.videoTrack}catch(c){m.error("LocalMediaHandler::init::Failed to get audio video tracks",{error:c})}if(!s&&n)try{s=yield o(this,Et).getAudioTrack(!1,o(this,ut).userSelectedDevice)}catch(c){m.error("LocalMediaHandler::init::Failed to get audio track",{error:c})}if(!a&&i)try{a=yield o(this,Et).getVideoTrack(o(this,We).userSelectedDevice)}catch(c){m.error("LocalMediaHandler::init::Failed to get video track",{error:c})}n&&!s&&ne.audioOff(),i&&!a&&ne.videoOff(),yield o(this,ut).setMediaTrack(s),yield o(this,We).setMediaTrack(a);try{yield o(this,vi).setupSpeaker()}catch{}if(a){const c=yield this.getDeviceById(a.getSettings().deviceId);ne.selectedDevice("VIDEO",c)}if(s){const c=yield this.getDeviceById(s.getSettings().deviceId);ne.selectedDevice("AUDIO",c)}(r=o(this,vi).currentDevice)!=null&&r.deviceId&&ne.selectedDevice("SPEAKER",o(this,vi).currentDevice),o(this,Et).onDeviceChange((c,d,h)=>{this.onDeviceChange(d,h)})})}getCurrentDevices(){return{audio:o(this,ut).currentDevice,video:o(this,We).currentDevice,speaker:o(this,vi).currentDevice}}get permissions(){return o(this,Et).permissions}getAllDevices(){return o(this,Et).getAvailableDevices()}getDeviceById(e,n){return o(this,Et).getDevice(e)}onAudioTrackMuted(){this.emit("AUDIO_TRACK_SILENT")}onAudioTrackChanged(){this.emit("AUDIO_TRACK_CHANGE")}get rawAudioTrack(){return o(this,ut).mediaTrack}get audioTrack(){return o(this,ut).transformedMediaTrack}get audioEnabled(){return o(this,ut).trackEnabled}enableAudio(){return p(this,null,function*(){if(!this.audioUpdateInProgress){this.audioUpdateInProgress=!0;try{yield o(this,ut).unmuteTrack()}catch{}finally{this.audioUpdateInProgress=!1}}})}disableAudio(){o(this,ut).muteTrack()}getAudioDevices(e){return o(this,Et).getAudioInputDevices(e)}setAudioDevice(e){return p(this,null,function*(){yield o(this,ut).setDevice(e),e!=null&&e.deviceId&&ne.selectedDevice("AUDIO",e),this.emit("AUDIO_TRACK_CHANGE"),this.emit("DEVICE_CHANGE",{device:e})})}setupSpeaker(){return o(this,vi).setupSpeaker()}setSpeakerDevice(e){return p(this,null,function*(){yield o(this,vi).setupSpeaker(e),e!=null&&e.deviceId&&ne.selectedDevice("SPEAKER",e),this.emit("DEVICE_CHANGE",{device:e})})}onVideoTrackChanged(){this.emit("VIDEO_TRACK_CHANGE")}onVideoTrackEnded(){this.emit("VIDEO_TRACK_CHANGE")}get rawVideoTrack(){return o(this,We).mediaTrack}get videoTrack(){return o(this,We).transformedMediaTrack}get videoEnabled(){return o(this,We).trackEnabled}enableVideo(){return p(this,null,function*(){if(!this.videoUpdateInProgress){this.videoUpdateInProgress=!0;try{yield o(this,We).unmuteTrack()}catch{}finally{this.videoUpdateInProgress=!1}}})}disableVideo(){o(this,We).disableTrack()}getVideoDevices(e){return o(this,Et).getVideoInputDevices(e)}setVideoDevice(e){return p(this,null,function*(){yield o(this,We).setDevice(e),e!=null&&e.deviceId&&ne.selectedDevice("VIDEO",e),this.emit("VIDEO_TRACK_CHANGE"),this.emit("DEVICE_CHANGE",{device:e})})}updateVideoConstraints(e){return p(this,null,function*(){yield o(this,We).updateConstraints(e)})}onScreenShareEnded(){this.emit("SCREENSHARE_ENDED")}get screenShareTracks(){return{audio:o(this,Bn).audioMediaTrack,video:o(this,Bn).videoMediaTrack}}get screenShareEnabled(){return o(this,Bn).trackEnabled}enableScreenShare(){return p(this,null,function*(){yield o(this,Bn).enableScreenShare()})}disableScreenShare(){return p(this,null,function*(){o(this,Bn).disableScreenShare()})}updateScreenshareConstraints(e){return p(this,null,function*(){yield o(this,Bn).updateConstraints(e)})}getSpeakerDevices(e){return o(this,Et).getAudioOutputDevices(e)}addAudioMiddleware(e){return o(this,ut).addMiddleware(e)}removeAudioMiddleware(e){return o(this,ut).removeMiddleware(e)}removeAllAudioMiddlewares(){return o(this,ut).removeAllMiddlewares()}addVideoMiddleware(e){return o(this,We).addMiddleware(e)}removeVideoMiddleware(e){return o(this,We).removeMiddleware(e)}removeAllVideoMiddlewares(){return o(this,We).removeAllMiddlewares()}setVideoMiddlewareGlobalConfig(e){return o(this,We).setVideoMiddlewareGlobalConfig(e)}destruct(){o(this,ut).disableTrack(),o(this,We).disableTrack(),o(this,We).terminateMiddlewareWebWorker(),o(this,Bn).disableScreenShare(),o(this,Et).destruct()}onDeviceChange(e,n){return p(this,null,function*(){var i,r;this.emit("DEVICE_LIST_UPDATED",e),!(n||!o(this,kd))&&((i=e==null?void 0:e.added)==null||i.forEach(s=>p(this,null,function*(){var a;s&&!jh(s)&&(s.kind==="audioinput"&&((a=this.audioTrack)==null?void 0:a.enabled)===!0?yield this.setAudioDevice(s):s.kind==="audiooutput"&&(yield this.setSpeakerDevice(s)))})),(r=e==null?void 0:e.removed)==null||r.forEach(s=>p(this,null,function*(){var a;if(s.kind==="audiooutput"&&((a=this.getCurrentDevices().speaker)==null?void 0:a.deviceId)===s.deviceId){const c=(yield this.getSpeakerDevices()).find(d=>d.deviceId!==s.deviceId);c&&(yield this.setSpeakerDevice(c))}})))})}removeAllTracks(){this.destruct()}removeAudioTrack(){o(this,ut).disableTrack()}removeVideoTrack(){o(this,We).disableTrack(),o(this,We).terminateMiddlewareWebWorker()}removeDocumentEventListeners(){return p(this,null,function*(){document.removeEventListener("visibilitychange",this.onVisibilityChange)})}}Et=new WeakMap,ut=new WeakMap,We=new WeakMap,vi=new WeakMap,Bn=new WeakMap,kd=new WeakMap,Fh=new WeakMap;yn([w.trace("MediaHandler.setupStreams")],cn.prototype,"setupStreams",1);yn([w.trace("MediaHandler.enableAudio")],cn.prototype,"enableAudio",1);yn([w.trace("MediaHandler.disableAudio")],cn.prototype,"disableAudio",1);yn([w.trace("MediaHandler.setAudioDevice")],cn.prototype,"setAudioDevice",1);yn([w.trace("MediaHandler.enableVideo")],cn.prototype,"enableVideo",1);yn([w.trace("MediaHandler.disableVideo")],cn.prototype,"disableVideo",1);yn([w.trace("MediaHandler.setVideoDevice")],cn.prototype,"setVideoDevice",1);yn([w.trace("MediaHandler.updateVideoConstraints")],cn.prototype,"updateVideoConstraints",1);yn([w.trace("MediaHandler.enableScreenShare")],cn.prototype,"enableScreenShare",1);yn([w.trace("MediaHandler.disableScreenShare")],cn.prototype,"disableScreenShare",1);yn([w.trace("MediaHandler.updateScreenshareConstraints")],cn.prototype,"updateScreenshareConstraints",1);yn([w.trace("MediaHandler.destruct")],cn.prototype,"destruct",1);yn([w.trace("MediaHandler.onDeviceChange")],cn.prototype,"onDeviceChange",1);function Yc(t,e,n){switch(!0){case Be.isChromiumBased():switch(e){case"NotAllowedError":return n.includes("by system")?"SYSTEM_DENIED":t==="screenshare"?"CANCELED":"DENIED";case"NotReadableError":default:return"COULD_NOT_START"}case Be.isSafari():switch(e){case"NotAllowedError":return"DENIED";default:return"COULD_NOT_START"}case Be.isFirefox():switch(e){case"NotFoundError":case"NotReadableError":return"SYSTEM_DENIED";case"NotAllowedError":return"DENIED";case"AbortError":default:return"COULD_NOT_START"}default:return"COULD_NOT_START"}}const AL=["virtual","emulator","krisp","solstice conference","teams","loom","zoom","manycam","blackhole","displayport","xsplit","wirecast","vMix","elgato","epiphan","voice changer","voicemod","morphvoxx"];function jh(t){var e,n;const i=(e=t.label)==null?void 0:e.toLowerCase();return((n=Be._bowser)==null?void 0:n.getOSName())==="macOS"&&i.includes("iphone")?(m.log("isVirtualDevice::ignore_macos_continuity"),!0):AL.some(r=>i==null?void 0:i.includes(r))}function ML(t,e){return p(this,null,function*(){if(!(t!=null&&t.length))return e;const n=new AudioContext,i=yield Promise.all(t==null?void 0:t.map(a=>a(n))),r=n.createMediaStreamSource(new MediaStream([e])),s=n.createMediaStreamDestination();try{let a=r;for(let c=0;c<i.length;c+=1)a.connect(i[c]),a=i[c];a.connect(s)}catch(a){return m.error("getTransformedAudioTrack::middleware_execution_failed",{error:a}),e}return s.stream.getAudioTracks()[0]})}var zs;class OL{constructor(){S(this,zs,void 0)}terminateMiddlewareWebWorker(){if(o(this,zs))try{la(o(this,zs)),T(this,zs,void 0)}catch{m.debug("WorkerTimers::terminateMiddlewareWebWorker::failed")}}getTransformedVideoTrack(e,n,i){return p(this,null,function*(){if(!(e!=null&&e.length))return n;const r=document.createElement("canvas"),s=yield Promise.all(e==null?void 0:e.map(g=>g({canvas:r,WorkerTimers:PT})));if(i.disablePerFrameCanvasRendering){const g=r.captureStream().getVideoTracks()[0];return Object.defineProperty(g,"originalSettings",{value:n.getSettings()}),g}const a=document.createElement("video"),c=new MediaStream;c.addTrack(n);const d=r.getContext("2d");a.srcObject=c,a.autoplay=!0,this.terminateMiddlewareWebWorker();const h=()=>p(this,null,function*(){if(n.enabled===!1||n.readyState==="ended"){this.terminateMiddlewareWebWorker(),a.remove(),r.remove();return}try{d.drawImage(a,0,0);for(let g=0;g<s.length;g+=1)typeof s[g]=="function"&&(yield s[g](r,d))}catch(g){m.error("getTransformedVideoTrack::middleware_execution_failed",{error:g})}});try{a.play()}catch{}a.addEventListener("play",()=>{r.width=a.width||n.getSettings().width,r.height=a.width||n.getSettings().height,T(this,zs,Xd(h,50))},!1);const u=r.captureStream().getVideoTracks()[0];return Object.defineProperty(u,"originalSettings",{value:n.getSettings()}),u})}}zs=new WeakMap;const Ng={gross:{width:{ideal:192},height:{ideal:144}},qvga:{width:{ideal:384},height:{ideal:288}},pvga:{width:{ideal:480},height:{ideal:360}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}},hd_cropped:{width:{ideal:900},height:{ideal:720}},fhd:{width:{ideal:1920},height:{ideal:1080}}},DL=[[320,[{rid:"q",maxBitrate:25e4,maxFramerate:24,scalabilityMode:"L1T1"}]],[640,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:25e4,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:7e5,maxFramerate:30,scalabilityMode:"L1T1"}]],[1280,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:5e5,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:13e5,maxFramerate:30,scalabilityMode:"L1T1"}]],[1920,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:9e5,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:15e5,maxFramerate:30,scalabilityMode:"L1T1"}]]],NL=t=>{var e;const n="getSettings"in t&&t.getSettings().width||"getConstraints"in t&&t.getConstraints().width||"originalSettings"in t&&((e=t.originalSettings)==null?void 0:e.width);let i=DL;se.hasFeature(ue.OVERRIDE_HIVE_SIMULCAST_DYNAMIC)&&(i=JSON.parse(se.getValue(ue.OVERRIDE_HIVE_SIMULCAST_DYNAMIC)));const r=i.map(([c])=>c).sort((c,d)=>c-d);let s=Number.MAX_VALUE,a=0;return r.forEach((c,d)=>{Math.abs(c-n)<s&&(s=Math.abs(c-n),a=d)}),i[a][1]};var De=(t=>(t.WEBCAM="webcam",t.WEBCAM_BACKUP="webcam_backup",t.MIC="mic",t.SCREENSHARE_VIDEO="screenshare_video",t.SCREENSHARE_AUDIO="screenshare_audio",t))(De||{});const LL=kC(),Vs=Gn(LL.config.media);function xL(t){var e,n;const i={};return t.audio&&(i.audio={enableStereo:(e=t.audio.enableStereo)!=null?e:!1,enableHighBitrate:(n=t.audio.enableHighBitrate)!=null?n:!1}),i.video=t.video.quality,i}var Ys,Wh;class VL{constructor(e,n){S(this,Ys,void 0),S(this,Wh,void 0),y(this,"getScreenShareConstraints",()=>{var i,r,s,a,c,d,h,u,g,E,b;const k=(i=o(this,Ys))==null?void 0:i.screenshare,A=(s=(r=k==null?void 0:k.width)==null?void 0:r.max)!=null?s:1920,M=(c=(a=k==null?void 0:k.height)==null?void 0:a.max)!=null?c:1080,B=(h=(d=k==null?void 0:k.frameRate)==null?void 0:d.max)!=null?h:5;let K=(g=(u=k==null?void 0:k.frameRate)==null?void 0:u.ideal)!=null?g:5;const X=k==null?void 0:k.displaySurface,O=k==null?void 0:k.selfBrowserSurface;se.getValue(ue.VAL_MIN_FRAMERATE)&&(K=parseInt((E=se.getValue(ue.VAL_MIN_FRAMERATE))==null?void 0:E.toString(),10));let $={width:{max:A},height:{max:M},frameRate:{ideal:K,max:B}};if(se.hasFeature(ue.SCREENSHARE_CONSTRAINTS)){const me=(b=se.getValue(ue.SCREENSHARE_CONSTRAINTS))==null?void 0:b.toString();$=JSON.parse(me)}return X!==void 0&&["monitor","browser","window"].includes(X)&&($=ee(H({},$),{displaySurface:X})),O!==void 0&&($=ee(H({},$),{selfBrowserSurface:O})),{audio:!0,video:$}}),y(this,"getAudioConstraints",i=>{var r,s,a,c,d,h,u,g;const E={},b=(r=o(this,Ys))==null?void 0:r.audio,k=b!=null&&b.enableStereo?2:1;return Be.isFirefox()||Be.isWebKitBased()?(E.audio={deviceId:i,autoGainControl:(s=b==null?void 0:b.autoGainControl)!=null?s:!0,echoCancellation:(a=b==null?void 0:b.echoCancellation)!=null?a:!0,noiseSuppression:(c=b==null?void 0:b.noiseSupression)!=null?c:!0,channelCount:k},E):(E.audio={},E.audio.optional=[i?{sourceId:i}:{sourceId:"default"},{channelCount:k},{echoCancellation:(d=b==null?void 0:b.echoCancellation)!=null?d:!0},{googEchoCancellation:(h=b==null?void 0:b.echoCancellation)!=null?h:!0},{googAutoGainControl:(u=b==null?void 0:b.autoGainControl)!=null?u:!0},{googNoiseSuppression:(g=b==null?void 0:b.noiseSupression)!=null?g:!0},{googHighpassFilter:!0}],E)}),y(this,"getVideoConstraints",i=>{var r,s,a,c;const d={},h=(r=o(this,Ys))==null?void 0:r.video;let u=Ng.vga;if(typeof h=="string"?u=Ng[h]:h!==void 0&&(u.height.ideal=h.height.ideal,u.width.ideal=h.width.ideal),u.frameRate={ideal:(a=(s=u.frameRate)==null?void 0:s.ideal)!=null?a:24},Be.isChromiumBased()&&(u.frameRate.max=30),se.hasFeature(ue.VIDEO_CONSTRAINTS)){const g=(c=se.getValue(ue.VIDEO_CONSTRAINTS))==null?void 0:c.toString();u=JSON.parse(g)}return d.video=u,typeof d.video=="boolean"||(i?d.video.deviceId={exact:i}:d.video.facingMode="user"),d}),T(this,Wh,e),T(this,Ys,n)}getUpdatedVideoConstraints(e){return e}}Ys=new WeakMap,Wh=new WeakMap;class ju extends Error{constructor(e,n,i){super(n),y(this,"constraints"),y(this,"name"),this.name=e,this.constraints=i}}class UL{constructor(){y(this,"permissions"),this.permissions={audio:"NOT_REQUESTED",video:"NOT_REQUESTED",screenshare:"NOT_REQUESTED"}}getAudioInputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="audioinput")})}getVideoInputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="videoinput")})}getAudioOutputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="audiooutput")})}}var BL=Object.defineProperty,FL=Object.getOwnPropertyDescriptor,Yn=(t,e,n,i)=>{for(var r=i>1?void 0:i?FL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&BL(e,n,r),r},Ya,Mn,Wu,Lg;let fn=(Lg=class extends UL{constructor(t,e){super(),y(this,"availableDevices"),S(this,Ya,void 0),S(this,Mn,void 0),S(this,Wu,void 0),T(this,Wu,t),T(this,Mn,new VL(t,e)),T(this,Ya,new AbortController),this.availableDevices=[],this.getAvailableDevices()}get constraintsBuilder(){return o(this,Mn)}destruct(){return p(this,null,function*(){var t;(t=o(this,Ya))==null||t.abort()})}handlePermissionErrors(t,e){const n=Yc(t,e.name,e.message);return this.permissions[t]=n,L.emit(x.MEDIA_PERMISSION_ERROR,{message:n,constraints:e.constraints,kind:t}),n}getAudioAndVideoTrack(t,e){return p(this,null,function*(){const n={audio:o(this,Mn).getAudioConstraints(t).audio,video:o(this,Mn).getVideoConstraints(e).video};try{m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(n)});const i=yield navigator.mediaDevices.getUserMedia(n);m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(n)});const r=i.getAudioTracks()[0];let s=i.getVideoTracks()[0];if(this.permissions.audio="ACCEPTED",this.permissions.video="ACCEPTED",se.hasFeature(ue.OBS_QUALITY)&&s.label.includes("OBS Virtual")){const a=(yield this.getVideoInputDevices()).find(c=>c.label.includes("OBS Virtual"));s=yield this.getVideoTrack(a.deviceId)}return L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"}),L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"}),{audioTrack:r,videoTrack:s}}catch(i){throw m.error("WebMediaInterface.getAudioAndVideoTrack",{error:i}),new D("Couldnt fetch audio and video track","1605")}})}getAudioTrack(t,e){return p(this,null,function*(){let n=yield this.getAudioInputDevices();if(n.length===0)throw this.permissions.audio="NO_DEVICES_AVAILABLE",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"}),new D("No audio devices available","1606");const i=r=>p(this,null,function*(){let s;try{n=n.filter(c=>c.deviceId!==r),s=o(this,Mn).getAudioConstraints(r),m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(s)});const[a]=(yield navigator.mediaDevices.getUserMedia(s)).getAudioTracks();return m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(s)}),a}catch(a){const c=Yc("audio",a.name,a.message),d=new ju(a.name,a.message,s);if(c==="COULD_NOT_START"){const h=n.shift();if(!h)throw d;m.info("getAudioTrack::gum_failed",{constraints:JSON.stringify(s),error:a});const u=o(this,Mn).getAudioConstraints(h.deviceId);return m.info("getAudioTrack::retrying_gum_for_next_device",{constraints:JSON.stringify(u)}),i(h.deviceId)}throw d}});try{const r=yield i(e);return r.enabled=!t,this.permissions.audio!=="ACCEPTED"&&(this.permissions.audio="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"})),r}catch(r){throw r.constraints&&this.handlePermissionErrors("audio",r),new D(r.message,"1601")}})}getVideoTrack(t){return p(this,null,function*(){var e;const n=se.hasFeature(ue.OBS_QUALITY),i=(e=yield this.getCurrentDeviceLabel(t))==null?void 0:e.includes("OBS Virtual"),r=n&&i,s=yield this.getVideoInputDevices();if(s.length===0)throw this.permissions.video="NO_DEVICES_AVAILABLE",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"}),new D("No video devices available","1607");const a=c=>p(this,null,function*(){try{let d=c;const{video:h}=d;r&&typeof h!="boolean"&&(d={video:{deviceId:h.deviceId}}),m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(d)});const[u]=(yield navigator.mediaDevices.getUserMedia(d)).getVideoTracks();if(r&&typeof h!="boolean"&&typeof h.width=="object"){const{width:g,height:E}=u.getSettings(),{ideal:b}=h.width;u.applyConstraints({width:{ideal:b},height:{ideal:Math.floor(E*b/g)},frameRate:h.frameRate})}return m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(d)}),u}catch(d){const h=Yc("video",d.name,d.message),u=new ju(d.name,d.message,c);if(h==="COULD_NOT_START"){const g=s.shift();if(!g)throw u;m.info("getVideoTrack::gum_failed",{constraints:JSON.stringify(c),error:d});const E=o(this,Mn).getVideoConstraints(g.deviceId);return m.info("getVideoTrack::retrying_gum_for_next_device",{constraints:JSON.stringify(E)}),a({video:E.video})}throw u}});try{const c=o(this,Mn).getVideoConstraints(t),d=yield a(c);return this.permissions.video!=="ACCEPTED"&&(this.permissions.video="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"})),d}catch(c){throw c.constraints&&this.handlePermissionErrors("video",c),new D(c.message,"1602")}})}getScreenShareTracks(){return p(this,null,function*(){const t=e=>p(this,null,function*(){try{m.info("getDisplayMediaWithoutTimeout::requesting_display_media",{constraints:JSON.stringify(e)}),ne.screenShareRequested();const n=yield navigator.mediaDevices.getDisplayMedia(e);return m.info("getDisplayMediaWithoutTimeout::received_display_media",{constraints:JSON.stringify(e)}),n}catch(n){const i=Yc("video",n.name,n.message),r=new ju(n.name,n.message,e),s={video:!0};if(qR(e,s)||!se.hasFeature(ue.SCREEENSHARE_CONSTRAINTS_RETRY))throw r;if(i==="COULD_NOT_START")return t(s);throw r}});try{const e=o(this,Mn).getScreenShareConstraints(),n=yield t(e);return this.permissions.screenshare!=="ACCEPTED"&&(this.permissions.screenshare="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.screenshare,kind:"screenshare"})),{audioTrack:n.getAudioTracks()[0],videoTrack:n.getVideoTracks()[0]}}catch(e){throw e.constraints&&this.handlePermissionErrors("screenshare",e),new D(e.message,"1612")}})}getCurrentDeviceLabel(t){return p(this,null,function*(){const e=yield this.getDevice(t||"default");return e==null?void 0:e.label})}getAvailableDevices(){return p(this,null,function*(){try{const t=yield navigator.mediaDevices.enumerateDevices();return this.availableDevices=t,t}catch(t){throw m.error("enumerate_devices_failed",{error:t}),new D("Failed to get available devices","1609")}})}getAvailableDevicesByKind(t){return p(this,null,function*(){try{return(yield navigator.mediaDevices.enumerateDevices()).filter(({kind:e})=>t===e)}catch(e){throw m.error("enumerate_devices_failed",{error:e}),new D("Failed to get available devices by kind","1609")}})}getDevice(t){return p(this,null,function*(){try{return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>e.deviceId===t)[0]}catch(e){throw m.error("enumerate_devices_failed",{error:e}),new D("Failed to get device","1609")}})}onDeviceChange(t){return p(this,null,function*(){Be.supportsDeviceChangeEvent()&&navigator.mediaDevices.addEventListener("devicechange",e=>p(this,null,function*(){var n,i;const r=u=>`${u.kind}-${u.deviceId}-${u.groupId}`,s=this.availableDevices,a=new Set(s.map(u=>r(u))),c=yield this.getAvailableDevices(),d=new Set(c.map(u=>r(u))),h={added:c.filter(u=>!a.has(r(u))),removed:s.filter(u=>!d.has(r(u))),devices:c};if((n=h.added)!=null&&n.length||(i=h.removed)!=null&&i.length){m.info("repopulated_full_device_list",{devices:JSON.stringify(c)});const u=[...h.added,...h.removed];u.some(g=>g.kind==="audioinput")&&ne.devices("AUDIO",c==null?void 0:c.filter(g=>g.kind==="audioinput")),u.some(g=>g.kind==="videoinput")&&ne.devices("VIDEO",c==null?void 0:c.filter(g=>g.kind==="videoinput")),u.some(g=>g.kind==="audiooutput")&&ne.devices("SPEAKER",c==null?void 0:c.filter(g=>g.kind==="audiooutput")),t(e,h,!1)}}),{signal:o(this,Ya).signal})})}},Ya=new WeakMap,Mn=new WeakMap,Wu=new WeakMap,Lg);Yn([w.trace("WebMediaInterface.destruct")],fn.prototype,"destruct",1);Yn([w.trace("WebMediaInterface.handlePermissionErrors")],fn.prototype,"handlePermissionErrors",1);Yn([w.trace("WebMediaInterface.getAudioAndVideoTrack")],fn.prototype,"getAudioAndVideoTrack",1);Yn([w.trace("WebMediaInterface.getAudioTrack")],fn.prototype,"getAudioTrack",1);Yn([w.trace("WebMediaInterface.getVideoTrack")],fn.prototype,"getVideoTrack",1);Yn([w.trace("WebMediaInterface.getScreenShareTracks")],fn.prototype,"getScreenShareTracks",1);Yn([w.trace("WebMediaInterface.getAvailableDevices")],fn.prototype,"getAvailableDevices",1);Yn([w.trace("WebMediaInterface.getAvailableDevicesByKind")],fn.prototype,"getAvailableDevicesByKind",1);Yn([w.trace("WebMediaInterface.getDevice")],fn.prototype,"getDevice",1);Yn([w.trace("WebMediaInterface.onDeviceChange")],fn.prototype,"onDeviceChange",1);fn=Yn([Lt("1600")],fn);const RE=fn,Ko={setItem:(t,e)=>{try{localStorage.setItem(t,e)}catch(n){m.error("LocalStorage::setItem::crashed",{error:n,localStorage:{key:t,value:e}})}},getItem:t=>{try{return localStorage.getItem(t)}catch(e){m.error("LocalStorage::getItem::crashed",{error:e,localStorage:{key:t}})}return null}},jL=(t=0)=>new Promise(e=>setTimeout(e,t)),WL=(t,e,n)=>{const i=typeof n=="number"?n:250,r=t.createMediaStreamSource(e),s=t.createAnalyser();s.fftSize=2048,r.connect(s);const a=new Uint8Array(s.fftSize);let c=!1;setTimeout(()=>{c=!0},i);function d(){return c?Promise.resolve(!0):(s.getByteTimeDomainData(a),a.some(h=>h!==128&&h!==0)?Promise.resolve(!1):jL().then(d))}return d().then(h=>(r.disconnect(),h),h=>{throw r.disconnect(),h})},HL=typeof AudioContext!="undefined"?AudioContext:null;class lm{constructor(e){y(this,"_AudioContext"),y(this,"audioContext"),y(this,"_audioContextRefContainers");const n=H({AudioContext:HL},e);Object.defineProperties(this,{_AudioContext:{value:n.AudioContext},audioContext:{value:null,writable:!0},_audioContextRefContainers:{value:new Set},AudioContextProvider:{enumerable:!0,value:lm}})}getOrCreate(e){if(!this._audioContextRefContainers.has(e)&&(this._audioContextRefContainers.add(e),this._AudioContext&&!this.audioContext))try{this.audioContext=new this._AudioContext}catch{}return this.audioContext}release(e){this._audioContextRefContainers.has(e)&&(this._audioContextRefContainers.delete(e),!this._audioContextRefContainers.size&&this.audioContext&&(this.audioContext.close(),this.audioContext=null))}}const xg=new lm,qL=3,GL=250;function $L(t){const e={},n=xg.getOrCreate(e);let i=qL;function r(){return i-=1,WL(n,t.srcObject,GL).then(s=>s?i>0?r():!0:!1).catch(()=>!0)}return r().finally(()=>{xg.release(e)})}function Vg(t){return p(this,null,function*(){const e=new Audio,n=new MediaStream;n.addTrack(t),e.srcObject=n;let i=!1;try{const r=e.play();r&&(yield r),i=yield $L(e),i&&m.info("checkIfAudioTrackIsSilent::silence_detected")}catch(r){m.error("checkIfAudioTrackIsSilent::failed_to_detect_silence",{error:r})}finally{e.pause(),e.remove()}return i})}var JL=Object.defineProperty,KL=Object.getOwnPropertyDescriptor,PE=(t,e,n,i)=>{for(var r=i>1?void 0:i?KL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&JL(e,n,r),r};let pl=class extends Ra{constructor(t,e,n){var i;super(),y(this,"constructorName",this.constructor.name),y(this,"userSelectedDevice"),y(this,"mediaInterface"),y(this,"isNonPreferredDevice"),y(this,"_mediaTrack"),y(this,"transformedMediaTrack"),y(this,"middlewares",[]),y(this,"currentDevice"),y(this,"userPreferredDeviceKey",`Dyte::${this.constructorName}::UserDeviceID`),y(this,"setUserPreferredDevice",r=>Ko.setItem(this.userPreferredDeviceKey,r)),y(this,"getUserPreferredDevice",()=>Ko.getItem(this.userPreferredDeviceKey)),this.mediaInterface=t,e&&this.setMediaTrack(e),this.userSelectedDevice=(i=this.getUserPreferredDevice())!=null?i:void 0,this.isNonPreferredDevice=n,this.onTrackEnded=this.onTrackEnded.bind(this),this.onTrackMuted=this.onTrackMuted.bind(this)}disableTrack(){var t,e;this.removeMediaTrackListeners(),(t=this._mediaTrack)==null||t.stop(),this._mediaTrack=void 0,(e=this.transformedMediaTrack)==null||e.stop(),this.transformedMediaTrack=void 0}get mediaTrack(){return this._mediaTrack}setMediaTrack(t){return p(this,null,function*(){const e=n=>{m.error(`${this.constructorName}.setMediaTrack.error`,{error:n})};try{this.disableTrack()}catch(n){e(n)}this._mediaTrack=yield this.conditionallyChangeTrack(t),yield this.setTransformedTrack();try{this.addMediaTrackListeners(),yield this.setCurrentDevice()}catch(n){e(n)}})}get trackEnabled(){return!!this.mediaTrack&&this.mediaTrack.readyState==="live"&&this.mediaTrack.enabled}muteTrack(){if(!this.mediaTrack){m.warn("BaseMediaHandler.muteTrack Tried muting with no track present");return}this.transformedMediaTrack&&(this.transformedMediaTrack.enabled=!1),this.mediaTrack.enabled=!1}unmuteTrack(){return p(this,null,function*(){try{this.mediaTrack?this.mediaTrack.enabled=!0:yield this.enableTrack(!1)}catch(t){throw m.error(`${this.constructorName}.unmuteTrack.error`,{error:t}),this.disableTrack(),new D("Failed to unmute track","1611")}})}getCurrentDeviceId(){var t,e;const{kind:n}=this.mediaTrack;switch(n){case"audio":{const i=this.mediaTrack.getConstraints();return this.userSelectedDevice?(e=(t=i==null?void 0:i.deviceId)!=null?t:i==null?void 0:i.advanced[0].deviceId)!=null?e:this.mediaTrack.getSettings().deviceId:this.mediaTrack.getSettings().deviceId}default:return this.mediaTrack.getSettings().deviceId}}setCurrentDevice(){return p(this,null,function*(){var t;if(!this.mediaTrack){this.currentDevice=void 0;return}const e=this.getCurrentDeviceId();((t=this.currentDevice)==null?void 0:t.deviceId)!==e&&(this.currentDevice=yield this.mediaInterface.getDevice(e))})}setDevice(t){return p(this,null,function*(){if(!t)throw m.warn(`${this.constructorName}.setDevice No device received`),new D("No device received!","1603");this.userSelectedDevice=t.deviceId,this.setUserPreferredDevice(t.deviceId),yield this.onSetDevice(t)})}addMiddleware(t){return p(this,null,function*(){if(Be.isWebKitBased()&&!se.hasFeature(ue.ALLOW_SAFARI_MEDIA_MIDDLEWARES))return{success:!1,message:"Middlewares are not supported in this WebKit engine based browser."};if(this.middlewares.includes(t))return{success:!1,message:"This middleware has been applied, already. Skipping."};try{return this.middlewares.push(t),this.trackEnabled&&(yield this.setTransformedTrack()),{success:!0,message:"Successfully added the middleware."}}catch(e){return m.error("While adding middleware",{error:e}),this.removeMiddleware(t),{success:!1,message:e==null?void 0:e.message}}})}removeMiddleware(t){return p(this,null,function*(){const e=this.middlewares.indexOf(t,0);if(e>-1)try{return this.middlewares.splice(e,1),yield this.setTransformedTrack(!0),{success:!0,message:"Successfully removed the middleware."}}catch(n){return m.error("While removing middleware",{error:n}),{success:!1,message:n==null?void 0:n.message}}return{success:!1,message:"No such middleware was found. Skipping."}})}removeAllMiddlewares(){return p(this,null,function*(){var t;if((t=this.middlewares)!=null&&t.length)try{return this.middlewares=[],yield this.setTransformedTrack(!0),{success:!0,message:"Successfully removed all the middlewares."}}catch(e){return m.error("While removing all the middlewares",{error:e}),{success:!1,message:e==null?void 0:e.message}}return{success:!1,message:"No middlewares were found. Skipping."}})}addMediaTrackListeners(){var t,e,n;this.mediaTrack&&(m.info(`${this.constructorName}.addMediaTrackListeners for deviceId ${(e=(t=this.mediaTrack)==null?void 0:t.getSettings())==null?void 0:e.deviceId} of type ${(n=this.mediaTrack)==null?void 0:n.kind}`),this.mediaTrack.addEventListener("ended",this.onTrackEnded),this.mediaTrack.addEventListener("mute",this.onTrackMuted))}removeMediaTrackListeners(){var t,e,n;this.mediaTrack&&(m.info(`${this.constructorName}.removeMediaTrackListeners for deviceId ${(e=(t=this.mediaTrack)==null?void 0:t.getSettings())==null?void 0:e.deviceId} of type ${(n=this.mediaTrack)==null?void 0:n.kind}`),m.info(`${this.constructorName}.removeMediaTrackListeners`),this.mediaTrack.removeEventListener("ended",this.onTrackEnded),this.mediaTrack.removeEventListener("mute",this.onTrackMuted))}};PE([w.trace("BaseMediaHandler.unmuteTrack")],pl.prototype,"unmuteTrack",1);pl=PE([Lt("1600")],pl);const AE=pl;var zL=Object.defineProperty,YL=Object.getOwnPropertyDescriptor,um=(t,e,n,i)=>{for(var r=i>1?void 0:i?YL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&zL(e,n,r),r};const Hu="[Dyte]nonSilentDeviceLabels";class zl extends AE{onSetDevice(e){return p(this,null,function*(){if(!e)throw m.warn("AudioMediaHandler.setDevice No device received"),new D("No device received!","1603");if(e.kind!=="audioinput")throw m.warn("AudioMediaHandler.setDevice Received non audio device"),new D("Non audio device received while setting device!","1603");try{const n=this.trackEnabled;yield this.setMediaTrack(yield this.mediaInterface.getAudioTrack(!n,this.userSelectedDevice)),this.userSelectedDevice=void 0}catch(n){throw m.error("AudioMediaHandler.setDevice.error",{error:n}),this.disableTrack(),new D(n.message,"1604")}})}enableTrack(e){return p(this,null,function*(){if(this.trackEnabled){m.warn("AudioMediaHandler.enableTrack Track already enabled!");return}const n=yield this.mediaInterface.getAudioTrack(e,this.userSelectedDevice);yield this.setMediaTrack(n)})}setTransformedTrack(e){return p(this,null,function*(){var n;if(!e&&!((n=this.middlewares)!=null&&n.length)){this.transformedMediaTrack=this.mediaTrack;return}try{this.transformedMediaTrack=yield ML(this.middlewares,this.mediaTrack),this.emit("trackChanged")}catch(i){m.error("AudioMediaHandler.setTransformedTrack",{error:i}),this.transformedMediaTrack=this.mediaTrack}})}onTrackEnded(){return p(this,null,function*(){m.info("AudioMediaHandler.TrackEnded"),this.emit("trackEnded");const e=this.mediaTrack.enabled;this.disableTrack(),yield this.enableTrack(!e),yield this.setTransformedTrack(),this.emit("trackChanged")})}onTrackMuted(){m.info("AudioMediaHandler.TrackMuted"),this.emit("trackMuted")}conditionallyChangeTrack(e){return p(this,null,function*(){var n;if(!e||this.userSelectedDevice)return e;let i=e;const r=yield this.mediaInterface.getAudioInputDevices(),s=this.isNonPreferredDevice?r.filter(d=>d&&!this.isNonPreferredDevice(d)):r;if(!(s!=null&&s.length))return i;s.find(d=>d.deviceId===e.getSettings().deviceId)||(i.stop(),m.info("localmediahandler::setupstreams::found_audio_non_preferred"),i=yield this.mediaInterface.getAudioTrack(!1,s[0].deviceId));const a=JSON.parse(Ko.getItem(Hu));if(a!=null&&a.devices.some(d=>d.label===i.label))return i;if(!(yield Vg(i))){const d=(n=a==null?void 0:a.devices.concat({label:i.label}))!=null?n:[{label:i.label}];return Ko.setItem(Hu,JSON.stringify({devices:d})),i}m.info("AudioMediaHandler.conditionallyChangeTrack.DetectedSilentTrack");const c=i.getSettings().deviceId;return s.filter(d=>d.deviceId!==c).some(d=>p(this,null,function*(){if(i=yield this.mediaInterface.getAudioTrack(!1,d.deviceId),!(yield Vg(i))){const h=a.devices.concat({label:i.label});return Ko.setItem(Hu,JSON.stringify({devices:h})),m.info("AudioMediaHandler.conditionallyChangeTrack.SuccesfullyChangedTrack"),!0}return m.info("AudioMediaHandler.conditionallyChangeTrack.AnotherSilentTrackFound"),!1})),i})}}um([w.trace("AudioMediaHandler.setTransformedTrack")],zl.prototype,"setTransformedTrack",1);um([w.trace("AudioMediaHandler.onTrackEnded")],zl.prototype,"onTrackEnded",1);um([w.trace("AudioMediaHandler.conditionallyChangeTrack")],zl.prototype,"conditionallyChangeTrack",1);const QL=zl;var Eo;class XL{constructor(e){S(this,Eo,void 0),y(this,"currentDevice"),T(this,Eo,e)}setupSpeaker(e){return p(this,null,function*(){var n,i;if(!(o(this,Eo)instanceof RE))return;let r=e;if(e||([r]=(yield o(this,Eo).getAvailableDevicesByKind("audiooutput")).filter(a=>!jh(a))),!r)throw new D("No speaker found","1608");if(((n=this.currentDevice)==null?void 0:n.deviceId)===r.deviceId)return;this.currentDevice=r;const s=document.querySelectorAll("audio");(i=s[0])!=null&&i.setSinkId&&s.forEach(a=>p(this,null,function*(){if(typeof a.sinkId!="undefined"&&this.currentDevice.deviceId&&a.sinkId!==this.currentDevice.deviceId)try{yield a.setSinkId(this.currentDevice.deviceId)}catch{}}))})}}Eo=new WeakMap;const ZL=XL;class e2 extends Ra{constructor(e){super(),y(this,"mediaInterface"),y(this,"audioMediaTrack"),y(this,"videoMediaTrack"),this.mediaInterface=e}get trackEnabled(){return!!this.videoMediaTrack}enableScreenShare(){return p(this,null,function*(){var e,n;try{const{audioTrack:i,videoTrack:r}=yield this.mediaInterface.getScreenShareTracks();if(this.audioMediaTrack=i,this.videoMediaTrack=r,this.addMediaTrackListeners(),((n=(e=this.mediaInterface)==null?void 0:e.permissions)==null?void 0:n.screenshare)==="ACCEPTED")return;this.mediaInterface.permissions&&(this.mediaInterface.permissions.screenshare="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.mediaInterface.permissions.screenshare,kind:"screenshare"}))}catch{}})}disableScreenShare(){var e,n;this.removeMediaTrackListeners(),(e=this.audioMediaTrack)==null||e.stop(),(n=this.videoMediaTrack)==null||n.stop(),this.videoMediaTrack=void 0,this.audioMediaTrack=void 0}updateConstraints(e){return p(this,null,function*(){if(!this.videoMediaTrack)throw new D("No media track enabled!","1610");const n=this.mediaInterface;if(!n.constraintsBuilder)throw new D("update constraints not supported for non web clients","1100");try{this.videoMediaTrack.applyConstraints(n.constraintsBuilder.getUpdatedVideoConstraints(e)),this.addMediaTrackListeners()}catch(i){m.error("ScreenShareHandler.updateConstraints.error",{error:i})}})}addMediaTrackListeners(){var e,n;(e=this.videoMediaTrack)==null||e.addEventListener("ended",this.onTrackEnded.bind(this)),Be.isWebKitBased()&&((n=this.videoMediaTrack)==null||n.addEventListener("mute",this.onTrackEnded.bind(this)))}removeMediaTrackListeners(){var e,n;(e=this.videoMediaTrack)==null||e.removeEventListener("ended",this.onTrackEnded),(n=this.videoMediaTrack)==null||n.removeEventListener("mute",this.onTrackEnded)}onTrackEnded(){this.emit("trackEnded")}}const t2=e2;var n2=Object.defineProperty,i2=Object.getOwnPropertyDescriptor,Yl=(t,e,n,i)=>{for(var r=i>1?void 0:i?i2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&n2(e,n,r),r},So,wd;class wc extends AE{constructor(e,n,i){super(e,n,i),S(this,So,void 0),S(this,wd,{disablePerFrameCanvasRendering:!1}),T(this,So,new OL)}onSetDevice(e){return p(this,null,function*(){if(!e)throw m.warn("VideoMediaHandler.setDevice No device received"),new D("No device received!","1603");if(e.kind!=="videoinput")throw m.warn("VideoMediaHandler.setDevice Received non video device",{devices:[e]}),new D("Non video device received while setting video device!","1603");if(!(this.mediaTrack&&this.mediaTrack.enabled)){m.warn("VideoMediaHandler.setDevice Tried switching device with video disabled",{devices:[e]}),this.currentDevice=e;return}try{yield this.setMediaTrack(yield this.mediaInterface.getVideoTrack(this.userSelectedDevice))}catch(n){throw m.error("VideoMediaHandler.setDevice.error",{error:n}),this.disableTrack(),new D("Failed to change device","1600")}})}enableTrack(){return p(this,null,function*(){if(this.trackEnabled){m.warn("VideoMediaHandler.enableTrack Track already enabled!");return}yield this.setMediaTrack(yield this.mediaInterface.getVideoTrack(this.userSelectedDevice))})}setTransformedTrack(e){return p(this,null,function*(){var n;if(!e&&!((n=this.middlewares)!=null&&n.length)){this.transformedMediaTrack=this.mediaTrack;return}try{this.transformedMediaTrack=yield o(this,So).getTransformedVideoTrack(this.middlewares,this.mediaTrack,o(this,wd)),this.emit("trackChanged")}catch(i){m.error("VideoMediaHandler.setTransformedTrack",{error:i}),this.transformedMediaTrack=this.mediaTrack}})}setVideoMiddlewareGlobalConfig(e){return p(this,null,function*(){T(this,wd,e)})}updateConstraints(e){return p(this,null,function*(){if(!this._mediaTrack)throw new D("No media track enabled!","1610");const n=this.mediaInterface;if(!n.constraintsBuilder)throw new D("update constraints not supported for non web clients","1100");try{this._mediaTrack.applyConstraints(n.constraintsBuilder.getUpdatedVideoConstraints(e)),yield this.setTransformedTrack(),this.addMediaTrackListeners(),yield this.setCurrentDevice()}catch(i){m.error("VideoMediaHandler.updateConstraints.error",{error:i})}})}terminateMiddlewareWebWorker(){o(this,So).terminateMiddlewareWebWorker()}onTrackEnded(){return p(this,null,function*(){m.info("VideoMediaHandler.TrackEnded"),this.disableTrack(),this.emit("trackEnded")})}onTrackMuted(){m.info("VideoMediaHandler.TrackMuted"),this.emit("trackMuted")}conditionallyChangeTrack(e){return p(this,null,function*(){if(!e||this.userSelectedDevice)return e;let n=e;const i=yield this.mediaInterface.getVideoInputDevices(),r=this.isNonPreferredDevice?i.filter(s=>!this.isNonPreferredDevice(s)):i;return!(r!=null&&r.length)||window.FAST_DYTE||r.find(s=>s.deviceId===e.getSettings().deviceId)||(n.stop(),m.info("localmediahandler::setupstreams::found_video_non_preferred"),n=yield this.mediaInterface.getVideoTrack(r[0].deviceId)),n})}}So=new WeakMap,wd=new WeakMap;Yl([w.trace("VideoMediaHandler.setTransformedTrack")],wc.prototype,"setTransformedTrack",1);Yl([w.trace("VideoMediaHandler.setVideoMiddlewareGlobalConfig")],wc.prototype,"setVideoMiddlewareGlobalConfig",1);Yl([w.trace("VideoMediaHandler.onTrackEnded")],wc.prototype,"onTrackEnded",1);Yl([w.trace("VideoMediaHandler.conditionallyChangeTrack")],wc.prototype,"conditionallyChangeTrack",1);const r2=wc,Ug=Gn(tm());var ln,Qs,_d,To;const bo=class{constructor(t){if(S(this,ln,void 0),S(this,Qs,void 0),S(this,_d,void 0),S(this,To,void 0),!t)throw new D("Could not load preset.","0904");T(this,ln,t.config),T(this,_d,t.name),T(this,Qs,t.ui||Gn(tm().ui)),T(this,To,t.permissions.plugins.config)}static fromResponse(t){return new bo(t)}static default(){return new bo(Ug)}static init(t,e=!0){return!t||e?new bo(Ug):new bo(t)}get setupScreen(){return{isEnabled:!0}}get waitingRoom(){return{isEnabled:!0}}get controlBar(){return{isEnabled:!0,elements:{chat:!0,fullscreen:!0,invite:!1,layout:!1,participants:!0,plugins:!0,polls:!0,reactions:!1,screenshare:!0}}}get header(){return{isEnabled:!0,elements:{logo:o(this,Qs).designTokens.logo,timer:!0,title:!0,participantCount:!0,changeLayout:!1}}}get pipMode(){return!0}get viewType(){return o(this,ln).viewType}get livestreamViewerQualities(){return o(this,ln).livestreamViewerQualities||[]}get maxVideoStreams(){return o(this,ln).maxVideoStreams}get maxScreenShareCount(){return o(this,ln).maxScreenshareCount}get plugins(){return[]}get disabledPlugins(){return Object.keys(o(this,To)).filter(t=>o(this,To)[t].disabled)}get designTokens(){return o(this,Qs).designTokens}get configDiff(){return o(this,Qs).configDiff}get mediaConstraints(){var t,e,n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K,X,O,$,me,Ie;return{audio:{enableStereo:(i=(n=(e=(t=o(this,ln))==null?void 0:t.media)==null?void 0:e.audio)==null?void 0:n.enableStereo)!=null?i:Vs.audio.enableStereo,enableHighBitrate:(c=(a=(s=(r=o(this,ln))==null?void 0:r.media)==null?void 0:s.audio)==null?void 0:a.enableHighBitrate)!=null?c:Vs.audio.enableHighBitrate},video:{quality:(g=(u=(h=(d=o(this,ln))==null?void 0:d.media)==null?void 0:h.video)==null?void 0:u.quality)!=null?g:Vs.video.quality,frameRate:(A=(k=(b=(E=o(this,ln))==null?void 0:E.media)==null?void 0:b.video)==null?void 0:k.frameRate)!=null?A:Vs.video.frameRate},screenshare:{quality:(X=(K=(B=(M=o(this,ln))==null?void 0:M.media)==null?void 0:B.screenshare)==null?void 0:K.quality)!=null?X:Vs.screenshare.quality,frameRate:(Ie=(me=($=(O=o(this,ln))==null?void 0:O.media)==null?void 0:$.screenshare)==null?void 0:me.frameRate)!=null?Ie:Vs.screenshare.frameRate}}}get name(){return o(this,_d)}};let s2=bo;ln=new WeakMap,Qs=new WeakMap,_d=new WeakMap,To=new WeakMap;var a2=Object.defineProperty,o2=Object.getOwnPropertyDescriptor,ME=(t,e,n,i)=>{for(var r=i>1?void 0:i?o2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&a2(e,n,r),r},ko;class hm extends gn{constructor(e){super(),S(this,ko,void 0),y(this,"state","IDLE"),y(this,"playbackUrl"),y(this,"ingestionCredentials"),y(this,"viewerCount"),T(this,ko,e),this.viewerCount=0}setLivestreamState(e){const n=this.state;this.state=e,n!==e&&this.emitCurrentLivestreamState()}emitCurrentLivestreamState(){this.emit("livestreamUpdate",this.state)}start(){return p(this,arguments,function*(e={manualIngestion:!1}){if(!o(this,ko).permissions.canLivestream)throw m.error("DyteLivestream::start::permission_denied"),new D("User does not have permission to start livestreaming","1901");this.setLivestreamState("STARTING");try{const n=Pt(),{playbackUrl:i,ingestionCredentials:r}=yield n.startLivestreaming(e);this.playbackUrl=i,this.ingestionCredentials=r,e!=null&&e.manualIngestion&&this.setLivestreamState("WAITING_ON_MANUAL_INGESTION")}catch(n){throw m.error("DyteRecording::stop::livestream_failed_to_start",{error:n}),this.setLivestreamState("IDLE"),new D("Error while starting livestream","1900")}})}stop(){return p(this,null,function*(){if(!o(this,ko).permissions.canLivestream)throw m.error("DyteLivestream::stop::permission_denied"),new D("User does not have permission to stop livestreaming","1901");if(this.state!=="LIVESTREAMING"&&this.state!=="WAITING_ON_MANUAL_INGESTION")throw m.error("DyteLivestream::stop::inconsistent_state"),new D("Livestream not started yet","1902");try{this.setLivestreamState("STOPPING"),yield Pt().stopLivestreaming()}catch(e){throw m.error("DyteLivestream::stop::livestream_failed_to_stop",{error:e}),this.setLivestreamState("STOPPING"),new D("Error while stopping livestream","1900")}})}}ko=new WeakMap;ME([w.trace("livestream.start")],hm.prototype,"start",1);ME([w.trace("livestream.stop")],hm.prototype,"stop",1);var c2=Object.defineProperty,d2=Object.getOwnPropertyDescriptor,l2=(t,e,n,i)=>{for(var r=i>1?void 0:i?d2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&c2(e,n,r),r},wo,_o,rr;class OE{constructor(e,n){y(this,"livestream"),S(this,wo,void 0),S(this,_o,void 0),S(this,rr,void 0),T(this,_o,e),this.livestream=new hm(e),T(this,rr,n),this.setupEvents()}fetchInitialLivestreamingState(){return p(this,null,function*(){const e=Pt(),{status:n,playbackUrl:i,manualIngest:r,ingestionCredentials:s}=yield e.getActiveLivestream();this.livestream.playbackUrl=i,this.livestream.ingestionCredentials=s,n==="LIVE"&&this.livestream.setLivestreamState("LIVESTREAMING"),n==="INVOKED"&&r&&this.livestream.setLivestreamState("WAITING_ON_MANUAL_INGESTION")})}setupEvents(){o(this,rr).on(Y.startedLivestream,e=>p(this,null,function*(){this.livestream.playbackUrl=e.playbackUrl,this.livestream.setLivestreamState("LIVESTREAMING");try{o(this,_o).permissions.canLivestream&&(yield this.fetchInitialLivestreamingState())}catch{m.error("Error: LivestreamController.fetchLivestream during startedLivestream re-fetch")}})),o(this,rr).on(Y.livestreamingInvoked,e=>p(this,null,function*(){if(e.manualIngest){this.livestream.setLivestreamState("WAITING_ON_MANUAL_INGESTION");try{o(this,_o).permissions.canLivestream&&(yield this.fetchInitialLivestreamingState())}catch{m.error("Error: LivestreamController.fetchLivestream during livestreamingInvoked re-fetch")}}})),o(this,rr).on(Y.stoppedLivestream,()=>{this.livestream.setLivestreamState("IDLE"),this.livestream.playbackUrl=void 0,this.livestream.ingestionCredentials=void 0}),o(this,rr).on(Y.erroredLivestream,()=>{this.livestream.setLivestreamState("IDLE"),this.livestream.playbackUrl=void 0}),o(this,rr).on(Y.roomPeerCount,e=>{this.livestream.viewerCount=e.count,this.livestream.emit("viewerCountUpdate",e.count)}),L.on(x.PEER_JOINED_INTERNAL,e=>p(this,null,function*(){var n;((n=e.flags)==null?void 0:n.hiddenParticipant)===!0&&e.recorderType==="LIVESTREAMER"&&(T(this,wo,e.id),this.livestream.setLivestreamState("LIVESTREAMING"))})),L.on(x.PEER_CLOSED,e=>{e.id===o(this,wo)&&(T(this,wo,void 0),this.livestream.setLivestreamState("IDLE"))}),L.onAsync(x.LEAVE_MEDIA_ROOM,()=>p(this,null,function*(){this.livestream.playbackUrl||(m.info("Fetching livestreaming state on leave stage"),yield this.fetchInitialLivestreamingState())})),L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){try{yield this.fetchInitialLivestreamingState()}catch{m.error("Error: LivestreamController.fetchLivestream")}}))}}wo=new WeakMap,_o=new WeakMap,rr=new WeakMap;l2([w.trace("LivestreamController.setupEvents")],OE.prototype,"setupEvents",1);var u2=Object.defineProperty,h2=Object.getOwnPropertyDescriptor,_c=(t,e,n,i)=>{for(var r=i>1?void 0:i?h2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&u2(e,n,r),r},Gt,Gr,$r,Hh,DE;class Ma{constructor({name:e,socketHandler:n,meetingId:i}){S(this,Hh),y(this,"name",""),S(this,Gt,{}),S(this,Gr,""),S(this,$r,void 0),y(this,"rateLimitConfig",{maxInvocations:5,period:1}),y(this,"bulkRateLimitConfig",{maxInvocations:5,period:1}),y(this,"listeners",{}),this.name=e,T(this,$r,n),T(this,Gr,i)}set(e,n,i=!0,r=!1){return p(this,null,function*(){o(this,Gt)[e]=n,i&&this.remoteSet(e,n),r&&(this.listeners[e]&&this.listeners[e].forEach(s=>s({[e]:o(this,Gt)[e]})),this.listeners["*"]&&this.listeners["*"].forEach(s=>s({[e]:o(this,Gt)[e]})))})}remoteSet(e,n){o(this,$r).storeInsertKeys(o(this,Gr),this.name,[{key:e,payload:n}])}bulkSet(e){return p(this,null,function*(){e.forEach(({key:n,payload:i})=>{o(this,Gt)[n]=i}),o(this,$r).storeInsertKeys(o(this,Gr),this.name,e)})}update(e,n,i=!0){return p(this,null,function*(){Q(this,Hh,DE).call(this,e,n,i)})}delete(e,n=!0,i=!1){return p(this,null,function*(){if(o(this,Gt)[e]&&delete o(this,Gt)[e],n)return o(this,$r).storeDeleteKeys(o(this,Gr),this.name,[{key:e}]);i&&(this.listeners[e]&&(this.listeners[e].forEach(r=>r({[e]:void 0})),delete this.listeners[e]),this.listeners["*"]&&this.listeners["*"].forEach(r=>r({[e]:void 0})))})}bulkDelete(e){return p(this,null,function*(){return e.forEach(({key:n})=>{o(this,Gt)[n]&&delete o(this,Gt)[n]}),o(this,$r).storeDeleteKeys(o(this,Gr),this.name,e)})}get(e){if(o(this,Gt)[e])return o(this,Gt)[e]}getAll(){return o(this,Gt)}get rateLimits(){return this.rateLimitConfig}updateRateLimits(e,n){this.rateLimitConfig.maxInvocations=e,this.rateLimitConfig.period=n}get bulkRateLimits(){return this.bulkRateLimitConfig}updateBulkRateLimits(e,n){this.bulkRateLimitConfig.maxInvocations=e,this.bulkRateLimitConfig.period=n}subscribe(e,n){if(this.listeners[e]){this.listeners[e].push(n);return}this.listeners[e]=[n]}unsubscribe(e,n){var i;if(n){this.listeners[e]=((i=this.listeners[e])==null?void 0:i.filter(r=>r!==n))||[];return}this.listeners[e]&&delete this.listeners[e]}populate(e){T(this,Gt,e)}}Gt=new WeakMap,Gr=new WeakMap,$r=new WeakMap,Hh=new WeakSet,DE=function(t,e,n=!0){let i;const r=o(this,Gt)[t],s=Object.prototype.toString.call(e),a=Object.prototype.toString.call(r);if(s!==a){this.set(t,e);return}switch(a){case"[object Array]":i=[...r,...e];break;case"[object Object]":i=H(H({},r),e);break;case"[object Map]":i=new Map([...r,...e]);break;case"[object Set]":i=new Set([...r,...e]);break;default:i=e;break}this.set(t,i,n)};_c([on(Aa,"rateLimitConfig")],Ma.prototype,"remoteSet",1);_c([on(Aa,"bulkRateLimitConfig")],Ma.prototype,"bulkSet",1);_c([on(Aa,"rateLimitConfig")],Ma.prototype,"update",1);_c([on(Aa,"rateLimitConfig")],Ma.prototype,"delete",1);_c([on(Aa,"bulkRateLimitConfig")],Ma.prototype,"bulkDelete",1);var ua,ha,Id,qu,ml,as,qh,NE;class p2{constructor(e,n){S(this,Id),S(this,qh),y(this,"stores",new Map),S(this,ua,void 0),S(this,ha,""),S(this,ml,void 0),S(this,as,new Map),T(this,ua,n),T(this,ha,e.getValue("meetingId")),T(this,ml,e),Q(this,qh,NE).call(this)}create(e){const n=new Ma({name:e,socketHandler:o(this,ua),meetingId:o(this,ha)});return o(this,ua).storeGetKeys(o(this,ha),e,[]),new Promise((i,r)=>{const s=setTimeout(()=>r(Error("Failed")),3e3);o(this,as).set(e,{rejectTimeout:s,resolve:i,store:n})})}}ua=new WeakMap,ha=new WeakMap,Id=new WeakSet,qu=function(){return o(this,ml).getValue("peerId")},ml=new WeakMap,as=new WeakMap,qh=new WeakSet,NE=function(){[ie.storeInsertKeys,ie.storeGetKeys,ie.storeDeleteKeys].forEach(t=>{o(this,ua).on(t,e=>p(this,null,function*(){var n,i;if(e.pluginId!==o(this,ha))return;const r=(n=e.storeItems)==null?void 0:n.map(a=>{var c;return{timestamp:a.timestamp,peerId:a.peerId,payload:JSON.parse((c=a.payload)!=null&&c.length?new TextDecoder().decode(a.payload):"{}"),key:a.storeKey}});if(t===ie.storeGetKeys){const a=o(this,as).get(e.storeName),c=this.stores.get(e.storeName)||(a==null?void 0:a.store);o(this,as).get(e.storeName)&&(this.stores.set(e.storeName,a.store),a.resolve(c),clearTimeout(a.rejectTimeout),o(this,as).delete(e.storeName)),r.forEach(d=>{c.set(d.key,d.payload,!1,!1)});return}const s=this.stores.get(e.storeName)||((i=o(this,as).get(e.storeName))==null?void 0:i.store);s!==void 0&&(t===ie.storeInsertKeys&&r.forEach(({key:a,peerId:c,payload:d})=>{c!==o(this,Id,qu)&&s.set(a,d,!1,!0)}),t===ie.storeDeleteKeys&&r.forEach(({key:a,peerId:c})=>{c!==o(this,Id,qu)&&s.delete(a,!1,!0)}))}))})};function os(t){var e,n,i,r,s,a,c,d,h,u,g,E,b;return t?{media:{audio:{enabled:t.audioEnabled,trackId:(e=t.audioTrack)==null?void 0:e.id,permission:"mediaPermissions"in t?(n=t.mediaPermissions)==null?void 0:n.audio:null},video:{enabled:t.videoEnabled,trackId:(i=t.videoTrack)==null?void 0:i.id,permission:"mediaPermissions"in t?(r=t.mediaPermissions)==null?void 0:r.video:null},screenshare:{enabled:t.screenShareEnabled,permission:"mediaPermissions"in t?(s=t.mediaPermissions)==null?void 0:s.screenshare:null,audio:{enabled:(c=(a=t.screenShareTracks)==null?void 0:a.audio)==null?void 0:c.enabled,trackId:(h=(d=t.screenShareTracks)==null?void 0:d.audio)==null?void 0:h.id},video:{enabled:(g=(u=t.screenShareTracks)==null?void 0:u.video)==null?void 0:g.enabled,trackId:(b=(E=t.screenShareTracks)==null?void 0:E.video)==null?void 0:b.id}}}}:{}}var m2=Object.defineProperty,f2=Object.getOwnPropertyDescriptor,Oa=(t,e,n,i)=>{for(var r=i>1?void 0:i?f2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&m2(e,n,r),r};const g2=.8,v2=1.2;var Qa,Xa,xr,Us,Za,Bs,eo,Gu,Bg,Gi,Qc,Vr,to,Xc,$i,$u,Zc,Ju,Fg;let Mi=(Fg=class extends gn{constructor(t,e,n,i){super(),S(this,Us),S(this,Bs),S(this,Gu),S(this,to),S(this,Zc),y(this,"id"),y(this,"userId"),y(this,"name"),y(this,"picture"),y(this,"isHost"),y(this,"customParticipantId"),y(this,"flags"),y(this,"device"),y(this,"videoTrack"),y(this,"audioTrack"),y(this,"screenShareTracks"),y(this,"videoEnabled"),y(this,"audioEnabled"),y(this,"screenShareEnabled"),y(this,"producers"),y(this,"manualProducerConfig"),S(this,Qa,void 0),y(this,"supportsRemoteControl",!1),S(this,Xa,void 0),y(this,"presetName"),S(this,xr,void 0),S(this,Gi,void 0),S(this,Qc,void 0),S(this,Vr,new Map),S(this,$i,1),S(this,$u,cl(O=>{if(!this.videoTrack)return;const{clientWidth:$,clientHeight:me}=O,{width:Ie,height:fe}=this.videoTrack.getSettings();if(!Ie||!fe)return;const Je=fe/me,ht=Ie/$,V=Math.max(Je,ht);V>v2&&o(this,$i)===1?(T(this,$i,0),L.emit(x.MAX_SPATIAL_LAYER_CHANGE,{peerId:this.id,maxSpatialLayer:o(this,$i)})):V<g2&&o(this,$i)===0&&(T(this,$i,1),L.emit(x.MAX_SPATIAL_LAYER_CHANGE,{peerId:this.id,maxSpatialLayer:o(this,$i)}))},2e3)),T(this,xr,t);const{id:r,userId:s,displayName:a,device:c,picture:d,isHost:h,flags:u,clientSpecificId:g,stageStatus:E,customParticipantId:b,audioMuted:k,audioTrack:A,videoEnabled:M=!1,videoTrack:B,producers:K,metadata:X}=e;this.id=r,this.userId=s,this.name=a,this.device=c,this.picture=d,this.isHost=h,this.flags=u,this.manualProducerConfig=eP,T(this,Xa,E!=null?E:"ON_STAGE"),this.customParticipantId=b!=null?b:g,this.audioEnabled=!k,this.audioTrack=A,this.videoEnabled=M,this.videoTrack=B,this.screenShareTracks={audio:void 0,video:void 0},this.producers=K!=null?K:[],this.presetName=X==null?void 0:X.preset_name,T(this,Qa,!1),T(this,Gi,n),T(this,Qc,i),this.setupEvents(),this.updateVideo=this.updateVideo.bind(this),Q(this,Zc,Ju).call(this)}get clientSpecificId(){return this.customParticipantId}get stageStatus(){return o(this,Xa)}setVideoEnabled(t,e=!0){this.videoEnabled=t,e&&(m.info("DyteParticipant::setVideoEnabled::videoUpdate",H({},os(this))),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}))}setAudioEnabled(t,e=!0){this.audioEnabled=t,e&&(m.info("DyteParticipant::setAudioEnabled::audioUpdate",H({},os(this))),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack}))}setScreenShareEnabled(t,e=!0){this.screenShareEnabled=t,e&&this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})}setupEvents(){this.on("videoUpdate",Q(this,Zc,Ju))}pin(){return p(this,null,function*(){if(!o(this,Bs,eo))throw new D("Can`t pin participant without joining room","1205");if(!o(this,Gi).permissions.pinParticipant)throw new D("You do not have permission to pin participants.","1201");return o(this,Us,Za).pinPeer(this.id)})}unpin(){return p(this,null,function*(){if(!o(this,Bs,eo))throw new D("Can`t unpin participant without joining room","1205");if(!o(this,Gi).permissions.pinParticipant)throw new D("You do not have permission to unpin participants.","1201");return o(this,Us,Za).pinPeer(null)})}setIsPinned(t,e=!0){var n;T(this,Qa,t);const i=t?"pinned":"unpinned";(n=o(this,to,Xc))==null||n.updateSource(this.id,{pinned:t}),e&&this.emit(i,this)}disableAudio(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::disable_audio",{dyteParticipant:{id:t}}),!o(this,Bs,eo))throw new D("Can`t disable participant audio without joining room","1205");if(o(this,Gi).permissions.canDisableParticipantAudio)return o(this,Us,Za).disableAudio(t);throw m.error("DyteParticipant::unauthorized_disable_audio",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to disable participant audio.","1201")})}kick(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::kick",{dyteParticipant:{id:t}}),!o(this,Gu,Bg))throw new D("Can`t kick participant without joining room","1205");if(o(this,Gi).permissions.kickParticipant){yield L.emitAsync(x.KICK_PEER,{peerId:t});return}throw m.error("DyteParticipant::unauthorized_kick",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to kick participants.","1201")})}disableVideo(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::disable_video",{dyteParticipant:{id:t}}),!o(this,Bs,eo))throw new D("Can`t disable participant video without joining room","1205");if(o(this,Gi).permissions.canDisableParticipantVideo)return o(this,Us,Za).disableVideo(t);throw m.error("DyteParticipant::unauthorized_disable_video",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to disable participant video.","1201")})}getPermissions(){return p(this,null,function*(){return o(this,Qc).getUserPermissions(this.userId)})}setStageStatus(t){T(this,Xa,t),this.emit("stageStatusUpdate",this)}get isPinned(){return o(this,Qa)}registerVideoElement(t){var e,n,i,r;let s;(n=(e=o(this,Vr).get(t))==null?void 0:e.observer)==null||n.disconnect(),"ResizeObserver"in window&&(s=new ResizeObserver(()=>o(this,$u).call(this,t)),s.observe(t)),o(this,Vr).set(t,{observer:s}),this.updateVideo(t),(r=o(this,to,Xc))==null||r.addSource(this.id,t,this.videoEnabled,this.isPinned,this.name,this.picture,(i=this.raised)!=null?i:!1)}deregisterVideoElement(t){var e,n,i;t.srcObject=void 0,(n=(e=o(this,Vr).get(t))==null?void 0:e.observer)==null||n.disconnect(),o(this,Vr).delete(t),(i=o(this,to,Xc))==null||i.removeSource(this.id)}updateVideo(t){var e;if(this.videoEnabled){if(this.videoTrack==null)return;const n=(e=t.srcObject)==null?void 0:e.getTracks()[0];if((n==null?void 0:n.id)===this.videoTrack.id)return;const i=new MediaStream;i.addTrack(this.videoTrack),t.srcObject=i}else t.srcObject=void 0;t.style.display=this.videoEnabled?"block":"none"}},Qa=new WeakMap,Xa=new WeakMap,xr=new WeakMap,Us=new WeakSet,Za=function(){return o(this,xr).getValue("roomNodeClient")},Bs=new WeakSet,eo=function(){return o(this,xr).getValue("connectionHandler").mediaJoined},Gu=new WeakSet,Bg=function(){return o(this,xr).getValue("connectionHandler").socketJoined},Gi=new WeakMap,Qc=new WeakMap,Vr=new WeakMap,to=new WeakSet,Xc=function(){return o(this,xr).getValue("pip")},$i=new WeakMap,$u=new WeakMap,Zc=new WeakSet,Ju=function(){Array.from(o(this,Vr).keys()).forEach(this.updateVideo)},Fg);Oa([w.trace("DyteParticipant.disableAudio")],Mi.prototype,"disableAudio",1);Oa([w.trace("DyteParticipant.kick")],Mi.prototype,"kick",1);Oa([w.trace("DyteParticipant.disableVideo")],Mi.prototype,"disableVideo",1);Oa([w.trace("DyteParticipant.getPermissions")],Mi.prototype,"getPermissions",1);Oa([w.trace("DyteParticipant.setStageStatus")],Mi.prototype,"setStageStatus",1);Mi=Oa([Lt("1200")],Mi);class no extends _E{constructor(e){const{onAddEvent:n="participantJoined",onDeleteEvent:i="participantLeft",onClearEvent:r="participantsCleared"}=e!=null?e:{};super({onAddEvent:n,onDeleteEvent:i,onClearEvent:r})}add(e,n=!0){return this.has(e.id)&&Object.is(this.get(e.id),e)===!1&&this.delete(e.id),super.add(e,n)}clear(e=!0,n=!1){return super.clear(e,n)}delete(e,n=!0,i=!1){return super.delete(e,n,i)}}var Jr;class y2 extends Ra{constructor(){super(),S(this,Jr,void 0),T(this,Jr,new Map)}__set(e,n){return o(this,Jr).set(e,n)}__clear(){return o(this,Jr).clear()}get(e){return o(this,Jr).get(e)}toArray(){return Array.from(o(this,Jr).values())}}Jr=new WeakMap;class E2{constructor(){y(this,"_orderedArray"),y(this,"_map"),this._map=new Map,this._orderedArray=[]}add(e,n){if(!this._map.has(e))return this._map.set(e,{peerId:e,priority:n}),this._orderedArray.splice(Math.max(n-1,0),0,e),this.index(e);const i=this.index(e);this.delete(e);const r=this.add(e,n);return i!==r?r:-1}delete(e){if(this._map.has(e)){const n=this.index(e);this._map.delete(e),this._orderedArray.splice(n,1)}}index(e){return this._map.has(e)?this._orderedArray.indexOf(e):-1}[Symbol.iterator](){return this._orderedArray[Symbol.iterator]()}}class S2{constructor(){y(this,"_activeSpeakerPeers"),y(this,"_compulsoryPeers"),this._activeSpeakerPeers=new E2,this._compulsoryPeers=new Set}add(e,n){if(!e)return-1;if(n<0)return this._compulsoryPeers.add(e),0;if(this.compulsoryPeers.includes(e)&&(n>0||n===246267631)){if(m.info("DyteSelectedPeer::removing_compulsory_peer",{selectedPeer:{peerId:e}}),this._removeFromCompulsoryPeer(e),n===246267631)return-1}else if(n===229490415)return this.delete(e),-1;return this._activeSpeakerPeers.add(e,n)}delete(e){m.info("DyteSelectedPeer::deleting_peer_from_selectedPeer",{selectedPeer:{peerId:e}}),this._removeFromCompulsoryPeer(e),this._activeSpeakerPeers.delete(e)}index(e){return this._activeSpeakerPeers.index(e)}get peers(){return Array.from(new Set(this.compulsoryPeers.concat(this.activeSpeakerPeers)))}get compulsoryPeers(){return Array.from(this._compulsoryPeers.values())}get activeSpeakerPeers(){return Array.from(this._activeSpeakerPeers)}_removeFromCompulsoryPeer(e){this._compulsoryPeers.delete(e)}}const LE=new S2;var T2=Object.defineProperty,b2=Object.getOwnPropertyDescriptor,En=(t,e,n,i)=>{for(var r=i>1?void 0:i?b2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&T2(e,n,r),r};const k2=["ACTIVE_GRID","PAGINATED","MANUAL"];var On,Fs,io,js,ro,so,ed,Ws,dn,jg;let Xt=(jg=class extends gn{constructor(t,e,n){super(),S(this,Fs),S(this,js),S(this,so),y(this,"waitlisted"),y(this,"joined"),y(this,"active"),y(this,"videoSubscribed"),y(this,"audioSubscribed"),y(this,"pinned"),y(this,"all"),S(this,On,void 0),S(this,Ws,void 0),S(this,dn,void 0),y(this,"rateLimitConfig",{maxInvocations:5,period:1}),y(this,"viewMode"),y(this,"currentPage"),y(this,"lastActiveSpeaker"),y(this,"selectedPeers",LE),T(this,On,t),T(this,Ws,e),T(this,dn,n),this.waitlisted=new no,this.joined=new no,this.videoSubscribed=new no,this.audioSubscribed=new no,this.active=this.videoSubscribed,this.pinned=new no,this.all=new y2,this.viewMode="ACTIVE_GRID",this.currentPage=0,this.setupEvents()}get pip(){return o(this,On).getValue("pip")}get rateLimits(){return this.rateLimitConfig}updateRateLimits(t,e){this.rateLimitConfig.maxInvocations=t,this.rateLimitConfig.period=e}setupEvents(){L.on(x.E2EE_ACTIVE_CONSUMER,({peerId:t})=>{var e;((e=o(this,On).getValue("modules").e2ee)==null?void 0:e.enabled)!==!0&&this.emit("media_decode_error",{reason:`Got encrypted media for participantId ${t}, but encryption wasn't enabled in init.defaults`,code:"1702"})})}get count(){return this.joined.size}get maxActiveParticipantsCount(){var t;return(t=o(this,On))==null?void 0:t.getValue("maxPreferredStreams")}setMaxActiveParticipantsCount(t){if(t<0||t>24)throw new D("0 <= Max active participants count limit <= 24","1203");o(this,On).setValue("maxPreferredStreams",t),o(this,so,ed)&&L.emit(x.UPDATE_ACTIVE)}get pageCount(){if(this.viewMode==="PAGINATED"){const t=this.selectedPeers.compulsoryPeers.length,e=this.joined.toArray().filter(n=>n.stageStatus==="ON_STAGE");return Math.ceil((e.length-t)/Math.max(this.maxActiveParticipantsCount-t,1))}return 0}acceptWaitingRoomRequest(t){var e,n;if(!o(this,js,ro))throw new D("Can`t accept waiting room request without joining room","1205");const i=(n=(e=this.waitlisted.get(t))==null?void 0:e.userId)!=null?n:t;return o(this,dn).acceptWaitingRoomRequest([i])}acceptAllWaitingRoomRequest(t){return p(this,null,function*(){const e=t.map(n=>{var i,r;return(r=(i=this.waitlisted.get(n))==null?void 0:i.userId)!=null?r:n});return o(this,dn).acceptWaitingRoomRequest(e)})}rejectWaitingRoomRequest(t){return p(this,null,function*(){var e,n;if(!o(this,js,ro))throw new D("Can`t reject waiting room request without joining room","1205");const i=(n=(e=this.waitlisted.get(t))==null?void 0:e.userId)!=null?n:t;o(this,dn).rejectWaitingRoomRequest([i])})}setViewMode(t){return p(this,null,function*(){if(m.info("DyteParticipants::set_view_mode",{pageNavigation:{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),!(e=>k2.includes(e))(t))throw m.error("DyteParticipants::setViewMode::invalid_view_mode",{pageNavigation:{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),new D(`Invalid view mode: ${t}. Try ACTIVE_GRID, PAGINATED or MANUAL.`,"1207");if(this.viewMode===t){m.info("DyteParticipants::setViewMode::view_mode_same_as_previous");return}if(t==="MANUAL")throw new D("Manual Subscription is not enabled for your Organization. Please contact support.","1208");this.viewMode=t,t==="PAGINATED"?(this.currentPage=1,L.emit(x.UPDATE_ACTIVE,{page:this.currentPage})):t==="ACTIVE_GRID"&&(this.currentPage=0,L.emit(x.UPDATE_ACTIVE)),this.emit("viewModeChanged",{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount})})}subscribe(t){return p(this,arguments,function*(e,n=["audio","video","screenshareAudio","screenshareVideo"]){if(this.viewMode!=="MANUAL")throw new D("MANUAL subscription mode was not activated.","1206");const i=[];e.forEach(r=>{const s=this.joined.get(r);if(s){if(n.includes("audio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{audio:!0}),this.videoSubscribed.add(s);const a=s.producers.find(c=>c.kind==="audio"&&!c.screenShare);a&&i.push(a)}if(n.includes("video")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{video:!0}),this.audioSubscribed.add(s);const a=s.producers.find(c=>c.kind==="video"&&!c.screenShare);a&&i.push(a)}if(n.includes("screenshareAudio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareAudio:!0});const a=s.producers.find(c=>c.kind==="audio"&&c.screenShare);i.push(a)}if(n.includes("screenshareVideo")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareVideo:!0});const a=s.producers.find(c=>c.kind==="video"&&c.screenShare);i.push(a)}}}),yield o(this,Fs,io).createConsumers(i)})}unsubscribe(t){return p(this,arguments,function*(e,n=["audio","video","screenshareAudio","screenshareVideo"]){if(this.viewMode!=="MANUAL")throw new D("MANUAL subscription mode was not activated.","1206");const i=[];e.forEach(r=>{const s=this.joined.get(r);if(s){if(n.includes("audio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{audio:!1});const a=s.producers.find(c=>c.kind==="audio"&&!c.screenShare);a&&i.push(a)}if(n.includes("video")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{video:!1});const a=s.producers.find(c=>c.kind==="video"&&!c.screenShare);a&&i.push(a)}if(n.includes("screenshareAudio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareAudio:!1});const a=s.producers.find(c=>c.kind==="audio"&&c.screenShare);i.push(a)}if(n.includes("screenshareVideo")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareVideo:!1});const a=s.producers.find(c=>c.kind==="video"&&c.screenShare);i.push(a)}}}),yield o(this,Fs,io).closeConsumers(i)})}getPeerIdsForCurrentPage(){m.info("DyteParticipants::getPeerIdsForCurrentPage()",{pageNavigation:{viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}});const{compulsoryPeers:t}=this.selectedPeers,e=t.filter(a=>this.joined.has(a)),n=Array.from(this.pinned.keys()).filter(a=>!e.includes(a)),i=Array.from(this.joined.toArray().filter(a=>a.stageStatus==="ON_STAGE").map(a=>a.id)),r=Math.max((this.currentPage-1)*(this.maxActiveParticipantsCount-e.length-n.length)),s=this.currentPage*(this.maxActiveParticipantsCount-e.length-n.length);return e.concat(n,i.slice(r,s))}setPage(t){return p(this,null,function*(){if(m.info("DyteParticipants::set_page",{pageNavigation:{settingPage:t,viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),this.viewMode==="PAGINATED"){if(!Number.isInteger(t))throw m.error("DyteParticipants::invalid_page_number"),new D(`Invalid page: ${t}. Page must be an integer and greater than 0 and less than or equal to .pageCount`,"1202");this.currentPage=t,L.emit(x.UPDATE_ACTIVE,{page:t}),this.emit("pageChanged",{viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount})}})}disableAllAudio(t){return p(this,null,function*(){if(m.info("DyteParticipants::disable_all_audio",{actions:{disableAllAudio:{allowUnmute:t}}}),!o(this,so,ed))throw new D("Can`t disable all audio without joining room","1205");if(o(this,Ws).permissions.canAllowParticipantAudio)return o(this,Fs,io).muteAll(t);throw m.error("DyteParticipants::unauthorized_disable_all_audio",{actions:{disableAllAudio:{allowUnmute:t}}}),new D("Unauthorized: User does not have permission to disable peer audio.","1201")})}disableAllVideo(){return p(this,null,function*(){if(m.info("DyteParticipants::disable_all_video"),!o(this,so,ed))throw new D("Can`t disable all video without joining room","1205");if(o(this,Ws).permissions.canAllowParticipantVideo)return o(this,Fs,io).muteAllVideo();throw m.error("DyteParticipants::unauthorized_disable_all_video"),new D("Unauthorized: User does not have permission to disable peer video.","1201")})}disableAudio(t){return p(this,null,function*(){this.joined.get(t).disableAudio()})}disableVideo(t){return p(this,null,function*(){this.joined.get(t).disableVideo()})}kick(t){return p(this,null,function*(){yield L.emitAsync(x.KICK_PEER,{peerId:t})})}kickAll(){return p(this,null,function*(){if(m.info("DyteParticipants::kick_all"),o(this,On).getValue("viewType")!=="LIVESTREAM"&&!o(this,js,ro))throw new D("Can`t kick all without joining room","1205");if(!o(this,Ws).permissions.kickParticipant)throw m.error("DyteParticipants::unauthorized_kick_all"),new D("Unauthorized: User does not have permission to kick peers.","1201");const t=se.hasFeature(ue.PROPAGATE_KICK_ALL);o(this,dn).kickAll(t)})}broadcastMessage(t,e,n){return p(this,null,function*(){if(m.info("DyteParticipants::broadcastMessage"),!o(this,js,ro))throw new D("Can`t broadcast message without joining room","1205");if(!(t!=null&&t.trim()))throw new D("`type` must be a non-empty string.","1209");if(n)if("meetingIds"in n)yield o(this,dn).broadcastToMeetings(t,n.meetingIds,e);else{let i=[];"participantIds"in n?i=n.participantIds:i=this.joined.toArray().filter(r=>{var s;return(s=n.presetNames)==null?void 0:s.includes(r.presetName)}).map(r=>r.id),yield o(this,dn).broadcastToPeers(t,i,e)}else yield o(this,dn).broadcastMessage(t,e)})}getAllJoinedPeers(t,e,n){return p(this,null,function*(){return(yield o(this,dn).getRoomPeers(t,e,n)).peers.map(Ni.formatSocketServiceMessage)})}updatePermissions(t,e){return p(this,null,function*(){const n=this.joined.toArray().filter(r=>t.includes(r.id)).map(r=>r.userId),i=[...new Set(n)];if(!i.length)throw new D("Cannot update permissions, no valid userIDs found","1204");o(this,dn).updatePermissions(i,e)})}getParticipantsInMeetingPreJoin(){return p(this,null,function*(){return o(this,dn).getRoomPeersNonPaginated()})}},On=new WeakMap,Fs=new WeakSet,io=function(){return o(this,On).getValue("roomNodeClient")},js=new WeakSet,ro=function(){var t;return((t=o(this,On).getValue("connectionHandler"))==null?void 0:t.socketJoined)===!0},so=new WeakSet,ed=function(){var t;return((t=o(this,On).getValue("connectionHandler"))==null?void 0:t.mediaJoined)===!0},Ws=new WeakMap,dn=new WeakMap,jg);En([w.trace("DyteParticipants.setViewMode")],Xt.prototype,"setViewMode",1);En([w.trace("DyteParticipants.setPage")],Xt.prototype,"setPage",1);En([w.trace("DyteParticipants.disableAllAudio")],Xt.prototype,"disableAllAudio",1);En([w.trace("DyteParticipants.disableAllVideo")],Xt.prototype,"disableAllVideo",1);En([w.trace("DyteParticipants.disablePeerAudio")],Xt.prototype,"disableAudio",1);En([w.trace("DyteParticipants.disablePeerVideo")],Xt.prototype,"disableVideo",1);En([w.trace("DyteParticipants.kickPeer")],Xt.prototype,"kick",1);En([w.trace("DyteParticipants.kickAll")],Xt.prototype,"kickAll",1);En([w.trace("DyteParticipants.broadcastMessage"),on(Aa,"rateLimitConfig")],Xt.prototype,"broadcastMessage",1);En([w.trace("DyteParticipants.getAllJoinedPeers"),on({maxInvocations:10,period:60})],Xt.prototype,"getAllJoinedPeers",1);En([w.trace("DyteParticipant.updatePermissions"),on({maxInvocations:1e3,period:60})],Xt.prototype,"updatePermissions",1);En([w.trace("DyteParticipants.getParticipantsInMeetingPreJoin")],Xt.prototype,"getParticipantsInMeetingPreJoin",1);Xt=En([Lt("1200")],Xt);var wr=(t=>(t.NEW="new",t.CONNECTING="connecting",t.RECONNECTING="reconnecting",t.DISCONNECTED="disconnected",t.CONNECTED="connected",t.FAILED="failed",t.CLOSED="closed",t))(wr||{}),bt=(t=>(t[t.HIVE=1]="HIVE",t[t.ROOM_NODE=2]="ROOM_NODE",t[t.CF=3]="CF",t))(bt||{}),w2=Object.defineProperty,_2=Object.getOwnPropertyDescriptor,Ps=(t,e,n,i)=>{for(var r=i>1?void 0:i?_2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&w2(e,n,r),r};const xE=class{constructor(t,e,n,i){switch(y(this,"participants"),y(this,"self"),y(this,"selectedPeers",LE),y(this,"maxSpatialLayerUpdates",new Map),y(this,"consumerPeerMap"),y(this,"events"),y(this,"roomSocketHandler"),y(this,"context"),y(this,"videoPeerConsumerMap",new Map),y(this,"updateConsumerSpatialLayers",cl(()=>{const r={},s=new Map(this.maxSpatialLayerUpdates);this.maxSpatialLayerUpdates.clear(),Array.from(s.entries()).forEach(([a,c])=>{r[c]===void 0&&(r[c]={layer:c,consumerIds:[]}),r[c].consumerIds.push(a)}),Object.keys(r).forEach(a=>{const c=r[a];m.log(`Switching max spatial layer to ${c.layer}`,{consumerIds:c.consumerIds}),this.roomNodeClient.switchConsumersToLayer(c.consumerIds,c.layer)})},2e3)),y(this,"updateConsumers",(r,s)=>{let a=Promise.resolve();s.length>0&&(m.info("Closing consumers for producers",{producers:s}),a=this.roomNodeClient.closeConsumers(s)),a.then(()=>{r.length!==0&&(m.info("Consuming producers",{producers:r}),this.roomNodeClient.createConsumers(r).catch(c=>m.error("Error activating peers",{error:c})))}).catch(c=>m.error("Error deactivating peers",{error:c}))}),y(this,"updateConsumersDebounced",cl(this.updateConsumers,200,{trailing:!0})),this.context=t,this.roomSocketHandler=n,this.participants=new Xt(t,e,this.roomSocketHandler),this.self=e,this.consumerPeerMap=new Map,i){case bt.HIVE:{this.events=In;break}case bt.CF:{this.events=Hn;break}default:this.events=In}e.config.viewType!=="CHAT"&&this.setupEventsGlobal(),this.setupEvents()}get roomNodeClient(){return this.context.getValue("roomNodeClient")}get mediaJoined(){var t;return((t=this.roomNodeClient)==null?void 0:t.mediaJoined)===!0}get pip(){return this.context.getValue("pip")}setupEvents(){this.roomSocketHandler.on(Y.getWaitingRoomRequests,this.waitingRoomRequestHandler.bind(this)),L.on(x.SOCKET_PEERS,t=>p(this,null,function*(){const e=se.hasFeature(ue.DEBUG_SOCKET_JOIN);if(e){const n=t&&(t==null?void 0:t.length)<20?{peers:JSON.stringify(t.map(i=>i.peerId))}:void 0;m.info("Processing socket peers",n)}t==null||t.forEach(n=>{n.waitlisted||this.onParticipantJoined(this.fromSocketService(n))}),e&&m.info("Processed socket peers")})),this.roomSocketHandler.on(this.events.peerJoinedBroadcast,({participant:t})=>{se.hasFeature(ue.DEBUG_SOCKET_JOIN)&&m.info("events.peerJoinedBroadcast",{peers:t.peerId}),this.onMediaJoined(t.peerId,t.producerStates,t.capabilities)}),this.roomSocketHandler.on(this.events.selfJoinComplete,({participants:t,selectedPeers:e,roomState:n})=>{if(se.hasFeature(ue.DEBUG_SOCKET_JOIN)){const s=t&&(t==null?void 0:t.length)<20?{peers:JSON.stringify(t.map(a=>a.peerId))}:void 0;m.info("events.selfJoinComplete",s)}t.forEach(({peerId:s,producerStates:a,capabilities:c})=>this.onMediaJoined(s,a,c));const{audioPeers:i,compulsoryPeers:r}=e!=null?e:{};n.pinnedPeerIds.length!==0&&this.onParticipantPinned(n.pinnedPeerIds[0]),this.computeActivateParticipants(i!=null?i:[],r),L.emit(x.UPDATE_ACTIVE,{createAllConsumers:!0})}),L.on(x.MAX_SPATIAL_LAYER_CHANGE,({peerId:t,maxSpatialLayer:e})=>{const n=this.videoPeerConsumerMap.get(t);n&&(this.maxSpatialLayerUpdates.set(n,e),this.updateConsumerSpatialLayers())}),L.on(x.NEW_PRODUCER,({peerId:t,producer:e})=>{const n=this.participants.joined.get(t);if(!n){m.warn("ParticipantController::NEW_PRODUCER::participant not found",{producer:{id:e==null?void 0:e.producerId,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}},dyteParticipant:{id:t}});return}if(n.producers.push(e),m.info("ParticipantController::NEW_PRODUCER::producer_added_to_participant",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}}),this.participants.viewMode==="MANUAL"){let i=!1;const r=e.kind==="audio",s=e.kind==="video",a=n.manualProducerConfig;(r&&(a.audio&&!e.screenShare||a.screenshareAudio&&e.screenShare)||s&&(a.video&&!e.screenShare||a.screenshareVideo&&e.screenShare))&&(i=!0),i?this.roomNodeClient.createConsumers([e]):m.info("ParticipantController::NEW_PRODUCER::not_consuming_producer",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}});return}(e==null?void 0:e.kind)==="audio"&&this.participants.audioSubscribed.get(t)||(e==null?void 0:e.kind)==="video"&&this.participants.videoSubscribed.get(t)||e!=null&&e.screenShare?this.roomNodeClient.createConsumers([e]).catch(i=>{m.error("ParticipantController::createConsumer failed",{error:i})}):m.info("ParticipantController::NEW_PRODUCER::not_consuming_producer",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}})}),L.on(x.PRODUCER_CLOSED,({peerId:t,producerId:e})=>{const n=this.participants.joined.get(t);if(!n){m.warn("ParticipantController::NEW_PRODUCER::participant not found",{dyteParticipant:{id:t}});return}n.producers=n.producers.filter(i=>i.producerId!==e)}),L.on(x.PRODUCER_TOGGLE,({peerId:t,producerId:e,paused:n,kind:i})=>{const r=this.participants.joined.get(t);if(r){i==="audio"&&r.setAudioEnabled(!n);const s=r.producers.find(a=>a.producerId===e);s&&(s.pause=n)}}),this.roomSocketHandler.on(this.events.globalPeerPinBroadcast,t=>{let e;if(t&&(e=t.participantId),!this.mediaJoined)return;const n=e;this.onParticipantPinned(n);const i=this.participants.joined.get(n);i&&this.roomNodeClient.activatePeers(i.producers).catch(r=>{m.error("unable to create consumers",{error:r})})}),this.roomSocketHandler.on(this.events.selectedPeer,({audioPeers:t,compulsoryPeers:e})=>{this.mediaJoined&&this.onSelectedPeers(e.concat(t))}),this.roomSocketHandler.on(this.events.selectedPeerDiff,({entries:t})=>{if(!this.mediaJoined)return;const e=t.map(n=>({peerId:n.peerId,priority:n.priority}));this.updateActiveParticipantsWithPriorities(e,!0)})}waitingRoomRequestHandler(t){const e=t.requests.filter(i=>!this.participants.waitlisted.toArray().find(r=>r.userId===i.userId)),n=this.participants.waitlisted.toArray().filter(i=>!t.requests.find(r=>r.userId===i.userId));e.forEach(i=>this.participants.waitlisted.add(new Mi(this.context,{id:i.peerId,displayName:i.displayName,audioMuted:!0,videoEnabled:!1,audioTrack:void 0,videoTrack:void 0,stageStatus:"OFF_STAGE",userId:i.userId,flags:{},isHost:!1,customParticipantId:i.customParticipantId,picture:i.picture,metadata:{preset_name:i.presetName}},this.self,this.roomSocketHandler))),n.forEach(i=>this.participants.waitlisted.delete(i.id))}get maxPreferredStreams(){return this.participants.maxActiveParticipantsCount}selectPagePeers(t){return p(this,null,function*(){const{compulsoryPeers:e}=this.selectedPeers,n=e.filter(c=>this.participants.joined.has(c)),i=Array.from(this.participants.pinned.keys()).filter(c=>!n.includes(c)),r=Array.from(this.participants.joined.toArray().filter(c=>c.stageStatus==="ON_STAGE").map(c=>c.id)),s=Math.max((t-1)*(this.maxPreferredStreams-n.length-i.length)),a=t*(this.maxPreferredStreams-n.length-i.length);return n.concat(i,r.slice(s,a))})}selectActivePeers(){const t=new Map,e=Array.from(this.participants.joined.toArray().filter(h=>h.stageStatus==="ON_STAGE").map(h=>(t.set(h.id,!0),h.id))),n=this.selectedPeers.peers,i=this.participants.pinned.toArray().reduce((h,u)=>(u.stageStatus!=="ON_STAGE"?this.participants.pinned.delete(u.id):h.push(u.id),h),[]),r=this.self.stageStatus==="ON_STAGE"?1:0,s=this.participants.maxActiveParticipantsCount-r,a=new Set(n.concat(i).filter(h=>h!==this.self.id&&t.has(h)));let c=Array.from(a);const d=s-a.size;if(d>=0){const h=e.filter(u=>!a.has(u)&&u!==this.self.id).slice(0,d);c=Array.from(a).concat(h)}else c=c.slice(0,s);return c}updateActive(t,e){return p(this,null,function*(){const{page:n,createAllConsumers:i}=e!=null?e:{};let{strategies:r}=e!=null?e:{},s,a;switch(t){case"PAGINATED":{if(!n)return;s=yield this.selectPagePeers(n),m.debug("ParticipantController::updateActive::updating_current_page_peers",{peerIds:s}),r!=null||(r={video:this.updateParticipantsMap.bind(this)}),a=this.updateConsumersDebounced;break}case"ACTIVE_GRID":{s=this.selectActivePeers(),m.debug("ParticipantController::updateActive::updating_current_selected_peers",{peerIds:s}),r!=null||(r={video:this.updateParticipantsMapMinReplacement.bind(this),audio:this.updateParticipantsMap.bind(this)}),a=this.updateConsumers;break}default:throw new Error(`View mode ${t} not supported`)}let c,d;const h=this.updateGrid(s,r);i?(c=this.mapPeerIdsToProducers(s,["audio","video","screenshare"]),d=[]):(c=[...this.mapPeerIdsToProducers([...h.video.add],["video"]),...this.mapPeerIdsToProducers([...h.audio.add],["audio"])],d=[...this.mapPeerIdsToProducers([...h.video.remove],["video"]),...this.mapPeerIdsToProducers([...h.audio.remove],["audio"])]),!(c.length===0&&d.length===0)&&a(c,d)})}computeActivateParticipants(t,e){const n=t.map((r,s)=>({peerId:r,priority:s+1})),i=e==null?void 0:e.map((r,s)=>({peerId:r,priority:-(s+1)}));n.push(...i!=null?i:[]),n.length>0&&this.updateActiveParticipantsWithPriorities(n)}fromSocketService(t){const e=xE.formatSocketServiceMessage(t);return new Mi(this.context,ee(H({},e),{isHost:!1,videoEnabled:!1,audioMuted:!0,videoTrack:void 0,audioTrack:void 0}),this.self,this.roomSocketHandler)}updatePipSource(t,e){var n,i;e?(n=this.pip)==null||n.enableSource(t):(i=this.pip)==null||i.disableSource(t)}onMediaJoined(t,e,n){if(!this.mediaJoined||t===this.self.id)return;const i=this.participants.joined.get(t);if(!i){m.warn(`Received media.peerJoinedBroadcast for non-existent peer ${t}`);return}e.forEach(r=>{r.kind===di.AUDIO&&!r.screenShare?i.setAudioEnabled(!r.pause):r.kind===di.VIDEO&&!r.screenShare&&(i.setVideoEnabled(!r.pause),this.updatePipSource(i.id,!r.pause)),i.producers.push(ee(H({},r),{producingTransportId:r.producingTransportId,kind:r.kind===di.AUDIO?"audio":"video",producingPeerId:t,mimeType:r.mimeType}))}),this.roomNodeClient.handlePeerCapabilities(t,n),se.hasFeature(ue.FORCE_VIDEO_CODEC)||this.roomNodeClient.shareWebcam(this.self.videoTrack)}updateParticipantsMapMinReplacement(t,e){const n=Array.from(t.keys()),i=new Map(t),r=[],s=[],a=new Set(e),c=[];return n.forEach((d,h)=>{(!a.has(d)||!this.participants.joined.get(d))&&c.push(h)}),e.forEach(d=>{if(t.get(d))return;if(n.length<e.length){n.push(d),r.push(d);return}const h=c.shift();s.push(n[h]),n[h]=d,r.push(n[h])}),n.forEach((d,h)=>{a.has(d)||s.concat(n.splice(h,1))}),Array.from(t.keys()).forEach(d=>{t.delete(d,!a.has(d))}),n.forEach(d=>{if(!this.participants.joined.get(d)){m.warn("updateActiveParticipants::participant_not_in_joined_list",{dyteParticipant:{id:d}});return}t.add(this.participants.joined.get(d),!i.get(d))}),t.emit("participantsUpdate"),[r,s]}updateParticipantsMap(t,e){const n=Array.from(t.keys()),i=[],r=[];return n.forEach(s=>{e.includes(s)||(t.delete(s,!0),r.push(s))}),e.forEach(s=>{t.get(s)||(t.add(this.participants.joined.get(s)),i.push(s))}),t.emit("participantsUpdate"),[i,r]}updatePinnedParticipants(){this.participants.pinned.forEach(t=>{t.setIsPinned(!1),this.participants.pinned.delete(t.id)})}setupEventsGlobal(){this.roomSocketHandler.on(Y.joinRoom,({peer:t})=>{if(!t.waitlisted){const e=se.hasFeature(ue.DEBUG_SOCKET_JOIN);e&&m.info("Processing socket join",{peers:t.peerId}),this.onParticipantJoined(this.fromSocketService(t)),e&&m.info("Processed socket join",{peers:t.peerId})}}),this.roomSocketHandler.on(Y.leaveRoom,t=>{const{peerId:e}=t.peer;this.selectedPeers.delete(e),this.onParticipantLeave(e)}),L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.self.permissions.acceptWaitingRequests&&this.roomSocketHandler.getWaitingRoomRequests()}),this.self.permissions.on("permissionsUpdate",t=>{const{acceptWaitingRequests:e}=t;e!==void 0&&(e?this.roomSocketHandler.getWaitingRoomRequests():this.participants.waitlisted.clear())}),L.on(x.SOCKET_SERVICE_DISCONNECTED,()=>{this.participants.joined.clear(),this.participants.videoSubscribed.clear(),this.participants.audioSubscribed.clear(),this.participants.pinned.clear(),this.participants.currentPage=0,this.participants.viewMode="ACTIVE_GRID",this.participants.emit("viewModeChanged",{viewMode:"ACTIVE_GRID",currentPage:this.participants.currentPage,pageCount:this.participants.pageCount})}),L.on(x.CONSUMER_PAUSED,({id:t})=>{this.processConsumerPaused(t)}),L.on(x.CONSUMER_RESUMED,({id:t})=>{this.processConsumerResumed(t)}),L.on(x.NEW_CONSUMER,({id:t})=>{this.processNewConsumer(t)}),L.on(x.CONSUMER_CLOSED,({id:t})=>{this.processConsumerClosed(t)}),L.on(x.ROOM_MESSAGE,t=>p(this,[t],function*({payload:e,type:n,timestamp:i}){this.participants.emit("broadcastedMessage",{type:n,payload:e,timestamp:i})})),L.on(x.MESSAGE,t=>p(this,[t],function*({payload:e,type:n,timestamp:i}){n!=="spotlight"&&this.participants.emit("broadcastedMessage",{type:n,payload:e,timestamp:i})})),L.on(x.LOW_CONSUMER_SCORE,({peerId:t,score:e,kind:n})=>{const i=this.participants.joined.get(t);i&&(i.emit("poorConnection",{score:e,kind:n}),this.participants.emit("poorConnection",{participantId:t,score:e,kind:n}))}),L.on(x.CONSUMER_SCORE_UPDATE,({score:t,kind:e,appData:n,peerId:i,scoreStats:r})=>{var s;const a=e==="video"&&((s=n==null?void 0:n.screenShare)!=null?s:!1),c=this.participants.joined.get(i);c&&(c.emit("mediaScoreUpdate",{kind:e,isScreenshare:a,score:t,participantId:i,scoreStats:r}),this.participants.emit("mediaScoreUpdate",{kind:e,isScreenshare:a,score:t,participantId:i,scoreStats:r}))}),L.onAsync(x.KICK_PEER,t=>p(this,[t],function*({peerId:e}){const n=this.participants.joined.get(e);this.roomNodeClient.kick(e),yield this.roomSocketHandler.kick(e),n?n.emit("kicked"):this.participants.joined.emit("kicked",{id:e})})),L.on(x.UPDATE_ACTIVE,(...t)=>p(this,[...t],function*({page:e,createAllConsumers:n}={}){yield this.updateActive(e?"PAGINATED":"ACTIVE_GRID",{page:e,createAllConsumers:n})}))}onParticipantPinned(t){return p(this,null,function*(){if(!t){this.self.isPinned&&this.self.setIsPinned(!1),this.participants.pinned.size!==0&&this.updatePinnedParticipants();return}if(t===this.self.id){this.participants.pinned.size!==0&&this.updatePinnedParticipants(),this.self.setIsPinned(!0);return}const e=this.participants.joined.get(t);this.self.isPinned&&this.self.setIsPinned(!1),this.updatePinnedParticipants(),e.setIsPinned(!0),this.participants.pinned.add(e)})}onParticipantJoined(t){return p(this,null,function*(){var e,n,i;if(this.self.id!==t.id&&!((e=t.flags)!=null&&e.recorder)&&!((n=t.flags)!=null&&n.hidden_participant)&&!((i=t.flags)!=null&&i.hiddenParticipant)&&(this.participants.videoSubscribed.delete(t.id),this.participants.audioSubscribed.delete(t.id),this.participants.joined.add(t),this.participants.waitlisted.delete(t.id),t.stageStatus==="REQUESTED_TO_JOIN_STAGE"&&L.emit(x.UPDATE_STAGE_REQUESTS,{request:{displayName:t.name,userId:t.userId,peerId:t.id},add:!0})),L.emit(x.PEER_JOINED_INTERNAL,t),this.self.config.viewType===Yt.Webinar&&t.stageStatus!=="ON_STAGE"||this.roomNodeClient===void 0||this.participants.videoSubscribed.size>=this.maxPreferredStreams)return;const r=this.participants.currentPage;this.updateActive(r?"PAGINATED":"ACTIVE_GRID",{page:r})})}onParticipantLeave(t){return p(this,null,function*(){const e=this.participants.joined.get(t);this.participants.joined.delete(t,!0,!0),this.participants.pinned.delete(t,!0,!0),this.participants.waitlisted.delete(t,!0,!0),this.roomNodeClient&&(this.roomNodeClient.handlePeerLeaving(t),this.roomNodeClient.closeConsumers(e==null?void 0:e.producers)),e&&e.stageStatus==="REQUESTED_TO_JOIN_STAGE"&&L.emit(x.UPDATE_STAGE_REQUESTS,{request:{displayName:e.name,userId:e.userId,peerId:e.id},add:!1});const{currentPage:n}=this.participants,i=this.maxPreferredStreams*(n-1),r=this.participants.videoSubscribed.get(t);i===0?this.participants.setViewMode("ACTIVE_GRID"):this.participants.joined.size<=i?n===2?this.participants.setViewMode("ACTIVE_GRID"):this.participants.setPage(n-1):r&&this.updateActive(n?"PAGINATED":"ACTIVE_GRID",{page:n})})}processMedia(t){var e;const n=this.roomNodeClient.getConsumers(),{peerId:i,kind:r,appData:s,track:a,producerId:c,rtpReceiver:d,paused:h}=(e=n.get(t))!=null?e:{};if(!i)return m.warn("processMedia::Peer ID is undefined",{consumer:{id:t,kind:r,peerId:i,appData:{supportsRemoteControl:!!(s!=null&&s.supportsRemoteControl),screenShare:!!(s!=null&&s.screenShare)},remotelyPaused:h,producerId:c}}),{};const u=s;return r==="video"&&u.screenShare!==!0&&this.videoPeerConsumerMap.set(i,t),m.info("ParticipantController::processMedia",{consumer:{id:t,peerId:i,kind:r,appData:u,remotelyPaused:h,producerId:c}}),this.consumerPeerMap.set(t,{type:r,peerId:i,appData:u,remotelyPaused:h,producerId:c}),{peerId:i,kind:r,appData:u,remotelyPaused:h,track:a,producerId:c,rtpReceiver:d}}processConsumerClosed(t){const{peerId:e,type:n,appData:i,remotelyPaused:r,producerId:s}=this.consumerPeerMap.get(t)||{},a=this.participants.joined.get(e);if(m.info("ParticipantController::processConsumerClosed",{consumer:{id:t,peerId:e,appData:i,kind:n,remotelyPaused:r,producerId:s}}),this.consumerPeerMap.delete(t),n==="video"&&i.screenShare!==!0&&this.videoPeerConsumerMap.delete(e),!a)return;const c=[];i&&i.screenShare?(a.setScreenShareEnabled(!1),ne.consumerSharedMediaState(t,{screen:!1}),a.screenShareTracks.video&&c.push(a.screenShareTracks.video.id),a.screenShareTracks.audio&&c.push(a.screenShareTracks.audio.id),a.screenShareTracks={audio:void 0,video:void 0}):n==="audio"?(a.setAudioEnabled(!1),a.audioTrack&&c.push(a.audioTrack.id),ne.consumerSharedMediaState(t,{audio:!1}),a.audioTrack=void 0):n==="video"&&(a.setVideoEnabled(!1),this.updatePipSource(a.id,!1),a.videoTrack&&c.push(a.videoTrack.id),ne.consumerSharedMediaState(t,{video:!1}),a.videoTrack=void 0),i.e2ee&&c.forEach(d=>{L.emit(x.E2EE_INACTIVE_CONSUMER,{peerId:e,trackId:d})})}processConsumerResumed(t){const{peerId:e,kind:n,appData:i,track:r,remotelyPaused:s,producerId:a,rtpReceiver:c}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processConsumerResumed",{consumer:{id:t,peerId:e,kind:n,appData:i,remotelyPaused:s,producerId:a}});const d=this.participants.joined.get(e);if(d){if(i.e2ee&&L.emit(x.E2EE_ACTIVE_CONSUMER,{peerId:e,rtpReceiver:c,track:r}),i.screenShare){n==="video"?d.screenShareTracks.video=r:n==="audio"&&(d.screenShareTracks.audio=r),d.setScreenShareEnabled(!0),ne.consumerSharedMediaState(t,{screen:!0});return}n==="video"?(d.videoTrack=r,d.setVideoEnabled(!0),this.updatePipSource(d.id,!0),ne.consumerSharedMediaState(t,{video:!0})):n==="audio"&&(d.audioTrack=r,d.setAudioEnabled(d.audioEnabled),ne.consumerSharedMediaState(t,{audio:d.audioEnabled}))}}processConsumerPaused(t){m.info(`ParticipantController::processConsumerPaused called for consumerId: ${t}`);const{peerId:e,kind:n,track:i,appData:r,remotelyPaused:s,producerId:a}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processConsumerPaused",{consumer:{id:t,peerId:e,kind:n,appData:r,remotelyPaused:s,producerId:a}});const c=this.participants.joined.get(e);c&&(i&&r.e2ee&&L.emit(x.E2EE_INACTIVE_CONSUMER,{peerId:e,trackId:i.id}),n==="video"?(c.videoTrack=i,c.setVideoEnabled(!1),this.updatePipSource(c.id,!1),ne.consumerSharedMediaState(t,{video:!1})):n==="audio"&&(c.audioTrack=i,c.setAudioEnabled(c.audioEnabled),ne.consumerSharedMediaState(t,{audio:c.audioEnabled})))}processNewConsumer(t){const{peerId:e,kind:n,remotelyPaused:i,track:r,appData:s,producerId:a,rtpReceiver:c}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processNewConsumer",{consumer:{id:t,peerId:e,kind:n,remotelyPaused:i,appData:s,producerId:a}});const d=this.participants.joined.get(e);if(d){if(s.screenShare){n==="video"?d.screenShareTracks.video=r:n==="audio"&&(d.screenShareTracks.audio=r),(!i||this.self.permissions.isRecorder||se.hasFeature(ue.SCREEENSHARE_ERR_HACK))&&d.setScreenShareEnabled(!0),s.supportsRemoteControl&&(d.supportsRemoteControl=!0),this.participants.broadcastMessage("screenshareConsumerCreated",{producerId:a,peerId:e,screenShare:!0,consumerId:t,consumerPeerId:this.self.id}),m.info("ParticipantController::newScreenshareConsumer::screenshareConsumerCreated",{consumer:{id:t,peerId:e,kind:n,remotelyPaused:i,appData:s,producerId:a}});return}n==="video"?(d.videoTrack=r,i||(d.setVideoEnabled(!0),this.updatePipSource(d.id,!0)),ne.consumerSharedMediaState(t,{video:!i})):n==="audio"&&(d.audioTrack=r,i||d.setAudioEnabled(!0),ne.consumerSharedMediaState(t,{audio:!i})),!i&&s.e2ee&&L.emit(x.E2EE_ACTIVE_CONSUMER,{peerId:e,rtpReceiver:c,track:r})}}static formatSocketServiceMessage(t){var e,n,i,r,s,a;if(!t)return;const c=om(t.stageType);return{id:t.peerId,userId:t.userId,name:t.displayName,displayName:t.displayName,stageType:c,customParticipantId:t.customParticipantId,presetId:t.presetId,picture:t.displayPictureUrl,waitlisted:t.waitlisted,stageStatus:c,metadata:{preset_name:(e=t.flags)==null?void 0:e.presetName},recorderType:(n=t.flags)==null?void 0:n.recorderType,flags:{hiddenParticipant:(i=t.flags)==null?void 0:i.hiddenParticipant,hidden_participant:(r=t.flags)==null?void 0:r.hiddenParticipant,recorder:((s=t.flags)==null?void 0:s.recorderType)!==void 0&&((a=t.flags)==null?void 0:a.recorderType)!=="NONE"}}}mapPeerIdsToProducers(t,e){const n=(i,r)=>i.filter(({kind:s,screenShare:a})=>r.includes(s)||a&&r.includes("screenshare"));return t.flatMap(i=>{const r=this.participants.joined.get(i);if(r)return n(r.producers,e)}).filter(i=>!!i)}updateGrid(t,e){let n=[],i=[],r=[],s=[];return e.video&&([n,r]=e.video(this.participants.videoSubscribed,t)),e.audio&&([i,s]=e.audio(this.participants.audioSubscribed,t)),{video:{add:n,remove:r},audio:{add:i,remove:s}}}onSelectedPeers(t,e){return p(this,null,function*(){this.participants.viewMode==="ACTIVE_GRID"&&this.computeActivateParticipants(t,e)})}updateActiveParticipantsWithPriorities(t,e=!1){if(!this.mediaJoined){m.warn("Skipped::ParticipantController::updateActiveParticipantsWithPriorities",{roomJoined:this.mediaJoined});return}t.forEach(i=>{this.selectedPeers.add(i.peerId,i.priority)});const n=this.selectedPeers.activeSpeakerPeers.at(0);n!==void 0&&n!==this.participants.lastActiveSpeaker&&(this.participants.lastActiveSpeaker=n,this.participants.emit("activeSpeaker",{peerId:n,volume:1})),e&&(this.participants.viewMode==="ACTIVE_GRID"?this.updateActive("ACTIVE_GRID"):this.participants.viewMode==="PAGINATED"&&this.updateActive("ACTIVE_GRID",{strategies:{audio:this.updateParticipantsMap.bind(this)}}))}};let Ni=xE;Ps([w.trace("ParticipantController.setupEvents")],Ni.prototype,"setupEvents",1);Ps([w.trace("ParticipantController.setupEvents")],Ni.prototype,"setupEventsGlobal",1);Ps([w.trace("ParticipantController.processMedia")],Ni.prototype,"processMedia",1);Ps([w.trace("ParticipantController.processConsumerClosed")],Ni.prototype,"processConsumerClosed",1);Ps([w.trace("ParticipantController.processConsumerResumed")],Ni.prototype,"processConsumerResumed",1);Ps([w.trace("ParticipantController.processConsumerPaused")],Ni.prototype,"processConsumerPaused",1);Ps([w.trace("ParticipantController.processNewConsumer")],Ni.prototype,"processNewConsumer",1);const Me=Gn(tm().permissions);var Z,Io,zo,Gh,nn,un;const Co=class extends gn{constructor(t,e,n,i=!1){if(super(),S(this,nn),S(this,Z,void 0),S(this,Io,void 0),S(this,zo,void 0),S(this,Gh,r=>{var s,a,c;const d=r,{chat:h,connectedMeetings:u,plugins:g,polls:E,media:b}=d,k=Ml(d,["chat","connectedMeetings","plugins","polls","media"]);if(h&&(h.private&&Xi(o(this,Z).chat.private,h.private),h.public&&Xi(o(this,Z).chat.public,h.public),this.emit("chatUpdate")),u&&Xi(o(this,Z).connectedMeetings,u),b){const A=B=>{switch(B){case yr.NONE:return re.Allowed;case yr.ALLOWED:return re.Allowed;case yr.NOT_ALLOWED:return re.NotAllowed;case yr.CAN_REQUEST:return re.CanRequest;default:return}},M={audio:void 0,video:void 0,screenshare:void 0};(s=b.audio)!=null&&s.canProduce&&(M.audio={canProduce:A(b.audio.canProduce)}),(a=b.video)!=null&&a.canProduce&&(M.video={canProduce:A(b.video.canProduce)}),(c=b.screenshare)!=null&&c.canProduce&&(M.screenshare={canProduce:A(b.screenshare.canProduce)}),Xi(o(this,Z).media,M)}g&&(Xi(o(this,Z).plugins,g),this.emit("pluginsUpdate")),E&&(Xi(o(this,Z).polls,E),this.emit("pollsUpdate")),Object.keys(k).length!==0&&Xi(o(this,Z),k),this.emit("permissionsUpdate",r)}),!e)throw m.error("DytePermissionsPreset::load_preset_permissions_failed"),new D("Could not load preset permissions.","0904");T(this,zo,t),T(this,Io,n),T(this,Z,e),i&&this.setupEvents()}setupEvents(){L.on(x.UPDATE_PERMISSIONS,o(this,Gh))}static fromResponse(t,e,n){return new Co(n,t,e,!0)}static default(t,e){return new Co(t,Me,e)}static init(t,e,n){let i;return n?i=new Co(t,n,e,!0):i=new Co(t,Me,e),i}get mediaRoomType(){const{sfu:t}=o(this,zo).getValue("roomNodeOptions");return t===bt.CF?"CF":"HIVE"}get stageEnabled(){var t;return((t=o(this,Z))==null?void 0:t.stageEnabled)||o(this,Io)===Yt.Webinar||o(this,Io)===Yt.Livestream}get acceptStageRequests(){var t,e;return this.stageEnabled?((t=o(this,Z))==null?void 0:t.acceptStageRequests)||((e=o(this,Z))==null?void 0:e.canAcceptProductionRequests):!1}get stageAccess(){var t,e,n;return((t=o(this,Z))==null?void 0:t.stageAccess)===re.NotAllowed?re.NotAllowed:((e=o(this,Z))==null?void 0:e.stageAccess)===re.CanRequest?re.CanRequest:((n=o(this,Z))==null?void 0:n.stageAccess)===re.Allowed||o(this,Z).media.audio.canProduce===re.Allowed||o(this,Z).media.video.canProduce===re.Allowed||o(this,Z).media.screenshare.canProduce===re.Allowed?re.Allowed:o(this,Z).media.audio.canProduce===re.CanRequest||o(this,Z).media.video.canProduce===re.CanRequest||o(this,Z).media.screenshare.canProduce===re.CanRequest?re.CanRequest:re.NotAllowed}get acceptWaitingRequests(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.acceptWaitingRequests)!=null?e:Me.acceptWaitingRequests}get requestProduceVideo(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.video)==null?void 0:n.canProduce)===re.CanRequest}get requestProduceAudio(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.audio)==null?void 0:n.canProduce)===re.CanRequest}get requestProduceScreenshare(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.screenshare)==null?void 0:n.canProduce)===re.CanRequest}get canAllowParticipantAudio(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.disableParticipantAudio)!=null?e:Me.disableParticipantAudio}get canAllowParticipantScreensharing(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canAcceptProductionRequests)!=null?e:Me.canAcceptProductionRequests}get canAllowParticipantVideo(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.disableParticipantVideo)!=null?e:Me.disableParticipantVideo}get canDisableParticipantAudio(){return this.canAllowParticipantAudio}get canDisableParticipantVideo(){return this.canAllowParticipantVideo}get kickParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.kickParticipant)!=null?e:Me.kickParticipant}get pinParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.pinParticipant)!=null?e:Me.pinParticipant}get canRecord(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canRecord)!=null?e:Me.canRecord}get waitingRoomType(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.waitingRoomType)!=null?e:Me.waitingRoomType}get waitingRoomBehaviour(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.waitingRoomType)!=null?e:Me.waitingRoomType}get plugins(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.plugins)!=null?e:Me.plugins}get polls(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.polls)!=null?e:Me.polls}get produceVideo(){return this.canProduceVideo}get requestProduce(){return o(this,Z).media.audio.canProduce===re.CanRequest||o(this,Z).media.video.canProduce===re.CanRequest||o(this,Z).media.screenshare.canProduce===re.CanRequest}get canProduceVideo(){var t;const e=(t=o(this,Z).media.video.canProduce)!=null?t:Me.media.video.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get produceScreenshare(){return this.canProduceScreenshare}get canProduceScreenshare(){var t;const e=(t=o(this,Z).media.screenshare.canProduce)!=null?t:Me.media.screenshare.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get produceAudio(){return this.canProduceAudio}get canProduceAudio(){var t;const e=(t=o(this,Z).media.audio.canProduce)!=null?t:Me.media.audio.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get chatPublic(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.public)!=null?n:Me.chat.public}get chatPrivate(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.private)!=null?n:Me.chat.private}get chatChannel(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.channel)!=null?n:Me.chat.channel}get chatMessage(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.message)!=null?n:Me.chat.message}get connectedMeetings(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.connectedMeetings)!=null?e:Me==null?void 0:Me.connectedMeetings}get hiddenParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.hiddenParticipant)!=null?e:Me.hiddenParticipant}get showParticipantList(){var t;return(t=o(this,Z).showParticipantList)!=null?t:Me.showParticipantList}get canChangeParticipantRole(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canChangeParticipantPermissions)!=null?e:Me.canChangeParticipantPermissions}get canChangeParticipantPermissions(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canChangeParticipantPermissions)!=null?e:Me.canChangeParticipantPermissions}get canChangeTheme(){return!1}get canPresent(){return o(this,Z).media.audio.canProduce===re.Allowed||o(this,Z).media.video.canProduce===re.Allowed||o(this,Z).media.screenshare.canProduce===re.Allowed}get acceptPresentRequests(){return this.acceptStageRequests}get canEditDisplayName(){var t;return(t=o(this,Z).canEditDisplayName)!=null?t:!1}get maxScreenShareCount(){return 1}get isRecorder(){return o(this,Z).isRecorder}get canSpotlight(){return o(this,Z).canSpotlight}get canLivestream(){return o(this,Z).canLivestream}get transcriptionEnabled(){return o(this,Z).transcriptionEnabled}};let I2=Co;Z=new WeakMap,Io=new WeakMap,zo=new WeakMap,Gh=new WeakMap,nn=new WeakSet,un=function(){return o(this,zo).getValue("stageStatus")};var VE;class UE extends gn{constructor(){super(...arguments),y(this,"localMediaHandler"),S(this,VE,void 0)}updatePermission(){return p(this,null,function*(){var e,n;const i=(h,u)=>{this.mediaPermissions[h]=u;const g={message:this.mediaPermissions[h],kind:h};u==="DENIED"?L.emit(x.MEDIA_PERMISSION_ERROR,g):L.emit(x.MEDIA_PERMISSION_UPDATE,g)};if(Be.getName()==="firefox")return;const r="microphone",s="camera",a=yield(e=navigator==null?void 0:navigator.permissions)==null?void 0:e.query({name:r}),c=yield(n=navigator==null?void 0:navigator.permissions)==null?void 0:n.query({name:s}),d=(h,u)=>{switch(u){case"granted":i(h,"ACCEPTED");break;case"denied":i(h,"DENIED");break;case"prompt":i(h,"NOT_REQUESTED");break}this.localMediaHandler.repopulateAvailableDevices()};a&&(a.onchange=()=>d("audio",a.state)),c&&(c.onchange=()=>d("video",c.state))})}populateMediaPermissionsInCallstats(e){return p(this,arguments,function*({message:n,kind:i}){switch(i){case"audio":{ne.mediaPermission("AUDIO",n),ne.mediaPermission("SPEAKER",n);break}case"video":{ne.mediaPermission("VIDEO",n);break}case"screenshare":{ne.mediaPermission("SCREENSHARE",n);break}}})}init(){return p(this,arguments,function*(e={},n=!1,i=null){var r,s,a,c,d,h;if(Be.init(),!this.localMediaHandler)try{let u=!0;if(i!=null&&i.getValue("defaults").mediaHandler)u=!1,this.localMediaHandler=i.getValue("defaults").mediaHandler.localMediaHandler;else if(navigator.RNLocalMediaHandlerImpl){const{RNLocalMediaHandlerImpl:g}=navigator;this.localMediaHandler=yield g.init()}else this.localMediaHandler=new cn(i,e.constraints,(r=i==null?void 0:i.getValue("defaults"))==null?void 0:r.isNonPreferredDevice,(s=i==null?void 0:i.getValue("defaults"))==null?void 0:s.autoSwitchAudioDevice);if(L.on(x.MEDIA_PERMISSION_UPDATE,g=>p(this,null,function*(){if(this.populateMediaPermissionsInCallstats({message:g.message,kind:g.kind}),g.message==="NOT_REQUESTED")switch(g==null?void 0:g.kind){case"audio":this.rawAudioTrack&&(m.info("Disabling audio due to media permission update"),this.disableAudio());break;case"video":this.rawVideoTrack&&(m.info("Disabling video due to media permission update"),this.disableVideo());break;default:break}this.emit("mediaPermissionUpdate",g)})),L.on(x.MEDIA_PERMISSION_ERROR,g=>p(this,null,function*(){const{kind:E,message:b,constraints:k}=g;this.populateMediaPermissionsInCallstats({message:b,kind:E}),E==="audio"?(m.info(`Disabling audio due to media permission error skipping: ${this.localMediaHandler.audioUpdateInProgress}`),this.localMediaHandler.audioUpdateInProgress===!1&&this.disableAudio()):E==="video"&&(m.info(`Disabling video due to media permission error skipping: ${this.localMediaHandler.videoUpdateInProgress}`),this.localMediaHandler.videoUpdateInProgress===!1&&this.disableVideo()),m.error("SelfController::mediaPermissionError",{error:{message:b},constraints:k,mediaPermissionsErrors:{kind:E,message:b}}),this.emit("mediaPermissionError",g),this.emit("mediaPermissionUpdate",{message:b,kind:E})})),u){m.info(`Setting up DyteSelfMedia streams using media handler. audio:${(a=e==null?void 0:e.audio)!=null?a:!0} video:${(c=e==null?void 0:e.video)!=null?c:!0}`);const g=this.localMediaHandler.setupStreams({video:(d=e==null?void 0:e.video)!=null?d:!0,audio:(h=e==null?void 0:e.audio)!=null?h:!0});n||(yield g)}}catch(u){m.error("DyteSelf::init::Failed To Setup Streams",{error:{name:u.name,message:u.message}})}})}get audioTrack(){return this.localMediaHandler.audioTrack}get rawAudioTrack(){return this.localMediaHandler.rawAudioTrack}get mediaPermissions(){return this.localMediaHandler.permissions}addAudioMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.addAudioMiddleware(e)})}removeAudioMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.removeAudioMiddleware(e)})}removeAllAudioMiddlewares(){return p(this,null,function*(){return this.localMediaHandler.removeAllAudioMiddlewares()})}get videoTrack(){return this.localMediaHandler.videoTrack}get rawVideoTrack(){return this.localMediaHandler.rawVideoTrack}addVideoMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.addVideoMiddleware(e)})}setVideoMiddlewareGlobalConfig(){return p(this,arguments,function*(e={disablePerFrameCanvasRendering:!1}){return this.localMediaHandler.setVideoMiddlewareGlobalConfig(e)})}removeVideoMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.removeVideoMiddleware(e)})}removeAllVideoMiddlewares(){return p(this,null,function*(){return this.localMediaHandler.removeAllVideoMiddlewares()})}get screenShareTracks(){return this.localMediaHandler.screenShareTracks}get audioEnabled(){return this.localMediaHandler.audioEnabled}get videoEnabled(){return this.localMediaHandler.videoEnabled}get screenShareEnabled(){return this.localMediaHandler.screenShareEnabled}enableAudio(){return p(this,null,function*(){yield this.localMediaHandler.enableAudio(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})}enableVideo(){return p(this,null,function*(){yield this.localMediaHandler.enableVideo(),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})}disableAudio(){return p(this,null,function*(){this.localMediaHandler.disableAudio(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})}enableScreenShare(){return p(this,null,function*(){yield this.localMediaHandler.enableScreenShare(),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})}disableScreenShare(){return p(this,null,function*(){yield this.localMediaHandler.disableScreenShare(),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})}disableVideo(){return p(this,null,function*(){yield this.localMediaHandler.disableVideo(),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})}getCurrentDevices(){return this.localMediaHandler.getCurrentDevices()}getAudioDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getAudioDevices()})}getVideoDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getVideoDevices()})}getSpeakerDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getSpeakerDevices()})}getDeviceById(e,n){let i;return n==="audio"?i="audioinput":n==="video"?i="videoinput":n==="speaker"&&(i="audiooutput"),this.localMediaHandler.getDeviceById(e,i)}setDevice(e){return p(this,null,function*(){switch(e.kind){case"audioinput":try{yield this.localMediaHandler.setAudioDevice(e)}catch{}finally{this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}break;case"audiooutput":yield this.localMediaHandler.setSpeakerDevice(e);break;case"videoinput":try{yield this.localMediaHandler.setVideoDevice(e)}catch{}finally{this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})}break}this.emit("deviceUpdate",{device:e})})}}VE=new WeakMap;const ao={},Rr={executeWithLock({methodName:t,lockName:e,timeout:n}){return(i,r,s)=>{const a=s.value;return s.value=function(...c){if(ao[e]){const u=new Error(`Unsupported concurrent calls on Dyte method: ${t}.`);throw u.name="UnsupportedConcurrentMethodExecution",m.error("DyteLocker::UnsupportedConcurrentMethodExecution",{error:{stack:u.stack},dyteLocker:{methodName:t,lockName:e}}),u}ao[e]=!0;const d=setTimeout(()=>delete ao[e],n),h=a.apply(this,c);return Promise.resolve(h).then(()=>{delete ao[e],clearTimeout(d)}).catch(()=>{delete ao[e],clearTimeout(d)}),h},s}}};var C2=Object.defineProperty,R2=Object.getOwnPropertyDescriptor,Zt=(t,e,n,i)=>{for(var r=i>1?void 0:i?R2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&C2(e,n,r),r},oo,en,co,mi,Ur,Hs,yt,It,ct,mt,lo,uo,td,Ku,Wg;let wt=(Wg=class extends UE{constructor(t,e,n,i,r){var s;super(),S(this,Ur),S(this,yt),S(this,ct),S(this,td),y(this,"name"),y(this,"picture"),y(this,"customParticipantId"),y(this,"waitlistStatus"),S(this,oo,void 0),S(this,en,void 0),S(this,co,void 0),y(this,"role"),y(this,"userId"),y(this,"organizationId"),y(this,"supportsRemoteControl",!1),y(this,"device"),S(this,mi,void 0),y(this,"hidden",!1),y(this,"presetName"),y(this,"roomState","init"),S(this,lo,new Set),S(this,uo,new Set),T(this,mi,t),this.userId=e.id,this.name=e.name,this.picture=e.picture,this.customParticipantId=(s=e.customParticipantId)!=null?s:e.clientSpecificId,this.waitlistStatus="none",T(this,en,n),T(this,oo,i),this.hidden=!1,T(this,co,!1),this.organizationId=e.organizationId,this.supportsRemoteControl=Be.isElectron(),this.device=Be.getDeviceInfo(),this.presetName=r,i.viewType!==Yt.Chat&&this.updatePermission(),this.updateVideo=this.updateVideo.bind(this),Q(this,td,Ku).call(this)}get stageStatus(){return o(this,mi).getValue("stageStatus")}get id(){return o(this,mi).getValue("peerId")}static __init__(t,e,n,i,r,s=!1){return p(this,null,function*(){var a,c,d,h,u;let g=(c=(a=t.getValue("defaults"))==null?void 0:a.audio)!=null?c:!0,E=(h=(d=t.getValue("defaults"))==null?void 0:d.video)!=null?h:!0;n.canProduceAudio!=="ALLOWED"&&(g=!1),n.canProduceVideo!=="ALLOWED"&&(E=!1);const b=new wt(t,e,n,i,r);if(i.viewType===Yt.Chat)return b;const k=xL(i.mediaConstraints);return Xi(k,(u=t.getValue("defaults"))==null?void 0:u.mediaConfiguration),yield b.init({audio:g,video:E,constraints:k},s,t),b.setupEvents(),b})}cleanupEvents(){this.removeAllListeners("videoUpdate"),this.localMediaHandler.removeAllListeners("AUDIO_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("VIDEO_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("DEVICE_CHANGE"),this.localMediaHandler.removeAllListeners("DEVICE_LIST_UPDATED"),this.localMediaHandler.removeAllListeners("SCREENSHARE_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("SCREENSHARE_ENDED"),this.localMediaHandler.removeAllListeners("AUDIO_TRACK_SILENT"),this.localMediaHandler.removeAllListeners("FORCE_MUTE_AUDIO"),this.localMediaHandler.removeAllListeners("FORCE_MUTE_VIDEO"),o(this,en).removeAllListeners("permissionsUpdate")}setupEvents(){this.on("videoUpdate",Q(this,td,Ku)),this.localMediaHandler.on("AUDIO_TRACK_CHANGE",()=>p(this,null,function*(){if(m.info("DyteSelf::setupEvents::AUDIO_TRACK_CHANGE",H({},os(this))),o(this,ct,mt)&&this.audioEnabled)try{yield o(this,yt,It).shareMic(this.audioTrack)}catch(t){m.error("DyteSelf::setupEvents::Error while sharing mic",{error:t}),this.localMediaHandler.disableAudio()}this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})),this.localMediaHandler.on("VIDEO_TRACK_CHANGE",()=>p(this,null,function*(){if(m.info("DyteSelf::setupEvents::VIDEO_TRACK_CHANGE",H({},os(this))),o(this,ct,mt)&&this.rawVideoTrack===void 0)m.info("DyteSelf::VIDEO_TRACK_CHANGE::Forcing_disable_video"),this.disableVideo();else if(this.videoEnabled&&o(this,ct,mt))try{const t=yield o(this,yt,It).shareWebcam(this.videoTrack);t&&t.id!==this.videoTrack.id&&se.hasFeature(ue.EXP_RESHARE)&&(yield o(this,yt,It).shareWebcam(this.videoTrack))}catch(t){m.error("DyteSelf::setupEvents::failed shareWebcam",{error:t}),this.videoEnabled&&(yield this.localMediaHandler.disableVideo())}this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})),this.localMediaHandler.on("DEVICE_CHANGE",t=>p(this,[t],function*({device:e}){this.emit("deviceUpdate",{device:e})})),this.localMediaHandler.on("DEVICE_LIST_UPDATED",t=>{this.emit("deviceListUpdate",t)}),this.localMediaHandler.on("SCREENSHARE_TRACK_CHANGE",()=>p(this,null,function*(){if(!o(this,ct,mt)){m.error("DyteSelf.SCREENSHARE_TRACK_CHANGE.LocalMediaInitialized_WithoutRoomNode");return}if(this.screenShareEnabled)try{yield o(this,yt,It).shareScreen(this.screenShareTracks)}catch(t){m.error("DyteSelf::setupEvents::Error while sharing screen",{error:t}),this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare())}m.info("DyteSelf::setupEvents::SCREENSHARE_TRACK_CHANGE",H({},os(this))),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})),this.localMediaHandler.on("SCREENSHARE_ENDED",()=>p(this,null,function*(){m.log("Disabling screenshare due to SCREENSHARE_ENDED"),yield this.disableScreenShare(),m.info("DyteSelf::setupEvents::SCREENSHARE_ENDED",H({},os(this)))})),this.localMediaHandler.on("AUDIO_TRACK_SILENT",()=>{ne.mediaTrackMuted("AUDIO")}),this.localMediaHandler.on("FORCE_MUTE_AUDIO",()=>{this.disableAudio()}),this.localMediaHandler.on("FORCE_MUTE_VIDEO",()=>p(this,null,function*(){o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),ne.videoOff()})),o(this,en).on("permissionsUpdate",t=>{var e,n,i;(e=t==null?void 0:t.media)!=null&&e.audio&&o(this,en).canProduceAudio!==re.Allowed&&(this.disableAudio(),m.info(`Disabled audio due to dynamic preset change: canProduceAudio: ${this.permissions.canProduceAudio}`)),(n=t==null?void 0:t.media)!=null&&n.video&&o(this,en).canProduceVideo!==re.Allowed&&(this.disableVideo(),m.info(`Disabled video due to dynamic preset change: canProduceVideo: ${this.permissions.canProduceVideo}`)),(i=t==null?void 0:t.media)!=null&&i.screenshare&&o(this,en).canProduceScreenshare!==re.Allowed&&(this.disableScreenShare(),m.info(`Disabled screenshare due to dynamic preset change: canProduceScreenshare: ${this.permissions.canProduceScreenshare}`))})}get permissions(){return o(this,en)}get config(){return o(this,oo)}get roomJoined(){var t;return o(this,oo).viewType===Yt.Livestream&&this.stageStatus!=="ON_STAGE"?((t=o(this,mi).getValue("connectionHandler"))==null?void 0:t.socketJoined)===!0:o(this,ct,mt)}setName(t){if(!t)throw new D("Name cannot be empty.","1103");this.name=t}setupTracks(){return p(this,arguments,function*(t={}){t.forceReset,yield this.disableAudio(),yield this.disableVideo(),this.localMediaHandler.removeAudioTrack(),this.localMediaHandler.removeVideoTrack(),t.audio&&(yield this.enableAudio()),t.video&&(yield this.enableVideo())})}destructMediaHandler(){return p(this,null,function*(){return this.localMediaHandler.destruct()})}removeDocumentEventListeners(){return p(this,null,function*(){return this.localMediaHandler.removeDocumentEventListeners()})}enableAudio(){return p(this,null,function*(){if(this.permissions.canProduceAudio!==re.NotAllowed&&!(o(this,en).canProduceAudio===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.audioEnabled){if(ne.audioOn(),yield this.localMediaHandler.enableAudio(),o(this,ct,mt)&&this.stageStatus==="ON_STAGE"){if(this.audioTrack)try{yield o(this,yt,It).shareMic(this.audioTrack)}catch(t){m.error("DyteSelf::enableAudio::Error while sharing mic",{error:t}),this.localMediaHandler.disableAudio()}if(!this.audioEnabled)return;o(this,yt,It).unmuteSelf()}this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}})}enableVideo(){return p(this,null,function*(){if(o(this,en).canProduceVideo!==re.NotAllowed&&!(o(this,en).canProduceVideo===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.videoEnabled){if(ne.videoOn(),yield this.localMediaHandler.enableVideo(),o(this,ct,mt)&&this.stageStatus==="ON_STAGE")try{yield o(this,yt,It).shareWebcam(this.videoTrack)}catch(t){m.error("DyteSelf::enableVideo::Error while sharing video",{error:t}),this.videoEnabled&&this.localMediaHandler.disableVideo()}this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),m.info("DyteSelf.enableVideo",H({},os(this)))}})}updateVideoConstraints(t){return p(this,null,function*(){if(!this.localMediaHandler.updateVideoConstraints)throw new D("Unsupported","1102");yield this.localMediaHandler.updateVideoConstraints(t)})}enableScreenShare(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t enable screenshare without joining room","1105");if(o(this,en).canProduceScreenshare!==re.NotAllowed&&!(o(this,en).canProduceScreenshare===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.screenShareEnabled&&(yield this.localMediaHandler.enableScreenShare(),this.screenShareTracks.audio||this.screenShareTracks.video)){try{yield o(this,yt,It).shareScreen(this.screenShareTracks)}catch(t){m.error("DyteSelf::enableScreenShare::Error while sharing screen",{error:t}),this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare())}this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})}})}updateScreenshareConstraints(t){return p(this,null,function*(){if(!this.localMediaHandler.updateScreenshareConstraints)throw new D("Unsupported","1102");yield this.localMediaHandler.updateScreenshareConstraints(t)})}disableAudio(){return p(this,null,function*(){this.audioEnabled&&(this.localMediaHandler.disableAudio(),o(this,ct,mt)&&o(this,yt,It).muteSelf(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack}),ne.audioOff())})}disableVideo(){return p(this,null,function*(){this.videoEnabled&&(yield this.localMediaHandler.disableVideo(),o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),ne.videoOff())})}disableScreenShare(){return p(this,null,function*(){this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare(),o(this,ct,mt)&&(yield o(this,yt,It).disableScreenShare()),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks}))})}getAllDevices(){return this.localMediaHandler.getAllDevices()}setIsPinned(t,e=!0){var n;T(this,co,t);const i=t?"pinned":"unpinned";(n=o(this,Ur,Hs))==null||n.updateSource(this.id,{pinned:t}),e&&this.emit(i,this)}get isPinned(){return o(this,co)}pin(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t pin participants without joining room","1105");return this.show(),o(this,yt,It).pinPeer(this.id)})}unpin(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t unpin participants without joining room","1105");return o(this,yt,It).pinPeer(null)})}hide(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t toggle participant tile without joining room","1105");this.hidden=!0,this.emit("toggleTile",{hidden:this.hidden})})}show(){if(!o(this,ct,mt))throw new D("Can`t toggle participant tile without joining room","1105");this.hidden=!1,this.emit("toggleTile",{hidden:this.hidden})}setDevice(t){return p(this,null,function*(){var e,n,i;if(!t)throw new D("No device selected","1104");const r=this.getCurrentDevices();if(t.deviceId&&(((e=r==null?void 0:r.audio)==null?void 0:e.deviceId)===t.deviceId||((n=r==null?void 0:r.video)==null?void 0:n.deviceId)===t.deviceId||((i=r==null?void 0:r.speaker)==null?void 0:i.deviceId)===t.deviceId)&&(m.warn("DyteSelf.setDevice.setting_to_in_use_device",{devices:[t]}),se.hasFeature(ue.SKIP_SETTING_IN_USE_DEVICE)))throw new D("Cannot set device currently in use","1106");switch(t.kind){case"audioinput":try{yield this.localMediaHandler.setAudioDevice(t)}catch{o(this,ct,mt)&&(yield o(this,yt,It).muteSelf()),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}break;case"audiooutput":yield this.localMediaHandler.setSpeakerDevice(t);break;case"videoinput":try{yield this.localMediaHandler.setVideoDevice(t)}catch{o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})}break}})}cleanUpTracks(){var t,e,n,i;(t=this.audioTrack)==null||t.stop(),(e=this.rawAudioTrack)==null||e.stop(),(n=this.videoTrack)==null||n.stop(),(i=this.rawVideoTrack)==null||i.stop()}registerVideoElement(t,e=!1){var n,i;e?o(this,lo).add(t):o(this,uo).add(t),this.updateVideo(t),e||(i=o(this,Ur,Hs))==null||i.addSource(this.id,t,this.videoEnabled,this.isPinned,this.name,this.picture,(n=this.raised)!=null?n:!1)}deregisterVideoElement(t,e=!1){t.srcObject=void 0,e?o(this,lo).delete(t):(o(this,uo).delete(t),o(this,Ur,Hs).removeSource(this.id))}updateVideo(t,e=!1){var n,i,r;if(this.videoEnabled){if(this.videoTrack==null)return;const s=(n=t.srcObject)==null?void 0:n.getTracks()[0];if((s==null?void 0:s.id)===this.videoTrack.id)return;const a=new MediaStream;a.addTrack(this.videoTrack),t.srcObject=a,e||(i=o(this,Ur,Hs))==null||i.enableSource(this.id)}else t.srcObject=void 0,e||(r=o(this,Ur,Hs))==null||r.disableSource(this.id);t.style.display=this.videoEnabled?"block":"none"}},oo=new WeakMap,en=new WeakMap,co=new WeakMap,mi=new WeakMap,Ur=new WeakSet,Hs=function(){return o(this,mi).getValue("pip")},yt=new WeakSet,It=function(){return o(this,mi).getValue("roomNodeClient")},ct=new WeakSet,mt=function(){var t;return((t=o(this,mi).getValue("connectionHandler"))==null?void 0:t.mediaJoined)===!0},lo=new WeakMap,uo=new WeakMap,td=new WeakSet,Ku=function(){Array.from(o(this,uo)).forEach(t=>this.updateVideo(t,!1)),Array.from(o(this,lo)).forEach(t=>this.updateVideo(t,!0))},Wg);Zt([w.trace("DyteSelf.cleanupEvents")],wt.prototype,"cleanupEvents",1);Zt([w.trace("DyteSelf.setupEvents")],wt.prototype,"setupEvents",1);Zt([w.trace("DyteSelf.setupTracks")],wt.prototype,"setupTracks",1);Zt([w.trace("DyteSelf.destructMediaHandler")],wt.prototype,"destructMediaHandler",1);Zt([w.trace("DyteSelf.removeDocumentEventListeners")],wt.prototype,"removeDocumentEventListeners",1);Zt([Rr.executeWithLock({methodName:"meeting.self.enableAudio",lockName:"DyteSelf.toggleAudio",timeout:3e3}),w.trace("DyteSelf.enableAudio")],wt.prototype,"enableAudio",1);Zt([Rr.executeWithLock({methodName:"meeting.self.enableVideo",lockName:"DyteSelf.toggleVideo",timeout:3e3}),w.trace("DyteSelf.enableVideo")],wt.prototype,"enableVideo",1);Zt([w.trace("DyteSelf.updateVideoConstraints")],wt.prototype,"updateVideoConstraints",1);Zt([w.trace("DyteSelf.enableScreenShare"),Rr.executeWithLock({methodName:"meeting.self.enableScreenShare",lockName:"DyteSelf.toggleScreenShare",timeout:3e3})],wt.prototype,"enableScreenShare",1);Zt([w.trace("DyteSelf.updateScreenshareConstraints")],wt.prototype,"updateScreenshareConstraints",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableAudio",lockName:"DyteSelf.toggleAudio",timeout:3e3}),w.trace("DyteSelf.disableAudio")],wt.prototype,"disableAudio",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableVideo",lockName:"DyteSelf.toggleVideo",timeout:3e3}),w.trace("DyteSelf.disableVideo")],wt.prototype,"disableVideo",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableScreenShare",lockName:"DyteSelf.toggleScreenShare",timeout:3e3}),w.trace("DyteSelf.disableScreenShare")],wt.prototype,"disableScreenShare",1);Zt([w.trace("DyteSelf.setDevice")],wt.prototype,"setDevice",1);wt=Zt([Lt("1100")],wt);var P2=Object.defineProperty,A2=Object.getOwnPropertyDescriptor,M2=(t,e,n,i)=>{for(var r=i>1?void 0:i?A2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&P2(e,n,r),r};let qs;var nd,Hg;const BE=(Hg=class{constructor(t,e){y(this,"socket"),S(this,nd,void 0),T(this,nd,e),this.socket=t,this.handleSocketEvents()}static create(t,e){return qs||(qs=new BE(t,e)),qs}static cleanup(){var t;try{(t=qs==null?void 0:qs.socket)==null||t.disconnect()}catch{m.error("roomSocketHandler::cleanup")}qs=void 0}joinRoom(t){return p(this,null,function*(){var e;this.socket.joinAttempted=!0;const n={capabilities:[],peer:{displayName:(e=t.name)!=null?e:"Participant",customParticipantId:t.customParticipantId,peerId:t.id,userId:t.userId,displayPictureUrl:t.picture,waitlisted:!1},roomUuid:""},i=this.socket.sendMessagePromise(Y.joinRoom,GM.toBinary(n));try{const{peer:r}=Gs.fromBinary((yield i).payload);o(this,nd).getValue("connectionHandler").socketJoined=!0,L.emit(x.SOCKET_SERVICE_ROOM_JOINED,{peer:r});const s=this.getRoomState(),a=this.getRoomPeersNonPaginated(),[{room:c},{peers:d}]=yield Promise.all([s,a]);return L.emit(x.ROOM_STATE,c),L.emit(x.SOCKET_PEERS,d),{peer:r}}catch(r){throw m.error("RoomSocketHandler.joinRoom.failed",{error:r}),new D("Error: RoomSocketHandler.joinRoom failed.","0002",r)}})}getAllAddedParticipants(){return p(this,null,function*(){try{return P1.fromBinary((yield this.socket.sendMessagePromise(Y.getAllAddedParticipants)).payload).participants.map(t=>{var e=t,{id:n}=e,i=Ml(e,["id"]);return ee(H({},i),{userId:n})})}catch{return[]}})}getRoomPeers(t,e,n){return p(this,null,function*(){let i;try{const r={seachQuery:t,limit:e,offset:n},s=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo,LM.toBinary(r));i=Ru.fromBinary(s.payload)}catch(r){m.error("getRoomPeers::binary_decode_error",{error:r})}return i})}getRoomPeersNonPaginated(){return p(this,null,function*(){let t;try{const e=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo);t=Ru.fromBinary(e.payload)}catch(e){m.error("getRoomJoinedPeers::binary_decode_error",{error:e})}return t})}getStagePeers(){return p(this,null,function*(){let t;try{const e=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo);t=Ru.fromBinary(e.payload)}catch(e){m.error("getRoomJoinedPeers::binary_decode_error",{error:e})}return t})}getPeerInfo(t){return p(this,null,function*(){let e;try{const n=yield this.socket.sendMessagePromise(Y.getPeerInfo,lE.toBinary({peerId:t}));e=Gs.fromBinary(n.payload)}catch(n){m.error("getPeerInfo::binary_decode_error",{error:n})}return e})}getRoomState(){return p(this,null,function*(){let t=sg.create();try{const e=yield this.socket.sendMessagePromise(Y.getRoomInfo);t=sg.fromBinary(e.payload)}catch(e){m.error("getRoomState::binary_decode_error",{error:e})}return t})}getRoomStageState(){return p(this,null,function*(){let t=dg.create();try{const e=yield this.socket.sendMessagePromise(Y.getRoomStageState);t=dg.fromBinary(e.payload)}catch(e){m.error("getRoomStageState::binary_decode_error",{error:e})}return t})}broadcastMessage(t,e){return p(this,null,function*(){const n={type:t,payload:new TextEncoder().encode(JSON.stringify(e)),timestamp:Date.now(),ids:[]};return this.socket.sendMessagePromise(Y.broadcastMessage,Va.toBinary(n))})}broadcastToMeetings(t,e,n){return p(this,null,function*(){const i={type:t,payload:new TextEncoder().encode(JSON.stringify(n)),timestamp:Date.now(),ids:e,broadcastType:1};return this.socket.sendMessagePromise(Y.broadcastToEntity,Va.toBinary(i))})}broadcastToPeers(t,e,n){return p(this,null,function*(){const i={type:t,payload:new TextEncoder().encode(JSON.stringify(n)),timestamp:Date.now(),ids:e,broadcastType:0};return this.socket.sendMessage(Y.broadcastToEntity,Va.toBinary(i))})}leaveRoom(){return p(this,null,function*(){this.socket.joinAttempted=!1,this.socket.sendMessagePromise(Y.leaveRoom,JM.toBinary({}))})}kick(t){return p(this,null,function*(){const e={peerIds:[t]};this.socket.sendMessage(Y.kick,hE.toBinary(e))})}kickAll(t=!1){return p(this,null,function*(){const e={propagateKickAcrossRooms:t};this.socket.sendMessage(Y.kickAll,oE.toBinary(e))})}getWaitingRoomRequests(){this.socket.sendMessage(Y.getWaitingRoomRequests)}acceptWaitingRoomRequest(t){const e={userIds:t};this.socket.sendMessage(Y.acceptWaitingRoomRequests,L1.toBinary(e))}rejectWaitingRoomRequest(t){const e={userIds:t};this.socket.sendMessage(Y.denyWaitingRoomRequests,V1.toBinary(e))}updatePermissions(t,e){return p(this,null,function*(){const n={updatePeersPresets:[]};return t.forEach(i=>{n.updatePeersPresets.push({userIds:i,patch:e})}),this.socket.sendMessagePromise(vd.updateUserPreset,hO.toBinary(n))})}handleSocketEvents(){this.socket.on(Y.broadcastMessage,({payload:t})=>{try{const e=Va.fromBinary(t);L.emit(x.ROOM_MESSAGE,{payload:JSON.parse(new TextDecoder().decode(e.payload)),type:e.type,timestamp:e.timestamp})}catch(e){m.error("failed to decode broadcast message:",e)}}),this.socket.on(Y.broadcastToEntity,({payload:t})=>{try{const e=Va.fromBinary(t);L.emit(x.MESSAGE,{payload:JSON.parse(new TextDecoder().decode(e.payload)),type:e.type,timestamp:e.timestamp})}catch(e){m.error("failed to decode peer broadcast message:",e)}})}on(t,e){let n,i;switch(t){case Y.joinRoom:case Y.leaveRoom:case Y.kick:case Y.kickAll:{n=Gs.fromBinary.bind(Gs),i=Gs.create();break}case Y.getWaitingRoomRequests:{n=(r,s)=>r?cg.fromBinary(r,s):{requests:[]},i=cg.create();break}case Y.recordingPaused:case Y.recordingStarted:case Y.recordingStopped:{n=yg.fromBinary.bind(yg);break}case vd.updateUserPreset:{n=lg.fromBinary.bind(lg);break}case Hn.peerJoinedBroadcast:case In.peerJoinedBroadcast:{n=Zf.fromBinary.bind(Zf);break}case Hn.selfJoinComplete:case In.selfJoinComplete:{n=Ih.fromBinary.bind(Ih);break}case Hn.globalPeerPinBroadcast:case In.globalPeerPinBroadcast:{n=ng.fromBinary.bind(ng);break}case Hn.selectedPeer:case In.selectedPeer:{n=_h.fromBinary.bind(_h);break}case Hn.selectedPeerDiff:case In.selectedPeerDiff:{n=Xf.fromBinary.bind(Xf);break}case Hn.leaveRoom:case In.leaveRoom:{n=Ch.fromBinary.bind(Ch);break}}this.socket.on(t,({payload:r})=>{let s=i;if(!n)return e(void 0);try{s=n(r)}catch(a){m.error("roomSocketHandler::on::binary_decode_error",{error:a})}return e(s)})}getUserPermissions(t){return p(this,null,function*(){const e={userIds:[t]};try{const n=yield this.socket.sendMessagePromise(vd.getUserPresets,sO.toBinary(e)),i=dO.fromBinary(n.payload).peerPresets[0],r=new TextDecoder().decode(i.preset),s=JSON.parse(r).permissions;return{chat:s.chat,polls:s.polls,plugins:s.plugins}}catch(n){throw m.error("Error in getting user preset",{error:n}),n}})}},nd=new WeakMap,Hg);let fl=BE;M2([w.trace("RoomSocketHandler.joinRoom")],fl.prototype,"joinRoom",1);var gs={},Ql={};Object.defineProperty(Ql,"__esModule",{value:!0});Ql.Logger=void 0;class O2{constructor(e){}debug(){}warn(){}error(){}}Ql.Logger=O2;Object.defineProperty(gs,"__esModule",{value:!0});var gl=gs.AwaitQueue=gs.AwaitQueueRemovedTaskError=gs.AwaitQueueStoppedError=void 0;const D2=Ql,Ji=new D2.Logger;class pm extends Error{constructor(e){super(e!=null?e:"AwaitQueue stopped"),this.name="AwaitQueueStoppedError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,pm)}}gs.AwaitQueueStoppedError=pm;class Xl extends Error{constructor(e){super(e!=null?e:"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Xl)}}gs.AwaitQueueRemovedTaskError=Xl;class N2{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}push(e,n){return p(this,null,function*(){if(n=n!=null?n:e.name,Ji.debug(`push() [name:${n}]`),typeof e!="function")throw new TypeError("given task is not a function");if(n)try{Object.defineProperty(e,"name",{value:n})}catch{}return new Promise((i,r)=>{const s={id:this.nextTaskId++,task:e,name:n,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:a=>{if(s.completed)return;s.completed=!0,this.pendingTasks.delete(s.id),Ji.debug(`resolving task [name:${s.name}]`),i(a);const[c]=this.pendingTasks.values();c&&!c.executedAt&&this.execute(c)},reject:a=>{if(!s.completed&&(s.completed=!0,this.pendingTasks.delete(s.id),Ji.debug(`rejecting task [name:${s.name}]: %s`,String(a)),r(a),!this.stopping)){const[c]=this.pendingTasks.values();c&&!c.executedAt&&this.execute(c)}}};this.pendingTasks.set(s.id,s),this.pendingTasks.size===1&&this.execute(s)})})}stop(){Ji.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Ji.debug(`stop() | stopping task [name:${e.name}]`);this.stopping=!1}remove(e){Ji.debug(`remove() [taskIdx:${e}]`);const n=Array.from(this.pendingTasks.values())[e];if(!n){Ji.debug(`stop() | no task with given idx [taskIdx:${e}]`);return}n.reject(new Xl)}dump(){const e=Date.now();let n=0;return Array.from(this.pendingTasks.values()).map(i=>({idx:n++,task:i.task,name:i.name,enqueuedTime:i.executedAt?i.executedAt-i.enqueuedAt:e-i.enqueuedAt,executionTime:i.executedAt?e-i.executedAt:0}))}execute(e){return p(this,null,function*(){if(Ji.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const n=yield e.task();e.resolve(n)}catch(n){e.reject(n)}})}}gl=gs.AwaitQueue=N2;function L2(t,e){const n=new Error(e);return n.name=t,n}class mc extends D{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,mc):this.stack=new Error(e).stack}}class an extends D{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,an):this.stack=new Error(e).stack}}class vs extends D{constructor(e){super(e),this.name="TransportConnectionError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,an):this.stack=new Error(e).stack}}const qg=t=>new Promise(e=>setTimeout(e,t));function mm(t,e){return p(this,null,function*(){return new Promise((n,i)=>p(this,null,function*(){const{strategy:r,maxRetryCount:s,delayTime:a}=H({strategy:"linear",maxRetryCount:3,delayTime:10},e);let c=0,d,h=!1;const u=g=>{h=!0,i(g)};for(;c<s;){try{const g=yield t(c,u);return n(g)}catch(g){if(d=g,h)break;if(c<s)r==="linear"?yield qg(a*(c+1)):r==="exponential"&&(yield qg(a*(c+Math.max(0,c-1))));else break}c+=1}return i(d)}))})}function x2(t){return t.map(e=>({channels:e.channels,clockRate:e.clockRate,mimeType:e.mimeType,sdpFmtpLine:e.sdpFmtpLine}))}function V2(t){return t.map(e=>({uri:e.uri}))}function id(t){return{codecs:x2(t.codecs),headerExtensions:V2(t.headerExtensions?t.headerExtensions:[])}}function U2(t){const e=RTCRtpReceiver.getCapabilities("audio"),n=RTCRtpReceiver.getCapabilities("video"),i=RTCRtpSender.getCapabilities("audio"),r=RTCRtpSender.getCapabilities("video");t&&(n.codecs=n.codecs.filter(({mimeType:a})=>t===a),r.codecs=r.codecs.filter(({mimeType:a})=>t===a));const s={audio:id(e),video:id(n)};return{sender:{audio:id(i),video:id(r)},receiver:s}}var At;class B2{constructor(e,n){S(this,At,void 0),y(this,"events"),y(this,"sfuType"),T(this,At,e),this.sfuType=n,this.events=n===bt.CF?Hn:In}joinRoom(e,n,i,r=!1,s=null){return p(this,null,function*(){const a={roomUuid:e,displayName:n,prejoined:r,capabilities:i};return s&&(a.location=s),(yield o(this,At).sendMessagePromiseWithTimeout({event:this.events.joinRoom,protobuf:zP.toBinary(a),timeout:5e3})).payload})}connectTransport(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.createWebRTCTransport,wP.toBinary(e))).payload,{transportId:i,description:r,producerIds:s}=rE.fromBinary(n),a={sdp:r==null?void 0:r.sdp,type:r.type};return{transportId:i,answer:a,producerIds:s}})}produce(e){return p(this,null,function*(){var n,i;const r=(yield o(this,At).sendMessagePromise(this.events.produce,aA.toBinary(e))).payload,s=WA.fromBinary(r);return{answer:{sdp:(n=s==null?void 0:s.description)==null?void 0:n.sdp,type:(i=s==null?void 0:s.description)==null?void 0:i.type},producerId:s.producerId}})}consume(e){return p(this,null,function*(){if(this.sfuType===bt.HIVE)throw new Error("Hive does not support socket consumer operations");const n=(yield o(this,At).sendMessagePromise(this.events.consume,rA.toBinary(e))).payload,{consumerIdsMap:{map:i},description:r}=FA.fromBinary(n);return{consumerStateMap:i,sessionDescription:r}})}closeProducer(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.closeProducer,pA.toBinary(e))).payload,{description:i}=zA.fromBinary(n);return i})}closeConsumer(e){return p(this,null,function*(){if(this.sfuType===bt.HIVE)throw new Error("Hive does not support socket consumer operations");return(yield o(this,At).sendMessagePromise(this.events.closeConsumer,fA.toBinary(e))).payload})}hostControlForPeer(e,n){return p(this,null,function*(){const i={audio:n==="audio",screeShare:!1,video:n==="video",participantId:e},r=(yield o(this,At).sendMessagePromise(this.events.hostControlPeer,TA.toBinary(i))).payload;if(!r)return!1;const{status:s}=nM.fromBinary(r);return s==="success"})}hostControlForAll(e){return p(this,null,function*(){const n={audio:e==="audio",screenShare:!1,video:e==="video"},i=(yield o(this,At).sendMessagePromise(this.events.hostControlAllPeers,kA.toBinary(n))).payload;if(!i)return!1;const{status:r}=rM.fromBinary(i);return r==="success"})}kickAll(){return p(this,null,function*(){const e={propagateKickAcrossRooms:!1};o(this,At).sendMessagePromise(Y.kickAll,oE.toBinary(e))})}kickPeer(e){return p(this,null,function*(){o(this,At).sendMessagePromise(Y.kick,hE.toBinary(e))})}changeDisplayName(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.changeDisplayName,EA.toBinary(e))).payload;if(!n)return!1;const{status:i}=aM.fromBinary(n);return i==="success"})}notifySelfJoinComplete(){return p(this,null,function*(){const e={},n=(yield o(this,At).sendMessagePromise(this.events.selfJoinComplete,QP.toBinary(e))).payload;return Ih.fromBinary(n)})}audioActivity(e){return p(this,null,function*(){o(this,At).sendMessage(this.events.audioActivity,IP.toBinary(e))})}}At=new WeakMap;class fc extends Nt.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}safeEmit(e,...n){const i=this.listenerCount(e);try{return this.emit(e,...n)}catch(r){return m.error(`EnhancedEventEmitter:: safeEmit() | event listener ${e} threw an error`,{error:r}),Boolean(i)}}safeEmitAsPromise(e,...n){return p(this,null,function*(){const i={}.EVENT_PROMISE_TIMEOUT?parseInt({}.EVENT_PROMISE_TIMEOUT,10):1e4;return this.safeEmitAsPromiseWithTimeout(e,i,...n)})}safeEmitAsPromiseWithTimeout(e,n,...i){return p(this,null,function*(){return new Promise((r,s)=>{setTimeout(s,n,"event request timeout");try{this.emit(e.toString(),...i,r,s)}catch(a){m.error(`EnhancedEventEmitter:: safeEmitAsPromise() | event listener for event ${e.toString()} threw an error [event:%s]:%o`,{error:a}),s(a)}})})}}class fm extends fc{constructor(){super(...arguments),y(this,"_sendWebStream",new MediaStream),y(this,"_sendScreenShareStream",new MediaStream),y(this,"_direction"),y(this,"pc"),y(this,"_transportReady",!1),y(this,"_mapMidTransceiver",new Map),y(this,"enableHighBitrate",!1),y(this,"enableStereo",!1),y(this,"enableDtx",!0)}get midTransceiverMap(){return this._mapMidTransceiver}close(){if(m.debug(`${this.name}::close()`),this.pc)try{this.pc.close()}catch(e){m.error(`${this.name}::pc.close()`,{error:e})}}restartIce(){return p(this,null,function*(){m.debug(`${this.name}::restartIce()`);const e=yield this.pc.createOffer({iceRestart:!0});return m.debug(`${this.name}::restartIce() | calling pc.setLocalDescription() [offer:${JSON.stringify(e)}]`),{offerSdp:e,callback:n=>p(this,null,function*(){m.info(`${this.name}::restartIce() | calling pc.setRemoteDescription() [answer:${JSON.stringify(n)}]`),yield this.pc.setRemoteDescription(n)})}})}init({direction:e,iceServers:n,iceTransportPolicy:i,additionalSettings:r,proprietaryConstraints:s,onTrackHandler:a}){m.debug("HandlerInterface::init()"),this._direction=e,this.pc=new RTCPeerConnection(H({iceServers:n||[],iceTransportPolicy:i||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},r),s),a&&this.pc.addEventListener("track",c=>{a(c)}),this._addEventListeners()}connect(){return p(this,null,function*(){const e=this.pc.createDataChannel("dyte"),n=yield this.pc.createOffer();return yield this.pc.setLocalDescription(n),m.info(`connect offer: ${JSON.stringify(n)}`),{offerSdp:n,callback:i=>p(this,null,function*(){m.debug(`${this.name}::connect() | calling pc.setRemoteDescription() [answer:${JSON.stringify(i)}]`),yield this.pc.setRemoteDescription(i),e.close()})}})}getTransportStats(){return p(this,null,function*(){return this.pc.getStats()})}_assertSendDirection(){if(this._direction!=="send")throw new Error('method can just be called for handlers with "send" direction')}_assertRecvDirection(){if(this._direction!=="recv")throw new Error('method can just be called for handlers with "recv" direction')}getReceiverStats(e){return p(this,null,function*(){this._assertRecvDirection();const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");return n.receiver.getStats()})}stopSending(e){return p(this,null,function*(){this._assertSendDirection(),m.debug(`stopSending() [localId:${e}]`);const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");n.sender.replaceTrack(null),this.pc.removeTrack(n.sender),n.direction="inactive";const i=yield this.pc.createOffer();return m.debug(`stopSending() | calling pc.setLocalDescription() [offer:${JSON.stringify(i)}]`),yield this.pc.setLocalDescription(i),{offerSdp:i,callback:r=>p(this,null,function*(){m.debug(`stopSending() | calling pc.setRemoteDescription() [answer:${JSON.stringify(r)}]`),yield this.pc.setRemoteDescription(r),this.midTransceiverMap.delete(e)})}})}replaceTrack(e,n){return p(this,null,function*(){this._assertSendDirection(),n?m.debug(`replaceTrack() [localId:${e}, track.id:${n.id}]`):m.debug(`replaceTrack() [localId:${e}, no track]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");yield i.sender.replaceTrack(n)})}setMaxSpatialLayer(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setMaxSpatialLayer() [localId:${e}, spatialLayer:${n}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters();r.encodings.forEach((s,a)=>{a<=n?s.active=!0:s.active=!1}),yield i.sender.setParameters(r)})}setRtpEncodingParameters(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setRtpEncodingParameters() [localId:${e}, params:${JSON.stringify(n)}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters();r.encodings.forEach((s,a)=>{r.encodings[a]=H(H({},s),n)}),yield i.sender.setParameters(r)})}getSenderStats(e){this._assertSendDirection();const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");return n.sender.getStats()}_addEventListeners(){this.pc.addEventListener("icecandidate",e=>{e.candidate&&this.emit("@icecandidate",{candidate:e.candidate})}),this.pc.addEventListener("iceconnectionstatechange",()=>{switch(this.pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this._transportReady=!0;break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed");break;default:m.warn("unknown state");break}}),this.pc.addEventListener("negotiationneeded",()=>{this.emit("@negotiationneeded",{}),m.debug("negotiationneeded")}),this.pc.addEventListener("icegatheringstatechange",()=>{switch(this.pc.iceGatheringState){case"gathering":m.debug("icegatheringstatechange | gathering"),this.emit("@icegatheringstatechange","gathering");break;case"complete":m.debug("icegatheringstatechange | complete"),this.emit("@icegatheringstatechange","complete");break;default:m.warn("unknown state");break}}),this.pc.addEventListener("icecandidateerror",e=>{m.warn("icecandidateerror",{error:{code:e.errorCode,message:e.errorText}})}),this.pc.addEventListener("datachannel",e=>{m.info("data channel created: ",{rtcChannel:{label:e.channel.label}});const{channel:n}=e;n.onopen=()=>{m.info("data channel open: ",{rtcChannel:{label:e.channel.label}}),this.safeEmit("dc_open",e.channel)},n.onclose=()=>{m.warn("data channel closed: ",{rtcChannel:{label:e.channel.label}})},n.onerror=()=>{m.error("data channel error: ",{rtcChannel:{label:e.channel.label}})}}),this.addCustomEventListeners()}addCustomEventListeners(){}}class gm extends fm{static createFactory(){return()=>new gm}get name(){return"Chrome74"}init({direction:e,iceServers:n,iceTransportPolicy:i,additionalSettings:r,proprietaryConstraints:s,onTrackHandler:a}){this._direction=e,this.pc=new RTCPeerConnection(H({iceServers:n||[],iceTransportPolicy:i||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"},r),s),a&&this.pc.addEventListener("track",c=>{a(c)}),this._addEventListeners()}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection();const a=this.pc.addTransceiver(n,{direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream],sendEncodings:i});if(!navigator.isReactNative){m.debug("creating new transceiver");const h=RTCRtpSender.getCapabilities(typeof n=="string"?n:n.kind);m.info(`senders available params: ${JSON.stringify(h)}`);const u=[];r&&r.length&&r.forEach(g=>{var E;const b=h.codecs.find(k=>k.mimeType.includes(g.name));if(g.parameters){m.debug(`codecOption.parameters:${JSON.stringify(g.parameters)}`);const k=((E=b.sdpFmtpLine)==null?void 0:E.split(";"))||[];k.push(...g.parameters);const A=Array.from(new Set(k).values());b.sdpFmtpLine=A.join(";")}u.push(b)}),m.info(`selected codecs: ${JSON.stringify(u)}`),a.setCodecPreferences(u)}const c=yield this.pc.createOffer();if(yield this.pc.setLocalDescription(c),r&&r.findIndex(({name:h})=>h==="opus")>=0){const{enableDtx:h,enableStereo:u}=this,g=this.enableHighBitrate?u?128e3:64e3:u?64e3:32e3;c.sdp=c.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${h?"usedtx=1;":""}${u?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${g}`),c.sdp+=`a=rtcp-fb:111 nack\r
25
- `}this.midTransceiverMap.set(a.mid,a);const d=h=>p(this,null,function*(){return m.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(h)}]`),yield this.pc.setRemoteDescription(h),a.mid});return m.debug(`send() | calling pc.setLocalDescription() [offer: ${JSON.stringify(c,void 0,2)}]`),{offerSdp:c,callback:d,sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>{this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(i.data)))}})}}class vl extends fm{constructor(e){super(),y(this,"supportsSendEncodings",!1),this.supportsSendEncodings=e.supportsSendEncodings}static createFactory(e){return()=>new vl(e)}get name(){return"Firefox60"}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection();const a=this.supportsSendEncodings&&i!==void 0?{sendEncodings:i}:{},c=this.pc.addTransceiver(n,H({direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream]},a));if(!this.supportsSendEncodings&&i){i.reverse();const u=c.sender.getParameters();u.encodings=i,yield c.sender.setParameters(u)}const d=(u,g)=>{var E;const b=Go(u),k=b.media[b.media.length-1],A=k.rtp.filter(X=>g.some(O=>O.name===X.codec)),M=k.fmtp.filter(X=>A.some(O=>O.payload===X.payload)),B=(E=k.rtcpFb)==null?void 0:E.filter(X=>A.some(O=>O.payload===X.payload)),K=A.map(X=>X.payload);return b.media[b.media.length-1].rtp=A,b.media[b.media.length-1].fmtp=M,b.media[b.media.length-1].rtcpFb=B,b.media[b.media.length-1].payloads=K.join(" "),ah(b)},h=yield this.pc.createOffer();if(h.sdp=d(h.sdp,r),m.debug(`send() | calling pc.setLocalDescription() [offer:${JSON.stringify(h)}]`),yield this.pc.setLocalDescription(h),n==="audio"||n.kind==="audio"){const{enableDtx:u,enableStereo:g}=this,E=this.enableHighBitrate?g?128e3:64e3:g?64e3:32e3;h.sdp=h.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${u?"usedtx=1;":""}${g?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${E}`)}return this.midTransceiverMap.set(c.mid,c),{offerSdp:h,callback:u=>p(this,null,function*(){return m.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(u)}]`),yield this.pc.setRemoteDescription(u),c.mid}),sender:c.sender,mid:c.mid}})}setMaxSpatialLayer(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setMaxSpatialLayer() [localId:${e}, spatialLayer:${n}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters(),s=r.encodings.length-1-n;r.encodings.forEach((a,c)=>{c>=s?a.active=!0:a.active=!1}),yield i.sender.setParameters(r)})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>p(this,null,function*(){const r=yield i.data.arrayBuffer();this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(r)))})})}}class vm extends fm{static createFactory(){return()=>new vm}get name(){return"Safari12"}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection(),m.debug("Safari12::creating new transceiver");const a=this.pc.addTransceiver(n,{direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream],sendEncodings:i}),c=RTCRtpSender.getCapabilities(typeof n=="string"?n:n.kind);m.info(`Safari12::senders available params: ${JSON.stringify(c)}`);const d=[];r&&r.length>0&&r.forEach(u=>{var g;const E=c.codecs.find(b=>b.mimeType.includes(u.name));if(u.parameters){m.info(`Safari12::codecOption.parameters:, ${JSON.stringify(u.parameters)}`);const b=((g=E.sdpFmtpLine)==null?void 0:g.split(";"))||[];b.push(...u.parameters);const k=[...new Set(b).values()];E.sdpFmtpLine=k.join(";")}d.push(E)}),m.info(`Safari12::selected codecs: ${JSON.stringify(d)}`),a.setCodecPreferences(d);const h=yield this.pc.createOffer();if(yield this.pc.setLocalDescription(h),n==="audio"||n.kind==="audio"){const{enableStereo:u,enableDtx:g}=this,E=this.enableHighBitrate?u?128e3:64e3:u?64e3:32e3;h.sdp=h.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${g?"usedtx=1;":""}${u?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${E}`)}return this.midTransceiverMap.set(a.mid,a),{offerSdp:h,callback:u=>p(this,null,function*(){return m.debug(`Safari12::send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(u)}]`),yield this.pc.setRemoteDescription(u),a.mid}),sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.ondatachannel=e=>{const{channel:n}=e;n.onmessage=i=>p(this,null,function*(){const r=String.fromCharCode(...new Uint8Array(i.data));this.safeEmit("datachannel",e.channel,r)})}}}function F2(t,e){return typeof t=="undefined"?e:typeof window!="undefined"&&Object.getOwnPropertyDescriptor(window,"structuredClone")?structuredClone(t):JSON.parse(JSON.stringify(t))}var Cd,Xs,yi,Ti,gr,Rd,zu,$h,FE,Jh,jE;class j2 extends fc{constructor(e){var n;super(),S(this,Ti),S(this,Rd),S(this,$h),S(this,Jh),y(this,"rtpReceiver"),y(this,"id"),y(this,"localId"),y(this,"producerId"),y(this,"producingTransportId"),y(this,"mimeType"),y(this,"track"),y(this,"peerId"),y(this,"appData"),y(this,"transceiver"),S(this,Cd,void 0),S(this,Xs,void 0),S(this,yi,void 0),this.id=e.id,this.localId=e.localId,T(this,Cd,e.handler),this.appData=e.appData,this.peerId=e.producingPeerId,this.producingTransportId=e.producingTransportId,T(this,yi,!1),this.producerId=e.producerId,this.track=e.track,T(this,Xs,(n=e.paused)!=null?n:!1),this.mimeType=e.mimeType,this.transceiver=e.transceiver,this.rtpReceiver=e.rtpReceiver,Q(this,$h,FE).call(this)}get closed(){return o(this,yi)}get kind(){return this.track.kind}get paused(){return o(this,Xs)}close(e,n){o(this,yi)||(m.debug(`Consumer::close() ${e?`with reason ${e}`:""}`,o(this,Ti,gr)),T(this,yi,!0),n&&(Q(this,Jh,jE).call(this),this.transceiver.stop()),this.safeEmit("close",e))}getStats(){return p(this,null,function*(){if(o(this,yi))throw new an("closed");return o(this,Cd).getReceiverStats(this.localId)})}pause(){if(m.debug("consumer::pause()",o(this,Ti,gr)),o(this,yi)){m.error("consumer::pause() | Consumer closed",o(this,Ti,gr));return}T(this,Xs,!0),this.track.enabled=!1,this.safeEmit("pause")}resume(){if(m.debug("consumer::resume()",o(this,Ti,gr)),o(this,yi)){m.error("Consumer::resume() | Consumer closed",o(this,Ti,gr));return}T(this,Xs,!1),this.track.enabled=!0,this.safeEmit("resume")}}Cd=new WeakMap,Xs=new WeakMap,yi=new WeakMap,Ti=new WeakSet,gr=function(){return{consumer:{id:this.id,appData:this.appData,peerId:this.peerId,kind:this.kind}}},Rd=new WeakSet,zu=function(){m.debug('Consumer::track "ended" event',o(this,Ti,gr)),this.safeEmit("trackended")},$h=new WeakSet,FE=function(){this.track.addEventListener("ended",Q(this,Rd,zu).bind(this))},Jh=new WeakSet,jE=function(){try{this.track.removeEventListener("ended",Q(this,Rd,zu)),this.track.stop()}catch(t){m.error("Consumer::destroyTrack()",ee(H({},o(this,Ti,gr)),{error:t}))}};var ti,Ro,Po,Zs,Fn,Mt,Kr,Ao,kn,jn;class W2 extends fc{constructor(e){var n,i;super(),S(this,kn),y(this,"id"),y(this,"localId"),S(this,ti,void 0),y(this,"kind"),y(this,"appData"),y(this,"rtpSender"),S(this,Ro,void 0),S(this,Po,void 0),S(this,Zs,void 0),S(this,Fn,!1),S(this,Mt,void 0),S(this,Kr,void 0),S(this,Ao,void 0),this.id=e.id,this.localId=e.localId,T(this,Mt,e.track),this.kind=(n=e.track)==null?void 0:n.kind,T(this,Kr,e.disableTrackOnPause?!((i=e.track)!=null&&i.enabled):!1),T(this,Ao,void 0),T(this,Ro,e.stopTracks),T(this,Po,e.disableTrackOnPause),T(this,Zs,e.zeroRtpOnPause),this.appData=e.appData||{},this._onTrackEnded=this._onTrackEnded.bind(this),T(this,ti,e.handler),this.rtpSender=e.rtpSender,this._handleTrack()}get closed(){return o(this,Fn)}get track(){return o(this,Mt)}get paused(){return o(this,Kr)}get maxSpatialLayer(){return o(this,Ao)}close(e){return p(this,null,function*(){if(o(this,Fn))return;if(m.debug(`Producer::close() ${e?`with reason ${e}`:""}`,o(this,kn,jn)),T(this,Fn,!0),this._destroyTrack(),e===yl){this.safeEmit("close",{reason:e});return}const{offerSdp:n,callback:i}=yield o(this,ti).stopSending(this.localId),{answer:r}=yield this.safeEmitAsPromise("close",{offer:n,reason:e});i(r)})}getStats(){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");return o(this,ti).getSenderStats(this.localId)})}pause(){m.debug("Producer::pause()",o(this,kn,jn)),o(this,Fn)&&m.error("Producer::pause() | Producer closed",o(this,kn,jn)),T(this,Kr,!0),o(this,Mt)&&o(this,Po)&&(o(this,Mt).enabled=!1),o(this,Zs)&&o(this,ti).replaceTrack(this.localId,null),this.emit("pause")}resume(){if(m.debug("Producer::resume()",o(this,kn,jn)),o(this,Fn)){m.error("Producer::resume() | Producer closed",o(this,kn,jn));return}T(this,Kr,!1),o(this,Mt)&&o(this,Po)&&(o(this,Mt).enabled=!0),o(this,Zs)&&o(this,ti).replaceTrack(this.localId,o(this,Mt)),this.emit("resume")}replaceTrack(e){return p(this,arguments,function*({track:n}){if(m.debug(`Producer::replaceTrack() trackId: ${n==null?void 0:n.id}`,o(this,kn,jn)),o(this,Fn)){if(n&&o(this,Ro))try{n.stop()}catch(i){m.error("Producer::replaceTrack",ee(H({},o(this,kn,jn)),{error:i}))}throw new an("closed")}else if(n&&n.readyState==="ended")throw new an("track ended");if(n===o(this,Mt)){m.debug(`replaceTrack() | same track, ignored trackId: ${n.id}`,o(this,kn,jn));return}(!o(this,Zs)||!o(this,Kr))&&(yield o(this,ti).replaceTrack(this.localId,n)),this._destroyTrack(),T(this,Mt,n),this._handleTrack()})}setMaxSpatialLayer(e){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");if(this.kind!=="video")throw new mc("not a video Producer");if(typeof e!="number")throw new TypeError("invalid spatialLayer");yield o(this,ti).setMaxSpatialLayer(this.localId,e),T(this,Ao,e)})}setRtpEncodingParameters(e){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");if(typeof e!="object")throw new TypeError("invalid params");yield o(this,ti).setRtpEncodingParameters(this.localId,e)})}_onTrackEnded(){m.debug(`Producer::track "ended" event trackId: ${this.track.id}`,o(this,kn,jn)),this.safeEmit("trackended",this.track.id)}_handleTrack(){o(this,Mt)&&o(this,Mt).addEventListener("ended",this._onTrackEnded)}_destroyTrack(){var e;if(o(this,Mt))try{o(this,Mt).removeEventListener("ended",this._onTrackEnded),o(this,Ro)&&o(this,Mt).stop()}catch(n){m.error(`Producer::_destroyTrack trackId: ${(e=this.track)==null?void 0:e.id}`,ee(H({},o(this,kn,jn)),{error:n}))}}}ti=new WeakMap,Ro=new WeakMap,Po=new WeakMap,Zs=new WeakMap,Fn=new WeakMap,Mt=new WeakMap,Kr=new WeakMap,Ao=new WeakMap,kn=new WeakSet,jn=function(){return{producer:{id:this.id,appData:this.appData,kind:this.kind}}};function WE(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Kh(t){return Math.random().toString(36).substring(2,2+t)}const rd=1;function Gg(t){const e=t;return delete e.payload._bolt,e}function H2(t){return t.payload&&WE(t.payload)}function HE(t){var e,n;return H2(t)&&(n=(e=t.payload._bolt)==null?void 0:e.id)!=null?n:""}var zr;const Mo=class extends Nt.EventEmitter{constructor(t,e,n){super(),y(this,"channel"),y(this,"queue"),y(this,"serverProtocolVersion"),S(this,zr,new Map),y(this,"respond",(i,r,s=!1)=>{let a;s?a=Mo.createErrorResponse(i,r):a=Mo.createResponse(i,r),this.channel.send(JSON.stringify(a))}),y(this,"notify",i=>{const r=Mo.createNotification(i);this.channel.send(JSON.stringify(r))}),y(this,"request",i=>p(this,null,function*(){const r=Mo.createRequest(i),s=new Promise((a,c)=>{const{id:d}=r.payload._bolt,h={id:d,method:r.type,resolve:u=>{this.queue.delete(d)&&(clearTimeout(h.timer),a(u))},timer:setTimeout(()=>{this.queue.delete(d)&&c(new Error(`request timeout for message id: ${d}`))},2e4),cancel:u=>{this.queue.delete(d)&&(clearTimeout(h.timer),c(u))}};this.queue.set(d,h)});return this.channel.send(JSON.stringify(r)),s})),y(this,"send",i=>{const r=JSON.stringify(i),s=16384;if(r.length>s){const a=s-200,c=Math.ceil(r.length/a),d=[];for(let u=0;u<c;u+=1){const g=u*a,E=(u+1)*a;d.push(r.slice(g,E))}const h=Ca();for(let u=0;u<c;u+=1){const g=d[u],E=JSON.stringify({id:h,count:c,chunkIndex:u,chunk:g});m.debug(`Sending message chunk over dc: ${E}`),this.channel.send(E)}}else m.debug(`Sending message over dc: ${r}`),this.channel.send(r)}),y(this,"processMessage",i=>{var r;o(this,zr).has(i.id)||o(this,zr).set(i.id,[]);const s=o(this,zr).get(i.id);if(s[i.chunkIndex]=i,(s==null?void 0:s.length)===i.count&&!s.some(a=>a===void 0)){const a=o(this,zr).get(i.id),c=a==null?void 0:a.reduce((h,u)=>h+u.chunk,"");o(this,zr).delete(i.id);const d=JSON.parse(c);if(!d.payload||!WE(d.payload))throw new Error("corrupted incoming message over dc",{cause:{code:"CORRUPT_DC_MESSAGE",values:d}});if(this.processBoltHandshake(d))return;if(this.serverProtocolVersion=(r=d.payload._bolt)==null?void 0:r.version,!this.processResponseMsg(d))return d}}),y(this,"processResponseMsg",i=>{const{id:r}=i.payload._bolt,s=this.queue.get(r);return s?(m.debug(`resolving pending request with id: ${r}, complete response: ${JSON.stringify(i)}`),i.type==="error"?s.cancel(Gg(i)):s.resolve(Gg(i)),!0):!1}),y(this,"processBoltHandshake",i=>{var r,s;return i.type==="_bolt"||i.type==="handshake"?(this.respond((s=(r=i.payload._bolt)==null?void 0:r.id)!=null?s:Kh(8),{type:"_bolt",payload:{message:"pong"}}),!0):!1}),this.label=e,this.transportId=n,this.channel=t,this.queue=new Map}};let Oo=Mo;zr=new WeakMap,y(Oo,"createRequest",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:ee(H({},t.payload),{_bolt:{id:Kh(8),type:"REQUEST",version:rd}})}}),y(Oo,"createResponse",(t,e)=>{var n;if((n=e.payload)!=null&&n._bolt)throw new Error("rpc fields are internal values");return{type:e.type,payload:ee(H({},e.payload),{_bolt:{id:t,type:"RESPONSE",version:rd}})}}),y(Oo,"createNotification",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:ee(H({},t.payload),{bolt:{id:Kh(8),type:"NOTIFY",version:rd}})}}),y(Oo,"createErrorResponse",(t,e)=>({type:"error",payload:{error:e.message,_bolt:{id:t,type:"RESPONSE",version:rd}}}));function q2(t){if(Promise.allSettled)return Promise.allSettled(t);const e=t.map(n=>n.then(i=>({status:"fulfilled",value:i})).catch(i=>({status:"rejected",reason:i})));return Promise.all(e)}const yl="transport closed";var Do;const zh=class extends fc{constructor(t,{id:e,direction:n,handlerFactory:i,iceServers:r,iceTransportPolicy:s,proprietaryConstraints:a,additionalSettings:c,appData:d,config:h}){var u,g,E;super(),y(this,"awaitQueue"),y(this,"observer"),S(this,Do,void 0),y(this,"id"),y(this,"serverId"),y(this,"direction"),y(this,"maxSctpMessageSize"),y(this,"handler"),y(this,"connectionState","new"),y(this,"producers"),y(this,"consumers"),y(this,"datachannels"),y(this,"connected",!1),y(this,"eventsDCReadyPromise"),y(this,"eventsDCReadyPromiseResolver"),y(this,"eventsDCFailureTimer"),y(this,"transportConnectionPromise"),y(this,"consumerTrackEvents"),y(this,"unknownTracksMap"),y(this,"appData"),m.debug(`constructor() [id: ${e}, direction: ${n}]`),T(this,Do,t),this.id=e,this.direction=n;const b=F2(c,{});delete b.iceServers,delete b.iceTransportPolicy,delete b.bundlePolicy,delete b.rtcpMuxPolicy,delete b.sdpSemantics,this.producers=new Map,this.consumers=new Map,this.datachannels=new Map,this.consumerTrackEvents=new Map,this.unknownTracksMap=new Map,this.awaitQueue=new gl,this.observer=new fc,this.handler=i(),this.handler.enableHighBitrate=(u=h==null?void 0:h.enableHighBitrate)!=null?u:!1,this.handler.enableStereo=(g=h==null?void 0:h.enableStereo)!=null?g:!1,this.handler.enableDtx=(E=h==null?void 0:h.enableDtx)!=null?E:!0,this.handler.init({onTrackHandler:this._ontrack.bind(this),direction:n,iceServers:r,iceTransportPolicy:s,additionalSettings:c,proprietaryConstraints:a}),this.appData=d||{},this.transportConnectionPromise=new Promise(k=>{this.observer.once("connected",()=>{k(!0)}),this.observer.once("disconnect",()=>{k(!1)}),this.observer.once("close",()=>{k(!1)})}),this.eventsDCReadyPromise=new Promise(k=>{this.eventsDCReadyPromiseResolver=k}),this.handler.on("@connectionstatechange",k=>{k!==this.connectionState&&(m.debug(`connection state changed to ${k}`),this.connectionState=k,k==="connected"&&(this.connected=!0,this.observer.emit("connected")),k==="disconnected"&&(this.connected=!1,this.observer.emit("disconnect")),(k==="failed"||k==="closed")&&(this.connected=!1,this.observer.emit("close")),this.closed||this.safeEmit("connectionstatechange",k))}),this.handler.on("@icecandidate",({candidate:k})=>{this.closed||this.safeEmit("icecandidate",k)}),this.handler.on("dc_open",k=>{let A=this.datachannels.get(k.label);A||(A||(A=new Oo(k,k.label,this.serverId),this.datachannels.set(k.label,A)),this.eventsDCFailureTimer=setTimeout(()=>{k.label==="events"&&(this.eventsDCReadyPromiseResolver(!1),this.safeEmit("dc_error",k.label))},5e3))}),this.handler.on("datachannel",(k,A)=>{k.label==="events"&&(this.eventsDCReadyPromiseResolver(!0),this.eventsDCFailureTimer&&clearTimeout(this.eventsDCFailureTimer));const M=this.datachannels.get(k.label);if(!M){m.error("unregistered datachannel for message",{rtcChannel:{label:k.label,message:A}});return}try{const B=JSON.parse(A);m.debug("datachannel message chunk recieved",{dataChannelMessageChunk:{id:B.id,count:B.count,chunkIndex:B.chunkIndex,chunk:B.chunk,transprtId:this.serverId}});const K=M.processMessage(B);if(!K)return;m.debug(`datachannel message with id:${B.id} on transport:${this.serverId}complete - ${JSON.stringify(K)}`),this.emit(`datachannel:${k.label}`,M.label,K)}catch(B){m.error("error parsing message",{error:B})}})}get closed(){return this.connectionState==="closed"}setServerId(t){this.serverId=t}getDatachannel(t){return this.datachannels.get(t)}get isEventsDCReady(){return this.eventsDCReadyPromise}close(){this.closed||(m.debug("Transport close called"),this.connectionState="closed",this.connected=!1,this.handler.close(),Array.from(this.producers.values()).forEach(t=>{t.close(yl).catch(()=>{})}),this.producers.clear(),Array.from(this.consumers.values()).forEach(t=>{t.close(yl)}),this.consumers.clear(),this.consumerTrackEvents.clear(),this.emit("close"),this.observer.emit("close"))}getStats(){return p(this,null,function*(){if(this.closed)throw new an("closed");return this.handler.getTransportStats()})}connect(t){return p(this,null,function*(){try{if(yield this.awaitQueue.push(()=>p(this,null,function*(){const{offerSdp:e,callback:n}=yield this.handler.connect(),{transportId:i,answer:r}=yield t(e);this.setServerId(i),yield n(r)})),!(yield this.transportConnectionPromise))throw new Error("ice connection failed");if(o(this,Do)===bt.HIVE&&!(yield this.isEventsDCReady))throw new Error("events datachannel not open")}catch(e){throw m.error("transport failed to connect:",{error:e}),e}})}restartIce(){return p(this,null,function*(){if(m.debug("restartIce()"),this.closed)throw new an("closed");return this.handler.restartIce()})}canProduce(t){return p(this,null,function*(){const{track:e,appData:n}=t;if(e){if(this.direction!=="send")throw new mc("not a sending Transport");if(e.readyState==="ended")throw new an("track ended");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(n&&typeof n!="object")throw new TypeError("if given, appData must be an object")}else throw new TypeError("missing track");if(!(yield this.transportConnectionPromise))throw new vs("transport not connected");return!0})}produce(t,e){return p(this,null,function*(){if(!(yield this.canProduce(t)))throw new Error("Cannot produce");const{track:n,encodings:i,codecOptions:r,stopTracks:s=!0,disableTrackOnPause:a=!0,zeroRtpOnPause:c=!1,appData:d={}}=t;m.debug(`produce() [track:${n.id}]`);const{producerId:h,localId:u,rtpSender:g}=yield this.awaitQueue.push(()=>p(this,null,function*(){const{offerSdp:E,callback:b,sender:k,mid:A}=yield this.handler.send({track:n,encodings:i,codecOptions:r,screenShare:d==null?void 0:d.screenShare}),{answer:M,producerId:B}=yield e({offer:E,kind:n.kind,paused:a?!n.enabled:!1,appData:ee(H({},d||{}),{mid:A}),codecOptions:r,producingTransportId:this.serverId}),K=yield b(M);return{producerId:B,localId:K,rtpSender:k}}),"producer");return this.createProducerObject({id:h,localId:u,track:n,stopTracks:s,disableTrackOnPause:a,zeroRtpOnPause:c,appData:d,handler:this.handler,rtpSender:g})})}createProducerObject(t){return p(this,null,function*(){const e=new W2(t);return this.producers.set(e.id,e),e.once("close",()=>{this.producers.delete(e.id)}),e})}closeProducer(t){return p(this,null,function*(){yield this.awaitQueue.push(t.close.bind(t),"producer")})}canConsume(){return p(this,null,function*(){if(this.closed)throw new an("closed");if(this.direction!=="recv")throw new mc("not a receiving transport");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(!(yield this.transportConnectionPromise))throw new vs("transport not connected");return!0})}consume(t,e,n){return p(this,null,function*(){return this.awaitQueue.push(()=>p(this,null,function*(){const i={},{consumerStates:r,sessionDescription:s,failedProducers:a}=yield e(t);r.forEach((h,u)=>{i[u]=this.createConsumerObjectAndWaitForTrack(ee(H({},h),{producerId:u}))});const c=a;s&&(m.info("Session description found, sending negotiation request"),yield n(s));const d=[];return yield Promise.all(Object.entries(i).map(([h,u])=>u.then(g=>d.push(g)).catch(()=>{m.error(`Failed to create consumer object, producer: ${h}`,{error:{message:"This should not happen"},transport:{serverId:this.serverId}})}))),{consumers:d,failedProducers:c}}),"consumer")})}static parseCodecAndFmtpMappings(t,e){const n=Go(t.sdp),i={};return n.media.forEach(r=>{e.includes(r.mid.toString())&&(i[r.mid.toString()]={rtp:r.rtp,fmtp:r.fmtp,payloads:r.payloads,rtcpFb:r.rtcpFb})}),i}static setCodecAndFmtpMappings(t,e,n){const i=Go(t.sdp);return i.media=i.media.map(r=>{if(e.includes(r.mid.toString())){const s=H({},r);return s.rtp=n[r.mid.toString()].rtp,s.fmtp=n[r.mid.toString()].fmtp,s.payloads=n[r.mid.toString()].payloads,s.rtcpFb=n[r.mid.toString()].rtcpFb,s}return r}),ee(H({},t),{sdp:ah(i)})}closeConsumers(t,e){return p(this,null,function*(){try{const n=t.map(a=>a.transceiver.mid),i=zh.parseCodecAndFmtpMappings(this.handler.pc.remoteDescription,n);m.info("Stopping transceivers",{consumerIds:t.map(({id:a})=>a)}),t.forEach(a=>a.close(void 0,!0));let r=yield this.handler.pc.createOffer();m.info("Created offer for closing consumers",{sdp:r.sdp}),r=zh.setCodecAndFmtpMappings(r,n,i),m.info("Updated codec and fmtp mappings in close consumer offer",{sdp:r.sdp}),yield this.setLocalDescription(r),m.info("Successfully set local description in close consumers");const s=yield e(t,r);m.info("Received answer in close consumers",{sdp:s.sdp}),yield this.setRemoteDescription(s),m.info("Remote description was set successfully in close consumers",{sdp:s.sdp})}catch(n){m.error("Failed to close consumers",{error:n})}})}setRemoteOffer(t){return p(this,null,function*(){try{m.info("Received offer from SFU",{sdp:t.sdp}),yield this.setRemoteDescription(t);const e=yield this.handler.pc.createAnswer();m.info("Created answer corresponding to received offer",{sdp:e.sdp});const n=Go(e.sdp);return n.media=n.media.map(i=>{if(i.type==="audio"){const r=H({},i),s=r.fmtp.find(a=>a.payload===111);return s&&(s.config+=";stereo=1;sprop-stereo=1"),r.rtcpFb||(r.rtcpFb=[]),r.rtcpFb.some(a=>a.type==="nack")||r.rtcpFb.push({payload:parseInt(r.payloads,10),type:"nack"}),r}return i}),e.sdp=ah(n),m.info("Setting munged SDP",{sdp:e.sdp}),yield this.setLocalDescription(e),m.info("Successfully set local description",{sdp:e.sdp}),e}catch(e){throw m.error("Set remote offer failed",{error:e}),e}})}_ontrack(t){const{track:e,transceiver:n,streams:i}=t;m.info(`track event received [trackId: ${e.id}]`);let r;o(this,Do)===bt.HIVE?r=`${i[0].id}:${e.kind}`:r=`${n.mid}:${e.kind}`,e.addEventListener("ended",()=>{m.info(`rtc consumer track ended [trackId: ${e.id}]`),this.unknownTracksMap.delete(r)});const s=this.consumerTrackEvents.get(r);s?(s(e,n),this.consumerTrackEvents.delete(r)):(m.warn(`track event handler not found ${r}`),this.unknownTracksMap.set(r,t))}sendErrorOverDC(t,e,n){const i=this.getDatachannel(t);if(!i)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:t}}});i.respond(e,n,!0)}sendResponseOverDC(t,e,n){const i=this.getDatachannel(t);if(!i)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:t}}});i.respond(e,n)}createConsumerObjectAndWaitForTrack(t){return p(this,null,function*(){const{consumerId:e,producerId:n,producingPeerId:i,producingTransportId:r,streamId:s,paused:a,screenShare:c,appData:d,kind:h,mimeType:u}=t,g=`${s}:${h}`,E=ee(H({},t),{name:"consumer creation task error",message:"consumer creation failed"});return new Promise((b,k)=>p(this,null,function*(){const A=setTimeout(()=>{this.consumerTrackEvents.delete(g),E.isTimedout=!0,k(E)},5e3),M=(K,X)=>{try{if(K.readyState==="ended")clearTimeout(A),k(E);else{const O=K;O.enabled=!0,this.handler.midTransceiverMap.set(X.mid,X);const $=new j2({id:e,localId:X.mid,transceiver:X,track:O,paused:a,producerId:n,producingPeerId:i,producingTransportId:r,handler:this.handler,appData:ee(H({},d),{screenShare:c,peerId:i}),rtpReceiver:X.receiver,mimeType:u});this.consumers.set(e,$),$.once("close",()=>{this.consumers.delete($.id),this.handler.midTransceiverMap.delete(X.mid)}),m.info("consumer created for ",{consumer:{id:e,kind:h,appData:{screenShare:c},peerId:i,producerId:n}}),this.observer.emit("newconsumer",$),clearTimeout(A),b($)}}catch(O){m.warn("error while creating consumer:",O),clearTimeout(A),k(E)}},B=this.unknownTracksMap.get(g);B?(this.unknownTracksMap.delete(g),M(B.track,B.transceiver)):this.consumerTrackEvents.set(g,M)}))})}setRemoteDescription(t){return p(this,null,function*(){yield this.handler.pc.setRemoteDescription(t)})}setLocalDescription(t){return p(this,null,function*(){m.debug(`${this.direction}() {transportId: ${this.serverId}} | calling pc.setLocalDescription() [offer:${JSON.stringify(t)}]`),yield this.handler.pc.setLocalDescription(t)})}retryFailedConsumerCreationTasks(t){return p(this,null,function*(){return q2(t.map(e=>p(this,null,function*(){return mm(n=>p(this,null,function*(){return n>0&&m.warn(`retrying failed consumer creation task: ${JSON.stringify(e)}`),this.createConsumerObjectAndWaitForTrack(H({},e))}))})))})}sendDataChannelMessage(t,e){return p(this,null,function*(){const n=this.getDatachannel(t);if(!n)throw L2("DC_NOT_READY",`${t} datachannel not ready`);const i=(yield n.request(e)).payload;return m.info(`sendDataChannelMessage::response ${JSON.stringify(i)}`),i})}};let G2=zh;Do=new WeakMap;function $2(){if(typeof navigator=="object"&&navigator.product==="ReactNative"){if(typeof RTCPeerConnection=="undefined"){m.warn("Device::this._detectDevice() | unsupported ReactNative without RTCPeerConnection");return}return m.debug("Device::this._detectDevice() | ReactNative handler chosen"),"Chrome74"}if(typeof navigator=="object"&&typeof navigator.userAgent=="string"){const t=navigator.userAgent,e=ov.getParser(t),n=e.getEngine();if(e.satisfies({chrome:">=74",chromium:">=74","microsoft edge":">=88"}))return"Chrome74";if(e.satisfies({chrome:">=55",chromium:">=55"}))return;if(e.satisfies({firefox:">=110"}))return"Firefox110";if(e.satisfies({firefox:">=60"}))return"Firefox60";if(e.satisfies({ios:{OS:">=14.3",firefox:">=30.0"}})||e.satisfies({safari:">=12.0"})&&typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(e.satisfies({safari:">=11"})||e.satisfies({"microsoft edge":">=11"})&&e.satisfies({"microsoft edge":"<=18"}))return;if(n.name&&n.name.toLowerCase()==="blink"){const i=t.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);return i?Number(i[1])>=74?"Chrome74":void 0:"Chrome74"}if(n.name.toLowerCase()==="webkit"&&e.getOS().name.toLowerCase()==="ios")return typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection")?"Safari12":void 0;m.warn("Device::this._detectDevice() | browser not supported");return}m.warn("Device::this._detectDevice() | unknown device")}var Pd;class J2{constructor(e,{handlerName:n,handlerFactory:i}={}){if(y(this,"handlerFactory"),S(this,Pd,void 0),m.debug("constructor()"),T(this,Pd,e),n&&i)throw new TypeError("just one of handlerName or handlerInterface can be given");if(i)this.handlerFactory=i;else{if(n)m.debug(`Device::constructor() | handler given: ${n}`);else if(n=$2(),n)m.debug(`Device::constructor() | detected handler: ${n}`);else throw new Error("device not supported");switch(n){case"Chrome74":this.handlerFactory=gm.createFactory();break;case"Safari12":this.handlerFactory=vm.createFactory();break;case"Firefox60":this.handlerFactory=vl.createFactory({supportsSendEncodings:!1});break;case"Firefox110":this.handlerFactory=vl.createFactory({supportsSendEncodings:!0});break;default:throw new TypeError(`unknown handlerName "${n}"`)}}}createTransport(e){const n=Ca();return new G2(o(this,Pd),ee(H({id:n},e),{handlerFactory:this.handlerFactory}))}}Pd=new WeakMap;const K2=2e3;var mr,Yo,Jt,Kt,va,Qo,No,Lo,ea,cs,xo,Xo,Ad,Md,Yh,Qh,qE,Xh,GE,Zh,$E,ep,JE,tp,$g,Od,Yu,Dd,Qu;class z2 extends Nt.EventEmitter{constructor(e,n,i){switch(super(),S(this,Xo),S(this,Md),S(this,Qh),S(this,Xh),S(this,Zh),S(this,ep),S(this,tp),S(this,Od),S(this,Dd),S(this,mr,void 0),S(this,Yo,void 0),S(this,Jt,void 0),S(this,Kt,void 0),S(this,va,void 0),S(this,Qo,void 0),S(this,No,void 0),S(this,Lo,{transportFailureCount:{send:0,recv:0},lastConnectionTime:0}),S(this,ea,void 0),S(this,cs,"all"),S(this,xo,void 0),T(this,mr,e),T(this,va,n),T(this,xo,i),T(this,Yo,new J2(i)),T(this,Qo,new B2(n,i)),i){case bt.CF:{T(this,No,Hn);break}case bt.HIVE:default:{T(this,No,In);break}}o(this,Xo,Ad).mediaState={send:{state:wr.NEW,reconnected:!1},recv:{state:wr.NEW,reconnected:!1}},se.hasFeature(ue.FORCE_RELAY)&&T(this,cs,"relay"),Q(this,Md,Yh).call(this)}get socket(){return o(this,va)}get socketHandler(){return o(this,Qo)}get sendTransport(){return o(this,Jt)}get recvTransport(){return o(this,Kt)}get events(){return o(this,No)}get nodeType(){return o(this,xo)}createTransports(e){return p(this,null,function*(){var n,i,r,s,a,c,d,h;se.hasFeature(ue.FORCE_RELAY)&&(m.info("ICE Transport Policy set to relay"),T(this,cs,"relay"));const u=yield Pt().getICEServers().catch(E=>(m.warn(`failed to get iceservers from server: ${E.message}`),[])),g=[];if(e.send){const E=se.hasFeature(ue.DISABLE_OPUS_DTX_CF),b=Q(this,Xh,GE).call(this,{iceServers:u,additionalSettings:{encodedInsertableStreams:(n=o(this,mr).getValue("modules").e2ee)==null?void 0:n.enabled},config:{enableHighBitrate:(s=(r=(i=o(this,mr).getValue("defaults").mediaConfiguration)==null?void 0:i.audio)==null?void 0:r.enableHighBitrate)!=null?s:!1,enableStereo:(d=(c=(a=o(this,mr).getValue("defaults").mediaConfiguration)==null?void 0:a.audio)==null?void 0:c.enableStereo)!=null?d:!1,enableDtx:o(this,xo)===bt.HIVE?!0:!!E},iceTransportPolicy:o(this,cs)});g.push(b)}if(e.recv){const E=Q(this,Zh,$E).call(this,{iceServers:u,additionalSettings:{encodedInsertableStreams:(h=o(this,mr).getValue("modules").e2ee)==null?void 0:h.enabled},iceTransportPolicy:o(this,cs)});g.push(E)}yield Promise.all(g)})}stopTransports(e){var n,i;if(e.send&&this.sendTransport!==void 0){const{id:r,serverId:s,direction:a}=o(this,Jt);m.info("Closing send transport",{transport:{id:r,serverId:s,type:a}}),o(this,Jt).close(),o(this,Jt).removeAllListeners(),T(this,Jt,void 0)}if(e.recv&&this.recvTransport!==void 0){const{id:r,serverId:s,direction:a}=o(this,Kt);m.info("Closing recv transport",{transport:{id:r,serverId:s,type:a}}),(n=o(this,Kt))==null||n.close(),(i=o(this,Kt))==null||i.removeAllListeners(),T(this,Kt,void 0)}Q(this,Md,Yh).call(this)}stopAllTransports(){m.info("Closing all transports"),this.stopTransports({send:!0,recv:!0})}connectTransportWithRetry(e){return p(this,null,function*(){const{id:n,serverId:i,direction:r}=e;Q(this,ep,JE).call(this,e);try{const s=se.hasFeature(ue.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3;return yield mm((a,c)=>p(this,null,function*(){a>0&&m.debug(`Retrying transport connect, count: ${a}`,{transport:{id:n,serverId:i,type:r}});try{if(e.closed)throw new vs("Cannot reconnect closed transport");yield Q(this,Qh,qE).call(this,e)}catch(d){if(d instanceof vs){c(d);return}throw m.error("Failed to connect transport, retrying",{transport:e,error:d}),d}}),{delayTime:100,strategy:"exponential",maxRetryCount:s}),e}catch(s){throw m.error(`Failed to connect send transport after retry: ${e.id}`,{error:s,transport:{id:n,serverId:i,type:r}}),e.close(),e.removeAllListeners(),s}})}handleErrors(e){throw new Error("Method not implemented.")}}mr=new WeakMap,Yo=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,va=new WeakMap,Qo=new WeakMap,No=new WeakMap,Lo=new WeakMap,ea=new WeakMap,cs=new WeakMap,xo=new WeakMap,Xo=new WeakSet,Ad=function(){return o(this,mr).getValue("connectionHandler")},Md=new WeakSet,Yh=function(){T(this,ea,{send:void 0,recv:void 0})},Qh=new WeakSet,qE=function(t){return p(this,null,function*(){const{id:e,direction:n}=t;if(m.info(`Connecting ${n} transport`,{transport:{id:e,type:n}}),!o(this,va).isConnected)throw new vs("Socket is not connected");if(t.connectionState==="closed")throw new vs("Transport is closed");try{yield t.connect(i=>Q(this,tp,$g).call(this,n,i)),m.info(`Connected ${n} transport`,{transport:{id:e,serverId:t.serverId,type:n}})}catch(i){throw o(this,Lo).transportFailureCount[n]+=1,i.message==="ice connection failed"?new vs(i.message):i}})},Xh=new WeakSet,GE=function(t){return p(this,null,function*(){var e,n;if(o(this,Jt)&&o(this,Jt).connected){m.info("Transport send is already connected",{transport:{id:(e=o(this,Jt))==null?void 0:e.id,serverId:(n=o(this,Jt))==null?void 0:n.serverId,type:"send"}});return}T(this,Jt,o(this,Yo).createTransport(ee(H({},t),{direction:"send"}))),ne.configureSendTransport(o(this,Jt))})},Zh=new WeakSet,$E=function(t){return p(this,null,function*(){var e,n;if(o(this,Kt)&&o(this,Kt).connected){m.info("Transport recv is already connected",{transport:{id:(e=o(this,Kt))==null?void 0:e.id,serverId:(n=o(this,Kt))==null?void 0:n.serverId,type:"recv"}});return}T(this,Kt,o(this,Yo).createTransport(ee(H({},t),{direction:"recv"}))),ne.configureRecvTransport(o(this,Kt))})},ep=new WeakSet,JE=function(t){const{direction:e,id:n}=t;t.on("connectionstatechange",i=>p(this,null,function*(){Q(this,Dd,Qu).call(this,{state:i,direction:e}),m.info(`Transport connection state changed for ${e} transport`,{transport:{id:n,serverId:t.serverId,type:e,status:i}});const r=()=>{const s=o(this,ea)[e];s!==void 0&&(clearTimeout(s),o(this,ea)[e]=void 0)};switch(i){case"connected":r(),o(this,Lo).lastConnectionTime=performance.now();break;case"disconnected":o(this,ea)[e]=setTimeout(()=>p(this,null,function*(){yield Q(this,Od,Yu).call(this,t)}),K2);break;case"failed":if(t.closed)return;r(),yield Q(this,Od,Yu).call(this,t);break}})),t.on("icecandidate",i=>p(this,null,function*(){m.debug("Sending iceCandidate:",{iceCandidate:i})})),t.on("datachannel:events",(i,r)=>p(this,null,function*(){var s,a;m.debug("Got data channel message on event:",{rtcChannel:{label:i,message:r}});try{switch(r.type){case"handshake":{const c={type:"handshake",payload:{message:"pong"}};t.sendResponseOverDC(i,HE(r),c);break}case"hub-disconnect":{m.debug(`media hub disconnected, full_reconnect: ${(s=r.payload)==null?void 0:s.full_reconnect}`),((a=r.payload)==null?void 0:a.full_reconnect)===!0&&this.handleErrors("rejoin");break}case"error":break;default:break}}catch{m.error(`Unable to handle the incoming datachannel message on channel ${i}`)}})),t.on("dc_error",()=>{t.direction==="recv"&&(m.warn("Events datachannel did not open in 5s",{country:w.location.country}),this.handleErrors("reconnectRecvTransport"))})},tp=new WeakSet,$g=function(t,e){return p(this,null,function*(){const n=t==="recv";try{const{sdp:i,type:r}=e,s={consuming:n,description:{sdp:i,type:r,target:n?Ai.SUBSCRIBER:Ai.PUBLISHER},producers:[]};return o(this,Qo).connectTransport(s)}catch(i){throw m.error(`Error in ${t} transport connection:`,{error:i,country:w.location.country}),i}})},Od=new WeakSet,Yu=function(t){return p(this,null,function*(){m.info("Called reconnect transport",{transport:t}),t.close(),t.removeAllListeners();const{direction:e}=t;switch(se.hasFeature(ue.HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED)&&o(this,va).isConnected&&o(this,Lo).transportFailureCount[e]>2&&(m.warn(`Multiple disconnections in ${e} transport, forcing relay`),T(this,cs,"relay")),yield this.createTransports({[e]:!0}),e){case"send":{yield this.connectTransportWithRetry(o(this,Jt)),m.info("Transport reconnected",{transport:o(this,Jt)}),L.emit(x.RESET_PRODUCER_STATE);break}case"recv":{yield this.connectTransportWithRetry(o(this,Kt)),m.info("Transport reconnected",{transport:o(this,Kt)}),L.emit(x.UPDATE_ACTIVE,{createAllConsumers:!0});break}default:m.warn("Unknown transport direction",{transport:t})}Q(this,Dd,Qu).call(this,{state:wr.CONNECTED,direction:e})})},Dd=new WeakSet,Qu=function(t){const{state:e,direction:n}=t;o(this,Xo,Ad).mediaState[n]={state:e,reconnected:!0},L.emit(x.TRANSPORT_STATE_UPDATE,H({transport:n},o(this,Xo,Ad).mediaState[n]))};var np,KE;class Y2{constructor(e){S(this,np),this.recvTransport=e,Q(this,np,KE).call(this)}create(e){return p(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n={type:"create_consumer",payload:{producers:e.map(({producerId:a,producingTransportId:c,kind:d,mimeType:h})=>({producerId:a,producingTransportId:c,preferredCodec:H(H({},d==="video"&&h?{video:h}:{}),d==="audio"&&h?{audio:h}:{})}))}},i=yield this.recvTransport.sendDataChannelMessage("events",n),r=new Map;e.forEach(a=>r.set(a.producerId,a));const s=new Map;return Object.entries(i).forEach(([a,c])=>{const d=r.get(c.producerId);d&&s.set(c.producerId,{consumerId:a,producingTransportId:d.producingTransportId,producingPeerId:d.producingPeerId,kind:d.kind,paused:d.pause,streamId:c.streamId,trackId:c.trackId,screenShare:d.screenShare,mimeType:d.mimeType,appData:{}})}),{consumerStates:s}})}negotiate(e,n,i){return p(this,null,function*(){try{m.debug(`Received offer over dc: ${e.sdp} for transport`);const r=yield this.recvTransport.setRemoteOffer(e),s={type:"answer",payload:{type:r.type,sdp:r.sdp}};return m.debug(`datachannel answer: ${JSON.stringify(s)}`),this.recvTransport.sendResponseOverDC(i,n,s),r}catch(r){throw m.error("datachannel:events::Error:",r),r.code!=="DC_NOT_FOUND"&&this.recvTransport.sendErrorOverDC(i,n,r),r}})}close(e){return p(this,null,function*(){if(!e.length)return{};const n=e.map(a=>a.id);m.info(`Closing consumers: ${JSON.stringify(n)}`);const i={type:"close_consumers",payload:{consumers:n}},r=yield this.recvTransport.sendDataChannelMessage("events",i),{failedConsumers:s}=r;return{failedConsumers:s}})}}np=new WeakSet,KE=function(){this.recvTransport.on("datachannel:events",(t,e)=>p(this,null,function*(){try{switch(e.type){case"negotiation":{const{sdp:n}=e.payload,i={sdp:n,type:"offer"};this.negotiate(i,HE(e),t);break}default:break}}catch{m.error(`Unable to handle the incoming datachannel message on channel ${t}`)}}))};class Q2{constructor(e,n,i,r){this.events=e,this.recvTransport=n,this.socket=i,this.socketHandler=r}create(e){return p(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n=new Map,i=[];e.forEach(d=>{const{producingPeerId:h,producerId:u,producingTransportId:g}=d;n.set(u,h),i.push({producingPeerId:h,producerId:u,producingTransportId:g})});const r=yield this.socketHandler.consume({requests:i,consumingTransportId:this.recvTransport.serverId}),s=new Map;e.forEach(d=>s.set(d.producerId,d));const a=new Map,c=[];return Object.entries(r.consumerStateMap).forEach(([d,h])=>{const u=s.get(d);if(!u)return;if(h.errorCode){if(m.warn(`Consumer request failed for producer ${d}`,{error:{message:h.errorCode}}),h.errorCode==="not_found_track_error"){m.error(`Track not found for producer: ${u.producerId}. This will not be retried.`);return}c.push(u);return}let g={};try{g=JSON.parse(h.producerState.appData)}catch{}a.set(d,{consumerId:h.consumerId,producingTransportId:u.producingTransportId,producingPeerId:u.producingPeerId,kind:u.kind,paused:u.pause,streamId:h.producerTrack.streamId,trackId:h.producerTrack.trackId,screenShare:u.screenShare,mimeType:u.mimeType,appData:g})}),{consumerStates:a,sessionDescription:r.sessionDescription,failedProducers:c}})}negotiate(e){return p(this,null,function*(){try{m.info("Negotiating socket consumer",{transport:this.recvTransport}),m.debug(`setting remote offer: ${JSON.stringify(e)} on recvTransport`,{transport:this.recvTransport});const n=yield this.recvTransport.setRemoteOffer(e),i={transportId:this.recvTransport.serverId,description:{sdp:n.sdp,type:n.type,target:Ai.SUBSCRIBER}};return m.debug(`sending renegotiate request: ${JSON.stringify(i)} on recvTransport`,{transport:this.recvTransport}),yield this.socket.sendMessagePromise(this.events.renegotiateSessionDescription,PP.toBinary(i)),m.info("Renegotiation done",{transport:this.recvTransport}),n}catch(n){m.error("Failed to renegotiate",{error:n});return}})}close(e){return p(this,null,function*(){if(!e.length)return{};const n=(i,r)=>p(this,null,function*(){const s=i.map(h=>h.localId);m.info(`Closing consumers: ${JSON.stringify(s)}`);const a={description:{sdp:r.sdp,type:r.type,target:Ai.SUBSCRIBER},consumerIds:s,consumingTransportId:this.recvTransport.serverId},c=yield this.socketHandler.closeConsumer(a),d=QA.fromBinary(c).description;return{sdp:d.sdp,type:d.type}});return this.recvTransport.awaitQueue.push(()=>this.recvTransport.closeConsumers(e,n),"close_consumer"),{}})}}class ym{constructor(e){this.socketHandler=e}static getMSIDFromSDP(e,n){return Go(e).media.filter(i=>n==="video"?i.type==="video":i.type==="audio").at(-1).msid}create(e){return p(this,arguments,function*({offer:n,kind:i,paused:r,appData:s,codecOptions:a,producingTransportId:c}){var d,h;const u=ym.getMSIDFromSDP(n.sdp,i),g={description:{sdp:n.sdp,type:n.type,target:Ai.PUBLISHER},paused:r,kind:i,msid:u,appData:JSON.stringify(s),screenShare:(d=s.screenShare)!=null?d:!1,mimeType:`${i}/${(h=a[0])==null?void 0:h.name}`,producingTransportId:c},{answer:E,producerId:b}=yield this.socketHandler.produce(g);return{answer:E,producerId:b}})}}var Zo,pa,us,ec,Nd,bi,ip,vr,tc,rp,zE,El,sp,ap,YE,op,QE,cp,XE,dp,ZE,lp,Jg,up,Kg;class X2 extends z2{constructor(e,n,i){super(e,n,i),S(this,rp),S(this,El),S(this,ap),S(this,op),S(this,cp),S(this,dp),S(this,lp),S(this,up),S(this,Zo,void 0),S(this,pa,void 0),S(this,us,void 0),S(this,ec,void 0),S(this,Nd,void 0),S(this,bi,void 0),S(this,ip,{producerCreationFailureCount:0,consumerCreationFailureCount:0,producerNotReadyFailureCount:0}),S(this,vr,[]),S(this,tc,void 0),T(this,Zo,e),o(this,rp,zE).mediaState={send:{state:wr.NEW,reconnected:!1},recv:{state:wr.NEW,reconnected:!1}},this.reset()}get socketHandler(){return super.socketHandler}get producers(){return o(this,pa)}get consumers(){return o(this,us)}get producerIdToConsumerIdMap(){return o(this,ec)}reset(){T(this,pa,new Map),T(this,us,new Map),T(this,ec,new Map)}setupTransports(e){return p(this,null,function*(){yield this.createTransports(e);let n,i;e.send&&(n=Q(this,ap,YE).call(this)),e.recv&&(i=Q(this,op,QE).call(this)),yield Promise.all([n,i])})}createProducer(e,n){return p(this,null,function*(){var i;if(!this.sendTransport||this.sendTransport.closed)throw new Error("Send transport is closed");try{const r=yield this.sendTransport.produce(e,Q(this,cp,XE).bind(this));return(i=e.appData)!=null&&i.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,r),Q(this,dp,ZE).call(this,r,n),r}catch(r){throw m.error("Failed to create producer",{error:r}),o(this,ip).producerCreationFailureCount+=1,r}})}closeProducer(e,n){return p(this,null,function*(){var i;const r=this.producers.get(e);if(!r){m.warn(`Producer with ID ${e} was not found`);return}n!=null&&n.stopTrack&&r.track.stop();try{yield this.sendTransport.closeProducer(r),(i=o(this,Zo).getValue("modules").e2ee)!=null&&i.enabled&&L.emit(x.E2EE_INACTIVE_PRODUCER,r)}catch(s){m.error("Failed to close producer on server",{error:s,producer:r})}})}closeAllProducers(){return Promise.all(Array.from(o(this,pa).entries()).map(([,e])=>e.close()))}createConsumer(e){return this.createConsumers([e])}createConsumers(e){return p(this,null,function*(){o(this,tc)||clearTimeout(o(this,tc)),T(this,vr,o(this,vr).concat(e)),yield Q(this,El,sp).call(this)})}closeConsumer(e){return this.closeConsumers([e])}closeConsumers(e){return p(this,null,function*(){if(!o(this,bi))return;const n=e.map(r=>this.consumers.get(r)).filter(r=>r!==void 0);if(n.length===0)return;const{failedConsumers:i}=yield o(this,bi).close(n);i!=null&&i.length&&m.warn("Failed to close some consumers",{consumerIds:i})})}closeAllConsumers(){return this.closeConsumers(Array.from(o(this,us).keys()))}switchConsumersToLayer(e,n){return p(this,null,function*(){const i=this.recvTransport.getDatachannel("events");if(!i){m.warn("events datachannel not found");return}const r={type:"switch_consumer_layer",payload:{consumerIds:e,layer:n}};yield i.request(r),m.info(`Consumers switched layers to ${n}`,{consumerIds:e})})}}Zo=new WeakMap,pa=new WeakMap,us=new WeakMap,ec=new WeakMap,Nd=new WeakMap,bi=new WeakMap,ip=new WeakMap,vr=new WeakMap,tc=new WeakMap,rp=new WeakSet,zE=function(){return o(this,Zo).getValue("connectionHandler")},El=new WeakSet,sp=function(){return p(this,null,function*(){if(!this.recvTransport||this.recvTransport.closed)throw new Error("Recv transport is closed");const t=500,e=o(this,vr).splice(0,o(this,vr).length);try{const n=e.filter(({producerId:s})=>!this.producers.get(s));if(n.length===0)return;const{consumers:i,failedProducers:r}=yield this.recvTransport.consume(n,Q(this,lp,Jg).bind(this),o(this,bi).negotiate.bind(o(this,bi)));i.forEach(Q(this,up,Kg).bind(this)),r!=null&&r.length&&(m.error("Failed to create consumers for producers",{producers:r}),T(this,vr,o(this,vr).concat(r)),T(this,tc,setTimeout(Q(this,El,sp).bind(this),t)))}catch(n){m.error("failed to consume on transport",{error:n})}})},ap=new WeakSet,YE=function(){return p(this,null,function*(){yield this.connectTransportWithRetry(this.sendTransport),T(this,Nd,new ym(this.socketHandler))})},op=new WeakSet,QE=function(){return p(this,null,function*(){switch(this.recvTransport.on("connect",()=>{o(this,ec).clear()}),yield this.connectTransportWithRetry(this.recvTransport),this.nodeType){case bt.CF:{T(this,bi,new Q2(this.events,this.recvTransport,this.socket,this.socketHandler));break}case bt.HIVE:default:T(this,bi,new Y2(this.recvTransport))}})},cp=new WeakSet,XE=function(t){return o(this,Nd).create(t)},dp=new WeakSet,ZE=function(t,e){t.on("close",(n,i)=>p(this,null,function*(){const{offer:r,reason:s}=n;if(m.info("producer::closing",{debuggingHint:s,producer:ee(H({},t),{status:"closing"})}),s!==yl){const a={producerId:t.id,description:{sdp:r.sdp,type:r.type,target:Ai.PUBLISHER}};try{const c=yield this.socketHandler.closeProducer(a),d={sdp:c==null?void 0:c.sdp,type:c==null?void 0:c.type};m.info("producer::closed",{producer:ee(H({},t),{status:"closed"})}),i({answer:d})}catch(c){m.error("producer close error",c)}}this.producers.delete(t.id),e()})),t.on("trackended",()=>{m.info("producer::trackended",{producer:ee(H({},t),{status:"UNKNOWN"})})}),o(this,pa).set(t.id,t)},lp=new WeakSet,Jg=function(t){return p(this,null,function*(){try{return yield this.recvTransport.canConsume(),yield o(this,bi).create(t)}catch(e){throw m.error("Error in consume request",{error:e}),e}})},up=new WeakSet,Kg=function(t){t.on("close",e=>p(this,null,function*(){m.debug("consumer closed",{consumer:{closureReason:e,id:t.id,kind:t.kind,appData:t.appData}}),o(this,us).delete(t.id),L.emit(x.CONSUMER_CLOSED,{id:t.id})})),o(this,us).set(t.id,t),this.producerIdToConsumerIdMap.set(t.producerId,t.id),L.emit(x.NEW_CONSUMER,{id:t.id,appData:t.appData,peerId:t.peerId})};var Ld,xd,Vd,Vo,nc,ic,Sl,Tl,Uo,mn,oi,ni,Yr,Qr,fr,bl,hp,eS,pp,tS,mp,nS,fp,iS;const gp=class{constructor({initialEnergyThreshold:t=.015,zeroCrossingThreshold:e=20,minVoiceDuration:n=3,hangoverFrames:i=5,noiseAdaptationRate:r=.95,voiceAdaptationRate:s=.99,minEnergyThreshold:a=.005,maxEnergyThreshold:c=.2,energyRatioThreshold:d=1.5,noiseHistorySize:h=50}={}){S(this,hp),S(this,pp),S(this,Ld,void 0),S(this,xd,void 0),S(this,Vd,void 0),S(this,Vo,void 0),S(this,nc,void 0),S(this,ic,void 0),S(this,Sl,void 0),S(this,Tl,void 0),S(this,Uo,void 0),S(this,mn,void 0),S(this,oi,void 0),S(this,ni,!1),S(this,Yr,0),S(this,Qr,0),S(this,fr,[]),S(this,bl,void 0),T(this,Vo,t),T(this,mn,t),T(this,Ld,e),T(this,xd,n),T(this,Vd,i),T(this,nc,r),T(this,ic,s),T(this,Sl,a),T(this,Tl,c),T(this,Uo,d),T(this,bl,h),T(this,oi,t/2)}get voiceDetected(){return o(this,ni)}processAudioChunk(t){var e,n;const i=Q(e=gp,mp,nS).call(e,t),r=Q(n=gp,fp,iS).call(n,t);return Q(this,hp,eS).call(this,i),i/o(this,oi)>o(this,Uo)&&i>o(this,mn)&&r>o(this,Ld)?(T(this,Yr,o(this,Yr)+1),T(this,Qr,o(this,Vd)),o(this,Yr)>=o(this,xd)&&T(this,ni,!0)):(T(this,Yr,0),o(this,Qr)>0?T(this,Qr,o(this,Qr)-1):o(this,ni)&&T(this,ni,!1),o(this,ni)||Q(this,pp,tS).call(this,i)),{energy:i,isVoice:o(this,ni)}}reset(){T(this,ni,!1),T(this,Yr,0),T(this,Qr,0),T(this,mn,o(this,Vo)),T(this,oi,o(this,Vo)/2),T(this,fr,[])}getThresholdInfo(){return{currentEnergyThreshold:o(this,mn),backgroundNoiseEnergy:o(this,oi),energyRatioThreshold:o(this,Uo)}}};let vp=gp;Ld=new WeakMap,xd=new WeakMap,Vd=new WeakMap,Vo=new WeakMap,nc=new WeakMap,ic=new WeakMap,Sl=new WeakMap,Tl=new WeakMap,Uo=new WeakMap,mn=new WeakMap,oi=new WeakMap,ni=new WeakMap,Yr=new WeakMap,Qr=new WeakMap,fr=new WeakMap,bl=new WeakMap,hp=new WeakSet,eS=function(t){o(this,ni)?T(this,mn,o(this,ic)*o(this,mn)+(1-o(this,ic))*t):T(this,mn,o(this,nc)*o(this,mn)+(1-o(this,nc))*o(this,oi)),T(this,mn,Math.max(o(this,Sl),Math.min(o(this,Tl),o(this,mn))))},pp=new WeakSet,tS=function(t){if(t<o(this,mn)*1.2)if(o(this,fr).push(t),o(this,fr).length>o(this,bl)&&o(this,fr).shift(),o(this,fr).length>=10){const e=[...o(this,fr)].sort((i,r)=>i-r),n=Math.floor(e.length/2);T(this,oi,e[n])}else T(this,oi,.95*o(this,oi)+.05*t)},mp=new WeakSet,nS=function(t){return Math.sqrt(t.map(e=>e*e).reduce((e,n)=>e+n)/t.length)},fp=new WeakSet,iS=function(t){let e=0;for(let n=1;n<t.length;n+=1)(t[n]>=0&&t[n-1]<0||t[n]<0&&t[n-1]>=0)&&(e+=1);return e},S(vp,mp),S(vp,fp);const Z2=60,ex=400;var sr,ar,ci,hs,ps,Bo,ya,rc,or,Xr,sc,yp,rS,Ud,Ep,Sp,sS,Xu,zg;const kl=class{constructor(t){S(this,yp),S(this,Sp),S(this,sr,void 0),S(this,ar,void 0),S(this,ci,void 0),S(this,hs,void 0),S(this,ps,void 0),S(this,Bo,void 0),S(this,ya,void 0),S(this,rc,void 0),S(this,or,void 0),S(this,Xr,void 0),S(this,sc,void 0),this.reportRequest=t,T(this,hs,new AudioContext),T(this,ps,o(this,hs).createAnalyser()),o(this,ps).fftSize=2048,T(this,rc,new vp)}set producerId(t){T(this,ci,t)}set audioTrack(t){T(this,Bo,t);const e=new MediaStream;e.addTrack(o(this,Bo)),o(this,hs).createMediaStreamSource(e).connect(o(this,ps))}start(){m.debug(`AudioActivityReporter: Starting audio activity reporter: ${o(this,ci)}`),o(this,sr)&&la(o(this,sr)),T(this,sr,Xd(()=>p(this,null,function*(){var t;if(!o(this,Bo)||!o(this,ci))return;const{energy:e}=Q(this,yp,rS).call(this),n=Q(t=kl,Ud,Ep).call(t,e);let i=.9;o(this,sc)!==n&&o(this,sc)?i=.9:n?i=.3:i=.5,T(this,ya,(o(this,ya)||0)*(1-i)+e*i)}),Z2)),o(this,ar)&&la(o(this,ar)),T(this,ar,Xd(Q(this,Sp,sS).bind(this),ex))}stop(){try{m.debug(`AudioActivityReporter: Stopping audio activity reporter: ${o(this,ci)}`),o(this,sr)&&(la(o(this,sr)),T(this,sr,void 0)),o(this,ar)&&(la(o(this,ar)),T(this,ar,void 0))}catch{}o(this,rc).reset()}};let Tp=kl;sr=new WeakMap,ar=new WeakMap,ci=new WeakMap,hs=new WeakMap,ps=new WeakMap,Bo=new WeakMap,ya=new WeakMap,rc=new WeakMap,or=new WeakMap,Xr=new WeakMap,sc=new WeakMap,yp=new WeakSet,rS=function(){var t;o(this,hs).state==="suspended"&&o(this,hs).resume().then(()=>{m.debug("AudioActivityReporter: AudioContext forced resumed")}).catch(s=>{m.error("AudioActivityReporter: Error resuming AudioContext",s)});const e=new Float32Array(o(this,ps).frequencyBinCount);o(this,ps).getFloatTimeDomainData(e);const{energy:n,isVoice:i}=o(this,rc).processAudioChunk(e),r=Q(t=kl,Xu,zg).call(t,n);return se.hasFeature(ue.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&m.debug(`AudioActivityReporter: producer: ${o(this,ci)}, energy: ${o(this,ya)},
21
+ ${t}`}const Aa={maxInvocations:5,period:1};function on(t,e){return function(n,i,r){const s=r.value;let a=0,c=Date.now();return r.value=function(...d){const h=Date.now(),u=e?this[e]:t;if(h-c>u.period*1e3&&(c=h,a=0),a>=u.maxInvocations)throw new D(`Method rate limit ${u.maxInvocations} invocations/${u.period}sec exceeded`,"0013");return a+=1,s.apply(this,d)},r}}var jN=Object.defineProperty,WN=Object.getOwnPropertyDescriptor,xt=(t,e,n,i)=>{for(var r=i>1?void 0:i?WN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&jN(e,n,r),r};const HN=["text","image","file","custom","poll"],yd={maxInvocations:180,period:60};var he,Os,pt,Ds,Wc,Nu,Tg,Hc,Lu,bg;let kt=(bg=class extends gn{constructor(t,e,n,i,r){super(),S(this,Nu),S(this,Hc),y(this,"messages"),y(this,"channels",[]),S(this,he,void 0),S(this,Os,void 0),S(this,pt,void 0),S(this,Ds,void 0),S(this,Wc,void 0),y(this,"maxTextLimit",2e3),T(this,Wc,t),T(this,pt,e),T(this,Ds,n),T(this,he,i),T(this,Os,r),this.messages=[]}setMaxTextLimit(t){this.maxTextLimit=t}sendMessageInternal(t,e,n){return p(this,arguments,function*(i,r,s,a={}){switch(i.type){case"text":{const c=a.replyTo&&a.replyTo.type==="text"?FN(i.message,a.replyTo.message):i.message;yield this.sendTextMessageInternal(c,r,s);break}case"image":yield this.sendImageMessageInternal(i.image,r,s);break;case"file":yield this.sendFileMessageInternal(i.file,r,s);break;default:m.error("sendMessage::message_type_not_supported",{dyteChat:{messageType:i.type}});break}})}sendTextMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(t.length>this.maxTextLimit)throw new D("Max character limit breached","0503");if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.text))throw m.error("sendTextMessage::private_chat_permission_denied"),new D("Could not send message to private chat.","0501")}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.text))throw m.error("sendTextMessage::public_chat_permission_denied"),new D("Could not send message to public chat.","0501");if(!t)throw m.error("sendTextMessage::message_can_not_be_empty"),new D("Message can not be empty.","0502");if(n){o(this,pt).sendMessageToChannel(t,Jt.TEXT,n);return}let h=[];e&&e.length>0&&(e.push(o(this,he).id),h=o(this,Os).joined.toArray().filter(u=>e.includes(u.id)).map(u=>u.userId),h.push(o(this,he).userId)),o(this,pt).sendMessage(t,Jt.TEXT,e)})}sendImageMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.files)){m.error("sendImageMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){m.error("sendImageMessage::permission_denied");return}if(!t){m.error("sendImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(t.type)){m.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:t.type}});return}try{const h=Pt(),{getLocation:u,putLocation:g}=yield h.getPresignedUrls(t.name,o(this,he).config.viewType);if(yield h.uploadFile(t,g),n){o(this,pt).sendMessageToChannel(u,Jt.IMAGE,n);return}let E=[];e&&e.length>0&&(e.push(o(this,he).id),E=o(this,Os).joined.toArray().filter(b=>e.includes(b.id)).map(b=>b.userId),E.push(o(this,he).userId)),o(this,pt).sendMessage(u,Jt.IMAGE,e)}catch{throw new D("Error sending image message.","0500")}})}sendFileMessageInternal(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(e&&e.length>0){if(!((i=o(this,he).permissions)!=null&&i.chatPrivate.canSend)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.files)){m.error("sendFileMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){m.error("sendFileMessage::permission_denied");return}if(!t){m.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const h=Pt(),{getLocation:u,putLocation:g}=yield h.getPresignedUrls(t.name,o(this,he).config.viewType);if(yield h.uploadFile(t,g),n){o(this,pt).sendMessageToChannel(JSON.stringify({link:u,name:t.name,size:"size"in t?t.size:0}),Jt.FILE,n);return}let E=[];e&&e.length>0&&(e.push(o(this,he).id),E=o(this,Os).joined.toArray().filter(k=>e.includes(k.id)).map(k=>k.userId),E.push(o(this,he).userId));const b=JSON.stringify({link:u,name:t.name,size:"size"in t?t.size:0});o(this,pt).sendMessage(b,Jt.FILE,e)}catch{throw new D("Error sending file message.","0500")}})}get rateLimits(){return yd}updateRateLimits(t,e){yd.maxInvocations=t,yd.period=e}sendTextMessage(t,e){return p(this,null,function*(){return this.sendTextMessageInternal(t,e)})}sendCustomMessage(t,e){return p(this,null,function*(){var n,i,r,s,a,c,d,h,u,g,E,b,k,A,M;if(e&&e.length>0){if(!((n=o(this,he).permissions)!=null&&n.chatPrivate.canSend)||!((i=o(this,he).permissions)!=null&&i.chatPrivate.files)||!((r=o(this,he).permissions)!=null&&r.chatPrivate.text)){m.error("sendCustomMessage::private_chat_permission_denied");return}}else if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.files)||!((u=(h=o(this,he).permissions)==null?void 0:h.chatPublic)!=null&&u.text)){m.error("sendCustomMessage::permission_denied");return}const B=X=>p(this,null,function*(){try{if(typeof X=="string")return{link:X};const O=Pt(),{getLocation:J,putLocation:me}=yield O.getPresignedUrls(X.name,o(this,he).config.viewType);return yield O.uploadFile(X,me),{link:J,type:X.type,name:X.name,size:X.size}}catch{throw new D("Error sending image message.","0500")}}),K=ee(H({},t),{files:yield Promise.all((E=(g=t.files)!=null?g:[])==null?void 0:E.map(X=>p(this,null,function*(){return B(X)}))),images:yield Promise.all((k=(b=t.images)!=null?b:[])==null?void 0:k.map(X=>p(this,null,function*(){return B(X)}))),videos:yield Promise.all((M=(A=t.videos)!=null?A:[])==null?void 0:M.map(X=>p(this,null,function*(){return B(X)})))});o(this,pt).sendMessage(JSON.stringify(K),Jt.CUSTOM,e)})}sendImageMessage(t,e){return p(this,null,function*(){return this.sendImageMessageInternal(t,e)})}sendFileMessage(t,e){return p(this,null,function*(){return this.sendFileMessageInternal(t,e)})}sendMessage(t,e){return p(this,null,function*(){return this.sendMessageInternal(t,e)})}editTextMessage(t,e,n){return p(this,null,function*(){var i,r,s,a,c,d;if(((r=(i=o(this,he).permissions)==null?void 0:i.chatMessage)==null?void 0:r.canEdit)==="NONE")throw new D("Not permitted to edit messages","0501");if(!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.canSend)||!((d=(c=o(this,he).permissions)==null?void 0:c.chatPublic)!=null&&d.text)){m.error("editTextMessage::permission_denied");return}if(!e){m.error("editTextMessage::message_can_not_be_empty");return}o(this,pt).editMessage(t,e,Jt.TEXT,n)})}editImageMessage(t,e,n){return p(this,null,function*(){var i,r,s,a;if(!((r=(i=o(this,he).permissions)==null?void 0:i.chatPublic)!=null&&r.canSend)||!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.files)){m.error("editImageMessage::permission_denied");return}if(!e){m.error("editImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(e.type)){m.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:e.type}});return}try{const c=Pt(),{getLocation:d,putLocation:h}=yield c.getPresignedUrls(e.name,o(this,he).config.viewType);yield c.uploadFile(e,h),o(this,pt).editMessage(t,d,Jt.IMAGE,n)}catch{throw new D("Error editing image message.","0500")}})}editFileMessage(t,e,n){return p(this,null,function*(){var i,r,s,a;if(!((r=(i=o(this,he).permissions)==null?void 0:i.chatPublic)!=null&&r.canSend)||!((a=(s=o(this,he).permissions)==null?void 0:s.chatPublic)!=null&&a.files)){m.error("sendFileMessage::permission_denied");return}if(!e){m.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const c=Pt(),{getLocation:d,putLocation:h}=yield c.getPresignedUrls(e.name,o(this,he).config.viewType);yield c.uploadFile(e,h),o(this,pt).editMessage(t,JSON.stringify({link:d,name:e.name,size:"size"in e?e.size:0}),Jt.FILE,n)}catch{throw new D("Error editing file message.","0500")}})}editMessage(t,e,n){return p(this,null,function*(){switch(e.type){case"text":{this.editTextMessage(t,e.message,n);break}case"image":{this.editImageMessage(t,e.image,n);break}case"file":{this.editFileMessage(t,e.file,n);break}default:{m.error("editMessage::message_type_not_supported",{dyteChat:{messageType:e.type}});break}}})}deleteMessage(t,e){return p(this,null,function*(){var n,i;if(((i=(n=o(this,he).permissions)==null?void 0:n.chatMessage)==null?void 0:i.canDelete)==="NONE")throw new D("Not permitted to delete messages","0501");o(this,pt).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 p(this,null,function*(){if(!o(this,Hc,Lu))throw new D("Can`t pin message without joining room","0505");if(!o(this,he).permissions.pinParticipant)throw new D("You do not have permission to pin messages.","0501");const e=this.messages.find(n=>n.id===t);if(e){o(this,pt).setPinState(e,!0);return}throw new D(`No message found with id: ${t}`,"0504")})}unpin(t){return p(this,null,function*(){if(!o(this,Hc,Lu))throw new D("Can`t unpin message without joining room","0505");if(!o(this,he).permissions.pinParticipant)throw new D("You do not have permission to unpin messages.","0501");const e=this.messages.find(n=>n.id===t);if(e){o(this,pt).setPinState(e,!1);return}throw new D(`No message found with id: ${t}`,"0504")})}getMessages(t,e,n,i=0,r=void 0){return p(this,null,function*(){const s=yield o(this,pt).getChatMessagesPaginated(t,e,n,i,r);return{messages:s.messages.map(a=>Ci.formatSocketServiceMessage(a)),next:s.next}})}createChannel(t,e){return p(this,arguments,function*(n,i,r={}){var s;const a=(s=o(this,he).permissions)==null?void 0:s.chatChannel;if(a){if(a.canCreate==="NONE")throw new D("Not permitted to create channels","0501");if(r.visibility==="public"&&!(a.canCreate==="PUBLIC"||a.canCreate==="ALL"))throw new D("Not permitted to create public channels","0501");if(r.visibility==="private"&&!(a.canCreate==="PRIVATE"||a.canCreate==="ALL"))throw new D("Not permitted to create private channels","0501")}if(!n||n.trim().length===0)throw new D("channel name cannot be empty.","0510");const c=[...new Set([...i,o(this,he).userId])];return yield o(this,Ds).createChannel(n.trim(),c,r.displayPictureUrl,r.visibility,r.isDirectMessage)})}updateChannel(t,e){var n,i,r,s,a;const c=this.channels.find(u=>u.id===t),d=(n=o(this,he).permissions)==null?void 0:n.chatChannel;if(d){if(d.canUpdate==="NONE")throw new D("Not permitted to update channels","0501");if(c.visibility==="public"&&!(d.canUpdate==="PUBLIC"||d.canUpdate==="ALL"))throw new D("Not permitted to update public channels","0501");if(c.visibility==="private"&&!(d.canUpdate==="PRIVATE"||d.canUpdate==="ALL"))throw new D("Not permitted to update private channels","0501")}const h={memberIds:(i=e.memberIds)!=null?i:c.memberIds,displayName:(r=e.displayName)!=null?r:c.displayName,displayPictureUrl:(s=e.displayPictureUrl)!=null?s:c.displayPictureUrl,visibility:(a=e.visibility)!=null?a:c.visibility};return o(this,Ds).updateChannel(t,h)}sendMessageToChannel(t,e){return p(this,arguments,function*(n,i,r={}){return this.sendMessageInternal(n,null,i,r)})}getChannelMembers(t){return p(this,null,function*(){return o(this,Ds).getChannelMembers(t)})}searchMessages(t){return p(this,arguments,function*(e,n={}){if(!se.hasFeature(ue.FEAT_CHAT_SDK_SEARCH))throw new D("searchMessages is temporarily disabled!","0506");return(yield o(this,pt).searchMessages(e,n)).map(Ci.formatSocketServiceMessage)})}markLastReadMessage(t,e){return p(this,null,function*(){yield o(this,pt).markLastReadMessage(t,e);const n=this.channels.find(i=>i.id===t);if(n){const i=ee(H({},n),{unreadCount:0});this.channels=this.channels.map(r=>r.id===t?i:r),this.emit("channelMessageUpdate",i)}})}get pinned(){return this.messages.filter(t=>t.pinned)}},he=new WeakMap,Os=new WeakMap,pt=new WeakMap,Ds=new WeakMap,Wc=new WeakMap,Nu=new WeakSet,Tg=function(){return o(this,Wc).getValue("connectionHandler")},Hc=new WeakSet,Lu=function(){return o(this,Nu,Tg).socketJoined===!0},bg);xt([w.trace("DyteChat.sendTextMessage"),on(yd)],kt.prototype,"sendTextMessage",1);xt([w.trace("DyteChat.sendImageMessage"),on({maxInvocations:20,period:60})],kt.prototype,"sendImageMessage",1);xt([w.trace("DyteChat.sendFileMessage"),on({maxInvocations:20,period:60})],kt.prototype,"sendFileMessage",1);xt([w.trace("DyteChat.sendMessage"),on({maxInvocations:180,period:60})],kt.prototype,"sendMessage",1);xt([w.trace("DyteChat.editTextMessage")],kt.prototype,"editTextMessage",1);xt([w.trace("DyteChat.editImageMessage")],kt.prototype,"editImageMessage",1);xt([w.trace("DyteChat.editFileMessage")],kt.prototype,"editFileMessage",1);xt([w.trace("DyteChat.editMessage")],kt.prototype,"editMessage",1);xt([w.trace("DyteChat.deleteMessage")],kt.prototype,"deleteMessage",1);xt([w.trace("DyteChat.createChannel")],kt.prototype,"createChannel",1);xt([w.trace("DyteChat.updateChannel")],kt.prototype,"updateChannel",1);xt([w.trace("DyteChat.sendMessageToChannel")],kt.prototype,"sendMessageToChannel",1);xt([w.trace("DyteChat.getChannelMembers")],kt.prototype,"getChannelMembers",1);xt([w.trace("DyteChat.searchMessages")],kt.prototype,"searchMessages",1);xt([w.trace("DyteChat.markLastReadMessage")],kt.prototype,"markLastReadMessage",1);kt=xt([Lt("0500")],kt);var qN=Object.defineProperty,GN=Object.getOwnPropertyDescriptor,JN=(t,e,n,i)=>{for(var r=i>1?void 0:i?GN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&qN(e,n,r),r},xu,kg;const Wr=(kg=class{constructor(t,e,n,i,r){y(this,"chat"),y(this,"chatSocketHandler"),y(this,"chatChannelSocketHandler"),y(this,"self"),S(this,xu,void 0),T(this,xu,t),this.chatSocketHandler=e,this.chatChannelSocketHandler=n,this.chat=new kt(t,e,n,i,r),this.self=i,this.setupEvents()}static init(t,e,n,i,r){return p(this,null,function*(){return new Wr(t,e,n,i,r)})}static formatMessage(t){return ee(H({},t),{time:new Date(t.time),type:HN[t.type]})}static formatSocketServiceMessage(t){const e=t.createdAt*1e3,n={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(n.type){case Jt.TEXT:{n.message=t.payload;break}case Jt.IMAGE:{n.link=t.payload;break}case Jt.FILE:{const{link:i,name:r,size:s}=JSON.parse(t.payload);n.link=i,n.name=r,n.size=s;break}case Jt.CUSTOM:{const{html:i,images:r,message:s,videos:a,files:c}=JSON.parse(t.payload);n.message=s,n.html=i,n.images=r,n.videos=a,n.files=c;break}}return Wr.formatMessage(n)}getChatMessages(){return p(this,null,function*(){if(this.self.config.viewType==="LIVESTREAM"||this.self.config.viewType==="CHAT"||se.hasFeature(ue.FEAT_PAGINATED_CHAT))return;const t=yield this.chatSocketHandler.getChatMessages();if(!(t!=null&&t.payload))return;const e=pE.fromBinary(t.payload).messages;this.chat.messages=e.map(n=>Wr.formatSocketServiceMessage(n))})}setupEvents(){L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){this.getChatMessages()})),this.chatSocketHandler.on(Ge.sendMessageToRoom,t=>{const e=Wr.formatSocketServiceMessage(t.message);if(!e.channelId)this.chat.messages=[...this.chat.messages,e];else{const n=this.chat.channels.find(i=>i.id===e.channelId);n&&(n.latestMessage=e,n.unreadCount+=1,this.chat.emit("channelMessageUpdate",n))}this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ge.sendMessageToPeers,t=>{const e=Wr.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(Ge.editMessage,t=>{const e=Wr.formatSocketServiceMessage(t.message);if(e.channelId){this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages});return}const n=this.chat.messages.findIndex(i=>i.id===e.id);n!==-1&&(this.chat.messages[n]=e,this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages}))}),this.chatSocketHandler.on(Ge.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[n]=this.chat.messages.splice(e,1);this.chat.emit("chatUpdate",{action:"delete",message:n,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ss.createChatChannel,t=>{const[e]=t.chatChannels,n=Es.formatChannel(e);this.chat.channels.push(n),this.chat.emit("channelCreate",n)}),this.chatSocketHandler.on(Ge.pinMessage,t=>{const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const n=this.chat.messages[e];n.pinned=t.pinned,this.chat.messages[e]=n,this.chat.emit("chatUpdate",{action:"edit",message:n,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(ss.updateChatChannel,t=>{const[e]=t.chatChannels,n=Es.formatChannel(e);this.chat.channels=this.chat.channels.map(i=>i.id===n.id?n:i),this.chat.emit("channelUpdate",n)})}},xu=new WeakMap,kg);let Ci=Wr;JN([w.trace("ChatController.setupEvents")],Ci.prototype,"setupEvents",1);var $N=Object.defineProperty,KN=Object.getOwnPropertyDescriptor,zN=(t,e,n,i)=>{for(var r=i>1?void 0:i?KN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&$N(e,n,r),r},Vu,wg,Uu,_g,Ua,Ba,qc,Ig;let Lh=(Ig=class extends gn{constructor(t,e,n){super(),S(this,Vu),S(this,Uu),y(this,"items"),S(this,Ua,void 0),S(this,Ba,void 0),S(this,qc,void 0),T(this,qc,t),T(this,Ua,e),T(this,Ba,n),this.items=[]}create(t,e,n=!1,i=!1){return p(this,null,function*(){if(!o(this,Uu,_g))throw new D("Can't create polls without joining room","0705");if(!o(this,Ua).permissions.polls.canCreate){m.error("DytePolls::create::permission_denied");return}if(!t||!e){m.error("DytePolls::question_and_options_can_not_be_empty",{dytePolls:{hasQuestion:!!t,optionsLength:e==null?void 0:e.length}});return}if(e.length<2){m.error("DytePolls::there_must_be_at_least_two_options",{dytePolls:{hasQuestion:!!t,optionsLength:e.length}});return}yield o(this,Ba).createPoll(t,e,n,i)})}vote(t,e){return p(this,null,function*(){if(!o(this,Ua).permissions.polls.canVote){m.error("DytePolls::vote::permission_denied");return}yield o(this,Ba).votePoll(t,e)})}},Vu=new WeakSet,wg=function(){return o(this,qc).getValue("connectionHandler")},Uu=new WeakSet,_g=function(){var t;return((t=o(this,Vu,wg))==null?void 0:t.socketJoined)===!0},Ua=new WeakMap,Ba=new WeakMap,qc=new WeakMap,Ig);Lh=zN([Lt("0700")],Lh);var YN=Object.defineProperty,QN=Object.getOwnPropertyDescriptor,XN=(t,e,n,i)=>{for(var r=i>1?void 0:i?QN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&YN(e,n,r),r},Fa,Ns,Cg;const Js=(Cg=class{constructor(t,e,n){y(this,"polls"),S(this,Fa,void 0),S(this,Ns,void 0),this.polls=new Lh(t,e,n),T(this,Fa,e),T(this,Ns,n),this.setupEvents()}static init(t,e,n){return p(this,null,function*(){return new Js(t,e,n)})}canViewPolls(){return o(this,Fa).permissions.polls.canView}setupEvents(){const t={[Si.createPoll]:i=>{i.poll&&this.updatePoll(Js.formatSocketServicePoll(i.poll))},[Si.updatePoll]:i=>{i.poll&&this.updatePoll(Js.formatSocketServicePoll(i.poll))},[Si.votePoll]:i=>{i.poll&&this.updatePoll(Js.formatSocketServicePoll(i.poll))}},e=()=>{L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{o(this,Ns).on(i,t[i])})},n=()=>{L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{o(this,Ns).removeListeners(i)})};o(this,Fa).permissions.on("permissionsUpdate",i=>p(this,null,function*(){var r;(r=i==null?void 0:i.polls)!=null&&r.canView?(yield this.getPolls(),e()):(this.polls.items=[],n())})),this.canViewPolls()&&e()}updatePoll(t){if(!this.canViewPolls())return;const e=this.polls.items.findIndex(n=>n.id===t.id);if(e>-1){const n=JSON.stringify(this.polls.items[e]);this.polls.items[e]=t,n!==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 p(this,null,function*(){const t=yield o(this,Ns).getPolls();if(!(t!=null&&t.payload))return;const{polls:e}=dN.fromBinary(t.payload);this.polls.items=e.map(n=>Js.formatSocketServicePoll(n))})}static formatSocketServicePoll(t){const e=t.options.map(n=>({count:n.count,text:n.text,votes:n.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}}},Fa=new WeakMap,Ns=new WeakMap,Cg);let yE=Js;XN([w.trace("PollController.setupEvents")],yE.prototype,"setupEvents",1);var ZN=Object.defineProperty,eL=Object.getOwnPropertyDescriptor,tL=(t,e,n,i)=>{for(var r=i>1?void 0:i?eL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ZN(e,n,r),r},EE=(t=>(t[t.User=0]="User",t[t.Meeting=1]="Meeting",t))(EE||{}),ja,Gc,Bu,Ls,Jc,Rg;let xh=(Rg=class extends gn{constructor(t,e,n,i,r){super(),S(this,Gc),y(this,"selfActiveTab"),y(this,"broadcastTabChanges"),S(this,ja,void 0),S(this,Ls,void 0),S(this,Jc,void 0),y(this,"viewType"),y(this,"meetingStartedTimestamp"),y(this,"meetingTitle"),y(this,"sessionId"),T(this,ja,t),T(this,Ls,e),this.viewType=n,T(this,Jc,i),this.meetingTitle=r,this.broadcastTabChanges=e.permissions.canSpotlight}get socketState(){return o(this,Gc,Bu).socketState}get mediaState(){return o(this,Gc,Bu).mediaState}get meetingId(){return o(this,ja).getValue("meetingId")}setBroadcastTabChanges(t){if(!o(this,Ls).permissions.canSpotlight)throw m.error("DyteSpotlight::setSpotlighted::permission_denied"),new D("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 n;m.info("DyteSpotlight::setActiveTab",{spotlight:{currentTab:{id:t.id,type:t.type}}}),this.selfActiveTab=t,e===0&&this.emit("selfTabUpdate",t),(n=o(this,Ls).permissions)!=null&&n.canSpotlight&&this.broadcastTabChanges&&e===0&&this.assertActiveTabToRoom()}assertActiveTabToRoom(){o(this,Jc).broadcastMessage("spotlight",{userId:o(this,Ls).userId,currentTab:this.selfActiveTab})}},ja=new WeakMap,Gc=new WeakSet,Bu=function(){return o(this,ja).getValue("connectionHandler")},Ls=new WeakMap,Jc=new WeakMap,Rg);xh=tL([Lt("0800")],xh);function nL(t){let e="",n=[""];const i=[n];let r=0,s=0,a=!0,c;for(c of t)c==='"'?(a&&c===e&&(n[r]+=c),a=!a):c===","&&a?c=n[++r]="":c===`
22
+ `&&a?(e==="\r"&&(n[r]=n[r].slice(0,-1)),n=i[++s]=[c=""],r=0):n[r]+=c,e=c;return i}var iL=Object.defineProperty,rL=Object.getOwnPropertyDescriptor,SE=(t,e,n,i)=>{for(var r=i>1?void 0:i?rL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&iL(e,n,r),r};let Tr=class extends gn{constructor(){super(),y(this,"transcripts"),this.transcripts=[]}static init(t){return p(this,null,function*(){const e=new Tr;try{t&&e.getActiveTranscript()}catch(n){m.error("Error fetching active transcriptions ",n)}return e})}static parseTranscript(t,e=!1){try{if(!t)return;const[[n,i,r,s,a,c]]=nL(t);return{id:Ca(),name:a,peerId:i,userId:r,customParticipantId:s,transcript:c,isPartialTranscript:e,date:new Date(parseInt(n,10)*1e3)}}catch(n){m.error(`Failed to parse transcript: ${t}`,n);return}}static parseTranscripts(t){return t?t.split(`
23
+ `).map(e=>Tr.parseTranscript(e,!1)).filter(Boolean):[]}getActiveTranscript(){return p(this,null,function*(){try{const t=Pt(),{transcript:e}=yield t.getActiveTranscript();this.transcripts=Tr.parseTranscripts(e)}catch{}})}onTranscript(t){return p(this,null,function*(){var e;const n=this.transcripts.filter(({peerId:i})=>i===t.peerId);if((e=n==null?void 0:n.at(-1))!=null&&e.isPartialTranscript){const i=n.at(-1);i.transcript=t.transcript,i.isPartialTranscript=t.isPartialTranscript,this.emit("transcript",i);return}this.transcripts=[...this.transcripts,t],this.emit("transcript",t)})}};SE([w.trace("DyteAi.getActiveTranscript")],Tr.prototype,"getActiveTranscript",1);Tr=SE([Lt("0000")],Tr);var sL=Object.defineProperty,aL=Object.getOwnPropertyDescriptor,oL=(t,e,n,i)=>{for(var r=i>1?void 0:i?aL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&sL(e,n,r),r},Lr,Wa,Fu,Pg;const TE=(Pg=class{constructor(t,e,n,i,r,s){y(this,"meta"),y(this,"ai"),S(this,Lr,void 0),S(this,Wa,void 0),y(this,"aiSocketHandler"),S(this,Fu,void 0),T(this,Fu,t),this.meta=new xh(t,e,e.config.viewType,n,s),this.ai=i,T(this,Lr,e),T(this,Wa,n),this.aiSocketHandler=r,e.config.viewType!==Yt.Chat&&this.setupEvents()}static init(t,e,n,i,r){return p(this,null,function*(){const s=yield Tr.init(e.permissions.transcriptionEnabled);return new TE(t,e,n,s,i,r)})}conditionallySetActiveTab(t){var e;t!=null&&t.currentTab&&((e=this.meta.selfActiveTab)==null?void 0:e.id)!==t.currentTab.id&&(this.meta.setSelfActiveTab(t.currentTab,EE.Meeting),this.meta.emit("activeTabUpdate",t.currentTab))}setupEvents(){L.on(x.TRANSPORT_STATE_UPDATE,t=>{this.meta.emit("mediaConnectionUpdate",t)}),L.on(x.SOCKET_STATE_UPDATE,t=>{this.meta.emit("socketConnectionUpdate",t)}),L.on(x.ROOM_STATE,({createdAt:t,roomUuid:e})=>{const n=this.meta.meetingStartedTimestamp;if(e&&(this.meta.sessionId=e),t&&!n){const i=new Date(t*1e3);this.meta.meetingStartedTimestamp=i,this.meta.emit("meetingStartTimeUpdate",{meetingStartedTimestamp:this.meta.meetingStartedTimestamp})}}),L.on(x.PRODUCER_SCORE_UPDATE,({score:t})=>{t<5&&this.meta.emit("poorConnection",{score:t})}),o(this,Lr).permissions.canSpotlight&&(m.info("DyteMetaController::Asserting Spotlight"),this.meta.selfActiveTab&&o(this,Wa).broadcastMessage("spotlight",{userId:o(this,Lr).userId,currentTab:this.meta.selfActiveTab})),L.on(x.PEER_JOINED_INTERNAL,t=>p(this,null,function*(){o(this,Lr).permissions.canSpotlight&&this.meta.selfActiveTab&&o(this,Wa).broadcastToPeers("spotlight",[t.id],{userId:o(this,Lr).userId,currentTab:this.meta.selfActiveTab})})),L.on(x.ROOM_MESSAGE,t=>{var e,n;let i;if("type"in t){if(t.type!=="spotlight")return;i=H(H({},t),t.payload)}else if("roomMessageType"in t){if(t.roomMessageType!=="spotlight")return;i=t}else return;m.info("Spotlight Assertion Received",{spotlight:{spotlighter:{id:i.userId},currentTab:{id:(e=i.currentTab)==null?void 0:e.id,type:(n=i.currentTab)==null?void 0:n.type}}}),this.conditionallySetActiveTab(i)}),L.on(x.MESSAGE,t=>{var e,n;let i;if("type"in t){if(t.type!=="spotlight")return;i=H(H({},t),t.payload)}else if("roomMessageType"in t){if(t.roomMessageType!=="spotlight")return;i=t}else return;m.info("Spotlight Assertion Received",{spotlight:{spotlighter:{id:i.userId},currentTab:{id:(e=i.currentTab)==null?void 0:e.id,type:(n=i.currentTab)==null?void 0:n.type}}}),this.conditionallySetActiveTab(i)}),this.aiSocketHandler.on(Y.transcript,t=>{const{meetingId:e,transcript:n,isPartial:i}=t,r=Tr.parseTranscript(n,i);if(!r){m.warn("Received empty transcript data");return}this.ai.onTranscript(r),this.meta.emit("transcript",r);const{peerId:s,name:a,transcript:c}=r;m.debug(`${e} Received transcript for peer ${s} - ${a}: ${c}`)})}},Lr=new WeakMap,Wa=new WeakMap,Fu=new WeakMap,Pg);let bE=TE;oL([w.trace("MetaController.setupEvents")],bE.prototype,"setupEvents",1);var cL=Object.defineProperty,dL=Object.getOwnPropertyDescriptor,Rs=(t,e,n,i)=>{for(var r=i>1?void 0:i?dL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&cL(e,n,r),r},Un,vo,be,Ed,gi,si,Sd,Vh,yo,Td;class Cr extends gn{constructor(e,n,i,r,s){super(),S(this,Sd),S(this,yo),S(this,Un,void 0),S(this,vo,void 0),S(this,be,void 0),S(this,Ed,void 0),S(this,gi,void 0),S(this,si,void 0),T(this,si,e),T(this,Un,r),T(this,vo,s),T(this,be,n),T(this,Ed,i),T(this,gi,[]),this.setupEvents()}get status(){return o(this,si).getValue("stageStatus")}setupEvents(){const e={[x.GET_STAGE_REQUESTS]:r=>p(this,null,function*(){T(this,gi,r)}),[x.UPDATE_STAGE_REQUESTS]:r=>p(this,[r],function*({add:s}){const a=o(this,gi).length,{stageRequests:c}=this.getAccessRequests();(s||c.length>a)&&this.emit("newStageRequest",{count:c.length}),this.emit("stageAccessRequestUpdate",c)})},n=()=>{Object.entries(e).forEach(([r,s])=>{L.onAsync(r,s)})},i=()=>{Object.entries(e).forEach(([r,s])=>{L.removeListener(r,s)})};o(this,be).permissions.on("permissionsUpdate",r=>{const{canAcceptProductionRequests:s}=r;s!==void 0&&(o(this,be).permissions.acceptStageRequests?(n(),o(this,Un).getStageRequests()):(i(),T(this,gi,[]),this.emit("stageAccessRequestUpdate",o(this,gi))))}),o(this,be).permissions.acceptStageRequests&&n()}getAccessRequests(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::get_access_request::permission_denied"),new D("You do not have permission to perform this action","2001");const e=o(this,Ed).joined.toArray().filter(n=>n.stageStatus==="REQUESTED_TO_JOIN_STAGE").map(n=>({displayName:n.name,userId:n.userId,peerId:n.id}));return T(this,gi,e),{stageRequests:o(this,gi)}}requestAccess(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(this.status!=="OFF_STAGE")throw new D(`Unable to request access you are currently ${this.status}`,"2006");if(o(this,be).permissions.stageAccess===re.Allowed){Q(this,yo,Td).call(this,"ACCEPTED_TO_JOIN_STAGE");return}o(this,Un).requestAccess(),Q(this,yo,Td).call(this,"REQUESTED_TO_JOIN_STAGE")})}cancelRequestAccess(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");o(this,Un).cancelRequestAccess(),Q(this,yo,Td).call(this,"OFF_STAGE")})}grantAccess(e){if(!o(this,be).roomJoined)throw new D("Can`t grant for participant without joining room");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::grant_access::permission_denied"),new D("You do not have permission to perform this action","2001");return o(this,Un).grantAccess(e)}denyAccess(e){if(!o(this,be).roomJoined)throw new D("Can`t rejectRequestToJoinStage for participant without joining room","2005");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::deny_access::permission_denied"),new D("You do not have permission to perform this action","2001");return o(this,Un).denyAccess(e)}join(){return p(this,null,function*(){const e=o(this,si).getValue("viewType");if(this.status==="ON_STAGE")throw new D("You are already on stage.","2006");if(this.status!=="ACCEPTED_TO_JOIN_STAGE"||o(this,be).permissions.stageAccess===re.NotAllowed)throw new D(`Unable to join stage you are currently ${this.status}`,"2006");if(yield o(this,Un).joinStage(),e===Yt.Livestream){yield o(this,vo).joinRoom(o(this,be));const{peers:n}=yield o(this,vo).getStagePeers();L.emit(x.SOCKET_PEERS,n)}o(this,si).setValue("stageStatus","ON_STAGE"),o(this,be).audioEnabled&&o(this,Sd,Vh).shareMic(o(this,be).audioTrack),o(this,be).videoEnabled&&o(this,Sd,Vh).shareWebcam(o(this,be).videoTrack)})}leave(){return p(this,null,function*(){if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!(this.status==="ON_STAGE"||this.status==="ACCEPTED_TO_JOIN_STAGE"))throw new D(`Unable to leave stage you are currently ${this.status}`,"2006");o(this,be).setIsPinned(!1),yield o(this,Un).leaveStage(o(this,be).userId),o(this,si).setValue("stageStatus","OFF_STAGE",!1),yield L.emitAsync(x.LEAVE_MEDIA_ROOM,"stageLeft"),o(this,si).notify("stageStatus")})}kick(e){return p(this,null,function*(){if(!o(this,be).roomJoined)throw new D("Can`t kick participant without joining room","2005");if(!o(this,be).permissions.stageEnabled)throw m.error("DyteStage::stage_disabled"),new D("Stage is disabled","2003");if(!o(this,be).permissions.acceptStageRequests)throw m.error("DyteStage::kick::permission_denied"),new D("You do not have permissions for kick","2001");return o(this,Un).kick(e)})}}Un=new WeakMap,vo=new WeakMap,be=new WeakMap,Ed=new WeakMap,gi=new WeakMap,si=new WeakMap,Sd=new WeakSet,Vh=function(){return o(this,si).getValue("roomNodeClient")},yo=new WeakSet,Td=function(t){return p(this,null,function*(){this.status!==t&&o(this,si).setValue("stageStatus",t)})};Rs([w.trace("DyteStage.getStageRequests")],Cr.prototype,"getAccessRequests",1);Rs([w.trace("DyteStage.requestAccess")],Cr.prototype,"requestAccess",1);Rs([w.trace("DyteStage.cancelRequestAccess")],Cr.prototype,"cancelRequestAccess",1);Rs([w.trace("DyteStage.grantAccess")],Cr.prototype,"grantAccess",1);Rs([w.trace("DyteStage.denyAccess")],Cr.prototype,"denyAccess",1);Rs([w.trace("DyteStage.joinStage")],Cr.prototype,"join",1);Rs([w.trace("DyteStage.leaveStage")],Cr.prototype,"leave",1);function lL(t){return!(t.viewType==="LIVESTREAM"||t.viewType==="CHAT")}function om(t){switch(t){case wi.UNSPECIFIED:return"OFF_STAGE";case wi.REQUESTED_STAGE:return"REQUESTED_TO_JOIN_STAGE";case wi.APPROVED_STAGE:return"ACCEPTED_TO_JOIN_STAGE";case wi.OFF_STAGE:return"OFF_STAGE";case wi.ON_STAGE:return"ON_STAGE";default:return"OFF_STAGE"}}var uL=Object.defineProperty,hL=Object.getOwnPropertyDescriptor,pL=(t,e,n,i)=>{for(var r=i>1?void 0:i?hL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&uL(e,n,r),r},Hr,$s,qr,bd,ir;class kE{constructor(e,n,i,r,s){y(this,"stage"),S(this,Hr,void 0),S(this,$s,void 0),S(this,qr,void 0),S(this,bd,0),S(this,ir,void 0),T(this,ir,e),this.stage=new Cr(e,r,s,n,i),T(this,qr,n),T(this,Hr,r),T(this,$s,s),this.setupEvents()}setupEvents(){o(this,ir).subscribe("stageStatus",e=>{this.stage.emit("stageStatusUpdate",e)}),o(this,qr).on(Y.grantStageAccess,()=>{o(this,Hr).permissions.stageAccess!==re.Allowed&&(this.stage.emit("stageRequestApproved"),this.setStageStatus("ACCEPTED_TO_JOIN_STAGE"))}),o(this,qr).on(Y.peerStageStatusUpdate,e=>{e!==void 0&&(e.peerId===o(this,Hr).id?this.selfStageStatusHandler(e):this.peerStageStatusHandler(e))}),o(this,qr).on(Y.denyStageAccess,()=>{o(this,Hr).permissions.stageAccess!==re.Allowed&&(this.stage.emit("stageRequestRejected"),this.setStageStatus("OFF_STAGE"))}),o(this,qr).on(Y.getStageRequests,e=>p(this,null,function*(){var n;if(o(this,Hr).permissions.stageAccess!==re.Allowed)return;const i=(n=e==null?void 0:e.stageRequests)!=null?n:[];yield L.emitAsync(x.GET_STAGE_REQUESTS,i),o(this,bd)<i.length&&i.length>0&&this.stage.emit("newStageRequest",{count:i.length}),T(this,bd,i.length),this.stage.emit("stageAccessRequestUpdate",i)}))}getCurrentStageRequests(){return o(this,$s).joined.toArray().filter(e=>e.stageStatus==="REQUESTED_TO_JOIN_STAGE").map(e=>({displayName:e.name,userId:e.userId,peerId:e.id}))}setStageStatus(e){return p(this,null,function*(){this.stage.status!==e&&o(this,ir).setValue("stageStatus",e)})}selfStageStatusHandler(e){const n=om(e.stageType),i=o(this,ir).getValue("stageStatus");if(i!==n)switch(e.stageType){case 1:o(this,ir).setValue("stageStatus","ACCEPTED_TO_JOIN_STAGE",!1),this.stage.join();break;case 2:case 3:this.setStageStatus(i);break;case 0:case 4:default:o(this,ir).setValue("stageStatus","ACCEPTED_TO_JOIN_STAGE",!1),this.stage.leave();break}}peerStageStatusHandler(e){return p(this,null,function*(){const n=o(this,$s).joined.get(e.peerId),i=o(this,$s).viewMode==="ACTIVE_GRID";if(!n){m.warn("err::peerStageStatusUpdate: participant not found");return}switch(e.stageType){case 1:n.setStageStatus("ON_STAGE"),i&&L.emit(x.UPDATE_ACTIVE);break;case 2:n.setStageStatus("ACCEPTED_TO_JOIN_STAGE");break;case 3:n.setStageStatus("REQUESTED_TO_JOIN_STAGE");break;case 0:case 4:default:n.setStageStatus("OFF_STAGE"),i&&L.emit(x.UPDATE_ACTIVE);break}L.emit(x.UPDATE_PEER_STAGE_STATUS,{id:n.id,status:n.stageStatus})})}}Hr=new WeakMap,$s=new WeakMap,qr=new WeakMap,bd=new WeakMap,ir=new WeakMap;pL([w.trace("DyteStage.setupEvents")],kE.prototype,"setupEvents",1);var mL=Object.defineProperty,fL=Object.getOwnPropertyDescriptor,$l=(t,e,n,i)=>{for(var r=i>1?void 0:i?fL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&mL(e,n,r),r};const Ye={getPeer:14,getPeers:15,chatMessage:16,getRoomName:17,getDisplayTitle:18,getPluginInitiator:19,customPluginEventToParent:20,peerJoined:22,peerLeft:23,sendData:24,stageStatusUpdate:25,peerStageStatusUpdate:26};var Ut,Tn,Ha,qa,qi,Ga,xs,Ja,Ag;let Ia=(Ag=class extends Ra{constructor(t,{baseURL:e,createdAt:n,description:i,id:r,name:s,organizationId:a,picture:c,private:d,published:h,staggered:u,tags:g,type:E,updatedAt:b},k,A,M,B,K){super(),S(this,Ut,void 0),y(this,"baseURL"),y(this,"createdAt"),y(this,"description"),y(this,"id"),y(this,"name"),S(this,Tn,void 0),S(this,Ha,void 0),S(this,qa,void 0),y(this,"organizationId"),y(this,"picture"),y(this,"private"),y(this,"published"),y(this,"staggered"),y(this,"tags"),y(this,"type"),y(this,"updatedAt"),S(this,qi,void 0),y(this,"config"),S(this,Ga,void 0),y(this,"active"),y(this,"iframes"),y(this,"enabledBy"),S(this,xs,void 0),S(this,Ja,void 0),T(this,xs,t),this.baseURL=e,this.createdAt=new Date(n),this.description=i,this.id=r,this.name=s,T(this,Tn,A),this.organizationId=a,this.picture=c,this.private=d,this.published=h,this.staggered=u,this.tags=g,this.type=E,this.updatedAt=new Date(b),this.active=!1,this.iframes=new Map,T(this,Ut,k),T(this,Ha,M),T(this,qa,B),this.enabledBy="",T(this,Ja,K)}sendIframeEvent(t){this.iframes.size&&this.iframes.forEach(e=>{const{iframe:n}=e;n&&(navigator.isReactNative?n.postMessage(JSON.stringify(t)):n.contentWindow.postMessage(t,"*"))})}handleIframeMessage(t){return p(this,null,function*(){var e;if(!this.active)return;const n=t,{payload:i,uuid:r,type:s}=n;switch(s){case ie.customPluginEventToRoom:{o(this,Ut).customPluginEventToRoom(this.id,i,r);break}case ie.customPluginEventToPeers:{o(this,Ut).customPluginEventToPeers(this.id,i.peerIds,i,r);break}case ie.enablePluginForRoom:{o(this,Ut).enablePluginForRoom(this.id,r);break}case ie.enablePluginForPeers:{o(this,Ut).enablePluginForPeers(this.id,i.peerIds,r);break}case ie.disablePluginForRoom:{o(this,Ut).disablePluginForRoom(this.id,r);break}case ie.disablePluginForPeers:{o(this,Ut).disablePluginForPeers(this.id,i.peerIds,r);break}case ie.storeInsertKeys:{o(this,Ut).storeInsertKeys(this.id,i.store,i.insertKeys,r);break}case ie.storeGetKeys:{o(this,Ut).storeGetKeys(this.id,i.store,i.getKeys,r);break}case ie.storeDeleteKeys:{o(this,Ut).storeDeleteKeys(this.id,i.store,i.deleteKeys,r);break}case ie.storeDelete:{o(this,Ut).storeDelete(this.id,i.store,r);break}case Ye.chatMessage:{const{messagePayload:a,peerIds:c}=i;if(!o(this,qa)){this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{error:"Chat is disabled for this room."}});return}try{yield o(this,qa).sendMessage(a,c),this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{success:!0}})}catch(d){this.sendIframeEvent({type:Ye.chatMessage,uuid:n.uuid,payload:{error:d}})}break}case Ye.getPeer:{let a;const{peerId:c}=i,d=ee(H({},o(this,Tn)),{id:o(this,Tn).id,isRecorder:(e=o(this,Tn).permissions)==null?void 0:e.isRecorder,isHidden:o(this,Tn).permissions.hiddenParticipant,stageStatus:o(this,Tn).stageStatus});c?(a=o(this,Ha).joined.get(i.peerId),o(this,Tn).id===c&&(a=d)):a=d,this.sendIframeEvent({type:Ye.getPeer,payload:{peer:a&&hl(a)},uuid:n.uuid});break}case Ye.getPeers:{const a=o(this,Ha).joined.toArray().map(c=>hl(c));this.sendIframeEvent({type:Ye.getPeers,payload:{peers:a},uuid:n.uuid});break}case Ye.getPluginInitiator:{this.sendIframeEvent({type:Ye.getPluginInitiator,payload:{enabledBy:this.enabledBy},uuid:n.uuid});break}case Ye.getDisplayTitle:{this.sendIframeEvent({type:Ye.getDisplayTitle,payload:{displayTitle:o(this,Ja)},uuid:n.uuid});break}case Ye.getRoomName:{this.sendIframeEvent({type:Ye.getRoomName,payload:{roomName:o(this,xs).getValue("meetingId")},uuid:n.uuid});break}case Ye.customPluginEventToParent:{this.emit(n.payload.eventName,n.payload.data);break}}})}sendData(t){this.active&&(m.info("DytePlugin::SendData",{plugin:{id:this.id,name:this.name,data:{eventName:t.eventName}}}),this.sendIframeEvent({type:Ye.sendData,uuid:"",payload:t}))}removePluginView(t="default"){var e;const{iframe:n,listener:i}=(e=this.iframes.get(t))!=null?e:{};(n||i)&&(navigator.isReactNative?n.props.onMessage=void 0:window.removeEventListener("message",i),this.iframes.delete(t))}addPluginView(t,e="default"){var n;if(!o(this,Ga))throw m.error("DytePlugin::addPluginView::no_auth_token_set_for_plugin"),new D("No auth token set for plugin.","0602");if(!t)throw m.error("DytePlugin::addPluginView::iframe_was_not_provided"),new D("Iframe was not provided.","0603");this.removePluginView(e);const i=t,r=new URL(this.baseURL),s={auth:o(this,Ga),parent:navigator.isReactNative?this.baseURL:window.location.origin,backend:o(this,xs).getValue("apiBase"),pluginId:this.id,roomName:(n=o(this,xs).getValue("meetingId"))!=null?n:"",displayTitle:o(this,Ja)};if(Object.keys(s).forEach(a=>{r.searchParams.set(a,s[a])}),i.src=r.href,i.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",i.title=e,navigator.isReactNative)i.props.onMessage=a=>{this.handleIframeMessage(JSON.parse(a.nativeEvent.data))},this.iframes.set(e,{iframe:i});else{const a=c=>p(this,null,function*(){c.source===t.contentWindow&&(yield this.handleIframeMessage(c.data))});window.addEventListener("message",a),this.iframes.set(e,{iframe:i,listener:a})}}setActive(t){var e,n;if(this.active=t,t){this.emit("stateUpdate",{active:this.active,pluginId:this.id,bind:this.addPluginView.bind(this),views:(e=this.config)==null?void 0:e.views});return}this.active=!1,this.emit("stateUpdate",{active:this.active,pluginId:this.id,views:(n=this.config)==null?void 0:n.views})}activateForSelf(){return p(this,null,function*(){const t=Pt(),e=yield t.authorizePlugin(this.id);T(this,Ga,e),T(this,qi,new Date);try{const n=yield t.getPluginConfig(this.baseURL);this.config=n}catch(n){m.error("DytePlugin::activateForSelf",{error:n})}this.setActive(!0),this.emit("enabled")})}deactivateForSelf(){Array.from(this.iframes.keys()).forEach(t=>{this.removePluginView(t)}),T(this,qi,void 0),this.iframes.clear(),this.setActive(!1),this.emit("closed")}enable(){return p(this,null,function*(){return this.activateForSelf()})}disable(){return this.deactivateForSelf()}activate(){return p(this,null,function*(){var t,e;this.active||(e=(t=o(this,Tn).permissions)==null?void 0:t.plugins)!=null&&e.canStart&&(o(this,Ut).addPlugin(this.id,this.staggered),T(this,qi,new Date),m.info("plugin::activated",{plugin:{id:this.id,enabledBy:this.enabledBy,name:this.name}}))})}deactivate(){return p(this,null,function*(){var t,e;this.active&&(!((e=(t=o(this,Tn).permissions)==null?void 0:t.plugins)!=null&&e.canClose)&&this.enabledBy!==o(this,Tn).id||(o(this,Ut).removePlugin(this.id),m.info("plugin::deactivated",{plugin:{id:this.id,name:this.name,duration:o(this,qi)?new Date().getTime()-o(this,qi).getTime():0}}),T(this,qi,void 0)))})}},Ut=new WeakMap,Tn=new WeakMap,Ha=new WeakMap,qa=new WeakMap,qi=new WeakMap,Ga=new WeakMap,xs=new WeakMap,Ja=new WeakMap,Ag);$l([on({maxInvocations:5,period:1})],Ia.prototype,"sendData",1);$l([w.trace("DytePlugin.activatePlugin")],Ia.prototype,"activate",1);$l([w.trace("DytePlugin.deactivatePlugin")],Ia.prototype,"deactivate",1);Ia=$l([Lt("0600")],Ia);var lt,Ks;class wE extends Map{constructor(e){const{onAddEvent:n,onDeleteEvent:i,onClearEvent:r}=e;super(),S(this,lt,void 0),S(this,Ks,void 0),y(this,"onAddEvent"),y(this,"onDeleteEvent"),y(this,"onClearEvent"),T(this,lt,new Ra),this.onAddEvent=n,this.onDeleteEvent=i,this.onClearEvent=r,T(this,Ks,new Map)}emit(e,...n){return o(this,lt).emit(e,...n)}on(e,n){return o(this,lt).on(e,n)}addListener(e,n){return o(this,lt).addListener(e,n)}off(e,n){return o(this,lt).off(e,n)}once(e,n){return o(this,lt).once(e,n)}prependListener(e,n){return o(this,lt).prependListener(e,n)}prependOnceListener(e,n){return o(this,lt).prependOnceListener(e,n)}removeListener(e,n){return o(this,lt).removeListener(e,n)}removeAllListeners(e){return o(this,lt).removeAllListeners(e)}listeners(e){return o(this,lt).listeners(e)}listenerCount(e){return o(this,lt).listenerCount(e)}getMaxListeners(){return o(this,lt).getMaxListeners()}setMaxListeners(e){return o(this,lt).setMaxListeners(e)}eventNames(){return o(this,lt).eventNames()}add(e,n=!0){return this.set(e.id,e,n)}set(e,n,i=!0){const r=super.set(e,n),s=(a,...c)=>{this.emit(a,n,...c)};return o(this,Ks).set(e,s),n.on("*",s),i&&o(this,lt).emit(this.onAddEvent,n),r}delete(e,n=!0,i=!1){const r=this.get(e);if(!r)return!1;r.removeListener("*",o(this,Ks).get(e));const s=super.delete(e);return i&&r.removeAllListeners(),n&&o(this,lt).emit(this.onDeleteEvent,r),s}clear(e=!0,n=!1){this.forEach(r=>{r.removeListener("*",o(this,Ks).get(r.id)),n&&r.removeAllListeners()});const i=super.clear();return e&&o(this,lt).emit(this.onClearEvent),i}toArray(){return Array.from(this.values())}}lt=new WeakMap,Ks=new WeakMap;class Mg extends wE{constructor(){super({onAddEvent:"pluginAdded",onDeleteEvent:"pluginDeleted"})}add(e,n=!0){return super.add(e,n)}delete(e,n=!0,i=!1){return super.delete(e,n,i)}}var gL=Object.defineProperty,vL=Object.getOwnPropertyDescriptor,yL=(t,e,n,i)=>{for(var r=i>1?void 0:i?vL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&gL(e,n,r),r};let Uh=class{constructor(){y(this,"all"),y(this,"active"),this.all=new Mg,this.active=new Mg}};Uh=yL([Lt("0600")],Uh);var EL=Object.defineProperty,SL=Object.getOwnPropertyDescriptor,Kl=(t,e,n,i)=>{for(var r=i>1?void 0:i?SL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&EL(e,n,r),r},An,$a,$c,Og;const _E=(Og=class{constructor(t,e,n,i){y(this,"plugins"),S(this,An,void 0),S(this,$a,void 0),S(this,$c,void 0),T(this,An,e),T(this,$a,n),T(this,$c,t),this.plugins=i,this.setupEvents()}static init(t,e,n,i,r,s,a,c){return p(this,null,function*(){const d=new Uh;return e.forEach(h=>{const u=new Ia(t,h,n,s,a,r,c);d.all.add(u)}),new _E(t,n,i,d)})}getRoomPlugins(){return p(this,null,function*(){var t;const{plugins:e}=yield o(this,An).getActivePlugins();(t=this.plugins.active)==null||t.toArray().forEach(n=>{this.disablePlugin({id:n.id})}),yield Promise.all(e.map(n=>this.enablePlugin({id:n.pluginId,enabledBy:n.enabledBy})))})}enablePlugin(t){return p(this,arguments,function*({id:e,enabledBy:n}){const i=this.plugins.all.get(e);i&&(yield i.activateForSelf(),i.enabledBy=n)})}disablePlugin(t){return p(this,arguments,function*({id:e}){const n=this.plugins.all.get(e);n&&n.deactivateForSelf()})}sendIframeEvent(t,e,n,i){const r=this.plugins.all.get(e);r&&r.sendIframeEvent({type:t,uuid:n,payload:i})}broadcastIframeEvent(t,e){this.plugins.active.forEach(n=>{this.sendIframeEvent(t,n.id,"",e)})}setupEvents(){this.plugins.all.on("stateUpdate",({active:t,id:e})=>{if(t){this.plugins.active.add(this.plugins.all.get(e));return}this.plugins.active.delete(e)}),L.onAsync(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){yield this.getRoomPlugins(),m.debug("[SOCKET_SERVICE_ROOM_JOINED] resolved request to fetch plugins.")})),o(this,An).on(ie.addPlugin,t=>p(this,null,function*(){var e;const n=t.pluginId;(e=this.plugins.all.get(n))!=null&&e.active||(yield this.enablePlugin({id:n,enabledBy:t.enabledBy}))})),o(this,An).on(ie.removePlugin,t=>p(this,null,function*(){var e;const n=t.pluginId;(e=this.plugins.all.get(n))!=null&&e.active&&(yield this.disablePlugin({id:n}))})),[ie.enablePluginForPeers,ie.enablePluginForRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{enabledBy:e.enabledBy})}))}),[ie.disablePluginForPeers,ie.disablePluginForRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{disabledBy:e.disabledBy})}))}),[ie.customPluginEventToPeers,ie.customPluginEventToRoom].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){this.sendIframeEvent(t,e.pluginId,n,{data:JSON.parse(new TextDecoder().decode(e.pluginData))})}))}),[ie.storeInsertKeys,ie.storeGetKeys,ie.storeDeleteKeys].forEach(t=>{o(this,An).on(t,(e,n)=>p(this,null,function*(){var i;const r=(i=e.storeItems)==null?void 0:i.map(s=>{var a;return{timestamp:s.timestamp,peerId:s.peerId,payload:JSON.parse((a=s.payload)!=null&&a.length?new TextDecoder().decode(s.payload):"{}"),key:s.storeKey}});this.sendIframeEvent(t,e.pluginId,n,{storeName:e.storeName,storeItems:r})}))}),o(this,An).on(ie.storeDelete,(t,e)=>p(this,null,function*(){this.sendIframeEvent(ie.storeDelete,t.pluginId,e,{storeName:t.storeName})})),o(this,$a).on(Ge.sendMessageToPeers,t=>{const e=Ci==null?void 0:Ci.formatSocketServiceMessage(t.message);this.broadcastIframeEvent(Ye.chatMessage,{message:e})}),o(this,$a).on(Ge.sendMessageToRoom,t=>{const e=Ci==null?void 0:Ci.formatSocketServiceMessage(t.message);this.broadcastIframeEvent(Ye.chatMessage,{message:e})}),L.on(x.PEER_JOINED_INTERNAL,t=>{const e=hl(t);this.broadcastIframeEvent(Ye.peerJoined,e)}),L.on(x.PEER_CLOSED,t=>{this.broadcastIframeEvent(Ye.peerLeft,t)}),L.on(x.UPDATE_PEER_STAGE_STATUS,t=>{this.broadcastIframeEvent(Ye.peerStageStatusUpdate,t)}),o(this,$c).subscribe("stageStatus",t=>{this.broadcastIframeEvent(Ye.stageStatusUpdate,t)})}},An=new WeakMap,$a=new WeakMap,$c=new WeakMap,Og);let bc=_E;Kl([w.trace("PluginController.getRoomPlugins")],bc.prototype,"getRoomPlugins",1);Kl([w.trace("PluginController.enableForSelf")],bc.prototype,"enablePlugin",1);Kl([w.trace("PluginController.disableForSelf")],bc.prototype,"disablePlugin",1);Kl([w.trace("PluginController.setupEvents")],bc.prototype,"setupEvents",1);class TL{constructor(){y(this,"mediaJoined"),y(this,"socketJoined"),y(this,"socketJoinAttempted"),y(this,"mediaJoinAttempted"),y(this,"socketState"),y(this,"mediaState"),this.mediaJoined=!1,this.socketJoined=!1,this.socketJoinAttempted=!1,this.mediaJoinAttempted=!1,this.socketState={state:void 0,reconnected:!1,reconnectionAttempt:void 0},this.mediaState={recv:void 0,send:void 0}}get joinAttempted(){return this.mediaJoinAttempted||this.socketJoinAttempted}get roomJoined(){return this.mediaJoined&&this.socketJoined}updateSocketConnectionState(e,n){let i;const{reconnected:r}=this.socketState;switch(e){case"connected":i={state:"connected",reconnected:r,reconnectionAttempt:void 0};break;case"disconnected":i={state:"disconnected",reconnected:!1,reconnectionAttempt:0},this.socketJoined=!1;break;case"reconnected":i={state:"connected",reconnected:!0,reconnectionAttempt:void 0};break;case"reconnecting":i={state:"reconnecting",reconnected:r,reconnectionAttempt:0};break;case"reconnectAttempt":i={state:"reconnecting",reconnected:r,reconnectionAttempt:n};break;case"failed":i={state:"failed",reconnected:r,reconnectionAttempt:void 0},this.socketJoined=!1;break}i&&(L.emit(x.SOCKET_STATE_UPDATE,i),this.socketState=i)}}var bL=Object.defineProperty,kL=Object.getOwnPropertyDescriptor,kc=(t,e,n,i)=>{for(var r=i>1?void 0:i?kL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&bL(e,n,r),r},Ka,Kc,za,zc,Dg;let Ss=(Dg=class extends gn{constructor(t,e){super(),S(this,za),S(this,Ka,void 0),S(this,Kc,void 0),y(this,"recordingPeerIds",[]),y(this,"recordings",[]),T(this,Kc,t),T(this,Ka,e)}get recordingState(){return this.recordings.some(t=>t.state==="RECORDING")?"RECORDING":this.recordings.some(t=>t.state==="PAUSED")?"PAUSED":this.recordings.some(t=>t.state==="STARTING")?"STARTING":this.recordings.some(t=>t.state==="STOPPING")?"STOPPING":"IDLE"}updateRecordings(t){this.recordings=t,this.emit("recordingUpdate",this.recordingState)}start(t){return p(this,null,function*(){if(!o(this,Ka).permissions.canRecord)throw m.error("DyteRecording::start::permission_denied"),new D("User does not have permission to start recording","1001");if((t==null?void 0:t.allowMultiple)!==!0&&(this.recordingState==="STARTING"||this.recordingState==="RECORDING"||this.recordingState==="STOPPING"))throw m.error("DyteRecording::start::recording_in_progress",{recording:{state:this.recordingState}}),new D(`Cant start recording, recordingState irregular: ${this.recordingState}`,"1005");try{const e=Pt(),{recording:n={}}=o(this,Kc).getValue("defaults"),i=yield e.startRecording(n,t==null?void 0:t.allowMultiple);this.updateRecordings([...this.recordings,{id:i,state:"STARTING",type:"BROWSER"}])}catch(e){throw m.error("DyteRecording::stop::recording_failed_to_start",{error:e}),new D("Error while starting recording","1000")}})}stop(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"stop",["RECORDING","PAUSED"],t)})}pause(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"pause",["RECORDING"],t)})}resume(t){return p(this,null,function*(){yield Q(this,za,zc).call(this,"resume",["PAUSED"],t)})}},Ka=new WeakMap,Kc=new WeakMap,za=new WeakSet,zc=function(t,e,n){return p(this,null,function*(){if(!o(this,Ka).permissions.canRecord)throw m.error("DyteRecording::stop::permission_denied"),new D("User does not have permission to stop recording","1001");let i=[];if(n!==void 0){const r=this.recordings.find(s=>s.id===n);if(r===void 0)throw new D("Could not find the specified recording","1004");if(e.includes(r.state)){m.error("DyteRecording::stop::recording_not_in_expected_state",{recording:{state:r.state}});return}i.push(r)}else i=this.recordings.filter(r=>e.includes(r.state));i.forEach(r=>p(this,null,function*(){const s=r.state;t==="stop"&&(r.state="STOPPING",this.emit("recordingUpdate","STOPPING"));try{yield Pt().updateRecording(r.id,t)}catch(a){throw m.error("DyteRecording::stop::recording_failed_to_stop",{error:a}),r.state!==s&&(r.state=s,this.emit("recordingUpdate",s)),new D("Error while stopping recording","1000")}}))})},Dg);kc([w.trace("DyteRecording.start")],Ss.prototype,"start",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"stop",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"pause",1);kc([w.trace("DyteRecording.stop")],Ss.prototype,"resume",1);Ss=kc([Lt("1000")],Ss);var wL=Object.defineProperty,_L=Object.getOwnPropertyDescriptor,IL=(t,e,n,i)=>{for(var r=i>1?void 0:i?_L(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&wL(e,n,r),r},Bh;class IE{constructor(e,n,i){y(this,"recording"),y(this,"room"),S(this,Bh,void 0),T(this,Bh,e),this.recording=new Ss(e,n),this.room=i,this.setupEvents()}getRecordingTypeFromProtoType(e){let n;switch(e){case fs.BROWSER:n="BROWSER";break;case fs.COMPOSITE:n="COMPOSITE";break;case fs.TRACK:n="TRACK";break;default:n="BROWSER"}return n}setupEvents(){L.on(x.ROOM_STATE,e=>{e.activeRecordings.length!==0?this.recording.updateRecordings(e.activeRecordings.map(n=>{const i=this.getRecordingTypeFromProtoType(n.recordingType);return{id:n.recordingId,state:n.recordingStatus,type:i}})):this.recording.recordings.length&&this.recording.updateRecordings([])}),this.room.on(Y.recordingStarted,e=>{let n=!1;const i=[...this.recording.recordings];if(i.forEach(r=>{r.id===e.recordingId&&(n=!0,r.state="RECORDING")}),n===!1){const r=this.getRecordingTypeFromProtoType(e.recordingType);i.push({id:e.recordingId,state:"RECORDING",type:r})}this.recording.updateRecordings(i)}),this.room.on(Y.recordingPaused,e=>{const n=[...this.recording.recordings];n.forEach(i=>{i.id===e.recordingId&&(i.state="PAUSED")}),this.recording.updateRecordings(n)}),this.room.on(Y.recordingStopped,e=>{const n=[...this.recording.recordings.filter(i=>i.id!==e.recordingId)];this.recording.updateRecordings(n)})}}Bh=new WeakMap;IL([w.trace("RecordingController.setupEvents")],IE.prototype,"setupEvents",1);class CL{static hasFeature(e){var n;return(n=se.hasFeature(e))!=null?n:!1}static getFeatureValue(e){return se.getValue(e)}static getAllFeatures(){return se.getAllFlags()}}class cm{constructor(e,n,i){y(this,"logger"),y(this,"features"),y(this,"browserSpecs"),y(this,"callStats"),this.logger=e,this.features=n,this.browserSpecs=Be,this.callStats=i}static init(e){return new cm(m,CL,e)}}class dm{constructor(e){y(this,"internals"),this.internals=e}static init(){return p(this,null,function*(){const e=cm.init(ne);return new dm(e)})}}var RL=Object.defineProperty,PL=Object.getOwnPropertyDescriptor,yn=(t,e,n,i)=>{for(var r=i>1?void 0:i?PL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&RL(e,n,r),r},Et,ut,We,vi,Bn,kd,Fh;class cn extends Ra{constructor(e,n,i=jh,r=!0){super(),S(this,Et,void 0),S(this,ut,void 0),S(this,We,void 0),S(this,vi,void 0),S(this,Bn,void 0),S(this,kd,void 0),S(this,Fh,void 0),y(this,"audioUpdateInProgress"),y(this,"videoUpdateInProgress"),T(this,Fh,e),this.audioUpdateInProgress=!1,this.videoUpdateInProgress=!1,T(this,Et,new CE(e,n)),T(this,ut,new QL(o(this,Et),void 0,i)),T(this,We,new r2(o(this,Et),void 0,i)),T(this,Bn,new t2(o(this,Et))),T(this,vi,new ZL(o(this,Et))),T(this,kd,r),o(this,ut).on("trackMuted",this.onAudioTrackMuted.bind(this)),o(this,ut).on("trackChanged",this.onAudioTrackChanged.bind(this)),o(this,We).on("trackChanged",this.onVideoTrackChanged.bind(this)),o(this,We).on("trackEnded",this.onVideoTrackEnded.bind(this)),o(this,Bn).on("trackEnded",this.onScreenShareEnded.bind(this)),this.onVisibilityChange=this.onVisibilityChange.bind(this),document.addEventListener("visibilitychange",this.onVisibilityChange)}onVisibilityChange(){return p(this,null,function*(){ne.tabChanged(document.visibilityState==="visible"),document.visibilityState!=="visible"?ne.browserBackgrounded():(ne.browserForegrounded(),yield this.setupSpeaker())})}repopulateAvailableDevices(){return p(this,null,function*(){return!0})}setupStreams(e){return p(this,arguments,function*({audio:n,video:i}){var r;n?ne.audioOn():ne.audioOff(),i?ne.videoOn():ne.videoOff();let s,a;if(n&&i)try{const c=yield o(this,Et).getAudioAndVideoTrack(o(this,ut).userSelectedDevice,o(this,We).userSelectedDevice);s=c.audioTrack,a=c.videoTrack}catch(c){m.error("LocalMediaHandler::init::Failed to get audio video tracks",{error:c})}if(!s&&n)try{s=yield o(this,Et).getAudioTrack(!1,o(this,ut).userSelectedDevice)}catch(c){m.error("LocalMediaHandler::init::Failed to get audio track",{error:c})}if(!a&&i)try{a=yield o(this,Et).getVideoTrack(o(this,We).userSelectedDevice)}catch(c){m.error("LocalMediaHandler::init::Failed to get video track",{error:c})}n&&!s&&ne.audioOff(),i&&!a&&ne.videoOff(),yield o(this,ut).setMediaTrack(s),yield o(this,We).setMediaTrack(a);try{yield o(this,vi).setupSpeaker()}catch{}if(a){const c=yield this.getDeviceById(a.getSettings().deviceId);ne.selectedDevice("VIDEO",c)}if(s){const c=yield this.getDeviceById(s.getSettings().deviceId);ne.selectedDevice("AUDIO",c)}(r=o(this,vi).currentDevice)!=null&&r.deviceId&&ne.selectedDevice("SPEAKER",o(this,vi).currentDevice),o(this,Et).onDeviceChange((c,d,h)=>{this.onDeviceChange(d,h)})})}getCurrentDevices(){return{audio:o(this,ut).currentDevice,video:o(this,We).currentDevice,speaker:o(this,vi).currentDevice}}get permissions(){return o(this,Et).permissions}getAllDevices(){return o(this,Et).getAvailableDevices()}getDeviceById(e,n){return o(this,Et).getDevice(e)}onAudioTrackMuted(){this.emit("AUDIO_TRACK_SILENT")}onAudioTrackChanged(){this.emit("AUDIO_TRACK_CHANGE")}get rawAudioTrack(){return o(this,ut).mediaTrack}get audioTrack(){return o(this,ut).transformedMediaTrack}get audioEnabled(){return o(this,ut).trackEnabled}enableAudio(){return p(this,null,function*(){if(!this.audioUpdateInProgress){this.audioUpdateInProgress=!0;try{yield o(this,ut).unmuteTrack()}catch{}finally{this.audioUpdateInProgress=!1}}})}disableAudio(){o(this,ut).muteTrack()}getAudioDevices(e){return o(this,Et).getAudioInputDevices(e)}setAudioDevice(e){return p(this,null,function*(){yield o(this,ut).setDevice(e),e!=null&&e.deviceId&&ne.selectedDevice("AUDIO",e),this.emit("AUDIO_TRACK_CHANGE"),this.emit("DEVICE_CHANGE",{device:e})})}setupSpeaker(){return o(this,vi).setupSpeaker()}setSpeakerDevice(e){return p(this,null,function*(){yield o(this,vi).setupSpeaker(e),e!=null&&e.deviceId&&ne.selectedDevice("SPEAKER",e),this.emit("DEVICE_CHANGE",{device:e})})}onVideoTrackChanged(){this.emit("VIDEO_TRACK_CHANGE")}onVideoTrackEnded(){this.emit("VIDEO_TRACK_CHANGE")}get rawVideoTrack(){return o(this,We).mediaTrack}get videoTrack(){return o(this,We).transformedMediaTrack}get videoEnabled(){return o(this,We).trackEnabled}enableVideo(){return p(this,null,function*(){if(!this.videoUpdateInProgress){this.videoUpdateInProgress=!0;try{yield o(this,We).unmuteTrack()}catch{}finally{this.videoUpdateInProgress=!1}}})}disableVideo(){o(this,We).disableTrack()}getVideoDevices(e){return o(this,Et).getVideoInputDevices(e)}setVideoDevice(e){return p(this,null,function*(){yield o(this,We).setDevice(e),e!=null&&e.deviceId&&ne.selectedDevice("VIDEO",e),this.emit("VIDEO_TRACK_CHANGE"),this.emit("DEVICE_CHANGE",{device:e})})}updateVideoConstraints(e){return p(this,null,function*(){yield o(this,We).updateConstraints(e)})}onScreenShareEnded(){this.emit("SCREENSHARE_ENDED")}get screenShareTracks(){return{audio:o(this,Bn).audioMediaTrack,video:o(this,Bn).videoMediaTrack}}get screenShareEnabled(){return o(this,Bn).trackEnabled}enableScreenShare(){return p(this,null,function*(){yield o(this,Bn).enableScreenShare()})}disableScreenShare(){return p(this,null,function*(){o(this,Bn).disableScreenShare()})}updateScreenshareConstraints(e){return p(this,null,function*(){yield o(this,Bn).updateConstraints(e)})}getSpeakerDevices(e){return o(this,Et).getAudioOutputDevices(e)}addAudioMiddleware(e){return o(this,ut).addMiddleware(e)}removeAudioMiddleware(e){return o(this,ut).removeMiddleware(e)}removeAllAudioMiddlewares(){return o(this,ut).removeAllMiddlewares()}addVideoMiddleware(e){return o(this,We).addMiddleware(e)}removeVideoMiddleware(e){return o(this,We).removeMiddleware(e)}removeAllVideoMiddlewares(){return o(this,We).removeAllMiddlewares()}setVideoMiddlewareGlobalConfig(e){return o(this,We).setVideoMiddlewareGlobalConfig(e)}destruct(){o(this,ut).disableTrack(),o(this,We).disableTrack(),o(this,We).terminateMiddlewareWebWorker(),o(this,Bn).disableScreenShare(),o(this,Et).destruct()}onDeviceChange(e,n){return p(this,null,function*(){var i,r;this.emit("DEVICE_LIST_UPDATED",e),!(n||!o(this,kd))&&((i=e==null?void 0:e.added)==null||i.forEach(s=>p(this,null,function*(){var a;s&&!jh(s)&&(s.kind==="audioinput"&&((a=this.audioTrack)==null?void 0:a.enabled)===!0?yield this.setAudioDevice(s):s.kind==="audiooutput"&&(yield this.setSpeakerDevice(s)))})),(r=e==null?void 0:e.removed)==null||r.forEach(s=>p(this,null,function*(){var a;if(s.kind==="audiooutput"&&((a=this.getCurrentDevices().speaker)==null?void 0:a.deviceId)===s.deviceId){const c=(yield this.getSpeakerDevices()).find(d=>d.deviceId!==s.deviceId);c&&(yield this.setSpeakerDevice(c))}})))})}removeAllTracks(){this.destruct()}removeAudioTrack(){o(this,ut).disableTrack()}removeVideoTrack(){o(this,We).disableTrack(),o(this,We).terminateMiddlewareWebWorker()}removeDocumentEventListeners(){return p(this,null,function*(){document.removeEventListener("visibilitychange",this.onVisibilityChange)})}}Et=new WeakMap,ut=new WeakMap,We=new WeakMap,vi=new WeakMap,Bn=new WeakMap,kd=new WeakMap,Fh=new WeakMap;yn([w.trace("MediaHandler.setupStreams")],cn.prototype,"setupStreams",1);yn([w.trace("MediaHandler.enableAudio")],cn.prototype,"enableAudio",1);yn([w.trace("MediaHandler.disableAudio")],cn.prototype,"disableAudio",1);yn([w.trace("MediaHandler.setAudioDevice")],cn.prototype,"setAudioDevice",1);yn([w.trace("MediaHandler.enableVideo")],cn.prototype,"enableVideo",1);yn([w.trace("MediaHandler.disableVideo")],cn.prototype,"disableVideo",1);yn([w.trace("MediaHandler.setVideoDevice")],cn.prototype,"setVideoDevice",1);yn([w.trace("MediaHandler.updateVideoConstraints")],cn.prototype,"updateVideoConstraints",1);yn([w.trace("MediaHandler.enableScreenShare")],cn.prototype,"enableScreenShare",1);yn([w.trace("MediaHandler.disableScreenShare")],cn.prototype,"disableScreenShare",1);yn([w.trace("MediaHandler.updateScreenshareConstraints")],cn.prototype,"updateScreenshareConstraints",1);yn([w.trace("MediaHandler.destruct")],cn.prototype,"destruct",1);yn([w.trace("MediaHandler.onDeviceChange")],cn.prototype,"onDeviceChange",1);function Yc(t,e,n){switch(!0){case Be.isChromiumBased():switch(e){case"NotAllowedError":return n.includes("by system")?"SYSTEM_DENIED":t==="screenshare"?"CANCELED":"DENIED";case"NotReadableError":default:return"COULD_NOT_START"}case Be.isSafari():switch(e){case"NotAllowedError":return"DENIED";default:return"COULD_NOT_START"}case Be.isFirefox():switch(e){case"NotFoundError":case"NotReadableError":return"SYSTEM_DENIED";case"NotAllowedError":return"DENIED";case"AbortError":default:return"COULD_NOT_START"}default:return"COULD_NOT_START"}}const AL=["virtual","emulator","krisp","solstice conference","teams","loom","zoom","manycam","blackhole","displayport","xsplit","wirecast","vMix","elgato","epiphan","voice changer","voicemod","morphvoxx"];function jh(t){var e,n;const i=(e=t.label)==null?void 0:e.toLowerCase();return((n=Be._bowser)==null?void 0:n.getOSName())==="macOS"&&i.includes("iphone")?(m.log("isVirtualDevice::ignore_macos_continuity"),!0):AL.some(r=>i==null?void 0:i.includes(r))}function ML(t,e){return p(this,null,function*(){if(!(t!=null&&t.length))return e;const n=new AudioContext,i=yield Promise.all(t==null?void 0:t.map(a=>a(n))),r=n.createMediaStreamSource(new MediaStream([e])),s=n.createMediaStreamDestination();try{let a=r;for(let c=0;c<i.length;c+=1)a.connect(i[c]),a=i[c];a.connect(s)}catch(a){return m.error("getTransformedAudioTrack::middleware_execution_failed",{error:a}),e}return s.stream.getAudioTracks()[0]})}var zs;class OL{constructor(){S(this,zs,void 0)}terminateMiddlewareWebWorker(){if(o(this,zs))try{la(o(this,zs)),T(this,zs,void 0)}catch{m.debug("WorkerTimers::terminateMiddlewareWebWorker::failed")}}getTransformedVideoTrack(e,n,i){return p(this,null,function*(){if(!(e!=null&&e.length))return n;const r=document.createElement("canvas"),s=yield Promise.all(e==null?void 0:e.map(g=>g({canvas:r,WorkerTimers:RT})));if(i.disablePerFrameCanvasRendering){const g=r.captureStream().getVideoTracks()[0];return Object.defineProperty(g,"originalSettings",{value:n.getSettings()}),g}const a=document.createElement("video"),c=new MediaStream;c.addTrack(n);const d=r.getContext("2d");a.srcObject=c,a.autoplay=!0,this.terminateMiddlewareWebWorker();const h=()=>p(this,null,function*(){if(n.enabled===!1||n.readyState==="ended"){this.terminateMiddlewareWebWorker(),a.remove(),r.remove();return}try{d.drawImage(a,0,0);for(let g=0;g<s.length;g+=1)typeof s[g]=="function"&&(yield s[g](r,d))}catch(g){m.error("getTransformedVideoTrack::middleware_execution_failed",{error:g})}});try{a.play()}catch{}a.addEventListener("play",()=>{r.width=a.width||n.getSettings().width,r.height=a.width||n.getSettings().height,T(this,zs,Xd(h,50))},!1);const u=r.captureStream().getVideoTracks()[0];return Object.defineProperty(u,"originalSettings",{value:n.getSettings()}),u})}}zs=new WeakMap;const Ng={gross:{width:{ideal:192},height:{ideal:144}},qvga:{width:{ideal:384},height:{ideal:288}},pvga:{width:{ideal:480},height:{ideal:360}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}},hd_cropped:{width:{ideal:900},height:{ideal:720}},fhd:{width:{ideal:1920},height:{ideal:1080}}},DL=[[320,[{rid:"q",maxBitrate:25e4,maxFramerate:24,scalabilityMode:"L1T1"}]],[640,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:25e4,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:7e5,maxFramerate:30,scalabilityMode:"L1T1"}]],[1280,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:5e5,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:13e5,maxFramerate:30,scalabilityMode:"L1T1"}]],[1920,[{rid:"q",scaleResolutionDownBy:2,maxBitrate:9e5,maxFramerate:24,scalabilityMode:"L1T1"},{rid:"h",maxBitrate:15e5,maxFramerate:30,scalabilityMode:"L1T1"}]]],NL=t=>{var e;const n="getSettings"in t&&t.getSettings().width||"getConstraints"in t&&t.getConstraints().width||"originalSettings"in t&&((e=t.originalSettings)==null?void 0:e.width);let i=DL;se.hasFeature(ue.OVERRIDE_HIVE_SIMULCAST_DYNAMIC)&&(i=JSON.parse(se.getValue(ue.OVERRIDE_HIVE_SIMULCAST_DYNAMIC)));const r=i.map(([c])=>c).sort((c,d)=>c-d);let s=Number.MAX_VALUE,a=0;return r.forEach((c,d)=>{Math.abs(c-n)<s&&(s=Math.abs(c-n),a=d)}),i[a][1]};var De=(t=>(t.WEBCAM="webcam",t.WEBCAM_BACKUP="webcam_backup",t.MIC="mic",t.SCREENSHARE_VIDEO="screenshare_video",t.SCREENSHARE_AUDIO="screenshare_audio",t))(De||{});const LL=bC(),Vs=Gn(LL.config.media);function xL(t){var e,n;const i={};return t.audio&&(i.audio={enableStereo:(e=t.audio.enableStereo)!=null?e:!1,enableHighBitrate:(n=t.audio.enableHighBitrate)!=null?n:!1}),i.video=t.video.quality,i}var Ys,Wh;class VL{constructor(e,n){S(this,Ys,void 0),S(this,Wh,void 0),y(this,"getScreenShareConstraints",()=>{var i,r,s,a,c,d,h,u,g,E,b;const k=(i=o(this,Ys))==null?void 0:i.screenshare,A=(s=(r=k==null?void 0:k.width)==null?void 0:r.max)!=null?s:1920,M=(c=(a=k==null?void 0:k.height)==null?void 0:a.max)!=null?c:1080,B=(h=(d=k==null?void 0:k.frameRate)==null?void 0:d.max)!=null?h:5;let K=(g=(u=k==null?void 0:k.frameRate)==null?void 0:u.ideal)!=null?g:5;const X=k==null?void 0:k.displaySurface,O=k==null?void 0:k.selfBrowserSurface;se.getValue(ue.VAL_MIN_FRAMERATE)&&(K=parseInt((E=se.getValue(ue.VAL_MIN_FRAMERATE))==null?void 0:E.toString(),10));let J={width:{max:A},height:{max:M},frameRate:{ideal:K,max:B}};if(se.hasFeature(ue.SCREENSHARE_CONSTRAINTS)){const me=(b=se.getValue(ue.SCREENSHARE_CONSTRAINTS))==null?void 0:b.toString();J=JSON.parse(me)}return X!==void 0&&["monitor","browser","window"].includes(X)&&(J=ee(H({},J),{displaySurface:X})),O!==void 0&&(J=ee(H({},J),{selfBrowserSurface:O})),{audio:!0,video:J}}),y(this,"getAudioConstraints",i=>{var r,s,a,c,d,h,u,g;const E={},b=(r=o(this,Ys))==null?void 0:r.audio,k=b!=null&&b.enableStereo?2:1;return Be.isFirefox()||Be.isWebKitBased()?(E.audio={deviceId:i,autoGainControl:(s=b==null?void 0:b.autoGainControl)!=null?s:!0,echoCancellation:(a=b==null?void 0:b.echoCancellation)!=null?a:!0,noiseSuppression:(c=b==null?void 0:b.noiseSupression)!=null?c:!0,channelCount:k},E):(E.audio={},E.audio.optional=[i?{sourceId:i}:{sourceId:"default"},{channelCount:k},{echoCancellation:(d=b==null?void 0:b.echoCancellation)!=null?d:!0},{googEchoCancellation:(h=b==null?void 0:b.echoCancellation)!=null?h:!0},{googAutoGainControl:(u=b==null?void 0:b.autoGainControl)!=null?u:!0},{googNoiseSuppression:(g=b==null?void 0:b.noiseSupression)!=null?g:!0},{googHighpassFilter:!0}],E)}),y(this,"getVideoConstraints",i=>{var r,s,a,c;const d={},h=(r=o(this,Ys))==null?void 0:r.video;let u=Ng.vga;if(typeof h=="string"?u=Ng[h]:h!==void 0&&(u.height.ideal=h.height.ideal,u.width.ideal=h.width.ideal),u.frameRate={ideal:(a=(s=u.frameRate)==null?void 0:s.ideal)!=null?a:24},Be.isChromiumBased()&&(u.frameRate.max=30),se.hasFeature(ue.VIDEO_CONSTRAINTS)){const g=(c=se.getValue(ue.VIDEO_CONSTRAINTS))==null?void 0:c.toString();u=JSON.parse(g)}return d.video=u,typeof d.video=="boolean"||(i?d.video.deviceId={exact:i}:d.video.facingMode="user"),d}),T(this,Wh,e),T(this,Ys,n)}getUpdatedVideoConstraints(e){return e}}Ys=new WeakMap,Wh=new WeakMap;class ju extends Error{constructor(e,n,i){super(n),y(this,"constraints"),y(this,"name"),this.name=e,this.constraints=i}}class UL{constructor(){y(this,"permissions"),this.permissions={audio:"NOT_REQUESTED",video:"NOT_REQUESTED",screenshare:"NOT_REQUESTED"}}getAudioInputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="audioinput")})}getVideoInputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="videoinput")})}getAudioOutputDevices(e){return p(this,null,function*(){let n=e;return e||(n=yield this.getAvailableDevices()),n.filter(i=>i.kind==="audiooutput")})}}var BL=Object.defineProperty,FL=Object.getOwnPropertyDescriptor,Yn=(t,e,n,i)=>{for(var r=i>1?void 0:i?FL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&BL(e,n,r),r},Ya,Mn,Wu,Lg;let fn=(Lg=class extends UL{constructor(t,e){super(),y(this,"availableDevices"),S(this,Ya,void 0),S(this,Mn,void 0),S(this,Wu,void 0),T(this,Wu,t),T(this,Mn,new VL(t,e)),T(this,Ya,new AbortController),this.availableDevices=[],this.getAvailableDevices()}get constraintsBuilder(){return o(this,Mn)}destruct(){return p(this,null,function*(){var t;(t=o(this,Ya))==null||t.abort()})}handlePermissionErrors(t,e){const n=Yc(t,e.name,e.message);return this.permissions[t]=n,L.emit(x.MEDIA_PERMISSION_ERROR,{message:n,constraints:e.constraints,kind:t}),n}getAudioAndVideoTrack(t,e){return p(this,null,function*(){const n={audio:o(this,Mn).getAudioConstraints(t).audio,video:o(this,Mn).getVideoConstraints(e).video};try{m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(n)});const i=yield navigator.mediaDevices.getUserMedia(n);m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(n)});const r=i.getAudioTracks()[0];let s=i.getVideoTracks()[0];if(this.permissions.audio="ACCEPTED",this.permissions.video="ACCEPTED",se.hasFeature(ue.OBS_QUALITY)&&s.label.includes("OBS Virtual")){const a=(yield this.getVideoInputDevices()).find(c=>c.label.includes("OBS Virtual"));s=yield this.getVideoTrack(a.deviceId)}return L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"}),L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"}),{audioTrack:r,videoTrack:s}}catch(i){throw m.error("WebMediaInterface.getAudioAndVideoTrack",{error:i}),new D("Couldnt fetch audio and video track","1605")}})}getAudioTrack(t,e){return p(this,null,function*(){let n=yield this.getAudioInputDevices();if(n.length===0)throw this.permissions.audio="NO_DEVICES_AVAILABLE",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"}),new D("No audio devices available","1606");const i=r=>p(this,null,function*(){let s;try{n=n.filter(c=>c.deviceId!==r),s=o(this,Mn).getAudioConstraints(r),m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(s)});const[a]=(yield navigator.mediaDevices.getUserMedia(s)).getAudioTracks();return m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(s)}),a}catch(a){const c=Yc("audio",a.name,a.message),d=new ju(a.name,a.message,s);if(c==="COULD_NOT_START"){const h=n.shift();if(!h)throw d;m.info("getAudioTrack::gum_failed",{constraints:JSON.stringify(s),error:a});const u=o(this,Mn).getAudioConstraints(h.deviceId);return m.info("getAudioTrack::retrying_gum_for_next_device",{constraints:JSON.stringify(u)}),i(h.deviceId)}throw d}});try{const r=yield i(e);return r.enabled=!t,this.permissions.audio!=="ACCEPTED"&&(this.permissions.audio="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.audio,kind:"audio"})),r}catch(r){throw r.constraints&&this.handlePermissionErrors("audio",r),new D(r.message,"1601")}})}getVideoTrack(t){return p(this,null,function*(){var e;const n=se.hasFeature(ue.OBS_QUALITY),i=(e=yield this.getCurrentDeviceLabel(t))==null?void 0:e.includes("OBS Virtual"),r=n&&i,s=yield this.getVideoInputDevices();if(s.length===0)throw this.permissions.video="NO_DEVICES_AVAILABLE",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"}),new D("No video devices available","1607");const a=c=>p(this,null,function*(){try{let d=c;const{video:h}=d;r&&typeof h!="boolean"&&(d={video:{deviceId:h.deviceId}}),m.info("getUserMediaWithoutTimeout::requesting_user_media",{constraints:JSON.stringify(d)});const[u]=(yield navigator.mediaDevices.getUserMedia(d)).getVideoTracks();if(r&&typeof h!="boolean"&&typeof h.width=="object"){const{width:g,height:E}=u.getSettings(),{ideal:b}=h.width;u.applyConstraints({width:{ideal:b},height:{ideal:Math.floor(E*b/g)},frameRate:h.frameRate})}return m.info("getUserMediaWithoutTimeout::received_user_media",{constraints:JSON.stringify(d)}),u}catch(d){const h=Yc("video",d.name,d.message),u=new ju(d.name,d.message,c);if(h==="COULD_NOT_START"){const g=s.shift();if(!g)throw u;m.info("getVideoTrack::gum_failed",{constraints:JSON.stringify(c),error:d});const E=o(this,Mn).getVideoConstraints(g.deviceId);return m.info("getVideoTrack::retrying_gum_for_next_device",{constraints:JSON.stringify(E)}),a({video:E.video})}throw u}});try{const c=o(this,Mn).getVideoConstraints(t),d=yield a(c);return this.permissions.video!=="ACCEPTED"&&(this.permissions.video="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.video,kind:"video"})),d}catch(c){throw c.constraints&&this.handlePermissionErrors("video",c),new D(c.message,"1602")}})}getScreenShareTracks(){return p(this,null,function*(){const t=e=>p(this,null,function*(){try{m.info("getDisplayMediaWithoutTimeout::requesting_display_media",{constraints:JSON.stringify(e)}),ne.screenShareRequested();const n=yield navigator.mediaDevices.getDisplayMedia(e);return m.info("getDisplayMediaWithoutTimeout::received_display_media",{constraints:JSON.stringify(e)}),n}catch(n){const i=Yc("video",n.name,n.message),r=new ju(n.name,n.message,e),s={video:!0};if(HR(e,s)||!se.hasFeature(ue.SCREEENSHARE_CONSTRAINTS_RETRY))throw r;if(i==="COULD_NOT_START")return t(s);throw r}});try{const e=o(this,Mn).getScreenShareConstraints(),n=yield t(e);return this.permissions.screenshare!=="ACCEPTED"&&(this.permissions.screenshare="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.permissions.screenshare,kind:"screenshare"})),{audioTrack:n.getAudioTracks()[0],videoTrack:n.getVideoTracks()[0]}}catch(e){throw e.constraints&&this.handlePermissionErrors("screenshare",e),new D(e.message,"1612")}})}getCurrentDeviceLabel(t){return p(this,null,function*(){const e=yield this.getDevice(t||"default");return e==null?void 0:e.label})}getAvailableDevices(){return p(this,null,function*(){try{const t=yield navigator.mediaDevices.enumerateDevices();return this.availableDevices=t,t}catch(t){throw m.error("enumerate_devices_failed",{error:t}),new D("Failed to get available devices","1609")}})}getAvailableDevicesByKind(t){return p(this,null,function*(){try{return(yield navigator.mediaDevices.enumerateDevices()).filter(({kind:e})=>t===e)}catch(e){throw m.error("enumerate_devices_failed",{error:e}),new D("Failed to get available devices by kind","1609")}})}getDevice(t){return p(this,null,function*(){try{return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>e.deviceId===t)[0]}catch(e){throw m.error("enumerate_devices_failed",{error:e}),new D("Failed to get device","1609")}})}onDeviceChange(t){return p(this,null,function*(){Be.supportsDeviceChangeEvent()&&navigator.mediaDevices.addEventListener("devicechange",e=>p(this,null,function*(){var n,i;const r=u=>`${u.kind}-${u.deviceId}-${u.groupId}`,s=this.availableDevices,a=new Set(s.map(u=>r(u))),c=yield this.getAvailableDevices(),d=new Set(c.map(u=>r(u))),h={added:c.filter(u=>!a.has(r(u))),removed:s.filter(u=>!d.has(r(u))),devices:c};if((n=h.added)!=null&&n.length||(i=h.removed)!=null&&i.length){m.info("repopulated_full_device_list",{devices:JSON.stringify(c)});const u=[...h.added,...h.removed];u.some(g=>g.kind==="audioinput")&&ne.devices("AUDIO",c==null?void 0:c.filter(g=>g.kind==="audioinput")),u.some(g=>g.kind==="videoinput")&&ne.devices("VIDEO",c==null?void 0:c.filter(g=>g.kind==="videoinput")),u.some(g=>g.kind==="audiooutput")&&ne.devices("SPEAKER",c==null?void 0:c.filter(g=>g.kind==="audiooutput")),t(e,h,!1)}}),{signal:o(this,Ya).signal})})}},Ya=new WeakMap,Mn=new WeakMap,Wu=new WeakMap,Lg);Yn([w.trace("WebMediaInterface.destruct")],fn.prototype,"destruct",1);Yn([w.trace("WebMediaInterface.handlePermissionErrors")],fn.prototype,"handlePermissionErrors",1);Yn([w.trace("WebMediaInterface.getAudioAndVideoTrack")],fn.prototype,"getAudioAndVideoTrack",1);Yn([w.trace("WebMediaInterface.getAudioTrack")],fn.prototype,"getAudioTrack",1);Yn([w.trace("WebMediaInterface.getVideoTrack")],fn.prototype,"getVideoTrack",1);Yn([w.trace("WebMediaInterface.getScreenShareTracks")],fn.prototype,"getScreenShareTracks",1);Yn([w.trace("WebMediaInterface.getAvailableDevices")],fn.prototype,"getAvailableDevices",1);Yn([w.trace("WebMediaInterface.getAvailableDevicesByKind")],fn.prototype,"getAvailableDevicesByKind",1);Yn([w.trace("WebMediaInterface.getDevice")],fn.prototype,"getDevice",1);Yn([w.trace("WebMediaInterface.onDeviceChange")],fn.prototype,"onDeviceChange",1);fn=Yn([Lt("1600")],fn);const CE=fn,Ko={setItem:(t,e)=>{try{localStorage.setItem(t,e)}catch(n){m.error("LocalStorage::setItem::crashed",{error:n,localStorage:{key:t,value:e}})}},getItem:t=>{try{return localStorage.getItem(t)}catch(e){m.error("LocalStorage::getItem::crashed",{error:e,localStorage:{key:t}})}return null}},jL=(t=0)=>new Promise(e=>setTimeout(e,t)),WL=(t,e,n)=>{const i=typeof n=="number"?n:250,r=t.createMediaStreamSource(e),s=t.createAnalyser();s.fftSize=2048,r.connect(s);const a=new Uint8Array(s.fftSize);let c=!1;setTimeout(()=>{c=!0},i);function d(){return c?Promise.resolve(!0):(s.getByteTimeDomainData(a),a.some(h=>h!==128&&h!==0)?Promise.resolve(!1):jL().then(d))}return d().then(h=>(r.disconnect(),h),h=>{throw r.disconnect(),h})},HL=typeof AudioContext!="undefined"?AudioContext:null;class lm{constructor(e){y(this,"_AudioContext"),y(this,"audioContext"),y(this,"_audioContextRefContainers");const n=H({AudioContext:HL},e);Object.defineProperties(this,{_AudioContext:{value:n.AudioContext},audioContext:{value:null,writable:!0},_audioContextRefContainers:{value:new Set},AudioContextProvider:{enumerable:!0,value:lm}})}getOrCreate(e){if(!this._audioContextRefContainers.has(e)&&(this._audioContextRefContainers.add(e),this._AudioContext&&!this.audioContext))try{this.audioContext=new this._AudioContext}catch{}return this.audioContext}release(e){this._audioContextRefContainers.has(e)&&(this._audioContextRefContainers.delete(e),!this._audioContextRefContainers.size&&this.audioContext&&(this.audioContext.close(),this.audioContext=null))}}const xg=new lm,qL=3,GL=250;function JL(t){const e={},n=xg.getOrCreate(e);let i=qL;function r(){return i-=1,WL(n,t.srcObject,GL).then(s=>s?i>0?r():!0:!1).catch(()=>!0)}return r().finally(()=>{xg.release(e)})}function Vg(t){return p(this,null,function*(){const e=new Audio,n=new MediaStream;n.addTrack(t),e.srcObject=n;let i=!1;try{const r=e.play();r&&(yield r),i=yield JL(e),i&&m.info("checkIfAudioTrackIsSilent::silence_detected")}catch(r){m.error("checkIfAudioTrackIsSilent::failed_to_detect_silence",{error:r})}finally{e.pause(),e.remove()}return i})}var $L=Object.defineProperty,KL=Object.getOwnPropertyDescriptor,RE=(t,e,n,i)=>{for(var r=i>1?void 0:i?KL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&$L(e,n,r),r};let pl=class extends Ra{constructor(t,e,n){var i;super(),y(this,"constructorName",this.constructor.name),y(this,"userSelectedDevice"),y(this,"mediaInterface"),y(this,"isNonPreferredDevice"),y(this,"_mediaTrack"),y(this,"transformedMediaTrack"),y(this,"middlewares",[]),y(this,"currentDevice"),y(this,"userPreferredDeviceKey",`Dyte::${this.constructorName}::UserDeviceID`),y(this,"setUserPreferredDevice",r=>Ko.setItem(this.userPreferredDeviceKey,r)),y(this,"getUserPreferredDevice",()=>Ko.getItem(this.userPreferredDeviceKey)),this.mediaInterface=t,e&&this.setMediaTrack(e),this.userSelectedDevice=(i=this.getUserPreferredDevice())!=null?i:void 0,this.isNonPreferredDevice=n,this.onTrackEnded=this.onTrackEnded.bind(this),this.onTrackMuted=this.onTrackMuted.bind(this)}disableTrack(){var t,e;this.removeMediaTrackListeners(),(t=this._mediaTrack)==null||t.stop(),this._mediaTrack=void 0,(e=this.transformedMediaTrack)==null||e.stop(),this.transformedMediaTrack=void 0}get mediaTrack(){return this._mediaTrack}setMediaTrack(t){return p(this,null,function*(){const e=n=>{m.error(`${this.constructorName}.setMediaTrack.error`,{error:n})};try{this.disableTrack()}catch(n){e(n)}this._mediaTrack=yield this.conditionallyChangeTrack(t),yield this.setTransformedTrack();try{this.addMediaTrackListeners(),yield this.setCurrentDevice()}catch(n){e(n)}})}get trackEnabled(){return!!this.mediaTrack&&this.mediaTrack.readyState==="live"&&this.mediaTrack.enabled}muteTrack(){if(!this.mediaTrack){m.warn("BaseMediaHandler.muteTrack Tried muting with no track present");return}this.transformedMediaTrack&&(this.transformedMediaTrack.enabled=!1),this.mediaTrack.enabled=!1}unmuteTrack(){return p(this,null,function*(){try{this.mediaTrack?this.mediaTrack.enabled=!0:yield this.enableTrack(!1)}catch(t){throw m.error(`${this.constructorName}.unmuteTrack.error`,{error:t}),this.disableTrack(),new D("Failed to unmute track","1611")}})}getCurrentDeviceId(){var t,e;const{kind:n}=this.mediaTrack;switch(n){case"audio":{const i=this.mediaTrack.getConstraints();return this.userSelectedDevice?(e=(t=i==null?void 0:i.deviceId)!=null?t:i==null?void 0:i.advanced[0].deviceId)!=null?e:this.mediaTrack.getSettings().deviceId:this.mediaTrack.getSettings().deviceId}default:return this.mediaTrack.getSettings().deviceId}}setCurrentDevice(){return p(this,null,function*(){var t;if(!this.mediaTrack){this.currentDevice=void 0;return}const e=this.getCurrentDeviceId();((t=this.currentDevice)==null?void 0:t.deviceId)!==e&&(this.currentDevice=yield this.mediaInterface.getDevice(e))})}setDevice(t){return p(this,null,function*(){if(!t)throw m.warn(`${this.constructorName}.setDevice No device received`),new D("No device received!","1603");this.userSelectedDevice=t.deviceId,this.setUserPreferredDevice(t.deviceId),yield this.onSetDevice(t)})}addMiddleware(t){return p(this,null,function*(){if(Be.isWebKitBased()&&!se.hasFeature(ue.ALLOW_SAFARI_MEDIA_MIDDLEWARES))return{success:!1,message:"Middlewares are not supported in this WebKit engine based browser."};if(this.middlewares.includes(t))return{success:!1,message:"This middleware has been applied, already. Skipping."};try{return this.middlewares.push(t),this.trackEnabled&&(yield this.setTransformedTrack()),{success:!0,message:"Successfully added the middleware."}}catch(e){return m.error("While adding middleware",{error:e}),this.removeMiddleware(t),{success:!1,message:e==null?void 0:e.message}}})}removeMiddleware(t){return p(this,null,function*(){const e=this.middlewares.indexOf(t,0);if(e>-1)try{return this.middlewares.splice(e,1),yield this.setTransformedTrack(!0),{success:!0,message:"Successfully removed the middleware."}}catch(n){return m.error("While removing middleware",{error:n}),{success:!1,message:n==null?void 0:n.message}}return{success:!1,message:"No such middleware was found. Skipping."}})}removeAllMiddlewares(){return p(this,null,function*(){var t;if((t=this.middlewares)!=null&&t.length)try{return this.middlewares=[],yield this.setTransformedTrack(!0),{success:!0,message:"Successfully removed all the middlewares."}}catch(e){return m.error("While removing all the middlewares",{error:e}),{success:!1,message:e==null?void 0:e.message}}return{success:!1,message:"No middlewares were found. Skipping."}})}addMediaTrackListeners(){var t,e,n;this.mediaTrack&&(m.info(`${this.constructorName}.addMediaTrackListeners for deviceId ${(e=(t=this.mediaTrack)==null?void 0:t.getSettings())==null?void 0:e.deviceId} of type ${(n=this.mediaTrack)==null?void 0:n.kind}`),this.mediaTrack.addEventListener("ended",this.onTrackEnded),this.mediaTrack.addEventListener("mute",this.onTrackMuted))}removeMediaTrackListeners(){var t,e,n;this.mediaTrack&&(m.info(`${this.constructorName}.removeMediaTrackListeners for deviceId ${(e=(t=this.mediaTrack)==null?void 0:t.getSettings())==null?void 0:e.deviceId} of type ${(n=this.mediaTrack)==null?void 0:n.kind}`),m.info(`${this.constructorName}.removeMediaTrackListeners`),this.mediaTrack.removeEventListener("ended",this.onTrackEnded),this.mediaTrack.removeEventListener("mute",this.onTrackMuted))}};RE([w.trace("BaseMediaHandler.unmuteTrack")],pl.prototype,"unmuteTrack",1);pl=RE([Lt("1600")],pl);const PE=pl;var zL=Object.defineProperty,YL=Object.getOwnPropertyDescriptor,um=(t,e,n,i)=>{for(var r=i>1?void 0:i?YL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&zL(e,n,r),r};const Hu="[Dyte]nonSilentDeviceLabels";class zl extends PE{onSetDevice(e){return p(this,null,function*(){if(!e)throw m.warn("AudioMediaHandler.setDevice No device received"),new D("No device received!","1603");if(e.kind!=="audioinput")throw m.warn("AudioMediaHandler.setDevice Received non audio device"),new D("Non audio device received while setting device!","1603");try{const n=this.trackEnabled;yield this.setMediaTrack(yield this.mediaInterface.getAudioTrack(!n,this.userSelectedDevice)),this.userSelectedDevice=void 0}catch(n){throw m.error("AudioMediaHandler.setDevice.error",{error:n}),this.disableTrack(),new D(n.message,"1604")}})}enableTrack(e){return p(this,null,function*(){if(this.trackEnabled){m.warn("AudioMediaHandler.enableTrack Track already enabled!");return}const n=yield this.mediaInterface.getAudioTrack(e,this.userSelectedDevice);yield this.setMediaTrack(n)})}setTransformedTrack(e){return p(this,null,function*(){var n;if(!e&&!((n=this.middlewares)!=null&&n.length)){this.transformedMediaTrack=this.mediaTrack;return}try{this.transformedMediaTrack=yield ML(this.middlewares,this.mediaTrack),this.emit("trackChanged")}catch(i){m.error("AudioMediaHandler.setTransformedTrack",{error:i}),this.transformedMediaTrack=this.mediaTrack}})}onTrackEnded(){return p(this,null,function*(){m.info("AudioMediaHandler.TrackEnded"),this.emit("trackEnded");const e=this.mediaTrack.enabled;this.disableTrack(),yield this.enableTrack(!e),yield this.setTransformedTrack(),this.emit("trackChanged")})}onTrackMuted(){m.info("AudioMediaHandler.TrackMuted"),this.emit("trackMuted")}conditionallyChangeTrack(e){return p(this,null,function*(){var n;if(!e||this.userSelectedDevice)return e;let i=e;const r=yield this.mediaInterface.getAudioInputDevices(),s=this.isNonPreferredDevice?r.filter(d=>d&&!this.isNonPreferredDevice(d)):r;if(!(s!=null&&s.length))return i;s.find(d=>d.deviceId===e.getSettings().deviceId)||(i.stop(),m.info("localmediahandler::setupstreams::found_audio_non_preferred"),i=yield this.mediaInterface.getAudioTrack(!1,s[0].deviceId));const a=JSON.parse(Ko.getItem(Hu));if(a!=null&&a.devices.some(d=>d.label===i.label))return i;if(!(yield Vg(i))){const d=(n=a==null?void 0:a.devices.concat({label:i.label}))!=null?n:[{label:i.label}];return Ko.setItem(Hu,JSON.stringify({devices:d})),i}m.info("AudioMediaHandler.conditionallyChangeTrack.DetectedSilentTrack");const c=i.getSettings().deviceId;return s.filter(d=>d.deviceId!==c).some(d=>p(this,null,function*(){if(i=yield this.mediaInterface.getAudioTrack(!1,d.deviceId),!(yield Vg(i))){const h=a.devices.concat({label:i.label});return Ko.setItem(Hu,JSON.stringify({devices:h})),m.info("AudioMediaHandler.conditionallyChangeTrack.SuccesfullyChangedTrack"),!0}return m.info("AudioMediaHandler.conditionallyChangeTrack.AnotherSilentTrackFound"),!1})),i})}}um([w.trace("AudioMediaHandler.setTransformedTrack")],zl.prototype,"setTransformedTrack",1);um([w.trace("AudioMediaHandler.onTrackEnded")],zl.prototype,"onTrackEnded",1);um([w.trace("AudioMediaHandler.conditionallyChangeTrack")],zl.prototype,"conditionallyChangeTrack",1);const QL=zl;var Eo;class XL{constructor(e){S(this,Eo,void 0),y(this,"currentDevice"),T(this,Eo,e)}setupSpeaker(e){return p(this,null,function*(){var n,i;if(!(o(this,Eo)instanceof CE))return;let r=e;if(e||([r]=(yield o(this,Eo).getAvailableDevicesByKind("audiooutput")).filter(a=>!jh(a))),!r)throw new D("No speaker found","1608");if(((n=this.currentDevice)==null?void 0:n.deviceId)===r.deviceId)return;this.currentDevice=r;const s=document.querySelectorAll("audio");(i=s[0])!=null&&i.setSinkId&&s.forEach(a=>p(this,null,function*(){if(typeof a.sinkId!="undefined"&&this.currentDevice.deviceId&&a.sinkId!==this.currentDevice.deviceId)try{yield a.setSinkId(this.currentDevice.deviceId)}catch{}}))})}}Eo=new WeakMap;const ZL=XL;class e2 extends Ra{constructor(e){super(),y(this,"mediaInterface"),y(this,"audioMediaTrack"),y(this,"videoMediaTrack"),this.mediaInterface=e}get trackEnabled(){return!!this.videoMediaTrack}enableScreenShare(){return p(this,null,function*(){var e,n;try{const{audioTrack:i,videoTrack:r}=yield this.mediaInterface.getScreenShareTracks();if(this.audioMediaTrack=i,this.videoMediaTrack=r,this.addMediaTrackListeners(),((n=(e=this.mediaInterface)==null?void 0:e.permissions)==null?void 0:n.screenshare)==="ACCEPTED")return;this.mediaInterface.permissions&&(this.mediaInterface.permissions.screenshare="ACCEPTED",L.emit(x.MEDIA_PERMISSION_UPDATE,{message:this.mediaInterface.permissions.screenshare,kind:"screenshare"}))}catch{}})}disableScreenShare(){var e,n;this.removeMediaTrackListeners(),(e=this.audioMediaTrack)==null||e.stop(),(n=this.videoMediaTrack)==null||n.stop(),this.videoMediaTrack=void 0,this.audioMediaTrack=void 0}updateConstraints(e){return p(this,null,function*(){if(!this.videoMediaTrack)throw new D("No media track enabled!","1610");const n=this.mediaInterface;if(!n.constraintsBuilder)throw new D("update constraints not supported for non web clients","1100");try{this.videoMediaTrack.applyConstraints(n.constraintsBuilder.getUpdatedVideoConstraints(e)),this.addMediaTrackListeners()}catch(i){m.error("ScreenShareHandler.updateConstraints.error",{error:i})}})}addMediaTrackListeners(){var e,n;(e=this.videoMediaTrack)==null||e.addEventListener("ended",this.onTrackEnded.bind(this)),Be.isWebKitBased()&&((n=this.videoMediaTrack)==null||n.addEventListener("mute",this.onTrackEnded.bind(this)))}removeMediaTrackListeners(){var e,n;(e=this.videoMediaTrack)==null||e.removeEventListener("ended",this.onTrackEnded),(n=this.videoMediaTrack)==null||n.removeEventListener("mute",this.onTrackEnded)}onTrackEnded(){this.emit("trackEnded")}}const t2=e2;var n2=Object.defineProperty,i2=Object.getOwnPropertyDescriptor,Yl=(t,e,n,i)=>{for(var r=i>1?void 0:i?i2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&n2(e,n,r),r},So,wd;class wc extends PE{constructor(e,n,i){super(e,n,i),S(this,So,void 0),S(this,wd,{disablePerFrameCanvasRendering:!1}),T(this,So,new OL)}onSetDevice(e){return p(this,null,function*(){if(!e)throw m.warn("VideoMediaHandler.setDevice No device received"),new D("No device received!","1603");if(e.kind!=="videoinput")throw m.warn("VideoMediaHandler.setDevice Received non video device",{devices:[e]}),new D("Non video device received while setting video device!","1603");if(!(this.mediaTrack&&this.mediaTrack.enabled)){m.warn("VideoMediaHandler.setDevice Tried switching device with video disabled",{devices:[e]}),this.currentDevice=e;return}try{yield this.setMediaTrack(yield this.mediaInterface.getVideoTrack(this.userSelectedDevice))}catch(n){throw m.error("VideoMediaHandler.setDevice.error",{error:n}),this.disableTrack(),new D("Failed to change device","1600")}})}enableTrack(){return p(this,null,function*(){if(this.trackEnabled){m.warn("VideoMediaHandler.enableTrack Track already enabled!");return}yield this.setMediaTrack(yield this.mediaInterface.getVideoTrack(this.userSelectedDevice))})}setTransformedTrack(e){return p(this,null,function*(){var n;if(!e&&!((n=this.middlewares)!=null&&n.length)){this.transformedMediaTrack=this.mediaTrack;return}try{this.transformedMediaTrack=yield o(this,So).getTransformedVideoTrack(this.middlewares,this.mediaTrack,o(this,wd)),this.emit("trackChanged")}catch(i){m.error("VideoMediaHandler.setTransformedTrack",{error:i}),this.transformedMediaTrack=this.mediaTrack}})}setVideoMiddlewareGlobalConfig(e){return p(this,null,function*(){T(this,wd,e)})}updateConstraints(e){return p(this,null,function*(){if(!this._mediaTrack)throw new D("No media track enabled!","1610");const n=this.mediaInterface;if(!n.constraintsBuilder)throw new D("update constraints not supported for non web clients","1100");try{this._mediaTrack.applyConstraints(n.constraintsBuilder.getUpdatedVideoConstraints(e)),yield this.setTransformedTrack(),this.addMediaTrackListeners(),yield this.setCurrentDevice()}catch(i){m.error("VideoMediaHandler.updateConstraints.error",{error:i})}})}terminateMiddlewareWebWorker(){o(this,So).terminateMiddlewareWebWorker()}onTrackEnded(){return p(this,null,function*(){m.info("VideoMediaHandler.TrackEnded"),this.disableTrack(),this.emit("trackEnded")})}onTrackMuted(){m.info("VideoMediaHandler.TrackMuted"),this.emit("trackMuted")}conditionallyChangeTrack(e){return p(this,null,function*(){if(!e||this.userSelectedDevice)return e;let n=e;const i=yield this.mediaInterface.getVideoInputDevices(),r=this.isNonPreferredDevice?i.filter(s=>!this.isNonPreferredDevice(s)):i;return!(r!=null&&r.length)||window.FAST_DYTE||r.find(s=>s.deviceId===e.getSettings().deviceId)||(n.stop(),m.info("localmediahandler::setupstreams::found_video_non_preferred"),n=yield this.mediaInterface.getVideoTrack(r[0].deviceId)),n})}}So=new WeakMap,wd=new WeakMap;Yl([w.trace("VideoMediaHandler.setTransformedTrack")],wc.prototype,"setTransformedTrack",1);Yl([w.trace("VideoMediaHandler.setVideoMiddlewareGlobalConfig")],wc.prototype,"setVideoMiddlewareGlobalConfig",1);Yl([w.trace("VideoMediaHandler.onTrackEnded")],wc.prototype,"onTrackEnded",1);Yl([w.trace("VideoMediaHandler.conditionallyChangeTrack")],wc.prototype,"conditionallyChangeTrack",1);const r2=wc,Ug=Gn(tm());var ln,Qs,_d,To;const bo=class{constructor(t){if(S(this,ln,void 0),S(this,Qs,void 0),S(this,_d,void 0),S(this,To,void 0),!t)throw new D("Could not load preset.","0904");T(this,ln,t.config),T(this,_d,t.name),T(this,Qs,t.ui||Gn(tm().ui)),T(this,To,t.permissions.plugins.config)}static fromResponse(t){return new bo(t)}static default(){return new bo(Ug)}static init(t,e=!0){return!t||e?new bo(Ug):new bo(t)}get setupScreen(){return{isEnabled:!0}}get waitingRoom(){return{isEnabled:!0}}get controlBar(){return{isEnabled:!0,elements:{chat:!0,fullscreen:!0,invite:!1,layout:!1,participants:!0,plugins:!0,polls:!0,reactions:!1,screenshare:!0}}}get header(){return{isEnabled:!0,elements:{logo:o(this,Qs).designTokens.logo,timer:!0,title:!0,participantCount:!0,changeLayout:!1}}}get pipMode(){return!0}get viewType(){return o(this,ln).viewType}get livestreamViewerQualities(){return o(this,ln).livestreamViewerQualities||[]}get maxVideoStreams(){return o(this,ln).maxVideoStreams}get maxScreenShareCount(){return o(this,ln).maxScreenshareCount}get plugins(){return[]}get disabledPlugins(){return Object.keys(o(this,To)).filter(t=>o(this,To)[t].disabled)}get designTokens(){return o(this,Qs).designTokens}get configDiff(){return o(this,Qs).configDiff}get mediaConstraints(){var t,e,n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K,X,O,J,me,Ie;return{audio:{enableStereo:(i=(n=(e=(t=o(this,ln))==null?void 0:t.media)==null?void 0:e.audio)==null?void 0:n.enableStereo)!=null?i:Vs.audio.enableStereo,enableHighBitrate:(c=(a=(s=(r=o(this,ln))==null?void 0:r.media)==null?void 0:s.audio)==null?void 0:a.enableHighBitrate)!=null?c:Vs.audio.enableHighBitrate},video:{quality:(g=(u=(h=(d=o(this,ln))==null?void 0:d.media)==null?void 0:h.video)==null?void 0:u.quality)!=null?g:Vs.video.quality,frameRate:(A=(k=(b=(E=o(this,ln))==null?void 0:E.media)==null?void 0:b.video)==null?void 0:k.frameRate)!=null?A:Vs.video.frameRate},screenshare:{quality:(X=(K=(B=(M=o(this,ln))==null?void 0:M.media)==null?void 0:B.screenshare)==null?void 0:K.quality)!=null?X:Vs.screenshare.quality,frameRate:(Ie=(me=(J=(O=o(this,ln))==null?void 0:O.media)==null?void 0:J.screenshare)==null?void 0:me.frameRate)!=null?Ie:Vs.screenshare.frameRate}}}get name(){return o(this,_d)}};let s2=bo;ln=new WeakMap,Qs=new WeakMap,_d=new WeakMap,To=new WeakMap;var a2=Object.defineProperty,o2=Object.getOwnPropertyDescriptor,AE=(t,e,n,i)=>{for(var r=i>1?void 0:i?o2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&a2(e,n,r),r},ko;class hm extends gn{constructor(e){super(),S(this,ko,void 0),y(this,"state","IDLE"),y(this,"playbackUrl"),y(this,"ingestionCredentials"),y(this,"viewerCount"),T(this,ko,e),this.viewerCount=0}setLivestreamState(e){const n=this.state;this.state=e,n!==e&&this.emitCurrentLivestreamState()}emitCurrentLivestreamState(){this.emit("livestreamUpdate",this.state)}start(){return p(this,arguments,function*(e={manualIngestion:!1}){if(!o(this,ko).permissions.canLivestream)throw m.error("DyteLivestream::start::permission_denied"),new D("User does not have permission to start livestreaming","1901");this.setLivestreamState("STARTING");try{const n=Pt(),{playbackUrl:i,ingestionCredentials:r}=yield n.startLivestreaming(e);this.playbackUrl=i,this.ingestionCredentials=r,e!=null&&e.manualIngestion&&this.setLivestreamState("WAITING_ON_MANUAL_INGESTION")}catch(n){throw m.error("DyteRecording::stop::livestream_failed_to_start",{error:n}),this.setLivestreamState("IDLE"),new D("Error while starting livestream","1900")}})}stop(){return p(this,null,function*(){if(!o(this,ko).permissions.canLivestream)throw m.error("DyteLivestream::stop::permission_denied"),new D("User does not have permission to stop livestreaming","1901");if(this.state!=="LIVESTREAMING"&&this.state!=="WAITING_ON_MANUAL_INGESTION")throw m.error("DyteLivestream::stop::inconsistent_state"),new D("Livestream not started yet","1902");try{this.setLivestreamState("STOPPING"),yield Pt().stopLivestreaming()}catch(e){throw m.error("DyteLivestream::stop::livestream_failed_to_stop",{error:e}),this.setLivestreamState("STOPPING"),new D("Error while stopping livestream","1900")}})}}ko=new WeakMap;AE([w.trace("livestream.start")],hm.prototype,"start",1);AE([w.trace("livestream.stop")],hm.prototype,"stop",1);var c2=Object.defineProperty,d2=Object.getOwnPropertyDescriptor,l2=(t,e,n,i)=>{for(var r=i>1?void 0:i?d2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&c2(e,n,r),r},wo,_o,rr;class ME{constructor(e,n){y(this,"livestream"),S(this,wo,void 0),S(this,_o,void 0),S(this,rr,void 0),T(this,_o,e),this.livestream=new hm(e),T(this,rr,n),this.setupEvents()}fetchInitialLivestreamingState(){return p(this,null,function*(){const e=Pt(),{status:n,playbackUrl:i,manualIngest:r,ingestionCredentials:s}=yield e.getActiveLivestream();this.livestream.playbackUrl=i,this.livestream.ingestionCredentials=s,n==="LIVE"&&this.livestream.setLivestreamState("LIVESTREAMING"),n==="INVOKED"&&r&&this.livestream.setLivestreamState("WAITING_ON_MANUAL_INGESTION")})}setupEvents(){o(this,rr).on(Y.startedLivestream,e=>p(this,null,function*(){this.livestream.playbackUrl=e.playbackUrl,this.livestream.setLivestreamState("LIVESTREAMING");try{o(this,_o).permissions.canLivestream&&(yield this.fetchInitialLivestreamingState())}catch{m.error("Error: LivestreamController.fetchLivestream during startedLivestream re-fetch")}})),o(this,rr).on(Y.livestreamingInvoked,e=>p(this,null,function*(){if(e.manualIngest){this.livestream.setLivestreamState("WAITING_ON_MANUAL_INGESTION");try{o(this,_o).permissions.canLivestream&&(yield this.fetchInitialLivestreamingState())}catch{m.error("Error: LivestreamController.fetchLivestream during livestreamingInvoked re-fetch")}}})),o(this,rr).on(Y.stoppedLivestream,()=>{this.livestream.setLivestreamState("IDLE"),this.livestream.playbackUrl=void 0,this.livestream.ingestionCredentials=void 0}),o(this,rr).on(Y.erroredLivestream,()=>{this.livestream.setLivestreamState("IDLE"),this.livestream.playbackUrl=void 0}),o(this,rr).on(Y.roomPeerCount,e=>{this.livestream.viewerCount=e.count,this.livestream.emit("viewerCountUpdate",e.count)}),L.on(x.PEER_JOINED_INTERNAL,e=>p(this,null,function*(){var n;((n=e.flags)==null?void 0:n.hiddenParticipant)===!0&&e.recorderType==="LIVESTREAMER"&&(T(this,wo,e.id),this.livestream.setLivestreamState("LIVESTREAMING"))})),L.on(x.PEER_CLOSED,e=>{e.id===o(this,wo)&&(T(this,wo,void 0),this.livestream.setLivestreamState("IDLE"))}),L.onAsync(x.LEAVE_MEDIA_ROOM,()=>p(this,null,function*(){this.livestream.playbackUrl||(m.info("Fetching livestreaming state on leave stage"),yield this.fetchInitialLivestreamingState())})),L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>p(this,null,function*(){try{yield this.fetchInitialLivestreamingState()}catch{m.error("Error: LivestreamController.fetchLivestream")}}))}}wo=new WeakMap,_o=new WeakMap,rr=new WeakMap;l2([w.trace("LivestreamController.setupEvents")],ME.prototype,"setupEvents",1);var u2=Object.defineProperty,h2=Object.getOwnPropertyDescriptor,_c=(t,e,n,i)=>{for(var r=i>1?void 0:i?h2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&u2(e,n,r),r},Gt,Gr,Jr,Hh,OE;class Ma{constructor({name:e,socketHandler:n,meetingId:i}){S(this,Hh),y(this,"name",""),S(this,Gt,{}),S(this,Gr,""),S(this,Jr,void 0),y(this,"rateLimitConfig",{maxInvocations:5,period:1}),y(this,"bulkRateLimitConfig",{maxInvocations:5,period:1}),y(this,"listeners",{}),this.name=e,T(this,Jr,n),T(this,Gr,i)}set(e,n,i=!0,r=!1){return p(this,null,function*(){o(this,Gt)[e]=n,i&&this.remoteSet(e,n),r&&(this.listeners[e]&&this.listeners[e].forEach(s=>s({[e]:o(this,Gt)[e]})),this.listeners["*"]&&this.listeners["*"].forEach(s=>s({[e]:o(this,Gt)[e]})))})}remoteSet(e,n){o(this,Jr).storeInsertKeys(o(this,Gr),this.name,[{key:e,payload:n}])}bulkSet(e){return p(this,null,function*(){e.forEach(({key:n,payload:i})=>{o(this,Gt)[n]=i}),o(this,Jr).storeInsertKeys(o(this,Gr),this.name,e)})}update(e,n,i=!0){return p(this,null,function*(){Q(this,Hh,OE).call(this,e,n,i)})}delete(e,n=!0,i=!1){return p(this,null,function*(){if(o(this,Gt)[e]&&delete o(this,Gt)[e],n)return o(this,Jr).storeDeleteKeys(o(this,Gr),this.name,[{key:e}]);i&&(this.listeners[e]&&(this.listeners[e].forEach(r=>r({[e]:void 0})),delete this.listeners[e]),this.listeners["*"]&&this.listeners["*"].forEach(r=>r({[e]:void 0})))})}bulkDelete(e){return p(this,null,function*(){return e.forEach(({key:n})=>{o(this,Gt)[n]&&delete o(this,Gt)[n]}),o(this,Jr).storeDeleteKeys(o(this,Gr),this.name,e)})}get(e){if(o(this,Gt)[e])return o(this,Gt)[e]}getAll(){return o(this,Gt)}get rateLimits(){return this.rateLimitConfig}updateRateLimits(e,n){this.rateLimitConfig.maxInvocations=e,this.rateLimitConfig.period=n}get bulkRateLimits(){return this.bulkRateLimitConfig}updateBulkRateLimits(e,n){this.bulkRateLimitConfig.maxInvocations=e,this.bulkRateLimitConfig.period=n}subscribe(e,n){if(this.listeners[e]){this.listeners[e].push(n);return}this.listeners[e]=[n]}unsubscribe(e,n){var i;if(n){this.listeners[e]=((i=this.listeners[e])==null?void 0:i.filter(r=>r!==n))||[];return}this.listeners[e]&&delete this.listeners[e]}populate(e){T(this,Gt,e)}}Gt=new WeakMap,Gr=new WeakMap,Jr=new WeakMap,Hh=new WeakSet,OE=function(t,e,n=!0){let i;const r=o(this,Gt)[t],s=Object.prototype.toString.call(e),a=Object.prototype.toString.call(r);if(s!==a){this.set(t,e);return}switch(a){case"[object Array]":i=[...r,...e];break;case"[object Object]":i=H(H({},r),e);break;case"[object Map]":i=new Map([...r,...e]);break;case"[object Set]":i=new Set([...r,...e]);break;default:i=e;break}this.set(t,i,n)};_c([on(Aa,"rateLimitConfig")],Ma.prototype,"remoteSet",1);_c([on(Aa,"bulkRateLimitConfig")],Ma.prototype,"bulkSet",1);_c([on(Aa,"rateLimitConfig")],Ma.prototype,"update",1);_c([on(Aa,"rateLimitConfig")],Ma.prototype,"delete",1);_c([on(Aa,"bulkRateLimitConfig")],Ma.prototype,"bulkDelete",1);var ua,ha,Id,qu,ml,as,qh,DE;class p2{constructor(e,n){S(this,Id),S(this,qh),y(this,"stores",new Map),S(this,ua,void 0),S(this,ha,""),S(this,ml,void 0),S(this,as,new Map),T(this,ua,n),T(this,ha,e.getValue("meetingId")),T(this,ml,e),Q(this,qh,DE).call(this)}create(e){const n=new Ma({name:e,socketHandler:o(this,ua),meetingId:o(this,ha)});return o(this,ua).storeGetKeys(o(this,ha),e,[]),new Promise((i,r)=>{const s=setTimeout(()=>r(Error("Failed")),3e3);o(this,as).set(e,{rejectTimeout:s,resolve:i,store:n})})}}ua=new WeakMap,ha=new WeakMap,Id=new WeakSet,qu=function(){return o(this,ml).getValue("peerId")},ml=new WeakMap,as=new WeakMap,qh=new WeakSet,DE=function(){[ie.storeInsertKeys,ie.storeGetKeys,ie.storeDeleteKeys].forEach(t=>{o(this,ua).on(t,e=>p(this,null,function*(){var n,i;if(e.pluginId!==o(this,ha))return;const r=(n=e.storeItems)==null?void 0:n.map(a=>{var c;return{timestamp:a.timestamp,peerId:a.peerId,payload:JSON.parse((c=a.payload)!=null&&c.length?new TextDecoder().decode(a.payload):"{}"),key:a.storeKey}});if(t===ie.storeGetKeys){const a=o(this,as).get(e.storeName),c=this.stores.get(e.storeName)||(a==null?void 0:a.store);o(this,as).get(e.storeName)&&(this.stores.set(e.storeName,a.store),a.resolve(c),clearTimeout(a.rejectTimeout),o(this,as).delete(e.storeName)),r.forEach(d=>{c.set(d.key,d.payload,!1,!1)});return}const s=this.stores.get(e.storeName)||((i=o(this,as).get(e.storeName))==null?void 0:i.store);s!==void 0&&(t===ie.storeInsertKeys&&r.forEach(({key:a,peerId:c,payload:d})=>{c!==o(this,Id,qu)&&s.set(a,d,!1,!0)}),t===ie.storeDeleteKeys&&r.forEach(({key:a,peerId:c})=>{c!==o(this,Id,qu)&&s.delete(a,!1,!0)}))}))})};function os(t){var e,n,i,r,s,a,c,d,h,u,g,E,b;return t?{media:{audio:{enabled:t.audioEnabled,trackId:(e=t.audioTrack)==null?void 0:e.id,permission:"mediaPermissions"in t?(n=t.mediaPermissions)==null?void 0:n.audio:null},video:{enabled:t.videoEnabled,trackId:(i=t.videoTrack)==null?void 0:i.id,permission:"mediaPermissions"in t?(r=t.mediaPermissions)==null?void 0:r.video:null},screenshare:{enabled:t.screenShareEnabled,permission:"mediaPermissions"in t?(s=t.mediaPermissions)==null?void 0:s.screenshare:null,audio:{enabled:(c=(a=t.screenShareTracks)==null?void 0:a.audio)==null?void 0:c.enabled,trackId:(h=(d=t.screenShareTracks)==null?void 0:d.audio)==null?void 0:h.id},video:{enabled:(g=(u=t.screenShareTracks)==null?void 0:u.video)==null?void 0:g.enabled,trackId:(b=(E=t.screenShareTracks)==null?void 0:E.video)==null?void 0:b.id}}}}:{}}var m2=Object.defineProperty,f2=Object.getOwnPropertyDescriptor,Oa=(t,e,n,i)=>{for(var r=i>1?void 0:i?f2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&m2(e,n,r),r};const g2=.8,v2=1.2;var Qa,Xa,xr,Us,Za,Bs,eo,Gu,Bg,Gi,Qc,Vr,to,Xc,Ji,Ju,Zc,$u,Fg;let Mi=(Fg=class extends gn{constructor(t,e,n,i){super(),S(this,Us),S(this,Bs),S(this,Gu),S(this,to),S(this,Zc),y(this,"id"),y(this,"userId"),y(this,"name"),y(this,"picture"),y(this,"isHost"),y(this,"customParticipantId"),y(this,"flags"),y(this,"device"),y(this,"videoTrack"),y(this,"audioTrack"),y(this,"screenShareTracks"),y(this,"videoEnabled"),y(this,"audioEnabled"),y(this,"screenShareEnabled"),y(this,"producers"),y(this,"manualProducerConfig"),S(this,Qa,void 0),y(this,"supportsRemoteControl",!1),S(this,Xa,void 0),y(this,"presetName"),S(this,xr,void 0),S(this,Gi,void 0),S(this,Qc,void 0),S(this,Vr,new Map),S(this,Ji,1),S(this,Ju,cl(O=>{if(!this.videoTrack)return;const{clientWidth:J,clientHeight:me}=O,{width:Ie,height:fe}=this.videoTrack.getSettings();if(!Ie||!fe)return;const $e=fe/me,ht=Ie/J,V=Math.max($e,ht);V>v2&&o(this,Ji)===1?(T(this,Ji,0),L.emit(x.MAX_SPATIAL_LAYER_CHANGE,{peerId:this.id,maxSpatialLayer:o(this,Ji)})):V<g2&&o(this,Ji)===0&&(T(this,Ji,1),L.emit(x.MAX_SPATIAL_LAYER_CHANGE,{peerId:this.id,maxSpatialLayer:o(this,Ji)}))},2e3)),T(this,xr,t);const{id:r,userId:s,displayName:a,device:c,picture:d,isHost:h,flags:u,clientSpecificId:g,stageStatus:E,customParticipantId:b,audioMuted:k,audioTrack:A,videoEnabled:M=!1,videoTrack:B,producers:K,metadata:X}=e;this.id=r,this.userId=s,this.name=a,this.device=c,this.picture=d,this.isHost=h,this.flags=u,this.manualProducerConfig=eP,T(this,Xa,E!=null?E:"ON_STAGE"),this.customParticipantId=b!=null?b:g,this.audioEnabled=!k,this.audioTrack=A,this.videoEnabled=M,this.videoTrack=B,this.screenShareTracks={audio:void 0,video:void 0},this.producers=K!=null?K:[],this.presetName=X==null?void 0:X.preset_name,T(this,Qa,!1),T(this,Gi,n),T(this,Qc,i),this.setupEvents(),this.updateVideo=this.updateVideo.bind(this),Q(this,Zc,$u).call(this)}get clientSpecificId(){return this.customParticipantId}get stageStatus(){return o(this,Xa)}setVideoEnabled(t,e=!0){this.videoEnabled=t,e&&(m.info("DyteParticipant::setVideoEnabled::videoUpdate",H({},os(this))),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}))}setAudioEnabled(t,e=!0){this.audioEnabled=t,e&&(m.info("DyteParticipant::setAudioEnabled::audioUpdate",H({},os(this))),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack}))}setScreenShareEnabled(t,e=!0){this.screenShareEnabled=t,e&&this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})}setupEvents(){this.on("videoUpdate",Q(this,Zc,$u))}pin(){return p(this,null,function*(){if(!o(this,Bs,eo))throw new D("Can`t pin participant without joining room","1205");if(!o(this,Gi).permissions.pinParticipant)throw new D("You do not have permission to pin participants.","1201");return o(this,Us,Za).pinPeer(this.id)})}unpin(){return p(this,null,function*(){if(!o(this,Bs,eo))throw new D("Can`t unpin participant without joining room","1205");if(!o(this,Gi).permissions.pinParticipant)throw new D("You do not have permission to unpin participants.","1201");return o(this,Us,Za).pinPeer(null)})}setIsPinned(t,e=!0){var n;T(this,Qa,t);const i=t?"pinned":"unpinned";(n=o(this,to,Xc))==null||n.updateSource(this.id,{pinned:t}),e&&this.emit(i,this)}disableAudio(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::disable_audio",{dyteParticipant:{id:t}}),!o(this,Bs,eo))throw new D("Can`t disable participant audio without joining room","1205");if(o(this,Gi).permissions.canDisableParticipantAudio)return o(this,Us,Za).disableAudio(t);throw m.error("DyteParticipant::unauthorized_disable_audio",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to disable participant audio.","1201")})}kick(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::kick",{dyteParticipant:{id:t}}),!o(this,Gu,Bg))throw new D("Can`t kick participant without joining room","1205");if(o(this,Gi).permissions.kickParticipant){yield L.emitAsync(x.KICK_PEER,{peerId:t});return}throw m.error("DyteParticipant::unauthorized_kick",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to kick participants.","1201")})}disableVideo(){return p(this,null,function*(){const t=this.id;if(m.info("DyteParticipant::disable_video",{dyteParticipant:{id:t}}),!o(this,Bs,eo))throw new D("Can`t disable participant video without joining room","1205");if(o(this,Gi).permissions.canDisableParticipantVideo)return o(this,Us,Za).disableVideo(t);throw m.error("DyteParticipant::unauthorized_disable_video",{dyteParticipant:{id:t}}),new D("Unauthorized: User does not have permission to disable participant video.","1201")})}getPermissions(){return p(this,null,function*(){return o(this,Qc).getUserPermissions(this.userId)})}setStageStatus(t){T(this,Xa,t),this.emit("stageStatusUpdate",this)}get isPinned(){return o(this,Qa)}registerVideoElement(t){var e,n,i,r;let s;(n=(e=o(this,Vr).get(t))==null?void 0:e.observer)==null||n.disconnect(),"ResizeObserver"in window&&(s=new ResizeObserver(()=>o(this,Ju).call(this,t)),s.observe(t)),o(this,Vr).set(t,{observer:s}),this.updateVideo(t),(r=o(this,to,Xc))==null||r.addSource(this.id,t,this.videoEnabled,this.isPinned,this.name,this.picture,(i=this.raised)!=null?i:!1)}deregisterVideoElement(t){var e,n,i;t.srcObject=void 0,(n=(e=o(this,Vr).get(t))==null?void 0:e.observer)==null||n.disconnect(),o(this,Vr).delete(t),(i=o(this,to,Xc))==null||i.removeSource(this.id)}updateVideo(t){var e;if(this.videoEnabled){if(this.videoTrack==null)return;const n=(e=t.srcObject)==null?void 0:e.getTracks()[0];if((n==null?void 0:n.id)===this.videoTrack.id)return;const i=new MediaStream;i.addTrack(this.videoTrack),t.srcObject=i}else t.srcObject=void 0;t.style.display=this.videoEnabled?"block":"none"}},Qa=new WeakMap,Xa=new WeakMap,xr=new WeakMap,Us=new WeakSet,Za=function(){return o(this,xr).getValue("roomNodeClient")},Bs=new WeakSet,eo=function(){return o(this,xr).getValue("connectionHandler").mediaJoined},Gu=new WeakSet,Bg=function(){return o(this,xr).getValue("connectionHandler").socketJoined},Gi=new WeakMap,Qc=new WeakMap,Vr=new WeakMap,to=new WeakSet,Xc=function(){return o(this,xr).getValue("pip")},Ji=new WeakMap,Ju=new WeakMap,Zc=new WeakSet,$u=function(){Array.from(o(this,Vr).keys()).forEach(this.updateVideo)},Fg);Oa([w.trace("DyteParticipant.disableAudio")],Mi.prototype,"disableAudio",1);Oa([w.trace("DyteParticipant.kick")],Mi.prototype,"kick",1);Oa([w.trace("DyteParticipant.disableVideo")],Mi.prototype,"disableVideo",1);Oa([w.trace("DyteParticipant.getPermissions")],Mi.prototype,"getPermissions",1);Oa([w.trace("DyteParticipant.setStageStatus")],Mi.prototype,"setStageStatus",1);Mi=Oa([Lt("1200")],Mi);class no extends wE{constructor(e){const{onAddEvent:n="participantJoined",onDeleteEvent:i="participantLeft",onClearEvent:r="participantsCleared"}=e!=null?e:{};super({onAddEvent:n,onDeleteEvent:i,onClearEvent:r})}add(e,n=!0){return this.has(e.id)&&Object.is(this.get(e.id),e)===!1&&this.delete(e.id),super.add(e,n)}clear(e=!0,n=!1){return super.clear(e,n)}delete(e,n=!0,i=!1){return super.delete(e,n,i)}}var $r;class y2 extends Ra{constructor(){super(),S(this,$r,void 0),T(this,$r,new Map)}__set(e,n){return o(this,$r).set(e,n)}__clear(){return o(this,$r).clear()}get(e){return o(this,$r).get(e)}toArray(){return Array.from(o(this,$r).values())}}$r=new WeakMap;class E2{constructor(){y(this,"_orderedArray"),y(this,"_map"),this._map=new Map,this._orderedArray=[]}add(e,n){if(!this._map.has(e))return this._map.set(e,{peerId:e,priority:n}),this._orderedArray.splice(Math.max(n-1,0),0,e),this.index(e);const i=this.index(e);this.delete(e);const r=this.add(e,n);return i!==r?r:-1}delete(e){if(this._map.has(e)){const n=this.index(e);this._map.delete(e),this._orderedArray.splice(n,1)}}index(e){return this._map.has(e)?this._orderedArray.indexOf(e):-1}[Symbol.iterator](){return this._orderedArray[Symbol.iterator]()}}class S2{constructor(){y(this,"_activeSpeakerPeers"),y(this,"_compulsoryPeers"),this._activeSpeakerPeers=new E2,this._compulsoryPeers=new Set}add(e,n){if(!e)return-1;if(n<0)return this._compulsoryPeers.add(e),0;if(this.compulsoryPeers.includes(e)&&(n>0||n===246267631)){if(m.info("DyteSelectedPeer::removing_compulsory_peer",{selectedPeer:{peerId:e}}),this._removeFromCompulsoryPeer(e),n===246267631)return-1}else if(n===229490415)return this.delete(e),-1;return this._activeSpeakerPeers.add(e,n)}delete(e){m.info("DyteSelectedPeer::deleting_peer_from_selectedPeer",{selectedPeer:{peerId:e}}),this._removeFromCompulsoryPeer(e),this._activeSpeakerPeers.delete(e)}index(e){return this._activeSpeakerPeers.index(e)}get peers(){return Array.from(new Set(this.compulsoryPeers.concat(this.activeSpeakerPeers)))}get compulsoryPeers(){return Array.from(this._compulsoryPeers.values())}get activeSpeakerPeers(){return Array.from(this._activeSpeakerPeers)}_removeFromCompulsoryPeer(e){this._compulsoryPeers.delete(e)}}const NE=new S2;var T2=Object.defineProperty,b2=Object.getOwnPropertyDescriptor,En=(t,e,n,i)=>{for(var r=i>1?void 0:i?b2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&T2(e,n,r),r};const k2=["ACTIVE_GRID","PAGINATED","MANUAL"];var On,Fs,io,js,ro,so,ed,Ws,dn,jg;let Xt=(jg=class extends gn{constructor(t,e,n){super(),S(this,Fs),S(this,js),S(this,so),y(this,"waitlisted"),y(this,"joined"),y(this,"active"),y(this,"videoSubscribed"),y(this,"audioSubscribed"),y(this,"pinned"),y(this,"all"),S(this,On,void 0),S(this,Ws,void 0),S(this,dn,void 0),y(this,"rateLimitConfig",{maxInvocations:5,period:1}),y(this,"viewMode"),y(this,"currentPage"),y(this,"lastActiveSpeaker"),y(this,"selectedPeers",NE),T(this,On,t),T(this,Ws,e),T(this,dn,n),this.waitlisted=new no,this.joined=new no,this.videoSubscribed=new no,this.audioSubscribed=new no,this.active=this.videoSubscribed,this.pinned=new no,this.all=new y2,this.viewMode="ACTIVE_GRID",this.currentPage=0,this.setupEvents()}get pip(){return o(this,On).getValue("pip")}get rateLimits(){return this.rateLimitConfig}updateRateLimits(t,e){this.rateLimitConfig.maxInvocations=t,this.rateLimitConfig.period=e}setupEvents(){L.on(x.E2EE_ACTIVE_CONSUMER,({peerId:t})=>{var e;((e=o(this,On).getValue("modules").e2ee)==null?void 0:e.enabled)!==!0&&this.emit("media_decode_error",{reason:`Got encrypted media for participantId ${t}, but encryption wasn't enabled in init.defaults`,code:"1702"})})}get count(){return this.joined.size}get maxActiveParticipantsCount(){var t;return(t=o(this,On))==null?void 0:t.getValue("maxPreferredStreams")}setMaxActiveParticipantsCount(t){if(t<0||t>24)throw new D("0 <= Max active participants count limit <= 24","1203");o(this,On).setValue("maxPreferredStreams",t),o(this,so,ed)&&L.emit(x.UPDATE_ACTIVE)}get pageCount(){if(this.viewMode==="PAGINATED"){const t=this.selectedPeers.compulsoryPeers.length,e=this.joined.toArray().filter(n=>n.stageStatus==="ON_STAGE");return Math.ceil((e.length-t)/Math.max(this.maxActiveParticipantsCount-t,1))}return 0}acceptWaitingRoomRequest(t){var e,n;if(!o(this,js,ro))throw new D("Can`t accept waiting room request without joining room","1205");const i=(n=(e=this.waitlisted.get(t))==null?void 0:e.userId)!=null?n:t;return o(this,dn).acceptWaitingRoomRequest([i])}acceptAllWaitingRoomRequest(t){return p(this,null,function*(){const e=t.map(n=>{var i,r;return(r=(i=this.waitlisted.get(n))==null?void 0:i.userId)!=null?r:n});return o(this,dn).acceptWaitingRoomRequest(e)})}rejectWaitingRoomRequest(t){return p(this,null,function*(){var e,n;if(!o(this,js,ro))throw new D("Can`t reject waiting room request without joining room","1205");const i=(n=(e=this.waitlisted.get(t))==null?void 0:e.userId)!=null?n:t;o(this,dn).rejectWaitingRoomRequest([i])})}setViewMode(t){return p(this,null,function*(){if(m.info("DyteParticipants::set_view_mode",{pageNavigation:{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),!(e=>k2.includes(e))(t))throw m.error("DyteParticipants::setViewMode::invalid_view_mode",{pageNavigation:{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),new D(`Invalid view mode: ${t}. Try ACTIVE_GRID, PAGINATED or MANUAL.`,"1207");if(this.viewMode===t){m.info("DyteParticipants::setViewMode::view_mode_same_as_previous");return}if(t==="MANUAL")throw new D("Manual Subscription is not enabled for your Organization. Please contact support.","1208");this.viewMode=t,t==="PAGINATED"?(this.currentPage=1,L.emit(x.UPDATE_ACTIVE,{page:this.currentPage})):t==="ACTIVE_GRID"&&(this.currentPage=0,L.emit(x.UPDATE_ACTIVE)),this.emit("viewModeChanged",{viewMode:t,currentPage:this.currentPage,pageCount:this.pageCount})})}subscribe(t){return p(this,arguments,function*(e,n=["audio","video","screenshareAudio","screenshareVideo"]){if(this.viewMode!=="MANUAL")throw new D("MANUAL subscription mode was not activated.","1206");const i=[];e.forEach(r=>{const s=this.joined.get(r);if(s){if(n.includes("audio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{audio:!0}),this.videoSubscribed.add(s);const a=s.producers.find(c=>c.kind==="audio"&&!c.screenShare);a&&i.push(a)}if(n.includes("video")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{video:!0}),this.audioSubscribed.add(s);const a=s.producers.find(c=>c.kind==="video"&&!c.screenShare);a&&i.push(a)}if(n.includes("screenshareAudio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareAudio:!0});const a=s.producers.find(c=>c.kind==="audio"&&c.screenShare);i.push(a)}if(n.includes("screenshareVideo")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareVideo:!0});const a=s.producers.find(c=>c.kind==="video"&&c.screenShare);i.push(a)}}}),yield o(this,Fs,io).createConsumers(i)})}unsubscribe(t){return p(this,arguments,function*(e,n=["audio","video","screenshareAudio","screenshareVideo"]){if(this.viewMode!=="MANUAL")throw new D("MANUAL subscription mode was not activated.","1206");const i=[];e.forEach(r=>{const s=this.joined.get(r);if(s){if(n.includes("audio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{audio:!1});const a=s.producers.find(c=>c.kind==="audio"&&!c.screenShare);a&&i.push(a)}if(n.includes("video")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{video:!1});const a=s.producers.find(c=>c.kind==="video"&&!c.screenShare);a&&i.push(a)}if(n.includes("screenshareAudio")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareAudio:!1});const a=s.producers.find(c=>c.kind==="audio"&&c.screenShare);i.push(a)}if(n.includes("screenshareVideo")){s.manualProducerConfig=ee(H({},s.manualProducerConfig),{screenshareVideo:!1});const a=s.producers.find(c=>c.kind==="video"&&c.screenShare);i.push(a)}}}),yield o(this,Fs,io).closeConsumers(i)})}getPeerIdsForCurrentPage(){m.info("DyteParticipants::getPeerIdsForCurrentPage()",{pageNavigation:{viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}});const{compulsoryPeers:t}=this.selectedPeers,e=t.filter(a=>this.joined.has(a)),n=Array.from(this.pinned.keys()).filter(a=>!e.includes(a)),i=Array.from(this.joined.toArray().filter(a=>a.stageStatus==="ON_STAGE").map(a=>a.id)),r=Math.max((this.currentPage-1)*(this.maxActiveParticipantsCount-e.length-n.length)),s=this.currentPage*(this.maxActiveParticipantsCount-e.length-n.length);return e.concat(n,i.slice(r,s))}setPage(t){return p(this,null,function*(){if(m.info("DyteParticipants::set_page",{pageNavigation:{settingPage:t,viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount,maxActiveParticipantsCount:this.maxActiveParticipantsCount}}),this.viewMode==="PAGINATED"){if(!Number.isInteger(t))throw m.error("DyteParticipants::invalid_page_number"),new D(`Invalid page: ${t}. Page must be an integer and greater than 0 and less than or equal to .pageCount`,"1202");this.currentPage=t,L.emit(x.UPDATE_ACTIVE,{page:t}),this.emit("pageChanged",{viewMode:this.viewMode,currentPage:this.currentPage,pageCount:this.pageCount})}})}disableAllAudio(t){return p(this,null,function*(){if(m.info("DyteParticipants::disable_all_audio",{actions:{disableAllAudio:{allowUnmute:t}}}),!o(this,so,ed))throw new D("Can`t disable all audio without joining room","1205");if(o(this,Ws).permissions.canAllowParticipantAudio)return o(this,Fs,io).muteAll(t);throw m.error("DyteParticipants::unauthorized_disable_all_audio",{actions:{disableAllAudio:{allowUnmute:t}}}),new D("Unauthorized: User does not have permission to disable peer audio.","1201")})}disableAllVideo(){return p(this,null,function*(){if(m.info("DyteParticipants::disable_all_video"),!o(this,so,ed))throw new D("Can`t disable all video without joining room","1205");if(o(this,Ws).permissions.canAllowParticipantVideo)return o(this,Fs,io).muteAllVideo();throw m.error("DyteParticipants::unauthorized_disable_all_video"),new D("Unauthorized: User does not have permission to disable peer video.","1201")})}disableAudio(t){return p(this,null,function*(){this.joined.get(t).disableAudio()})}disableVideo(t){return p(this,null,function*(){this.joined.get(t).disableVideo()})}kick(t){return p(this,null,function*(){yield L.emitAsync(x.KICK_PEER,{peerId:t})})}kickAll(){return p(this,null,function*(){if(m.info("DyteParticipants::kick_all"),o(this,On).getValue("viewType")!=="LIVESTREAM"&&!o(this,js,ro))throw new D("Can`t kick all without joining room","1205");if(!o(this,Ws).permissions.kickParticipant)throw m.error("DyteParticipants::unauthorized_kick_all"),new D("Unauthorized: User does not have permission to kick peers.","1201");const t=se.hasFeature(ue.PROPAGATE_KICK_ALL);o(this,dn).kickAll(t)})}broadcastMessage(t,e,n){return p(this,null,function*(){if(m.info("DyteParticipants::broadcastMessage"),!o(this,js,ro))throw new D("Can`t broadcast message without joining room","1205");if(!(t!=null&&t.trim()))throw new D("`type` must be a non-empty string.","1209");if(n)if("meetingIds"in n)yield o(this,dn).broadcastToMeetings(t,n.meetingIds,e);else{let i=[];"participantIds"in n?i=n.participantIds:i=this.joined.toArray().filter(r=>{var s;return(s=n.presetNames)==null?void 0:s.includes(r.presetName)}).map(r=>r.id),yield o(this,dn).broadcastToPeers(t,i,e)}else yield o(this,dn).broadcastMessage(t,e)})}getAllJoinedPeers(t,e,n){return p(this,null,function*(){return(yield o(this,dn).getRoomPeers(t,e,n)).peers.map(Ni.formatSocketServiceMessage)})}updatePermissions(t,e){return p(this,null,function*(){const n=this.joined.toArray().filter(r=>t.includes(r.id)).map(r=>r.userId),i=[...new Set(n)];if(!i.length)throw new D("Cannot update permissions, no valid userIDs found","1204");o(this,dn).updatePermissions(i,e)})}getParticipantsInMeetingPreJoin(){return p(this,null,function*(){return o(this,dn).getRoomPeersNonPaginated()})}},On=new WeakMap,Fs=new WeakSet,io=function(){return o(this,On).getValue("roomNodeClient")},js=new WeakSet,ro=function(){var t;return((t=o(this,On).getValue("connectionHandler"))==null?void 0:t.socketJoined)===!0},so=new WeakSet,ed=function(){var t;return((t=o(this,On).getValue("connectionHandler"))==null?void 0:t.mediaJoined)===!0},Ws=new WeakMap,dn=new WeakMap,jg);En([w.trace("DyteParticipants.setViewMode")],Xt.prototype,"setViewMode",1);En([w.trace("DyteParticipants.setPage")],Xt.prototype,"setPage",1);En([w.trace("DyteParticipants.disableAllAudio")],Xt.prototype,"disableAllAudio",1);En([w.trace("DyteParticipants.disableAllVideo")],Xt.prototype,"disableAllVideo",1);En([w.trace("DyteParticipants.disablePeerAudio")],Xt.prototype,"disableAudio",1);En([w.trace("DyteParticipants.disablePeerVideo")],Xt.prototype,"disableVideo",1);En([w.trace("DyteParticipants.kickPeer")],Xt.prototype,"kick",1);En([w.trace("DyteParticipants.kickAll")],Xt.prototype,"kickAll",1);En([w.trace("DyteParticipants.broadcastMessage"),on(Aa,"rateLimitConfig")],Xt.prototype,"broadcastMessage",1);En([w.trace("DyteParticipants.getAllJoinedPeers"),on({maxInvocations:10,period:60})],Xt.prototype,"getAllJoinedPeers",1);En([w.trace("DyteParticipant.updatePermissions"),on({maxInvocations:1e3,period:60})],Xt.prototype,"updatePermissions",1);En([w.trace("DyteParticipants.getParticipantsInMeetingPreJoin")],Xt.prototype,"getParticipantsInMeetingPreJoin",1);Xt=En([Lt("1200")],Xt);var wr=(t=>(t.NEW="new",t.CONNECTING="connecting",t.RECONNECTING="reconnecting",t.DISCONNECTED="disconnected",t.CONNECTED="connected",t.FAILED="failed",t.CLOSED="closed",t))(wr||{}),bt=(t=>(t[t.HIVE=1]="HIVE",t[t.ROOM_NODE=2]="ROOM_NODE",t[t.CF=3]="CF",t))(bt||{}),w2=Object.defineProperty,_2=Object.getOwnPropertyDescriptor,Ps=(t,e,n,i)=>{for(var r=i>1?void 0:i?_2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&w2(e,n,r),r};const LE=class{constructor(t,e,n,i){switch(y(this,"participants"),y(this,"self"),y(this,"selectedPeers",NE),y(this,"maxSpatialLayerUpdates",new Map),y(this,"consumerPeerMap"),y(this,"events"),y(this,"roomSocketHandler"),y(this,"context"),y(this,"videoPeerConsumerMap",new Map),y(this,"updateConsumerSpatialLayers",cl(()=>{const r={},s=new Map(this.maxSpatialLayerUpdates);this.maxSpatialLayerUpdates.clear(),Array.from(s.entries()).forEach(([a,c])=>{r[c]===void 0&&(r[c]={layer:c,consumerIds:[]}),r[c].consumerIds.push(a)}),Object.keys(r).forEach(a=>{const c=r[a];m.log(`Switching max spatial layer to ${c.layer}`,{consumerIds:c.consumerIds}),this.roomNodeClient.switchConsumersToLayer(c.consumerIds,c.layer)})},2e3)),y(this,"updateConsumers",(r,s)=>{let a=Promise.resolve();s.length>0&&(m.info("Closing consumers for producers",{producers:s}),a=this.roomNodeClient.closeConsumers(s)),a.then(()=>{r.length!==0&&(m.info("Consuming producers",{producers:r}),this.roomNodeClient.createConsumers(r).catch(c=>m.error("Error activating peers",{error:c})))}).catch(c=>m.error("Error deactivating peers",{error:c}))}),y(this,"updateConsumersDebounced",cl(this.updateConsumers,200,{trailing:!0})),this.context=t,this.roomSocketHandler=n,this.participants=new Xt(t,e,this.roomSocketHandler),this.self=e,this.consumerPeerMap=new Map,i){case bt.HIVE:{this.events=In;break}case bt.CF:{this.events=Hn;break}default:this.events=In}e.config.viewType!=="CHAT"&&this.setupEventsGlobal(),this.setupEvents()}get roomNodeClient(){return this.context.getValue("roomNodeClient")}get mediaJoined(){var t;return((t=this.roomNodeClient)==null?void 0:t.mediaJoined)===!0}get pip(){return this.context.getValue("pip")}setupEvents(){this.roomSocketHandler.on(Y.getWaitingRoomRequests,this.waitingRoomRequestHandler.bind(this)),L.on(x.SOCKET_PEERS,t=>p(this,null,function*(){const e=se.hasFeature(ue.DEBUG_SOCKET_JOIN);if(e){const n=t&&(t==null?void 0:t.length)<20?{peers:JSON.stringify(t.map(i=>i.peerId))}:void 0;m.info("Processing socket peers",n)}t==null||t.forEach(n=>{n.waitlisted||this.onParticipantJoined(this.fromSocketService(n))}),e&&m.info("Processed socket peers")})),this.roomSocketHandler.on(this.events.peerJoinedBroadcast,({participant:t})=>{se.hasFeature(ue.DEBUG_SOCKET_JOIN)&&m.info("events.peerJoinedBroadcast",{peers:t.peerId}),this.onMediaJoined(t.peerId,t.producerStates,t.capabilities)}),this.roomSocketHandler.on(this.events.selfJoinComplete,({participants:t,selectedPeers:e,roomState:n})=>{if(se.hasFeature(ue.DEBUG_SOCKET_JOIN)){const s=t&&(t==null?void 0:t.length)<20?{peers:JSON.stringify(t.map(a=>a.peerId))}:void 0;m.info("events.selfJoinComplete",s)}t.forEach(({peerId:s,producerStates:a,capabilities:c})=>this.onMediaJoined(s,a,c));const{audioPeers:i,compulsoryPeers:r}=e!=null?e:{};n.pinnedPeerIds.length!==0&&this.onParticipantPinned(n.pinnedPeerIds[0]),this.computeActivateParticipants(i!=null?i:[],r),L.emit(x.UPDATE_ACTIVE,{createAllConsumers:!0})}),L.on(x.MAX_SPATIAL_LAYER_CHANGE,({peerId:t,maxSpatialLayer:e})=>{const n=this.videoPeerConsumerMap.get(t);n&&(this.maxSpatialLayerUpdates.set(n,e),this.updateConsumerSpatialLayers())}),L.on(x.NEW_PRODUCER,({peerId:t,producer:e})=>{const n=this.participants.joined.get(t);if(!n){m.warn("ParticipantController::NEW_PRODUCER::participant not found",{producer:{id:e==null?void 0:e.producerId,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}},dyteParticipant:{id:t}});return}if(n.producers.push(e),m.info("ParticipantController::NEW_PRODUCER::producer_added_to_participant",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}}),this.participants.viewMode==="MANUAL"){let i=!1;const r=e.kind==="audio",s=e.kind==="video",a=n.manualProducerConfig;(r&&(a.audio&&!e.screenShare||a.screenshareAudio&&e.screenShare)||s&&(a.video&&!e.screenShare||a.screenshareVideo&&e.screenShare))&&(i=!0),i?this.roomNodeClient.createConsumers([e]):m.info("ParticipantController::NEW_PRODUCER::not_consuming_producer",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}});return}(e==null?void 0:e.kind)==="audio"&&this.participants.audioSubscribed.get(t)||(e==null?void 0:e.kind)==="video"&&this.participants.videoSubscribed.get(t)||e!=null&&e.screenShare?this.roomNodeClient.createConsumers([e]).catch(i=>{m.error("ParticipantController::createConsumer failed",{error:i})}):m.info("ParticipantController::NEW_PRODUCER::not_consuming_producer",{producer:{id:e==null?void 0:e.producerId,peerId:t,kind:e==null?void 0:e.kind,status:"UNKNOWN",appData:{screenShare:e==null?void 0:e.screenShare}}})}),L.on(x.PRODUCER_CLOSED,({peerId:t,producerId:e})=>{const n=this.participants.joined.get(t);if(!n){m.warn("ParticipantController::NEW_PRODUCER::participant not found",{dyteParticipant:{id:t}});return}n.producers=n.producers.filter(i=>i.producerId!==e)}),L.on(x.PRODUCER_TOGGLE,({peerId:t,producerId:e,paused:n,kind:i})=>{const r=this.participants.joined.get(t);if(r){i==="audio"&&r.setAudioEnabled(!n);const s=r.producers.find(a=>a.producerId===e);s&&(s.pause=n)}}),this.roomSocketHandler.on(this.events.globalPeerPinBroadcast,t=>{let e;if(t&&(e=t.participantId),!this.mediaJoined)return;const n=e;this.onParticipantPinned(n);const i=this.participants.joined.get(n);i&&this.roomNodeClient.activatePeers(i.producers).catch(r=>{m.error("unable to create consumers",{error:r})})}),this.roomSocketHandler.on(this.events.selectedPeer,({audioPeers:t,compulsoryPeers:e})=>{this.mediaJoined&&this.onSelectedPeers(e.concat(t))}),this.roomSocketHandler.on(this.events.selectedPeerDiff,({entries:t})=>{if(!this.mediaJoined)return;const e=t.map(n=>({peerId:n.peerId,priority:n.priority}));this.updateActiveParticipantsWithPriorities(e,!0)})}waitingRoomRequestHandler(t){const e=t.requests.filter(i=>!this.participants.waitlisted.toArray().find(r=>r.userId===i.userId)),n=this.participants.waitlisted.toArray().filter(i=>!t.requests.find(r=>r.userId===i.userId));e.forEach(i=>this.participants.waitlisted.add(new Mi(this.context,{id:i.peerId,displayName:i.displayName,audioMuted:!0,videoEnabled:!1,audioTrack:void 0,videoTrack:void 0,stageStatus:"OFF_STAGE",userId:i.userId,flags:{},isHost:!1,customParticipantId:i.customParticipantId,picture:i.picture,metadata:{preset_name:i.presetName}},this.self,this.roomSocketHandler))),n.forEach(i=>this.participants.waitlisted.delete(i.id))}get maxPreferredStreams(){return this.participants.maxActiveParticipantsCount}selectPagePeers(t){return p(this,null,function*(){const{compulsoryPeers:e}=this.selectedPeers,n=e.filter(c=>this.participants.joined.has(c)),i=Array.from(this.participants.pinned.keys()).filter(c=>!n.includes(c)),r=Array.from(this.participants.joined.toArray().filter(c=>c.stageStatus==="ON_STAGE").map(c=>c.id)),s=Math.max((t-1)*(this.maxPreferredStreams-n.length-i.length)),a=t*(this.maxPreferredStreams-n.length-i.length);return n.concat(i,r.slice(s,a))})}selectActivePeers(){const t=new Map,e=Array.from(this.participants.joined.toArray().filter(h=>h.stageStatus==="ON_STAGE").map(h=>(t.set(h.id,!0),h.id))),n=this.selectedPeers.peers,i=this.participants.pinned.toArray().reduce((h,u)=>(u.stageStatus!=="ON_STAGE"?this.participants.pinned.delete(u.id):h.push(u.id),h),[]),r=this.self.stageStatus==="ON_STAGE"?1:0,s=this.participants.maxActiveParticipantsCount-r,a=new Set(n.concat(i).filter(h=>h!==this.self.id&&t.has(h)));let c=Array.from(a);const d=s-a.size;if(d>=0){const h=e.filter(u=>!a.has(u)&&u!==this.self.id).slice(0,d);c=Array.from(a).concat(h)}else c=c.slice(0,s);return c}updateActive(t,e){return p(this,null,function*(){const{page:n,createAllConsumers:i}=e!=null?e:{};let{strategies:r}=e!=null?e:{},s,a;switch(t){case"PAGINATED":{if(!n)return;s=yield this.selectPagePeers(n),m.debug("ParticipantController::updateActive::updating_current_page_peers",{peerIds:s}),r!=null||(r={video:this.updateParticipantsMap.bind(this)}),a=this.updateConsumersDebounced;break}case"ACTIVE_GRID":{s=this.selectActivePeers(),m.debug("ParticipantController::updateActive::updating_current_selected_peers",{peerIds:s}),r!=null||(r={video:this.updateParticipantsMapMinReplacement.bind(this),audio:this.updateParticipantsMap.bind(this)}),a=this.updateConsumers;break}default:throw new Error(`View mode ${t} not supported`)}let c,d;const h=this.updateGrid(s,r);i?(c=this.mapPeerIdsToProducers(s,["audio","video","screenshare"]),d=[]):(c=[...this.mapPeerIdsToProducers([...h.video.add],["video"]),...this.mapPeerIdsToProducers([...h.audio.add],["audio"])],d=[...this.mapPeerIdsToProducers([...h.video.remove],["video"]),...this.mapPeerIdsToProducers([...h.audio.remove],["audio"])]),!(c.length===0&&d.length===0)&&a(c,d)})}computeActivateParticipants(t,e){const n=t.map((r,s)=>({peerId:r,priority:s+1})),i=e==null?void 0:e.map((r,s)=>({peerId:r,priority:-(s+1)}));n.push(...i!=null?i:[]),n.length>0&&this.updateActiveParticipantsWithPriorities(n)}fromSocketService(t){const e=LE.formatSocketServiceMessage(t);return new Mi(this.context,ee(H({},e),{isHost:!1,videoEnabled:!1,audioMuted:!0,videoTrack:void 0,audioTrack:void 0}),this.self,this.roomSocketHandler)}updatePipSource(t,e){var n,i;e?(n=this.pip)==null||n.enableSource(t):(i=this.pip)==null||i.disableSource(t)}onMediaJoined(t,e,n){if(!this.mediaJoined||t===this.self.id)return;const i=this.participants.joined.get(t);if(!i){m.warn(`Received media.peerJoinedBroadcast for non-existent peer ${t}`);return}e.forEach(r=>{r.kind===di.AUDIO&&!r.screenShare?i.setAudioEnabled(!r.pause):r.kind===di.VIDEO&&!r.screenShare&&(i.setVideoEnabled(!r.pause),this.updatePipSource(i.id,!r.pause)),i.producers.push(ee(H({},r),{producingTransportId:r.producingTransportId,kind:r.kind===di.AUDIO?"audio":"video",producingPeerId:t,mimeType:r.mimeType}))}),this.roomNodeClient.handlePeerCapabilities(t,n),se.hasFeature(ue.FORCE_VIDEO_CODEC)||this.roomNodeClient.shareWebcam(this.self.videoTrack)}updateParticipantsMapMinReplacement(t,e){const n=Array.from(t.keys()),i=new Map(t),r=[],s=[],a=new Set(e),c=[];return n.forEach((d,h)=>{(!a.has(d)||!this.participants.joined.get(d))&&c.push(h)}),e.forEach(d=>{if(t.get(d))return;if(n.length<e.length){n.push(d),r.push(d);return}const h=c.shift();s.push(n[h]),n[h]=d,r.push(n[h])}),n.forEach((d,h)=>{a.has(d)||s.concat(n.splice(h,1))}),Array.from(t.keys()).forEach(d=>{t.delete(d,!a.has(d))}),n.forEach(d=>{if(!this.participants.joined.get(d)){m.warn("updateActiveParticipants::participant_not_in_joined_list",{dyteParticipant:{id:d}});return}t.add(this.participants.joined.get(d),!i.get(d))}),t.emit("participantsUpdate"),[r,s]}updateParticipantsMap(t,e){const n=Array.from(t.keys()),i=[],r=[];return n.forEach(s=>{e.includes(s)||(t.delete(s,!0),r.push(s))}),e.forEach(s=>{t.get(s)||(t.add(this.participants.joined.get(s)),i.push(s))}),t.emit("participantsUpdate"),[i,r]}updatePinnedParticipants(){this.participants.pinned.forEach(t=>{t.setIsPinned(!1),this.participants.pinned.delete(t.id)})}setupEventsGlobal(){this.roomSocketHandler.on(Y.joinRoom,({peer:t})=>{if(!t.waitlisted){const e=se.hasFeature(ue.DEBUG_SOCKET_JOIN);e&&m.info("Processing socket join",{peers:t.peerId}),this.onParticipantJoined(this.fromSocketService(t)),e&&m.info("Processed socket join",{peers:t.peerId})}}),this.roomSocketHandler.on(Y.leaveRoom,t=>{const{peerId:e}=t.peer;this.selectedPeers.delete(e),this.onParticipantLeave(e)}),L.on(x.SOCKET_SERVICE_ROOM_JOINED,()=>{this.self.permissions.acceptWaitingRequests&&this.roomSocketHandler.getWaitingRoomRequests()}),this.self.permissions.on("permissionsUpdate",t=>{const{acceptWaitingRequests:e}=t;e!==void 0&&(e?this.roomSocketHandler.getWaitingRoomRequests():this.participants.waitlisted.clear())}),L.on(x.SOCKET_SERVICE_DISCONNECTED,()=>{this.participants.joined.clear(),this.participants.videoSubscribed.clear(),this.participants.audioSubscribed.clear(),this.participants.pinned.clear(),this.participants.currentPage=0,this.participants.viewMode="ACTIVE_GRID",this.participants.emit("viewModeChanged",{viewMode:"ACTIVE_GRID",currentPage:this.participants.currentPage,pageCount:this.participants.pageCount})}),L.on(x.CONSUMER_PAUSED,({id:t})=>{this.processConsumerPaused(t)}),L.on(x.CONSUMER_RESUMED,({id:t})=>{this.processConsumerResumed(t)}),L.on(x.NEW_CONSUMER,({id:t})=>{this.processNewConsumer(t)}),L.on(x.CONSUMER_CLOSED,({id:t})=>{this.processConsumerClosed(t)}),L.on(x.ROOM_MESSAGE,t=>p(this,[t],function*({payload:e,type:n,timestamp:i}){this.participants.emit("broadcastedMessage",{type:n,payload:e,timestamp:i})})),L.on(x.MESSAGE,t=>p(this,[t],function*({payload:e,type:n,timestamp:i}){n!=="spotlight"&&this.participants.emit("broadcastedMessage",{type:n,payload:e,timestamp:i})})),L.on(x.LOW_CONSUMER_SCORE,({peerId:t,score:e,kind:n})=>{const i=this.participants.joined.get(t);i&&(i.emit("poorConnection",{score:e,kind:n}),this.participants.emit("poorConnection",{participantId:t,score:e,kind:n}))}),L.on(x.CONSUMER_SCORE_UPDATE,({score:t,kind:e,appData:n,peerId:i,scoreStats:r})=>{var s;const a=e==="video"&&((s=n==null?void 0:n.screenShare)!=null?s:!1),c=this.participants.joined.get(i);c&&(c.emit("mediaScoreUpdate",{kind:e,isScreenshare:a,score:t,participantId:i,scoreStats:r}),this.participants.emit("mediaScoreUpdate",{kind:e,isScreenshare:a,score:t,participantId:i,scoreStats:r}))}),L.onAsync(x.KICK_PEER,t=>p(this,[t],function*({peerId:e}){const n=this.participants.joined.get(e);this.roomNodeClient.kick(e),yield this.roomSocketHandler.kick(e),n?n.emit("kicked"):this.participants.joined.emit("kicked",{id:e})})),L.on(x.UPDATE_ACTIVE,(...t)=>p(this,[...t],function*({page:e,createAllConsumers:n}={}){yield this.updateActive(e?"PAGINATED":"ACTIVE_GRID",{page:e,createAllConsumers:n})}))}onParticipantPinned(t){return p(this,null,function*(){if(!t){this.self.isPinned&&this.self.setIsPinned(!1),this.participants.pinned.size!==0&&this.updatePinnedParticipants();return}if(t===this.self.id){this.participants.pinned.size!==0&&this.updatePinnedParticipants(),this.self.setIsPinned(!0);return}const e=this.participants.joined.get(t);this.self.isPinned&&this.self.setIsPinned(!1),this.updatePinnedParticipants(),e.setIsPinned(!0),this.participants.pinned.add(e)})}onParticipantJoined(t){return p(this,null,function*(){var e,n,i;if(this.self.id!==t.id&&!((e=t.flags)!=null&&e.recorder)&&!((n=t.flags)!=null&&n.hidden_participant)&&!((i=t.flags)!=null&&i.hiddenParticipant)&&(this.participants.videoSubscribed.delete(t.id),this.participants.audioSubscribed.delete(t.id),this.participants.joined.add(t),this.participants.waitlisted.delete(t.id),t.stageStatus==="REQUESTED_TO_JOIN_STAGE"&&L.emit(x.UPDATE_STAGE_REQUESTS,{request:{displayName:t.name,userId:t.userId,peerId:t.id},add:!0})),L.emit(x.PEER_JOINED_INTERNAL,t),this.self.config.viewType===Yt.Webinar&&t.stageStatus!=="ON_STAGE"||this.roomNodeClient===void 0||this.participants.videoSubscribed.size>=this.maxPreferredStreams)return;const r=this.participants.currentPage;this.updateActive(r?"PAGINATED":"ACTIVE_GRID",{page:r})})}onParticipantLeave(t){return p(this,null,function*(){const e=this.participants.joined.get(t);this.participants.joined.delete(t,!0,!0),this.participants.pinned.delete(t,!0,!0),this.participants.waitlisted.delete(t,!0,!0),this.roomNodeClient&&(this.roomNodeClient.handlePeerLeaving(t),this.roomNodeClient.closeConsumers(e==null?void 0:e.producers)),e&&e.stageStatus==="REQUESTED_TO_JOIN_STAGE"&&L.emit(x.UPDATE_STAGE_REQUESTS,{request:{displayName:e.name,userId:e.userId,peerId:e.id},add:!1});const{currentPage:n}=this.participants,i=this.maxPreferredStreams*(n-1),r=this.participants.videoSubscribed.get(t);i===0?this.participants.setViewMode("ACTIVE_GRID"):this.participants.joined.size<=i?n===2?this.participants.setViewMode("ACTIVE_GRID"):this.participants.setPage(n-1):r&&this.updateActive(n?"PAGINATED":"ACTIVE_GRID",{page:n})})}processMedia(t){var e;const n=this.roomNodeClient.getConsumers(),{peerId:i,kind:r,appData:s,track:a,producerId:c,rtpReceiver:d,paused:h}=(e=n.get(t))!=null?e:{};if(!i)return m.warn("processMedia::Peer ID is undefined",{consumer:{id:t,kind:r,peerId:i,appData:{supportsRemoteControl:!!(s!=null&&s.supportsRemoteControl),screenShare:!!(s!=null&&s.screenShare)},remotelyPaused:h,producerId:c}}),{};const u=s;return r==="video"&&u.screenShare!==!0&&this.videoPeerConsumerMap.set(i,t),m.info("ParticipantController::processMedia",{consumer:{id:t,peerId:i,kind:r,appData:u,remotelyPaused:h,producerId:c}}),this.consumerPeerMap.set(t,{type:r,peerId:i,appData:u,remotelyPaused:h,producerId:c}),{peerId:i,kind:r,appData:u,remotelyPaused:h,track:a,producerId:c,rtpReceiver:d}}processConsumerClosed(t){const{peerId:e,type:n,appData:i,remotelyPaused:r,producerId:s}=this.consumerPeerMap.get(t)||{},a=this.participants.joined.get(e);if(m.info("ParticipantController::processConsumerClosed",{consumer:{id:t,peerId:e,appData:i,kind:n,remotelyPaused:r,producerId:s}}),this.consumerPeerMap.delete(t),n==="video"&&i.screenShare!==!0&&this.videoPeerConsumerMap.delete(e),!a)return;const c=[];i&&i.screenShare?(a.setScreenShareEnabled(!1),ne.consumerSharedMediaState(t,{screen:!1}),a.screenShareTracks.video&&c.push(a.screenShareTracks.video.id),a.screenShareTracks.audio&&c.push(a.screenShareTracks.audio.id),a.screenShareTracks={audio:void 0,video:void 0}):n==="audio"?(a.setAudioEnabled(!1),a.audioTrack&&c.push(a.audioTrack.id),ne.consumerSharedMediaState(t,{audio:!1}),a.audioTrack=void 0):n==="video"&&(a.setVideoEnabled(!1),this.updatePipSource(a.id,!1),a.videoTrack&&c.push(a.videoTrack.id),ne.consumerSharedMediaState(t,{video:!1}),a.videoTrack=void 0),i.e2ee&&c.forEach(d=>{L.emit(x.E2EE_INACTIVE_CONSUMER,{peerId:e,trackId:d})})}processConsumerResumed(t){const{peerId:e,kind:n,appData:i,track:r,remotelyPaused:s,producerId:a,rtpReceiver:c}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processConsumerResumed",{consumer:{id:t,peerId:e,kind:n,appData:i,remotelyPaused:s,producerId:a}});const d=this.participants.joined.get(e);if(d){if(i.e2ee&&L.emit(x.E2EE_ACTIVE_CONSUMER,{peerId:e,rtpReceiver:c,track:r}),i.screenShare){n==="video"?d.screenShareTracks.video=r:n==="audio"&&(d.screenShareTracks.audio=r),d.setScreenShareEnabled(!0),ne.consumerSharedMediaState(t,{screen:!0});return}n==="video"?(d.videoTrack=r,d.setVideoEnabled(!0),this.updatePipSource(d.id,!0),ne.consumerSharedMediaState(t,{video:!0})):n==="audio"&&(d.audioTrack=r,d.setAudioEnabled(d.audioEnabled),ne.consumerSharedMediaState(t,{audio:d.audioEnabled}))}}processConsumerPaused(t){m.info(`ParticipantController::processConsumerPaused called for consumerId: ${t}`);const{peerId:e,kind:n,track:i,appData:r,remotelyPaused:s,producerId:a}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processConsumerPaused",{consumer:{id:t,peerId:e,kind:n,appData:r,remotelyPaused:s,producerId:a}});const c=this.participants.joined.get(e);c&&(i&&r.e2ee&&L.emit(x.E2EE_INACTIVE_CONSUMER,{peerId:e,trackId:i.id}),n==="video"?(c.videoTrack=i,c.setVideoEnabled(!1),this.updatePipSource(c.id,!1),ne.consumerSharedMediaState(t,{video:!1})):n==="audio"&&(c.audioTrack=i,c.setAudioEnabled(c.audioEnabled),ne.consumerSharedMediaState(t,{audio:c.audioEnabled})))}processNewConsumer(t){const{peerId:e,kind:n,remotelyPaused:i,track:r,appData:s,producerId:a,rtpReceiver:c}=this.processMedia(t);if(!e)return;m.info("ParticipantController::processNewConsumer",{consumer:{id:t,peerId:e,kind:n,remotelyPaused:i,appData:s,producerId:a}});const d=this.participants.joined.get(e);if(d){if(s.screenShare){n==="video"?d.screenShareTracks.video=r:n==="audio"&&(d.screenShareTracks.audio=r),(!i||this.self.permissions.isRecorder||se.hasFeature(ue.SCREEENSHARE_ERR_HACK))&&d.setScreenShareEnabled(!0),s.supportsRemoteControl&&(d.supportsRemoteControl=!0),this.participants.broadcastMessage("screenshareConsumerCreated",{producerId:a,peerId:e,screenShare:!0,consumerId:t,consumerPeerId:this.self.id}),m.info("ParticipantController::newScreenshareConsumer::screenshareConsumerCreated",{consumer:{id:t,peerId:e,kind:n,remotelyPaused:i,appData:s,producerId:a}});return}n==="video"?(d.videoTrack=r,i||(d.setVideoEnabled(!0),this.updatePipSource(d.id,!0)),ne.consumerSharedMediaState(t,{video:!i})):n==="audio"&&(d.audioTrack=r,i||d.setAudioEnabled(!0),ne.consumerSharedMediaState(t,{audio:!i})),!i&&s.e2ee&&L.emit(x.E2EE_ACTIVE_CONSUMER,{peerId:e,rtpReceiver:c,track:r})}}static formatSocketServiceMessage(t){var e,n,i,r,s,a;if(!t)return;const c=om(t.stageType);return{id:t.peerId,userId:t.userId,name:t.displayName,displayName:t.displayName,stageType:c,customParticipantId:t.customParticipantId,presetId:t.presetId,picture:t.displayPictureUrl,waitlisted:t.waitlisted,stageStatus:c,metadata:{preset_name:(e=t.flags)==null?void 0:e.presetName},recorderType:(n=t.flags)==null?void 0:n.recorderType,flags:{hiddenParticipant:(i=t.flags)==null?void 0:i.hiddenParticipant,hidden_participant:(r=t.flags)==null?void 0:r.hiddenParticipant,recorder:((s=t.flags)==null?void 0:s.recorderType)!==void 0&&((a=t.flags)==null?void 0:a.recorderType)!=="NONE"}}}mapPeerIdsToProducers(t,e){const n=(i,r)=>i.filter(({kind:s,screenShare:a})=>r.includes(s)||a&&r.includes("screenshare"));return t.flatMap(i=>{const r=this.participants.joined.get(i);if(r)return n(r.producers,e)}).filter(i=>!!i)}updateGrid(t,e){let n=[],i=[],r=[],s=[];return e.video&&([n,r]=e.video(this.participants.videoSubscribed,t)),e.audio&&([i,s]=e.audio(this.participants.audioSubscribed,t)),{video:{add:n,remove:r},audio:{add:i,remove:s}}}onSelectedPeers(t,e){return p(this,null,function*(){this.participants.viewMode==="ACTIVE_GRID"&&this.computeActivateParticipants(t,e)})}updateActiveParticipantsWithPriorities(t,e=!1){if(!this.mediaJoined){m.warn("Skipped::ParticipantController::updateActiveParticipantsWithPriorities",{roomJoined:this.mediaJoined});return}t.forEach(i=>{this.selectedPeers.add(i.peerId,i.priority)});const n=this.selectedPeers.activeSpeakerPeers.at(0);n!==void 0&&n!==this.participants.lastActiveSpeaker&&(this.participants.lastActiveSpeaker=n,this.participants.emit("activeSpeaker",{peerId:n,volume:1})),e&&(this.participants.viewMode==="ACTIVE_GRID"?this.updateActive("ACTIVE_GRID"):this.participants.viewMode==="PAGINATED"&&this.updateActive("ACTIVE_GRID",{strategies:{audio:this.updateParticipantsMap.bind(this)}}))}};let Ni=LE;Ps([w.trace("ParticipantController.setupEvents")],Ni.prototype,"setupEvents",1);Ps([w.trace("ParticipantController.setupEvents")],Ni.prototype,"setupEventsGlobal",1);Ps([w.trace("ParticipantController.processMedia")],Ni.prototype,"processMedia",1);Ps([w.trace("ParticipantController.processConsumerClosed")],Ni.prototype,"processConsumerClosed",1);Ps([w.trace("ParticipantController.processConsumerResumed")],Ni.prototype,"processConsumerResumed",1);Ps([w.trace("ParticipantController.processConsumerPaused")],Ni.prototype,"processConsumerPaused",1);Ps([w.trace("ParticipantController.processNewConsumer")],Ni.prototype,"processNewConsumer",1);const Me=Gn(tm().permissions);var Z,Io,zo,Gh,nn,un;const Co=class extends gn{constructor(t,e,n,i=!1){if(super(),S(this,nn),S(this,Z,void 0),S(this,Io,void 0),S(this,zo,void 0),S(this,Gh,r=>{var s,a,c;const d=r,{chat:h,connectedMeetings:u,plugins:g,polls:E,media:b}=d,k=Ml(d,["chat","connectedMeetings","plugins","polls","media"]);if(h&&(h.private&&Xi(o(this,Z).chat.private,h.private),h.public&&Xi(o(this,Z).chat.public,h.public),this.emit("chatUpdate")),u&&Xi(o(this,Z).connectedMeetings,u),b){const A=B=>{switch(B){case yr.NONE:return re.Allowed;case yr.ALLOWED:return re.Allowed;case yr.NOT_ALLOWED:return re.NotAllowed;case yr.CAN_REQUEST:return re.CanRequest;default:return}},M={audio:void 0,video:void 0,screenshare:void 0};(s=b.audio)!=null&&s.canProduce&&(M.audio={canProduce:A(b.audio.canProduce)}),(a=b.video)!=null&&a.canProduce&&(M.video={canProduce:A(b.video.canProduce)}),(c=b.screenshare)!=null&&c.canProduce&&(M.screenshare={canProduce:A(b.screenshare.canProduce)}),Xi(o(this,Z).media,M)}g&&(Xi(o(this,Z).plugins,g),this.emit("pluginsUpdate")),E&&(Xi(o(this,Z).polls,E),this.emit("pollsUpdate")),Object.keys(k).length!==0&&Xi(o(this,Z),k),this.emit("permissionsUpdate",r)}),!e)throw m.error("DytePermissionsPreset::load_preset_permissions_failed"),new D("Could not load preset permissions.","0904");T(this,zo,t),T(this,Io,n),T(this,Z,e),i&&this.setupEvents()}setupEvents(){L.on(x.UPDATE_PERMISSIONS,o(this,Gh))}static fromResponse(t,e,n){return new Co(n,t,e,!0)}static default(t,e){return new Co(t,Me,e)}static init(t,e,n){let i;return n?i=new Co(t,n,e,!0):i=new Co(t,Me,e),i}get mediaRoomType(){const{sfu:t}=o(this,zo).getValue("roomNodeOptions");return t===bt.CF?"CF":"HIVE"}get stageEnabled(){var t;return((t=o(this,Z))==null?void 0:t.stageEnabled)||o(this,Io)===Yt.Webinar||o(this,Io)===Yt.Livestream}get acceptStageRequests(){var t,e;return this.stageEnabled?((t=o(this,Z))==null?void 0:t.acceptStageRequests)||((e=o(this,Z))==null?void 0:e.canAcceptProductionRequests):!1}get stageAccess(){var t,e,n;return((t=o(this,Z))==null?void 0:t.stageAccess)===re.NotAllowed?re.NotAllowed:((e=o(this,Z))==null?void 0:e.stageAccess)===re.CanRequest?re.CanRequest:((n=o(this,Z))==null?void 0:n.stageAccess)===re.Allowed||o(this,Z).media.audio.canProduce===re.Allowed||o(this,Z).media.video.canProduce===re.Allowed||o(this,Z).media.screenshare.canProduce===re.Allowed?re.Allowed:o(this,Z).media.audio.canProduce===re.CanRequest||o(this,Z).media.video.canProduce===re.CanRequest||o(this,Z).media.screenshare.canProduce===re.CanRequest?re.CanRequest:re.NotAllowed}get acceptWaitingRequests(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.acceptWaitingRequests)!=null?e:Me.acceptWaitingRequests}get requestProduceVideo(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.video)==null?void 0:n.canProduce)===re.CanRequest}get requestProduceAudio(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.audio)==null?void 0:n.canProduce)===re.CanRequest}get requestProduceScreenshare(){var t,e,n;return((n=(e=(t=o(this,Z))==null?void 0:t.media)==null?void 0:e.screenshare)==null?void 0:n.canProduce)===re.CanRequest}get canAllowParticipantAudio(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.disableParticipantAudio)!=null?e:Me.disableParticipantAudio}get canAllowParticipantScreensharing(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canAcceptProductionRequests)!=null?e:Me.canAcceptProductionRequests}get canAllowParticipantVideo(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.disableParticipantVideo)!=null?e:Me.disableParticipantVideo}get canDisableParticipantAudio(){return this.canAllowParticipantAudio}get canDisableParticipantVideo(){return this.canAllowParticipantVideo}get kickParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.kickParticipant)!=null?e:Me.kickParticipant}get pinParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.pinParticipant)!=null?e:Me.pinParticipant}get canRecord(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canRecord)!=null?e:Me.canRecord}get waitingRoomType(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.waitingRoomType)!=null?e:Me.waitingRoomType}get waitingRoomBehaviour(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.waitingRoomType)!=null?e:Me.waitingRoomType}get plugins(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.plugins)!=null?e:Me.plugins}get polls(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.polls)!=null?e:Me.polls}get produceVideo(){return this.canProduceVideo}get requestProduce(){return o(this,Z).media.audio.canProduce===re.CanRequest||o(this,Z).media.video.canProduce===re.CanRequest||o(this,Z).media.screenshare.canProduce===re.CanRequest}get canProduceVideo(){var t;const e=(t=o(this,Z).media.video.canProduce)!=null?t:Me.media.video.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get produceScreenshare(){return this.canProduceScreenshare}get canProduceScreenshare(){var t;const e=(t=o(this,Z).media.screenshare.canProduce)!=null?t:Me.media.screenshare.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get produceAudio(){return this.canProduceAudio}get canProduceAudio(){var t;const e=(t=o(this,Z).media.audio.canProduce)!=null?t:Me.media.audio.canProduce;return this.stageEnabled&&(o(this,nn,un)==="ACCEPTED_TO_JOIN_STAGE"||o(this,nn,un)==="ON_STAGE")&&e===re.CanRequest?re.Allowed:this.stageEnabled&&(o(this,nn,un)==="OFF_STAGE"||o(this,nn,un)==="REQUESTED_TO_JOIN_STAGE")&&e===re.Allowed?re.NotAllowed:e}get chatPublic(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.public)!=null?n:Me.chat.public}get chatPrivate(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.private)!=null?n:Me.chat.private}get chatChannel(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.channel)!=null?n:Me.chat.channel}get chatMessage(){var t,e,n;return(n=(e=(t=o(this,Z))==null?void 0:t.chat)==null?void 0:e.message)!=null?n:Me.chat.message}get connectedMeetings(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.connectedMeetings)!=null?e:Me==null?void 0:Me.connectedMeetings}get hiddenParticipant(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.hiddenParticipant)!=null?e:Me.hiddenParticipant}get showParticipantList(){var t;return(t=o(this,Z).showParticipantList)!=null?t:Me.showParticipantList}get canChangeParticipantRole(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canChangeParticipantPermissions)!=null?e:Me.canChangeParticipantPermissions}get canChangeParticipantPermissions(){var t,e;return(e=(t=o(this,Z))==null?void 0:t.canChangeParticipantPermissions)!=null?e:Me.canChangeParticipantPermissions}get canChangeTheme(){return!1}get canPresent(){return o(this,Z).media.audio.canProduce===re.Allowed||o(this,Z).media.video.canProduce===re.Allowed||o(this,Z).media.screenshare.canProduce===re.Allowed}get acceptPresentRequests(){return this.acceptStageRequests}get canEditDisplayName(){var t;return(t=o(this,Z).canEditDisplayName)!=null?t:!1}get maxScreenShareCount(){return 1}get isRecorder(){return o(this,Z).isRecorder}get canSpotlight(){return o(this,Z).canSpotlight}get canLivestream(){return o(this,Z).canLivestream}get transcriptionEnabled(){return o(this,Z).transcriptionEnabled}};let I2=Co;Z=new WeakMap,Io=new WeakMap,zo=new WeakMap,Gh=new WeakMap,nn=new WeakSet,un=function(){return o(this,zo).getValue("stageStatus")};var xE;class VE extends gn{constructor(){super(...arguments),y(this,"localMediaHandler"),S(this,xE,void 0)}updatePermission(){return p(this,null,function*(){var e,n;const i=(h,u)=>{this.mediaPermissions[h]=u;const g={message:this.mediaPermissions[h],kind:h};u==="DENIED"?L.emit(x.MEDIA_PERMISSION_ERROR,g):L.emit(x.MEDIA_PERMISSION_UPDATE,g)};if(Be.getName()==="firefox")return;const r="microphone",s="camera",a=yield(e=navigator==null?void 0:navigator.permissions)==null?void 0:e.query({name:r}),c=yield(n=navigator==null?void 0:navigator.permissions)==null?void 0:n.query({name:s}),d=(h,u)=>{switch(u){case"granted":i(h,"ACCEPTED");break;case"denied":i(h,"DENIED");break;case"prompt":i(h,"NOT_REQUESTED");break}this.localMediaHandler.repopulateAvailableDevices()};a&&(a.onchange=()=>d("audio",a.state)),c&&(c.onchange=()=>d("video",c.state))})}populateMediaPermissionsInCallstats(e){return p(this,arguments,function*({message:n,kind:i}){switch(i){case"audio":{ne.mediaPermission("AUDIO",n),ne.mediaPermission("SPEAKER",n);break}case"video":{ne.mediaPermission("VIDEO",n);break}case"screenshare":{ne.mediaPermission("SCREENSHARE",n);break}}})}init(){return p(this,arguments,function*(e={},n=!1,i=null){var r,s,a,c,d,h;if(Be.init(),!this.localMediaHandler)try{let u=!0;if(i!=null&&i.getValue("defaults").mediaHandler)u=!1,this.localMediaHandler=i.getValue("defaults").mediaHandler.localMediaHandler;else if(navigator.RNLocalMediaHandlerImpl){const{RNLocalMediaHandlerImpl:g}=navigator;this.localMediaHandler=yield g.init()}else this.localMediaHandler=new cn(i,e.constraints,(r=i==null?void 0:i.getValue("defaults"))==null?void 0:r.isNonPreferredDevice,(s=i==null?void 0:i.getValue("defaults"))==null?void 0:s.autoSwitchAudioDevice);if(L.on(x.MEDIA_PERMISSION_UPDATE,g=>p(this,null,function*(){if(this.populateMediaPermissionsInCallstats({message:g.message,kind:g.kind}),g.message==="NOT_REQUESTED")switch(g==null?void 0:g.kind){case"audio":this.rawAudioTrack&&(m.info("Disabling audio due to media permission update"),this.disableAudio());break;case"video":this.rawVideoTrack&&(m.info("Disabling video due to media permission update"),this.disableVideo());break;default:break}this.emit("mediaPermissionUpdate",g)})),L.on(x.MEDIA_PERMISSION_ERROR,g=>p(this,null,function*(){const{kind:E,message:b,constraints:k}=g;this.populateMediaPermissionsInCallstats({message:b,kind:E}),E==="audio"?(m.info(`Disabling audio due to media permission error skipping: ${this.localMediaHandler.audioUpdateInProgress}`),this.localMediaHandler.audioUpdateInProgress===!1&&this.disableAudio()):E==="video"&&(m.info(`Disabling video due to media permission error skipping: ${this.localMediaHandler.videoUpdateInProgress}`),this.localMediaHandler.videoUpdateInProgress===!1&&this.disableVideo()),m.error("SelfController::mediaPermissionError",{error:{message:b},constraints:k,mediaPermissionsErrors:{kind:E,message:b}}),this.emit("mediaPermissionError",g),this.emit("mediaPermissionUpdate",{message:b,kind:E})})),u){m.info(`Setting up DyteSelfMedia streams using media handler. audio:${(a=e==null?void 0:e.audio)!=null?a:!0} video:${(c=e==null?void 0:e.video)!=null?c:!0}`);const g=this.localMediaHandler.setupStreams({video:(d=e==null?void 0:e.video)!=null?d:!0,audio:(h=e==null?void 0:e.audio)!=null?h:!0});n||(yield g)}}catch(u){m.error("DyteSelf::init::Failed To Setup Streams",{error:{name:u.name,message:u.message}})}})}get audioTrack(){return this.localMediaHandler.audioTrack}get rawAudioTrack(){return this.localMediaHandler.rawAudioTrack}get mediaPermissions(){return this.localMediaHandler.permissions}addAudioMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.addAudioMiddleware(e)})}removeAudioMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.removeAudioMiddleware(e)})}removeAllAudioMiddlewares(){return p(this,null,function*(){return this.localMediaHandler.removeAllAudioMiddlewares()})}get videoTrack(){return this.localMediaHandler.videoTrack}get rawVideoTrack(){return this.localMediaHandler.rawVideoTrack}addVideoMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.addVideoMiddleware(e)})}setVideoMiddlewareGlobalConfig(){return p(this,arguments,function*(e={disablePerFrameCanvasRendering:!1}){return this.localMediaHandler.setVideoMiddlewareGlobalConfig(e)})}removeVideoMiddleware(e){return p(this,null,function*(){return this.localMediaHandler.removeVideoMiddleware(e)})}removeAllVideoMiddlewares(){return p(this,null,function*(){return this.localMediaHandler.removeAllVideoMiddlewares()})}get screenShareTracks(){return this.localMediaHandler.screenShareTracks}get audioEnabled(){return this.localMediaHandler.audioEnabled}get videoEnabled(){return this.localMediaHandler.videoEnabled}get screenShareEnabled(){return this.localMediaHandler.screenShareEnabled}enableAudio(){return p(this,null,function*(){yield this.localMediaHandler.enableAudio(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})}enableVideo(){return p(this,null,function*(){yield this.localMediaHandler.enableVideo(),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})}disableAudio(){return p(this,null,function*(){this.localMediaHandler.disableAudio(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})}enableScreenShare(){return p(this,null,function*(){yield this.localMediaHandler.enableScreenShare(),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})}disableScreenShare(){return p(this,null,function*(){yield this.localMediaHandler.disableScreenShare(),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})}disableVideo(){return p(this,null,function*(){yield this.localMediaHandler.disableVideo(),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})}getCurrentDevices(){return this.localMediaHandler.getCurrentDevices()}getAudioDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getAudioDevices()})}getVideoDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getVideoDevices()})}getSpeakerDevices(){return p(this,null,function*(){return yield this.localMediaHandler.getSpeakerDevices()})}getDeviceById(e,n){let i;return n==="audio"?i="audioinput":n==="video"?i="videoinput":n==="speaker"&&(i="audiooutput"),this.localMediaHandler.getDeviceById(e,i)}setDevice(e){return p(this,null,function*(){switch(e.kind){case"audioinput":try{yield this.localMediaHandler.setAudioDevice(e)}catch{}finally{this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}break;case"audiooutput":yield this.localMediaHandler.setSpeakerDevice(e);break;case"videoinput":try{yield this.localMediaHandler.setVideoDevice(e)}catch{}finally{this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})}break}this.emit("deviceUpdate",{device:e})})}}xE=new WeakMap;const ao={},Rr={executeWithLock({methodName:t,lockName:e,timeout:n}){return(i,r,s)=>{const a=s.value;return s.value=function(...c){if(ao[e]){const u=new Error(`Unsupported concurrent calls on Dyte method: ${t}.`);throw u.name="UnsupportedConcurrentMethodExecution",m.error("DyteLocker::UnsupportedConcurrentMethodExecution",{error:{stack:u.stack},dyteLocker:{methodName:t,lockName:e}}),u}ao[e]=!0;const d=setTimeout(()=>delete ao[e],n),h=a.apply(this,c);return Promise.resolve(h).then(()=>{delete ao[e],clearTimeout(d)}).catch(()=>{delete ao[e],clearTimeout(d)}),h},s}}};var C2=Object.defineProperty,R2=Object.getOwnPropertyDescriptor,Zt=(t,e,n,i)=>{for(var r=i>1?void 0:i?R2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&C2(e,n,r),r},oo,en,co,mi,Ur,Hs,yt,It,ct,mt,lo,uo,td,Ku,Wg;let wt=(Wg=class extends VE{constructor(t,e,n,i,r){var s;super(),S(this,Ur),S(this,yt),S(this,ct),S(this,td),y(this,"name"),y(this,"picture"),y(this,"customParticipantId"),y(this,"waitlistStatus"),S(this,oo,void 0),S(this,en,void 0),S(this,co,void 0),y(this,"role"),y(this,"userId"),y(this,"organizationId"),y(this,"supportsRemoteControl",!1),y(this,"device"),S(this,mi,void 0),y(this,"hidden",!1),y(this,"presetName"),y(this,"roomState","init"),S(this,lo,new Set),S(this,uo,new Set),T(this,mi,t),this.userId=e.id,this.name=e.name,this.picture=e.picture,this.customParticipantId=(s=e.customParticipantId)!=null?s:e.clientSpecificId,this.waitlistStatus="none",T(this,en,n),T(this,oo,i),this.hidden=!1,T(this,co,!1),this.organizationId=e.organizationId,this.supportsRemoteControl=Be.isElectron(),this.device=Be.getDeviceInfo(),this.presetName=r,i.viewType!==Yt.Chat&&this.updatePermission(),this.updateVideo=this.updateVideo.bind(this),Q(this,td,Ku).call(this)}get stageStatus(){return o(this,mi).getValue("stageStatus")}get id(){return o(this,mi).getValue("peerId")}static __init__(t,e,n,i,r,s=!1){return p(this,null,function*(){var a,c,d,h,u;let g=(c=(a=t.getValue("defaults"))==null?void 0:a.audio)!=null?c:!0,E=(h=(d=t.getValue("defaults"))==null?void 0:d.video)!=null?h:!0;n.canProduceAudio!=="ALLOWED"&&(g=!1),n.canProduceVideo!=="ALLOWED"&&(E=!1);const b=new wt(t,e,n,i,r);if(i.viewType===Yt.Chat)return b;const k=xL(i.mediaConstraints);return Xi(k,(u=t.getValue("defaults"))==null?void 0:u.mediaConfiguration),yield b.init({audio:g,video:E,constraints:k},s,t),b.setupEvents(),b})}cleanupEvents(){this.removeAllListeners("videoUpdate"),this.localMediaHandler.removeAllListeners("AUDIO_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("VIDEO_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("DEVICE_CHANGE"),this.localMediaHandler.removeAllListeners("DEVICE_LIST_UPDATED"),this.localMediaHandler.removeAllListeners("SCREENSHARE_TRACK_CHANGE"),this.localMediaHandler.removeAllListeners("SCREENSHARE_ENDED"),this.localMediaHandler.removeAllListeners("AUDIO_TRACK_SILENT"),this.localMediaHandler.removeAllListeners("FORCE_MUTE_AUDIO"),this.localMediaHandler.removeAllListeners("FORCE_MUTE_VIDEO"),o(this,en).removeAllListeners("permissionsUpdate")}setupEvents(){this.on("videoUpdate",Q(this,td,Ku)),this.localMediaHandler.on("AUDIO_TRACK_CHANGE",()=>p(this,null,function*(){if(m.info("DyteSelf::setupEvents::AUDIO_TRACK_CHANGE",H({},os(this))),o(this,ct,mt)&&this.audioEnabled)try{yield o(this,yt,It).shareMic(this.audioTrack)}catch(t){m.error("DyteSelf::setupEvents::Error while sharing mic",{error:t}),this.localMediaHandler.disableAudio()}this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})})),this.localMediaHandler.on("VIDEO_TRACK_CHANGE",()=>p(this,null,function*(){if(m.info("DyteSelf::setupEvents::VIDEO_TRACK_CHANGE",H({},os(this))),o(this,ct,mt)&&this.rawVideoTrack===void 0)m.info("DyteSelf::VIDEO_TRACK_CHANGE::Forcing_disable_video"),this.disableVideo();else if(this.videoEnabled&&o(this,ct,mt))try{const t=yield o(this,yt,It).shareWebcam(this.videoTrack);t&&t.id!==this.videoTrack.id&&se.hasFeature(ue.EXP_RESHARE)&&(yield o(this,yt,It).shareWebcam(this.videoTrack))}catch(t){m.error("DyteSelf::setupEvents::failed shareWebcam",{error:t}),this.videoEnabled&&(yield this.localMediaHandler.disableVideo())}this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})})),this.localMediaHandler.on("DEVICE_CHANGE",t=>p(this,[t],function*({device:e}){this.emit("deviceUpdate",{device:e})})),this.localMediaHandler.on("DEVICE_LIST_UPDATED",t=>{this.emit("deviceListUpdate",t)}),this.localMediaHandler.on("SCREENSHARE_TRACK_CHANGE",()=>p(this,null,function*(){if(!o(this,ct,mt)){m.error("DyteSelf.SCREENSHARE_TRACK_CHANGE.LocalMediaInitialized_WithoutRoomNode");return}if(this.screenShareEnabled)try{yield o(this,yt,It).shareScreen(this.screenShareTracks)}catch(t){m.error("DyteSelf::setupEvents::Error while sharing screen",{error:t}),this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare())}m.info("DyteSelf::setupEvents::SCREENSHARE_TRACK_CHANGE",H({},os(this))),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})})),this.localMediaHandler.on("SCREENSHARE_ENDED",()=>p(this,null,function*(){m.log("Disabling screenshare due to SCREENSHARE_ENDED"),yield this.disableScreenShare(),m.info("DyteSelf::setupEvents::SCREENSHARE_ENDED",H({},os(this)))})),this.localMediaHandler.on("AUDIO_TRACK_SILENT",()=>{ne.mediaTrackMuted("AUDIO")}),this.localMediaHandler.on("FORCE_MUTE_AUDIO",()=>{this.disableAudio()}),this.localMediaHandler.on("FORCE_MUTE_VIDEO",()=>p(this,null,function*(){o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),ne.videoOff()})),o(this,en).on("permissionsUpdate",t=>{var e,n,i;(e=t==null?void 0:t.media)!=null&&e.audio&&o(this,en).canProduceAudio!==re.Allowed&&(this.disableAudio(),m.info(`Disabled audio due to dynamic preset change: canProduceAudio: ${this.permissions.canProduceAudio}`)),(n=t==null?void 0:t.media)!=null&&n.video&&o(this,en).canProduceVideo!==re.Allowed&&(this.disableVideo(),m.info(`Disabled video due to dynamic preset change: canProduceVideo: ${this.permissions.canProduceVideo}`)),(i=t==null?void 0:t.media)!=null&&i.screenshare&&o(this,en).canProduceScreenshare!==re.Allowed&&(this.disableScreenShare(),m.info(`Disabled screenshare due to dynamic preset change: canProduceScreenshare: ${this.permissions.canProduceScreenshare}`))})}get permissions(){return o(this,en)}get config(){return o(this,oo)}get roomJoined(){var t;return o(this,oo).viewType===Yt.Livestream&&this.stageStatus!=="ON_STAGE"?((t=o(this,mi).getValue("connectionHandler"))==null?void 0:t.socketJoined)===!0:o(this,ct,mt)}setName(t){if(!t)throw new D("Name cannot be empty.","1103");this.name=t}setupTracks(){return p(this,arguments,function*(t={}){t.forceReset,yield this.disableAudio(),yield this.disableVideo(),this.localMediaHandler.removeAudioTrack(),this.localMediaHandler.removeVideoTrack(),t.audio&&(yield this.enableAudio()),t.video&&(yield this.enableVideo())})}destructMediaHandler(){return p(this,null,function*(){return this.localMediaHandler.destruct()})}removeDocumentEventListeners(){return p(this,null,function*(){return this.localMediaHandler.removeDocumentEventListeners()})}enableAudio(){return p(this,null,function*(){if(this.permissions.canProduceAudio!==re.NotAllowed&&!(o(this,en).canProduceAudio===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.audioEnabled){if(ne.audioOn(),yield this.localMediaHandler.enableAudio(),o(this,ct,mt)&&this.stageStatus==="ON_STAGE"){if(this.audioTrack)try{yield o(this,yt,It).shareMic(this.audioTrack)}catch(t){m.error("DyteSelf::enableAudio::Error while sharing mic",{error:t}),this.localMediaHandler.disableAudio()}if(!this.audioEnabled)return;o(this,yt,It).unmuteSelf()}this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}})}enableVideo(){return p(this,null,function*(){if(o(this,en).canProduceVideo!==re.NotAllowed&&!(o(this,en).canProduceVideo===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.videoEnabled){if(ne.videoOn(),yield this.localMediaHandler.enableVideo(),o(this,ct,mt)&&this.stageStatus==="ON_STAGE")try{yield o(this,yt,It).shareWebcam(this.videoTrack)}catch(t){m.error("DyteSelf::enableVideo::Error while sharing video",{error:t}),this.videoEnabled&&this.localMediaHandler.disableVideo()}this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),m.info("DyteSelf.enableVideo",H({},os(this)))}})}updateVideoConstraints(t){return p(this,null,function*(){if(!this.localMediaHandler.updateVideoConstraints)throw new D("Unsupported","1102");yield this.localMediaHandler.updateVideoConstraints(t)})}enableScreenShare(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t enable screenshare without joining room","1105");if(o(this,en).canProduceScreenshare!==re.NotAllowed&&!(o(this,en).canProduceScreenshare===re.CanRequest&&(this.stageStatus==="OFF_STAGE"||this.stageStatus==="REQUESTED_TO_JOIN_STAGE"))&&!this.screenShareEnabled&&(yield this.localMediaHandler.enableScreenShare(),this.screenShareTracks.audio||this.screenShareTracks.video)){try{yield o(this,yt,It).shareScreen(this.screenShareTracks)}catch(t){m.error("DyteSelf::enableScreenShare::Error while sharing screen",{error:t}),this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare())}this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks})}})}updateScreenshareConstraints(t){return p(this,null,function*(){if(!this.localMediaHandler.updateScreenshareConstraints)throw new D("Unsupported","1102");yield this.localMediaHandler.updateScreenshareConstraints(t)})}disableAudio(){return p(this,null,function*(){this.audioEnabled&&(this.localMediaHandler.disableAudio(),o(this,ct,mt)&&o(this,yt,It).muteSelf(),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack}),ne.audioOff())})}disableVideo(){return p(this,null,function*(){this.videoEnabled&&(yield this.localMediaHandler.disableVideo(),o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack}),ne.videoOff())})}disableScreenShare(){return p(this,null,function*(){this.screenShareEnabled&&(yield this.localMediaHandler.disableScreenShare(),o(this,ct,mt)&&(yield o(this,yt,It).disableScreenShare()),this.emit("screenShareUpdate",{screenShareEnabled:this.screenShareEnabled,screenShareTracks:this.screenShareTracks}))})}getAllDevices(){return this.localMediaHandler.getAllDevices()}setIsPinned(t,e=!0){var n;T(this,co,t);const i=t?"pinned":"unpinned";(n=o(this,Ur,Hs))==null||n.updateSource(this.id,{pinned:t}),e&&this.emit(i,this)}get isPinned(){return o(this,co)}pin(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t pin participants without joining room","1105");return this.show(),o(this,yt,It).pinPeer(this.id)})}unpin(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t unpin participants without joining room","1105");return o(this,yt,It).pinPeer(null)})}hide(){return p(this,null,function*(){if(!o(this,ct,mt))throw new D("Can`t toggle participant tile without joining room","1105");this.hidden=!0,this.emit("toggleTile",{hidden:this.hidden})})}show(){if(!o(this,ct,mt))throw new D("Can`t toggle participant tile without joining room","1105");this.hidden=!1,this.emit("toggleTile",{hidden:this.hidden})}setDevice(t){return p(this,null,function*(){var e,n,i;if(!t)throw new D("No device selected","1104");const r=this.getCurrentDevices();if(t.deviceId&&(((e=r==null?void 0:r.audio)==null?void 0:e.deviceId)===t.deviceId||((n=r==null?void 0:r.video)==null?void 0:n.deviceId)===t.deviceId||((i=r==null?void 0:r.speaker)==null?void 0:i.deviceId)===t.deviceId)&&(m.warn("DyteSelf.setDevice.setting_to_in_use_device",{devices:[t]}),se.hasFeature(ue.SKIP_SETTING_IN_USE_DEVICE)))throw new D("Cannot set device currently in use","1106");switch(t.kind){case"audioinput":try{yield this.localMediaHandler.setAudioDevice(t)}catch{o(this,ct,mt)&&(yield o(this,yt,It).muteSelf()),this.emit("audioUpdate",{audioEnabled:this.audioEnabled,audioTrack:this.audioTrack})}break;case"audiooutput":yield this.localMediaHandler.setSpeakerDevice(t);break;case"videoinput":try{yield this.localMediaHandler.setVideoDevice(t)}catch{o(this,ct,mt)&&(yield o(this,yt,It).pauseWebcam()),this.emit("videoUpdate",{videoEnabled:this.videoEnabled,videoTrack:this.videoTrack})}break}})}cleanUpTracks(){var t,e,n,i;(t=this.audioTrack)==null||t.stop(),(e=this.rawAudioTrack)==null||e.stop(),(n=this.videoTrack)==null||n.stop(),(i=this.rawVideoTrack)==null||i.stop()}registerVideoElement(t,e=!1){var n,i;e?o(this,lo).add(t):o(this,uo).add(t),this.updateVideo(t),e||(i=o(this,Ur,Hs))==null||i.addSource(this.id,t,this.videoEnabled,this.isPinned,this.name,this.picture,(n=this.raised)!=null?n:!1)}deregisterVideoElement(t,e=!1){t.srcObject=void 0,e?o(this,lo).delete(t):(o(this,uo).delete(t),o(this,Ur,Hs).removeSource(this.id))}updateVideo(t,e=!1){var n,i,r;if(this.videoEnabled){if(this.videoTrack==null)return;const s=(n=t.srcObject)==null?void 0:n.getTracks()[0];if((s==null?void 0:s.id)===this.videoTrack.id)return;const a=new MediaStream;a.addTrack(this.videoTrack),t.srcObject=a,e||(i=o(this,Ur,Hs))==null||i.enableSource(this.id)}else t.srcObject=void 0,e||(r=o(this,Ur,Hs))==null||r.disableSource(this.id);t.style.display=this.videoEnabled?"block":"none"}},oo=new WeakMap,en=new WeakMap,co=new WeakMap,mi=new WeakMap,Ur=new WeakSet,Hs=function(){return o(this,mi).getValue("pip")},yt=new WeakSet,It=function(){return o(this,mi).getValue("roomNodeClient")},ct=new WeakSet,mt=function(){var t;return((t=o(this,mi).getValue("connectionHandler"))==null?void 0:t.mediaJoined)===!0},lo=new WeakMap,uo=new WeakMap,td=new WeakSet,Ku=function(){Array.from(o(this,uo)).forEach(t=>this.updateVideo(t,!1)),Array.from(o(this,lo)).forEach(t=>this.updateVideo(t,!0))},Wg);Zt([w.trace("DyteSelf.cleanupEvents")],wt.prototype,"cleanupEvents",1);Zt([w.trace("DyteSelf.setupEvents")],wt.prototype,"setupEvents",1);Zt([w.trace("DyteSelf.setupTracks")],wt.prototype,"setupTracks",1);Zt([w.trace("DyteSelf.destructMediaHandler")],wt.prototype,"destructMediaHandler",1);Zt([w.trace("DyteSelf.removeDocumentEventListeners")],wt.prototype,"removeDocumentEventListeners",1);Zt([Rr.executeWithLock({methodName:"meeting.self.enableAudio",lockName:"DyteSelf.toggleAudio",timeout:3e3}),w.trace("DyteSelf.enableAudio")],wt.prototype,"enableAudio",1);Zt([Rr.executeWithLock({methodName:"meeting.self.enableVideo",lockName:"DyteSelf.toggleVideo",timeout:3e3}),w.trace("DyteSelf.enableVideo")],wt.prototype,"enableVideo",1);Zt([w.trace("DyteSelf.updateVideoConstraints")],wt.prototype,"updateVideoConstraints",1);Zt([w.trace("DyteSelf.enableScreenShare"),Rr.executeWithLock({methodName:"meeting.self.enableScreenShare",lockName:"DyteSelf.toggleScreenShare",timeout:3e3})],wt.prototype,"enableScreenShare",1);Zt([w.trace("DyteSelf.updateScreenshareConstraints")],wt.prototype,"updateScreenshareConstraints",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableAudio",lockName:"DyteSelf.toggleAudio",timeout:3e3}),w.trace("DyteSelf.disableAudio")],wt.prototype,"disableAudio",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableVideo",lockName:"DyteSelf.toggleVideo",timeout:3e3}),w.trace("DyteSelf.disableVideo")],wt.prototype,"disableVideo",1);Zt([Rr.executeWithLock({methodName:"meeting.self.disableScreenShare",lockName:"DyteSelf.toggleScreenShare",timeout:3e3}),w.trace("DyteSelf.disableScreenShare")],wt.prototype,"disableScreenShare",1);Zt([w.trace("DyteSelf.setDevice")],wt.prototype,"setDevice",1);wt=Zt([Lt("1100")],wt);var P2=Object.defineProperty,A2=Object.getOwnPropertyDescriptor,M2=(t,e,n,i)=>{for(var r=i>1?void 0:i?A2(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&P2(e,n,r),r};let qs;var nd,Hg;const UE=(Hg=class{constructor(t,e){y(this,"socket"),S(this,nd,void 0),T(this,nd,e),this.socket=t,this.handleSocketEvents()}static create(t,e){return qs||(qs=new UE(t,e)),qs}static cleanup(){var t;try{(t=qs==null?void 0:qs.socket)==null||t.disconnect()}catch{m.error("roomSocketHandler::cleanup")}qs=void 0}joinRoom(t){return p(this,null,function*(){var e;this.socket.joinAttempted=!0;const n={capabilities:[],peer:{displayName:(e=t.name)!=null?e:"Participant",customParticipantId:t.customParticipantId,peerId:t.id,userId:t.userId,displayPictureUrl:t.picture,waitlisted:!1},roomUuid:""},i=this.socket.sendMessagePromise(Y.joinRoom,GM.toBinary(n));try{const{peer:r}=Gs.fromBinary((yield i).payload);o(this,nd).getValue("connectionHandler").socketJoined=!0,L.emit(x.SOCKET_SERVICE_ROOM_JOINED,{peer:r});const s=this.getRoomState(),a=this.getRoomPeersNonPaginated(),[{room:c},{peers:d}]=yield Promise.all([s,a]);return L.emit(x.ROOM_STATE,c),L.emit(x.SOCKET_PEERS,d),{peer:r}}catch(r){throw m.error("RoomSocketHandler.joinRoom.failed",{error:r}),new D("Error: RoomSocketHandler.joinRoom failed.","0002",r)}})}getAllAddedParticipants(){return p(this,null,function*(){try{return P1.fromBinary((yield this.socket.sendMessagePromise(Y.getAllAddedParticipants)).payload).participants.map(t=>{var e=t,{id:n}=e,i=Ml(e,["id"]);return ee(H({},i),{userId:n})})}catch{return[]}})}getRoomPeers(t,e,n){return p(this,null,function*(){let i;try{const r={seachQuery:t,limit:e,offset:n},s=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo,LM.toBinary(r));i=Ru.fromBinary(s.payload)}catch(r){m.error("getRoomPeers::binary_decode_error",{error:r})}return i})}getRoomPeersNonPaginated(){return p(this,null,function*(){let t;try{const e=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo);t=Ru.fromBinary(e.payload)}catch(e){m.error("getRoomJoinedPeers::binary_decode_error",{error:e})}return t})}getStagePeers(){return p(this,null,function*(){let t;try{const e=yield this.socket.sendMessagePromise(Y.getRoomPeersInfo);t=Ru.fromBinary(e.payload)}catch(e){m.error("getRoomJoinedPeers::binary_decode_error",{error:e})}return t})}getPeerInfo(t){return p(this,null,function*(){let e;try{const n=yield this.socket.sendMessagePromise(Y.getPeerInfo,dE.toBinary({peerId:t}));e=Gs.fromBinary(n.payload)}catch(n){m.error("getPeerInfo::binary_decode_error",{error:n})}return e})}getRoomState(){return p(this,null,function*(){let t=sg.create();try{const e=yield this.socket.sendMessagePromise(Y.getRoomInfo);t=sg.fromBinary(e.payload)}catch(e){m.error("getRoomState::binary_decode_error",{error:e})}return t})}getRoomStageState(){return p(this,null,function*(){let t=dg.create();try{const e=yield this.socket.sendMessagePromise(Y.getRoomStageState);t=dg.fromBinary(e.payload)}catch(e){m.error("getRoomStageState::binary_decode_error",{error:e})}return t})}broadcastMessage(t,e){return p(this,null,function*(){const n={type:t,payload:new TextEncoder().encode(JSON.stringify(e)),timestamp:Date.now(),ids:[]};return this.socket.sendMessagePromise(Y.broadcastMessage,Va.toBinary(n))})}broadcastToMeetings(t,e,n){return p(this,null,function*(){const i={type:t,payload:new TextEncoder().encode(JSON.stringify(n)),timestamp:Date.now(),ids:e,broadcastType:1};return this.socket.sendMessagePromise(Y.broadcastToEntity,Va.toBinary(i))})}broadcastToPeers(t,e,n){return p(this,null,function*(){const i={type:t,payload:new TextEncoder().encode(JSON.stringify(n)),timestamp:Date.now(),ids:e,broadcastType:0};return this.socket.sendMessage(Y.broadcastToEntity,Va.toBinary(i))})}leaveRoom(){return p(this,null,function*(){this.socket.joinAttempted=!1,this.socket.sendMessagePromise(Y.leaveRoom,$M.toBinary({}))})}kick(t){return p(this,null,function*(){const e={peerIds:[t]};this.socket.sendMessage(Y.kick,uE.toBinary(e))})}kickAll(t=!1){return p(this,null,function*(){const e={propagateKickAcrossRooms:t};this.socket.sendMessage(Y.kickAll,aE.toBinary(e))})}getWaitingRoomRequests(){this.socket.sendMessage(Y.getWaitingRoomRequests)}acceptWaitingRoomRequest(t){const e={userIds:t};this.socket.sendMessage(Y.acceptWaitingRoomRequests,L1.toBinary(e))}rejectWaitingRoomRequest(t){const e={userIds:t};this.socket.sendMessage(Y.denyWaitingRoomRequests,V1.toBinary(e))}updatePermissions(t,e){return p(this,null,function*(){const n={updatePeersPresets:[]};return t.forEach(i=>{n.updatePeersPresets.push({userIds:i,patch:e})}),this.socket.sendMessagePromise(vd.updateUserPreset,hO.toBinary(n))})}handleSocketEvents(){this.socket.on(Y.broadcastMessage,({payload:t})=>{try{const e=Va.fromBinary(t);L.emit(x.ROOM_MESSAGE,{payload:JSON.parse(new TextDecoder().decode(e.payload)),type:e.type,timestamp:e.timestamp})}catch(e){m.error("failed to decode broadcast message:",e)}}),this.socket.on(Y.broadcastToEntity,({payload:t})=>{try{const e=Va.fromBinary(t);L.emit(x.MESSAGE,{payload:JSON.parse(new TextDecoder().decode(e.payload)),type:e.type,timestamp:e.timestamp})}catch(e){m.error("failed to decode peer broadcast message:",e)}})}on(t,e){let n,i;switch(t){case Y.joinRoom:case Y.leaveRoom:case Y.kick:case Y.kickAll:{n=Gs.fromBinary.bind(Gs),i=Gs.create();break}case Y.getWaitingRoomRequests:{n=(r,s)=>r?cg.fromBinary(r,s):{requests:[]},i=cg.create();break}case Y.recordingPaused:case Y.recordingStarted:case Y.recordingStopped:{n=yg.fromBinary.bind(yg);break}case vd.updateUserPreset:{n=lg.fromBinary.bind(lg);break}case Hn.peerJoinedBroadcast:case In.peerJoinedBroadcast:{n=Zf.fromBinary.bind(Zf);break}case Hn.selfJoinComplete:case In.selfJoinComplete:{n=Ih.fromBinary.bind(Ih);break}case Hn.globalPeerPinBroadcast:case In.globalPeerPinBroadcast:{n=ng.fromBinary.bind(ng);break}case Hn.selectedPeer:case In.selectedPeer:{n=_h.fromBinary.bind(_h);break}case Hn.selectedPeerDiff:case In.selectedPeerDiff:{n=Xf.fromBinary.bind(Xf);break}case Hn.leaveRoom:case In.leaveRoom:{n=Ch.fromBinary.bind(Ch);break}}this.socket.on(t,({payload:r})=>{let s=i;if(!n)return e(void 0);try{s=n(r)}catch(a){m.error("roomSocketHandler::on::binary_decode_error",{error:a})}return e(s)})}getUserPermissions(t){return p(this,null,function*(){const e={userIds:[t]};try{const n=yield this.socket.sendMessagePromise(vd.getUserPresets,sO.toBinary(e)),i=dO.fromBinary(n.payload).peerPresets[0],r=new TextDecoder().decode(i.preset),s=JSON.parse(r).permissions;return{chat:s.chat,polls:s.polls,plugins:s.plugins}}catch(n){throw m.error("Error in getting user preset",{error:n}),n}})}},nd=new WeakMap,Hg);let fl=UE;M2([w.trace("RoomSocketHandler.joinRoom")],fl.prototype,"joinRoom",1);var gs={},Ql={};Object.defineProperty(Ql,"__esModule",{value:!0});Ql.Logger=void 0;class O2{constructor(e){}debug(){}warn(){}error(){}}Ql.Logger=O2;Object.defineProperty(gs,"__esModule",{value:!0});var gl=gs.AwaitQueue=gs.AwaitQueueRemovedTaskError=gs.AwaitQueueStoppedError=void 0;const D2=Ql,$i=new D2.Logger;class pm extends Error{constructor(e){super(e!=null?e:"AwaitQueue stopped"),this.name="AwaitQueueStoppedError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,pm)}}gs.AwaitQueueStoppedError=pm;class Xl extends Error{constructor(e){super(e!=null?e:"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Xl)}}gs.AwaitQueueRemovedTaskError=Xl;class N2{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}push(e,n){return p(this,null,function*(){if(n=n!=null?n:e.name,$i.debug(`push() [name:${n}]`),typeof e!="function")throw new TypeError("given task is not a function");if(n)try{Object.defineProperty(e,"name",{value:n})}catch{}return new Promise((i,r)=>{const s={id:this.nextTaskId++,task:e,name:n,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:a=>{if(s.completed)return;s.completed=!0,this.pendingTasks.delete(s.id),$i.debug(`resolving task [name:${s.name}]`),i(a);const[c]=this.pendingTasks.values();c&&!c.executedAt&&this.execute(c)},reject:a=>{if(!s.completed&&(s.completed=!0,this.pendingTasks.delete(s.id),$i.debug(`rejecting task [name:${s.name}]: %s`,String(a)),r(a),!this.stopping)){const[c]=this.pendingTasks.values();c&&!c.executedAt&&this.execute(c)}}};this.pendingTasks.set(s.id,s),this.pendingTasks.size===1&&this.execute(s)})})}stop(){$i.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())$i.debug(`stop() | stopping task [name:${e.name}]`);this.stopping=!1}remove(e){$i.debug(`remove() [taskIdx:${e}]`);const n=Array.from(this.pendingTasks.values())[e];if(!n){$i.debug(`stop() | no task with given idx [taskIdx:${e}]`);return}n.reject(new Xl)}dump(){const e=Date.now();let n=0;return Array.from(this.pendingTasks.values()).map(i=>({idx:n++,task:i.task,name:i.name,enqueuedTime:i.executedAt?i.executedAt-i.enqueuedAt:e-i.enqueuedAt,executionTime:i.executedAt?e-i.executedAt:0}))}execute(e){return p(this,null,function*(){if($i.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const n=yield e.task();e.resolve(n)}catch(n){e.reject(n)}})}}gl=gs.AwaitQueue=N2;function L2(t,e){const n=new Error(e);return n.name=t,n}class mc extends D{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,mc):this.stack=new Error(e).stack}}class an extends D{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,an):this.stack=new Error(e).stack}}class vs extends D{constructor(e){super(e),this.name="TransportConnectionError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,an):this.stack=new Error(e).stack}}const qg=t=>new Promise(e=>setTimeout(e,t));function mm(t,e){return p(this,null,function*(){return new Promise((n,i)=>p(this,null,function*(){const{strategy:r,maxRetryCount:s,delayTime:a}=H({strategy:"linear",maxRetryCount:3,delayTime:10},e);let c=0,d,h=!1;const u=g=>{h=!0,i(g)};for(;c<s;){try{const g=yield t(c,u);return n(g)}catch(g){if(d=g,h)break;if(c<s)r==="linear"?yield qg(a*(c+1)):r==="exponential"&&(yield qg(a*(c+Math.max(0,c-1))));else break}c+=1}return i(d)}))})}function x2(t){return t.map(e=>({channels:e.channels,clockRate:e.clockRate,mimeType:e.mimeType,sdpFmtpLine:e.sdpFmtpLine}))}function V2(t){return t.map(e=>({uri:e.uri}))}function id(t){return{codecs:x2(t.codecs),headerExtensions:V2(t.headerExtensions?t.headerExtensions:[])}}function U2(t){const e=RTCRtpReceiver.getCapabilities("audio"),n=RTCRtpReceiver.getCapabilities("video"),i=RTCRtpSender.getCapabilities("audio"),r=RTCRtpSender.getCapabilities("video");t&&(n.codecs=n.codecs.filter(({mimeType:a})=>t===a),r.codecs=r.codecs.filter(({mimeType:a})=>t===a));const s={audio:id(e),video:id(n)};return{sender:{audio:id(i),video:id(r)},receiver:s}}var At;class B2{constructor(e,n){S(this,At,void 0),y(this,"events"),y(this,"sfuType"),T(this,At,e),this.sfuType=n,this.events=n===bt.CF?Hn:In}joinRoom(e,n,i,r=!1,s=null){return p(this,null,function*(){const a={roomUuid:e,displayName:n,prejoined:r,capabilities:i};return s&&(a.location=s),(yield o(this,At).sendMessagePromiseWithTimeout({event:this.events.joinRoom,protobuf:zP.toBinary(a),timeout:5e3})).payload})}connectTransport(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.createWebRTCTransport,wP.toBinary(e))).payload,{transportId:i,description:r,producerIds:s}=iE.fromBinary(n),a={sdp:r==null?void 0:r.sdp,type:r.type};return{transportId:i,answer:a,producerIds:s}})}produce(e){return p(this,null,function*(){var n,i;const r=(yield o(this,At).sendMessagePromise(this.events.produce,aA.toBinary(e))).payload,s=WA.fromBinary(r);return{answer:{sdp:(n=s==null?void 0:s.description)==null?void 0:n.sdp,type:(i=s==null?void 0:s.description)==null?void 0:i.type},producerId:s.producerId}})}consume(e){return p(this,null,function*(){if(this.sfuType===bt.HIVE)throw new Error("Hive does not support socket consumer operations");const n=(yield o(this,At).sendMessagePromise(this.events.consume,rA.toBinary(e))).payload,{consumerIdsMap:{map:i},description:r}=FA.fromBinary(n);return{consumerStateMap:i,sessionDescription:r}})}closeProducer(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.closeProducer,pA.toBinary(e))).payload,{description:i}=zA.fromBinary(n);return i})}closeConsumer(e){return p(this,null,function*(){if(this.sfuType===bt.HIVE)throw new Error("Hive does not support socket consumer operations");return(yield o(this,At).sendMessagePromise(this.events.closeConsumer,fA.toBinary(e))).payload})}hostControlForPeer(e,n){return p(this,null,function*(){const i={audio:n==="audio",screeShare:!1,video:n==="video",participantId:e},r=(yield o(this,At).sendMessagePromise(this.events.hostControlPeer,TA.toBinary(i))).payload;if(!r)return!1;const{status:s}=nM.fromBinary(r);return s==="success"})}hostControlForAll(e){return p(this,null,function*(){const n={audio:e==="audio",screenShare:!1,video:e==="video"},i=(yield o(this,At).sendMessagePromise(this.events.hostControlAllPeers,kA.toBinary(n))).payload;if(!i)return!1;const{status:r}=rM.fromBinary(i);return r==="success"})}kickAll(){return p(this,null,function*(){const e={propagateKickAcrossRooms:!1};o(this,At).sendMessagePromise(Y.kickAll,aE.toBinary(e))})}kickPeer(e){return p(this,null,function*(){o(this,At).sendMessagePromise(Y.kick,uE.toBinary(e))})}changeDisplayName(e){return p(this,null,function*(){const n=(yield o(this,At).sendMessagePromise(this.events.changeDisplayName,EA.toBinary(e))).payload;if(!n)return!1;const{status:i}=aM.fromBinary(n);return i==="success"})}notifySelfJoinComplete(){return p(this,null,function*(){const e={},n=(yield o(this,At).sendMessagePromise(this.events.selfJoinComplete,QP.toBinary(e))).payload;return Ih.fromBinary(n)})}audioActivity(e){return p(this,null,function*(){o(this,At).sendMessage(this.events.audioActivity,IP.toBinary(e))})}}At=new WeakMap;class fc extends Nt.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}safeEmit(e,...n){const i=this.listenerCount(e);try{return this.emit(e,...n)}catch(r){return m.error(`EnhancedEventEmitter:: safeEmit() | event listener ${e} threw an error`,{error:r}),Boolean(i)}}safeEmitAsPromise(e,...n){return p(this,null,function*(){const i={}.EVENT_PROMISE_TIMEOUT?parseInt({}.EVENT_PROMISE_TIMEOUT,10):1e4;return this.safeEmitAsPromiseWithTimeout(e,i,...n)})}safeEmitAsPromiseWithTimeout(e,n,...i){return p(this,null,function*(){return new Promise((r,s)=>{setTimeout(s,n,"event request timeout");try{this.emit(e.toString(),...i,r,s)}catch(a){m.error(`EnhancedEventEmitter:: safeEmitAsPromise() | event listener for event ${e.toString()} threw an error [event:%s]:%o`,{error:a}),s(a)}})})}}class fm extends fc{constructor(){super(...arguments),y(this,"_sendWebStream",new MediaStream),y(this,"_sendScreenShareStream",new MediaStream),y(this,"_direction"),y(this,"pc"),y(this,"_transportReady",!1),y(this,"_mapMidTransceiver",new Map),y(this,"enableHighBitrate",!1),y(this,"enableStereo",!1),y(this,"enableDtx",!0)}get midTransceiverMap(){return this._mapMidTransceiver}close(){if(m.debug(`${this.name}::close()`),this.pc)try{this.pc.close()}catch(e){m.error(`${this.name}::pc.close()`,{error:e})}}restartIce(){return p(this,null,function*(){m.debug(`${this.name}::restartIce()`);const e=yield this.pc.createOffer({iceRestart:!0});return m.debug(`${this.name}::restartIce() | calling pc.setLocalDescription() [offer:${JSON.stringify(e)}]`),{offerSdp:e,callback:n=>p(this,null,function*(){m.info(`${this.name}::restartIce() | calling pc.setRemoteDescription() [answer:${JSON.stringify(n)}]`),yield this.pc.setRemoteDescription(n)})}})}init({direction:e,iceServers:n,iceTransportPolicy:i,additionalSettings:r,proprietaryConstraints:s,onTrackHandler:a}){m.debug("HandlerInterface::init()"),this._direction=e,this.pc=new RTCPeerConnection(H({iceServers:n||[],iceTransportPolicy:i||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},r),s),a&&this.pc.addEventListener("track",c=>{a(c)}),this._addEventListeners()}connect(){return p(this,null,function*(){const e=this.pc.createDataChannel("dyte"),n=yield this.pc.createOffer();return yield this.pc.setLocalDescription(n),m.info(`connect offer: ${JSON.stringify(n)}`),{offerSdp:n,callback:i=>p(this,null,function*(){m.debug(`${this.name}::connect() | calling pc.setRemoteDescription() [answer:${JSON.stringify(i)}]`),yield this.pc.setRemoteDescription(i),e.close()})}})}getTransportStats(){return p(this,null,function*(){return this.pc.getStats()})}_assertSendDirection(){if(this._direction!=="send")throw new Error('method can just be called for handlers with "send" direction')}_assertRecvDirection(){if(this._direction!=="recv")throw new Error('method can just be called for handlers with "recv" direction')}getReceiverStats(e){return p(this,null,function*(){this._assertRecvDirection();const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");return n.receiver.getStats()})}stopSending(e){return p(this,null,function*(){this._assertSendDirection(),m.debug(`stopSending() [localId:${e}]`);const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");n.sender.replaceTrack(null),this.pc.removeTrack(n.sender),n.direction="inactive";const i=yield this.pc.createOffer();return m.debug(`stopSending() | calling pc.setLocalDescription() [offer:${JSON.stringify(i)}]`),yield this.pc.setLocalDescription(i),{offerSdp:i,callback:r=>p(this,null,function*(){m.debug(`stopSending() | calling pc.setRemoteDescription() [answer:${JSON.stringify(r)}]`),yield this.pc.setRemoteDescription(r),this.midTransceiverMap.delete(e)})}})}replaceTrack(e,n){return p(this,null,function*(){this._assertSendDirection(),n?m.debug(`replaceTrack() [localId:${e}, track.id:${n.id}]`):m.debug(`replaceTrack() [localId:${e}, no track]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");yield i.sender.replaceTrack(n)})}setMaxSpatialLayer(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setMaxSpatialLayer() [localId:${e}, spatialLayer:${n}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters();r.encodings.forEach((s,a)=>{a<=n?s.active=!0:s.active=!1}),yield i.sender.setParameters(r)})}setRtpEncodingParameters(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setRtpEncodingParameters() [localId:${e}, params:${JSON.stringify(n)}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters();r.encodings.forEach((s,a)=>{r.encodings[a]=H(H({},s),n)}),yield i.sender.setParameters(r)})}getSenderStats(e){this._assertSendDirection();const n=this.midTransceiverMap.get(e);if(!n)throw new Error("associated RTCRtpTransceiver not found");return n.sender.getStats()}_addEventListeners(){this.pc.addEventListener("icecandidate",e=>{e.candidate&&this.emit("@icecandidate",{candidate:e.candidate})}),this.pc.addEventListener("iceconnectionstatechange",()=>{switch(this.pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this._transportReady=!0;break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed");break;default:m.warn("unknown state");break}}),this.pc.addEventListener("negotiationneeded",()=>{this.emit("@negotiationneeded",{}),m.debug("negotiationneeded")}),this.pc.addEventListener("icegatheringstatechange",()=>{switch(this.pc.iceGatheringState){case"gathering":m.debug("icegatheringstatechange | gathering"),this.emit("@icegatheringstatechange","gathering");break;case"complete":m.debug("icegatheringstatechange | complete"),this.emit("@icegatheringstatechange","complete");break;default:m.warn("unknown state");break}}),this.pc.addEventListener("icecandidateerror",e=>{m.warn("icecandidateerror",{error:{code:e.errorCode,message:e.errorText}})}),this.pc.addEventListener("datachannel",e=>{m.info("data channel created: ",{rtcChannel:{label:e.channel.label}});const{channel:n}=e;n.onopen=()=>{m.info("data channel open: ",{rtcChannel:{label:e.channel.label}}),this.safeEmit("dc_open",e.channel)},n.onclose=()=>{m.warn("data channel closed: ",{rtcChannel:{label:e.channel.label}})},n.onerror=()=>{m.error("data channel error: ",{rtcChannel:{label:e.channel.label}})}}),this.addCustomEventListeners()}addCustomEventListeners(){}}class gm extends fm{static createFactory(){return()=>new gm}get name(){return"Chrome74"}init({direction:e,iceServers:n,iceTransportPolicy:i,additionalSettings:r,proprietaryConstraints:s,onTrackHandler:a}){this._direction=e,this.pc=new RTCPeerConnection(H({iceServers:n||[],iceTransportPolicy:i||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"},r),s),a&&this.pc.addEventListener("track",c=>{a(c)}),this._addEventListeners()}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection();const a=this.pc.addTransceiver(n,{direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream],sendEncodings:i});if(!navigator.isReactNative){m.debug("creating new transceiver");const h=RTCRtpSender.getCapabilities(typeof n=="string"?n:n.kind);m.info(`senders available params: ${JSON.stringify(h)}`);const u=[];r&&r.length&&r.forEach(g=>{var E;const b=h.codecs.find(k=>k.mimeType.includes(g.name));if(g.parameters){m.debug(`codecOption.parameters:${JSON.stringify(g.parameters)}`);const k=((E=b.sdpFmtpLine)==null?void 0:E.split(";"))||[];k.push(...g.parameters);const A=Array.from(new Set(k).values());b.sdpFmtpLine=A.join(";")}u.push(b)}),m.info(`selected codecs: ${JSON.stringify(u)}`),a.setCodecPreferences(u)}const c=yield this.pc.createOffer();if(yield this.pc.setLocalDescription(c),r&&r.findIndex(({name:h})=>h==="opus")>=0){const{enableDtx:h,enableStereo:u}=this,g=this.enableHighBitrate?u?128e3:64e3:u?64e3:32e3;c.sdp=c.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${h?"usedtx=1;":""}${u?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${g}`),c.sdp+=`a=rtcp-fb:111 nack\r
24
+ `}this.midTransceiverMap.set(a.mid,a);const d=h=>p(this,null,function*(){return m.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(h)}]`),yield this.pc.setRemoteDescription(h),a.mid});return m.debug(`send() | calling pc.setLocalDescription() [offer: ${JSON.stringify(c,void 0,2)}]`),{offerSdp:c,callback:d,sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>{this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(i.data)))}})}}class vl extends fm{constructor(e){super(),y(this,"supportsSendEncodings",!1),this.supportsSendEncodings=e.supportsSendEncodings}static createFactory(e){return()=>new vl(e)}get name(){return"Firefox60"}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection();const a=this.supportsSendEncodings&&i!==void 0?{sendEncodings:i}:{},c=this.pc.addTransceiver(n,H({direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream]},a));if(!this.supportsSendEncodings&&i){i.reverse();const u=c.sender.getParameters();u.encodings=i,yield c.sender.setParameters(u)}const d=(u,g)=>{var E;const b=Go(u),k=b.media[b.media.length-1],A=k.rtp.filter(X=>g.some(O=>O.name===X.codec)),M=k.fmtp.filter(X=>A.some(O=>O.payload===X.payload)),B=(E=k.rtcpFb)==null?void 0:E.filter(X=>A.some(O=>O.payload===X.payload)),K=A.map(X=>X.payload);return b.media[b.media.length-1].rtp=A,b.media[b.media.length-1].fmtp=M,b.media[b.media.length-1].rtcpFb=B,b.media[b.media.length-1].payloads=K.join(" "),ah(b)},h=yield this.pc.createOffer();if(h.sdp=d(h.sdp,r),m.debug(`send() | calling pc.setLocalDescription() [offer:${JSON.stringify(h)}]`),yield this.pc.setLocalDescription(h),n==="audio"||n.kind==="audio"){const{enableDtx:u,enableStereo:g}=this,E=this.enableHighBitrate?g?128e3:64e3:g?64e3:32e3;h.sdp=h.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${u?"usedtx=1;":""}${g?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${E}`)}return this.midTransceiverMap.set(c.mid,c),{offerSdp:h,callback:u=>p(this,null,function*(){return m.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(u)}]`),yield this.pc.setRemoteDescription(u),c.mid}),sender:c.sender,mid:c.mid}})}setMaxSpatialLayer(e,n){return p(this,null,function*(){this._assertSendDirection(),m.debug(`setMaxSpatialLayer() [localId:${e}, spatialLayer:${n}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters(),s=r.encodings.length-1-n;r.encodings.forEach((a,c)=>{c>=s?a.active=!0:a.active=!1}),yield i.sender.setParameters(r)})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>p(this,null,function*(){const r=yield i.data.arrayBuffer();this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(r)))})})}}class vm extends fm{static createFactory(){return()=>new vm}get name(){return"Safari12"}send(e){return p(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection(),m.debug("Safari12::creating new transceiver");const a=this.pc.addTransceiver(n,{direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream],sendEncodings:i}),c=RTCRtpSender.getCapabilities(typeof n=="string"?n:n.kind);m.info(`Safari12::senders available params: ${JSON.stringify(c)}`);const d=[];r&&r.length>0&&r.forEach(u=>{var g;const E=c.codecs.find(b=>b.mimeType.includes(u.name));if(u.parameters){m.info(`Safari12::codecOption.parameters:, ${JSON.stringify(u.parameters)}`);const b=((g=E.sdpFmtpLine)==null?void 0:g.split(";"))||[];b.push(...u.parameters);const k=[...new Set(b).values()];E.sdpFmtpLine=k.join(";")}d.push(E)}),m.info(`Safari12::selected codecs: ${JSON.stringify(d)}`),a.setCodecPreferences(d);const h=yield this.pc.createOffer();if(yield this.pc.setLocalDescription(h),n==="audio"||n.kind==="audio"){const{enableStereo:u,enableDtx:g}=this,E=this.enableHighBitrate?u?128e3:64e3:u?64e3:32e3;h.sdp=h.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${g?"usedtx=1;":""}${u?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${E}`)}return this.midTransceiverMap.set(a.mid,a),{offerSdp:h,callback:u=>p(this,null,function*(){return m.debug(`Safari12::send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(u)}]`),yield this.pc.setRemoteDescription(u),a.mid}),sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.ondatachannel=e=>{const{channel:n}=e;n.onmessage=i=>p(this,null,function*(){const r=String.fromCharCode(...new Uint8Array(i.data));this.safeEmit("datachannel",e.channel,r)})}}}function F2(t,e){return typeof t=="undefined"?e:typeof window!="undefined"&&Object.getOwnPropertyDescriptor(window,"structuredClone")?structuredClone(t):JSON.parse(JSON.stringify(t))}var Cd,Xs,yi,Ti,gr,Rd,zu,Jh,BE,$h,FE;class j2 extends fc{constructor(e){var n;super(),S(this,Ti),S(this,Rd),S(this,Jh),S(this,$h),y(this,"rtpReceiver"),y(this,"id"),y(this,"localId"),y(this,"producerId"),y(this,"producingTransportId"),y(this,"mimeType"),y(this,"track"),y(this,"peerId"),y(this,"appData"),y(this,"transceiver"),S(this,Cd,void 0),S(this,Xs,void 0),S(this,yi,void 0),this.id=e.id,this.localId=e.localId,T(this,Cd,e.handler),this.appData=e.appData,this.peerId=e.producingPeerId,this.producingTransportId=e.producingTransportId,T(this,yi,!1),this.producerId=e.producerId,this.track=e.track,T(this,Xs,(n=e.paused)!=null?n:!1),this.mimeType=e.mimeType,this.transceiver=e.transceiver,this.rtpReceiver=e.rtpReceiver,Q(this,Jh,BE).call(this)}get closed(){return o(this,yi)}get kind(){return this.track.kind}get paused(){return o(this,Xs)}close(e,n){o(this,yi)||(m.debug(`Consumer::close() ${e?`with reason ${e}`:""}`,o(this,Ti,gr)),T(this,yi,!0),n&&(Q(this,$h,FE).call(this),this.transceiver.stop()),this.safeEmit("close",e))}getStats(){return p(this,null,function*(){if(o(this,yi))throw new an("closed");return o(this,Cd).getReceiverStats(this.localId)})}pause(){if(m.debug("consumer::pause()",o(this,Ti,gr)),o(this,yi)){m.error("consumer::pause() | Consumer closed",o(this,Ti,gr));return}T(this,Xs,!0),this.track.enabled=!1,this.safeEmit("pause")}resume(){if(m.debug("consumer::resume()",o(this,Ti,gr)),o(this,yi)){m.error("Consumer::resume() | Consumer closed",o(this,Ti,gr));return}T(this,Xs,!1),this.track.enabled=!0,this.safeEmit("resume")}}Cd=new WeakMap,Xs=new WeakMap,yi=new WeakMap,Ti=new WeakSet,gr=function(){return{consumer:{id:this.id,appData:this.appData,peerId:this.peerId,kind:this.kind}}},Rd=new WeakSet,zu=function(){m.debug('Consumer::track "ended" event',o(this,Ti,gr)),this.safeEmit("trackended")},Jh=new WeakSet,BE=function(){this.track.addEventListener("ended",Q(this,Rd,zu).bind(this))},$h=new WeakSet,FE=function(){try{this.track.removeEventListener("ended",Q(this,Rd,zu)),this.track.stop()}catch(t){m.error("Consumer::destroyTrack()",ee(H({},o(this,Ti,gr)),{error:t}))}};var ti,Ro,Po,Zs,Fn,Mt,Kr,Ao,kn,jn;class W2 extends fc{constructor(e){var n,i;super(),S(this,kn),y(this,"id"),y(this,"localId"),S(this,ti,void 0),y(this,"kind"),y(this,"appData"),y(this,"rtpSender"),S(this,Ro,void 0),S(this,Po,void 0),S(this,Zs,void 0),S(this,Fn,!1),S(this,Mt,void 0),S(this,Kr,void 0),S(this,Ao,void 0),this.id=e.id,this.localId=e.localId,T(this,Mt,e.track),this.kind=(n=e.track)==null?void 0:n.kind,T(this,Kr,e.disableTrackOnPause?!((i=e.track)!=null&&i.enabled):!1),T(this,Ao,void 0),T(this,Ro,e.stopTracks),T(this,Po,e.disableTrackOnPause),T(this,Zs,e.zeroRtpOnPause),this.appData=e.appData||{},this._onTrackEnded=this._onTrackEnded.bind(this),T(this,ti,e.handler),this.rtpSender=e.rtpSender,this._handleTrack()}get closed(){return o(this,Fn)}get track(){return o(this,Mt)}get paused(){return o(this,Kr)}get maxSpatialLayer(){return o(this,Ao)}close(e){return p(this,null,function*(){if(o(this,Fn))return;if(m.debug(`Producer::close() ${e?`with reason ${e}`:""}`,o(this,kn,jn)),T(this,Fn,!0),this._destroyTrack(),e===yl){this.safeEmit("close",{reason:e});return}const{offerSdp:n,callback:i}=yield o(this,ti).stopSending(this.localId),{answer:r}=yield this.safeEmitAsPromise("close",{offer:n,reason:e});i(r)})}getStats(){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");return o(this,ti).getSenderStats(this.localId)})}pause(){m.debug("Producer::pause()",o(this,kn,jn)),o(this,Fn)&&m.error("Producer::pause() | Producer closed",o(this,kn,jn)),T(this,Kr,!0),o(this,Mt)&&o(this,Po)&&(o(this,Mt).enabled=!1),o(this,Zs)&&o(this,ti).replaceTrack(this.localId,null),this.emit("pause")}resume(){if(m.debug("Producer::resume()",o(this,kn,jn)),o(this,Fn)){m.error("Producer::resume() | Producer closed",o(this,kn,jn));return}T(this,Kr,!1),o(this,Mt)&&o(this,Po)&&(o(this,Mt).enabled=!0),o(this,Zs)&&o(this,ti).replaceTrack(this.localId,o(this,Mt)),this.emit("resume")}replaceTrack(e){return p(this,arguments,function*({track:n}){if(m.debug(`Producer::replaceTrack() trackId: ${n==null?void 0:n.id}`,o(this,kn,jn)),o(this,Fn)){if(n&&o(this,Ro))try{n.stop()}catch(i){m.error("Producer::replaceTrack",ee(H({},o(this,kn,jn)),{error:i}))}throw new an("closed")}else if(n&&n.readyState==="ended")throw new an("track ended");if(n===o(this,Mt)){m.debug(`replaceTrack() | same track, ignored trackId: ${n.id}`,o(this,kn,jn));return}(!o(this,Zs)||!o(this,Kr))&&(yield o(this,ti).replaceTrack(this.localId,n)),this._destroyTrack(),T(this,Mt,n),this._handleTrack()})}setMaxSpatialLayer(e){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");if(this.kind!=="video")throw new mc("not a video Producer");if(typeof e!="number")throw new TypeError("invalid spatialLayer");yield o(this,ti).setMaxSpatialLayer(this.localId,e),T(this,Ao,e)})}setRtpEncodingParameters(e){return p(this,null,function*(){if(o(this,Fn))throw new an("closed");if(typeof e!="object")throw new TypeError("invalid params");yield o(this,ti).setRtpEncodingParameters(this.localId,e)})}_onTrackEnded(){m.debug(`Producer::track "ended" event trackId: ${this.track.id}`,o(this,kn,jn)),this.safeEmit("trackended",this.track.id)}_handleTrack(){o(this,Mt)&&o(this,Mt).addEventListener("ended",this._onTrackEnded)}_destroyTrack(){var e;if(o(this,Mt))try{o(this,Mt).removeEventListener("ended",this._onTrackEnded),o(this,Ro)&&o(this,Mt).stop()}catch(n){m.error(`Producer::_destroyTrack trackId: ${(e=this.track)==null?void 0:e.id}`,ee(H({},o(this,kn,jn)),{error:n}))}}}ti=new WeakMap,Ro=new WeakMap,Po=new WeakMap,Zs=new WeakMap,Fn=new WeakMap,Mt=new WeakMap,Kr=new WeakMap,Ao=new WeakMap,kn=new WeakSet,jn=function(){return{producer:{id:this.id,appData:this.appData,kind:this.kind}}};function jE(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Kh(t){return Math.random().toString(36).substring(2,2+t)}const rd=1;function Gg(t){const e=t;return delete e.payload._bolt,e}function H2(t){return t.payload&&jE(t.payload)}function WE(t){var e,n;return H2(t)&&(n=(e=t.payload._bolt)==null?void 0:e.id)!=null?n:""}var zr;const Mo=class extends Nt.EventEmitter{constructor(t,e,n){super(),y(this,"channel"),y(this,"queue"),y(this,"serverProtocolVersion"),S(this,zr,new Map),y(this,"respond",(i,r,s=!1)=>{let a;s?a=Mo.createErrorResponse(i,r):a=Mo.createResponse(i,r),this.channel.send(JSON.stringify(a))}),y(this,"notify",i=>{const r=Mo.createNotification(i);this.channel.send(JSON.stringify(r))}),y(this,"request",i=>p(this,null,function*(){const r=Mo.createRequest(i),s=new Promise((a,c)=>{const{id:d}=r.payload._bolt,h={id:d,method:r.type,resolve:u=>{this.queue.delete(d)&&(clearTimeout(h.timer),a(u))},timer:setTimeout(()=>{this.queue.delete(d)&&c(new Error(`request timeout for message id: ${d}`))},2e4),cancel:u=>{this.queue.delete(d)&&(clearTimeout(h.timer),c(u))}};this.queue.set(d,h)});return this.channel.send(JSON.stringify(r)),s})),y(this,"send",i=>{const r=JSON.stringify(i),s=16384;if(r.length>s){const a=s-200,c=Math.ceil(r.length/a),d=[];for(let u=0;u<c;u+=1){const g=u*a,E=(u+1)*a;d.push(r.slice(g,E))}const h=Ca();for(let u=0;u<c;u+=1){const g=d[u],E=JSON.stringify({id:h,count:c,chunkIndex:u,chunk:g});m.debug(`Sending message chunk over dc: ${E}`),this.channel.send(E)}}else m.debug(`Sending message over dc: ${r}`),this.channel.send(r)}),y(this,"processMessage",i=>{var r;o(this,zr).has(i.id)||o(this,zr).set(i.id,[]);const s=o(this,zr).get(i.id);if(s[i.chunkIndex]=i,(s==null?void 0:s.length)===i.count&&!s.some(a=>a===void 0)){const a=o(this,zr).get(i.id),c=a==null?void 0:a.reduce((h,u)=>h+u.chunk,"");o(this,zr).delete(i.id);const d=JSON.parse(c);if(!d.payload||!jE(d.payload))throw new Error("corrupted incoming message over dc",{cause:{code:"CORRUPT_DC_MESSAGE",values:d}});if(this.processBoltHandshake(d))return;if(this.serverProtocolVersion=(r=d.payload._bolt)==null?void 0:r.version,!this.processResponseMsg(d))return d}}),y(this,"processResponseMsg",i=>{const{id:r}=i.payload._bolt,s=this.queue.get(r);return s?(m.debug(`resolving pending request with id: ${r}, complete response: ${JSON.stringify(i)}`),i.type==="error"?s.cancel(Gg(i)):s.resolve(Gg(i)),!0):!1}),y(this,"processBoltHandshake",i=>{var r,s;return i.type==="_bolt"||i.type==="handshake"?(this.respond((s=(r=i.payload._bolt)==null?void 0:r.id)!=null?s:Kh(8),{type:"_bolt",payload:{message:"pong"}}),!0):!1}),this.label=e,this.transportId=n,this.channel=t,this.queue=new Map}};let Oo=Mo;zr=new WeakMap,y(Oo,"createRequest",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:ee(H({},t.payload),{_bolt:{id:Kh(8),type:"REQUEST",version:rd}})}}),y(Oo,"createResponse",(t,e)=>{var n;if((n=e.payload)!=null&&n._bolt)throw new Error("rpc fields are internal values");return{type:e.type,payload:ee(H({},e.payload),{_bolt:{id:t,type:"RESPONSE",version:rd}})}}),y(Oo,"createNotification",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:ee(H({},t.payload),{bolt:{id:Kh(8),type:"NOTIFY",version:rd}})}}),y(Oo,"createErrorResponse",(t,e)=>({type:"error",payload:{error:e.message,_bolt:{id:t,type:"RESPONSE",version:rd}}}));function q2(t){if(Promise.allSettled)return Promise.allSettled(t);const e=t.map(n=>n.then(i=>({status:"fulfilled",value:i})).catch(i=>({status:"rejected",reason:i})));return Promise.all(e)}const yl="transport closed";var Do;const zh=class extends fc{constructor(t,{id:e,direction:n,handlerFactory:i,iceServers:r,iceTransportPolicy:s,proprietaryConstraints:a,additionalSettings:c,appData:d,config:h}){var u,g,E;super(),y(this,"awaitQueue"),y(this,"observer"),S(this,Do,void 0),y(this,"id"),y(this,"serverId"),y(this,"direction"),y(this,"maxSctpMessageSize"),y(this,"handler"),y(this,"connectionState","new"),y(this,"producers"),y(this,"consumers"),y(this,"datachannels"),y(this,"connected",!1),y(this,"eventsDCReadyPromise"),y(this,"eventsDCReadyPromiseResolver"),y(this,"eventsDCFailureTimer"),y(this,"transportConnectionPromise"),y(this,"consumerTrackEvents"),y(this,"unknownTracksMap"),y(this,"appData"),m.debug(`constructor() [id: ${e}, direction: ${n}]`),T(this,Do,t),this.id=e,this.direction=n;const b=F2(c,{});delete b.iceServers,delete b.iceTransportPolicy,delete b.bundlePolicy,delete b.rtcpMuxPolicy,delete b.sdpSemantics,this.producers=new Map,this.consumers=new Map,this.datachannels=new Map,this.consumerTrackEvents=new Map,this.unknownTracksMap=new Map,this.awaitQueue=new gl,this.observer=new fc,this.handler=i(),this.handler.enableHighBitrate=(u=h==null?void 0:h.enableHighBitrate)!=null?u:!1,this.handler.enableStereo=(g=h==null?void 0:h.enableStereo)!=null?g:!1,this.handler.enableDtx=(E=h==null?void 0:h.enableDtx)!=null?E:!0,this.handler.init({onTrackHandler:this._ontrack.bind(this),direction:n,iceServers:r,iceTransportPolicy:s,additionalSettings:c,proprietaryConstraints:a}),this.appData=d||{},this.transportConnectionPromise=new Promise(k=>{this.observer.once("connected",()=>{k(!0)}),this.observer.once("disconnect",()=>{k(!1)}),this.observer.once("close",()=>{k(!1)})}),this.eventsDCReadyPromise=new Promise(k=>{this.eventsDCReadyPromiseResolver=k}),this.handler.on("@connectionstatechange",k=>{k!==this.connectionState&&(m.debug(`connection state changed to ${k}`),this.connectionState=k,k==="connected"&&(this.connected=!0,this.observer.emit("connected")),k==="disconnected"&&(this.connected=!1,this.observer.emit("disconnect")),(k==="failed"||k==="closed")&&(this.connected=!1,this.observer.emit("close")),this.closed||this.safeEmit("connectionstatechange",k))}),this.handler.on("@icecandidate",({candidate:k})=>{this.closed||this.safeEmit("icecandidate",k)}),this.handler.on("dc_open",k=>{let A=this.datachannels.get(k.label);A||(A||(A=new Oo(k,k.label,this.serverId),this.datachannels.set(k.label,A)),this.eventsDCFailureTimer=setTimeout(()=>{k.label==="events"&&(this.eventsDCReadyPromiseResolver(!1),this.safeEmit("dc_error",k.label))},5e3))}),this.handler.on("datachannel",(k,A)=>{k.label==="events"&&(this.eventsDCReadyPromiseResolver(!0),this.eventsDCFailureTimer&&clearTimeout(this.eventsDCFailureTimer));const M=this.datachannels.get(k.label);if(!M){m.error("unregistered datachannel for message",{rtcChannel:{label:k.label,message:A}});return}try{const B=JSON.parse(A);m.debug("datachannel message chunk recieved",{dataChannelMessageChunk:{id:B.id,count:B.count,chunkIndex:B.chunkIndex,chunk:B.chunk,transprtId:this.serverId}});const K=M.processMessage(B);if(!K)return;m.debug(`datachannel message with id:${B.id} on transport:${this.serverId}complete - ${JSON.stringify(K)}`),this.emit(`datachannel:${k.label}`,M.label,K)}catch(B){m.error("error parsing message",{error:B})}})}get closed(){return this.connectionState==="closed"}setServerId(t){this.serverId=t}getDatachannel(t){return this.datachannels.get(t)}get isEventsDCReady(){return this.eventsDCReadyPromise}close(){this.closed||(m.debug("Transport close called"),this.connectionState="closed",this.connected=!1,this.handler.close(),Array.from(this.producers.values()).forEach(t=>{t.close(yl).catch(()=>{})}),this.producers.clear(),Array.from(this.consumers.values()).forEach(t=>{t.close(yl)}),this.consumers.clear(),this.consumerTrackEvents.clear(),this.emit("close"),this.observer.emit("close"))}getStats(){return p(this,null,function*(){if(this.closed)throw new an("closed");return this.handler.getTransportStats()})}connect(t){return p(this,null,function*(){try{if(yield this.awaitQueue.push(()=>p(this,null,function*(){const{offerSdp:e,callback:n}=yield this.handler.connect(),{transportId:i,answer:r}=yield t(e);this.setServerId(i),yield n(r)})),!(yield this.transportConnectionPromise))throw new Error("ice connection failed");if(o(this,Do)===bt.HIVE&&!(yield this.isEventsDCReady))throw new Error("events datachannel not open")}catch(e){throw m.error("transport failed to connect:",{error:e}),e}})}restartIce(){return p(this,null,function*(){if(m.debug("restartIce()"),this.closed)throw new an("closed");return this.handler.restartIce()})}canProduce(t){return p(this,null,function*(){const{track:e,appData:n}=t;if(e){if(this.direction!=="send")throw new mc("not a sending Transport");if(e.readyState==="ended")throw new an("track ended");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(n&&typeof n!="object")throw new TypeError("if given, appData must be an object")}else throw new TypeError("missing track");if(!(yield this.transportConnectionPromise))throw new vs("transport not connected");return!0})}produce(t,e){return p(this,null,function*(){if(!(yield this.canProduce(t)))throw new Error("Cannot produce");const{track:n,encodings:i,codecOptions:r,stopTracks:s=!0,disableTrackOnPause:a=!0,zeroRtpOnPause:c=!1,appData:d={}}=t;m.debug(`produce() [track:${n.id}]`);const{producerId:h,localId:u,rtpSender:g}=yield this.awaitQueue.push(()=>p(this,null,function*(){const{offerSdp:E,callback:b,sender:k,mid:A}=yield this.handler.send({track:n,encodings:i,codecOptions:r,screenShare:d==null?void 0:d.screenShare}),{answer:M,producerId:B}=yield e({offer:E,kind:n.kind,paused:a?!n.enabled:!1,appData:ee(H({},d||{}),{mid:A}),codecOptions:r,producingTransportId:this.serverId}),K=yield b(M);return{producerId:B,localId:K,rtpSender:k}}),"producer");return this.createProducerObject({id:h,localId:u,track:n,stopTracks:s,disableTrackOnPause:a,zeroRtpOnPause:c,appData:d,handler:this.handler,rtpSender:g})})}createProducerObject(t){return p(this,null,function*(){const e=new W2(t);return this.producers.set(e.id,e),e.once("close",()=>{this.producers.delete(e.id)}),e})}closeProducer(t){return p(this,null,function*(){yield this.awaitQueue.push(t.close.bind(t),"producer")})}canConsume(){return p(this,null,function*(){if(this.closed)throw new an("closed");if(this.direction!=="recv")throw new mc("not a receiving transport");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(!(yield this.transportConnectionPromise))throw new vs("transport not connected");return!0})}consume(t,e,n){return p(this,null,function*(){return this.awaitQueue.push(()=>p(this,null,function*(){const i={},{consumerStates:r,sessionDescription:s,failedProducers:a}=yield e(t);r.forEach((h,u)=>{i[u]=this.createConsumerObjectAndWaitForTrack(ee(H({},h),{producerId:u}))});const c=a;s&&(m.info("Session description found, sending negotiation request"),yield n(s));const d=[];return yield Promise.all(Object.entries(i).map(([h,u])=>u.then(g=>d.push(g)).catch(()=>{m.error(`Failed to create consumer object, producer: ${h}`,{error:{message:"This should not happen"},transport:{serverId:this.serverId}})}))),{consumers:d,failedProducers:c}}),"consumer")})}static parseCodecAndFmtpMappings(t,e){const n=Go(t.sdp),i={};return n.media.forEach(r=>{e.includes(r.mid.toString())&&(i[r.mid.toString()]={rtp:r.rtp,fmtp:r.fmtp,payloads:r.payloads,rtcpFb:r.rtcpFb})}),i}static setCodecAndFmtpMappings(t,e,n){const i=Go(t.sdp);return i.media=i.media.map(r=>{if(e.includes(r.mid.toString())){const s=H({},r);return s.rtp=n[r.mid.toString()].rtp,s.fmtp=n[r.mid.toString()].fmtp,s.payloads=n[r.mid.toString()].payloads,s.rtcpFb=n[r.mid.toString()].rtcpFb,s}return r}),ee(H({},t),{sdp:ah(i)})}closeConsumers(t,e){return p(this,null,function*(){try{const n=t.map(a=>a.transceiver.mid),i=zh.parseCodecAndFmtpMappings(this.handler.pc.remoteDescription,n);m.info("Stopping transceivers",{consumerIds:t.map(({id:a})=>a)}),t.forEach(a=>a.close(void 0,!0));let r=yield this.handler.pc.createOffer();m.info("Created offer for closing consumers",{sdp:r.sdp}),r=zh.setCodecAndFmtpMappings(r,n,i),m.info("Updated codec and fmtp mappings in close consumer offer",{sdp:r.sdp}),yield this.setLocalDescription(r),m.info("Successfully set local description in close consumers");const s=yield e(t,r);m.info("Received answer in close consumers",{sdp:s.sdp}),yield this.setRemoteDescription(s),m.info("Remote description was set successfully in close consumers",{sdp:s.sdp})}catch(n){m.error("Failed to close consumers",{error:n})}})}setRemoteOffer(t){return p(this,null,function*(){try{m.info("Received offer from SFU",{sdp:t.sdp}),yield this.setRemoteDescription(t);const e=yield this.handler.pc.createAnswer();m.info("Created answer corresponding to received offer",{sdp:e.sdp});const n=Go(e.sdp);return n.media=n.media.map(i=>{if(i.type==="audio"){const r=H({},i),s=r.fmtp.find(a=>a.payload===111);return s&&(s.config+=";stereo=1;sprop-stereo=1"),r.rtcpFb||(r.rtcpFb=[]),r.rtcpFb.some(a=>a.type==="nack")||r.rtcpFb.push({payload:parseInt(r.payloads,10),type:"nack"}),r}return i}),e.sdp=ah(n),m.info("Setting munged SDP",{sdp:e.sdp}),yield this.setLocalDescription(e),m.info("Successfully set local description",{sdp:e.sdp}),e}catch(e){throw m.error("Set remote offer failed",{error:e}),e}})}_ontrack(t){const{track:e,transceiver:n,streams:i}=t;m.info(`track event received [trackId: ${e.id}]`);let r;o(this,Do)===bt.HIVE?r=`${i[0].id}:${e.kind}`:r=`${n.mid}:${e.kind}`,e.addEventListener("ended",()=>{m.info(`rtc consumer track ended [trackId: ${e.id}]`),this.unknownTracksMap.delete(r)});const s=this.consumerTrackEvents.get(r);s?(s(e,n),this.consumerTrackEvents.delete(r)):(m.warn(`track event handler not found ${r}`),this.unknownTracksMap.set(r,t))}sendErrorOverDC(t,e,n){const i=this.getDatachannel(t);if(!i)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:t}}});i.respond(e,n,!0)}sendResponseOverDC(t,e,n){const i=this.getDatachannel(t);if(!i)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:t}}});i.respond(e,n)}createConsumerObjectAndWaitForTrack(t){return p(this,null,function*(){const{consumerId:e,producerId:n,producingPeerId:i,producingTransportId:r,streamId:s,paused:a,screenShare:c,appData:d,kind:h,mimeType:u}=t,g=`${s}:${h}`,E=ee(H({},t),{name:"consumer creation task error",message:"consumer creation failed"});return new Promise((b,k)=>p(this,null,function*(){const A=setTimeout(()=>{this.consumerTrackEvents.delete(g),E.isTimedout=!0,k(E)},5e3),M=(K,X)=>{try{if(K.readyState==="ended")clearTimeout(A),k(E);else{const O=K;O.enabled=!0,this.handler.midTransceiverMap.set(X.mid,X);const J=new j2({id:e,localId:X.mid,transceiver:X,track:O,paused:a,producerId:n,producingPeerId:i,producingTransportId:r,handler:this.handler,appData:ee(H({},d),{screenShare:c,peerId:i}),rtpReceiver:X.receiver,mimeType:u});this.consumers.set(e,J),J.once("close",()=>{this.consumers.delete(J.id),this.handler.midTransceiverMap.delete(X.mid)}),m.info("consumer created for ",{consumer:{id:e,kind:h,appData:{screenShare:c},peerId:i,producerId:n}}),this.observer.emit("newconsumer",J),clearTimeout(A),b(J)}}catch(O){m.warn("error while creating consumer:",O),clearTimeout(A),k(E)}},B=this.unknownTracksMap.get(g);B?(this.unknownTracksMap.delete(g),M(B.track,B.transceiver)):this.consumerTrackEvents.set(g,M)}))})}setRemoteDescription(t){return p(this,null,function*(){yield this.handler.pc.setRemoteDescription(t)})}setLocalDescription(t){return p(this,null,function*(){m.debug(`${this.direction}() {transportId: ${this.serverId}} | calling pc.setLocalDescription() [offer:${JSON.stringify(t)}]`),yield this.handler.pc.setLocalDescription(t)})}retryFailedConsumerCreationTasks(t){return p(this,null,function*(){return q2(t.map(e=>p(this,null,function*(){return mm(n=>p(this,null,function*(){return n>0&&m.warn(`retrying failed consumer creation task: ${JSON.stringify(e)}`),this.createConsumerObjectAndWaitForTrack(H({},e))}))})))})}sendDataChannelMessage(t,e){return p(this,null,function*(){const n=this.getDatachannel(t);if(!n)throw L2("DC_NOT_READY",`${t} datachannel not ready`);const i=(yield n.request(e)).payload;return m.info(`sendDataChannelMessage::response ${JSON.stringify(i)}`),i})}};let G2=zh;Do=new WeakMap;function J2(){if(typeof navigator=="object"&&navigator.product==="ReactNative"){if(typeof RTCPeerConnection=="undefined"){m.warn("Device::this._detectDevice() | unsupported ReactNative without RTCPeerConnection");return}return m.debug("Device::this._detectDevice() | ReactNative handler chosen"),"Chrome74"}if(typeof navigator=="object"&&typeof navigator.userAgent=="string"){const t=navigator.userAgent,e=ov.getParser(t),n=e.getEngine();if(e.satisfies({chrome:">=74",chromium:">=74","microsoft edge":">=88"}))return"Chrome74";if(e.satisfies({chrome:">=55",chromium:">=55"}))return;if(e.satisfies({firefox:">=110"}))return"Firefox110";if(e.satisfies({firefox:">=60"}))return"Firefox60";if(e.satisfies({ios:{OS:">=14.3",firefox:">=30.0"}})||e.satisfies({safari:">=12.0"})&&typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(e.satisfies({safari:">=11"})||e.satisfies({"microsoft edge":">=11"})&&e.satisfies({"microsoft edge":"<=18"}))return;if(n.name&&n.name.toLowerCase()==="blink"){const i=t.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);return i?Number(i[1])>=74?"Chrome74":void 0:"Chrome74"}if(n.name.toLowerCase()==="webkit"&&e.getOS().name.toLowerCase()==="ios")return typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection")?"Safari12":void 0;m.warn("Device::this._detectDevice() | browser not supported");return}m.warn("Device::this._detectDevice() | unknown device")}var Pd;class $2{constructor(e,{handlerName:n,handlerFactory:i}={}){if(y(this,"handlerFactory"),S(this,Pd,void 0),m.debug("constructor()"),T(this,Pd,e),n&&i)throw new TypeError("just one of handlerName or handlerInterface can be given");if(i)this.handlerFactory=i;else{if(n)m.debug(`Device::constructor() | handler given: ${n}`);else if(n=J2(),n)m.debug(`Device::constructor() | detected handler: ${n}`);else throw new Error("device not supported");switch(n){case"Chrome74":this.handlerFactory=gm.createFactory();break;case"Safari12":this.handlerFactory=vm.createFactory();break;case"Firefox60":this.handlerFactory=vl.createFactory({supportsSendEncodings:!1});break;case"Firefox110":this.handlerFactory=vl.createFactory({supportsSendEncodings:!0});break;default:throw new TypeError(`unknown handlerName "${n}"`)}}}createTransport(e){const n=Ca();return new G2(o(this,Pd),ee(H({id:n},e),{handlerFactory:this.handlerFactory}))}}Pd=new WeakMap;const K2=2e3;var mr,Yo,$t,Kt,va,Qo,No,Lo,ea,cs,xo,Xo,Ad,Md,Yh,Qh,HE,Xh,qE,Zh,GE,ep,JE,tp,Jg,Od,Yu,Dd,Qu;class z2 extends Nt.EventEmitter{constructor(e,n,i){switch(super(),S(this,Xo),S(this,Md),S(this,Qh),S(this,Xh),S(this,Zh),S(this,ep),S(this,tp),S(this,Od),S(this,Dd),S(this,mr,void 0),S(this,Yo,void 0),S(this,$t,void 0),S(this,Kt,void 0),S(this,va,void 0),S(this,Qo,void 0),S(this,No,void 0),S(this,Lo,{transportFailureCount:{send:0,recv:0},lastConnectionTime:0}),S(this,ea,void 0),S(this,cs,"all"),S(this,xo,void 0),T(this,mr,e),T(this,va,n),T(this,xo,i),T(this,Yo,new $2(i)),T(this,Qo,new B2(n,i)),i){case bt.CF:{T(this,No,Hn);break}case bt.HIVE:default:{T(this,No,In);break}}o(this,Xo,Ad).mediaState={send:{state:wr.NEW,reconnected:!1},recv:{state:wr.NEW,reconnected:!1}},se.hasFeature(ue.FORCE_RELAY)&&T(this,cs,"relay"),Q(this,Md,Yh).call(this)}get socket(){return o(this,va)}get socketHandler(){return o(this,Qo)}get sendTransport(){return o(this,$t)}get recvTransport(){return o(this,Kt)}get events(){return o(this,No)}get nodeType(){return o(this,xo)}createTransports(e){return p(this,null,function*(){var n,i,r,s,a,c,d,h;se.hasFeature(ue.FORCE_RELAY)&&(m.info("ICE Transport Policy set to relay"),T(this,cs,"relay"));const u=yield Pt().getICEServers().catch(E=>(m.warn(`failed to get iceservers from server: ${E.message}`),[])),g=[];if(e.send){const E=se.hasFeature(ue.DISABLE_OPUS_DTX_CF),b=Q(this,Xh,qE).call(this,{iceServers:u,additionalSettings:{encodedInsertableStreams:(n=o(this,mr).getValue("modules").e2ee)==null?void 0:n.enabled},config:{enableHighBitrate:(s=(r=(i=o(this,mr).getValue("defaults").mediaConfiguration)==null?void 0:i.audio)==null?void 0:r.enableHighBitrate)!=null?s:!1,enableStereo:(d=(c=(a=o(this,mr).getValue("defaults").mediaConfiguration)==null?void 0:a.audio)==null?void 0:c.enableStereo)!=null?d:!1,enableDtx:o(this,xo)===bt.HIVE?!0:!!E},iceTransportPolicy:o(this,cs)});g.push(b)}if(e.recv){const E=Q(this,Zh,GE).call(this,{iceServers:u,additionalSettings:{encodedInsertableStreams:(h=o(this,mr).getValue("modules").e2ee)==null?void 0:h.enabled},iceTransportPolicy:o(this,cs)});g.push(E)}yield Promise.all(g)})}stopTransports(e){var n,i;if(e.send&&this.sendTransport!==void 0){const{id:r,serverId:s,direction:a}=o(this,$t);m.info("Closing send transport",{transport:{id:r,serverId:s,type:a}}),o(this,$t).close(),o(this,$t).removeAllListeners(),T(this,$t,void 0)}if(e.recv&&this.recvTransport!==void 0){const{id:r,serverId:s,direction:a}=o(this,Kt);m.info("Closing recv transport",{transport:{id:r,serverId:s,type:a}}),(n=o(this,Kt))==null||n.close(),(i=o(this,Kt))==null||i.removeAllListeners(),T(this,Kt,void 0)}Q(this,Md,Yh).call(this)}stopAllTransports(){m.info("Closing all transports"),this.stopTransports({send:!0,recv:!0})}connectTransportWithRetry(e){return p(this,null,function*(){const{id:n,serverId:i,direction:r}=e;Q(this,ep,JE).call(this,e);try{const s=se.hasFeature(ue.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3;return yield mm((a,c)=>p(this,null,function*(){a>0&&m.debug(`Retrying transport connect, count: ${a}`,{transport:{id:n,serverId:i,type:r}});try{if(e.closed)throw new vs("Cannot reconnect closed transport");yield Q(this,Qh,HE).call(this,e)}catch(d){if(d instanceof vs){c(d);return}throw m.error("Failed to connect transport, retrying",{transport:e,error:d}),d}}),{delayTime:100,strategy:"exponential",maxRetryCount:s}),e}catch(s){throw m.error(`Failed to connect send transport after retry: ${e.id}`,{error:s,transport:{id:n,serverId:i,type:r}}),e.close(),e.removeAllListeners(),s}})}handleErrors(e){throw new Error("Method not implemented.")}}mr=new WeakMap,Yo=new WeakMap,$t=new WeakMap,Kt=new WeakMap,va=new WeakMap,Qo=new WeakMap,No=new WeakMap,Lo=new WeakMap,ea=new WeakMap,cs=new WeakMap,xo=new WeakMap,Xo=new WeakSet,Ad=function(){return o(this,mr).getValue("connectionHandler")},Md=new WeakSet,Yh=function(){T(this,ea,{send:void 0,recv:void 0})},Qh=new WeakSet,HE=function(t){return p(this,null,function*(){const{id:e,direction:n}=t;if(m.info(`Connecting ${n} transport`,{transport:{id:e,type:n}}),!o(this,va).isConnected)throw new vs("Socket is not connected");if(t.connectionState==="closed")throw new vs("Transport is closed");try{yield t.connect(i=>Q(this,tp,Jg).call(this,n,i)),m.info(`Connected ${n} transport`,{transport:{id:e,serverId:t.serverId,type:n}})}catch(i){throw o(this,Lo).transportFailureCount[n]+=1,i.message==="ice connection failed"?new vs(i.message):i}})},Xh=new WeakSet,qE=function(t){return p(this,null,function*(){var e,n;if(o(this,$t)&&o(this,$t).connected){m.info("Transport send is already connected",{transport:{id:(e=o(this,$t))==null?void 0:e.id,serverId:(n=o(this,$t))==null?void 0:n.serverId,type:"send"}});return}T(this,$t,o(this,Yo).createTransport(ee(H({},t),{direction:"send"}))),ne.configureSendTransport(o(this,$t))})},Zh=new WeakSet,GE=function(t){return p(this,null,function*(){var e,n;if(o(this,Kt)&&o(this,Kt).connected){m.info("Transport recv is already connected",{transport:{id:(e=o(this,Kt))==null?void 0:e.id,serverId:(n=o(this,Kt))==null?void 0:n.serverId,type:"recv"}});return}T(this,Kt,o(this,Yo).createTransport(ee(H({},t),{direction:"recv"}))),ne.configureRecvTransport(o(this,Kt))})},ep=new WeakSet,JE=function(t){const{direction:e,id:n}=t;t.on("connectionstatechange",i=>p(this,null,function*(){Q(this,Dd,Qu).call(this,{state:i,direction:e}),m.info(`Transport connection state changed for ${e} transport`,{transport:{id:n,serverId:t.serverId,type:e,status:i}});const r=()=>{const s=o(this,ea)[e];s!==void 0&&(clearTimeout(s),o(this,ea)[e]=void 0)};switch(i){case"connected":r(),o(this,Lo).lastConnectionTime=performance.now();break;case"disconnected":o(this,ea)[e]=setTimeout(()=>p(this,null,function*(){yield Q(this,Od,Yu).call(this,t)}),K2);break;case"failed":if(t.closed)return;r(),yield Q(this,Od,Yu).call(this,t);break}})),t.on("icecandidate",i=>p(this,null,function*(){m.debug("Sending iceCandidate:",{iceCandidate:i})})),t.on("datachannel:events",(i,r)=>p(this,null,function*(){var s,a;m.debug("Got data channel message on event:",{rtcChannel:{label:i,message:r}});try{switch(r.type){case"handshake":{const c={type:"handshake",payload:{message:"pong"}};t.sendResponseOverDC(i,WE(r),c);break}case"hub-disconnect":{m.debug(`media hub disconnected, full_reconnect: ${(s=r.payload)==null?void 0:s.full_reconnect}`),((a=r.payload)==null?void 0:a.full_reconnect)===!0&&this.handleErrors("rejoin");break}case"error":break;default:break}}catch{m.error(`Unable to handle the incoming datachannel message on channel ${i}`)}})),t.on("dc_error",()=>{t.direction==="recv"&&(m.warn("Events datachannel did not open in 5s",{country:w.location.country}),this.handleErrors("reconnectRecvTransport"))})},tp=new WeakSet,Jg=function(t,e){return p(this,null,function*(){const n=t==="recv";try{const{sdp:i,type:r}=e,s={consuming:n,description:{sdp:i,type:r,target:n?Ai.SUBSCRIBER:Ai.PUBLISHER},producers:[]};return o(this,Qo).connectTransport(s)}catch(i){throw m.error(`Error in ${t} transport connection:`,{error:i,country:w.location.country}),i}})},Od=new WeakSet,Yu=function(t){return p(this,null,function*(){m.info("Called reconnect transport",{transport:t}),t.close(),t.removeAllListeners();const{direction:e}=t;switch(se.hasFeature(ue.HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED)&&o(this,va).isConnected&&o(this,Lo).transportFailureCount[e]>2&&(m.warn(`Multiple disconnections in ${e} transport, forcing relay`),T(this,cs,"relay")),yield this.createTransports({[e]:!0}),e){case"send":{yield this.connectTransportWithRetry(o(this,$t)),m.info("Transport reconnected",{transport:o(this,$t)}),L.emit(x.RESET_PRODUCER_STATE);break}case"recv":{yield this.connectTransportWithRetry(o(this,Kt)),m.info("Transport reconnected",{transport:o(this,Kt)}),L.emit(x.UPDATE_ACTIVE,{createAllConsumers:!0});break}default:m.warn("Unknown transport direction",{transport:t})}Q(this,Dd,Qu).call(this,{state:wr.CONNECTED,direction:e})})},Dd=new WeakSet,Qu=function(t){const{state:e,direction:n}=t;o(this,Xo,Ad).mediaState[n]={state:e,reconnected:!0},L.emit(x.TRANSPORT_STATE_UPDATE,H({transport:n},o(this,Xo,Ad).mediaState[n]))};var np,$E;class Y2{constructor(e){S(this,np),this.recvTransport=e,Q(this,np,$E).call(this)}create(e){return p(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n={type:"create_consumer",payload:{producers:e.map(({producerId:a,producingTransportId:c,kind:d,mimeType:h})=>({producerId:a,producingTransportId:c,preferredCodec:H(H({},d==="video"&&h?{video:h}:{}),d==="audio"&&h?{audio:h}:{})}))}},i=yield this.recvTransport.sendDataChannelMessage("events",n),r=new Map;e.forEach(a=>r.set(a.producerId,a));const s=new Map;return Object.entries(i).forEach(([a,c])=>{const d=r.get(c.producerId);d&&s.set(c.producerId,{consumerId:a,producingTransportId:d.producingTransportId,producingPeerId:d.producingPeerId,kind:d.kind,paused:d.pause,streamId:c.streamId,trackId:c.trackId,screenShare:d.screenShare,mimeType:d.mimeType,appData:{}})}),{consumerStates:s}})}negotiate(e,n,i){return p(this,null,function*(){try{m.debug(`Received offer over dc: ${e.sdp} for transport`);const r=yield this.recvTransport.setRemoteOffer(e),s={type:"answer",payload:{type:r.type,sdp:r.sdp}};return m.debug(`datachannel answer: ${JSON.stringify(s)}`),this.recvTransport.sendResponseOverDC(i,n,s),r}catch(r){throw m.error("datachannel:events::Error:",r),r.code!=="DC_NOT_FOUND"&&this.recvTransport.sendErrorOverDC(i,n,r),r}})}close(e){return p(this,null,function*(){if(!e.length)return{};const n=e.map(a=>a.id);m.info(`Closing consumers: ${JSON.stringify(n)}`);const i={type:"close_consumers",payload:{consumers:n}},r=yield this.recvTransport.sendDataChannelMessage("events",i),{failedConsumers:s}=r;return{failedConsumers:s}})}}np=new WeakSet,$E=function(){this.recvTransport.on("datachannel:events",(t,e)=>p(this,null,function*(){try{switch(e.type){case"negotiation":{const{sdp:n}=e.payload,i={sdp:n,type:"offer"};this.negotiate(i,WE(e),t);break}default:break}}catch{m.error(`Unable to handle the incoming datachannel message on channel ${t}`)}}))};class Q2{constructor(e,n,i,r){this.events=e,this.recvTransport=n,this.socket=i,this.socketHandler=r}create(e){return p(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n=new Map,i=[];e.forEach(d=>{const{producingPeerId:h,producerId:u,producingTransportId:g}=d;n.set(u,h),i.push({producingPeerId:h,producerId:u,producingTransportId:g})});const r=yield this.socketHandler.consume({requests:i,consumingTransportId:this.recvTransport.serverId}),s=new Map;e.forEach(d=>s.set(d.producerId,d));const a=new Map,c=[];return Object.entries(r.consumerStateMap).forEach(([d,h])=>{const u=s.get(d);if(!u)return;if(h.errorCode){if(m.warn(`Consumer request failed for producer ${d}`,{error:{message:h.errorCode}}),h.errorCode==="not_found_track_error"){m.error(`Track not found for producer: ${u.producerId}. This will not be retried.`);return}c.push(u);return}let g={};try{g=JSON.parse(h.producerState.appData)}catch{}a.set(d,{consumerId:h.consumerId,producingTransportId:u.producingTransportId,producingPeerId:u.producingPeerId,kind:u.kind,paused:u.pause,streamId:h.producerTrack.streamId,trackId:h.producerTrack.trackId,screenShare:u.screenShare,mimeType:u.mimeType,appData:g})}),{consumerStates:a,sessionDescription:r.sessionDescription,failedProducers:c}})}negotiate(e){return p(this,null,function*(){try{m.info("Negotiating socket consumer",{transport:this.recvTransport}),m.debug(`setting remote offer: ${JSON.stringify(e)} on recvTransport`,{transport:this.recvTransport});const n=yield this.recvTransport.setRemoteOffer(e),i={transportId:this.recvTransport.serverId,description:{sdp:n.sdp,type:n.type,target:Ai.SUBSCRIBER}};return m.debug(`sending renegotiate request: ${JSON.stringify(i)} on recvTransport`,{transport:this.recvTransport}),yield this.socket.sendMessagePromise(this.events.renegotiateSessionDescription,PP.toBinary(i)),m.info("Renegotiation done",{transport:this.recvTransport}),n}catch(n){m.error("Failed to renegotiate",{error:n});return}})}close(e){return p(this,null,function*(){if(!e.length)return{};const n=(i,r)=>p(this,null,function*(){const s=i.map(h=>h.localId);m.info(`Closing consumers: ${JSON.stringify(s)}`);const a={description:{sdp:r.sdp,type:r.type,target:Ai.SUBSCRIBER},consumerIds:s,consumingTransportId:this.recvTransport.serverId},c=yield this.socketHandler.closeConsumer(a),d=QA.fromBinary(c).description;return{sdp:d.sdp,type:d.type}});return this.recvTransport.awaitQueue.push(()=>this.recvTransport.closeConsumers(e,n),"close_consumer"),{}})}}class ym{constructor(e){this.socketHandler=e}static getMSIDFromSDP(e,n){return Go(e).media.filter(i=>n==="video"?i.type==="video":i.type==="audio").at(-1).msid}create(e){return p(this,arguments,function*({offer:n,kind:i,paused:r,appData:s,codecOptions:a,producingTransportId:c}){var d,h;const u=ym.getMSIDFromSDP(n.sdp,i),g={description:{sdp:n.sdp,type:n.type,target:Ai.PUBLISHER},paused:r,kind:i,msid:u,appData:JSON.stringify(s),screenShare:(d=s.screenShare)!=null?d:!1,mimeType:`${i}/${(h=a[0])==null?void 0:h.name}`,producingTransportId:c},{answer:E,producerId:b}=yield this.socketHandler.produce(g);return{answer:E,producerId:b}})}}var Zo,pa,us,ec,Nd,bi,ip,vr,tc,rp,KE,El,sp,ap,zE,op,YE,cp,QE,dp,XE,lp,$g,up,Kg;class X2 extends z2{constructor(e,n,i){super(e,n,i),S(this,rp),S(this,El),S(this,ap),S(this,op),S(this,cp),S(this,dp),S(this,lp),S(this,up),S(this,Zo,void 0),S(this,pa,void 0),S(this,us,void 0),S(this,ec,void 0),S(this,Nd,void 0),S(this,bi,void 0),S(this,ip,{producerCreationFailureCount:0,consumerCreationFailureCount:0,producerNotReadyFailureCount:0}),S(this,vr,[]),S(this,tc,void 0),T(this,Zo,e),o(this,rp,KE).mediaState={send:{state:wr.NEW,reconnected:!1},recv:{state:wr.NEW,reconnected:!1}},this.reset()}get socketHandler(){return super.socketHandler}get producers(){return o(this,pa)}get consumers(){return o(this,us)}get producerIdToConsumerIdMap(){return o(this,ec)}reset(){T(this,pa,new Map),T(this,us,new Map),T(this,ec,new Map)}setupTransports(e){return p(this,null,function*(){yield this.createTransports(e);let n,i;e.send&&(n=Q(this,ap,zE).call(this)),e.recv&&(i=Q(this,op,YE).call(this)),yield Promise.all([n,i])})}createProducer(e,n){return p(this,null,function*(){var i;if(!this.sendTransport||this.sendTransport.closed)throw new Error("Send transport is closed");try{const r=yield this.sendTransport.produce(e,Q(this,cp,QE).bind(this));return(i=e.appData)!=null&&i.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,r),Q(this,dp,XE).call(this,r,n),r}catch(r){throw m.error("Failed to create producer",{error:r}),o(this,ip).producerCreationFailureCount+=1,r}})}closeProducer(e,n){return p(this,null,function*(){var i;const r=this.producers.get(e);if(!r){m.warn(`Producer with ID ${e} was not found`);return}n!=null&&n.stopTrack&&r.track.stop();try{yield this.sendTransport.closeProducer(r),(i=o(this,Zo).getValue("modules").e2ee)!=null&&i.enabled&&L.emit(x.E2EE_INACTIVE_PRODUCER,r)}catch(s){m.error("Failed to close producer on server",{error:s,producer:r})}})}closeAllProducers(){return Promise.all(Array.from(o(this,pa).entries()).map(([,e])=>e.close()))}createConsumer(e){return this.createConsumers([e])}createConsumers(e){return p(this,null,function*(){o(this,tc)||clearTimeout(o(this,tc)),T(this,vr,o(this,vr).concat(e)),yield Q(this,El,sp).call(this)})}closeConsumer(e){return this.closeConsumers([e])}closeConsumers(e){return p(this,null,function*(){if(!o(this,bi))return;const n=e.map(r=>this.consumers.get(r)).filter(r=>r!==void 0);if(n.length===0)return;const{failedConsumers:i}=yield o(this,bi).close(n);i!=null&&i.length&&m.warn("Failed to close some consumers",{consumerIds:i})})}closeAllConsumers(){return this.closeConsumers(Array.from(o(this,us).keys()))}switchConsumersToLayer(e,n){return p(this,null,function*(){const i=this.recvTransport.getDatachannel("events");if(!i){m.warn("events datachannel not found");return}const r={type:"switch_consumer_layer",payload:{consumerIds:e,layer:n}};yield i.request(r),m.info(`Consumers switched layers to ${n}`,{consumerIds:e})})}}Zo=new WeakMap,pa=new WeakMap,us=new WeakMap,ec=new WeakMap,Nd=new WeakMap,bi=new WeakMap,ip=new WeakMap,vr=new WeakMap,tc=new WeakMap,rp=new WeakSet,KE=function(){return o(this,Zo).getValue("connectionHandler")},El=new WeakSet,sp=function(){return p(this,null,function*(){if(!this.recvTransport||this.recvTransport.closed)throw new Error("Recv transport is closed");const t=500,e=o(this,vr).splice(0,o(this,vr).length);try{const n=e.filter(({producerId:s})=>!this.producers.get(s));if(n.length===0)return;const{consumers:i,failedProducers:r}=yield this.recvTransport.consume(n,Q(this,lp,$g).bind(this),o(this,bi).negotiate.bind(o(this,bi)));i.forEach(Q(this,up,Kg).bind(this)),r!=null&&r.length&&(m.error("Failed to create consumers for producers",{producers:r}),T(this,vr,o(this,vr).concat(r)),T(this,tc,setTimeout(Q(this,El,sp).bind(this),t)))}catch(n){m.error("failed to consume on transport",{error:n})}})},ap=new WeakSet,zE=function(){return p(this,null,function*(){yield this.connectTransportWithRetry(this.sendTransport),T(this,Nd,new ym(this.socketHandler))})},op=new WeakSet,YE=function(){return p(this,null,function*(){switch(this.recvTransport.on("connect",()=>{o(this,ec).clear()}),yield this.connectTransportWithRetry(this.recvTransport),this.nodeType){case bt.CF:{T(this,bi,new Q2(this.events,this.recvTransport,this.socket,this.socketHandler));break}case bt.HIVE:default:T(this,bi,new Y2(this.recvTransport))}})},cp=new WeakSet,QE=function(t){return o(this,Nd).create(t)},dp=new WeakSet,XE=function(t,e){t.on("close",(n,i)=>p(this,null,function*(){const{offer:r,reason:s}=n;if(m.info("producer::closing",{debuggingHint:s,producer:ee(H({},t),{status:"closing"})}),s!==yl){const a={producerId:t.id,description:{sdp:r.sdp,type:r.type,target:Ai.PUBLISHER}};try{const c=yield this.socketHandler.closeProducer(a),d={sdp:c==null?void 0:c.sdp,type:c==null?void 0:c.type};m.info("producer::closed",{producer:ee(H({},t),{status:"closed"})}),i({answer:d})}catch(c){m.error("producer close error",c)}}this.producers.delete(t.id),e()})),t.on("trackended",()=>{m.info("producer::trackended",{producer:ee(H({},t),{status:"UNKNOWN"})})}),o(this,pa).set(t.id,t)},lp=new WeakSet,$g=function(t){return p(this,null,function*(){try{return yield this.recvTransport.canConsume(),yield o(this,bi).create(t)}catch(e){throw m.error("Error in consume request",{error:e}),e}})},up=new WeakSet,Kg=function(t){t.on("close",e=>p(this,null,function*(){m.debug("consumer closed",{consumer:{closureReason:e,id:t.id,kind:t.kind,appData:t.appData}}),o(this,us).delete(t.id),L.emit(x.CONSUMER_CLOSED,{id:t.id})})),o(this,us).set(t.id,t),this.producerIdToConsumerIdMap.set(t.producerId,t.id),L.emit(x.NEW_CONSUMER,{id:t.id,appData:t.appData,peerId:t.peerId})};var Ld,xd,Vd,Vo,nc,ic,Sl,Tl,Uo,mn,oi,ni,Yr,Qr,fr,bl,hp,ZE,pp,eS,mp,tS,fp,nS;const gp=class{constructor({initialEnergyThreshold:t=.015,zeroCrossingThreshold:e=20,minVoiceDuration:n=3,hangoverFrames:i=5,noiseAdaptationRate:r=.95,voiceAdaptationRate:s=.99,minEnergyThreshold:a=.005,maxEnergyThreshold:c=.2,energyRatioThreshold:d=1.5,noiseHistorySize:h=50}={}){S(this,hp),S(this,pp),S(this,Ld,void 0),S(this,xd,void 0),S(this,Vd,void 0),S(this,Vo,void 0),S(this,nc,void 0),S(this,ic,void 0),S(this,Sl,void 0),S(this,Tl,void 0),S(this,Uo,void 0),S(this,mn,void 0),S(this,oi,void 0),S(this,ni,!1),S(this,Yr,0),S(this,Qr,0),S(this,fr,[]),S(this,bl,void 0),T(this,Vo,t),T(this,mn,t),T(this,Ld,e),T(this,xd,n),T(this,Vd,i),T(this,nc,r),T(this,ic,s),T(this,Sl,a),T(this,Tl,c),T(this,Uo,d),T(this,bl,h),T(this,oi,t/2)}get voiceDetected(){return o(this,ni)}processAudioChunk(t){var e,n;const i=Q(e=gp,mp,tS).call(e,t),r=Q(n=gp,fp,nS).call(n,t);return Q(this,hp,ZE).call(this,i),i/o(this,oi)>o(this,Uo)&&i>o(this,mn)&&r>o(this,Ld)?(T(this,Yr,o(this,Yr)+1),T(this,Qr,o(this,Vd)),o(this,Yr)>=o(this,xd)&&T(this,ni,!0)):(T(this,Yr,0),o(this,Qr)>0?T(this,Qr,o(this,Qr)-1):o(this,ni)&&T(this,ni,!1),o(this,ni)||Q(this,pp,eS).call(this,i)),{energy:i,isVoice:o(this,ni)}}reset(){T(this,ni,!1),T(this,Yr,0),T(this,Qr,0),T(this,mn,o(this,Vo)),T(this,oi,o(this,Vo)/2),T(this,fr,[])}getThresholdInfo(){return{currentEnergyThreshold:o(this,mn),backgroundNoiseEnergy:o(this,oi),energyRatioThreshold:o(this,Uo)}}};let vp=gp;Ld=new WeakMap,xd=new WeakMap,Vd=new WeakMap,Vo=new WeakMap,nc=new WeakMap,ic=new WeakMap,Sl=new WeakMap,Tl=new WeakMap,Uo=new WeakMap,mn=new WeakMap,oi=new WeakMap,ni=new WeakMap,Yr=new WeakMap,Qr=new WeakMap,fr=new WeakMap,bl=new WeakMap,hp=new WeakSet,ZE=function(t){o(this,ni)?T(this,mn,o(this,ic)*o(this,mn)+(1-o(this,ic))*t):T(this,mn,o(this,nc)*o(this,mn)+(1-o(this,nc))*o(this,oi)),T(this,mn,Math.max(o(this,Sl),Math.min(o(this,Tl),o(this,mn))))},pp=new WeakSet,eS=function(t){if(t<o(this,mn)*1.2)if(o(this,fr).push(t),o(this,fr).length>o(this,bl)&&o(this,fr).shift(),o(this,fr).length>=10){const e=[...o(this,fr)].sort((i,r)=>i-r),n=Math.floor(e.length/2);T(this,oi,e[n])}else T(this,oi,.95*o(this,oi)+.05*t)},mp=new WeakSet,tS=function(t){return Math.sqrt(t.map(e=>e*e).reduce((e,n)=>e+n)/t.length)},fp=new WeakSet,nS=function(t){let e=0;for(let n=1;n<t.length;n+=1)(t[n]>=0&&t[n-1]<0||t[n]<0&&t[n-1]>=0)&&(e+=1);return e},S(vp,mp),S(vp,fp);const Z2=60,ex=400;var sr,ar,ci,hs,ps,Bo,ya,rc,or,Xr,sc,yp,iS,Ud,Ep,Sp,rS,Xu,zg;const kl=class{constructor(t){S(this,yp),S(this,Sp),S(this,sr,void 0),S(this,ar,void 0),S(this,ci,void 0),S(this,hs,void 0),S(this,ps,void 0),S(this,Bo,void 0),S(this,ya,void 0),S(this,rc,void 0),S(this,or,void 0),S(this,Xr,void 0),S(this,sc,void 0),this.reportRequest=t,T(this,hs,new AudioContext),T(this,ps,o(this,hs).createAnalyser()),o(this,ps).fftSize=2048,T(this,rc,new vp)}set producerId(t){T(this,ci,t)}set audioTrack(t){T(this,Bo,t);const e=new MediaStream;e.addTrack(o(this,Bo)),o(this,hs).createMediaStreamSource(e).connect(o(this,ps))}start(){m.debug(`AudioActivityReporter: Starting audio activity reporter: ${o(this,ci)}`),o(this,sr)&&la(o(this,sr)),T(this,sr,Xd(()=>p(this,null,function*(){var t;if(!o(this,Bo)||!o(this,ci))return;const{energy:e}=Q(this,yp,iS).call(this),n=Q(t=kl,Ud,Ep).call(t,e);let i=.9;o(this,sc)!==n&&o(this,sc)?i=.9:n?i=.3:i=.5,T(this,ya,(o(this,ya)||0)*(1-i)+e*i)}),Z2)),o(this,ar)&&la(o(this,ar)),T(this,ar,Xd(Q(this,Sp,rS).bind(this),ex))}stop(){try{m.debug(`AudioActivityReporter: Stopping audio activity reporter: ${o(this,ci)}`),o(this,sr)&&(la(o(this,sr)),T(this,sr,void 0)),o(this,ar)&&(la(o(this,ar)),T(this,ar,void 0))}catch{}o(this,rc).reset()}};let Tp=kl;sr=new WeakMap,ar=new WeakMap,ci=new WeakMap,hs=new WeakMap,ps=new WeakMap,Bo=new WeakMap,ya=new WeakMap,rc=new WeakMap,or=new WeakMap,Xr=new WeakMap,sc=new WeakMap,yp=new WeakSet,iS=function(){var t;o(this,hs).state==="suspended"&&o(this,hs).resume().then(()=>{m.debug("AudioActivityReporter: AudioContext forced resumed")}).catch(s=>{m.error("AudioActivityReporter: Error resuming AudioContext",s)});const e=new Float32Array(o(this,ps).frequencyBinCount);o(this,ps).getFloatTimeDomainData(e);const{energy:n,isVoice:i}=o(this,rc).processAudioChunk(e),r=Q(t=kl,Xu,zg).call(t,n);return se.hasFeature(ue.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&m.debug(`AudioActivityReporter: producer: ${o(this,ci)}, energy: ${o(this,ya)},
26
25
  slogScale: ${r}, isVoice: ${i}, minEnergy: ${o(this,or)},
27
- maxEnergy: ${o(this,Xr)}`),r===-1/0||n<1e-6?{energy:0,isVoice:!1}:((!o(this,or)||r<o(this,or))&&T(this,or,r),(!o(this,Xr)||r>o(this,Xr))&&T(this,Xr,r),{energy:(r-o(this,or))/(o(this,Xr)-o(this,or))*10||0,isVoice:i})},Ud=new WeakSet,Ep=function(t){return t<5},Sp=new WeakSet,sS=function(t=o(this,ya)){var e;if(!o(this,ci)||!t){se.hasFeature(ue.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&m.debug(`AudioActivityReporter: No producerId or energy to report: ${o(this,ci)}`);return}const n={producerId:o(this,ci),energy:Math.round(t),silent:Q(e=kl,Ud,Ep).call(e,t)};T(this,sc,n.silent),this.reportRequest(n)},Xu=new WeakSet,zg=function(t){const e=Math.log10(t);return Math.round(e)},S(Tp,Ud),S(Tp,Xu);const tx=(t=!1)=>{const e=new window.AudioContext,n=e.createOscillator();n.type="triangle",n.frequency.setValueAtTime(20,e.currentTime);const i=e.createGain();i.gain.setValueAtTime(0,e.currentTime),n.connect(i);const r=e.createMediaStreamDestination();i.connect(r),n.start();const s=r.stream.getAudioTracks()[0];return s.enabled=t,s},nx=(t=!1)=>{var e,n;const i=new MediaStream().getVideoTracks()[0],r=document.createElement("canvas");r.height=(e=i==null?void 0:i.getSettings().height)!=null?e:720,r.width=(n=i==null?void 0:i.getSettings().width)!=null?n:1280;const s=r.getContext("2d");s.fillStyle="black",s.fillRect(0,0,r.width,r.height),setInterval(()=>{s.fillStyle="black",s.fillRect(0,0,r.width,r.height)},1e3);const a=r.captureStream().getVideoTracks()[0];return a.enabled=t,a};var ix=Object.defineProperty,rx=Object.getOwnPropertyDescriptor,Te=(t,e,n,i)=>{for(var r=i>1?void 0:i?rx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ix(e,n,r),r};const Xn=["video/VP9","video/VP8"];var Bd,Fd,Ht,te,Fo,Zr,rn,ta,na,es,jd,cr,jo,ia,ra,sn,hn,ts,sa,Ot,qt,aa,Wo,bp,aS,kp,oS,wp,cS;class Se{constructor(e,n,i){S(this,ts),S(this,Ot),S(this,aa),S(this,bp),S(this,kp),S(this,wp),y(this,"context"),y(this,"authToken"),y(this,"e2ee"),S(this,Bd,void 0),S(this,Fd,void 0),S(this,Ht,void 0),S(this,te,void 0),S(this,Fo,void 0),S(this,Zr,void 0),S(this,rn,void 0),S(this,ta,void 0),S(this,na,void 0),S(this,es,void 0),S(this,jd,void 0),S(this,cr,void 0),S(this,jo,void 0),S(this,ia,void 0),S(this,ra,void 0),S(this,sn,void 0),S(this,hn,void 0),y(this,"partialJoinRoomPromise");var r,s;this.context=e;const{socket:a}=i;this.mediaJoined=!1,T(this,ia,new Map([["video/VP9",new Set],["video/VP8",new Set]])),T(this,ra,new Map([["video/VP9",new Set],["video/VP8",new Set]])),T(this,Zr,n),T(this,Ht,a),T(this,ta,!1),T(this,te,new X2(e,a,n)),T(this,rn,o(this,te).events),T(this,cr,new Set),T(this,sn,new Map),T(this,na,!1),T(this,es,new gl),n===bt.CF&&!navigator.isReactNative&&T(this,hn,new Tp(o(this,te).socketHandler.audioActivity.bind(o(this,te).socketHandler))),this.e2ee=(s=(r=e.getValue("modules").e2ee)==null?void 0:r.enabled)!=null?s:!1,this.handleSocketEvents(),this.handleCallstatsEvents(),T(this,jd,cl(()=>p(this,null,function*(){if(!o(this,ts,sa).mediaJoinAttempted)return;const{roomJoined:c}=yield this.joinRoom(o(this,Fd),o(this,Bd),{},!0,!0);c&&(L.emit(x.RESET_PRODUCER_STATE),L.emit(x.ROOM_NODE_RECONNECTED))}),5e3,{leading:!0,maxWait:1e3}))}get peerId(){return this.context.getValue("peerId")}get mediaJoined(){return o(this,ts,sa).mediaJoined}set mediaJoined(e){o(this,ts,sa).mediaJoined=e}reset(e=!0){o(this,te).closeAllProducers(),o(this,te).closeAllConsumers(),o(this,sn).clear(),o(this,cr).clear(),e&&(this.partialJoinRoomPromise=void 0,o(this,es).stop(),o(this,te).stopAllTransports(),o(this,te).reset(),T(this,es,new gl))}joinRoom(e,n){return p(this,arguments,function*(i,r,s={},a=!1,c=!1){o(this,ts,sa).mediaJoinAttempted=!0,T(this,ta,!0),this.reset(a);const d=Pt().ipInfo;if(d!=null&&d.loc&&!o(this,jo)){const u=d.loc.split(",");T(this,jo,{latitude:parseFloat(u[0]),longitude:parseFloat(u[1])})}let h;try{return h=yield o(this,es).push(()=>this._joinRoom(i,r,s,c,o(this,jo)),"joinRoom"),h}catch{h={roomJoined:!1}}return h.roomJoined||L.emit(x.ROOM_NODE_FAILED),h})}_partialJoinRoom(e,n,i=!1,r=void 0){return p(this,null,function*(){var s;const{ipInfo:a}=Pt();let c=r;if(a!=null&&a.loc&&!r){const[u,g]=a.loc.split(",").map(parseFloat);c={latitude:u,longitude:g}}const d=(s=se.getValue(ue.FORCE_VIDEO_CODEC))==null?void 0:s.toString(),h=U2(d);T(this,Fo,h),yield mm((u,g)=>p(this,null,function*(){if(!o(this,Ht).isConnected){g(new Error("socket is not connected"));return}u>0&&m.warn(`retrying sending join room request, count: ${u}`);try{yield o(this,te).socketHandler.joinRoom(n,e,h,i,c)}catch(E){throw m.error("failed to send join room request, error:",{error:E}),E}}),{delayTime:1e3,strategy:"exponential",maxRetryCount:se.hasFeature(ue.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3}),yield o(this,te).setupTransports({send:!0,recv:!0}),o(this,Zr)!==bt.HIVE&&se.hasFeature(ue.PRECREATE_PRODUCERS)&&(this.shareWebcam(nx()),this.shareMic(tx()))})}partialJoinRoom(e,n,i=!1,r=void 0){return p(this,null,function*(){return this.partialJoinRoomPromise=o(this,es).push(()=>this._partialJoinRoom(e,n,i,r)),this.partialJoinRoomPromise})}_joinRoom(e,n){return p(this,arguments,function*(i,r,s={},a=!1,c=null){T(this,Fd,i);try{this.partialJoinRoomPromise?yield this.partialJoinRoomPromise:yield this._partialJoinRoom(i,r,a,c)}catch(d){m.error("error in partial join room",{error:d})}finally{this.partialJoinRoomPromise=void 0}try{return navigator.product!=="ReactNative"&&setTimeout(()=>p(this,null,function*(){const d={userId:this.context.getValue("userId"),peerId:this.peerId,roomUUID:r,roomViewType:"groupCall",deviceInfo:ee(H({},Be.getDeviceInfo()),{userAgent:navigator.userAgent,memory:navigator.deviceMemory,cpus:navigator.hardwareConcurrency}),sdkName:this.context.getValue("sdkName"),sdkVersion:this.context.getValue("sdkVersion"),metaData:{},permissions:{}};ne.roomJoined(d)})),{roomJoined:yield this.completeJoinRoom()}}catch(d){return m.error("error on sending join room request",{error:d}),{roomJoined:!1}}})}completeJoinRoom(){return p(this,null,function*(){try{this.mediaJoined=!0;const{roomState:e}=yield o(this,te).socketHandler.notifySelfJoinComplete();return T(this,Bd,e.roomUuid),T(this,na,!0),T(this,ta,!1),!0}catch(e){return m.error("error on completing join room:",{error:e}),this.mediaJoined=!1,!1}})}leaveRoom(){return p(this,null,function*(){o(this,te).stopAllTransports(),T(this,na,!1),o(this,ts,sa).mediaJoinAttempted=!1;const e={closeRoom:!1};o(this,Ht).sendMessagePromise(o(this,rn).leaveRoom,ZP.toBinary(e)).then(n=>{var i;(i=VA.fromBinary(n.payload))!=null&&i.closed||m.warn("weird state on peer closed and should not happen")}).catch(n=>{m.error("error on sending leave room request",{error:n})}),ne.callEnded(),w.destruct()})}getConsumers(){return o(this,te).consumers}activatePeers(e){return p(this,null,function*(){return this.createConsumers(e)})}deactivatePeers(e,n="default"){return p(this,null,function*(){const i=new Set;e.forEach(s=>{s.screenShare&&s.kind==="video"&&i.add(s.producingPeerId)});const r=n==="default"?e.filter(s=>!i.has(s.producingPeerId)).filter(s=>s.kind!=="audio"):e;yield Promise.all(r.map(s=>{const a=o(this,te).producerIdToConsumerIdMap.get(s.producerId);if(!a){m.warn(`consumer not found in deactivate producers: ${s.producerId}`);return}return o(this,te).closeConsumer(a)}))})}createConsumers(e){return p(this,null,function*(){return e.length===0?Promise.resolve():o(this,te).createConsumers(e)})}closeConsumers(e){return p(this,null,function*(){if(!e.length)return;const n=e.reduce((i,r)=>{const s=o(this,te).producerIdToConsumerIdMap.get(r.producerId);return s?(i.push(s),i):(m.warn(`consumer not found in deactivate producers: ${r.producerId}`),i)},[]);yield o(this,te).closeConsumers(n)})}_shareWebcam(e,n){return p(this,null,function*(){const i=n==="video/VP9"?De.WEBCAM:De.WEBCAM_BACKUP,r=Q(this,Ot,qt).call(this,i);if(r){const u=yield r;if(o(this,te).producers.has(u)){const g=o(this,te).producers.get(u);if(!g.closed&&!navigator.isReactNative)return yield g.replaceTrack({track:e}),yield this.resumeWebcam(i),e;yield this.disableWebcam(n)}return this._shareWebcam(e,n)}const s=Q(this,wp,cS).call(this,e,n),a=ll(this.context,"disableSimulcast"),c=o(this,Zr)===bt.CF?ue.ENABLE_CF_SIMULCAST:ue.ENABLE_HIVE_SIMULCAST;!a&&se.hasFeature(c)?(m.info(`Simulcast enabled for SFU: ${o(this,Zr)}`),s.encodings=NL(e)):m.info(`Simulcast disabled for webcam producer, SFU: ${o(this,Zr)}`),se.hasFeature(ue.TRACK_HINT)&&(s.track.contentHint=se.getValue(ue.TRACK_HINT));const d=()=>{m.info("Disabling video due to the producer closure"),o(this,sn).delete(i)},h=o(this,te).createProducer(s,d);return Q(this,aa,Wo).call(this,i,h.then(u=>u.id)),h.then(u=>u.track)})}shareWebcam(e){return p(this,null,function*(){if(e===void 0)return null;if(se.hasFeature(ue.FORCE_VIDEO_CODEC)){const n=se.getValue(ue.FORCE_VIDEO_CODEC).toString();if(n)return m.debug(`Calling _shareWebcam with forced video codec: ${n}`),this._shareWebcam(e,n)}return yield Promise.all(Xn.map(n=>{var i,r;return((r=(i=o(this,Fo).sender)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(s=>s.mimeType===n))>=0&&o(this,ra).get(n).size>0?(m.debug(`Calling _shareWebcam with video codec: ${n}`),this._shareWebcam(e,n)):e})),e})}shareScreen(e){return p(this,null,function*(){const{video:n,audio:i}=e;if(n===void 0)return;const r={track:n,codecOptions:[{name:"VP8"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Be.isElectron()},stopTracks:!1},s=()=>{m.info("Disabling screenShare due to the producer closure"),o(this,sn).delete(De.SCREENSHARE_VIDEO),o(this,sn).delete(De.SCREENSHARE_AUDIO)},a=o(this,te).createProducer(r,s);Q(this,aa,Wo).call(this,De.SCREENSHARE_VIDEO,a.then(d=>d.id));let c;if(i){const d={track:i,codecOptions:[{name:"opus"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Be.isElectron()},stopTracks:!1,zeroRtpOnPause:!0},h=()=>{};c=o(this,te).createProducer(d,h),Q(this,aa,Wo).call(this,De.SCREENSHARE_AUDIO,c.then(u=>u.id))}yield Promise.all([a,c||Promise.resolve()]),ne.screenShareStart()})}shareMic(e){return p(this,null,function*(){try{if(e===void 0)throw new an("track undefined");const n=Q(this,Ot,qt).call(this,De.MIC);if(n){const a=yield n;if(o(this,te).producers.has(a)){const c=o(this,te).producers.get(a);if(!c.closed&&!navigator.isReactNative){yield c.replaceTrack({track:e}),yield this.resumeMic(),o(this,hn)&&(o(this,hn).audioTrack=e,o(this,hn).producerId=a,o(this,hn).start());return}yield o(this,te).closeProducer(a,{stopTrack:!1})}yield this.shareMic(e);return}const i=Q(this,kp,oS).call(this,e),r=()=>{o(this,sn).delete(De.MIC)},s=o(this,te).createProducer(i,r);Q(this,aa,Wo).call(this,De.MIC,s.then(a=>a.id)),yield s.then(a=>{o(this,hn)&&(o(this,hn).audioTrack=a.track,o(this,hn).producerId=a.id,o(this,hn).start())})}catch(n){throw new D(n)}})}pauseMic(){return p(this,null,function*(){var e;const n=yield Q(this,Ot,qt).call(this,De.MIC),i=o(this,te).producers.get(n);if(!i){m.error("pauseMic::could_not_find_mic_producer");return}if(i.paused){m.info("pauseMic::mic_producer_already_paused");return}i.pause(),(e=o(this,hn))==null||e.stop();const r={producerId:i.id,pause:!0};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(r))})}pauseWebcam(){return p(this,null,function*(){const e=yield Q(this,Ot,qt).call(this,De.WEBCAM),n=yield Q(this,Ot,qt).call(this,De.WEBCAM_BACKUP),i=o(this,te).producers.get(e),r=o(this,te).producers.get(n);if(!i&&!r){m.error("pauseWebcam::could_not_find_webcam_producer");return}const s=a=>{const c={producerId:a.id,pause:!0};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(c))};i&&(i.pause(),s(i)),r&&(r.pause(),s(r))})}resumeMic(){return p(this,null,function*(){const e=yield Q(this,Ot,qt).call(this,De.MIC),n=o(this,te).producers.get(e);if(!n){m.error("resumeMic::could_not_find_mic_producer");return}if(!n.pause){m.info("resumeMic::mic_producer_already_resumed");return}n.resume(),n.appData.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,n);const i={producerId:n.id,pause:!1};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(i))})}resumeWebcam(){return p(this,arguments,function*(e=De.WEBCAM){const n=yield Q(this,Ot,qt).call(this,e),i=o(this,te).producers.get(n);if(!i){m.error("resumeWebcam::could_not_find_webcam_producer");return}if(!i.paused){m.info("resumeWebcam::webcam_producer_already_resumed");return}i.resume(),i.appData.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,i);const r={producerId:i.id,pause:!1};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(r))})}disableWebcam(e){return p(this,null,function*(){const n=e==="video/VP9"?De.WEBCAM:De.WEBCAM_BACKUP,i=yield Q(this,Ot,qt).call(this,n);Q(this,bp,aS).call(this,n),i&&(yield o(this,te).closeProducer(i))})}disableMic(){return p(this,null,function*(){var e;const n=yield Q(this,Ot,qt).call(this,De.MIC);n&&(yield o(this,te).closeProducer(n)),(e=o(this,hn))==null||e.stop(),o(this,sn).delete(De.MIC)})}disableScreenShare(){return p(this,null,function*(){m.info("screen_sharing_stopped"),ne.screenShareStop();const e=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_VIDEO),n=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_AUDIO);e&&(yield o(this,te).closeProducer(e)),n&&(yield o(this,te).closeProducer(n)),o(this,cr).clear(),o(this,sn).delete(De.SCREENSHARE_VIDEO),o(this,sn).delete(De.SCREENSHARE_AUDIO)})}muteSelf(){return p(this,null,function*(){this.pauseMic()})}unmuteSelf(){return p(this,null,function*(){})}resetVideoProducers(e,n){return p(this,null,function*(){if(e){const i=yield Q(this,Ot,qt).call(this,De.WEBCAM),r=yield Q(this,Ot,qt).call(this,De.WEBCAM_BACKUP);yield o(this,te).closeProducer(i,{stopTrack:!1}),yield o(this,te).closeProducer(r,{stopTrack:!1}),this.shareWebcam(e)}if(n){const i=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_VIDEO);yield o(this,te).closeProducer(i,{stopTrack:!1}),this.shareScreen({video:n})}})}changeDisplayName(e,n){return p(this,null,function*(){const i={displayName:e,participantId:n!=null?n:this.peerId};if(!(yield o(this,te).socketHandler.changeDisplayName(i)))throw new Error("failed to change display name!")})}kick(e){const n={peerIds:[e]};o(this,te).socketHandler.kickPeer(n)}kickAll(){o(this,te).socketHandler.kickAll()}muteAll(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForAll("audio")))throw new Error("failed to mute all participant")})}muteAllVideo(){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForAll("video")))throw new Error("failed to mute all video participant")})}disableAudio(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForPeer(e,"audio")))throw new Error("failed to mute given participant")})}disableVideo(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForPeer(e,"video")))throw new Error("failed to mute video of given participant")})}pinPeer(e){return p(this,null,function*(){const n={participantId:e!=null?e:""};try{yield o(this,Ht).sendMessagePromise(o(this,rn).globalPinPeer,dA.toBinary(n))}catch(i){m.error("Error in pinning peer:",{error:i})}})}validateScreenShare(e){return this.peerId===e.peerId&&o(this,te).producers.get(e.producerId)&&o(this,cr).add(e.consumerPeerId),o(this,cr).size}switchConsumersToLayer(e,n){return p(this,null,function*(){o(this,te).switchConsumersToLayer(e,n)})}handleSocketEvents(){return p(this,null,function*(){o(this,Ht).on(o(this,rn).peerProducerCreateBroadcast,({payload:e})=>{var n,i;if(this.mediaJoined)try{const{participantId:r,producerState:s}=pM.fromBinary(e);if(r===this.peerId)return;if(s!=null&&s.mimeType||(s.mimeType=s.kind===di.AUDIO?"audio/opus":"video/VP8"),s.kind===di.VIDEO&&!s.screenShare&&((i=(n=o(this,Fo).receiver)==null?void 0:n.video)==null?void 0:i.codecs.findIndex(a=>a.mimeType===Xn[0]))>=0&&o(this,ia).get(Xn[0]).has(r)&&s.mimeType!==Xn[0]){m.warn(`Ignoring producer: ${s.producerId}`);return}m.info(`producer created broadcast: ${r}, producer state: ${s}`),L.emit(x.NEW_PRODUCER,{peerId:r,producer:ee(H({},s),{kind:s.kind===di.AUDIO?"audio":"video",producingPeerId:r})})}catch(r){m.error("error in peer-producer-create-broadcast",{error:r})}}),o(this,Ht).on(o(this,rn).peerProducerToggleBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,initiatorParticipantId:i,producerState:{kind:r,pause:s,producerId:a}}=tg.fromBinary(e),c=r===di.AUDIO?"audio":"video";if(m.info(`producer toggle broadcast: ${n}, producerId: ${a}, kind:${c}, paused:${s} payload: ${JSON.stringify(tg.fromBinary(e))}`),n===this.peerId&&i!==this.peerId&&s&&L.emit(c==="audio"?x.MUTE_SELF:x.MUTE_SELF_VIDEO),n===this.peerId)return;L.emit(x.PRODUCER_TOGGLE,{peerId:n,producerId:a,paused:s,kind:c}),Array.from(this.getConsumers().values()).filter(d=>d.producerId===a).forEach(d=>{d.paused!==s&&(m.debug(`consumer state mismatched for ${d.id}. updating consumer pause state ${d.paused} to ${s}`),s?(d.pause(),L.emit(x.CONSUMER_PAUSED,{id:d.id})):(d.resume(),L.emit(x.CONSUMER_RESUMED,{id:d.id})))})}catch(n){m.error("error in producer toggle broadcast handler",{error:n})}}),o(this,Ht).on(o(this,rn).peerLeaveBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n}=Ch.fromBinary(e);if(n===this.peerId)return;m.info(`peer left broadcast:${n}`),o(this,cr).delete(n),o(this,te).consumers.forEach(i=>{i.peerId===n&&i.close()}),L.emit(x.PEER_CLOSED,{id:n})}catch(n){m.error("error in peer left broadcast",{error:n})}}),o(this,Ht).on(o(this,rn).peerProducerCloseBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,producerState:{producerId:i}}=gM.fromBinary(e);if(n===this.peerId)return;m.info(`producer closed broadcast:${n}`),L.emit(x.PRODUCER_CLOSED,{peerId:n,producerId:i});const r=o(this,te).producerIdToConsumerIdMap.get(i);if(!r){m.warn(`no consumer found for producer:${i}`);return}m.info(`closing consumer ${r}, producer id: ${i}`),o(this,te).closeConsumer(r).then(()=>{m.info(`closed consumer: ${r}`),o(this,te).producerIdToConsumerIdMap.delete(i),L.emit(x.CONSUMER_CLOSED,{id:r})}).catch(s=>{m.error("error closing consumer",{error:s})})}catch(n){m.error("error on producer close broadcast",{error:n})}}),o(this,Ht).on(o(this,rn).mediaRoomTerminationBroadcastResponse,()=>{!this.mediaJoined&&!o(this,ta)&&!o(this,na)||(m.warn("media hub termination broadcast received, rejoining room"),L.emit(x.ROOM_NODE_DISCONNECTED),o(this,jd).call(this))})})}handleCallstatsEvents(){ne.onConsumerScore(e=>{e.forEach((n,i)=>{const r=o(this,te).consumers.get(i);r&&L.emit(x.CONSUMER_SCORE_UPDATE,{id:i,kind:r.kind,peerId:r.peerId,score:n.score,scoreStats:n})})}),ne.onProducerScore(e=>{e.forEach((n,i)=>{const r=Array.from(o(this,te).producers.values()).find(s=>s.id===i);r&&L.emit(x.PRODUCER_SCORE_UPDATE,{id:i,kind:r.kind,appData:r.appData,score:n.score,scoreStats:n})})})}handlePeerCapabilities(e,n){var i,r,s,a;for(let c=0;c<=Xn.length;c+=1){const d=Xn[c];if(((r=(i=n==null?void 0:n.receiver)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(h=>h.mimeType===d))>=0||c===Xn.length-1){o(this,ra).get(d).add(e);break}}for(let c=0;c<=Xn.length;c+=1){const d=Xn[c];if(((a=(s=n==null?void 0:n.sender)==null?void 0:s.video)==null?void 0:a.codecs.findIndex(h=>h.mimeType===d))>=0||c===Xn.length-1){o(this,ia).get(d).add(e);break}}}handlePeerLeaving(e){se.hasFeature(ue.FORCE_VIDEO_CODEC)||(o(this,ia).forEach(n=>n.delete(e)),o(this,ra).forEach((n,i)=>{n.delete(e),n.size===0&&this.disableWebcam(i)}))}}Bd=new WeakMap,Fd=new WeakMap,Ht=new WeakMap,te=new WeakMap,Fo=new WeakMap,Zr=new WeakMap,rn=new WeakMap,ta=new WeakMap,na=new WeakMap,es=new WeakMap,jd=new WeakMap,cr=new WeakMap,jo=new WeakMap,ia=new WeakMap,ra=new WeakMap,sn=new WeakMap,hn=new WeakMap,ts=new WeakSet,sa=function(){return this.context.getValue("connectionHandler")},Ot=new WeakSet,qt=function(t){return o(this,sn).get(t)},aa=new WeakSet,Wo=function(t,e){return o(this,sn).set(t,e)},bp=new WeakSet,aS=function(t){return o(this,sn).delete(t)},kp=new WeakSet,oS=function(t){return{track:t,encodings:[{priority:"high"}],codecOptions:[{name:"opus"}],appData:{e2ee:this.e2ee},stopTracks:!1,zeroRtpOnPause:!0}},wp=new WeakSet,cS=function(t,e){return{track:t,codecOptions:[{name:e?e.split("/")[1]:"VP8"}],appData:{screenShare:!1,e2ee:this.e2ee},stopTracks:!1}};Te([w.trace("MediaNodeClient.reset",{country:w.location.country})],Se.prototype,"reset",1);Te([w.trace("MediaNodeClient.joinRoom")],Se.prototype,"joinRoom",1);Te([w.trace("MediaNodeClient.completeJoinRoom")],Se.prototype,"completeJoinRoom",1);Te([w.trace("MediaNodeClient.leaveRoom")],Se.prototype,"leaveRoom",1);Te([w.trace("MediaNodeClient.activatePeers")],Se.prototype,"activatePeers",1);Te([w.trace("MediaNodeClient.deactivatePeers")],Se.prototype,"deactivatePeers",1);Te([w.trace("MediaNodeClient.createConsumers")],Se.prototype,"createConsumers",1);Te([w.trace("MediaNodeClient.closeConsumers")],Se.prototype,"closeConsumers",1);Te([w.trace("MediaNodeClient._shareWebcam")],Se.prototype,"_shareWebcam",1);Te([w.trace("MediaNodeClient.shareWebcam")],Se.prototype,"shareWebcam",1);Te([w.trace("MediaNodeClient.shareScreen")],Se.prototype,"shareScreen",1);Te([w.trace("MediaNodeClient.shareMic")],Se.prototype,"shareMic",1);Te([w.trace("MediaNodeClient.pauseMic")],Se.prototype,"pauseMic",1);Te([w.trace("MediaNodeClient.pauseWebcam")],Se.prototype,"pauseWebcam",1);Te([w.trace("MediaNodeClient.resumeMic")],Se.prototype,"resumeMic",1);Te([w.trace("MediaNodeClient.resumeWebcam")],Se.prototype,"resumeWebcam",1);Te([w.trace("MediaNodeClient.disableWebcam")],Se.prototype,"disableWebcam",1);Te([w.trace("HiveClient.disableMic")],Se.prototype,"disableMic",1);Te([w.trace("HiveClient.disableScreenShare")],Se.prototype,"disableScreenShare",1);Te([w.trace("MediaNodeClient.muteSelf")],Se.prototype,"muteSelf",1);Te([w.trace("MediaNodeClient.resetVideoProducers")],Se.prototype,"resetVideoProducers",1);Te([w.trace("MediaNodeClient.changeDisplayName")],Se.prototype,"changeDisplayName",1);Te([w.trace("MediaNodeClient.kickPeer")],Se.prototype,"kick",1);Te([w.trace("MediaNodeClient.kickAllPeers")],Se.prototype,"kickAll",1);Te([w.trace("MediaNodeClient.muteAll")],Se.prototype,"muteAll",1);Te([w.trace("MediaNodeClient.muteAllVideo")],Se.prototype,"muteAllVideo",1);Te([w.trace("MediaNodeClient.disableAudio")],Se.prototype,"disableAudio",1);Te([w.trace("MediaNodeClient.disableVideo")],Se.prototype,"disableVideo",1);Te([w.trace("MediaNodeClient.pinPeer")],Se.prototype,"pinPeer",1);Te([w.trace("MediaNodeClient.validateScreenShare")],Se.prototype,"validateScreenShare",1);function dS(t,e,n){const i=t.getValue("roomNodeClient");if(i){if(i)return i;throw new Error("Room node client already set up.")}const r=new Se(t,e,n);return t.setValue("roomNodeClient",r),r}function lS(t){const e=t.getValue("roomNodeClient");try{e==null||e.leaveRoom()}catch{m.error("roomNodeClient::cleanupRoomNodeClient")}t.setValue("roomNodeClient",void 0)}var sx=Object.defineProperty,ax=Object.getOwnPropertyDescriptor,As=(t,e,n,i)=>{for(var r=i>1?void 0:i?ax(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&sx(e,n,r),r},Br,Zn,Bt,bn,Dn,Yg;const uS=(Yg=class{constructor(t,e,n,i){S(this,bn),y(this,"self"),y(this,"authToken"),S(this,Br,void 0),y(this,"viewType"),S(this,Zn,void 0),S(this,Bt,void 0);const{socket:r}=n,s=t.getValue("authToken");this.self=e,T(this,Bt,t),this.viewType=i,this.authToken=s,T(this,Br,r),T(this,Zn,n),e.config.viewType!==Yt.Chat&&this.setupEvents()}get peerId(){return o(this,Bt).getValue("peerId")}get mediaJoined(){return o(this,Bt).getValue("connectionHandler").mediaJoined}static init(t,e,n,i,r){return p(this,null,function*(){const s=Pt(),a=t.getValue("peerId"),c=!!t.getValue("cachedUserDetails"),d=yield wt.__init__(t,n,i,r,r.name,c);if(navigator.product!=="ReactNative"){const h=!se.hasFeature(ue.PRECALL_BANDWIDTH_TEST);setTimeout(()=>p(this,null,function*(){const u=yield d.getAllDevices();m.info("populated_full_device_list",{devices:JSON.stringify(u)}),ne.devices("AUDIO",u==null?void 0:u.filter(g=>g.kind==="audioinput")),ne.devices("VIDEO",u==null?void 0:u.filter(g=>g.kind==="videoinput")),ne.devices("SPEAKER",u==null?void 0:u.filter(g=>g.kind==="audiooutput")),m.info("Callstats:: initializing");try{yield ne.initialize({peerId:a,engineName:Be.getDeviceInfo().engineName,env:t.getValue("env"),iceServers:yield s.getICEServers(),apiBase:t.getValue("apiBase"),flags:se.getAllFlags(),logger:m,apiHostnames:eE(t),skipConnectivityChecks:h}),m.info("Callstats:: initialized")}catch(g){m.error("Callstats:: initialization failed",{error:g})}}),0)}else m.info("Callstats:: Skipped initialization due to navigator product being ReactNative.");return new uS(t,d,e,r.viewType)})}shareMediaTracks(){return p(this,null,function*(){var t;const{audioTrack:e,videoTrack:n,permissions:i,audioEnabled:r,videoEnabled:s,screenShareEnabled:a,screenShareTracks:c}=this.self;if(i.canProduceAudio&&r)try{yield o(this,bn,Dn).shareMic(e)}catch{this.self.disableAudio()}if(i.canProduceVideo&&s)try{const d=yield o(this,bn,Dn).shareWebcam(n);d&&d.id!==n.id&&se.hasFeature(ue.EXP_RESHARE)&&(yield o(this,bn,Dn).shareWebcam(d))}catch{this.self.disableVideo()}if(i.canProduceScreenshare&&a)try{yield(t=o(this,bn,Dn))==null?void 0:t.shareScreen({video:c.video,audio:c.audio})}catch{this.self.disableScreenShare()}})}kickHandler(t){return p(this,null,function*(){let e="kicked";(t==null?void 0:t.kickType)==="kickAll"&&(e="ended"),this.leaveRoom(e)})}waitlistedHandler(){m.info("SelController.waitlisted"),this.self.waitlistStatus="waiting",this.self.roomState="waitlisted",this.self.emit("waitlisted")}waitlistAcceptHandler(){if(m.info("SelController.waitlistAccepted"),this.self.waitlistStatus==="accepted"){m.warn("SelfController.WAITLIST_ACCEPTED.UserAlreadyAccepted");return}this.self.waitlistStatus="accepted",this.joinRoom()}waitlistRejectedHandler(){if(m.info("SelfController.waitlistRejected"),this.self.waitlistStatus==="rejected"){m.warn("SelfController.WAITLIST_REJECTED.UserAlreadyRejected");return}this.self.waitlistStatus="rejected",this.leaveRoom("rejected")}resetSelf(t){return p(this,null,function*(){ne.callEnded(),o(this,bn,Dn).reset(),t&&(yield this.joinRoom(t))})}setupEvents(){L.on(x.RESET_PRODUCER_STATE,()=>p(this,null,function*(){this.mediaJoined&&this.shareMediaTracks()})),L.on(x.ROOM_NODE_RECONNECTED,()=>{this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:!0})}),L.on(x.ROOM_NODE_DISCONNECTED,()=>{this.self.roomState!=="disconnected"&&(this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"}))}),L.on(x.ROOM_NODE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),L.on(x.SOCKET_SERVICE_RECONNECTED,({wasJoinAttempted:t})=>{t===!1&&(this.self.roomState="init"),this.resetSelf(t)}),L.on(x.SOCKET_SERVICE_DISCONNECTED,({joinAttempted:t})=>{if(this.self.roomState==="disconnected")return;let{peerId:e}=this;t&&se.hasFeature(ue.REFRESH_ID_ON_DISCONNECTION)&&(e=Ca()),o(this,Br).updateURL(e),w.resetPeerId(e),Pt().setHeader("dyte-tracing-id",e),ms.remapContext(e,o(this,Bt)),this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"})}),L.on(x.SOCKET_SERVICE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),o(this,Zn).on(Y.waitingRoomRequestAccepted,()=>{this.waitlistAcceptHandler()}),o(this,Zn).on(vd.updateUserPreset,t=>{t.updatePeersPresets.forEach(e=>{e.userIds===this.self.userId&&L.emit(x.UPDATE_PERMISSIONS,e.patch)})}),o(this,Zn).on(Y.waitingRoomRequestDenied,()=>{this.waitlistRejectedHandler()}),o(this,Zn).on(Y.kick,()=>{this.kickHandler({kickType:"kick"})}),o(this,Zn).on(Y.kickAll,()=>{this.kickHandler({kickType:"kickAll"})}),L.onAsync(x.JOIN_MEDIA_ROOM,this.joinMediaRoom.bind(this)),L.on(x.PRODUCER_SCORE_UPDATE,({score:t,kind:e,appData:n,scoreStats:i})=>{var r;const s=(r=n==null?void 0:n.screenShare)!=null?r:!1;this.self.emit("mediaScoreUpdate",{kind:e,isScreenshare:s,score:t,participantId:this.self.id,scoreStats:i})}),L.on(x.MUTE_SELF,()=>p(this,null,function*(){this.self.audioEnabled&&(yield this.self.disableAudio(),ne.audioOff())})),L.on(x.MUTE_SELF_VIDEO,()=>p(this,null,function*(){this.self.videoEnabled&&(yield this.self.disableVideo(),ne.videoOff())})),L.onAsync(x.LEAVE_MEDIA_ROOM,this.leaveMediaRoom.bind(this)),L.on(x.PIP_HANGUP,this.leaveRoom.bind(this))}joinRoom(t=!1){return p(this,null,function*(){try{const{peer:e}=yield o(this,Zn).joinRoom(this.self);o(this,Zn).socket.flush();const n=om(e.stageType);if(o(this,Bt).setValue("stageStatus",n,!1),e.waitlisted){this.waitlistedHandler();return}yield this.joinMediaRoom(t),o(this,Bt).notify("stageStatus")}catch(e){throw m.error("Error in joinRoom",{error:e}),e}})}leaveRoom(t="left"){return p(this,null,function*(){var e,n;if(t==="rejected"){try{(e=o(this,Br))==null||e.disconnect()}catch{m.error("SelfController::leaveRoom::socketDisconnect")}this.self.roomState=t,this.self.emit("roomLeft",{state:t});return}this.self.setIsPinned(!1),o(this,Bt).setValue("stageStatus","OFF_STAGE",!1),yield this.leaveMediaRoom(t),o(this,Bt).notify("stageStatus");try{(n=o(this,Br))==null||n.disconnect()}catch{m.error("SelfController::leaveRoom::socketDisconnect")}lS(o(this,Bt)),fl.cleanup(),this.self.roomState=t,this.self.emit("roomLeft",{state:t})})}joinMediaRoom(t=!1){return p(this,null,function*(){var e,n;const{peerId:i,viewType:r,meetingId:s,stageStatus:a,roomNodeOptions:c}=o(this,Bt).getAllValues(),{sfu:d}=c;try{if(r===Yt.Livestream){if(a!=="ON_STAGE"){this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t});return}dS(o(this,Bt),d,{socket:o(this,Br),peerId:i})}const{roomJoined:h}=(n=yield(e=o(this,bn,Dn))==null?void 0:e.joinRoom(this.self.name,s,{audio:this.self.audioEnabled,video:this.self.videoEnabled,screen:this.self.screenShareEnabled},t,t))!=null?n:{};if(!h)return;a==="ON_STAGE"&&(yield this.shareMediaTracks()),this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t})}catch(h){throw m.error("Error:SelfController.mediaRoomJoin",{error:h}),new D("Error: could not join media room","0002")}})}leaveMediaRoom(t){return p(this,null,function*(){const e=o(this,Bt).getValue("viewType");t!=="connected-meeting"&&(yield this.cleanupSelf()),!(t==="stageLeft"&&e===Yt.Webinar)&&o(this,bn,Dn)&&(o(this,bn,Dn).mediaJoined&&t!=="disconnected"&&(yield o(this,bn,Dn).leaveRoom()),!(t==="stageLeft"&&e===Yt.Livestream)&&(o(this,bn,Dn).mediaJoined=!1))})}cleanupSelf(){return p(this,null,function*(){yield this.self.disableAudio(),yield this.self.disableVideo(),yield this.self.disableScreenShare(),this.self.cleanUpTracks(),this.self.destructMediaHandler(),navigator.isReactNative||this.self.removeDocumentEventListeners()})}},Br=new WeakMap,Zn=new WeakMap,Bt=new WeakMap,bn=new WeakSet,Dn=function(){return o(this,Bt).getValue("roomNodeClient")},Yg);let Pr=uS;As([w.trace("SelfController.resetSelf")],Pr.prototype,"resetSelf",1);As([w.trace("SelfController.setupEvents")],Pr.prototype,"setupEvents",1);As([w.trace("SelfController.joinRoom")],Pr.prototype,"joinRoom",1);As([w.trace("SelfController.leaveRoom")],Pr.prototype,"leaveRoom",1);As([w.trace("SelfController.joinMediaRoom")],Pr.prototype,"joinMediaRoom",1);As([w.trace("SelfController.leaveMediaRoom")],Pr.prototype,"leaveMediaRoom",1);As([w.trace("SelfController.init")],Pr,"init",1);var Wd;class ox{constructor(e){S(this,Wd,void 0),T(this,Wd,e)}on(e,n){let i;e===Y.roomPeerCount?i=rg.fromBinary.bind(rg):i=fg.fromBinary.bind(fg),o(this,Wd).on(e,({payload:r})=>{const s=i(r);return n(s)})}}Wd=new WeakMap;var Hd;class cx{constructor(e){S(this,Hd,void 0),T(this,Hd,e)}on(e,n){let i,r;switch(e){case Y.transcript:{i=Cu.fromBinary.bind(Cu),r=Cu.create();break}default:{m.debug("AISocketHandler switch case hit default, event not accounted for.");break}}o(this,Hd).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("chatSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}}Hd=new WeakMap;var dx=Object.defineProperty,lx=Object.getOwnPropertyDescriptor,Em=(t,e,n,i)=>{for(var r=i>1?void 0:i?lx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&dx(e,n,r),r},dr;class Zl{constructor(e){S(this,dr,void 0),T(this,dr,e)}getPolls(){return o(this,dr).sendMessagePromise(Si.getPolls)}createPoll(e,n,i=!1,r=!1){const s={anonymous:i,hideVotes:r,question:e,options:n};return o(this,dr).sendMessage(Si.createPoll,rN.toBinary(s))}votePoll(e,n){const i={index:n,pollId:e};return o(this,dr).sendMessage(Si.votePoll,aN.toBinary(i))}on(e,n){let i,r;switch(e){case Si.updatePoll:case Si.createPoll:case Si.votePoll:{i=Du.fromBinary.bind(Du),r=Du.create();break}}o(this,dr).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("pollSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}removeListeners(e){o(this,dr).removeListeners(e)}}dr=new WeakMap;Em([w.trace("PollSocketHandler.getPolls")],Zl.prototype,"getPolls",1);Em([w.trace("PollSocketHandler.createPoll")],Zl.prototype,"createPoll",1);Em([w.trace("PollSocketHandler.votePoll")],Zl.prototype,"votePoll",1);var pn;class ux{constructor(e){S(this,pn,void 0),T(this,pn,e)}getStageRequests(){return p(this,null,function*(){const{payload:e}=yield o(this,pn).sendMessagePromise(Y.getStageRequests);return e?Ou.fromBinary(e):{stageRequests:[]}})}requestAccess(){o(this,pn).sendMessage(Y.requestStageAccess)}cancelRequestAccess(){o(this,pn).sendMessage(Y.cancelStageRequest)}grantAccess(e){return p(this,null,function*(){const n={userIds:e};o(this,pn).sendMessage(Y.grantStageAccess,KD.toBinary(n))})}denyAccess(e){return p(this,null,function*(){const n={userIds:e};o(this,pn).sendMessage(Y.denyStageAccess,YD.toBinary(n))})}joinStage(){return o(this,pn).sendMessagePromise(Y.joinStage,void 0,void 0,Y.peerStageStatusUpdate)}leaveStage(e){const n={userIds:[e]};return o(this,pn).sendMessagePromise(Y.leaveStage,vg.toBinary(n),void 0,Y.peerStageStatusUpdate)}kick(e){const n={userIds:e};return o(this,pn).sendMessagePromise(Y.leaveStage,vg.toBinary(n))}on(e,n){let i;switch(e){case Y.grantStageAccess:case Y.denyStageAccess:{i=void 0;break}case Y.getStagePeers:{i=gg.fromBinary.bind(gg);break}case Y.getStageRequests:case Y.requestStageAccess:case Y.cancelStageRequest:{i=Ou.fromBinary.bind(Ou);break}case Y.peerStageStatusUpdate:{i=ig.fromBinary.bind(ig);break}}o(this,pn).on(e,({payload:r,id:s})=>{if(!r||!i)return n(void 0,s);const a=i(r);return n(a,s)})}getPeerInfo(e){return p(this,null,function*(){const n=yield o(this,pn).sendMessagePromise(Y.getPeerInfo,lE.toBinary({peerId:e}));return Gs.fromBinary(n.payload)})}}pn=new WeakMap;var St;class hx{constructor(e){S(this,St,void 0),T(this,St,e)}addPlugin(e,n){o(this,St).sendMessage(ie.addPlugin,uD.toBinary({pluginId:e,staggered:n}))}removePlugin(e){o(this,St).sendMessage(ie.removePlugin,pD.toBinary({pluginId:e,staggered:!1}))}getActivePlugins(){return p(this,null,function*(){const{payload:e}=yield o(this,St).sendMessagePromise(ie.getPlugins);return e?xD.fromBinary(e):{plugins:[]}})}customPluginEventToRoom(e,n,i){const r={pluginId:e,pluginData:new TextEncoder().encode(JSON.stringify(n))};o(this,St).sendMessage(ie.customPluginEventToRoom,kD.toBinary(r),i)}customPluginEventToPeers(e,n,i,r){const s={pluginId:e,peerIds:n,pluginData:new TextEncoder().encode(JSON.stringify(i))};o(this,St).sendMessage(ie.customPluginEventToPeers,_D.toBinary(s),r)}enablePluginForRoom(e,n){o(this,St).sendMessage(ie.enablePluginForRoom,fD.toBinary({pluginId:e}),n)}enablePluginForPeers(e,n,i){o(this,St).sendMessage(ie.enablePluginForPeers,ED.toBinary({pluginId:e,peerIds:n}),i)}disablePluginForRoom(e,n){o(this,St).sendMessage(ie.disablePluginForRoom,vD.toBinary({pluginId:e}),n)}disablePluginForPeers(e,n,i){o(this,St).sendMessage(ie.disablePluginForPeers,TD.toBinary({pluginId:e,peerIds:n}),i)}storeInsertKeys(e,n,i,r){const s={pluginId:e,storeName:n,insertKeys:i.map(a=>({storeKey:a.key,payload:new TextEncoder().encode(JSON.stringify(a.payload))}))};o(this,St).sendMessage(ie.storeInsertKeys,ug.toBinary(s),r)}storeGetKeys(e,n,i,r){const s={pluginId:e,storeName:n,getKeys:i.map(a=>({storeKey:a.key}))};o(this,St).sendMessage(ie.storeGetKeys,PD.toBinary(s),r)}storeDeleteKeys(e,n,i,r){const s={pluginId:e,storeName:n,deleteKeys:i.map(a=>({storeKey:a.key}))};o(this,St).sendMessage(ie.storeDeleteKeys,MD.toBinary(s),r)}storeDelete(e,n,i){o(this,St).sendMessage(ie.storeDelete,DD.toBinary({pluginId:e,storeName:n}),i)}getPluginDataOld(e,n){m.info("getPluginDataOld",{plugin:{id:e,storeName:n}})}storePluginDataOld(e,n,i){const r={pluginId:e,storeName:n,insertKeys:[{storeKey:i.key,payload:new TextEncoder().encode(JSON.stringify(i))}]};o(this,St).sendMessage(ie.storeInsertKeys,ug.toBinary(r))}on(e,n){let i;switch(e){case ie.addPlugin:case ie.enablePluginForPeers:case ie.enablePluginForRoom:{i=Mh.fromBinary.bind(Mh);break}case ie.removePlugin:case ie.disablePluginForPeers:case ie.disablePluginForRoom:{i=hg.fromBinary.bind(hg);break}case ie.customPluginEventToPeers:case ie.customPluginEventToRoom:{i=mg.fromBinary.bind(mg);break}case ie.storeInsertKeys:case ie.storeGetKeys:case ie.storeDeleteKeys:case ie.storeDelete:{i=pg.fromBinary.bind(pg);break}}o(this,St).on(e,({payload:r,id:s})=>{const a=i(r);return n(a,s)})}}St=new WeakMap;var px=Object.defineProperty,mx=(t,e,n)=>e in t?px(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fx=(t,e,n)=>(mx(t,typeof e!="symbol"?e+"":e,n),n),Sm=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},W=(t,e,n)=>(Sm(t,e,"read from private field"),n?n.call(t):e.get(t)),Ve=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},ke=(t,e,n,i)=>(Sm(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),qe=(t,e,n)=>(Sm(t,e,"access private method"),n),wl={},gx={get exports(){return wl},set exports(t){wl=t}},Ea=typeof Reflect=="object"?Reflect:null,Qg=Ea&&typeof Ea.apply=="function"?Ea.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},qd;Ea&&typeof Ea.ownKeys=="function"?qd=Ea.ownKeys:Object.getOwnPropertySymbols?qd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qd=function(t){return Object.getOwnPropertyNames(t)};function vx(t){console&&console.warn&&console.warn(t)}var hS=Number.isNaN||function(t){return t!==t};function _e(){_e.init.call(this)}gx.exports=_e;wl.once=Tx;_e.EventEmitter=_e;_e.prototype._events=void 0;_e.prototype._eventsCount=0;_e.prototype._maxListeners=void 0;var Xg=10;function eu(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(_e,"defaultMaxListeners",{enumerable:!0,get:function(){return Xg},set:function(t){if(typeof t!="number"||t<0||hS(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Xg=t}});_e.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};_e.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||hS(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 pS(t){return t._maxListeners===void 0?_e.defaultMaxListeners:t._maxListeners}_e.prototype.getMaxListeners=function(){return pS(this)};_e.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[t];if(c===void 0)return!1;if(typeof c=="function")Qg(c,this,e);else for(var d=c.length,h=yS(c,d),n=0;n<d;++n)Qg(h[n],this,e);return!0};function mS(t,e,n,i){var r,s,a;if(eu(n),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),a===void 0)a=s[e]=n,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),r=pS(t),r>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,vx(c)}return t}_e.prototype.addListener=function(t,e){return mS(this,t,e,!1)};_e.prototype.on=_e.prototype.addListener;_e.prototype.prependListener=function(t,e){return mS(this,t,e,!0)};function yx(){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 fS(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=yx.bind(i);return r.listener=n,i.wrapFn=r,r}_e.prototype.once=function(t,e){return eu(e),this.on(t,fS(this,t,e)),this};_e.prototype.prependOnceListener=function(t,e){return eu(e),this.prependListener(t,fS(this,t,e)),this};_e.prototype.removeListener=function(t,e){var n,i,r,s,a;if(eu(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():Ex(n,r),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};_e.prototype.off=_e.prototype.removeListener;_e.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[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 gS(t,e,n){var i=t._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?Sx(r):yS(r,r.length)}_e.prototype.listeners=function(t){return gS(this,t,!0)};_e.prototype.rawListeners=function(t){return gS(this,t,!1)};_e.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):vS.call(t,e)};_e.prototype.listenerCount=vS;function vS(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}_e.prototype.eventNames=function(){return this._eventsCount>0?qd(this._events):[]};function yS(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function Ex(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Sx(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Tx(t,e){return new Promise(function(n,i){function r(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",r),n([].slice.call(arguments))}ES(t,e,s,{once:!0}),e!=="error"&&bx(t,r,{once:!0})})}function bx(t,e,n){typeof t.on=="function"&&ES(t,"error",e,n)}function ES(t,e,n,i){if(typeof t.on=="function")i.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function r(s){i.once&&t.removeEventListener(e,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class kx extends _{constructor(){super("message.v1.SocketMessage",[{no:1,name:"event",kind:"scalar",T:13},{no:2,name:"id",kind:"scalar",opt:!0,T:9},{no:3,name:"payload",kind:"scalar",opt:!0,T:12},{no:4,name:"metadata",kind:"scalar",opt:!0,T:12}])}}const Zg=new kx;class SS{static encode(e){return Zg.toBinary(e)}static decode(e){return Zg.fromBinary(new Uint8Array(e))}}function wx(t,e){return Math.floor(Math.random()*(e-t+1)+t)}var lr;class _x{constructor(e={}){fx(this,"opts"),Ve(this,lr,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},ke(this,lr,0)}wait(){return p(this,null,function*(){ke(this,lr,W(this,lr)+1);const e=wx(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*Oe(2,W(this,lr))));yield new Promise(n=>{setTimeout(n,e)})})}getAttempts(){return W(this,lr)}reset(){ke(this,lr,0)}}lr=new WeakMap;const Ki={debug:0,info:1,warn:2,error:3};var ns,is;class Ix{constructor(e){Ve(this,ns,void 0),Ve(this,is,void 0),ke(this,ns,console),ke(this,is,e)}debug(...e){Ki[W(this,is)]>Ki.debug||W(this,ns).debug("[Sockrates]:",...e)}info(...e){Ki[W(this,is)]>Ki.info||W(this,ns).info("[Sockrates]:",...e)}warn(...e){Ki[W(this,is)]>Ki.warn||W(this,ns).warn("[Sockrates]:",...e)}error(...e){Ki[W(this,is)]>Ki.error||W(this,ns).error("[Sockrates]:",...e)}}ns=new WeakMap,is=new WeakMap;var TS=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))(TS||{});const Cx="2",Rx="3";var Qe,oa,He,rt,ur,Tt,_i,Er,Wn,ca,Ei,_p,bS,Ho,Gd,Ip,kS,Cp,ev,_l,Rp,Pp,wS,ac,$d,oc,Il,Cl,Ap,Sa,cc,dc,Rl;class Px{constructor(e,n){var i;Ve(this,_p),Ve(this,Ho),Ve(this,Ip),Ve(this,Cp),Ve(this,_l),Ve(this,Pp),Ve(this,ac),Ve(this,oc),Ve(this,Cl),Ve(this,Sa),Ve(this,dc),Ve(this,Qe,void 0),Ve(this,oa,void 0),Ve(this,He,void 0),Ve(this,rt,void 0),Ve(this,ur,void 0),Ve(this,Tt,void 0),Ve(this,_i,void 0),Ve(this,Er,void 0),Ve(this,Wn,void 0),Ve(this,ca,void 0),Ve(this,Ei,void 0);var r,s,a,c,d,h,u,g,E;ke(this,oa,e),ke(this,ur,[]),ke(this,Tt,new wl),ke(this,_i,!0),ke(this,Wn,!1),ke(this,He,n!=null?n:{}),(r=W(this,He)).autoReconnect!=null||(r.autoReconnect=!0),(s=W(this,He)).retryConnectionInterval!=null||(s.retryConnectionInterval=1e3),(a=W(this,He)).pingTimeout!=null||(a.pingTimeout=3e4),(c=W(this,He)).connectionTimeout!=null||(c.connectionTimeout=5e3),(d=W(this,He)).debug!=null||(d.debug=!0),(h=W(this,He)).maxReconnectionAttempts!=null||(h.maxReconnectionAttempts=10),(u=W(this,He)).disconnectOnPingTimeout!=null||(u.disconnectOnPingTimeout=!0),(g=W(this,He)).queueOnDisconnect!=null||(g.queueOnDisconnect=!1),(E=W(this,He)).flushOnReconnect!=null||(E.flushOnReconnect=!1),ke(this,Er,{code:void 0,reason:void 0}),ke(this,rt,(i=W(this,He).logger)!=null?i:new Ix(W(this,He).debug?"debug":"info")),ke(this,Ei,new _x)}get readyState(){var e;return(e=W(this,Qe))==null?void 0:e.readyState}get url(){return W(this,oa)}updateURL(e){ke(this,oa,e),qe(this,Pp,wS).call(this)}get config(){return W(this,He)}get sendQueue(){return W(this,ur)}flush(){if(!W(this,He).queueOnDisconnect)return!1;const e=[];return W(this,ur).forEach(n=>{this.send(n.event,n.id,n.payload,n.metadata)||e.push(n)}),ke(this,ur,e),W(this,ur)}connect(e=!1){return p(this,null,function*(){if(!e&&[0,1].includes(this.readyState)){W(this,rt).debug("Websocket was already connecting or connected.");return}if(W(this,_i)!==!1)return new Promise((n,i)=>{qe(this,Sa,cc).call(this),qe(this,dc,Rl).call(this);try{ke(this,Qe,new WebSocket(qe(this,_p,bS).call(this,W(this,oa)))),W(this,Qe).binaryType="arraybuffer",W(this,rt).debug("Connecting");const r=setTimeout(()=>{W(this,rt).debug("Connection timeout. Closing socket"),ke(this,_i,!0),qe(this,dc,Rl).call(this),W(this,Qe).close(3001,"Connection Timeout"),W(this,He).autoReconnect&&!W(this,Wn)&&(W(this,Tt).emit("reconnecting"),qe(this,ac,$d).call(this)),i(new Error("Connection timed out!"))},W(this,He).connectionTimeout);W(this,Qe).onopen=()=>{W(this,rt).debug(`Ready State: ${TS[W(this,Qe).readyState]}`),r&&clearTimeout(r),qe(this,Cl,Ap).call(this),ke(this,Er,{code:void 0,reason:void 0}),W(this,Tt).emit("connected"),W(this,He).flushOnReconnect&&this.flush(),n()},W(this,Qe).onclose=s=>{try{r&&clearTimeout(r);const{code:a,reason:c}=s;i(c),W(this,rt).debug("Socket closed. Close event:",{event:s}),W(this,rt).debug(`Connection closed code: ${a}`),W(this,rt).debug(`Connection closed reason: ${c}`),W(this,Wn)||qe(this,_l,Rp).call(this,a,c)}catch(a){qe(this,Ho,Gd).call(this,a)}},W(this,Qe).onerror=s=>{qe(this,Ho,Gd).call(this,s)},W(this,Qe).onmessage=s=>qe(this,Ip,kS).call(this,s)}catch(r){qe(this,Ho,Gd).call(this,r,i)}})})}send(e,n,i,r){const s={event:e,id:n,payload:i,metadata:r};if(W(this,He).queueOnDisconnect&&(!W(this,Qe)||W(this,Qe).readyState!==1))return W(this,rt).debug("Queuing message since socket is not connected!",s),W(this,ur).push(s),!1;const a=SS.encode(s);return qe(this,oc,Il).call(this,a)}emit(e,n,i,r){return this.send(e,n,i,r)}sendRaw(e){return qe(this,oc,Il).call(this,e)}receive(e,n){return W(this,Tt).on(e.toString(),n)}on(e,n){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){W(this,Tt).on(e,n);return}this.receive(e,n)}removeAllListeners(){W(this,Tt).removeAllListeners()}removeReceiver(e,n){this.removeListener(e,n)}removeListener(e,n){W(this,Tt).removeListener(e.toString(),n)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){W(this,Tt).listeners(e.toString()).map(n=>this.removeListener(e,n))}disconnect(){ke(this,_i,!1),qe(this,Sa,cc).call(this),this.removeAllListeners(),ke(this,Er,{code:1e3,reason:"Sockrates disconnect method called"}),W(this,Qe).close(1e3,"Sockrates disconnect method called.")}}Qe=new WeakMap,oa=new WeakMap,He=new WeakMap,rt=new WeakMap,ur=new WeakMap,Tt=new WeakMap,_i=new WeakMap,Er=new WeakMap,Wn=new WeakMap,ca=new WeakMap,Ei=new WeakMap,_p=new WeakSet,bS=function(t){if(t.startsWith("ws://")||t.startsWith("wss://"))return t;if(t.startsWith("https://"))return`wss://${t.substring(8)}`;if(t.startsWith("http://"))return`ws://${t.substring(7)}`;throw new Error("Invalid URL. URL must start with http(s):// or ws(s)://.")},Ho=new WeakSet,Gd=function(t,e){W(this,rt).error("Error:",{error:t}),W(this,Tt).emit("errored",{error:t}),e==null||e(t)},Ip=new WeakSet,kS=function(t){if(qe(this,Cl,Ap).call(this),t.data===Cx){W(this,rt).debug("Received ping from server"),qe(this,oc,Il).call(this,Rx);return}const e=SS.decode(t.data),{id:n,payload:i}=e;W(this,rt).debug("Received message",{event:e.event,messageID:n}),W(this,Tt).emit(e.event.toString(),{id:n,payload:i})},Cp=new WeakSet,ev=function(){return W(this,Qe).readyState===1},_l=new WeakSet,Rp=function(t,e){ke(this,Er,{reason:e,code:t}),W(this,Tt).emit("disconnected",{code:t,reason:e})},Pp=new WeakSet,wS=function(){const{reason:t,code:e}=W(this,Er);e&&e!==1e3&&W(this,_i)&&W(this,He).autoReconnect&&!W(this,Wn)&&(W(this,rt).debug(`Triggering reconnection due to ${t}.`),W(this,Tt).emit("reconnecting"),qe(this,ac,$d).call(this))},ac=new WeakSet,$d=function(t=!0){return p(this,null,function*(){if(t&&W(this,Wn)){W(this,rt).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(W(this,Wn)||W(this,Ei).reset(),W(this,He).maxReconnectionAttempts!==null&&W(this,Ei).getAttempts()>=W(this,He).maxReconnectionAttempts){W(this,Tt).emit("failed"),ke(this,Wn,!1);return}ke(this,Wn,!0),qe(this,dc,Rl).call(this),qe(this,Sa,cc).call(this);try{if(yield W(this,Ei).wait(),W(this,_i)===!1)return;if(W(this,rt).debug(`Reconnection attempt ${W(this,Ei).getAttempts()}`),W(this,Tt).emit("reconnectAttempt",{attempt:W(this,Ei).getAttempts()}),yield this.connect(),!qe(this,Cp,ev).call(this))throw Error("Reconnect Failed");ke(this,Wn,!1),ke(this,Er,{code:void 0,reason:void 0}),W(this,Tt).emit("reconnected")}catch{W(this,rt).debug("Failed to reconnect."),W(this,Tt).emit("reconnectFailure",{attempt:W(this,Ei).getAttempts()}),qe(this,ac,$d).call(this,!1)}})},oc=new WeakSet,Il=function(t){try{return W(this,Qe).send(t),!0}catch(e){return W(this,rt).error(e.message),!1}},Cl=new WeakSet,Ap=function(){this.config.disconnectOnPingTimeout&&(W(this,rt).debug("Resetting ping timeout"),qe(this,Sa,cc).call(this),ke(this,ca,setTimeout(()=>{var t;W(this,rt).debug("Disconnecting the socket due to ping timeout"),ke(this,_i,!0);const e=3002,n="Ping timeout";(t=W(this,Qe))==null||t.close(e,n),qe(this,_l,Rp).call(this,e,n)},W(this,He).pingTimeout)))},Sa=new WeakSet,cc=function(){W(this,ca)&&(clearTimeout(W(this,ca)),ke(this,ca,void 0))},dc=new WeakSet,Rl=function(){W(this,Qe)&&(W(this,Qe).onopen=void 0,W(this,Qe).onerror=void 0,W(this,Qe).onmessage=void 0,W(this,Qe).onclose=void 0)};var Ax=Object.defineProperty,Mx=Object.getOwnPropertyDescriptor,tu=(t,e,n,i)=>{for(var r=i>1?void 0:i?Mx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ax(e,n,r),r};const tv=65535,Ox=3e3;var Fr,Ke,ze,et,Nn,zi,sd,Zu,ad,eh,nv;const _S=(nv=class{constructor(t,{peerId:e,meetingId:n,authToken:i,capabilities:r}){S(this,ze),S(this,sd),S(this,ad),S(this,Fr,void 0),S(this,Ke,void 0),y(this,"roomName"),y(this,"authToken"),y(this,"capabilities"),S(this,Nn,void 0),S(this,zi,void 0);var s;if(!e||!n||!i)throw new D("peerId, meetingId, or authToken can not be empty","0404");T(this,Nn,void 0),T(this,zi,t),this.capabilities=r,this.roomName=n,this.authToken=i,T(this,Fr,Q(this,sd,Zu).call(this,e)),T(this,Ke,new Px(o(this,Fr),{autoReconnect:!0,disconnectOnPingTimeout:(s=r.includes("PING"))!=null?s:!1,queueOnDisconnect:!0,flushOnReconnect:!1,logger:m})),this.handleSocketConnectionEvents()}get joinAttempted(){return o(this,ze,et).socketJoinAttempted}set joinAttempted(t){o(this,ze,et).socketJoinAttempted=t}get peerId(){return o(this,zi).getValue("peerId")}updateURL(t){t!==this.peerId&&(T(this,Fr,Q(this,sd,Zu).call(this,t)),m.debug("SocketService:: Connection URL updated.")),o(this,Ke).updateURL(o(this,Fr))}static getSocketEdgeDomain(t){return ga({servicePrefix:"socket-edge",baseURI:t})}get url(){return o(this,Fr)}connect(){return p(this,null,function*(){o(this,ze,et).socketJoinAttempted=!0,yield o(this,Ke).connect(),o(this,ze,et).socketJoinAttempted=!0,o(this,ze,et).socketState={state:"connected",reconnected:!1,reconnectionAttempt:void 0}})}disconnect(){return p(this,null,function*(){o(this,ze,et).socketJoinAttempted=!1,o(this,Ke).disconnect(),o(this,ze,et).socketJoinAttempted=!0,o(this,ze,et).socketState={state:"disconnected",reconnected:!1,reconnectionAttempt:void 0}})}get isConnected(){try{return o(this,Ke).readyState===1}catch{return!1}}sendMessage(t,e,n){const i={};return w.injectContext(i),o(this,Ke).send(t,n!=null?n:Q(this,ad,eh).call(this),e,new TextEncoder().encode(JSON.stringify(i)))}sendMessagePromise(t,e,n,i){const r=parseInt({}.SOCKET_SERVICE_MESSAGE_REQUEST_TIMEOUT,10)||2e4;return this.sendMessagePromiseWithTimeout({event:t,timeout:r,protobuf:e,messageId:n,resp:i})}sendMessagePromiseWithTimeout({event:t,timeout:e,protobuf:n,messageId:i,resp:r}){const s=r!=null?r:t;return new Promise((a,c)=>{const d=(b,k)=>{o(this,Ke).removeListener(s,b),o(this,Ke).removeListener(tv,k),o(this,Ke).removeListener(In.errorResponse,k),o(this,Ke).removeListener(Hn.errorResponse,k)},h=i!=null?i:Q(this,ad,eh).call(this),u={};w.injectContext(u);const g=({id:b,payload:k})=>{if(h===b){let A;try{const M=CA.fromBinary(k);A=new Error(M.errorMessage)}catch(M){A=new Error("failed to parse error message",{cause:M});try{const B=RM.fromBinary(k);A=new Error(B.message)}catch(B){A=new Error("failed to parse error message",{cause:B})}}c(A),d(E,g)}},E=({id:b,payload:k})=>{h===b&&(a({id:b,payload:k}),d(E,g))};o(this,Ke).on(s,E),o(this,Ke).on(tv,g),o(this,Ke).on(In.errorResponse,g),o(this,Ke).on(Hn.errorResponse,g),setTimeout(()=>{d(E,g),c(new Error(`request timeout for callback eventId:${t}`))},e),o(this,Ke).send(t,h,n,new TextEncoder().encode(JSON.stringify(u)))})}on(t,e){o(this,Ke).on(t,e)}onStateEvent(t,e){o(this,Ke).on(t,e)}removeListener(t,e){o(this,Ke).removeListener(t,e)}removeListeners(t){o(this,Ke).removeListeners(t)}flush(){return o(this,Ke).flush()}handleSocketConnectionEvents(){this.onStateEvent("connected",()=>p(this,null,function*(){m.info("SocketService::Connected to socket-edge"),o(this,Nn)&&(clearTimeout(o(this,Nn)),T(this,Nn,void 0)),o(this,ze,et).updateSocketConnectionState("connected")})),this.onStateEvent("disconnected",({code:t,reason:e})=>{var n;m.info("SocketService::Disconnected from socket-edge",{error:{code:t,reason:e},country:w.location.country});const{recv:i,send:r}=(n=o(this,ze,et).mediaState)!=null?n:{};i!=null&&i.state&&(i==null?void 0:i.state)!==wr.CONNECTED||r!=null&&r.state&&(r==null?void 0:r.state)!==wr.CONNECTED?L.emit(x.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,ze,et).joinAttempted}):T(this,Nn,setTimeout(()=>{L.emit(x.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,ze,et).joinAttempted}),T(this,Nn,void 0)},Ox)),o(this,ze,et).updateSocketConnectionState("disconnected")}),this.onStateEvent("reconnecting",()=>p(this,null,function*(){m.info("SocketService::Reconnecting to socket-edge",{country:w.location.country}),o(this,ze,et).updateSocketConnectionState("reconnecting")})),this.onStateEvent("reconnectAttempt",t=>p(this,[t],function*({attempt:e}){m.info("SocketService::Attempting to reconnect to socket-edge",{socket:{retryAttempt:e}}),o(this,ze,et).updateSocketConnectionState("reconnectAttempt",e)})),this.onStateEvent("reconnectFailure",({attempt:t})=>{m.info("SocketService::Reconnect attempt to socket-edge failed",{socket:{retryAttempt:t}}),o(this,ze,et).updateSocketConnectionState("reconnectFailure",t)}),this.onStateEvent("reconnected",()=>p(this,null,function*(){m.info("SocketService::Reconnected to socket-edge",{connectionState:{joinAttempted:o(this,ze,et).mediaJoinAttempted}}),o(this,Nn)&&(clearTimeout(o(this,Nn)),T(this,Nn,void 0)),L.emit(x.SOCKET_SERVICE_RECONNECTED,{wasJoinAttempted:o(this,ze,et).mediaJoinAttempted}),o(this,ze,et).updateSocketConnectionState("reconnected")})),this.onStateEvent("failed",()=>p(this,null,function*(){m.info("SocketService::Failed to connect to socket-edge",{country:w.location.country}),L.emit(x.SOCKET_SERVICE_FAILED),o(this,ze,et).updateSocketConnectionState("failed")}))}},Fr=new WeakMap,Ke=new WeakMap,ze=new WeakSet,et=function(){return o(this,zi).getValue("connectionHandler")},Nn=new WeakMap,zi=new WeakMap,sd=new WeakSet,Zu=function(t){let e=_S.getSocketEdgeDomain(o(this,zi).getValue("baseURI"));typeof ll(o(this,zi),"socket_server_base")=="string"&&(e=ll(o(this,zi),"socket_server_base"));const n=`wss://${e}`,i=new URL(`${n}/ws`),r=this.peerId,s=ee(H({roomID:this.roomName,peerID:t,authToken:this.authToken,useMediaV2:!0},r!==t&&{oldPeerID:r}),{ping:this.capabilities.includes("PING"),capabilities:this.capabilities.map(a=>ul[a]).join(" "),joinWithDetails:!0,useCfWorker:!0});return Object.entries(s).forEach(([a,c])=>{i.searchParams.append(a,c.toString())}),i.href},ad=new WeakSet,eh=function(){return`${this.peerId}-${(Math.random()+1).toString(36).substring(7)}`},nv);let Ic=_S;tu([w.trace("SocketService.connect")],Ic.prototype,"connect",1);tu([w.trace("SocketService.disconnect")],Ic.prototype,"disconnect",1);tu([w.trace("SocketService.sendMessagePromise")],Ic.prototype,"sendMessagePromise",1);tu([w.trace("SocketService.sendMessagePromiseWithTimeout")],Ic.prototype,"sendMessagePromiseWithTimeout",1);const rs=class{static handleConnectedRoomsDumpRaw({payload:t}){var e;const n=t1.fromBinary(t),i=n.meetings.map(r=>{var s;return{id:r.id,title:r.title,participants:(s=r.participants)!=null?s:[]}});return{parentMeeting:{id:n.parentMeeting.id,title:n.parentMeeting.title,participants:(e=n.parentMeeting.participants)!=null?e:[]},meetings:i}}static handleTransferPeerRaw({payload:t}){const e=C1.fromBinary(t);return{authToken:e.authToken,meetingId:e.meetingId}}static handleMovedPeerRaw({payload:t}){const e=uE.fromBinary(t);return{meetingId:e.meetingId,customParticipantId:e.customParticipantId}}static handleConnectedRoomsUpdatedRaw({payload:t}){return og.fromBinary(t).payloads.map(e=>({id:e.id,title:e.title}))}static handleConnectedRoomsDeletedRaw({payload:t}){return v1.fromBinary(t).payloads}static getConnectedRoomsDump(){return p(this,null,function*(){const t=yield rs.socketService.sendMessagePromise(Y.getConnectedRoomsDump);return rs.handleConnectedRoomsDumpRaw(t)})}static createConnectedRooms(t){return p(this,null,function*(){const{payload:e}=yield rs.socketService.sendMessagePromise(Y.createConnectedRooms,s1.toBinary({payloads:t}));return og.fromBinary(e).payloads.map(n=>({id:n.id,title:n.title}))})}static updateConnectedRooms(t){return p(this,null,function*(){})}static disableConnectedRooms(t){return p(this,null,function*(){const e=t.map(i=>({id:i})),n=yield rs.socketService.sendMessagePromise(Y.deleteConnectedRooms,f1.toBinary({payloads:e}));return rs.handleConnectedRoomsDeletedRaw(n)})}static movePeersBetweenRooms(t){return p(this,null,function*(){try{const e=yield rs.socketService.sendMessagePromise(Y.movePeers,k1.toBinary({sourceMeetingId:t.sourceMeetingId,destinationMeetingId:t.destinationMeetingId,participants:t.participants}));return new TextDecoder().decode(e.payload).includes("error")?{success:!1,error:"failed to move participants"}:{success:!0}}catch(e){return{success:!1,error:e}}})}};let $e=rs;y($e,"socketService"),y($e,"currentMeetingId");var Dx=Object.defineProperty,Nx=Object.getOwnPropertyDescriptor,nu=(t,e,n,i)=>{for(var r=i>1?void 0:i?Nx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Dx(e,n,r),r};const da=class{constructor(t,e){y(this,"apiBase"),y(this,"selfController"),y(this,"pollController"),y(this,"chatController"),y(this,"metaController"),y(this,"storesManager"),y(this,"stageController"),y(this,"pluginController"),y(this,"internalsController"),y(this,"recordingController"),y(this,"livestreamController"),y(this,"participantController"),this.apiBase=t,this.storesManager=e.storesManager,this.metaController=e.metaController,this.selfController=e.selfController,this.chatController=e.chatController,this.pollController=e.pollController,this.stageController=e.stageController,this.pluginController=e.pluginController,this.recordingController=e.recordingController,this.internalsController=e.internalsController,this.participantController=e.participantController,this.livestreamController=e.livestreamController}static init(t){return p(this,null,function*(){var e,n;const{peerId:i,apiBase:r,authToken:s,meetingId:a,organizationId:c,cachedUserDetails:d}=t.getAllValues();if(L.reset(),fl.cleanup(),lS(t),Be.isSupported()===!1)throw new D("Browser not supported","0010",!0);const h=BN(t,{authToken:s,baseURL:r,cachedUserDetails:d});h.setRoomName(a),h.setRoomUUID(a),h.setOrganizationId(c),h.setHeader("dyte-tracing-id",i),t.setValue("apiClient",h);const u=new TL;t.setValue("connectionHandler",u);const g=da.createSocketService(t),E=g.connect(),b=h.getUserDetails(),k=h.getPlugins();let A=bt.HIVE,M,B="";try{yield da.setupFlagsmith(t)}catch($){m.error("Failed to setup flagsmith",{error:$})}try{yield E}catch($){m.error("[Controller]: Failed to connect to socket server:",{error:$})}try{({sfu:A,meetingTitle:B}=yield h.getRoomNodeData()),M=yield b,m.info(`SFU ${A} is being used.`),t.setValue("presetName",M.preset.name),t.setValue("roomNodeOptions",{sfu:A})}catch($){m.error("Failed to get room metadata",{error:$})}const K=s2.init(M.preset,!t.getValue("modules").theme),X=da.setupControllers(g,t,M,k,B,K);lL(K)&&((e=da.createRoomNodeClient(t,g).partialJoinRoom(M.participant.name,a,void 0))==null||e.catch($=>{m.error("[Controller]: Failed to queue partial media room promise:",{error:$})})),w.location.country=(n=h.ipInfo)==null?void 0:n.country;const{controllers:O}=yield X;return hP(),new da(r,O)})}static setupFlagsmith(t){return p(this,null,function*(){var e;const{peerId:n,baseURI:i,overrides:r,meetingId:s,organizationId:a}=t.getAllValues(),c=lP(s),d=ee(H({entity:wh.PEER,clientId:a,isAnonUser:!a,sdkVersion:t.getValue("sdkVersion"),presetName:t.getValue("presetName"),meetingHash:c,roomName:s},Be.getDeviceInfo()),{isReactNative:navigator.isReactNative});try{const h=(e=r==null?void 0:r.whitelabelled_flags_endpoint)==null||e?ga({servicePrefix:"flags",baseURI:i}):"edge.api.flagsmith.com";yield se.identify(`${wh.PEER}_${n}`,JSON.parse(JSON.stringify(d)),!1,5e3,h,m),m.info("flagsmith::allFlags",{flags:JSON.stringify(se.getAllFlags())},!0)}catch{m.error("Failed to fetch flagsmith flags")}})}static setupControllers(t,e,n,i,r,s){return p(this,null,function*(){var a,c,d;const h=e.getValue("modules"),{preset:u,participant:g}=n,E=e.getValue("defaults"),{sfu:b}=e.getValue("roomNodeOptions"),{viewType:k,mediaConstraints:{audio:A}}=s;e.setValue("viewType",k),e.setValue("defaults",H({mediaConfiguration:{audio:{enableHighBitrate:(a=A.enableHighBitrate)!=null?a:!1,enableStereo:(c=A.enableStereo)!=null?c:!1}}},E));const M=I2.init(e,k,u.permissions);e.setValue("maxPreferredStreams",Be.isMobile()?s.maxVideoStreams.mobile:s.maxVideoStreams.desktop);let B,K,X,O,$,me,Ie,fe;const Je=new cx(t);$e.socketService=t;const ht=new Zl(t),V=new Cn(t),I=new ux(t),P=fl.create(t,e),z=new hx(t),ye=new ox(t),Xe=new Es(t),q=yield Pr.init(e,P,g,M,s),N=yield kE.init(e,q.self,P,Je,r);if(h.participant&&(fe=new Ni(e,q.self,P,b)),(d=h.e2ee)!=null&&d.enabled&&h.e2ee.manager.init(m,L),h.chat&&(K=yield Ci.init(e,V,Xe,q.self,fe.participants)),h.internals&&($=yield dm.init()),h.livestream&&s.viewType===Yt.Livestream&&se.hasFeature(ue.LIVESTREAM)&&(Ie=new OE(q.self,ye)),s.viewType!==Yt.Chat){if(h.poll&&(B=yield EE.init(e,q.self,ht)),h.recording&&(me=new CE(e,q.self,P)),h.stage&&(X=new wE(e,I,P,q.self,fe.participants)),h.plugin){if(!fe)throw new D("The plugin module cannot be initialized without the `participant` module","0102");const Pn=yield i;O=yield bc.init(e,Pn,z,V,K==null?void 0:K.chat,q.self,fe.participants,r)}if(h.pip){const Pn=yield fP._init(e,q.self);e.setValue("pip",Pn)}}const Ze={storesManager:new p2(e,z),pollController:B,selfController:q,metaController:N,chatController:K,stageController:X,pluginController:O,recordingController:me,internalsController:$,livestreamController:Ie,participantController:fe};return{theme:s,permissions:M,controllers:Ze}})}static createRoomNodeClient(t,e){const{peerId:n,roomNodeOptions:i}=t.getAllValues(),{sfu:r}=i;return dS(t,r,{socket:e,peerId:n})}static createSocketService(t){const{peerId:e,meetingId:n,authToken:i}=t.getAllValues(),r=["PING"];return new Ic(t,{peerId:e,meetingId:n,authToken:i,capabilities:r})}};let Cc=da;nu([w.trace("Controller.init")],Cc,"init",1);nu([w.trace("setupFlagsmith")],Cc,"setupFlagsmith",1);nu([w.trace("Controller.createRoomNodeClient")],Cc,"createRoomNodeClient",1);nu([w.trace("Controller.createSocketService")],Cc,"createSocketService",1);var Lx=Object.defineProperty,xx=Object.getOwnPropertyDescriptor,Vx=(t,e,n,i)=>{for(var r=i>1?void 0:i?xx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Lx(e,n,r),r},Jd,Mp;class IS extends gn{constructor(e,n){super(),S(this,Jd,void 0),y(this,"meetings",[]),y(this,"parentMeeting",null),S(this,Mp,void 0),T(this,Mp,e),T(this,Jd,n.self)}get supportsConnectedMeetings(){return o(this,Jd).id!==""}get isActive(){return this.meetings.length!==0}get currentMeetingId(){return $e.currentMeetingId}validateConnectedMeetingsAction(){if(!this.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
28
- Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`)}getConnectedMeetings(){return p(this,null,function*(){return this.validateConnectedMeetingsAction(),yield $e.getConnectedRoomsDump()})}createMeetings(e){return p(this,null,function*(){return this.validateConnectedMeetingsAction(),(yield $e.createConnectedRooms(e)).map(n=>({id:n.id,title:n.title}))})}updateMeetings(e){return p(this,null,function*(){this.validateConnectedMeetingsAction(),yield $e.updateConnectedRooms(e.map(n=>({meetingId:n.id,title:n.title})))})}deleteMeetings(e){return p(this,null,function*(){this.validateConnectedMeetingsAction();const n=this.meetings.map(i=>e.includes(i.id)&&i.participants.length!==0?this.moveParticipants(i.id,this.parentMeeting.id,i.participants.map(r=>r.id)):Promise.resolve());return yield Promise.all(n),yield $e.disableConnectedRooms(e)})}moveParticipants(e,n,i){return p(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield $e.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i.map(s=>({id:s}))});return r.success&&this.moveSuccessHandler(e,n,i),r})}moveParticipantsWithCustomPreset(e,n,i){return p(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield $e.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i});return r.success&&this.moveSuccessHandler(e,n,i.map(s=>s.id)),r})}moveSuccessHandler(e,n,i){const r=new Map;[...this.parentMeeting.participants,...this.meetings.flatMap(s=>s.participants)].forEach(s=>r.set(s.id,s)),n===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.concat(i.map(s=>r.get(s)))),e===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.filter(s=>!i.includes(s.id))),this.meetings=this.meetings.map(s=>{if(n===s.id){const a=s.participants.concat(i.map(c=>r.get(c)));return ee(H({},s),{participants:a})}if(e===s.id){const a=s.participants.filter(c=>!i.includes(c.id));return ee(H({},s),{participants:a})}return s})}}Jd=new WeakMap,Mp=new WeakMap;Vx([on({maxInvocations:60,period:60})],IS.prototype,"getConnectedMeetings",1);var Ux=Object.defineProperty,Bx=Object.getOwnPropertyDescriptor,Tm=(t,e,n,i)=>{for(var r=i>1?void 0:i?Bx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ux(e,n,r),r},ho,Ln,th,nh;const hr=(th=class{constructor(t,e,n){y(this,"connectedMeetings"),S(this,ho,void 0),S(this,Ln,void 0),S(this,nh,void 0),T(this,nh,t),T(this,ho,n),this.connectedMeetings=new IS(t,e),this.setCurrentMeeting(e)}static init(t,e,n){return hr.instance||(hr.instance=new hr(t,e,n)),hr.instance.connectedMeetings.supportsConnectedMeetings&&(hr.instance.setupEvents(),e.self.once("roomJoined",()=>hr.instance.getConnectedMeetings())),hr.instance}setCurrentMeeting(t){T(this,Ln,t),$e.currentMeetingId=t.meta.meetingId}getConnectedMeetings(){this.connectedMeetings.getConnectedMeetings()}setupEvents(){$e.socketService&&($e.socketService.on(Y.getConnectedRoomsDump,this.handleConnectedRoomsDump.bind(this)),$e.socketService.on(Y.transferPeer,this.handleTransferPeer.bind(this)),$e.socketService.on(Y.movedPeer,this.handleMovedPeer.bind(this)),$e.socketService.on(Y.connectedRoomsUpdated,this.handleConnectedRoomsUpdated.bind(this)),$e.socketService.on(Y.connectedRoomsDeleted,this.handleConnectedRoomsDeleted.bind(this)))}handleTransferPeer(t){const e=$e.handleTransferPeerRaw(t);return this.switchMeeting(e)}switchMeeting(t){return p(this,arguments,function*({authToken:e,meetingId:n}){var i,r,s,a;if(!this.connectedMeetings.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
29
- Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`);m.info("ConnectedMeetingsController::switchMeeting:: asking ui-kit to show switching breakout UI"),this.connectedMeetings.emit("changingMeeting",n);const c={video:o(this,Ln).self.videoEnabled,audio:o(this,Ln).self.audioEnabled};try{o(this,Ln).self.cleanupEvents(),yield o(this,Ln).leave("connected-meeting")}catch(h){m.error(`ConnectedMeetingsController:: switchMeeting:: issues in leaving previous meeting. Meeting Id: ${(r=(i=o(this,Ln))==null?void 0:i.meta)==null?void 0:r.meetingId}`,{error:h})}$e.socketService=void 0,m.info(`ConnectedMeetingsController::switchMeeting:: initializing new meeting. Meeting Id: ${n}`);const d=yield CS.init(ee(H({},o(this,ho)),{cachedUserDetails:null,defaults:ee(H(H({},o(this,ho).defaults),c),{mediaHandler:o(this,Ln).self}),authToken:e}));m.info(`ConnectedMeetingsController::switchMeeting:: initialized new meeting. Meeting Id: ${(s=d==null?void 0:d.meta)==null?void 0:s.meetingId}`);try{const{hidden:h}=o(this,Ln).self;d.self.setName(o(this,Ln).self.name),yield d.join(),h&&d.self.hide()}catch(h){m.error("ConnectedMeetingsController.joinRoom",{error:h})}return m.info(`ConnectedMeetingsController::switchMeeting:: asking ui-kit to show in-meeting ui of newly joined meeting id: ${(a=d==null?void 0:d.meta)==null?void 0:a.meetingId}`),this.connectedMeetings.emit("meetingChanged",d),this.setCurrentMeeting(d),d})}handleConnectedRoomsDump(t){const e=$e.handleConnectedRoomsDumpRaw(t);this.connectedMeetings.meetings=e.meetings.map(n=>({id:n.id,title:n.title,participants:n.participants||[]})),this.connectedMeetings.parentMeeting={id:e.parentMeeting.id,title:e.parentMeeting.title,participants:e.parentMeeting.participants},this.emitStateUpdate()}handleMovedPeer(t){return $e.handleMovedPeerRaw(t)}handleConnectedRoomsUpdated(t){const e=$e.handleConnectedRoomsUpdatedRaw(t),n=new Map;this.connectedMeetings.meetings.forEach(i=>{n.set(i.id,i)}),e.forEach(i=>{n.has(i.id)?n.get(i.id).title=i.title:n.set(i.id,ee(H({},i),{participants:[]}))}),this.connectedMeetings.meetings=Array.from(n.values()),this.emitStateUpdate()}handleConnectedRoomsDeleted(t){const e=$e.handleConnectedRoomsDeletedRaw(t).map(n=>n.id);this.connectedMeetings.meetings=this.connectedMeetings.meetings.filter(n=>!e.includes(n.id)),this.emitStateUpdate()}emitStateUpdate(){this.connectedMeetings.emit("stateUpdate",{meetings:this.connectedMeetings.meetings,parentMeeting:this.connectedMeetings.parentMeeting})}},ho=new WeakMap,Ln=new WeakMap,nh=new WeakMap,y(th,"instance"),th);let iu=hr;Tm([w.trace("ConnectedMeetingsController.getConnectedMeetings")],iu.prototype,"getConnectedMeetings",1);Tm([w.trace("ConnectedMeetingsController.setupEvents")],iu.prototype,"setupEvents",1);Tm([w.trace("ConnectedMeetingsController.switchMeeting")],iu.prototype,"switchMeeting",1);class Fx{constructor(){y(this,"battery"),y(this,"init",()=>p(this,null,function*(){try{"getBattery"in navigator&&(this.battery=yield navigator.getBattery(),this.battery.addEventListener("chargingchange",this.updateChargeInfo),this.battery.addEventListener("levelchange",this.updateLevelInfo),this.updateLevelInfo(),this.updateChargeInfo())}catch(e){m.error("Error getting battery",e)}})),y(this,"updateChargeInfo",()=>{var e;m.log(`Battery charging? ${(e=this.battery)!=null&&e.charging?"Yes":"No"}`)}),y(this,"updateLevelInfo",()=>{if(!this.battery){m.log("Battery level: Not known");return}m.log(`Battery level: ${this.battery.level*100}%`)}),y(this,"cleanup",()=>{var e,n;"getBattery"in navigator&&((e=this.battery)==null||e.removeEventListener("chargingchange",this.updateChargeInfo),(n=this.battery)==null||n.removeEventListener("levelchange",this.updateLevelInfo))})}}const iv=new Fx;function jx(t,e){t.startsWith("eyJ")||console.error("Invalid auth token provided. Ensure you are passing a %cparticipant `authToken`%c \u2014 not an Org API Key or an incorrectly formatted token.\nYou get the participant token from the Add Participant API: https://docs.dyte.io/api#/operations/add_participant","font-weight: bold","font-weight: normal");try{const{meetingId:n,orgId:i,participantId:r}=JSON.parse(atob(t.split(".")[1]));if(!n)throw Error(`Received V1 auth token ${t}`);let s="dyte.io";e&&(s=e);const a=`https://api.${s}`;return{meetingId:n,orgId:i,participantId:r,baseURI:s,apiBase:a}}catch(n){throw m.error("constants::decodeAuthToken",{error:n,debuggingHint:`Unable to decode auth token: ${t}`},!0),new D("Invalid auth token","0004")}}var Wx=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,ru=(t,e,n,i)=>{for(var r=i>1?void 0:i?Hx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Wx(e,n,r),r},Ct,od,cd,ih,rv,sv;let _r=(sv=class{constructor(t,e){S(this,ih),S(this,Ct,void 0),S(this,od,void 0),S(this,cd,void 0),T(this,cd,t),T(this,Ct,e)}static init(t){return p(this,null,function*(){var e,n,i,r,s,a,c;oP(),Be.init();const d=(n=(e=t==null?void 0:t.cachedUserDetails)==null?void 0:e.peerId)!=null?n:Ca();iv.init();const{authToken:h,baseURI:u}=t,g=jx(h,u),{meetingId:E}=g,b=Ml(g,["meetingId"]);window.__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION=!0;const k=_r.setupContext(d,t,E,b);w.meetingMetadata.roomName=E,w.meetingMetadata.userId=b.participantId,w.meetingMetadata.organizationId=b.orgId,w.init(k,(r=(i=t.modules)==null?void 0:i.tracing)!=null?r:!0),m.info("DyteClient::init::options",{dyteClientInitOptions:ee(H({},t),{authToken:`${(s=t.authToken)==null?void 0:s.slice(0,10)}...
30
- ${(a=t.authToken)==null?void 0:a.slice(-10)}`})});const A=yield Cc.init(k),M=new _r(k,A);return Q(c=M,ih,rv).call(c,t),M})}static setupContext(t,e,n,i){var r;const s=ms.createContext(t,e),a=H(H({},tP),e==null?void 0:e.modules);return s.setValue("peerId",t),s.setValue("modules",a),s.setValue("sdkName","web-core"),s.setValue("meetingId",n),s.setValue("apiBase",i.apiBase),s.setValue("baseURI",i.baseURI),s.setValue("userId",i.participantId),s.setValue("organizationId",i.orgId),s.setValue("authToken",e.authToken),s.setValue("overrides",(r=e.overrides)!=null?r:{}),s.setValue("env",nP({baseURI:i.baseURI})),s.setValue("defaults",e.defaults||{audio:!0,video:!0}),s.setValue("onError",e.onError||(()=>{})),s.setValue("cachedUserDetails",Gn(e.cachedUserDetails)),s.setValue("sdkVersion","VERSION_PLACEHOLDER"),s}join(){return p(this,null,function*(){const{selfController:t}=o(this,Ct);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return p(this,null,function*(){iv.cleanup();const{selfController:e}=o(this,Ct);return e.leaveRoom(t)})}get participants(){var t;return(t=o(this,Ct).participantController)==null?void 0:t.participants}get self(){var t;return(t=o(this,Ct).selfController)==null?void 0:t.self}get meta(){var t;return(t=o(this,Ct).metaController)==null?void 0:t.meta}get ai(){var t;return(t=o(this,Ct).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=o(this,Ct).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=o(this,Ct).chatController)==null?void 0:t.chat}get polls(){var t;return(t=o(this,Ct).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=o(this,od))==null?void 0:t.connectedMeetings}get recording(){var t;return(t=o(this,Ct).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=o(this,Ct).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=o(this,Ct).stageController)==null?void 0:t.stage}get stores(){return o(this,Ct).storesManager}get __internals__(){var t;return(t=o(this,Ct).internalsController)==null?void 0:t.internals}joinRoom(){return p(this,null,function*(){return this.join()})}leaveRoom(t){return p(this,null,function*(){return this.leave(t)})}},Ct=new WeakMap,od=new WeakMap,cd=new WeakMap,ih=new WeakSet,rv=function(t){T(this,od,iu.init(o(this,cd),this,t))},sv);ru([Lt("0002"),Rr.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],_r.prototype,"join",1);ru([Lt("0003")],_r.prototype,"leave",1);ru([Lt("0001"),Rr.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],_r,"init",1);_r=ru([Lt("0000")],_r);const CS=_r;class qx{constructor(e){Pc(this,"meeting");Pc(this,"l");Pc(this,"onUpdate",()=>{this.l.forEach(e=>{e()})});var n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K,X;this.meeting=e,this.l=new Set,(n=this.meeting.self)==null||n.addListener("*",this.onUpdate),(i=this.meeting.meta)==null||i.addListener("*",this.onUpdate),(r=this.meeting.participants)==null||r.addListener("*",this.onUpdate),(a=(s=this.meeting.participants)==null?void 0:s.joined)==null||a.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(u=(h=this.meeting.participants)==null?void 0:h.waitlisted)==null||u.addListener("*",this.onUpdate),(g=this.meeting.stage)==null||g.addListener("*",this.onUpdate),(E=this.meeting.livestream)==null||E.addListener("*",this.onUpdate),(b=this.meeting.chat)==null||b.addListener("*",this.onUpdate),(k=this.meeting.plugins)==null||k.all.addListener("*",this.onUpdate),(A=this.meeting.recording)==null||A.addListener("*",this.onUpdate),(M=this.meeting.connectedMeetings)==null||M.addListener("*",this.onUpdate),(B=this.meeting.spotlight)==null||B.addListener("*",this.onUpdate),(K=this.meeting.remote)==null||K.addListener("*",this.onUpdate),(X=this.meeting.polls)==null||X.addListener("*",this.onUpdate)}clean(){var e,n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K;(e=this.meeting.self)==null||e.removeListener("*",this.onUpdate),(n=this.meeting.meta)==null||n.removeListener("*",this.onUpdate),(i=this.meeting.participants)==null||i.removeListener("*",this.onUpdate),(s=(r=this.meeting.participants)==null?void 0:r.joined)==null||s.removeListener("*",this.onUpdate),(c=(a=this.meeting.participants)==null?void 0:a.active)==null||c.removeListener("*",this.onUpdate),(h=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||h.removeListener("*",this.onUpdate),(u=this.meeting.stage)==null||u.removeListener("*",this.onUpdate),(g=this.meeting.livestream)==null||g.removeListener("*",this.onUpdate),(E=this.meeting.chat)==null||E.removeListener("*",this.onUpdate),(b=this.meeting.plugins)==null||b.all.removeListener("*",this.onUpdate),(k=this.meeting.recording)==null||k.removeListener("*",this.onUpdate),(A=this.meeting.connectedMeetings)==null||A.removeListener("*",this.onUpdate),(M=this.meeting.spotlight)==null||M.removeListener("*",this.onUpdate),(B=this.meeting.remote)==null||B.removeListener("*",this.onUpdate),(K=this.meeting.polls)==null||K.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const su=zt.createContext({meeting:void 0,updates:void 0});function Gx({value:t,children:e,fallback:n}){const[i,r]=zt.useState(),s=zt.useRef();return zt.useEffect(()=>(t&&r(new qx(t)),()=>{var a;(a=s.current)==null||a.clean()}),[t]),xS.default.createElement(su.Provider,{value:{meeting:t,updates:i}},t?e:n)}const $x=()=>{const{meeting:t}=zt.useContext(su);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},Jx=t=>{const e=zt.useRef(!1),[n,i]=zt.useState(),r=t==null?void 0:t.resetOnLeave,s=zt.useCallback(async a=>{if(!e.current)return e.current=!0,CS.init(a).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return zt.useEffect(()=>{if(!n||!r)return()=>{};const a=({state:c})=>{c!=="connected-meeting"&&c!=="disconnected"&&i(void 0)};return n.self.on("roomLeft",a),()=>{n.self.removeListener("roomLeft",a)}},[n]),zt.useEffect(()=>{if(!n||!n.connectedMeetings)return()=>{};const a=c=>{i(void 0),setTimeout(()=>{i(c)},100)};return n.connectedMeetings.on("meetingChanged",a),()=>{n.connectedMeetings.removeListener("meetingChanged",a)}},[n]),[n,s]},Kx=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),zx=t=>{const{meeting:e,updates:n}=zt.useContext(su);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=zt.useRef(t(e)),[,r]=zt.useReducer(s=>s+1,0);return zt.useEffect(()=>{const s=e&&t(e),a=()=>{const c=e&&t(e);Kx(i.current,c)&&(i.current=c,r())};return s&&typeof s=="object"&&"addListener"in s?(s.addListener("*",r),()=>{s.removeListener("*",r)}):(n==null||n.addListener(a),()=>{n==null||n.removeListener(a)})},[e,n]),i.current};exports.RTKSelfMedia=UE;exports.RealtimeKitContext=su;exports.RealtimeKitProvider=Gx;exports.useRealtimeKitClient=Jx;exports.useRealtimeKitMeeting=$x;exports.useRealtimeKitSelector=zx;
26
+ maxEnergy: ${o(this,Xr)}`),r===-1/0||n<1e-6?{energy:0,isVoice:!1}:((!o(this,or)||r<o(this,or))&&T(this,or,r),(!o(this,Xr)||r>o(this,Xr))&&T(this,Xr,r),{energy:(r-o(this,or))/(o(this,Xr)-o(this,or))*10||0,isVoice:i})},Ud=new WeakSet,Ep=function(t){return t<5},Sp=new WeakSet,rS=function(t=o(this,ya)){var e;if(!o(this,ci)||!t){se.hasFeature(ue.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&m.debug(`AudioActivityReporter: No producerId or energy to report: ${o(this,ci)}`);return}const n={producerId:o(this,ci),energy:Math.round(t),silent:Q(e=kl,Ud,Ep).call(e,t)};T(this,sc,n.silent),this.reportRequest(n)},Xu=new WeakSet,zg=function(t){const e=Math.log10(t);return Math.round(e)},S(Tp,Ud),S(Tp,Xu);const tx=(t=!1)=>{const e=new window.AudioContext,n=e.createOscillator();n.type="triangle",n.frequency.setValueAtTime(20,e.currentTime);const i=e.createGain();i.gain.setValueAtTime(0,e.currentTime),n.connect(i);const r=e.createMediaStreamDestination();i.connect(r),n.start();const s=r.stream.getAudioTracks()[0];return s.enabled=t,s},nx=(t=!1)=>{var e,n;const i=new MediaStream().getVideoTracks()[0],r=document.createElement("canvas");r.height=(e=i==null?void 0:i.getSettings().height)!=null?e:720,r.width=(n=i==null?void 0:i.getSettings().width)!=null?n:1280;const s=r.getContext("2d");s.fillStyle="black",s.fillRect(0,0,r.width,r.height),setInterval(()=>{s.fillStyle="black",s.fillRect(0,0,r.width,r.height)},1e3);const a=r.captureStream().getVideoTracks()[0];return a.enabled=t,a};var ix=Object.defineProperty,rx=Object.getOwnPropertyDescriptor,Te=(t,e,n,i)=>{for(var r=i>1?void 0:i?rx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ix(e,n,r),r};const Xn=["video/VP9","video/VP8"];var Bd,Fd,Ht,te,Fo,Zr,rn,ta,na,es,jd,cr,jo,ia,ra,sn,hn,ts,sa,Ot,qt,aa,Wo,bp,sS,kp,aS,wp,oS;class Se{constructor(e,n,i){S(this,ts),S(this,Ot),S(this,aa),S(this,bp),S(this,kp),S(this,wp),y(this,"context"),y(this,"authToken"),y(this,"e2ee"),S(this,Bd,void 0),S(this,Fd,void 0),S(this,Ht,void 0),S(this,te,void 0),S(this,Fo,void 0),S(this,Zr,void 0),S(this,rn,void 0),S(this,ta,void 0),S(this,na,void 0),S(this,es,void 0),S(this,jd,void 0),S(this,cr,void 0),S(this,jo,void 0),S(this,ia,void 0),S(this,ra,void 0),S(this,sn,void 0),S(this,hn,void 0),y(this,"partialJoinRoomPromise");var r,s;this.context=e;const{socket:a}=i;this.mediaJoined=!1,T(this,ia,new Map([["video/VP9",new Set],["video/VP8",new Set]])),T(this,ra,new Map([["video/VP9",new Set],["video/VP8",new Set]])),T(this,Zr,n),T(this,Ht,a),T(this,ta,!1),T(this,te,new X2(e,a,n)),T(this,rn,o(this,te).events),T(this,cr,new Set),T(this,sn,new Map),T(this,na,!1),T(this,es,new gl),n===bt.CF&&!navigator.isReactNative&&T(this,hn,new Tp(o(this,te).socketHandler.audioActivity.bind(o(this,te).socketHandler))),this.e2ee=(s=(r=e.getValue("modules").e2ee)==null?void 0:r.enabled)!=null?s:!1,this.handleSocketEvents(),this.handleCallstatsEvents(),T(this,jd,cl(()=>p(this,null,function*(){if(!o(this,ts,sa).mediaJoinAttempted)return;const{roomJoined:c}=yield this.joinRoom(o(this,Fd),o(this,Bd),{},!0,!0);c&&(L.emit(x.RESET_PRODUCER_STATE),L.emit(x.ROOM_NODE_RECONNECTED))}),5e3,{leading:!0,maxWait:1e3}))}get peerId(){return this.context.getValue("peerId")}get mediaJoined(){return o(this,ts,sa).mediaJoined}set mediaJoined(e){o(this,ts,sa).mediaJoined=e}reset(e=!0){o(this,te).closeAllProducers(),o(this,te).closeAllConsumers(),o(this,sn).clear(),o(this,cr).clear(),e&&(this.partialJoinRoomPromise=void 0,o(this,es).stop(),o(this,te).stopAllTransports(),o(this,te).reset(),T(this,es,new gl))}joinRoom(e,n){return p(this,arguments,function*(i,r,s={},a=!1,c=!1){o(this,ts,sa).mediaJoinAttempted=!0,T(this,ta,!0),this.reset(a);const d=Pt().ipInfo;if(d!=null&&d.loc&&!o(this,jo)){const u=d.loc.split(",");T(this,jo,{latitude:parseFloat(u[0]),longitude:parseFloat(u[1])})}let h;try{return h=yield o(this,es).push(()=>this._joinRoom(i,r,s,c,o(this,jo)),"joinRoom"),h}catch{h={roomJoined:!1}}return h.roomJoined||L.emit(x.ROOM_NODE_FAILED),h})}_partialJoinRoom(e,n,i=!1,r=void 0){return p(this,null,function*(){var s;const{ipInfo:a}=Pt();let c=r;if(a!=null&&a.loc&&!r){const[u,g]=a.loc.split(",").map(parseFloat);c={latitude:u,longitude:g}}const d=(s=se.getValue(ue.FORCE_VIDEO_CODEC))==null?void 0:s.toString(),h=U2(d);T(this,Fo,h),yield mm((u,g)=>p(this,null,function*(){if(!o(this,Ht).isConnected){g(new Error("socket is not connected"));return}u>0&&m.warn(`retrying sending join room request, count: ${u}`);try{yield o(this,te).socketHandler.joinRoom(n,e,h,i,c)}catch(E){throw m.error("failed to send join room request, error:",{error:E}),E}}),{delayTime:1e3,strategy:"exponential",maxRetryCount:se.hasFeature(ue.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3}),yield o(this,te).setupTransports({send:!0,recv:!0}),o(this,Zr)!==bt.HIVE&&se.hasFeature(ue.PRECREATE_PRODUCERS)&&(this.shareWebcam(nx()),this.shareMic(tx()))})}partialJoinRoom(e,n,i=!1,r=void 0){return p(this,null,function*(){return this.partialJoinRoomPromise=o(this,es).push(()=>this._partialJoinRoom(e,n,i,r)),this.partialJoinRoomPromise})}_joinRoom(e,n){return p(this,arguments,function*(i,r,s={},a=!1,c=null){T(this,Fd,i);try{this.partialJoinRoomPromise?yield this.partialJoinRoomPromise:yield this._partialJoinRoom(i,r,a,c)}catch(d){m.error("error in partial join room",{error:d})}finally{this.partialJoinRoomPromise=void 0}try{return navigator.product!=="ReactNative"&&setTimeout(()=>p(this,null,function*(){const d={userId:this.context.getValue("userId"),peerId:this.peerId,roomUUID:r,roomViewType:"groupCall",deviceInfo:ee(H({},Be.getDeviceInfo()),{userAgent:navigator.userAgent,memory:navigator.deviceMemory,cpus:navigator.hardwareConcurrency}),sdkName:this.context.getValue("sdkName"),sdkVersion:this.context.getValue("sdkVersion"),metaData:{},permissions:{}};ne.roomJoined(d)})),{roomJoined:yield this.completeJoinRoom()}}catch(d){return m.error("error on sending join room request",{error:d}),{roomJoined:!1}}})}completeJoinRoom(){return p(this,null,function*(){try{this.mediaJoined=!0;const{roomState:e}=yield o(this,te).socketHandler.notifySelfJoinComplete();return T(this,Bd,e.roomUuid),T(this,na,!0),T(this,ta,!1),!0}catch(e){return m.error("error on completing join room:",{error:e}),this.mediaJoined=!1,!1}})}leaveRoom(){return p(this,null,function*(){o(this,te).stopAllTransports(),T(this,na,!1),o(this,ts,sa).mediaJoinAttempted=!1;const e={closeRoom:!1};o(this,Ht).sendMessagePromise(o(this,rn).leaveRoom,ZP.toBinary(e)).then(n=>{var i;(i=VA.fromBinary(n.payload))!=null&&i.closed||m.warn("weird state on peer closed and should not happen")}).catch(n=>{m.error("error on sending leave room request",{error:n})}),ne.callEnded(),w.destruct()})}getConsumers(){return o(this,te).consumers}activatePeers(e){return p(this,null,function*(){return this.createConsumers(e)})}deactivatePeers(e,n="default"){return p(this,null,function*(){const i=new Set;e.forEach(s=>{s.screenShare&&s.kind==="video"&&i.add(s.producingPeerId)});const r=n==="default"?e.filter(s=>!i.has(s.producingPeerId)).filter(s=>s.kind!=="audio"):e;yield Promise.all(r.map(s=>{const a=o(this,te).producerIdToConsumerIdMap.get(s.producerId);if(!a){m.warn(`consumer not found in deactivate producers: ${s.producerId}`);return}return o(this,te).closeConsumer(a)}))})}createConsumers(e){return p(this,null,function*(){return e.length===0?Promise.resolve():o(this,te).createConsumers(e)})}closeConsumers(e){return p(this,null,function*(){if(!e.length)return;const n=e.reduce((i,r)=>{const s=o(this,te).producerIdToConsumerIdMap.get(r.producerId);return s?(i.push(s),i):(m.warn(`consumer not found in deactivate producers: ${r.producerId}`),i)},[]);yield o(this,te).closeConsumers(n)})}_shareWebcam(e,n){return p(this,null,function*(){const i=n==="video/VP9"?De.WEBCAM:De.WEBCAM_BACKUP,r=Q(this,Ot,qt).call(this,i);if(r){const u=yield r;if(o(this,te).producers.has(u)){const g=o(this,te).producers.get(u);if(!g.closed&&!navigator.isReactNative)return yield g.replaceTrack({track:e}),yield this.resumeWebcam(i),e;yield this.disableWebcam(n)}return this._shareWebcam(e,n)}const s=Q(this,wp,oS).call(this,e,n),a=ll(this.context,"disableSimulcast"),c=o(this,Zr)===bt.CF?ue.ENABLE_CF_SIMULCAST:ue.ENABLE_HIVE_SIMULCAST;!a&&se.hasFeature(c)?(m.info(`Simulcast enabled for SFU: ${o(this,Zr)}`),s.encodings=NL(e)):m.info(`Simulcast disabled for webcam producer, SFU: ${o(this,Zr)}`),se.hasFeature(ue.TRACK_HINT)&&(s.track.contentHint=se.getValue(ue.TRACK_HINT));const d=()=>{m.info("Disabling video due to the producer closure"),o(this,sn).delete(i)},h=o(this,te).createProducer(s,d);return Q(this,aa,Wo).call(this,i,h.then(u=>u.id)),h.then(u=>u.track)})}shareWebcam(e){return p(this,null,function*(){if(e===void 0)return null;if(se.hasFeature(ue.FORCE_VIDEO_CODEC)){const n=se.getValue(ue.FORCE_VIDEO_CODEC).toString();if(n)return m.debug(`Calling _shareWebcam with forced video codec: ${n}`),this._shareWebcam(e,n)}return yield Promise.all(Xn.map(n=>{var i,r;return((r=(i=o(this,Fo).sender)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(s=>s.mimeType===n))>=0&&o(this,ra).get(n).size>0?(m.debug(`Calling _shareWebcam with video codec: ${n}`),this._shareWebcam(e,n)):e})),e})}shareScreen(e){return p(this,null,function*(){const{video:n,audio:i}=e;if(n===void 0)return;const r={track:n,codecOptions:[{name:"VP8"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Be.isElectron()},stopTracks:!1},s=()=>{m.info("Disabling screenShare due to the producer closure"),o(this,sn).delete(De.SCREENSHARE_VIDEO),o(this,sn).delete(De.SCREENSHARE_AUDIO)},a=o(this,te).createProducer(r,s);Q(this,aa,Wo).call(this,De.SCREENSHARE_VIDEO,a.then(d=>d.id));let c;if(i){const d={track:i,codecOptions:[{name:"opus"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Be.isElectron()},stopTracks:!1,zeroRtpOnPause:!0},h=()=>{};c=o(this,te).createProducer(d,h),Q(this,aa,Wo).call(this,De.SCREENSHARE_AUDIO,c.then(u=>u.id))}yield Promise.all([a,c||Promise.resolve()]),ne.screenShareStart()})}shareMic(e){return p(this,null,function*(){try{if(e===void 0)throw new an("track undefined");const n=Q(this,Ot,qt).call(this,De.MIC);if(n){const a=yield n;if(o(this,te).producers.has(a)){const c=o(this,te).producers.get(a);if(!c.closed&&!navigator.isReactNative){yield c.replaceTrack({track:e}),yield this.resumeMic(),o(this,hn)&&(o(this,hn).audioTrack=e,o(this,hn).producerId=a,o(this,hn).start());return}yield o(this,te).closeProducer(a,{stopTrack:!1})}yield this.shareMic(e);return}const i=Q(this,kp,aS).call(this,e),r=()=>{o(this,sn).delete(De.MIC)},s=o(this,te).createProducer(i,r);Q(this,aa,Wo).call(this,De.MIC,s.then(a=>a.id)),yield s.then(a=>{o(this,hn)&&(o(this,hn).audioTrack=a.track,o(this,hn).producerId=a.id,o(this,hn).start())})}catch(n){throw new D(n)}})}pauseMic(){return p(this,null,function*(){var e;const n=yield Q(this,Ot,qt).call(this,De.MIC),i=o(this,te).producers.get(n);if(!i){m.error("pauseMic::could_not_find_mic_producer");return}if(i.paused){m.info("pauseMic::mic_producer_already_paused");return}i.pause(),(e=o(this,hn))==null||e.stop();const r={producerId:i.id,pause:!0};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(r))})}pauseWebcam(){return p(this,null,function*(){const e=yield Q(this,Ot,qt).call(this,De.WEBCAM),n=yield Q(this,Ot,qt).call(this,De.WEBCAM_BACKUP),i=o(this,te).producers.get(e),r=o(this,te).producers.get(n);if(!i&&!r){m.error("pauseWebcam::could_not_find_webcam_producer");return}const s=a=>{const c={producerId:a.id,pause:!0};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(c))};i&&(i.pause(),s(i)),r&&(r.pause(),s(r))})}resumeMic(){return p(this,null,function*(){const e=yield Q(this,Ot,qt).call(this,De.MIC),n=o(this,te).producers.get(e);if(!n){m.error("resumeMic::could_not_find_mic_producer");return}if(!n.pause){m.info("resumeMic::mic_producer_already_resumed");return}n.resume(),n.appData.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,n);const i={producerId:n.id,pause:!1};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(i))})}resumeWebcam(){return p(this,arguments,function*(e=De.WEBCAM){const n=yield Q(this,Ot,qt).call(this,e),i=o(this,te).producers.get(n);if(!i){m.error("resumeWebcam::could_not_find_webcam_producer");return}if(!i.paused){m.info("resumeWebcam::webcam_producer_already_resumed");return}i.resume(),i.appData.e2ee&&L.emit(x.E2EE_ACTIVE_PRODUCER,i);const r={producerId:i.id,pause:!1};o(this,Ht).sendMessage(o(this,rn).toggleProducer,Uc.toBinary(r))})}disableWebcam(e){return p(this,null,function*(){const n=e==="video/VP9"?De.WEBCAM:De.WEBCAM_BACKUP,i=yield Q(this,Ot,qt).call(this,n);Q(this,bp,sS).call(this,n),i&&(yield o(this,te).closeProducer(i))})}disableMic(){return p(this,null,function*(){var e;const n=yield Q(this,Ot,qt).call(this,De.MIC);n&&(yield o(this,te).closeProducer(n)),(e=o(this,hn))==null||e.stop(),o(this,sn).delete(De.MIC)})}disableScreenShare(){return p(this,null,function*(){m.info("screen_sharing_stopped"),ne.screenShareStop();const e=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_VIDEO),n=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_AUDIO);e&&(yield o(this,te).closeProducer(e)),n&&(yield o(this,te).closeProducer(n)),o(this,cr).clear(),o(this,sn).delete(De.SCREENSHARE_VIDEO),o(this,sn).delete(De.SCREENSHARE_AUDIO)})}muteSelf(){return p(this,null,function*(){this.pauseMic()})}unmuteSelf(){return p(this,null,function*(){})}resetVideoProducers(e,n){return p(this,null,function*(){if(e){const i=yield Q(this,Ot,qt).call(this,De.WEBCAM),r=yield Q(this,Ot,qt).call(this,De.WEBCAM_BACKUP);yield o(this,te).closeProducer(i,{stopTrack:!1}),yield o(this,te).closeProducer(r,{stopTrack:!1}),this.shareWebcam(e)}if(n){const i=yield Q(this,Ot,qt).call(this,De.SCREENSHARE_VIDEO);yield o(this,te).closeProducer(i,{stopTrack:!1}),this.shareScreen({video:n})}})}changeDisplayName(e,n){return p(this,null,function*(){const i={displayName:e,participantId:n!=null?n:this.peerId};if(!(yield o(this,te).socketHandler.changeDisplayName(i)))throw new Error("failed to change display name!")})}kick(e){const n={peerIds:[e]};o(this,te).socketHandler.kickPeer(n)}kickAll(){o(this,te).socketHandler.kickAll()}muteAll(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForAll("audio")))throw new Error("failed to mute all participant")})}muteAllVideo(){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForAll("video")))throw new Error("failed to mute all video participant")})}disableAudio(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForPeer(e,"audio")))throw new Error("failed to mute given participant")})}disableVideo(e){return p(this,null,function*(){if(!(yield o(this,te).socketHandler.hostControlForPeer(e,"video")))throw new Error("failed to mute video of given participant")})}pinPeer(e){return p(this,null,function*(){const n={participantId:e!=null?e:""};try{yield o(this,Ht).sendMessagePromise(o(this,rn).globalPinPeer,dA.toBinary(n))}catch(i){m.error("Error in pinning peer:",{error:i})}})}validateScreenShare(e){return this.peerId===e.peerId&&o(this,te).producers.get(e.producerId)&&o(this,cr).add(e.consumerPeerId),o(this,cr).size}switchConsumersToLayer(e,n){return p(this,null,function*(){o(this,te).switchConsumersToLayer(e,n)})}handleSocketEvents(){return p(this,null,function*(){o(this,Ht).on(o(this,rn).peerProducerCreateBroadcast,({payload:e})=>{var n,i;if(this.mediaJoined)try{const{participantId:r,producerState:s}=pM.fromBinary(e);if(r===this.peerId)return;if(s!=null&&s.mimeType||(s.mimeType=s.kind===di.AUDIO?"audio/opus":"video/VP8"),s.kind===di.VIDEO&&!s.screenShare&&((i=(n=o(this,Fo).receiver)==null?void 0:n.video)==null?void 0:i.codecs.findIndex(a=>a.mimeType===Xn[0]))>=0&&o(this,ia).get(Xn[0]).has(r)&&s.mimeType!==Xn[0]){m.warn(`Ignoring producer: ${s.producerId}`);return}m.info(`producer created broadcast: ${r}, producer state: ${s}`),L.emit(x.NEW_PRODUCER,{peerId:r,producer:ee(H({},s),{kind:s.kind===di.AUDIO?"audio":"video",producingPeerId:r})})}catch(r){m.error("error in peer-producer-create-broadcast",{error:r})}}),o(this,Ht).on(o(this,rn).peerProducerToggleBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,initiatorParticipantId:i,producerState:{kind:r,pause:s,producerId:a}}=tg.fromBinary(e),c=r===di.AUDIO?"audio":"video";if(m.info(`producer toggle broadcast: ${n}, producerId: ${a}, kind:${c}, paused:${s} payload: ${JSON.stringify(tg.fromBinary(e))}`),n===this.peerId&&i!==this.peerId&&s&&L.emit(c==="audio"?x.MUTE_SELF:x.MUTE_SELF_VIDEO),n===this.peerId)return;L.emit(x.PRODUCER_TOGGLE,{peerId:n,producerId:a,paused:s,kind:c}),Array.from(this.getConsumers().values()).filter(d=>d.producerId===a).forEach(d=>{d.paused!==s&&(m.debug(`consumer state mismatched for ${d.id}. updating consumer pause state ${d.paused} to ${s}`),s?(d.pause(),L.emit(x.CONSUMER_PAUSED,{id:d.id})):(d.resume(),L.emit(x.CONSUMER_RESUMED,{id:d.id})))})}catch(n){m.error("error in producer toggle broadcast handler",{error:n})}}),o(this,Ht).on(o(this,rn).peerLeaveBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n}=Ch.fromBinary(e);if(n===this.peerId)return;m.info(`peer left broadcast:${n}`),o(this,cr).delete(n),o(this,te).consumers.forEach(i=>{i.peerId===n&&i.close()}),L.emit(x.PEER_CLOSED,{id:n})}catch(n){m.error("error in peer left broadcast",{error:n})}}),o(this,Ht).on(o(this,rn).peerProducerCloseBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,producerState:{producerId:i}}=gM.fromBinary(e);if(n===this.peerId)return;m.info(`producer closed broadcast:${n}`),L.emit(x.PRODUCER_CLOSED,{peerId:n,producerId:i});const r=o(this,te).producerIdToConsumerIdMap.get(i);if(!r){m.warn(`no consumer found for producer:${i}`);return}m.info(`closing consumer ${r}, producer id: ${i}`),o(this,te).closeConsumer(r).then(()=>{m.info(`closed consumer: ${r}`),o(this,te).producerIdToConsumerIdMap.delete(i),L.emit(x.CONSUMER_CLOSED,{id:r})}).catch(s=>{m.error("error closing consumer",{error:s})})}catch(n){m.error("error on producer close broadcast",{error:n})}}),o(this,Ht).on(o(this,rn).mediaRoomTerminationBroadcastResponse,()=>{!this.mediaJoined&&!o(this,ta)&&!o(this,na)||(m.warn("media hub termination broadcast received, rejoining room"),L.emit(x.ROOM_NODE_DISCONNECTED),o(this,jd).call(this))})})}handleCallstatsEvents(){ne.onConsumerScore(e=>{e.forEach((n,i)=>{const r=o(this,te).consumers.get(i);r&&L.emit(x.CONSUMER_SCORE_UPDATE,{id:i,kind:r.kind,peerId:r.peerId,score:n.score,scoreStats:n})})}),ne.onProducerScore(e=>{e.forEach((n,i)=>{const r=Array.from(o(this,te).producers.values()).find(s=>s.id===i);r&&L.emit(x.PRODUCER_SCORE_UPDATE,{id:i,kind:r.kind,appData:r.appData,score:n.score,scoreStats:n})})})}handlePeerCapabilities(e,n){var i,r,s,a;for(let c=0;c<=Xn.length;c+=1){const d=Xn[c];if(((r=(i=n==null?void 0:n.receiver)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(h=>h.mimeType===d))>=0||c===Xn.length-1){o(this,ra).get(d).add(e);break}}for(let c=0;c<=Xn.length;c+=1){const d=Xn[c];if(((a=(s=n==null?void 0:n.sender)==null?void 0:s.video)==null?void 0:a.codecs.findIndex(h=>h.mimeType===d))>=0||c===Xn.length-1){o(this,ia).get(d).add(e);break}}}handlePeerLeaving(e){se.hasFeature(ue.FORCE_VIDEO_CODEC)||(o(this,ia).forEach(n=>n.delete(e)),o(this,ra).forEach((n,i)=>{n.delete(e),n.size===0&&this.disableWebcam(i)}))}}Bd=new WeakMap,Fd=new WeakMap,Ht=new WeakMap,te=new WeakMap,Fo=new WeakMap,Zr=new WeakMap,rn=new WeakMap,ta=new WeakMap,na=new WeakMap,es=new WeakMap,jd=new WeakMap,cr=new WeakMap,jo=new WeakMap,ia=new WeakMap,ra=new WeakMap,sn=new WeakMap,hn=new WeakMap,ts=new WeakSet,sa=function(){return this.context.getValue("connectionHandler")},Ot=new WeakSet,qt=function(t){return o(this,sn).get(t)},aa=new WeakSet,Wo=function(t,e){return o(this,sn).set(t,e)},bp=new WeakSet,sS=function(t){return o(this,sn).delete(t)},kp=new WeakSet,aS=function(t){return{track:t,encodings:[{priority:"high"}],codecOptions:[{name:"opus"}],appData:{e2ee:this.e2ee},stopTracks:!1,zeroRtpOnPause:!0}},wp=new WeakSet,oS=function(t,e){return{track:t,codecOptions:[{name:e?e.split("/")[1]:"VP8"}],appData:{screenShare:!1,e2ee:this.e2ee},stopTracks:!1}};Te([w.trace("MediaNodeClient.reset",{country:w.location.country})],Se.prototype,"reset",1);Te([w.trace("MediaNodeClient.joinRoom")],Se.prototype,"joinRoom",1);Te([w.trace("MediaNodeClient.completeJoinRoom")],Se.prototype,"completeJoinRoom",1);Te([w.trace("MediaNodeClient.leaveRoom")],Se.prototype,"leaveRoom",1);Te([w.trace("MediaNodeClient.activatePeers")],Se.prototype,"activatePeers",1);Te([w.trace("MediaNodeClient.deactivatePeers")],Se.prototype,"deactivatePeers",1);Te([w.trace("MediaNodeClient.createConsumers")],Se.prototype,"createConsumers",1);Te([w.trace("MediaNodeClient.closeConsumers")],Se.prototype,"closeConsumers",1);Te([w.trace("MediaNodeClient._shareWebcam")],Se.prototype,"_shareWebcam",1);Te([w.trace("MediaNodeClient.shareWebcam")],Se.prototype,"shareWebcam",1);Te([w.trace("MediaNodeClient.shareScreen")],Se.prototype,"shareScreen",1);Te([w.trace("MediaNodeClient.shareMic")],Se.prototype,"shareMic",1);Te([w.trace("MediaNodeClient.pauseMic")],Se.prototype,"pauseMic",1);Te([w.trace("MediaNodeClient.pauseWebcam")],Se.prototype,"pauseWebcam",1);Te([w.trace("MediaNodeClient.resumeMic")],Se.prototype,"resumeMic",1);Te([w.trace("MediaNodeClient.resumeWebcam")],Se.prototype,"resumeWebcam",1);Te([w.trace("MediaNodeClient.disableWebcam")],Se.prototype,"disableWebcam",1);Te([w.trace("HiveClient.disableMic")],Se.prototype,"disableMic",1);Te([w.trace("HiveClient.disableScreenShare")],Se.prototype,"disableScreenShare",1);Te([w.trace("MediaNodeClient.muteSelf")],Se.prototype,"muteSelf",1);Te([w.trace("MediaNodeClient.resetVideoProducers")],Se.prototype,"resetVideoProducers",1);Te([w.trace("MediaNodeClient.changeDisplayName")],Se.prototype,"changeDisplayName",1);Te([w.trace("MediaNodeClient.kickPeer")],Se.prototype,"kick",1);Te([w.trace("MediaNodeClient.kickAllPeers")],Se.prototype,"kickAll",1);Te([w.trace("MediaNodeClient.muteAll")],Se.prototype,"muteAll",1);Te([w.trace("MediaNodeClient.muteAllVideo")],Se.prototype,"muteAllVideo",1);Te([w.trace("MediaNodeClient.disableAudio")],Se.prototype,"disableAudio",1);Te([w.trace("MediaNodeClient.disableVideo")],Se.prototype,"disableVideo",1);Te([w.trace("MediaNodeClient.pinPeer")],Se.prototype,"pinPeer",1);Te([w.trace("MediaNodeClient.validateScreenShare")],Se.prototype,"validateScreenShare",1);function cS(t,e,n){const i=t.getValue("roomNodeClient");if(i){if(i)return i;throw new Error("Room node client already set up.")}const r=new Se(t,e,n);return t.setValue("roomNodeClient",r),r}function dS(t){const e=t.getValue("roomNodeClient");try{e==null||e.leaveRoom()}catch{m.error("roomNodeClient::cleanupRoomNodeClient")}t.setValue("roomNodeClient",void 0)}var sx=Object.defineProperty,ax=Object.getOwnPropertyDescriptor,As=(t,e,n,i)=>{for(var r=i>1?void 0:i?ax(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&sx(e,n,r),r},Br,Zn,Bt,bn,Dn,Yg;const lS=(Yg=class{constructor(t,e,n,i){S(this,bn),y(this,"self"),y(this,"authToken"),S(this,Br,void 0),y(this,"viewType"),S(this,Zn,void 0),S(this,Bt,void 0);const{socket:r}=n,s=t.getValue("authToken");this.self=e,T(this,Bt,t),this.viewType=i,this.authToken=s,T(this,Br,r),T(this,Zn,n),e.config.viewType!==Yt.Chat&&this.setupEvents()}get peerId(){return o(this,Bt).getValue("peerId")}get mediaJoined(){return o(this,Bt).getValue("connectionHandler").mediaJoined}static init(t,e,n,i,r){return p(this,null,function*(){const s=Pt(),a=t.getValue("peerId"),c=!!t.getValue("cachedUserDetails"),d=yield wt.__init__(t,n,i,r,r.name,c);if(navigator.product!=="ReactNative"){const h=!se.hasFeature(ue.PRECALL_BANDWIDTH_TEST);setTimeout(()=>p(this,null,function*(){const u=yield d.getAllDevices();m.info("populated_full_device_list",{devices:JSON.stringify(u)}),ne.devices("AUDIO",u==null?void 0:u.filter(g=>g.kind==="audioinput")),ne.devices("VIDEO",u==null?void 0:u.filter(g=>g.kind==="videoinput")),ne.devices("SPEAKER",u==null?void 0:u.filter(g=>g.kind==="audiooutput")),m.info("Callstats:: initializing");try{yield ne.initialize({peerId:a,engineName:Be.getDeviceInfo().engineName,env:t.getValue("env"),iceServers:yield s.getICEServers(),apiBase:t.getValue("apiBase"),flags:se.getAllFlags(),logger:m,apiHostnames:Zy(t),skipConnectivityChecks:h}),m.info("Callstats:: initialized")}catch(g){m.error("Callstats:: initialization failed",{error:g})}}),0)}else m.info("Callstats:: Skipped initialization due to navigator product being ReactNative.");return new lS(t,d,e,r.viewType)})}shareMediaTracks(){return p(this,null,function*(){var t;const{audioTrack:e,videoTrack:n,permissions:i,audioEnabled:r,videoEnabled:s,screenShareEnabled:a,screenShareTracks:c}=this.self;if(i.canProduceAudio&&r)try{yield o(this,bn,Dn).shareMic(e)}catch{this.self.disableAudio()}if(i.canProduceVideo&&s)try{const d=yield o(this,bn,Dn).shareWebcam(n);d&&d.id!==n.id&&se.hasFeature(ue.EXP_RESHARE)&&(yield o(this,bn,Dn).shareWebcam(d))}catch{this.self.disableVideo()}if(i.canProduceScreenshare&&a)try{yield(t=o(this,bn,Dn))==null?void 0:t.shareScreen({video:c.video,audio:c.audio})}catch{this.self.disableScreenShare()}})}kickHandler(t){return p(this,null,function*(){let e="kicked";(t==null?void 0:t.kickType)==="kickAll"&&(e="ended"),this.leaveRoom(e)})}waitlistedHandler(){m.info("SelController.waitlisted"),this.self.waitlistStatus="waiting",this.self.roomState="waitlisted",this.self.emit("waitlisted")}waitlistAcceptHandler(){if(m.info("SelController.waitlistAccepted"),this.self.waitlistStatus==="accepted"){m.warn("SelfController.WAITLIST_ACCEPTED.UserAlreadyAccepted");return}this.self.waitlistStatus="accepted",this.joinRoom()}waitlistRejectedHandler(){if(m.info("SelfController.waitlistRejected"),this.self.waitlistStatus==="rejected"){m.warn("SelfController.WAITLIST_REJECTED.UserAlreadyRejected");return}this.self.waitlistStatus="rejected",this.leaveRoom("rejected")}resetSelf(t){return p(this,null,function*(){ne.callEnded(),o(this,bn,Dn).reset(),t&&(yield this.joinRoom(t))})}setupEvents(){L.on(x.RESET_PRODUCER_STATE,()=>p(this,null,function*(){this.mediaJoined&&this.shareMediaTracks()})),L.on(x.ROOM_NODE_RECONNECTED,()=>{this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:!0})}),L.on(x.ROOM_NODE_DISCONNECTED,()=>{this.self.roomState!=="disconnected"&&(this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"}))}),L.on(x.ROOM_NODE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),L.on(x.SOCKET_SERVICE_RECONNECTED,({wasJoinAttempted:t})=>{t===!1&&(this.self.roomState="init"),this.resetSelf(t)}),L.on(x.SOCKET_SERVICE_DISCONNECTED,({joinAttempted:t})=>{if(this.self.roomState==="disconnected")return;let{peerId:e}=this;t&&se.hasFeature(ue.REFRESH_ID_ON_DISCONNECTION)&&(e=Ca()),o(this,Br).updateURL(e),w.resetPeerId(e),Pt().setHeader("dyte-tracing-id",e),ms.remapContext(e,o(this,Bt)),this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"})}),L.on(x.SOCKET_SERVICE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),o(this,Zn).on(Y.waitingRoomRequestAccepted,()=>{this.waitlistAcceptHandler()}),o(this,Zn).on(vd.updateUserPreset,t=>{t.updatePeersPresets.forEach(e=>{e.userIds===this.self.userId&&L.emit(x.UPDATE_PERMISSIONS,e.patch)})}),o(this,Zn).on(Y.waitingRoomRequestDenied,()=>{this.waitlistRejectedHandler()}),o(this,Zn).on(Y.kick,()=>{this.kickHandler({kickType:"kick"})}),o(this,Zn).on(Y.kickAll,()=>{this.kickHandler({kickType:"kickAll"})}),L.onAsync(x.JOIN_MEDIA_ROOM,this.joinMediaRoom.bind(this)),L.on(x.PRODUCER_SCORE_UPDATE,({score:t,kind:e,appData:n,scoreStats:i})=>{var r;const s=(r=n==null?void 0:n.screenShare)!=null?r:!1;this.self.emit("mediaScoreUpdate",{kind:e,isScreenshare:s,score:t,participantId:this.self.id,scoreStats:i})}),L.on(x.MUTE_SELF,()=>p(this,null,function*(){this.self.audioEnabled&&(yield this.self.disableAudio(),ne.audioOff())})),L.on(x.MUTE_SELF_VIDEO,()=>p(this,null,function*(){this.self.videoEnabled&&(yield this.self.disableVideo(),ne.videoOff())})),L.onAsync(x.LEAVE_MEDIA_ROOM,this.leaveMediaRoom.bind(this)),L.on(x.PIP_HANGUP,this.leaveRoom.bind(this))}joinRoom(t=!1){return p(this,null,function*(){try{const{peer:e}=yield o(this,Zn).joinRoom(this.self);o(this,Zn).socket.flush();const n=om(e.stageType);if(o(this,Bt).setValue("stageStatus",n,!1),e.waitlisted){this.waitlistedHandler();return}yield this.joinMediaRoom(t),o(this,Bt).notify("stageStatus")}catch(e){throw m.error("Error in joinRoom",{error:e}),e}})}leaveRoom(t="left"){return p(this,null,function*(){var e,n;if(t==="rejected"){try{(e=o(this,Br))==null||e.disconnect()}catch{m.error("SelfController::leaveRoom::socketDisconnect")}this.self.roomState=t,this.self.emit("roomLeft",{state:t});return}this.self.setIsPinned(!1),o(this,Bt).setValue("stageStatus","OFF_STAGE",!1),yield this.leaveMediaRoom(t),o(this,Bt).notify("stageStatus");try{(n=o(this,Br))==null||n.disconnect()}catch{m.error("SelfController::leaveRoom::socketDisconnect")}dS(o(this,Bt)),fl.cleanup(),this.self.roomState=t,this.self.emit("roomLeft",{state:t})})}joinMediaRoom(t=!1){return p(this,null,function*(){var e,n;const{peerId:i,viewType:r,meetingId:s,stageStatus:a,roomNodeOptions:c}=o(this,Bt).getAllValues(),{sfu:d}=c;try{if(r===Yt.Livestream){if(a!=="ON_STAGE"){this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t});return}cS(o(this,Bt),d,{socket:o(this,Br),peerId:i})}const{roomJoined:h}=(n=yield(e=o(this,bn,Dn))==null?void 0:e.joinRoom(this.self.name,s,{audio:this.self.audioEnabled,video:this.self.videoEnabled,screen:this.self.screenShareEnabled},t,t))!=null?n:{};if(!h)return;a==="ON_STAGE"&&(yield this.shareMediaTracks()),this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t})}catch(h){throw m.error("Error:SelfController.mediaRoomJoin",{error:h}),new D("Error: could not join media room","0002")}})}leaveMediaRoom(t){return p(this,null,function*(){const e=o(this,Bt).getValue("viewType");t!=="connected-meeting"&&(yield this.cleanupSelf()),!(t==="stageLeft"&&e===Yt.Webinar)&&o(this,bn,Dn)&&(o(this,bn,Dn).mediaJoined&&t!=="disconnected"&&(yield o(this,bn,Dn).leaveRoom()),!(t==="stageLeft"&&e===Yt.Livestream)&&(o(this,bn,Dn).mediaJoined=!1))})}cleanupSelf(){return p(this,null,function*(){yield this.self.disableAudio(),yield this.self.disableVideo(),yield this.self.disableScreenShare(),this.self.cleanUpTracks(),this.self.destructMediaHandler(),navigator.isReactNative||this.self.removeDocumentEventListeners()})}},Br=new WeakMap,Zn=new WeakMap,Bt=new WeakMap,bn=new WeakSet,Dn=function(){return o(this,Bt).getValue("roomNodeClient")},Yg);let Pr=lS;As([w.trace("SelfController.resetSelf")],Pr.prototype,"resetSelf",1);As([w.trace("SelfController.setupEvents")],Pr.prototype,"setupEvents",1);As([w.trace("SelfController.joinRoom")],Pr.prototype,"joinRoom",1);As([w.trace("SelfController.leaveRoom")],Pr.prototype,"leaveRoom",1);As([w.trace("SelfController.joinMediaRoom")],Pr.prototype,"joinMediaRoom",1);As([w.trace("SelfController.leaveMediaRoom")],Pr.prototype,"leaveMediaRoom",1);As([w.trace("SelfController.init")],Pr,"init",1);var Wd;class ox{constructor(e){S(this,Wd,void 0),T(this,Wd,e)}on(e,n){let i;e===Y.roomPeerCount?i=rg.fromBinary.bind(rg):i=fg.fromBinary.bind(fg),o(this,Wd).on(e,({payload:r})=>{const s=i(r);return n(s)})}}Wd=new WeakMap;var Hd;class cx{constructor(e){S(this,Hd,void 0),T(this,Hd,e)}on(e,n){let i,r;switch(e){case Y.transcript:{i=Cu.fromBinary.bind(Cu),r=Cu.create();break}default:{m.debug("AISocketHandler switch case hit default, event not accounted for.");break}}o(this,Hd).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("chatSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}}Hd=new WeakMap;var dx=Object.defineProperty,lx=Object.getOwnPropertyDescriptor,Em=(t,e,n,i)=>{for(var r=i>1?void 0:i?lx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&dx(e,n,r),r},dr;class Zl{constructor(e){S(this,dr,void 0),T(this,dr,e)}getPolls(){return o(this,dr).sendMessagePromise(Si.getPolls)}createPoll(e,n,i=!1,r=!1){const s={anonymous:i,hideVotes:r,question:e,options:n};return o(this,dr).sendMessage(Si.createPoll,rN.toBinary(s))}votePoll(e,n){const i={index:n,pollId:e};return o(this,dr).sendMessage(Si.votePoll,aN.toBinary(i))}on(e,n){let i,r;switch(e){case Si.updatePoll:case Si.createPoll:case Si.votePoll:{i=Du.fromBinary.bind(Du),r=Du.create();break}}o(this,dr).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){m.error("pollSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}removeListeners(e){o(this,dr).removeListeners(e)}}dr=new WeakMap;Em([w.trace("PollSocketHandler.getPolls")],Zl.prototype,"getPolls",1);Em([w.trace("PollSocketHandler.createPoll")],Zl.prototype,"createPoll",1);Em([w.trace("PollSocketHandler.votePoll")],Zl.prototype,"votePoll",1);var pn;class ux{constructor(e){S(this,pn,void 0),T(this,pn,e)}getStageRequests(){return p(this,null,function*(){const{payload:e}=yield o(this,pn).sendMessagePromise(Y.getStageRequests);return e?Ou.fromBinary(e):{stageRequests:[]}})}requestAccess(){o(this,pn).sendMessage(Y.requestStageAccess)}cancelRequestAccess(){o(this,pn).sendMessage(Y.cancelStageRequest)}grantAccess(e){return p(this,null,function*(){const n={userIds:e};o(this,pn).sendMessage(Y.grantStageAccess,KD.toBinary(n))})}denyAccess(e){return p(this,null,function*(){const n={userIds:e};o(this,pn).sendMessage(Y.denyStageAccess,YD.toBinary(n))})}joinStage(){return o(this,pn).sendMessagePromise(Y.joinStage,void 0,void 0,Y.peerStageStatusUpdate)}leaveStage(e){const n={userIds:[e]};return o(this,pn).sendMessagePromise(Y.leaveStage,vg.toBinary(n),void 0,Y.peerStageStatusUpdate)}kick(e){const n={userIds:e};return o(this,pn).sendMessagePromise(Y.leaveStage,vg.toBinary(n))}on(e,n){let i;switch(e){case Y.grantStageAccess:case Y.denyStageAccess:{i=void 0;break}case Y.getStagePeers:{i=gg.fromBinary.bind(gg);break}case Y.getStageRequests:case Y.requestStageAccess:case Y.cancelStageRequest:{i=Ou.fromBinary.bind(Ou);break}case Y.peerStageStatusUpdate:{i=ig.fromBinary.bind(ig);break}}o(this,pn).on(e,({payload:r,id:s})=>{if(!r||!i)return n(void 0,s);const a=i(r);return n(a,s)})}getPeerInfo(e){return p(this,null,function*(){const n=yield o(this,pn).sendMessagePromise(Y.getPeerInfo,dE.toBinary({peerId:e}));return Gs.fromBinary(n.payload)})}}pn=new WeakMap;var St;class hx{constructor(e){S(this,St,void 0),T(this,St,e)}addPlugin(e,n){o(this,St).sendMessage(ie.addPlugin,uD.toBinary({pluginId:e,staggered:n}))}removePlugin(e){o(this,St).sendMessage(ie.removePlugin,pD.toBinary({pluginId:e,staggered:!1}))}getActivePlugins(){return p(this,null,function*(){const{payload:e}=yield o(this,St).sendMessagePromise(ie.getPlugins);return e?xD.fromBinary(e):{plugins:[]}})}customPluginEventToRoom(e,n,i){const r={pluginId:e,pluginData:new TextEncoder().encode(JSON.stringify(n))};o(this,St).sendMessage(ie.customPluginEventToRoom,kD.toBinary(r),i)}customPluginEventToPeers(e,n,i,r){const s={pluginId:e,peerIds:n,pluginData:new TextEncoder().encode(JSON.stringify(i))};o(this,St).sendMessage(ie.customPluginEventToPeers,_D.toBinary(s),r)}enablePluginForRoom(e,n){o(this,St).sendMessage(ie.enablePluginForRoom,fD.toBinary({pluginId:e}),n)}enablePluginForPeers(e,n,i){o(this,St).sendMessage(ie.enablePluginForPeers,ED.toBinary({pluginId:e,peerIds:n}),i)}disablePluginForRoom(e,n){o(this,St).sendMessage(ie.disablePluginForRoom,vD.toBinary({pluginId:e}),n)}disablePluginForPeers(e,n,i){o(this,St).sendMessage(ie.disablePluginForPeers,TD.toBinary({pluginId:e,peerIds:n}),i)}storeInsertKeys(e,n,i,r){const s={pluginId:e,storeName:n,insertKeys:i.map(a=>({storeKey:a.key,payload:new TextEncoder().encode(JSON.stringify(a.payload))}))};o(this,St).sendMessage(ie.storeInsertKeys,ug.toBinary(s),r)}storeGetKeys(e,n,i,r){const s={pluginId:e,storeName:n,getKeys:i.map(a=>({storeKey:a.key}))};o(this,St).sendMessage(ie.storeGetKeys,PD.toBinary(s),r)}storeDeleteKeys(e,n,i,r){const s={pluginId:e,storeName:n,deleteKeys:i.map(a=>({storeKey:a.key}))};o(this,St).sendMessage(ie.storeDeleteKeys,MD.toBinary(s),r)}storeDelete(e,n,i){o(this,St).sendMessage(ie.storeDelete,DD.toBinary({pluginId:e,storeName:n}),i)}getPluginDataOld(e,n){m.info("getPluginDataOld",{plugin:{id:e,storeName:n}})}storePluginDataOld(e,n,i){const r={pluginId:e,storeName:n,insertKeys:[{storeKey:i.key,payload:new TextEncoder().encode(JSON.stringify(i))}]};o(this,St).sendMessage(ie.storeInsertKeys,ug.toBinary(r))}on(e,n){let i;switch(e){case ie.addPlugin:case ie.enablePluginForPeers:case ie.enablePluginForRoom:{i=Mh.fromBinary.bind(Mh);break}case ie.removePlugin:case ie.disablePluginForPeers:case ie.disablePluginForRoom:{i=hg.fromBinary.bind(hg);break}case ie.customPluginEventToPeers:case ie.customPluginEventToRoom:{i=mg.fromBinary.bind(mg);break}case ie.storeInsertKeys:case ie.storeGetKeys:case ie.storeDeleteKeys:case ie.storeDelete:{i=pg.fromBinary.bind(pg);break}}o(this,St).on(e,({payload:r,id:s})=>{const a=i(r);return n(a,s)})}}St=new WeakMap;var px=Object.defineProperty,mx=(t,e,n)=>e in t?px(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fx=(t,e,n)=>(mx(t,typeof e!="symbol"?e+"":e,n),n),Sm=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},W=(t,e,n)=>(Sm(t,e,"read from private field"),n?n.call(t):e.get(t)),Ve=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},ke=(t,e,n,i)=>(Sm(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),qe=(t,e,n)=>(Sm(t,e,"access private method"),n),wl={},gx={get exports(){return wl},set exports(t){wl=t}},Ea=typeof Reflect=="object"?Reflect:null,Qg=Ea&&typeof Ea.apply=="function"?Ea.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},qd;Ea&&typeof Ea.ownKeys=="function"?qd=Ea.ownKeys:Object.getOwnPropertySymbols?qd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qd=function(t){return Object.getOwnPropertyNames(t)};function vx(t){console&&console.warn&&console.warn(t)}var uS=Number.isNaN||function(t){return t!==t};function _e(){_e.init.call(this)}gx.exports=_e;wl.once=Tx;_e.EventEmitter=_e;_e.prototype._events=void 0;_e.prototype._eventsCount=0;_e.prototype._maxListeners=void 0;var Xg=10;function eu(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(_e,"defaultMaxListeners",{enumerable:!0,get:function(){return Xg},set:function(t){if(typeof t!="number"||t<0||uS(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Xg=t}});_e.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};_e.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||uS(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 hS(t){return t._maxListeners===void 0?_e.defaultMaxListeners:t._maxListeners}_e.prototype.getMaxListeners=function(){return hS(this)};_e.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[t];if(c===void 0)return!1;if(typeof c=="function")Qg(c,this,e);else for(var d=c.length,h=vS(c,d),n=0;n<d;++n)Qg(h[n],this,e);return!0};function pS(t,e,n,i){var r,s,a;if(eu(n),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),a===void 0)a=s[e]=n,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),r=hS(t),r>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,vx(c)}return t}_e.prototype.addListener=function(t,e){return pS(this,t,e,!1)};_e.prototype.on=_e.prototype.addListener;_e.prototype.prependListener=function(t,e){return pS(this,t,e,!0)};function yx(){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 mS(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=yx.bind(i);return r.listener=n,i.wrapFn=r,r}_e.prototype.once=function(t,e){return eu(e),this.on(t,mS(this,t,e)),this};_e.prototype.prependOnceListener=function(t,e){return eu(e),this.prependListener(t,mS(this,t,e)),this};_e.prototype.removeListener=function(t,e){var n,i,r,s,a;if(eu(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():Ex(n,r),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};_e.prototype.off=_e.prototype.removeListener;_e.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[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 fS(t,e,n){var i=t._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?Sx(r):vS(r,r.length)}_e.prototype.listeners=function(t){return fS(this,t,!0)};_e.prototype.rawListeners=function(t){return fS(this,t,!1)};_e.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):gS.call(t,e)};_e.prototype.listenerCount=gS;function gS(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}_e.prototype.eventNames=function(){return this._eventsCount>0?qd(this._events):[]};function vS(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function Ex(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Sx(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Tx(t,e){return new Promise(function(n,i){function r(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",r),n([].slice.call(arguments))}yS(t,e,s,{once:!0}),e!=="error"&&bx(t,r,{once:!0})})}function bx(t,e,n){typeof t.on=="function"&&yS(t,"error",e,n)}function yS(t,e,n,i){if(typeof t.on=="function")i.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function r(s){i.once&&t.removeEventListener(e,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class kx extends _{constructor(){super("message.v1.SocketMessage",[{no:1,name:"event",kind:"scalar",T:13},{no:2,name:"id",kind:"scalar",opt:!0,T:9},{no:3,name:"payload",kind:"scalar",opt:!0,T:12},{no:4,name:"metadata",kind:"scalar",opt:!0,T:12}])}}const Zg=new kx;class ES{static encode(e){return Zg.toBinary(e)}static decode(e){return Zg.fromBinary(new Uint8Array(e))}}function wx(t,e){return Math.floor(Math.random()*(e-t+1)+t)}var lr;class _x{constructor(e={}){fx(this,"opts"),Ve(this,lr,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},ke(this,lr,0)}wait(){return p(this,null,function*(){ke(this,lr,W(this,lr)+1);const e=wx(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*Oe(2,W(this,lr))));yield new Promise(n=>{setTimeout(n,e)})})}getAttempts(){return W(this,lr)}reset(){ke(this,lr,0)}}lr=new WeakMap;const Ki={debug:0,info:1,warn:2,error:3};var ns,is;class Ix{constructor(e){Ve(this,ns,void 0),Ve(this,is,void 0),ke(this,ns,console),ke(this,is,e)}debug(...e){Ki[W(this,is)]>Ki.debug||W(this,ns).debug("[Sockrates]:",...e)}info(...e){Ki[W(this,is)]>Ki.info||W(this,ns).info("[Sockrates]:",...e)}warn(...e){Ki[W(this,is)]>Ki.warn||W(this,ns).warn("[Sockrates]:",...e)}error(...e){Ki[W(this,is)]>Ki.error||W(this,ns).error("[Sockrates]:",...e)}}ns=new WeakMap,is=new WeakMap;var SS=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))(SS||{});const Cx="2",Rx="3";var Qe,oa,He,rt,ur,Tt,_i,Er,Wn,ca,Ei,_p,TS,Ho,Gd,Ip,bS,Cp,ev,_l,Rp,Pp,kS,ac,Jd,oc,Il,Cl,Ap,Sa,cc,dc,Rl;class Px{constructor(e,n){var i;Ve(this,_p),Ve(this,Ho),Ve(this,Ip),Ve(this,Cp),Ve(this,_l),Ve(this,Pp),Ve(this,ac),Ve(this,oc),Ve(this,Cl),Ve(this,Sa),Ve(this,dc),Ve(this,Qe,void 0),Ve(this,oa,void 0),Ve(this,He,void 0),Ve(this,rt,void 0),Ve(this,ur,void 0),Ve(this,Tt,void 0),Ve(this,_i,void 0),Ve(this,Er,void 0),Ve(this,Wn,void 0),Ve(this,ca,void 0),Ve(this,Ei,void 0);var r,s,a,c,d,h,u,g,E;ke(this,oa,e),ke(this,ur,[]),ke(this,Tt,new wl),ke(this,_i,!0),ke(this,Wn,!1),ke(this,He,n!=null?n:{}),(r=W(this,He)).autoReconnect!=null||(r.autoReconnect=!0),(s=W(this,He)).retryConnectionInterval!=null||(s.retryConnectionInterval=1e3),(a=W(this,He)).pingTimeout!=null||(a.pingTimeout=3e4),(c=W(this,He)).connectionTimeout!=null||(c.connectionTimeout=5e3),(d=W(this,He)).debug!=null||(d.debug=!0),(h=W(this,He)).maxReconnectionAttempts!=null||(h.maxReconnectionAttempts=10),(u=W(this,He)).disconnectOnPingTimeout!=null||(u.disconnectOnPingTimeout=!0),(g=W(this,He)).queueOnDisconnect!=null||(g.queueOnDisconnect=!1),(E=W(this,He)).flushOnReconnect!=null||(E.flushOnReconnect=!1),ke(this,Er,{code:void 0,reason:void 0}),ke(this,rt,(i=W(this,He).logger)!=null?i:new Ix(W(this,He).debug?"debug":"info")),ke(this,Ei,new _x)}get readyState(){var e;return(e=W(this,Qe))==null?void 0:e.readyState}get url(){return W(this,oa)}updateURL(e){ke(this,oa,e),qe(this,Pp,kS).call(this)}get config(){return W(this,He)}get sendQueue(){return W(this,ur)}flush(){if(!W(this,He).queueOnDisconnect)return!1;const e=[];return W(this,ur).forEach(n=>{this.send(n.event,n.id,n.payload,n.metadata)||e.push(n)}),ke(this,ur,e),W(this,ur)}connect(e=!1){return p(this,null,function*(){if(!e&&[0,1].includes(this.readyState)){W(this,rt).debug("Websocket was already connecting or connected.");return}if(W(this,_i)!==!1)return new Promise((n,i)=>{qe(this,Sa,cc).call(this),qe(this,dc,Rl).call(this);try{ke(this,Qe,new WebSocket(qe(this,_p,TS).call(this,W(this,oa)))),W(this,Qe).binaryType="arraybuffer",W(this,rt).debug("Connecting");const r=setTimeout(()=>{W(this,rt).debug("Connection timeout. Closing socket"),ke(this,_i,!0),qe(this,dc,Rl).call(this),W(this,Qe).close(3001,"Connection Timeout"),W(this,He).autoReconnect&&!W(this,Wn)&&(W(this,Tt).emit("reconnecting"),qe(this,ac,Jd).call(this)),i(new Error("Connection timed out!"))},W(this,He).connectionTimeout);W(this,Qe).onopen=()=>{W(this,rt).debug(`Ready State: ${SS[W(this,Qe).readyState]}`),r&&clearTimeout(r),qe(this,Cl,Ap).call(this),ke(this,Er,{code:void 0,reason:void 0}),W(this,Tt).emit("connected"),W(this,He).flushOnReconnect&&this.flush(),n()},W(this,Qe).onclose=s=>{try{r&&clearTimeout(r);const{code:a,reason:c}=s;i(c),W(this,rt).debug("Socket closed. Close event:",{event:s}),W(this,rt).debug(`Connection closed code: ${a}`),W(this,rt).debug(`Connection closed reason: ${c}`),W(this,Wn)||qe(this,_l,Rp).call(this,a,c)}catch(a){qe(this,Ho,Gd).call(this,a)}},W(this,Qe).onerror=s=>{qe(this,Ho,Gd).call(this,s)},W(this,Qe).onmessage=s=>qe(this,Ip,bS).call(this,s)}catch(r){qe(this,Ho,Gd).call(this,r,i)}})})}send(e,n,i,r){const s={event:e,id:n,payload:i,metadata:r};if(W(this,He).queueOnDisconnect&&(!W(this,Qe)||W(this,Qe).readyState!==1))return W(this,rt).debug("Queuing message since socket is not connected!",s),W(this,ur).push(s),!1;const a=ES.encode(s);return qe(this,oc,Il).call(this,a)}emit(e,n,i,r){return this.send(e,n,i,r)}sendRaw(e){return qe(this,oc,Il).call(this,e)}receive(e,n){return W(this,Tt).on(e.toString(),n)}on(e,n){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){W(this,Tt).on(e,n);return}this.receive(e,n)}removeAllListeners(){W(this,Tt).removeAllListeners()}removeReceiver(e,n){this.removeListener(e,n)}removeListener(e,n){W(this,Tt).removeListener(e.toString(),n)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){W(this,Tt).listeners(e.toString()).map(n=>this.removeListener(e,n))}disconnect(){ke(this,_i,!1),qe(this,Sa,cc).call(this),this.removeAllListeners(),ke(this,Er,{code:1e3,reason:"Sockrates disconnect method called"}),W(this,Qe).close(1e3,"Sockrates disconnect method called.")}}Qe=new WeakMap,oa=new WeakMap,He=new WeakMap,rt=new WeakMap,ur=new WeakMap,Tt=new WeakMap,_i=new WeakMap,Er=new WeakMap,Wn=new WeakMap,ca=new WeakMap,Ei=new WeakMap,_p=new WeakSet,TS=function(t){if(t.startsWith("ws://")||t.startsWith("wss://"))return t;if(t.startsWith("https://"))return`wss://${t.substring(8)}`;if(t.startsWith("http://"))return`ws://${t.substring(7)}`;throw new Error("Invalid URL. URL must start with http(s):// or ws(s)://.")},Ho=new WeakSet,Gd=function(t,e){W(this,rt).error("Error:",{error:t}),W(this,Tt).emit("errored",{error:t}),e==null||e(t)},Ip=new WeakSet,bS=function(t){if(qe(this,Cl,Ap).call(this),t.data===Cx){W(this,rt).debug("Received ping from server"),qe(this,oc,Il).call(this,Rx);return}const e=ES.decode(t.data),{id:n,payload:i}=e;W(this,rt).debug("Received message",{event:e.event,messageID:n}),W(this,Tt).emit(e.event.toString(),{id:n,payload:i})},Cp=new WeakSet,ev=function(){return W(this,Qe).readyState===1},_l=new WeakSet,Rp=function(t,e){ke(this,Er,{reason:e,code:t}),W(this,Tt).emit("disconnected",{code:t,reason:e})},Pp=new WeakSet,kS=function(){const{reason:t,code:e}=W(this,Er);e&&e!==1e3&&W(this,_i)&&W(this,He).autoReconnect&&!W(this,Wn)&&(W(this,rt).debug(`Triggering reconnection due to ${t}.`),W(this,Tt).emit("reconnecting"),qe(this,ac,Jd).call(this))},ac=new WeakSet,Jd=function(t=!0){return p(this,null,function*(){if(t&&W(this,Wn)){W(this,rt).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(W(this,Wn)||W(this,Ei).reset(),W(this,He).maxReconnectionAttempts!==null&&W(this,Ei).getAttempts()>=W(this,He).maxReconnectionAttempts){W(this,Tt).emit("failed"),ke(this,Wn,!1);return}ke(this,Wn,!0),qe(this,dc,Rl).call(this),qe(this,Sa,cc).call(this);try{if(yield W(this,Ei).wait(),W(this,_i)===!1)return;if(W(this,rt).debug(`Reconnection attempt ${W(this,Ei).getAttempts()}`),W(this,Tt).emit("reconnectAttempt",{attempt:W(this,Ei).getAttempts()}),yield this.connect(),!qe(this,Cp,ev).call(this))throw Error("Reconnect Failed");ke(this,Wn,!1),ke(this,Er,{code:void 0,reason:void 0}),W(this,Tt).emit("reconnected")}catch{W(this,rt).debug("Failed to reconnect."),W(this,Tt).emit("reconnectFailure",{attempt:W(this,Ei).getAttempts()}),qe(this,ac,Jd).call(this,!1)}})},oc=new WeakSet,Il=function(t){try{return W(this,Qe).send(t),!0}catch(e){return W(this,rt).error(e.message),!1}},Cl=new WeakSet,Ap=function(){this.config.disconnectOnPingTimeout&&(W(this,rt).debug("Resetting ping timeout"),qe(this,Sa,cc).call(this),ke(this,ca,setTimeout(()=>{var t;W(this,rt).debug("Disconnecting the socket due to ping timeout"),ke(this,_i,!0);const e=3002,n="Ping timeout";(t=W(this,Qe))==null||t.close(e,n),qe(this,_l,Rp).call(this,e,n)},W(this,He).pingTimeout)))},Sa=new WeakSet,cc=function(){W(this,ca)&&(clearTimeout(W(this,ca)),ke(this,ca,void 0))},dc=new WeakSet,Rl=function(){W(this,Qe)&&(W(this,Qe).onopen=void 0,W(this,Qe).onerror=void 0,W(this,Qe).onmessage=void 0,W(this,Qe).onclose=void 0)};var Ax=Object.defineProperty,Mx=Object.getOwnPropertyDescriptor,tu=(t,e,n,i)=>{for(var r=i>1?void 0:i?Mx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ax(e,n,r),r};const tv=65535,Ox=3e3;var Fr,Ke,ze,et,Nn,zi,sd,Zu,ad,eh,nv;const wS=(nv=class{constructor(t,{peerId:e,meetingId:n,authToken:i,capabilities:r}){S(this,ze),S(this,sd),S(this,ad),S(this,Fr,void 0),S(this,Ke,void 0),y(this,"roomName"),y(this,"authToken"),y(this,"capabilities"),S(this,Nn,void 0),S(this,zi,void 0);var s;if(!e||!n||!i)throw new D("peerId, meetingId, or authToken can not be empty","0404");T(this,Nn,void 0),T(this,zi,t),this.capabilities=r,this.roomName=n,this.authToken=i,T(this,Fr,Q(this,sd,Zu).call(this,e)),T(this,Ke,new Px(o(this,Fr),{autoReconnect:!0,disconnectOnPingTimeout:(s=r.includes("PING"))!=null?s:!1,queueOnDisconnect:!0,flushOnReconnect:!1,logger:m})),this.handleSocketConnectionEvents()}get joinAttempted(){return o(this,ze,et).socketJoinAttempted}set joinAttempted(t){o(this,ze,et).socketJoinAttempted=t}get peerId(){return o(this,zi).getValue("peerId")}updateURL(t){t!==this.peerId&&(T(this,Fr,Q(this,sd,Zu).call(this,t)),m.debug("SocketService:: Connection URL updated.")),o(this,Ke).updateURL(o(this,Fr))}static getSocketEdgeDomain(t){return ga({servicePrefix:"socket-edge",baseURI:t})}get url(){return o(this,Fr)}connect(){return p(this,null,function*(){o(this,ze,et).socketJoinAttempted=!0,yield o(this,Ke).connect(),o(this,ze,et).socketJoinAttempted=!0,o(this,ze,et).socketState={state:"connected",reconnected:!1,reconnectionAttempt:void 0}})}disconnect(){return p(this,null,function*(){o(this,ze,et).socketJoinAttempted=!1,o(this,Ke).disconnect(),o(this,ze,et).socketJoinAttempted=!0,o(this,ze,et).socketState={state:"disconnected",reconnected:!1,reconnectionAttempt:void 0}})}get isConnected(){try{return o(this,Ke).readyState===1}catch{return!1}}sendMessage(t,e,n){const i={};return w.injectContext(i),o(this,Ke).send(t,n!=null?n:Q(this,ad,eh).call(this),e,new TextEncoder().encode(JSON.stringify(i)))}sendMessagePromise(t,e,n,i){const r=parseInt({}.SOCKET_SERVICE_MESSAGE_REQUEST_TIMEOUT,10)||2e4;return this.sendMessagePromiseWithTimeout({event:t,timeout:r,protobuf:e,messageId:n,resp:i})}sendMessagePromiseWithTimeout({event:t,timeout:e,protobuf:n,messageId:i,resp:r}){const s=r!=null?r:t;return new Promise((a,c)=>{const d=(b,k)=>{o(this,Ke).removeListener(s,b),o(this,Ke).removeListener(tv,k),o(this,Ke).removeListener(In.errorResponse,k),o(this,Ke).removeListener(Hn.errorResponse,k)},h=i!=null?i:Q(this,ad,eh).call(this),u={};w.injectContext(u);const g=({id:b,payload:k})=>{if(h===b){let A;try{const M=CA.fromBinary(k);A=new Error(M.errorMessage)}catch(M){A=new Error("failed to parse error message",{cause:M});try{const B=RM.fromBinary(k);A=new Error(B.message)}catch(B){A=new Error("failed to parse error message",{cause:B})}}c(A),d(E,g)}},E=({id:b,payload:k})=>{h===b&&(a({id:b,payload:k}),d(E,g))};o(this,Ke).on(s,E),o(this,Ke).on(tv,g),o(this,Ke).on(In.errorResponse,g),o(this,Ke).on(Hn.errorResponse,g),setTimeout(()=>{d(E,g),c(new Error(`request timeout for callback eventId:${t}`))},e),o(this,Ke).send(t,h,n,new TextEncoder().encode(JSON.stringify(u)))})}on(t,e){o(this,Ke).on(t,e)}onStateEvent(t,e){o(this,Ke).on(t,e)}removeListener(t,e){o(this,Ke).removeListener(t,e)}removeListeners(t){o(this,Ke).removeListeners(t)}flush(){return o(this,Ke).flush()}handleSocketConnectionEvents(){this.onStateEvent("connected",()=>p(this,null,function*(){m.info("SocketService::Connected to socket-edge"),o(this,Nn)&&(clearTimeout(o(this,Nn)),T(this,Nn,void 0)),o(this,ze,et).updateSocketConnectionState("connected")})),this.onStateEvent("disconnected",({code:t,reason:e})=>{var n;m.info("SocketService::Disconnected from socket-edge",{error:{code:t,reason:e},country:w.location.country});const{recv:i,send:r}=(n=o(this,ze,et).mediaState)!=null?n:{};i!=null&&i.state&&(i==null?void 0:i.state)!==wr.CONNECTED||r!=null&&r.state&&(r==null?void 0:r.state)!==wr.CONNECTED?L.emit(x.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,ze,et).joinAttempted}):T(this,Nn,setTimeout(()=>{L.emit(x.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,ze,et).joinAttempted}),T(this,Nn,void 0)},Ox)),o(this,ze,et).updateSocketConnectionState("disconnected")}),this.onStateEvent("reconnecting",()=>p(this,null,function*(){m.info("SocketService::Reconnecting to socket-edge",{country:w.location.country}),o(this,ze,et).updateSocketConnectionState("reconnecting")})),this.onStateEvent("reconnectAttempt",t=>p(this,[t],function*({attempt:e}){m.info("SocketService::Attempting to reconnect to socket-edge",{socket:{retryAttempt:e}}),o(this,ze,et).updateSocketConnectionState("reconnectAttempt",e)})),this.onStateEvent("reconnectFailure",({attempt:t})=>{m.info("SocketService::Reconnect attempt to socket-edge failed",{socket:{retryAttempt:t}}),o(this,ze,et).updateSocketConnectionState("reconnectFailure",t)}),this.onStateEvent("reconnected",()=>p(this,null,function*(){m.info("SocketService::Reconnected to socket-edge",{connectionState:{joinAttempted:o(this,ze,et).mediaJoinAttempted}}),o(this,Nn)&&(clearTimeout(o(this,Nn)),T(this,Nn,void 0)),L.emit(x.SOCKET_SERVICE_RECONNECTED,{wasJoinAttempted:o(this,ze,et).mediaJoinAttempted}),o(this,ze,et).updateSocketConnectionState("reconnected")})),this.onStateEvent("failed",()=>p(this,null,function*(){m.info("SocketService::Failed to connect to socket-edge",{country:w.location.country}),L.emit(x.SOCKET_SERVICE_FAILED),o(this,ze,et).updateSocketConnectionState("failed")}))}},Fr=new WeakMap,Ke=new WeakMap,ze=new WeakSet,et=function(){return o(this,zi).getValue("connectionHandler")},Nn=new WeakMap,zi=new WeakMap,sd=new WeakSet,Zu=function(t){let e=wS.getSocketEdgeDomain(o(this,zi).getValue("baseURI"));typeof ll(o(this,zi),"socket_server_base")=="string"&&(e=ll(o(this,zi),"socket_server_base"));const n=`wss://${e}`,i=new URL(`${n}/ws`),r=this.peerId,s=ee(H({roomID:this.roomName,peerID:t,authToken:this.authToken,useMediaV2:!0},r!==t&&{oldPeerID:r}),{ping:this.capabilities.includes("PING"),capabilities:this.capabilities.map(a=>ul[a]).join(" "),joinWithDetails:!0,useCfWorker:!0});return Object.entries(s).forEach(([a,c])=>{i.searchParams.append(a,c.toString())}),i.href},ad=new WeakSet,eh=function(){return`${this.peerId}-${(Math.random()+1).toString(36).substring(7)}`},nv);let Ic=wS;tu([w.trace("SocketService.connect")],Ic.prototype,"connect",1);tu([w.trace("SocketService.disconnect")],Ic.prototype,"disconnect",1);tu([w.trace("SocketService.sendMessagePromise")],Ic.prototype,"sendMessagePromise",1);tu([w.trace("SocketService.sendMessagePromiseWithTimeout")],Ic.prototype,"sendMessagePromiseWithTimeout",1);const rs=class{static handleConnectedRoomsDumpRaw({payload:t}){var e;const n=t1.fromBinary(t),i=n.meetings.map(r=>{var s;return{id:r.id,title:r.title,participants:(s=r.participants)!=null?s:[]}});return{parentMeeting:{id:n.parentMeeting.id,title:n.parentMeeting.title,participants:(e=n.parentMeeting.participants)!=null?e:[]},meetings:i}}static handleTransferPeerRaw({payload:t}){const e=C1.fromBinary(t);return{authToken:e.authToken,meetingId:e.meetingId}}static handleMovedPeerRaw({payload:t}){const e=lE.fromBinary(t);return{meetingId:e.meetingId,customParticipantId:e.customParticipantId}}static handleConnectedRoomsUpdatedRaw({payload:t}){return og.fromBinary(t).payloads.map(e=>({id:e.id,title:e.title}))}static handleConnectedRoomsDeletedRaw({payload:t}){return v1.fromBinary(t).payloads}static getConnectedRoomsDump(){return p(this,null,function*(){const t=yield rs.socketService.sendMessagePromise(Y.getConnectedRoomsDump);return rs.handleConnectedRoomsDumpRaw(t)})}static createConnectedRooms(t){return p(this,null,function*(){const{payload:e}=yield rs.socketService.sendMessagePromise(Y.createConnectedRooms,s1.toBinary({payloads:t}));return og.fromBinary(e).payloads.map(n=>({id:n.id,title:n.title}))})}static updateConnectedRooms(t){return p(this,null,function*(){})}static disableConnectedRooms(t){return p(this,null,function*(){const e=t.map(i=>({id:i})),n=yield rs.socketService.sendMessagePromise(Y.deleteConnectedRooms,f1.toBinary({payloads:e}));return rs.handleConnectedRoomsDeletedRaw(n)})}static movePeersBetweenRooms(t){return p(this,null,function*(){try{const e=yield rs.socketService.sendMessagePromise(Y.movePeers,k1.toBinary({sourceMeetingId:t.sourceMeetingId,destinationMeetingId:t.destinationMeetingId,participants:t.participants}));return new TextDecoder().decode(e.payload).includes("error")?{success:!1,error:"failed to move participants"}:{success:!0}}catch(e){return{success:!1,error:e}}})}};let Je=rs;y(Je,"socketService"),y(Je,"currentMeetingId");var Dx=Object.defineProperty,Nx=Object.getOwnPropertyDescriptor,nu=(t,e,n,i)=>{for(var r=i>1?void 0:i?Nx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Dx(e,n,r),r};const da=class{constructor(t,e){y(this,"apiBase"),y(this,"selfController"),y(this,"pollController"),y(this,"chatController"),y(this,"metaController"),y(this,"storesManager"),y(this,"stageController"),y(this,"pluginController"),y(this,"internalsController"),y(this,"recordingController"),y(this,"livestreamController"),y(this,"participantController"),this.apiBase=t,this.storesManager=e.storesManager,this.metaController=e.metaController,this.selfController=e.selfController,this.chatController=e.chatController,this.pollController=e.pollController,this.stageController=e.stageController,this.pluginController=e.pluginController,this.recordingController=e.recordingController,this.internalsController=e.internalsController,this.participantController=e.participantController,this.livestreamController=e.livestreamController}static init(t){return p(this,null,function*(){var e,n;const{peerId:i,apiBase:r,authToken:s,meetingId:a,organizationId:c,cachedUserDetails:d}=t.getAllValues();if(L.reset(),fl.cleanup(),dS(t),Be.isSupported()===!1)throw new D("Browser not supported","0010",!0);const h=BN(t,{authToken:s,baseURL:r,cachedUserDetails:d});h.setRoomName(a),h.setRoomUUID(a),h.setOrganizationId(c),h.setHeader("dyte-tracing-id",i),t.setValue("apiClient",h);const u=new TL;t.setValue("connectionHandler",u);const g=da.createSocketService(t),E=g.connect(),b=h.getUserDetails(),k=h.getPlugins();let A=bt.HIVE,M,B="";try{yield da.setupFlagsmith(t)}catch(J){m.error("Failed to setup flagsmith",{error:J})}try{yield E}catch(J){m.error("[Controller]: Failed to connect to socket server:",{error:J})}try{({sfu:A,meetingTitle:B}=yield h.getRoomNodeData()),M=yield b,m.info(`SFU ${A} is being used.`),t.setValue("presetName",M.preset.name),t.setValue("roomNodeOptions",{sfu:A})}catch(J){m.error("Failed to get room metadata",{error:J})}const K=s2.init(M.preset,!t.getValue("modules").theme),X=da.setupControllers(g,t,M,k,B,K);lL(K)&&((e=da.createRoomNodeClient(t,g).partialJoinRoom(M.participant.name,a,void 0))==null||e.catch(J=>{m.error("[Controller]: Failed to queue partial media room promise:",{error:J})})),w.location.country=(n=h.ipInfo)==null?void 0:n.country;const{controllers:O}=yield X;return hP(),new da(r,O)})}static setupFlagsmith(t){return p(this,null,function*(){var e;const{peerId:n,baseURI:i,overrides:r,meetingId:s,organizationId:a}=t.getAllValues(),c=lP(s),d=ee(H({entity:wh.PEER,clientId:a,isAnonUser:!a,sdkVersion:t.getValue("sdkVersion"),presetName:t.getValue("presetName"),meetingHash:c,roomName:s},Be.getDeviceInfo()),{isReactNative:navigator.isReactNative});try{const h=(e=r==null?void 0:r.whitelabelled_flags_endpoint)==null||e?ga({servicePrefix:"flags",baseURI:i}):"edge.api.flagsmith.com";yield se.identify(`${wh.PEER}_${n}`,JSON.parse(JSON.stringify(d)),!1,5e3,h,m),m.info("flagsmith::allFlags",{flags:JSON.stringify(se.getAllFlags())},!0)}catch{m.error("Failed to fetch flagsmith flags")}})}static setupControllers(t,e,n,i,r,s){return p(this,null,function*(){var a,c,d;const h=e.getValue("modules"),{preset:u,participant:g}=n,E=e.getValue("defaults"),{sfu:b}=e.getValue("roomNodeOptions"),{viewType:k,mediaConstraints:{audio:A}}=s;e.setValue("viewType",k),e.setValue("defaults",H({mediaConfiguration:{audio:{enableHighBitrate:(a=A.enableHighBitrate)!=null?a:!1,enableStereo:(c=A.enableStereo)!=null?c:!1}}},E));const M=I2.init(e,k,u.permissions);e.setValue("maxPreferredStreams",Be.isMobile()?s.maxVideoStreams.mobile:s.maxVideoStreams.desktop);let B,K,X,O,J,me,Ie,fe;const $e=new cx(t);Je.socketService=t;const ht=new Zl(t),V=new Cn(t),I=new ux(t),P=fl.create(t,e),z=new hx(t),ye=new ox(t),Xe=new Es(t),q=yield Pr.init(e,P,g,M,s),N=yield bE.init(e,q.self,P,$e,r);if(h.participant&&(fe=new Ni(e,q.self,P,b)),(d=h.e2ee)!=null&&d.enabled&&h.e2ee.manager.init(m,L),h.chat&&(K=yield Ci.init(e,V,Xe,q.self,fe.participants)),h.internals&&(J=yield dm.init()),h.livestream&&s.viewType===Yt.Livestream&&se.hasFeature(ue.LIVESTREAM)&&(Ie=new ME(q.self,ye)),s.viewType!==Yt.Chat){if(h.poll&&(B=yield yE.init(e,q.self,ht)),h.recording&&(me=new IE(e,q.self,P)),h.stage&&(X=new kE(e,I,P,q.self,fe.participants)),h.plugin){if(!fe)throw new D("The plugin module cannot be initialized without the `participant` module","0102");const Pn=yield i;O=yield bc.init(e,Pn,z,V,K==null?void 0:K.chat,q.self,fe.participants,r)}if(h.pip){const Pn=yield fP._init(e,q.self);e.setValue("pip",Pn)}}const Ze={storesManager:new p2(e,z),pollController:B,selfController:q,metaController:N,chatController:K,stageController:X,pluginController:O,recordingController:me,internalsController:J,livestreamController:Ie,participantController:fe};return{theme:s,permissions:M,controllers:Ze}})}static createRoomNodeClient(t,e){const{peerId:n,roomNodeOptions:i}=t.getAllValues(),{sfu:r}=i;return cS(t,r,{socket:e,peerId:n})}static createSocketService(t){const{peerId:e,meetingId:n,authToken:i}=t.getAllValues(),r=["PING"];return new Ic(t,{peerId:e,meetingId:n,authToken:i,capabilities:r})}};let Cc=da;nu([w.trace("Controller.init")],Cc,"init",1);nu([w.trace("setupFlagsmith")],Cc,"setupFlagsmith",1);nu([w.trace("Controller.createRoomNodeClient")],Cc,"createRoomNodeClient",1);nu([w.trace("Controller.createSocketService")],Cc,"createSocketService",1);var Lx=Object.defineProperty,xx=Object.getOwnPropertyDescriptor,Vx=(t,e,n,i)=>{for(var r=i>1?void 0:i?xx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Lx(e,n,r),r},$d,Mp;class _S extends gn{constructor(e,n){super(),S(this,$d,void 0),y(this,"meetings",[]),y(this,"parentMeeting",null),S(this,Mp,void 0),T(this,Mp,e),T(this,$d,n.self)}get supportsConnectedMeetings(){return o(this,$d).id!==""}get isActive(){return this.meetings.length!==0}get currentMeetingId(){return Je.currentMeetingId}validateConnectedMeetingsAction(){if(!this.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
27
+ Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`)}getConnectedMeetings(){return p(this,null,function*(){return this.validateConnectedMeetingsAction(),yield Je.getConnectedRoomsDump()})}createMeetings(e){return p(this,null,function*(){return this.validateConnectedMeetingsAction(),(yield Je.createConnectedRooms(e)).map(n=>({id:n.id,title:n.title}))})}updateMeetings(e){return p(this,null,function*(){this.validateConnectedMeetingsAction(),yield Je.updateConnectedRooms(e.map(n=>({meetingId:n.id,title:n.title})))})}deleteMeetings(e){return p(this,null,function*(){this.validateConnectedMeetingsAction();const n=this.meetings.map(i=>e.includes(i.id)&&i.participants.length!==0?this.moveParticipants(i.id,this.parentMeeting.id,i.participants.map(r=>r.id)):Promise.resolve());return yield Promise.all(n),yield Je.disableConnectedRooms(e)})}moveParticipants(e,n,i){return p(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield Je.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i.map(s=>({id:s}))});return r.success&&this.moveSuccessHandler(e,n,i),r})}moveParticipantsWithCustomPreset(e,n,i){return p(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield Je.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i});return r.success&&this.moveSuccessHandler(e,n,i.map(s=>s.id)),r})}moveSuccessHandler(e,n,i){const r=new Map;[...this.parentMeeting.participants,...this.meetings.flatMap(s=>s.participants)].forEach(s=>r.set(s.id,s)),n===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.concat(i.map(s=>r.get(s)))),e===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.filter(s=>!i.includes(s.id))),this.meetings=this.meetings.map(s=>{if(n===s.id){const a=s.participants.concat(i.map(c=>r.get(c)));return ee(H({},s),{participants:a})}if(e===s.id){const a=s.participants.filter(c=>!i.includes(c.id));return ee(H({},s),{participants:a})}return s})}}$d=new WeakMap,Mp=new WeakMap;Vx([on({maxInvocations:60,period:60})],_S.prototype,"getConnectedMeetings",1);var Ux=Object.defineProperty,Bx=Object.getOwnPropertyDescriptor,Tm=(t,e,n,i)=>{for(var r=i>1?void 0:i?Bx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ux(e,n,r),r},ho,Ln,th,nh;const hr=(th=class{constructor(t,e,n){y(this,"connectedMeetings"),S(this,ho,void 0),S(this,Ln,void 0),S(this,nh,void 0),T(this,nh,t),T(this,ho,n),this.connectedMeetings=new _S(t,e),this.setCurrentMeeting(e)}static init(t,e,n){return hr.instance||(hr.instance=new hr(t,e,n)),hr.instance.connectedMeetings.supportsConnectedMeetings&&(hr.instance.setupEvents(),e.self.once("roomJoined",()=>hr.instance.getConnectedMeetings())),hr.instance}setCurrentMeeting(t){T(this,Ln,t),Je.currentMeetingId=t.meta.meetingId}getConnectedMeetings(){this.connectedMeetings.getConnectedMeetings()}setupEvents(){Je.socketService&&(Je.socketService.on(Y.getConnectedRoomsDump,this.handleConnectedRoomsDump.bind(this)),Je.socketService.on(Y.transferPeer,this.handleTransferPeer.bind(this)),Je.socketService.on(Y.movedPeer,this.handleMovedPeer.bind(this)),Je.socketService.on(Y.connectedRoomsUpdated,this.handleConnectedRoomsUpdated.bind(this)),Je.socketService.on(Y.connectedRoomsDeleted,this.handleConnectedRoomsDeleted.bind(this)))}handleTransferPeer(t){const e=Je.handleTransferPeerRaw(t);return this.switchMeeting(e)}switchMeeting(t){return p(this,arguments,function*({authToken:e,meetingId:n}){var i,r,s,a;if(!this.connectedMeetings.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
28
+ Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`);m.info("ConnectedMeetingsController::switchMeeting:: asking ui-kit to show switching breakout UI"),this.connectedMeetings.emit("changingMeeting",n);const c={video:o(this,Ln).self.videoEnabled,audio:o(this,Ln).self.audioEnabled};try{o(this,Ln).self.cleanupEvents(),yield o(this,Ln).leave("connected-meeting")}catch(h){m.error(`ConnectedMeetingsController:: switchMeeting:: issues in leaving previous meeting. Meeting Id: ${(r=(i=o(this,Ln))==null?void 0:i.meta)==null?void 0:r.meetingId}`,{error:h})}Je.socketService=void 0,m.info(`ConnectedMeetingsController::switchMeeting:: initializing new meeting. Meeting Id: ${n}`);const d=yield IS.init(ee(H({},o(this,ho)),{cachedUserDetails:null,defaults:ee(H(H({},o(this,ho).defaults),c),{mediaHandler:o(this,Ln).self}),authToken:e}));m.info(`ConnectedMeetingsController::switchMeeting:: initialized new meeting. Meeting Id: ${(s=d==null?void 0:d.meta)==null?void 0:s.meetingId}`);try{const{hidden:h}=o(this,Ln).self;d.self.setName(o(this,Ln).self.name),yield d.join(),h&&d.self.hide()}catch(h){m.error("ConnectedMeetingsController.joinRoom",{error:h})}return m.info(`ConnectedMeetingsController::switchMeeting:: asking ui-kit to show in-meeting ui of newly joined meeting id: ${(a=d==null?void 0:d.meta)==null?void 0:a.meetingId}`),this.connectedMeetings.emit("meetingChanged",d),this.setCurrentMeeting(d),d})}handleConnectedRoomsDump(t){const e=Je.handleConnectedRoomsDumpRaw(t);this.connectedMeetings.meetings=e.meetings.map(n=>({id:n.id,title:n.title,participants:n.participants||[]})),this.connectedMeetings.parentMeeting={id:e.parentMeeting.id,title:e.parentMeeting.title,participants:e.parentMeeting.participants},this.emitStateUpdate()}handleMovedPeer(t){return Je.handleMovedPeerRaw(t)}handleConnectedRoomsUpdated(t){const e=Je.handleConnectedRoomsUpdatedRaw(t),n=new Map;this.connectedMeetings.meetings.forEach(i=>{n.set(i.id,i)}),e.forEach(i=>{n.has(i.id)?n.get(i.id).title=i.title:n.set(i.id,ee(H({},i),{participants:[]}))}),this.connectedMeetings.meetings=Array.from(n.values()),this.emitStateUpdate()}handleConnectedRoomsDeleted(t){const e=Je.handleConnectedRoomsDeletedRaw(t).map(n=>n.id);this.connectedMeetings.meetings=this.connectedMeetings.meetings.filter(n=>!e.includes(n.id)),this.emitStateUpdate()}emitStateUpdate(){this.connectedMeetings.emit("stateUpdate",{meetings:this.connectedMeetings.meetings,parentMeeting:this.connectedMeetings.parentMeeting})}},ho=new WeakMap,Ln=new WeakMap,nh=new WeakMap,y(th,"instance"),th);let iu=hr;Tm([w.trace("ConnectedMeetingsController.getConnectedMeetings")],iu.prototype,"getConnectedMeetings",1);Tm([w.trace("ConnectedMeetingsController.setupEvents")],iu.prototype,"setupEvents",1);Tm([w.trace("ConnectedMeetingsController.switchMeeting")],iu.prototype,"switchMeeting",1);class Fx{constructor(){y(this,"battery"),y(this,"init",()=>p(this,null,function*(){try{"getBattery"in navigator&&(this.battery=yield navigator.getBattery(),this.battery.addEventListener("chargingchange",this.updateChargeInfo),this.battery.addEventListener("levelchange",this.updateLevelInfo),this.updateLevelInfo(),this.updateChargeInfo())}catch(e){m.error("Error getting battery",e)}})),y(this,"updateChargeInfo",()=>{var e;m.log(`Battery charging? ${(e=this.battery)!=null&&e.charging?"Yes":"No"}`)}),y(this,"updateLevelInfo",()=>{if(!this.battery){m.log("Battery level: Not known");return}m.log(`Battery level: ${this.battery.level*100}%`)}),y(this,"cleanup",()=>{var e,n;"getBattery"in navigator&&((e=this.battery)==null||e.removeEventListener("chargingchange",this.updateChargeInfo),(n=this.battery)==null||n.removeEventListener("levelchange",this.updateLevelInfo))})}}const iv=new Fx;function jx(t,e){t.startsWith("eyJ")||console.error("Invalid auth token provided. Ensure you are passing a %cparticipant `authToken`%c \u2014 not an Org API Key or an incorrectly formatted token.\nYou get the participant token from the Add Participant API: https://docs.dyte.io/api#/operations/add_participant","font-weight: bold","font-weight: normal");try{const{meetingId:n,orgId:i,participantId:r}=JSON.parse(atob(t.split(".")[1]));if(!n)throw Error(`Received V1 auth token ${t}`);let s="dyte.io";e&&(s=e);const a=`https://api.${s}`;return{meetingId:n,orgId:i,participantId:r,baseURI:s,apiBase:a}}catch(n){throw m.error("constants::decodeAuthToken",{error:n,debuggingHint:`Unable to decode auth token: ${t}`},!0),new D("Invalid auth token","0004")}}var Wx=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,ru=(t,e,n,i)=>{for(var r=i>1?void 0:i?Hx(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Wx(e,n,r),r},Ct,od,cd,ih,rv,sv;let _r=(sv=class{constructor(t,e){S(this,ih),S(this,Ct,void 0),S(this,od,void 0),S(this,cd,void 0),T(this,cd,t),T(this,Ct,e)}static init(t){return p(this,null,function*(){var e,n,i,r,s,a,c;oP(),Be.init();const d=(n=(e=t==null?void 0:t.cachedUserDetails)==null?void 0:e.peerId)!=null?n:Ca();iv.init();const{authToken:h,baseURI:u}=t,g=jx(h,u),{meetingId:E}=g,b=Ml(g,["meetingId"]);window.__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION=!0;const k=_r.setupContext(d,t,E,b);w.meetingMetadata.roomName=E,w.meetingMetadata.userId=b.participantId,w.meetingMetadata.organizationId=b.orgId,w.init(k,(r=(i=t.modules)==null?void 0:i.tracing)!=null?r:!0),m.info("DyteClient::init::options",{dyteClientInitOptions:ee(H({},t),{authToken:`${(s=t.authToken)==null?void 0:s.slice(0,10)}...
29
+ ${(a=t.authToken)==null?void 0:a.slice(-10)}`})});const A=yield Cc.init(k),M=new _r(k,A);return Q(c=M,ih,rv).call(c,t),M})}static setupContext(t,e,n,i){var r;const s=ms.createContext(t,e),a=H(H({},tP),e==null?void 0:e.modules);return s.setValue("peerId",t),s.setValue("modules",a),s.setValue("sdkName","web-core"),s.setValue("meetingId",n),s.setValue("apiBase",i.apiBase),s.setValue("baseURI",i.baseURI),s.setValue("userId",i.participantId),s.setValue("organizationId",i.orgId),s.setValue("authToken",e.authToken),s.setValue("overrides",(r=e.overrides)!=null?r:{}),s.setValue("env",nP({baseURI:i.baseURI})),s.setValue("defaults",e.defaults||{audio:!0,video:!0}),s.setValue("onError",e.onError||(()=>{})),s.setValue("cachedUserDetails",Gn(e.cachedUserDetails)),s.setValue("sdkVersion","VERSION_PLACEHOLDER"),s}join(){return p(this,null,function*(){const{selfController:t}=o(this,Ct);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return p(this,null,function*(){iv.cleanup();const{selfController:e}=o(this,Ct);return e.leaveRoom(t)})}get participants(){var t;return(t=o(this,Ct).participantController)==null?void 0:t.participants}get self(){var t;return(t=o(this,Ct).selfController)==null?void 0:t.self}get meta(){var t;return(t=o(this,Ct).metaController)==null?void 0:t.meta}get ai(){var t;return(t=o(this,Ct).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=o(this,Ct).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=o(this,Ct).chatController)==null?void 0:t.chat}get polls(){var t;return(t=o(this,Ct).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=o(this,od))==null?void 0:t.connectedMeetings}get recording(){var t;return(t=o(this,Ct).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=o(this,Ct).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=o(this,Ct).stageController)==null?void 0:t.stage}get stores(){return o(this,Ct).storesManager}get __internals__(){var t;return(t=o(this,Ct).internalsController)==null?void 0:t.internals}joinRoom(){return p(this,null,function*(){return this.join()})}leaveRoom(t){return p(this,null,function*(){return this.leave(t)})}},Ct=new WeakMap,od=new WeakMap,cd=new WeakMap,ih=new WeakSet,rv=function(t){T(this,od,iu.init(o(this,cd),this,t))},sv);ru([Lt("0002"),Rr.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],_r.prototype,"join",1);ru([Lt("0003")],_r.prototype,"leave",1);ru([Lt("0001"),Rr.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],_r,"init",1);_r=ru([Lt("0000")],_r);const IS=_r;class qx{constructor(e){Pc(this,"meeting");Pc(this,"l");Pc(this,"onUpdate",()=>{this.l.forEach(e=>{e()})});var n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K,X;this.meeting=e,this.l=new Set,(n=this.meeting.self)==null||n.addListener("*",this.onUpdate),(i=this.meeting.meta)==null||i.addListener("*",this.onUpdate),(r=this.meeting.participants)==null||r.addListener("*",this.onUpdate),(a=(s=this.meeting.participants)==null?void 0:s.joined)==null||a.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(u=(h=this.meeting.participants)==null?void 0:h.waitlisted)==null||u.addListener("*",this.onUpdate),(g=this.meeting.stage)==null||g.addListener("*",this.onUpdate),(E=this.meeting.livestream)==null||E.addListener("*",this.onUpdate),(b=this.meeting.chat)==null||b.addListener("*",this.onUpdate),(k=this.meeting.plugins)==null||k.all.addListener("*",this.onUpdate),(A=this.meeting.recording)==null||A.addListener("*",this.onUpdate),(M=this.meeting.connectedMeetings)==null||M.addListener("*",this.onUpdate),(B=this.meeting.spotlight)==null||B.addListener("*",this.onUpdate),(K=this.meeting.remote)==null||K.addListener("*",this.onUpdate),(X=this.meeting.polls)==null||X.addListener("*",this.onUpdate)}clean(){var e,n,i,r,s,a,c,d,h,u,g,E,b,k,A,M,B,K;(e=this.meeting.self)==null||e.removeListener("*",this.onUpdate),(n=this.meeting.meta)==null||n.removeListener("*",this.onUpdate),(i=this.meeting.participants)==null||i.removeListener("*",this.onUpdate),(s=(r=this.meeting.participants)==null?void 0:r.joined)==null||s.removeListener("*",this.onUpdate),(c=(a=this.meeting.participants)==null?void 0:a.active)==null||c.removeListener("*",this.onUpdate),(h=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||h.removeListener("*",this.onUpdate),(u=this.meeting.stage)==null||u.removeListener("*",this.onUpdate),(g=this.meeting.livestream)==null||g.removeListener("*",this.onUpdate),(E=this.meeting.chat)==null||E.removeListener("*",this.onUpdate),(b=this.meeting.plugins)==null||b.all.removeListener("*",this.onUpdate),(k=this.meeting.recording)==null||k.removeListener("*",this.onUpdate),(A=this.meeting.connectedMeetings)==null||A.removeListener("*",this.onUpdate),(M=this.meeting.spotlight)==null||M.removeListener("*",this.onUpdate),(B=this.meeting.remote)==null||B.removeListener("*",this.onUpdate),(K=this.meeting.polls)==null||K.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const su=zt.createContext({meeting:void 0,updates:void 0});function Gx({value:t,children:e,fallback:n}){const[i,r]=zt.useState(),s=zt.useRef();return zt.useEffect(()=>(t&&r(new qx(t)),()=>{var a;(a=s.current)==null||a.clean()}),[t]),LS.default.createElement(su.Provider,{value:{meeting:t,updates:i}},t?e:n)}const Jx=()=>{const{meeting:t}=zt.useContext(su);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},$x=t=>{const e=zt.useRef(!1),[n,i]=zt.useState(),r=t==null?void 0:t.resetOnLeave,s=zt.useCallback(async a=>{if(!e.current)return e.current=!0,IS.init(a).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return zt.useEffect(()=>{if(!n||!r)return()=>{};const a=({state:c})=>{c!=="connected-meeting"&&c!=="disconnected"&&i(void 0)};return n.self.on("roomLeft",a),()=>{n.self.removeListener("roomLeft",a)}},[n]),zt.useEffect(()=>{if(!n||!n.connectedMeetings)return()=>{};const a=c=>{i(void 0),setTimeout(()=>{i(c)},100)};return n.connectedMeetings.on("meetingChanged",a),()=>{n.connectedMeetings.removeListener("meetingChanged",a)}},[n]),[n,s]},Kx=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),zx=t=>{const{meeting:e,updates:n}=zt.useContext(su);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=zt.useRef(t(e)),[,r]=zt.useReducer(s=>s+1,0);return zt.useEffect(()=>{const s=e&&t(e),a=()=>{const c=e&&t(e);Kx(i.current,c)&&(i.current=c,r())};return s&&typeof s=="object"&&"addListener"in s?(s.addListener("*",r),()=>{s.removeListener("*",r)}):(n==null||n.addListener(a),()=>{n==null||n.removeListener(a)})},[e,n]),i.current};exports.RTKSelfMedia=VE;exports.RealtimeKitContext=su;exports.RealtimeKitProvider=Gx;exports.useRealtimeKitClient=$x;exports.useRealtimeKitMeeting=Jx;exports.useRealtimeKitSelector=zx;