import{template as t,isLocalEnv as s,baseAssetURL as a}from"@gem-sdk/core";import{createClass as e,createStateOrContext as i,Liquid as o,LiquidFor as n,If as l}from"@gem-sdk/system";import{getDynamicSourceLocales as r,getSettingPreloadData as d}from"../../../helpers.js";import{getButtonClasses as p}from"./common/classes.js";import{getButtonStyles as m}from"./common/styles.js";let Button=({setting:c,advanced:u,styles:y,pageContext:g,builderProps:_,className:f=""})=>{let $=r({pageContext:g,settingId:"label",val:c?.label,uid:_?.uid,translate:c?.translate}),v=e({...!!f&&{[f]:!0},...p({styles:y,uid:_?.uid})}),b=m({styles:y,uid:_?.uid}),S=i({setting:{label:c?.label},totalVariant:"{{total_combinations}}"});return t`
    ${o("{%- assign total_combinations = 1 -%}")}
    ${n("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
    ${o(`
      {%- liquid
        assign inventory_quantity = variant.inventory_quantity | default: 0
        assign supported_payment_methods = shop.enabled_payment_types
      -%}
    `)}
    <gp-product-dynamic data-id="${_?.uid}" data-translate-label='${$}' class="${u?.cssClass}" gp-data='${JSON.stringify(S).replaceAll("'","&#039;")}
    '>
    <div class="${v}">
        {{ form | payment_button }}
    </div>
    {% style %}
      ${b}
    {% endstyle %}
    </gp-product-dynamic>
    ${l(s,`<script ${d('class="gps-link" delay',"src")}="{{ 'gp-product-dynamic-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${d('class="gps-link" delay',"src")}="${a}/assets-v2/gp-product-dynamic-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{Button as default};
