"hide"/"show"/Make "last" unavailable_products /out of stock in Predictive Search of Avenue theme v3

Hi, I want the predictive search to hide/show or push down/make “last” products that are out of stock (unavailable_products). This is for Avenue theme v. 3.0.3

The Query parameters are here - https://shopify.dev/api/ajax/reference/predictive-search. Please see options of show / hide / last of unavailable_products

The predictive-search.liquid file is below -


  

    {%- assign search_results = 0 -%}
        
    {% if predictive_search.performed %}
    {% assign search_terms = predictive_search.terms %}
    
    {% if predictive_search.resources.products.size > 0 %}
      {%- assign search_results = search_results | plus: 1 -%}
      {%- for product in predictive_search.resources.products -%}
      - {% if product.featured_media != blank %}
          
              {%- liquid
                assign img_src=product.featured_media
                capture id
                  echo img_src.id
                  echo section.id
                endcapture
                capture alt
                  if img_src.alt != blank
                    echo img_src.alt
                  else
                    echo product.title
                  endif
                endcapture
                render 'image.load', img_src: img_src, size: 120, id: id, alt: alt, lazyignore: true, screen: 'lazyloaded '
              -%}
          
            {% endif %}
          
              #### {{ product.title }}
              {% if settings.vendor_enable %}

  {{ product.vendor }}

  {% endif %}
            
                {%- liquid
                  if settings.reviews_enable
                     render 'product.rating', product: product
                  endif
                -%}
              
                  {%- liquid
                    if product.price_min > 0
                      if product.price_varies
                        echo 'products.product.from' | t
                      endif
                      echo '###### '            
                      if settings.currency_enable
                        echo product.price | money_with_currency
                      else
                        echo product.price | money
                      endif            
                      if product.compare_at_price > product.price
                        echo ' | <del>'              
                        if settings.currency_enable
                          echo product.compare_at_price | money_with_currency
                        else
                          echo product.compare_at_price | money
                        endif              
                        echo '</del>'
                      endif
                      render 'product.unitPrice', variant: product.selected_or_first_available_variant, variant_free: false, variant_slash: 'true'
                      echo ''
                    else
                      if product.price_varies
                        echo '###### '
                        echo 'products.product.free' | t
                        echo ' - '              
                        if settings.currency_enable
                          echo product.price_max | money_with_currency
                        else
                          echo product.price_max | money
                        endif              
                        assign variant_free = true
                        render 'product.unitPrice', variant: product.selected_or_first_available_variant, variant_free: false, variant_slash: 'true'
                        echo ''
                      else
                        echo '###### '
                        if settings.currency_enable
                          echo product.price | money_with_currency
                        else
                          echo product.price | money
                        endif
                        echo '###### '
                        echo 'products.product.free' | t
                        echo ''
                      endif
                    endif
                  -%}
              
            
          
        
      

      {%- endfor -%}      
    {% endif %}

    {% if predictive_search.resources.collections.size > 0 %}
      {%- assign search_results = search_results | plus: 1 -%}
      - ###### {{ 'general.search.collections' | t }}
      

      {%- for collection in predictive_search.resources.collections -%}
      - {%- liquid
              assign img_src=blank
              if collection.image == blank
                assign img_src=collection.products.first.featured_media.preview_image
              else
                assign img_src=collection.image
              endif
            -%}
            {% if img_src != blank %}
          

              {%- liquid
                capture id
                  echo img_src.id
                  echo section.id
                endcapture
                capture alt
                  if img_src.alt != blank
                    echo img_src.alt
                  else
                    echo product.title
                  endif
                endcapture
                render 'image.load', img_src: img_src, size: 260, id: id, alt: alt, lazyignore: true, screen: 'lazyloaded '
              -%}
          

            {% endif %}
            ##### {{ collection.title }}
        
      

      {%- endfor -%}
    {% endif %}

    {% if predictive_search.resources.articles.size > 0 %}
      {%- assign search_results = search_results | plus: 1 -%}
      - ###### {{ 'general.search.articles' | t }}
      

      {%- for article in predictive_search.resources.articles -%}
      - {% if article.image != blank %}
          
              {%- liquid
                assign img_src=article.image
                capture id
                  echo img_src.id
                  echo section.id
                endcapture
                capture alt
                  if img_src.alt != blank
                    echo img_src.alt
                  else
                    echo product.title
                  endif
                endcapture
                render 'image.load', img_src: img_src, size: 120, id: id, alt: alt, lazyignore: true, screen: 'lazyloaded '
              -%}
          
            {% endif %}
          
              #### {{ article.title }} 
          
        
      

      {%- endfor -%}
    {% endif %}

    {% if predictive_search.resources.pages.size > 0 %}
      {%- assign search_results = search_results | plus: 1 -%}
      - ###### {{ 'general.search.pages' | t }}
      

      {% for page in predictive_search.resources.pages %}
      - #### {{ page.title }} 
          
        
        

  <small>{{ page.content | strip_html | truncatewords: 40 | highlight: predictive_search.terms }}</small>

      

      {% endfor %}
    {% endif %} 
    
    {% else %}
    {% assign search_terms = search.terms %}
    
    {%- liquid
      assign search_results = ''
      for line_item in search.results
        capture search_results
          unless search_results == blank
            echo search_results
            echo '|'
          endunless
          echo line_item.object_type
        endcapture
      endfor
      assign search_results = search_results | split: '|' | uniq
    -%}

    {% for categories in search_results %}
    {% unless forloop.index0 < 1 and forloop.last %}
    - ###### {{ categories | capitalize | append: 's' }}
    

    {% endunless %}
    {% for line_item in search.results %}
      {% if line_item.object_type == categories %}
      {%- assign search_results = search_results | plus: 1 -%}
        {% if line_item.object_type == 'product' %}
    	{%- assign product = line_item -%}
        - {% if product.featured_media != blank %}
            
                {%- liquid
                  assign img_src=product.featured_media
                  capture id
                    echo img_src.id
                    echo section.id
                  endcapture
                  capture alt
                    if img_src.alt != blank
                      echo img_src.alt
                    else
                      echo product.title
                    endif
                  endcapture
                  render 'image.load', img_src: img_src, size: 120, id: id, alt: alt, lazyignore: true, screen: 'lazyloaded '
                -%}
            
              {% endif %}
            
                #### {{ product.title }}
                {% if settings.vendor_enable %}

  {{ product.vendor }}

  {% endif %}
              
                  {%- liquid
                    if settings.reviews_enable
                      render 'product.rating', product: product
                    endif
                  -%}
                
                    {%- liquid
                      if product.price_min > 0
                        if product.price_varies
                          echo 'products.product.from' | t
                        endif
                        echo '###### '            
                        if settings.currency_enable
                          echo product.price | money_with_currency
                        else
                          echo product.price | money
                        endif            
                        if product.compare_at_price > product.price
                          echo ' | <del>'              
                          if settings.currency_enable
                            echo product.compare_at_price | money_with_currency
                          else
                            echo product.compare_at_price | money
                          endif              
                          echo '</del>'
                        endif
                        render 'product.unitPrice', variant: product.selected_or_first_available_variant, variant_free: false, variant_slash: 'true'
                        echo ''
                      else
                        if product.price_varies
                          echo '###### '
                          echo 'products.product.free' | t
                          echo ' - '              
                          if settings.currency_enable
                            echo product.price_max | money_with_currency
                          else
                            echo product.price_max | money
                          endif              
                          assign variant_free = true
                          render 'product.unitPrice', variant: product.selected_or_first_available_variant, variant_free: false, variant_slash: 'true'
                          echo ''
                        else
                          echo '###### '
                          if settings.currency_enable
                            echo product.price | money_with_currency
                          else
                            echo product.price | money
                          endif
                          echo '###### '
                          echo 'products.product.free' | t
                          echo ''
                        endif
                      endif
                    -%}
                
              
            
          
        

        {% elsif line_item.object_type == 'article' %}
    	{%- assign article = line_item -%}
        - {% if article.image != blank %}
            
                {%- liquid
                  assign img_src=article.image
                  capture id
                    echo img_src.id
                    echo section.id
                  endcapture
                  capture alt
                    if img_src.alt != blank
                      echo img_src.alt
                    else
                      echo product.title
                    endif
                  endcapture
                  render 'image.load', img_src: img_src, size: 120, id: id, alt: alt, lazyignore: true, screen: 'lazyloaded '
                -%}
            
              {% endif %}
            
                #### {{ article.title }} 
            
          
        

        {% elsif line_item.object_type == 'page' %}
    	{%- assign page = line_item -%}
        - #### {{ page.title }} 
            
          
          

  <small>{{ page.content | strip_html | truncatewords: 40 | highlight: predictive_search.terms }}</small>

        

        {% endif %}
      {% endif %}
    {% endfor %}
    {% endfor %}
    
    {% endif %}

    -