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