import{template as e,WrapRenderChildren as o,RenderChildren as s,RenderIf as r,hasTranslatedLiquid as t,isLocalEnv as i,baseAssetURL as a}from"@gem-sdk/core";import{getBackgroundTranslated as l,getSettingPreloadData as m}from"../../../helpers.js";import p from"../../../video/components/HTML5Embed.liquid.js";import{createClass as d,If as n}from"@gem-sdk/system";import{getYoutubeVideoId as c}from"../../../video/common/helpers.js";import u from"../../../video/components/LiteYouTubeEmbed.liquid.js";import{getAttr as f}from"./common/attrs.js";import{Row as g}from"../../settings/configs/row/translate.js";import{getClass as $}from"./common/classes.js";import{getRowStyle as y}from"./common/styles.js";import{getData as k,checkHasBackgroundVideo as j,isRenderHtmlVideo as v,isRenderYoutubeVideo as b}from"./common/helpers.js";import{getResponsiveSetting as w}from"../../../hero-banner/common/helpers.js";let Row=h=>{let{styles:C,setting:E,rawChildren:S,builderProps:q}=h,{isSection:L}=E??{},{background:P}=C??{},R=L?"section":"div",T=l({background:P,uid:q?.uid,enableTranslate:!!g?.background?.id,pageContext:h.pageContext??{}}),{stateData:V}=k(h,T),{rowStyle:x,backgroundBoxStyle:z,embedVideoStyle:A,sectionStyle:N}=y({rowProps:h,type:"Liquid",translatedBackground:T}),{rowAttr:_}=f(h),{rowClass:G,backgroundBoxClass:I,backgroundBoxInnerClass:M,sectionClass:O,wrapperYoutubeClasses:B,iframeYoutubeClasses:H}=$(h),U=d({[G]:!0}),Y=()=>{if(!j(P))return;let e=w(P||{});if(v(P))return p({uid:q?.uid,muted:!0,loop:e.desktop?.loop,controls:!1,autoplay:!0,src:"",title:"Video",className:"gp-relative",style:A});if(b(P)){let o=e?.desktop?.video??"",s=c(o)||"",r=t(o),i=`&loop=false&playlist=${s}&showinfo=0&rel=0&fs=0&enablejsapi=1`;return u({uid:q?.uid,id:s,autoplay:!0,title:"Video",translatedVideoUrl:r?o:"",controls:!1,params:i,adNetwork:!1,noCookie:!0,muted:!0,lazy:e?.desktop?.lazyLoad??!0,preload:!0,style:A,wrapperClass:B,iframeClass:H})}},D=()=>{if(j(P))return e`
      ${r(i,`<script ${m('class="gps-link" delay',"src")}="{{ 'gp-row-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${m('class="gps-link" delay',"src")}="${a}/assets-v2/gp-row-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
    `},F=e`
    <gp-row gp-data='${V}' ${{..._}} class="${U}" style="${x()}">
      ${n(!!Y(),e`
          <div class="${I}" style="${z}">
            <div class="${M}">${Y()}</div>
          </div>
        `)}

      ${o({uid:q?.uid||"",customProps:S?.[0].customProps},S?.map(e=>{if(e)return s({...e,order:E?.order,layout:E?.layout,justifyContent:E?.verticalAlign})}))}

      ${D()}
    </gp-row>
  `;return e`
    ${r(!!C?.preloadBgImage,`${r(!!P?.desktop?.image?.src,`<link rel="preload" href="${P?.desktop?.image?.src}" as="image" />`)}${r(!!P?.tablet?.image?.src,`<link rel="preload" href="${P?.tablet?.image?.src}" as="image" />`)}${r(!!P?.mobile?.image?.src,`<link rel="preload" href="${P?.mobile?.image?.src}" as="image" />`)}`)}

    ${r(!!L,"{% assign locationOrigin = request.origin | append: routes.root_url | split: '/' | join: '/' %}")}

    ${n(L,e`
        <${R}
          class="${O} ${L?m("gps-lazy"):""}"
          style="${N}"
        >
          ${F}
        </${R}>
      `,e`${F}`)}
  `};export{Row as default};
