import{dataStringify as s,isLocalEnv as t,baseAssetURL as e,template as i}from"@gem-sdk/core";import{createStyle as o,createClass as r,createAttr as a,createStateOrContext as l,Liquid as d,If as n}from"@gem-sdk/system";import{getButtonAttributes as m}from"../common/attrs.js";import{getButtonStyles as p,getTypoStyles as c,getButtonIconStyles as u,getButtonWrapperStyles as $}from"../common/styles.js";import{getButtonClasses as g,getButtonIconClasses as f,getButtonLabelClasses as b,getButtonWrapperClasses as L,getButtonContentWrapperClasses as y,getButtonContainerClasses as j}from"../common/classes.js";import{getSettingPreloadData as v}from"../../helpers.js";import q from"./ButtonIcon.liquid.js";import k from"./ButtonLabel.liquid.js";import S from"./ButtonLoadingIndicator.liquid.js";import{getData as h,getInsertLinkData as E}from"../common/helpers.js";let x=x=>{let{advanced:B,className:C,nodePrice:I,customAttrs:T,styles:A={},setting:G={},builderProps:H,wrapClassName:M="",translateSetting:_,isForceValue:N,pageContext:O}=x,{iconSvg:P,btnLink:R,htmlType:V,disabled:w,enableBtnLink:z,shouldClearSpace:D,disabledLoading:F=!0}=G,{enableTextStyle:J=!0}=A,{customCss:K,wrapStyle:Q,restStyle:U,dataState:W,dataIdAttr:X,isShowIcon:Y,isScrollToElement:Z,getArialLabel:ss,getLabelToDisplay:st,checkIsShowLabel:se,checkIsEditableLabel:si}=h(x),{HTMLTag:so,urlData:sr,shouldRenderLink:sa}=E({enableBtnLink:z,htmlType:V,setting:R,defaultTag:"button",isLiquid:!0}),sl=o({...p(A,G?.enableHoverEffect)}),sd=o({...c(A)}),sn=o({...c(A),...u(A,G)}),sm=o({...$(U,A)}),sp=r({...g({styles:A,className:C,shouldRenderLink:sa,uid:H?.uid,advanced:B})}),sc=r({...f(st({isLiquid:!0,translateSetting:_,isForceValue:N,pageContext:O??{}}),D,J)}),su=r({...b(A,si({isLiquid:!0}))}),s$=r({...L(M,C,B?.cssClass)}),sg=r({...y(G)}),sf=r({...j()}),sb=a({...m({disabled:w,dataState:W,dataId:X,arialLabel:ss({isLiquid:!0})})}),sL=l({btnLink:G?.btnLink});return d(i`
    <gp-button
      gp-data='${s(sL)}'
      style="${{...Q}}"
      class="${sf}"
    >
      <div style="${sm}" class="${s$}">
        <style>${K}</style>
        ${n(Z,`<a
            class="gp-trigger-button-link gp-hidden"
            href=${sr.href}
            target=${sr.target}
          ></a>`)}
        <${so}
          ${{...sb}}
          ${{...T}}
          ${{...sr}}
          style="${sl}"
          class="${sp}"
        >
        ${n(!F,S(),"")}
        <div class="${sg}">
          ${n(Y,q({iconSvg:P??"",styles:sn,classes:sc}))}
          ${n(J&&se({isLiquid:!0,translateSetting:_,isForceValue:N,pageContext:O??{}}),k({label:st({isLiquid:!0,translateSetting:_,isForceValue:N,pageContext:O??{}}),styles:sd,classes:su}))}
        </div>
        ${n(!!I,I?.toString()??"","")}
        </${so}>
      </div>
      ${n(t,`<script ${v('class="gps-link" delay',"src")}="{{ 'gp-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${v('class="gps-link" delay',"src")}="${e}/assets-v2/gp-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
    </gp-button>
  `)};export{x as default};
