@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/AFK/AFKController.js +110 -0
- package/dist/commonjs/AFK/AFKController.js.map +1 -0
- package/dist/commonjs/Config/Config.js +560 -0
- package/dist/commonjs/Config/Config.js.map +1 -0
- package/dist/commonjs/Config/SettingBase.js +99 -0
- package/dist/commonjs/Config/SettingBase.js.map +1 -0
- package/dist/commonjs/Config/SettingFlag.js +50 -0
- package/dist/commonjs/Config/SettingFlag.js.map +1 -0
- package/dist/commonjs/Config/SettingNumber.js +84 -0
- package/dist/commonjs/Config/SettingNumber.js.map +1 -0
- package/dist/commonjs/Config/SettingOption.js +85 -0
- package/dist/commonjs/Config/SettingOption.js.map +1 -0
- package/dist/commonjs/Config/SettingText.js +43 -0
- package/dist/commonjs/Config/SettingText.js.map +1 -0
- package/dist/commonjs/DataChannel/DataChannelController.js +107 -0
- package/dist/commonjs/DataChannel/DataChannelController.js.map +1 -0
- package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +95 -0
- package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js.map +1 -0
- package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +19 -0
- package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js.map +1 -0
- package/dist/commonjs/DataChannel/DataChannelSender.js +44 -0
- package/dist/commonjs/DataChannel/DataChannelSender.js.map +1 -0
- package/dist/commonjs/DataChannel/InitialSettings.js +42 -0
- package/dist/commonjs/DataChannel/InitialSettings.js.map +1 -0
- package/dist/commonjs/DataChannel/LatencyTestResults.js +61 -0
- package/dist/commonjs/DataChannel/LatencyTestResults.js.map +1 -0
- package/dist/commonjs/FreezeFrame/FreezeFrame.js +94 -0
- package/dist/commonjs/FreezeFrame/FreezeFrame.js.map +1 -0
- package/dist/commonjs/FreezeFrame/FreezeFrameController.js +96 -0
- package/dist/commonjs/FreezeFrame/FreezeFrameController.js.map +1 -0
- package/dist/commonjs/Inputs/GamepadController.js +189 -0
- package/dist/commonjs/Inputs/GamepadController.js.map +1 -0
- package/dist/commonjs/Inputs/GamepadTypes.js +22 -0
- package/dist/commonjs/Inputs/GamepadTypes.js.map +1 -0
- package/dist/commonjs/Inputs/IInputController.js +3 -0
- package/dist/commonjs/Inputs/IInputController.js.map +1 -0
- package/dist/commonjs/Inputs/InputClassesFactory.js +97 -0
- package/dist/commonjs/Inputs/InputClassesFactory.js.map +1 -0
- package/dist/commonjs/Inputs/KeyCodes.js +113 -0
- package/dist/commonjs/Inputs/KeyCodes.js.map +1 -0
- package/dist/commonjs/Inputs/KeyboardController.js +138 -0
- package/dist/commonjs/Inputs/KeyboardController.js.map +1 -0
- package/dist/commonjs/Inputs/MouseButtons.js +29 -0
- package/dist/commonjs/Inputs/MouseButtons.js.map +1 -0
- package/dist/commonjs/Inputs/MouseController.js +98 -0
- package/dist/commonjs/Inputs/MouseController.js.map +1 -0
- package/dist/commonjs/Inputs/MouseControllerHovering.js +94 -0
- package/dist/commonjs/Inputs/MouseControllerHovering.js.map +1 -0
- package/dist/commonjs/Inputs/MouseControllerLocked.js +154 -0
- package/dist/commonjs/Inputs/MouseControllerLocked.js.map +1 -0
- package/dist/commonjs/Inputs/SpecialKeyCodes.js +20 -0
- package/dist/commonjs/Inputs/SpecialKeyCodes.js.map +1 -0
- package/dist/commonjs/Inputs/TouchController.js +124 -0
- package/dist/commonjs/Inputs/TouchController.js.map +1 -0
- package/dist/commonjs/Inputs/TouchControllerFake.js +92 -0
- package/dist/commonjs/Inputs/TouchControllerFake.js.map +1 -0
- package/dist/commonjs/Inputs/XRGamepadController.js +125 -0
- package/dist/commonjs/Inputs/XRGamepadController.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/AggregatedStats.js +253 -0
- package/dist/commonjs/PeerConnectionController/AggregatedStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/CandidatePairStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/CandidateStat.js +11 -0
- package/dist/commonjs/PeerConnectionController/CandidateStat.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/CodecStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/CodecStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/DataChannelStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/DataChannelStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +23 -0
- package/dist/commonjs/PeerConnectionController/InboundRTPStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/InboundTrackStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +17 -0
- package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +585 -0
- package/dist/commonjs/PeerConnectionController/PeerConnectionController.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/SessionStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/SessionStats.js.map +1 -0
- package/dist/commonjs/PeerConnectionController/StreamStats.js +11 -0
- package/dist/commonjs/PeerConnectionController/StreamStats.js.map +1 -0
- package/dist/commonjs/PixelStreaming/PixelStreaming.js +608 -0
- package/dist/commonjs/PixelStreaming/PixelStreaming.js.map +1 -0
- package/dist/commonjs/UI/OnScreenKeyboard.js +83 -0
- package/dist/commonjs/UI/OnScreenKeyboard.js.map +1 -0
- package/dist/commonjs/UeInstanceMessage/ResponseController.js +39 -0
- package/dist/commonjs/UeInstanceMessage/ResponseController.js.map +1 -0
- package/dist/commonjs/UeInstanceMessage/SendMessageController.js +121 -0
- package/dist/commonjs/UeInstanceMessage/SendMessageController.js.map +1 -0
- package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +211 -0
- package/dist/commonjs/UeInstanceMessage/StreamMessageController.js.map +1 -0
- package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +50 -0
- package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js.map +1 -0
- package/dist/commonjs/Util/EventEmitter.js +387 -0
- package/dist/commonjs/Util/EventEmitter.js.map +1 -0
- package/dist/commonjs/Util/FileUtil.js +109 -0
- package/dist/commonjs/Util/FileUtil.js.map +1 -0
- package/dist/commonjs/Util/IURLSearchParams.js +26 -0
- package/dist/commonjs/Util/IURLSearchParams.js.map +1 -0
- package/dist/commonjs/Util/InputCoordTranslator.js +50 -0
- package/dist/commonjs/Util/InputCoordTranslator.js.map +1 -0
- package/dist/commonjs/Util/RTCUtils.js +41 -0
- package/dist/commonjs/Util/RTCUtils.js.map +1 -0
- package/dist/commonjs/VideoPlayer/StreamController.js +68 -0
- package/dist/commonjs/VideoPlayer/StreamController.js.map +1 -0
- package/dist/commonjs/VideoPlayer/VideoPlayer.js +178 -0
- package/dist/commonjs/VideoPlayer/VideoPlayer.js.map +1 -0
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1224 -0
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js.map +1 -0
- package/dist/commonjs/WebXR/WebXRController.js +361 -0
- package/dist/commonjs/WebXR/WebXRController.js.map +1 -0
- package/dist/commonjs/pixelstreamingfrontend.js +71 -0
- package/dist/commonjs/pixelstreamingfrontend.js.map +1 -0
- package/dist/esm/AFK/AFKController.js +106 -0
- package/dist/esm/AFK/AFKController.js.map +1 -0
- package/dist/esm/Config/Config.js +552 -0
- package/dist/esm/Config/Config.js.map +1 -0
- package/dist/esm/Config/SettingBase.js +95 -0
- package/dist/esm/Config/SettingBase.js.map +1 -0
- package/dist/esm/Config/SettingFlag.js +46 -0
- package/dist/esm/Config/SettingFlag.js.map +1 -0
- package/dist/esm/Config/SettingNumber.js +80 -0
- package/dist/esm/Config/SettingNumber.js.map +1 -0
- package/dist/esm/Config/SettingOption.js +81 -0
- package/dist/esm/Config/SettingOption.js.map +1 -0
- package/dist/esm/Config/SettingText.js +39 -0
- package/dist/esm/Config/SettingText.js.map +1 -0
- package/dist/esm/DataChannel/DataChannelController.js +103 -0
- package/dist/esm/DataChannel/DataChannelController.js.map +1 -0
- package/dist/esm/DataChannel/DataChannelLatencyTestController.js +91 -0
- package/dist/esm/DataChannel/DataChannelLatencyTestController.js.map +1 -0
- package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +15 -0
- package/dist/esm/DataChannel/DataChannelLatencyTestResults.js.map +1 -0
- package/dist/esm/DataChannel/DataChannelSender.js +40 -0
- package/dist/esm/DataChannel/DataChannelSender.js.map +1 -0
- package/dist/esm/DataChannel/InitialSettings.js +35 -0
- package/dist/esm/DataChannel/InitialSettings.js.map +1 -0
- package/dist/esm/DataChannel/LatencyTestResults.js +57 -0
- package/dist/esm/DataChannel/LatencyTestResults.js.map +1 -0
- package/dist/esm/FreezeFrame/FreezeFrame.js +90 -0
- package/dist/esm/FreezeFrame/FreezeFrame.js.map +1 -0
- package/dist/esm/FreezeFrame/FreezeFrameController.js +92 -0
- package/dist/esm/FreezeFrame/FreezeFrameController.js.map +1 -0
- package/dist/esm/Inputs/GamepadController.js +185 -0
- package/dist/esm/Inputs/GamepadController.js.map +1 -0
- package/dist/esm/Inputs/GamepadTypes.js +18 -0
- package/dist/esm/Inputs/GamepadTypes.js.map +1 -0
- package/dist/esm/Inputs/IInputController.js +2 -0
- package/dist/esm/Inputs/IInputController.js.map +1 -0
- package/dist/esm/Inputs/InputClassesFactory.js +92 -0
- package/dist/esm/Inputs/InputClassesFactory.js.map +1 -0
- package/dist/esm/Inputs/KeyCodes.js +110 -0
- package/dist/esm/Inputs/KeyCodes.js.map +1 -0
- package/dist/esm/Inputs/KeyboardController.js +134 -0
- package/dist/esm/Inputs/KeyboardController.js.map +1 -0
- package/dist/esm/Inputs/MouseButtons.js +24 -0
- package/dist/esm/Inputs/MouseButtons.js.map +1 -0
- package/dist/esm/Inputs/MouseController.js +94 -0
- package/dist/esm/Inputs/MouseController.js.map +1 -0
- package/dist/esm/Inputs/MouseControllerHovering.js +90 -0
- package/dist/esm/Inputs/MouseControllerHovering.js.map +1 -0
- package/dist/esm/Inputs/MouseControllerLocked.js +150 -0
- package/dist/esm/Inputs/MouseControllerLocked.js.map +1 -0
- package/dist/esm/Inputs/SpecialKeyCodes.js +16 -0
- package/dist/esm/Inputs/SpecialKeyCodes.js.map +1 -0
- package/dist/esm/Inputs/TouchController.js +120 -0
- package/dist/esm/Inputs/TouchController.js.map +1 -0
- package/dist/esm/Inputs/TouchControllerFake.js +88 -0
- package/dist/esm/Inputs/TouchControllerFake.js.map +1 -0
- package/dist/esm/Inputs/XRGamepadController.js +121 -0
- package/dist/esm/Inputs/XRGamepadController.js.map +1 -0
- package/dist/esm/PeerConnectionController/AggregatedStats.js +249 -0
- package/dist/esm/PeerConnectionController/AggregatedStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/CandidatePairStats.js +7 -0
- package/dist/esm/PeerConnectionController/CandidatePairStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/CandidateStat.js +7 -0
- package/dist/esm/PeerConnectionController/CandidateStat.js.map +1 -0
- package/dist/esm/PeerConnectionController/CodecStats.js +7 -0
- package/dist/esm/PeerConnectionController/CodecStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/DataChannelStats.js +7 -0
- package/dist/esm/PeerConnectionController/DataChannelStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/InboundRTPStats.js +17 -0
- package/dist/esm/PeerConnectionController/InboundRTPStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/InboundTrackStats.js +7 -0
- package/dist/esm/PeerConnectionController/InboundTrackStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +12 -0
- package/dist/esm/PeerConnectionController/OutBoundRTPStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/PeerConnectionController.js +581 -0
- package/dist/esm/PeerConnectionController/PeerConnectionController.js.map +1 -0
- package/dist/esm/PeerConnectionController/SessionStats.js +7 -0
- package/dist/esm/PeerConnectionController/SessionStats.js.map +1 -0
- package/dist/esm/PeerConnectionController/StreamStats.js +7 -0
- package/dist/esm/PeerConnectionController/StreamStats.js.map +1 -0
- package/dist/esm/PixelStreaming/PixelStreaming.js +604 -0
- package/dist/esm/PixelStreaming/PixelStreaming.js.map +1 -0
- package/dist/esm/UI/OnScreenKeyboard.js +79 -0
- package/dist/esm/UI/OnScreenKeyboard.js.map +1 -0
- package/dist/esm/UeInstanceMessage/ResponseController.js +35 -0
- package/dist/esm/UeInstanceMessage/ResponseController.js.map +1 -0
- package/dist/esm/UeInstanceMessage/SendMessageController.js +117 -0
- package/dist/esm/UeInstanceMessage/SendMessageController.js.map +1 -0
- package/dist/esm/UeInstanceMessage/StreamMessageController.js +206 -0
- package/dist/esm/UeInstanceMessage/StreamMessageController.js.map +1 -0
- package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +46 -0
- package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js.map +1 -0
- package/dist/esm/Util/EventEmitter.js +346 -0
- package/dist/esm/Util/EventEmitter.js.map +1 -0
- package/dist/esm/Util/FileUtil.js +104 -0
- package/dist/esm/Util/FileUtil.js.map +1 -0
- package/dist/esm/Util/IURLSearchParams.js +22 -0
- package/dist/esm/Util/IURLSearchParams.js.map +1 -0
- package/dist/esm/Util/InputCoordTranslator.js +46 -0
- package/dist/esm/Util/InputCoordTranslator.js.map +1 -0
- package/dist/esm/Util/RTCUtils.js +37 -0
- package/dist/esm/Util/RTCUtils.js.map +1 -0
- package/dist/esm/VideoPlayer/StreamController.js +64 -0
- package/dist/esm/VideoPlayer/StreamController.js.map +1 -0
- package/dist/esm/VideoPlayer/VideoPlayer.js +174 -0
- package/dist/esm/VideoPlayer/VideoPlayer.js.map +1 -0
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1220 -0
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js.map +1 -0
- package/dist/esm/WebXR/WebXRController.js +357 -0
- package/dist/esm/WebXR/WebXRController.js.map +1 -0
- package/dist/esm/pixelstreamingfrontend.js +25 -0
- package/dist/esm/pixelstreamingfrontend.js.map +1 -0
- package/{types → dist/types}/Config/SettingNumber.d.ts +3 -3
- package/{types → dist/types}/Config/SettingOption.d.ts +8 -1
- package/{types → dist/types}/DataChannel/DataChannelLatencyTestController.d.ts +1 -2
- package/{types → dist/types}/PeerConnectionController/AggregatedStats.d.ts +1 -3
- package/{types → dist/types}/pixelstreamingfrontend.d.ts +2 -1
- package/package.json +45 -49
- package/readme.md +9 -1
- package/src/Config/Config.ts +74 -25
- package/src/Config/SettingNumber.ts +13 -5
- package/src/Config/SettingOption.ts +31 -13
- package/src/DataChannel/DataChannelLatencyTestController.ts +6 -6
- package/src/PeerConnectionController/AggregatedStats.ts +26 -27
- package/src/PeerConnectionController/PeerConnectionController.ts +38 -9
- package/src/WebRtcPlayer/WebRtcPlayerController.ts +1 -1
- package/src/pixelstreamingfrontend.ts +7 -1
- package/tsconfig.cjs.json +9 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +4 -6
- package/dist/lib-pixelstreamingfrontend.esm.js +0 -1
- package/dist/lib-pixelstreamingfrontend.js +0 -1
- package/webpack.common.js +0 -35
- package/webpack.dev.js +0 -35
- package/webpack.prod.js +0 -36
- /package/{types → dist/types}/AFK/AFKController.d.ts +0 -0
- /package/{types → dist/types}/Config/Config.d.ts +0 -0
- /package/{types → dist/types}/Config/SettingBase.d.ts +0 -0
- /package/{types → dist/types}/Config/SettingFlag.d.ts +0 -0
- /package/{types → dist/types}/Config/SettingText.d.ts +0 -0
- /package/{types → dist/types}/DataChannel/DataChannelController.d.ts +0 -0
- /package/{types → dist/types}/DataChannel/DataChannelLatencyTestResults.d.ts +0 -0
- /package/{types → dist/types}/DataChannel/DataChannelSender.d.ts +0 -0
- /package/{types → dist/types}/DataChannel/InitialSettings.d.ts +0 -0
- /package/{types → dist/types}/DataChannel/LatencyTestResults.d.ts +0 -0
- /package/{types → dist/types}/FreezeFrame/FreezeFrame.d.ts +0 -0
- /package/{types → dist/types}/FreezeFrame/FreezeFrameController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/GamepadController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/GamepadTypes.d.ts +0 -0
- /package/{types → dist/types}/Inputs/IInputController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/InputClassesFactory.d.ts +0 -0
- /package/{types → dist/types}/Inputs/KeyCodes.d.ts +0 -0
- /package/{types → dist/types}/Inputs/KeyboardController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/MouseButtons.d.ts +0 -0
- /package/{types → dist/types}/Inputs/MouseController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/MouseControllerHovering.d.ts +0 -0
- /package/{types → dist/types}/Inputs/MouseControllerLocked.d.ts +0 -0
- /package/{types → dist/types}/Inputs/SpecialKeyCodes.d.ts +0 -0
- /package/{types → dist/types}/Inputs/TouchController.d.ts +0 -0
- /package/{types → dist/types}/Inputs/TouchControllerFake.d.ts +0 -0
- /package/{types → dist/types}/Inputs/XRGamepadController.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/CandidatePairStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/CandidateStat.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/CodecStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/DataChannelStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/InboundRTPStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/InboundTrackStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/OutBoundRTPStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/PeerConnectionController.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/SessionStats.d.ts +0 -0
- /package/{types → dist/types}/PeerConnectionController/StreamStats.d.ts +0 -0
- /package/{types → dist/types}/PixelStreaming/PixelStreaming.d.ts +0 -0
- /package/{types → dist/types}/UI/OnScreenKeyboard.d.ts +0 -0
- /package/{types → dist/types}/UeInstanceMessage/ResponseController.d.ts +0 -0
- /package/{types → dist/types}/UeInstanceMessage/SendMessageController.d.ts +0 -0
- /package/{types → dist/types}/UeInstanceMessage/StreamMessageController.d.ts +0 -0
- /package/{types → dist/types}/UeInstanceMessage/ToStreamerMessagesController.d.ts +0 -0
- /package/{types → dist/types}/Util/EventEmitter.d.ts +0 -0
- /package/{types → dist/types}/Util/FileUtil.d.ts +0 -0
- /package/{types → dist/types}/Util/IURLSearchParams.d.ts +0 -0
- /package/{types → dist/types}/Util/InputCoordTranslator.d.ts +0 -0
- /package/{types → dist/types}/Util/RTCUtils.d.ts +0 -0
- /package/{types → dist/types}/VideoPlayer/StreamController.d.ts +0 -0
- /package/{types → dist/types}/VideoPlayer/VideoPlayer.d.ts +0 -0
- /package/{types → dist/types}/WebRtcPlayer/WebRtcPlayerController.d.ts +0 -0
- /package/{types → dist/types}/WebXR/WebXRController.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("sdp")):"function"==typeof define&&define.amd?define(["sdp"],t):"object"==typeof exports?exports["lib-pixelstreamingfrontend"]=t(require("sdp")):e["lib-pixelstreamingfrontend"]=t(e.sdp)}(this,(e=>(()=>{"use strict";var t={290:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},7:e=>{var t,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,s){function r(n){e.removeListener(t,i),s(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}p(e,t,i,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,r)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function d(e,t,n,s){var r,i,o,d;if(a(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"==typeof o?o=i[t]=s?[n,o]:[o,n]:s?o.unshift(n):o.push(n),(r=l(e))>0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,d=h,console&&console.warn&&console.warn(d)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=h.bind(s);return r.listener=n,s.wrapFn=r,r}function u(e,t,n){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):m(r,r.length)}function g(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function p(e,t,n,s){if("function"==typeof e.on)s.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(i){s.once&&e.removeEventListener(t,r),n(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return l(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)s(l,this,t);else{var d=l.length,h=m(l,d);for(n=0;n<d;++n)s(h[n],this,t)}return!0},i.prototype.addListener=function(e,t){return d(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return d(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,c(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,c(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,s,r,i,o;if(a(t),void 0===(s=this._events))return this;if(void 0===(n=s[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){o=n[i].listener,r=i;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(s[e]=n[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,s;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,i=Object.keys(n);for(s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},i.prototype.listeners=function(e){return u(this,e,!0)},i.prototype.rawListeners=function(e){return u(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},i.prototype.listenerCount=g,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},89:t=>{t.exports=e}},n={};function s(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,s),i.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};s.r(r),s.d(r,{AfkLogic:()=>zt,AfkTimedOutEvent:()=>et,AfkWarningActivateEvent:()=>Je,AfkWarningDeactivateEvent:()=>Ze,AfkWarningUpdateEvent:()=>Ye,AggregatedStats:()=>en,CandidatePairStats:()=>jn,CandidateStat:()=>Qt,Config:()=>$t,ControlSchemeType:()=>jt,DataChannelCloseEvent:()=>dt,DataChannelErrorEvent:()=>ht,DataChannelLatencyTestResponseEvent:()=>Mt,DataChannelLatencyTestResultEvent:()=>kt,DataChannelOpenEvent:()=>lt,DataChannelStats:()=>qt,EncoderSettings:()=>ln,EventEmitter:()=>Dt,Flags:()=>At,HideFreezeFrameEvent:()=>St,InboundAudioStats:()=>Gt,InboundVideoStats:()=>Xt,InitialSettings:()=>on,InitialSettingsEvent:()=>Rt,InputCoordTranslator:()=>An,LatencyTestResultEvent:()=>Et,LatencyTestResults:()=>hn,LoadFreezeFrameEvent:()=>wt,LogLevel:()=>o,Logger:()=>d,MessageDirection:()=>Mn,MessageHelpers:()=>a,MessageRegistry:()=>Ve,Messages:()=>i,NumericParameters:()=>Bt,OptionParameters:()=>_t,OutBoundVideoStats:()=>Jt,PixelStreaming:()=>$n,PlayStreamErrorEvent:()=>ft,PlayStreamEvent:()=>yt,PlayStreamRejectedEvent:()=>vt,PlayerCountEvent:()=>Ft,SettingBase:()=>Ke,SettingFlag:()=>Ge,SettingNumber:()=>Xe,SettingOption:()=>Qe,SettingText:()=>qe,SettingsChangedEvent:()=>Pt,SignallingProtocol:()=>He,StatsReceivedEvent:()=>bt,StreamLoadingEvent:()=>ut,StreamPreConnectEvent:()=>gt,StreamPreDisconnectEvent:()=>mt,StreamReconnectEvent:()=>pt,StreamerIDChangedMessageEvent:()=>Tt,StreamerListMessageEvent:()=>Ct,TextParameters:()=>Vt,VideoEncoderAvgQPEvent:()=>tt,VideoInitializedEvent:()=>ct,WebRTCSettings:()=>dn,WebRtcAutoConnectEvent:()=>st,WebRtcConnectedEvent:()=>it,WebRtcConnectingEvent:()=>rt,WebRtcDisconnectedEvent:()=>at,WebRtcFailedEvent:()=>ot,WebRtcPlayerController:()=>Bn,WebRtcSdpEvent:()=>nt,WebRtcTCPRelayDetectedEvent:()=>Ot,WebSocketTransport:()=>g,WebSocketTransportNJS:()=>Gn,WebXRController:()=>Vn,XrFrameEvent:()=>xt,XrSessionEndedEvent:()=>Lt,XrSessionStartedEvent:()=>It});var i={};s.r(i),s.d(i,{answer:()=>Te,base_message:()=>de,config:()=>ce,dataChannelRequest:()=>xe,disconnectPlayer:()=>ke,endpointId:()=>ge,endpointIdConfirm:()=>me,iceCandidate:()=>Me,iceCandidateData:()=>Ee,identify:()=>ue,layerPreference:()=>Le,listStreamers:()=>fe,offer:()=>Ce,peerConnectionOptions:()=>he,peerDataChannels:()=>Fe,peerDataChannelsReady:()=>Oe,ping:()=>Re,playerConnected:()=>Se,playerCount:()=>Be,playerDisconnected:()=>be,pong:()=>Pe,startStreaming:()=>Ae,stats:()=>Ue,stopStreaming:()=>Ne,streamerDataChannels:()=>De,streamerDisconnected:()=>Ie,streamerIdChanged:()=>pe,streamerList:()=>ye,subscribe:()=>ve,unsubscribe:()=>we});var o,a={};s.r(a),s.d(a,{createMessage:()=>We,validateMessage:()=>_e}),function(e){e[e.Disabled=0]="Disabled",e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Info=3]="Info",e[e.Debug=4]="Debug"}(o||(o={}));class l{constructor(){this.logLevel=o.Debug,this.includeStack=!0}}const d=new class{InitLogging(e,t){this.ValidateContext(),this.context.logLevel=e,this.context.includeStack=t}Debug(e){this.ValidateContext(),this.context.logLevel>=o.Debug&&this.CommonLog("Debug",e)}Info(e){this.ValidateContext(),this.context.logLevel>=o.Info&&this.CommonLog("Info",e)}Warning(e){this.ValidateContext(),this.context.logLevel>=o.Warning&&this.CommonLog("Warning",e)}Error(e){this.ValidateContext(),this.context.logLevel>=o.Error&&this.CommonLog("Error",e)}CommonLog(e,t){let n=`[${e}] - ${t}`;this.context.includeStack&&(n+=`\nStack: ${this.GetStackTrace()}`),console.log(n)}GetStackTrace(){const e=new Error;let t="No Stack Available for this browser";return e.stack&&(t=e.stack.toString().replace(/Error/g,"")),t}ValidateContext(){this.context||(window?window.loggerContext?this.context=window.loggerContext:(this.context=new l,window.loggerContext=this.context):this.context=new l)}};var h,c,u=s(7);class g extends u.EventEmitter{constructor(){super(),this.WS_OPEN_STATE=1}sendMessage(e){this.webSocket&&this.webSocket.send(JSON.stringify(e))}connect(e){d.Info(e);try{return this.webSocket=new WebSocket(e),this.webSocket.onopen=e=>this.handleOnOpen(),this.webSocket.onerror=e=>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 d.Error(e),!1}}disconnect(e,t){this.webSocket&&this.webSocket.close(e,t)}isConnected(){return!!this.webSocket&&this.webSocket.readyState!=WebSocket.CLOSED}handleOnMessageBinary(e){e&&e.data&&e.data.text().then((e=>{const t=new MessageEvent("messageFromBinary",{data:e});this.handleOnMessage(t)})).catch((e=>{d.Error(`Failed to parse binary blob from websocket, reason: ${e.message}`)}))}handleOnMessage(e){if(e.data&&e.data instanceof Blob)return void this.handleOnMessageBinary(e);let t;d.Info("received => \n"+JSON.stringify(JSON.parse(e.data),void 0,4));try{t=JSON.parse(e.data)}catch(t){return void(t instanceof Error?d.Error(`Error parsing message string ${e.data}.\n${t.message}`):d.Error("Unknown error while parsing message data in handleOnMessage"))}this.onMessage&&this.onMessage(t)}handleOnOpen(){d.Info("Connected to the signalling server via WebSocket"),this.emit("open")}handleOnError(){this.emit("error")}handleOnClose(e){d.Info("Disconnected to the signalling server via WebSocket: "+JSON.stringify(e.code)+" - "+e.reason),this.emit("close",e)}}function m(e,t,n){let s,r,i=n;for(let n of e.fields){let e=n.localName;if(n.oneof){const o=i[n.oneof];if(null==(null==o?void 0:o.oneofKind))continue;if(s=o[e],r=t[n.oneof],r.oneofKind=o.oneofKind,null==s){delete r[e];continue}}else if(s=i[e],r=t,null==s)continue;switch(n.repeat&&(r[e].length=s.length),n.kind){case"scalar":case"enum":if(n.repeat)for(let t=0;t<s.length;t++)r[e][t]=s[t];else r[e]=s;break;case"message":let t=n.T();if(n.repeat)for(let n=0;n<s.length;n++)r[e][n]=t.create(s[n]);else void 0===r[e]?r[e]=t.create(s):t.mergePartial(r[e],s);break;case"map":switch(n.V.kind){case"scalar":case"enum":Object.assign(r[e],s);break;case"message":let t=n.V.T();for(let n of Object.keys(s))r[e][n]=t.create(s[n])}}}}!function(e){e.symbol=Symbol.for("protobuf-ts/unknown"),e.onRead=(n,s,r,i,o)=>{(t(s)?s[e.symbol]:s[e.symbol]=[]).push({no:r,wireType:i,data:o})},e.onWrite=(t,n,s)=>{for(let{no:t,wireType:r,data:i}of e.list(n))s.tag(t,r).raw(i)},e.list=(n,s)=>{if(t(n)){let t=n[e.symbol];return s?t.filter((e=>e.no==s)):t}return[]},e.last=(t,n)=>e.list(t,n).slice(-1)[0];const t=t=>t&&Array.isArray(t[e.symbol])}(h||(h={})),function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(c||(c={}));const p=Symbol.for("protobuf-ts/message-type");function f(e){let t=!1;const n=[];for(let s=0;s<e.length;s++){let r=e.charAt(s);"_"==r?t=!0:/\d/.test(r)?(n.push(r),t=!0):t?(n.push(r.toUpperCase()),t=!1):0==s?n.push(r.toLowerCase()):n.push(r)}return n.join("")}var y,v,w;function S(e){var t,n,s,r;return e.localName=null!==(t=e.localName)&&void 0!==t?t:f(e.name),e.jsonName=null!==(n=e.jsonName)&&void 0!==n?n:f(e.name),e.repeat=null!==(s=e.repeat)&&void 0!==s?s:w.NO,e.opt=null!==(r=e.opt)&&void 0!==r?r:!e.repeat&&!e.oneof&&"message"==e.kind,e}function b(e){if("object"!=typeof e||null===e||!e.hasOwnProperty("oneofKind"))return!1;switch(typeof e.oneofKind){case"string":return void 0!==e[e.oneofKind]&&2==Object.keys(e).length;case"undefined":return 1==Object.keys(e).length;default:return!1}}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(y||(y={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER"}(v||(v={})),function(e){e[e.NO=0]="NO",e[e.PACKED=1]="PACKED",e[e.UNPACKED=2]="UNPACKED"}(w||(w={}));class C{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let s of this.fields)if(s.oneof)n.includes(s.oneof)||(n.push(s.oneof),e.push(s.oneof),t.push(s.oneof));else switch(t.push(s.localName),s.kind){case"scalar":case"enum":s.opt&&!s.repeat||e.push(s.localName);break;case"message":s.repeat&&e.push(s.localName);break;case"map":e.push(s.localName)}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(null==e||"object"!=typeof e)return!1;this.prepare();let s=Object.keys(e),r=this.data;if(s.length<r.req.length||r.req.some((e=>!s.includes(e))))return!1;if(!n&&s.some((e=>!r.known.includes(e))))return!1;if(t<1)return!0;for(const s of r.oneofs){const r=e[s];if(!b(r))return!1;if(void 0===r.oneofKind)continue;const i=this.fields.find((e=>e.localName===r.oneofKind));if(!i)return!1;if(!this.field(r[r.oneofKind],i,n,t))return!1}for(const s of this.fields)if(void 0===s.oneof&&!this.field(e[s.localName],s,n,t))return!1;return!0}field(e,t,n,s){let r=t.repeat;switch(t.kind){case"scalar":return void 0===e?t.opt:r?this.scalars(e,t.T,s,t.L):this.scalar(e,t.T,t.L);case"enum":return void 0===e?t.opt:r?this.scalars(e,y.INT32,s):this.scalar(e,y.INT32);case"message":return void 0===e||(r?this.messages(e,t.T(),n,s):this.message(e,t.T(),n,s));case"map":if("object"!=typeof e||null===e)return!1;if(s<2)return!0;if(!this.mapKeys(e,t.K,s))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,s,t.V.L);case"enum":return this.scalars(Object.values(e),y.INT32,s);case"message":return this.messages(Object.values(e),t.V.T(),n,s)}}return!0}message(e,t,n,s){return n?t.isAssignable(e,s):t.is(e,s)}messages(e,t,n,s){if(!Array.isArray(e))return!1;if(s<2)return!0;if(n){for(let n=0;n<e.length&&n<s;n++)if(!t.isAssignable(e[n],s-1))return!1}else for(let n=0;n<e.length&&n<s;n++)if(!t.is(e[n],s-1))return!1;return!0}scalar(e,t,n){let s=typeof e;switch(t){case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:switch(n){case v.BIGINT:return"bigint"==s;case v.NUMBER:return"number"==s&&!isNaN(e);default:return"string"==s}case y.BOOL:return"boolean"==s;case y.STRING:return"string"==s;case y.BYTES:return e instanceof Uint8Array;case y.DOUBLE:case y.FLOAT:return"number"==s&&!isNaN(e);default:return"number"==s&&Number.isInteger(e)}}scalars(e,t,n,s){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e))for(let r=0;r<e.length&&r<n;r++)if(!this.scalar(e[r],t,s))return!1;return!0}mapKeys(e,t,n){let s=Object.keys(e);switch(t){case y.INT32:case y.FIXED32:case y.SFIXED32:case y.SINT32:case y.UINT32:return this.scalars(s.slice(0,n).map((e=>parseInt(e))),t,n);case y.BOOL:return this.scalars(s.slice(0,n).map((e=>"true"==e||"false"!=e&&e)),t,n);default:return this.scalars(s,t,n,v.STRING)}}}function T(e){let t=typeof e;if("object"==t){if(Array.isArray(e))return"array";if(null===e)return"null"}return t}let E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),M=[];for(let e=0;e<E.length;e++)M[E[e].charCodeAt(0)]=e;function k(){let e=0,t=0;for(let n=0;n<28;n+=7){let s=this.buf[this.pos++];if(e|=(127&s)<<n,!(128&s))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let s=this.buf[this.pos++];if(t|=(127&s)<<n,!(128&s))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function R(e,t,n){for(let s=0;s<28;s+=7){const r=e>>>s,i=!(r>>>7==0&&0==t),o=255&(i?128|r:r);if(n.push(o),!i)return}const s=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|s:s)),r){for(let e=3;e<31;e+=7){const s=t>>>e,r=!(s>>>7==0),i=255&(r?128|s:s);if(n.push(i),!r)return}n.push(t>>>31&1)}}M["-".charCodeAt(0)]=E.indexOf("+"),M["_".charCodeAt(0)]=E.indexOf("/");const P=4294967296;function I(e){let t="-"==e[0];t&&(e=e.slice(1));const n=1e6;let s=0,r=0;function i(t,i){const o=Number(e.slice(t,i));r*=n,s=s*n+o,s>=P&&(r+=s/P|0,s%=P)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),[t,s,r]}function L(e,t){if(t>>>0<=2097151)return""+(P*t+(e>>>0));let n=(e>>>24|t<<8)>>>0&16777215,s=t>>16&65535,r=(16777215&e)+6777216*n+6710656*s,i=n+8147497*s,o=2*s,a=1e7;function l(e,t){let n=e?String(e):"";return t?"0000000".slice(n.length)+n:n}return r>=a&&(i+=Math.floor(r/a),r%=a),i>=a&&(o+=Math.floor(i/a),i%=a),l(o,0)+l(i,o)+l(r,1)}function x(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function F(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}let O;function D(e){if(!e)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}!function(){const e=new DataView(new ArrayBuffer(8)),t=void 0!==globalThis.BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64;O=t?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:e}:void 0}();const A=/^-?[0-9]+$/,N=4294967296,B=2147483648;class U{constructor(e,t){this.lo=0|e,this.hi=0|t}isZero(){return 0==this.lo&&0==this.hi}toNumber(){let e=this.hi*N+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class V extends U{static from(e){if(O)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=O.C(e);case"number":if(0===e)return this.ZERO;e=O.C(e);case"bigint":if(!e)return this.ZERO;if(e<O.UMIN)throw new Error("signed value for ulong");if(e>O.UMAX)throw new Error("ulong too large");return O.V.setBigUint64(0,e,!0),new V(O.V.getInt32(0,!0),O.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!A.test(e))throw new Error("string is no integer");let[t,n,s]=I(e);if(t)throw new Error("signed value for ulong");return new V(n,s);case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new V(e,e/N)}throw new Error("unknown value "+typeof e)}toString(){return O?this.toBigInt().toString():L(this.lo,this.hi)}toBigInt(){return D(O),O.V.setInt32(0,this.lo,!0),O.V.setInt32(4,this.hi,!0),O.V.getBigUint64(0,!0)}}V.ZERO=new V(0,0);class W extends U{static from(e){if(O)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=O.C(e);case"number":if(0===e)return this.ZERO;e=O.C(e);case"bigint":if(!e)return this.ZERO;if(e<O.MIN)throw new Error("signed long too small");if(e>O.MAX)throw new Error("signed long too large");return O.V.setBigInt64(0,e,!0),new W(O.V.getInt32(0,!0),O.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!A.test(e))throw new Error("string is no integer");let[t,n,s]=I(e);if(t){if(s>B||s==B&&0!=n)throw new Error("signed long too small")}else if(s>=B)throw new Error("signed long too large");let r=new W(n,s);return t?r.negate():r;case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new W(e,e/N):new W(-e,-e/N).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return!!(this.hi&B)}negate(){let e=~this.hi,t=this.lo;return t?t=1+~t:e+=1,new W(t,e)}toString(){if(O)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+L(e.lo,e.hi)}return L(this.lo,this.hi)}toBigInt(){return D(O),O.V.setInt32(0,this.lo,!0),O.V.setInt32(4,this.hi,!0),O.V.getBigInt64(0,!0)}}function _(e,t){if(!e)throw new Error(t)}function H(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function $(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function j(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}function z(e,t){switch(t){case v.BIGINT:return e.toBigInt();case v.NUMBER:return e.toNumber();default:return e.toString()}}W.ZERO=new W(0,0);class K{constructor(e){this.info=e}prepare(){var e;if(void 0===this.fMap){this.fMap={};const t=null!==(e=this.info.fields)&&void 0!==e?e:[];for(const e of t)this.fMap[e.name]=e,this.fMap[e.jsonName]=e,this.fMap[e.localName]=e}}assert(e,t,n){if(!e){let e=T(n);throw"number"!=e&&"boolean"!=e||(e=n.toString()),new Error(`Cannot parse JSON ${e} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const s=[];for(const[i,o]of Object.entries(e)){const e=this.fMap[i];if(!e){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${i}`);continue}const a=e.localName;let l;if(e.oneof){if(null===o&&("enum"!==e.kind||"google.protobuf.NullValue"!==e.T()[0]))continue;if(s.includes(e.oneof))throw new Error(`Multiple members of the oneof group "${e.oneof}" of ${this.info.typeName} are present in JSON.`);s.push(e.oneof),l=t[e.oneof]={oneofKind:a}}else l=t;if("map"==e.kind){if(null===o)continue;this.assert(null!==(r=o)&&"object"==typeof r&&!Array.isArray(r),e.name,o);const t=l[a];for(const[s,r]of Object.entries(o)){let i;switch(this.assert(null!==r,e.name+" map value",null),e.V.kind){case"message":i=e.V.T().internalJsonRead(r,n);break;case"enum":if(i=this.enum(e.V.T(),r,e.name,n.ignoreUnknownFields),!1===i)continue;break;case"scalar":i=this.scalar(r,e.V.T,e.V.L,e.name)}this.assert(void 0!==i,e.name+" map value",r);let o=s;e.K==y.BOOL&&(o="true"==o||"false"!=o&&o),o=this.scalar(o,e.K,v.STRING,e.name).toString(),t[o]=i}}else if(e.repeat){if(null===o)continue;this.assert(Array.isArray(o),e.name,o);const t=l[a];for(const s of o){let r;switch(this.assert(null!==s,e.name,null),e.kind){case"message":r=e.T().internalJsonRead(s,n);break;case"enum":if(r=this.enum(e.T(),s,e.name,n.ignoreUnknownFields),!1===r)continue;break;case"scalar":r=this.scalar(s,e.T,e.L,e.name)}this.assert(void 0!==r,e.name,o),t.push(r)}}else switch(e.kind){case"message":if(null===o&&"google.protobuf.Value"!=e.T().typeName){this.assert(void 0===e.oneof,e.name+" (oneof member)",null);continue}l[a]=e.T().internalJsonRead(o,n,l[a]);break;case"enum":let t=this.enum(e.T(),o,e.name,n.ignoreUnknownFields);if(!1===t)continue;l[a]=t;break;case"scalar":l[a]=this.scalar(o,e.T,e.L,e.name)}}var r}enum(e,t,n,s){if("google.protobuf.NullValue"==e[0]&&_(null===t||"NULL_VALUE"===t,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),null===t)return 0;switch(typeof t){case"number":return _(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let r=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(r=t.substring(e[2].length));let i=e[1][r];return(void 0!==i||!s)&&(_("number"==typeof i,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),i)}_(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,s){let r;try{switch(t){case y.DOUBLE:case y.FLOAT:if(null===e)return 0;if("NaN"===e)return Number.NaN;if("Infinity"===e)return Number.POSITIVE_INFINITY;if("-Infinity"===e)return Number.NEGATIVE_INFINITY;if(""===e){r="empty string";break}if("string"==typeof e&&e.trim().length!==e.length){r="extra whitespace";break}if("string"!=typeof e&&"number"!=typeof e)break;let s=Number(e);if(Number.isNaN(s)){r="not a number";break}if(!Number.isFinite(s)){r="too large or small";break}return t==y.FLOAT&&j(s),s;case y.INT32:case y.FIXED32:case y.SFIXED32:case y.SINT32:case y.UINT32:if(null===e)return 0;let i;if("number"==typeof e?i=e:""===e?r="empty string":"string"==typeof e&&(e.trim().length!==e.length?r="extra whitespace":i=Number(e)),void 0===i)break;return t==y.UINT32?$(i):H(i),i;case y.INT64:case y.SFIXED64:case y.SINT64:if(null===e)return z(W.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return z(W.from(e),n);case y.FIXED64:case y.UINT64:if(null===e)return z(V.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return z(V.from(e),n);case y.BOOL:if(null===e)return!1;if("boolean"!=typeof e)break;return e;case y.STRING:if(null===e)return"";if("string"!=typeof e){r="extra whitespace";break}try{encodeURIComponent(e)}catch(r){r="invalid UTF8";break}return e;case y.BYTES:if(null===e||""===e)return new Uint8Array(0);if("string"!=typeof e)break;return function(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,s=new Uint8Array(t),r=0,i=0,o=0;for(let t=0;t<e.length;t++){if(n=M[e.charCodeAt(t)],void 0===n)switch(e[t]){case"=":i=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=n,i=1;break;case 1:s[r++]=o<<2|(48&n)>>4,o=n,i=2;break;case 2:s[r++]=(15&o)<<4|(60&n)>>2,o=n,i=3;break;case 3:s[r++]=(3&o)<<6|n,i=0}}if(1==i)throw Error("invalid base64 string.");return s.subarray(0,r)}(e)}}catch(e){r=e.message}this.assert(!1,s+(r?" - "+r:""),e)}}class G{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}write(e,t){const n={},s=e;for(const e of this.fields){if(!e.oneof){let r=this.field(e,s[e.localName],t);void 0!==r&&(n[t.useProtoFieldName?e.name:e.jsonName]=r);continue}const r=s[e.oneof];if(r.oneofKind!==e.localName)continue;const i="scalar"==e.kind||"enum"==e.kind?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let o=this.field(e,r[e.localName],i);_(void 0!==o),n[t.useProtoFieldName?e.name:e.jsonName]=o}return n}field(e,t,n){let s;if("map"==e.kind){_("object"==typeof t&&null!==t);const r={};switch(e.V.kind){case"scalar":for(const[n,s]of Object.entries(t)){const t=this.scalar(e.V.T,s,e.name,!1,!0);_(void 0!==t),r[n.toString()]=t}break;case"message":const s=e.V.T();for(const[i,o]of Object.entries(t)){const t=this.message(s,o,e.name,n);_(void 0!==t),r[i.toString()]=t}break;case"enum":const i=e.V.T();for(const[s,o]of Object.entries(t)){_(void 0===o||"number"==typeof o);const t=this.enum(i,o,e.name,!1,!0,n.enumAsInteger);_(void 0!==t),r[s.toString()]=t}}(n.emitDefaultValues||Object.keys(r).length>0)&&(s=r)}else if(e.repeat){_(Array.isArray(t));const r=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++){const s=this.scalar(e.T,t[n],e.name,e.opt,!0);_(void 0!==s),r.push(s)}break;case"enum":const s=e.T();for(let i=0;i<t.length;i++){_(void 0===t[i]||"number"==typeof t[i]);const o=this.enum(s,t[i],e.name,e.opt,!0,n.enumAsInteger);_(void 0!==o),r.push(o)}break;case"message":const i=e.T();for(let s=0;s<t.length;s++){const o=this.message(i,t[s],e.name,n);_(void 0!==o),r.push(o)}}(n.emitDefaultValues||r.length>0||n.emitDefaultValues)&&(s=r)}else switch(e.kind){case"scalar":s=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":s=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":s=this.message(e.T(),t,e.name,n)}return s}enum(e,t,n,s,r,i){if("google.protobuf.NullValue"==e[0])return r||s?null:void 0;if(void 0!==t){if(0!==t||r||s)return _("number"==typeof t),_(Number.isInteger(t)),i||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}else _(s)}message(e,t,n,s){return void 0===t?s.emitDefaultValues?null:void 0:e.internalJsonWrite(t,s)}scalar(e,t,n,s,r){if(void 0===t)return void _(s);const i=r||s;switch(e){case y.INT32:case y.SFIXED32:case y.SINT32:return 0===t?i?0:void 0:(H(t),t);case y.FIXED32:case y.UINT32:return 0===t?i?0:void 0:($(t),t);case y.FLOAT:j(t);case y.DOUBLE:return 0===t?i?0:void 0:(_("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case y.STRING:return""===t?i?"":void 0:(_("string"==typeof t),t);case y.BOOL:return!1===t?!i&&void 0:(_("boolean"==typeof t),t);case y.UINT64:case y.FIXED64:_("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let e=V.from(t);if(e.isZero()&&!i)return;return e.toString();case y.INT64:case y.SFIXED64:case y.SINT64:_("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let n=W.from(t);if(n.isZero()&&!i)return;return n.toString();case y.BYTES:return _(t instanceof Uint8Array),t.byteLength?function(e){let t,n="",s=0,r=0;for(let i=0;i<e.length;i++)switch(t=e[i],s){case 0:n+=E[t>>2],r=(3&t)<<4,s=1;break;case 1:n+=E[r|t>>4],r=(15&t)<<2,s=2;break;case 2:n+=E[r|t>>6],n+=E[63&t],s=0}return s&&(n+=E[r],n+="=",1==s&&(n+="=")),n}(t):i?"":void 0}}}function X(e,t=v.STRING){switch(e){case y.BOOL:return!1;case y.UINT64:case y.FIXED64:return z(V.ZERO,t);case y.INT64:case y.SFIXED64:case y.SINT64:return z(W.ZERO,t);case y.DOUBLE:case y.FLOAT:return 0;case y.BYTES:return new Uint8Array(0);case y.STRING:return"";default:return 0}}class q{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=null!==(e=this.info.fields)&&void 0!==e?e:[];this.fieldNoToField=new Map(t.map((e=>[e.no,e])))}}read(e,t,n,s){this.prepare();const r=void 0===s?e.len:e.pos+s;for(;e.pos<r;){const[s,r]=e.tag(),i=this.fieldNoToField.get(s);if(!i){let i=n.readUnknownField;if("throw"==i)throw new Error(`Unknown field ${s} (wire type ${r}) for ${this.info.typeName}`);let o=e.skip(r);!1!==i&&(!0===i?h.onRead:i)(this.info.typeName,t,s,r,o);continue}let o=t,a=i.repeat,l=i.localName;switch(i.oneof&&(o=o[i.oneof],o.oneofKind!==l&&(o=t[i.oneof]={oneofKind:l})),i.kind){case"scalar":case"enum":let t="enum"==i.kind?y.INT32:i.T,s="scalar"==i.kind?i.L:void 0;if(a){let n=o[l];if(r==c.LengthDelimited&&t!=y.STRING&&t!=y.BYTES){let r=e.uint32()+e.pos;for(;e.pos<r;)n.push(this.scalar(e,t,s))}else n.push(this.scalar(e,t,s))}else o[l]=this.scalar(e,t,s);break;case"message":if(a){let t=o[l],s=i.T().internalBinaryRead(e,e.uint32(),n);t.push(s)}else o[l]=i.T().internalBinaryRead(e,e.uint32(),n,o[l]);break;case"map":let[d,h]=this.mapEntry(i,e,n);o[l][d]=h}}}mapEntry(e,t,n){let s,r,i=t.uint32(),o=t.pos+i;for(;t.pos<o;){let[i,o]=t.tag();switch(i){case 1:s=e.K==y.BOOL?t.bool().toString():this.scalar(t,e.K,v.STRING);break;case 2:switch(e.V.kind){case"scalar":r=this.scalar(t,e.V.T,e.V.L);break;case"enum":r=t.int32();break;case"message":r=e.V.T().internalBinaryRead(t,t.uint32(),n)}break;default:throw new Error(`Unknown field ${i} (wire type ${o}) in map entry for ${this.info.typeName}#${e.name}`)}}if(void 0===s){let t=X(e.K);s=e.K==y.BOOL?t.toString():t}if(void 0===r)switch(e.V.kind){case"scalar":r=X(e.V.T,e.V.L);break;case"enum":r=0;break;case"message":r=e.V.T().create()}return[s,r]}scalar(e,t,n){switch(t){case y.INT32:return e.int32();case y.STRING:return e.string();case y.BOOL:return e.bool();case y.DOUBLE:return e.double();case y.FLOAT:return e.float();case y.INT64:return z(e.int64(),n);case y.UINT64:return z(e.uint64(),n);case y.FIXED64:return z(e.fixed64(),n);case y.FIXED32:return e.fixed32();case y.BYTES:return e.bytes();case y.UINT32:return e.uint32();case y.SFIXED32:return e.sfixed32();case y.SFIXED64:return z(e.sfixed64(),n);case y.SINT32:return e.sint32();case y.SINT64:return z(e.sint64(),n)}}}class Q{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort(((e,t)=>e.no-t.no))}}write(e,t,n){this.prepare();for(const s of this.fields){let r,i,o=s.repeat,a=s.localName;if(s.oneof){const t=e[s.oneof];if(t.oneofKind!==a)continue;r=t[a],i=!0}else r=e[a],i=!1;switch(s.kind){case"scalar":case"enum":let e="enum"==s.kind?y.INT32:s.T;if(o)if(_(Array.isArray(r)),o==w.PACKED)this.packed(t,e,s.no,r);else for(const n of r)this.scalar(t,e,s.no,n,!0);else void 0===r?_(s.opt):this.scalar(t,e,s.no,r,i||s.opt);break;case"message":if(o){_(Array.isArray(r));for(const e of r)this.message(t,n,s.T(),s.no,e)}else this.message(t,n,s.T(),s.no,r);break;case"map":_("object"==typeof r&&null!==r);for(const[e,i]of Object.entries(r))this.mapEntry(t,n,s,e,i)}}let s=n.writeUnknownFields;!1!==s&&(!0===s?h.onWrite:s)(this.info.typeName,e,t)}mapEntry(e,t,n,s,r){e.tag(n.no,c.LengthDelimited),e.fork();let i=s;switch(n.K){case y.INT32:case y.FIXED32:case y.UINT32:case y.SFIXED32:case y.SINT32:i=Number.parseInt(s);break;case y.BOOL:_("true"==s||"false"==s),i="true"==s}switch(this.scalar(e,n.K,1,i,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,r,!0);break;case"enum":this.scalar(e,y.INT32,2,r,!0);break;case"message":this.message(e,t,n.V.T(),2,r)}e.join()}message(e,t,n,s,r){void 0!==r&&(n.internalBinaryWrite(r,e.tag(s,c.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,s,r){let[i,o,a]=this.scalarInfo(t,s);a&&!r||(e.tag(n,i),e[o](s))}packed(e,t,n,s){if(!s.length)return;_(t!==y.BYTES&&t!==y.STRING),e.tag(n,c.LengthDelimited),e.fork();let[,r]=this.scalarInfo(t);for(let t=0;t<s.length;t++)e[r](s[t]);e.join()}scalarInfo(e,t){let n,s=c.Varint,r=void 0===t,i=0===t;switch(e){case y.INT32:n="int32";break;case y.STRING:i=r||!t.length,s=c.LengthDelimited,n="string";break;case y.BOOL:i=!1===t,n="bool";break;case y.UINT32:n="uint32";break;case y.DOUBLE:s=c.Bit64,n="double";break;case y.FLOAT:s=c.Bit32,n="float";break;case y.INT64:i=r||W.from(t).isZero(),n="int64";break;case y.UINT64:i=r||V.from(t).isZero(),n="uint64";break;case y.FIXED64:i=r||V.from(t).isZero(),s=c.Bit64,n="fixed64";break;case y.BYTES:i=r||!t.byteLength,s=c.LengthDelimited,n="bytes";break;case y.FIXED32:s=c.Bit32,n="fixed32";break;case y.SFIXED32:s=c.Bit32,n="sfixed32";break;case y.SFIXED64:i=r||W.from(t).isZero(),s=c.Bit64,n="sfixed64";break;case y.SINT32:n="sint32";break;case y.SINT64:i=r||W.from(t).isZero(),n="sint64"}return[s,n,r||i]}}const J={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Y={ignoreUnknownFields:!1},Z=Object.values;function ee(e,t,n){if(t===n)return!0;if(e!==y.BYTES)return!1;let s=t,r=n;if(s.length!==r.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!=r[e])return!1;return!0}function te(e,t,n){if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(!ee(e,t[s],n[s]))return!1;return!0}function ne(e,t,n){if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(!e.equals(t[s],n[s]))return!1;return!0}const se={writeUnknownFields:!0,writerFactory:()=>new re};class re{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for($(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return H(e),x(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){j(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){$(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){H(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return H(e),x(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),s=W.from(e);return n.setInt32(0,s.lo,!0),n.setInt32(4,s.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),s=V.from(e);return n.setInt32(0,s.lo,!0),n.setInt32(4,s.hi,!0),this.raw(t)}int64(e){let t=W.from(e);return R(t.lo,t.hi,this.buf),this}sint64(e){let t=W.from(e),n=t.hi>>31;return R(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=V.from(e);return R(t.lo,t.hi,this.buf),this}}const ie={readUnknownField:!0,readerFactory:e=>new oe(e)};class oe{constructor(e,t){this.varint64=k,this.uint32=F,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case c.Varint:for(;128&this.buf[this.pos++];);break;case c.Bit64:this.pos+=4;case c.Bit32:this.pos+=4;break;case c.LengthDelimited:let t=this.uint32();this.pos+=t;break;case c.StartGroup:let n;for(;(n=this.tag()[1])!==c.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return new W(...this.varint64())}uint64(){return new V(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,new W(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new V(this.sfixed32(),this.sfixed32())}sfixed64(){return new W(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}const ae=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class le{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(S),this.options=null!=n?n:{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},ae),{[p]:{value:this}})),this.refTypeCheck=new C(this),this.refJsonReader=new K(this),this.refJsonWriter=new G(this),this.refBinReader=new q(this),this.refBinWriter=new Q(this)}create(e){let t=function(e){const t=e.messagePrototype?Object.create(e.messagePrototype):Object.defineProperty({},p,{value:e});for(let n of e.fields){let e=n.localName;if(!n.opt)if(n.oneof)t[n.oneof]={oneofKind:void 0};else if(n.repeat)t[e]=[];else switch(n.kind){case"scalar":t[e]=X(n.T,n.L);break;case"enum":t[e]=0;break;case"map":t[e]={}}}return t}(this);return void 0!==e&&m(this,t,e),t}clone(e){let t=this.create();return m(this,t,e),t}equals(e,t){return function(e,t,n){if(t===n)return!0;if(!t||!n)return!1;for(let s of e.fields){let e=s.localName,r=s.oneof?t[s.oneof][e]:t[e],i=s.oneof?n[s.oneof][e]:n[e];switch(s.kind){case"enum":case"scalar":let e="enum"==s.kind?y.INT32:s.T;if(!(s.repeat?te(e,r,i):ee(e,r,i)))return!1;break;case"map":if(!("message"==s.V.kind?ne(s.V.T(),Z(r),Z(i)):te("enum"==s.V.kind?y.INT32:s.V.T,Z(r),Z(i))))return!1;break;case"message":let t=s.T();if(!(s.repeat?ne(t,r,i):t.equals(r,i)))return!1}}return!0}(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){m(this,e,t)}fromBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},ie),e):ie}(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,function(e){return e?Object.assign(Object.assign({},Y),e):Y}(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,function(e){return e?Object.assign(Object.assign({},J),e):J}(t))}toJsonString(e,t){var n;let s=this.toJson(e,t);return JSON.stringify(s,null,null!==(n=null==t?void 0:t.prettySpaces)&&void 0!==n?n:0)}toBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},se),e):se}(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(null!==e&&"object"==typeof e&&!Array.isArray(e)){let s=null!=n?n:this.create();return this.refJsonReader.read(e,s,t),s}throw new Error(`Unable to parse message ${this.typeName} from JSON ${T(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create();return this.refBinReader.read(e,r,n,t),r}}const de=new class extends le{constructor(){super("base_message",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},he=new class extends le{constructor(){super("peerConnectionOptions",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){return null!=s?s:this.create()}internalBinaryWrite(e,t,n){let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ce=new class extends le{constructor(){super("config",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"peerConnectionOptions",kind:"message",T:()=>he},{no:3,name:"protocolVersion",kind:"scalar",opt:!0,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.peerConnectionOptions=he.internalBinaryRead(e,e.uint32(),n,r.peerConnectionOptions);break;case 3:r.protocolVersion=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),e.peerConnectionOptions&&he.internalBinaryWrite(e.peerConnectionOptions,t.tag(2,c.LengthDelimited).fork(),n).join(),void 0!==e.protocolVersion&&t.tag(3,c.LengthDelimited).string(e.protocolVersion);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ue=new class extends le{constructor(){super("identify",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ge=new class extends le{constructor(){super("endpointId",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"protocolVersion",kind:"scalar",opt:!0,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.id="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.id=e.string();break;case 3:r.protocolVersion=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.id&&t.tag(2,c.LengthDelimited).string(e.id),void 0!==e.protocolVersion&&t.tag(3,c.LengthDelimited).string(e.protocolVersion);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},me=new class extends le{constructor(){super("endpointIdConfirm",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"committedId",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.committedId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.committedId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.committedId&&t.tag(2,c.LengthDelimited).string(e.committedId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},pe=new class extends le{constructor(){super("streamerIdChanged",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"newID",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.newID="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.newID=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.newID&&t.tag(2,c.LengthDelimited).string(e.newID);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},fe=new class extends le{constructor(){super("listStreamers",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ye=new class extends le{constructor(){super("streamerList",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"ids",kind:"scalar",repeat:2,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.ids=[],void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.ids.push(e.string());break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);for(let n=0;n<e.ids.length;n++)t.tag(2,c.LengthDelimited).string(e.ids[n]);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ve=new class extends le{constructor(){super("subscribe",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"streamerId",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.streamerId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.streamerId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.streamerId&&t.tag(2,c.LengthDelimited).string(e.streamerId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},we=new class extends le{constructor(){super("unsubscribe",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Se=new class extends le{constructor(){super("playerConnected",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"dataChannel",kind:"scalar",T:8},{no:3,name:"sfu",kind:"scalar",T:8},{no:5,name:"playerId",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.dataChannel=!1,t.sfu=!1,t.playerId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.dataChannel=e.bool();break;case 3:r.sfu=e.bool();break;case 5:r.playerId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),!1!==e.dataChannel&&t.tag(2,c.Varint).bool(e.dataChannel),!1!==e.sfu&&t.tag(3,c.Varint).bool(e.sfu),""!==e.playerId&&t.tag(5,c.LengthDelimited).string(e.playerId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},be=new class extends le{constructor(){super("playerDisconnected",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"playerId",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.playerId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.playerId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.playerId&&t.tag(2,c.LengthDelimited).string(e.playerId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ce=new class extends le{constructor(){super("offer",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"playerId",kind:"scalar",opt:!0,T:9},{no:4,name:"sfu",kind:"scalar",opt:!0,T:8},{no:5,name:"multiplex",kind:"scalar",opt:!0,T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.sdp="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.sdp=e.string();break;case 3:r.playerId=e.string();break;case 4:r.sfu=e.bool();break;case 5:r.multiplex=e.bool();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.sdp&&t.tag(2,c.LengthDelimited).string(e.sdp),void 0!==e.playerId&&t.tag(3,c.LengthDelimited).string(e.playerId),void 0!==e.sfu&&t.tag(4,c.Varint).bool(e.sfu),void 0!==e.multiplex&&t.tag(5,c.Varint).bool(e.multiplex);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Te=new class extends le{constructor(){super("answer",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"playerId",kind:"scalar",opt:!0,T:9},{no:4,name:"minBitrateBps",kind:"scalar",opt:!0,T:5},{no:5,name:"maxBitrateBps",kind:"scalar",opt:!0,T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.sdp="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.sdp=e.string();break;case 3:r.playerId=e.string();break;case 4:r.minBitrateBps=e.int32();break;case 5:r.maxBitrateBps=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.sdp&&t.tag(2,c.LengthDelimited).string(e.sdp),void 0!==e.playerId&&t.tag(3,c.LengthDelimited).string(e.playerId),void 0!==e.minBitrateBps&&t.tag(4,c.Varint).int32(e.minBitrateBps),void 0!==e.maxBitrateBps&&t.tag(5,c.Varint).int32(e.maxBitrateBps);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ee=new class extends le{constructor(){super("iceCandidateData",[{no:1,name:"candidate",kind:"scalar",T:9},{no:2,name:"sdpMid",kind:"scalar",T:9},{no:3,name:"sdpMLineIndex",kind:"scalar",T:5},{no:4,name:"usernameFragment",kind:"scalar",opt:!0,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.candidate="",t.sdpMid="",t.sdpMLineIndex=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.candidate=e.string();break;case 2:r.sdpMid=e.string();break;case 3:r.sdpMLineIndex=e.int32();break;case 4:r.usernameFragment=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.candidate&&t.tag(1,c.LengthDelimited).string(e.candidate),""!==e.sdpMid&&t.tag(2,c.LengthDelimited).string(e.sdpMid),0!==e.sdpMLineIndex&&t.tag(3,c.Varint).int32(e.sdpMLineIndex),void 0!==e.usernameFragment&&t.tag(4,c.LengthDelimited).string(e.usernameFragment);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Me=new class extends le{constructor(){super("iceCandidate",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"candidate",kind:"message",T:()=>Ee},{no:3,name:"playerId",kind:"scalar",opt:!0,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.candidate=Ee.internalBinaryRead(e,e.uint32(),n,r.candidate);break;case 3:r.playerId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),e.candidate&&Ee.internalBinaryWrite(e.candidate,t.tag(2,c.LengthDelimited).fork(),n).join(),void 0!==e.playerId&&t.tag(3,c.LengthDelimited).string(e.playerId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},ke=new class extends le{constructor(){super("disconnectPlayer",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"playerId",kind:"scalar",T:9},{no:3,name:"reason",kind:"scalar",opt:!0,T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.playerId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.playerId=e.string();break;case 3:r.reason=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.playerId&&t.tag(2,c.LengthDelimited).string(e.playerId),void 0!==e.reason&&t.tag(3,c.LengthDelimited).string(e.reason);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Re=new class extends le{constructor(){super("ping",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"time",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.time=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.time=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),0!==e.time&&t.tag(2,c.Varint).int32(e.time);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Pe=new class extends le{constructor(){super("pong",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"time",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.time=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.time=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),0!==e.time&&t.tag(2,c.Varint).int32(e.time);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ie=new class extends le{constructor(){super("streamerDisconnected",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Le=new class extends le{constructor(){super("layerPreference",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"spatialLayer",kind:"scalar",T:5},{no:3,name:"temporalLayer",kind:"scalar",T:5},{no:4,name:"playerId",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.spatialLayer=0,t.temporalLayer=0,t.playerId="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.spatialLayer=e.int32();break;case 3:r.temporalLayer=e.int32();break;case 4:r.playerId=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),0!==e.spatialLayer&&t.tag(2,c.Varint).int32(e.spatialLayer),0!==e.temporalLayer&&t.tag(3,c.Varint).int32(e.temporalLayer),""!==e.playerId&&t.tag(4,c.LengthDelimited).string(e.playerId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},xe=new class extends le{constructor(){super("dataChannelRequest",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Fe=new class extends le{constructor(){super("peerDataChannels",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"playerId",kind:"scalar",T:9},{no:3,name:"sendStreamId",kind:"scalar",T:5},{no:4,name:"recvStreamId",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.playerId="",t.sendStreamId=0,t.recvStreamId=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.playerId=e.string();break;case 3:r.sendStreamId=e.int32();break;case 4:r.recvStreamId=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.playerId&&t.tag(2,c.LengthDelimited).string(e.playerId),0!==e.sendStreamId&&t.tag(3,c.Varint).int32(e.sendStreamId),0!==e.recvStreamId&&t.tag(4,c.Varint).int32(e.recvStreamId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Oe=new class extends le{constructor(){super("peerDataChannelsReady",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},De=new class extends le{constructor(){super("streamerDataChannels",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sfuId",kind:"scalar",T:9},{no:3,name:"sendStreamId",kind:"scalar",T:5},{no:4,name:"recvStreamId",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.sfuId="",t.sendStreamId=0,t.recvStreamId=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.sfuId=e.string();break;case 3:r.sendStreamId=e.int32();break;case 4:r.recvStreamId=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.sfuId&&t.tag(2,c.LengthDelimited).string(e.sfuId),0!==e.sendStreamId&&t.tag(3,c.Varint).int32(e.sendStreamId),0!==e.recvStreamId&&t.tag(4,c.Varint).int32(e.recvStreamId);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ae=new class extends le{constructor(){super("startStreaming",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ne=new class extends le{constructor(){super("stopStreaming",[{no:1,name:"type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();if(1===t)r.type=e.string();else{let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Be=new class extends le{constructor(){super("playerCount",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"count",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.count=0,void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.count=e.int32();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),0!==e.count&&t.tag(2,c.Varint).int32(e.count);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ue=new class extends le{constructor(){super("stats",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"data",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.type="",t.data="",void 0!==e&&m(this,t,e),t}internalBinaryRead(e,t,n,s){let r=null!=s?s:this.create(),i=e.pos+t;for(;e.pos<i;){let[t,s]=e.tag();switch(t){case 1:r.type=e.string();break;case 2:r.data=e.string();break;default:let i=n.readUnknownField;if("throw"===i)throw new globalThis.Error(`Unknown field ${t} (wire type ${s}) for ${this.typeName}`);let o=e.skip(s);!1!==i&&(!0===i?h.onRead:i)(this.typeName,r,t,s,o)}}return r}internalBinaryWrite(e,t,n){""!==e.type&&t.tag(1,c.LengthDelimited).string(e.type),""!==e.data&&t.tag(2,c.LengthDelimited).string(e.data);let s=n.writeUnknownFields;return!1!==s&&(1==s?h.onWrite:s)(this.typeName,e,t),t}},Ve={answer:Te,config:ce,disconnectPlayer:ke,endpointId:ge,endpointIdConfirm:me,iceCandidate:Me,identify:ue,listStreamers:fe,offer:Ce,ping:Re,playerConnected:Se,playerCount:Be,playerDisconnected:be,pong:Pe,stats:Ue,streamerDisconnected:Ie,streamerList:ye,subscribe:ve,unsubscribe:we,layerPreference:Le,dataChannelRequest:xe,peerDataChannels:Fe,peerDataChannelsReady:Oe,streamerDataChannels:De,startStreaming:Ae,stopStreaming:Ne};function We(e,t){const n=e.create();return n.type=e.typeName,t&&e.mergePartial(n,t),n}function _e(e){let t=!0;if(!e.type)return d.Error(`Parsed message has no type. Rejected. ${JSON.stringify(e)}`),null;const n=Ve[e.type];if(!n)return d.Error(`Message is of an unknown type: "${e.type}". Rejected.`),null;if(n.fields)for(const s of n.fields)s.opt||Object.prototype.hasOwnProperty.call(e,s.name)||(d.Error(`Message "${e.type}"" is missing required field "${s.name}". Rejected.`),t=!1);for(const s in e)n.fields.find((e=>e.name===s))||(d.Error(`Message "${e.type}" contains unknown field "${s}". Rejected.`),t=!1);return t?n:null}class He extends u.EventEmitter{static get SIGNALLING_VERSION(){return"1.2.1"}constructor(e){super(),this.transport=e,e.onMessage=t=>{if(t.type==Re.typeName){const t=We(Pe,{time:(new Date).getTime()});e.sendMessage(t)}e.emit("message",t),this.emit(t.type,t)}}connect(e){return this.transport.connect(e)}disconnect(e,t){this.transport.disconnect(e,t)}isConnected(){return this.transport.isConnected()}sendMessage(e){this.transport.sendMessage(e),this.transport.emit("out",e)}}class $e{constructor(e){this.videoElementProvider=e,this.audioElement=document.createElement("Audio"),this.videoElementProvider.setAudioElement(this.audioElement)}handleOnTrack(e){if(d.Info("handleOnTrack "+JSON.stringify(e.streams)),e.streams.length<1||"probator"==e.streams[0].id)return;const t=this.videoElementProvider.getVideoElement();if(e.track&&d.Info("Got track - "+e.track.kind+" id="+e.track.id+" readyState="+e.track.readyState),"audio"!=e.track.kind)return"video"==e.track.kind&&t.srcObject!==e.streams[0]?(t.srcObject=e.streams[0],void d.Info("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,d.Info("Created new audio element to play separate audio stream."))}}class je{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,s=0;const r=this.rootDiv.clientWidth/this.rootDiv.clientHeight,i=this.freezeFrameWidth/this.freezeFrameHeight;r<i?(e=this.rootDiv.clientWidth,t=Math.floor(this.rootDiv.clientWidth/i),n=Math.floor(.5*(this.rootDiv.clientHeight-t)),s=0):(e=Math.floor(this.rootDiv.clientHeight*i),t=this.rootDiv.clientHeight,n=0,s=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=s+"px",this.imageElement.style.top=n+"px"}}}class ze{constructor(e){this.receiving=!1,this.size=0,this.jpeg=void 0,this.valid=!1,this.freezeFrameDelay=50,this.freezeFrame=new je(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,d.Info(`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`);this.jpeg.length===this.size?(this.receiving=!1,this.valid=!0,d.Info(`received complete freeze frame ${this.size}`),this.updateFreezeFrameAndShow(this.jpeg,t)):this.jpeg.length>this.size&&(d.Error(`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`),this.jpeg=void 0,this.receiving=!1)}}class Ke{constructor(e,t,n,s,r=()=>{}){this.parseURLParams(),this.onChange=r,this.onChangeEmit=()=>{},this.id=e,this.description=n,this.label=t,this.value=s}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)}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search),t=this.getValueAsString();let n=!1;for(const[s,r]of e)if(s.toLowerCase()==this.id.toLowerCase()){e.set(s,t),n=!0;break}n||e.set(this.id,t),window.history.replaceState({},"",""!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}getValueAsString(){return""}parseURLParams(){this._urlParams={};const e=new URLSearchParams(window.location.search);for(const[t,n]of e)this._urlParams[t.toLowerCase()]=n}hasURLParam(e){return e.toLowerCase()in this._urlParams}getURLParam(e){return this.hasURLParam(e)?this._urlParams[e.toLowerCase()]:""}}class Ge extends Ke{constructor(e,t,n,s,r,i=()=>{}){if(super(e,t,n,s,i),r&&this.hasURLParam(this.id)){const e=this.getURLParam(this.id);this.flag="false"!=e.toLowerCase()}else this.flag=s;this.useUrlParams=r}getValueAsString(){return this.flag?"true":"false"}enable(){this.flag=!0}get flag(){return!!this.value}set flag(e){this.value=e}}class Xe extends Ke{constructor(e,t,n,s,r,i,o,a=()=>{}){if(super(e,t,n,i,a),this._min=s,this._max=r,o&&this.hasURLParam(this.id)){const e=Number.parseFloat(this.getURLParam(this.id));this.number=Number.isNaN(e)?i:e}else this.number=i;this.useUrlParams=o}getValueAsString(){return this.number.toString()}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 qe extends Ke{constructor(e,t,n,s,r,i=()=>{}){super(e,t,n,s,i),r&&this.hasURLParam(this.id)?this.text=this.getURLParam(this.id):this.text=s,this.useUrlParams=r}getValueAsString(){return this.text}get text(){return this.value}set text(e){this.value=e}}class Qe extends Ke{constructor(e,t,n,s,r,i,o=()=>{}){super(e,t,n,s,o),this.options=r;const a=this.hasURLParam(this.id)?this.getURLParam(this.id):s;this.selected=a,this.useUrlParams=i}getValueAsString(){return this.selected}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){let t=this.options.filter((t=>-1!==t.indexOf(e)));t.length?this.value=t[0]:(t=this.options.filter((t=>-1!==t.indexOf(e.split(" ")[0]))),t.length&&(this.value=t[0]))}}class Je extends Event{constructor(e){super("afkWarningActivate"),this.data=e}}class Ye extends Event{constructor(e){super("afkWarningUpdate"),this.data=e}}class Ze extends Event{constructor(){super("afkWarningDeactivate")}}class et extends Event{constructor(){super("afkTimedOut")}}class tt extends Event{constructor(e){super("videoEncoderAvgQP"),this.data=e}}class nt extends Event{constructor(){super("webRtcSdp")}}class st extends Event{constructor(){super("webRtcAutoConnect")}}class rt extends Event{constructor(){super("webRtcConnecting")}}class it extends Event{constructor(){super("webRtcConnected")}}class ot extends Event{constructor(){super("webRtcFailed")}}class at extends Event{constructor(e){super("webRtcDisconnected"),this.data=e}}class lt extends Event{constructor(e){super("dataChannelOpen"),this.data=e}}class dt extends Event{constructor(e){super("dataChannelClose"),this.data=e}}class ht extends Event{constructor(e){super("dataChannelError"),this.data=e}}class ct extends Event{constructor(){super("videoInitialized")}}class ut extends Event{constructor(){super("streamLoading")}}class gt extends Event{constructor(){super("streamConnect")}}class mt extends Event{constructor(){super("streamDisconnect")}}class pt extends Event{constructor(){super("streamReconnect")}}class ft extends Event{constructor(e){super("playStreamError"),this.data=e}}class yt extends Event{constructor(){super("playStream")}}class vt extends Event{constructor(e){super("playStreamRejected"),this.data=e}}class wt extends Event{constructor(e){super("loadFreezeFrame"),this.data=e}}class St extends Event{constructor(){super("hideFreezeFrame")}}class bt extends Event{constructor(e){super("statsReceived"),this.data=e}}class Ct extends Event{constructor(e){super("streamerListMessage"),this.data=e}}class Tt extends Event{constructor(e){super("StreamerIDChangedMessage"),this.data=e}}class Et extends Event{constructor(e){super("latencyTestResult"),this.data=e}}class Mt extends Event{constructor(e){super("dataChannelLatencyTestResponse"),this.data=e}}class kt extends Event{constructor(e){super("dataChannelLatencyTestResult"),this.data=e}}class Rt extends Event{constructor(e){super("initialSettings"),this.data=e}}class Pt extends Event{constructor(e){super("settingsChanged"),this.data=e}}class It extends Event{constructor(){super("xrSessionStarted")}}class Lt extends Event{constructor(){super("xrSessionEnded")}}class xt extends Event{constructor(e){super("xrFrame"),this.data=e}}class Ft extends Event{constructor(e){super("playerCount"),this.data=e}}class Ot extends Event{constructor(){super("webRtcTCPRelayDetected")}}class Dt extends EventTarget{dispatchEvent(e){return super.dispatchEvent(e)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}}class At{}At.AutoConnect="AutoConnect",At.AutoPlayVideo="AutoPlayVideo",At.AFKDetection="TimeoutIfIdle",At.HoveringMouseMode="HoveringMouse",At.ForceMonoAudio="ForceMonoAudio",At.ForceTURN="ForceTURN",At.FakeMouseWithTouches="FakeMouseWithTouches",At.IsQualityController="ControlsQuality",At.MatchViewportResolution="MatchViewportRes",At.StartVideoMuted="StartVideoMuted",At.SuppressBrowserKeys="SuppressBrowserKeys",At.UseMic="UseMic",At.UseCamera="UseCamera",At.KeyboardInput="KeyboardInput",At.MouseInput="MouseInput",At.TouchInput="TouchInput",At.GamepadInput="GamepadInput",At.XRControllerInput="XRControllerInput",At.WaitForStreamer="WaitForStreamer",At.HideUI="HideUI";const Nt=e=>Object.getOwnPropertyNames(At).some((t=>At[t]===e));class Bt{}Bt.AFKTimeoutSecs="AFKTimeout",Bt.AFKCountdownSecs="AFKCountdown",Bt.MinQP="MinQP",Bt.MaxQP="MaxQP",Bt.WebRTCFPS="WebRTCFPS",Bt.WebRTCMinBitrate="WebRTCMinBitrate",Bt.WebRTCMaxBitrate="WebRTCMaxBitrate",Bt.MaxReconnectAttempts="MaxReconnectAttempts",Bt.StreamerAutoJoinInterval="StreamerAutoJoinInterval";const Ut=e=>Object.getOwnPropertyNames(Bt).some((t=>Bt[t]===e));class Vt{}Vt.SignallingServerUrl="ss";const Wt=e=>Object.getOwnPropertyNames(Vt).some((t=>Vt[t]===e));class _t{}_t.PreferredCodec="PreferredCodec",_t.StreamerId="StreamerId";const Ht=e=>Object.getOwnPropertyNames(_t).some((t=>_t[t]===e));class $t{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)}get useUrlParams(){return this._useUrlParams}populateDefaultSettings(e,t){this.textParameters.set(Vt.SignallingServerUrl,new qe(Vt.SignallingServerUrl,"Signalling url","Url of the signalling server",t&&Object.prototype.hasOwnProperty.call(t,Vt.SignallingServerUrl)?t[Vt.SignallingServerUrl]:("https:"===location.protocol?"wss://":"ws://")+window.location.hostname+("80"===window.location.port||""===window.location.port?"":`:${window.location.port}`),e)),this.optionParameters.set(_t.StreamerId,new Qe(_t.StreamerId,"Streamer ID","The ID of the streamer to stream.",t&&Object.prototype.hasOwnProperty.call(t,_t.StreamerId)?t[_t.StreamerId]:"",[],e)),this.optionParameters.set(_t.PreferredCodec,new Qe(_t.PreferredCodec,"Preferred Codec","The preferred codec to be used during codec negotiation","H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",t&&Object.prototype.hasOwnProperty.call(t,_t.PreferredCodec)?[t[_t.PreferredCodec]]: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 s=n.mimeType.split("/")[1]+" "+(n.sdpFmtpLine||"");null!==t.exec(s)&&e.push(s)})),e}(),e)),this.flags.set(At.AutoConnect,new Ge(At.AutoConnect,"Auto connect to stream","Whether we should attempt to auto connect to the signalling server or show a click to start prompt.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.AutoConnect))&&t[At.AutoConnect],e)),this.flags.set(At.AutoPlayVideo,new Ge(At.AutoPlayVideo,"Auto play video","When video is ready automatically start playing it as opposed to showing a play button.",!t||!Object.prototype.hasOwnProperty.call(t,At.AutoPlayVideo)||t[At.AutoPlayVideo],e)),this.flags.set(At.UseMic,new Ge(At.UseMic,"Use microphone","Make browser request microphone access and open an input audio track.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.UseMic))&&t[At.UseMic],e)),this.flags.set(At.UseCamera,new Ge(At.UseCamera,"Use webcam","Make browser request webcam access and open a input video track.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.UseCamera))&&t[At.UseCamera],e)),this.flags.set(At.StartVideoMuted,new Ge(At.StartVideoMuted,"Start video muted","Video will start muted if true.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.StartVideoMuted))&&t[At.StartVideoMuted],e)),this.flags.set(At.SuppressBrowserKeys,new Ge(At.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.",!t||!Object.prototype.hasOwnProperty.call(t,At.SuppressBrowserKeys)||t[At.SuppressBrowserKeys],e)),this.flags.set(At.IsQualityController,new Ge(At.IsQualityController,"Is quality controller?","True if this peer controls stream quality",!t||!Object.prototype.hasOwnProperty.call(t,At.IsQualityController)||t[At.IsQualityController],e)),this.flags.set(At.ForceMonoAudio,new Ge(At.ForceMonoAudio,"Force mono audio","Force browser to request mono audio in the SDP",!(!t||!Object.prototype.hasOwnProperty.call(t,At.ForceMonoAudio))&&t[At.ForceMonoAudio],e)),this.flags.set(At.ForceTURN,new Ge(At.ForceTURN,"Force TURN","Only generate TURN/Relayed ICE candidates.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.ForceTURN))&&t[At.ForceTURN],e)),this.flags.set(At.AFKDetection,new Ge(At.AFKDetection,"AFK if idle","Timeout the experience if user is AFK for a period.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.AFKDetection))&&t[At.AFKDetection],e)),this.flags.set(At.MatchViewportResolution,new Ge(At.MatchViewportResolution,"Match viewport resolution","Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.MatchViewportResolution))&&t[At.MatchViewportResolution],e)),this.flags.set(At.HoveringMouseMode,new Ge(At.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.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.HoveringMouseMode))&&t[At.HoveringMouseMode],e,((e,t)=>{t.label=`Control Scheme: ${e?"Hovering":"Locked"} Mouse`}))),this.flags.set(At.FakeMouseWithTouches,new Ge(At.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.",!(!t||!Object.prototype.hasOwnProperty.call(t,At.FakeMouseWithTouches))&&t[At.FakeMouseWithTouches],e)),this.flags.set(At.KeyboardInput,new Ge(At.KeyboardInput,"Keyboard input","If enabled, send keyboard events to streamer",!t||!Object.prototype.hasOwnProperty.call(t,At.KeyboardInput)||t[At.KeyboardInput],e)),this.flags.set(At.MouseInput,new Ge(At.MouseInput,"Mouse input","If enabled, send mouse events to streamer",!t||!Object.prototype.hasOwnProperty.call(t,At.MouseInput)||t[At.MouseInput],e)),this.flags.set(At.TouchInput,new Ge(At.TouchInput,"Touch input","If enabled, send touch events to streamer",!t||!Object.prototype.hasOwnProperty.call(t,At.TouchInput)||t[At.TouchInput],e)),this.flags.set(At.GamepadInput,new Ge(At.GamepadInput,"Gamepad input","If enabled, send gamepad events to streamer",!t||!Object.prototype.hasOwnProperty.call(t,At.GamepadInput)||t[At.GamepadInput],e)),this.flags.set(At.XRControllerInput,new Ge(At.XRControllerInput,"XR controller input","If enabled, send XR controller events to streamer",!t||!Object.prototype.hasOwnProperty.call(t,At.XRControllerInput)||t[At.XRControllerInput],e)),this.flags.set(At.WaitForStreamer,new Ge(At.WaitForStreamer,"Wait for streamer","Will continue trying to connect to the first streamer available.",!t||!Object.prototype.hasOwnProperty.call(t,At.WaitForStreamer)||t[At.WaitForStreamer],e)),this.flags.set(At.HideUI,new Ge(At.HideUI,"Hide the UI overlay","Will hide all UI overlay details",!(!t||!Object.prototype.hasOwnProperty.call(t,At.HideUI))&&t[At.HideUI],e)),this.numericParameters.set(Bt.AFKTimeoutSecs,new Xe(Bt.AFKTimeoutSecs,"AFK timeout","The time (in seconds) it takes for the application to time out if AFK timeout is enabled.",0,600,t&&Object.prototype.hasOwnProperty.call(t,Bt.AFKTimeoutSecs)?t[Bt.AFKTimeoutSecs]:120,e)),this.numericParameters.set(Bt.AFKCountdownSecs,new Xe(Bt.AFKCountdownSecs,"AFK countdown","The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.",10,180,10,e)),this.numericParameters.set(Bt.MaxReconnectAttempts,new Xe(Bt.MaxReconnectAttempts,"Max Reconnects","Maximum number of reconnects the application will attempt when a streamer disconnects.",0,999,t&&Object.prototype.hasOwnProperty.call(t,Bt.MaxReconnectAttempts)?t[Bt.MaxReconnectAttempts]:3,e)),this.numericParameters.set(Bt.MinQP,new Xe(Bt.MinQP,"Min QP","The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.",0,51,t&&Object.prototype.hasOwnProperty.call(t,Bt.MinQP)?t[Bt.MinQP]:0,e)),this.numericParameters.set(Bt.MaxQP,new Xe(Bt.MaxQP,"Max QP","The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.",0,51,t&&Object.prototype.hasOwnProperty.call(t,Bt.MaxQP)?t[Bt.MaxQP]:51,e)),this.numericParameters.set(Bt.WebRTCFPS,new Xe(Bt.WebRTCFPS,"Max FPS","The maximum FPS that WebRTC will try to transmit frames at.",1,999,t&&Object.prototype.hasOwnProperty.call(t,Bt.WebRTCFPS)?t[Bt.WebRTCFPS]:60,e)),this.numericParameters.set(Bt.WebRTCMinBitrate,new Xe(Bt.WebRTCMinBitrate,"Min Bitrate (kbps)","The minimum bitrate that WebRTC should use.",0,5e5,t&&Object.prototype.hasOwnProperty.call(t,Bt.WebRTCMinBitrate)?t[Bt.WebRTCMinBitrate]:0,e)),this.numericParameters.set(Bt.WebRTCMaxBitrate,new Xe(Bt.WebRTCMaxBitrate,"Max Bitrate (kbps)","The maximum bitrate that WebRTC should use.",0,5e5,t&&Object.prototype.hasOwnProperty.call(t,Bt.WebRTCMaxBitrate)?t[Bt.WebRTCMaxBitrate]:0,e)),this.numericParameters.set(Bt.StreamerAutoJoinInterval,new Xe(Bt.StreamerAutoJoinInterval,"Streamer Auto Join Interval (ms)","Delay between retries when waiting for an available streamer.",500,9e5,t&&Object.prototype.hasOwnProperty.call(t,Bt.StreamerAutoJoinInterval)?t[Bt.StreamerAutoJoinInterval]:3e3,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:d.Warning(`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:d.Warning(`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:d.Warning(`Cannot set text setting called ${e} - it does not exist in the Config.optionParameters map.`)}setOptionSettingValue(e,t){if(this.optionParameters.has(e)){const n=this.optionParameters.get(e),s=n.options;s.includes(t)||(s.push(t),n.options=s),n.selected=t}else d.Warning(`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:d.Warning(`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))Nt(t)?this.setFlagEnabled(t,e[t]):Ut(t)?this.setNumericSetting(t,e[t]):Wt(t)?this.setTextSetting(t,e[t]):Ht(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 Pt({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 Pt({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 Pt({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 Pt({id:n.id,type:"option",value:t,target:n})))}}}var jt;!function(e){e[e.LockedMouse=0]="LockedMouse",e[e.HoveringMouse=1]="HoveringMouse"}(jt||(jt={}));class zt{constructor(e,t,n){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 Ze))}startAfkWarningTimer(){this.config.getNumericSettingValue(Bt.AFKTimeoutSecs)>0&&this.config.isFlagEnabled(At.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(At.AFKDetection)&&(clearTimeout(this.warnTimer),this.warnTimer=setTimeout((()=>this.activateAfkEvent()),1e3*this.config.getNumericSettingValue(Bt.AFKTimeoutSecs)))}activateAfkEvent(){this.pauseAfkWarningTimer(),this.pixelStreaming.dispatchEvent(new Je({countDown:this.countDown,dismissAfk:this.onDismissAfk})),this.countDown=this.config.getNumericSettingValue(Bt.AFKCountdownSecs),this.countdownActive=!0,this.pixelStreaming.dispatchEvent(new Ye({countDown:this.countDown})),this.config.isFlagEnabled(At.HoveringMouseMode)||document.exitPointerLock&&document.exitPointerLock(),this.countDownTimer=setInterval((()=>{this.countDown--,0==this.countDown?(this.pixelStreaming.dispatchEvent(new et),this.onAFKTimedOutCallback(),d.Info("You have been disconnected due to inactivity"),this.stopAfkWarningTimer()):this.pixelStreaming.dispatchEvent(new Ye({countDown:this.countDown}))}),1e3)}}class Kt{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;d.Info(`Data Channel (${this.label}) opened.`),this.onOpen(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnClose(e){var t;d.Info(`Data Channel (${this.label}) closed.`),this.onClose(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnMessage(e){d.Info(`Data Channel (${this.label}) message: ${e}`)}handleOnError(e){var t;d.Info(`Data Channel (${this.label}) error: ${e}`),this.onError(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}onOpen(e,t){}onClose(e,t){}onError(e,t){}}class Gt{}class Xt{}class qt{}class Qt{}class Jt{}class Yt{}class Zt{}class en{constructor(){this.inboundVideoStats=new Xt,this.inboundAudioStats=new Gt,this.DataChannelStats=new qt,this.outBoundVideoStats=new Jt,this.sessionStats=new Yt,this.streamStats=new Zt,this.codecs=new Map}processStats(e){this.localCandidates=new Array,this.remoteCandidates=new Array,this.candidatePairs=new Array,e.forEach((e=>{switch(e.type){case"candidate-pair":this.handleCandidatePair(e);break;case"certificate":case"media-source":case"media-playout":case"outbound-rtp":case"peer-connection":case"remote-inbound-rtp":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"transport":this.handleTransport(e);break;case"stream":this.handleStream(e);break;default:d.Error("unhandled Stat Type"),d.Info(e)}}))}handleStream(e){this.streamStats=e}handleCandidatePair(e){this.candidatePairs.push(e)}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 Qt;t.label="local-candidate",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.candidateType=e.candidateType,t.id=e.id,t.relayProtocol=e.relayProtocol,t.transportId=e.transportId,this.localCandidates.push(t)}handleRemoteCandidate(e){const t=new Qt;t.label="remote-candidate",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.id=e.id,t.candidateType=e.candidateType,t.relayProtocol=e.relayProtocol,t.transportId=e.transportId,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:d.Info("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)}handleTransport(e){this.transportStats=e}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 s=Date.now()-e;this.sessionStats.runTime=new Date(s).toISOString().substr(11,8).toString();const r=null===t?"Not sent yet":t?"true":"false";this.sessionStats.controlsStreamInput=r,this.sessionStats.videoEncoderAvgQP=n}isNumber(e){return"number"==typeof e&&isFinite(e)}getActiveCandidatePair(){return this.transportStats?this.candidatePairs.find((e=>e.id===this.transportStats.selectedCandidatePairId),null):this.candidatePairs.find((e=>e.selected),null)}}var tn=s(89);class nn{static isVideoTransceiver(e){return this.canTransceiverReceiveVideo(e)||this.canTransceiverSendVideo(e)}static canTransceiverReceiveVideo(e){return!!e&&("sendrecv"===e.direction||"recvonly"===e.direction)&&e.receiver&&e.receiver.track&&"video"===e.receiver.track.kind}static canTransceiverSendVideo(e){return!!e&&("sendrecv"===e.direction||"sendonly"===e.direction)&&e.sender&&e.sender.track&&"video"===e.sender.track.kind}static isAudioTransceiver(e){return this.canTransceiverReceiveAudio(e)||this.canTransceiverSendAudio(e)}static canTransceiverReceiveAudio(e){return!!e&&("sendrecv"===e.direction||"recvonly"===e.direction)&&e.receiver&&e.receiver.track&&"audio"===e.receiver.track.kind}static canTransceiverSendAudio(e){return!!e&&("sendrecv"===e.direction||"sendonly"===e.direction)&&e.sender&&e.sender.track&&"audio"===e.sender.track.kind}}var sn=function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};class rn{constructor(e,t,n){this.config=t,this.createPeerConnection(e,n)}createPeerConnection(e,t){this.config.isFlagEnabled(At.ForceTURN)&&(e.iceTransportPolicy="relay",d.Info("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 en,this.preferredCodec=t,this.updateCodecSelection=!0}createOffer(e,t){return sn(this,void 0,void 0,(function*(){d.Info("Create Offer");const n="localhost"===location.hostname||"127.0.0.1"===location.hostname,s="https:"===location.protocol;let r=t.isFlagEnabled(At.UseMic),i=t.isFlagEnabled(At.UseCamera);!r&&!i||n||s||(r=!1,i=!1,d.Error("Microphone and Webcam access in the browser will not work if you are not on HTTPS or localhost. Disabling mic and webcam access."),d.Error("For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'")),this.setupTransceiversAsync(r,i).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,r),null===(t=this.peerConnection)||void 0===t||t.setLocalDescription(e),this.onSendWebRTCOffer(e)})).catch((()=>{this.showTextOverlaySetupFailure()}))}))}))}receiveOffer(e,t){var n;return sn(this,void 0,void 0,(function*(){d.Info("Receive Offer"),null===(n=this.peerConnection)||void 0===n||n.setRemoteDescription(e).then((()=>{const n="localhost"===location.hostname||"127.0.0.1"===location.hostname,s="https:"===location.protocol;let r=t.isFlagEnabled(At.UseMic),i=t.isFlagEnabled(At.UseCamera);!r&&!i||n||s||(r=!1,i=!1,d.Error("Microphone and Webcam access in the browser will not work if you are not on HTTPS or localhost. Disabling mic and webcam access."),d.Error("For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'")),this.config.setOptionSettingOptions(_t.PreferredCodec,this.fuzzyIntersectUEAndBrowserCodecs(e)),this.setupTransceiversAsync(r,i).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((()=>{d.Error("createAnswer() failed")}))}))}))}))}receiveAnswer(e){var t;null===(t=this.peerConnection)||void 0===t||t.setRemoteDescription(e),this.config.setOptionSettingOptions(_t.PreferredCodec,this.fuzzyIntersectUEAndBrowserCodecs(e))}generateStats(){var e,t;const n=e=>{this.aggregatedStats.processStats(e)},s=null===(e=this.peerConnection)||void 0===e?void 0:e.getStats(this.audioTrack).then(n),r=null===(t=this.peerConnection)||void 0===t?void 0:t.getStats(this.videoTrack).then(n);Promise.allSettled([s,r]).then((()=>{this.onVideoStats(this.aggregatedStats),this.updateCodecSelection&&this.aggregatedStats.inboundVideoStats.codecId&&this.config.setOptionSettingValue(_t.PreferredCodec,this.aggregatedStats.codecs.get(this.aggregatedStats.inboundVideoStats.codecId))}))}close(){this.peerConnection&&(this.peerConnection.close(),this.peerConnection=null)}mungeSDP(e,t){let n=e.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=10000;x-google-max-bitrate=100000\r\n"),s="maxaveragebitrate=510000;";return t&&(s+="sprop-maxcapturerate=48000;"),s+=this.config.isFlagEnabled(At.ForceMonoAudio)?"stereo=0;":"stereo=1;",s+="useinbandfec=1",n=n.replace("useinbandfec=1",s),n}handleOnIce(e){var t;d.Info("peerconnection handleOnIce"),this.config.isFlagEnabled(At.ForceTURN)&&e.candidate.indexOf("relay")<0?d.Info(`Dropping candidate because it was not TURN relay. | Type= ${e.type} | Protocol= ${e.protocol} | Address=${e.address} | Port=${e.port} |`):null===(t=this.peerConnection)||void 0===t||t.addIceCandidate(e)}handleSignalStateChange(e){d.Info("signaling state change: "+e)}handleIceConnectionStateChange(e){d.Info("ice connection state change: "+e),this.onIceConnectionStateChange(e)}handleIceGatheringStateChange(e){d.Info("ice gathering state change: "+JSON.stringify(e))}handleOnTrack(e){e.streams.length<1||"probator"==e.streams[0].id||("video"==e.track.kind&&(this.videoTrack=e.track),"audio"==e.track.kind&&(this.audioTrack=e.track),this.onTrack(e))}handleIceCandidate(e){this.onPeerIceCandidate(e)}handleDataChannel(e){this.onDataChannel(e)}onTrack(e){}onIceConnectionStateChange(e){}onPeerIceCandidate(e){}onDataChannel(e){}fuzzyIntersectUEAndBrowserCodecs(e){const t=new Array,n=this.parseAvailableCodecs(e),s=this.config.getSettingOption(_t.PreferredCodec).options;for(const e of n)if(s.includes(e))t.push(e);else{const n=e.split(" ")[0];for(const e of s)if(e.includes(n)){t.push(e);break}}return t}setupTransceiversAsync(e,t){var n,s,r,i,o,a,l,d;return sn(this,void 0,void 0,(function*(){let h=!1;for(const e of null!==(s=null===(n=this.peerConnection)||void 0===n?void 0:n.getTransceivers())&&void 0!==s?s:[])if(e&&e.receiver&&e.receiver.track&&"video"===e.receiver.track.kind){h=!0;break}if(t?yield this.setupVideoSender(h):h||null===(r=this.peerConnection)||void 0===r||r.addTransceiver("video",{direction:"recvonly"}),RTCRtpReceiver.getCapabilities&&""!=this.preferredCodec)for(const e of null!==(o=null===(i=this.peerConnection)||void 0===i?void 0:i.getTransceivers())&&void 0!==o?o:[])if(e&&e.receiver&&e.receiver.track&&"video"===e.receiver.track.kind&&e.setCodecPreferences){const t=this.preferredCodec.split(" "),n={mimeType:"video/"+t[0],clockRate:9e4,sdpFmtpLine:t[1]?t[1]:""},s=[n];RTCRtpReceiver.getCapabilities("video").codecs.forEach((e=>{(e.mimeType!=n.mimeType||(null==e?void 0:e.sdpFmtpLine)!=(null==n?void 0:n.sdpFmtpLine))&&s.push(e)}));for(const e of s)void 0!==(null==e?void 0:e.sdpFmtpLine)&&""!==e.sdpFmtpLine||delete e.sdpFmtpLine;e.setCodecPreferences(s)}let c=!1;for(const e of null!==(l=null===(a=this.peerConnection)||void 0===a?void 0:a.getTransceivers())&&void 0!==l?l:[])if(e&&e.receiver&&e.receiver.track&&"audio"===e.receiver.track.kind){c=!0;break}e?yield this.setupAudioSender(c):c||null===(d=this.peerConnection)||void 0===d||d.addTransceiver("audio",{direction:"recvonly"})}))}setupVideoSender(e){var t,n,s,r;return sn(this,void 0,void 0,(function*(){const i=yield navigator.mediaDevices.getUserMedia({video:!0});if(i)if(e){for(const e of null!==(n=null===(t=this.peerConnection)||void 0===t?void 0:t.getTransceivers())&&void 0!==n?n:[])if(nn.canTransceiverReceiveVideo(e))for(const t of i.getTracks())t.kind&&"video"==t.kind&&(e.sender.replaceTrack(t),e.direction="sendrecv")}else for(const e of i.getTracks())e.kind&&"video"==e.kind&&(null===(s=this.peerConnection)||void 0===s||s.addTransceiver(e,{direction:"sendrecv"}));else e||null===(r=this.peerConnection)||void 0===r||r.addTransceiver("video",{direction:"recvonly"})}))}setupAudioSender(e){var t,n,s,r;return sn(this,void 0,void 0,(function*(){const i=yield navigator.mediaDevices.getUserMedia({video:!1,audio:{autoGainControl:!1,channelCount:1,echoCancellation:!1,latency:0,noiseSuppression:!1,sampleRate:48e3,sampleSize:16,volume:1}});if(i)if(e){for(const e of null!==(n=null===(t=this.peerConnection)||void 0===t?void 0:t.getTransceivers())&&void 0!==n?n:[])if(nn.canTransceiverReceiveAudio(e))for(const t of i.getTracks())t.kind&&"audio"==t.kind&&(e.sender.replaceTrack(t),e.direction="sendrecv")}else for(const e of i.getTracks())e.kind&&"audio"==e.kind&&(null===(s=this.peerConnection)||void 0===s||s.addTransceiver(e,{direction:"sendrecv"}));else e||null===(r=this.peerConnection)||void 0===r||r.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,tn.splitSections)(e.sdp);return n.shift(),n.forEach((e=>{const{codecs:n}=(0,tn.parseRtpParameters)(e),s=/(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!==s.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 on{constructor(){this.PixelStreamingSettings=new an,this.EncoderSettings=new ln,this.WebRTCSettings=new dn}ueCompatible(){null!=this.WebRTCSettings.MaxFPS&&(this.WebRTCSettings.FPS=this.WebRTCSettings.MaxFPS)}}class an{}class ln{}class dn{}class hn{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||(d.Info(`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`),this.EncodeMs=this.PostEncodeTimeMs-this.PreEncodeTimeMs),null!=this.CaptureToSendMs||null==this.PreCaptureTimeMs&&null==this.PostCaptureTimeMs||(d.Info(`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`),this.CaptureToSendMs=this.PostCaptureTimeMs-this.PreCaptureTimeMs)}}class cn{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(),d.Info("Received first chunk of file"));const n=new TextDecoder("utf-16").decode(e.slice(1));d.Info(n),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(),d.Info("Received first chunk of file"));const n=new TextDecoder("utf-16").decode(e.slice(1));d.Info(n),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),d.Info(`Received file chunk: ${t.data.length}/${t.size}`),t.data.length===t.size){t.receiving=!1,t.valid=!0,d.Info("Received complete file");const e=(new Date).getTime()-t.timestampStart,n=Math.round(16*t.size*1024/e);d.Info(`Average transfer bitrate: ${n}kb/s over ${e/1e3} seconds`);const s=new Blob(t.data,{type:t.mimetype}),r=document.createElement("a");r.setAttribute("href",URL.createObjectURL(s)),r.setAttribute("download",`transfer.${t.extension}`),document.body.append(r),r.remove()}else t.data.length>t.size&&(t.receiving=!1,d.Error(`Received bigger file than advertised: ${t.data.length}/${t.size}`))}}class un{constructor(){this.mimetype="",this.extension="",this.receiving=!1,this.size=0,this.data=[],this.valid=!1}}class gn{}gn.backSpace=8,gn.shift=16,gn.control=17,gn.alt=18,gn.rightShift=253,gn.rightControl=254,gn.rightAlt=255;const mn=Object.freeze({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});class pn{constructor(e,t,n){this.streamMessageController=e,this.config=t,this.activeKeys=n,this.onKeyDownListener=this.handleOnKeyDown.bind(this),this.onKeyUpListener=this.handleOnKeyUp.bind(this),this.onKeyPressListener=this.handleOnKeyPress.bind(this),this.onCompositionEndListener=this.handleOnCompositionEnd.bind(this)}register(){document.addEventListener("compositionend",this.onCompositionEndListener),document.addEventListener("keydown",this.onKeyDownListener),document.addEventListener("keyup",this.onKeyUpListener),document.addEventListener("keypress",this.onKeyPressListener)}unregister(){document.removeEventListener("compositionend",this.onCompositionEndListener),document.removeEventListener("keydown",this.onKeyDownListener),document.removeEventListener("keyup",this.onKeyUpListener),document.removeEventListener("keypress",this.onKeyPressListener)}handleOnKeyDown(e){const t=this.getKeycode(e);t&&229!==t&&(this.streamMessageController.toStreamerHandlers.get("KeyDown")([this.getKeycode(e),e.repeat?1:0]),this.activeKeys.getActiveKeys().push(t),t===gn.backSpace&&document.dispatchEvent(new KeyboardEvent("keypress",{charCode:gn.backSpace})),this.config.isFlagEnabled(At.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyUp(e){const t=this.getKeycode(e);t&&(this.streamMessageController.toStreamerHandlers.get("KeyUp")([t]),this.config.isFlagEnabled(At.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyPress(e){const t=this.getKeycode(e);t&&this.streamMessageController.toStreamerHandlers.get("KeyPress")([t])}handleOnCompositionEnd(e){e.data&&e.data.length&&e.data.split("").forEach((e=>{this.handleOnKeyDown(new KeyboardEvent("keydown",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)})),this.handleOnKeyPress(new KeyboardEvent("keypress",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)})),this.handleOnKeyUp(new KeyboardEvent("keyup",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)}))}))}getKeycode(e){if(!("keyCode"in e)){const t=e;return t.code in mn?mn[t.code]:(d.Warning(`Keyboard code of ${t.code} is not supported in our mapping, ignoring this key.`),null)}return e.keyCode===gn.shift&&"ShiftRight"===e.code?gn.rightShift:e.keyCode===gn.control&&"ControlRight"===e.code?gn.rightControl:e.keyCode===gn.alt&&"AltRight"===e.code?gn.rightAlt:e.keyCode}isKeyCodeBrowserKey(e){return e>=112&&e<=123||9===e}}class fn{}fn.mainButton=0,fn.auxiliaryButton=1,fn.secondaryButton=2,fn.fourthButton=3,fn.fifthButton=4;class yn{}yn.primaryButton=1,yn.secondaryButton=2,yn.auxiliaryButton=4,yn.fourthButton=8,yn.fifthButton=16;class vn{constructor(e,t,n,s){this.streamMessageController=e,this.coordinateConverter=n,this.videoPlayer=t,this.activeKeys=s,this.onEnterListener=this.onMouseEnter.bind(this),this.onLeaveListener=this.onMouseLeave.bind(this)}register(){this.registerMouseEnterAndLeaveEvents()}unregister(){this.unregisterMouseEnterAndLeaveEvents()}registerMouseEnterAndLeaveEvents(){const e=this.videoPlayer.getVideoParentElement();e.addEventListener("mouseenter",this.onEnterListener),e.addEventListener("mouseleave",this.onLeaveListener)}unregisterMouseEnterAndLeaveEvents(){const e=this.videoPlayer.getVideoParentElement();e.removeEventListener("mouseenter",this.onEnterListener),e.removeEventListener("mouseleave",this.onLeaveListener)}onMouseEnter(e){this.videoPlayer.isVideoReady()&&(this.streamMessageController.toStreamerHandlers.get("MouseEnter")(),this.pressMouseButtons(e.buttons,e.x,e.y))}onMouseLeave(e){this.videoPlayer.isVideoReady()&&(this.streamMessageController.toStreamerHandlers.get("MouseLeave")(),this.releaseMouseButtons(e.buttons,e.x,e.y))}releaseMouseButtons(e,t,n){const s=this.coordinateConverter.translateUnsigned(t,n);e&yn.primaryButton&&this.sendMouseUp(fn.mainButton,s.x,s.y),e&yn.secondaryButton&&this.sendMouseUp(fn.secondaryButton,s.x,s.y),e&yn.auxiliaryButton&&this.sendMouseUp(fn.auxiliaryButton,s.x,s.y),e&yn.fourthButton&&this.sendMouseUp(fn.fourthButton,s.x,s.y),e&yn.fifthButton&&this.sendMouseUp(fn.fifthButton,s.x,s.y)}pressMouseButtons(e,t,n){if(!this.videoPlayer.isVideoReady())return;const s=this.coordinateConverter.translateUnsigned(t,n);e&yn.primaryButton&&this.sendMouseDown(fn.mainButton,s.x,s.y),e&yn.secondaryButton&&this.sendMouseDown(fn.secondaryButton,s.x,s.y),e&yn.auxiliaryButton&&this.sendMouseDown(fn.auxiliaryButton,s.x,s.y),e&yn.fourthButton&&this.sendMouseDown(fn.fourthButton,s.x,s.y),e&yn.fifthButton&&this.sendMouseDown(fn.fifthButton,s.x,s.y)}sendMouseDown(e,t,n){var s;null===(s=this.streamMessageController.toStreamerHandlers.get("MouseDown"))||void 0===s||s([e,t,n])}sendMouseUp(e,t,n){var s;const r=this.coordinateConverter.translateUnsigned(t,n);null===(s=this.streamMessageController.toStreamerHandlers.get("MouseUp"))||void 0===s||s([e,r.x,r.y])}}class wn extends vn{constructor(e,t,n,s){super(e,t,n,s),this.videoElementParent=t.getVideoParentElement(),this.x=this.videoElementParent.getBoundingClientRect().width/2,this.y=this.videoElementParent.getBoundingClientRect().height/2,this.normalizedCoord=this.coordinateConverter.translateUnsigned(this.x,this.y),this.onRequestLockListener=this.onRequestLock.bind(this),this.onLockStateChangeListener=this.onLockStateChange.bind(this),this.onMouseUpListener=this.onMouseUp.bind(this),this.onMouseDownListener=this.onMouseDown.bind(this),this.onMouseDblClickListener=this.onMouseDblClick.bind(this),this.onMouseWheelListener=this.onMouseWheel.bind(this),this.onMouseMoveListener=this.onMouseMove.bind(this)}register(){super.register(),this.videoElementParent.requestPointerLock=this.videoElementParent.requestPointerLock||this.videoElementParent.mozRequestPointerLock,document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock,this.videoElementParent.requestPointerLock&&this.videoElementParent.addEventListener("click",this.onRequestLockListener),document.addEventListener("pointerlockchange",this.onLockStateChangeListener),document.addEventListener("mozpointerlockchange",this.onLockStateChangeListener),this.videoElementParent.addEventListener("mousedown",this.onMouseDownListener),this.videoElementParent.addEventListener("mouseup",this.onMouseUpListener),this.videoElementParent.addEventListener("wheel",this.onMouseWheelListener),this.videoElementParent.addEventListener("dblclick",this.onMouseDblClickListener)}unregister(){const e=document.pointerLockElement||document.mozPointerLockElement;document.exitPointerLock&&e===this.videoElementParent&&document.exitPointerLock(),this.videoElementParent.removeEventListener("click",this.onRequestLockListener),document.removeEventListener("pointerlockchange",this.onLockStateChangeListener),document.removeEventListener("mozpointerlockchange",this.onLockStateChangeListener),document.removeEventListener("mousemove",this.onMouseMoveListener),this.videoElementParent.removeEventListener("mousedown",this.onMouseDownListener),this.videoElementParent.removeEventListener("mouseup",this.onMouseUpListener),this.videoElementParent.removeEventListener("wheel",this.onMouseWheelListener),this.videoElementParent.removeEventListener("dblclick",this.onMouseDblClickListener),super.unregister()}onRequestLock(){this.videoElementParent.requestPointerLock()}onLockStateChange(){(document.pointerLockElement||document.mozPointerLockElement)===this.videoElementParent?(d.Info("Pointer locked"),document.addEventListener("mousemove",this.onMouseMoveListener)):(d.Info("The pointer lock status is now unlocked"),document.removeEventListener("mousemove",this.onMouseMoveListener),this.activeKeys.getActiveKeys().forEach((e=>{this.streamMessageController.toStreamerHandlers.get("KeyUp")([e])})))}onMouseDown(e){this.videoPlayer.isVideoReady()&&this.streamMessageController.toStreamerHandlers.get("MouseDown")([e.button,this.normalizedCoord.x,this.normalizedCoord.y])}onMouseUp(e){this.videoPlayer.isVideoReady()&&this.streamMessageController.toStreamerHandlers.get("MouseUp")([e.button,this.normalizedCoord.x,this.normalizedCoord.y])}onMouseMove(e){if(!this.videoPlayer.isVideoReady())return;const t=this.videoPlayer.getVideoParentElement().clientWidth,n=this.videoPlayer.getVideoParentElement().clientHeight;for(this.x+=e.movementX,this.y+=e.movementY;this.x>t;)this.x-=t;for(;this.y>n;)this.y-=n;for(;this.x<0;)this.x+=t;for(;this.y<0;)this.y+=n;this.normalizedCoord=this.coordinateConverter.translateUnsigned(this.x,this.y);const s=this.coordinateConverter.translateSigned(e.movementX,e.movementY);this.streamMessageController.toStreamerHandlers.get("MouseMove")([this.normalizedCoord.x,this.normalizedCoord.y,s.x,s.y])}onMouseWheel(e){this.videoPlayer.isVideoReady()&&this.streamMessageController.toStreamerHandlers.get("MouseWheel")([e.wheelDelta,this.normalizedCoord.x,this.normalizedCoord.y])}onMouseDblClick(e){this.videoPlayer.isVideoReady()&&this.streamMessageController.toStreamerHandlers.get("MouseDouble")([e.button,this.normalizedCoord.x,this.normalizedCoord.y])}}class Sn extends vn{constructor(e,t,n,s){super(e,t,n,s),this.videoElementParent=t.getVideoParentElement(),this.onMouseUpListener=this.onMouseUp.bind(this),this.onMouseDownListener=this.onMouseDown.bind(this),this.onMouseDblClickListener=this.onMouseDblClick.bind(this),this.onMouseWheelListener=this.onMouseWheel.bind(this),this.onMouseMoveListener=this.onMouseMove.bind(this),this.onContextMenuListener=this.onContextMenu.bind(this)}register(){super.register(),this.videoElementParent.addEventListener("mousemove",this.onMouseMoveListener),this.videoElementParent.addEventListener("mousedown",this.onMouseDownListener),this.videoElementParent.addEventListener("mouseup",this.onMouseUpListener),this.videoElementParent.addEventListener("contextmenu",this.onContextMenuListener),this.videoElementParent.addEventListener("wheel",this.onMouseWheelListener),this.videoElementParent.addEventListener("dblclick",this.onMouseDblClickListener)}unregister(){this.videoElementParent.removeEventListener("mousemove",this.onMouseMoveListener),this.videoElementParent.removeEventListener("mousedown",this.onMouseDownListener),this.videoElementParent.removeEventListener("mouseup",this.onMouseUpListener),this.videoElementParent.removeEventListener("contextmenu",this.onContextMenuListener),this.videoElementParent.removeEventListener("wheel",this.onMouseWheelListener),this.videoElementParent.removeEventListener("dblclick",this.onMouseDblClickListener),super.unregister()}onMouseDown(e){if(!this.videoPlayer.isVideoReady())return;const t=this.coordinateConverter.translateUnsigned(e.offsetX,e.offsetY);this.streamMessageController.toStreamerHandlers.get("MouseDown")([e.button,t.x,t.y]),e.preventDefault()}onMouseUp(e){if(!this.videoPlayer.isVideoReady())return;const t=this.coordinateConverter.translateUnsigned(e.offsetX,e.offsetY);this.streamMessageController.toStreamerHandlers.get("MouseUp")([e.button,t.x,t.y]),e.preventDefault()}onContextMenu(e){this.videoPlayer.isVideoReady()&&e.preventDefault()}onMouseMove(e){if(!this.videoPlayer.isVideoReady())return;const t=this.coordinateConverter.translateUnsigned(e.offsetX,e.offsetY),n=this.coordinateConverter.translateSigned(e.movementX,e.movementY);this.streamMessageController.toStreamerHandlers.get("MouseMove")([t.x,t.y,n.x,n.y]),e.preventDefault()}onMouseWheel(e){if(!this.videoPlayer.isVideoReady())return;const t=this.coordinateConverter.translateUnsigned(e.offsetX,e.offsetY);this.streamMessageController.toStreamerHandlers.get("MouseWheel")([e.wheelDelta,t.x,t.y]),e.preventDefault()}onMouseDblClick(e){if(!this.videoPlayer.isVideoReady())return;const t=this.coordinateConverter.translateUnsigned(e.offsetX,e.offsetY);this.streamMessageController.toStreamerHandlers.get("MouseDouble")([e.button,t.x,t.y])}}class bn{constructor(e,t,n){this.fingers=[9,8,7,6,5,4,3,2,1,0],this.fingerIds=new Map,this.maxByteValue=255,this.streamMessageController=e,this.videoPlayer=t,this.coordinateConverter=n,this.videoElementParent=t.getVideoElement(),this.onTouchStartListener=this.onTouchStart.bind(this),this.onTouchEndListener=this.onTouchEnd.bind(this),this.onTouchMoveListener=this.onTouchMove.bind(this)}register(){this.videoElementParent.addEventListener("touchstart",this.onTouchStartListener),this.videoElementParent.addEventListener("touchend",this.onTouchEndListener),this.videoElementParent.addEventListener("touchmove",this.onTouchMoveListener)}unregister(){this.videoElementParent.addEventListener("touchstart",this.onTouchStartListener),this.videoElementParent.addEventListener("touchend",this.onTouchEndListener),this.videoElementParent.addEventListener("touchmove",this.onTouchMoveListener)}rememberTouch(e){const t=this.fingers.pop();void 0===t&&d.Info("exhausted touch identifiers"),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.videoPlayer.isVideoReady()){for(let t=0;t<e.changedTouches.length;t++)this.rememberTouch(e.changedTouches[t]);this.emitTouchData("TouchStart",e.changedTouches),e.preventDefault()}}onTouchEnd(e){if(this.videoPlayer.isVideoReady()){this.emitTouchData("TouchEnd",e.changedTouches);for(let t=0;t<e.changedTouches.length;t++)this.forgetTouch(e.changedTouches[t]);e.preventDefault()}}onTouchMove(e){this.videoPlayer.isVideoReady()&&(this.emitTouchData("TouchMove",e.touches),e.preventDefault())}emitTouchData(e,t){if(!this.videoPlayer.isVideoReady())return;const n=this.videoPlayer.getVideoParentElement().getBoundingClientRect(),s=this.streamMessageController.toStreamerHandlers;for(let r=0;r<t.length;r++){const i=1,o=t[r],a=o.clientX-n.left,l=o.clientY-n.top;d.Info(`F${this.fingerIds.get(o.identifier)}=(${a}, ${l})`);const h=this.coordinateConverter.translateUnsigned(a,l);switch(e){case"TouchStart":s.get("TouchStart")([i,h.x,h.y,this.fingerIds.get(o.identifier),this.maxByteValue*(o.force>0?o.force:1),h.inRange?1:0]);break;case"TouchEnd":s.get("TouchEnd")([i,h.x,h.y,this.fingerIds.get(o.identifier),this.maxByteValue*o.force,h.inRange?1:0]);break;case"TouchMove":s.get("TouchMove")([i,h.x,h.y,this.fingerIds.get(o.identifier),this.maxByteValue*(o.force>0?o.force:1),h.inRange?1:0])}}}}class Cn{constructor(e,t,n){this.streamMessageController=e,this.videoPlayer=t,this.coordinateConverter=n,this.onTouchStartListener=this.onTouchStart.bind(this),this.onTouchEndListener=this.onTouchEnd.bind(this),this.onTouchMoveListener=this.onTouchMove.bind(this),this.videoElementParentClientRect=this.videoPlayer.getVideoParentElement().getBoundingClientRect()}register(){document.addEventListener("touchstart",this.onTouchStartListener),document.addEventListener("touchend",this.onTouchEndListener),document.addEventListener("touchmove",this.onTouchMoveListener)}unregister(){document.removeEventListener("touchstart",this.onTouchStartListener),document.removeEventListener("touchend",this.onTouchEndListener),document.removeEventListener("touchmove",this.onTouchMoveListener)}onTouchStart(e){if(this.videoPlayer.isVideoReady()&&e.target===this.videoPlayer.getVideoElement()){if(null==this.fakeTouchFinger){const t=e.changedTouches[0];this.fakeTouchFinger={id:t.identifier,x:t.clientX-this.videoElementParentClientRect.left,y:t.clientY-this.videoElementParentClientRect.top};const n=this.videoPlayer.getVideoParentElement(),s=new MouseEvent("mouseenter",t);n.dispatchEvent(s);const r=this.coordinateConverter.translateUnsigned(this.fakeTouchFinger.x,this.fakeTouchFinger.y);this.streamMessageController.toStreamerHandlers.get("MouseDown")([fn.mainButton,r.x,r.y])}e.preventDefault()}}onTouchEnd(e){if(!this.videoPlayer.isVideoReady()||null==this.fakeTouchFinger)return;const t=this.videoPlayer.getVideoParentElement(),n=this.streamMessageController.toStreamerHandlers;for(let s=0;s<e.changedTouches.length;s++){const r=e.changedTouches[s];if(r.identifier===this.fakeTouchFinger.id){const e=r.clientX-this.videoElementParentClientRect.left,s=r.clientY-this.videoElementParentClientRect.top,i=this.coordinateConverter.translateUnsigned(e,s);n.get("MouseUp")([fn.mainButton,i.x,i.y]);const o=new MouseEvent("mouseleave",r);t.dispatchEvent(o),this.fakeTouchFinger=null;break}}e.preventDefault()}onTouchMove(e){if(!this.videoPlayer.isVideoReady()||null==this.fakeTouchFinger)return;const t=this.streamMessageController.toStreamerHandlers;for(let n=0;n<e.touches.length;n++){const s=e.touches[n];if(s.identifier===this.fakeTouchFinger.id){const e=s.clientX-this.videoElementParentClientRect.left,n=s.clientY-this.videoElementParentClientRect.top,r=this.coordinateConverter.translateUnsigned(e,n),i=this.coordinateConverter.translateSigned(e-this.fakeTouchFinger.x,n-this.fakeTouchFinger.y);t.get("MouseMove")([r.x,r.y,i.x,i.y]),this.fakeTouchFinger.x=e,this.fakeTouchFinger.y=n;break}}e.preventDefault()}}function Tn(e){return JSON.parse(JSON.stringify({buttons:e.buttons.map((e=>JSON.parse(JSON.stringify({pressed:e.pressed,touched:e.touched,value:e.value})))),axes:e.axes}))}var En,Mn;!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"}(En||(En={}));class kn{constructor(e){this.streamMessageController=e,this.onGamepadConnectedListener=this.onGamepadConnected.bind(this),this.onGamepadDisconnectedListener=this.onGamepadDisconnected.bind(this),this.beforeUnloadListener=this.onBeforeUnload.bind(this),this.requestAnimationFrame=(window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame).bind(window)}register(){window.addEventListener("beforeunload",this.beforeUnloadListener);const e=window;if("GamepadEvent"in e?(window.addEventListener("gamepadconnected",this.onGamepadConnectedListener),window.addEventListener("gamepaddisconnected",this.onGamepadDisconnectedListener)):"WebKitGamepadEvent"in e&&(window.addEventListener("webkitgamepadconnected",this.onGamepadConnectedListener),window.addEventListener("webkitgamepaddisconnected",this.onGamepadDisconnectedListener)),this.controllers=[],navigator.getGamepads)for(const e of navigator.getGamepads())e&&this.onGamepadConnected(new GamepadEvent("gamepadconnected",{gamepad:e}))}unregister(){window.removeEventListener("gamepadconnected",this.onGamepadConnectedListener),window.removeEventListener("gamepaddisconnected",this.onGamepadDisconnectedListener),window.removeEventListener("webkitgamepadconnected",this.onGamepadConnectedListener),window.removeEventListener("webkitgamepaddisconnected",this.onGamepadDisconnectedListener);for(const e of this.controllers)void 0!==e.id&&this.streamMessageController.toStreamerHandlers.get("GamepadDisconnected")([e.id]);this.controllers=[]}onGamepadResponseReceived(e){for(const t of this.controllers)if(void 0===t.id){t.id=e;break}}onGamepadConnected(e){const t=e.gamepad,n={currentState:Tn(t),prevState:Tn(t),id:void 0};this.controllers[t.index]=n,window.requestAnimationFrame((()=>this.updateStatus())),this.streamMessageController.toStreamerHandlers.get("GamepadConnected")()}onGamepadDisconnected(e){const t=e.gamepad,n=this.controllers[t.index];delete this.controllers[t.index],this.controllers=this.controllers.filter((e=>void 0!==e)),this.streamMessageController.toStreamerHandlers.get("GamepadDisconnected")([n.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.streamMessageController.toStreamerHandlers;for(const t of this.controllers){const n=void 0===t.id?this.controllers.indexOf(t):t.id,s=t.currentState;for(let s=0;s<t.currentState.buttons.length;s++){const r=t.currentState.buttons[s],i=t.prevState.buttons[s];r.pressed?s==En.LeftTrigger?e.get("GamepadAnalog")([n,5,r.value]):s==En.RightTrigger?e.get("GamepadAnalog")([n,6,r.value]):e.get("GamepadButtonPressed")([n,s,i.pressed?1:0]):!r.pressed&&i.pressed&&(s==En.LeftTrigger?e.get("GamepadAnalog")([n,5,0]):s==En.RightTrigger?e.get("GamepadAnalog")([n,6,0]):e.get("GamepadButtonReleased")([n,s,0]))}for(let t=0;t<s.axes.length;t+=2){const r=parseFloat(s.axes[t].toFixed(4)),i=-parseFloat(s.axes[t+1].toFixed(4));e.get("GamepadAnalog")([n,t+1,r]),e.get("GamepadAnalog")([n,t+2,i])}this.controllers[n].prevState=Tn(s)}this.controllers.length>0&&this.requestAnimationFrame((()=>this.updateStatus()))}onBeforeUnload(e){for(const e of this.controllers)this.streamMessageController.toStreamerHandlers.get("GamepadDisconnected")([e.id])}}class Rn{constructor(e,t,n){this.activeKeys=new Pn,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=n}registerKeyBoard(e){d.Info("Register Keyboard Events");const t=new pn(this.toStreamerMessagesProvider,e,this.activeKeys);return t.register(),t}registerMouse(e){let t;return d.Info("Register Mouse Events"),t=e==jt.HoveringMouse?new Sn(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter,this.activeKeys):new wn(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter,this.activeKeys),t.register(),t}registerTouch(e){let t;return d.Info("Registering Touch"),t=e?new Cn(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter):new bn(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter),t.register(),t}registerGamePad(){d.Info("Register Game Pad");const e=new kn(this.toStreamerMessagesProvider);return e.register(),e}}class Pn{constructor(){this.activeKeys=[],this.activeKeys=[]}getActiveKeys(){return this.activeKeys}}class In{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=()=>{null!=this.audioElement&&this.audioElement.paused&&this.audioElement.play(),this.videoElement.paused&&this.videoElement.play()},this.videoElement.onloadedmetadata=()=>{this.onVideoInitialized()},window.addEventListener("resize",(()=>this.resizePlayerStyle()),!0),window.addEventListener("orientationchange",(()=>this.onOrientationChange()))}setAudioElement(e){this.audioElement=e}play(){return this.videoElement.muted=this.config.isFlagEnabled(At.StartVideoMuted),this.videoElement.autoplay=this.config.isFlagEnabled(At.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(At.MatchViewportResolution))if((new Date).getTime()-this.lastTimeResized>300){const e=this.getVideoParentElement();if(!e)return;this.onMatchViewportResolutionCallback(e.clientWidth,e.clientHeight),this.lastTimeResized=(new Date).getTime()}else d.Info("Resizing too often - skipping"),clearTimeout(this.resizeTimeoutHandle),this.resizeTimeoutHandle=window.setTimeout((()=>this.updateVideoStreamSize()),100)}}class Ln{constructor(){this.toStreamerHandlers=new Map,this.fromStreamerHandlers=new Map,this.toStreamerMessages=new Map,this.fromStreamerMessages=new Map}populateDefaultProtocol(){this.toStreamerMessages.set("IFrameRequest",{id:0,structure:[]}),this.toStreamerMessages.set("RequestQualityControl",{id:1,structure:[]}),this.toStreamerMessages.set("FpsRequest",{id:2,structure:[]}),this.toStreamerMessages.set("AverageBitrateRequest",{id:3,structure:[]}),this.toStreamerMessages.set("StartStreaming",{id:4,structure:[]}),this.toStreamerMessages.set("StopStreaming",{id:5,structure:[]}),this.toStreamerMessages.set("LatencyTest",{id:6,structure:["string"]}),this.toStreamerMessages.set("RequestInitialSettings",{id:7,structure:[]}),this.toStreamerMessages.set("TestEcho",{id:8,structure:[]}),this.toStreamerMessages.set("DataChannelLatencyTest",{id:9,structure:[]}),this.toStreamerMessages.set("UIInteraction",{id:50,structure:["string"]}),this.toStreamerMessages.set("Command",{id:51,structure:["string"]}),this.toStreamerMessages.set("KeyDown",{id:60,structure:["uint8","uint8"]}),this.toStreamerMessages.set("KeyUp",{id:61,structure:["uint8"]}),this.toStreamerMessages.set("KeyPress",{id:62,structure:["uint16"]}),this.toStreamerMessages.set("MouseEnter",{id:70,structure:[]}),this.toStreamerMessages.set("MouseLeave",{id:71,structure:[]}),this.toStreamerMessages.set("MouseDown",{id:72,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.set("MouseUp",{id:73,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.set("MouseMove",{id:74,structure:["uint16","uint16","int16","int16"]}),this.toStreamerMessages.set("MouseWheel",{id:75,structure:["int16","uint16","uint16"]}),this.toStreamerMessages.set("MouseDouble",{id:76,structure:["uint8","uint16","uint16"]}),this.toStreamerMessages.set("TouchStart",{id:80,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.set("TouchEnd",{id:81,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.set("TouchMove",{id:82,structure:["uint8","uint16","uint16","uint8","uint8","uint8"]}),this.toStreamerMessages.set("GamepadConnected",{id:93,structure:[]}),this.toStreamerMessages.set("GamepadButtonPressed",{id:90,structure:["uint8","uint8","uint8"]}),this.toStreamerMessages.set("GamepadButtonReleased",{id:91,structure:["uint8","uint8","uint8"]}),this.toStreamerMessages.set("GamepadAnalog",{id:92,structure:["uint8","uint8","double"]}),this.toStreamerMessages.set("GamepadDisconnected",{id:94,structure:["uint8"]}),this.fromStreamerMessages.set(0,"QualityControlOwnership"),this.fromStreamerMessages.set(1,"Response"),this.fromStreamerMessages.set(2,"Command"),this.fromStreamerMessages.set(3,"FreezeFrame"),this.fromStreamerMessages.set(4,"UnfreezeFrame"),this.fromStreamerMessages.set(5,"VideoEncoderAvgQP"),this.fromStreamerMessages.set(6,"LatencyTest"),this.fromStreamerMessages.set(7,"InitialSettings"),this.fromStreamerMessages.set(8,"FileExtension"),this.fromStreamerMessages.set(9,"FileMimeType"),this.fromStreamerMessages.set(10,"FileContents"),this.fromStreamerMessages.set(11,"TestEcho"),this.fromStreamerMessages.set(12,"InputControlOwnership"),this.fromStreamerMessages.set(13,"GamepadResponse"),this.fromStreamerMessages.set(14,"DataChannelLatencyTest"),this.fromStreamerMessages.set(255,"Protocol")}registerMessageHandler(e,t,n){switch(e){case Mn.ToStreamer:this.toStreamerHandlers.set(t,n);break;case Mn.FromStreamer:this.fromStreamerHandlers.set(t,n);break;default:d.Info(`Unknown message direction ${e}`)}}}!function(e){e[e.ToStreamer=0]="ToStreamer",e[e.FromStreamer=1]="FromStreamer"}(Mn||(Mn={}));class xn{constructor(){this.responseEventListeners=new Map}addResponseEventListener(e,t){this.responseEventListeners.set(e,t)}removeResponseEventListener(e){this.responseEventListeners.delete(e)}onResponse(e){d.Info("DataChannelReceiveMessageType.Response");const t=new TextDecoder("utf-16").decode(e.slice(1));d.Info(t),this.responseEventListeners.forEach((e=>{e(t)}))}}class Fn{constructor(e,t){this.dataChannelSender=e,this.toStreamerMessagesMapProvider=t}sendMessageToStreamer(e,t){void 0===t&&(t=[]);const n=this.toStreamerMessagesMapProvider.toStreamerMessages.get(e);if(void 0===n)return void d.Error(`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`);if(n.structure&&t&&n.structure.length!==t.length)return void d.Error(`Provided message data doesn't match expected layout. Expected [ ${n.structure.map((e=>{switch(e){case"uint8":case"uint16":case"int16":case"float":case"double":return"number";case"string":return"string"}})).toString()} ] but received [ ${t.map((e=>typeof e)).toString()} ]`);let s=0;const r=new TextEncoder;t.forEach(((e,t)=>{switch(n.structure[t]){case"uint8":s+=1;break;case"uint16":case"int16":s+=2;break;case"float":s+=4;break;case"double":s+=8;break;case"string":s+=2,s+=2*r.encode(e).length}}));const i=new DataView(new ArrayBuffer(s+1));i.setUint8(0,n.id);let o=1;t.forEach(((e,t)=>{switch(n.structure[t]){case"uint8":i.setUint8(o,e),o+=1;break;case"uint16":i.setUint16(o,e,!0),o+=2;break;case"int16":i.setInt16(o,e,!0),o+=2;break;case"float":i.setFloat32(o,e,!0),o+=4;break;case"double":i.setFloat64(o,e,!0),o+=8;break;case"string":i.setUint16(o,e.length,!0),o+=2;for(let t=0;t<e.length;t++)i.setUint16(o,e.charCodeAt(t),!0),o+=2}})),this.dataChannelSender.canSend()?this.dataChannelSender.sendData(i.buffer):d.Info(`Data channel cannot send yet, skipping sending message: ${e} - ${new Uint8Array(i.buffer)}`)}}class On{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 Dn{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),d.Info(`Message Sent: ${new Uint8Array(e)}`),this.resetAfkWarningTimerOnDataSend()):d.Error(`Message Failed: ${new Uint8Array(e)}`)}resetAfkWarningTimerOnDataSend(){}}class An{reconfigure(e,t){const n=e.height/e.width,s=t.height/t.width;this.playerIsLarger=n>s,this.playerSize=e,this.ratio=this.playerIsLarger?n/s:s/n}translateUnsigned(e,t){const n=this.playerIsLarger?e/this.playerSize.width:this.ratio*(e/this.playerSize.width-.5)+.5,s=this.playerIsLarger?this.ratio*(t/this.playerSize.height-.5)+.5:t/this.playerSize.height;return n<0||n>1||s<0||s>1?{inRange:!1,x:65535,y:65535}:{inRange:!0,x:65536*n,y:65536*s}}translateSigned(e,t){return{x:32767*(this.playerIsLarger?e/(.5*this.playerSize.width):this.ratio*e/(.5*this.playerSize.width)),y:32767*(this.playerIsLarger?this.ratio*t/(.5*this.playerSize.height):t/(.5*this.playerSize.height))}}untranslateUnsigned(e,t){const n=this.playerIsLarger?e/65536:(e/65536-.5)/this.ratio+.5,s=this.playerIsLarger?(t/65536-.5)/this.ratio+.5:t/65536;return{x:n*this.playerSize.width,y:s*this.playerSize.height}}}class Nn{constructor(e){this._urlParams={};const t=new URLSearchParams(e);for(const[e,n]of t)this._urlParams[e.toLowerCase()]=n}has(e){return e.toLowerCase()in this._urlParams}get(e){return this.has(e)?this._urlParams[e.toLowerCase()]:null}}class Bn{constructor(e,t){this.shouldShowPlayOverlay=!0,this.autoJoinTimer=void 0,this.config=e,this.pixelStreaming=t,this.responseController=new xn,this.file=new un,this.sdpConstraints={offerToReceiveAudio:!0,offerToReceiveVideo:!0},this.afkController=new zt(this.config,this.pixelStreaming,this.onAfkTriggered.bind(this)),this.afkController.onAFKTimedOutCallback=()=>{this.closeSignalingServer("You have been disconnected due to inactivity.",!1)},this.freezeFrameController=new ze(this.pixelStreaming.videoElementParent),this.videoPlayer=new In(this.pixelStreaming.videoElementParent,this.config),this.videoPlayer.onVideoInitialized=()=>this.handleVideoInitialized(),this.videoPlayer.onMatchViewportResolutionCallback=(e,t)=>{const n={"Resolution.Width":e,"Resolution.Height":t};this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify(n)])},this.videoPlayer.onResizePlayerCallback=()=>{this.setUpMouseAndFreezeFrame()},this.streamController=new $e(this.videoPlayer),this.coordinateConverter=new An,this.sendrecvDataChannelController=new Kt,this.recvDataChannelController=new Kt,this.registerDataChannelEventEmitters(this.sendrecvDataChannelController),this.registerDataChannelEventEmitters(this.recvDataChannelController),this.dataChannelSender=new Dn(this.sendrecvDataChannelController),this.dataChannelSender.resetAfkWarningTimerOnDataSend=()=>this.afkController.resetAfkWarningTimer(),this.streamMessageController=new Ln,this.transport=new g,this.protocol=new He(this.transport),this.protocol.addListener(ce.typeName,(e=>this.handleOnConfigMessage(e))),this.protocol.addListener(ye.typeName,(e=>this.handleStreamerListMessage(e))),this.protocol.addListener(pe.typeName,(e=>this.handleStreamerIDChangedMessage(e))),this.protocol.addListener(Be.typeName,(e=>{const t=e;this.pixelStreaming._onPlayerCount(t.count)})),this.protocol.addListener(Te.typeName,(e=>this.handleWebRtcAnswer(e))),this.protocol.addListener(Ce.typeName,(e=>this.handleWebRtcOffer(e))),this.protocol.addListener(Fe.typeName,(e=>this.handleWebRtcSFUPeerDatachannels(e))),this.protocol.addListener(Me.typeName,(e=>{const t=e;this.handleIceCandidate(t.candidate)})),this.protocol.transport.addListener("open",(()=>{const e=We(fe);this.protocol.sendMessage(e),this.reconnectAttempt=0,this.isReconnecting=!1})),this.protocol.transport.addListener("error",(()=>{d.Error("Got a transport error.")})),this.protocol.transport.addListener("close",(e=>{const t=this.config.getNumericSettingValue(Bt.MaxReconnectAttempts),n=this.reconnectAttempt<t,s=(this.forceReconnect||this.enableAutoReconnect&&t>0&&n)&&1001!=e.code,r=!s,i=this.disconnectMessage?this.disconnectMessage:e.reason;this.forceReconnect=!1,this.pixelStreaming._onDisconnect(i,r),this.afkController.stopAfkWarningTimer(),this.statsTimerHandle&&void 0!==this.statsTimerHandle&&window.clearInterval(this.statsTimerHandle),this.setVideoEncoderAvgQP(0),this.setTouchInputEnabled(!1),this.setMouseInputEnabled(!1),this.setKeyboardInputEnabled(!1),this.setGamePadInputEnabled(!1),s&&setTimeout((()=>{this.reconnectAttempt++,this.doReconnect(e.reason)}),2e3)})),this.sendMessageController=new Fn(this.dataChannelSender,this.streamMessageController),this.toStreamerMessagesController=new On(this.sendMessageController),this.registerMessageHandlers(),this.streamMessageController.populateDefaultProtocol(),this.inputClassesFactory=new Rn(this.streamMessageController,this.videoPlayer,this.coordinateConverter),this.isUsingSFU=!1,this.isQualityController=!1,this.preferredCodec="",this.enableAutoReconnect=!0,this.forceReconnect=!1,this.reconnectAttempt=0,this.isReconnecting=!1,this.config._addOnOptionSettingChangedListener(_t.StreamerId,(e=>{if(""===e)return;this.peerConnectionController.peerConnection.close(),this.peerConnectionController.createPeerConnection(this.peerConfig,this.preferredCodec),this.subscribedStream=e;const t=We(ve,{streamerId:e});this.protocol.sendMessage(t)})),this.setVideoEncoderAvgQP(-1),this.signallingUrlBuilder=()=>this.config.getTextSettingValue(Vt.SignallingServerUrl)}requestUnquantizedAndDenormalizeUnsigned(e,t){return this.coordinateConverter.untranslateUnsigned(e,t)}handleOnMessage(e){const t=new Uint8Array(e.data);d.Info("Message incoming:"+t);const n=this.streamMessageController.fromStreamerMessages.get(t[0]);this.streamMessageController.fromStreamerHandlers.get(n)(e.data)}registerMessageHandlers(){this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"QualityControlOwnership",(e=>this.onQualityControlOwnership(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"Response",(e=>this.responseController.onResponse(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"Command",(e=>{this.onCommand(e)})),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"FreezeFrame",(e=>this.onFreezeFrameMessage(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"UnfreezeFrame",(()=>this.invalidateFreezeFrameAndEnableVideo())),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"VideoEncoderAvgQP",(e=>this.handleVideoEncoderAvgQP(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"LatencyTest",(e=>this.handleLatencyTestResult(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"DataChannelLatencyTest",(e=>this.handleDataChannelLatencyTestResponse(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"InitialSettings",(e=>this.handleInitialSettings(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"FileExtension",(e=>this.onFileExtension(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"FileMimeType",(e=>this.onFileMimeType(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"FileContents",(e=>this.onFileContents(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"TestEcho",(()=>{})),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"InputControlOwnership",(e=>this.onInputControlOwnership(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"GamepadResponse",(e=>this.onGamepadResponse(e))),this.streamMessageController.registerMessageHandler(Mn.FromStreamer,"Protocol",(e=>this.onProtocolMessage(e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"IFrameRequest",(()=>this.sendMessageController.sendMessageToStreamer("IFrameRequest"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"RequestQualityControl",(()=>this.sendMessageController.sendMessageToStreamer("RequestQualityControl"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"FpsRequest",(()=>this.sendMessageController.sendMessageToStreamer("FpsRequest"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"AverageBitrateRequest",(()=>this.sendMessageController.sendMessageToStreamer("AverageBitrateRequest"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"StartStreaming",(()=>this.sendMessageController.sendMessageToStreamer("StartStreaming"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"StopStreaming",(()=>this.sendMessageController.sendMessageToStreamer("StopStreaming"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"LatencyTest",(e=>this.sendMessageController.sendMessageToStreamer("LatencyTest",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"RequestInitialSettings",(()=>this.sendMessageController.sendMessageToStreamer("RequestInitialSettings"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"TestEcho",(()=>{})),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"UIInteraction",(e=>this.sendMessageController.sendMessageToStreamer("UIInteraction",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"Command",(e=>this.sendMessageController.sendMessageToStreamer("Command",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"TextboxEntry",(e=>this.sendMessageController.sendMessageToStreamer("TextboxEntry",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"KeyDown",(e=>this.sendMessageController.sendMessageToStreamer("KeyDown",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"KeyUp",(e=>this.sendMessageController.sendMessageToStreamer("KeyUp",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"KeyPress",(e=>this.sendMessageController.sendMessageToStreamer("KeyPress",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseEnter",(e=>this.sendMessageController.sendMessageToStreamer("MouseEnter",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseLeave",(e=>this.sendMessageController.sendMessageToStreamer("MouseLeave",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseDown",(e=>this.sendMessageController.sendMessageToStreamer("MouseDown",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseUp",(e=>this.sendMessageController.sendMessageToStreamer("MouseUp",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseMove",(e=>this.sendMessageController.sendMessageToStreamer("MouseMove",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseWheel",(e=>this.sendMessageController.sendMessageToStreamer("MouseWheel",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"MouseDouble",(e=>this.sendMessageController.sendMessageToStreamer("MouseDouble",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"TouchStart",(e=>this.sendMessageController.sendMessageToStreamer("TouchStart",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"TouchEnd",(e=>this.sendMessageController.sendMessageToStreamer("TouchEnd",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"TouchMove",(e=>this.sendMessageController.sendMessageToStreamer("TouchMove",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"GamepadConnected",(()=>this.sendMessageController.sendMessageToStreamer("GamepadConnected"))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"GamepadButtonPressed",(e=>this.sendMessageController.sendMessageToStreamer("GamepadButtonPressed",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"GamepadButtonReleased",(e=>this.sendMessageController.sendMessageToStreamer("GamepadButtonReleased",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"GamepadAnalog",(e=>this.sendMessageController.sendMessageToStreamer("GamepadAnalog",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"GamepadDisconnected",(e=>this.sendMessageController.sendMessageToStreamer("GamepadDisconnected",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XREyeViews",(e=>this.sendMessageController.sendMessageToStreamer("XREyeViews",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRHMDTransform",(e=>this.sendMessageController.sendMessageToStreamer("XRHMDTransform",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRControllerTransform",(e=>this.sendMessageController.sendMessageToStreamer("XRControllerTransform",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRSystem",(e=>this.sendMessageController.sendMessageToStreamer("XRSystem",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRButtonTouched",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonTouched",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRButtonTouchReleased",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonTouchReleased",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRButtonPressed",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonPressed",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRButtonReleased",(e=>this.sendMessageController.sendMessageToStreamer("XRButtonReleased",e))),this.streamMessageController.registerMessageHandler(Mn.ToStreamer,"XRAnalog",(e=>this.sendMessageController.sendMessageToStreamer("XRAnalog",e)))}onCommand(e){d.Info("DataChannelReceiveMessageType.Command");const t=new TextDecoder("utf-16").decode(e.slice(1));d.Info("Data Channel Command: "+t);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")||d.Error("Malformed protocol received. Ensure the protocol message contains a direction");const s=n.Direction;delete n.Direction,d.Info(`Received new ${s==Mn.FromStreamer?"FromStreamer":"ToStreamer"} protocol. Updating existing protocol...`),Object.keys(n).forEach((e=>{const t=n[e];switch(s){case Mn.ToStreamer:if(!Object.prototype.hasOwnProperty.call(t,"id"))return void d.Error(`ToStreamer->${e} protocol definition was malformed as it didn't contain at least an id\n\n Definition was: ${JSON.stringify(t,null,2)}`);if("UIInteraction"===e||"Command"===e||"LatencyTest"===e)return;this.streamMessageController.toStreamerHandlers.get(e)?this.streamMessageController.toStreamerMessages.set(e,t):d.Error(`There was no registered handler for "${e}" - try adding one using registerMessageHandler(MessageDirection.ToStreamer, "${e}", myHandler)`);break;case Mn.FromStreamer:if(!Object.prototype.hasOwnProperty.call(t,"id"))return void d.Error(`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.set(t.id,e):d.Error(`There was no registered handler for "${t}" - try adding one using registerMessageHandler(MessageDirection.FromStreamer, "${e}", myHandler)`);break;default:d.Error(`Unknown direction: ${s}`)}})),this.toStreamerMessagesController.SendRequestInitialSettings(),this.toStreamerMessagesController.SendRequestQualityControl()}catch(e){d.Info(e)}}onInputControlOwnership(e){const t=new Uint8Array(e);d.Info("DataChannelReceiveMessageType.InputControlOwnership");const n=new Boolean(t[1]).valueOf();d.Info(`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()}tryReconnect(e){this.forceReconnect=!0,this.doReconnect(e)}doReconnect(e){this.protocol?(this.isReconnecting=!0,this.protocol.isConnected()?(this.forceReconnect||(e=`${e} Reconnecting.`),this.closeSignalingServer(e,!0)):(this.pixelStreaming._onWebRtcAutoConnect(),this.connectToSignallingServer())):d.Info("This player has no protocol connection.")}loadFreezeFrameOrShowPlayOverlay(){this.pixelStreaming.dispatchEvent(new wt({shouldShowPlayOverlay:this.shouldShowPlayOverlay,isValid:this.freezeFrameController.valid,jpegData:this.freezeFrameController.jpeg})),!0===this.shouldShowPlayOverlay?(d.Info("showing play overlay"),this.resizePlayerStyle()):(d.Info("showing freeze frame"),this.freezeFrameController.showFreezeFrame()),setTimeout((()=>{this.videoPlayer.setVideoEnabled(!1)}),this.freezeFrameController.freezeFrameDelay)}onFreezeFrameMessage(e){d.Info("DataChannelReceiveMessageType.FreezeFrame");const t=new Uint8Array(e);this.freezeFrameController.processFreezeFrameMessage(t,(()=>this.loadFreezeFrameOrShowPlayOverlay()))}invalidateFreezeFrameAndEnableVideo(){d.Info("DataChannelReceiveMessageType.FreezeFrame"),setTimeout((()=>{this.pixelStreaming.dispatchEvent(new St),this.freezeFrameController.hideFreezeFrame()}),this.freezeFrameController.freezeFrameDelay),this.videoPlayer.getVideoElement()&&this.videoPlayer.setVideoEnabled(!0)}onFileExtension(e){const t=new Uint8Array(e);cn.setExtensionFromBytes(t,this.file)}onFileMimeType(e){const t=new Uint8Array(e);cn.setMimeTypeFromBytes(t,this.file)}onFileContents(e){const t=new Uint8Array(e);cn.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 ft({message:e})),d.Error(e),void this.closeSignalingServer("Stream not initialized correctly",!1)}if(this.videoPlayer.hasVideoSource()){if(this.setTouchInputEnabled(this.config.isFlagEnabled(At.TouchInput)),this.pixelStreaming.dispatchEvent(new yt),this.streamController.audioElement.srcObject){const e=this.config.isFlagEnabled(At.StartVideoMuted);this.streamController.audioElement.muted=e,e?this.playVideo():this.streamController.audioElement.play().then((()=>{this.playVideo()})).catch((e=>{d.Info(e),d.Info("Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."),this.pixelStreaming.dispatchEvent(new vt({reason:e}))}))}else this.playVideo();this.shouldShowPlayOverlay=!1,this.freezeFrameController.showFreezeFrame()}else d.Warning("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(),d.Info(e),d.Info("Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."),this.pixelStreaming.dispatchEvent(new vt({reason:e}))}))}autoPlayVideoOrSetUpPlayOverlay(){this.config.isFlagEnabled(At.AutoPlayVideo)&&this.playStream(),this.resizePlayerStyle()}connectToSignallingServer(){this.locallyClosed=!1,this.enableAutoReconnect=!0,this.disconnectMessage=null;const e=this.signallingUrlBuilder();this.protocol.connect(e)}startSession(e){if(this.peerConfig=e,this.config.isFlagEnabled(At.ForceTURN)&&!this.checkTurnServerAvailability(e))return d.Info("No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead"),void this.closeSignalingServer("TURN cannot be forced, closing connection. Please use STUN instead.",!1);this.peerConnectionController=new rn(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)}checkTurnServerAvailability(e){if(!e.iceServers)return d.Info("A turn sever was not found"),!1;for(const t of e.iceServers)for(const e of t.urls)if(e.includes("turn"))return d.Info(`A turn sever was found at ${e}`),!0;return d.Info("A turn sever was not found"),!1}handleOnConfigMessage(e){this.resizePlayerStyle(),this.startSession(e.peerConnectionOptions)}handleStreamerListMessage(e){d.Info(`Got streamer list ${e.ids}`);let t="";const n=this.config.getSettingOption(_t.StreamerId);n.selected.toString().trim()&&(t=n.selected);const s=[...e.ids];s.unshift(""),this.config.setOptionSettingOptions(_t.StreamerId,s);let r="";const i=this.config.isFlagEnabled(At.WaitForStreamer),o=this.config.getNumericSettingValue(Bt.MaxReconnectAttempts),a=this.config.getNumericSettingValue(Bt.StreamerAutoJoinInterval),l=this.config.useUrlParams,h=new Nn(window.location.search);l&&h.has(_t.StreamerId)?t=h.get(_t.StreamerId):this.subscribedStream&&(t=this.subscribedStream),t&&e.ids.includes(t)?r=t:t&&i||1!=e.ids.length||(r=e.ids[0]),r?(this.reconnectAttempt=0,this.isReconnecting=!1,this.config.setOptionSettingValue(_t.StreamerId,r)):i&&(this.reconnectAttempt<o?(this.reconnectAttempt++,this.isReconnecting=!0,setTimeout((()=>{this.protocol.sendMessage(We(fe))}),a)):(this.reconnectAttempt=0,this.isReconnecting=!1,this.enableAutoReconnect=!1)),this.pixelStreaming.dispatchEvent(new Ct({messageStreamerList:e,autoSelectedStreamerId:r,wantedStreamerId:t}))}handleStreamerIDChangedMessage(e){const t=e.newID,n=this.config.getSettingOption(_t.StreamerId),s=n.onChange;n.onChange=()=>{};const r=n.options;for(let e=0;e<r.length;++e)if(r[e]==this.subscribedStream){r[e]=t;break}n.options=r,n.selected=t,n.onChange=s,this.subscribedStream=e.newID,this.pixelStreaming.dispatchEvent(new Tt({newID:t}))}handleWebRtcAnswer(e){d.Info(`Got answer sdp ${e.sdp}`);const t={sdp:e.sdp,type:"answer"};this.peerConnectionController.receiveAnswer(t),this.handlePostWebrtcNegotiation()}handleWebRtcOffer(e){d.Info(`Got offer sdp ${e.sdp}`),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.protocol.sendMessage(We(Oe)),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(At.MouseInput)),this.setKeyboardInputEnabled(this.config.isFlagEnabled(At.KeyboardInput)),this.setGamePadInputEnabled(this.config.isFlagEnabled(At.GamepadInput))}handleIceCandidate(e){d.Info("Web RTC Controller: onWebRtcIce");const t=new RTCIceCandidate(e);this.peerConnectionController.handleOnIce(t)}handleSendIceCandidate(e){d.Info("OnIceCandidate"),e.candidate&&e.candidate.candidate&&this.protocol.sendMessage(We(Me,{candidate:e.candidate}))}handleDataChannel(e){d.Info("Data channel created for us by browser as we are a receiving peer."),this.sendrecvDataChannelController.dataChannel=e.channel,this.sendrecvDataChannelController.setupDataChannel(),this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}handleSendWebRTCOffer(e){d.Info("Sending the offer to the Server");const t={sdp:e.sdp,minBitrateBps:1e3*this.config.getNumericSettingValue(Bt.WebRTCMinBitrate),maxBitrateBps:1e3*this.config.getNumericSettingValue(Bt.WebRTCMaxBitrate)};this.protocol.sendMessage(We(Ce,t))}handleSendWebRTCAnswer(e){d.Info("Sending the answer to the Server");const t={sdp:e.sdp,minBitrateBps:1e3*this.config.getNumericSettingValue(Bt.WebRTCMinBitrate),maxBitrateBps:1e3*this.config.getNumericSettingValue(Bt.WebRTCMaxBitrate)};this.protocol.sendMessage(We(Te,t)),this.isUsingSFU&&this.protocol.sendMessage(We(xe))}setUpMouseAndFreezeFrame(){const e=this.videoPlayer.getVideoParentElement(),t=this.videoPlayer.getVideoElement();this.coordinateConverter.reconfigure({width:e.clientWidth,height:e.clientHeight},{width:t.videoWidth,height:t.videoHeight}),this.freezeFrameController.freezeFrame.resize()}closeSignalingServer(e,t){var n;this.locallyClosed=!0,this.enableAutoReconnect=t,this.disconnectMessage=e,null===(n=this.protocol)||void 0===n||n.disconnect(1e3,e)}closePeerConnection(){var e;null===(e=this.peerConnectionController)||void 0===e||e.close()}close(){this.closeSignalingServer("",!1),this.closePeerConnection()}getStats(){this.peerConnectionController.generateStats()}sendLatencyTest(){this.latencyStartTime=Date.now(),this.streamMessageController.toStreamerHandlers.get("LatencyTest")([JSON.stringify({StartTime:this.latencyStartTime})])}sendDataChannelLatencyTest(e){this.streamMessageController.toStreamerHandlers.get("DataChannelLatencyTest")([JSON.stringify(e)])}sendEncoderMinQP(e){d.Info(`MinQP=${e}\n`),null!=e&&this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"Encoder.MinQP":e})])}sendEncoderMaxQP(e){d.Info(`MaxQP=${e}\n`),null!=e&&this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"Encoder.MaxQP":e})])}sendWebRTCMinBitrate(e){d.Info(`WebRTC Min Bitrate=${e}`),null!=e&&this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"WebRTC.MinBitrate":e})])}sendWebRTCMaxBitrate(e){d.Info(`WebRTC Max Bitrate=${e}`),null!=e&&this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"WebRTC.MaxBitrate":e})])}sendWebRTCFps(e){d.Info(`WebRTC FPS=${e}`),null!=e&&(this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"WebRTC.Fps":e})]),this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"WebRTC.MaxFps":e})]))}sendShowFps(){d.Info("---- Sending show stat to UE ----"),this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({"stat.fps":""})])}sendIframeRequest(){d.Info("---- Sending Request for an IFrame ----"),this.streamMessageController.toStreamerHandlers.get("IFrameRequest")()}emitUIInteraction(e){d.Info("---- Sending custom UIInteraction message ----"),this.streamMessageController.toStreamerHandlers.get("UIInteraction")([JSON.stringify(e)])}emitCommand(e){d.Info("---- Sending custom Command message ----"),this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify(e)])}emitConsoleCommand(e){d.Info("---- Sending custom Command:ConsoleCommand message ----"),this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ConsoleCommand:e})])}sendRequestQualityControlOwnership(){d.Info("---- Sending Request to Control Quality ----"),this.toStreamerMessagesController.SendRequestQualityControl()}handleLatencyTestResult(e){d.Info("DataChannelReceiveMessageType.latencyTest");const t=new TextDecoder("utf-16").decode(e.slice(1)),n=new hn;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)}handleDataChannelLatencyTestResponse(e){d.Info("DataChannelReceiveMessageType.dataChannelLatencyResponse");const t=new TextDecoder("utf-16").decode(e.slice(1)),n=JSON.parse(t);this.pixelStreaming._onDataChannelLatencyTestResponse(n)}handleInitialSettings(e){d.Info("DataChannelReceiveMessageType.InitialSettings");const t=new TextDecoder("utf-16").decode(e.slice(1)),n=JSON.parse(t),s=new on;n.Encoder&&(s.EncoderSettings=n.Encoder),n.WebRTC&&(s.WebRTCSettings=n.WebRTC),n.PixelStreaming&&(s.PixelStreamingSettings=n.PixelStreaming),n.ConfigOptions&&void 0!==n.ConfigOptions.DefaultToHover&&this.config.setFlagEnabled(At.HoveringMouseMode,!!n.ConfigOptions.DefaultToHover),s.ueCompatible(),d.Info(t),this.pixelStreaming._onInitialSettings(s)}handleVideoEncoderAvgQP(e){d.Info("DataChannelReceiveMessageType.VideoEncoderAvgQP");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);d.Info("DataChannelReceiveMessageType.QualityControlOwnership"),this.isQualityController=new Boolean(t[1]).valueOf(),d.Info(`Received quality controller message, will control quality: ${this.isQualityController}`),this.pixelStreaming._onQualityControlOwnership(this.isQualityController)}handleVideoStats(e){this.pixelStreaming._onVideoStats(e)}resizePlayerStyle(){this.videoPlayer.resizePlayerStyle()}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.unregister(),e&&(this.keyboardController=this.inputClassesFactory.registerKeyBoard(this.config))}setMouseInputEnabled(e){var t;if(null===(t=this.mouseController)||void 0===t||t.unregister(),e){const e=this.config.isFlagEnabled(At.HoveringMouseMode)?jt.HoveringMouse:jt.LockedMouse;this.mouseController=this.inputClassesFactory.registerMouse(e)}}setTouchInputEnabled(e){var t;null===(t=this.touchController)||void 0===t||t.unregister(),e&&(this.touchController=this.inputClassesFactory.registerTouch(this.config.isFlagEnabled(At.FakeMouseWithTouches)))}setGamePadInputEnabled(e){var t;null===(t=this.gamePadController)||void 0===t||t.unregister(),e&&(this.gamePadController=this.inputClassesFactory.registerGamePad())}registerDataChannelEventEmitters(e){e.onOpen=(e,t)=>this.pixelStreaming.dispatchEvent(new lt({label:e,event:t})),e.onClose=(e,t)=>this.pixelStreaming.dispatchEvent(new dt({label:e,event:t})),e.onError=(e,t)=>this.pixelStreaming.dispatchEvent(new ht({label:e,event:t}))}registerMessageHandler(e,t,n){t===Mn.FromStreamer&&void 0===n&&d.Warning(`Unable to register handler for ${e} as no handler was passed`),this.streamMessageController.registerMessageHandler(t,e,(s=>void 0===n&&t===Mn.ToStreamer?this.sendMessageController.sendMessageToStreamer(e,s):n(s)))}}class Un{constructor(e){this.toStreamerMessagesProvider=e,this.controllers=[]}updateStatus(e,t,n){if(e.gamepad){const s=t.getPose(e.gripSpace,n);if(!s)return;let r=0;e.profiles.includes("htc-vive")?r=1:e.profiles.includes("oculus-touch")&&(r=2),this.toStreamerMessagesProvider.toStreamerHandlers.get("XRSystem")([r]);let i=2;switch(e.handedness){case"left":i=0;break;case"right":i=1}const o=s.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],i]),void 0===this.controllers[i]&&(this.controllers[i]={prevState:void 0,currentState:void 0,id:void 0},this.controllers[i].prevState=Tn(e.gamepad)),this.controllers[i].currentState=Tn(e.gamepad);const l=this.controllers[i],d=l.currentState,h=l.prevState;for(let e=0;e<d.buttons.length;e++){const t=d.buttons[e],n=h.buttons[e];if(t.pressed){const s=n.pressed?1:0;this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonPressed")([i,e,s,t.value])}else n.pressed&&this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonReleased")([i,e,0]);if(t.touched){const t=n.touched?1:0;this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonTouched")([i,e,t])}else n.touched&&this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonTouchReleased")([i,e,0])}for(let e=0;e<d.axes.length;e++){const t=d.axes[e];t!=h.axes[e]&&this.toStreamerMessagesProvider.toStreamerHandlers.get("XRAnalog")([i,e,t])}this.controllers[i].prevState=d}}}class Vn{constructor(e){this.xrViewerPose=null,this.EPSILON=1e-7,this.videoTexture=null,this.prevVideoWidth=0,this.prevVideoHeight=0,this.leftView=null,this.rightView=null,this.lastSentLeftEyeProj=null,this.lastSentRightEyeProj=null,this.lastSentRelativeLeftEyePos=null,this.lastSentRelativeRightEyePos=null,this.xrSession=null,this.webRtcController=e,this.xrGamepadController=new Un(this.webRtcController.streamMessageController),this.onSessionEnded=new EventTarget,this.onSessionStarted=new EventTarget,this.onFrame=new EventTarget}xrClicked(){if(this.xrSession)this.xrSession.end();else{if(!navigator.xr)return void d.Error("This browser does not support XR.");navigator.xr.requestSession("immersive-vr",{optionalFeatures:[]}).then((e=>{this.onXrSessionStarted(e)}))}}onXrSessionEnded(){d.Info("XR Session ended"),this.xrSession=null,this.onSessionEnded.dispatchEvent(new Event("xrSessionEnded"))}initGL(){if(this.gl)return;const e=document.createElement("canvas");this.gl=e.getContext("webgl2",{xrCompatible:!0}),this.gl.clearColor(0,0,0,1)}initShaders(){const e=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(e,"\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n\n // varyings\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n // pass the texCoord to the fragment shader\n // The GPU will interpolate this value between points.\n v_texCoord = a_texCoord;\n }\n "),this.gl.compileShader(e);const t=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(t,"\n precision mediump float;\n\n // our texture\n uniform sampler2D u_image;\n\n // the texCoords passed in from the vertex shader.\n varying vec2 v_texCoord;\n\n void main() {\n gl_FragColor = texture2D(u_image, v_texCoord);\n }\n "),this.gl.compileShader(t);const n=this.gl.createProgram();this.gl.attachShader(n,e),this.gl.attachShader(n,t),this.gl.linkProgram(n),this.gl.useProgram(n),this.positionLocation=this.gl.getAttribLocation(n,"a_position"),this.texcoordLocation=this.gl.getAttribLocation(n,"a_texCoord")}updateVideoTexture(){this.videoTexture||(this.videoTexture=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),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.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR));const e=this.webRtcController.videoPlayer.getVideoElement().videoHeight,t=this.webRtcController.videoPlayer.getVideoElement().videoWidth;this.prevVideoHeight!=e||this.prevVideoWidth!=t?this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,e,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.webRtcController.videoPlayer.getVideoElement()):this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,t,e,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.webRtcController.videoPlayer.getVideoElement()),this.prevVideoHeight=e,this.prevVideoWidth=t}initBuffers(){this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-1,1,1,1,-1,-1,-1,-1,1,1,1,-1]),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.texcoordBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texcoordBuffer),this.gl.enableVertexAttribArray(this.texcoordLocation),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.vertexAttribPointer(this.texcoordLocation,2,this.gl.FLOAT,!1,0,0)}onXrSessionStarted(e){d.Info("XR Session started"),this.xrSession=e,this.xrSession.addEventListener("end",(()=>{this.onXrSessionEnded()})),this.initGL(),this.initShaders(),this.initBuffers(),e.requestReferenceSpace("local").then((t=>{if(this.xrRefSpace=t,this.xrSession.updateRenderState({baseLayer:new XRWebGLLayer(this.xrSession,this.gl)}),this.xrSession.supportedFrameRates)for(const t of this.xrSession.supportedFrameRates)90==t&&e.updateTargetFrameRate(90);this.xrSession.requestAnimationFrame(this.onXrFrame.bind(this))})),this.onSessionStarted.dispatchEvent(new Event("xrSessionStarted"))}areArraysEqual(e,t){return e.length===t.length&&e.every(((e,n)=>Math.abs(e-t[n])<=this.EPSILON))}arePointsEqual(e,t){return Math.abs(e.x-t.x)>=this.EPSILON&&Math.abs(e.y-t.y)>=this.EPSILON&&Math.abs(e.z-t.z)>=this.EPSILON}sendXRDataToUE(){if(null==this.leftView||null==this.rightView)return;let e=null==this.lastSentLeftEyeProj||null==this.lastSentRightEyeProj||null==this.lastSentRelativeLeftEyePos||null==this.lastSentRelativeRightEyePos;const t=this.leftView.transform.matrix,n=this.leftView.projectionMatrix,s=this.rightView.transform.matrix,r=this.rightView.projectionMatrix,i=this.xrViewerPose.transform.matrix;if(!e&&null!=this.lastSentLeftEyeProj&&null!=this.lastSentRightEyeProj){const t=this.areArraysEqual(n,this.lastSentLeftEyeProj),s=this.areArraysEqual(r,this.lastSentRightEyeProj);e=0==t||0==s}const o=new DOMPointReadOnly(this.leftView.transform.position.x-this.xrViewerPose.transform.position.x,this.leftView.transform.position.y-this.xrViewerPose.transform.position.y,this.leftView.transform.position.z-this.xrViewerPose.transform.position.z,1),a=new DOMPointReadOnly(this.leftView.transform.position.x-this.xrViewerPose.transform.position.x,this.leftView.transform.position.y-this.xrViewerPose.transform.position.y,this.leftView.transform.position.z-this.xrViewerPose.transform.position.z,1);if(!e&&null!=this.lastSentRelativeLeftEyePos&&null!=this.lastSentRelativeRightEyePos){const t=this.arePointsEqual(o,this.lastSentRelativeLeftEyePos),n=this.arePointsEqual(a,this.lastSentRelativeRightEyePos);e=0==t||0==n}e?(this.webRtcController.streamMessageController.toStreamerHandlers.get("XREyeViews")([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],n[0],n[4],n[8],n[12],n[1],n[5],n[9],n[13],n[2],n[6],n[10],n[14],n[3],n[7],n[11],n[15],s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15],r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15],i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]]),this.lastSentLeftEyeProj=n,this.lastSentRightEyeProj=r,this.lastSentRelativeLeftEyePos=o,this.lastSentRelativeRightEyePos=a):this.webRtcController.streamMessageController.toStreamerHandlers.get("XRHMDTransform")([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]])}onXrFrame(e,t){if(this.xrViewerPose=t.getViewerPose(this.xrRefSpace),this.xrViewerPose){if(this.updateViews(),null==this.leftView||null==this.rightView)return;this.sendXRDataToUE(),this.updateVideoTexture(),this.render()}this.webRtcController.config.isFlagEnabled(At.XRControllerInput)&&this.xrSession.inputSources.forEach(((e,n,s)=>{this.xrGamepadController.updateStatus(e,t,this.xrRefSpace)}),this),this.xrSession.requestAnimationFrame(((e,t)=>this.onXrFrame(e,t))),this.onFrame.dispatchEvent(new xt({time:e,frame:t}))}updateViews(){if(this.xrViewerPose)for(const e of this.xrViewerPose.views)"left"===e.eye?this.leftView=e:"right"===e.eye&&(this.rightView=e)}render(){if(!this.gl)return;const e=this.xrSession.renderState.baseLayer;this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e.framebuffer),this.gl.viewport(0,0,e.framebufferWidth,e.framebufferHeight),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}static isSessionSupported(e){return"https:"!==location.protocol&&d.Info("WebXR requires https, if you want WebXR use https."),navigator.xr?navigator.xr.isSessionSupported(e):new Promise((()=>!1))}}class Wn{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,this.hiddenInput.style.position="absolute",this.hiddenInput.style.left="-10%",this.hiddenInput.style.width="0px",this.hiddenInput.style.opacity="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.style.display="none",this.editTextButton.addEventListener("touchend",(e=>{this.hiddenInput.focus(),e.preventDefault()})))}showOnScreenKeyboard(e){if(e.showOnScreenKeyboard){this.editTextButton.style.display="default";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.style.display="none",this.hiddenInput.blur()}}class _n{constructor(e){this.seq=e.Seq,this.playerSentTimestamp=Date.now(),this.requestFillerSize=e.Filler?e.Filler.length:0}update(e){this.playerReceivedTimestamp=Date.now(),this.streamerReceivedTimestamp=e.ReceivedTimestamp,this.streamerSentTimestamp=e.SentTimestamp,this.responseFillerSize=e.Filler?e.Filler.length:0}}class Hn{constructor(e,t){this.sink=e,this.callback=t,this.records=new Map,this.seq=0}start(e){return!this.isRunning()&&(this.startTime=Date.now(),this.records.clear(),this.interval=setInterval((()=>{Date.now()-this.startTime>=e.duration?this.stop():this.sendRequest(e.requestSize,e.responseSize)}).bind(this),Math.floor(1e3/e.rps)),!0)}stop(){this.interval&&(clearInterval(this.interval),this.interval=void 0,this.callback(this.produceResult()))}produceResult(){const e=new Map(this.records);return{records:e,dataChannelRtt:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.playerReceivedTimestamp-t.playerSentTimestamp)),0)/this.records.size),playerToStreamerTime:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.streamerReceivedTimestamp-t.playerSentTimestamp)),0)/this.records.size),streamerToPlayerTime:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.playerReceivedTimestamp-t.streamerSentTimestamp)),0)/this.records.size),exportLatencyAsCSV:()=>{let t="Timestamp;RTT;PlayerToStreamer;StreamerToPlayer;\n";return e.forEach((e=>{t+=e.playerSentTimestamp+";",t+=e.playerReceivedTimestamp-e.playerSentTimestamp+";",t+=e.streamerReceivedTimestamp-e.playerSentTimestamp+";",t+=e.playerReceivedTimestamp-e.streamerSentTimestamp+";",t+="\n"})),t}}}isRunning(){return!!this.interval}receive(e){if(!this.isRunning())return;if(!e)return void d.Error("Undefined response from server");const t=this.records.get(e.Seq);t&&t.update(e)}sendRequest(e,t){const n=this.createRequest(e,t),s=new _n(n);this.records.set(s.seq,s),this.sink(n)}createRequest(e,t){return{Seq:this.seq++,FillResponseSize:t,Filler:e?"A".repeat(e):""}}}class $n{constructor(e,t){this.allowConsoleCommands=!1,this.config=e,(null==t?void 0:t.videoElementParent)&&(this._videoElementParent=t.videoElementParent),this._eventEmitter=new Dt,this.configureSettings(),this.setWebRtcPlayerController(new Bn(this.config,this)),this.onScreenKeyboardHelper=new Wn(this.videoElementParent),this.onScreenKeyboardHelper.unquantizeAndDenormalizeUnsigned=(e,t)=>this._webRtcController.requestUnquantizedAndDenormalizeUnsigned(e,t),this._activateOnScreenKeyboard=e=>this.onScreenKeyboardHelper.showOnScreenKeyboard(e),this._webXrController=new Vn(this._webRtcController),this._setupWebRtcTCPRelayDetection=this._setupWebRtcTCPRelayDetection.bind(this),this._eventEmitter.addEventListener("webRtcConnected",(e=>{this._eventEmitter.addEventListener("statsReceived",this._setupWebRtcTCPRelayDetection)}))}get videoElementParent(){return this._videoElementParent||(this._videoElementParent=document.createElement("div"),this._videoElementParent.id="videoElementParent"),this._videoElementParent}configureSettings(){this.config._addOnSettingChangedListener(At.IsQualityController,(e=>{!0!==e||this._webRtcController.isQualityController||this._webRtcController.sendRequestQualityControlOwnership()})),this.config._addOnSettingChangedListener(At.AFKDetection,(e=>{this._webRtcController.setAfkEnabled(e)})),this.config._addOnSettingChangedListener(At.MatchViewportResolution,(()=>{this._webRtcController.videoPlayer.updateVideoStreamSize()})),this.config._addOnSettingChangedListener(At.HoveringMouseMode,(e=>{this.config.setFlagLabel(At.HoveringMouseMode,`Control Scheme: ${e?"Hovering":"Locked"} Mouse`),this._webRtcController.setMouseInputEnabled(this.config.isFlagEnabled(At.MouseInput))})),this.config._addOnSettingChangedListener(At.KeyboardInput,(e=>{this._webRtcController.setKeyboardInputEnabled(e)})),this.config._addOnSettingChangedListener(At.MouseInput,(e=>{this._webRtcController.setMouseInputEnabled(e)})),this.config._addOnSettingChangedListener(At.FakeMouseWithTouches,(e=>{this._webRtcController.setTouchInputEnabled(this.config.isFlagEnabled(At.TouchInput))})),this.config._addOnSettingChangedListener(At.TouchInput,(e=>{this._webRtcController.setTouchInputEnabled(e)})),this.config._addOnSettingChangedListener(At.GamepadInput,(e=>{this._webRtcController.setGamePadInputEnabled(e)})),this.config._addOnNumericSettingChangedListener(Bt.MinQP,(e=>{d.Info("-------- Sending MinQP --------"),this._webRtcController.sendEncoderMinQP(e),d.Info("-------------------------------------------")})),this.config._addOnNumericSettingChangedListener(Bt.MaxQP,(e=>{d.Info("-------- Sending encoder settings --------"),this._webRtcController.sendEncoderMaxQP(e),d.Info("-------------------------------------------")})),this.config._addOnNumericSettingChangedListener(Bt.WebRTCMinBitrate,(e=>{d.Info("-------- Sending web rtc settings --------"),this._webRtcController.sendWebRTCMinBitrate(1e3*e),d.Info("-------------------------------------------")})),this.config._addOnNumericSettingChangedListener(Bt.WebRTCMaxBitrate,(e=>{d.Info("-------- Sending web rtc settings --------"),this._webRtcController.sendWebRTCMaxBitrate(1e3*e),d.Info("-------------------------------------------")})),this.config._addOnNumericSettingChangedListener(Bt.WebRTCFPS,(e=>{d.Info("-------- Sending web rtc settings --------"),this._webRtcController.sendWebRTCFps(e),d.Info("-------------------------------------------")})),this.config._addOnOptionSettingChangedListener(_t.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(_t.PreferredCodec).selected),this._webRtcController.resizePlayerStyle(),this.checkForAutoConnect()}connect(){this._eventEmitter.dispatchEvent(new gt),this._webRtcController.connectToSignallingServer()}reconnect(){this._eventEmitter.dispatchEvent(new pt),this._webRtcController.tryReconnect("Reconnecting...")}disconnect(){this._eventEmitter.dispatchEvent(new mt),this._webRtcController.close()}play(){this._onStreamLoading(),this._webRtcController.playStream()}checkForAutoConnect(){this.config.isFlagEnabled(At.AutoConnect)&&(this._onWebRtcAutoConnect(),this._webRtcController.connectToSignallingServer())}unmuteMicrophone(e=!1){if(!this.config.isFlagEnabled("UseMic"))return e?(this.config.setFlagEnabled("UseMic",!0),void this.reconnect()):void d.Warning("Trying to unmute mic, but PixelStreaming was initialized with no microphone track. Call with forceEnable == true to re-connect with a mic track.");this.setMicrophoneMuted(!1)}muteMicrophone(){this.config.isFlagEnabled("UseMic")?this.setMicrophoneMuted(!0):d.Info("Trying to mute mic, but PixelStreaming has no microphone track, so sending sound is already disabled.")}setMicrophoneMuted(e){var t,n,s,r;for(const i of null!==(r=null===(s=null===(n=null===(t=this._webRtcController)||void 0===t?void 0:t.peerConnectionController)||void 0===n?void 0:n.peerConnection)||void 0===s?void 0:s.getTransceivers())&&void 0!==r?r:[])nn.canTransceiverSendAudio(i)&&(i.sender.track.enabled=!e)}unmuteCamera(e=!1){if(!this.config.isFlagEnabled("UseCamera"))return e?(this.config.setFlagEnabled("UseCamera",!0),void this.reconnect()):void d.Warning("Trying to unmute video, but PixelStreaming was initialized with no video track. Call with forceEnable == true to re-connect with a video track.");this.setCameraMuted(!1)}muteCamera(){this.config.isFlagEnabled("UseCamera")?this.setCameraMuted(!0):d.Info("Trying to mute camera, but PixelStreaming has no video track, so sending video is already disabled.")}setCameraMuted(e){var t,n,s,r;for(const i of null!==(r=null===(s=null===(n=null===(t=this._webRtcController)||void 0===t?void 0:t.peerConnectionController)||void 0===n?void 0:n.peerConnection)||void 0===s?void 0:s.getTransceivers())&&void 0!==r?r:[])nn.canTransceiverSendVideo(i)&&(i.sender.track.enabled=!e)}_onWebRtcAutoConnect(){this._eventEmitter.dispatchEvent(new st)}_onWebRtcSdp(){this._eventEmitter.dispatchEvent(new nt)}_onStreamLoading(){this._eventEmitter.dispatchEvent(new ut)}_onDisconnect(e,t){this._eventEmitter.dispatchEvent(new at({eventString:e,allowClickToReconnect:t}))}_onWebRtcConnecting(){this._eventEmitter.dispatchEvent(new rt)}_onWebRtcConnected(){this._eventEmitter.dispatchEvent(new it)}_onWebRtcFailed(){this._eventEmitter.dispatchEvent(new ot)}_onVideoInitialized(){this._eventEmitter.dispatchEvent(new ct),this._videoStartTime=Date.now()}_onLatencyTestResult(e){this._eventEmitter.dispatchEvent(new Et({latencyTimings:e}))}_onDataChannelLatencyTestResponse(e){this._eventEmitter.dispatchEvent(new Mt({response: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 bt({aggregatedStats:e}))}_onVideoEncoderAvgQP(e){this._eventEmitter.dispatchEvent(new tt({avgQP:e}))}_onInitialSettings(e){var t;this._eventEmitter.dispatchEvent(new Rt({settings:e})),e.PixelStreamingSettings&&(this.allowConsoleCommands=null!==(t=e.PixelStreamingSettings.AllowPixelStreamingCommands)&&void 0!==t&&t,!1===this.allowConsoleCommands&&d.Info("-AllowPixelStreamingCommands=false, sending arbitrary console commands from browser to UE is disabled."));const n=this.config.useUrlParams,s=new Nn(window.location.search);d.Info(`using URL parameters ${n}`),e.EncoderSettings&&(this.config.setNumericSetting(Bt.MinQP,n&&s.has(Bt.MinQP)?Number.parseFloat(s.get(Bt.MinQP)):e.EncoderSettings.MinQP),this.config.setNumericSetting(Bt.MaxQP,n&&s.has(Bt.MaxQP)?Number.parseFloat(s.get(Bt.MaxQP)):e.EncoderSettings.MaxQP)),e.WebRTCSettings&&(this.config.setNumericSetting(Bt.WebRTCMinBitrate,n&&s.has(Bt.WebRTCMinBitrate)?Number.parseFloat(s.get(Bt.WebRTCMinBitrate)):e.WebRTCSettings.MinBitrate/1e3),this.config.setNumericSetting(Bt.WebRTCMaxBitrate,n&&s.has(Bt.WebRTCMaxBitrate)?Number.parseFloat(s.get(Bt.WebRTCMaxBitrate)):e.WebRTCSettings.MaxBitrate/1e3),this.config.setNumericSetting(Bt.WebRTCFPS,n&&s.has(Bt.WebRTCFPS)?Number.parseFloat(s.get(Bt.WebRTCFPS)):e.WebRTCSettings.FPS))}_onQualityControlOwnership(e){this.config.setFlagEnabled(At.IsQualityController,e)}_onPlayerCount(e){this._eventEmitter.dispatchEvent(new Ft({count:e}))}_setupWebRtcTCPRelayDetection(e){const t=e.data.aggregatedStats.getActiveCandidatePair();if(null!=t){const n=e.data.aggregatedStats.localCandidates.find((e=>e.id==t.localCandidateId),null);null!=n&&"relay"==n.candidateType&&"tcp"==n.relayProtocol&&this._eventEmitter.dispatchEvent(new Ot),this._eventEmitter.removeEventListener("statsReceived",this._setupWebRtcTCPRelayDetection)}}requestLatencyTest(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendLatencyTest(),!0)}requestDataChannelLatencyTest(e){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._dataChannelLatencyTestController||(this._dataChannelLatencyTestController=new Hn(this._webRtcController.sendDataChannelLatencyTest.bind(this._webRtcController),(e=>{this._eventEmitter.dispatchEvent(new kt({result:e}))})),this.addEventListener("dataChannelLatencyTestResponse",(({data:{response:e}})=>{this._dataChannelLatencyTestController.receive(e)}))),this._dataChannelLatencyTestController.start(e))}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 webRtcController(){return this._webRtcController}get signallingProtocol(){return this._webRtcController.protocol}get webXrController(){return this._webXrController}registerMessageHandler(e,t,n){t!==Mn.FromStreamer||void 0!==n?t===Mn.ToStreamer&&void 0===n?this._webRtcController.streamMessageController.registerMessageHandler(t,e,(t=>this._webRtcController.sendMessageController.sendMessageToStreamer(e,t))):this._webRtcController.streamMessageController.registerMessageHandler(t,e,(e=>n(e))):d.Warning(`Unable to register an undefined handler for ${e}`)}get toStreamerHandlers(){return this._webRtcController.streamMessageController.toStreamerHandlers}isReconnecting(){return this._webRtcController.isReconnecting}}class jn{}var zn=s(290),Kn=s.n(zn);class Gn extends u.EventEmitter{constructor(e){super(),this.WS_OPEN_STATE=1,e&&(this.webSocket=e,this.setupSocketHandlers(),this.emit("open"))}sendMessage(e){this.webSocket&&this.webSocket.send(JSON.stringify(e))}connect(e){return this.webSocket=new(Kn())(e),this.setupSocketHandlers(),!0}disconnect(e,t){this.webSocket&&this.webSocket.close(e,t)}isConnected(){return!!this.webSocket&&this.webSocket.readyState!=Kn().CLOSED}handleOnMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return}this.onMessage&&this.onMessage(t)}handleOnOpen(e){this.emit("open",e)}handleOnError(e){this.emit("error",e)}handleOnClose(e){this.emit("close",e)}close(){var e;null===(e=this.webSocket)||void 0===e||e.close()}setupSocketHandlers(){this.webSocket&&(this.webSocket.addEventListener("open",this.handleOnOpen.bind(this)),this.webSocket.addEventListener("error",this.handleOnError.bind(this)),this.webSocket.addEventListener("close",this.handleOnClose.bind(this)),this.webSocket.addEventListener("message",this.handleOnMessage.bind(this)))}}return r})()));
|
package/webpack.common.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
const package = require('./package.json');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const webpack = require('webpack');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
entry: {
|
|
9
|
-
index: './src/pixelstreamingfrontend.ts'
|
|
10
|
-
},
|
|
11
|
-
module: {
|
|
12
|
-
rules: [
|
|
13
|
-
{
|
|
14
|
-
test: /\.tsx?$/,
|
|
15
|
-
loader: 'ts-loader',
|
|
16
|
-
exclude: [/node_modules/]
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
resolve: {
|
|
21
|
-
extensions: ['.tsx', '.ts', '.js']
|
|
22
|
-
},
|
|
23
|
-
externals: {
|
|
24
|
-
sdp: "sdp"
|
|
25
|
-
},
|
|
26
|
-
plugins: [
|
|
27
|
-
new webpack.DefinePlugin({
|
|
28
|
-
LIBRARY_VERSION: JSON.stringify(package.version)
|
|
29
|
-
})
|
|
30
|
-
],
|
|
31
|
-
output: {
|
|
32
|
-
path: path.resolve(__dirname, 'dist'),
|
|
33
|
-
globalObject: 'this'
|
|
34
|
-
}
|
|
35
|
-
};
|
package/webpack.dev.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
const { merge } = require('webpack-merge');
|
|
4
|
-
const common = require('./webpack.common.js');
|
|
5
|
-
|
|
6
|
-
const devCommon = {
|
|
7
|
-
mode: 'development',
|
|
8
|
-
devtool: 'inline-source-map',
|
|
9
|
-
devServer: {
|
|
10
|
-
static: './dist',
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
module.exports = [
|
|
15
|
-
merge(common, devCommon, {
|
|
16
|
-
output: {
|
|
17
|
-
filename: 'lib-pixelstreamingfrontend.js',
|
|
18
|
-
library: {
|
|
19
|
-
name: 'lib-pixelstreamingfrontend', // exposed variable that will provide access to the library classes
|
|
20
|
-
type: 'umd'
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
}),
|
|
24
|
-
merge(common, devCommon, {
|
|
25
|
-
output: {
|
|
26
|
-
filename: 'lib-pixelstreamingfrontend.esm.js',
|
|
27
|
-
library: {
|
|
28
|
-
type: 'module'
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
experiments: {
|
|
32
|
-
outputModule: true
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
];
|