"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("../../common/classes.js"),r=require("../../../../../video/components/HTML5Embed.liquid.js"),d=require("../../../../../image/components/Modal3d.liquid.js"),s=require("../../../../../image/components/NextImage.liquid.js"),u=require("../../../../../image/components/Video.liquid.js"),o=require("../../../../helpers/function.js"),l=require("../../composables/getProductImagesStyles.js"),g=require("../../composables/getProductImagesClassName.js"),m=require("../../composables/getProductImagesAttr.js"),p=require("@gem-sdk/system"),c=require("../../../../../carousel-v3/components/root/Carousel.liquid.js"),n=require("../../../../../carousel-v3/components/item/CarouselItem.liquid.js");exports.default=({builderPropUID:f,children:h,enableLazyLoadImage:y,...I})=>{let{featuredImageCarouselClasses:q,galleryItemClasses:_,featuredCarouselItemClasses:M}=g.getProductImagesClassName({...I,builderProps:{uid:f}}),{featuredImageCarouselStyle:v,featureImageStyle:b,featureImageCarouselOnlyOneImageStyle:w,featureImageOnlyOneImageStyle:$,featureImageCarouselItemStyle:L}=l.getProductImagesStyles(I),{featuredImageCarouselSettingAttrs:S}=m.getProductImagesAttr(I),x=i.getAspectRatio(I.ftShape),j=p.If("other"==I.hoverEffect,p.LiquidIf("product.media.size > 1","group-hover:gp-opacity-0")),R=()=>`
    {% case featureMedia.media_type %}
      {% when 'image' %}
        ${C()}
      {% when 'external_video' %}
        {% assign mediaSourceVideo = featureMedia | external_video_url %}
        ${z()}
      {% when 'video' %}
        {% assign mediaSourceVideo = featureMedia.sources.last.url %}
        ${P()}
      {% when 'model' %}
        ${O()}
      {% else %}
        ${T()}
    {% endcase %}
    `,O=()=>d.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:x}),z=()=>u.default({src:"{{mediaSourceVideo}}",alt:"{{featureMedia.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"},aspectRatio:x}),P=()=>{let i=p.createStyle({...a.getVideoHeight({ftLayout:I?.ftLayout,ftShape:I?.ftShape}),...e.makeStyleResponsive("objf",I?.ftLayout)}),t=p.createStyle({...a.getVideoHeight({ftLayout:I?.ftLayout,ftShape:I?.ftShape})});return r.default({src:"{{mediaSourceVideo}}",title:"{{featureMedia.alt | escape}}",autoplay:!1,controls:!0,thumbnail:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",isCheckLoaded:!0,wrapperStyles:t,poster:{altText:"{{featureMedia.alt | escape}}"},style:{width:"100%","max-height":"100%",...i},className:"gp-invisible"})},C=()=>e.template`
      ${E(e.cls("gp-w-full gp-transition-opacity",j,"{{shouldHidden}}"))}
      ${p.If(I?.hoverEffect!=="none",`<div class="${e.cls("zoom-element !gp-max-w-none",a.getZoomImageClass())}">
            ${E("image-zoom",!0)}
          </div>`," ")}
      ${p.If(I?.hoverEffect=="zoom"&&I?.zoomType=="glasses",`<div class="${e.cls("zoom-lens-element",a.getZoomLenClass())}" style="opacity: 0; background-image: url('{{ featureMedia.src | img_url: "1024x1024"}}')"></div>`," ")}
    `,E=(a,t)=>e.template`
    {% assign src = featureMedia.src %}
    ${p.If(t&&"other"==I.hoverEffect,`{% assign media_length = product.media | size %}
      {% assign other_image_index = ${I.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 %}")}
    `)}
    ${s.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:I?.ftLayout,aspectRatio:x,qualityType:I?.qualityType,qualityPercent:I?.qualityPercent},priority:I?.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:y})}`,T=()=>e.template`
    ${s.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:I?.ftLayout,aspectRatio:x,qualityType:I?.qualityType,qualityPercent:I?.qualityPercent},priority:I?.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:y})}`,k=i.getPaddingBottomByShapeSetting(I.ftShape),A=a.checkRenderFeaturedCarousel(I),N="gp-featured-image-wrapper",W=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:`${_("gp-ft-image-item !gp-min-w-full !gp-max-w-full ")}`,parentId:`ft-${f}-{{section.id}}-{{product.id}}`,style:L,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' }}")} ${p.LiquidIf("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'",`{{ '${t.FEATURE_MEDIA_CENTER_CLASSES}' }}`)}"
        style="${o.getStyleOfObject(e.makeStyleResponsive("pb",k))}"
      >
        ${R()}
      </div>
      `})}`)}
    `,s.default({src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",id:"noImageError",width:"480",height:"480",alt:"no image",priority:I?.preload,setting:{layout:I?.ftLayout,aspectRatio:x,qualityType:I?.qualityType,qualityPercent:I?.qualityPercent},style:{height:"100%"},className:"gp-w-full featured-image-only !gp-rounded-none",customLazyload:!0,enableLazyLoadImage:y}));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(I?.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="${o.getStyleOfObject(b)}"
        >
          <div
            class="gp-relative"
            style="${o.getStyleOfObject($)}"
          >
            ${h}
            <div
              type="gp-feature-image-only"
              product-id="{{product.id}}"
              product-media="{{product.media.size}}"
              class="${M(N)}"
              style="${o.getStyleOfObject(w)}"
            >
              <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="${o.getStyleOfObject(e.makeStyleResponsive("pb",k))} ${p.LiquidIf("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'","{{ 'display: flex; align-items: center; justify-content: center' }}")}"
              >
                ${R()}
              </div>
            </div>
          </div>
        </div>
      `)}
    {% endcapture %}
    ${p.LiquidIf("product.media.size > 1",`
        ${p.If(A,`
      ${c.default({builderProps:{uid:f},rootId:`ft-${f}-{{section.id}}-{{product.id}}`,conditionAppendJs:"product.media.size > 1",wrapperClass:N,rootClass:`${q}`,rootAttrs:{type:"gp-feature-image-carousel","product-id":"{{product.id}}","product-media":"{{product.media.size}}"},isHiddenArrowWhenDisabled:!0,setting:S,rootStyles:b,styles:v,style:{playSpeed:600},disableMarginAuto:!0,children:W,productBadgeLiquid:h||""})}
    `," ")}
        ${p.If(!A,"{{ featureImageOnlyOne }}"," ")}
      `,"{{ featureImageOnlyOne }}")}
  `)};
