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