import{template as o,RenderIf as s,isLocalEnv as t,baseAssetURL as e}from"@gem-sdk/core";import{getSettingPreloadData as i}from"../../../helpers.js";import{createClass as l,createStyle as n,createStateOrContext as r,LiquidIf as c}from"@gem-sdk/system";import{getClassContainer as a,getClassToolbarWrapper as p,getClassToolbarSortWrapper as d,getClassSelect as m,getClassToolbarWrapperQuantity as u}from"./common/classes.js";import{getStyleCollectionToolbar as f,getStyleToolbarWrapper as $,getStyleSelect as y,getStyleToolbarWrapperQuantity as g}from"./common/styles.js";import{getSortingTextDisplayVal as v,getQuantityTextDisplayVal as b}from"./common/helpers.js";let _=({setting:_,builderProps:S,pageContext:j})=>{let{displayQuantity:k}=_??{},q=l({...a()}),E=l({...p()}),T=l({...d()}),h=l({...m(_)}),C=l({...u(_)}),x=l({"gp-flex-1":!0}),A=n({...f(_)}),G=n({...$(_)}),N=n({...y(_)}),O=n({...g(_)}),I=v({setting:_,builderProps:S,pageContext:j},"liquid"),J=b({setting:_,builderProps:S,pageContext:j},"liquid"),M=r({uid:S?.uid});return o`
    <gp-collection-toolbar
      class="${q}"
      style="${A}"
      id="${S?.uid}"
      gp-data='${JSON.stringify(M)}'
    >
      <div class="${E}" style="${G}" >
        <div class="${T}">
          <select id="sorting" class="${h}" style="${N}" >

            {% if collection.sort_by == "" %}
              {% assign sort_by = collection.default_sort_by %}
            {% else %}
              {% assign sort_by = collection.sort_by %}
            {% endif %}

            <option key=${I} value="">
              ${I}
            </option>
            {% for option in collection.sort_options %}
              {% if sort_by == option.value %}
                <option value="{{ option.value }}" selected>{{ option.name }}</option>
              {% else %}
                <option value="{{ option.value }}">{{ option.name }}</option>
              {% endif %}
            {% endfor %}
          </select>
        </div>
        <div
          class="${C}"
          style="${O}"
        >
          {% assign quantityTemplate = ${J} %}
          {% assign productsCount = collection.products_count %}
          ${c(k?.toString()??"",o`<span class="gf_product-quantity">{{ quantityTemplate | replace: '%number%', productsCount }}</span>`,"")}
        </div>
        <div class="${x}">&nbsp;</div>
      </div>
    </gp-collection-toolbar>
    ${s(t,`<script ${i('class="gps-link" delay',"src")}="{{ 'gp-collection-toolbar-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${i('class="gps-link" delay',"src")}="${e}/assets-v2/gp-collection-toolbar-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{_ as default};
