var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure.')}var sdp={exports:{}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){const n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((e=>0===e.indexOf(n)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const n={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":n.relatedAddress=t[e+1];break;case"rport":n.relatedPort=parseInt(t[e+1],10);break;case"tcptype":n.tcpType=t[e+1];break;case"ufrag":n.ufrag=t[e+1],n.usernameFragment=t[e+1];break;default:void 0===n[t[e]]&&(n[t[e]]=t[e+1])}return n},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let n;const r=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;e<r.length;e++)n=r[e].trim().split("="),t[n[0].trim()]=n[1];return t},t.writeFmtp=function(e){let t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const r=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){const r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");n.profile=r[2];for(let i=3;i<r.length;i++){const s=r[i],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){const r=t.parseRtpMap(o),i=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(r.parameters=i.length?t.parseFmtp(i[0]):{},r.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),n.codecs.push(r),r.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(r.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{n.headerExtensions.push(t.parseExtmap(e))}));const i=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((e=>{i.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){let r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=n.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));let i=0;return n.codecs.forEach((e=>{e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((e=>{r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){const n=[],r=t.parseRtpParameters(e),i=-1!==r.fecMechanisms.indexOf("RED"),s=-1!==r.fecMechanisms.indexOf("ULPFEC"),o=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=o.length>0&&o[0].ssrc;let l;const c=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));c.length>0&&c[0].length>1&&c[0][0]===a&&(l=c[0][1]),r.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&l&&(t.rtx={ssrc:l}),n.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:s?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&a&&n.push({ssrc:a});let d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substring(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substring(5),10)*.95-16e3:void 0,n.forEach((e=>{e.maxBitrate=d}))),n},t.parseRtcpParameters=function(e){const n={},r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);const i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;const s=t.matchPrefix(e,"a=rtcp-mux");return n.mux=s.length>0,n},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let n;const r=t.matchPrefix(e,"a=msid:");if(1===r.length)return n=r[0].substring(7).split(" "),{stream:n[0],track:n[1]};const i=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0?(n=i[0].value.split(" "),{stream:n[0],track:n[1]}):void 0},t.parseSctpDescription=function(e){const n=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:");let i;r.length>0&&(i=parseInt(r[0].substring(19),10)),isNaN(i)&&(i=65536);const s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substring(12),10),protocol:n.fmt,maxMessageSize:i};const o=t.matchPrefix(e,"a=sctpmap:");if(o.length>0){const e=o[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){let i;const s=void 0!==n?n:2;return i=e||t.generateSessionId(),"v=0\r\no="+(r||"thisisadapterortc")+" "+i+" "+s+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){const r=t.splitLines(e);for(let e=0;e<r.length;e++)switch(r[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[e].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){const n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const n=t.splitLines(e);for(let e=0;e<n.length;e++)if(n[e].length<2||"="!==n[e].charAt(1))return!1;return!0},e.exports=t}(sdp);var t,s,e,n$1={d:(e,t)=>{for(var n in t)n$1.o(t,n)&&!n$1.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r$1={};n$1.d(r$1,{Dz:()=>me,g$:()=>A$1,Lt:()=>R$1,Q9:()=>x$1,qf:()=>L$1,hV:()=>Me,z$:()=>Te,J0:()=>fe,De:()=>ge,$C:()=>ue,al:()=>_$1,_W:()=>W$1,tz:()=>B$1,Nu:()=>Ce,zg:()=>Oe,vp:()=>ne,vU:()=>re,wF:()=>q$1,rv:()=>pe,Nh:()=>ve,ss:()=>Fe,qW:()=>J$1,QL:()=>Y$1,cf:()=>Ie,eM:()=>$$a,Yd:()=>i,iM:()=>p$1,qy:()=>o$1,ce:()=>v$2,sK:()=>oe,Ok:()=>ce,q5:()=>Ee,g:()=>vt,xl:()=>N$1,I:()=>K$1,bx:()=>Q$1,Ib:()=>b$1,Az:()=>M$1,Iw:()=>w$2,qY:()=>k$1,db:()=>P$1,mR:()=>Z$1,Tn:()=>C$1,rV:()=>X$1,gh:()=>V$1,i5:()=>j$1,x_:()=>de,Am:()=>lt$1,eR:()=>F$1,r8:()=>H$1,u3:()=>Ue,vd:()=>O$1,iV:()=>I$1,jZ:()=>U$1,SW:()=>z$2,ZH:()=>G$1,Ni:()=>ht,lh:()=>D$1,bq:()=>f$1,$f:()=>St,eu:()=>se,Ax:()=>te,Mc:()=>ee});class i{static GetStackTrace(){const e=new Error;let t="No Stack Available for this browser";return e.stack&&(t=e.stack.toString().replace(/Error/g,"")),t}static SetLoggerVerbosity(e){null!=this.verboseLogLevel&&(this.verboseLogLevel=e)}static Log(e,t,n){if(n>this.verboseLogLevel)return;const r=`Level: Log\nMsg: ${t}\nCaller: ${e}`;console.log(r)}static Info(e,t,n){if(n>this.verboseLogLevel)return;const r=`Level: Info\nMsg: ${t}`;console.info(r)}static Error(e,t){const n=`Level: Error\nMsg: ${t}\nCaller: ${e}`;console.error(n)}static Warning(e,t){const n=`Level: Warning\nCaller: ${e}\nMsg: ${t}`;console.warn(n)}}i.verboseLogLevel=5,(e=t||(t={})).LIST_STREAMERS="listStreamers",e.SUBSCRIBE="subscribe",e.UNSUBSCRIBE="unsubscribe",e.ICE_CANDIDATE="iceCandidate",e.OFFER="offer",e.ANSWER="answer",e.DATACHANNELREQUEST="dataChannelRequest",e.SFURECVDATACHANNELREADY="peerDataChannelsReady",e.PONG="pong";class o$1{payload(){return i.Log(i.GetStackTrace(),"Sending => \n"+JSON.stringify(this,void 0,4),6),JSON.stringify(this)}}class a$1 extends o$1{constructor(){super(),this.type=t.LIST_STREAMERS}}class d$1 extends o$1{constructor(e){super(),this.type=t.SUBSCRIBE,this.streamerId=e}}class l$1 extends o$1{constructor(){super(),this.type=t.UNSUBSCRIBE}}class c$1 extends o$1{constructor(e){super(),this.type=t.PONG,this.time=e}}class h$2 extends o$1{constructor(e){super(),this.type=t.OFFER,e&&(this.type=e.type,this.sdp=e.sdp)}}class g$1 extends o$1{constructor(e){super(),this.type=t.ANSWER,e&&(this.type=e.type,this.sdp=e.sdp)}}class u$1 extends o$1{constructor(){super(),this.type=t.DATACHANNELREQUEST}}class m$1 extends o$1{constructor(){super(),this.type=t.SFURECVDATACHANNELREADY}}class S$1{constructor(e){this.type=t.ICE_CANDIDATE,this.candidate=e}payload(){return i.Log(i.GetStackTrace(),"Sending => \n"+JSON.stringify(this,void 0,4),6),JSON.stringify(this)}}!function(e){e.CONFIG="config",e.STREAMER_LIST="streamerList",e.PLAYER_COUNT="playerCount",e.OFFER="offer",e.ANSWER="answer",e.ICE_CANDIDATE="iceCandidate",e.PEER_DATA_CHANNELS="peerDataChannels",e.PING="ping",e.WARNING="warning"}(s||(s={}));class p$1{}class v$2 extends p$1{}class C$1{constructor(){this.FromUEMessageHandlers=new Map}addMessageHandler(e,t){this.FromUEMessageHandlers.set(e,t)}handleMessage(e,t){this.FromUEMessageHandlers.has(e)?this.FromUEMessageHandlers.get(e)(t):i.Error(i.GetStackTrace(),`Message type of ${e} does not have a message handler registered on the frontend - ignoring message.`)}static setupDefaultHandlers(e){e.signallingProtocol.addMessageHandler(s.PING,(t=>{const n=new c$1((new Date).getTime()).payload();i.Log(i.GetStackTrace(),s.PING+": "+t,6),e.webSocket.send(n)})),e.signallingProtocol.addMessageHandler(s.CONFIG,(t=>{i.Log(i.GetStackTrace(),s.CONFIG,6);const n=JSON.parse(t);e.onConfig(n)})),e.signallingProtocol.addMessageHandler(s.STREAMER_LIST,(t=>{i.Log(i.GetStackTrace(),s.STREAMER_LIST,6);const n=JSON.parse(t);e.onStreamerList(n)})),e.signallingProtocol.addMessageHandler(s.PLAYER_COUNT,(e=>{i.Log(i.GetStackTrace(),s.PLAYER_COUNT,6);const t=JSON.parse(e);i.Log(i.GetStackTrace(),"Player Count: "+t.count,6)})),e.signallingProtocol.addMessageHandler(s.ANSWER,(t=>{i.Log(i.GetStackTrace(),s.ANSWER,6);const n=JSON.parse(t);e.onWebRtcAnswer(n)})),e.signallingProtocol.addMessageHandler(s.OFFER,(t=>{i.Log(i.GetStackTrace(),s.OFFER,6);const n=JSON.parse(t);e.onWebRtcOffer(n)})),e.signallingProtocol.addMessageHandler(s.ICE_CANDIDATE,(t=>{i.Log(i.GetStackTrace(),s.ICE_CANDIDATE,6);const n=JSON.parse(t);e.onIceCandidate(n.candidate)})),e.signallingProtocol.addMessageHandler(s.WARNING,(e=>{i.Warning(i.GetStackTrace(),`Warning received: ${e}`)})),e.signallingProtocol.addMessageHandler(s.PEER_DATA_CHANNELS,(t=>{i.Log(i.GetStackTrace(),s.PEER_DATA_CHANNELS,6);const n=JSON.parse(t);e.onWebRtcPeerDataChannels(n)}))}}class f$1{constructor(){this.WS_OPEN_STATE=1,this.onOpen=new EventTarget,this.onClose=new EventTarget,this.signallingProtocol=new C$1,C$1.setupDefaultHandlers(this)}connect(e){i.Log(i.GetStackTrace(),e,6);try{return this.webSocket=new WebSocket(e),this.webSocket.onopen=e=>this.handleOnOpen(e),this.webSocket.onerror=()=>this.handleOnError(),this.webSocket.onclose=e=>this.handleOnClose(e),this.webSocket.onmessage=e=>this.handleOnMessage(e),this.webSocket.onmessagebinary=e=>this.handleOnMessageBinary(e),!0}catch(e){return i.Error(e,e),!1}}handleOnMessageBinary(e){e&&e.data&&e.data.text().then((e=>{const t=new MessageEvent("messageFromBinary",{data:e});this.handleOnMessage(t)})).catch((e=>{i.Error(i.GetStackTrace(),`Failed to parse binary blob from websocket, reason: ${e}`)}))}handleOnMessage(e){if(e.data&&e.data instanceof Blob)return void this.handleOnMessageBinary(e);const t=JSON.parse(e.data);i.Log(i.GetStackTrace(),"received => \n"+JSON.stringify(JSON.parse(e.data),void 0,4),6),this.signallingProtocol.handleMessage(t.type,e.data)}handleOnOpen(e){i.Log(i.GetStackTrace(),"Connected to the signalling server via WebSocket",6),this.onOpen.dispatchEvent(new Event("open"))}handleOnError(){i.Error(i.GetStackTrace(),"WebSocket error")}handleOnClose(e){this.onWebSocketOncloseOverlayMessage(e),i.Log(i.GetStackTrace(),"Disconnected to the signalling server via WebSocket: "+JSON.stringify(e.code)+" - "+e.reason),this.onClose.dispatchEvent(new Event("close"))}requestStreamerList(){const e=new a$1;this.webSocket.send(e.payload())}sendSubscribe(e){const t=new d$1(e);this.webSocket.send(t.payload())}sendUnsubscribe(){const e=new l$1;this.webSocket.send(e.payload())}sendWebRtcOffer(e){const t=new h$2(e);this.webSocket.send(t.payload())}sendWebRtcAnswer(e){const t=new g$1(e);this.webSocket.send(t.payload())}sendWebRtcDatachannelRequest(){const e=new u$1;this.webSocket.send(e.payload())}sendSFURecvDataChannelReady(){const e=new m$1;this.webSocket.send(e.payload())}sendIceCandidate(e){if(i.Log(i.GetStackTrace(),"Sending Ice Candidate"),this.webSocket&&this.webSocket.readyState===this.WS_OPEN_STATE){const t=new S$1(e);this.webSocket.send(t.payload())}}close(){var e;null===(e=this.webSocket)||void 0===e||e.close()}onWebSocketOncloseOverlayMessage(e){}onConfig(e){}onStreamerList(e){}onIceCandidate(e){}onWebRtcAnswer(e){}onWebRtcOffer(e){}onWebRtcPeerDataChannels(e){}}class T$1{constructor(e){this.videoElementProvider=e,this.audioElement=document.createElement("Audio")}handleOnTrack(e){i.Log(i.GetStackTrace(),"handleOnTrack "+JSON.stringify(e.streams),6);const t=this.videoElementProvider.getVideoElement();if(e.track&&i.Log(i.GetStackTrace(),"Got track - "+e.track.kind+" id="+e.track.id+" readyState="+e.track.readyState,6),"audio"!=e.track.kind)return"video"==e.track.kind&&t.srcObject!==e.streams[0]?(t.srcObject=e.streams[0],void i.Log(i.GetStackTrace(),"Set video source from video track ontrack.")):void 0;this.CreateAudioTrack(e.streams[0])}CreateAudioTrack(e){const t=this.videoElementProvider.getVideoElement();t.srcObject!=e&&t.srcObject&&t.srcObject!==e&&(this.audioElement.srcObject=e,i.Log(i.GetStackTrace(),"Created new audio element to play separate audio stream."))}}class E$1{constructor(e){this.freezeFrameHeight=0,this.freezeFrameWidth=0,this.rootDiv=e,this.rootElement=document.createElement("div"),this.rootElement.id="freezeFrame",this.rootElement.style.display="none",this.rootElement.style.pointerEvents="none",this.rootElement.style.position="absolute",this.rootElement.style.zIndex="20",this.imageElement=document.createElement("img"),this.imageElement.style.position="absolute",this.rootElement.appendChild(this.imageElement),this.rootDiv.appendChild(this.rootElement)}setElementForShow(){this.rootElement.style.display="block"}setElementForHide(){this.rootElement.style.display="none"}updateImageElementSource(e){const t=btoa(e.reduce(((e,t)=>e+String.fromCharCode(t)),""));this.imageElement.src="data:image/jpeg;base64,"+t}setDimensionsFromElementAndResize(){this.freezeFrameHeight=this.imageElement.naturalHeight,this.freezeFrameWidth=this.imageElement.naturalWidth,this.resize()}resize(){if(0!==this.freezeFrameWidth&&0!==this.freezeFrameHeight){let e=0,t=0,n=0,r=0;const i=this.rootDiv.clientWidth/this.rootDiv.clientHeight,s=this.freezeFrameWidth/this.freezeFrameHeight;i<s?(e=this.rootDiv.clientWidth,t=Math.floor(this.rootDiv.clientWidth/s),n=Math.floor(.5*(this.rootDiv.clientHeight-t)),r=0):(e=Math.floor(this.rootDiv.clientHeight*s),t=this.rootDiv.clientHeight,n=0,r=Math.floor(.5*(this.rootDiv.clientWidth-e))),this.rootElement.style.width=this.rootDiv.offsetWidth+"px",this.rootElement.style.height=this.rootDiv.offsetHeight+"px",this.rootElement.style.left="0px",this.rootElement.style.top="0px",this.imageElement.style.width=e+"px",this.imageElement.style.height=t+"px",this.imageElement.style.left=r+"px",this.imageElement.style.top=n+"px"}}}class y$1{constructor(e){this.receiving=!1,this.size=0,this.jpeg=void 0,this.valid=!1,this.freezeFrameDelay=50,this.freezeFrame=new E$1(e)}showFreezeFrame(){this.valid&&this.freezeFrame.setElementForShow()}hideFreezeFrame(){this.valid=!1,this.freezeFrame.setElementForHide()}updateFreezeFrameAndShow(e,t){this.freezeFrame.updateImageElementSource(e),this.freezeFrame.imageElement.onload=()=>{this.freezeFrame.setDimensionsFromElementAndResize(),t()}}processFreezeFrameMessage(e,t){this.receiving||(this.receiving=!0,this.valid=!1,this.size=0,this.jpeg=void 0),this.size=new DataView(e.slice(1,5).buffer).getInt32(0,!0);const n=e.slice(5);if(this.jpeg){const e=new Uint8Array(this.jpeg.length+n.length);e.set(this.jpeg,0),e.set(n,this.jpeg.length),this.jpeg=e}else this.jpeg=n,this.receiving=!0,i.Log(i.GetStackTrace(),`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`,6);this.jpeg.length===this.size?(this.receiving=!1,this.valid=!0,i.Log(i.GetStackTrace(),`received complete freeze frame ${this.size}`,6),this.updateFreezeFrameAndShow(this.jpeg,t)):this.jpeg.length>this.size&&(i.Error(i.GetStackTrace(),`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`),this.jpeg=void 0,this.receiving=!1)}}class b$1{constructor(e,t,n,r,i=(()=>{})){this.onChange=i,this.onChangeEmit=()=>{},this.id=e,this.description=n,this.label=t,this.value=r}set label(e){this._label=e,this.onChangeEmit(this._value)}get label(){return this._label}get value(){return this._value}set value(e){this._value=e,this.onChange(this._value,this),this.onChangeEmit(this._value)}}class M$1 extends b$1{constructor(e,t,n,r,i,s=(()=>{})){super(e,t,n,r,s);const o=new URLSearchParams(window.location.search);if(i&&o.has(this.id)){const e=this.getUrlParamFlag();this.flag=e}else this.flag=r;this.useUrlParams=i}getUrlParamFlag(){const e=new URLSearchParams(window.location.search);return!!e.has(this.id)&&"false"!==e.get(this.id)&&"False"!==e.get(this.id)}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);!0===this.flag?e.set(this.id,"true"):e.set(this.id,"false"),window.history.replaceState({},"",""!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}enable(){this.flag=!0}get flag(){return!!this.value}set flag(e){this.value=e}}class w$2 extends b$1{constructor(e,t,n,r,i,s,o,a=(()=>{})){super(e,t,n,s,a),this._min=r,this._max=i;const l=new URLSearchParams(window.location.search);if(o&&l.has(this.id)){const e=Number.parseInt(l.get(this.id));this.number=Number.isNaN(e)?s:e}else this.number=s;this.useUrlParams=o}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.number.toString()),window.history.replaceState({},"",""!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}set number(e){this.value=this.clamp(e)}get number(){return this.value}clamp(e){return Math.max(Math.min(this._max,e),this._min)}get min(){return this._min}get max(){return this._max}addOnChangedListener(e){this.onChange=e}}class P$1 extends b$1{constructor(e,t,n,r,i,s=(()=>{})){super(e,t,n,r,s);const o=new URLSearchParams(window.location.search);if(i&&o.has(this.id)){const e=this.getUrlParamText();this.text=e}else this.text=r;this.useUrlParams=i}getUrlParamText(){var e;const t=new URLSearchParams(window.location.search);return t.has(this.id)&&null!==(e=t.get(this.id))&&void 0!==e?e:""}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.text),window.history.replaceState({},"",""!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}get text(){return this.value}set text(e){this.value=e}}class k$1 extends b$1{constructor(e,t,n,r,i,s,o=(()=>{})){super(e,t,n,[r,r],o),this.options=i;const a=new URLSearchParams(window.location.search),l=s&&a.has(this.id)?this.getUrlParamText():r;this.selected=l,this.useUrlParams=s}getUrlParamText(){var e;const t=new URLSearchParams(window.location.search);return t.has(this.id)&&null!==(e=t.get(this.id))&&void 0!==e?e:""}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.selected),window.history.replaceState({},"",""!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}addOnChangedListener(e){this.onChange=e}get options(){return this._options}set options(e){this._options=e,this.onChangeEmit(this.selected)}get selected(){return this.value}set selected(e){const t=this.options.filter((t=>-1!==t.indexOf(e)));t.length&&(this.value=t[0])}}class R$1 extends Event{constructor(e){super("afkWarningActivate"),this.data=e}}class L$1 extends Event{constructor(e){super("afkWarningUpdate"),this.data=e}}class x$1 extends Event{constructor(){super("afkWarningDeactivate")}}class A$1 extends Event{constructor(){super("afkTimedOut")}}class F$1 extends Event{constructor(e){super("videoEncoderAvgQP"),this.data=e}}class D$1 extends Event{constructor(){super("webRtcSdp")}}class O$1 extends Event{constructor(){super("webRtcAutoConnect")}}class U$1 extends Event{constructor(){super("webRtcConnecting")}}class I$1 extends Event{constructor(){super("webRtcConnected")}}class G$1 extends Event{constructor(){super("webRtcFailed")}}class z$2 extends Event{constructor(e){super("webRtcDisconnected"),this.data=e}}class B$1 extends Event{constructor(e){super("dataChannelOpen"),this.data=e}}class _$1 extends Event{constructor(e){super("dataChannelClose"),this.data=e}}class W$1 extends Event{constructor(e){super("dataChannelError"),this.data=e}}class H$1 extends Event{constructor(){super("videoInitialized")}}class V$1 extends Event{constructor(){super("streamLoading")}}class N$1 extends Event{constructor(e){super("playStreamError"),this.data=e}}class K$1 extends Event{constructor(){super("playStream")}}class Q$1 extends Event{constructor(e){super("playStreamRejected"),this.data=e}}class $$a extends Event{constructor(e){super("loadFreezeFrame"),this.data=e}}class q$1 extends Event{constructor(){super("hideFreezeFrame")}}class X$1 extends Event{constructor(e){super("statsReceived"),this.data=e}}class j$1 extends Event{constructor(e){super("streamerListMessage"),this.data=e}}class Y$1 extends Event{constructor(e){super("latencyTestResult"),this.data=e}}class J$1 extends Event{constructor(e){super("initialSettings"),this.data=e}}class Z$1 extends Event{constructor(e){super("settingsChanged"),this.data=e}}class ee extends Event{constructor(){super("xrSessionStarted")}}class te extends Event{constructor(){super("xrSessionEnded")}}class se extends Event{constructor(e){super("xrFrame"),this.data=e}}class ne extends EventTarget{dispatchEvent(e){return super.dispatchEvent(e)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}}class re{}re.AutoConnect="AutoConnect",re.AutoPlayVideo="AutoPlayVideo",re.AFKDetection="TimeoutIfIdle",re.BrowserSendOffer="OfferToReceive",re.HoveringMouseMode="HoveringMouse",re.ForceMonoAudio="ForceMonoAudio",re.ForceTURN="ForceTURN",re.FakeMouseWithTouches="FakeMouseWithTouches",re.IsQualityController="ControlsQuality",re.MatchViewportResolution="MatchViewportRes",re.PreferSFU="preferSFU",re.StartVideoMuted="StartVideoMuted",re.SuppressBrowserKeys="SuppressBrowserKeys",re.UseMic="UseMic",re.KeyboardInput="KeyboardInput",re.MouseInput="MouseInput",re.TouchInput="TouchInput",re.GamepadInput="GamepadInput",re.XRControllerInput="XRControllerInput";const ie=e=>Object.getOwnPropertyNames(re).some((t=>re[t]===e));class oe{}oe.AFKTimeoutSecs="AFKTimeout",oe.MinQP="MinQP",oe.MaxQP="MaxQP",oe.WebRTCFPS="WebRTCFPS",oe.WebRTCMinBitrate="WebRTCMinBitrate",oe.WebRTCMaxBitrate="WebRTCMaxBitrate";const ae=e=>Object.getOwnPropertyNames(oe).some((t=>oe[t]===e));class de{}de.SignallingServerUrl="ss";const le=e=>Object.getOwnPropertyNames(de).some((t=>de[t]===e));class ce{}ce.PreferredCodec="PreferredCodec",ce.StreamerId="StreamerId";const he=e=>Object.getOwnPropertyNames(ce).some((t=>ce[t]===e));class ge{constructor(e={}){this.flags=new Map,this.numericParameters=new Map,this.textParameters=new Map,this.optionParameters=new Map;const{initialSettings:t,useUrlParams:n}=e;this._useUrlParams=!!n,this.populateDefaultSettings(this._useUrlParams),t&&this.setSettings(t)}get useUrlParams(){return this._useUrlParams}populateDefaultSettings(e){this.textParameters.set(de.SignallingServerUrl,new P$1(de.SignallingServerUrl,"Signalling url","Url of the signalling server",("https:"===location.protocol?"wss://":"ws://")+window.location.hostname+("80"===window.location.port||""===window.location.port?"":`:${window.location.port}`),e)),this.optionParameters.set(ce.StreamerId,new k$1(ce.StreamerId,"Streamer ID","The ID of the streamer to stream.","",[],e)),this.optionParameters.set(ce.PreferredCodec,new k$1(ce.PreferredCodec,"Preferred Codec","The preferred codec to be used during codec negotiation","H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",function(){const e=[];if(!RTCRtpReceiver.getCapabilities)return e.push("Only available on Chrome"),e;const t=/(VP\d|H26\d|AV1).*/;return RTCRtpReceiver.getCapabilities("video").codecs.forEach((n=>{const r=n.mimeType.split("/")[1]+" "+(n.sdpFmtpLine||"");null!==t.exec(r)&&e.push(r)})),e}(),e)),this.flags.set(re.AutoConnect,new M$1(re.AutoConnect,"Auto connect to stream","Whether we should attempt to auto connect to the signalling server or show a click to start prompt.",!1,e)),this.flags.set(re.AutoPlayVideo,new M$1(re.AutoPlayVideo,"Auto play video","When video is ready automatically start playing it as opposed to showing a play button.",!0,e)),this.flags.set(re.BrowserSendOffer,new M$1(re.BrowserSendOffer,"Browser send offer","Browser will initiate the WebRTC handshake by sending the offer to the streamer",!1,e)),this.flags.set(re.UseMic,new M$1(re.UseMic,"Use microphone","Make browser request microphone access and open an input audio track.",!1,e)),this.flags.set(re.StartVideoMuted,new M$1(re.StartVideoMuted,"Start video muted","Video will start muted if true.",!1,e)),this.flags.set(re.SuppressBrowserKeys,new M$1(re.SuppressBrowserKeys,"Suppress browser keys","Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.",!0,e)),this.flags.set(re.PreferSFU,new M$1(re.PreferSFU,"Prefer SFU","Try to connect to the SFU instead of P2P.",!1,e)),this.flags.set(re.IsQualityController,new M$1(re.IsQualityController,"Is quality controller?","True if this peer controls stream quality",!0,e)),this.flags.set(re.ForceMonoAudio,new M$1(re.ForceMonoAudio,"Force mono audio","Force browser to request mono audio in the SDP",!1,e)),this.flags.set(re.ForceTURN,new M$1(re.ForceTURN,"Force TURN","Only generate TURN/Relayed ICE candidates.",!1,e)),this.flags.set(re.AFKDetection,new M$1(re.AFKDetection,"AFK if idle","Timeout the experience if user is AFK for a period.",!1,e)),this.flags.set(re.MatchViewportResolution,new M$1(re.MatchViewportResolution,"Match viewport resolution","Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.",!1,e)),this.flags.set(re.HoveringMouseMode,new M$1(re.HoveringMouseMode,"Control Scheme: Locked Mouse","Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.",!1,e,((e,t)=>{t.label=`Control Scheme: ${e?"Hovering":"Locked"} Mouse`}))),this.flags.set(re.FakeMouseWithTouches,new M$1(re.FakeMouseWithTouches,"Fake mouse with touches","A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.",!1,e)),this.flags.set(re.KeyboardInput,new M$1(re.KeyboardInput,"Keyboard input","If enabled, send keyboard events to streamer",!0,e)),this.flags.set(re.MouseInput,new M$1(re.MouseInput,"Mouse input","If enabled, send mouse events to streamer",!0,e)),this.flags.set(re.TouchInput,new M$1(re.TouchInput,"Touch input","If enabled, send touch events to streamer",!0,e)),this.flags.set(re.GamepadInput,new M$1(re.GamepadInput,"Gamepad input","If enabled, send gamepad events to streamer",!0,e)),this.flags.set(re.XRControllerInput,new M$1(re.XRControllerInput,"XR controller input","If enabled, send XR controller events to streamer",!0,e)),this.numericParameters.set(oe.AFKTimeoutSecs,new w$2(oe.AFKTimeoutSecs,"AFK timeout","The time (in seconds) it takes for the application to time out if AFK timeout is enabled.",0,600,120,e)),this.numericParameters.set(oe.MinQP,new w$2(oe.MinQP,"Min QP","The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.",0,51,0,e)),this.numericParameters.set(oe.MaxQP,new w$2(oe.MaxQP,"Max QP","The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.",0,51,51,e)),this.numericParameters.set(oe.WebRTCFPS,new w$2(oe.WebRTCFPS,"Max FPS","The maximum FPS that WebRTC will try to transmit frames at.",1,999,60,e)),this.numericParameters.set(oe.WebRTCMinBitrate,new w$2(oe.WebRTCMinBitrate,"Min Bitrate (kbps)","The minimum bitrate that WebRTC should use.",0,5e5,0,e)),this.numericParameters.set(oe.WebRTCMaxBitrate,new w$2(oe.WebRTCMaxBitrate,"Max Bitrate (kbps)","The maximum bitrate that WebRTC should use.",0,5e5,0,e))}_addOnNumericSettingChangedListener(e,t){this.numericParameters.has(e)&&this.numericParameters.get(e).addOnChangedListener(t)}_addOnOptionSettingChangedListener(e,t){this.optionParameters.has(e)&&this.optionParameters.get(e).addOnChangedListener(t)}getNumericSettingValue(e){if(this.numericParameters.has(e))return this.numericParameters.get(e).number;throw new Error(`There is no numeric setting with the id of ${e}`)}getTextSettingValue(e){if(this.textParameters.has(e))return this.textParameters.get(e).value;throw new Error(`There is no numeric setting with the id of ${e}`)}setNumericSetting(e,t){if(!this.numericParameters.has(e))throw new Error(`There is no numeric setting with the id of ${e}`);this.numericParameters.get(e).number=t}_addOnSettingChangedListener(e,t){this.flags.has(e)&&(this.flags.get(e).onChange=t)}_addOnTextSettingChangedListener(e,t){this.textParameters.has(e)&&(this.textParameters.get(e).onChange=t)}getSettingOption(e){return this.optionParameters.get(e)}isFlagEnabled(e){return this.flags.get(e).flag}setFlagEnabled(e,t){this.flags.has(e)?this.flags.get(e).flag=t:i.Warning(i.GetStackTrace(),`Cannot toggle flag called ${e} - it does not exist in the Config.flags map.`)}setTextSetting(e,t){this.textParameters.has(e)?this.textParameters.get(e).text=t:i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.textParameters map.`)}setOptionSettingOptions(e,t){this.optionParameters.has(e)?this.optionParameters.get(e).options=t:i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.optionParameters map.`)}setOptionSettingValue(e,t){this.optionParameters.has(e)?this.optionParameters.get(e).selected=t:i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.enumParameters map.`)}setFlagLabel(e,t){this.flags.has(e)?this.flags.get(e).label=t:i.Warning(i.GetStackTrace(),`Cannot set label for flag called ${e} - it does not exist in the Config.flags map.`)}setSettings(e){for(const t of Object.keys(e))ie(t)?this.setFlagEnabled(t,e[t]):ae(t)?this.setNumericSetting(t,e[t]):le(t)?this.setTextSetting(t,e[t]):he(t)&&this.setOptionSettingValue(t,e[t])}getSettings(){const e={};for(const[t,n]of this.flags.entries())e[t]=n.flag;for(const[t,n]of this.numericParameters.entries())e[t]=n.number;for(const[t,n]of this.textParameters.entries())e[t]=n.text;for(const[t,n]of this.optionParameters.entries())e[t]=n.selected;return e}getFlags(){return Array.from(this.flags.values())}getTextSettings(){return Array.from(this.textParameters.values())}getNumericSettings(){return Array.from(this.numericParameters.values())}getOptionSettings(){return Array.from(this.optionParameters.values())}_registerOnChangeEvents(e){for(const t of this.flags.keys()){const n=this.flags.get(t);n&&(n.onChangeEmit=t=>e.dispatchEvent(new Z$1({id:n.id,type:"flag",value:t,target:n})))}for(const t of this.numericParameters.keys()){const n=this.numericParameters.get(t);n&&(n.onChangeEmit=t=>e.dispatchEvent(new Z$1({id:n.id,type:"number",value:t,target:n})))}for(const t of this.textParameters.keys()){const n=this.textParameters.get(t);n&&(n.onChangeEmit=t=>e.dispatchEvent(new Z$1({id:n.id,type:"text",value:t,target:n})))}for(const t of this.optionParameters.keys()){const n=this.optionParameters.get(t);n&&(n.onChangeEmit=t=>e.dispatchEvent(new Z$1({id:n.id,type:"option",value:t,target:n})))}}}var ue;!function(e){e[e.LockedMouse=0]="LockedMouse",e[e.HoveringMouse=1]="HoveringMouse"}(ue||(ue={}));class me{constructor(e,t,n){this.closeTimeout=10,this.active=!1,this.countdownActive=!1,this.warnTimer=void 0,this.countDown=0,this.countDownTimer=void 0,this.config=e,this.pixelStreaming=t,this.onDismissAfk=n,this.onAFKTimedOutCallback=()=>{console.log("AFK timed out, did you want to override this callback?")}}onAfkClick(){clearInterval(this.countDownTimer),(this.active||this.countdownActive)&&(this.startAfkWarningTimer(),this.pixelStreaming.dispatchEvent(new x$1))}startAfkWarningTimer(){this.config.getNumericSettingValue(oe.AFKTimeoutSecs)>0&&this.config.isFlagEnabled(re.AFKDetection)?this.active=!0:this.active=!1,this.resetAfkWarningTimer()}stopAfkWarningTimer(){this.active=!1,this.countdownActive=!1,clearTimeout(this.warnTimer),clearInterval(this.countDownTimer)}pauseAfkWarningTimer(){this.active=!1}resetAfkWarningTimer(){this.active&&this.config.isFlagEnabled(re.AFKDetection)&&(clearTimeout(this.warnTimer),this.warnTimer=setTimeout((()=>this.activateAfkEvent()),1e3*this.config.getNumericSettingValue(oe.AFKTimeoutSecs)))}activateAfkEvent(){this.pauseAfkWarningTimer(),this.pixelStreaming.dispatchEvent(new R$1({countDown:this.countDown,dismissAfk:this.onDismissAfk})),this.countDown=this.closeTimeout,this.countdownActive=!0,this.pixelStreaming.dispatchEvent(new L$1({countDown:this.countDown})),this.config.isFlagEnabled(re.HoveringMouseMode)||document.exitPointerLock&&document.exitPointerLock(),this.countDownTimer=setInterval((()=>{this.countDown--,0==this.countDown?(this.pixelStreaming.dispatchEvent(new A$1),this.onAFKTimedOutCallback(),i.Log(i.GetStackTrace(),"disconnected due to inactivity"),this.stopAfkWarningTimer()):this.pixelStreaming.dispatchEvent(new L$1({countDown:this.countDown}))}),1e3)}}class Se{constructor(){this.isReceivingFreezeFrame=!1}getDataChannelInstance(){return this}createDataChannel(e,t,n){this.peerConnection=e,this.label=t,this.datachannelOptions=n,null==n&&(this.datachannelOptions={},this.datachannelOptions.ordered=!0),this.dataChannel=this.peerConnection.createDataChannel(this.label,this.datachannelOptions),this.setupDataChannel()}setupDataChannel(){this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=e=>this.handleOnOpen(e),this.dataChannel.onclose=e=>this.handleOnClose(e),this.dataChannel.onmessage=e=>this.handleOnMessage(e),this.dataChannel.onerror=e=>this.handleOnError(e)}handleOnOpen(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) opened.`,7),this.onOpen(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnClose(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) closed.`,7),this.onClose(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnMessage(e){i.Log(i.GetStackTrace(),`Data Channel (${this.label}) message: ${e}`,8)}handleOnError(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) error: ${e}`,7),this.onError(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}onOpen(e,t){}onClose(e,t){}onError(e,t){}}class pe{}class ve{}class Ce{}class fe{}class Te{}class Ee{}class ye{}class be{}class Me{constructor(){this.inboundVideoStats=new ve,this.inboundAudioStats=new pe,this.candidatePair=new Te,this.DataChannelStats=new Ce,this.outBoundVideoStats=new Ee,this.sessionStats=new ye,this.streamStats=new be,this.codecs=new Map}processStats(e){this.localCandidates=new Array,this.remoteCandidates=new Array,e.forEach((e=>{switch(e.type){case"candidate-pair":this.handleCandidatePair(e);break;case"certificate":case"media-source":case"outbound-rtp":case"peer-connection":case"remote-inbound-rtp":case"transport":break;case"codec":this.handleCodec(e);break;case"data-channel":this.handleDataChannel(e);break;case"inbound-rtp":this.handleInBoundRTP(e);break;case"local-candidate":this.handleLocalCandidate(e);break;case"remote-candidate":this.handleRemoteCandidate(e);break;case"remote-outbound-rtp":this.handleRemoteOutBound(e);break;case"track":this.handleTrack(e);break;case"stream":this.handleStream(e);break;default:i.Error(i.GetStackTrace(),"unhandled Stat Type"),i.Log(i.GetStackTrace(),e)}}))}handleStream(e){this.streamStats=e}handleCandidatePair(e){this.candidatePair.bytesReceived=e.bytesReceived,this.candidatePair.bytesSent=e.bytesSent,this.candidatePair.localCandidateId=e.localCandidateId,this.candidatePair.remoteCandidateId=e.remoteCandidateId,this.candidatePair.nominated=e.nominated,this.candidatePair.readable=e.readable,this.candidatePair.selected=e.selected,this.candidatePair.writable=e.writable,this.candidatePair.state=e.state,this.candidatePair.currentRoundTripTime=e.currentRoundTripTime}handleDataChannel(e){this.DataChannelStats.bytesReceived=e.bytesReceived,this.DataChannelStats.bytesSent=e.bytesSent,this.DataChannelStats.dataChannelIdentifier=e.dataChannelIdentifier,this.DataChannelStats.id=e.id,this.DataChannelStats.label=e.label,this.DataChannelStats.messagesReceived=e.messagesReceived,this.DataChannelStats.messagesSent=e.messagesSent,this.DataChannelStats.protocol=e.protocol,this.DataChannelStats.state=e.state,this.DataChannelStats.timestamp=e.timestamp}handleLocalCandidate(e){const t=new fe;t.label="local-candidate",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.candidateType=e.candidateType,t.id=e.id,this.localCandidates.push(t)}handleRemoteCandidate(e){const t=new fe;t.label="local-candidate",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.id=e.id,t.candidateType=e.candidateType,this.remoteCandidates.push(t)}handleInBoundRTP(e){switch(e.kind){case"video":this.inboundVideoStats=e,null!=this.lastVideoStats&&(this.inboundVideoStats.bitrate=8*(this.inboundVideoStats.bytesReceived-this.lastVideoStats.bytesReceived)/(this.inboundVideoStats.timestamp-this.lastVideoStats.timestamp),this.inboundVideoStats.bitrate=Math.floor(this.inboundVideoStats.bitrate)),this.lastVideoStats=Object.assign({},this.inboundVideoStats);break;case"audio":this.inboundAudioStats=e,null!=this.lastAudioStats&&(this.inboundAudioStats.bitrate=8*(this.inboundAudioStats.bytesReceived-this.lastAudioStats.bytesReceived)/(this.inboundAudioStats.timestamp-this.lastAudioStats.timestamp),this.inboundAudioStats.bitrate=Math.floor(this.inboundAudioStats.bitrate)),this.lastAudioStats=Object.assign({},this.inboundAudioStats);break;default:i.Log(i.GetStackTrace(),"Kind is not handled")}}handleRemoteOutBound(e){"video"===e.kind&&(this.outBoundVideoStats.bytesSent=e.bytesSent,this.outBoundVideoStats.id=e.id,this.outBoundVideoStats.localId=e.localId,this.outBoundVideoStats.packetsSent=e.packetsSent,this.outBoundVideoStats.remoteTimestamp=e.remoteTimestamp,this.outBoundVideoStats.timestamp=e.timestamp)}handleTrack(e){"track"!==e.type||"video_label"!==e.trackIdentifier&&"video"!==e.kind||(this.inboundVideoStats.framesDropped=e.framesDropped,this.inboundVideoStats.framesReceived=e.framesReceived,this.inboundVideoStats.frameHeight=e.frameHeight,this.inboundVideoStats.frameWidth=e.frameWidth)}handleCodec(e){const t=e.id,n=`${e.mimeType.replace("video/","").replace("audio/","")}${e.sdpFmtpLine?` ${e.sdpFmtpLine}`:""}`;this.codecs.set(t,n)}handleSessionStatistics(e,t,n){const r=Date.now()-e;this.sessionStats.runTime=new Date(r).toISOString().substr(11,8).toString();const i=null===t?"Not sent yet":t?"true":"false";this.sessionStats.controlsStreamInput=i,this.sessionStats.videoEncoderAvgQP=n}isNumber(e){return"number"==typeof e&&isFinite(e)}}const we=(Pe={parseRtpParameters:()=>sdp.exports.parseRtpParameters,splitSections:()=>sdp.exports.splitSections},ke={},n$1.d(ke,Pe),ke);var Pe,ke,Re,Le,xe=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((r=r.apply(e,t||[])).next())}))};class Ae{constructor(e,t,n){this.config=t,this.createPeerConnection(e,n)}createPeerConnection(e,t){this.config.isFlagEnabled(re.ForceTURN)&&(e.iceTransportPolicy="relay",i.Log(i.GetStackTrace(),"Forcing TURN usage by setting ICE Transport Policy in peer connection config.")),this.peerConnection=new RTCPeerConnection(e),this.peerConnection.onsignalingstatechange=e=>this.handleSignalStateChange(e),this.peerConnection.oniceconnectionstatechange=e=>this.handleIceConnectionStateChange(e),this.peerConnection.onicegatheringstatechange=e=>this.handleIceGatheringStateChange(e),this.peerConnection.ontrack=e=>this.handleOnTrack(e),this.peerConnection.onicecandidate=e=>this.handleIceCandidate(e),this.peerConnection.ondatachannel=e=>this.handleDataChannel(e),this.aggregatedStats=new Me,this.preferredCodec=t,this.updateCodecSelection=!0}createOffer(e,t){return xe(this,void 0,void 0,(function*(){i.Log(i.GetStackTrace(),"Create Offer",6);const n="localhost"===location.hostname||"127.0.0.1"===location.hostname,r="https:"===location.protocol;let s=t.isFlagEnabled(re.UseMic);!s||n||r||(s=!1,i.Error(i.GetStackTrace(),"https only"),i.Error(i.GetStackTrace(),"enable 'unsafely-treat-insecure-origin-as-secure'")),this.setupTransceiversAsync(s).finally((()=>{var t;null===(t=this.peerConnection)||void 0===t||t.createOffer(e).then((e=>{var t;this.showTextOverlayConnecting(),e.sdp=this.mungeSDP(e.sdp,s),null===(t=this.peerConnection)||void 0===t||t.setLocalDescription(e),this.onSendWebRTCOffer(e)})).catch((()=>{this.showTextOverlaySetupFailure()}))}))}))}receiveOffer(e,t){var n;return xe(this,void 0,void 0,(function*(){i.Log(i.GetStackTrace(),"Receive Offer",6),null===(n=this.peerConnection)||void 0===n||n.setRemoteDescription(e).then((()=>{const e="localhost"===location.hostname||"127.0.0.1"===location.hostname,n="https:"===location.protocol;let r=t.isFlagEnabled(re.UseMic);!r||e||n||(r=!1,i.Error(i.GetStackTrace(),"https only"),i.Error(i.GetStackTrace(),"enable 'unsafely-treat-insecure-origin-as-secure'")),this.setupTransceiversAsync(r).finally((()=>{var e;null===(e=this.peerConnection)||void 0===e||e.createAnswer().then((e=>{var t;return e.sdp=this.mungeSDP(e.sdp,r),null===(t=this.peerConnection)||void 0===t?void 0:t.setLocalDescription(e)})).then((()=>{var e;this.onSendWebRTCAnswer(null===(e=this.peerConnection)||void 0===e?void 0:e.currentLocalDescription)})).catch((()=>{i.Error(i.GetStackTrace(),"createAnswer() failed")}))}))})),this.config.setOptionSettingOptions(ce.PreferredCodec,this.parseAvailableCodecs(e).filter((e=>this.config.getSettingOption(ce.PreferredCodec).options.includes(e))))}))}receiveAnswer(e){var t;null===(t=this.peerConnection)||void 0===t||t.setRemoteDescription(e),this.config.setOptionSettingOptions(ce.PreferredCodec,this.parseAvailableCodecs(e).filter((e=>this.config.getSettingOption(ce.PreferredCodec).options.includes(e))))}generateStats(){var e;null===(e=this.peerConnection)||void 0===e||e.getStats(null).then((e=>{this.aggregatedStats.processStats(e),this.onVideoStats(this.aggregatedStats),this.updateCodecSelection&&this.config.setOptionSettingValue(ce.PreferredCodec,this.aggregatedStats.codecs.get(this.aggregatedStats.inboundVideoStats.codecId))}))}close(){this.peerConnection&&(this.peerConnection.close(),this.peerConnection=null)}mungeSDP(e,t){const n=e;n.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=10000;x-google-max-bitrate=100000\r\n");let r="";return r+="maxaveragebitrate=510000;",t&&(r+="sprop-maxcapturerate=48000;"),r+=this.config.isFlagEnabled(re.ForceMonoAudio)?"stereo=0;":"stereo=1;",r+="useinbandfec=1",n.replace("useinbandfec=1",r),n}handleOnIce(e){var t;i.Log(i.GetStackTrace(),"peerconnection handleOnIce",6),this.config.isFlagEnabled(re.ForceTURN)&&e.candidate.indexOf("relay")<0?i.Info(i.GetStackTrace(),`Dropping candidate because it was not TURN relay. | Type= ${e.type} | Protocol= ${e.protocol} | Address=${e.address} | Port=${e.port} |`,6):null===(t=this.peerConnection)||void 0===t||t.addIceCandidate(e)}handleSignalStateChange(e){i.Log(i.GetStackTrace(),"signaling state change: "+e,6)}handleIceConnectionStateChange(e){i.Log(i.GetStackTrace(),"ice connection state change: "+e,6),this.onIceConnectionStateChange(e)}handleIceGatheringStateChange(e){i.Log(i.GetStackTrace(),"ice gathering state change: "+JSON.stringify(e),6)}handleOnTrack(e){this.onTrack(e)}handleIceCandidate(e){this.onPeerIceCandidate(e)}handleDataChannel(e){this.onDataChannel(e)}onTrack(e){}onIceConnectionStateChange(e){}onPeerIceCandidate(e){}onDataChannel(e){}setupTransceiversAsync(e){var t,n,r,i,s,o,a,l,c;return xe(this,void 0,void 0,(function*(){const d=(null===(t=this.peerConnection)||void 0===t?void 0:t.getTransceivers().length)>0;if(null===(n=this.peerConnection)||void 0===n||n.addTransceiver("video",{direction:"recvonly"}),RTCRtpReceiver.getCapabilities&&""!=this.preferredCodec)for(const e of null!==(i=null===(r=this.peerConnection)||void 0===r?void 0:r.getTransceivers())&&void 0!==i?i:[])if(e&&e.receiver&&e.receiver.track&&"video"===e.receiver.track.kind){const t=this.preferredCodec.split(" "),n=[{mimeType:"video/"+t[0],clockRate:9e4,sdpFmtpLine:t[1]?t[1]:""}];this.config.getSettingOption(ce.PreferredCodec).options.filter((e=>e!=this.preferredCodec)).forEach((e=>{const t=e.split(" ");n.push({mimeType:"video/"+t[0],clockRate:9e4,sdpFmtpLine:t[1]?t[1]:""})}));for(const e of n)""===e.sdpFmtpLine&&delete e.sdpFmtpLine;e.setCodecPreferences(n)}if(e){const t={video:!1,audio:!!e&&{autoGainControl:!1,channelCount:1,echoCancellation:!1,latency:0,noiseSuppression:!1,sampleRate:48e3,sampleSize:16,volume:1}},n=yield navigator.mediaDevices.getUserMedia(t);if(n)if(d){for(const e of null!==(a=null===(o=this.peerConnection)||void 0===o?void 0:o.getTransceivers())&&void 0!==a?a:[])if(e&&e.receiver&&e.receiver.track&&"audio"===e.receiver.track.kind)for(const t of n.getTracks())t.kind&&"audio"==t.kind&&(e.sender.replaceTrack(t),e.direction="sendrecv")}else for(const e of n.getTracks())e.kind&&"audio"==e.kind&&(null===(l=this.peerConnection)||void 0===l||l.addTransceiver(e,{direction:"sendrecv"}));else null===(c=this.peerConnection)||void 0===c||c.addTransceiver("audio",{direction:"recvonly"})}else null===(s=this.peerConnection)||void 0===s||s.addTransceiver("audio",{direction:"recvonly"})}))}onVideoStats(e){}onSendWebRTCOffer(e){}onSendWebRTCAnswer(e){}showTextOverlayConnecting(){}showTextOverlaySetupFailure(){}parseAvailableCodecs(e){if(!RTCRtpReceiver.getCapabilities)return["Only available on Chrome"];const t=[],n=(0,we.splitSections)(e.sdp);return n.shift(),n.forEach((e=>{const{codecs:n}=(0,we.parseRtpParameters)(e),r=/(VP\d|H26\d|AV1).*/;n.forEach((e=>{const n=e.name+" "+Object.keys(e.parameters||{}).map((t=>t+"="+e.parameters[t])).join(";");if(null!==r.exec(n)){"VP9"==e.name&&(e.parameters={"profile-id":"0"});const n=e.name+" "+Object.keys(e.parameters||{}).map((t=>t+"="+e.parameters[t])).join(";");t.push(n)}}))})),t}}class Fe{constructor(){this.PixelStreamingSettings=new De,this.EncoderSettings=new Oe,this.WebRTCSettings=new Ue}ueCompatible(){null!=this.WebRTCSettings.MaxFPS&&(this.WebRTCSettings.FPS=this.WebRTCSettings.MaxFPS)}}class De{}class Oe{}class Ue{}class Ie{constructor(){this.ReceiptTimeMs=null,this.TransmissionTimeMs=null,this.PreCaptureTimeMs=null,this.PostCaptureTimeMs=null,this.PreEncodeTimeMs=null,this.PostEncodeTimeMs=null,this.EncodeMs=null,this.CaptureToSendMs=null,this.testStartTimeMs=0,this.browserReceiptTimeMs=0,this.latencyExcludingDecode=0,this.testDuration=0,this.networkLatency=0,this.browserSendLatency=0,this.frameDisplayDeltaTimeMs=0,this.endToEndLatency=0,this.encodeLatency=0}setFrameDisplayDeltaTime(e){0==this.frameDisplayDeltaTimeMs&&(this.frameDisplayDeltaTimeMs=Math.round(e))}processFields(){null!=this.EncodeMs||null==this.PreEncodeTimeMs&&null==this.PostEncodeTimeMs||(i.Log(i.GetStackTrace(),`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`,6),this.EncodeMs=this.PostEncodeTimeMs-this.PreEncodeTimeMs),null!=this.CaptureToSendMs||null==this.PreCaptureTimeMs&&null==this.PostCaptureTimeMs||(i.Log(i.GetStackTrace(),`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`,6),this.CaptureToSendMs=this.PostCaptureTimeMs-this.PreCaptureTimeMs)}}class Ge{static setExtensionFromBytes(e,t){t.receiving||(t.mimetype="",t.extension="",t.receiving=!0,t.valid=!1,t.size=0,t.data=[],t.timestampStart=(new Date).getTime(),i.Log(i.GetStackTrace(),"Received first chunk of file",6));const n=new TextDecoder("utf-16").decode(e.slice(1));i.Log(i.GetStackTrace(),n,6),t.extension=n}static setMimeTypeFromBytes(e,t){t.receiving||(t.mimetype="",t.extension="",t.receiving=!0,t.valid=!1,t.size=0,t.data=[],t.timestampStart=(new Date).getTime(),i.Log(i.GetStackTrace(),"Received first chunk of file",6));const n=new TextDecoder("utf-16").decode(e.slice(1));i.Log(i.GetStackTrace(),n,6),t.mimetype=n}static setContentsFromBytes(e,t){if(!t.receiving)return;t.size=Math.ceil(new DataView(e.slice(1,5).buffer).getInt32(0,!0)/16379);const n=e.slice(5);if(t.data.push(n),i.Log(i.GetStackTrace(),`Received file chunk: ${t.data.length}/${t.size}`,6),t.data.length===t.size){t.receiving=!1,t.valid=!0,i.Log(i.GetStackTrace(),"Received complete file",6);const e=(new Date).getTime()-t.timestampStart,n=Math.round(16*t.size*1024/e);i.Log(i.GetStackTrace(),`Average transfer bitrate: ${n}kb/s over ${e/1e3} seconds`,6);const r=new Blob(t.data,{type:t.mimetype}),s=document.createElement("a");s.setAttribute("href",URL.createObjectURL(r)),s.setAttribute("download",`transfer.${t.extension}`),document.body.append(s),s.remove()}else t.data.length>t.size&&(t.receiving=!1,i.Error(i.GetStackTrace(),`Received bigger file than advertised: ${t.data.length}/${t.size}`))}}class ze{constructor(){this.mimetype="",this.extension="",this.receiving=!1,this.size=0,this.data=[],this.valid=!1}}class Be{}Be.mainButton=0,Be.auxiliaryButton=1,Be.secondaryButton=2,Be.fourthButton=3,Be.fifthButton=4;class _e{}_e.primaryButton=1,_e.secondaryButton=2,_e.auxiliaryButton=4,_e.fourthButton=8,_e.fifthButton=16;class We{constructor(){this.unregisterCallbacks=[]}addUnregisterCallback(e){this.unregisterCallbacks.push(e)}unregisterAll(){for(const e of this.unregisterCallbacks)e();this.unregisterCallbacks=[]}}class He{constructor(e,t,n){this.touchEventListenerTracker=new We,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=n;const r=e=>this.onTouchStart(e),i=e=>this.onTouchEnd(e),s=e=>this.onTouchMove(e);document.addEventListener("touchstart",r,{passive:!1}),document.addEventListener("touchend",i,{passive:!1}),document.addEventListener("touchmove",s,{passive:!1}),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("touchstart",r))),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("touchend",i))),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("touchmove",s)))}unregisterTouchEvents(){this.touchEventListenerTracker.unregisterAll()}setVideoElementParentClientRect(e){this.videoElementParentClientRect=e}onTouchStart(e){if(this.videoElementProvider.isVideoReady()){if(null==this.fakeTouchFinger){const t=e.changedTouches[0];this.fakeTouchFinger=new Ve(t.identifier,t.clientX-this.videoElementParentClientRect.left,t.clientY-this.videoElementParentClientRect.top);const n=this.videoElementProvider.getVideoParentElement(),r=new MouseEvent("mouseenter",t);n.dispatchEvent(r);const i=this.coordinateConverter.normalizeAndQuantizeUnsigned(this.fakeTouchFinger.x,this.fakeTouchFinger.y);this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([Be.mainButton,i.x,i.y])}e.preventDefault()}}onTouchEnd(e){if(!this.videoElementProvider.isVideoReady())return;const t=this.videoElementProvider.getVideoParentElement(),n=this.toStreamerMessagesProvider.toStreamerHandlers;for(let r=0;r<e.changedTouches.length;r++){const i=e.changedTouches[r];if(i.identifier===this.fakeTouchFinger.id){const e=i.clientX-this.videoElementParentClientRect.left,r=i.clientY-this.videoElementParentClientRect.top,s=this.coordinateConverter.normalizeAndQuantizeUnsigned(e,r);n.get("MouseUp")([Be.mainButton,s.x,s.y]);const o=new MouseEvent("mouseleave",i);t.dispatchEvent(o),this.fakeTouchFinger=null;break}}e.preventDefault()}onTouchMove(e){if(!this.videoElementProvider.isVideoReady())return;const t=this.toStreamerMessagesProvider.toStreamerHandlers;for(let n=0;n<e.touches.length;n++){const r=e.touches[n];if(r.identifier===this.fakeTouchFinger.id){const e=r.clientX-this.videoElementParentClientRect.left,n=r.clientY-this.videoElementParentClientRect.top,i=this.coordinateConverter.normalizeAndQuantizeUnsigned(e,n),s=this.coordinateConverter.normalizeAndQuantizeSigned(e-this.fakeTouchFinger.x,n-this.fakeTouchFinger.y);t.get("MouseMove")([i.x,i.y,s.x,s.y]),this.fakeTouchFinger.x=e,this.fakeTouchFinger.y=n;break}}e.preventDefault()}}class Ve{constructor(e,t,n){this.id=e,this.x=t,this.y=n}}class Ne{}Ne.backSpace=8,Ne.shift=16,Ne.control=17,Ne.alt=18,Ne.rightShift=253,Ne.rightControl=254,Ne.rightAlt=255;class Ke{constructor(e,t,n){this.keyboardEventListenerTracker=new We,this.CodeToKeyCode={Escape:27,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,Minus:173,Equal:187,Backspace:8,Tab:9,KeyQ:81,KeyW:87,KeyE:69,KeyR:82,KeyT:84,KeyY:89,KeyU:85,KeyI:73,KeyO:79,KeyP:80,BracketLeft:219,BracketRight:221,Enter:13,ControlLeft:17,KeyA:65,KeyS:83,KeyD:68,KeyF:70,KeyG:71,KeyH:72,KeyJ:74,KeyK:75,KeyL:76,Semicolon:186,Quote:222,Backquote:192,ShiftLeft:16,Backslash:220,KeyZ:90,KeyX:88,KeyC:67,KeyV:86,KeyB:66,KeyN:78,KeyM:77,Comma:188,Period:190,Slash:191,ShiftRight:253,AltLeft:18,Space:32,CapsLock:20,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,Pause:19,ScrollLock:145,NumpadDivide:111,NumpadMultiply:106,NumpadSubtract:109,NumpadAdd:107,NumpadDecimal:110,Numpad9:105,Numpad8:104,Numpad7:103,Numpad6:102,Numpad5:101,Numpad4:100,Numpad3:99,Numpad2:98,Numpad1:97,Numpad0:96,NumLock:144,ControlRight:254,AltRight:255,Home:36,End:35,ArrowUp:38,ArrowLeft:37,ArrowRight:39,ArrowDown:40,PageUp:33,PageDown:34,Insert:45,Delete:46,ContextMenu:93},this.toStreamerMessagesProvider=e,this.config=t,this.activeKeysProvider=n}registerKeyBoardEvents(){const e=e=>this.handleOnKeyDown(e),t=e=>this.handleOnKeyUp(e),n=e=>this.handleOnKeyPress(e);document.addEventListener("keydown",e),document.addEventListener("keyup",t),document.addEventListener("keypress",n),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("keydown",e))),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("keyup",t))),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("keypress",n)))}unregisterKeyBoardEvents(){this.keyboardEventListenerTracker.unregisterAll()}handleOnKeyDown(e){const t=this.getKeycode(e);t&&(i.Log(i.GetStackTrace(),`key down ${t}, repeat = ${e.repeat}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyDown")([this.getKeycode(e),e.repeat?1:0]),this.activeKeysProvider.getActiveKeys().push(t),t===Ne.backSpace&&document.dispatchEvent(new KeyboardEvent("keypress",{charCode:Ne.backSpace})),this.config.isFlagEnabled(re.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyUp(e){const t=this.getKeycode(e);t&&(i.Log(i.GetStackTrace(),`key up ${t}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyUp")([t,e.repeat?1:0]),this.config.isFlagEnabled(re.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyPress(e){if(!("charCode"in e))return void i.Warning(i.GetStackTrace(),"KeyboardEvent.charCode is deprecated in this browser, cannot send key press.");const t=e.charCode;i.Log(i.GetStackTrace(),`key press ${t}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyPress")([t])}getKeycode(e){if(!("keyCode"in e)){const t=e;return t.code in this.CodeToKeyCode?this.CodeToKeyCode[t.code]:(i.Warning(i.GetStackTrace(),`Keyboard code of ${t.code} is not supported in our mapping, ignoring this key.`),null)}return e.keyCode===Ne.shift&&"ShiftRight"===e.code?Ne.rightShift:e.keyCode===Ne.control&&"ControlRight"===e.code?Ne.rightControl:e.keyCode===Ne.alt&&"AltRight"===e.code?Ne.rightAlt:e.keyCode}isKeyCodeBrowserKey(e){return e>=112&&e<=123||9===e}}class Qe{constructor(e,t,n){this.x=0,this.y=0,this.updateMouseMovePositionEvent=e=>{this.updateMouseMovePosition(e)},this.mouseEventListenerTracker=new We,this.videoElementProvider=e,this.mouseController=t,this.activeKeysProvider=n;const r=this.videoElementProvider.getVideoParentElement();this.x=r.getBoundingClientRect().width/2,this.y=r.getBoundingClientRect().height/2,this.coord=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x,this.y)}unregisterMouseEvents(){this.mouseEventListenerTracker.unregisterAll()}lockStateChange(){const e=this.videoElementProvider.getVideoParentElement(),t=this.mouseController.toStreamerMessagesProvider.toStreamerHandlers;if(document.pointerLockElement===e||document.mozPointerLockElement===e)i.Log(i.GetStackTrace(),"Pointer locked",6),document.addEventListener("mousemove",this.updateMouseMovePositionEvent,!1),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("mousemove",this.updateMouseMovePositionEvent,!1)));else{i.Log(i.GetStackTrace(),"The pointer lock status is now unlocked",6),document.removeEventListener("mousemove",this.updateMouseMovePositionEvent,!1);let e=this.activeKeysProvider.getActiveKeys();const n=[];new Set(e).forEach((e=>{})),n.forEach((e=>{t.get("KeyUp")([e])})),e=[]}}updateMouseMovePosition(e){if(!this.videoElementProvider.isVideoReady())return;const t=this.mouseController.toStreamerMessagesProvider.toStreamerHandlers,n=this.videoElementProvider.getVideoParentElement().clientWidth,r=this.videoElementProvider.getVideoParentElement().clientHeight;this.x+=e.movementX,this.y+=e.movementY,this.x>n&&(this.x-=n),this.y>r&&(this.y-=r),this.x<0&&(this.x=n+this.x),this.y<0&&(this.y=r-this.y),this.coord=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x,this.y);const i=this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX,e.movementY);t.get("MouseMove")([this.coord.x,this.coord.y,i.x,i.y])}handleMouseDown(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e.button,this.coord.x,this.coord.y])}handleMouseUp(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e.button,this.coord.x,this.coord.y])}handleMouseWheel(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseWheel")([e.wheelDelta,this.coord.x,this.coord.y])}handleMouseDouble(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDouble")([e.button,this.coord.x,this.coord.y])}handlePressMouseButtons(e){this.videoElementProvider.isVideoReady()&&this.mouseController.pressMouseButtons(e.buttons,this.x,this.y)}handleReleaseMouseButtons(e){this.videoElementProvider.isVideoReady()&&this.mouseController.releaseMouseButtons(e.buttons,this.x,this.y)}}class $e{constructor(e){this.mouseController=e}unregisterMouseEvents(){}updateMouseMovePosition(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),"MouseMove",6);const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY),n=this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX,e.movementY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseMove")([t.x,t.y,n.x,n.y]),e.preventDefault()}handleMouseDown(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),"onMouse Down",6);const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e.button,t.x,t.y]),e.preventDefault()}handleMouseUp(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e.button,t.x,t.y]),e.preventDefault()}handleContextMenu(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e.button,t.x,t.y]),e.preventDefault()}handleMouseWheel(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseWheel")([e.wheelDelta,t.x,t.y]),e.preventDefault()}handleMouseDouble(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDouble")([e.button,t.x,t.y])}handlePressMouseButtons(e){this.mouseController.videoElementProvider.isVideoReady()&&this.mouseController.pressMouseButtons(e.buttons,e.offsetX,e.offsetY)}handleReleaseMouseButtons(e){this.mouseController.videoElementProvider.isVideoReady()&&this.mouseController.releaseMouseButtons(e.buttons,e.offsetX,e.offsetY)}}class qe{constructor(e,t,n,r){this.mouseEventListenerTracker=new We,this.toStreamerMessagesProvider=e,this.coordinateConverter=n,this.videoElementProvider=t,this.activeKeysProvider=r,this.registerMouseEnterAndLeaveEvents()}unregisterMouseEvents(){this.mouseEventListenerTracker.unregisterAll()}registerLockedMouseEvents(e){const t=this.videoElementProvider.getVideoParentElement(),n=new Qe(this.videoElementProvider,e,this.activeKeysProvider);if(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock,document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock,t.requestPointerLock){const e=()=>{t.requestPointerLock()};t.addEventListener("click",e),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("click",e)))}const r=()=>n.lockStateChange();document.addEventListener("pointerlockchange",r,!1),document.addEventListener("mozpointerlockchange",r,!1),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("pointerlockchange",r,!1))),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("mozpointerlockchange",r,!1)));const i=e=>n.handleMouseDown(e),s=e=>n.handleMouseUp(e),o=e=>n.handleMouseWheel(e),a=e=>n.handleMouseDouble(e);t.addEventListener("mousedown",i),t.addEventListener("mouseup",s),t.addEventListener("wheel",o),t.addEventListener("dblclick",a),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("mousedown",i))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("mouseup",s))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("wheel",o))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("dblclick",a))),this.mouseEventListenerTracker.addUnregisterCallback((()=>n.unregisterMouseEvents())),this.mouseEventListenerTracker.addUnregisterCallback((()=>{!document.exitPointerLock||document.pointerLockElement!==t&&document.mozPointerLockElement!==t||document.exitPointerLock()}))}registerHoveringMouseEvents(e){const t=this.videoElementProvider.getVideoParentElement(),n=new $e(e),r=e=>n.updateMouseMovePosition(e),i=e=>n.handleMouseDown(e),s=e=>n.handleMouseUp(e),o=e=>n.handleContextMenu(e),a=e=>n.handleMouseWheel(e),l=e=>n.handleMouseDouble(e);t.addEventListener("mousemove",r),t.addEventListener("mousedown",i),t.addEventListener("mouseup",s),t.addEventListener("contextmenu",o),t.addEventListener("wheel",a),t.addEventListener("dblclick",l),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("mousemove",r))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("mousedown",i))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("mouseup",s))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("contextmenu",o))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("wheel",a))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener("dblclick",l))),this.mouseEventListenerTracker.addUnregisterCallback((()=>n.unregisterMouseEvents()))}registerMouseEnterAndLeaveEvents(){const e=this.videoElementProvider.getVideoParentElement(),t=e=>{this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),"Mouse Entered",6),this.sendMouseEnter(),this.pressMouseButtons(e.buttons,e.x,e.y))},n=e=>{this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),"Mouse Left",6),this.sendMouseLeave(),this.releaseMouseButtons(e.buttons,e.x,e.y))};e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),this.mouseEventListenerTracker.addUnregisterCallback((()=>e.removeEventListener("mouseenter",t))),this.mouseEventListenerTracker.addUnregisterCallback((()=>e.removeEventListener("mouseleave",n)))}releaseMouseButtons(e,t,n){const r=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,n);e&_e.primaryButton&&this.sendMouseUp(Be.mainButton,r.x,r.y),e&_e.secondaryButton&&this.sendMouseUp(Be.secondaryButton,r.x,r.y),e&_e.auxiliaryButton&&this.sendMouseUp(Be.auxiliaryButton,r.x,r.y),e&_e.fourthButton&&this.sendMouseUp(Be.fourthButton,r.x,r.y),e&_e.fifthButton&&this.sendMouseUp(Be.fifthButton,r.x,r.y)}pressMouseButtons(e,t,n){if(!this.videoElementProvider.isVideoReady())return;const r=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,n);e&_e.primaryButton&&this.sendMouseDown(Be.mainButton,r.x,r.y),e&_e.secondaryButton&&this.sendMouseDown(Be.secondaryButton,r.x,r.y),e&_e.auxiliaryButton&&this.sendMouseDown(Be.auxiliaryButton,r.x,r.y),e&_e.fourthButton&&this.sendMouseDown(Be.fourthButton,r.x,r.y),e&_e.fifthButton&&this.sendMouseDown(Be.fifthButton,r.x,r.y)}sendMouseEnter(){this.videoElementProvider.isVideoReady()&&this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseEnter")()}sendMouseLeave(){this.videoElementProvider.isVideoReady()&&this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseLeave")()}sendMouseDown(e,t,n){this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),`mouse button ${e} down at (${t}, ${n})`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e,t,n]))}sendMouseUp(e,t,n){if(!this.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),`mouse button ${e} up at (${t}, ${n})`,6);const r=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,n);this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e,r.x,r.y])}}class Xe{constructor(e,t,n){this.fingers=[9,8,7,6,5,4,3,2,1,0],this.fingerIds=new Map,this.maxByteValue=255,this.touchEventListenerTracker=new We,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=n,this.videoElementParent=t.getVideoElement();const r=e=>this.onTouchStart(e),s=e=>this.onTouchEnd(e),o=e=>this.onTouchMove(e);this.videoElementParent.addEventListener("touchstart",r,{passive:!1}),this.videoElementParent.addEventListener("touchend",s,{passive:!1}),this.videoElementParent.addEventListener("touchmove",o,{passive:!1}),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener("touchstart",r))),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener("touchend",s))),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener("touchmove",o))),i.Log(i.GetStackTrace(),"Touch Events Registered",6);const a=e=>{e.preventDefault()};document.addEventListener("touchmove",a,{passive:!1}),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener("touchmove",a)))}unregisterTouchEvents(){this.touchEventListenerTracker.unregisterAll()}rememberTouch(e){const t=this.fingers.pop();void 0===t&&i.Log(i.GetStackTrace(),"exhausted touch identifiers",6),this.fingerIds.set(e.identifier,t)}forgetTouch(e){this.fingers.push(this.fingerIds.get(e.identifier)),this.fingers.sort((function(e,t){return t-e})),this.fingerIds.delete(e.identifier)}onTouchStart(e){if(this.videoElementProvider.isVideoReady()){for(let t=0;t<e.changedTouches.length;t++)this.rememberTouch(e.changedTouches[t]);i.Log(i.GetStackTrace(),"touch start",6),this.emitTouchData("TouchStart",e.changedTouches),e.preventDefault()}}onTouchEnd(e){if(this.videoElementProvider.isVideoReady()){i.Log(i.GetStackTrace(),"touch end",6),this.emitTouchData("TouchEnd",e.changedTouches);for(let t=0;t<e.changedTouches.length;t++)this.forgetTouch(e.changedTouches[t]);e.preventDefault()}}onTouchMove(e){this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),"touch move",6),this.emitTouchData("TouchMove",e.touches),e.preventDefault())}emitTouchData(e,t){if(!this.videoElementProvider.isVideoReady())return;const n=this.videoElementProvider.getVideoParentElement(),r=this.toStreamerMessagesProvider.toStreamerHandlers;for(let s=0;s<t.length;s++){const o=1,a=t[s],l=a.clientX-n.offsetLeft,c=a.clientY-n.offsetTop;i.Log(i.GetStackTrace(),`F${this.fingerIds.get(a.identifier)}=(${l}, ${c})`,6);const d=this.coordinateConverter.normalizeAndQuantizeUnsigned(l,c);switch(e){case"TouchStart":r.get("TouchStart")([o,d.x,d.y,this.fingerIds.get(a.identifier),this.maxByteValue*a.force,d.inRange?1:0]);break;case"TouchEnd":r.get("TouchEnd")([o,d.x,d.y,this.fingerIds.get(a.identifier),this.maxByteValue*a.force,d.inRange?1:0]);break;case"TouchMove":r.get("TouchMove")([o,d.x,d.y,this.fingerIds.get(a.identifier),this.maxByteValue*a.force,d.inRange?1:0])}}}}class je{constructor(e){this.gamePadEventListenerTracker=new We,this.toStreamerMessagesProvider=e,this.requestAnimationFrame=(window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame).bind(window);const t=window;if("GamepadEvent"in t){const e=e=>this.gamePadConnectHandler(e),t=e=>this.gamePadDisconnectHandler(e);window.addEventListener("gamepadconnected",e),window.addEventListener("gamepaddisconnected",t),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener("gamepadconnected",e))),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener("gamepaddisconnected",t)))}else if("WebKitGamepadEvent"in t){const e=e=>this.gamePadConnectHandler(e),t=e=>this.gamePadDisconnectHandler(e);window.addEventListener("webkitgamepadconnected",e),window.addEventListener("webkitgamepaddisconnected",t),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener("webkitgamepadconnected",e))),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener("webkitgamepaddisconnected",t)))}if(this.controllers=[],navigator.getGamepads)for(const e of navigator.getGamepads())e&&this.gamePadConnectHandler(new GamepadEvent("gamepadconnected",{gamepad:e}))}unregisterGamePadEvents(){this.gamePadEventListenerTracker.unregisterAll();for(const e of this.controllers)void 0!==e.id&&this.onGamepadDisconnected(e.id);this.controllers=[],this.onGamepadConnected=()=>{},this.onGamepadDisconnected=()=>{}}gamePadConnectHandler(e){i.Log(i.GetStackTrace(),"Gamepad connect handler",6);const t=e.gamepad,n={currentState:t,prevState:t,id:void 0};this.controllers.push(n),this.controllers[t.index].currentState=t,this.controllers[t.index].prevState=t,i.Log(i.GetStackTrace(),"gamepad: "+t.id+" connected",6),window.requestAnimationFrame((()=>this.updateStatus())),this.onGamepadConnected()}gamePadDisconnectHandler(e){i.Log(i.GetStackTrace(),"Gamepad disconnect handler",6),i.Log(i.GetStackTrace(),"gamepad: "+e.gamepad.id+" disconnected",6);const t=this.controllers[e.gamepad.index];delete this.controllers[e.gamepad.index],this.controllers=this.controllers.filter((e=>void 0!==e)),this.onGamepadDisconnected(t.id)}scanGamePads(){const e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[];for(let t=0;t<e.length;t++)e[t]&&e[t].index in this.controllers&&(this.controllers[e[t].index].currentState=e[t])}updateStatus(){this.scanGamePads();const e=this.toStreamerMessagesProvider.toStreamerHandlers;for(const t of this.controllers){const n=void 0===t.id?this.controllers.indexOf(t):t.id,r=t.currentState;for(let r=0;r<t.currentState.buttons.length;r++){const i=t.currentState.buttons[r],s=t.prevState.buttons[r];i.pressed?r==Re.LeftTrigger?e.get("GamepadAnalog")([n,5,i.value]):r==Re.RightTrigger?e.get("GamepadAnalog")([n,6,i.value]):e.get("GamepadButtonPressed")([n,r,s.pressed?1:0]):!i.pressed&&s.pressed&&(r==Re.LeftTrigger?e.get("GamepadAnalog")([n,5,0]):r==Re.RightTrigger?e.get("GamepadAnalog")([n,6,0]):e.get("GamepadButtonReleased")([n,r]))}for(let t=0;t<r.axes.length;t+=2){const i=parseFloat(r.axes[t].toFixed(4)),s=-parseFloat(r.axes[t+1].toFixed(4));e.get("GamepadAnalog")([n,t+1,i]),e.get("GamepadAnalog")([n,t+2,s])}this.controllers[n].prevState=r}this.controllers.length>0&&this.requestAnimationFrame((()=>this.updateStatus()))}onGamepadResponseReceived(e){for(const t of this.controllers)if(void 0===t.id){t.id=e;break}}onGamepadConnected(){}onGamepadDisconnected(e){}}!function(e){e[e.RightClusterBottomButton=0]="RightClusterBottomButton",e[e.RightClusterRightButton=1]="RightClusterRightButton",e[e.RightClusterLeftButton=2]="RightClusterLeftButton",e[e.RightClusterTopButton=3]="RightClusterTopButton",e[e.LeftShoulder=4]="LeftShoulder",e[e.RightShoulder=5]="RightShoulder",e[e.LeftTrigger=6]="LeftTrigger",e[e.RightTrigger=7]="RightTrigger",e[e.SelectOrBack=8]="SelectOrBack",e[e.StartOrForward=9]="StartOrForward",e[e.LeftAnalogPress=10]="LeftAnalogPress",e[e.RightAnalogPress=11]="RightAnalogPress",e[e.LeftClusterTopButton=12]="LeftClusterTopButton",e[e.LeftClusterBottomButton=13]="LeftClusterBottomButton",e[e.LeftClusterLeftButton=14]="LeftClusterLeftButton",e[e.LeftClusterRightButton=15]="LeftClusterRightButton",e[e.CentreButton=16]="CentreButton",e[e.LeftStickHorizontal=0]="LeftStickHorizontal",e[e.LeftStickVertical=1]="LeftStickVertical",e[e.RightStickHorizontal=2]="RightStickHorizontal",e[e.RightStickVertical=3]="RightStickVertical"}(Re||(Re={}));class Ye{constructor(e,t,n){this.activeKeys=new Je,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=n}registerKeyBoard(e){i.Log(i.GetStackTrace(),"Register Keyboard Events",7);const t=new Ke(this.toStreamerMessagesProvider,e,this.activeKeys);return t.registerKeyBoardEvents(),t}registerMouse(e){i.Log(i.GetStackTrace(),"Register Mouse Events",7);const t=new qe(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter,this.activeKeys);switch(e){case ue.LockedMouse:t.registerLockedMouseEvents(t);break;case ue.HoveringMouse:t.registerHoveringMouseEvents(t);break;default:i.Info(i.GetStackTrace(),"unknown Control Scheme Type Defaulting to Locked Mouse Events"),t.registerLockedMouseEvents(t)}return t}registerTouch(e,t){if(i.Log(i.GetStackTrace(),"Registering Touch",6),e){const e=new He(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter);return e.setVideoElementParentClientRect(t),e}return new Xe(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter)}registerGamePad(){return i.Log(i.GetStackTrace(),"Register Game Pad",7),new je(this.toStreamerMessagesProvider)}}class Je{constructor(){this.activeKeys=[],this.activeKeys=[]}getActiveKeys(){return this.activeKeys}}class Ze{constructor(e,t){this.lastTimeResized=(new Date).getTime(),this.videoElement=document.createElement("video"),this.config=t,this.videoElement.id="streamingVideo",this.videoElement.disablePictureInPicture=!0,this.videoElement.playsInline=!0,this.videoElement.style.width="100%",this.videoElement.style.height="100%",this.videoElement.style.position="absolute",this.videoElement.style.pointerEvents="all",e.appendChild(this.videoElement),this.onResizePlayerCallback=()=>{console.log("Resolution changed, restyling player, did you forget to override this function?")},this.onMatchViewportResolutionCallback=()=>{console.log("Resolution changed and match viewport resolution is turned on, did you forget to override this function?")},this.videoElement.onclick=()=>{this.videoElement.paused&&this.videoElement.play()},this.videoElement.onloadedmetadata=()=>{this.onVideoInitialized()},window.addEventListener("resize",(()=>this.resizePlayerStyle()),!0),window.addEventListener("orientationchange",(()=>this.onOrientationChange()))}play(){return this.videoElement.muted=this.config.isFlagEnabled(re.StartVideoMuted),this.videoElement.autoplay=this.config.isFlagEnabled(re.AutoPlayVideo),this.videoElement.play()}isPaused(){return this.videoElement.paused}isVideoReady(){return void 0!==this.videoElement.readyState&&this.videoElement.readyState>0}hasVideoSource(){return void 0!==this.videoElement.srcObject&&null!==this.videoElement.srcObject}getVideoElement(){return this.videoElement}getVideoParentElement(){return this.videoElement.parentElement}setVideoEnabled(e){this.videoElement.srcObject.getTracks().forEach((t=>t.enabled=e))}onVideoInitialized(){}onOrientationChange(){clearTimeout(this.orientationChangeTimeout),this.orientationChangeTimeout=window.setTimeout((()=>{this.resizePlayerStyle()}),500)}resizePlayerStyle(){const e=this.getVideoParentElement();e&&(this.updateVideoStreamSize(),e.classList.contains("fixed-size")||this.resizePlayerStyleToFillParentElement(),this.onResizePlayerCallback())}resizePlayerStyleToFillParentElement(){this.getVideoParentElement().setAttribute("style","top: 0px; left: 0px; width: 100%; height: 100%; cursor: default;")}updateVideoStreamSize(){if(this.config.isFlagEnabled(re.MatchViewportResolution))if((new Date).getTime()-this.lastTimeResized>1e3){const e=this.getVideoParentElement();if(!e)return;this.onMatchViewportResolutionCallback(e.clientWidth,e.clientHeight),this.lastTimeResized=(new Date).getTime()}else i.Log(i.GetStackTrace(),"Resizing too often - skipping",6),clearTimeout(this.resizeTimeoutHandle),this.resizeTimeoutHandle=window.setTimeout((()=>this.updateVideoStreamSize),1e3)}}class et$1{constructor(){this.map=new Map,this.reverseMap=new Map}getFromKey(e){return this.map.get(e)}getFromValue(e){return this.reverseMap.get(e)}add(e,t){this.map.set(e,t),this.reverseMap.set(t,e)}remove(e,t){this.map.delete(e),this.reverseMap.delete(t)}}class tt$1{constructor(){this.toStreamerHandlers=new Map,this.fromStreamerHandlers=new Map,this.toStreamerMessages=new et$1,this.fromStreamerMessages=new et$1}populateDefaultProtocol(){this.toStreamerMessages.add("IFrameRequest",{id:0,byteLength:0,structure:[]}),this.toStreamerMessages.add("RequestQualityControl",{id:1,byteLength:0,structure:[]}),this.toStreamerMessages.add("FpsRequest",{id:2,byteLength:0,structure:[]}),this.toStreamerMessages.add("AverageBitrateRequest",{id:3,byteLength:0,structure:[]}),this.toStreamerMessages.add("StartStreaming",{id:4,byteLength:0,structure:[]}),this.toStreamerMessages.add("StopStreaming",{id:5,byteLength:0,structure:[]}),this.toStreamerMessages.add("LatencyTest",{id:6,byteLength:0,structure:[]}),this.toStreamerMessages.add("RequestInitialSettings",{id:7,byteLength:0,structure:[]}),this.toStreamerMessages.add("TestEcho",{id:8,byteLength:0,structure:[]}),this.toStreamerMessages.add("UIInteraction",{id:50,byteLength:0,structure:[]}),this.toStreamerMessages.add("Command",{id:51,byteLength:0,structure:[]}),this.toStreamerMessages.add("KeyDown",{id:60,byteLength:2,structure:["uint8","uint8"]}),this.toStreamerMessages.add("KeyUp",{id:61,byteLength:1,structure:["uint8"]}),this.toStreamerMessages.add("KeyPress",{id:62,byteLength:2,structure:["uint16"]}),this.toStreamerMessages.add("MouseEnter",{id:70,byteLength:0,structure:[]}),this.toStreamerMessages.add("MouseLeave",{id:71,byteLength:0,structure:[]}),this.toStreamerMessages.add("MouseDown",{id:72,byteLength:5,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.add("MouseUp",{id:73,byteLength:5,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.add("MouseMove",{id:74,byteLength:8,structure:["uint16","uint16","int16","int16"]}),this.toStreamerMessages.add("MouseWheel",{id:75,byteLength:6,structure:["int16","uint16","uint16"]}),this.toStreamerMessages.add("MouseDouble",{id:76,byteLength:5,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.add("TouchStart",{id:80,byteLength:8,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.add("TouchEnd",{id:81,byteLength:8,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.add("TouchMove",{id:82,byteLength:8,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.add("GamepadConnected",{id:93,byteLength:0,structure:[]}),this.toStreamerMessages.add("GamepadButtonPressed",{id:90,byteLength:3,structure:["uint8","uint8","uint8"]}),this.toStreamerMessages.add("GamepadButtonReleased",{id:91,byteLength:3,structure:["uint8","uint8","uint8"]}),this.toStreamerMessages.add("GamepadAnalog",{id:92,byteLength:10,structure:["uint8","uint8","double"]}),this.toStreamerMessages.add("GamepadDisconnected",{id:94,byteLength:1,structure:["uint8"]}),this.fromStreamerMessages.add("QualityControlOwnership",0),this.fromStreamerMessages.add("Response",1),this.fromStreamerMessages.add("Command",2),this.fromStreamerMessages.add("FreezeFrame",3),this.fromStreamerMessages.add("UnfreezeFrame",4),this.fromStreamerMessages.add("VideoEncoderAvgQP",5),this.fromStreamerMessages.add("LatencyTest",6),this.fromStreamerMessages.add("InitialSettings",7),this.fromStreamerMessages.add("FileExtension",8),this.fromStreamerMessages.add("FileMimeType",9),this.fromStreamerMessages.add("FileContents",10),this.fromStreamerMessages.add("TestEcho",11),this.fromStreamerMessages.add("InputControlOwnership",12),this.fromStreamerMessages.add("GamepadResponse",13),this.fromStreamerMessages.add("Protocol",255)}registerMessageHandler(e,t,n){switch(e){case Le.ToStreamer:this.toStreamerHandlers.set(t,n);break;case Le.FromStreamer:this.fromStreamerHandlers.set(t,n);break;default:i.Log(i.GetStackTrace(),`Unknown message direction ${e}`)}}}!function(e){e[e.ToStreamer=0]="ToStreamer",e[e.FromStreamer=1]="FromStreamer"}(Le||(Le={}));class st$1{constructor(){this.responseEventListeners=new Map}addResponseEventListener(e,t){this.responseEventListeners.set(e,t)}removeResponseEventListener(e){this.responseEventListeners.delete(e)}onResponse(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.Response",6);const t=new TextDecoder("utf-16").decode(e.slice(1));i.Log(i.GetStackTrace(),t,6),this.responseEventListeners.forEach((e=>{e(t)}))}}class nt$1{constructor(e,t){this.dataChannelSender=e,this.toStreamerMessagesMapProvider=t}sendLatencyTest(e){this.sendDescriptor("LatencyTest",e)}emitCommand(e){this.sendDescriptor("Command",e)}emitUIInteraction(e){this.sendDescriptor("UIInteraction",e)}sendDescriptor(e,t){const n=JSON.stringify(t),r=this.toStreamerMessagesMapProvider.toStreamerMessages.getFromKey(e);void 0===r&&i.Error(i.GetStackTrace(),`Attempted to emit descriptor with message type: ${e}, but the frontend hasn't been configured to send such a message. Check you've added the message type in your cpp`),i.Log(i.GetStackTrace(),"Sending: "+t,6);const s=new DataView(new ArrayBuffer(3+2*n.length));let o=0;s.setUint8(o,r.id),o++,s.setUint16(o,n.length,!0),o+=2;for(let e=0;e<n.length;e++)s.setUint16(o,n.charCodeAt(e),!0),o+=2;this.dataChannelSender.canSend()?this.dataChannelSender.sendData(s.buffer):i.Info(i.GetStackTrace(),`Data channel cannot send yet, skipping sending descriptor message: ${e} - ${n}`)}}class rt$1{constructor(e,t){this.dataChannelSender=e,this.toStreamerMessagesMapProvider=t}sendMessageToStreamer(e,t){void 0===t&&(t=[]);const n=this.toStreamerMessagesMapProvider.toStreamerMessages.getFromKey(e);if(void 0===n)return void i.Error(i.GetStackTrace(),`Attempted to send a message to the streamer with message type: ${e}, but the frontend hasn't been configured to send such a message. Check you've added the message type in your cpp`);const r=new DataView(new ArrayBuffer(n.byteLength+1));r.setUint8(0,n.id);let s=1;t.forEach(((e,t)=>{switch(n.structure[t]){case"uint8":r.setUint8(s,e),s+=1;break;case"uint16":r.setUint16(s,e,!0),s+=2;break;case"int16":r.setInt16(s,e,!0),s+=2;break;case"float":r.setFloat32(s,e,!0),s+=4;break;case"double":r.setFloat64(s,e,!0),s+=8}})),this.dataChannelSender.canSend()?this.dataChannelSender.sendData(r.buffer):i.Info(i.GetStackTrace(),`Data channel cannot send yet, skipping sending message: ${e} - ${new Uint8Array(r.buffer)}`)}}class it$1{constructor(e){this.sendMessageController=e}SendRequestQualityControl(){this.sendMessageController.sendMessageToStreamer("RequestQualityControl")}SendMaxFpsRequest(){this.sendMessageController.sendMessageToStreamer("FpsRequest")}SendAverageBitrateRequest(){this.sendMessageController.sendMessageToStreamer("AverageBitrateRequest")}SendStartStreaming(){this.sendMessageController.sendMessageToStreamer("StartStreaming")}SendStopStreaming(){this.sendMessageController.sendMessageToStreamer("StopStreaming")}SendRequestInitialSettings(){this.sendMessageController.sendMessageToStreamer("RequestInitialSettings")}}class ot$1{constructor(e){this.dataChannelProvider=e}canSend(){return void 0!==this.dataChannelProvider.getDataChannelInstance().dataChannel&&"open"==this.dataChannelProvider.getDataChannelInstance().dataChannel.readyState}sendData(e){const t=this.dataChannelProvider.getDataChannelInstance();"open"==t.dataChannel.readyState?(t.dataChannel.send(e),i.Log(i.GetStackTrace(),`Message Sent: ${new Uint8Array(e)}`,6),this.resetAfkWarningTimerOnDataSend()):i.Error(i.GetStackTrace(),`Message Failed: ${new Uint8Array(e)}`)}resetAfkWarningTimerOnDataSend(){}}class at$2{constructor(e){this.videoElementProvider=e,this.normalizeAndQuantizeUnsignedFunc=()=>{throw new Error("Normalize and quantize unsigned, method not implemented.")},this.normalizeAndQuantizeSignedFunc=()=>{throw new Error("Normalize and unquantize signed, method not implemented.")},this.denormalizeAndUnquantizeUnsignedFunc=()=>{throw new Error("Denormalize and unquantize unsigned, method not implemented.")}}normalizeAndQuantizeUnsigned(e,t){return this.normalizeAndQuantizeUnsignedFunc(e,t)}unquantizeAndDenormalizeUnsigned(e,t){return this.denormalizeAndUnquantizeUnsignedFunc(e,t)}normalizeAndQuantizeSigned(e,t){return this.normalizeAndQuantizeSignedFunc(e,t)}setupNormalizeAndQuantize(){if(this.videoElementParent=this.videoElementProvider.getVideoParentElement(),this.videoElement=this.videoElementProvider.getVideoElement(),this.videoElementParent&&this.videoElement){const e=this.videoElementParent.clientHeight/this.videoElementParent.clientWidth,t=this.videoElement.videoHeight/this.videoElement.videoWidth;e>t?(i.Log(i.GetStackTrace(),"Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio",6),this.ratio=e/t,this.normalizeAndQuantizeUnsignedFunc=(e,t)=>this.normalizeAndQuantizeUnsignedPlayerBigger(e,t),this.normalizeAndQuantizeSignedFunc=(e,t)=>this.normalizeAndQuantizeSignedPlayerBigger(e,t),this.denormalizeAndUnquantizeUnsignedFunc=(e,t)=>this.denormalizeAndUnquantizeUnsignedPlayerBigger(e,t)):(i.Log(i.GetStackTrace(),"Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio",6),this.ratio=t/e,this.normalizeAndQuantizeUnsignedFunc=(e,t)=>this.normalizeAndQuantizeUnsignedPlayerSmaller(e,t),this.normalizeAndQuantizeSignedFunc=(e,t)=>this.normalizeAndQuantizeSignedPlayerSmaller(e,t),this.denormalizeAndUnquantizeUnsignedFunc=(e,t)=>this.denormalizeAndUnquantizeUnsignedPlayerSmaller(e,t))}}normalizeAndQuantizeUnsignedPlayerBigger(e,t){const n=e/this.videoElementParent.clientWidth,r=this.ratio*(t/this.videoElementParent.clientHeight-.5)+.5;return n<0||n>1||r<0||r>1?new dt(!1,65535,65535):new dt(!0,65536*n,65536*r)}denormalizeAndUnquantizeUnsignedPlayerBigger(e,t){const n=e/65536,r=(t/65536-.5)/this.ratio+.5;return new lt$1(n*this.videoElementParent.clientWidth,r*this.videoElementParent.clientHeight)}normalizeAndQuantizeSignedPlayerBigger(e,t){const n=e/(.5*this.videoElementParent.clientWidth),r=this.ratio*t/(.5*this.videoElementParent.clientHeight);return new ct$1(32767*n,32767*r)}normalizeAndQuantizeUnsignedPlayerSmaller(e,t){const n=this.ratio*(e/this.videoElementParent.clientWidth-.5)+.5,r=t/this.videoElementParent.clientHeight;return n<0||n>1||r<0||r>1?new dt(!1,65535,65535):new dt(!0,65536*n,65536*r)}denormalizeAndUnquantizeUnsignedPlayerSmaller(e,t){const n=(e/65536-.5)/this.ratio+.5,r=t/65536;return new lt$1(n*this.videoElementParent.clientWidth,r*this.videoElementParent.clientHeight)}normalizeAndQuantizeSignedPlayerSmaller(e,t){const n=this.ratio*e/(.5*this.videoElementParent.clientWidth),r=t/(.5*this.videoElementParent.clientHeight);return new ct$1(32767*n,32767*r)}}class dt{constructor(e,t,n){this.inRange=e,this.x=t,this.y=n}}class lt$1{constructor(e,t){this.x=e,this.y=t}}class ct$1{constructor(e,t){this.x=e,this.y=t}}class ht{constructor(e,t){this.shouldShowPlayOverlay=!0,this.config=e,this.pixelStreaming=t,this.responseController=new st$1,this.file=new ze,this.sdpConstraints={offerToReceiveAudio:!0,offerToReceiveVideo:!0},this.afkController=new me(this.config,this.pixelStreaming,this.onAfkTriggered.bind(this)),this.afkController.onAFKTimedOutCallback=()=>{this.setDisconnectMessageOverride("due to inactivity"),this.closeSignalingServer()},this.freezeFrameController=new y$1(this.pixelStreaming.videoElementParent),this.videoPlayer=new Ze(this.pixelStreaming.videoElementParent,this.config),this.videoPlayer.onVideoInitialized=()=>this.handleVideoInitialized(),this.videoPlayer.onMatchViewportResolutionCallback=(e,t)=>{const n={"Resolution.Width":e,"Resolution.Height":t};this.sendDescriptorController.emitCommand(n)},this.videoPlayer.onResizePlayerCallback=()=>{this.setUpMouseAndFreezeFrame()},this.streamController=new T$1(this.videoPlayer),this.coordinateConverter=new at$2(this.videoPlayer),this.sendrecvDataChannelController=new Se,this.recvDataChannelController=new Se,this.registerDataChannelEventEmitters(this.sendrecvDataChannelController),this.registerDataChannelEventEmitters(this.recvDataChannelController),this.dataChannelSender=new ot$1(this.sendrecvDataChannelController),this.dataChannelSender.resetAfkWarningTimerOnDataSend=()=>this.afkController.resetAfkWarningTimer(),this.streamMessageController=new tt$1,this.webSocketController=new f$1,this.webSocketController.onConfig=e=>this.handleOnConfigMessage(e),this.webSocketController.onStreamerList=e=>this.handleStreamerListMessage(e),this.webSocketController.onWebSocketOncloseOverlayMessage=e=>{this.pixelStreaming._onDisconnect(`WS disconnect (${e.code}) ${""!=e.reason?"- "+e.reason:""}`),this.setVideoEncoderAvgQP(0)},this.webSocketController.onOpen.addEventListener("open",(()=>{this.config.isFlagEnabled(re.BrowserSendOffer)||this.webSocketController.requestStreamerList()})),this.webSocketController.onClose.addEventListener("close",(()=>{this.afkController.stopAfkWarningTimer(),this.statsTimerHandle&&void 0!==this.statsTimerHandle&&window.clearInterval(this.statsTimerHandle),this.setTouchInputEnabled(!1),this.setMouseInputEnabled(!1),this.setKeyboardInputEnabled(!1),this.setGamePadInputEnabled(!1)})),this.sendDescriptorController=new nt$1(this.dataChannelSender,this.streamMessageController),this.sendMessageController=new rt$1(this.dataChannelSender,this.streamMessageController),this.toStreamerMessagesController=new it$1(this.sendMessageController),this.registerMessageHandlers(),this.streamMessageController.populateDefaultProtocol(),this.inputClassesFactory=new Ye(this.streamMessageController,this.videoPlayer,this.coordinateConverter),this.isUsingSFU=!1,this.isQualityController=!1,this.preferredCodec="",this.config._addOnOptionSettingChangedListener(ce.StreamerId,(e=>{this.peerConnectionController.peerConnection.close(),this.peerConnectionController.createPeerConnection(this.peerConfig,this.preferredCodec),this.webSocketController.sendSubscribe(e)})),this.setVideoEncoderAvgQP(-1),this.signallingUrlBuilder=()=>{let e=this.config.getTextSettingValue(de.SignallingServerUrl);return this.config.isFlagEnabled(re.BrowserSendOffer)&&(e+="?"+re.BrowserSendOffer+"=true"),e}}requestUnquantizedAndDenormalizeUnsigned(e,t){return this.coordinateConverter.unquantizeAndDenormalizeUnsigned(e,t)}handleOnMessage(e){const t=new Uint8Array(e.data);i.Log(i.GetStackTrace(),"Message incoming:"+t,6);const n=this.streamMessageController.fromStreamerMessages.getFromValue(t[0]);this.streamMessageController.fromStreamerHandlers.get(n)(e.data)}registerMessageHandlers(){this.streamMessageController.registerMessageHandler(Le.FromStreamer,"QualityControlOwnership",(e=>this.onQualityControlOwnership(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"Response",(e=>this.responseController.onResponse(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"Command",(e=>{this.onCommand(e)})),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"FreezeFrame",(e=>this.onFreezeFrameMessage(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"UnfreezeFrame",(()=>this.invalidateFreezeFrameAndEnableVideo())),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"VideoEncoderAvgQP",(e=>this.handleVideoEncoderAvgQP(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"LatencyTest",(e=>this.handleLatencyTestResult(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"InitialSettings",(e=>this.handleInitialSettings(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"FileExtension",(e=>this.onFileExtension(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"FileMimeType",(e=>this.onFileMimeType(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"FileContents",(e=>this.onFileContents(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"TestEcho",(()=>{})),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"InputControlOwnership",(e=>this.onInputControlOwnership(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"GamepadResponse",(e=>this.onGamepadResponse(e))),this.streamMessageController.registerMessageHandler(Le.FromStreamer,"Protocol",(e=>this.onProtocolMessage(e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"IFrameRequest",(()=>this.sendMessageController.sendMessageToStreamer("IFrameRequest"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"RequestQualityControl",(()=>this.sendMessageController.sendMessageToStreamer("RequestQualityControl"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"FpsRequest",(()=>this.sendMessageController.sendMessageToStreamer("FpsRequest"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"AverageBitrateRequest",(()=>this.sendMessageController.sendMessageToStreamer("AverageBitrateRequest"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"StartStreaming",(()=>this.sendMessageController.sendMessageToStreamer("StartStreaming"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"StopStreaming",(()=>this.sendMessageController.sendMessageToStreamer("StopStreaming"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"LatencyTest",(()=>this.sendMessageController.sendMessageToStreamer("LatencyTest"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"RequestInitialSettings",(()=>this.sendMessageController.sendMessageToStreamer("RequestInitialSettings"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"TestEcho",(()=>{})),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"UIInteraction",(e=>this.sendDescriptorController.emitUIInteraction(e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"Command",(e=>this.sendDescriptorController.emitCommand(e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"KeyDown",(e=>this.sendMessageController.sendMessageToStreamer("KeyDown",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"KeyUp",(e=>this.sendMessageController.sendMessageToStreamer("KeyUp",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"KeyPress",(e=>this.sendMessageController.sendMessageToStreamer("KeyPress",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseEnter",(e=>this.sendMessageController.sendMessageToStreamer("MouseEnter",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseLeave",(e=>this.sendMessageController.sendMessageToStreamer("MouseLeave",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseDown",(e=>this.sendMessageController.sendMessageToStreamer("MouseDown",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseUp",(e=>this.sendMessageController.sendMessageToStreamer("MouseUp",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseMove",(e=>this.sendMessageController.sendMessageToStreamer("MouseMove",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseWheel",(e=>this.sendMessageController.sendMessageToStreamer("MouseWheel",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"MouseDouble",(e=>this.sendMessageController.sendMessageToStreamer("MouseDouble",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"TouchStart",(e=>this.sendMessageController.sendMessageToStreamer("TouchStart",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"TouchEnd",(e=>this.sendMessageController.sendMessageToStreamer("TouchEnd",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"TouchMove",(e=>this.sendMessageController.sendMessageToStreamer("TouchMove",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"GamepadConnected",(()=>this.sendMessageController.sendMessageToStreamer("GamepadConnected"))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"GamepadButtonPressed",(e=>this.sendMessageController.sendMessageToStreamer("GamepadButtonPressed",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"GamepadButtonReleased",(e=>this.sendMessageController.sendMessageToStreamer("GamepadButtonReleased",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"GamepadAnalog",(e=>this.sendMessageController.sendMessageToStreamer("GamepadAnalog",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"GamepadDisconnected",(e=>this.sendMessageController.sendMessageToStreamer("GamepadDisconnected",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRHMDTransform",(e=>this.sendMessageController.sendMessageToStreamer("XRHMDTransform",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRControllerTransform",(e=>this.sendMessageController.sendMessageToStreamer("XRControllerTransform",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRSystem",(e=>this.sendMessageController.sendMessageToStreamer("XRSystem",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRButtonTouched",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonTouched",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRButtonPressed",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonPressed",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRButtonReleased",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonReleased",e))),this.streamMessageController.registerMessageHandler(Le.ToStreamer,"XRAnalog",(e=>this.sendMessageController.sendMessageToStreamer("XRAnalog",e)))}onCommand(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.Command",6);const t=new TextDecoder("utf-16").decode(e.slice(1));i.Log(i.GetStackTrace(),"Data Channel Command: "+t,6);const n=JSON.parse(t);"onScreenKeyboard"===n.command&&this.pixelStreaming._activateOnScreenKeyboard(n)}onProtocolMessage(e){try{const t=new TextDecoder("utf-16").decode(e.slice(1)),n=JSON.parse(t);Object.prototype.hasOwnProperty.call(n,"Direction")||i.Error(i.GetStackTrace(),"Malformed protocol received. Ensure the protocol message contains a direction");const r=n.Direction;delete n.Direction,i.Log(i.GetStackTrace(),`Received new ${r==Le.FromStreamer?"FromStreamer":"ToStreamer"} protocol. Updating existing protocol...`),Object.keys(n).forEach((e=>{const t=n[e];switch(r){case Le.ToStreamer:if(!Object.prototype.hasOwnProperty.call(t,"id")||!Object.prototype.hasOwnProperty.call(t,"byteLength"))return void i.Error(i.GetStackTrace(),`ToStreamer->${e} protocol definition was malformed as it didn't contain at least an id and a byteLength\n\n Definition was: ${JSON.stringify(t,null,2)}`);if(t.byteLength>0&&!Object.prototype.hasOwnProperty.call(t,"structure"))return void i.Error(i.GetStackTrace(),`ToStreamer->${e} protocol definition was malformed as it specified a byteLength but no accompanying structure`);this.streamMessageController.toStreamerHandlers.get(e)?this.streamMessageController.toStreamerMessages.add(e,t):i.Error(i.GetStackTrace(),`There was no registered handler for "${e}" - try adding one using registerMessageHandler(MessageDirection.ToStreamer, "${e}", myHandler)`);break;case Le.FromStreamer:if(!Object.prototype.hasOwnProperty.call(t,"id"))return void i.Error(i.GetStackTrace(),`FromStreamer->${e} protocol definition was malformed as it didn't contain at least an id\n\n Definition was: ${JSON.stringify(t,null,2)}`);this.streamMessageController.fromStreamerHandlers.get(e)?this.streamMessageController.fromStreamerMessages.add(e,t.id):i.Error(i.GetStackTrace(),`There was no registered handler for "${t}" - try adding one using registerMessageHandler(MessageDirection.FromStreamer, "${e}", myHandler)`);break;default:i.Error(i.GetStackTrace(),`Unknown direction: ${r}`)}})),this.toStreamerMessagesController.SendRequestInitialSettings(),this.toStreamerMessagesController.SendRequestQualityControl()}catch(e){i.Log(i.GetStackTrace(),e)}}onInputControlOwnership(e){const t=new Uint8Array(e);i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.InputControlOwnership",6);const n=new Boolean(t[1]).valueOf();i.Log(i.GetStackTrace(),`Received input controller message - will your input control the stream: ${n}`),this.pixelStreaming._onInputControlOwnership(n)}onGamepadResponse(e){const t=new TextDecoder("utf-16").decode(e.slice(1)),n=JSON.parse(t);this.gamePadController.onGamepadResponseReceived(n.controllerId)}onAfkTriggered(){this.afkController.onAfkClick(),this.videoPlayer.isPaused()&&this.videoPlayer.hasVideoSource()&&this.playStream()}setAfkEnabled(e){e?this.onAfkTriggered():this.afkController.stopAfkWarningTimer()}restartStreamAutomatically(){if(this.webSocketController)if(this.webSocketController.webSocket&&this.webSocketController.webSocket.readyState!==WebSocket.CLOSED){this.pixelStreaming._showActionOrErrorOnDisconnect=!1,this.setDisconnectMessageOverride("Restarting stream..."),this.closeSignalingServer();const e=setTimeout((()=>{this.pixelStreaming._onWebRtcAutoConnect(),this.connectToSignallingServer(),clearTimeout(e)}),3e3)}else i.Log(i.GetStackTrace(),"A websocket connection has not been made yet so we will start the stream"),this.pixelStreaming._onWebRtcAutoConnect(),this.connectToSignallingServer();else i.Log(i.GetStackTrace(),"The Web Socket Controller does not exist so this will not work right now.")}loadFreezeFrameOrShowPlayOverlay(){this.pixelStreaming.dispatchEvent(new $$a({shouldShowPlayOverlay:this.shouldShowPlayOverlay,isValid:this.freezeFrameController.valid,jpegData:this.freezeFrameController.jpeg})),!0===this.shouldShowPlayOverlay?(i.Log(i.GetStackTrace(),"showing play overlay"),this.resizePlayerStyle()):(i.Log(i.GetStackTrace(),"showing freeze frame"),this.freezeFrameController.showFreezeFrame()),setTimeout((()=>{this.videoPlayer.setVideoEnabled(!1)}),this.freezeFrameController.freezeFrameDelay)}onFreezeFrameMessage(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.FreezeFrame",6);const t=new Uint8Array(e);this.freezeFrameController.processFreezeFrameMessage(t,(()=>this.loadFreezeFrameOrShowPlayOverlay()))}invalidateFreezeFrameAndEnableVideo(){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.FreezeFrame",6),setTimeout((()=>{this.pixelStreaming.dispatchEvent(new q$1),this.freezeFrameController.hideFreezeFrame()}),this.freezeFrameController.freezeFrameDelay),this.videoPlayer.getVideoElement()&&this.videoPlayer.setVideoEnabled(!0)}onFileExtension(e){const t=new Uint8Array(e);Ge.setExtensionFromBytes(t,this.file)}onFileMimeType(e){const t=new Uint8Array(e);Ge.setMimeTypeFromBytes(t,this.file)}onFileContents(e){const t=new Uint8Array(e);Ge.setContentsFromBytes(t,this.file)}playStream(){if(!this.videoPlayer.getVideoElement()){const e="Could not play video stream because the video player was not initialized correctly.";return this.pixelStreaming.dispatchEvent(new N$1({message:e})),i.Error(i.GetStackTrace(),e),this.setDisconnectMessageOverride("Stream not initialized correctly"),void this.closeSignalingServer()}this.videoPlayer.hasVideoSource()?(this.setTouchInputEnabled(this.config.isFlagEnabled(re.TouchInput)),this.pixelStreaming.dispatchEvent(new K$1),this.streamController.audioElement.srcObject?(this.streamController.audioElement.muted=this.config.isFlagEnabled(re.StartVideoMuted),this.streamController.audioElement.play().then((()=>{this.playVideo()})).catch((e=>{i.Log(i.GetStackTrace(),e),i.Log(i.GetStackTrace(),"Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."),this.pixelStreaming.dispatchEvent(new Q$1({reason:e}))}))):this.playVideo(),this.shouldShowPlayOverlay=!1,this.freezeFrameController.showFreezeFrame()):i.Warning(i.GetStackTrace(),"Cannot play stream, the video element has no srcObject to play.")}playVideo(){this.videoPlayer.play().catch((e=>{this.streamController.audioElement.srcObject&&this.streamController.audioElement.pause(),i.Log(i.GetStackTrace(),e),i.Log(i.GetStackTrace(),"Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."),this.pixelStreaming.dispatchEvent(new Q$1({reason:e}))}))}autoPlayVideoOrSetUpPlayOverlay(){this.config.isFlagEnabled(re.AutoPlayVideo)&&this.playStream(),this.resizePlayerStyle()}connectToSignallingServer(){const e=this.signallingUrlBuilder();this.webSocketController.connect(e)}startSession(e){if(this.peerConfig=e,this.config.isFlagEnabled(re.ForceTURN)&&!this.checkTurnServerAvailability(e))return i.Info(i.GetStackTrace(),"No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead"),this.setDisconnectMessageOverride("TURN cannot be forced, closing connection. Please use STUN instead."),void this.closeSignalingServer();this.peerConnectionController=new Ae(this.peerConfig,this.config,this.preferredCodec),this.peerConnectionController.onVideoStats=e=>this.handleVideoStats(e),this.peerConnectionController.onSendWebRTCOffer=e=>this.handleSendWebRTCOffer(e),this.peerConnectionController.onSendWebRTCAnswer=e=>this.handleSendWebRTCAnswer(e),this.peerConnectionController.onPeerIceCandidate=e=>this.handleSendIceCandidate(e),this.peerConnectionController.onDataChannel=e=>this.handleDataChannel(e),this.peerConnectionController.showTextOverlayConnecting=()=>this.pixelStreaming._onWebRtcConnecting(),this.peerConnectionController.showTextOverlaySetupFailure=()=>this.pixelStreaming._onWebRtcFailed();let t=!1;this.peerConnectionController.onIceConnectionStateChange=()=>{!t&&["connected","completed"].includes(this.peerConnectionController.peerConnection.iceConnectionState)&&(this.pixelStreaming._onWebRtcConnected(),t=!0)},this.peerConnectionController.onTrack=e=>this.streamController.handleOnTrack(e),this.config.isFlagEnabled(re.BrowserSendOffer)&&(this.sendrecvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection,"cirrus",this.datachannelOptions),this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e),this.peerConnectionController.createOffer(this.sdpConstraints,this.config))}checkTurnServerAvailability(e){if(!e.iceServers)return i.Info(i.GetStackTrace(),"A turn sever was not found"),!1;for(const t of e.iceServers)for(const e of t.urls)if(e.includes("turn"))return i.Log(i.GetStackTrace(),`A turn sever was found at ${e}`),!0;return i.Info(i.GetStackTrace(),"A turn sever was not found"),!1}handleOnConfigMessage(e){this.resizePlayerStyle(),this.startSession(e.peerConnectionOptions),this.webSocketController.onWebRtcAnswer=e=>this.handleWebRtcAnswer(e),this.webSocketController.onWebRtcOffer=e=>this.handleWebRtcOffer(e),this.webSocketController.onWebRtcPeerDataChannels=e=>this.handleWebRtcSFUPeerDatachannels(e),this.webSocketController.onIceCandidate=e=>this.handleIceCandidate(e)}handleStreamerListMessage(e){i.Log(i.GetStackTrace(),`Got streamer list ${e.ids}`,6);const t=[...e.ids];t.unshift(""),this.config.setOptionSettingOptions(ce.StreamerId,t);const n=new URLSearchParams(window.location.search);let r=null;1==e.ids.length?r=e.ids[0]:this.config.isFlagEnabled(re.PreferSFU)&&e.ids.includes("SFU")?r="SFU":n.has(ce.StreamerId)&&e.ids.includes(n.get(ce.StreamerId))&&(r=n.get(ce.StreamerId)),null!==r&&this.config.setOptionSettingValue(ce.StreamerId,r),this.pixelStreaming.dispatchEvent(new j$1({messageStreamerList:e,autoSelectedStreamerId:r}))}handleWebRtcAnswer(e){i.Log(i.GetStackTrace(),`Got answer sdp ${e.sdp}`,6);const t={sdp:e.sdp,type:"answer"};this.peerConnectionController.receiveAnswer(t),this.handlePostWebrtcNegotiation()}handleWebRtcOffer(e){i.Log(i.GetStackTrace(),`Got offer sdp ${e.sdp}`,6),this.isUsingSFU=!!e.sfu&&e.sfu,this.isUsingSFU&&(this.peerConnectionController.preferredCodec="");const t={sdp:e.sdp,type:"offer"};this.peerConnectionController.receiveOffer(t,this.config),this.handlePostWebrtcNegotiation()}handleWebRtcSFUPeerDatachannels(e){const t={ordered:!0,negotiated:!0,id:e.sendStreamId},n=e.sendStreamId!=e.recvStreamId;if(this.sendrecvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection,n?"send-datachannel":"datachannel",t),n){const t={ordered:!0,negotiated:!0,id:e.recvStreamId};this.recvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection,"recv-datachannel",t),this.recvDataChannelController.handleOnOpen=()=>this.webSocketController.sendSFURecvDataChannelReady(),this.recvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}else this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}handlePostWebrtcNegotiation(){this.afkController.startAfkWarningTimer(),this.pixelStreaming._onWebRtcSdp(),this.statsTimerHandle&&void 0!==this.statsTimerHandle&&window.clearInterval(this.statsTimerHandle),this.statsTimerHandle=window.setInterval((()=>this.getStats()),1e3),this.setMouseInputEnabled(this.config.isFlagEnabled(re.MouseInput)),this.setKeyboardInputEnabled(this.config.isFlagEnabled(re.KeyboardInput)),this.setGamePadInputEnabled(this.config.isFlagEnabled(re.GamepadInput))}handleIceCandidate(e){i.Log(i.GetStackTrace(),"Web RTC Controller: onWebRtcIce",6);const t=new RTCIceCandidate(e);this.peerConnectionController.handleOnIce(t)}handleSendIceCandidate(e){i.Log(i.GetStackTrace(),"OnIceCandidate",6),e.candidate&&e.candidate.candidate&&this.webSocketController.sendIceCandidate(e.candidate)}handleDataChannel(e){i.Log(i.GetStackTrace(),"Data channel created for us by browser as we are a receiving peer.",6),this.sendrecvDataChannelController.dataChannel=e.channel,this.sendrecvDataChannelController.setupDataChannel(),this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}handleSendWebRTCOffer(e){i.Log(i.GetStackTrace(),"Sending the offer to the Server",6),this.webSocketController.sendWebRtcOffer(e)}handleSendWebRTCAnswer(e){i.Log(i.GetStackTrace(),"Sending the answer to the Server",6),this.webSocketController.sendWebRtcAnswer(e),this.isUsingSFU&&this.webSocketController.sendWebRtcDatachannelRequest()}setUpMouseAndFreezeFrame(){this.videoElementParentClientRect=this.videoPlayer.getVideoParentElement().getBoundingClientRect(),this.coordinateConverter.setupNormalizeAndQuantize(),this.freezeFrameController.freezeFrame.resize()}closeSignalingServer(){var e;null===(e=this.webSocketController)||void 0===e||e.close()}closePeerConnection(){var e;null===(e=this.peerConnectionController)||void 0===e||e.close()}close(){this.closeSignalingServer(),this.closePeerConnection()}getStats(){this.peerConnectionController.generateStats()}sendLatencyTest(){this.latencyStartTime=Date.now(),this.sendDescriptorController.sendLatencyTest({StartTime:this.latencyStartTime})}sendEncoderMinQP(e){i.Log(i.GetStackTrace(),`MinQP=${e}\n`,6),null!=e&&this.sendDescriptorController.emitCommand({"Encoder.MinQP":e})}sendEncoderMaxQP(e){i.Log(i.GetStackTrace(),`MaxQP=${e}\n`,6),null!=e&&this.sendDescriptorController.emitCommand({"Encoder.MaxQP":e})}sendWebRTCMinBitrate(e){i.Log(i.GetStackTrace(),`WebRTC Min Bitrate=${e}`,6),null!=e&&this.sendDescriptorController.emitCommand({"WebRTC.MinBitrate":e})}sendWebRTCMaxBitrate(e){i.Log(i.GetStackTrace(),`WebRTC Max Bitrate=${e}`,6),null!=e&&this.sendDescriptorController.emitCommand({"WebRTC.MaxBitrate":e})}sendWebRTCFps(e){i.Log(i.GetStackTrace(),`WebRTC FPS=${e}`,6),null!=e&&(this.sendDescriptorController.emitCommand({"WebRTC.Fps":e}),this.sendDescriptorController.emitCommand({"WebRTC.MaxFps":e}))}sendShowFps(){i.Log(i.GetStackTrace(),"---- Sending show stat to UE ----",6),this.sendDescriptorController.emitCommand({"stat.fps":""})}sendIframeRequest(){i.Log(i.GetStackTrace(),"---- Sending Request for an IFrame ----",6),this.streamMessageController.toStreamerHandlers.get("IFrameRequest")()}emitUIInteraction(e){i.Log(i.GetStackTrace(),"---- Sending custom UIInteraction message ----",6),this.sendDescriptorController.emitUIInteraction(e)}emitCommand(e){i.Log(i.GetStackTrace(),"---- Sending custom Command message ----",6),this.sendDescriptorController.emitCommand(e)}emitConsoleCommand(e){i.Log(i.GetStackTrace(),"---- Sending custom Command:ConsoleCommand message ----",6),this.sendDescriptorController.emitCommand({ConsoleCommand:e})}sendRequestQualityControlOwnership(){i.Log(i.GetStackTrace(),"---- Sending Request to Control Quality ----",6),this.toStreamerMessagesController.SendRequestQualityControl()}handleLatencyTestResult(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.latencyTest",6);const t=new TextDecoder("utf-16").decode(e.slice(1)),n=new Ie;Object.assign(n,JSON.parse(t)),n.processFields(),n.testStartTimeMs=this.latencyStartTime,n.browserReceiptTimeMs=Date.now(),n.latencyExcludingDecode=~~(n.browserReceiptTimeMs-n.testStartTimeMs),n.testDuration=~~(n.TransmissionTimeMs-n.ReceiptTimeMs),n.networkLatency=~~(n.latencyExcludingDecode-n.testDuration),n.frameDisplayDeltaTimeMs&&n.browserReceiptTimeMs&&(n.endToEndLatency=(n.frameDisplayDeltaTimeMs,n.networkLatency,~~+n.CaptureToSendMs)),this.pixelStreaming._onLatencyTestResult(n)}handleInitialSettings(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.InitialSettings",6);const t=new TextDecoder("utf-16").decode(e.slice(1)),n=JSON.parse(t),r=new Fe;n.Encoder&&(r.EncoderSettings=n.Encoder),n.WebRTC&&(r.WebRTCSettings=n.WebRTC),n.PixelStreaming&&(r.PixelStreamingSettings=n.PixelStreaming),n.ConfigOptions&&this.config.setFlagEnabled(re.HoveringMouseMode,!!n.ConfigOptions.DefaultToHover),r.ueCompatible(),i.Log(i.GetStackTrace(),t,6),this.pixelStreaming._onInitialSettings(r)}handleVideoEncoderAvgQP(e){i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.VideoEncoderAvgQP",6);const t=Number(new TextDecoder("utf-16").decode(e.slice(1)));this.setVideoEncoderAvgQP(t)}handleVideoInitialized(){this.pixelStreaming._onVideoInitialized(),this.autoPlayVideoOrSetUpPlayOverlay(),this.resizePlayerStyle(),this.videoPlayer.updateVideoStreamSize()}onQualityControlOwnership(e){const t=new Uint8Array(e);i.Log(i.GetStackTrace(),"DataChannelReceiveMessageType.QualityControlOwnership",6),this.isQualityController=new Boolean(t[1]).valueOf(),i.Log(i.GetStackTrace(),`Received quality controller message, will control quality: ${this.isQualityController}`),this.pixelStreaming._onQualityControlOwnership(this.isQualityController)}handleVideoStats(e){this.pixelStreaming._onVideoStats(e)}resizePlayerStyle(){this.videoPlayer.resizePlayerStyle()}getDisconnectMessageOverride(){return this.disconnectMessageOverride}setDisconnectMessageOverride(e){this.disconnectMessageOverride=e}setPreferredCodec(e){this.preferredCodec=e,this.peerConnectionController&&(this.peerConnectionController.preferredCodec=e,this.peerConnectionController.updateCodecSelection=!1)}setVideoEncoderAvgQP(e){this.videoAvgQp=e,this.pixelStreaming._onVideoEncoderAvgQP(this.videoAvgQp)}setKeyboardInputEnabled(e){var t;null===(t=this.keyboardController)||void 0===t||t.unregisterKeyBoardEvents(),e&&(this.keyboardController=this.inputClassesFactory.registerKeyBoard(this.config))}setMouseInputEnabled(e){var t;if(null===(t=this.mouseController)||void 0===t||t.unregisterMouseEvents(),e){const e=this.config.isFlagEnabled(re.HoveringMouseMode)?ue.HoveringMouse:ue.LockedMouse;this.mouseController=this.inputClassesFactory.registerMouse(e)}}setTouchInputEnabled(e){var t;null===(t=this.touchController)||void 0===t||t.unregisterTouchEvents(),e&&(this.touchController=this.inputClassesFactory.registerTouch(this.config.isFlagEnabled(re.FakeMouseWithTouches),this.videoElementParentClientRect))}setGamePadInputEnabled(e){var t;null===(t=this.gamePadController)||void 0===t||t.unregisterGamePadEvents(),e&&(this.gamePadController=this.inputClassesFactory.registerGamePad(),this.gamePadController.onGamepadConnected=()=>{this.streamMessageController.toStreamerHandlers.get("GamepadConnected")()},this.gamePadController.onGamepadDisconnected=e=>{this.streamMessageController.toStreamerHandlers.get("GamepadDisconnected")([e])})}registerDataChannelEventEmitters(e){e.onOpen=(e,t)=>this.pixelStreaming.dispatchEvent(new B$1({label:e,event:t})),e.onClose=(e,t)=>this.pixelStreaming.dispatchEvent(new _$1({label:e,event:t})),e.onError=(e,t)=>this.pixelStreaming.dispatchEvent(new W$1({label:e,event:t}))}}class gt{static vertexShader(){return"\n\t\tattribute vec2 a_position;\n\t\tattribute vec2 a_texCoord;\n\n\t\t// input\n\t\tuniform vec2 u_resolution;\n\t\tuniform vec4 u_offset;\n\n\t\t//\n\t\tvarying vec2 v_texCoord;\n\n\t\tvoid main() {\n\t\t // convert the rectangle from pixels to 0.0 to 1.0\n\t\t vec2 zeroToOne = a_position / u_resolution;\n\n\t\t // convert from 0->1 to 0->2\n\t\t vec2 zeroToTwo = zeroToOne * 2.0;\n\n\t\t // convert from 0->2 to -1->+1 (clipspace)\n\t\t vec2 clipSpace = zeroToTwo - 1.0;\n\n\t\t gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n\t\t // pass the texCoord to the fragment shader\n\t\t // The GPU will interpolate this value between points.\n\t\t v_texCoord = (a_texCoord * u_offset.xy) + u_offset.zw;\n\t\t}\n\t\t"}static fragmentShader(){return"\n\t\tprecision mediump float;\n\n\t\t// our texture\n\t\tuniform sampler2D u_image;\n\n\t\t// the texCoords passed in from the vertex shader.\n\t\tvarying vec2 v_texCoord;\n\n\t\tvoid main() {\n\t\t gl_FragColor = texture2D(u_image, v_texCoord);\n\t\t}\n\t\t"}}class ut{static deepCopyGamepad(e){return JSON.parse(JSON.stringify({buttons:e.buttons.map((e=>JSON.parse(JSON.stringify({pressed:e.pressed,touched:e.touched})))),axes:e.axes}))}}class mt{constructor(e){this.toStreamerMessagesProvider=e,this.controllers=[]}updateStatus(e,t,n){if(e.gamepad){const r=t.getPose(e.gripSpace,n);if(!r)return;let i=0;e.profiles.includes("htc-vive")?i=1:e.profiles.includes("oculus-touch")&&(i=2),this.toStreamerMessagesProvider.toStreamerHandlers.get("XRSystem")([i]);let s=2;switch(e.handedness){case"left":s=0;break;case"right":s=1}const o=r.transform.matrix,a=[];for(let e=0;e<16;e++)a[e]=new Float32Array([o[e]])[0];this.toStreamerMessagesProvider.toStreamerHandlers.get("XRControllerTransform")([a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15],s]),void 0===this.controllers[s]&&(this.controllers[s]={prevState:void 0,currentState:void 0,id:void 0},this.controllers[s].prevState=ut.deepCopyGamepad(e.gamepad)),this.controllers[s].currentState=ut.deepCopyGamepad(e.gamepad);const l=this.controllers[s],c=l.currentState,d=l.prevState;for(let e=0;e<c.buttons.length;e++){const t=c.buttons[e],n=d.buttons[e];t.pressed?this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonPressed")([s,e,n.pressed?1:0]):!t.pressed&&n.pressed&&this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonReleased")([s,e,0]),t.touched&&!t.pressed?this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonPressed")([s,3,n.touched?1:0]):!t.touched&&n.touched&&this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonReleased")([s,3,0])}for(let e=0;e<c.axes.length;e++)this.toStreamerMessagesProvider.toStreamerHandlers.get("XRAnalog")([s,e,c.axes[e]]);this.controllers[s].prevState=c}}}class St{constructor(e){this.xrSession=null,this.webRtcController=e,this.xrControllers=[],this.xrGamepadController=new mt(this.webRtcController.streamMessageController),this.onSessionEnded=new EventTarget,this.onSessionStarted=new EventTarget,this.onFrame=new EventTarget}xrClicked(){this.xrSession?this.xrSession.end():navigator.xr.requestSession("immersive-vr").then((e=>{this.onXrSessionStarted(e)}))}onXrSessionEnded(){i.Log(i.GetStackTrace(),"XR Session ended"),this.xrSession=null,this.onSessionEnded.dispatchEvent(new Event("xrSessionEnded"))}onXrSessionStarted(e){i.Log(i.GetStackTrace(),"XR Session started"),this.xrSession=e,this.xrSession.addEventListener("end",(()=>{this.onXrSessionEnded()}));const t=document.createElement("canvas");this.gl=t.getContext("webgl2",{xrCompatible:!0}),this.xrSession.updateRenderState({baseLayer:new XRWebGLLayer(this.xrSession,this.gl)});const n=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(n,gt.vertexShader()),this.gl.compileShader(n);const r=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(r,gt.fragmentShader()),this.gl.compileShader(r);const s=this.gl.createProgram();this.gl.attachShader(s,n),this.gl.attachShader(s,r),this.gl.linkProgram(s),this.gl.useProgram(s),this.positionLocation=this.gl.getAttribLocation(s,"a_position"),this.texcoordLocation=this.gl.getAttribLocation(s,"a_texCoord"),this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.enableVertexAttribArray(this.positionLocation);const o=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_2D,o),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.texcoordBuffer=this.gl.createBuffer(),this.resolutionLocation=this.gl.getUniformLocation(s,"u_resolution"),this.offsetLocation=this.gl.getUniformLocation(s,"u_offset"),e.requestReferenceSpace("local").then((e=>{this.xrRefSpace=e,this.xrSession.requestAnimationFrame(((e,t)=>this.onXrFrame(e,t)))})),this.onSessionStarted.dispatchEvent(new Event("xrSessionStarted"))}onXrFrame(e,t){const n=t.getViewerPose(this.xrRefSpace);if(n){const e=n.transform.matrix,t=[];for(let n=0;n<16;n++)t[n]=new Float32Array([e[n]])[0];this.webRtcController.streamMessageController.toStreamerHandlers.get("XRHMDTransform")([t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]);const r=this.xrSession.renderState.baseLayer;this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,r.framebuffer),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.webRtcController.videoPlayer.getVideoElement()),this.render(this.webRtcController.videoPlayer.getVideoElement())}this.webRtcController.config.isFlagEnabled(re.XRControllerInput)&&this.xrSession.inputSources.forEach(((e,n,r)=>{this.xrGamepadController.updateStatus(e,t,this.xrRefSpace)}),this),this.xrSession.requestAnimationFrame(((e,t)=>this.onXrFrame(e,t))),this.onFrame.dispatchEvent(new se({time:e,frame:t}))}render(e){if(!this.gl)return;const t=this.xrSession.renderState.baseLayer;let n,r,i,s,o;this.gl.viewport(0,0,t.framebufferWidth,t.framebufferHeight),this.gl.uniform4f(this.offsetLocation,1,1,0,0),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,e.videoWidth,0,0,e.videoHeight,0,e.videoHeight,e.videoWidth,0,e.videoWidth,e.videoHeight]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texcoordBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),n=2,r=this.gl.FLOAT,i=!1,s=0,o=0,this.gl.vertexAttribPointer(this.positionLocation,n,r,i,s,o),this.gl.enableVertexAttribArray(this.texcoordLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texcoordBuffer),n=2,r=this.gl.FLOAT,i=!1,s=0,o=0,this.gl.vertexAttribPointer(this.texcoordLocation,n,r,i,s,o),this.gl.uniform2f(this.resolutionLocation,e.videoWidth,e.videoHeight);const a=this.gl.TRIANGLES;o=0,this.gl.drawArrays(a,o,6)}static isSessionSupported(e){return navigator.xr?navigator.xr.isSessionSupported(e):new Promise((()=>!1))}}class pt{constructor(e){this.editTextButton=null,this.hiddenInput=null,"ontouchstart"in document.documentElement&&this.createOnScreenKeyboardHelpers(e)}unquantizeAndDenormalizeUnsigned(e,t){return null}createOnScreenKeyboardHelpers(e){this.hiddenInput||(this.hiddenInput=document.createElement("input"),this.hiddenInput.id="hiddenInput",this.hiddenInput.maxLength=0,e.appendChild(this.hiddenInput)),this.editTextButton||(this.editTextButton=document.createElement("button"),this.editTextButton.id="editTextButton",this.editTextButton.innerHTML="edit text",e.appendChild(this.editTextButton),this.editTextButton.classList.add("hiddenState"),this.editTextButton.addEventListener("touchend",(e=>{this.hiddenInput.focus(),e.preventDefault()})))}showOnScreenKeyboard(e){if(e.showOnScreenKeyboard){this.editTextButton.classList.remove("hiddenState");const t=this.unquantizeAndDenormalizeUnsigned(e.x,e.y);this.editTextButton.style.top=t.y.toString()+"px",this.editTextButton.style.left=(t.x-40).toString()+"px"}else this.editTextButton.classList.add("hiddenState"),this.hiddenInput.blur()}}class vt{constructor(e,t){this._showActionOrErrorOnDisconnect=!0,this.allowConsoleCommands=!1,this.config=e,(null==t?void 0:t.videoElementParent)&&(this._videoElementParent=t.videoElementParent),this._eventEmitter=new ne,this.configureSettings(),this.setWebRtcPlayerController(new ht(this.config,this)),this.onScreenKeyboardHelper=new pt(this.videoElementParent),this.onScreenKeyboardHelper.unquantizeAndDenormalizeUnsigned=(e,t)=>this._webRtcController.requestUnquantizedAndDenormalizeUnsigned(e,t),this._activateOnScreenKeyboard=e=>this.onScreenKeyboardHelper.showOnScreenKeyboard(e),this._webXrController=new St(this._webRtcController)}get videoElementParent(){return this._videoElementParent||(this._videoElementParent=document.createElement("div"),this._videoElementParent.id="videoElementParent"),this._videoElementParent}configureSettings(){this.config._addOnSettingChangedListener(re.IsQualityController,(e=>{!0!==e||this._webRtcController.isQualityController||this._webRtcController.sendRequestQualityControlOwnership()})),this.config._addOnSettingChangedListener(re.AFKDetection,(e=>{this._webRtcController.setAfkEnabled(e)})),this.config._addOnSettingChangedListener(re.MatchViewportResolution,(()=>{this._webRtcController.videoPlayer.updateVideoStreamSize()})),this.config._addOnSettingChangedListener(re.HoveringMouseMode,(e=>{this.config.setFlagLabel(re.HoveringMouseMode,`Control Scheme: ${e?"Hovering":"Locked"} Mouse`),this._webRtcController.setMouseInputEnabled(this.config.isFlagEnabled(re.MouseInput))})),this.config._addOnSettingChangedListener(re.KeyboardInput,(e=>{this._webRtcController.setKeyboardInputEnabled(e)})),this.config._addOnSettingChangedListener(re.MouseInput,(e=>{this._webRtcController.setMouseInputEnabled(e)})),this.config._addOnSettingChangedListener(re.TouchInput,(e=>{this._webRtcController.setTouchInputEnabled(e)})),this.config._addOnSettingChangedListener(re.GamepadInput,(e=>{this._webRtcController.setGamePadInputEnabled(e)})),this.config._addOnNumericSettingChangedListener(oe.MinQP,(e=>{i.Log(i.GetStackTrace(),"-------- Sending MinQP --------",7),this._webRtcController.sendEncoderMinQP(e),i.Log(i.GetStackTrace(),"-------------------------------------------",7)})),this.config._addOnNumericSettingChangedListener(oe.MaxQP,(e=>{i.Log(i.GetStackTrace(),"-------- Sending encoder settings --------",7),this._webRtcController.sendEncoderMaxQP(e),i.Log(i.GetStackTrace(),"-------------------------------------------",7)})),this.config._addOnNumericSettingChangedListener(oe.WebRTCMinBitrate,(e=>{i.Log(i.GetStackTrace(),"-------- Sending web rtc settings --------",7),this._webRtcController.sendWebRTCMinBitrate(1e3*e),i.Log(i.GetStackTrace(),"-------------------------------------------",7)})),this.config._addOnNumericSettingChangedListener(oe.WebRTCMaxBitrate,(e=>{i.Log(i.GetStackTrace(),"-------- Sending web rtc settings --------",7),this._webRtcController.sendWebRTCMaxBitrate(1e3*e),i.Log(i.GetStackTrace(),"-------------------------------------------",7)})),this.config._addOnNumericSettingChangedListener(oe.WebRTCFPS,(e=>{i.Log(i.GetStackTrace(),"-------- Sending web rtc settings --------",7),this._webRtcController.sendWebRTCFps(e),i.Log(i.GetStackTrace(),"-------------------------------------------",7)})),this.config._addOnOptionSettingChangedListener(ce.PreferredCodec,(e=>{this._webRtcController&&this._webRtcController.setPreferredCodec(e)})),this.config._registerOnChangeEvents(this._eventEmitter)}_activateOnScreenKeyboard(e){throw new Error("Method not implemented.")}_onInputControlOwnership(e){this._inputController=e}setWebRtcPlayerController(e){this._webRtcController=e,this._webRtcController.setPreferredCodec(this.config.getSettingOption(ce.PreferredCodec).selected),this._webRtcController.resizePlayerStyle(),this.checkForAutoConnect()}connect(){this._webRtcController.connectToSignallingServer()}reconnect(){this._webRtcController.restartStreamAutomatically()}disconnect(){this._webRtcController.close()}play(){this._onStreamLoading(),this._webRtcController.playStream()}checkForAutoConnect(){this.config.isFlagEnabled(re.AutoConnect)&&(this._onWebRtcAutoConnect(),this._webRtcController.connectToSignallingServer())}_onWebRtcAutoConnect(){this._eventEmitter.dispatchEvent(new O$1),this._showActionOrErrorOnDisconnect=!0}_onWebRtcSdp(){this._eventEmitter.dispatchEvent(new D$1)}_onStreamLoading(){this._eventEmitter.dispatchEvent(new V$1)}_onDisconnect(e){""!=this._webRtcController.getDisconnectMessageOverride()&&void 0!==this._webRtcController.getDisconnectMessageOverride()&&null!=this._webRtcController.getDisconnectMessageOverride()&&(e=this._webRtcController.getDisconnectMessageOverride(),this._webRtcController.setDisconnectMessageOverride("")),this._eventEmitter.dispatchEvent(new z$2({eventString:e,showActionOrErrorOnDisconnect:this._showActionOrErrorOnDisconnect})),0==this._showActionOrErrorOnDisconnect&&(this._showActionOrErrorOnDisconnect=!0)}_onWebRtcConnecting(){this._eventEmitter.dispatchEvent(new U$1)}_onWebRtcConnected(){this._eventEmitter.dispatchEvent(new I$1)}_onWebRtcFailed(){this._eventEmitter.dispatchEvent(new G$1)}_onVideoInitialized(){this._eventEmitter.dispatchEvent(new H$1),this._videoStartTime=Date.now()}_onLatencyTestResult(e){this._eventEmitter.dispatchEvent(new Y$1({latencyTimings:e}))}_onVideoStats(e){this._videoStartTime&&void 0!==this._videoStartTime||(this._videoStartTime=Date.now()),e.handleSessionStatistics(this._videoStartTime,this._inputController,this._webRtcController.videoAvgQp),this._eventEmitter.dispatchEvent(new X$1({aggregatedStats:e}))}_onVideoEncoderAvgQP(e){this._eventEmitter.dispatchEvent(new F$1({avgQP:e}))}_onInitialSettings(e){var t;this._eventEmitter.dispatchEvent(new J$1({settings:e})),e.PixelStreamingSettings&&(this.allowConsoleCommands=null!==(t=e.PixelStreamingSettings.AllowPixelStreamingCommands)&&void 0!==t&&t,!1===this.allowConsoleCommands&&i.Info(i.GetStackTrace(),"-AllowPixelStreamingCommands=false, sending arbitrary console commands from browser to UE is disabled."));const n=this.config.useUrlParams,r=new URLSearchParams(window.location.search);e.EncoderSettings&&(this.config.setNumericSetting(oe.MinQP,n&&r.has(oe.MinQP)?Number.parseInt(r.get(oe.MinQP)):e.EncoderSettings.MinQP),this.config.setNumericSetting(oe.MaxQP,n&&r.has(oe.MaxQP)?Number.parseInt(r.get(oe.MaxQP)):e.EncoderSettings.MaxQP)),e.WebRTCSettings&&(this.config.setNumericSetting(oe.WebRTCMinBitrate,n&&r.has(oe.WebRTCMinBitrate)?Number.parseInt(r.get(oe.WebRTCMinBitrate))/1e3:e.WebRTCSettings.MinBitrate/1e3),this.config.setNumericSetting(oe.WebRTCMaxBitrate,n&&r.has(oe.WebRTCMaxBitrate)?Number.parseInt(r.get(oe.WebRTCMaxBitrate))/1e3:e.WebRTCSettings.MaxBitrate/1e3),this.config.setNumericSetting(oe.WebRTCFPS,n&&r.has(oe.WebRTCFPS)?Number.parseInt(r.get(oe.WebRTCFPS)):e.WebRTCSettings.FPS))}_onQualityControlOwnership(e){this.config.setFlagEnabled(re.IsQualityController,e)}requestLatencyTest(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendLatencyTest(),!0)}requestShowFps(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendShowFps(),!0)}requestIframe(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendIframeRequest(),!0)}emitUIInteraction(e){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.emitUIInteraction(e),!0)}emitCommand(e){return!(!this._webRtcController.videoPlayer.isVideoReady()||!this.allowConsoleCommands&&"ConsoleCommand"in e||(this._webRtcController.emitCommand(e),0))}emitConsoleCommand(e){return!(!this.allowConsoleCommands||!this._webRtcController.videoPlayer.isVideoReady()||(this._webRtcController.emitConsoleCommand(e),0))}addResponseEventListener(e,t){this._webRtcController.responseController.addResponseEventListener(e,t)}removeResponseEventListener(e){this._webRtcController.responseController.removeResponseEventListener(e)}dispatchEvent(e){return this._eventEmitter.dispatchEvent(e)}addEventListener(e,t){this._eventEmitter.addEventListener(e,t)}removeEventListener(e,t){this._eventEmitter.removeEventListener(e,t)}toggleXR(){this.webXrController.xrClicked()}setSignallingUrlBuilder(e){this._webRtcController.signallingUrlBuilder=e}get webSocketController(){return this._webRtcController.webSocketController}get webXrController(){return this._webXrController}}var Ct=r$1.Dz,ft=r$1.g$,Tt=r$1.Lt,Et=r$1.Q9,yt=r$1.qf,bt=r$1.hV,Mt=r$1.z$,wt=r$1.J0,Pt=r$1.De,kt=r$1.$C,Rt=r$1.al,Lt=r$1._W,xt=r$1.tz,At=r$1.Nu,Ft=r$1.zg,Dt=r$1.vp,Ot=r$1.vU,Ut=r$1.wF,It=r$1.rv,Gt=r$1.Nh,zt=r$1.ss,Bt=r$1.qW,_t=r$1.QL,Wt=r$1.cf,Ht=r$1.eM,Vt=r$1.Yd,Nt=r$1.iM,Kt=r$1.qy,Qt=r$1.ce,$t=r$1.sK,qt=r$1.Ok,Xt=r$1.q5,jt=r$1.g,Yt=r$1.xl,Jt=r$1.I,Zt=r$1.bx,es=r$1.Ib,ts=r$1.Az,ss=r$1.Iw,ns$1=r$1.qY,rs=r$1.db,is=r$1.mR,os=r$1.Tn,as=r$1.rV,ds=r$1.gh,ls=r$1.i5,cs=r$1.x_,hs=r$1.Am,gs=r$1.eR,us=r$1.r8,ms=r$1.u3,Ss=r$1.vd,ps=r$1.iV,vs=r$1.jZ,Cs=r$1.SW,fs=r$1.ZH,Ts=r$1.Ni,Es=r$1.lh,ys=r$1.bq,bs=r$1.$f,Ms=r$1.eu,ws=r$1.Ax,Ps=r$1.Mc;function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(this,arguments)}var _typeof$1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},isBrowser="object"===("undefined"==typeof window?"undefined":_typeof$1(window))&&"object"===("undefined"==typeof document?"undefined":_typeof$1(document))&&9===document.nodeType;function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,_setPrototypeOf(e,t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}var plainObjectConstrurctor={}.constructor;function cloneStyle(e){if(null==e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(cloneStyle);if(e.constructor!==plainObjectConstrurctor)return e;var t={};for(var n in e)t[n]=cloneStyle(e[n]);return t}function createRule(e,t,n){void 0===e&&(e="unnamed");var r=n.jss,i=cloneStyle(t);return r.plugins.onCreateRule(e,i,n)||(e[0],null)}var join$4=function(e,t){for(var n="",r=0;r<e.length&&"!important"!==e[r];r++)n&&(n+=t),n+=e[r];return n},toCssValue=function(e){if(!Array.isArray(e))return e;var t="";if(Array.isArray(e[0]))for(var n=0;n<e.length&&"!important"!==e[n];n++)t&&(t+=", "),t+=join$4(e[n]," ");else t=join$4(e,", ");return"!important"===e[e.length-1]&&(t+=" !important"),t};function getWhitespaceSymbols(e){return e&&!1===e.format?{linebreak:"",space:""}:{linebreak:"\n",space:" "}}function indentStr(e,t){for(var n="",r=0;r<t;r++)n+=" ";return n+e}function toCss(e,t,n){void 0===n&&(n={});var r="";if(!t)return r;var i=n.indent,s=void 0===i?0:i,o=t.fallbacks;!1===n.format&&(s=-1/0);var a=getWhitespaceSymbols(n),l=a.linebreak,c=a.space;if(e&&s++,o)if(Array.isArray(o))for(var d=0;d<o.length;d++){var u=o[d];for(var h in u){var p=u[h];null!=p&&(r&&(r+=l),r+=indentStr(h+":"+c+toCssValue(p)+";",s))}}else for(var g in o){var m=o[g];null!=m&&(r&&(r+=l),r+=indentStr(g+":"+c+toCssValue(m)+";",s))}for(var f in t){var v=t[f];null!=v&&"fallbacks"!==f&&(r&&(r+=l),r+=indentStr(f+":"+c+toCssValue(v)+";",s))}return(r||n.allowEmpty)&&e?(r&&(r=""+l+r+l),indentStr(""+e+c+"{"+r,--s)+indentStr("}",s)):r}var escapeRegex=/([[\].#*$><+~=|^:(),"'`\s])/g,nativeEscape="undefined"!=typeof CSS&&CSS.escape,escape=function(e){return nativeEscape?nativeEscape(e):e.replace(escapeRegex,"\\$1")},BaseStyleRule=function(){function e(e,t,n){this.type="style",this.isProcessed=!1;var r=n.sheet,i=n.Renderer;this.key=e,this.options=n,this.style=t,r?this.renderer=r.renderer:i&&(this.renderer=new i)}return e.prototype.prop=function(e,t,n){if(void 0===t)return this.style[e];var r=!!n&&n.force;if(!r&&this.style[e]===t)return this;var i=t;n&&!1===n.process||(i=this.options.jss.plugins.onChangeValue(t,e,this));var s=null==i||!1===i,o=e in this.style;if(s&&!o&&!r)return this;var a=s&&o;if(a?delete this.style[e]:this.style[e]=i,this.renderable&&this.renderer)return a?this.renderer.removeProperty(this.renderable,e):this.renderer.setProperty(this.renderable,e,i),this;var l=this.options.sheet;return l&&l.attached,this},e}(),StyleRule=function(e){function t(t,n,r){var i;i=e.call(this,t,n,r)||this;var s=r.selector,o=r.scoped,a=r.sheet,l=r.generateId;return s?i.selectorText=s:!1!==o&&(i.id=l(_assertThisInitialized(_assertThisInitialized(i)),a),i.selectorText="."+escape(i.id)),i}_inheritsLoose(t,e);var n=t.prototype;return n.applyTo=function(e){var t=this.renderer;if(t){var n=this.toJSON();for(var r in n)t.setProperty(e,r,n[r])}return this},n.toJSON=function(){var e={};for(var t in this.style){var n=this.style[t];"object"!=typeof n?e[t]=n:Array.isArray(n)&&(e[t]=toCssValue(n))}return e},n.toString=function(e){var t=this.options.sheet,n=t&&t.options.link?_extends({},e,{allowEmpty:!0}):e;return toCss(this.selectorText,this.style,n)},_createClass(t,[{key:"selector",set:function(e){if(e!==this.selectorText){this.selectorText=e;var t=this.renderer,n=this.renderable;n&&t&&(t.setSelector(n,e)||t.replaceRule(n,this))}},get:function(){return this.selectorText}}]),t}(BaseStyleRule),pluginStyleRule={onCreateRule:function(e,t,n){return"@"===e[0]||n.parent&&"keyframes"===n.parent.type?null:new StyleRule(e,t,n)}},defaultToStringOptions={indent:1,children:!0},atRegExp=/@([\w-]+)/,ConditionalRule=function(){function e(e,t,n){this.type="conditional",this.isProcessed=!1,this.key=e;var r=e.match(atRegExp);for(var i in this.at=r?r[1]:"unknown",this.query=n.name||"@"+this.at,this.options=n,this.rules=new RuleList(_extends({},n,{parent:this})),t)this.rules.add(i,t[i]);this.rules.process()}var t=e.prototype;return t.getRule=function(e){return this.rules.get(e)},t.indexOf=function(e){return this.rules.indexOf(e)},t.addRule=function(e,t,n){var r=this.rules.add(e,t,n);return r?(this.options.jss.plugins.onProcessRule(r),r):null},t.replaceRule=function(e,t,n){var r=this.rules.replace(e,t,n);return r&&this.options.jss.plugins.onProcessRule(r),r},t.toString=function(e){void 0===e&&(e=defaultToStringOptions);var t=getWhitespaceSymbols(e).linebreak;if(null==e.indent&&(e.indent=defaultToStringOptions.indent),null==e.children&&(e.children=defaultToStringOptions.children),!1===e.children)return this.query+" {}";var n=this.rules.toString(e);return n?this.query+" {"+t+n+t+"}":""},e}(),keyRegExp=/@container|@media|@supports\s+/,pluginConditionalRule={onCreateRule:function(e,t,n){return keyRegExp.test(e)?new ConditionalRule(e,t,n):null}},defaultToStringOptions$1={indent:1,children:!0},nameRegExp=/@keyframes\s+([\w-]+)/,KeyframesRule=function(){function e(e,t,n){this.type="keyframes",this.at="@keyframes",this.isProcessed=!1;var r=e.match(nameRegExp);r&&r[1]?this.name=r[1]:this.name="noname",this.key=this.type+"-"+this.name,this.options=n;var i=n.scoped,s=n.sheet,o=n.generateId;for(var a in this.id=!1===i?this.name:escape(o(this,s)),this.rules=new RuleList(_extends({},n,{parent:this})),t)this.rules.add(a,t[a],_extends({},n,{parent:this}));this.rules.process()}return e.prototype.toString=function(e){void 0===e&&(e=defaultToStringOptions$1);var t=getWhitespaceSymbols(e).linebreak;if(null==e.indent&&(e.indent=defaultToStringOptions$1.indent),null==e.children&&(e.children=defaultToStringOptions$1.children),!1===e.children)return this.at+" "+this.id+" {}";var n=this.rules.toString(e);return n&&(n=""+t+n+t),this.at+" "+this.id+" {"+n+"}"},e}(),keyRegExp$1=/@keyframes\s+/,refRegExp=/\$([\w-]+)/g,findReferencedKeyframe=function(e,t){return"string"==typeof e?e.replace(refRegExp,(function(e,n){return n in t?t[n]:e})):e},replaceRef=function(e,t,n){var r=e[t],i=findReferencedKeyframe(r,n);i!==r&&(e[t]=i)},pluginKeyframesRule={onCreateRule:function(e,t,n){return"string"==typeof e&&keyRegExp$1.test(e)?new KeyframesRule(e,t,n):null},onProcessStyle:function(e,t,n){return"style"===t.type&&n?("animation-name"in e&&replaceRef(e,"animation-name",n.keyframes),"animation"in e&&replaceRef(e,"animation",n.keyframes),e):e},onChangeValue:function(e,t,n){var r=n.options.sheet;if(!r)return e;switch(t){case"animation":case"animation-name":return findReferencedKeyframe(e,r.keyframes);default:return e}}},KeyframeRule=function(e){function t(){return e.apply(this,arguments)||this}return _inheritsLoose(t,e),t.prototype.toString=function(e){var t=this.options.sheet,n=t&&t.options.link?_extends({},e,{allowEmpty:!0}):e;return toCss(this.key,this.style,n)},t}(BaseStyleRule),pluginKeyframeRule={onCreateRule:function(e,t,n){return n.parent&&"keyframes"===n.parent.type?new KeyframeRule(e,t,n):null}},FontFaceRule=function(){function e(e,t,n){this.type="font-face",this.at="@font-face",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){var t=getWhitespaceSymbols(e).linebreak;if(Array.isArray(this.style)){for(var n="",r=0;r<this.style.length;r++)n+=toCss(this.at,this.style[r]),this.style[r+1]&&(n+=t);return n}return toCss(this.at,this.style,e)},e}(),keyRegExp$2=/@font-face/,pluginFontFaceRule={onCreateRule:function(e,t,n){return keyRegExp$2.test(e)?new FontFaceRule(e,t,n):null}},ViewportRule=function(){function e(e,t,n){this.type="viewport",this.at="@viewport",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){return toCss(this.key,this.style,e)},e}(),pluginViewportRule={onCreateRule:function(e,t,n){return"@viewport"===e||"@-ms-viewport"===e?new ViewportRule(e,t,n):null}},SimpleRule=function(){function e(e,t,n){this.type="simple",this.isProcessed=!1,this.key=e,this.value=t,this.options=n}return e.prototype.toString=function(e){if(Array.isArray(this.value)){for(var t="",n=0;n<this.value.length;n++)t+=this.key+" "+this.value[n]+";",this.value[n+1]&&(t+="\n");return t}return this.key+" "+this.value+";"},e}(),keysMap={"@charset":!0,"@import":!0,"@namespace":!0},pluginSimpleRule={onCreateRule:function(e,t,n){return e in keysMap?new SimpleRule(e,t,n):null}},plugins=[pluginStyleRule,pluginConditionalRule,pluginKeyframesRule,pluginKeyframeRule,pluginFontFaceRule,pluginViewportRule,pluginSimpleRule],defaultUpdateOptions={process:!0},forceUpdateOptions={force:!0,process:!0},RuleList=function(){function e(e){this.map={},this.raw={},this.index=[],this.counter=0,this.options=e,this.classes=e.classes,this.keyframes=e.keyframes}var t=e.prototype;return t.add=function(e,t,n){var r=this.options,i=r.parent,s=r.sheet,o=r.jss,a=r.Renderer,l=r.generateId,c=r.scoped,d=_extends({classes:this.classes,parent:i,sheet:s,jss:o,Renderer:a,generateId:l,scoped:c,name:e,keyframes:this.keyframes,selector:void 0},n),u=e;e in this.raw&&(u=e+"-d"+this.counter++),this.raw[u]=t,u in this.classes&&(d.selector="."+escape(this.classes[u]));var h=createRule(u,t,d);if(!h)return null;this.register(h);var p=void 0===d.index?this.index.length:d.index;return this.index.splice(p,0,h),h},t.replace=function(e,t,n){var r=this.get(e),i=this.index.indexOf(r);r&&this.remove(r);var s=n;return-1!==i&&(s=_extends({},n,{index:i})),this.add(e,t,s)},t.get=function(e){return this.map[e]},t.remove=function(e){this.unregister(e),delete this.raw[e.key],this.index.splice(this.index.indexOf(e),1)},t.indexOf=function(e){return this.index.indexOf(e)},t.process=function(){var e=this.options.jss.plugins;this.index.slice(0).forEach(e.onProcessRule,e)},t.register=function(e){this.map[e.key]=e,e instanceof StyleRule?(this.map[e.selector]=e,e.id&&(this.classes[e.key]=e.id)):e instanceof KeyframesRule&&this.keyframes&&(this.keyframes[e.name]=e.id)},t.unregister=function(e){delete this.map[e.key],e instanceof StyleRule?(delete this.map[e.selector],delete this.classes[e.key]):e instanceof KeyframesRule&&delete this.keyframes[e.name]},t.update=function(){var e,t,n;if("string"==typeof(arguments.length<=0?void 0:arguments[0])?(e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],n=arguments.length<=2?void 0:arguments[2]):(t=arguments.length<=0?void 0:arguments[0],n=arguments.length<=1?void 0:arguments[1],e=null),e)this.updateOne(this.get(e),t,n);else for(var r=0;r<this.index.length;r++)this.updateOne(this.index[r],t,n)},t.updateOne=function(t,n,r){void 0===r&&(r=defaultUpdateOptions);var i=this.options,s=i.jss.plugins,o=i.sheet;if(t.rules instanceof e)t.rules.update(n,r);else{var a=t.style;if(s.onUpdate(n,t,o,r),r.process&&a&&a!==t.style){for(var l in s.onProcessStyle(t.style,t,o),t.style){var c=t.style[l];c!==a[l]&&t.prop(l,c,forceUpdateOptions)}for(var d in a){var u=t.style[d],h=a[d];null==u&&u!==h&&t.prop(d,null,forceUpdateOptions)}}}},t.toString=function(e){for(var t="",n=this.options.sheet,r=!!n&&n.options.link,i=getWhitespaceSymbols(e).linebreak,s=0;s<this.index.length;s++){var o=this.index[s].toString(e);(o||r)&&(t&&(t+=i),t+=o)}return t},e}(),StyleSheet=function(){function e(e,t){for(var n in this.attached=!1,this.deployed=!1,this.classes={},this.keyframes={},this.options=_extends({},t,{sheet:this,parent:this,classes:this.classes,keyframes:this.keyframes}),t.Renderer&&(this.renderer=new t.Renderer(this)),this.rules=new RuleList(this.options),e)this.rules.add(n,e[n]);this.rules.process()}var t=e.prototype;return t.attach=function(){return this.attached||(this.renderer&&this.renderer.attach(),this.attached=!0,this.deployed||this.deploy()),this},t.detach=function(){return this.attached?(this.renderer&&this.renderer.detach(),this.attached=!1,this):this},t.addRule=function(e,t,n){var r=this.queue;this.attached&&!r&&(this.queue=[]);var i=this.rules.add(e,t,n);return i?(this.options.jss.plugins.onProcessRule(i),this.attached?this.deployed?(r?r.push(i):(this.insertRule(i),this.queue&&(this.queue.forEach(this.insertRule,this),this.queue=void 0)),i):i:(this.deployed=!1,i)):null},t.replaceRule=function(e,t,n){var r=this.rules.get(e);if(!r)return this.addRule(e,t,n);var i=this.rules.replace(e,t,n);return i&&this.options.jss.plugins.onProcessRule(i),this.attached?this.deployed?(this.renderer&&(i?r.renderable&&this.renderer.replaceRule(r.renderable,i):this.renderer.deleteRule(r)),i):i:(this.deployed=!1,i)},t.insertRule=function(e){this.renderer&&this.renderer.insertRule(e)},t.addRules=function(e,t){var n=[];for(var r in e){var i=this.addRule(r,e[r],t);i&&n.push(i)}return n},t.getRule=function(e){return this.rules.get(e)},t.deleteRule=function(e){var t="object"==typeof e?e:this.rules.get(e);return!(!t||this.attached&&!t.renderable)&&(this.rules.remove(t),!(this.attached&&t.renderable&&this.renderer)||this.renderer.deleteRule(t.renderable))},t.indexOf=function(e){return this.rules.indexOf(e)},t.deploy=function(){return this.renderer&&this.renderer.deploy(),this.deployed=!0,this},t.update=function(){var e;return(e=this.rules).update.apply(e,arguments),this},t.updateOne=function(e,t,n){return this.rules.updateOne(e,t,n),this},t.toString=function(e){return this.rules.toString(e)},e}(),PluginsRegistry=function(){function e(){this.plugins={internal:[],external:[]},this.registry={}}var t=e.prototype;return t.onCreateRule=function(e,t,n){for(var r=0;r<this.registry.onCreateRule.length;r++){var i=this.registry.onCreateRule[r](e,t,n);if(i)return i}return null},t.onProcessRule=function(e){if(!e.isProcessed){for(var t=e.options.sheet,n=0;n<this.registry.onProcessRule.length;n++)this.registry.onProcessRule[n](e,t);e.style&&this.onProcessStyle(e.style,e,t),e.isProcessed=!0}},t.onProcessStyle=function(e,t,n){for(var r=0;r<this.registry.onProcessStyle.length;r++)t.style=this.registry.onProcessStyle[r](t.style,t,n)},t.onProcessSheet=function(e){for(var t=0;t<this.registry.onProcessSheet.length;t++)this.registry.onProcessSheet[t](e)},t.onUpdate=function(e,t,n,r){for(var i=0;i<this.registry.onUpdate.length;i++)this.registry.onUpdate[i](e,t,n,r)},t.onChangeValue=function(e,t,n){for(var r=e,i=0;i<this.registry.onChangeValue.length;i++)r=this.registry.onChangeValue[i](r,t,n);return r},t.use=function(e,t){void 0===t&&(t={queue:"external"});var n=this.plugins[t.queue];-1===n.indexOf(e)&&(n.push(e),this.registry=[].concat(this.plugins.external,this.plugins.internal).reduce((function(e,t){for(var n in t)n in e&&e[n].push(t[n]);return e}),{onCreateRule:[],onProcessRule:[],onProcessStyle:[],onProcessSheet:[],onChangeValue:[],onUpdate:[]}))},e}(),SheetsRegistry=function(){function e(){this.registry=[]}var t=e.prototype;return t.add=function(e){var t=this.registry,n=e.options.index;if(-1===t.indexOf(e))if(0===t.length||n>=this.index)t.push(e);else for(var r=0;r<t.length;r++)if(t[r].options.index>n)return void t.splice(r,0,e)},t.reset=function(){this.registry=[]},t.remove=function(e){var t=this.registry.indexOf(e);this.registry.splice(t,1)},t.toString=function(e){for(var t=void 0===e?{}:e,n=t.attached,r=_objectWithoutPropertiesLoose(t,["attached"]),i=getWhitespaceSymbols(r).linebreak,s="",o=0;o<this.registry.length;o++){var a=this.registry[o];null!=n&&a.attached!==n||(s&&(s+=i),s+=a.toString(r))}return s},_createClass(e,[{key:"index",get:function(){return 0===this.registry.length?0:this.registry[this.registry.length-1].options.index}}]),e}(),sheets=new SheetsRegistry,globalThis$1="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),ns="2f1acc6c3a606b082e5eef5e54414ffb";null==globalThis$1[ns]&&(globalThis$1[ns]=0);var moduleId=globalThis$1[ns]++,createGenerateId=function(e){void 0===e&&(e={});var t=0;return function(n,r){t+=1;var i="",s="";return r&&(r.options.classNamePrefix&&(s=r.options.classNamePrefix),null!=r.options.jss.id&&(i=String(r.options.jss.id))),e.minify?""+(s||"c")+moduleId+i+t:s+n.key+"-"+moduleId+(i?"-"+i:"")+"-"+t}},memoize=function(e){var t;return function(){return t||(t=e()),t}},getPropertyValue=function(e,t){try{return e.attributeStyleMap?e.attributeStyleMap.get(t):e.style.getPropertyValue(t)}catch(e){return""}},setProperty=function(e,t,n){try{var r=n;if(Array.isArray(n)&&(r=toCssValue(n)),e.attributeStyleMap)e.attributeStyleMap.set(t,r);else{var i=r?r.indexOf("!important"):-1,s=i>-1?r.substr(0,i-1):r;e.style.setProperty(t,s,i>-1?"important":"")}}catch(e){return!1}return!0},removeProperty=function(e,t){try{e.attributeStyleMap?e.attributeStyleMap.delete(t):e.style.removeProperty(t)}catch(e){}},setSelector=function(e,t){return e.selectorText=t,e.selectorText===t},getHead=memoize((function(){return document.querySelector("head")}));function findHigherSheet(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.attached&&r.options.index>t.index&&r.options.insertionPoint===t.insertionPoint)return r}return null}function findHighestSheet(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.attached&&r.options.insertionPoint===t.insertionPoint)return r}return null}function findCommentNode(e){for(var t=getHead(),n=0;n<t.childNodes.length;n++){var r=t.childNodes[n];if(8===r.nodeType&&r.nodeValue.trim()===e)return r}return null}function findPrevNode(e){var t=sheets.registry;if(t.length>0){var n=findHigherSheet(t,e);if(n&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element};if((n=findHighestSheet(t,e))&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element.nextSibling}}var r=e.insertionPoint;if(r&&"string"==typeof r){var i=findCommentNode(r);if(i)return{parent:i.parentNode,node:i.nextSibling}}return!1}function insertStyle(e,t){var n=t.insertionPoint,r=findPrevNode(t);if(!1!==r&&r.parent)r.parent.insertBefore(e,r.node);else if(n&&"number"==typeof n.nodeType){var i=n,s=i.parentNode;s&&s.insertBefore(e,i.nextSibling)}else getHead().appendChild(e)}var getNonce=memoize((function(){var e=document.querySelector('meta[property="csp-nonce"]');return e?e.getAttribute("content"):null})),_insertRule=function(e,t,n){try{"insertRule"in e?e.insertRule(t,n):"appendRule"in e&&e.appendRule(t)}catch(e){return!1}return e.cssRules[n]},getValidRuleInsertionIndex=function(e,t){var n=e.cssRules.length;return void 0===t||t>n?n:t},createStyle=function(){var e=document.createElement("style");return e.textContent="\n",e},DomRenderer=function(){function e(e){this.getPropertyValue=getPropertyValue,this.setProperty=setProperty,this.removeProperty=removeProperty,this.setSelector=setSelector,this.hasInsertedRules=!1,this.cssRules=[],e&&sheets.add(e),this.sheet=e;var t=this.sheet?this.sheet.options:{},n=t.media,r=t.meta,i=t.element;this.element=i||createStyle(),this.element.setAttribute("data-jss",""),n&&this.element.setAttribute("media",n),r&&this.element.setAttribute("data-meta",r);var s=getNonce();s&&this.element.setAttribute("nonce",s)}var t=e.prototype;return t.attach=function(){if(!this.element.parentNode&&this.sheet){insertStyle(this.element,this.sheet.options);var e=Boolean(this.sheet&&this.sheet.deployed);this.hasInsertedRules&&e&&(this.hasInsertedRules=!1,this.deploy())}},t.detach=function(){if(this.sheet){var e=this.element.parentNode;e&&e.removeChild(this.element),this.sheet.options.link&&(this.cssRules=[],this.element.textContent="\n")}},t.deploy=function(){var e=this.sheet;e&&(e.options.link?this.insertRules(e.rules):this.element.textContent="\n"+e.toString()+"\n")},t.insertRules=function(e,t){for(var n=0;n<e.index.length;n++)this.insertRule(e.index[n],n,t)},t.insertRule=function(e,t,n){if(void 0===n&&(n=this.element.sheet),e.rules){var r=e,i=n;if("conditional"===e.type||"keyframes"===e.type){var s=getValidRuleInsertionIndex(n,t);if(!1===(i=_insertRule(n,r.toString({children:!1}),s)))return!1;this.refCssRule(e,s,i)}return this.insertRules(r.rules,i),i}var o=e.toString();if(!o)return!1;var a=getValidRuleInsertionIndex(n,t),l=_insertRule(n,o,a);return!1!==l&&(this.hasInsertedRules=!0,this.refCssRule(e,a,l),l)},t.refCssRule=function(e,t,n){e.renderable=n,e.options.parent instanceof StyleSheet&&this.cssRules.splice(t,0,n)},t.deleteRule=function(e){var t=this.element.sheet,n=this.indexOf(e);return-1!==n&&(t.deleteRule(n),this.cssRules.splice(n,1),!0)},t.indexOf=function(e){return this.cssRules.indexOf(e)},t.replaceRule=function(e,t){var n=this.indexOf(e);return-1!==n&&(this.element.sheet.deleteRule(n),this.cssRules.splice(n,1),this.insertRule(t,n))},t.getRules=function(){return this.element.sheet.cssRules},e}(),instanceCounter=0,Jss=function(){function e(e){this.id=instanceCounter++,this.version="10.10.0",this.plugins=new PluginsRegistry,this.options={id:{minify:!1},createGenerateId:createGenerateId,Renderer:isBrowser?DomRenderer:null,plugins:[]},this.generateId=createGenerateId({minify:!1});for(var t=0;t<plugins.length;t++)this.plugins.use(plugins[t],{queue:"internal"});this.setup(e)}var t=e.prototype;return t.setup=function(e){return void 0===e&&(e={}),e.createGenerateId&&(this.options.createGenerateId=e.createGenerateId),e.id&&(this.options.id=_extends({},this.options.id,e.id)),(e.createGenerateId||e.id)&&(this.generateId=this.options.createGenerateId(this.options.id)),null!=e.insertionPoint&&(this.options.insertionPoint=e.insertionPoint),"Renderer"in e&&(this.options.Renderer=e.Renderer),e.plugins&&this.use.apply(this,e.plugins),this},t.createStyleSheet=function(e,t){void 0===t&&(t={});var n=t.index;"number"!=typeof n&&(n=0===sheets.index?0:sheets.index+1);var r=new StyleSheet(e,_extends({},t,{jss:this,generateId:t.generateId||this.generateId,insertionPoint:this.options.insertionPoint,Renderer:this.options.Renderer,index:n}));return this.plugins.onProcessSheet(r),r},t.removeStyleSheet=function(e){return e.detach(),sheets.remove(e),this},t.createRule=function(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n={}),"object"==typeof e)return this.createRule(void 0,e,t);var r=_extends({},n,{name:e,jss:this,Renderer:this.options.Renderer});r.generateId||(r.generateId=this.generateId),r.classes||(r.classes={}),r.keyframes||(r.keyframes={});var i=createRule(e,t,r);return i&&this.plugins.onProcessRule(i),i},t.use=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.plugins.use(t)})),this},e}(),createJss=function(e){return new Jss(e)},index=createJss(),index$1=index,at$1="@global",atPrefix="@global ",GlobalContainerRule=function(){function e(e,t,n){for(var r in this.type="global",this.at=at$1,this.isProcessed=!1,this.key=e,this.options=n,this.rules=new RuleList(_extends({},n,{parent:this})),t)this.rules.add(r,t[r]);this.rules.process()}var t=e.prototype;return t.getRule=function(e){return this.rules.get(e)},t.addRule=function(e,t,n){var r=this.rules.add(e,t,n);return r&&this.options.jss.plugins.onProcessRule(r),r},t.replaceRule=function(e,t,n){var r=this.rules.replace(e,t,n);return r&&this.options.jss.plugins.onProcessRule(r),r},t.indexOf=function(e){return this.rules.indexOf(e)},t.toString=function(e){return this.rules.toString(e)},e}(),GlobalPrefixedRule=function(){function e(e,t,n){this.type="global",this.at=at$1,this.isProcessed=!1,this.key=e,this.options=n;var r=e.substr(atPrefix.length);this.rule=n.jss.createRule(r,t,_extends({},n,{parent:this}))}return e.prototype.toString=function(e){return this.rule?this.rule.toString(e):""},e}(),separatorRegExp=/\s*,\s*/g;function addScope(e,t){for(var n=e.split(separatorRegExp),r="",i=0;i<n.length;i++)r+=t+" "+n[i].trim(),n[i+1]&&(r+=", ");return r}function handleNestedGlobalContainerRule(e,t){var n=e.options,r=e.style,i=r?r[at$1]:null;if(i){for(var s in i)t.addRule(s,i[s],_extends({},n,{selector:addScope(s,e.selector)}));delete r[at$1]}}function handlePrefixedGlobalRule(e,t){var n=e.options,r=e.style;for(var i in r)if("@"===i[0]&&i.substr(0,at$1.length)===at$1){var s=addScope(i.substr(at$1.length),e.selector);t.addRule(s,r[i],_extends({},n,{selector:s})),delete r[i]}}function jssGlobal(){return{onCreateRule:function(e,t,n){if(!e)return null;if(e===at$1)return new GlobalContainerRule(e,t,n);if("@"===e[0]&&e.substr(0,atPrefix.length)===atPrefix)return new GlobalPrefixedRule(e,t,n);var r=n.parent;return r&&("global"===r.type||r.options.parent&&"global"===r.options.parent.type)&&(n.scoped=!1),n.selector||!1!==n.scoped||(n.selector=e),null},onProcessRule:function(e,t){"style"===e.type&&t&&(handleNestedGlobalContainerRule(e,t),handlePrefixedGlobalRule(e,t))}}}var uppercasePattern=/[A-Z]/g,msPattern=/^ms-/,cache={};function toHyphenLower(e){return"-"+e.toLowerCase()}function hyphenateStyleName(e){if(cache.hasOwnProperty(e))return cache[e];var t=e.replace(uppercasePattern,toHyphenLower);return cache[e]=msPattern.test(t)?"-"+t:t}function convertCase(e){var t={};for(var n in e)t[0===n.indexOf("--")?n:hyphenateStyleName(n)]=e[n];return e.fallbacks&&(Array.isArray(e.fallbacks)?t.fallbacks=e.fallbacks.map(convertCase):t.fallbacks=convertCase(e.fallbacks)),t}function camelCase(){return{onProcessStyle:function(e){if(Array.isArray(e)){for(var t=0;t<e.length;t++)e[t]=convertCase(e[t]);return e}return convertCase(e)},onChangeValue:function(e,t,n){if(0===t.indexOf("--"))return e;var r=hyphenateStyleName(t);return t===r?e:(n.prop(r,e),null)}}}var n={d:(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},o={};n.d(o,{ym:()=>b,EW:()=>h$1,Mx:()=>Q,L3:()=>H,rl:()=>m,NR:()=>u,f1:()=>v$1,IY:()=>E,RZ:()=>d,XY:()=>j,Fk:()=>g,Zh:()=>N,ek:()=>R,MG:()=>z$1,gE:()=>U,tW:()=>B,wr:()=>p});const l=(a={Flags:()=>Ot,Logger:()=>Vt,NumericParameters:()=>$t,OptionParameters:()=>qt,SettingFlag:()=>ts,TextParameters:()=>cs,WebXRController:()=>bs},r={},n.d(r,a),r);var a,r,c;class d{constructor(e,t,n){this.rootDiv=e,this.rootElement=t,this.textElement=n,this.rootElement.appendChild(this.textElement),this.hide(),this.rootDiv.appendChild(this.rootElement)}show(){this.rootElement.classList.remove("hiddenState")}hide(){this.rootElement.classList.add("hiddenState")}}class h$1 extends d{constructor(e,t,n){super(e,t,n),this.onActionCallback=()=>{l.Logger.Info(l.Logger.GetStackTrace(),"Did you forget to set the onAction callback in your overlay?")}}update(e){null==e&&null==e||(this.textElement.innerHTML=e)}onAction(e){this.onActionCallback=e}activate(){this.onActionCallback()}}class m extends h$1{static createRootElement(){const e=document.createElement("div");return e.id="connectOverlay",e.className="clickableState",e}static createContentElement(){const e=document.createElement("div");return e.id="connectButton",e.innerHTML="",e}constructor(e){super(e,m.createRootElement(),m.createContentElement()),this.rootElement.addEventListener("click",(()=>{this.rootElement.removeEventListener("click",(()=>{}),!1),document.getElementById("connectButton").style.visibility="hidden",document.getElementById("connectButton").setAttribute("disabled","disabled"),this.activate()}))}}class u extends h$1{static createRootElement(){const e=document.createElement("div");return e.id="disconnectOverlay",e.className="clickableState",e}static createContentElement(){const e=document.createElement("div");return e.id="disconnectButton",e.innerHTML="",e}constructor(e){super(e,u.createRootElement(),u.createContentElement()),this.rootElement.addEventListener("click",(()=>{document.getElementById("disconnectButton").style.visibility="hidden",document.getElementById("disconnectButton").setAttribute("disabled","disabled"),this.activate()}))}}class g extends h$1{static createRootElement(){const e=document.createElement("div");return e.id="playOverlay",e.className="clickableState",e}static createContentElement(){const e=document.createElement("img");return e.id="playButton",e.src="data:image/png;base64,",e.alt="Start Streaming",e}constructor(e){super(e,g.createRootElement(),g.createContentElement()),this.rootElement.addEventListener("click",(()=>{this.rootElement.removeEventListener("click",(()=>{}),!1),this.activate()}))}}class p extends d{constructor(e,t,n){super(e,t,n)}update(e){null==e&&null==e||(this.textElement.innerHTML=e)}}class E extends p{static createRootElement(){const e=document.createElement("div");return e.id="infoOverlay",e.className="textDisplayState",e}static createContentElement(){const e=document.createElement("div");return e.id="messageOverlayInner",e}constructor(e){super(e,E.createRootElement(),E.createContentElement())}}class v$1 extends p{static createRootElement(){const e=document.createElement("div");return e.id="errorOverlay",e.className="textDisplayState",e}static createContentElement(){const e=document.createElement("div");return e.id="errorOverlayInner",e}constructor(e){super(e,v$1.createRootElement(),v$1.createContentElement())}}class b extends h$1{static createRootElement(){const e=document.createElement("div");return e.id="afkOverlay",e.className="clickableState",e}static createContentElement(){const e=document.createElement("div");return e.id="afkOverlayInner",e.innerHTML='<center>No activity detected<br>Disconnecting in <span id="afkCountDownNumber"></span> seconds<br>Click to continue<br></center>',e}constructor(e){super(e,b.createRootElement(),b.createContentElement()),this.rootElement.addEventListener("click",(()=>{this.activate()}))}updateCountdown(e){this.textElement.innerHTML=`<center>No activity detected<br>Disconnecting in <span id="afkCountDownNumber">${e}</span> seconds<br>Click to continue<br></center>`}}class f{get rootElement(){return this._rootElement}set rootElement(e){e.onclick=()=>this.toggleFullscreen(),this._rootElement=e}constructor(){this.isFullscreen=!1,document.addEventListener("webkitfullscreenchange",(()=>this.onFullscreenChange()),!1),document.addEventListener("mozfullscreenchange",(()=>this.onFullscreenChange()),!1),document.addEventListener("fullscreenchange",(()=>this.onFullscreenChange()),!1),document.addEventListener("MSFullscreenChange",(()=>this.onFullscreenChange()),!1)}toggleFullscreen(){if(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen();else{const e=this.fullscreenElement;if(!e)return;e.requestFullscreen?e.requestFullscreen():e.mozRequestFullscreen?e.mozRequestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitEnterFullscreen&&e.webkitEnterFullscreen()}this.onFullscreenChange()}onFullscreenChange(){this.isFullscreen=document.webkitIsFullScreen||document.mozFullScreen||document.msFullscreenElement&&null!==document.msFullscreenElement||document.fullscreenElement&&null!==document.fullscreenElement}}class y extends f{constructor(e){super(),this.rootElement=e}}class x extends f{constructor(){super();const e=document.createElement("button");e.type="button",e.classList.add("UiTool"),e.id="fullscreen-btn",e.appendChild(this.maximizeIcon),e.appendChild(this.minimizeIcon),this.rootElement=e}get tooltipText(){return this._tooltipText||(this._tooltipText=document.createElement("span"),this._tooltipText.classList.add("tooltiptext"),this._tooltipText.innerHTML="Fullscreen"),this._tooltipText}get maximizeIcon(){if(!this._maximizeIcon){this._maximizeIcon=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._maximizeIcon.setAttributeNS(null,"id","maximizeIcon"),this._maximizeIcon.setAttributeNS(null,"x","0px"),this._maximizeIcon.setAttributeNS(null,"y","0px"),this._maximizeIcon.setAttributeNS(null,"viewBox","0 0 384.97 384.97");const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("svgIcon"),this._maximizeIcon.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d","M384.97,12.03c0-6.713-5.317-12.03-12.03-12.03H264.847c-6.833,0-11.922,5.39-11.934,12.223c0,6.821,5.101,11.838,11.934,11.838h96.062l-0.193,96.519c0,6.833,5.197,12.03,12.03,12.03c6.833-0.012,12.03-5.197,12.03-12.03l0.193-108.369c0-0.036-0.012-0.06-0.012-0.084C384.958,12.09,384.97,12.066,384.97,12.03z");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttributeNS(null,"d","M120.496,0H12.403c-0.036,0-0.06,0.012-0.096,0.012C12.283,0.012,12.247,0,12.223,0C5.51,0,0.192,5.317,0.192,12.03L0,120.399c0,6.833,5.39,11.934,12.223,11.934c6.821,0,11.838-5.101,11.838-11.934l0.192-96.339h96.242c6.833,0,12.03-5.197,12.03-12.03C132.514,5.197,127.317,0,120.496,0z");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttributeNS(null,"d","M120.123,360.909H24.061v-96.242c0-6.833-5.197-12.03-12.03-12.03S0,257.833,0,264.667v108.092c0,0.036,0.012,0.06,0.012,0.084c0,0.036-0.012,0.06-0.012,0.096c0,6.713,5.317,12.03,12.03,12.03h108.092c6.833,0,11.922-5.39,11.934-12.223C132.057,365.926,126.956,360.909,120.123,360.909z");const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttributeNS(null,"d","M372.747,252.913c-6.833,0-11.85,5.101-11.838,11.934v96.062h-96.242c-6.833,0-12.03,5.197-12.03,12.03s5.197,12.03,12.03,12.03h108.092c0.036,0,0.06-0.012,0.084-0.012c0.036-0.012,0.06,0.012,0.096,0.012c6.713,0,12.03-5.317,12.03-12.03V264.847C384.97,258.014,379.58,252.913,372.747,252.913z"),e.appendChild(t),e.appendChild(n),e.appendChild(r),e.appendChild(i)}return this._maximizeIcon}get minimizeIcon(){if(!this._minimizeIcon){this._minimizeIcon=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._minimizeIcon.setAttributeNS(null,"id","minimizeIcon"),this._minimizeIcon.setAttributeNS(null,"x","0px"),this._minimizeIcon.setAttributeNS(null,"y","0px"),this._minimizeIcon.setAttributeNS(null,"viewBox","0 0 385.331 385.331");const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("svgIcon"),this._minimizeIcon.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d","M264.943,156.665h108.273c6.833,0,11.934-5.39,11.934-12.211c0-6.833-5.101-11.85-11.934-11.838h-96.242V36.181c0-6.833-5.197-12.03-12.03-12.03s-12.03,5.197-12.03,12.03v108.273c0,0.036,0.012,0.06,0.012,0.084c0,0.036-0.012,0.06-0.012,0.096C252.913,151.347,258.23,156.677,264.943,156.665z");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttributeNS(null,"d","M120.291,24.247c-6.821,0-11.838,5.113-11.838,11.934v96.242H12.03c-6.833,0-12.03,5.197-12.03,12.03c0,6.833,5.197,12.03,12.03,12.03h108.273c0.036,0,0.06-0.012,0.084-0.012c0.036,0,0.06,0.012,0.096,0.012c6.713,0,12.03-5.317,12.03-12.03V36.181C132.514,29.36,127.124,24.259,120.291,24.247z");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttributeNS(null,"d","M120.387,228.666H12.115c-6.833,0.012-11.934,5.39-11.934,12.223c0,6.833,5.101,11.85,11.934,11.838h96.242v96.423c0,6.833,5.197,12.03,12.03,12.03c6.833,0,12.03-5.197,12.03-12.03V240.877c0-0.036-0.012-0.06-0.012-0.084c0-0.036,0.012-0.06,0.012-0.096C132.418,233.983,127.1,228.666,120.387,228.666z");const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttributeNS(null,"d","M373.3,228.666H265.028c-0.036,0-0.06,0.012-0.084,0.012c-0.036,0-0.06-0.012-0.096-0.012c-6.713,0-12.03,5.317-12.03,12.03v108.273c0,6.833,5.39,11.922,12.223,11.934c6.821,0.012,11.838-5.101,11.838-11.922v-96.242H373.3c6.833,0,12.03-5.197,12.03-12.03S380.134,228.678,373.3,228.666z"),e.appendChild(t),e.appendChild(n),e.appendChild(r),e.appendChild(i)}return this._minimizeIcon}onFullscreenChange(){super.onFullscreenChange();const e=this.minimizeIcon,t=this.maximizeIcon;this.isFullscreen?(e.style.display="inline",e.style.transform="translate(0, 0)",t.style.display="none"):(e.style.display="none",t.style.display="inline",t.style.transform="translate(0, 0)")}}class C{get rootElement(){return this._rootElement||(this._rootElement=document.createElement("button"),this._rootElement.type="button",this._rootElement.classList.add("UiTool"),this._rootElement.id="settingsBtn",this._rootElement.appendChild(this.settingsIcon)),this._rootElement}get tooltipText(){return this._tooltipText||(this._tooltipText=document.createElement("span"),this._tooltipText.classList.add("tooltiptext"),this._tooltipText.innerHTML="Settings"),this._tooltipText}get settingsIcon(){if(!this._settingsIcon){this._settingsIcon=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._settingsIcon.setAttributeNS(null,"id","settingsIcon"),this._settingsIcon.setAttributeNS(null,"x","0px"),this._settingsIcon.setAttributeNS(null,"y","0px"),this._settingsIcon.setAttributeNS(null,"viewBox","0 0 478.703 478.703");const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("svgIcon"),this._settingsIcon.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d","M454.2,189.101l-33.6-5.7c-3.5-11.3-8-22.2-13.5-32.6l19.8-27.7c8.4-11.8,7.1-27.9-3.2-38.1l-29.8-29.8\t\t\tc-5.6-5.6-13-8.7-20.9-8.7c-6.2,0-12.1,1.9-17.1,5.5l-27.8,19.8c-10.8-5.7-22.1-10.4-33.8-13.9l-5.6-33.2\t\t\tc-2.4-14.3-14.7-24.7-29.2-24.7h-42.1c-14.5,0-26.8,10.4-29.2,24.7l-5.8,34c-11.2,3.5-22.1,8.1-32.5,13.7l-27.5-19.8\t\t\tc-5-3.6-11-5.5-17.2-5.5c-7.9,0-15.4,3.1-20.9,8.7l-29.9,29.8c-10.2,10.2-11.6,26.3-3.2,38.1l20,28.1\t\t\tc-5.5,10.5-9.9,21.4-13.3,32.7l-33.2,5.6c-14.3,2.4-24.7,14.7-24.7,29.2v42.1c0,14.5,10.4,26.8,24.7,29.2l34,5.8\t\t\tc3.5,11.2,8.1,22.1,13.7,32.5l-19.7,27.4c-8.4,11.8-7.1,27.9,3.2,38.1l29.8,29.8c5.6,5.6,13,8.7,20.9,8.7c6.2,0,12.1-1.9,17.1-5.5\t\t\tl28.1-20c10.1,5.3,20.7,9.6,31.6,13l5.6,33.6c2.4,14.3,14.7,24.7,29.2,24.7h42.2c14.5,0,26.8-10.4,29.2-24.7l5.7-33.6\t\t\tc11.3-3.5,22.2-8,32.6-13.5l27.7,19.8c5,3.6,11,5.5,17.2,5.5l0,0c7.9,0,15.3-3.1,20.9-8.7l29.8-29.8c10.2-10.2,11.6-26.3,3.2-38.1\t\t\tl-19.8-27.8c5.5-10.5,10.1-21.4,13.5-32.6l33.6-5.6c14.3-2.4,24.7-14.7,24.7-29.2v-42.1\t\t\tC478.9,203.801,468.5,191.501,454.2,189.101z M451.9,260.401c0,1.3-0.9,2.4-2.2,2.6l-42,7c-5.3,0.9-9.5,4.8-10.8,9.9\t\t\tc-3.8,14.7-9.6,28.8-17.4,41.9c-2.7,4.6-2.5,10.3,0.6,14.7l24.7,34.8c0.7,1,0.6,2.5-0.3,3.4l-29.8,29.8c-0.7,0.7-1.4,0.8-1.9,0.8\t\t\tc-0.6,0-1.1-0.2-1.5-0.5l-34.7-24.7c-4.3-3.1-10.1-3.3-14.7-0.6c-13.1,7.8-27.2,13.6-41.9,17.4c-5.2,1.3-9.1,5.6-9.9,10.8l-7.1,42\t\t\tc-0.2,1.3-1.3,2.2-2.6,2.2h-42.1c-1.3,0-2.4-0.9-2.6-2.2l-7-42c-0.9-5.3-4.8-9.5-9.9-10.8c-14.3-3.7-28.1-9.4-41-16.8\t\t\tc-2.1-1.2-4.5-1.8-6.8-1.8c-2.7,0-5.5,0.8-7.8,2.5l-35,24.9c-0.5,0.3-1,0.5-1.5,0.5c-0.4,0-1.2-0.1-1.9-0.8l-29.8-29.8\t\t\tc-0.9-0.9-1-2.3-0.3-3.4l24.6-34.5c3.1-4.4,3.3-10.2,0.6-14.8c-7.8-13-13.8-27.1-17.6-41.8c-1.4-5.1-5.6-9-10.8-9.9l-42.3-7.2\t\t\tc-1.3-0.2-2.2-1.3-2.2-2.6v-42.1c0-1.3,0.9-2.4,2.2-2.6l41.7-7c5.3-0.9,9.6-4.8,10.9-10c3.7-14.7,9.4-28.9,17.1-42\t\t\tc2.7-4.6,2.4-10.3-0.7-14.6l-24.9-35c-0.7-1-0.6-2.5,0.3-3.4l29.8-29.8c0.7-0.7,1.4-0.8,1.9-0.8c0.6,0,1.1,0.2,1.5,0.5l34.5,24.6\t\t\tc4.4,3.1,10.2,3.3,14.8,0.6c13-7.8,27.1-13.8,41.8-17.6c5.1-1.4,9-5.6,9.9-10.8l7.2-42.3c0.2-1.3,1.3-2.2,2.6-2.2h42.1\t\t\tc1.3,0,2.4,0.9,2.6,2.2l7,41.7c0.9,5.3,4.8,9.6,10,10.9c15.1,3.8,29.5,9.7,42.9,17.6c4.6,2.7,10.3,2.5,14.7-0.6l34.5-24.8\t\t\tc0.5-0.3,1-0.5,1.5-0.5c0.4,0,1.2,0.1,1.9,0.8l29.8,29.8c0.9,0.9,1,2.3,0.3,3.4l-24.7,34.7c-3.1,4.3-3.3,10.1-0.6,14.7\t\t\tc7.8,13.1,13.6,27.2,17.4,41.9c1.3,5.2,5.6,9.1,10.8,9.9l42,7.1c1.3,0.2,2.2,1.3,2.2,2.6v42.1H451.9z");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttributeNS(null,"d","M239.4,136.001c-57,0-103.3,46.3-103.3,103.3s46.3,103.3,103.3,103.3s103.3-46.3,103.3-103.3S296.4,136.001,239.4,136.001z M239.4,315.601c-42.1,0-76.3-34.2-76.3-76.3s34.2-76.3,76.3-76.3s76.3,34.2,76.3,76.3S281.5,315.601,239.4,315.601z"),e.appendChild(t),e.appendChild(n)}return this._settingsIcon}}class S{get rootElement(){return this._rootElement||(this._rootElement=document.createElement("button"),this._rootElement.type="button",this._rootElement.classList.add("UiTool"),this._rootElement.id="statsBtn",this._rootElement.appendChild(this.statsIcon)),this._rootElement}get tooltipText(){return this._tooltipText||(this._tooltipText=document.createElement("span"),this._tooltipText.classList.add("tooltiptext"),this._tooltipText.innerHTML="Information"),this._tooltipText}get statsIcon(){if(!this._statsIcon){this._statsIcon=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._statsIcon.setAttributeNS(null,"id","statsIcon"),this._statsIcon.setAttributeNS(null,"x","0px"),this._statsIcon.setAttributeNS(null,"y","0px"),this._statsIcon.setAttributeNS(null,"viewBox","0 0 330 330");const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("svgIcon"),this._statsIcon.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d","M165,0.008C74.019,0.008,0,74.024,0,164.999c0,90.977,74.019,164.992,165,164.992s165-74.015,165-164.992C330,74.024,255.981,0.008,165,0.008z M165,299.992c-74.439,0-135-60.557-135-134.992S90.561,30.008,165,30.008s135,60.557,135,134.991C300,239.436,239.439,299.992,165,299.992z");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttributeNS(null,"d","M165,130.008c-8.284,0-15,6.716-15,15v99.983c0,8.284,6.716,15,15,15s15-6.716,15-15v-99.983C180,136.725,173.284,130.008,165,130.008z");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttributeNS(null,"d","M165,70.011c-3.95,0-7.811,1.6-10.61,4.39c-2.79,2.79-4.39,6.66-4.39,10.61s1.6,7.81,4.39,10.61c2.79,2.79,6.66,4.39,10.61,4.39s7.81-1.6,10.609-4.39c2.79-2.8,4.391-6.66,4.391-10.61s-1.601-7.82-4.391-10.61C172.81,71.61,168.95,70.011,165,70.011z"),e.appendChild(t),e.appendChild(n),e.appendChild(r)}return this._statsIcon}}class w$1{get rootElement(){return this._rootElement||(this._rootElement=document.createElement("button"),this._rootElement.type="button",this._rootElement.classList.add("UiTool"),this._rootElement.id="xrBtn",this._rootElement.appendChild(this.xrIcon)),this._rootElement}get tooltipText(){return this._tooltipText||(this._tooltipText=document.createElement("span"),this._tooltipText.classList.add("tooltiptext"),this._tooltipText.innerHTML="XR"),this._tooltipText}get xrIcon(){if(!this._xrIcon){this._xrIcon=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._xrIcon.setAttributeNS(null,"id","xrIcon"),this._xrIcon.setAttributeNS(null,"x","0px"),this._xrIcon.setAttributeNS(null,"y","0px"),this._xrIcon.setAttributeNS(null,"viewBox","0 0 100 100");const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("svgIcon"),this._xrIcon.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d","M29 41c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 14c-2.8 0-5-2.2-5-5s2.2-5 5-5 5 2.2 5 5-2.2 5-5 5zm42-14c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 14c-2.8 0-5-2.2-5-5s2.2-5 5-5 5 2.2 5 5-2.2 5-5 5zm12-31H17c-6.6 0-12 5.4-12 12v28c0 6.6 5.4 12 12 12h14.5c3.5 0 6.8-1.5 9-4.1l3.5-4c1.5-1.7 3.7-2.7 6-2.7s4.5 1 6 2.7l3.5 4c2.3 2.6 5.6 4.1 9 4.1H83c6.6 0 12-5.4 12-12V36c0-6.6-5.4-12-12-12zm8 40c0 4.4-3.6 8-8 8H68.5c-2.3 0-4.5-1-6-2.7l-3.5-4c-2.3-2.6-5.6-4.1-9-4.1-3.5 0-6.8 1.5-9 4.1l-3.5 4C36 71 33.8 72 31.5 72H17c-4.4 0-8-3.6-8-8V36c0-4.4 3.6-8 8-8h66c4.4 0 8 3.6 8 8v28z"),e.appendChild(t)}return this._xrIcon}}function T(e){return!e||!!e&&e.isEnabled}function _(e){return null==e||e.creationMode===c.CreateDefaultElement}!function(e){e[e.CreateDefaultElement=0]="CreateDefaultElement",e[e.UseCustomElement=1]="UseCustomElement",e[e.Disable=2]="Disable"}(c||(c={}));class L{constructor(e){e&&!_(e.statsButtonType)||(this.statsIcon=new S),e&&!_(e.fullscreenButtonType)||(this.settingsIcon=new C),e&&!_(e.settingsButtonType)||(this.fullscreenIcon=new x),e&&!_(e.xrIconType)||(this.xrIcon=new w$1)}get rootElement(){return this._rootElement||(this._rootElement=document.createElement("div"),this._rootElement.id="controls",this.fullscreenIcon&&this._rootElement.appendChild(this.fullscreenIcon.rootElement),this.settingsIcon&&this._rootElement.appendChild(this.settingsIcon.rootElement),this.statsIcon&&this._rootElement.appendChild(this.statsIcon.rootElement),this.xrIcon),this._rootElement}}class I{constructor(e,t){this._label=e,this._buttonText=t}addOnClickListener(e){this.button.addEventListener("click",e)}get button(){return this._button||(this._button=document.createElement("input"),this._button.type="button",this._button.value=this._buttonText,this._button.classList.add("overlay-button"),this._button.classList.add("btn-flat")),this._button}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.classList.add("setting");const e=document.createElement("div");e.innerText=this._label,this._rootElement.appendChild(e);const t=document.createElement("label");t.classList.add("btn-overlay"),this._rootElement.appendChild(t),t.appendChild(this.button)}return this._rootElement}}class k{constructor(){this._rootElement=null}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.id="settings-panel",this._rootElement.classList.add("panel-wrap");const e=document.createElement("div");e.classList.add("panel"),this._rootElement.appendChild(e);const t=document.createElement("div");t.id="settingsHeading",t.textContent="Settings",e.appendChild(t),e.appendChild(this.settingsCloseButton),e.appendChild(this.settingsContentElement)}return this._rootElement}get settingsContentElement(){return this._settingsContentElement||(this._settingsContentElement=document.createElement("div"),this._settingsContentElement.id="settingsContent"),this._settingsContentElement}get settingsCloseButton(){return this._settingsCloseButton||(this._settingsCloseButton=document.createElement("div"),this._settingsCloseButton.id="settingsClose"),this._settingsCloseButton}show(){this.rootElement.classList.contains("panel-wrap-visible")||this.rootElement.classList.add("panel-wrap-visible")}toggleVisibility(){this.rootElement.classList.toggle("panel-wrap-visible")}hide(){this.rootElement.classList.contains("panel-wrap-visible")&&this.rootElement.classList.remove("panel-wrap-visible")}}class F{get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("section"),this._rootElement.classList.add("settingsContainer");const e=document.createElement("div");e.id="latencyTestHeader",e.classList.add("settings-text"),e.classList.add("settingsHeader"),this._rootElement.appendChild(e);const t=document.createElement("div");t.innerHTML="Latency Test",e.appendChild(t),e.appendChild(this.latencyTestButton);const n=document.createElement("div");n.id="latencyTestContainer",n.classList.add("d-none"),this._rootElement.appendChild(n),n.appendChild(this.latencyTestResultsElement)}return this._rootElement}get latencyTestResultsElement(){return this._latencyTestResultsElement||(this._latencyTestResultsElement=document.createElement("div"),this._latencyTestResultsElement.id="latencyStatsResults",this._latencyTestResultsElement.classList.add("StatsResult")),this._latencyTestResultsElement}get latencyTestButton(){return this._latencyTestButton||(this._latencyTestButton=document.createElement("input"),this._latencyTestButton.type="button",this._latencyTestButton.value="Run Test",this._latencyTestButton.id="btn-start-latency-test",this._latencyTestButton.classList.add("streamTools-button"),this._latencyTestButton.classList.add("btn-flat")),this._latencyTestButton}handleTestResult(e){l.Logger.Log(l.Logger.GetStackTrace(),e.toString(),6);let t="";t+="<div>Net latency RTT (ms): "+e.networkLatency+"</div>",t+="<div>UE Encode (ms): "+e.EncodeMs+"</div>",t+="<div>UE Capture (ms): "+e.CaptureToSendMs+"</div>",t+="<div>Browser send latency (ms): "+e.browserSendLatency+"</div>",t+=e.frameDisplayDeltaTimeMs&&e.browserReceiptTimeMs?"<div>Browser receive latency (ms): "+e.frameDisplayDeltaTimeMs+"</div>":"",t+="<div>Total latency (excluding browser) (ms): "+e.latencyExcludingDecode+"</div>",t+=e.endToEndLatency?"<div>Total latency (ms): "+e.endToEndLatency+"</div>":"",this.latencyTestResultsElement.innerHTML=t}}class P{static formatBytes(e,t){if(0===e)return"0";const n=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,r)).toFixed(n))+" "+["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"][r]}}class A{}class O{constructor(){this.statsMap=new Map,this.latencyTest=new F}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.id="stats-panel",this._rootElement.classList.add("panel-wrap");const e=document.createElement("div");e.classList.add("panel"),this._rootElement.appendChild(e);const t=document.createElement("div");t.id="statsHeading",t.textContent="Information",e.appendChild(t),e.appendChild(this.statsCloseButton),e.appendChild(this.statsContentElement)}return this._rootElement}get statsContentElement(){if(!this._statsContentElement){this._statsContentElement=document.createElement("div"),this._statsContentElement.id="statsContent";const e=document.createElement("div");e.id="streamToolsStats",e.classList.add("container");const t=document.createElement("div");t.id="ControlStats",t.classList.add("row");const n=document.createElement("section");n.id="statistics",n.classList.add("settingsContainer");const r=document.createElement("div");r.id="statisticsHeader",r.classList.add("settings-text"),r.classList.add("settingsHeader");const i=document.createElement("div");i.innerHTML="Session Stats",this._statsContentElement.appendChild(e),e.appendChild(t),t.appendChild(n),n.appendChild(r),r.appendChild(i),n.appendChild(this.statisticsContainer),t.appendChild(this.latencyTest.rootElement)}return this._statsContentElement}get statisticsContainer(){return this._statisticsContainer||(this._statisticsContainer=document.createElement("div"),this._statisticsContainer.id="statisticsContainer",this._statisticsContainer.classList.add("d-none"),this._statisticsContainer.appendChild(this.statsResult)),this._statisticsContainer}get statsResult(){return this._statsResult||(this._statsResult=document.createElement("div"),this._statsResult.id="statisticsResult",this._statsResult.classList.add("StatsResult")),this._statsResult}get statsCloseButton(){return this._statsCloseButton||(this._statsCloseButton=document.createElement("div"),this._statsCloseButton.id="statsClose"),this._statsCloseButton}show(){this.rootElement.classList.contains("panel-wrap-visible")||this.rootElement.classList.add("panel-wrap-visible")}toggleVisibility(){this.rootElement.classList.toggle("panel-wrap-visible")}hide(){this.rootElement.classList.contains("panel-wrap-visible")&&this.rootElement.classList.remove("panel-wrap-visible")}handleStats(e){var t,n,r,i,s;const o=new Intl.NumberFormat(window.navigator.language,{maximumFractionDigits:0}),a=P.formatBytes(e.inboundVideoStats.bytesReceived,2);this.addOrUpdateStat("InboundDataStat","Received",a);const c=Object.prototype.hasOwnProperty.call(e.inboundVideoStats,"packetsLost")?o.format(e.inboundVideoStats.packetsLost):"Chrome only";this.addOrUpdateStat("PacketsLostStat","Packets Lost",c),e.inboundVideoStats.bitrate&&this.addOrUpdateStat("VideoBitrateStat","Video Bitrate (kbps)",e.inboundVideoStats.bitrate.toString()),e.inboundAudioStats.bitrate&&this.addOrUpdateStat("AudioBitrateStat","Audio Bitrate (kbps)",e.inboundAudioStats.bitrate.toString());const d=Object.prototype.hasOwnProperty.call(e.inboundVideoStats,"frameWidth")&&e.inboundVideoStats.frameWidth&&Object.prototype.hasOwnProperty.call(e.inboundVideoStats,"frameHeight")&&e.inboundVideoStats.frameHeight?e.inboundVideoStats.frameWidth+"x"+e.inboundVideoStats.frameHeight:"Chrome only";this.addOrUpdateStat("VideoResStat","Video resolution",d);const u=Object.prototype.hasOwnProperty.call(e.inboundVideoStats,"framesDecoded")?o.format(e.inboundVideoStats.framesDecoded):"Chrome only";this.addOrUpdateStat("FramesDecodedStat","Frames Decoded",u),e.inboundVideoStats.framesPerSecond&&this.addOrUpdateStat("FramerateStat","Framerate",e.inboundVideoStats.framesPerSecond.toString()),this.addOrUpdateStat("FramesDroppedStat","Frames dropped",null===(t=e.inboundVideoStats.framesDropped)||void 0===t?void 0:t.toString()),e.inboundVideoStats.codecId&&this.addOrUpdateStat("VideoCodecStat","Video codec",null!==(r=null===(n=e.codecs.get(e.inboundVideoStats.codecId))||void 0===n?void 0:n.split(" ")[0])&&void 0!==r?r:""),e.inboundAudioStats.codecId&&this.addOrUpdateStat("AudioCodecStat","Audio codec",null!==(s=null===(i=e.codecs.get(e.inboundAudioStats.codecId))||void 0===i?void 0:i.split(" ")[0])&&void 0!==s?s:"");const h=Object.prototype.hasOwnProperty.call(e.candidatePair,"currentRoundTripTime")&&e.isNumber(e.candidatePair.currentRoundTripTime)?o.format(1e3*e.candidatePair.currentRoundTripTime):"Can't calculate";this.addOrUpdateStat("RTTStat","Net RTT (ms)",h),this.addOrUpdateStat("DurationStat","Duration",e.sessionStats.runTime),this.addOrUpdateStat("ControlsInputStat","Controls stream input",e.sessionStats.controlsStreamInput),this.addOrUpdateStat("QPStat","Video quantization parameter",e.sessionStats.videoEncoderAvgQP.toString()),l.Logger.Log(l.Logger.GetStackTrace(),`--------- Stats ---------\n ${e}\n------------------------`,6)}addOrUpdateStat(e,t,n){const r=`${t}: ${n}`;if(this.statsMap.has(e)){const t=this.statsMap.get(e);void 0!==t&&(t.element.innerHTML=r)}else{const i=new A;i.id=e,i.stat=n,i.title=t,i.element=document.createElement("div"),i.element.innerHTML=r,this.statsResult.appendChild(i.element),this.statsMap.set(e,i)}}}class M{constructor(){this.videoEncoderAvgQP=-1,this.statsText="",this.color="",this.orangeQP=26,this.redQP=35}get rootElement(){return this._rootElement||(this._rootElement=document.createElement("div"),this._rootElement.id="connection",this._rootElement.classList.add("UiTool"),this._rootElement.appendChild(this.qualityStatus),this._rootElement.appendChild(this.qualityText),this.updateQpTooltip(-1)),this._rootElement}get qualityText(){return this._qualityText||(this._qualityText=document.createElement("span"),this._qualityText.id="qualityText",this._qualityText.classList.add("tooltiptext")),this._qualityText}get qualityStatus(){return this._qualityStatus||(this._qualityStatus=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._qualityStatus.setAttributeNS(null,"id","connectionStrength"),this._qualityStatus.setAttributeNS(null,"x","0px"),this._qualityStatus.setAttributeNS(null,"y","0px"),this._qualityStatus.setAttributeNS(null,"viewBox","0 0 494.45 494.45"),this.qualityStatus.appendChild(this.dot),this.qualityStatus.appendChild(this.middle),this.qualityStatus.appendChild(this.outer),this.qualityStatus.appendChild(this.inner)),this._qualityStatus}get dot(){return this._dot||(this._dot=document.createElementNS("http://www.w3.org/2000/svg","circle"),this._dot.setAttributeNS(null,"id","dot"),this._dot.setAttributeNS(null,"cx","247.125"),this._dot.setAttributeNS(null,"cy","398.925"),this._dot.setAttributeNS(null,"r","35.3")),this._dot}get outer(){return this._outer||(this._outer=document.createElementNS("http://www.w3.org/2000/svg","path"),this._outer.setAttributeNS(null,"id","outer"),this._outer.setAttributeNS(null,"d","M467.925,204.625c-6.8,0-13.5-2.6-18.7-7.8c-111.5-111.4-292.7-111.4-404.1,0c-10.3,10.3-27.1,10.3-37.4,0s-10.3-27.1,0-37.4c64-64,149-99.2,239.5-99.2s175.5,35.2,239.5,99.2c10.3,10.3,10.3,27.1,0,37.4C481.425,202.025,474.625,204.625,467.925,204.625z")),this._outer}get middle(){return this._middle||(this._middle=document.createElementNS("http://www.w3.org/2000/svg","path"),this._middle.setAttributeNS(null,"id","middle"),this._middle.setAttributeNS(null,"d","M395.225,277.325c-6.8,0-13.5-2.6-18.7-7.8c-71.4-71.3-187.4-71.3-258.8,0c-10.3,10.3-27.1,10.3-37.4,0s-10.3-27.1,0-37.4c92-92,241.6-92,333.6,0c10.3,10.3,10.3,27.1,0,37.4C408.725,274.725,401.925,277.325,395.225,277.325z")),this._middle}get inner(){return this._inner||(this._inner=document.createElementNS("http://www.w3.org/2000/svg","path"),this._inner.setAttributeNS(null,"id","inner"),this._inner.setAttributeNS(null,"d","M323.625,348.825c-6.8,0-13.5-2.6-18.7-7.8c-15.4-15.4-36-23.9-57.8-23.9s-42.4,8.5-57.8,23.9c-10.3,10.3-27.1,10.3-37.4,0c-10.3-10.3-10.3-27.1,0-37.4c25.4-25.4,59.2-39.4,95.2-39.4s69.8,14,95.2,39.5c10.3,10.3,10.3,27.1,0,37.4C337.225,346.225,330.425,348.825,323.625,348.825z")),this._inner}blinkVideoQualityStatus(e){let t=e,n=1;const r=setInterval((()=>{n-=.1,this.qualityText.style.opacity=String(Math.abs(2*(n-.5))),n<=.1&&(0==--t?clearInterval(r):n=1)}),100/e)}updateQpTooltip(e){this.videoEncoderAvgQP=e,e>this.redQP?(this.color="red",this.blinkVideoQualityStatus(2),this.statsText=`<div style="color: ${this.color}">Poor encoding quality</div>`,this.outer.setAttributeNS(null,"fill","#3c3b40"),this.middle.setAttributeNS(null,"fill","#3c3b40"),this.inner.setAttributeNS(null,"fill",this.color),this.dot.setAttributeNS(null,"fill",this.color)):e>this.orangeQP?(this.color="orange",this.blinkVideoQualityStatus(1),this.statsText=`<div style="color: ${this.color}">Blocky encoding quality</div>`,this.outer.setAttributeNS(null,"fill","#3c3b40"),this.middle.setAttributeNS(null,"fill",this.color),this.inner.setAttributeNS(null,"fill",this.color),this.dot.setAttributeNS(null,"fill",this.color)):e<=0?(this.color="#b0b0b0",this.outer.setAttributeNS(null,"fill","#3c3b40"),this.middle.setAttributeNS(null,"fill","#3c3b40"),this.inner.setAttributeNS(null,"fill","#3c3b40"),this.dot.setAttributeNS(null,"fill","#3c3b40"),this.statsText=`<div style="color: ${this.color}">Not connected</div>`):(this.color="lime",this.qualityStatus.style.opacity="1",this.statsText=`<div style="color: ${this.color}">Clear encoding quality</div>`,this.outer.setAttributeNS(null,"fill",this.color),this.middle.setAttributeNS(null,"fill",this.color),this.inner.setAttributeNS(null,"fill",this.color),this.dot.setAttributeNS(null,"fill",this.color)),this.qualityText.innerHTML=this.statsText}}class N{constructor(e){this._setting=e}get setting(){return this._setting}get rootElement(){return this._rootElement||(this._rootElement=document.createElement("div")),this._rootElement}}class R extends N{constructor(e){super(e),this.label=e.label,this.flag=e.flag}get setting(){return this._setting}get settingsTextElem(){return this._settingsTextElem||(this._settingsTextElem=document.createElement("div"),this._settingsTextElem.innerText=this.setting._label,this._settingsTextElem.title=this.setting.description),this._settingsTextElem}get checkbox(){return this._checkbox||(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox"),this._checkbox}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.id=this.setting.id,this._rootElement.classList.add("setting"),this._rootElement.appendChild(this.settingsTextElem);const e=document.createElement("label");e.classList.add("tgl-switch"),this._rootElement.appendChild(e),this.checkbox.title=this.setting.description,this.checkbox.classList.add("tgl"),this.checkbox.classList.add("tgl-flat");const t=document.createElement("div");t.classList.add("tgl-slider"),e.appendChild(this.checkbox),e.appendChild(t),this.checkbox.addEventListener("change",(()=>{this.setting.flag!==this.checkbox.checked&&(this.setting.flag=this.checkbox.checked,this.setting.updateURLParams())}))}return this._rootElement}set flag(e){this.checkbox.checked=e}get flag(){return this.checkbox.checked}set label(e){this.settingsTextElem.innerText=e}get label(){return this.settingsTextElem.innerText}}class z$1 extends N{constructor(e){super(e),this.label=this.setting.label,this.number=this.setting.number}get setting(){return this._setting}get settingsTextElem(){return this._settingsTextElem||(this._settingsTextElem=document.createElement("label"),this._settingsTextElem.innerText=this.setting.label,this._settingsTextElem.title=this.setting.description),this._settingsTextElem}get spinner(){return this._spinner||(this._spinner=document.createElement("input"),this._spinner.type="number",this._spinner.min=this.setting.min.toString(),this._spinner.max=this.setting.max.toString(),this._spinner.value=this.setting.number.toString(),this._spinner.title=this.setting.description,this._spinner.classList.add("form-control")),this._spinner}get rootElement(){return this._rootElement||(this._rootElement=document.createElement("div"),this._rootElement.classList.add("setting"),this._rootElement.classList.add("form-group"),this._rootElement.appendChild(this.settingsTextElem),this._rootElement.appendChild(this.spinner),this.spinner.onchange=e=>{const t=e.target,n=Number.parseInt(t.value);Number.isNaN(n)?(l.Logger.Warning(l.Logger.GetStackTrace(),`Could not parse value change into a valid number - value was ${t.value}, resetting value to ${this.setting.min}`),this.setting.number!==this.setting.min&&(this.setting.number=this.setting.min)):this.setting.number!==n&&(this.setting.number=n,this.setting.updateURLParams())}),this._rootElement}set number(e){this.spinner.value=this.setting.clamp(e).toString()}get number(){return+this.spinner.value}set label(e){this.settingsTextElem.innerText=e}get label(){return this.settingsTextElem.innerText}}class B extends N{constructor(e){super(e),this.label=this.setting.label,this.text=this.setting.text}get setting(){return this._setting}get settingsTextElem(){return this._settingsTextElem||(this._settingsTextElem=document.createElement("div"),this._settingsTextElem.innerText=this.setting.label,this._settingsTextElem.title=this.setting.description),this._settingsTextElem}get textbox(){return this._textbox||(this._textbox=document.createElement("input"),this._textbox.classList.add("form-control"),this._textbox.type="textbox"),this._textbox}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.id=this.setting.id,this._rootElement.classList.add("setting"),this._rootElement.appendChild(this.settingsTextElem);const e=document.createElement("label");this._rootElement.appendChild(e),this.textbox.title=this.setting.description,e.appendChild(this.textbox),this.textbox.addEventListener("input",(()=>{this.setting.text!==this.textbox.value&&(this.setting.text=this.textbox.value,this.setting.updateURLParams())}))}return this._rootElement}set text(e){this.textbox.value=e}get text(){return this.textbox.value}set label(e){this.settingsTextElem.innerText=e}get label(){return this.settingsTextElem.innerText}}class U extends N{constructor(e){super(e),this.label=this.setting.label,this.options=this.setting.options,this.selected=this.setting.selected}get setting(){return this._setting}get selector(){return this._selector||(this._selector=document.createElement("select"),this._selector.classList.add("form-control"),this._selector.classList.add("settings-option")),this._selector}get settingsTextElem(){return this._settingsTextElem||(this._settingsTextElem=document.createElement("div"),this._settingsTextElem.innerText=this.setting.label,this._settingsTextElem.title=this.setting.description),this._settingsTextElem}set label(e){this.settingsTextElem.innerText=e}get label(){return this.settingsTextElem.innerText}get rootElement(){if(!this._rootElement){this._rootElement=document.createElement("div"),this._rootElement.id=this.setting.id,this._rootElement.classList.add("setting"),this._rootElement.classList.add("form-group"),this._rootElement.appendChild(this.settingsTextElem);const e=document.createElement("label");this._rootElement.appendChild(e),this.selector.title=this.setting.description,e.appendChild(this.selector),this.selector.onchange=()=>{this.setting.selected!==this.selector.value&&(this.setting.selected=this.selector.value,this.setting.updateURLParams())}}return this._rootElement}set options(e){for(let e=this.selector.options.length-1;e>=0;e--)this.selector.remove(e);e.forEach((e=>{const t=document.createElement("option");t.value=e,t.innerHTML=e,this.selector.appendChild(t)}))}get options(){return[...this.selector.options].map((e=>e.value))}set selected(e){const t=this.options.filter((t=>-1!==t.indexOf(e)));t.length&&(this.selector.value=t[0])}get selected(){return this.selector.value}disable(){this.selector.disabled=!0}enable(){this.selector.disabled=!1}}const D="LightMode";class H{constructor(e){this.customFlags=new Map,this.flagsUi=new Map,this.numericParametersUi=new Map,this.textParametersUi=new Map,this.optionParametersUi=new Map,this.createCustomUISettings(e.useUrlParams),this.registerSettingsUIComponents(e)}createCustomUISettings(e){this.customFlags.set(D,new l.SettingFlag(D,"Color Scheme: Dark Mode","Page styling will be either light or dark",!1,e,((e,t)=>{t.label=`Color Scheme: ${e?"Light":"Dark"} Mode`})))}registerSettingsUIComponents(e){for(const t of e.getFlags())this.flagsUi.set(t.id,new R(t));for(const e of Array.from(this.customFlags.values()))this.flagsUi.set(e.id,new R(e));for(const t of e.getTextSettings())this.textParametersUi.set(t.id,new B(t));for(const t of e.getNumericSettings())this.numericParametersUi.set(t.id,new z$1(t));for(const t of e.getOptionSettings())this.optionParametersUi.set(t.id,new U(t))}buildSectionWithHeading(e,t){const n=document.createElement("section");n.classList.add("settingsContainer");const r=document.createElement("div");return r.classList.add("settingsHeader"),r.classList.add("settings-text"),r.textContent=t,n.appendChild(r),e.appendChild(n),n}populateSettingsElement(e){const t=this.buildSectionWithHeading(e,"Pixel Streaming");this.addSettingText(t,this.textParametersUi.get(l.TextParameters.SignallingServerUrl)),this.addSettingOption(t,this.optionParametersUi.get(l.OptionParameters.StreamerId)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.AutoConnect)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.AutoPlayVideo)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.BrowserSendOffer)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.UseMic)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.StartVideoMuted)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.PreferSFU)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.IsQualityController)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.ForceMonoAudio)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.ForceTURN)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.SuppressBrowserKeys)),this.addSettingFlag(t,this.flagsUi.get(l.Flags.AFKDetection)),this.addSettingNumeric(t,this.numericParametersUi.get(l.NumericParameters.AFKTimeoutSecs));const n=this.buildSectionWithHeading(e,"UI");this.addSettingFlag(n,this.flagsUi.get(l.Flags.MatchViewportResolution)),this.addSettingFlag(n,this.flagsUi.get(l.Flags.HoveringMouseMode)),this.addSettingFlag(n,this.flagsUi.get(D));const r=this.buildSectionWithHeading(e,"Input");this.addSettingFlag(r,this.flagsUi.get(l.Flags.KeyboardInput)),this.addSettingFlag(r,this.flagsUi.get(l.Flags.MouseInput)),this.addSettingFlag(r,this.flagsUi.get(l.Flags.TouchInput)),this.addSettingFlag(r,this.flagsUi.get(l.Flags.GamepadInput)),this.addSettingFlag(r,this.flagsUi.get(l.Flags.XRControllerInput));const i=this.buildSectionWithHeading(e,"Encoder");this.addSettingNumeric(i,this.numericParametersUi.get(l.NumericParameters.MinQP)),this.addSettingNumeric(i,this.numericParametersUi.get(l.NumericParameters.MaxQP));const s=this.optionParametersUi.get(l.OptionParameters.PreferredCodec);this.addSettingOption(i,this.optionParametersUi.get(l.OptionParameters.PreferredCodec)),s&&[...s.selector.options].map((e=>e.value)).includes("Only available on Chrome")&&s.disable();const o=this.buildSectionWithHeading(e,"WebRTC");this.addSettingNumeric(o,this.numericParametersUi.get(l.NumericParameters.WebRTCFPS)),this.addSettingNumeric(o,this.numericParametersUi.get(l.NumericParameters.WebRTCMinBitrate)),this.addSettingNumeric(o,this.numericParametersUi.get(l.NumericParameters.WebRTCMaxBitrate))}addSettingText(e,t){t&&(e.appendChild(t.rootElement),this.textParametersUi.set(t.setting.id,t))}addSettingFlag(e,t){t&&(e.appendChild(t.rootElement),this.flagsUi.set(t.setting.id,t))}addSettingNumeric(e,t){t&&(e.appendChild(t.rootElement),this.numericParametersUi.set(t.setting.id,t))}addSettingOption(e,t){t&&(e.appendChild(t.rootElement),this.optionParametersUi.set(t.setting.id,t))}onSettingsChanged({data:{id:e,target:t,type:n}}){if("flag"===n){const n=e,r=t,i=this.flagsUi.get(n);i&&(i.flag!==r.flag&&(i.flag=r.flag),i.label!==r.label&&(i.label=r.label))}else if("number"===n){const n=e,r=t,i=this.numericParametersUi.get(n);i&&(i.number!==r.number&&(i.number=r.number),i.label!==r.label&&(i.label=r.label))}else if("text"===n){const n=e,r=t,i=this.textParametersUi.get(n);i&&(i.text!==r.text&&(i.text=r.text),i.label!==r.label&&(i.label=r.label))}else if("option"===n){const n=e,r=t,i=this.optionParametersUi.get(n);if(i){const e=i.options,t=r.options;e.length===t.length&&e.every((e=>t.includes(e)))||(i.options=r.options),i.selected!==r.selected&&(i.selected=r.selected),i.label!==r.label&&(i.label=r.label)}}}addCustomFlagOnSettingChangedListener(e,t){this.customFlags.has(e)&&(this.customFlags.get(e).onChange=t)}setCustomFlagLabel(e,t){this.customFlags.has(e)?(this.customFlags.get(e).label=t,this.flagsUi.get(e).label=t):l.Logger.Warning(l.Logger.GetStackTrace(),`Cannot set label for flag called ${e} - it does not exist in the Config.flags map.`)}isCustomFlagEnabled(e){return this.customFlags.get(e).flag}}class Q{constructor(e){this._options=e,this.stream=e.stream,this.onColorModeChanged=e.onColorModeChanged,this.configUI=new H(this.stream.config),this.createOverlays(),T(e.statsPanelConfig)&&(this.statsPanel=new O,this.uiFeaturesElement.appendChild(this.statsPanel.rootElement)),T(e.settingsPanelConfig)&&(this.settingsPanel=new k,this.uiFeaturesElement.appendChild(this.settingsPanel.rootElement),this.configureSettings()),e.videoQpIndicatorConfig&&e.videoQpIndicatorConfig.disableIndicator||(this.videoQpIndicator=new M,this.uiFeaturesElement.appendChild(this.videoQpIndicator.rootElement)),this.createButtons(),this.registerCallbacks(),this.showConnectOrAutoConnectOverlays(),this.setColorMode(this.configUI.isCustomFlagEnabled(D))}createOverlays(){this.disconnectOverlay=new u(this.stream.videoElementParent),this.connectOverlay=new m(this.stream.videoElementParent),this.playOverlay=new g(this.stream.videoElementParent),this.infoOverlay=new E(this.stream.videoElementParent),this.errorOverlay=new v$1(this.stream.videoElementParent),this.afkOverlay=new b(this.stream.videoElementParent),this.disconnectOverlay.onAction((()=>this.stream.reconnect())),this.connectOverlay.onAction((()=>this.stream.connect())),this.playOverlay.onAction((()=>this.stream.play()))}createButtons(){const e={statsButtonType:this._options.statsPanelConfig?this._options.statsPanelConfig.visibilityButtonConfig:void 0,settingsButtonType:this._options.settingsPanelConfig?this._options.settingsPanelConfig.visibilityButtonConfig:void 0,fullscreenButtonType:this._options.fullScreenControlsConfig,xrIconType:this._options.xrControlsConfig},t=new L(e);this.uiFeaturesElement.appendChild(t.rootElement);const n=this._options.fullScreenControlsConfig&&this._options.fullScreenControlsConfig.creationMode===c.UseCustomElement?new y(this._options.fullScreenControlsConfig.customElement):t.fullscreenIcon;n&&(n.fullscreenElement=this.rootElement);const r=t.settingsIcon?t.settingsIcon.rootElement:this._options.settingsPanelConfig.visibilityButtonConfig.customElement;r&&(r.onclick=()=>this.settingsClicked()),this.settingsPanel&&(this.settingsPanel.settingsCloseButton.onclick=()=>this.settingsClicked());const i=t.xrIcon?t.xrIcon.rootElement:this._options.xrControlsConfig.creationMode===c.UseCustomElement?this._options.xrControlsConfig.customElement:void 0;i&&(i.onclick=()=>this.stream.toggleXR());const s=t.statsIcon?t.statsIcon.rootElement:this._options.statsPanelConfig.visibilityButtonConfig.customElement;if(s&&(s.onclick=()=>this.statsClicked()),this.statsPanel&&(this.statsPanel.statsCloseButton.onclick=()=>this.statsClicked()),this.settingsPanel){const e=new I("Show FPS","Toggle");e.addOnClickListener((()=>{this.stream.requestShowFps()}));const t=new I("Restart Stream","Restart");t.addOnClickListener((()=>{this.stream.reconnect()}));const n=new I("Request keyframe","Request");n.addOnClickListener((()=>{this.stream.requestIframe()}));const r=this.configUI.buildSectionWithHeading(this.settingsPanel.settingsContentElement,"Commands");r.appendChild(e.rootElement),r.appendChild(n.rootElement),r.appendChild(t.rootElement)}}configureSettings(){this.configUI.populateSettingsElement(this.settingsPanel.settingsContentElement),this.configUI.addCustomFlagOnSettingChangedListener(D,(e=>{this.configUI.setCustomFlagLabel(D,`Color Scheme: ${e?"Light":"Dark"} Mode`),this.setColorMode(e)}))}registerCallbacks(){this.stream.addEventListener("afkWarningActivate",(({data:{countDown:e,dismissAfk:t}})=>this.showAfkOverlay(e,t))),this.stream.addEventListener("afkWarningUpdate",(({data:{countDown:e}})=>this.afkOverlay.updateCountdown(e))),this.stream.addEventListener("afkWarningDeactivate",(()=>this.afkOverlay.hide())),this.stream.addEventListener("afkTimedOut",(()=>this.afkOverlay.hide())),this.stream.addEventListener("videoEncoderAvgQP",(({data:{avgQP:e}})=>this.onVideoEncoderAvgQP(e))),this.stream.addEventListener("webRtcSdp",(()=>this.onWebRtcSdp())),this.stream.addEventListener("webRtcAutoConnect",(()=>this.onWebRtcAutoConnect())),this.stream.addEventListener("webRtcConnecting",(()=>this.onWebRtcConnecting())),this.stream.addEventListener("webRtcConnected",(()=>this.onWebRtcConnected())),this.stream.addEventListener("webRtcFailed",(()=>this.onWebRtcFailed())),this.stream.addEventListener("webRtcDisconnected",(({data:{eventString:e,showActionOrErrorOnDisconnect:t}})=>this.onDisconnect(e,t))),this.stream.addEventListener("videoInitialized",(()=>this.onVideoInitialized())),this.stream.addEventListener("streamLoading",(()=>this.onStreamLoading())),this.stream.addEventListener("playStreamError",(({data:{message:e}})=>this.onPlayStreamError(e))),this.stream.addEventListener("playStream",(()=>this.onPlayStream())),this.stream.addEventListener("playStreamRejected",(({data:{reason:e}})=>this.onPlayStreamRejected(e))),this.stream.addEventListener("loadFreezeFrame",(({data:{shouldShowPlayOverlay:e}})=>this.onLoadFreezeFrame(e))),this.stream.addEventListener("statsReceived",(({data:{aggregatedStats:e}})=>this.onStatsReceived(e))),this.stream.addEventListener("latencyTestResult",(({data:{latencyTimings:e}})=>this.onLatencyTestResults(e))),this.stream.addEventListener("streamerListMessage",(({data:{messageStreamerList:e,autoSelectedStreamerId:t}})=>this.handleStreamerListMessage(e,t))),this.stream.addEventListener("settingsChanged",(e=>this.configUI.onSettingsChanged(e)))}get rootElement(){return this._rootElement||(this._rootElement=document.createElement("div"),this._rootElement.id="playerUI",this._rootElement.classList.add("noselect"),this._rootElement.appendChild(this.stream.videoElementParent),this._rootElement.appendChild(this.uiFeaturesElement)),this._rootElement}get uiFeaturesElement(){return this._uiFeatureElement||(this._uiFeatureElement=document.createElement("div"),this._uiFeatureElement.id="uiFeatures"),this._uiFeatureElement}showDisconnectOverlay(e){this.hideCurrentOverlay(),this.updateDisconnectOverlay(e),this.disconnectOverlay.show(),this.currentOverlay=this.disconnectOverlay}updateDisconnectOverlay(e){this.disconnectOverlay.update(e)}onDisconnectionAction(){this.disconnectOverlay.activate()}hideCurrentOverlay(){null!=this.currentOverlay&&(this.currentOverlay.hide(),this.currentOverlay=null)}showConnectOverlay(){this.hideCurrentOverlay(),this.connectOverlay.show(),this.currentOverlay=this.connectOverlay}showPlayOverlay(){this.hideCurrentOverlay(),this.playOverlay.show(),this.currentOverlay=this.playOverlay}showTextOverlay(e){this.hideCurrentOverlay(),this.infoOverlay.update(e),this.infoOverlay.show(),this.currentOverlay=this.infoOverlay}showErrorOverlay(e){this.hideCurrentOverlay(),this.errorOverlay.update(e),this.errorOverlay.show(),this.currentOverlay=this.errorOverlay}settingsClicked(){this.statsPanel.hide(),this.settingsPanel.toggleVisibility()}statsClicked(){this.settingsPanel.hide(),this.statsPanel.toggleVisibility()}onConnectAction(){this.connectOverlay.activate()}onPlayAction(){this.playOverlay.activate()}showAfkOverlay(e,t){this.hideCurrentOverlay(),this.afkOverlay.updateCountdown(e),this.afkOverlay.onAction((()=>t())),this.afkOverlay.show(),this.currentOverlay=this.afkOverlay}showConnectOrAutoConnectOverlays(){this.stream.config.isFlagEnabled(l.Flags.AutoConnect)||this.showConnectOverlay()}onWebRtcAutoConnect(){this.showTextOverlay("Auto Connecting Now")}onWebRtcSdp(){this.showTextOverlay("WebRTC Connection Negotiated")}onStreamLoading(){const e=document.createElement("span");e.className="visually-hidden",e.innerHTML="Loading...";const t=document.createElement("div");t.id="loading-spinner",t.className="spinner-border ms-2",t.setAttribute("role","status"),t.appendChild(e),this.showTextOverlay("Loading Stream "+t.outerHTML)}onDisconnect(e,t){0==t?this.showErrorOverlay(`Disconnected: ${e}`):this.showDisconnectOverlay(`Disconnected: ${e} <div class="clickableState">Click To Restart</div>`),this.statsPanel.latencyTest.latencyTestButton.onclick=()=>{}}onWebRtcConnecting(){this.showTextOverlay("Starting connection to server, please wait")}onWebRtcConnected(){this.showTextOverlay("WebRTC connected, waiting for video")}onWebRtcFailed(){}onLoadFreezeFrame(e){!0===e&&(l.Logger.Log(l.Logger.GetStackTrace(),"showing play overlay"),this.showPlayOverlay())}onPlayStream(){this.hideCurrentOverlay()}onPlayStreamError(e){this.showErrorOverlay(e)}onPlayStreamRejected(e){this.showPlayOverlay()}onVideoInitialized(){this.stream.config.isFlagEnabled(l.Flags.AutoPlayVideo)||this.showPlayOverlay(),this.statsPanel.latencyTest.latencyTestButton.onclick=()=>{this.stream.requestLatencyTest()}}onVideoEncoderAvgQP(e){this.videoQpIndicator&&this.videoQpIndicator.updateQpTooltip(e)}onInitialSettings(e){e.PixelStreamingSettings&&e.PixelStreamingSettings.DisableLatencyTest&&(this.statsPanel.latencyTest.latencyTestButton.disabled=!0,this.statsPanel.latencyTest.latencyTestButton.title="Disabled by -PixelStreamingDisableLatencyTester=true",l.Logger.Info(l.Logger.GetStackTrace(),"-PixelStreamingDisableLatencyTester=true, requesting latency report from the the browser to UE is disabled."))}onStatsReceived(e){this.statsPanel.handleStats(e)}onLatencyTestResults(e){this.statsPanel.latencyTest.handleTestResult(e)}handleStreamerListMessage(e,t){null===t&&(0===e.ids.length?this.showDisconnectOverlay('No streamers connected. <div class="clickableState">Click To Restart</div>'):this.showTextOverlay("Multiple streamers detected. Use the dropdown in the settings menu to select the streamer"))}setColorMode(e){this.onColorModeChanged&&this.onColorModeChanged(e)}}const W=(e=>{var t={};return n.d(t,e),t})({default:()=>index$1}),Z=(e=>{var t={};return n.d(t,e),t})({default:()=>jssGlobal}),X=(e=>{var t={};return n.d(t,e),t})({default:()=>camelCase});class j{constructor(e){this.defaultLightModePalette={"--color0":"#e2e0dd80","--color1":"#FFFFFF","--color2":"#000000","--color3":"#0585fe","--color4":"#35b350","--color5":"#ffab00","--color6":"#e1e2dd","--color7":"#c3c4bf"},this.defaultDarkModePalette={"--color0":"#1D1F2280","--color1":"#000000","--color2":"#FFFFFF","--color3":"#0585fe","--color4":"#35b350","--color5":"#ffab00","--color6":"#1e1d22","--color7":"#3c3b40"},this.defaultStyles={":root":{"--color0":"#1D1F2280","--color1":"#000000","--color2":"#FFFFFF","--color3":"#0585fe","--color4":"#35b350","--color5":"#ffab00","--color6":"#1e1d22","--color7":"#3c3b40","--color8":"#41008c","--color9":"#3e0070","--color10":"#2e0052","--color11":"rgba(65,0,139,1)"},".noselect":{userSelect:"none"},"#playerUI":{width:"100%",height:"100%",position:"relative"},"#videoElementParent":{width:"100%",height:"100%",position:"absolute",backgroundColor:"transparent"},"#uiFeatures":{width:"100%",height:"100%",zIndex:"30",position:"relative",color:"var(--color2)",pointerEvents:"none",overflow:"hidden"},".UiTool .tooltiptext":{visibility:"hidden",width:"auto",color:"var(--color2)",textAlign:"center",borderRadius:"15px",padding:"0px 10px",fontFamily:"'Montserrat', sans-serif",fontSize:"0.75rem",letterSpacing:"0.75px",position:"absolute",top:"0",transform:"translateY(25%)",left:"125%",zIndex:"20"},".UiTool:hover .tooltiptext":{visibility:"visible",backgroundColor:"white"},"#connection .tooltiptext":{top:"125%",transform:"translateX(-25%)",left:"0",zIndex:"20",padding:"5px 10px"},"#connection":{position:"absolute",bottom:"8%",left:"5%",fontFamily:"'Michroma', sans-serif",height:"3rem",width:"3rem",pointerEvents:"all"},"#settings-panel .tooltiptext":{display:"block",top:"125%",transform:"translateX(-50%)",left:"0",zIndex:"20",padding:"5px 10px",border:"3px solid var(--color3)",width:"max-content",fallbacks:[{width:"max-content"},{border:"3px solid var(--color3)"},{padding:"5px 10px"},{zIndex:"20"},{left:"0"},{transform:"translateX(-50%)"},{top:"125%"},{display:"block"}]},"#controls":{position:"absolute",top:"3%",left:"2%",fontFamily:"'Michroma', sans-serif",pointerEvents:"all",display:"block"},"#controls>*":{marginBottom:"0.5rem",borderRadius:"50%",display:"block",height:"2rem",lineHeight:"1.75rem",padding:"0.5rem"},"#controls #additionalinfo":{textAlign:"center",fontFamily:"'Montserrat', sans-serif"},"#fullscreen-btn":{padding:"0.6rem !important"},"#minimizeIcon":{display:"none"},"#settingsBtn, #statsBtn":{cursor:"pointer"},"#uiFeatures button":{backgroundColor:"transparent",border:"1px solid var(--color7)",color:"transparent",position:"relative",width:"3rem",height:"3rem",padding:"0.5rem",textAlign:"center"},"#uiFeatures button:hover":{backgroundColor:"var(--color3)",border:"3px solid var(--color3)",transition:"0.25s ease",paddingLeft:"0.55rem",paddingTop:"0.55rem"},"#uiFeatures button:active":{border:"3px solid var(--color3)",backgroundColor:"var(--color7)",paddingLeft:"0.55rem",paddingTop:"0.55rem"},".btn-flat":{backgroundColor:"transparent",color:"var(--color2)",fontFamily:"'Montserrat'",fontWeight:"bold",border:"3px solid var(--color3)",borderRadius:"1rem",fontSize:"0.75rem",paddingLeft:"0.5rem",paddingRight:"0.5rem",cursor:"pointer",textAlign:"center"},".btn-flat:hover":{backgroundColor:"var(--color3)",transition:"ease 0.3s"},".btn-flat:disabled":{background:"var(--color7)",borderColor:"var(--color3)",color:"var(--color3)",cursor:"default"},".btn-flat:active":{backgroundColor:"transparent"},".btn-flat:focus":{outline:"none"},"#uiFeatures img":{width:"100%",height:"100%"},".panel-wrap":{position:"absolute",top:"0",bottom:"0",right:"0",height:"100%",minWidth:"20vw",maxWidth:"100vw",transform:"translateX(100%)",transition:".3s ease-out",pointerEvents:"all",backdropFilter:"blur(10px)",webkitBackdropFilter:"blur(10px)",overflowY:"auto",overflowX:"hidden",backgroundColor:"transparent"},".panel-wrap-visible":{transform:"translateX(0%)"},".panel":{overflowY:"auto",padding:"1em"},"#settingsHeading, #statsHeading":{display:"inline-block",fontSize:"2em",marginBlockStart:"0.67em",marginBlockEnd:"0.67em",marginInlineStart:"0px",marginInlineEnd:"0px",position:"relative",padding:"0 0 0 2rem"},"#settingsClose, #statsClose":{margin:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",paddingRight:"0.5rem",fontSize:"2em",float:"right"},"#settingsClose:after, #statsClose:after":{paddingLeft:"0.5rem",display:"inline-block",content:'"\\00d7"'},"#settingsClose:hover, #statsClose:hover":{color:"var(--color3)",transition:"ease 0.3s"},"#settingsContent, #statsContent":{marginLeft:"2rem",marginRight:"2rem"},".setting":{display:"flex",flexDirection:"row",justifyContent:"space-between",padding:"0.15rem 10px 0.15rem 10px"},".settings-text":{color:"var(--color2)",verticalAlign:"middle",fontWeight:"normal"},".settings-option":{width:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap"},"#connectOverlay, #playOverlay, #infoOverlay, #errorOverlay, #afkOverlay, #disconnectOverlay":{zIndex:"30",position:"absolute",color:"var(--color2)",fontSize:"1.8em",width:"100%",height:"100%",backgroundColor:"transparent",alignItems:"center",justifyContent:"center",textTransform:"uppercase"},".clickableState":{alignItems:"center",justifyContent:"center",display:"flex",cursor:"pointer"},".textDisplayState":{display:"flex"},".hiddenState":{display:"none"},"#playButton, #connectButton":{display:"inline-block",height:"auto",zIndex:"30"},"img#playButton":{maxWidth:"241px",width:"10%"},"#uiInteraction":{position:"fixed"},"#UIInteractionButtonBoundary":{padding:"2px"},"#UIInteractionButton":{cursor:"pointer"},"#hiddenInput":{position:"absolute",left:"-10%",width:"0px",opacity:"0"},"#editTextButton":{position:"absolute",height:"40px",width:"40px"},".btn-overlay":{verticalAlign:"middle",display:"inline-block"},".tgl-switch":{verticalAlign:"middle",display:"inline-block"},".tgl-switch .tgl":{display:"none"},".tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl+.tgl-slider":{webkitBoxSizing:"border-box",boxSizing:"border-box"},".tgl::-moz-selection, .tgl:after::-moz-selection, .tgl:before::-moz-selection, .tgl *::-moz-selection, .tgl *:after::-moz-selection, .tgl *:before::-moz-selection, .tgl+.tgl-slider::-moz-selection":{background:"none"},".tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl+.tgl-slider::selection":{background:"none"},".tgl-slider":{},".tgl+.tgl-slider":{outline:"0",display:"block",width:"40px",height:"18px",position:"relative",cursor:"pointer",userSelect:"none"},".tgl+.tgl-slider:after, .tgl+.tgl-slider:before":{position:"relative",display:"block",content:'""',width:"50%",height:"100%"},".tgl+.tgl-slider:after":{left:"0"},".tgl+.tgl-slider:before":{display:"none"},".tgl-flat+.tgl-slider":{padding:"2px",webkitTransition:"all .2s ease",transition:"all .2s ease",background:"var(--color6)",border:"3px solid var(--color7)",borderRadius:"2em"},".tgl-flat+.tgl-slider:after":{webkitTransition:"all .2s ease",transition:"all .2s ease",background:"var(--color7)",content:'""',borderRadius:"1em"},".tgl-flat:checked+.tgl-slider":{border:"3px solid var(--color3)"},".tgl-flat:checked+.tgl-slider:after":{left:"50%",background:"var(--color3)"},".btn-apply":{display:"block !important",marginLeft:"auto",marginRight:"auto",width:"40%"},".form-control":{backgroundColor:"transparent",border:"2px solid var(--color7)",borderRadius:"4px",color:"var(--color2)",textAlign:"right",fontFamily:"inherit"},".form-control:hover":{borderColor:"var(--color7)"},".form-group":{paddingTop:"4px",display:"grid",gridTemplateColumns:"80% 20%",rowGap:"4px",paddingRight:"10px",paddingLeft:"10px"},".form-group label":{verticalAlign:"middle",fontWeight:"normal"},".settingsContainer":{display:"flex",flexDirection:"column",borderBottom:"1px solid var(--color7)",paddingTop:"10px",paddingBottom:"10px"},".settingsContainer> :first-child":{marginTop:"4px",marginBottom:"4px",fontWeight:"bold",justifyContent:"space-between",display:"flex",flexDirection:"row",alignItems:"baseline"},".collapse":{paddingLeft:"5%"},"#streamTools":{borderBottomRightRadius:"5px",borderBottomLeftRadius:"5px",userSelect:"none",position:"absolute",top:"0",right:"2%",zIndex:"100",border:"4px solid var(--colour8)",borderTopWidth:"0px"},".settingsHeader":{fontStyle:"italic"},"#streamToolsHeader":{display:"flex",flexDirection:"row",justifyContent:"space-between",borderBottom:"1px solid var(--colour8)"},".streamTools":{fontFamily:"var(--buttonFont)",fontWeight:"lighter",color:"var(--color7)"},".streamTools-shown>#streamToolsSettings, .streamTools-shown>#streamToolsStats":{display:"block"},"#streamToolsToggle":{width:"100%"},"#qualityStatus":{fontSize:"37px",paddingRight:"4px"},".svgIcon":{fill:"var(--color2)"}};const{customStyles:t,lightModePalette:n,darkModePalette:r}=null!=e?e:{},i={plugins:[(0,Z.default)(),(0,X.default)()]};W.default.setup(i),this.customStyles=t,this.lightModePalette=null!=n?n:this.defaultLightModePalette,this.darkModePalette=null!=r?r:this.defaultDarkModePalette}applyStyleSheet(){W.default.createStyleSheet({"@global":Object.assign(Object.assign({},this.defaultStyles),this.customStyles)}).attach()}applyPalette(e){const t=document.querySelector(":root");t.style.setProperty("--color0",e["--color0"]),t.style.setProperty("--color1",e["--color1"]),t.style.setProperty("--color2",e["--color2"]),t.style.setProperty("--color3",e["--color3"]),t.style.setProperty("--color4",e["--color4"]),t.style.setProperty("--color5",e["--color5"]),t.style.setProperty("--color6",e["--color6"]),t.style.setProperty("--color7",e["--color7"])}setColorMode(e){e?this.applyPalette(this.lightModePalette):this.applyPalette(this.darkModePalette)}}var q=o.ym,V=o.EW,G=o.Mx,J=o.L3,Y=o.rl,K=o.NR,$$9=o.f1,tt=o.IY,et=o.RZ,st=o.XY,it=o.Fk,nt=o.Zh,ot=o.ek,lt=o.MG,at=o.gE,rt=o.tW,ct=o.wr,check=function(e){return e&&e.Math==Math&&e},global$g=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||Function("return this")(),objectGetOwnPropertyDescriptor={},fails$l=function(e){try{return!!e()}catch(e){return!0}},fails$k=fails$l,descriptors=!fails$k((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),fails$j=fails$l,functionBindNative=!fails$j((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$3=functionBindNative,call$g=Function.prototype.call,functionCall=NATIVE_BIND$3?call$g.bind(call$g):function(){return call$g.apply(call$g,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable={}.propertyIsEnumerable,getOwnPropertyDescriptor$3=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$3&&!$propertyIsEnumerable.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$3(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable;var match,version,createPropertyDescriptor$5=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},NATIVE_BIND$2=functionBindNative,FunctionPrototype$2=Function.prototype,call$f=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$2&&FunctionPrototype$2.bind.bind(call$f,call$f),functionUncurryThis=NATIVE_BIND$2?uncurryThisWithBind:function(e){return function(){return call$f.apply(e,arguments)}},uncurryThis$o=functionUncurryThis,toString$a=uncurryThis$o({}.toString),stringSlice$8=uncurryThis$o("".slice),classofRaw$2=function(e){return stringSlice$8(toString$a(e),8,-1)},uncurryThis$n=functionUncurryThis,fails$i=fails$l,classof$7=classofRaw$2,$Object$4=Object,split$3=uncurryThis$n("".split),indexedObject=fails$i((function(){return!$Object$4("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$7(e)?split$3(e,""):$Object$4(e)}:$Object$4,isNullOrUndefined$5=function(e){return null==e},isNullOrUndefined$4=isNullOrUndefined$5,$TypeError$b=TypeError,requireObjectCoercible$8=function(e){if(isNullOrUndefined$4(e))throw $TypeError$b("Can't call method on "+e);return e},IndexedObject$1=indexedObject,requireObjectCoercible$7=requireObjectCoercible$8,toIndexedObject$5=function(e){return IndexedObject$1(requireObjectCoercible$7(e))},documentAll$2="object"==typeof document&&document.all,IS_HTMLDDA=void 0===documentAll$2&&void 0!==documentAll$2,documentAll_1={all:documentAll$2,IS_HTMLDDA:IS_HTMLDDA},$documentAll$1=documentAll_1,documentAll$1=$documentAll$1.all,isCallable$j=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},isCallable$i=isCallable$j,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$8=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$i(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$i(e)},global$f=global$g,isCallable$h=isCallable$j,aFunction=function(e){return isCallable$h(e)?e:void 0},getBuiltIn$4=function(e,t){return arguments.length<2?aFunction(global$f[e]):global$f[e]&&global$f[e][t]},uncurryThis$m=functionUncurryThis,objectIsPrototypeOf=uncurryThis$m({}.isPrototypeOf),engineUserAgent="undefined"!=typeof navigator&&String(navigator.userAgent)||"",global$e=global$g,userAgent=engineUserAgent,process=global$e.process,Deno=global$e.Deno,versions=process&&process.versions||Deno&&Deno.version,v8=versions&&versions.v8;v8&&(version=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version&&userAgent&&((!(match=userAgent.match(/Edge\/(\d+)/))||match[1]>=74)&&((match=userAgent.match(/Chrome\/(\d+)/))&&(version=+match[1])));var engineV8Version=version,V8_VERSION=engineV8Version,fails$h=fails$l,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$h((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION&&V8_VERSION<41})),NATIVE_SYMBOL$1=symbolConstructorDetection,useSymbolAsUid=NATIVE_SYMBOL$1&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,getBuiltIn$3=getBuiltIn$4,isCallable$g=isCallable$j,isPrototypeOf$2=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,$Object$3=Object,isSymbol$2=USE_SYMBOL_AS_UID$1?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$3("Symbol");return isCallable$g(t)&&isPrototypeOf$2(t.prototype,$Object$3(e))},$String$4=String,tryToString$2=function(e){try{return $String$4(e)}catch(e){return"Object"}},isCallable$f=isCallable$j,tryToString$1=tryToString$2,$TypeError$a=TypeError,aCallable$4=function(e){if(isCallable$f(e))return e;throw $TypeError$a(tryToString$1(e)+" is not a function")},aCallable$3=aCallable$4,isNullOrUndefined$3=isNullOrUndefined$5,getMethod$5=function(e,t){var n=e[t];return isNullOrUndefined$3(n)?void 0:aCallable$3(n)},call$e=functionCall,isCallable$e=isCallable$j,isObject$7=isObject$8,$TypeError$9=TypeError,ordinaryToPrimitive$1=function(e,t){var n,r;if("string"===t&&isCallable$e(n=e.toString)&&!isObject$7(r=call$e(n,e)))return r;if(isCallable$e(n=e.valueOf)&&!isObject$7(r=call$e(n,e)))return r;if("string"!==t&&isCallable$e(n=e.toString)&&!isObject$7(r=call$e(n,e)))return r;throw $TypeError$9("Can't convert object to primitive value")},shared$4={exports:{}},isPure=!1,global$d=global$g,defineProperty$6=Object.defineProperty,defineGlobalProperty$3=function(e,t){try{defineProperty$6(global$d,e,{value:t,configurable:!0,writable:!0})}catch(n){global$d[e]=t}return t},global$c=global$g,defineGlobalProperty$2=defineGlobalProperty$3,SHARED="__core-js_shared__",store$3=global$c[SHARED]||defineGlobalProperty$2(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$4.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.29.1",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.29.1/LICENSE",source:"https://github.com/zloirock/core-js"});var requireObjectCoercible$6=requireObjectCoercible$8,$Object$2=Object,toObject$5=function(e){return $Object$2(requireObjectCoercible$6(e))},uncurryThis$l=functionUncurryThis,toObject$4=toObject$5,hasOwnProperty=uncurryThis$l({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty(toObject$4(e),t)},uncurryThis$k=functionUncurryThis,id=0,postfix=Math.random(),toString$9=uncurryThis$k(1..toString),uid$2=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$9(++id+postfix,36)},global$b=global$g,shared$3=shared$4.exports,hasOwn$b=hasOwnProperty_1,uid$1=uid$2,NATIVE_SYMBOL=symbolConstructorDetection,USE_SYMBOL_AS_UID=useSymbolAsUid,Symbol$1=global$b.Symbol,WellKnownSymbolsStore=shared$3("wks"),createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$1.for||Symbol$1:Symbol$1&&Symbol$1.withoutSetter||uid$1,wellKnownSymbol$g=function(e){return hasOwn$b(WellKnownSymbolsStore,e)||(WellKnownSymbolsStore[e]=NATIVE_SYMBOL&&hasOwn$b(Symbol$1,e)?Symbol$1[e]:createWellKnownSymbol("Symbol."+e)),WellKnownSymbolsStore[e]},call$d=functionCall,isObject$6=isObject$8,isSymbol$1=isSymbol$2,getMethod$4=getMethod$5,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$f=wellKnownSymbol$g,$TypeError$8=TypeError,TO_PRIMITIVE=wellKnownSymbol$f("toPrimitive"),toPrimitive$1=function(e,t){if(!isObject$6(e)||isSymbol$1(e))return e;var n,r=getMethod$4(e,TO_PRIMITIVE);if(r){if(void 0===t&&(t="default"),n=call$d(r,e,t),!isObject$6(n)||isSymbol$1(n))return n;throw $TypeError$8("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive=toPrimitive$1,isSymbol=isSymbol$2,toPropertyKey$3=function(e){var t=toPrimitive(e,"string");return isSymbol(t)?t:t+""},global$a=global$g,isObject$5=isObject$8,document$1=global$a.document,EXISTS$1=isObject$5(document$1)&&isObject$5(document$1.createElement),documentCreateElement$2=function(e){return EXISTS$1?document$1.createElement(e):{}},DESCRIPTORS$c=descriptors,fails$g=fails$l,createElement=documentCreateElement$2,ie8DomDefine=!DESCRIPTORS$c&&!fails$g((function(){return 7!=Object.defineProperty(createElement("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$b=descriptors,call$c=functionCall,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,createPropertyDescriptor$4=createPropertyDescriptor$5,toIndexedObject$4=toIndexedObject$5,toPropertyKey$2=toPropertyKey$3,hasOwn$a=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$b?$getOwnPropertyDescriptor$1:function(e,t){if(e=toIndexedObject$4(e),t=toPropertyKey$2(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$1(e,t)}catch(e){}if(hasOwn$a(e,t))return createPropertyDescriptor$4(!call$c(propertyIsEnumerableModule$1.f,e,t),e[t])};var objectDefineProperty={},DESCRIPTORS$a=descriptors,fails$f=fails$l,v8PrototypeDefineBug=DESCRIPTORS$a&&fails$f((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$4=isObject$8,$String$3=String,$TypeError$7=TypeError,anObject$e=function(e){if(isObject$4(e))return e;throw $TypeError$7($String$3(e)+" is not an object")},DESCRIPTORS$9=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$d=anObject$e,toPropertyKey$1=toPropertyKey$3,$TypeError$6=TypeError,$defineProperty=Object.defineProperty,$getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$9?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,n){if(anObject$d(e),t=toPropertyKey$1(t),anObject$d(n),"function"==typeof e&&"prototype"===t&&"value"in n&&WRITABLE in n&&!n[WRITABLE]){var r=$getOwnPropertyDescriptor(e,t);r&&r[WRITABLE]&&(e[t]=n.value,n={configurable:CONFIGURABLE$1 in n?n[CONFIGURABLE$1]:r[CONFIGURABLE$1],enumerable:ENUMERABLE in n?n[ENUMERABLE]:r[ENUMERABLE],writable:!1})}return $defineProperty(e,t,n)}:$defineProperty:function(e,t,n){if(anObject$d(e),t=toPropertyKey$1(t),anObject$d(n),IE8_DOM_DEFINE)try{return $defineProperty(e,t,n)}catch(e){}if("get"in n||"set"in n)throw $TypeError$6("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var DESCRIPTORS$8=descriptors,definePropertyModule$4=objectDefineProperty,createPropertyDescriptor$3=createPropertyDescriptor$5,createNonEnumerableProperty$5=DESCRIPTORS$8?function(e,t,n){return definePropertyModule$4.f(e,t,createPropertyDescriptor$3(1,n))}:function(e,t,n){return e[t]=n,e},makeBuiltIn$3={exports:{}},DESCRIPTORS$7=descriptors,hasOwn$9=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$7&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$9(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$7||DESCRIPTORS$7&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},uncurryThis$j=functionUncurryThis,isCallable$d=isCallable$j,store$1=sharedStore,functionToString=uncurryThis$j(Function.toString);isCallable$d(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var set,get,has,inspectSource$2=store$1.inspectSource,global$9=global$g,isCallable$c=isCallable$j,WeakMap$1=global$9.WeakMap,weakMapBasicDetection=isCallable$c(WeakMap$1)&&/native code/.test(String(WeakMap$1)),shared$2=shared$4.exports,uid=uid$2,keys=shared$2("keys"),sharedKey$3=function(e){return keys[e]||(keys[e]=uid(e))},hiddenKeys$4={},NATIVE_WEAK_MAP=weakMapBasicDetection,global$8=global$g,isObject$3=isObject$8,createNonEnumerableProperty$4=createNonEnumerableProperty$5,hasOwn$8=hasOwnProperty_1,shared$1=sharedStore,sharedKey$2=sharedKey$3,hiddenKeys$3=hiddenKeys$4,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$3=global$8.TypeError,WeakMap=global$8.WeakMap,enforce=function(e){return has(e)?get(e):set(e,{})},getterFor=function(e){return function(t){var n;if(!isObject$3(t)||(n=get(t)).type!==e)throw TypeError$3("Incompatible receiver, "+e+" required");return n}};if(NATIVE_WEAK_MAP||shared$1.state){var store=shared$1.state||(shared$1.state=new WeakMap);store.get=store.get,store.has=store.has,store.set=store.set,set=function(e,t){if(store.has(e))throw TypeError$3(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get=function(e){return store.get(e)||{}},has=function(e){return store.has(e)}}else{var STATE=sharedKey$2("state");hiddenKeys$3[STATE]=!0,set=function(e,t){if(hasOwn$8(e,STATE))throw TypeError$3(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$4(e,STATE,t),t},get=function(e){return hasOwn$8(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$8(e,STATE)}}var internalState={set:set,get:get,has:has,enforce:enforce,getterFor:getterFor},uncurryThis$i=functionUncurryThis,fails$e=fails$l,isCallable$b=isCallable$j,hasOwn$7=hasOwnProperty_1,DESCRIPTORS$6=descriptors,CONFIGURABLE_FUNCTION_NAME$1=functionName.CONFIGURABLE,inspectSource$1=inspectSource$2,InternalStateModule$4=internalState,enforceInternalState=InternalStateModule$4.enforce,getInternalState$3=InternalStateModule$4.get,$String$2=String,defineProperty$5=Object.defineProperty,stringSlice$7=uncurryThis$i("".slice),replace$6=uncurryThis$i("".replace),join$3=uncurryThis$i([].join),CONFIGURABLE_LENGTH=DESCRIPTORS$6&&!fails$e((function(){return 8!==defineProperty$5((function(){}),"length",{value:8}).length})),TEMPLATE=String(String).split("String"),makeBuiltIn$2=makeBuiltIn$3.exports=function(e,t,n){"Symbol("===stringSlice$7($String$2(t),0,7)&&(t="["+replace$6($String$2(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!hasOwn$7(e,"name")||CONFIGURABLE_FUNCTION_NAME$1&&e.name!==t)&&(DESCRIPTORS$6?defineProperty$5(e,"name",{value:t,configurable:!0}):e.name=t),CONFIGURABLE_LENGTH&&n&&hasOwn$7(n,"arity")&&e.length!==n.arity&&defineProperty$5(e,"length",{value:n.arity});try{n&&hasOwn$7(n,"constructor")&&n.constructor?DESCRIPTORS$6&&defineProperty$5(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var r=enforceInternalState(e);return hasOwn$7(r,"source")||(r.source=join$3(TEMPLATE,"string"==typeof t?t:"")),e};Function.prototype.toString=makeBuiltIn$2((function(){return isCallable$b(this)&&getInternalState$3(this).source||inspectSource$1(this)}),"toString");var isCallable$a=isCallable$j,definePropertyModule$3=objectDefineProperty,makeBuiltIn$1=makeBuiltIn$3.exports,defineGlobalProperty$1=defineGlobalProperty$3,defineBuiltIn$8=function(e,t,n,r){r||(r={});var i=r.enumerable,s=void 0!==r.name?r.name:t;if(isCallable$a(n)&&makeBuiltIn$1(n,s,r),r.global)i?e[t]=n:defineGlobalProperty$1(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=n:definePropertyModule$3.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},objectGetOwnPropertyNames={},ceil=Math.ceil,floor$4=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$4:ceil)(t)},trunc=mathTrunc,toIntegerOrInfinity$4=function(e){var t=+e;return t!=t||0===t?0:trunc(t)},toIntegerOrInfinity$3=toIntegerOrInfinity$4,max$2=Math.max,min$3=Math.min,toAbsoluteIndex$2=function(e,t){var n=toIntegerOrInfinity$3(e);return n<0?max$2(n+t,0):min$3(n,t)},toIntegerOrInfinity$2=toIntegerOrInfinity$4,min$2=Math.min,toLength$3=function(e){return e>0?min$2(toIntegerOrInfinity$2(e),9007199254740991):0},toLength$2=toLength$3,lengthOfArrayLike$3=function(e){return toLength$2(e.length)},toIndexedObject$3=toIndexedObject$5,toAbsoluteIndex$1=toAbsoluteIndex$2,lengthOfArrayLike$2=lengthOfArrayLike$3,createMethod$2=function(e){return function(t,n,r){var i,s=toIndexedObject$3(t),o=lengthOfArrayLike$2(s),a=toAbsoluteIndex$1(r,o);if(e&&n!=n){for(;o>a;)if((i=s[a++])!=i)return!0}else for(;o>a;a++)if((e||a in s)&&s[a]===n)return e||a||0;return!e&&-1}},arrayIncludes={includes:createMethod$2(!0),indexOf:createMethod$2(!1)},uncurryThis$h=functionUncurryThis,hasOwn$6=hasOwnProperty_1,toIndexedObject$2=toIndexedObject$5,indexOf$1=arrayIncludes.indexOf,hiddenKeys$2=hiddenKeys$4,push$4=uncurryThis$h([].push),objectKeysInternal=function(e,t){var n,r=toIndexedObject$2(e),i=0,s=[];for(n in r)!hasOwn$6(hiddenKeys$2,n)&&hasOwn$6(r,n)&&push$4(s,n);for(;t.length>i;)hasOwn$6(r,n=t[i++])&&(~indexOf$1(s,n)||push$4(s,n));return s},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,hiddenKeys$1=enumBugKeys$2.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys$1(e,hiddenKeys$1)};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var getBuiltIn$2=getBuiltIn$4,uncurryThis$g=functionUncurryThis,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,anObject$c=anObject$e,concat$2=uncurryThis$g([].concat),ownKeys$1=getBuiltIn$2("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule.f(anObject$c(e)),n=getOwnPropertySymbolsModule$1.f;return n?concat$2(t,n(e)):t},hasOwn$5=hasOwnProperty_1,ownKeys=ownKeys$1,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,definePropertyModule$2=objectDefineProperty,copyConstructorProperties$1=function(e,t,n){for(var r=ownKeys(t),i=definePropertyModule$2.f,s=getOwnPropertyDescriptorModule.f,o=0;o<r.length;o++){var a=r[o];hasOwn$5(e,a)||n&&hasOwn$5(n,a)||i(e,a,s(t,a))}},fails$d=fails$l,isCallable$9=isCallable$j,replacement=/#|\.prototype\./,isForced$1=function(e,t){var n=data[normalize(e)];return n==POLYFILL||n!=NATIVE&&(isCallable$9(t)?fails$d(t):!!t)},normalize=isForced$1.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$1.data={},NATIVE=isForced$1.NATIVE="N",POLYF