{"version":3,"sources":["../ui/src/components/player-core/players/staticVideoTag.tsx"],"sourcesContent":["import { conditions, videoTag } from \"helpers\";\r\nimport { useEffect, useRef } from \"react\";\r\nimport { handleStaticVideoCanPlay, handleStaticVideoEnded, handleStaticVideoLoadedData, handleStaticVideoPause, handleStaticVideoPlay, handleStaticVideoPlaying, handleStaticVideoTimeUpdate } from \"../../../../../redux/actions\";\r\nimport { useAppDispatch, useAppSelector } from \"../../../../../redux/hooks\";\r\nimport { setVideoElementSizeInfo } from \"../../../../../redux/slices/videoDataSlice\";\r\nimport { ConditionName } from \"../../../../../interfaces\";\r\nimport { handlePageLoadTime } from \"../../../../../helpers\";\r\nimport { shallowEqual } from 'react-redux'\r\n\r\nconst StaticVideoTag = () => {\r\n    const dispatch = useAppDispatch();\r\n    const { params, ads } = useAppSelector(({ videoData: { params, ads } }) => ({ params, ads }), shallowEqual);\r\n    useAppSelector(({ controller: { firstPlay } }) => ({ firstPlay }), shallowEqual);\r\n    const loadingDurationRef = useRef<any>(0);\r\n    const initialWaitingDurationRef = useRef<any>(0);\r\n    const timerRef = useRef<any>(null);\r\n\r\n    useEffect(() => {\r\n        handlePageLoadTime(loadingDurationRef);\r\n        initialWaitingDurationRef.current = Date.now();\r\n    }, [])\r\n\r\n    useEffect(() => {\r\n        const handleResize = () => {\r\n            const element: any = videoTag()?.getBoundingClientRect();\r\n            if (element) dispatch(setVideoElementSizeInfo(element));\r\n        }\r\n        if (conditions(ConditionName.isFirstPlay)) handleResize();\r\n        window.addEventListener(\"resize\", handleResize);\r\n\r\n        return () => window.removeEventListener(\"resize\", handleResize);\r\n    }, [])\r\n\r\n    return (\r\n        <video\r\n            autoPlay={conditions(ConditionName.hasAutoPlay)}\r\n            id={conditions(ConditionName.isPlayingAd) ? \"ad-player-tag\" : \"player-tag\"}\r\n            className={`pl-w-screen pl-h-screen pl-items-center pl-flex-1 ${conditions(ConditionName.isPlayingAd) && \"pl-absolute z-[100000]\"} ${conditions(ConditionName.isFirstPlay) && \"pl-opacity-0\"}`}\r\n            onPause={handleStaticVideoPause}\r\n            onPlay={(event) => handleStaticVideoPlay(event, timerRef)}\r\n            onPlaying={() => handleStaticVideoPlaying(loadingDurationRef, initialWaitingDurationRef, timerRef)}\r\n            onTimeUpdate={handleStaticVideoTimeUpdate}\r\n            onCanPlay={handleStaticVideoCanPlay}\r\n            onLoadedData={handleStaticVideoLoadedData}\r\n            onEnded={handleStaticVideoEnded}\r\n            playsInline\r\n        >\r\n            <source src={conditions(ConditionName.isPlayingAd) ? ads.adStreamLink : params.src} />\r\n        </video>\r\n    )\r\n}\r\n\r\nexport default StaticVideoTag;"],"mappings":"iPAAAA,IACA,OAAS,aAAAC,EAAW,UAAAC,MAAc,QAMlC,OAAS,gBAAAC,MAAoB,cAwCjB,cAAAC,MAAA,oBAtCZ,IAAMC,EAAiB,IAAM,CACzB,IAAMC,EAAWC,EAAe,EAC1B,CAAE,OAAAC,EAAQ,IAAAC,CAAI,EAAIC,EAAe,CAAC,CAAE,UAAW,CAAE,OAAAF,EAAQ,IAAAC,CAAI,CAAE,KAAO,CAAE,OAAAD,EAAQ,IAAAC,CAAI,GAAIN,CAAY,EAC1GO,EAAe,CAAC,CAAE,WAAY,CAAE,UAAAC,CAAU,CAAE,KAAO,CAAE,UAAAA,CAAU,GAAIR,CAAY,EAC/E,IAAMS,EAAqBC,EAAY,CAAC,EAClCC,EAA4BD,EAAY,CAAC,EACzCE,EAAWF,EAAY,IAAI,EAEjC,OAAAG,EAAU,IAAM,CACZC,EAAmBL,CAAkB,EACrCE,EAA0B,QAAU,KAAK,IAAI,CACjD,EAAG,CAAC,CAAC,EAELE,EAAU,IAAM,CACZ,IAAME,EAAe,IAAM,CACvB,IAAMC,EAAeC,EAAS,GAAG,sBAAsB,EACnDD,GAASb,EAASe,EAAwBF,CAAO,CAAC,CAC1D,EACA,OAAIG,eAAoC,GAAGJ,EAAa,EACxD,OAAO,iBAAiB,SAAUA,CAAY,EAEvC,IAAM,OAAO,oBAAoB,SAAUA,CAAY,CAClE,EAAG,CAAC,CAAC,EAGDd,EAAC,SACG,SAAUkB,eAAoC,EAC9C,GAAIA,eAAoC,EAAI,gBAAkB,aAC9D,UAAW,qDAAqDA,eAAoC,GAAK,wBAAwB,IAAIA,eAAoC,GAAK,cAAc,GAC5L,QAASC,EACT,OAASC,GAAUC,EAAsBD,EAAOT,CAAQ,EACxD,UAAW,IAAMW,EAAyBd,EAAoBE,EAA2BC,CAAQ,EACjG,aAAcY,EACd,UAAWC,EACX,aAAcC,EACd,QAASC,EACT,YAAW,GAEX,SAAA1B,EAAC,UAAO,IAAKkB,eAAoC,EAAIb,EAAI,aAAeD,EAAO,IAAK,EACxF,CAER,EAEOuB,EAAQ1B","names":["init_esm_shims","useEffect","useRef","shallowEqual","jsx","StaticVideoTag","dispatch","useAppDispatch","params","ads","useAppSelector","firstPlay","loadingDurationRef","useRef","initialWaitingDurationRef","timerRef","useEffect","handlePageLoadTime","handleResize","element","videoTag","setVideoElementSizeInfo","conditions","handleStaticVideoPause","event","handleStaticVideoPlay","handleStaticVideoPlaying","handleStaticVideoTimeUpdate","handleStaticVideoCanPlay","handleStaticVideoLoadedData","handleStaticVideoEnded","staticVideoTag_default"]}