"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),common=require("./common/common.js"),FeatureImageWithGallery_liquid=require("./components/feature-gallery/FeatureImageWithGallery.liquid.js"),GalleryCarousel_liquid=require("./components/gallery-carousel/GalleryCarousel.liquid.js"),GalleryGrid_liquid=require("./components/gallery-grid/GalleryGrid.liquid.js"),helpers=require("../../../helpers.js"),productGallery=require("./common/productGallery.js"),getProductImagesClassName=require("./composables/getProductImagesClassName.js"),getProductImagesStyles=require("./composables/getProductImagesStyles.js"),system=require("@gem-sdk/system"),getBorderActiveCss=require("./common/getBorderActiveCss.js"),_function=require("../../helpers/function.js");const ProductImages=e=>{let t=common.setDefaultWhenUndefineSetting(e),{setting:s,styles:r,builderProps:i,style:a}=t,{rawChildren:o,pageContext:l}=e,{enableLazyLoadImage:d}=l??{},u={...s,...r},c=`
    {
      "id":${JSON.stringify(i?.uid)},
      "pageContext": ${JSON.stringify(helpers.filterPageContext(l))},
      "setting":${JSON.stringify(s)},
      "styles":${JSON.stringify(r)},
      "productUrl":{{product.url | json | escape}},
      "product":{{product | json | escape}},
      "collectionUrl": {{ collection.url | json | escape }},
      "collection": {{ collection | json | escape}}
    }
  `,p=system.createAttr({"section-id":"{{section.id}}","data-id":`${i?.uid}`}),{isOnlyFeatureAllDevices:m,isRenderGalleryGrid:n}=common.getConditionRenderGalleryImages(u?.position,s?.type),g=n?{}:system.createAttr({"data-only-image":system.LiquidIf("product.media.size > 1","false","true")}),{wrapperClasses:y,productImagesGalleryClasses:f}=getProductImagesClassName.getProductImagesClassName(e),I=system.createClass({"gp-grid gp-w-full !gp-m-0 gp-relative":!0}),h=system.createClass({"gp-w-full !gp-m-0 gp-relative":!0}),{wrapContainerStyle:$,wrapContainerStyleOnlyOneImage:S,galleryImageStyle:q}=getProductImagesStyles.getProductImagesStyles(u),v=productGallery.getShapeByLayout({shape:u.shape,shapeForBottom:u.shapeForBottom,shapeFor1Col:u.shapeFor1Col,shapeFor2Col:u.shapeFor2Col,shapeForFtOnly:u.shapeForFtOnly,shapeForInsideBottom:u.shapeForInsideBottom??productGallery.sizeSettingDefaultForNewLayout,shapeForInside:u.shapeForInside??productGallery.sizeSettingDefaultForNewLayout},u.position),C=common.getStyleInsideLayout(u.position,v,u?.spacing),G=()=>core.template`
      ${core.WrapRenderChildren({uid:i?.uid||"",customProps:o?.[0].customProps},o?.map(e=>{if(e)return core.template`${core.RenderChildren({...e,isInsideProductImage:!0,imageData:{imageShape:r?.ftShape,imageAlign:r?.align,imageLayout:r?.position},dotData:{dotSize:s?.ftDotSize,dotGapToCarousel:s?.ftDotGapToCarousel,dotStyle:s?.ftDotStyle}})}`}))}
    `,P=()=>core.template`
      <div
        class="${f}"
        style="${_function.getStyleOfObject(q)}"
        ${{...g}}
      >
        ${system.LiquidIf("product.media.size > 1",GalleryCarousel_liquid.default({builderPropUID:`gp-gallery-${i?.uid}`,...u,enableLazyLoadImage:d}))}
        ${system.If(n,GalleryGrid_liquid.default({builderPropUID:i?.uid,wrapperStyle:{...C},children:G(),...u,enableLazyLoadImage:d}))}
      </div>
    `,j=()=>s?.borderActive?.border!=="none";return core.template`
  ${system.If(j(),system.LiquidIf("product.media.size > 1",`<style>${getBorderActiveCss.getBorderActiveCss({settings:u,uid:i?.uid,type:"Liquid"})}</style>`),"")}
  ${system.Liquid(`
    {% assign featured_image = product.featured_image %}
    ${system.LiquidIf("variant != null and variant.featured_image != null","{% assign featured_image = variant.featured_image %}")}
  `)}
    <gp-product-images-v3
      gp-data='${c}'
      ${{...p}}
      style="${{...a}}"
      class="${y}"
    >
      <div
        class="${system.LiquidIf("product.media.size > 1",`${I}`,`${h}`)}"
        style="${system.LiquidIf("product.media.size > 1",_function.getStyleOfObject($),_function.getStyleOfObject(S))}"
      >
        ${FeatureImageWithGallery_liquid.default({builderPropUID:`gp-carousel-${i?.uid}`,...u,children:G(),enableLazyLoadImage:d})}
        ${system.If(!m,P())}
      </div>
    </gp-product-images-v3>
    ${system.If(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-images-v3-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-product-images-v3-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};exports.default=ProductImages;
