"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),i=require("../../common/common.js"),a=require("../../common/productFeaturedImage.js"),t=require("../../../../../video/components/HTML5Embed.liquid.js"),r=require("../../../../../image/components/Modal3d.liquid.js"),d=require("../../../../../image/components/NextImage.liquid.js"),s=require("../../../../../image/components/Video.liquid.js"),u=require("../../../../helpers/function.js"),o=require("../../composables/getProductImagesStyles.js"),l=require("../../composables/getProductImagesClassName.js"),g=require("../../composables/getProductImagesAttr.js"),p=require("@gem-sdk/system"),m=require("../../../../../carousel-v3/components/root/Carousel.liquid.js"),n=require("../../../../../carousel-v3/components/item/CarouselItem.liquid.js");exports.default=({builderPropUID:c,children:f,enableLazyLoadImage:h,...y})=>{let{featuredImageCarouselClasses:I,galleryItemClasses:q,featuredCarouselItemClasses:v}=l.getProductImagesClassName({...y,builderProps:{uid:c}}),{featuredImageCarouselStyle:M,featureImageStyle:b,featureImageCarouselOnlyOneImageStyle:_,featureImageOnlyOneImageStyle:w,featureImageCarouselItemStyle:$}=o.getProductImagesStyles(y),{featuredImageCarouselSettingAttrs:L}=g.getProductImagesAttr(y),S=i.getAspectRatio(y.ftShape),x=p.If("other"==y.hoverEffect,p.LiquidIf("product.media.size > 1","group-hover:gp-opacity-0")),j=()=>`
    {% case featureMedia.media_type %}
      {% when 'image' %}
        ${R()}
      {% when 'external_video' %}
        {% assign mediaSourceVideo = featureMedia | external_video_url %}
        ${z()}
      {% when 'video' %}
        {% assign mediaSourceVideo = featureMedia.sources.last.url %}
        ${P()}
      {% when 'model' %}
        ${O()}
      {% else %}
        ${k()}
    {% endcase %}
    `,O=()=>r.default({src:p.LiquidIf("featureMedia.sources.first.url contains '.glb'","{{ featureMedia.sources.first.url }}","{{featureMedia.sources.last.url}}"),alt:"{{featureMedia.preview_image.alt}}",poster:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",cameraControls:!0,arStatus:"not-presenting",style:{width:"100%"},aspectRatio:S}),z=()=>s.default({src:"{{mediaSourceVideo}}",alt:"{{featureMedia.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"},aspectRatio:S}),P=()=>{let i=p.createStyle({...a.getVideoHeight({ftLayout:y?.ftLayout,ftShape:y?.ftShape}),...e.makeStyleResponsive("objf",y?.ftLayout)}),r=p.createStyle({...a.getVideoHeight({ftLayout:y?.ftLayout,ftShape:y?.ftShape})});return t.default({src:"{{mediaSourceVideo}}",title:"{{featureMedia.alt | escape}}",autoplay:!1,controls:!0,thumbnail:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",isCheckLoaded:!0,wrapperStyles:r,poster:{altText:"{{featureMedia.alt | escape}}"},style:{width:"100%","max-height":"100%",...i},className:"gp-invisible"})},R=()=>e.template`
      ${C(e.cls("gp-w-full gp-transition-opacity",x,"{{shouldHidden}}"))}
      ${p.If(y?.hoverEffect!=="none",`<div class="${e.cls("zoom-element !gp-max-w-none",a.getZoomImageClass())}">
            ${C("image-zoom",!0)}
          </div>`," ")}
      ${p.If(y?.hoverEffect=="zoom"&&y?.zoomType=="glasses",`<div class="${e.cls("zoom-lens-element",a.getZoomLenClass())}" style="opacity: 0; background-image: url('{{ featureMedia.src | img_url: "1024x1024"}}')"></div>`," ")}
    `,C=(a,t)=>e.template`
    {% assign src = featureMedia.src %}
    ${p.If(t&&"other"==y.hoverEffect,`{% assign media_length = product.media | size %}
      {% assign other_image_index = ${y.otherImage} | plus: 0 %}
      {% if other_image_index >= media_length %}
        {% assign other_image_index = media_length | minus: 1 %}
      {% endif %}
      {% assign otherImage = product.media[other_image_index] %}
      ${p.LiquidIf("otherImage.media_type != 'image'","{% assign src = otherImage.preview_image.src %}","{% assign src = otherImage.src %}")}
    `)}
    ${d.default({srcIsLiquidCode:!0,src:p.LiquidIf("src != null",i.getSrcImage("src"),"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif"),id:p.LiquidIf("featureMedia != null","{{featureMedia.id}}"),width:"{{featureMedia.width}}",height:"{{featureMedia.height}}",alt:"{{featureMedia.alt | escape}}",srcset:`${i.getSrcImage("src")}`,baseSrc:"{{src | image_url}}",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:y?.ftLayout,aspectRatio:S,qualityType:y?.qualityType,qualityPercent:y?.qualityPercent},priority:y?.preload,className:`gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none ${a??""}`,enableLazyLoadImage:h})}`,k=()=>e.template`
    ${d.default({srcIsLiquidCode:!0,src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",alt:"No Image",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:y?.ftLayout,aspectRatio:S,qualityType:y?.qualityType,qualityPercent:y?.qualityPercent},priority:y?.preload,className:"gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none",enableLazyLoadImage:h})}`,T=i.getPaddingBottomByShapeSetting(y.ftShape),N=a.checkRenderFeaturedCarousel(y),W="gp-featured-image-wrapper",A=p.LiquidIf("product.media.size > 0",`{% assign largestRatio = 0 %}
      ${p.LiquidFor("featureMedia in product.media",`
          ${p.LiquidIf("featureMedia.media_type == 'video' and featureMedia.preview_image",`{% assign height = featureMedia.preview_image.height | times: 1.0 %}
            {% assign width = featureMedia.preview_image.width | times: 1.0 %}`,`{% assign height = featureMedia.height | times: 1.0 %}
            {% assign width = featureMedia.width | times: 1.0 %}`)}
          {% assign ratio = height | divided_by: width %}
          ${p.LiquidIf("ratio > largestRatio","{% assign largestRatio = ratio %}")}
        `)}
      ${p.LiquidFor("featureMedia in product.media",`${p.LiquidIf("featureMedia.media_type == 'image'",`${p.LiquidFor("image in product.images",p.LiquidIf("image.src == featureMedia.src","{% assign imageID = image.id %}{% break %}"))}`,"{% assign imageID = '' %}")}
        
    ${p.Liquid(`{% assign productImageWidth = 0 %}
    {% case featureMedia.media_type %}
      {% when 'image' %}
        {% assign productImageWidth = featureMedia.width %}
      {% else %}
        {% assign productImageWidth = featureMedia.preview_image.width %}
    {% endcase %}`)}
    ${n.default({id:"{{section.id}}-{{imageID}}",contentType:"productImage",className:`${q("gp-ft-image-item !gp-min-w-full !gp-max-w-full ")}`,parentId:`ft-${c}-{{section.id}}-{{product.id}}`,style:$,customStyle:{width:"{{productImageWidth}}px"},children:`
      <div
        class="gp-w-full gp-relative ${p.LiquidIf("featureMedia == null or featureMedia.media_type == 'image'","{{ 'gp-h-0' }}","{{ 'gp-h-full !gp-pb-0' }}")}"
        style="${u.getStyleOfObject(e.makeStyleResponsive("pb",T))} ${p.LiquidIf("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'","{{ 'display: flex; align-items: center; justify-content: center' }}")}"
      >
        ${j()}
      </div>
      `})}`)}
    `,d.default({src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",id:"noImageError",width:"480",height:"480",alt:"no image",priority:y?.preload,setting:{layout:y?.ftLayout,aspectRatio:S,qualityType:y?.qualityType,qualityPercent:y?.qualityPercent},style:{height:"100%"},className:"gp-w-full featured-image-only !gp-rounded-none",customLazyload:!0,enableLazyLoadImage:h}));return p.Liquid(`
    {% capture featureImageOnlyOne %}
      ${p.Liquid(`
        {% assign featureMedia = variant.featured_media %}
        {% unless featureMedia %}
        {% assign featureMedia = product.featured_media %}
        {% endunless %}
        ${p.LiquidIf("product.media.size > 1",(()=>{switch(y?.preDisplay){case"1st-images":return`
          {% assign featureMedia = product.media.first %}
        `;case"1st-3d-mode":return p.LiquidFor("media in product.media",p.LiquidIf("media.media_type == 'model'","{% assign featureMedia = media %}{% break %}"));case"1st-video":return p.LiquidFor("media in product.media",p.LiquidIf("media.media_type == 'video' or media.media_type == 'external_video'","{% assign featureMedia = media %}{% break %}"));default:return`
          {% assign featureMedia = variant.featured_media %}
          {% unless featureMedia %}
          {% assign featureMedia = product.featured_media %}
          {% endunless %}
        `}})())}
        {% assign largestRatio = 0 %}
        {% assign height = featureMedia.height | times: 1.0 %}
        {% assign width = featureMedia.width | times: 1.0 %}
        {% assign ratio = height | divided_by: width %}
        ${p.LiquidIf("ratio > largestRatio","{% assign largestRatio = ratio %}")}
        {% assign productImageWidth = 0 %}
        {% case featureMedia.media_type %}
          {% when 'image' %}
            {% assign productImageWidth = featureMedia.width %}
          {% else %}
            {% assign productImageWidth = featureMedia.preview_image.width %}
        {% endcase %}
        ${p.LiquidIf("featureMedia == null","{% assign productImageWidth = 1600 %}")}
        <div
          class='gp-feature-image-carousel gp-feature-image-only'
          style="${u.getStyleOfObject(b)}"
        >
          <div
            class="gp-relative"
            style="${u.getStyleOfObject(w)}"
          >
            ${f}
            <div
              type="gp-feature-image-only"
              product-id="{{product.id}}"
              product-media="{{product.media.size}}"
              class="${v(W)}"
              style="${u.getStyleOfObject(_)}"
            >
              <div
                class="gp-w-full gp-relative ${p.LiquidIf("featureMedia == null or featureMedia.media_type == 'image'","{{ 'gp-h-0' }}","{{ 'gp-h-full !gp-pb-0' }}")}"
                style="${u.getStyleOfObject(e.makeStyleResponsive("pb",T))} ${p.LiquidIf("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'","{{ 'display: flex; align-items: center; justify-content: center' }}")}"
              >
                ${j()}
              </div>
            </div>
          </div>
        </div>
      `)}
    {% endcapture %}
    ${p.LiquidIf("product.media.size > 1",`
        ${p.If(N,`
      ${m.default({builderProps:{uid:c},rootId:`ft-${c}-{{section.id}}-{{product.id}}`,conditionAppendJs:"product.media.size > 1",wrapperClass:W,rootClass:`${I}`,rootAttrs:{type:"gp-feature-image-carousel","product-id":"{{product.id}}","product-media":"{{product.media.size}}"},isHiddenArrowWhenDisabled:!0,setting:L,rootStyles:b,styles:M,style:{playSpeed:600},disableMarginAuto:!0,children:A,productBadgeLiquid:f||""})}
    `," ")}
        ${p.If(!N,"{{ featureImageOnlyOne }}"," ")}
      `,"{{ featureImageOnlyOne }}")}
  `)};
