"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),helpers=require("../common/helpers.js");const useLiteYoutubeEmbed=(e,t,r)=>{let{lazy:u,autoplay:s,isHeroBanner:a,thumbnail:c}=e,o=!!c,[l,n]=React.useState(!1),[i,p]=React.useState(!u&&(!o||!!s)),d=()=>{l||n(!0)},R=()=>{i||p(!0)},b=React.useRef(!1),f=React.useRef(0),F=React.useRef(),m=e=>{let r=e.target;if(r&&a&&helpers.isSettingLoop(t)&&f.current>0){let e=parseFloat((f.current/100*5).toFixed(2));clearInterval(F.current),F.current=setInterval(()=>{let t=parseFloat(r.getCurrentTime().toFixed(2)),u=parseFloat((f.current-t).toFixed(2));u<=parseFloat((1.5*e).toFixed(2))&&r.seekTo(0)},1e3*e)}};return React.useEffect(()=>()=>{F.current&&(clearInterval(F.current),b.current=!1)},[r,t]),{iframe:i,addIframe:R,intervalPlay:m,warmConnections:d,isVideoStarted:b,videoDuration:f}};exports.default=useLiteYoutubeEmbed,exports.useLiteYoutubeEmbed=useLiteYoutubeEmbed;
