"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),Modal3d_liquid=require("../../../../../image/components/Modal3d.liquid.js"),NextImage_liquid=require("../../../../../image/components/NextImage.liquid.js"),Video_liquid=require("../../../../../image/components/Video.liquid.js"),HTML5Embed_liquid=require("../../../../../video/components/HTML5Embed.liquid.js"),_function=require("../../../../helpers/function.js"),common=require("../../common/common.js"),productFeaturedImage=require("../../common/productFeaturedImage.js"),productGallery=require("../../common/productGallery.js"),getProductImagesClassName=require("../../composables/getProductImagesClassName.js"),getProductImagesStyles=require("../../composables/getProductImagesStyles.js");const ProductGalleryGrid=({builderPropUID:e,wrapperStyle:i,children:t,enableLazyLoadImage:a,...s})=>{let{galleryItemClasses:o,galleryGridWrapperClasses:d}=getProductImagesClassName.getProductImagesClassName(s),{galleryGridStyles:r,galleryGridItemStyles:l}=getProductImagesStyles.getProductImagesStyles(s),m=productGallery.getShapeByLayout({shape:s.shape,shapeForBottom:s.shapeForBottom,shapeFor1Col:s.shapeFor1Col,shapeFor2Col:s.shapeFor2Col,shapeForFtOnly:s.shapeForFtOnly,shapeForInsideBottom:s.shapeForInsideBottom,shapeForInside:s.shapeForInside},s.position),c=(e=!1)=>{let i=["desktop","mobile","tablet"],t={desktop:"none",tablet:"none",mobile:"none"};return i.forEach(i=>{let a=core.getResponsiveValueByScreen(s?.position,i)||"",o="one-col"===a||"two-col"===a,d=e?!o:o;t[i]=d?"block":"none"}),core.makeStyleResponsive("d",t)},u=()=>c(),g=()=>c(!0),p=(e,i)=>core.template`
      ${NextImage_liquid.default({srcIsLiquidCode:!0,src:`${common.getSrcImage("media.preview_image")}`,width:"{{media.width}}",height:"{{media.height}}",alt:"{{media.alt | escape}}",baseSrc:"{{media.preview_image | image_url}}",setting:e,style:i,className:"!gp-rounded-none",customLazyload:!1,enableLazyLoadImage:a})}
      ${system.If(s?.galleryHoverEffect!=="none",`<div class="${core.cls("zoom-element !gp-max-w-none gp-w-full gp-h-full",productFeaturedImage.getZoomImageClass())}">
          ${NextImage_liquid.default({srcIsLiquidCode:!0,src:`${common.getSrcImage("media.preview_image")}`,width:"{{media.width}}",height:"{{media.height}}",baseSrc:"{{media.preview_image | image_url}}",alt:"{{media.alt | escape}}",setting:e,style:i,className:"!gp-rounded-none gp-w-full gp-h-full",customLazyload:!1,enableLazyLoadImage:a})}
          </div>`," ")}
      ${system.If(s?.galleryHoverEffect=="zoom"&&s?.galleryZoomType=="glasses",`<div class="${core.cls("zoom-lens-element",productFeaturedImage.getZoomLenClass())}" style="opacity: 0; background-image: url('{{media.preview_image | product_img_url: '1024x1024'}}')">
            </div>
          `," ")}
    `,n=()=>Modal3d_liquid.default({src:system.LiquidIf("media.sources.first.url contains '.glb'","{{ media.sources.first.url }}","{{media.sources.last.url}}"),alt:"{{media.preview_image.alt}}",poster:"{{media.preview_image.src | product_img_url: '1024x1024'}}",cameraControls:!0,arStatus:"not-presenting",style:{width:"100%",height:"100%"},aspectRatio:common.getAspectRatio(m)}),y=()=>Video_liquid.default({src:"{{mediaSourceVideo}}",alt:"{{media.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"}}),f=()=>HTML5Embed_liquid.default({src:"{{mediaSourceVideo}}",title:"{{media.alt | escape}}",autoplay:!1,controls:!0,style:{width:"100%","max-height":"100%"}}),h=()=>core.template`
      ${system.LiquidIf("media.media_type == 'video' or media.media_type == 'external_video'",`<div class="gp-absolute gp-pb-1 gp-pr-1 gp-right-0 gp-bottom-0" >
          <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
            <rect opacity="0.9" width="24" height="24" rx="3" fill="#212121"/>
            <path d="M17.6869 12.2646L17.6868 12.2646L6.78379 18.4464C6.78378 18.4464 6.78376 18.4464 6.78374 18.4464C6.52931 18.5903 6.1665 18.4179 6.1665 18.0416V5.95844C6.1665 5.58218 6.52917 5.40981 6.7836 5.55354C6.78366 5.55357 6.78373 5.55361 6.78379 5.55365L17.6868 11.7354L17.6869 11.7354C17.8819 11.846 17.8819 12.154 17.6869 12.2646Z" stroke="#F9F9F9" stroke-miterlimit="10"/>
          </svg>
        </div>`)}
      ${system.LiquidIf("media.media_type == 'model'",`<div class="gp-absolute gp-pb-1 gp-pr-1 gp-right-0 gp-bottom-0">
          <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
            <rect opacity="0.9" width="24" height="24" rx="3" fill="#212121"/>
            <path fill-rule="evenodd" clip-rule="evenodd" d="M11.7441 4.57034C11.9017 4.47655 12.098 4.47655 12.2555 4.57034L18.5889 8.33957C18.7404 8.42971 18.8332 8.59296 18.8332 8.76923V15.2308C18.8332 15.407 18.7404 15.5703 18.5889 15.6604L12.2555 19.4297C12.098 19.5234 11.9017 19.5234 11.7441 19.4297L5.41079 15.6604C5.25932 15.5703 5.1665 15.407 5.1665 15.2308V8.76923C5.1665 8.59296 5.25932 8.42971 5.41079 8.33957L11.7441 4.57034ZM6.1665 9.64865V14.9465L11.4998 18.1206V12.8227L6.1665 9.64865ZM12.4998 12.8227V18.1206L17.8332 14.9465V9.64865L12.4998 12.8227ZM17.3555 8.76923L11.9998 11.9566L6.64417 8.76923L11.9998 5.58185L17.3555 8.76923Z" fill="#F9F9F9"/>
          </svg>
        </div>`)}
      ${p({aspectRatio:common.getAspectRatio(m),layout:s?.layout,qualityType:s?.qualityType,qualityPercent:s?.qualityPercent},{width:"100%",height:"100%"})}

      <div class="gp-absolute gp-inset-0 gp-flex gp-cursor-pointer gp-items-center gp-justify-center gp-bg-black/50 gp-opacity-0 gp-transition-opacity gp-duration-100 group-hover:gp-opacity-100"
        style="${_function.getStyleOfObject(productGallery.getZoomDisplay(s?.clickOpenLightBox))}" >
        <svg
          height="100%"
          width="100%"
          xmlns="http://www.w3.org/2000/svg"
          class="gp-h-6 gp-w-6"
          viewBox="0 0 512 512"
          color="#fff"
        >
          <path
            fill="currentColor"
            stroke-linecap="round"
            stroke-linejoin="round"
            d="M62.2467 345.253C43.7072 326.714 29.1474 305.116 18.9714 281.057C8.42839 256.13 3.08301 229.671 3.08301 202.418C3.08301 175.165 8.43012 148.707 18.974 123.78C29.15 99.7213 43.7098 78.123 62.2485 59.5834C80.788 41.0439 102.386 26.4841 126.445 16.3081C151.372 5.76422 177.831 0.417969 205.084 0.417969C232.337 0.417969 258.794 5.76421 283.722 16.3064C307.78 26.4823 329.379 41.0422 347.918 59.5817C366.458 78.1212 381.017 99.7196 391.194 123.778C401.737 148.706 407.083 175.163 407.083 202.417C407.083 229.671 401.737 256.129 391.194 281.056C388.406 287.648 385.277 294.048 381.839 300.257L493.397 411.815C514.091 432.511 514.091 466.187 493.395 486.883L484.272 496.006C474.245 506.032 460.915 511.553 446.738 511.553C432.559 511.553 419.228 506.032 409.202 496.006L296.022 382.824C291.996 384.854 287.898 386.762 283.721 388.528C258.794 399.073 232.336 404.419 205.082 404.419C177.828 404.419 151.371 399.071 126.443 388.528C102.385 378.352 80.7863 363.793 62.2467 345.253ZM301.699 336.166C313.928 327.317 324.896 316.835 334.282 305.034C342.149 295.142 348.9 284.325 354.355 272.775C364.433 251.432 370.076 227.586 370.076 202.419C370.076 111.296 296.206 37.4253 205.083 37.4253C113.96 37.4253 40.0895 111.294 40.0895 202.418C40.0895 293.541 113.96 367.411 205.084 367.411C227.413 367.411 248.701 362.967 268.126 354.928C280.091 349.976 291.347 343.658 301.699 336.166ZM467.229 460.716C473.507 454.439 473.507 444.26 467.229 437.982L360.595 331.348C356.601 336.153 352.378 340.794 347.919 345.253C341.671 351.502 335.068 357.286 328.147 362.615L435.371 469.839C438.511 472.977 442.624 474.547 446.739 474.547C450.853 474.547 454.967 472.978 458.106 469.839L467.229 460.716ZM223.582 183.91H281.071C291.292 183.91 299.574 192.194 299.575 202.414C299.575 206.778 298.062 210.786 295.533 213.951C292.143 218.195 286.926 220.916 281.072 220.916H228.303H223.583V225.63V278.406C223.583 287.081 217.613 294.358 209.559 296.361C208.124 296.717 206.625 296.909 205.08 296.909C194.861 296.909 186.577 288.625 186.577 278.406V220.917H129.087C118.868 220.917 110.584 212.633 110.584 202.414C110.584 192.195 118.868 183.911 129.087 183.911H186.576V126.421C186.576 116.202 194.86 107.918 205.079 107.918C215.298 107.918 223.582 116.202 223.582 126.421V183.91Z"
          />
        </svg>
      </div>
    `,C=i=>`
    ${system.LiquidIf("media.media_type == 'video'","{% assign mediaSourceUrl = media.sources.last.url %}")}
    ${system.LiquidIf("media.media_type == 'external_video'","{% assign mediaSourceUrl = media | external_video_url %}{% assign mediaSource = media | json %}")}
    ${system.LiquidIf("media.media_type == 'image'","{% assign mediaSourceUrl = media.src %}")}
    <div
      aria-hidden
      id="{{imageID}}"
      media-type="{{media.media_type}}"
      media-poster="{{media.preview_image.src}}"
      media-source-url="{{media.sources.first.url}}"
      media-last-source-url="{{mediaSourceUrl}}"
      external-id="{{media.external_id}}"
      grid-index="{{forloop.index}}"
      data-outline="${i?"active":"deactive"}"
      class="${o(`gem-slider-item-${e}-{{product.id}} gp-gallery-image-item ${i}`)}"
      style="${_function.getStyleOfObject(l)}"
      >
      ${system.LiquidIf("media.media_type == 'external_video' or media.media_type == 'video' or media.media_type == 'model'","{% assign isMedia = true %}")}

      ${system.LiquidIf("media.media_type == 'external_video' or media.media_type == 'video'","{% assign isVideo = true %}")}

      <div class="gp-h-full gp-w-full" style="${system.LiquidIf("media == null or media.media_type == 'image'","display: block !important;")} ${system.LiquidIf("isVideo == true",_function.getStyleOfObject({...g()}))}">
        ${system.LiquidIf("media != null",h(),v())}
      </div>

      <div class="${system.LiquidIf("isMedia","gp-flex gp-justify-center gp-items-center")}"
      style="${system.LiquidIf("isMedia",_function.getStyleOfObject({...core.makeStyleResponsive("aspect",common.getAspectRatio(m))}))} ${_function.getStyleOfObject({...u()})}"
      >
        {% case media.media_type %}
          {% when 'external_video' %}
            {% assign mediaSourceVideo = media | external_video_url %}
            ${y()}
          {% when 'video' %}
            {% assign mediaSourceVideo = media.sources.last.url %}
            ${f()}
          {% when 'model' %}
            ${n()}
        {% endcase %}
      </div>
      {% assign isVideo= false %}
      {% assign isMedia= false %}
    </div>`,v=()=>core.template`
    ${NextImage_liquid.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:{aspectRatio:common.getAspectRatio(m),layout:s?.layout,qualityType:s?.qualityType,qualityPercent:s?.qualityPercent},className:"!gp-rounded-none",customLazyload:!1,enableLazyLoadImage:a})}`;return system.Liquid(`
  <div type="grid-gallery"
    class="${d}"
    style="${_function.getStyleOfObject(r)}}"
  >
    ${system.LiquidFor("media in product.media",`${system.LiquidIf("media.media_type == 'image'",system.LiquidFor("image in product.images",system.LiquidIf("image.src == media.src","{% assign imageID = image.id %}{% break %}")),"{% assign imageID = '' %}")}
      ${system.LiquidIf("media.id == product.featured_media.id ",C(s?.borderActive?.border!=="none"?"active":""),C())}`)}
    ${system.LiquidIf("product.media.size > 0",t)}
    ${system.LiquidIf("product.media.size < 1",C())}
  </div>`)};exports.default=ProductGalleryGrid;
