{"version":3,"file":"ClockValidatorApp-BVj5YWPV.js","sources":["../../Client/Common/heartbeat.ts","../../Client/features/clockValidator/ClockValidatorApp.tsx"],"sourcesContent":["import { Log } from './Log';\nimport { IApproximateWaitingTimeResponse } from '../Common/interfaces';\n\nexport class HeartbeatRequest {\n public RequestWaitingTime = false;\n public RequestWaitingroomMessages = false;\n}\n\nexport interface HeartbeatResponse {\n Message?: string;\n WaitingTime?: IApproximateWaitingTimeResponse;\n Duration?: number;\n BitRate?: number;\n Failed?: boolean;\n}\n\nexport class Heartbeat {\n public static isStarted = false;\n public static isFetching = false;\n public static heartbeatRequest: HeartbeatRequest = new HeartbeatRequest();\n public static start(\n videoSessionId: number,\n heartbeatRequest: HeartbeatRequest,\n onHeartBeatResponseCallBack: (response: HeartbeatResponse) => void,\n ): void {\n Heartbeat.heartbeatRequest = heartbeatRequest;\n if (this.isStarted) {\n Log.warn('Heartbeat already started', { videoSessionId });\n return;\n }\n this.isStarted = true;\n Heartbeat.loop(\n videoSessionId,\n onHeartBeatResponseCallBack,\n Heartbeat.heartbeatRequest,\n );\n setInterval(\n () =>\n Heartbeat.loop(\n videoSessionId,\n onHeartBeatResponseCallBack,\n Heartbeat.heartbeatRequest,\n ),\n 3000,\n );\n }\n\n private static loop(\n videoSessionId: number,\n onHeartBeatResponseCallBack: (data: any) => void,\n heartbeatRequest: HeartbeatRequest,\n ): void {\n if (this.isFetching) {\n return;\n }\n this.isFetching = true;\n\n performance.mark('hb-start');\n fetch('/api/consultations/heartbeat/' + videoSessionId, {\n method: 'POST',\n cache: 'no-cache',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(heartbeatRequest),\n })\n .then(async (response) => {\n let hbr: HeartbeatResponse = {};\n let nbytes = 0;\n if (response.ok) {\n hbr = await response.json();\n nbytes = Number.parseInt(\n response.headers.get('Content-length'),\n );\n } else {\n hbr.Failed = true;\n }\n\n // Get the duratin for the fetch call\n hbr.Duration = performance.measure(\n 'hb-start-to-end',\n 'hb-start',\n ).duration;\n\n // Poor man's bit rate calculation. However, it is a number which depends\n // on body size of the response body and is therefore more relaible then\n // Duration. In case of an request error, response body size will be zero\n // and bit rate will be set to zero as well.\n hbr.BitRate = Math.floor(\n (nbytes * 8) / (hbr.Duration / 1000.0),\n );\n\n // Clear marks and measurments\n performance.clearMarks('hb-start');\n performance.clearMeasures('hb-start-to-end');\n\n return Promise.resolve(hbr);\n })\n .then(onHeartBeatResponseCallBack)\n .catch((exception) => {\n //Swallowing any exception for heartbeat because they are not actionable.\n })\n .finally(() => {\n this.isFetching = false;\n });\n }\n}\n","import * as React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Log } from '../../Common/Log';\nimport { Texts } from '../../Common/Texts';\n\nexport function ClockValidatorApp(containerQuery: string) {\n const elm = document.querySelector(containerQuery);\n const root = createRoot(elm);\n root.render(