'use client';
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useRef as t,useEffect as o}from"react";import{useStockCounterInteraction as r}from"../hooks/useStockCounterInteraction.js";import{createClass as l,createStyle as m,createAttr as n}from"@gem-sdk/system";import{useStockCounter as a}from"../hooks/useStockCounter.js";import{getInlineCss as i}from"../common/helpers.js";import{getProgressBarClasses as c,getContainerClasses as d,getWrapperIconClasses as u,getIconClasses as p,getOuterIconClasses as f,getTextClasses as y,getWrapperClasses as h}from"../common/classes.js";import{getProgressBarStyles as N,getContainerStyles as S,getWrapperStyles as k,getIconStyles as _,getTextStyles as j}from"../common/styles.js";import{getWrapperAttrs as I,getIconAttrs as g}from"../common/attrs.js";let StockCounter=({setting:v,styles:C,builderProps:H})=>{let{displayProgressBar:L,borderRadius:M}=C??{},{showIcon:O,icon:T,layout:b="full",oosIcon:x}=v??{},{outputMessage:V,isOutOfStock:q,inventoryQuantity:w,shouldHideCounter:z}=a(v,C),A=t(null),{dispatchStockCounterInteraction:B}=r({element:A,uid:H?.uid}),D=i(H?.uid,M),E=!1!==L&&!q,F="progress-bar"!==b,G=l({...c(C)}),J=m({...N(C,v)}),K=m({...S(C)}),P=l({...d(v)}),Q=m({...k(C)}),R=l({...u(v)}),U=l({...p()}),W=l({...f()}),X=e=>m({..._(C,v,e)}),Y=({isOutOfStockIcon:e,isVisible:s})=>n({...g(e,s)}),Z=l({...y(C)}),$=e=>m({...j(C,e)}),ee=l({...h(v,q)}),es=n({...I(H)});return(o(()=>{B(w)},[w]),z)?null:e("div",{...es,style:Q,ref:A,className:ee,children:[s("style",{children:D}),e("div",{className:P,style:K,children:[e("div",{className:R,children:[O&&(q?s("div",{...Y({isOutOfStockIcon:q,isVisible:q}),style:X(!0),className:W,children:s("span",{className:U,dangerouslySetInnerHTML:{__html:x||""}})}):s("div",{...Y({isOutOfStockIcon:!q,isVisible:!q}),style:X(!1),className:W,children:s("span",{className:U,dangerouslySetInnerHTML:{__html:T||""}})})),F&&(q?s("p",{dangerouslySetInnerHTML:{__html:V()},className:Z,style:$(!0)}):s("p",{dangerouslySetInnerHTML:{__html:V()},className:Z,style:$(!1)}))]}),E&&s("div",{style:J,className:G})]})]})};export{StockCounter as default};
