@impleotv/stanag-player 1.3.14 → 1.3.15
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import A,{forwardRef as e,useRef as n,useState as r,useEffect as t,useImperativeHandle as o,useCallback as c}from"react";var g=function(){return g=Object.assign||function(A){for(var e,n=1,r=arguments.length;n<r;n++)for(var t in e=arguments[n])Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A},g.apply(this,arguments)};function a(A,e,n,r){return new(n||(n=Promise))((function(t,o){function c(A){try{a(r.next(A))}catch(A){o(A)}}function g(A){try{a(r.throw(A))}catch(A){o(A)}}function a(A){var e;A.done?t(A.value):(e=A.value,e instanceof n?e:new n((function(A){A(e)}))).then(c,g)}a((r=r.apply(A,e||[])).next())}))}function i(A,e){var n,r,t,o,c={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:g(0),throw:g(1),return:g(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function g(g){return function(a){return function(g){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,g[0]&&(c=0)),c;)try{if(n=1,r&&(t=2&g[0]?r.return:g[0]?r.throw||((t=r.return)&&t.call(r),0):r.next)&&!(t=t.call(r,g[1])).done)return t;switch(r=0,t&&(g=[2&g[0],t.value]),g[0]){case 0:case 1:t=g;break;case 4:return c.label++,{value:g[1],done:!1};case 5:c.label++,r=g[1],g=[0];continue;case 7:g=c.ops.pop(),c.trys.pop();continue;default:if(!(t=c.trys,(t=t.length>0&&t[t.length-1])||6!==g[0]&&2!==g[0])){c=0;continue}if(3===g[0]&&(!t||g[1]>t[0]&&g[1]<t[3])){c.label=g[1];break}if(6===g[0]&&c.label<t[1]){c.label=t[1],t=g;break}if(t&&c.label<t[2]){c.label=t[2],c.ops.push(g);break}t[2]&&c.ops.pop(),c.trys.pop();continue}g=e.call(A,c)}catch(A){g=[6,A],r=0}finally{n=t=0}if(5&g[0])throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}([g,a])}}}"function"==typeof SuppressedError&&SuppressedError;function C(A,e){void 0===e&&(e={});var n=e.insertAt;if(A&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css","top"===n&&r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.styleSheet?t.styleSheet.cssText=A:t.appendChild(document.createTextNode(A))}}function I(A){return A.endsWith("/")?A.slice(0,-1):A}function s(A,e){var n;e.current&&((null===(n=A.current)||void 0===n?void 0:n.paused)?(e.current.textContent="▶",e.current.title="Play"):(e.current.textContent="▐▐",e.current.title="Pause"))}function u(A,e,n){var r,t;if(A.current&&n.current)switch(null===(r=n.current)||void 0===r?void 0:r.recorderState){case"starting":A.current&&(A.current.textContent="⭕",A.current.title="Starting recording");break;case"running":A.current.textContent="🔴",A.current.title="Stop recording",n.current.recorderTimer=setInterval((function(){var A,r;if(null===(A=n.current)||void 0===A?void 0:A.recordingStarted){var t=function(A){if(void 0===A)return 0;var e=new Date(A);return((new Date).getTime()-e.getTime())/1e3}(null===(r=n.current)||void 0===r?void 0:r.recordingStarted);e.current&&(e.current.classList.remove("recorder-idle"),e.current.classList.add("recorder-active"),e.current.innerHTML=d(t,!1))}}),1e3);break;case"stopping":A.current&&(A.current.textContent="🔘");break;case"stopped":A.current&&(A.current.textContent="⚪",A.current.title="Record"),n.current&&n.current.recorderTimer&&(clearInterval(null===(t=n.current)||void 0===t?void 0:t.recorderTimer),n.current.recorderTimer=void 0),e.current&&(e.current.innerHTML=d(0,!1),e.current.classList.remove("recorder-active"),e.current.classList.add("recorder-idle"));break;case"waiting":A.current&&(A.current.textContent="🟠",A.current.title="Waiting for stream");break;case"error":A.current&&(A.current.textContent="🚫",A.current.title="Recording error: ".concat(n.current.recorderButtonText));break;default:A.current&&(A.current.textContent="🔵",A.current.title="Unknown state")}}function l(A,e){if(A.current){var n={service:"recorder",command:e,params:""};console.log("fetch POST: ".concat(A.current.serverUrl,"/command/ ").concat(JSON.stringify(n))),fetch(A.current.serverUrl+"/command",{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((function(A){A.ok||A.text().then((function(e){console.error("".concat(A.statusText," - ").concat(e))}))})).catch((function(A){var e,n;null===(n=null===(e=A.response)||void 0===e?void 0:e.json())||void 0===n||n.then((function(A){console.error("Error: ".concat(A.message)),console.error("Details: ".concat(JSON.stringify(A.details)))}))}))}else console.error("player.current is ".concat(A.current))}function d(A,e){if(void 0===e&&(e=!0),null==A)return"00:00:00.0";var n=new Date(1e3*A),r=n.getUTCHours(),t=n.getUTCMinutes(),o=n.getUTCSeconds(),c="";A>=86400&&(c+=Math.floor(A/86400)+":");if(c+=(r<10?"0"+r:r)+":"+(t<10?"0"+t:t)+":"+(o<10?"0"+o:o),e){var g=n.getUTCMilliseconds();c+="."+(Math.round(g/100)%10).toString()}return c}C(" \n.player-container {\n width: 100%;\n box-sizing: border-box; \n position: relative;\n }\n\n.videoContainer {\n width: 100%;\n display: inline-block;\n vertical-align: top;\n}\n\n.info {\n color: dimgray;\n font-size: 0.8em;\n}\n\n.video-player {\n position: relative;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.video {\n width: 100%;\n}\n\n.time {\n font-size: 0.9em;\n color: greenyellow;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 40px;\n transition: font-size 0.2s ease;\n}\n\n.time:hover {\n font-size: 1em;\n}\n\n.recorder-time{\n font-size: 0.9em;\n color: red;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 20px;\n font-weight: bold;\n transition: font-size 0.2s ease;\n}\n\n.recorder-time:hover {\n font-size: 1em;\n}\n\n\n.recorder-active {\n opacity: 100%;\n}\n\n.recorder-idle {\n opacity: 40%;\n}\n\n.recorder-disabled {\n display: none;\n}\n\n.player-controls {\n display: flex;\n position: absolute;\n bottom: 0;\n width: 100%;\n transform: translateY(100%);\n transition: .4s;\n flex-wrap: wrap;\n background: rgba(0, 0, 0, 0.5);\n}\n\n.video-player:hover .player-controls {\n transform: translateY(0);\n}\n\n\n.play-button,\n.record-button {\n width: 10%;\n background: rgba(0, 0, 0, 0);\n color: white;\n border: none;\n padding: 8px;\n}\n\n\n.screen-control-buttons {\n margin-left: auto; \n}\n\n.fullscreen-button,\n.pip-button { \n width: 50%;\n background: rgba(0, 0, 0, 0);\n color: black;\n border: none;\n padding: 8px;\n}\n\n.play-button:focus .record-button:focus .fullscreen-button:focus {\n outline: none;\n}\n\n.overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: none;\n justify-content: center;\n align-items: center;\n }\n \n .overlayExpired p {\n color: white;\n font-size: 1.2rem;\n text-align: center;\n }\n\n .overlayError p {\n color: Red;\n font-size: 1rem;\n text-align: center;\n }");var h=e((function(e,c){var C=n(null),h=n(null),E=n(null),B=n(null),Q=n(null),f=n(null),v=n(null),Y=n(null),G=n(null),p=n(!0),m=r(),y=m[0],w=m[1],b=r(e.controls&&!e.useStandardControls),S=b[0],R=b[1],T=r(16/9),x=T[0],L=T[1],k=r({width:e.width||360,height:(e.width||360)/x});k[0];var D=k[1],P=r({width:1920,height:1080}),N=P[0],U=P[1],W=r(0),O=W[0],M=W[1],H=r(0),z=H[0],F=H[1],j=r(null),J=j[0],V=j[1],K=n(),X=n(),q=n(),Z=n(),$={iceServers:e.iceServers?[{urls:e.iceServers}]:[]};t((function(){a(void 0,void 0,void 0,(function(){var A,n,r,t,o,c,g,a,C,s,l,d,E,Q;return i(this,(function(i){switch(i.label){case 0:if(e.serverUrl)A=I(e.serverUrl);else{if(e.serverName){if(void 0===e.serverPort)return g="Undefined server port while using serverName",console.log(g),e.showErrors&&(V(g),null===(a=G.current)||void 0===a||a.classList.add("overlayError"),G.current.style.display="flex"),[2];n=I(e.serverName)}else n=window.location.origin;r=new URL(n),A="".concat(r.protocol,"//").concat(r.hostname,":").concat(e.serverPort)}if(h.current){if(!A)return g="Server url is not set",console.log(g),e.showErrors&&(V(g),null===(s=G.current)||void 0===s||s.classList.add("overlayError"),G.current.style.display="flex"),[2];w(A),h.current.serverUrl=A,V(""),null===(C=G.current)||void 0===C||C.classList.remove("overlayError"),G.current.style.display="none"}i.label=1;case 1:return i.trys.push([1,6,,7]),[4,fetch(A+"/info")];case 2:return[4,i.sent().json()];case 3:return(t=i.sent())&&(h.current.poster=t.poster,e.onServerInfo&&e.onServerInfo(t),t.recorderEnabled||(null===(l=B.current)||void 0===l||l.classList.add("recorder-disabled"),null===(d=f.current)||void 0===d||d.classList.add("recorder-disabled")),t.demoExpired&&(V("Demo Expired"),null===(E=G.current)||void 0===E||E.classList.add("overlayExpired"),G.current.style.display="flex")),[4,fetch(A+"/recorderState")];case 4:return[4,i.sent().json()];case 5:return(o=i.sent())&&h.current&&(h.current.recorderState=o.state,h.current.recordingStarted=o.timeStarted.length>0?o.timeStarted:void 0,h.current.recorderButtonText="",u(f,B,h)),[3,7];case 6:return c=i.sent(),g="Error fetching data from ".concat(A,": ").concat(c.message),console.log(g,c),e.showErrors&&(V(g),null===(Q=G.current)||void 0===Q||Q.classList.add("overlayError"),G.current.style.display="flex"),[3,7];case 7:return[2]}}))}))}),[e.serverName,e.serverPort,z,e.showErrors]);var _=function(A){A.preventDefault(),function(A,e){var n,r,t;console.log("handlePlayPause"),(null===(n=A.current)||void 0===n?void 0:n.paused)?null===(r=A.current)||void 0===r||r.play():null===(t=A.current)||void 0===t||t.pause()}(C)},AA=function(A){A.preventDefault(),function(A,e,n){if(n.current){switch(n.current.recorderState){case"starting":n.current.recorderState="stopping";break;case"stopped":n.current.recorderState="starting",l(n,"start");break;case"running":case"waiting":case"error":n.current.recorderState="stopping",l(n,"stop");break;default:n.current.recorderState="unknown"}u(A,e,n)}}(f,B,h)};t((function(){var A,n,r,t,o,c;S?(console.log("Assign custom controls"),null!=C.current&&(C.current.addEventListener("timeupdate",(function(A){E.current&&(E.current.innerHTML=d(C.current?C.current.currentTime:null))})),C.current.onplay=function(A){p.current=!1,s(C,Q)},C.current.onpause=function(A){p.current=!0,s(C,Q)}),null===(A=Q.current)||void 0===A||A.removeEventListener("click",_),null===(n=Q.current)||void 0===n||n.addEventListener("click",_),null===(r=f.current)||void 0===r||r.removeEventListener("click",AA),null===(t=f.current)||void 0===t||t.addEventListener("click",AA),null===(o=v.current)||void 0===o||o.addEventListener("click",(function(A){var e;e=C,document.fullscreenElement||document.mozFullScreen||document.webkitIsFullScreen?document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen():e.current&&(e.current.requestFullScreen?e.current.requestFullScreen():e.current.mozRequestFullScreen?e.current.mozRequestFullScreen():e.current.webkitRequestFullScreen())})),null===(c=Y.current)||void 0===c||c.addEventListener("click",(function(A){!function(A){var e;document.pictureInPictureElement?document.exitPictureInPicture():null===(e=A.current)||void 0===e||e.requestPictureInPicture()}(C)}))):null!=C.current&&(C.current.onplay=function(A){p.current=!1},C.current.onpause=function(A){p.current=!0},C.current.addEventListener("loadedmetadata",(function(A){var n;U({width:C.current.videoWidth,height:C.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:C.current.videoWidth,videoHeight:C.current.videoHeight})}))),null!=C.current&&C.current.addEventListener("loadedmetadata",(function(A){var n;U({width:C.current.videoWidth,height:C.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:C.current.videoWidth,videoHeight:C.current.videoHeight})}))}),[S]),t((function(){null!=C.current&&(C.current.platformName=e.platformName,C.current.sensorName=e.sensorName,C.current.missionIdOrName=e.missionIdOrName)}),[e]),t((function(){var A,n;null!=C.current&&(C.current.muted=!0,C.current.autoplay=null!==(A=e.autoplay)&&void 0!==A&&A,e.showColorBars?C.current.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQBMAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCA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AEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":e.poster?C.current.poster=e.poster:C.current.poster=h.current.poster?"".concat(y,"/").concat(h.current.poster):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=",e.useStandardControls?(C.current.controls=null===(n=e.controls)||void 0===n||n,R(!1)):(C.current.controls=!1,R(e.controls&&!e.useStandardControls)))}),[e.controls,e.useStandardControls,e.autoplay,e.poster,e.showColorBars,e.showErrors,y]);t((function(){try{if(y){var A=new URL(y),n="ws";"http:"!=A.protocol&&(n+="s");var r=void 0;r=e.useReverseProxy?new WebSocket(n+"://".concat(A.hostname,"/ws/").concat(A.port)):new WebSocket(n+"://".concat(A.host,"/ws")),q.current=r,r.onmessage=function(A){var n=JSON.parse(A.data);n?n.error?(console.log(n.error),e.onError&&e.onError(n.error)):n.candidate?K.current.addIceCandidate(n):K.current.setRemoteDescription(n):console.log("failed to parse msg")},r.onerror=function(A){console.log("Websocket Error.")},r.onclose=function(A){var n;Z.current&&e.onConnected&&(e.onConnected(!1),Z.current=!1),1e3!=A.code&&(console.log("Websocket closed: ".concat(A.code)),setTimeout((function(){M(Date.now())}),1e3));var r="Disconnected from the server";console.log(r),e.showErrors&&G&&(V(r),null===(n=G.current)||void 0===n||n.classList.add("overlayError"),G.current.style.display="flex")},r.onopen=function(){!Z.current&&e.onConnected&&(Z.current=!0,e.onConnected(!0),G.current.style.display="none"),setTimeout((function(){F(Date.now())}),100)}}}catch(A){console.log("Error: ".concat(A.message))}return function(){console.log("Player close")}}),[y,e.useReverseProxy,e.iceServers,O,e.showErrors]),t((function(){try{var A=N.width/N.height;if(L(A),e.width){var n=e.width/A;D({width:e.width,height:n}),e.onSizeChange&&e.onSizeChange({width:e.width,height:n})}}catch(A){console.log("Error: ".concat(A.message))}}),[N.width,N.height,e.width]),t((function(){try{if(0!=z){K.current=new RTCPeerConnection($);var A=K.current;(n=K.current)&&(X.current=n.createDataChannel("klv"),X.current.binaryType="arraybuffer",X.current.onclose=function(){console.log("dataChannel has closed")},X.current.onopen=function(){console.log("dataChannel has opened")},X.current.onmessage=function(A){var n=new DataView(A.data),r=new TextDecoder("utf8"),t=JSON.parse(r.decode(n));switch(t.type){case"klv":p.current||e.onDataReceive&&e.onDataReceive(new Date(t.klvs[2]/1e3).toISOString(),t.klvs);break;case"msg":e.onMessageReceive&&e.onMessageReceive(t.msg);break;case"state":switch(e.onStateChange&&e.onStateChange(t.state),t.state){case"Timeout":h.current&&"running"===h.current.recorderState&&(h.current.recorderState="waiting",u(f,B,h));break;case"Online":h.current&&"waiting"===h.current.recorderState&&(h.current.recorderState="running",u(f,B,h));break;case"DemoExpired":V("Demo Expired"),G.current&&(G.current.classList.add("overlayExpired"),G.current.style.display="flex")}break;case"recorderState":e.onRecorderStateChange&&e.onRecorderStateChange(t.state),h.current&&(h.current.recorderState=t.state,h.current.recordingStarted=t.timeStarted.length>0?t.timeStarted:void 0,u(f,B,h));break;case"recorderEvent":"error"===t.event&&h.current&&(h.current.recorderState="error",h.current.recorderButtonText=t.data),u(f,B,h),e.onRecorderEvent&&e.onRecorderEvent(t.event)}}),A.ontrack=function(A){null!=C.current&&(C.current.srcObject=A.streams[0])},A.onconnectionstatechange=function(e){console.log(A.iceConnectionState),"disconnected"===A.iceConnectionState&&X.current&&(X.current.close(),X.current.onopen=null,X.current.onclose=null,X.current.onmessage=null,X.current.onerror=null,X.current=void 0,A.close(),K.current=void 0)},A.oniceconnectionstatechange=function(e){return console.log(A.iceConnectionState)},A.onicegatheringstatechange=function(e){return console.log(A.iceGatheringState)},A.addTransceiver("video",{direction:"sendrecv"}),A.onicecandidate=function(A){var e;A.candidate&&""!==A.candidate.candidate&&(null===(e=q.current)||void 0===e||e.send(JSON.stringify(A.candidate)))},A.createOffer().then((function(A){var e;K.current.setLocalDescription(A),null===(e=q.current)||void 0===e||e.send(JSON.stringify(A))}))}}catch(A){console.log("Error: ".concat(A.message))}var n}),[z]);var eA=function(){if(!C.current)return console.error("Video element not found"),null;var A=C.current,e=document.createElement("canvas");e.width=A.videoWidth,e.height=A.videoHeight;var n=e.getContext("2d");return n?n.drawImage(A,0,0,e.width,e.height):console.error("Failed to get canvas context"),e};return o(c,(function(){return g(g({},C.current),{getSnapshot:eA})})),A.createElement("div",{className:"player-container",ref:h},A.createElement("div",{className:"videoContainer"},A.createElement("div",{className:"video-player"},A.createElement("video",{id:"videoWindow",className:"video",ref:C}),S&&A.createElement("div",{className:"player-controls"},A.createElement("button",{className:"play-button",title:"Play",ref:Q},"▶"),A.createElement("button",{className:"record-button",title:"Record",ref:f},"⚪"),A.createElement("div",{className:"time"},A.createElement("span",{className:"currentPlaybackTime",title:"Playback time",ref:E},"00:00:00.000")),A.createElement("div",{className:"recorder-time"},A.createElement("span",{className:"currentRecordingTime",title:"Recording time",ref:B},"00:00:00")),A.createElement("div",{className:"screen-control-buttons"},A.createElement("button",{className:"pip-button",title:"Picture in picture",ref:Y},"🔳"),A.createElement("button",{className:"fullscreen-button",title:"Full screen",ref:v},"⬜"))))),A.createElement("div",{className:"overlay",ref:G},A.createElement("p",null,J)))}));h.defaultProps={useReverseProxy:!1,width:360,controls:!0,autoplay:!0,iceServers:"stun:stun.l.google.com:19302",showErrors:!0};function E(){return(new Date).toISOString()}function B(A,e){A?A("[".concat(E(),"] ").concat(e)):console.log("[".concat(E(),"] ").concat(e))}function Q(A){var e,n,r=new URL(window.location.href),t=function(A){return A.pathname.endsWith("/")?A:new URL(A.pathname+"/",A.origin)},o=((n=(e=r).pathname).endsWith("/")||(n=n.slice(0,n.lastIndexOf("/")+1)),new URL(n||"/",e.origin));if(A&&""!==A.trim()){var c=new URL(A,o);return t(c.origin===r.origin&&(""===c.pathname||"/"===c.pathname)?"/"!==o.pathname?o:new URL("/webrtc/",r.origin):c)}return t("/"!==o.pathname?o:new URL("/webrtc/",r.origin))}function f(A,e){var n=String(A||"").trim();try{return new URL(n)}catch(A){}if(n.startsWith("/")){var r=(e.pathname.replace(/\/$/,"")+n).replace(/\/{2,}/g,"/");return new URL(r,"".concat(e.origin))}return new URL(n,e)}C(" \n.player-container {\n position: relative;\n overflow: hidden;\n}\n\n.video {\n display: block;\n object-fit: cover;\n}\n\n.videoContainer {\n width: 100%;\n display: inline-block;\n vertical-align: top;\n}\n\n.info {\n color: dimgray;\n font-size: 0.8em;\n}\n\n.video-player {\n position: relative;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.time {\n font-size: 0.9em;\n color: greenyellow;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 40px;\n transition: font-size 0.2s ease;\n}\n\n.time:hover {\n font-size: 1em;\n}\n\n.recorder-time{\n font-size: 0.9em;\n color: red;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 20px;\n font-weight: bold;\n transition: font-size 0.2s ease;\n}\n\n.recorder-time:hover {\n font-size: 1em;\n}\n\n\n.recorder-active {\n opacity: 100%;\n}\n\n.recorder-idle {\n opacity: 40%;\n}\n\n.recorder-disabled {\n display: none;\n}\n\n.player-controls {\n display: flex;\n position: absolute;\n bottom: 0;\n width: 100%;\n transform: translateY(100%);\n transition: .4s;\n flex-wrap: wrap;\n background: rgba(0, 0, 0, 0.5);\n}\n\n.video-player:hover .player-controls {\n transform: translateY(0);\n}\n\n\n.play-button,\n.record-button {\n width: 10%;\n background: rgba(0, 0, 0, 0);\n color: white;\n border: none;\n padding: 8px;\n}\n\n\n.screen-control-buttons {\n margin-left: auto; \n}\n\n.fullscreen-button,\n.pip-button { \n width: 50%;\n background: rgba(0, 0, 0, 0);\n color: black;\n border: none;\n padding: 8px;\n}\n\n.play-button:focus .record-button:focus .fullscreen-button:focus {\n outline: none;\n}\n\n.overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: none;\n justify-content: center;\n align-items: center;\n }\n \n .overlayExpired p {\n color: white;\n font-size: 1.2rem;\n text-align: center;\n }\n\n .overlayError p {\n color: Red;\n font-size: 1rem;\n text-align: center;\n }");var v=e((function(e,C){var I=e.serverUrl,s=e.platform,u=void 0===s?"":s,l=e.sensor,d=void 0===l?"":l,h=e.missionIdOrName,E=e.iceServers,v=e.width,Y=e.controls,G=void 0===Y||Y,p=e.autoplay,m=void 0===p||p,y=e.layer,w=void 0===y?"main":y,b=e.simulcastEnabled,S=e.poster,R=e.showColorBars,T=void 0!==R&&R,x=e.lowLatencyHints,L=void 0===x||x,k=e.fastDrainOnStart,D=void 0===k||k,P=e.preferLowLatencyCodecs,N=void 0===P||P;e.onDataReceive,e.onError;var U=e.onStateChange;e.onStreamInfo;var W=e.onSizeChange,O=e.onLog,M=e.onSensorMessage,H=e.onSensorError,z=Q(I),F=f("whep",z).toString(),j=f("api/iceServers",z).toString(),J=n(null),V=n(null),K=n(),X=n(null),q=r(16/9),Z=q[0],$=q[1],_=n(null),AA=n(null),eA=n("0"),nA=n(!0),rA=n({platform:u,sensor:d}),tA=n(!0),oA=n(null),cA=n(null),gA=c((function(){oA.current&&(window.clearInterval(oA.current),oA.current=null)}),[]),aA=function(A){return A?"".concat(A.candidateType,"@").concat(A.ip||A.address,":").concat(A.port):"n/a"},iA=c((function(A){return void 0===A&&(A=""),a(void 0,void 0,void 0,(function(){var e,n,r,t,o,c,g;return i(this,(function(a){switch(a.label){case 0:return(e=V.current)?[4,e.getStats()]:[2];case 1:return n=a.sent(),r=null,n.forEach((function(A){"transport"===A.type&&A.selectedCandidatePairId&&!r&&(r=n.get(A.selectedCandidatePairId))})),r||n.forEach((function(A){"candidate-pair"!==A.type||!A.selected&&!A.nominated||r||(r=A)})),r?r.id!==cA.current||A?(cA.current=r.id,t=n.get(r.localCandidateId),o=n.get(r.remoteCandidateId),c=(null!==(g=r.currentRoundTripTime)&&void 0!==g?g:r.totalRoundTripTime)||0,B(O,"[ICE SELECTED] Path: ".concat((i=t,i?"relay"===i.candidateType?"TURN relay":"host"===i.candidateType?"Direct (host)":"srflx"===i.candidateType?"Direct (srflx)":"prflx"===i.candidateType?"Direct (prflx)":i.candidateType:"unknown")," | Local: ").concat(aA(t)," | Remote: ").concat(aA(o)," | RTT: ").concat((1e3*c).toFixed(1)," ms")),[2]):[2]:(A&&B(O,"No selected ICE pair yet (".concat(A,").")),[2])}var i}))}))}),[O]),CA=c((function(){gA(),oA.current=window.setInterval((function(){iA()}),3e3)}),[iA,gA]);t((function(){if(W){var A=function(){var A=X.current;if(A){var e=null!=v?v:A.clientWidth;W({width:e,height:v?v/Z:e/Z})}};if(A(),!v&&X.current){var e=new ResizeObserver((function(){return A()}));return e.observe(X.current),function(){return e.disconnect()}}}}),[W,v,Z]);var IA=c((function(){return a(void 0,void 0,void 0,(function(){var A,e,n,r;return i(this,(function(t){switch(t.label){case 0:if("string"==typeof E&&E)return[2,{servers:[{urls:E}],forceRelay:!1}];if(Array.isArray(E)&&E.length)return[2,{servers:E,forceRelay:!1}];t.label=1;case 1:return t.trys.push([1,4,,5]),[4,fetch(j,{credentials:"same-origin",headers:{Accept:"application/json"}})];case 2:if(!(A=t.sent()).ok)throw new Error("HTTP ".concat(A.status));return[4,A.json()];case 3:return e=t.sent(),Array.isArray(e)?[2,{servers:e,forceRelay:!1}]:(n=Array.isArray(null==e?void 0:e.iceServers)?e.iceServers:[],r=!!(null==e?void 0:e.forceRelay),[2,{servers:n.length?n:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:r}]);case 4:return t.sent(),[2,{servers:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:!1}];case 5:return[2]}}))}))}),[E,j]),sA=c((function(){var A;try{null===(A=AA.current)||void 0===A||A.close()}catch(A){}AA.current=null}),[]),uA=c((function(){return a(void 0,void 0,void 0,(function(){var A;return i(this,(function(e){switch(e.label){case 0:if(sA(),!(A=_.current))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(A,{method:"DELETE",credentials:"same-origin"})];case 2:return e.sent(),B(O,"Deleted WHEP resource: ".concat(A)),[3,4];case 3:return e.sent(),[3,4];case 4:return _.current=null,[2]}}))}))}),[O,sA]),lA=c((function(){nA.current&&(void 0!==K.current&&window.clearTimeout(K.current),K.current=window.setTimeout((function(){K.current=void 0,nA.current&&QA()}),2e3))}),[]),dA=c((function(){return a(void 0,void 0,void 0,(function(){var A,e,n;return i(this,(function(r){switch(r.label){case 0:if(nA.current=!1,void 0!==K.current&&(window.clearTimeout(K.current),K.current=void 0),gA(),cA.current=null,A=V.current){V.current=null;try{A.close()}catch(A){}}if(e=J.current){try{e.pause()}catch(A){}try{e.srcObject=null}catch(A){}try{null===(n=e.load)||void 0===n||n.call(e)}catch(A){}}return tA.current=!1,[4,uA()];case 1:return r.sent(),[2]}}))}))}),[uA,gA]);function hA(A){var n,r;if(tA.current){var t="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{var o=JSON.parse(t),c=new Date(o[2]/1e3).toISOString();null===(n=e.onDataReceive)||void 0===n||n.call(e,c,o)}catch(A){null===(r=e.onError)||void 0===r||r.call(e,"KLV parse error: ".concat(A.message))}}}function EA(A,n){var r,t="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{null==n||n(t)}catch(A){null===(r=e.onError)||void 0===r||r.call(e,A.message)}}t((function(){var A=J.current;if(A){tA.current=!A.paused;var e=function(){tA.current=!0,B(O,"[KLV] gate: OPEN (playing)")},n=function(){tA.current=!1,B(O,"[KLV] gate: CLOSED (paused)")};return A.addEventListener("play",e),A.addEventListener("playing",e),A.addEventListener("pause",n),A.addEventListener("ended",n),function(){A.removeEventListener("play",e),A.removeEventListener("playing",e),A.removeEventListener("pause",n),A.removeEventListener("ended",n)}}}),[O]);var BA=c((function(){return a(void 0,void 0,void 0,(function(){var A,e,n,r,t,o;return i(this,(function(c){switch(c.label){case 0:return null===(o=V.current)||void 0===o||o.close(),V.current=null,[4,IA()];case 1:return A=c.sent(),e=A.servers,n=A.forceRelay,r=new RTCPeerConnection({iceServers:e,iceTransportPolicy:n?"relay":"all",iceCandidatePoolSize:1,bundlePolicy:"balanced",rtcpMuxPolicy:"require"}),V.current=r,r.addEventListener("iceconnectionstatechange",(function(){r===V.current&&(B(O,"ICE state: ".concat(r.iceConnectionState)),["connected","completed"].includes(r.iceConnectionState)&&(iA("iceconnectionstatechange"),CA()),["disconnected","failed","closed"].includes(r.iceConnectionState)&&(gA(),lA()))})),r.addEventListener("connectionstatechange",(function(){r===V.current&&(B(O,"PC state: ".concat(r.connectionState)),"connected"===r.connectionState&&(iA("connectionstatechange"),CA()),["disconnected","failed","closed"].includes(r.connectionState)&&gA())})),r.ontrack=function(A){J.current&&(J.current.srcObject=A.streams[0],m&&(J.current.muted=!0,J.current.playsInline=!0,J.current.play().catch((function(){}))),function(A){var e,n;if(L)try{var r=V.current;if(!r)return;var t=r.getReceivers().find((function(e){return e.track===A}));if(!t)return;"playoutDelayHint"in t&&(t.playoutDelayHint=.02,B(O,"[RX] playoutDelayHint=0.02s")),"jitterBufferTarget"in t&&(t.jitterBufferTarget=0,B(O,"[RX] jitterBufferTarget=0ms"));var o=null===(e=t.getParameters)||void 0===e?void 0:e.call(t);o&&"degradationPreference"in o&&(o.degradationPreference="maintain-framerate",null===(n=t.setParameters)||void 0===n||n.call(t,o).catch((function(){})),B(O,"[RX] degradationPreference=maintain-framerate"))}catch(A){B(O,"[RX] hints skipped: ".concat(A.message))}}(A.track),function(){if(D){var A=J.current;if(A){var e=A.playbackRate;A.playbackRate=1.2,window.setTimeout((function(){J.current&&(J.current.playbackRate=e)}),1500),B(O,"[MEDIA] fast-drain 1.2× for 1.5s")}}}())},r.ondatachannel=function(A){var e=A.channel;e.binaryType="arraybuffer",e.onmessage=function(A){switch(e.label){case"klv-data":hA(A.data);break;case"info":case"sensor-state":EA(A.data,U);break;case"sensor-message":EA(A.data,M);break;case"sensor-error":EA(A.data,H)}}},t=!1,r.onicecandidate=function(A){return a(void 0,void 0,void 0,(function(){var e,n,r,o,c,g;return i(this,(function(a){switch(a.label){case 0:if(!(e=_.current))return[2];a.label=1;case 1:return a.trys.push([1,6,,7]),A.candidate?(r=null!==(g=A.candidate.sdpMid)&&void 0!==g?g:eA.current,n="a=mid:".concat(r,"\r\na=").concat(A.candidate.candidate,"\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:n,credentials:"same-origin"})]):[3,3];case 2:return a.sent(),[3,5];case 3:return t?[3,5]:(t=!0,r=eA.current,o="a=mid:".concat(r,"\r\na=end-of-candidates\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:o,credentials:"same-origin"})]);case 4:a.sent(),a.label=5;case 5:return[3,7];case 6:return c=a.sent(),B(O,"WHEP PATCH error: ".concat(c.message)),[3,7];case 7:return[2]}}))}))},[2,r]}}))}))}),[m,IA,O,iA,CA,gA,lA,U,M]),QA=c((function(){return a(void 0,void 0,void 0,(function(){var A,e,n,r,t,o,c,g,a,C,I;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),T?[2]:(nA.current=!0,[4,uA()]);case 1:return i.sent(),[4,BA()];case 2:return A=i.sent(),function(A){var e,n,r,t;if(N)try{var o=null===(n=(e=RTCRtpReceiver).getCapabilities)||void 0===n?void 0:n.call(e,"video");if(!o||!o.codecs)return;var c=o.codecs.slice(),g=function(A){var e=(A.mimeType||"").toLowerCase(),n=(A.sdpFmtpLine||"").toLowerCase();return"video/vp8"===e?0:"video/h264"===e&&/profile-level-id=42/.test(n)?1:"video/h264"===e?2:3};c.sort((function(A,e){return g(A)-g(e)})),null===(t=(r=A).setCodecPreferences)||void 0===t||t.call(r,c),B(O,"[CODEC] preferences applied (VP8/H264-baseline first)")}catch(A){B(O,"[CODEC] skipped: ".concat(A.message))}}(A.addTransceiver("video",{direction:"recvonly"})),s=A,(l=function(A,e,n){var r=s.createDataChannel(A,n);return r.binaryType="arraybuffer",r.onopen=function(){return B(O,"[DC:".concat(A,"] open"))},r.onclose=function(){return B(O,"[DC:".concat(A,"] close"))},r.onmessage=function(A){return e(A.data)},r})("klv-data",(function(A){return hA(A)}),{ordered:!1,maxRetransmits:0}),l("sensor-state",(function(A){return EA(A,U)}),{ordered:!0}),l("sensor-message",(function(A){return EA(A,M)}),{ordered:!0}),l("sensor-error",(function(A){return EA(A,H)}),{ordered:!0}),e=function(){if(!d)throw new Error("`sensor` prop is required");var A={Authorization:"Bearer none","Content-Type":"application/sdp",Sensor:d};return u&&(A.Platform=u),A["Simulcast-Layer"]=b?"all":w||"main",h&&(A.Mission=h),A}(),[4,A.createOffer()];case 3:return n=i.sent(),[4,A.setLocalDescription(n)];case 4:return i.sent(),eA.current=function(A){if(!A)return"0";for(var e=0,n=A.split(/^m=/m);e<n.length;e++){var r=n[e];if(r.startsWith("application")){var t=r.match(/^a=mid:(.+)$/m);return t?t[1].trim():"0"}}return"0"}(null===(I=A.localDescription)||void 0===I?void 0:I.sdp),B(O,"Local data MID: ".concat(eA.current)),[4,fetch(F,{method:"POST",headers:e,body:n.sdp,credentials:"same-origin"})];case 5:return(r=i.sent()).ok?[3,7]:[4,r.text().catch((function(){return""}))];case 6:throw t=i.sent(),new Error("Server ".concat(r.status," ").concat(r.statusText).concat(t?" - "+t:""));case 7:return o=r.headers.get("Location"),(c=function(A,e){if(!A)return null;var n,r=new URL(e),t=new URL(".",r);try{n=new URL(A,t)}catch(A){return null}return n.origin!==r.origin&&(n=new URL(n.pathname+n.search+n.hash,r.origin)),n.toString()}(o,F))?(_.current=c,B(O,"WHEP resource: ".concat(_.current))):(_.current=null,B(O,"No Location header visible (CORS). Running without trickle PATCH/DELETE.")),[4,r.text()];case 8:return g=i.sent(),[4,A.setRemoteDescription({type:"answer",sdp:g})];case 9:return i.sent(),B(O,"Subscribed successfully!"),iA("post-answer"),_.current&&(a=_.current.endsWith("/")?_.current+"events":_.current+"/events",AA.current=new EventSource(a),AA.current.addEventListener("candidate",(function(e){var n=function(A){for(var e=null,n=null,r=0,t=A.split(/\r?\n/);r<t.length;r++){var o=t[r].trim();o&&(o.startsWith("a=mid:")?e=o.slice(6).trim():o.startsWith("a=candidate:")?n=o.slice(2):o.startsWith("candidate:")&&(n=o))}if(!n)return null;var c={candidate:n};return null!==e&&(c.sdpMid=e),c}(e.data);n&&("sdpMid"in n&&null!=n.sdpMid||(n.sdpMid=eA.current),A.addIceCandidate(n).catch((function(A){return B(O,"addIceCandidate error: ".concat(A.message))})),B(O,"[ICE add] ".concat(n.candidate," (mid=").concat(n.sdpMid,")")))})),AA.current.addEventListener("end",(function(){return B(O,"[SSE] server end-of-candidates")})),AA.current.addEventListener("ping",(function(){}))),[3,11];case 10:return C=i.sent(),B(O,"Subscription failed: ".concat(C.message)),lA(),[3,11];case 11:return[2]}var s,l}))}))}),[T,uA,BA,O,lA,F,iA]);t((function(){var A=rA.current;if(A.platform!==u||A.sensor!==d){rA.current={platform:u,sensor:d},B(O,"Selection changed (platform=".concat(u||"n/a",", sensor=").concat(d||"n/a","). Restarting stream."));var e=!1;return a(void 0,void 0,void 0,(function(){return i(this,(function(A){switch(A.label){case 0:return[4,dA()];case 1:return A.sent(),e?[2]:d?T?[2]:[4,QA()]:(B(O,"Sensor is empty after selection change; staying disconnected."),[2]);case 2:return A.sent(),[2]}}))})),function(){e=!0}}}),[u,d,dA,QA,T,O]);var fA=function(){var A,e=J.current;if(!e)return null;var n=document.createElement("canvas");return n.width=e.videoWidth,n.height=e.videoHeight,null===(A=n.getContext("2d"))||void 0===A||A.drawImage(e,0,0,n.width,n.height),n};o(C,(function(){return g(g({},J.current),{getSnapshot:fA})})),t((function(){B(O,"Starting subscriber... (base=".concat(Q(I),")")),QA();var A=function(){dA()};return window.addEventListener("pagehide",A),window.addEventListener("beforeunload",A),function(){window.removeEventListener("pagehide",A),window.removeEventListener("beforeunload",A),dA()}}),[]);var vA=T?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAA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MMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=";return A.createElement("div",{className:"player-container",ref:X,style:g({width:v?"".concat(v,"px"):"100%"},v?{height:"".concat((v/Z).toFixed(0),"px")}:{aspectRatio:String(Z)})},A.createElement("video",{ref:J,controls:G,autoPlay:m&&!T,muted:m,playsInline:!0,poster:vA,style:{backgroundColor:"black",width:"100%",height:"100%",display:"block",objectFit:"contain"},onLoadedMetadata:function(){var A,n=J.current;if((null==n?void 0:n.videoWidth)&&n.videoHeight){var r=n.videoWidth/n.videoHeight;$(r),null===(A=e.onStreamInfo)||void 0===A||A.call(e,{videoWidth:n.videoWidth,videoHeight:n.videoHeight})}}}))}));export{h as StanagPlayer,v as StanagPlayerWhep};
|
|
1
|
+
import A,{forwardRef as e,useRef as n,useState as r,useEffect as t,useImperativeHandle as o,useCallback as c}from"react";var a=function(){return a=Object.assign||function(A){for(var e,n=1,r=arguments.length;n<r;n++)for(var t in e=arguments[n])Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A},a.apply(this,arguments)};function g(A,e,n,r){return new(n||(n=Promise))(function(t,o){function c(A){try{g(r.next(A))}catch(A){o(A)}}function a(A){try{g(r.throw(A))}catch(A){o(A)}}function g(A){var e;A.done?t(A.value):(e=A.value,e instanceof n?e:new n(function(A){A(e)})).then(c,a)}g((r=r.apply(A,e||[])).next())})}function i(A,e){var n,r,t,o={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=a(0),c.throw=a(1),c.return=a(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function a(a){return function(g){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(t=2&a[0]?r.return:a[0]?r.throw||((t=r.return)&&t.call(r),0):r.next)&&!(t=t.call(r,a[1])).done)return t;switch(r=0,t&&(a=[2&a[0],t.value]),a[0]){case 0:case 1:t=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(t=o.trys,(t=t.length>0&&t[t.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!t||a[1]>t[0]&&a[1]<t[3])){o.label=a[1];break}if(6===a[0]&&o.label<t[1]){o.label=t[1],t=a;break}if(t&&o.label<t[2]){o.label=t[2],o.ops.push(a);break}t[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(A,o)}catch(A){a=[6,A],r=0}finally{n=t=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,g])}}}"function"==typeof SuppressedError&&SuppressedError;function C(A,e){void 0===e&&(e={});var n=e.insertAt;if(A&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css","top"===n&&r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.styleSheet?t.styleSheet.cssText=A:t.appendChild(document.createTextNode(A))}}function I(A){return A.endsWith("/")?A.slice(0,-1):A}function s(A,e){var n;e.current&&((null===(n=A.current)||void 0===n?void 0:n.paused)?(e.current.textContent="▶",e.current.title="Play"):(e.current.textContent="▐▐",e.current.title="Pause"))}function u(A,e,n){var r,t;if(A.current&&n.current)switch(null===(r=n.current)||void 0===r?void 0:r.recorderState){case"starting":A.current&&(A.current.textContent="⭕",A.current.title="Starting recording");break;case"running":A.current.textContent="🔴",A.current.title="Stop recording",n.current.recorderTimer=setInterval(function(){var A,r;if(null===(A=n.current)||void 0===A?void 0:A.recordingStarted){var t=function(A){if(void 0===A)return 0;var e=new Date(A);return((new Date).getTime()-e.getTime())/1e3}(null===(r=n.current)||void 0===r?void 0:r.recordingStarted);e.current&&(e.current.classList.remove("recorder-idle"),e.current.classList.add("recorder-active"),e.current.innerHTML=d(t,!1))}},1e3);break;case"stopping":A.current&&(A.current.textContent="🔘");break;case"stopped":A.current&&(A.current.textContent="⚪",A.current.title="Record"),n.current&&n.current.recorderTimer&&(clearInterval(null===(t=n.current)||void 0===t?void 0:t.recorderTimer),n.current.recorderTimer=void 0),e.current&&(e.current.innerHTML=d(0,!1),e.current.classList.remove("recorder-active"),e.current.classList.add("recorder-idle"));break;case"waiting":A.current&&(A.current.textContent="🟠",A.current.title="Waiting for stream");break;case"error":A.current&&(A.current.textContent="🚫",A.current.title="Recording error: ".concat(n.current.recorderButtonText));break;default:A.current&&(A.current.textContent="🔵",A.current.title="Unknown state")}}function l(A,e){if(A.current){var n={service:"recorder",command:e,params:""};console.log("fetch POST: ".concat(A.current.serverUrl,"/command/ ").concat(JSON.stringify(n))),fetch(A.current.serverUrl+"/command",{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then(function(A){A.ok||A.text().then(function(e){console.error("".concat(A.statusText," - ").concat(e))})}).catch(function(A){var e,n;null===(n=null===(e=A.response)||void 0===e?void 0:e.json())||void 0===n||n.then(function(A){console.error("Error: ".concat(A.message)),console.error("Details: ".concat(JSON.stringify(A.details)))})})}else console.error("player.current is ".concat(A.current))}function d(A,e){if(void 0===e&&(e=!0),null==A)return"00:00:00.0";var n=new Date(1e3*A),r=n.getUTCHours(),t=n.getUTCMinutes(),o=n.getUTCSeconds(),c="";A>=86400&&(c+=Math.floor(A/86400)+":");if(c+=(r<10?"0"+r:r)+":"+(t<10?"0"+t:t)+":"+(o<10?"0"+o:o),e){var a=n.getUTCMilliseconds();c+="."+(Math.round(a/100)%10).toString()}return c}C(" \n.player-container {\n width: 100%;\n box-sizing: border-box; \n position: relative;\n }\n\n.videoContainer {\n width: 100%;\n display: inline-block;\n vertical-align: top;\n}\n\n.info {\n color: dimgray;\n font-size: 0.8em;\n}\n\n.video-player {\n position: relative;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.video {\n width: 100%;\n}\n\n.time {\n font-size: 0.9em;\n color: greenyellow;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 40px;\n transition: font-size 0.2s ease;\n}\n\n.time:hover {\n font-size: 1em;\n}\n\n.recorder-time{\n font-size: 0.9em;\n color: red;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 20px;\n font-weight: bold;\n transition: font-size 0.2s ease;\n}\n\n.recorder-time:hover {\n font-size: 1em;\n}\n\n\n.recorder-active {\n opacity: 100%;\n}\n\n.recorder-idle {\n opacity: 40%;\n}\n\n.recorder-disabled {\n display: none;\n}\n\n.player-controls {\n display: flex;\n position: absolute;\n bottom: 0;\n width: 100%;\n transform: translateY(100%);\n transition: .4s;\n flex-wrap: wrap;\n background: rgba(0, 0, 0, 0.5);\n}\n\n.video-player:hover .player-controls {\n transform: translateY(0);\n}\n\n\n.play-button,\n.record-button {\n width: 10%;\n background: rgba(0, 0, 0, 0);\n color: white;\n border: none;\n padding: 8px;\n}\n\n\n.screen-control-buttons {\n margin-left: auto; \n}\n\n.fullscreen-button,\n.pip-button { \n width: 50%;\n background: rgba(0, 0, 0, 0);\n color: black;\n border: none;\n padding: 8px;\n}\n\n.play-button:focus .record-button:focus .fullscreen-button:focus {\n outline: none;\n}\n\n.overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: none;\n justify-content: center;\n align-items: center;\n }\n \n .overlayExpired p {\n color: white;\n font-size: 1.2rem;\n text-align: center;\n }\n\n .overlayError p {\n color: Red;\n font-size: 1rem;\n text-align: center;\n }");var h=e(function(e,c){var C=n(null),h=n(null),E=n(null),B=n(null),Q=n(null),f=n(null),v=n(null),Y=n(null),G=n(null),p=n(!0),m=r(),y=m[0],w=m[1],b=r(e.controls&&!e.useStandardControls),S=b[0],R=b[1],T=r(16/9),x=T[0],L=T[1],k=r({width:e.width||360,height:(e.width||360)/x});k[0];var D=k[1],P=r({width:1920,height:1080}),N=P[0],W=P[1],U=r(0),O=U[0],M=U[1],H=r(0),F=H[0],z=H[1],j=r(null),J=j[0],V=j[1],K=n(),X=n(),q=n(),Z=n(),$={iceServers:e.iceServers?[{urls:e.iceServers}]:[]};t(function(){g(void 0,void 0,void 0,function(){var A,n,r,t,o,c,a,g,C,s,l,d,E,Q;return i(this,function(i){switch(i.label){case 0:if(e.serverUrl)A=I(e.serverUrl);else{if(e.serverName){if(void 0===e.serverPort)return a="Undefined server port while using serverName",console.log(a),e.showErrors&&(V(a),null===(g=G.current)||void 0===g||g.classList.add("overlayError"),G.current.style.display="flex"),[2];n=I(e.serverName)}else n=window.location.origin;r=new URL(n),A="".concat(r.protocol,"//").concat(r.hostname,":").concat(e.serverPort)}if(h.current){if(!A)return a="Server url is not set",console.log(a),e.showErrors&&(V(a),null===(s=G.current)||void 0===s||s.classList.add("overlayError"),G.current.style.display="flex"),[2];w(A),h.current.serverUrl=A,V(""),null===(C=G.current)||void 0===C||C.classList.remove("overlayError"),G.current.style.display="none"}i.label=1;case 1:return i.trys.push([1,6,,7]),[4,fetch(A+"/info")];case 2:return[4,i.sent().json()];case 3:return(t=i.sent())&&(h.current.poster=t.poster,e.onServerInfo&&e.onServerInfo(t),t.recorderEnabled||(null===(l=B.current)||void 0===l||l.classList.add("recorder-disabled"),null===(d=f.current)||void 0===d||d.classList.add("recorder-disabled")),t.demoExpired&&(V("Demo Expired"),null===(E=G.current)||void 0===E||E.classList.add("overlayExpired"),G.current.style.display="flex")),[4,fetch(A+"/recorderState")];case 4:return[4,i.sent().json()];case 5:return(o=i.sent())&&h.current&&(h.current.recorderState=o.state,h.current.recordingStarted=o.timeStarted.length>0?o.timeStarted:void 0,h.current.recorderButtonText="",u(f,B,h)),[3,7];case 6:return c=i.sent(),a="Error fetching data from ".concat(A,": ").concat(c.message),console.log(a,c),e.showErrors&&(V(a),null===(Q=G.current)||void 0===Q||Q.classList.add("overlayError"),G.current.style.display="flex"),[3,7];case 7:return[2]}})})},[e.serverName,e.serverPort,F,e.showErrors]);var _=function(A){A.preventDefault(),function(A){var e,n,r;console.log("handlePlayPause"),(null===(e=A.current)||void 0===e?void 0:e.paused)?null===(n=A.current)||void 0===n||n.play():null===(r=A.current)||void 0===r||r.pause()}(C)},AA=function(A){A.preventDefault(),function(A,e,n){if(n.current){switch(n.current.recorderState){case"starting":n.current.recorderState="stopping";break;case"stopped":n.current.recorderState="starting",l(n,"start");break;case"running":case"waiting":case"error":n.current.recorderState="stopping",l(n,"stop");break;default:n.current.recorderState="unknown"}u(A,e,n)}}(f,B,h)};t(function(){var A,n,r,t,o,c;S?(console.log("Assign custom controls"),null!=C.current&&(C.current.addEventListener("timeupdate",function(A){E.current&&(E.current.innerHTML=d(C.current?C.current.currentTime:null))}),C.current.onplay=function(A){p.current=!1,s(C,Q)},C.current.onpause=function(A){p.current=!0,s(C,Q)}),null===(A=Q.current)||void 0===A||A.removeEventListener("click",_),null===(n=Q.current)||void 0===n||n.addEventListener("click",_),null===(r=f.current)||void 0===r||r.removeEventListener("click",AA),null===(t=f.current)||void 0===t||t.addEventListener("click",AA),null===(o=v.current)||void 0===o||o.addEventListener("click",function(A){var e;e=C,document.fullscreenElement||document.mozFullScreen||document.webkitIsFullScreen?document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen():e.current&&(e.current.requestFullScreen?e.current.requestFullScreen():e.current.mozRequestFullScreen?e.current.mozRequestFullScreen():e.current.webkitRequestFullScreen())}),null===(c=Y.current)||void 0===c||c.addEventListener("click",function(A){!function(A){var e;document.pictureInPictureElement?document.exitPictureInPicture():null===(e=A.current)||void 0===e||e.requestPictureInPicture()}(C)})):null!=C.current&&(C.current.onplay=function(A){p.current=!1},C.current.onpause=function(A){p.current=!0},C.current.addEventListener("loadedmetadata",function(A){var n;W({width:C.current.videoWidth,height:C.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:C.current.videoWidth,videoHeight:C.current.videoHeight})})),null!=C.current&&C.current.addEventListener("loadedmetadata",function(A){var n;W({width:C.current.videoWidth,height:C.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:C.current.videoWidth,videoHeight:C.current.videoHeight})})},[S]),t(function(){null!=C.current&&(C.current.platformName=e.platformName,C.current.sensorName=e.sensorName,C.current.missionIdOrName=e.missionIdOrName)},[e]),t(function(){var A,n;null!=C.current&&(C.current.muted=!0,C.current.autoplay=null!==(A=e.autoplay)&&void 0!==A&&A,e.showColorBars?C.current.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAA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AABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":e.poster?C.current.poster=e.poster:C.current.poster=h.current.poster?"".concat(y,"/").concat(h.current.poster):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=",e.useStandardControls?(C.current.controls=null===(n=e.controls)||void 0===n||n,R(!1)):(C.current.controls=!1,R(e.controls&&!e.useStandardControls)))},[e.controls,e.useStandardControls,e.autoplay,e.poster,e.showColorBars,e.showErrors,y]);t(function(){try{if(y){var A=new URL(y),n="ws";"http:"!=A.protocol&&(n+="s");var r=void 0;r=e.useReverseProxy?new WebSocket(n+"://".concat(A.hostname,"/ws/").concat(A.port)):new WebSocket(n+"://".concat(A.host,"/ws")),q.current=r,r.onmessage=function(A){var n=JSON.parse(A.data);n?n.error?(console.log(n.error),e.onError&&e.onError(n.error)):n.candidate?K.current.addIceCandidate(n):K.current.setRemoteDescription(n):console.log("failed to parse msg")},r.onerror=function(A){console.log("Websocket Error.")},r.onclose=function(A){var n;Z.current&&e.onConnected&&(e.onConnected(!1),Z.current=!1),1e3!=A.code&&(console.log("Websocket closed: ".concat(A.code)),setTimeout(function(){M(Date.now())},1e3));var r="Disconnected from the server";console.log(r),e.showErrors&&G&&(V(r),null===(n=G.current)||void 0===n||n.classList.add("overlayError"),G.current.style.display="flex")},r.onopen=function(){!Z.current&&e.onConnected&&(Z.current=!0,e.onConnected(!0),G.current.style.display="none"),setTimeout(function(){z(Date.now())},100)}}}catch(A){console.log("Error: ".concat(A.message))}return function(){console.log("Player close")}},[y,e.useReverseProxy,e.iceServers,O,e.showErrors]),t(function(){try{var A=N.width/N.height;if(L(A),e.width){var n=e.width/A;D({width:e.width,height:n}),e.onSizeChange&&e.onSizeChange({width:e.width,height:n})}}catch(A){console.log("Error: ".concat(A.message))}},[N.width,N.height,e.width]),t(function(){try{if(0!=F){K.current=new RTCPeerConnection($);var A=K.current;(n=K.current)&&(X.current=n.createDataChannel("klv"),X.current.binaryType="arraybuffer",X.current.onclose=function(){console.log("dataChannel has closed")},X.current.onopen=function(){console.log("dataChannel has opened")},X.current.onmessage=function(A){var n=new DataView(A.data),r=new TextDecoder("utf8"),t=JSON.parse(r.decode(n));switch(t.type){case"klv":p.current||e.onDataReceive&&e.onDataReceive(new Date(t.klvs[2]/1e3).toISOString(),t.klvs);break;case"msg":e.onMessageReceive&&e.onMessageReceive(t.msg);break;case"state":switch(e.onStateChange&&e.onStateChange(t.state),t.state){case"Timeout":h.current&&"running"===h.current.recorderState&&(h.current.recorderState="waiting",u(f,B,h));break;case"Online":h.current&&"waiting"===h.current.recorderState&&(h.current.recorderState="running",u(f,B,h));break;case"DemoExpired":V("Demo Expired"),G.current&&(G.current.classList.add("overlayExpired"),G.current.style.display="flex")}break;case"recorderState":e.onRecorderStateChange&&e.onRecorderStateChange(t.state),h.current&&(h.current.recorderState=t.state,h.current.recordingStarted=t.timeStarted.length>0?t.timeStarted:void 0,u(f,B,h));break;case"recorderEvent":"error"===t.event&&h.current&&(h.current.recorderState="error",h.current.recorderButtonText=t.data),u(f,B,h),e.onRecorderEvent&&e.onRecorderEvent(t.event)}}),A.ontrack=function(A){null!=C.current&&(C.current.srcObject=A.streams[0])},A.onconnectionstatechange=function(e){console.log(A.iceConnectionState),"disconnected"===A.iceConnectionState&&X.current&&(X.current.close(),X.current.onopen=null,X.current.onclose=null,X.current.onmessage=null,X.current.onerror=null,X.current=void 0,A.close(),K.current=void 0)},A.oniceconnectionstatechange=function(e){return console.log(A.iceConnectionState)},A.onicegatheringstatechange=function(e){return console.log(A.iceGatheringState)},A.addTransceiver("video",{direction:"sendrecv"}),A.onicecandidate=function(A){var e;A.candidate&&""!==A.candidate.candidate&&(null===(e=q.current)||void 0===e||e.send(JSON.stringify(A.candidate)))},A.createOffer().then(function(A){var e;K.current.setLocalDescription(A),null===(e=q.current)||void 0===e||e.send(JSON.stringify(A))})}}catch(A){console.log("Error: ".concat(A.message))}var n},[F]);var eA=function(){if(!C.current)return console.error("Video element not found"),null;var A=C.current,e=document.createElement("canvas");e.width=A.videoWidth,e.height=A.videoHeight;var n=e.getContext("2d");return n?n.drawImage(A,0,0,e.width,e.height):console.error("Failed to get canvas context"),e};return o(c,function(){return a(a({},C.current),{getSnapshot:eA})}),A.createElement("div",{className:"player-container",ref:h},A.createElement("div",{className:"videoContainer"},A.createElement("div",{className:"video-player"},A.createElement("video",{id:"videoWindow",className:"video",ref:C}),S&&A.createElement("div",{className:"player-controls"},A.createElement("button",{className:"play-button",title:"Play",ref:Q},"▶"),A.createElement("button",{className:"record-button",title:"Record",ref:f},"⚪"),A.createElement("div",{className:"time"},A.createElement("span",{className:"currentPlaybackTime",title:"Playback time",ref:E},"00:00:00.000")),A.createElement("div",{className:"recorder-time"},A.createElement("span",{className:"currentRecordingTime",title:"Recording time",ref:B},"00:00:00")),A.createElement("div",{className:"screen-control-buttons"},A.createElement("button",{className:"pip-button",title:"Picture in picture",ref:Y},"🔳"),A.createElement("button",{className:"fullscreen-button",title:"Full screen",ref:v},"⬜"))))),A.createElement("div",{className:"overlay",ref:G},A.createElement("p",null,J)))});h.defaultProps={useReverseProxy:!1,width:360,controls:!0,autoplay:!0,iceServers:"stun:stun.l.google.com:19302",showErrors:!0};function E(){return(new Date).toISOString()}function B(A,e){A?A("[".concat(E(),"] ").concat(e)):console.log("[".concat(E(),"] ").concat(e))}function Q(A){var e,n,r=new URL(window.location.href),t=function(A){return A.pathname.endsWith("/")?A:new URL(A.pathname+"/",A.origin)},o=((n=(e=r).pathname).endsWith("/")||(n=n.slice(0,n.lastIndexOf("/")+1)),new URL(n||"/",e.origin));if(A&&""!==A.trim()){var c=new URL(A,o);return t(c.origin===r.origin&&(""===c.pathname||"/"===c.pathname)?"/"!==o.pathname?o:new URL("/webrtc/",r.origin):c)}return t("/"!==o.pathname?o:new URL("/webrtc/",r.origin))}function f(A,e){var n=String(A||"").trim();try{return new URL(n)}catch(A){}if(n.startsWith("/")){var r=(e.pathname.replace(/\/$/,"")+n).replace(/\/{2,}/g,"/");return new URL(r,"".concat(e.origin))}return new URL(n,e)}C(" \n.player-container {\n position: relative;\n overflow: hidden;\n}\n\n.video {\n display: block;\n object-fit: cover;\n}\n\n.videoContainer {\n width: 100%;\n display: inline-block;\n vertical-align: top;\n}\n\n.info {\n color: dimgray;\n font-size: 0.8em;\n}\n\n.video-player {\n position: relative;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.time {\n font-size: 0.9em;\n color: greenyellow;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 40px;\n transition: font-size 0.2s ease;\n}\n\n.time:hover {\n font-size: 1em;\n}\n\n.recorder-time{\n font-size: 0.9em;\n color: red;\n width: 15%;\n text-align: center;\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: 20px;\n font-weight: bold;\n transition: font-size 0.2s ease;\n}\n\n.recorder-time:hover {\n font-size: 1em;\n}\n\n\n.recorder-active {\n opacity: 100%;\n}\n\n.recorder-idle {\n opacity: 40%;\n}\n\n.recorder-disabled {\n display: none;\n}\n\n.player-controls {\n display: flex;\n position: absolute;\n bottom: 0;\n width: 100%;\n transform: translateY(100%);\n transition: .4s;\n flex-wrap: wrap;\n background: rgba(0, 0, 0, 0.5);\n}\n\n.video-player:hover .player-controls {\n transform: translateY(0);\n}\n\n\n.play-button,\n.record-button {\n width: 10%;\n background: rgba(0, 0, 0, 0);\n color: white;\n border: none;\n padding: 8px;\n}\n\n\n.screen-control-buttons {\n margin-left: auto; \n}\n\n.fullscreen-button,\n.pip-button { \n width: 50%;\n background: rgba(0, 0, 0, 0);\n color: black;\n border: none;\n padding: 8px;\n}\n\n.play-button:focus .record-button:focus .fullscreen-button:focus {\n outline: none;\n}\n\n.overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: none;\n justify-content: center;\n align-items: center;\n }\n \n .overlayExpired p {\n color: white;\n font-size: 1.2rem;\n text-align: center;\n }\n\n .overlayError p {\n color: Red;\n font-size: 1rem;\n text-align: center;\n }");var v=e(function(e,C){var I=e.serverUrl,s=e.platform,u=void 0===s?"":s,l=e.sensor,d=void 0===l?"":l,h=e.missionIdOrName,E=e.iceServers,v=e.width,Y=e.controls,G=void 0===Y||Y,p=e.autoplay,m=void 0===p||p,y=e.layer,w=void 0===y?"main":y,b=e.simulcastEnabled,S=e.poster,R=e.showColorBars,T=void 0!==R&&R,x=e.lowLatencyHints,L=void 0===x||x,k=e.fastDrainOnStart,D=void 0===k||k,P=e.preferLowLatencyCodecs,N=void 0===P||P;e.onDataReceive,e.onError;var W=e.onStateChange;e.onStreamInfo;var U=e.onSizeChange,O=e.onLog,M=e.onSensorMessage,H=e.onSensorError,F=Q(I),z=f("whep",F).toString(),j=f("api/iceServers",F).toString(),J=n(null),V=n(null),K=n(),X=n(null),q=n(null),Z=r(16/9),$=Z[0],_=Z[1],AA=n(16/9),eA=n(null),nA=n(null),rA=n("0"),tA=n(!0),oA=n({platform:u,sensor:d}),cA=n(!0),aA=n(null),gA=n(null),iA=c(function(){aA.current&&(window.clearInterval(aA.current),aA.current=null)},[]),CA=function(A){return A?"".concat(A.candidateType,"@").concat(A.ip||A.address,":").concat(A.port):"n/a"},IA=c(function(A){return void 0===A&&(A=""),g(void 0,void 0,void 0,function(){var e,n,r,t,o,c,a;return i(this,function(g){switch(g.label){case 0:return(e=V.current)?[4,e.getStats()]:[2];case 1:return n=g.sent(),r=null,n.forEach(function(A){"transport"===A.type&&A.selectedCandidatePairId&&!r&&(r=n.get(A.selectedCandidatePairId))}),r||n.forEach(function(A){"candidate-pair"!==A.type||!A.selected&&!A.nominated||r||(r=A)}),r?r.id!==gA.current||A?(gA.current=r.id,t=n.get(r.localCandidateId),o=n.get(r.remoteCandidateId),c=(null!==(a=r.currentRoundTripTime)&&void 0!==a?a:r.totalRoundTripTime)||0,B(O,"[ICE SELECTED] Path: ".concat((i=t,i?"relay"===i.candidateType?"TURN relay":"host"===i.candidateType?"Direct (host)":"srflx"===i.candidateType?"Direct (srflx)":"prflx"===i.candidateType?"Direct (prflx)":i.candidateType:"unknown")," | Local: ").concat(CA(t)," | Remote: ").concat(CA(o)," | RTT: ").concat((1e3*c).toFixed(1)," ms")),[2]):[2]:(A&&B(O,"No selected ICE pair yet (".concat(A,").")),[2])}var i})})},[O]),sA=c(function(){iA(),aA.current=window.setInterval(function(){IA()},3e3)},[IA,iA]);t(function(){if(U){var A=function(){var A=X.current;if(A){var e=null!=v?v:A.clientWidth;U({width:e,height:v?v/$:e/$})}};if(A(),!v&&X.current){var e=new ResizeObserver(function(){return A()});return e.observe(X.current),function(){return e.disconnect()}}}},[U,v,$]);var uA=c(function(){return g(void 0,void 0,void 0,function(){var A,e,n,r;return i(this,function(t){switch(t.label){case 0:if("string"==typeof E&&E)return[2,{servers:[{urls:E}],forceRelay:!1}];if(Array.isArray(E)&&E.length)return[2,{servers:E,forceRelay:!1}];t.label=1;case 1:return t.trys.push([1,4,,5]),[4,fetch(j,{credentials:"same-origin",headers:{Accept:"application/json"}})];case 2:if(!(A=t.sent()).ok)throw new Error("HTTP ".concat(A.status));return[4,A.json()];case 3:return e=t.sent(),Array.isArray(e)?[2,{servers:e,forceRelay:!1}]:(n=Array.isArray(null==e?void 0:e.iceServers)?e.iceServers:[],r=!!(null==e?void 0:e.forceRelay),[2,{servers:n.length?n:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:r}]);case 4:return t.sent(),[2,{servers:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:!1}];case 5:return[2]}})})},[E,j]),lA=c(function(){null!==q.current&&(window.clearTimeout(q.current),q.current=null)},[]),dA=c(function(A){void 0===A&&(A=5e3),lA(),q.current=window.setTimeout(function(){var A;q.current=null;try{null===(A=nA.current)||void 0===A||A.close()}catch(A){}nA.current=null,B(O,"[SSE] closed automatically")},A)},[O,lA]),hA=c(function(){var A;lA();try{null===(A=nA.current)||void 0===A||A.close()}catch(A){}nA.current=null},[lA]),EA=c(function(){return g(void 0,void 0,void 0,function(){var A;return i(this,function(e){switch(e.label){case 0:if(hA(),!(A=eA.current))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(A,{method:"DELETE",credentials:"same-origin"})];case 2:return e.sent(),B(O,"Deleted WHEP resource: ".concat(A)),[3,4];case 3:return e.sent(),[3,4];case 4:return eA.current=null,[2]}})})},[O,hA]),BA=c(function(){tA.current&&(void 0!==K.current&&window.clearTimeout(K.current),K.current=window.setTimeout(function(){K.current=void 0,tA.current&&pA()},2e3))},[]),QA=c(function(){return g(void 0,void 0,void 0,function(){var A,e,n;return i(this,function(r){switch(r.label){case 0:if(tA.current=!1,void 0!==K.current&&(window.clearTimeout(K.current),K.current=void 0),iA(),gA.current=null,A=V.current){V.current=null;try{A.close()}catch(A){}}if(e=J.current){try{e.pause()}catch(A){}try{e.srcObject=null}catch(A){}try{null===(n=e.load)||void 0===n||n.call(e)}catch(A){}}return cA.current=!1,[4,EA()];case 1:return r.sent(),[2]}})})},[EA,iA]);function fA(A){var n,r;if(cA.current){var t="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{var o=JSON.parse(t),c=new Date(o[2]/1e3).toISOString();null===(n=e.onDataReceive)||void 0===n||n.call(e,c,o)}catch(A){null===(r=e.onError)||void 0===r||r.call(e,"KLV parse error: ".concat(A.message))}}}function vA(A,n){var r,t="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{null==n||n(t)}catch(A){null===(r=e.onError)||void 0===r||r.call(e,A.message)}}t(function(){var A=J.current;if(A){cA.current=!A.paused;var e=function(){cA.current=!0,B(O,"[KLV] gate: OPEN (playing)")},n=function(){cA.current=!1,B(O,"[KLV] gate: CLOSED (paused)")};return A.addEventListener("play",e),A.addEventListener("playing",e),A.addEventListener("pause",n),A.addEventListener("ended",n),function(){A.removeEventListener("play",e),A.removeEventListener("playing",e),A.removeEventListener("pause",n),A.removeEventListener("ended",n)}}},[O]);var YA=c(function(A){var e=J.current;if((null==e?void 0:e.videoWidth)&&e.videoHeight){var n=e.videoWidth/e.videoHeight;Number.isFinite(n)&&(Math.abs(n-AA.current)<.001||(AA.current=n,_(n),B(O,"[MEDIA] aspect ratio updated (".concat(A,"): ").concat(e.videoWidth,"x").concat(e.videoHeight))))}},[O]);var GA=c(function(){return g(void 0,void 0,void 0,function(){var A,e,n,r,t,o;return i(this,function(c){switch(c.label){case 0:return null===(o=V.current)||void 0===o||o.close(),V.current=null,[4,uA()];case 1:return A=c.sent(),e=A.servers,n=A.forceRelay,r=new RTCPeerConnection({iceServers:e,iceTransportPolicy:n?"relay":"all",iceCandidatePoolSize:1,bundlePolicy:"balanced",rtcpMuxPolicy:"require"}),V.current=r,r.addEventListener("iceconnectionstatechange",function(){r===V.current&&(B(O,"ICE state: ".concat(r.iceConnectionState)),["connected","completed"].includes(r.iceConnectionState)&&(IA("iceconnectionstatechange"),sA()),["disconnected","failed","closed"].includes(r.iceConnectionState)&&(iA(),BA()))}),r.addEventListener("connectionstatechange",function(){r===V.current&&(B(O,"PC state: ".concat(r.connectionState)),"connected"===r.connectionState&&(IA("connectionstatechange"),sA(),dA(3e3)),["disconnected","failed","closed"].includes(r.connectionState)&&iA())}),r.ontrack=function(A){J.current&&(J.current.srcObject=A.streams[0],m&&(J.current.muted=!0,J.current.playsInline=!0,J.current.play().catch(function(){})),function(A){var e,n;if(L)try{var r=V.current;if(!r)return;var t=r.getReceivers().find(function(e){return e.track===A});if(!t)return;"playoutDelayHint"in t&&(t.playoutDelayHint=.02,B(O,"[RX] playoutDelayHint=0.02s")),"jitterBufferTarget"in t&&(t.jitterBufferTarget=0,B(O,"[RX] jitterBufferTarget=0ms"));var o=null===(e=t.getParameters)||void 0===e?void 0:e.call(t);o&&"degradationPreference"in o&&(o.degradationPreference="maintain-framerate",null===(n=t.setParameters)||void 0===n||n.call(t,o).catch(function(){}),B(O,"[RX] degradationPreference=maintain-framerate"))}catch(A){B(O,"[RX] hints skipped: ".concat(A.message))}}(A.track),function(){if(D){var A=J.current;if(A){var e=A.playbackRate;A.playbackRate=1.2,window.setTimeout(function(){J.current&&(J.current.playbackRate=e)},1500),B(O,"[MEDIA] fast-drain 1.2× for 1.5s")}}}())},r.ondatachannel=function(A){var e=A.channel;e.binaryType="arraybuffer",e.onmessage=function(A){switch(e.label){case"klv-data":fA(A.data);break;case"info":case"sensor-state":vA(A.data,W);break;case"sensor-message":vA(A.data,M);break;case"sensor-error":vA(A.data,H)}}},t=!1,r.onicecandidate=function(A){return g(void 0,void 0,void 0,function(){var e,n,r,o,c,a;return i(this,function(g){switch(g.label){case 0:if(!(e=eA.current))return[2];g.label=1;case 1:return g.trys.push([1,6,,7]),A.candidate?(r=null!==(a=A.candidate.sdpMid)&&void 0!==a?a:rA.current,n="a=mid:".concat(r,"\r\na=").concat(A.candidate.candidate,"\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:n,credentials:"same-origin"})]):[3,3];case 2:return g.sent(),[3,5];case 3:return t?[3,5]:(t=!0,r=rA.current,o="a=mid:".concat(r,"\r\na=end-of-candidates\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:o,credentials:"same-origin"})]);case 4:g.sent(),g.label=5;case 5:return[3,7];case 6:return c=g.sent(),B(O,"WHEP PATCH error: ".concat(c.message)),[3,7];case 7:return[2]}})})},[2,r]}})})},[m,uA,O,IA,sA,iA,BA,W,M,dA]),pA=c(function(){return g(void 0,void 0,void 0,function(){var A,e,n,r,t,o,c,a,g,C,I;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),T?[2]:(tA.current=!0,[4,EA()]);case 1:return i.sent(),[4,GA()];case 2:return A=i.sent(),function(A){var e,n,r,t;if(N)try{var o=null===(n=(e=RTCRtpReceiver).getCapabilities)||void 0===n?void 0:n.call(e,"video");if(!o||!o.codecs)return;var c=o.codecs.slice(),a=function(A){var e=(A.mimeType||"").toLowerCase(),n=(A.sdpFmtpLine||"").toLowerCase();return"video/vp8"===e?0:"video/h264"===e&&/profile-level-id=42/.test(n)?1:"video/h264"===e?2:3};c.sort(function(A,e){return a(A)-a(e)}),null===(t=(r=A).setCodecPreferences)||void 0===t||t.call(r,c),B(O,"[CODEC] preferences applied (VP8/H264-baseline first)")}catch(A){B(O,"[CODEC] skipped: ".concat(A.message))}}(A.addTransceiver("video",{direction:"recvonly"})),s=A,(l=function(A,e,n){var r=s.createDataChannel(A,n);return r.binaryType="arraybuffer",r.onopen=function(){return B(O,"[DC:".concat(A,"] open"))},r.onclose=function(){return B(O,"[DC:".concat(A,"] close"))},r.onmessage=function(A){return e(A.data)},r})("klv-data",function(A){return fA(A)},{ordered:!1,maxRetransmits:0}),l("sensor-state",function(A){return vA(A,W)},{ordered:!0}),l("sensor-message",function(A){return vA(A,M)},{ordered:!0}),l("sensor-error",function(A){return vA(A,H)},{ordered:!0}),e=function(){if(!d)throw new Error("`sensor` prop is required");var A={Authorization:"Bearer none","Content-Type":"application/sdp",Sensor:d};return u&&(A.Platform=u),A["Simulcast-Layer"]=b?"all":w||"main",h&&(A.Mission=h),A}(),[4,A.createOffer()];case 3:return n=i.sent(),[4,A.setLocalDescription(n)];case 4:return i.sent(),rA.current=function(A){if(!A)return"0";for(var e=0,n=A.split(/^m=/m);e<n.length;e++){var r=n[e];if(r.startsWith("application")){var t=r.match(/^a=mid:(.+)$/m);return t?t[1].trim():"0"}}return"0"}(null===(I=A.localDescription)||void 0===I?void 0:I.sdp),B(O,"Local data MID: ".concat(rA.current)),[4,fetch(z,{method:"POST",headers:e,body:n.sdp,credentials:"same-origin"})];case 5:return(r=i.sent()).ok?[3,7]:[4,r.text().catch(function(){return""})];case 6:throw t=i.sent(),new Error("Server ".concat(r.status," ").concat(r.statusText).concat(t?" - "+t:""));case 7:return o=r.headers.get("Location"),(c=function(A,e){if(!A)return null;var n,r=new URL(e),t=new URL(".",r);try{n=new URL(A,t)}catch(A){return null}return n.origin!==r.origin&&(n=new URL(n.pathname+n.search+n.hash,r.origin)),n.toString()}(o,z))?(eA.current=c,B(O,"WHEP resource: ".concat(eA.current))):(eA.current=null,B(O,"No Location header visible (CORS). Running without trickle PATCH/DELETE.")),[4,r.text()];case 8:return a=i.sent(),[4,A.setRemoteDescription({type:"answer",sdp:a})];case 9:return i.sent(),B(O,"Subscribed successfully!"),IA("post-answer"),eA.current&&(g=eA.current.endsWith("/")?eA.current+"events":eA.current+"/events",nA.current=new EventSource(g),nA.current.addEventListener("candidate",function(e){var n=function(A){for(var e=null,n=null,r=0,t=A.split(/\r?\n/);r<t.length;r++){var o=t[r].trim();o&&(o.startsWith("a=mid:")?e=o.slice(6).trim():o.startsWith("a=candidate:")?n=o.slice(2):o.startsWith("candidate:")&&(n=o))}if(!n)return null;var c={candidate:n};return null!==e&&(c.sdpMid=e),c}(e.data);n&&("sdpMid"in n&&null!=n.sdpMid||(n.sdpMid=rA.current),A.addIceCandidate(n).catch(function(A){return B(O,"addIceCandidate error: ".concat(A.message))}),B(O,"[ICE add] ".concat(n.candidate," (mid=").concat(n.sdpMid,")")),lA())}),nA.current.addEventListener("end",function(){B(O,"[SSE] server end-of-candidates"),dA(0)}),nA.current.addEventListener("ping",function(){}),nA.current.addEventListener("open",function(){dA(3e4)}),nA.current.addEventListener("error",function(){dA(0)})),[3,11];case 10:return C=i.sent(),B(O,"Subscription failed: ".concat(C.message)),BA(),[3,11];case 11:return[2]}var s,l})})},[T,EA,GA,O,BA,z,IA,dA,lA]);t(function(){var A=oA.current;if(A.platform!==u||A.sensor!==d){oA.current={platform:u,sensor:d},B(O,"Selection changed (platform=".concat(u||"n/a",", sensor=").concat(d||"n/a","). Restarting stream."));var e=!1;return g(void 0,void 0,void 0,function(){return i(this,function(A){switch(A.label){case 0:return[4,QA()];case 1:return A.sent(),e?[2]:d?T?[2]:[4,pA()]:(B(O,"Sensor is empty after selection change; staying disconnected."),[2]);case 2:return A.sent(),[2]}})}),function(){e=!0}}},[u,d,QA,pA,T,O]);var mA=function(){var A,e=J.current;if(!e)return null;var n=document.createElement("canvas");return n.width=e.videoWidth,n.height=e.videoHeight,null===(A=n.getContext("2d"))||void 0===A||A.drawImage(e,0,0,n.width,n.height),n};o(C,function(){return a(a({},J.current),{getSnapshot:mA})}),t(function(){B(O,"Starting subscriber... (base=".concat(Q(I),")")),pA();var A=function(){QA()};return window.addEventListener("pagehide",A),window.addEventListener("beforeunload",A),function(){window.removeEventListener("pagehide",A),window.removeEventListener("beforeunload",A),QA()}},[]);var yA=T?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQBMAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAE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AAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":S||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=";return A.createElement("div",{className:"player-container",ref:X,style:a({width:v?"".concat(v,"px"):"100%"},v?{height:"".concat((v/$).toFixed(0),"px")}:{aspectRatio:String($)})},A.createElement("video",{ref:J,controls:G,autoPlay:m&&!T,muted:m,playsInline:!0,poster:yA,style:{backgroundColor:"black",width:"100%",height:"100%",display:"block",objectFit:"contain"},onLoadedMetadata:function(){var A;YA("loadedmetadata");var n=J.current;(null==n?void 0:n.videoWidth)&&n.videoHeight&&(null===(A=e.onStreamInfo)||void 0===A||A.call(e,{videoWidth:n.videoWidth,videoHeight:n.videoHeight}))},onPlaying:function(){return YA("playing")}}))});export{h as StanagPlayer,v as StanagPlayerWhep};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|