"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../common/helpers.js"),system=require("@gem-sdk/system"),attrs=require("../common/attrs.js"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),HTML5Embed_liquid=require("./HTML5Embed.liquid.js"),LiteVimeoEmbed_liquid=require("./LiteVimeoEmbed.liquid.js"),LiteYouTubeEmbed_liquid=require("./LiteYouTubeEmbed.liquid.js"),NextImage_liquid=require("../../image/components/NextImage.liquid.js"),helpers$1=require("../../image/common/helpers.js");const Video=({className:e,setting:t,style:s,builderAttrs:l,builderProps:i,advanced:a,pageContext:r})=>{let d=helpers.getSettingTranslatedVideoAndThumbnail({setting:t,uid:i?.uid,pageContext:r??{}}),{youtubeUrl:o="",vimeoUrl:u="",html5Url:m,autoplay:c=!1,loopVideo:y=!1,controls:n=!1,mute:p,poster:g,startTime:b,endTime:q,lazy:h,type:V}=d??{},{youtubeUrlTranslated:f,vimeoUrlTranslated:I}=d,S=helpers$1.getImageSrc(g),{cssClass:k}=a??{},L=helpers.getAspectRatioSettings(d?.ratioOptions,d?.aspectRatio),T=system.createAttr({...attrs.getAttr({uid:i?.uid||""})}),_=system.createStyle({...styles.getStyle(d,s)}),j=system.createStyle({...styles.getYoutubeStyle(L)}),v=system.createStyle({...styles.getVimeoStyle(L)}),x=system.createStyle({...styles.getHtml5Style(L)}),$=system.createStyle({...styles.getFallBackImageStyle(t?.aspectRatio)}),E=system.createClass({...classes.getFallbackImageClasses()}),N=system.createClass({...classes.getClasses({className:e,builderProps:i,isInstantLP:!1,advancedCssClass:k})}),C=()=>{switch(V){case"youtube":{let e=helpers.getYoutubeVideoId(o),t=core.hasTranslatedLiquid(f);if((!helpers.youtubeVideoRegex.test(o)||!e)&&!t)return NextImage_liquid.default({src:helpers.fallbackImageVideoUrl,alt:"Fallback video",className:E,style:$});let s="";return y&&(s+=`&loop=1&playlist=${e}`),b&&(s+=`&start=${helpers.parseTimeVideo(b)}`),q&&(s+=`&end=${helpers.parseTimeVideo(q)}`),LiteYouTubeEmbed_liquid.default({uid:i?.uid,id:e??"",translatedVideoUrl:t?f:"",autoplay:c,title:"Video",controls:n,params:s,adNetwork:!1,noCookie:!0,muted:!p,thumbnail:S,lazy:h??!0,preload:g?.preload,poster:g,style:j})}case"vimeo":{let e=helpers.getVimeoVideoId(u),t=core.hasTranslatedLiquid(I);if((!helpers.vimeoVideoRegex.test(u)||!e)&&!t)return NextImage_liquid.default({src:helpers.fallbackImageVideoUrl,alt:"Fallback video",className:E,style:$});return LiteVimeoEmbed_liquid.default({muted:!p,loop:y,controls:n,thumbnail:S,thumbnailLink:g?.src,autoplay:c,lazy:h??!0,id:e??"",translatedVideoUrl:t?I:"",title:"Video",aspectRatio:L,poster:g,vimeoStyleIframe:v})}case"html5":if(!m)return NextImage_liquid.default({src:helpers.fallbackImageVideoUrl,alt:"Fallback video",className:E,style:$});return HTML5Embed_liquid.default({uid:i?.uid,muted:!p,loop:y,controls:n,autoplay:c,src:m,thumbnail:S,title:"Video",poster:g,lazy:h??!0,isVideoComponent:!0,style:x})}};return core.template`
    <div
      ${{...l}} ${{...T}} class="${N}" style="${_}">
      ${C()}
    </div>
  `};exports.default=Video;
