"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,isHeroBanner:s}=e,[a,c]=React.useState(!1),[o,l]=React.useState(!u),n=()=>{a||c(!0)},i=()=>{o||l(!0)},p=React.useRef(!1),d=React.useRef(0),R=React.useRef(),b=e=>{let r=e.target;if(r&&s&&helpers.isSettingLoop(t)&&d.current>0){let e=parseFloat((d.current/100*5).toFixed(2));clearInterval(R.current),R.current=setInterval(()=>{let t=parseFloat(r.getCurrentTime().toFixed(2)),u=parseFloat((d.current-t).toFixed(2));u<=parseFloat((1.5*e).toFixed(2))&&r.seekTo(0)},1e3*e)}};return React.useEffect(()=>()=>{R.current&&(clearInterval(R.current),p.current=!1)},[r,t]),{iframe:o,addIframe:i,intervalPlay:b,warmConnections:n,isVideoStarted:p,videoDuration:d}};exports.default=useLiteYoutubeEmbed,exports.useLiteYoutubeEmbed=useLiteYoutubeEmbed;
