export default function(){window?.gtag&&(wp.hooks.addAction("presto.playerPlay","presto-player",videoStart),wp.hooks.addAction("presto.playerPause","presto-player",videoPause),wp.hooks.addAction("presto.playerReady","presto-player",videoLoad),wp.hooks.addAction("presto.playerTimeUpdate","presto-player",videoTime))}export function videoData(e){return{video_current_time:parseInt(e?.currentTime||0),video_provider:e?.provider||"html5",...e?.duration?{video_duration:parseInt(e?.duration)}:{},...e?.source?{video_url:e?.source}:{},...e?.config?.title?{video_title:e?.config?.title}:{}}}export function videoStart(e){e?.config?.hasPlayed||(e.config.hasPlayed=!0,window?.gtag("event","Play",videoData(e)))}export function videoPause(e){window?.gtag("event","Pause",videoData(e))}export function videoLoad(e){e?.config?.hasLoaded||(e.config.hasLoaded=!0,window?.gtag("event","Player Load",videoData(e)))}let watched={25:!1,50:!1,75:!1,100:!1};export function videoTime(e){if(!e.currentTime)return;const o=parseFloat(e.currentTime)/parseFloat(e.duration)*100;Object.keys(watched).forEach((t=>{!watched[t]&&o>=parseInt(t)&&(watched[t]=!0,window?.gtag("event",`${t} Percent Played`,videoData(e)))}))}