@impleotv/stanag-player 1.3.13 → 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.
@@ -2,7 +2,9 @@ import React from 'react';
2
2
  declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
3
3
  export default _default;
4
4
  export declare const PlayerUrl: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
5
+ export declare const SkyPlayer: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
5
6
  export declare const Player: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
6
7
  export declare const StServer: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
8
+ export declare const StServerNuc: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
7
9
  export declare const pr11: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
8
10
  export declare const PlayerDocker: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./StanagPlayerWhep").StanagPlayerProps & React.RefAttributes<import("./StanagPlayerWhep").StanagPlayerHandle>>;
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var A=require("react");function e(A){return A&&"object"==typeof A&&"default"in A?A:{default:A}}var n=e(A),t=function(){return t=Object.assign||function(A){for(var e,n=1,t=arguments.length;n<t;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(A[r]=e[r]);return A},t.apply(this,arguments)};function r(A,e,n,t){return new(n||(n=Promise))((function(r,o){function a(A){try{g(t.next(A))}catch(A){o(A)}}function c(A){try{g(t.throw(A))}catch(A){o(A)}}function g(A){var e;A.done?r(A.value):(e=A.value,e instanceof n?e:new n((function(A){A(e)}))).then(a,c)}g((t=t.apply(A,e||[])).next())}))}function o(A,e){var n,t,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(g){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(n=1,t&&(r=2&c[0]?t.return:c[0]?t.throw||((r=t.return)&&r.call(t),0):t.next)&&!(r=r.call(t,c[1])).done)return r;switch(t=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,t=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){a.label=c[1];break}if(6===c[0]&&a.label<r[1]){a.label=r[1],r=c;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(c);break}r[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(A,a)}catch(A){c=[6,A],t=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,g])}}}"function"==typeof SuppressedError&&SuppressedError;function a(A,e){void 0===e&&(e={});var n=e.insertAt;if(A&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=A:r.appendChild(document.createTextNode(A))}}function c(A){return A.endsWith("/")?A.slice(0,-1):A}function g(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 i(A,e,n){var t,r;if(A.current&&n.current)switch(null===(t=n.current)||void 0===t?void 0:t.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,t;if(null===(A=n.current)||void 0===A?void 0:A.recordingStarted){var r=function(A){if(void 0===A)return 0;var e=new Date(A);return((new Date).getTime()-e.getTime())/1e3}(null===(t=n.current)||void 0===t?void 0:t.recordingStarted);e.current&&(e.current.classList.remove("recorder-idle"),e.current.classList.add("recorder-active"),e.current.innerHTML=I(r,!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===(r=n.current)||void 0===r?void 0:r.recorderTimer),n.current.recorderTimer=void 0),e.current&&(e.current.innerHTML=I(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 C(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 I(A,e){if(void 0===e&&(e=!0),null==A)return"00:00:00.0";var n=new Date(1e3*A),t=n.getUTCHours(),r=n.getUTCMinutes(),o=n.getUTCSeconds(),a="";A>=86400&&(a+=Math.floor(A/86400)+":");if(a+=(t<10?"0"+t:t)+":"+(r<10?"0"+r:r)+":"+(o<10?"0"+o:o),e){var c=n.getUTCMilliseconds();a+="."+(Math.round(c/100)%10).toString()}return a}a(" \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 s=A.forwardRef((function(e,a){var s=A.useRef(null),u=A.useRef(null),l=A.useRef(null),d=A.useRef(null),h=A.useRef(null),E=A.useRef(null),B=A.useRef(null),f=A.useRef(null),Q=A.useRef(null),v=A.useRef(!0),Y=A.useState(),G=Y[0],p=Y[1],m=A.useState(e.controls&&!e.useStandardControls),y=m[0],w=m[1],b=A.useState(16/9),S=b[0],R=b[1],T=A.useState({width:e.width||360,height:(e.width||360)/S});T[0];var x=T[1],k=A.useState({width:1920,height:1080}),L=k[0],D=k[1],P=A.useState(0),N=P[0],U=P[1],W=A.useState(0),O=W[0],M=W[1],H=A.useState(null),z=H[0],F=H[1],j=A.useRef(),J=A.useRef(),V=A.useRef(),K=A.useRef(),X={iceServers:e.iceServers?[{urls:e.iceServers}]:[]};A.useEffect((function(){r(void 0,void 0,void 0,(function(){var A,n,t,r,a,g,C,I,s,l,h,B,f,v;return o(this,(function(o){switch(o.label){case 0:if(e.serverUrl)A=c(e.serverUrl);else{if(e.serverName){if(void 0===e.serverPort)return C="Undefined server port while using serverName",console.log(C),e.showErrors&&(F(C),null===(I=Q.current)||void 0===I||I.classList.add("overlayError"),Q.current.style.display="flex"),[2];n=c(e.serverName)}else n=window.location.origin;t=new URL(n),A="".concat(t.protocol,"//").concat(t.hostname,":").concat(e.serverPort)}if(u.current){if(!A)return C="Server url is not set",console.log(C),e.showErrors&&(F(C),null===(l=Q.current)||void 0===l||l.classList.add("overlayError"),Q.current.style.display="flex"),[2];p(A),u.current.serverUrl=A,F(""),null===(s=Q.current)||void 0===s||s.classList.remove("overlayError"),Q.current.style.display="none"}o.label=1;case 1:return o.trys.push([1,6,,7]),[4,fetch(A+"/info")];case 2:return[4,o.sent().json()];case 3:return(r=o.sent())&&(u.current.poster=r.poster,e.onServerInfo&&e.onServerInfo(r),r.recorderEnabled||(null===(h=d.current)||void 0===h||h.classList.add("recorder-disabled"),null===(B=E.current)||void 0===B||B.classList.add("recorder-disabled")),r.demoExpired&&(F("Demo Expired"),null===(f=Q.current)||void 0===f||f.classList.add("overlayExpired"),Q.current.style.display="flex")),[4,fetch(A+"/recorderState")];case 4:return[4,o.sent().json()];case 5:return(a=o.sent())&&u.current&&(u.current.recorderState=a.state,u.current.recordingStarted=a.timeStarted.length>0?a.timeStarted:void 0,u.current.recorderButtonText="",i(E,d,u)),[3,7];case 6:return g=o.sent(),C="Error fetching data from ".concat(A,": ").concat(g.message),console.log(C,g),e.showErrors&&(F(C),null===(v=Q.current)||void 0===v||v.classList.add("overlayError"),Q.current.style.display="flex"),[3,7];case 7:return[2]}}))}))}),[e.serverName,e.serverPort,O,e.showErrors]);var q=function(A){A.preventDefault(),function(A,e){var n,t,r;console.log("handlePlayPause"),(null===(n=A.current)||void 0===n?void 0:n.paused)?null===(t=A.current)||void 0===t||t.play():null===(r=A.current)||void 0===r||r.pause()}(s)},Z=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",C(n,"start");break;case"running":case"waiting":case"error":n.current.recorderState="stopping",C(n,"stop");break;default:n.current.recorderState="unknown"}i(A,e,n)}}(E,d,u)};A.useEffect((function(){var A,n,t,r,o,a;y?(console.log("Assign custom controls"),null!=s.current&&(s.current.addEventListener("timeupdate",(function(A){l.current&&(l.current.innerHTML=I(s.current?s.current.currentTime:null))})),s.current.onplay=function(A){v.current=!1,g(s,h)},s.current.onpause=function(A){v.current=!0,g(s,h)}),null===(A=h.current)||void 0===A||A.removeEventListener("click",q),null===(n=h.current)||void 0===n||n.addEventListener("click",q),null===(t=E.current)||void 0===t||t.removeEventListener("click",Z),null===(r=E.current)||void 0===r||r.addEventListener("click",Z),null===(o=B.current)||void 0===o||o.addEventListener("click",(function(A){var e;e=s,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===(a=f.current)||void 0===a||a.addEventListener("click",(function(A){!function(A){var e;document.pictureInPictureElement?document.exitPictureInPicture():null===(e=A.current)||void 0===e||e.requestPictureInPicture()}(s)}))):null!=s.current&&(s.current.onplay=function(A){v.current=!1},s.current.onpause=function(A){v.current=!0},s.current.addEventListener("loadedmetadata",(function(A){var n;D({width:s.current.videoWidth,height:s.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:s.current.videoWidth,videoHeight:s.current.videoHeight})}))),null!=s.current&&s.current.addEventListener("loadedmetadata",(function(A){var n;D({width:s.current.videoWidth,height:s.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:s.current.videoWidth,videoHeight:s.current.videoHeight})}))}),[y]),A.useEffect((function(){null!=s.current&&(s.current.platformName=e.platformName,s.current.sensorName=e.sensorName,s.current.missionIdOrName=e.missionIdOrName)}),[e]),A.useEffect((function(){var A,n;null!=s.current&&(s.current.muted=!0,s.current.autoplay=null!==(A=e.autoplay)&&void 0!==A&&A,e.showColorBars?s.current.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQBMAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABC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AAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":e.poster?s.current.poster=e.poster:s.current.poster=u.current.poster?"".concat(G,"/").concat(u.current.poster):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=",e.useStandardControls?(s.current.controls=null===(n=e.controls)||void 0===n||n,w(!1)):(s.current.controls=!1,w(e.controls&&!e.useStandardControls)))}),[e.controls,e.useStandardControls,e.autoplay,e.poster,e.showColorBars,e.showErrors,G]);A.useEffect((function(){try{if(G){var A=new URL(G),n="ws";"http:"!=A.protocol&&(n+="s");var t=void 0;t=e.useReverseProxy?new WebSocket(n+"://".concat(A.hostname,"/ws/").concat(A.port)):new WebSocket(n+"://".concat(A.host,"/ws")),V.current=t,t.onmessage=function(A){var n=JSON.parse(A.data);n?n.error?(console.log(n.error),e.onError&&e.onError(n.error)):n.candidate?j.current.addIceCandidate(n):j.current.setRemoteDescription(n):console.log("failed to parse msg")},t.onerror=function(A){console.log("Websocket Error.")},t.onclose=function(A){var n;K.current&&e.onConnected&&(e.onConnected(!1),K.current=!1),1e3!=A.code&&(console.log("Websocket closed: ".concat(A.code)),setTimeout((function(){U(Date.now())}),1e3));var t="Disconnected from the server";console.log(t),e.showErrors&&Q&&(F(t),null===(n=Q.current)||void 0===n||n.classList.add("overlayError"),Q.current.style.display="flex")},t.onopen=function(){!K.current&&e.onConnected&&(K.current=!0,e.onConnected(!0),Q.current.style.display="none"),setTimeout((function(){M(Date.now())}),100)}}}catch(A){console.log("Error: ".concat(A.message))}return function(){console.log("Player close")}}),[G,e.useReverseProxy,e.iceServers,N,e.showErrors]),A.useEffect((function(){try{var A=L.width/L.height;if(R(A),e.width){var n=e.width/A;x({width:e.width,height:n}),e.onSizeChange&&e.onSizeChange({width:e.width,height:n})}}catch(A){console.log("Error: ".concat(A.message))}}),[L.width,L.height,e.width]),A.useEffect((function(){try{if(0!=O){j.current=new RTCPeerConnection(X);var A=j.current;(n=j.current)&&(J.current=n.createDataChannel("klv"),J.current.binaryType="arraybuffer",J.current.onclose=function(){console.log("dataChannel has closed")},J.current.onopen=function(){console.log("dataChannel has opened")},J.current.onmessage=function(A){var n=new DataView(A.data),t=new TextDecoder("utf8"),r=JSON.parse(t.decode(n));switch(r.type){case"klv":v.current||e.onDataReceive&&e.onDataReceive(new Date(r.klvs[2]/1e3).toISOString(),r.klvs);break;case"msg":e.onMessageReceive&&e.onMessageReceive(r.msg);break;case"state":switch(e.onStateChange&&e.onStateChange(r.state),r.state){case"Timeout":u.current&&"running"===u.current.recorderState&&(u.current.recorderState="waiting",i(E,d,u));break;case"Online":u.current&&"waiting"===u.current.recorderState&&(u.current.recorderState="running",i(E,d,u));break;case"DemoExpired":F("Demo Expired"),Q.current&&(Q.current.classList.add("overlayExpired"),Q.current.style.display="flex")}break;case"recorderState":e.onRecorderStateChange&&e.onRecorderStateChange(r.state),u.current&&(u.current.recorderState=r.state,u.current.recordingStarted=r.timeStarted.length>0?r.timeStarted:void 0,i(E,d,u));break;case"recorderEvent":"error"===r.event&&u.current&&(u.current.recorderState="error",u.current.recorderButtonText=r.data),i(E,d,u),e.onRecorderEvent&&e.onRecorderEvent(r.event)}}),A.ontrack=function(A){null!=s.current&&(s.current.srcObject=A.streams[0])},A.onconnectionstatechange=function(e){console.log(A.iceConnectionState),"disconnected"===A.iceConnectionState&&J.current&&(J.current.close(),J.current.onopen=null,J.current.onclose=null,J.current.onmessage=null,J.current.onerror=null,J.current=void 0,A.close(),j.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=V.current)||void 0===e||e.send(JSON.stringify(A.candidate)))},A.createOffer().then((function(A){var e;j.current.setLocalDescription(A),null===(e=V.current)||void 0===e||e.send(JSON.stringify(A))}))}}catch(A){console.log("Error: ".concat(A.message))}var n}),[O]);var $=function(){if(!s.current)return console.error("Video element not found"),null;var A=s.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 A.useImperativeHandle(a,(function(){return t(t({},s.current),{getSnapshot:$})})),n.default.createElement("div",{className:"player-container",ref:u},n.default.createElement("div",{className:"videoContainer"},n.default.createElement("div",{className:"video-player"},n.default.createElement("video",{id:"videoWindow",className:"video",ref:s}),y&&n.default.createElement("div",{className:"player-controls"},n.default.createElement("button",{className:"play-button",title:"Play",ref:h},"▶"),n.default.createElement("button",{className:"record-button",title:"Record",ref:E},"⚪"),n.default.createElement("div",{className:"time"},n.default.createElement("span",{className:"currentPlaybackTime",title:"Playback time",ref:l},"00:00:00.000")),n.default.createElement("div",{className:"recorder-time"},n.default.createElement("span",{className:"currentRecordingTime",title:"Recording time",ref:d},"00:00:00")),n.default.createElement("div",{className:"screen-control-buttons"},n.default.createElement("button",{className:"pip-button",title:"Picture in picture",ref:f},"🔳"),n.default.createElement("button",{className:"fullscreen-button",title:"Full screen",ref:B},"⬜"))))),n.default.createElement("div",{className:"overlay",ref:Q},n.default.createElement("p",null,z)))}));s.defaultProps={useReverseProxy:!1,width:360,controls:!0,autoplay:!0,iceServers:"stun:stun.l.google.com:19302",showErrors:!0};function u(){return(new Date).toISOString()}function l(A,e){A?A("[".concat(u(),"] ").concat(e)):console.log("[".concat(u(),"] ").concat(e))}function d(A){var e,n,t=new URL(window.location.href),r=function(A){return A.pathname.endsWith("/")?A:new URL(A.pathname+"/",A.origin)},o=((n=(e=t).pathname).endsWith("/")||(n=n.slice(0,n.lastIndexOf("/")+1)),new URL(n||"/",e.origin));if(A&&""!==A.trim()){var a=new URL(A,o);return r(a.origin===t.origin&&(""===a.pathname||"/"===a.pathname)?"/"!==o.pathname?o:new URL("/webrtc/",t.origin):a)}return r("/"!==o.pathname?o:new URL("/webrtc/",t.origin))}function h(A,e){var n=String(A||"").trim();try{return new URL(n)}catch(A){}if(n.startsWith("/")){var t=(e.pathname.replace(/\/$/,"")+n).replace(/\/{2,}/g,"/");return new URL(t,"".concat(e.origin))}return new URL(n,e)}a(" \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 E=A.forwardRef((function(e,a){var c=e.serverUrl,g=e.platform,i=void 0===g?"":g,C=e.sensor,I=void 0===C?"":C,s=e.missionIdOrName,u=e.iceServers,E=e.width,B=e.controls,f=void 0===B||B,Q=e.autoplay,v=void 0===Q||Q,Y=e.layer,G=void 0===Y?"main":Y,p=e.simulcastEnabled,m=e.poster,y=e.showColorBars,w=void 0!==y&&y,b=e.lowLatencyHints,S=void 0===b||b,R=e.fastDrainOnStart,T=void 0===R||R,x=e.preferLowLatencyCodecs,k=void 0===x||x;e.onDataReceive,e.onError;var L=e.onStateChange;e.onStreamInfo;var D=e.onSizeChange,P=e.onLog,N=e.onSensorMessage,U=e.onSensorError,W=d(c),O=h("whep",W).toString(),M=h("api/iceServers",W).toString(),H=A.useRef(null),z=A.useRef(null),F=A.useRef(),j=A.useRef(null),J=A.useState(16/9),V=J[0],K=J[1],X=A.useRef(null),q=A.useRef(null),Z=A.useRef("0"),$=A.useRef(!0),_=A.useRef(null),AA=A.useRef(null),eA=A.useCallback((function(){_.current&&(window.clearInterval(_.current),_.current=null)}),[]),nA=function(A){return A?"".concat(A.candidateType,"@").concat(A.ip||A.address,":").concat(A.port):"n/a"},tA=A.useCallback((function(A){return void 0===A&&(A=""),r(void 0,void 0,void 0,(function(){var e,n,t,r,a,c,g;return o(this,(function(o){switch(o.label){case 0:return(e=z.current)?[4,e.getStats()]:[2];case 1:return n=o.sent(),t=null,n.forEach((function(A){"transport"===A.type&&A.selectedCandidatePairId&&!t&&(t=n.get(A.selectedCandidatePairId))})),t||n.forEach((function(A){"candidate-pair"!==A.type||!A.selected&&!A.nominated||t||(t=A)})),t?t.id!==AA.current||A?(AA.current=t.id,r=n.get(t.localCandidateId),a=n.get(t.remoteCandidateId),c=(null!==(g=t.currentRoundTripTime)&&void 0!==g?g:t.totalRoundTripTime)||0,l(P,"[ICE SELECTED] Path: ".concat((i=r,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(nA(r)," | Remote: ").concat(nA(a)," | RTT: ").concat((1e3*c).toFixed(1)," ms")),[2]):[2]:(A&&l(P,"No selected ICE pair yet (".concat(A,").")),[2])}var i}))}))}),[P]),rA=A.useCallback((function(){eA(),_.current=window.setInterval((function(){tA()}),3e3)}),[tA,eA]);A.useEffect((function(){if(D){var A=function(){var A=j.current;if(A){var e=null!=E?E:A.clientWidth;D({width:e,height:E?E/V:e/V})}};if(A(),!E&&j.current){var e=new ResizeObserver((function(){return A()}));return e.observe(j.current),function(){return e.disconnect()}}}}),[D,E,V]);var oA=A.useCallback((function(){return r(void 0,void 0,void 0,(function(){var A,e,n,t;return o(this,(function(r){switch(r.label){case 0:if("string"==typeof u&&u)return[2,{servers:[{urls:u}],forceRelay:!1}];if(Array.isArray(u)&&u.length)return[2,{servers:u,forceRelay:!1}];r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(M,{credentials:"same-origin",headers:{Accept:"application/json"}})];case 2:if(!(A=r.sent()).ok)throw new Error("HTTP ".concat(A.status));return[4,A.json()];case 3:return e=r.sent(),Array.isArray(e)?[2,{servers:e,forceRelay:!1}]:(n=Array.isArray(null==e?void 0:e.iceServers)?e.iceServers:[],t=!!(null==e?void 0:e.forceRelay),[2,{servers:n.length?n:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:t}]);case 4:return r.sent(),[2,{servers:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:!1}];case 5:return[2]}}))}))}),[u,M]),aA=A.useCallback((function(){var A;try{null===(A=q.current)||void 0===A||A.close()}catch(A){}q.current=null}),[]),cA=A.useCallback((function(){return r(void 0,void 0,void 0,(function(){var A;return o(this,(function(e){switch(e.label){case 0:if(aA(),!(A=X.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(),l(P,"Deleted WHEP resource: ".concat(A)),[3,4];case 3:return e.sent(),[3,4];case 4:return X.current=null,[2]}}))}))}),[P,aA]),gA=A.useCallback((function(){window.clearTimeout(F.current),F.current=window.setTimeout((function(){return sA()}),2e3)}),[]);function iA(A){var n,t;if($.current){var r="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{var o=JSON.parse(r),a=new Date(o[2]/1e3).toISOString();null===(n=e.onDataReceive)||void 0===n||n.call(e,a,o)}catch(A){null===(t=e.onError)||void 0===t||t.call(e,"KLV parse error: ".concat(A.message))}}}function CA(A,n){var t,r="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{null==n||n(r)}catch(A){null===(t=e.onError)||void 0===t||t.call(e,A.message)}}A.useEffect((function(){var A=H.current;if(A){$.current=!A.paused;var e=function(){$.current=!0,l(P,"[KLV] gate: OPEN (playing)")},n=function(){$.current=!1,l(P,"[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)}}}),[P]);var IA=A.useCallback((function(){return r(void 0,void 0,void 0,(function(){var A,e,n,t,a,c;return o(this,(function(g){switch(g.label){case 0:return null===(c=z.current)||void 0===c||c.close(),z.current=null,[4,oA()];case 1:return A=g.sent(),e=A.servers,n=A.forceRelay,t=new RTCPeerConnection({iceServers:e,iceTransportPolicy:n?"relay":"all",iceCandidatePoolSize:1,bundlePolicy:"balanced",rtcpMuxPolicy:"require"}),z.current=t,t.addEventListener("iceconnectionstatechange",(function(){l(P,"ICE state: ".concat(t.iceConnectionState)),["connected","completed"].includes(t.iceConnectionState)&&(tA("iceconnectionstatechange"),rA()),["disconnected","failed","closed"].includes(t.iceConnectionState)&&(eA(),gA())})),t.addEventListener("connectionstatechange",(function(){l(P,"PC state: ".concat(t.connectionState)),"connected"===t.connectionState&&(tA("connectionstatechange"),rA()),["disconnected","failed","closed"].includes(t.connectionState)&&eA()})),t.ontrack=function(A){H.current&&(H.current.srcObject=A.streams[0],v&&(H.current.muted=!0,H.current.playsInline=!0,H.current.play().catch((function(){}))),function(A){var e,n;if(S)try{var t=z.current;if(!t)return;var r=t.getReceivers().find((function(e){return e.track===A}));if(!r)return;"playoutDelayHint"in r&&(r.playoutDelayHint=.02,l(P,"[RX] playoutDelayHint=0.02s")),"jitterBufferTarget"in r&&(r.jitterBufferTarget=0,l(P,"[RX] jitterBufferTarget=0ms"));var o=null===(e=r.getParameters)||void 0===e?void 0:e.call(r);o&&"degradationPreference"in o&&(o.degradationPreference="maintain-framerate",null===(n=r.setParameters)||void 0===n||n.call(r,o).catch((function(){})),l(P,"[RX] degradationPreference=maintain-framerate"))}catch(A){l(P,"[RX] hints skipped: ".concat(A.message))}}(A.track),function(){if(T){var A=H.current;if(A){var e=A.playbackRate;A.playbackRate=1.2,window.setTimeout((function(){H.current&&(H.current.playbackRate=e)}),1500),l(P,"[MEDIA] fast-drain 1.2× for 1.5s")}}}())},t.ondatachannel=function(A){var e=A.channel;e.binaryType="arraybuffer",e.onmessage=function(A){switch(e.label){case"klv-data":iA(A.data);break;case"info":case"sensor-state":CA(A.data,L);break;case"sensor-message":CA(A.data,N);break;case"sensor-error":CA(A.data,U)}}},a=!1,t.onicecandidate=function(A){return r(void 0,void 0,void 0,(function(){var e,n,t,r,c,g;return o(this,(function(o){switch(o.label){case 0:if(!(e=X.current))return[2];o.label=1;case 1:return o.trys.push([1,6,,7]),A.candidate?(t=null!==(g=A.candidate.sdpMid)&&void 0!==g?g:Z.current,n="a=mid:".concat(t,"\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 o.sent(),[3,5];case 3:return a?[3,5]:(a=!0,t=Z.current,r="a=mid:".concat(t,"\r\na=end-of-candidates\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:r,credentials:"same-origin"})]);case 4:o.sent(),o.label=5;case 5:return[3,7];case 6:return c=o.sent(),l(P,"WHEP PATCH error: ".concat(c.message)),[3,7];case 7:return[2]}}))}))},[2,t]}}))}))}),[v,oA,P,tA,rA,eA,gA,L,N]),sA=A.useCallback((function(){return r(void 0,void 0,void 0,(function(){var A,e,n,t,r,a,c,g,C,u,d;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,10,,11]),w?[2]:[4,cA()];case 1:return o.sent(),[4,IA()];case 2:return A=o.sent(),function(A){var e,n,t,r;if(k)try{var o=null===(n=(e=RTCRtpReceiver).getCapabilities)||void 0===n?void 0:n.call(e,"video");if(!o||!o.codecs)return;var a=o.codecs.slice(),c=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};a.sort((function(A,e){return c(A)-c(e)})),null===(r=(t=A).setCodecPreferences)||void 0===r||r.call(t,a),l(P,"[CODEC] preferences applied (VP8/H264-baseline first)")}catch(A){l(P,"[CODEC] skipped: ".concat(A.message))}}(A.addTransceiver("video",{direction:"recvonly"})),h=A,(E=function(A,e,n){var t=h.createDataChannel(A,n);return t.binaryType="arraybuffer",t.onopen=function(){return l(P,"[DC:".concat(A,"] open"))},t.onclose=function(){return l(P,"[DC:".concat(A,"] close"))},t.onmessage=function(A){return e(A.data)},t})("klv-data",(function(A){return iA(A)}),{ordered:!1,maxRetransmits:0}),E("sensor-state",(function(A){return CA(A,L)}),{ordered:!0}),E("sensor-message",(function(A){return CA(A,N)}),{ordered:!0}),E("sensor-error",(function(A){return CA(A,U)}),{ordered:!0}),e=function(){if(!I)throw new Error("`sensor` prop is required");var A={Authorization:"Bearer none","Content-Type":"application/sdp",Sensor:I};return i&&(A.Platform=i),A["Simulcast-Layer"]=p?"all":G||"main",s&&(A.Mission=s),A}(),[4,A.createOffer()];case 3:return n=o.sent(),[4,A.setLocalDescription(n)];case 4:return o.sent(),Z.current=function(A){if(!A)return"0";for(var e=0,n=A.split(/^m=/m);e<n.length;e++){var t=n[e];if(t.startsWith("application")){var r=t.match(/^a=mid:(.+)$/m);return r?r[1].trim():"0"}}return"0"}(null===(d=A.localDescription)||void 0===d?void 0:d.sdp),l(P,"Local data MID: ".concat(Z.current)),[4,fetch(O,{method:"POST",headers:e,body:n.sdp,credentials:"same-origin"})];case 5:return(t=o.sent()).ok?[3,7]:[4,t.text().catch((function(){return""}))];case 6:throw r=o.sent(),new Error("Server ".concat(t.status," ").concat(t.statusText).concat(r?" - "+r:""));case 7:return a=t.headers.get("Location"),(c=function(A,e){if(!A)return null;var n,t=new URL(e),r=new URL(".",t);try{n=new URL(A,r)}catch(A){return null}return n.origin!==t.origin&&(n=new URL(n.pathname+n.search+n.hash,t.origin)),n.toString()}(a,O))?(X.current=c,l(P,"WHEP resource: ".concat(X.current))):(X.current=null,l(P,"No Location header visible (CORS). Running without trickle PATCH/DELETE.")),[4,t.text()];case 8:return g=o.sent(),[4,A.setRemoteDescription({type:"answer",sdp:g})];case 9:return o.sent(),l(P,"Subscribed successfully!"),tA("post-answer"),X.current&&(C=X.current.endsWith("/")?X.current+"events":X.current+"/events",q.current=new EventSource(C),q.current.addEventListener("candidate",(function(e){var n=function(A){for(var e=null,n=null,t=0,r=A.split(/\r?\n/);t<r.length;t++){var o=r[t].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 a={candidate:n};return null!==e&&(a.sdpMid=e),a}(e.data);n&&("sdpMid"in n&&null!=n.sdpMid||(n.sdpMid=Z.current),A.addIceCandidate(n).catch((function(A){return l(P,"addIceCandidate error: ".concat(A.message))})),l(P,"[ICE add] ".concat(n.candidate," (mid=").concat(n.sdpMid,")")))})),q.current.addEventListener("end",(function(){return l(P,"[SSE] server end-of-candidates")})),q.current.addEventListener("ping",(function(){}))),[3,11];case 10:return u=o.sent(),l(P,"Subscription failed: ".concat(u.message)),gA(),[3,11];case 11:return[2]}var h,E}))}))}),[w,cA,IA,P,gA,O,tA]),uA=function(){var A,e=H.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};A.useImperativeHandle(a,(function(){return t(t({},H.current),{getSnapshot:uA})})),A.useEffect((function(){l(P,"Starting subscriber... (base=".concat(d(c),")")),sA();var A=function(){cA()};return window.addEventListener("pagehide",A),window.addEventListener("beforeunload",A),function(){var e,n;window.removeEventListener("pagehide",A),window.removeEventListener("beforeunload",A),window.clearTimeout(F.current),eA(),null===(e=z.current)||void 0===e||e.close();try{null===(n=q.current)||void 0===n||n.close()}catch(A){}cA()}}),[]);var lA=w?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQBMAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAA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IAABAAAQAACAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":m||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=";return n.default.createElement("div",{className:"player-container",ref:j,style:t({width:E?"".concat(E,"px"):"100%"},E?{height:"".concat((E/V).toFixed(0),"px")}:{aspectRatio:String(V)})},n.default.createElement("video",{ref:H,controls:f,autoPlay:v&&!w,muted:v,playsInline:!0,poster:lA,style:{backgroundColor:"black",width:"100%",height:"100%",display:"block",objectFit:"contain"},onLoadedMetadata:function(){var A,n=H.current;if((null==n?void 0:n.videoWidth)&&n.videoHeight){var t=n.videoWidth/n.videoHeight;K(t),null===(A=e.onStreamInfo)||void 0===A||A.call(e,{videoWidth:n.videoWidth,videoHeight:n.videoHeight})}}}))}));exports.StanagPlayer=s,exports.StanagPlayerWhep=E;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var A=require("react");function e(A){return A&&"object"==typeof A&&"default"in A?A:{default:A}}var n=e(A),t=function(){return t=Object.assign||function(A){for(var e,n=1,t=arguments.length;n<t;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(A[r]=e[r]);return A},t.apply(this,arguments)};function r(A,e,n,t){return new(n||(n=Promise))(function(r,o){function c(A){try{g(t.next(A))}catch(A){o(A)}}function a(A){try{g(t.throw(A))}catch(A){o(A)}}function g(A){var e;A.done?r(A.value):(e=A.value,e instanceof n?e:new n(function(A){A(e)})).then(c,a)}g((t=t.apply(A,e||[])).next())})}function o(A,e){var n,t,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[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,t&&(r=2&a[0]?t.return:a[0]?t.throw||((r=t.return)&&r.call(t),0):t.next)&&!(r=r.call(t,a[1])).done)return r;switch(t=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,t=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(A,o)}catch(A){a=[6,A],t=0}finally{n=r=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 t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=A:r.appendChild(document.createTextNode(A))}}function a(A){return A.endsWith("/")?A.slice(0,-1):A}function g(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 i(A,e,n){var t,r;if(A.current&&n.current)switch(null===(t=n.current)||void 0===t?void 0:t.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,t;if(null===(A=n.current)||void 0===A?void 0:A.recordingStarted){var r=function(A){if(void 0===A)return 0;var e=new Date(A);return((new Date).getTime()-e.getTime())/1e3}(null===(t=n.current)||void 0===t?void 0:t.recordingStarted);e.current&&(e.current.classList.remove("recorder-idle"),e.current.classList.add("recorder-active"),e.current.innerHTML=s(r,!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===(r=n.current)||void 0===r?void 0:r.recorderTimer),n.current.recorderTimer=void 0),e.current&&(e.current.innerHTML=s(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 C(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 s(A,e){if(void 0===e&&(e=!0),null==A)return"00:00:00.0";var n=new Date(1e3*A),t=n.getUTCHours(),r=n.getUTCMinutes(),o=n.getUTCSeconds(),c="";A>=86400&&(c+=Math.floor(A/86400)+":");if(c+=(t<10?"0"+t:t)+":"+(r<10?"0"+r:r)+":"+(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 u=A.forwardRef(function(e,c){var u=A.useRef(null),I=A.useRef(null),l=A.useRef(null),d=A.useRef(null),h=A.useRef(null),E=A.useRef(null),B=A.useRef(null),f=A.useRef(null),Q=A.useRef(null),v=A.useRef(!0),Y=A.useState(),G=Y[0],p=Y[1],m=A.useState(e.controls&&!e.useStandardControls),y=m[0],w=m[1],b=A.useState(16/9),S=b[0],R=b[1],T=A.useState({width:e.width||360,height:(e.width||360)/S});T[0];var k=T[1],x=A.useState({width:1920,height:1080}),L=x[0],D=x[1],P=A.useState(0),N=P[0],W=P[1],U=A.useState(0),O=U[0],M=U[1],H=A.useState(null),F=H[0],j=H[1],z=A.useRef(),J=A.useRef(),V=A.useRef(),K=A.useRef(),X={iceServers:e.iceServers?[{urls:e.iceServers}]:[]};A.useEffect(function(){r(void 0,void 0,void 0,function(){var A,n,t,r,c,g,C,s,u,l,h,B,f,v;return o(this,function(o){switch(o.label){case 0:if(e.serverUrl)A=a(e.serverUrl);else{if(e.serverName){if(void 0===e.serverPort)return C="Undefined server port while using serverName",console.log(C),e.showErrors&&(j(C),null===(s=Q.current)||void 0===s||s.classList.add("overlayError"),Q.current.style.display="flex"),[2];n=a(e.serverName)}else n=window.location.origin;t=new URL(n),A="".concat(t.protocol,"//").concat(t.hostname,":").concat(e.serverPort)}if(I.current){if(!A)return C="Server url is not set",console.log(C),e.showErrors&&(j(C),null===(l=Q.current)||void 0===l||l.classList.add("overlayError"),Q.current.style.display="flex"),[2];p(A),I.current.serverUrl=A,j(""),null===(u=Q.current)||void 0===u||u.classList.remove("overlayError"),Q.current.style.display="none"}o.label=1;case 1:return o.trys.push([1,6,,7]),[4,fetch(A+"/info")];case 2:return[4,o.sent().json()];case 3:return(r=o.sent())&&(I.current.poster=r.poster,e.onServerInfo&&e.onServerInfo(r),r.recorderEnabled||(null===(h=d.current)||void 0===h||h.classList.add("recorder-disabled"),null===(B=E.current)||void 0===B||B.classList.add("recorder-disabled")),r.demoExpired&&(j("Demo Expired"),null===(f=Q.current)||void 0===f||f.classList.add("overlayExpired"),Q.current.style.display="flex")),[4,fetch(A+"/recorderState")];case 4:return[4,o.sent().json()];case 5:return(c=o.sent())&&I.current&&(I.current.recorderState=c.state,I.current.recordingStarted=c.timeStarted.length>0?c.timeStarted:void 0,I.current.recorderButtonText="",i(E,d,I)),[3,7];case 6:return g=o.sent(),C="Error fetching data from ".concat(A,": ").concat(g.message),console.log(C,g),e.showErrors&&(j(C),null===(v=Q.current)||void 0===v||v.classList.add("overlayError"),Q.current.style.display="flex"),[3,7];case 7:return[2]}})})},[e.serverName,e.serverPort,O,e.showErrors]);var q=function(A){A.preventDefault(),function(A){var e,n,t;console.log("handlePlayPause"),(null===(e=A.current)||void 0===e?void 0:e.paused)?null===(n=A.current)||void 0===n||n.play():null===(t=A.current)||void 0===t||t.pause()}(u)},Z=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",C(n,"start");break;case"running":case"waiting":case"error":n.current.recorderState="stopping",C(n,"stop");break;default:n.current.recorderState="unknown"}i(A,e,n)}}(E,d,I)};A.useEffect(function(){var A,n,t,r,o,c;y?(console.log("Assign custom controls"),null!=u.current&&(u.current.addEventListener("timeupdate",function(A){l.current&&(l.current.innerHTML=s(u.current?u.current.currentTime:null))}),u.current.onplay=function(A){v.current=!1,g(u,h)},u.current.onpause=function(A){v.current=!0,g(u,h)}),null===(A=h.current)||void 0===A||A.removeEventListener("click",q),null===(n=h.current)||void 0===n||n.addEventListener("click",q),null===(t=E.current)||void 0===t||t.removeEventListener("click",Z),null===(r=E.current)||void 0===r||r.addEventListener("click",Z),null===(o=B.current)||void 0===o||o.addEventListener("click",function(A){var e;e=u,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=f.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()}(u)})):null!=u.current&&(u.current.onplay=function(A){v.current=!1},u.current.onpause=function(A){v.current=!0},u.current.addEventListener("loadedmetadata",function(A){var n;D({width:u.current.videoWidth,height:u.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:u.current.videoWidth,videoHeight:u.current.videoHeight})})),null!=u.current&&u.current.addEventListener("loadedmetadata",function(A){var n;D({width:u.current.videoWidth,height:u.current.videoHeight}),null===(n=e.onStreamInfo)||void 0===n||n.call(e,{videoWidth:u.current.videoWidth,videoHeight:u.current.videoHeight})})},[y]),A.useEffect(function(){null!=u.current&&(u.current.platformName=e.platformName,u.current.sensorName=e.sensorName,u.current.missionIdOrName=e.missionIdOrName)},[e]),A.useEffect(function(){var A,n;null!=u.current&&(u.current.muted=!0,u.current.autoplay=null!==(A=e.autoplay)&&void 0!==A&&A,e.showColorBars?u.current.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAH4CAYAAAAb2oPSAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wwHCycIr9AEVAAACllJREFUeNrt2TFOhEAYhuEZEwgnoeEAdnIGO65AYeFtLDyAh7DZE9hzEgLFWGixtYlM/szzNG40WTJfwOQNeV3XkghrWRYjVDWboOr6NyO4/5t1m93/7n///6ljXT+MENiDCQAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAIQBMAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAh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AAEIAACAAAQAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":e.poster?u.current.poster=e.poster:u.current.poster=I.current.poster?"".concat(G,"/").concat(I.current.poster):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=",e.useStandardControls?(u.current.controls=null===(n=e.controls)||void 0===n||n,w(!1)):(u.current.controls=!1,w(e.controls&&!e.useStandardControls)))},[e.controls,e.useStandardControls,e.autoplay,e.poster,e.showColorBars,e.showErrors,G]);A.useEffect(function(){try{if(G){var A=new URL(G),n="ws";"http:"!=A.protocol&&(n+="s");var t=void 0;t=e.useReverseProxy?new WebSocket(n+"://".concat(A.hostname,"/ws/").concat(A.port)):new WebSocket(n+"://".concat(A.host,"/ws")),V.current=t,t.onmessage=function(A){var n=JSON.parse(A.data);n?n.error?(console.log(n.error),e.onError&&e.onError(n.error)):n.candidate?z.current.addIceCandidate(n):z.current.setRemoteDescription(n):console.log("failed to parse msg")},t.onerror=function(A){console.log("Websocket Error.")},t.onclose=function(A){var n;K.current&&e.onConnected&&(e.onConnected(!1),K.current=!1),1e3!=A.code&&(console.log("Websocket closed: ".concat(A.code)),setTimeout(function(){W(Date.now())},1e3));var t="Disconnected from the server";console.log(t),e.showErrors&&Q&&(j(t),null===(n=Q.current)||void 0===n||n.classList.add("overlayError"),Q.current.style.display="flex")},t.onopen=function(){!K.current&&e.onConnected&&(K.current=!0,e.onConnected(!0),Q.current.style.display="none"),setTimeout(function(){M(Date.now())},100)}}}catch(A){console.log("Error: ".concat(A.message))}return function(){console.log("Player close")}},[G,e.useReverseProxy,e.iceServers,N,e.showErrors]),A.useEffect(function(){try{var A=L.width/L.height;if(R(A),e.width){var n=e.width/A;k({width:e.width,height:n}),e.onSizeChange&&e.onSizeChange({width:e.width,height:n})}}catch(A){console.log("Error: ".concat(A.message))}},[L.width,L.height,e.width]),A.useEffect(function(){try{if(0!=O){z.current=new RTCPeerConnection(X);var A=z.current;(n=z.current)&&(J.current=n.createDataChannel("klv"),J.current.binaryType="arraybuffer",J.current.onclose=function(){console.log("dataChannel has closed")},J.current.onopen=function(){console.log("dataChannel has opened")},J.current.onmessage=function(A){var n=new DataView(A.data),t=new TextDecoder("utf8"),r=JSON.parse(t.decode(n));switch(r.type){case"klv":v.current||e.onDataReceive&&e.onDataReceive(new Date(r.klvs[2]/1e3).toISOString(),r.klvs);break;case"msg":e.onMessageReceive&&e.onMessageReceive(r.msg);break;case"state":switch(e.onStateChange&&e.onStateChange(r.state),r.state){case"Timeout":I.current&&"running"===I.current.recorderState&&(I.current.recorderState="waiting",i(E,d,I));break;case"Online":I.current&&"waiting"===I.current.recorderState&&(I.current.recorderState="running",i(E,d,I));break;case"DemoExpired":j("Demo Expired"),Q.current&&(Q.current.classList.add("overlayExpired"),Q.current.style.display="flex")}break;case"recorderState":e.onRecorderStateChange&&e.onRecorderStateChange(r.state),I.current&&(I.current.recorderState=r.state,I.current.recordingStarted=r.timeStarted.length>0?r.timeStarted:void 0,i(E,d,I));break;case"recorderEvent":"error"===r.event&&I.current&&(I.current.recorderState="error",I.current.recorderButtonText=r.data),i(E,d,I),e.onRecorderEvent&&e.onRecorderEvent(r.event)}}),A.ontrack=function(A){null!=u.current&&(u.current.srcObject=A.streams[0])},A.onconnectionstatechange=function(e){console.log(A.iceConnectionState),"disconnected"===A.iceConnectionState&&J.current&&(J.current.close(),J.current.onopen=null,J.current.onclose=null,J.current.onmessage=null,J.current.onerror=null,J.current=void 0,A.close(),z.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=V.current)||void 0===e||e.send(JSON.stringify(A.candidate)))},A.createOffer().then(function(A){var e;z.current.setLocalDescription(A),null===(e=V.current)||void 0===e||e.send(JSON.stringify(A))})}}catch(A){console.log("Error: ".concat(A.message))}var n},[O]);var $=function(){if(!u.current)return console.error("Video element not found"),null;var A=u.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 A.useImperativeHandle(c,function(){return t(t({},u.current),{getSnapshot:$})}),n.default.createElement("div",{className:"player-container",ref:I},n.default.createElement("div",{className:"videoContainer"},n.default.createElement("div",{className:"video-player"},n.default.createElement("video",{id:"videoWindow",className:"video",ref:u}),y&&n.default.createElement("div",{className:"player-controls"},n.default.createElement("button",{className:"play-button",title:"Play",ref:h},"▶"),n.default.createElement("button",{className:"record-button",title:"Record",ref:E},"⚪"),n.default.createElement("div",{className:"time"},n.default.createElement("span",{className:"currentPlaybackTime",title:"Playback time",ref:l},"00:00:00.000")),n.default.createElement("div",{className:"recorder-time"},n.default.createElement("span",{className:"currentRecordingTime",title:"Recording time",ref:d},"00:00:00")),n.default.createElement("div",{className:"screen-control-buttons"},n.default.createElement("button",{className:"pip-button",title:"Picture in picture",ref:f},"🔳"),n.default.createElement("button",{className:"fullscreen-button",title:"Full screen",ref:B},"⬜"))))),n.default.createElement("div",{className:"overlay",ref:Q},n.default.createElement("p",null,F)))});u.defaultProps={useReverseProxy:!1,width:360,controls:!0,autoplay:!0,iceServers:"stun:stun.l.google.com:19302",showErrors:!0};function I(){return(new Date).toISOString()}function l(A,e){A?A("[".concat(I(),"] ").concat(e)):console.log("[".concat(I(),"] ").concat(e))}function d(A){var e,n,t=new URL(window.location.href),r=function(A){return A.pathname.endsWith("/")?A:new URL(A.pathname+"/",A.origin)},o=((n=(e=t).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 r(c.origin===t.origin&&(""===c.pathname||"/"===c.pathname)?"/"!==o.pathname?o:new URL("/webrtc/",t.origin):c)}return r("/"!==o.pathname?o:new URL("/webrtc/",t.origin))}function h(A,e){var n=String(A||"").trim();try{return new URL(n)}catch(A){}if(n.startsWith("/")){var t=(e.pathname.replace(/\/$/,"")+n).replace(/\/{2,}/g,"/");return new URL(t,"".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 E=A.forwardRef(function(e,c){var a=e.serverUrl,g=e.platform,i=void 0===g?"":g,C=e.sensor,s=void 0===C?"":C,u=e.missionIdOrName,I=e.iceServers,E=e.width,B=e.controls,f=void 0===B||B,Q=e.autoplay,v=void 0===Q||Q,Y=e.layer,G=void 0===Y?"main":Y,p=e.simulcastEnabled,m=e.poster,y=e.showColorBars,w=void 0!==y&&y,b=e.lowLatencyHints,S=void 0===b||b,R=e.fastDrainOnStart,T=void 0===R||R,k=e.preferLowLatencyCodecs,x=void 0===k||k;e.onDataReceive,e.onError;var L=e.onStateChange;e.onStreamInfo;var D=e.onSizeChange,P=e.onLog,N=e.onSensorMessage,W=e.onSensorError,U=d(a),O=h("whep",U).toString(),M=h("api/iceServers",U).toString(),H=A.useRef(null),F=A.useRef(null),j=A.useRef(),z=A.useRef(null),J=A.useRef(null),V=A.useState(16/9),K=V[0],X=V[1],q=A.useRef(16/9),Z=A.useRef(null),$=A.useRef(null),_=A.useRef("0"),AA=A.useRef(!0),eA=A.useRef({platform:i,sensor:s}),nA=A.useRef(!0),tA=A.useRef(null),rA=A.useRef(null),oA=A.useCallback(function(){tA.current&&(window.clearInterval(tA.current),tA.current=null)},[]),cA=function(A){return A?"".concat(A.candidateType,"@").concat(A.ip||A.address,":").concat(A.port):"n/a"},aA=A.useCallback(function(A){return void 0===A&&(A=""),r(void 0,void 0,void 0,function(){var e,n,t,r,c,a,g;return o(this,function(o){switch(o.label){case 0:return(e=F.current)?[4,e.getStats()]:[2];case 1:return n=o.sent(),t=null,n.forEach(function(A){"transport"===A.type&&A.selectedCandidatePairId&&!t&&(t=n.get(A.selectedCandidatePairId))}),t||n.forEach(function(A){"candidate-pair"!==A.type||!A.selected&&!A.nominated||t||(t=A)}),t?t.id!==rA.current||A?(rA.current=t.id,r=n.get(t.localCandidateId),c=n.get(t.remoteCandidateId),a=(null!==(g=t.currentRoundTripTime)&&void 0!==g?g:t.totalRoundTripTime)||0,l(P,"[ICE SELECTED] Path: ".concat((i=r,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(r)," | Remote: ").concat(cA(c)," | RTT: ").concat((1e3*a).toFixed(1)," ms")),[2]):[2]:(A&&l(P,"No selected ICE pair yet (".concat(A,").")),[2])}var i})})},[P]),gA=A.useCallback(function(){oA(),tA.current=window.setInterval(function(){aA()},3e3)},[aA,oA]);A.useEffect(function(){if(D){var A=function(){var A=z.current;if(A){var e=null!=E?E:A.clientWidth;D({width:e,height:E?E/K:e/K})}};if(A(),!E&&z.current){var e=new ResizeObserver(function(){return A()});return e.observe(z.current),function(){return e.disconnect()}}}},[D,E,K]);var iA=A.useCallback(function(){return r(void 0,void 0,void 0,function(){var A,e,n,t;return o(this,function(r){switch(r.label){case 0:if("string"==typeof I&&I)return[2,{servers:[{urls:I}],forceRelay:!1}];if(Array.isArray(I)&&I.length)return[2,{servers:I,forceRelay:!1}];r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(M,{credentials:"same-origin",headers:{Accept:"application/json"}})];case 2:if(!(A=r.sent()).ok)throw new Error("HTTP ".concat(A.status));return[4,A.json()];case 3:return e=r.sent(),Array.isArray(e)?[2,{servers:e,forceRelay:!1}]:(n=Array.isArray(null==e?void 0:e.iceServers)?e.iceServers:[],t=!!(null==e?void 0:e.forceRelay),[2,{servers:n.length?n:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:t}]);case 4:return r.sent(),[2,{servers:[{urls:["stun:stun.l.google.com:19302"]}],forceRelay:!1}];case 5:return[2]}})})},[I,M]),CA=A.useCallback(function(){null!==J.current&&(window.clearTimeout(J.current),J.current=null)},[]),sA=A.useCallback(function(A){void 0===A&&(A=5e3),CA(),J.current=window.setTimeout(function(){var A;J.current=null;try{null===(A=$.current)||void 0===A||A.close()}catch(A){}$.current=null,l(P,"[SSE] closed automatically")},A)},[P,CA]),uA=A.useCallback(function(){var A;CA();try{null===(A=$.current)||void 0===A||A.close()}catch(A){}$.current=null},[CA]),IA=A.useCallback(function(){return r(void 0,void 0,void 0,function(){var A;return o(this,function(e){switch(e.label){case 0:if(uA(),!(A=Z.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(),l(P,"Deleted WHEP resource: ".concat(A)),[3,4];case 3:return e.sent(),[3,4];case 4:return Z.current=null,[2]}})})},[P,uA]),lA=A.useCallback(function(){AA.current&&(void 0!==j.current&&window.clearTimeout(j.current),j.current=window.setTimeout(function(){j.current=void 0,AA.current&&QA()},2e3))},[]),dA=A.useCallback(function(){return r(void 0,void 0,void 0,function(){var A,e,n;return o(this,function(t){switch(t.label){case 0:if(AA.current=!1,void 0!==j.current&&(window.clearTimeout(j.current),j.current=void 0),oA(),rA.current=null,A=F.current){F.current=null;try{A.close()}catch(A){}}if(e=H.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 nA.current=!1,[4,IA()];case 1:return t.sent(),[2]}})})},[IA,oA]);function hA(A){var n,t;if(nA.current){var r="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{var o=JSON.parse(r),c=new Date(o[2]/1e3).toISOString();null===(n=e.onDataReceive)||void 0===n||n.call(e,c,o)}catch(A){null===(t=e.onError)||void 0===t||t.call(e,"KLV parse error: ".concat(A.message))}}}function EA(A,n){var t,r="string"==typeof A?A:A instanceof ArrayBuffer?(new TextDecoder).decode(A):String(A);try{null==n||n(r)}catch(A){null===(t=e.onError)||void 0===t||t.call(e,A.message)}}A.useEffect(function(){var A=H.current;if(A){nA.current=!A.paused;var e=function(){nA.current=!0,l(P,"[KLV] gate: OPEN (playing)")},n=function(){nA.current=!1,l(P,"[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)}}},[P]);var BA=A.useCallback(function(A){var e=H.current;if((null==e?void 0:e.videoWidth)&&e.videoHeight){var n=e.videoWidth/e.videoHeight;Number.isFinite(n)&&(Math.abs(n-q.current)<.001||(q.current=n,X(n),l(P,"[MEDIA] aspect ratio updated (".concat(A,"): ").concat(e.videoWidth,"x").concat(e.videoHeight))))}},[P]);var fA=A.useCallback(function(){return r(void 0,void 0,void 0,function(){var A,e,n,t,c,a;return o(this,function(g){switch(g.label){case 0:return null===(a=F.current)||void 0===a||a.close(),F.current=null,[4,iA()];case 1:return A=g.sent(),e=A.servers,n=A.forceRelay,t=new RTCPeerConnection({iceServers:e,iceTransportPolicy:n?"relay":"all",iceCandidatePoolSize:1,bundlePolicy:"balanced",rtcpMuxPolicy:"require"}),F.current=t,t.addEventListener("iceconnectionstatechange",function(){t===F.current&&(l(P,"ICE state: ".concat(t.iceConnectionState)),["connected","completed"].includes(t.iceConnectionState)&&(aA("iceconnectionstatechange"),gA()),["disconnected","failed","closed"].includes(t.iceConnectionState)&&(oA(),lA()))}),t.addEventListener("connectionstatechange",function(){t===F.current&&(l(P,"PC state: ".concat(t.connectionState)),"connected"===t.connectionState&&(aA("connectionstatechange"),gA(),sA(3e3)),["disconnected","failed","closed"].includes(t.connectionState)&&oA())}),t.ontrack=function(A){H.current&&(H.current.srcObject=A.streams[0],v&&(H.current.muted=!0,H.current.playsInline=!0,H.current.play().catch(function(){})),function(A){var e,n;if(S)try{var t=F.current;if(!t)return;var r=t.getReceivers().find(function(e){return e.track===A});if(!r)return;"playoutDelayHint"in r&&(r.playoutDelayHint=.02,l(P,"[RX] playoutDelayHint=0.02s")),"jitterBufferTarget"in r&&(r.jitterBufferTarget=0,l(P,"[RX] jitterBufferTarget=0ms"));var o=null===(e=r.getParameters)||void 0===e?void 0:e.call(r);o&&"degradationPreference"in o&&(o.degradationPreference="maintain-framerate",null===(n=r.setParameters)||void 0===n||n.call(r,o).catch(function(){}),l(P,"[RX] degradationPreference=maintain-framerate"))}catch(A){l(P,"[RX] hints skipped: ".concat(A.message))}}(A.track),function(){if(T){var A=H.current;if(A){var e=A.playbackRate;A.playbackRate=1.2,window.setTimeout(function(){H.current&&(H.current.playbackRate=e)},1500),l(P,"[MEDIA] fast-drain 1.2× for 1.5s")}}}())},t.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,L);break;case"sensor-message":EA(A.data,N);break;case"sensor-error":EA(A.data,W)}}},c=!1,t.onicecandidate=function(A){return r(void 0,void 0,void 0,function(){var e,n,t,r,a,g;return o(this,function(o){switch(o.label){case 0:if(!(e=Z.current))return[2];o.label=1;case 1:return o.trys.push([1,6,,7]),A.candidate?(t=null!==(g=A.candidate.sdpMid)&&void 0!==g?g:_.current,n="a=mid:".concat(t,"\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 o.sent(),[3,5];case 3:return c?[3,5]:(c=!0,t=_.current,r="a=mid:".concat(t,"\r\na=end-of-candidates\r\n"),[4,fetch(e,{method:"PATCH",headers:{"Content-Type":"application/trickle-ice-sdpfrag"},body:r,credentials:"same-origin"})]);case 4:o.sent(),o.label=5;case 5:return[3,7];case 6:return a=o.sent(),l(P,"WHEP PATCH error: ".concat(a.message)),[3,7];case 7:return[2]}})})},[2,t]}})})},[v,iA,P,aA,gA,oA,lA,L,N,sA]),QA=A.useCallback(function(){return r(void 0,void 0,void 0,function(){var A,e,n,t,r,c,a,g,C,I,d;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,10,,11]),w?[2]:(AA.current=!0,[4,IA()]);case 1:return o.sent(),[4,fA()];case 2:return A=o.sent(),function(A){var e,n,t,r;if(x)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===(r=(t=A).setCodecPreferences)||void 0===r||r.call(t,c),l(P,"[CODEC] preferences applied (VP8/H264-baseline first)")}catch(A){l(P,"[CODEC] skipped: ".concat(A.message))}}(A.addTransceiver("video",{direction:"recvonly"})),h=A,(E=function(A,e,n){var t=h.createDataChannel(A,n);return t.binaryType="arraybuffer",t.onopen=function(){return l(P,"[DC:".concat(A,"] open"))},t.onclose=function(){return l(P,"[DC:".concat(A,"] close"))},t.onmessage=function(A){return e(A.data)},t})("klv-data",function(A){return hA(A)},{ordered:!1,maxRetransmits:0}),E("sensor-state",function(A){return EA(A,L)},{ordered:!0}),E("sensor-message",function(A){return EA(A,N)},{ordered:!0}),E("sensor-error",function(A){return EA(A,W)},{ordered:!0}),e=function(){if(!s)throw new Error("`sensor` prop is required");var A={Authorization:"Bearer none","Content-Type":"application/sdp",Sensor:s};return i&&(A.Platform=i),A["Simulcast-Layer"]=p?"all":G||"main",u&&(A.Mission=u),A}(),[4,A.createOffer()];case 3:return n=o.sent(),[4,A.setLocalDescription(n)];case 4:return o.sent(),_.current=function(A){if(!A)return"0";for(var e=0,n=A.split(/^m=/m);e<n.length;e++){var t=n[e];if(t.startsWith("application")){var r=t.match(/^a=mid:(.+)$/m);return r?r[1].trim():"0"}}return"0"}(null===(d=A.localDescription)||void 0===d?void 0:d.sdp),l(P,"Local data MID: ".concat(_.current)),[4,fetch(O,{method:"POST",headers:e,body:n.sdp,credentials:"same-origin"})];case 5:return(t=o.sent()).ok?[3,7]:[4,t.text().catch(function(){return""})];case 6:throw r=o.sent(),new Error("Server ".concat(t.status," ").concat(t.statusText).concat(r?" - "+r:""));case 7:return c=t.headers.get("Location"),(a=function(A,e){if(!A)return null;var n,t=new URL(e),r=new URL(".",t);try{n=new URL(A,r)}catch(A){return null}return n.origin!==t.origin&&(n=new URL(n.pathname+n.search+n.hash,t.origin)),n.toString()}(c,O))?(Z.current=a,l(P,"WHEP resource: ".concat(Z.current))):(Z.current=null,l(P,"No Location header visible (CORS). Running without trickle PATCH/DELETE.")),[4,t.text()];case 8:return g=o.sent(),[4,A.setRemoteDescription({type:"answer",sdp:g})];case 9:return o.sent(),l(P,"Subscribed successfully!"),aA("post-answer"),Z.current&&(C=Z.current.endsWith("/")?Z.current+"events":Z.current+"/events",$.current=new EventSource(C),$.current.addEventListener("candidate",function(e){var n=function(A){for(var e=null,n=null,t=0,r=A.split(/\r?\n/);t<r.length;t++){var o=r[t].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=_.current),A.addIceCandidate(n).catch(function(A){return l(P,"addIceCandidate error: ".concat(A.message))}),l(P,"[ICE add] ".concat(n.candidate," (mid=").concat(n.sdpMid,")")),CA())}),$.current.addEventListener("end",function(){l(P,"[SSE] server end-of-candidates"),sA(0)}),$.current.addEventListener("ping",function(){}),$.current.addEventListener("open",function(){sA(3e4)}),$.current.addEventListener("error",function(){sA(0)})),[3,11];case 10:return I=o.sent(),l(P,"Subscription failed: ".concat(I.message)),lA(),[3,11];case 11:return[2]}var h,E})})},[w,IA,fA,P,lA,O,aA,sA,CA]);A.useEffect(function(){var A=eA.current;if(A.platform!==i||A.sensor!==s){eA.current={platform:i,sensor:s},l(P,"Selection changed (platform=".concat(i||"n/a",", sensor=").concat(s||"n/a","). Restarting stream."));var e=!1;return r(void 0,void 0,void 0,function(){return o(this,function(A){switch(A.label){case 0:return[4,dA()];case 1:return A.sent(),e?[2]:s?w?[2]:[4,QA()]:(l(P,"Sensor is empty after selection change; staying disconnected."),[2]);case 2:return A.sent(),[2]}})}),function(){e=!0}}},[i,s,dA,QA,w,P]);var vA=function(){var A,e=H.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};A.useImperativeHandle(c,function(){return t(t({},H.current),{getSnapshot:vA})}),A.useEffect(function(){l(P,"Starting subscriber... (base=".concat(d(a),")")),QA();var A=function(){dA()};return window.addEventListener("pagehide",A),window.addEventListener("beforeunload",A),function(){window.removeEventListener("pagehide",A),window.removeEventListener("beforeunload",A),dA()}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CAAAgAAEAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAIAABAAAQgAAAAAhAAAAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAIQAAAAAQgAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAABAAAIAACAAAQAAEIAAAAAIQAAAAAQgAAAAAhAAAAABCAAAgAAEAABAAAIAACAAAQAABCAAAAACEAAAAAEIAACAAAQAAEAAAgAAIAABAAAQgAAAAAhAAAAABCAAAIAABAAAQAACAAAgAAEAABCAAAAACEAAAAAEIAAAAAIQAAAAAQgAAIAABAAAQAACAAA05RsJEyujR+3OEgAAAABJRU5ErkJggg==":m||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAAAAADqFoKKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAHJUlEQVR42u3UMQEAAAjDMMDT/FtDyBIJPboZgE4nAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGKAEgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCBggBIABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAgAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggIABSgAYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECBghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAhgggAECGCCAAQIYIIABAgYoAWCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABghggAAGCGCAAAYIYIAABggYIIABAjR5XwwF1YyFqLcAAAAASUVORK5CYII=";return n.default.createElement("div",{className:"player-container",ref:z,style:t({width:E?"".concat(E,"px"):"100%"},E?{height:"".concat((E/K).toFixed(0),"px")}:{aspectRatio:String(K)})},n.default.createElement("video",{ref:H,controls:f,autoPlay:v&&!w,muted:v,playsInline:!0,poster:YA,style:{backgroundColor:"black",width:"100%",height:"100%",display:"block",objectFit:"contain"},onLoadedMetadata:function(){var A;BA("loadedmetadata");var n=H.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 BA("playing")}}))});exports.StanagPlayer=u,exports.StanagPlayerWhep=E;
2
2
  //# sourceMappingURL=index.js.map