"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./common/styles.js"),t=require("./common/helpers.js"),s=require("@gem-sdk/core"),r=require("@gem-sdk/system"),a=require("../../../helpers.js"),i=require("./helpers/getButtonDynamicSourceLocales.js"),o=require("./SoldOutButton.liquid.js"),n=require("./AddToCartButton.liquid.js");exports.default=l=>{let{setting:u,builderProps:c,style:p,styles:d,pageContext:g}=l,{wrapStyle:S,restStyle:m}=e.getSplitStyle(p),{outOfStockButtonLabel:y,unavailableButtonLabel:b,variantSelectionRequiredMessage:f,successMessage:q,errorMessage:v}=i.getButtonDynamicSourceLocales({setting:u,pageContext:g,builderProps:c}),{urlData:$}=a.getInsertLinkData("",u?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:u?.customURL),_=r.createStateOrContext(t.getGPProductButtonState({styles:d,setting:u})),h=t.escapeSingleQuoteForAttr(q??u?.successMessage),j=t.escapeSingleQuoteForAttr(v??u?.errorMessage),A=t.escapeSingleQuoteForAttr(f??u?.variantSelectionRequiredMessage);return s.template`
    ${r.Liquid("{%- assign total_combinations = 1 -%}")}
    ${r.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
    {%- liquid
      assign inventory_quantity = variant.inventory_quantity | default: 0
      assign is_in_stock = variant.available
    -%}
    <gp-product-button
      style="${S}"
      gp-data-wrapper="true"
      gp-href="${$.href}"
      class="gp-product-button"
      gp-label-out-of-stock="${y}"
      gp-label-unavailable="${b}"
      gp-data='${JSON.stringify(_)}'
      data-variant-selection-required-message="${A}"
      gp-enable-third-partycart="{{shop.metafields.GEMPAGES.enableThirdPartyCart}}"
      gp-error-message="${j}"
      gp-success-message="${h}"
    >
      ${n.AddToCartButton({...l,style:m})}
      ${o.SoldOutButton({...l,style:m,label:y})}
    </gp-product-button>
    ${r.If(s.isLocalEnv,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="${s.baseAssetURL}/assets-v2/gp-product-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
