import{makeStyleResponsive as t,template as e}from"@gem-sdk/core";import{getLiquidForAppBlock as a}from"../common/helpers.js";let s=({setting:s,advanced:o})=>{let{widgetType:i,showAllReviews:r,showRatingWidgetAllReviews:d,version:l,appBlockId:g,align:c}=s??{},n=t=>{switch(i){case"reviews_widget":return{id:"looxReviews","data-product-id":t,...r?{"data-loox-aggregate":"true"}:{}};case"rating_widget":return{class:"loox-rating","data-id":t,"data-fetch":"","data-rating":"{{ product.metafields.loox.avg_rating }}","data-raters":"{{ product.metafields.loox.num_reviews }}"};case"carousel_widget":return{id:"looxCarousel","data-show-more":"true"}}};return"v2"===l?a(g,c,o?.cssClass):e`
    <script defer strategy="lazyOnload" src="${"//loox.io/widget/loox.js?shop={{ request.host }}"}"></script>
    <div
      class="${o?.cssClass}"
      style="${{...t("ta",s?.align)}}"
    >
      {% if '${i}' == "rating_widget"  %}
        {% if '${d}' == 'true' %}
          {% if shop.metafields.loox["global_stats"]  %}
            {% assign looxstats = shop.metafields.loox["global_stats"] | split: ',' %}
            <a href="#looxReviews">
              <div class="loox-rating" data-rating="{{ looxstats[0] }}" data-raters="{{ looxstats[1] }}"></div>
            </a>
          {% endif %}
        {% else %}
          <a href="#looxReviews">
            <div ${{...n("{{ product.id }}")}}></div>
          </a>
        {% endif %}
      {% else %}
        <div ${{...n("{{ product.id }}")}}></div>
      {% endif %}
    </div>
  `};export{s as default};
