import{template as t,RenderIf as i}from"@gem-sdk/core";import{getStyle as o}from"./common/styles.js";import{getClass as r}from"./common/classes.js";import{getAttr as s}from"./common/attrs.js";import d from"./ProductListGridItem.liquid.js";import{getStaticLocale as e}from"../../../helpers.js";let ProductListGridLayout=a=>{let{setting:n,builderProps:c,styles:m,productListId:u,productSrc:p}=a,{gridLayoutStyle:l}=o(a),{gridLayoutClass:f}=r(a),{productListAttr:g}=s(a),$=i=>t`
      <gp-same-height
        class="gp-contents"
        style="visibility: hidden"
        gp-data='${JSON.stringify({targetUid:c?.builderData?.childrens?.[0],slidesToShow:n?.slidesToShow,rowGap:m?.horizontalGutter})}'>
        ${i}
      </gp-same-height>
    `,h=()=>t`
      {%- assign count = 0 -%}
      {%- for product in products limit: limit -%}
      {%- if product.id != empty -%}
      {%- assign count = count | plus: 1 -%}
      {%- assign variant = product.selected_or_first_available_variant -%}
      {%- assign product_form_id = 'product-form-' | append: "${c?.uid}" | append: product.id -%}
        ${d({...a})}
      {%- endif -%}
      {% endfor %}
      {%- if count == 0 and ${u?.length} == 0 -%}
        {% if '${p}' == 'RelatedProduct' -%}
          <div>${e("ProductList","no_related_products")}</div>
        {% else %}
          <div>${e("ProductList","no_products_found")}</div>
        {%- endif -%}
      {%- endif -%}
    `;return t`
    <div
      ${g}
      style="${l}"
      class="${f}"
    >
      ${i(n?.sameHeight,$(`${h()}`))}
      ${i(!n?.sameHeight,t`${h()}`)}
    </div>
  `};export{ProductListGridLayout as default};
