{% comment %}
Usage:

Property "app":
This is the "string" of the "review app", for example "judge_me"

Property "type":
Type of the widget. Possible values are:
- badge
- reviews

{% endcomment %}

{%- if product != blank -%}
    {%- case settings.review_app -%}

        {%- when 'none' -%}
        {%- when 'judge_me' -%}
            {%- if type == "badge" -%}
                {%- render 'judgeme_widgets', widget_type: 'judgeme_preview_badge', jm_style: '', concierge_install: false, product: product -%}
            {%- elsif type == "reviews" -%}
                {%- render 'judgeme_widgets', widget_type: 'judgeme_review_widget', concierge_install: false, product: product -%}
            {%- endif -%}

        {%- when 'loox' -%}
            {%- if type == "badge" -%}
                <div
                    class="loox-rating"
                    data-id="{{ product.id }}"
                    data-rating="{{ product.metafields.loox.avg_rating }}"
                    data-raters="{{ product.metafields.loox.num_reviews }}">
                </div>
            {%- elsif type == "reviews" -%}
                <div id="looxReviews" 
                    data-product-id="{{ product.id }}" 
                    class="loox-reviews-default">
                    {{ product.metafields.loox.reviews }}
                </div>
            {%- endif -%}
        
        {%- when 'ali_express' -%}
            {%- if type == "badge" -%}
                <div
                    product-id="{{ product.id }}"
                    class="alr-display-review-badge"
                    onclick="scroll_to_ali()">
                </div>
            {%- elsif type == "reviews" -%}
                <div
                    id="shopify-ali-review"
                    product-id="{{ product.id }}">
                    {{ shop.metafields.review_collector.review_code }}
                </div>
            {%- endif -%}

        {%- when 'ali_reviews' -%}
            {%- if type == "badge" -%}
                <div
                    product-id="{{ product.id }}"
                    class="alr-display-review-badge"
                    onclick="scroll_to_ali()">
                </div>
            {%- elsif type == "reviews" -%}
                <div
                    id="shopify-ali-review"
                    product-id="{{ product.id }}">
                    {{ shop.metafields.review_collector.review_code }}
                </div>
            {%- endif -%}

        {%- when 'ryviu' -%}
            {%- if type == "badge" -%}
                <div class="review-widget">
                    <ryviu-widget-total
                        reviews_data="{{ product.metafields.ryviu.product_reviews_info | escape }}"
                        product_id="{{ product.id }}"
                        handle="{{ product.handle }}">
                    </ryviu-widget-total>
                </div>
            {%- elsif type == "reviews" -%}
                <div
                    id="wc_review_section"
                    class="wc_review_main_content"
                    data-url="{{ shop.url }}"
                    data-handle="{{ product.handle }}"
                    data-product_id="{{ product.id }}"
                    data-limit="0">
                </div>
            {%- endif -%}

        {%- when 'vitals' -%}
            {%- if type == "badge" -%}
                <div class="bundle-aggregated_reviews"></div>
            {%- elsif type == "reviews" -%}
                <div id="bundle-product_reviews"></div>
            {%- endif -%}

    {%- endcase -%}
{%- endif -%}