import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import{useMemo as t,Children as m,isValidElement as l,createElement as i}from"react";import s from"next/head";import a from"../ChildrenDroppable.js";import p from"../../../video/components/HTML5Embed.js";import{getYoutubeVideoId as d,youtubeVideoRegex as n}from"../../../video/common/helpers.js";import c from"../../../video/components/LiteYouTubeEmbed.js";import{createClass as f}from"@gem-sdk/system";import{useRowSettings as y}from"../../hooks/useRowSetting.js";import{getAttr as u}from"./common/attrs.js";import{getClass as h}from"./common/classes.js";import{getRowStyle as v}from"./common/styles.js";import{checkHasBackgroundVideo as g}from"./common/helpers.js";import{isEmptyChildren as j}from"@gem-sdk/core";let k=k=>{let{styles:b,setting:C,children:w}=k,{isSection:N,as:T="div"}=C??{},{background:E}=b??{},{builderAttrs:H,bgVideo:x,isRowEmpty:P,rowClassEditorOnly:R,isRenderPlaceholderViewBox:L,isPostPurchase:$,ref:z,postPurchaseVerticalAlign:A}=y(k),{rowStyle:B,backgroundBoxStyle:D,embedVideoStyle:I,sectionStyle:M}=v({rowProps:k,isPostPurchase:$,type:"React"}),{rowAttr:S}=u(k),{rowClass:V,backgroundBoxClass:Y,backgroundBoxInnerClass:q,sectionClass:F,wrapperYoutubeClasses:G,iframeYoutubeClasses:J}=h(k),K=f({[V]:!0,[R]:!0}),O=t(()=>{if(!g(E))return;if(x?.videoType==="html5"&&!x.videoHtml5||x?.videoType==="youtube"&&!x.video)return null;if(x?.videoType==="html5"&&x.videoHtml5)return e(p,{muted:!0,loop:x.loop,controls:!1,autoplay:!0,src:x.videoHtml5,title:"Video",className:"gp-relative",style:I});let o=x?.video??"",r=d(o);if(!n.test(o)||!r)return;let t=`&loop=${x?.loop?1:0}&playlist=${r}&showinfo=0&rel=0&fs=0&enablejsapi=1`;return e(c,{id:r,autoplay:!0,title:"",controls:!1,params:t,adNetwork:!1,noCookie:!0,muted:!0,lazy:!1,style:I,wrapperClass:G,iframeClass:J})},[E,x,I,J,G]),Q=m.map(w,e=>!!j(e)),U=o("div",{ref:z,...H,...S,style:B($),className:K,children:[!!O&&e("div",{className:Y,style:D,children:e("div",{className:q,children:O})}),L?e(r,{}):P?e(a,{}):m.map(w,e=>l(e)?i(e.type,{hiddenEmptyCol:k.hiddenEmptyCol&&!j(e)&&!Q,...e.props,key:e.key,order:C?.order,layout:C?.layout,justifyContent:$?A():C?.verticalAlign}):null)]});return o(r,{children:[!!b?.preloadBgImage&&o(s,{children:[!!E?.desktop?.image?.src&&e("link",{rel:"preload",href:E.desktop.image.src,as:"image"}),!!E?.tablet?.image?.src&&e("link",{rel:"preload",href:E.tablet.image.src,as:"image"}),!!E?.mobile?.image?.src&&e("link",{rel:"preload",href:E.mobile.image.src,as:"image"})]}),N?e(T,{className:F,style:M,children:U}):U]})};export{k as default};
