yt-uikit 0.7.381 → 0.7.383
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -3877,7 +3877,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
3877
3877
|
scrollbar-width: none;
|
|
3878
3878
|
|
|
3879
3879
|
-ms-overflow-style: none;
|
|
3880
|
-
`,Bf=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function zf({bundle:e,addToCartFunction:n,currentProductId:r}){const d=i((()=>{if(r){const t="gid://shopify/Product/"+r,n=e.products?.some((e=>e.productId===t));return n?t:e.products?.[0]?.productId}return e.products?.[0]?.productId}),[r,e.products]),s=i((()=>Bf(d,e.products)),[d,e.products]),p=o(null),u=o(null),m=o({});c("");const f=e.customizations??{},g=(i((()=>s?.productDetails?.variants?.edges?.reduce(((e,{node:t})=>t.inventoryQuantity>0?e+=1:e),0)),[s]),i((()=>Bf(d,e.products)?.id),[d,e.products]));i((()=>g?Bf(d,e.products):void 0),[d,e.products,g]),i((()=>e.products?.some((e=>e.productDetails?.options?.some((e=>e.values.length>1))))||!1),[e.products]),f.volumeBundle;const h=i((()=>e?.volumeTiers||[]),[e?.volumeTiers]),x=h.findIndex((e=>e.isDefault)),[y,b]=c(-1!==x?h[x].tier:h?.[0]?.tier||1),[v,w]=c(s?.productDetails?.variants?.edges?.[0]?.node?.id||""),[C,k]=c({}),[E,T]=c(h.reduce(((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},(()=>s?.productDetails?.options?.map((e=>e.values[0]))||[])),e)),{})||{}),[S,$]=c(!1),[B,z]=c(window.innerWidth<550),[D,I]=c(null);o([]);const _=o([]);l((()=>{const e=()=>{z(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{const e=e=>{D&&_.current[D.index]&&_.current[D.index][D.optionIndex]&&!_.current[D.index][D.optionIndex]?.contains(e.target)&&I(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[D]);const O=a((e=>{if(!f.general?.trackInventory)return null;const t=h.find((t=>t.tier===e));if(!t)return null;const n=t.minimumQuantity,r=s?.productDetails?.variants?.edges||[];for(const e of r){const t=e.node;if(t.inventoryQuantity>=n&&t.availableForSale){const e=t.title.split(" / ");return Array(n).fill(e)}}const o=[],a={},i=[...r].sort(((e,t)=>t.node.inventoryQuantity-e.node.inventoryQuantity));for(let e=0;e<n&&o.length<n;e++){let e=!1;for(const t of i){const n=t.node,r=a[n.id]||0;if(n.inventoryQuantity>r&&n.availableForSale){const t=n.title.split(" / ");o.push(t),a[n.id]=r+1,e=!0;break}}if(!e)return null}return o.length===n?o:null}),[s,h]),P=a((e=>{if(!f.general?.trackInventory)return!0;const t=h.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=s?.productDetails?.variants?.edges||[];let o=0;for(const e of r){const t=e.node;t.availableForSale&&(o+=Math.max(0,t.inventoryQuantity))}return o>=n}),[f.general?.trackInventory,h,s]);l((()=>{const e={},t=s?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&h.forEach((n=>{e[n.tier]={};for(let r=0;r<n.minimumQuantity;r++)e[n.tier][r]=t})),k(e)}),[s?.id,h?.map((e=>`${e.tier}-${e.minimumQuantity}`)).join("|")]),l((()=>{if(!m.current[y]){const e=O(y);if(e){const t=y-1;T((n=>({...n,[t]:e})));const n={};e.forEach(((e,t)=>{const r=e.join(" / "),o=s?.productDetails?.variants?.edges?.find((e=>e.node.title===r))?.node.id||v;n[t]=o})),k((e=>({...e,[y]:n})))}m.current[y]=!0}}),[y,s,v,O]);const A=(e,t)=>e?.productDetails?.variants?.edges?.find((e=>e.node.id===t))?.node,N=a(((e,t,n,r,o)=>{if(!f?.general?.trackInventory)return!0;const a=h.find((t=>t.tier===e));if(!a)return!1;const i=a.minimumQuantity,l=[...n];l[r]=o;const c=l.join(" / "),d=s?.productDetails?.variants?.edges?.find((e=>e.node.title===c))?.node;if(!d||!d.availableForSale||d.inventoryQuantity<=0)return!1;const p={},u=C[e]||{};for(let e=0;e<i;e++){let n;if(e===t)n=d.id;else{const t=u[e]||v,r=A(s,t);if(!r)return!1;n=r.id}p[n]=(p[n]||0)+1}for(const[e,t]of Object.entries(p)){const n=A(s,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[f?.general?.trackInventory,h,s,E,E,C,v]),F=a((e=>{if(!f.general?.trackInventory)return!0;const t=h.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=e-1,o={};for(let e=0;e<n;e++){const t=(E[r]?.[e]||s.productDetails.options.map((e=>e.values[0]))).join(" / "),n=s?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!n)return!1;const a=n.node.id;o[a]=(o[a]||0)+1}for(const[e,t]of Object.entries(o)){const n=A(s,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[f.general?.trackInventory,h,s,E]),M=(e,t,n)=>{k((r=>({...r,[e]:{...r[e]||{},[t]:n}})))},R=a((()=>!1===f.general?.trackInventory?s?.productDetails?.variants?.edges?.[0]?.node:s?.productDetails?.variants?.edges?.find((e=>e.node.inventoryQuantity>0))?.node||s?.productDetails?.variants?.edges?.[0]?.node),[s]),L=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]),j=()=>{const e=L();if(e){const t=s?.productDetails?.variants?.edges?.find((t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e)));if(t)w(String(t.node.id));else{const e=R();e&&w(String(e.id))}}};l((()=>{j();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",j),()=>{t=!1,window.removeEventListener("urlChange",j),window.history.pushState=n,window.history.replaceState=r}}),[L,s?.id,R]);const V=t=>{const n=h.find((e=>e.tier===t));if(!n)return{original:0,discounted:0};let r=0,o=0;const a=C[t]||{};for(let e=0;e<n.minimumQuantity;e++){const t=a[e]||v,n=A(s,t);n&&(n.compareAtPrice?r+=Number.parseFloat(n.compareAtPrice):r+=Number.parseFloat(n.price),o+=Number.parseFloat(n.price))}return"percentOff"===e?.discountType?o*=1-n.discountValue/100:"amountOff"===e?.discountType&&(o-=n.discountValue),o<0&&(o=0),{original:r,discounted:o,discountValue:n.discountValue}},H=(e,t,n,r)=>{let o=A(e,t);if(r){const a=C[r]?.[n||0]||t;o=A(e,a)}return o?.image?.url?o.image.url:e.productDetails?.media?.edges[0]?.node?.preview?.image?.url||""},W=i((()=>h.find((e=>e.tier===y))),[h,y]),U=i((()=>W?V(W.tier):null),[W,C,v]),[Q,G]=c(null),Y=i((()=>{if(!W||!U)return;const e=C[W.tier]||{},t={};for(let n=0;n<W.minimumQuantity;n++){const r=e[n]||v;t[r]=(t[r]||0)+1}return t}),[W?.minimumQuantity,v,C,U]),q=i((()=>Object.entries(Y??{}).map((([e,t])=>({variantId:e,quantity:t})))),[Y]);if(l((()=>{if(!W||!U)return;const e={tier:y,items:W.minimumQuantity,discountedPrice:U.discounted,originalPrice:U.original,variants:q,productId:s?.id??null,tierMeta:{title:W.title,subtitle:W.subtitle,badgeTitle:W.badgeTitle},productData:s,tierData:W},t=u.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(p.current&&clearTimeout(p.current),p.current=window.setTimeout((()=>{u.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t)}),50),()=>{p.current&&clearTimeout(p.current)})}),[y,W?.tier,W?.minimumQuantity,U?.discounted,U?.original,s?.id,JSON.stringify(q)]),!n)return t.createElement(t.Fragment,null);const Z=f.volumeBundle?.cardStyle,K=f.general?.primaryColor,X=f.general?.secondaryColor,J=f.general.primaryContrastColor,ee=f.general.secondaryContrastColor,te="high"===e.cornerRadiusType?"20px":"medium"===e.cornerRadiusType?"6px":"0px",ne="bundles"==e.appName?e.pageHeader?.title:e?.title,re="bundles"==e.appName?e.pageHeader?.description:e?.subtitle;return l((()=>{F(y)&&Q?.tier===y&&G(null)}),[y,q,F,Q]),t.createElement(Xm,{verticalMargin:f.volumeBundle?.verticalMargin,backgroundColor:f.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},t.createElement(Jm,{className:"yt-bundle-header"},ne&&ne.trim().length>0&&t.createElement(ef,{fontSize:f.volumeBundle?.titleFontSize,backgroundColor:f.volumeBundle?.titleBackgroundColor,textColor:f.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},ne),t.createElement(tf,{className:"yt-bundle-header-subtitle",fontSize:f.volumeBundle?.subtitleFontSize},re)),"vertical"===Z?t.createElement("div",{style:{display:"grid",gridTemplateColumns:B||4===h.length?"repeat(2, 1fr)":h.length>4?"repeat(3, 1fr)":`repeat(${h.length}, 1fr)`,justifyItems:"center",gap:B?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},h.map((n=>{const r=V(n.tier),o=r.original-r.discounted,a=y===n.tier,i=!P(n.tier);return t.createElement(t.Fragment,{key:n.tier},t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:te||"24px",...a?{border:`2px solid ${K}`}:{border:`1px solid ${X}`},boxShadow:`6px 6px 0px -1px ${a?K:X}20`,...n.badgeTitle&&{position:"relative"},zIndex:5,backgroundColor:i?"#f5f5f5":"white",cursor:i?"not-allowed":"pointer",position:"relative",height:"100%",maxHeight:"350px",width:"100%",opacity:i?.6:1},className:"yt-volume-vertical-tier-item "+(a?"yt-volume-vertical-tier-item-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),onClick:()=>!i&&b(n.tier)},n.badgeTitle&&t.createElement("div",{style:{position:"absolute",top:"-15px",zIndex:-1,left:"0",right:"0",width:"80%",textAlign:"center",margin:"0 auto",fontSize:"10px",clipPath:"polygon(2% 0%, 98% 0%, 100% 100%, 0% 100%)",backgroundColor:a?K:X,color:a?J:ee,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:a?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},0!==r.discountValue&&t.createElement(t.Fragment,null,B&&o&&!!r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},t.createElement(lf,{primaryBackgroundColorCta:a?K:X,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?J:ee},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`))),n.imageUrl&&t.createElement("img",{src:n.imageUrl,style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:te||"24px",borderTopRightRadius:te||"24px"},className:"yt-volume-vertical-tier-badge"})),t.createElement("div",{style:{padding:"8px",paddingTop:"0"}},t.createElement(cf,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},t.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},t.createElement(df,{style:{fontSize:B?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),!B&&o&&!!r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility&&t.createElement(lf,{primaryBackgroundColorCta:a?K:X,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?J:ee},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`),a&&n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:K,color:J,padding:"2px"}},t.createElement(Jr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),t.createElement(sf,{style:{lineHeight:"normal",fontSize:B?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null))),t.createElement(pf,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},t.createElement(uf,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.discounted.toFixed(2))),o?t.createElement(mf,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.original.toFixed(2))):"")),a&&!n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:K,color:J,padding:"2px"}},t.createElement(Jr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))}))):t.createElement(t.Fragment,null,h.map((n=>{const r=V(n.tier),o=r.original-r.discounted,a=!P(n.tier);return t.createElement(t.Fragment,{key:n.tier},n.badgeTitle&&t.createElement(nf,{primaryTextColorCta:J,primaryBackgroundColorCta:K,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement(rf,{cornerRadiusType:e?.cornerRadiusType??"",key:n.tier,primaryBackgroundColorCta:K??"",isSelected:y===n.tier,onClick:()=>b(n.tier),style:{borderRadius:te,cursor:"pointer",backgroundColor:a?"#f5f5f5":"white",opacity:a?.6:1},className:"yt-volume-horizontal-tier-container "+(y===n.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2)},t.createElement(of,{cornerRadiusType:e?.cornerRadiusType??"",style:{borderRadius:te,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},t.createElement(af,{className:"yt-volume-horizontal-tier-info"},t.createElement(yf,{"data-active":y===n.tier,accentColor:K,className:"yt-volume-horizontal-tier-radio-wrapper"},t.createElement(bf,{name:"tier",checked:y===n.tier,onChange:()=>!a&&b(n.tier),disabled:a,className:"yt-volume-horizontal-tier-radio-hidden"}),t.createElement(vf,{accentColor:K,className:"yt-volume-horizontal-tier-radio-custom"})),t.createElement(cf,{className:"yt-volume-horizontal-tier-details"},t.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},t.createElement(df,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),o&&r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility?t.createElement(lf,{primaryBackgroundColorCta:K,isSelected:y===n.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`):""),t.createElement(sf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null)))),t.createElement(pf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},o?t.createElement(mf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.original.toFixed(2))):"",t.createElement(uf,{className:"yt-volume-horizontal-tier-discounted-price"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.discounted.toFixed(2))))),y===n.tier&&t.createElement(ff,{className:"yt-volume-horizontal-tier-product-grid",style:{padding:s.productDetails.variants.edges.length<=1?"0":"10px 15px",gap:s.productDetails.variants.edges.length<=1?"0":"10px"}},Array.from({length:n.minimumQuantity}).map(((r,o)=>{const i=n.tier-1,l=(E[i]||[])[o]||s.productDetails.options?.map((e=>e.values[0]))||[],c=s?.productDetails?.options.some((e=>e.values.length>1));return t.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},c&&t.createElement(wf,{src:H(s,v,o,n.tier),alt:s?.productDetails?.title||"Product",className:"yt-volume-horizontal-tier-product-image"}),"auto"===f?.volumeBundle?.variantSelectorType?t.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},s?.productDetails?.options?.map(((r,d)=>{if(!c)return null;const p=D?.tier===n.tier&&D?.index===o&&D?.optionIndex===d,u=e?.variantOptions?.options?.find((e=>e.name===r.name));let m="";return"color"===u?.type&&(m=u?.values?.find((e=>e.name===l[d]))?.value||""),t.createElement(Tf,{key:d,ref:e=>{_.current[o]||(_.current[o]=[]),_.current[o][d]=e},style:{zIndex:p?1e3:"auto",display:"flex"},isActive:p},t.createElement(Sf,{onClick:e=>{e.stopPropagation(),I(p?null:{tier:n.tier,index:o,optionIndex:d})},isActive:p,disabled:a},"color"===u?.type&&m&&t.createElement("div",{className:"yt-fixedBundle-product-card_color-swatch",style:{display:"inline-block",width:20,height:20,borderRadius:"50%",backgroundColor:m||"transparent",border:"1px solid #ddd"}}),l[d],t.createElement(Vr,null)),p&&t.createElement($f,{style:{zIndex:1001}},r.values.map((e=>{const r=[...l];r[d]=e;const c=!N(n.tier,o,l,d,e)||a;s.productDetails.variants.edges.find((({node:e})=>e.title===r.join(" / ")));const p=t=>{if(t.preventDefault(),t.stopPropagation(),T((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t})),c){G({tier:n.tier,index:o,optionIndex:d,value:e}),I(null);const t=C[n.tier]?.[o]||v;return void M(n.tier,o,t)}const a=r.join(" / "),l=s.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||v;M(n.tier,o,l),I(null)},m=u?.values.find((t=>t.name===e));return"image"===u?.type&&m?.value?t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},t.createElement(kf,{src:m.value,alt:e}),e):"color"===u?.type&&m?.value?t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},t.createElement(Ef,{style:{backgroundColor:m.value}}),e):t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},e)}))))}))):t.createElement(gf,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},s?.productDetails?.options.map(((r,c)=>{if(!(r.values.length>1))return null;const d=e.variantOptions?.options?.find((e=>e.name===r.name))||null;return t.createElement("div",{key:r.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},r.values.map((e=>{const r=l[c]===e,p=!N(n.tier,o,l,c,e)||a,u=d?.values.find((t=>t.name===e)),m=t=>{if(t.preventDefault(),t.stopPropagation(),p)return;const r=[...l];r[c]=e,T((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const a=r.join(" / "),d=s.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||v;M(n.tier,o,d)},g={opacity:p?.5:1,cursor:p?"not-allowed":"pointer"};return"color"===d?.type&&u?.value?t.createElement("button",{key:e,onClick:m,style:{...g,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:p},t.createElement("div",{style:{width:r?"24px":"20px",height:r?"24px":"20px",borderRadius:"50%",backgroundColor:u.value,lineHeight:"normal",boxShadow:"rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 2px"}},t.createElement("span",null))):"image"===d?.type&&u?.value?t.createElement("button",{key:e,onClick:m,style:{...g,border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:r?"#F7F7F7":"transparent",padding:"0px",width:r?"20px":"18px",height:r?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:p},t.createElement("img",{src:u.value,alt:e,style:{width:r?"26px":"24px",height:r?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):t.createElement(hf,{key:e,isSelected:r,onClick:m,style:{...g,padding:"4px 8px",border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:p},e)}))))}))))}))),Q&&Q.tier===n.tier&&t.createElement("div",{style:{color:K,textAlign:"center",fontSize:"14px",fontStyle:"normal",fontWeight:"500",lineHeight:"110%",background:`${K}1A`,padding:"12px",borderBottomLeftRadius:te,borderBottomRightRadius:te}},"There aren’t enough items in our stock for select option, please select smaller bundle.")))}))),e?.showCta&&t.createElement("div",{style:{position:"relative"}},t.createElement(xf,{bgColor:f.general?.ctaBackgroundColor,textColor:f.general?.ctaTextColor,border:`1px solid ${f.general?.ctaBorderColor||"#121212"}`,shadow:f.general.ctaShadowType,padding:f.general?.ctaPadding,width:f.general?.ctaWidth,hoverProperties:{customizeHoverState:f.general?.customizeHoverState,backgroundColor:f.general?.ctaHoverBackgroundColor,textColor:f.general?.ctaHoverTextColor},onClick:async()=>{if(F(y))try{$(!0);const e=h.find((e=>e.tier===y));if(!e)return;const t={},r=C[e.tier]||{};for(let n=0;n<e.minimumQuantity;n++){const e=r[n]||v;t[e]?t[e].quantity+=1:t[e]={quantity:1}}const o=V(e.tier),a=Array.from({length:e.minimumQuantity},((e,t)=>r[t]||v));n&&await n(o.original,a)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{$(!1)}else console.error("Selected tier is out of stock")},borderRadius:f.general.ctaBorderRadius??"",disabled:S,className:"yt-volume-add-to-cart-button"},t.createElement(t.Fragment,null,S?t.createElement(Uo,{color:"white",loading:S,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},t.createElement("span",null,f.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",t.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const n=V(y);return t.createElement(t.Fragment,null,Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(n.discounted.toFixed(2))," ",n?.original&&t.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(n?.original.toFixed(2))," "))})()))))))}const Df=x.div`
|
|
3880
|
+
`,Bf=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function zf({bundle:e,addToCartFunction:n,currentProductId:r}){const d=i((()=>{if(r){const t="gid://shopify/Product/"+r,n=e.products?.some((e=>e.productId===t));return n?t:e.products?.[0]?.productId}return e.products?.[0]?.productId}),[r,e.products]),s=i((()=>Bf(d,e.products)),[d,e.products]),p=o(null),u=o(null),m=o({});c("");const f=e.customizations??{},g=(i((()=>s?.productDetails?.variants?.edges?.reduce(((e,{node:t})=>t.inventoryQuantity>0?e+=1:e),0)),[s]),i((()=>Bf(d,e.products)?.id),[d,e.products]));i((()=>g?Bf(d,e.products):void 0),[d,e.products,g]),i((()=>e.products?.some((e=>e.productDetails?.options?.some((e=>e.values.length>1))))||!1),[e.products]),f.volumeBundle;const h=i((()=>e?.volumeTiers||[]),[e?.volumeTiers]),x=h.findIndex((e=>e.isDefault)),[y,b]=c(-1!==x?h[x].tier:h?.[0]?.tier||1),[v,w]=c(s?.productDetails?.variants?.edges?.[0]?.node?.id||""),[C,k]=c({}),[E,T]=c(h.reduce(((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},(()=>s?.productDetails?.options?.map((e=>e.values[0]))||[])),e)),{})||{}),[S,$]=c(!1),[B,z]=c(window.innerWidth<550),[D,I]=c(null);o([]);const _=o([]),O=o(y);l((()=>{const e=()=>{z(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{const e=e=>{D&&_.current[D.index]&&_.current[D.index][D.optionIndex]&&!_.current[D.index][D.optionIndex]?.contains(e.target)&&I(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[D]);const P=a((e=>{if(!f.general?.trackInventory)return null;const t=h.find((t=>t.tier===e));if(!t)return null;const n=t.minimumQuantity,r=s?.productDetails?.variants?.edges||[];for(const e of r){const t=e.node;if(t.inventoryQuantity>=n&&t.availableForSale){const e=t.title.split(" / ");return Array(n).fill(e)}}const o=[],a={},i=[...r].sort(((e,t)=>t.node.inventoryQuantity-e.node.inventoryQuantity));for(let e=0;e<n&&o.length<n;e++){let e=!1;for(const t of i){const n=t.node,r=a[n.id]||0;if(n.inventoryQuantity>r&&n.availableForSale){const t=n.title.split(" / ");o.push(t),a[n.id]=r+1,e=!0;break}}if(!e)return null}return o.length===n?o:null}),[s,h]),A=a((e=>{if(!f.general?.trackInventory)return!0;const t=h.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=s?.productDetails?.variants?.edges||[];let o=0;for(const e of r){const t=e.node;t.availableForSale&&(o+=Math.max(0,t.inventoryQuantity))}return o>=n}),[f.general?.trackInventory,h,s]);l((()=>{const e={},t=s?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&h.forEach((n=>{e[n.tier]={};for(let r=0;r<n.minimumQuantity;r++)e[n.tier][r]=t})),k(e)}),[s?.id,h?.map((e=>`${e.tier}-${e.minimumQuantity}`)).join("|")]),l((()=>{if(!m.current[y]){const e=P(y);if(e){const t=y-1;T((n=>({...n,[t]:e})));const n={};e.forEach(((e,t)=>{const r=e.join(" / "),o=s?.productDetails?.variants?.edges?.find((e=>e.node.title===r))?.node.id||v;n[t]=o})),k((e=>({...e,[y]:n})))}m.current[y]=!0}}),[y,s,v,P]);const N=(e,t)=>e?.productDetails?.variants?.edges?.find((e=>e.node.id===t))?.node,F=a(((e,t,n,r,o)=>{if(!f?.general?.trackInventory)return!0;const a=h.find((t=>t.tier===e));if(!a)return!1;const i=a.minimumQuantity,l=[...n];l[r]=o;const c=l.join(" / "),d=s?.productDetails?.variants?.edges?.find((e=>e.node.title===c))?.node;if(!d||!d.availableForSale||d.inventoryQuantity<=0)return!1;const p={},u=C[e]||{};for(let e=0;e<i;e++){let n;if(e===t)n=d.id;else{const t=u[e]||v,r=N(s,t);if(!r)return!1;n=r.id}p[n]=(p[n]||0)+1}for(const[e,t]of Object.entries(p)){const n=N(s,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[f?.general?.trackInventory,h,s,E,E,C,v]),M=a((e=>{if(!f.general?.trackInventory)return!0;const t=h.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=e-1,o={};for(let e=0;e<n;e++){const t=(E[r]?.[e]||s.productDetails.options.map((e=>e.values[0]))).join(" / "),n=s?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!n)return!1;const a=n.node.id;o[a]=(o[a]||0)+1}for(const[e,t]of Object.entries(o)){const n=N(s,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[f.general?.trackInventory,h,s,E]),R=(e,t,n)=>{k((r=>({...r,[e]:{...r[e]||{},[t]:n}})))},L=a((()=>!1===f.general?.trackInventory?s?.productDetails?.variants?.edges?.[0]?.node:s?.productDetails?.variants?.edges?.find((e=>e.node.inventoryQuantity>0))?.node||s?.productDetails?.variants?.edges?.[0]?.node),[s]),j=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]);l((()=>{O.current=y}),[y]),l((()=>{G&&(Y(null),V())}),[y]);const V=()=>{const e=j();if(e){const t=s?.productDetails?.variants?.edges?.find((t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e)));let n=t?.node;if(n)w(String(n.id));else{const e=L();e&&(w(String(e.id)),n=e)}if(n){!n.availableForSale||n.inventoryQuantity<=0?(Y(null),setTimeout((()=>{Y({tier:O.current,index:0,optionIndex:0,value:n.title})}),0)):G&&Y(null)}}};l((()=>{V();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",V),()=>{t=!1,window.removeEventListener("urlChange",V),window.history.pushState=n,window.history.replaceState=r}}),[j,s?.id,L]);const H=t=>{const n=h.find((e=>e.tier===t));if(!n)return{original:0,discounted:0};let r=0,o=0;const a=C[t]||{};for(let e=0;e<n.minimumQuantity;e++){const t=a[e]||v,n=N(s,t);n&&(n.compareAtPrice?r+=Number.parseFloat(n.compareAtPrice):r+=Number.parseFloat(n.price),o+=Number.parseFloat(n.price))}return"percentOff"===e?.discountType?o*=1-n.discountValue/100:"amountOff"===e?.discountType&&(o-=n.discountValue),o<0&&(o=0),{original:r,discounted:o,discountValue:n.discountValue}},W=(e,t,n,r)=>{let o=N(e,t);if(r){const a=C[r]?.[n||0]||t;o=N(e,a)}return o?.image?.url?o.image.url:e.productDetails?.media?.edges[0]?.node?.preview?.image?.url||""},U=i((()=>h.find((e=>e.tier===y))),[h,y]),Q=i((()=>U?H(U.tier):null),[U,C,v]),[G,Y]=c(null),q=i((()=>{if(!U||!Q)return;const e=C[U.tier]||{},t={};for(let n=0;n<U.minimumQuantity;n++){const r=e[n]||v;t[r]=(t[r]||0)+1}return t}),[U?.minimumQuantity,v,C,Q]),Z=i((()=>Object.entries(q??{}).map((([e,t])=>({variantId:e,quantity:t})))),[q]);if(l((()=>{if(!U||!Q)return;const e={tier:y,items:U.minimumQuantity,discountedPrice:Q.discounted,originalPrice:Q.original,variants:Z,productId:s?.id??null,tierMeta:{title:U.title,subtitle:U.subtitle,badgeTitle:U.badgeTitle},productData:s,tierData:U},t=u.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(p.current&&clearTimeout(p.current),p.current=window.setTimeout((()=>{u.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t)}),50),()=>{p.current&&clearTimeout(p.current)})}),[y,U?.tier,U?.minimumQuantity,Q?.discounted,Q?.original,s?.id,JSON.stringify(Z)]),l((()=>{if(!v||!U)return;const e=N(s,v);if(e){const t={};for(let e=0;e<U.minimumQuantity;e++)t[e]=v;k((e=>({...e,[y]:t})));const n=e.title.split(" / "),r=Array(U.minimumQuantity).fill(n);T((e=>({...e,[y-1]:r})))}}),[v,y,s,U]),!n)return t.createElement(t.Fragment,null);const K=f.volumeBundle?.cardStyle,X=f.general?.primaryColor,J=f.general?.secondaryColor,ee=f.general.primaryContrastColor,te=f.general.secondaryContrastColor,ne="high"===e.cornerRadiusType?"20px":"medium"===e.cornerRadiusType?"6px":"0px",re="bundles"==e.appName?e.pageHeader?.title:e?.title,oe="bundles"==e.appName?e.pageHeader?.description:e?.subtitle;return l((()=>{M(y)&&G?.tier===y&&Y(null)}),[y,Z,M,G]),t.createElement(Xm,{verticalMargin:f.volumeBundle?.verticalMargin,backgroundColor:f.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},t.createElement(Jm,{className:"yt-bundle-header"},re&&re.trim().length>0&&t.createElement(ef,{fontSize:f.volumeBundle?.titleFontSize,backgroundColor:f.volumeBundle?.titleBackgroundColor,textColor:f.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},re),t.createElement(tf,{className:"yt-bundle-header-subtitle",fontSize:f.volumeBundle?.subtitleFontSize},oe)),"vertical"===K?t.createElement("div",{style:{display:"grid",gridTemplateColumns:B||4===h.length?"repeat(2, 1fr)":h.length>4?"repeat(3, 1fr)":`repeat(${h.length}, 1fr)`,justifyItems:"center",gap:B?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},h.map((n=>{const r=H(n.tier),o=r.original-r.discounted,a=y===n.tier,i=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:ne||"24px",...a?{border:`2px solid ${X}`}:{border:`1px solid ${J}`},boxShadow:`6px 6px 0px -1px ${a?X:J}20`,...n.badgeTitle&&{position:"relative"},zIndex:5,backgroundColor:i?"#f5f5f5":"white",cursor:i?"not-allowed":"pointer",position:"relative",height:"100%",maxHeight:"350px",width:"100%",opacity:i?.6:1},className:"yt-volume-vertical-tier-item "+(a?"yt-volume-vertical-tier-item-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),onClick:()=>!i&&b(n.tier)},n.badgeTitle&&t.createElement("div",{style:{position:"absolute",top:"-15px",zIndex:-1,left:"0",right:"0",width:"80%",textAlign:"center",margin:"0 auto",fontSize:"10px",clipPath:"polygon(2% 0%, 98% 0%, 100% 100%, 0% 100%)",backgroundColor:a?X:J,color:a?ee:te,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:a?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},0!==r.discountValue&&t.createElement(t.Fragment,null,B&&o&&!!r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},t.createElement(lf,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`))),n.imageUrl&&t.createElement("img",{src:n.imageUrl,style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:ne||"24px",borderTopRightRadius:ne||"24px"},className:"yt-volume-vertical-tier-badge"})),t.createElement("div",{style:{padding:"8px",paddingTop:"0"}},t.createElement(cf,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},t.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},t.createElement(df,{style:{fontSize:B?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),!B&&o&&!!r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility&&t.createElement(lf,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`),a&&n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Jr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),t.createElement(sf,{style:{lineHeight:"normal",fontSize:B?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null))),t.createElement(pf,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},t.createElement(uf,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.discounted.toFixed(2))),o?t.createElement(mf,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.original.toFixed(2))):"")),a&&!n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Jr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))}))):t.createElement(t.Fragment,null,h.map((n=>{const r=H(n.tier),o=r.original-r.discounted,a=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},n.badgeTitle&&t.createElement(nf,{primaryTextColorCta:ee,primaryBackgroundColorCta:X,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement(rf,{cornerRadiusType:e?.cornerRadiusType??"",key:n.tier,primaryBackgroundColorCta:X??"",isSelected:y===n.tier,onClick:()=>b(n.tier),style:{borderRadius:ne,cursor:"pointer",backgroundColor:a?"#f5f5f5":"white",opacity:a?.6:1},className:"yt-volume-horizontal-tier-container "+(y===n.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2)},t.createElement(of,{cornerRadiusType:e?.cornerRadiusType??"",style:{borderRadius:ne,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},t.createElement(af,{className:"yt-volume-horizontal-tier-info"},t.createElement(yf,{"data-active":y===n.tier,accentColor:X,className:"yt-volume-horizontal-tier-radio-wrapper"},t.createElement(bf,{name:"tier",checked:y===n.tier,onChange:()=>!a&&b(n.tier),disabled:a,className:"yt-volume-horizontal-tier-radio-hidden"}),t.createElement(vf,{accentColor:X,className:"yt-volume-horizontal-tier-radio-custom"})),t.createElement(cf,{className:"yt-volume-horizontal-tier-details"},t.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},t.createElement(df,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),o&&r?.discountValue&&"Enabled"===f.volumeBundle?.discountBadgeVisibility?t.createElement(lf,{primaryBackgroundColorCta:X,isSelected:y===n.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Th(f.general.currencySymbol,e.storeCurrencyCode)}${Eh(r.discountValue)}`):""),t.createElement(sf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null)))),t.createElement(pf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},o?t.createElement(mf,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.original.toFixed(2))):"",t.createElement(uf,{className:"yt-volume-horizontal-tier-discounted-price"},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(r.discounted.toFixed(2))))),y===n.tier&&t.createElement(ff,{className:"yt-volume-horizontal-tier-product-grid",style:{padding:s.productDetails.variants.edges.length<=1?"0":"10px 15px",gap:s.productDetails.variants.edges.length<=1?"0":"10px"}},Array.from({length:n.minimumQuantity}).map(((r,o)=>{const i=n.tier-1,l=(E[i]||[])[o]||s.productDetails.options?.map((e=>e.values[0]))||[],c=s?.productDetails?.options.some((e=>e.values.length>1));return t.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},c&&t.createElement(wf,{src:W(s,v,o,n.tier),alt:s?.productDetails?.title||"Product",className:"yt-volume-horizontal-tier-product-image"}),"auto"===f?.volumeBundle?.variantSelectorType?t.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},s?.productDetails?.options?.map(((r,d)=>{if(!c)return null;const p=D?.tier===n.tier&&D?.index===o&&D?.optionIndex===d,u=e?.variantOptions?.options?.find((e=>e.name===r.name));let m="";return"color"===u?.type&&(m=u?.values?.find((e=>e.name===l[d]))?.value||""),t.createElement(Tf,{key:d,ref:e=>{_.current[o]||(_.current[o]=[]),_.current[o][d]=e},style:{zIndex:p?1e3:"auto",display:"flex"},isActive:p},t.createElement(Sf,{onClick:e=>{e.stopPropagation(),I(p?null:{tier:n.tier,index:o,optionIndex:d})},isActive:p,disabled:a},"color"===u?.type&&m&&t.createElement("div",{className:"yt-fixedBundle-product-card_color-swatch",style:{display:"inline-block",width:20,height:20,borderRadius:"50%",backgroundColor:m||"transparent",border:"1px solid #ddd"}}),l[d],t.createElement(Vr,null)),p&&t.createElement($f,{style:{zIndex:1001}},r.values.map((e=>{const r=[...l];r[d]=e;const c=!F(n.tier,o,l,d,e)||a;s.productDetails.variants.edges.find((({node:e})=>e.title===r.join(" / ")));const p=t=>{if(t.preventDefault(),t.stopPropagation(),T((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t})),c){Y({tier:y,index:o,optionIndex:d,value:e}),I(null);const t=C[n.tier]?.[o]||v;return void R(n.tier,o,t)}const a=r.join(" / "),l=s.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||v;R(n.tier,o,l),I(null)},m=u?.values.find((t=>t.name===e));return"image"===u?.type&&m?.value?t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},t.createElement(kf,{src:m.value,alt:e}),e):"color"===u?.type&&m?.value?t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},t.createElement(Ef,{style:{backgroundColor:m.value}}),e):t.createElement(Cf,{key:e,onClick:p,style:{cursor:"pointer"}},e)}))))}))):t.createElement(gf,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},s?.productDetails?.options.map(((r,c)=>{if(!(r.values.length>1))return null;const d=e.variantOptions?.options?.find((e=>e.name===r.name))||null;return t.createElement("div",{key:r.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},r.values.map((e=>{const r=l[c]===e,p=!F(n.tier,o,l,c,e)||a,u=d?.values.find((t=>t.name===e)),m=t=>{if(t.preventDefault(),t.stopPropagation(),p)return;const r=[...l];r[c]=e,T((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const a=r.join(" / "),d=s.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||v;R(n.tier,o,d)},g={opacity:p?.5:1,cursor:p?"not-allowed":"pointer"};return"color"===d?.type&&u?.value?t.createElement("button",{key:e,onClick:m,style:{...g,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:p},t.createElement("div",{style:{width:r?"24px":"20px",height:r?"24px":"20px",borderRadius:"50%",backgroundColor:u.value,lineHeight:"normal",boxShadow:"rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 2px"}},t.createElement("span",null))):"image"===d?.type&&u?.value?t.createElement("button",{key:e,onClick:m,style:{...g,border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:r?"#F7F7F7":"transparent",padding:"0px",width:r?"20px":"18px",height:r?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:p},t.createElement("img",{src:u.value,alt:e,style:{width:r?"26px":"24px",height:r?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):t.createElement(hf,{key:e,isSelected:r,onClick:m,style:{...g,padding:"4px 8px",border:r?`1px solid ${f.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:p},e)}))))}))))}))),G&&G.tier===n.tier&&t.createElement("div",{style:{color:X,textAlign:"center",fontSize:"14px",fontStyle:"normal",fontWeight:"500",lineHeight:"110%",background:`${X}1A`,padding:"12px",borderBottomLeftRadius:ne,borderBottomRightRadius:ne}},"There aren’t enough items in our stock for select option, please select smaller bundle.")))}))),e?.showCta&&t.createElement("div",{style:{position:"relative"}},t.createElement(xf,{bgColor:M(y)?f.general?.ctaBackgroundColor:"#ccc",textColor:M(y)?f.general?.ctaTextColor:"#666",border:`1px solid ${M(y)?f.general?.ctaBorderColor||"#121212":"#999"}`,shadow:f.general.ctaShadowType,padding:f.general?.ctaPadding,width:f.general?.ctaWidth,hoverProperties:{customizeHoverState:!!M(y)&&f.general?.customizeHoverState,backgroundColor:f.general?.ctaHoverBackgroundColor,textColor:f.general?.ctaHoverTextColor},onClick:async()=>{if(M(y))try{$(!0);const e=h.find((e=>e.tier===y));if(!e)return;const t={},r=C[e.tier]||{};for(let n=0;n<e.minimumQuantity;n++){const e=r[n]||v;t[e]?t[e].quantity+=1:t[e]={quantity:1}}const o=H(e.tier),a=Array.from({length:e.minimumQuantity},((e,t)=>r[t]||v));n&&await n(o.original,a)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{$(!1)}else console.error("Selected tier is out of stock")},borderRadius:f.general.ctaBorderRadius??"",disabled:S||!M(y),className:"yt-volume-add-to-cart-button"},M(y)?t.createElement(t.Fragment,null,S?t.createElement(Uo,{color:"white",loading:S,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},t.createElement("span",null,f.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",t.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const n=H(y);return t.createElement(t.Fragment,null,Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(n.discounted.toFixed(2))," ",n?.original&&t.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},Th(f.general.currencySymbol,e.storeCurrencyCode),Eh(n?.original.toFixed(2))," "))})()))):t.createElement(t.Fragment,null,"Out of Stock"))))}const Df=x.div`
|
|
3881
3881
|
container-type: inline-size;
|
|
3882
3882
|
border-radius: ${e=>e.borderRadius?e.borderRadius:"8px"};
|
|
3883
3883
|
max-width: 800px;
|