'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),YouTube=require("react-youtube"),helpers=require("../common/helpers.js"),NextImage=require("../../image/components/NextImage.js"),system=require("@gem-sdk/system"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),useLiteYoutubeEmbed=require("../hooks/useLiteYoutubeEmbed.js");const LiteYouTubeEmbed=e=>{let t=core.useEditorMode(),s="edit"!==t,{style:a,poster:r,iframeClass:l,wrapperClass:i,title:u}=e,{preload:o}=r||{},{videoId:c,paramsImp:m,posterUrl:n,iframeSrc:d}=helpers.getYoutubeParams(e),{iframe:y,intervalPlay:b,warmConnections:g,isVideoStarted:p,videoDuration:j,addIframe:x}=useLiteYoutubeEmbed.useLiteYoutubeEmbed(e,m,c),f=o&&s,h=system.createClass({...classes.getButtonYoutubeClasses(y)}),C=system.createClass({...classes.getImageYoutubeClasses()}),Y=system.createClass({...classes.getArticleYoutubeClasses(f||!1,i)}),v=system.createClass({...classes.getIframeYoutubeClasses(l)}),R=system.createStyle({...styles.getIframeYoutubeStyle(a)}),S=system.createStyle({...styles.getArticleYoutubeStyle(a,n)}),N=system.createClass({...classes.getYoutubeContentClasses()}),q=()=>{if(e.isHeroBanner&&helpers.isSettingLoop(m))return jsxRuntime.jsx(YouTube,{videoId:c,title:u,iframeClassName:v,style:R,className:N,opts:{host:"https://www.youtube-nocookie.com",playerVars:{autoplay:1,state:1,controls:0,mute:1,...helpers.covertStrParamsToObj(m)}},onReady:t=>{if(t.target.playVideo(),j.current=Math.floor(t.target.getDuration()),e.isHeroBanner){let e=t.target.getIframe();if(e){let t=e.closest("div.hero-banner-container");if(t){let s=new CustomEvent("youtube-iframe-ready",{detail:{iframe:e},bubbles:!0,cancelable:!0});t.dispatchEvent(s)}}}},onStateChange:e=>{let t=e.target;p.current||(t.playVideo(),p.current=!0,b(e)),0===e.data&&(j.current=t.getCurrentTime(),t.playVideo(),b(e))}});let t=jsxRuntime.jsx("iframe",{className:v,style:R,title:u,frameBorder:"0",allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,src:d});return e.isHeroBanner?jsxRuntime.jsx("div",{className:N,children:t}):t};return jsxRuntime.jsxs("article",{"aria-hidden":!0,className:Y,"data-title":u,style:S,onPointerOver:g,onClick:x,children:[jsxRuntime.jsx(NextImage.default,{src:n,alt:r?.altText,title:r?.imageTitle,priority:s&&o,enableLazyLoadImage:!0,className:C,isDisableAspectStyle:!0}),jsxRuntime.jsx("button",{type:"button","aria-label":"Play",className:h,children:jsxRuntime.jsxs("svg",{height:"100%",version:"1.1",viewBox:"0 0 68 48",width:"100%",children:[jsxRuntime.jsx("path",{d:"M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z",fill:"#f00"}),jsxRuntime.jsx("path",{d:"M 45,24 27,14 27,34",fill:"#fff"})]})}),y&&q()]})};exports.default=LiteYouTubeEmbed;
