import{composeClasses as s,template as t,RenderIf as i,isLocalEnv as e,baseAssetURL as o}from"@gem-sdk/core";import{getDynamicSourceLocales as l,createSettingId as c,getSettingPreloadData as d}from"../../helpers.js";import{getInlineCss as r,getLiquidInitData as a,getLiquidTextContent as $,getTextDisplayData as p}from"../common/helpers.js";import{getProgressBarClasses as u,getContainerClasses as n,getLiquidTagClasses as m,getWrapperIconClasses as v,getIconClasses as g,getOuterIconClasses as f,getWrapperClasses as k,getTextClasses as y}from"../common/classes.js";import{getProgressBarStyles as S,getContainerStyles as b,getWrapperStyles as I,getIconStyles as O,getTextStyles as j}from"../common/styles.js";import{getLiquidTagAttrs as _,getLiquidProgressBarAttrs as h,getLiquidTextAttrs as V,getIconAttrs as E}from"../common/attrs.js";import{createAttr as C,createClass as M,createStyle as A,LiquidIf as G}from"@gem-sdk/system";import{StockCounter as Q}from"../settings/configs/translate.js";let StockCounter=({setting:R,styles:x,style:N,advanced:P,builderProps:T,pageContext:q})=>{let{borderRadius:w}=x??{},{showIcon:z,icon:B,oosIcon:D,layout:F="full",template:H,outOfStockMessage:J,continueSelling:K,unlimitedQuantityMessage:L}=R??{},U=r(T?.uid,w),W="progress-bar"!==F,X=l({val:H,uid:T?.uid,settingId:c({id:Q?.template?.id}),pageContext:q,isReplaceInventoryQuantity:!0}),Y=l({val:J,uid:T?.uid,settingId:c({id:Q?.outOfStockMessage?.id}),pageContext:q}),Z=l({val:K,uid:T?.uid,settingId:c({id:Q?.continueSelling?.id}),pageContext:q}),ss=l({val:L,uid:T?.uid,settingId:c({id:Q?.unlimitedQuantityMessage?.id}),pageContext:q}),st=C({..._(T,R,x)}),si=M({...s("gp-stock-counter-progress gp-mt-2 data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...u(x)}),se=A({...S(x,R)}),so=A({...b(x)}),sl=M({...n(R)}),sc=M({...m(P)}),sd=A({...N}),sr=A({...I(x)}),sa=a(R,x),s$=$({templateStringDisplay:X,outOfStockMessageDisplay:Y,continueSellingDisplay:Z,unlimitedQuantityMessageDisplay:ss}),sp=M({...v(R)}),su=M({...s("gp-stock-counter-icon data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...g(),...f()}),sn=M({...k(R)}),sm=s=>A({...O(x,R,s)}),sv=({isOutOfStockIcon:s,isVisible:t})=>C({...E(s,t)}),sg=C({...h()}),sf=M({...y(x),...s("gp-stock-counter-mark")}),sk=s=>A({...j(x,s)}),sy=C({...V()}),sS=p({templateStringDisplay:X,outOfStockMessageDisplay:Y,continueSellingDisplay:Z,unlimitedQuantityMessageDisplay:ss},x);return t`
    ${sa}
    <gp-product-stock-counter ${{...st}} class="${sc}"
      style="${sd}">
      <div class="${sn}" style="${sr}">
      <style>${U}</style>
        <div
          class="${sl}"
          style="${so}"
        >
          <div class="${sp}">
            ${i(z,t`
              ${G("is_out_of_stock",t`<div
                    ${{...sv({isOutOfStockIcon:!0,isVisible:!0})}}
                    class="${su}"
                    style="${sm(!0)}"
                  >
                    ${D}
                  </div>
              <div
                    ${{...sv({isOutOfStockIcon:!1,isVisible:!1})}}
                     data-slot-type="false"
                    class="${su}"
                    style="${sm(!1)}"
                >
                  ${B}
                </div>`,t` <div
                    ${{...sv({isOutOfStockIcon:!0,isVisible:!1})}}
                    class="${su}"
                    style="${sm(!0)}"
                >
                  ${D}
              </div>
              <div
                    ${{...sv({isOutOfStockIcon:!1,isVisible:!0})}}
                    class="${su}"
                    style="${sm(!1)}"
                >
                  ${B}
                </div>`)}
            `)}
            ${sS}
            ${i(W,t`
              ${G("is_out_of_stock",t`<p
                ${{...sy}}
                class="${sf}"
                style="${sk(!0)}"
              >
                ${s$}
              </p>`,t`<p
                ${{...sy}}
                class="${sf}"
                style="${sk(!1)}"
              >
                ${s$}
              </p>`)}
              `)}

          </div>

          <div
            ${{...sg}}
            style="${se}"
            class="${si}"
          ></div>
        </div>
        </div>
      </gp-product-stock-counter>
      ${i(e,`<script ${d('class="gps-link" delay',"src")}="{{ 'gp-product-stock-counter-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${d('class="gps-link" delay',"src")}="${o}/assets-v2/gp-product-stock-counter-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{StockCounter as default};
