yt-uikit 0.8.68 → 0.8.69
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
|
@@ -3491,7 +3491,7 @@ import e,{useState as t,useEffect as n,useMemo as o,useRef as r,useCallback as i
|
|
|
3491
3491
|
scrollbar-width: none;
|
|
3492
3492
|
|
|
3493
3493
|
-ms-overflow-style: none;
|
|
3494
|
-
`,wd=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function Cd({bundle:a,addToCartFunction:l,currentProductId:c,dispatchAnalyticsEvent:d}){const s=o(()=>{if(c){const e="gid://shopify/Product/"+c,t=a.products?.some(t=>t.productId===e);return t?e:a.products?.[0]?.productId}return a.products?.[0]?.productId},[c,a.products]),p=o(()=>wd(s,a.products),[s,a.products]),u=r(null),m=r(null);r({}),document.querySelector("#ProductSelect-product-template"),document.querySelector('form[action="/cart/add"]');const[g,x]=t(0),[f,y]=t(""),b=a.customizations??{},h=!1===b?.general?.showDecimalsInBundlePricing,v=o(()=>p?.productDetails?.tracksInventory??!0,[p?.productDetails?.tracksInventory]),w=i(e=>{if(!v)return 1/0;if(!e)return 0;if(!e.inventoryItem?.tracked)return 1/0;let t=e.inventoryQuantity??0;return t>0?t:"continue"===e.inventoryPolicy?.toLowerCase()?1/0:0},[v]),C=(o(()=>p?.productDetails?.variants?.edges?.reduce((e,{node:t})=>w(t)>0?e+1:e,0),[p,w]),o(()=>wd(s,a.products)?.id,[s,a.products]));o(()=>C?wd(s,a.products):void 0,[s,a.products,C]),o(()=>a.products?.some(e=>e.productDetails?.options?.some(e=>e.values.length>1))||!1,[a.products]),b.volumeBundle;const E=o(()=>a?.volumeTiers||[],[a?.volumeTiers]),k=E.findIndex(e=>e.isDefault),[T,S]=t(-1!==k?E[k].tier:E?.[0]?.tier||1),[$,B]=t(p?.productDetails?.variants?.edges?.find(e=>w(e?.node)>0)?.node?.id||p?.productDetails?.variants?.edges?.[0]?.node?.id||""),[I,z]=t({}),[F,N]=t(E.reduce((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},()=>p?.productDetails?.options?.map(e=>e.values[0])||[]),e),{})||{}),[P,D]=t(!1),[A,_]=t(window.innerWidth<550),[R,O]=t(null),[L,M]=t(null);r([]);const j=r([]),V=r(T);n(()=>{d?.({eventNameCustom:"block_visibility",eventTypeCustom:"views",data:{bundleId:a._id,bundleType:"volume-bundle"}});const e=()=>{_(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),n(()=>{const e=e=>{R&&j.current[R.index]&&j.current[R.index][R.optionIndex]&&!j.current[R.index][R.optionIndex]?.contains(e.target)&&O(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[R]),i(e=>{const t=E.find(t=>t.tier===e);if(!t)return null;const n=t.minimumQuantity,o=p?.productDetails?.variants?.edges||[];for(const e of o){const t=e.node;if(w(t)>=n){const e=t.title.split(" / ");return Array(n).fill(e)}}const r=[],i={},a=[...o].sort((e,t)=>{const n=w(e.node),o=w(t.node);return n===1/0&&o===1/0?0:n===1/0?-1:o===1/0?1:o-n});for(let e=0;e<n&&r.length<n;e++){let e=!1;for(const t of a){const n=t.node,o=i[n.id]||0;if(w(n)>o&&n.availableForSale){const t=n.title.split(" / ");r.push(t),i[n.id]=o+1,e=!0;break}}if(!e)return null}return r.length===n?r:null},[p,E,w]);const W=i(e=>{const t=E.find(t=>t.tier===e);if(!t)return!1;const n=t.minimumQuantity,o=p?.productDetails?.variants?.edges||[];let r=0;for(const e of o){const t=w(e.node);if(t===1/0){r=1/0;break}r+=t}return r>=n},[E,p,w]);n(()=>{const e={},t=p?.productDetails?.variants?.edges?.find(e=>w(e?.node)>0)?.node?.id||p?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&E.forEach(n=>{e[n.tier]={};for(let o=0;o<n.minimumQuantity;o++)e[n.tier][o]=t}),z(e)},[p?.id,E?.map(e=>`${e.tier}-${e.minimumQuantity}`).join("|"),w]);const H=(e,t)=>e?.productDetails?.variants?.edges?.find(e=>e.node.id===t)?.node,q=i((e,t,n,o,r)=>{const i=E.find(t=>t.tier===e);if(!i)return!1;const a=i.minimumQuantity,l=[...n];l[o]=r;const c=l.join(" / "),d=p?.productDetails?.variants?.edges?.find(e=>e.node.title===c)?.node;if(!d||0===w(d))return!1;const s={},u=I[e]||{};for(let e=0;e<a;e++){let n;if(e===t)n=d.id;else{const t=u[e]||$,o=H(p,t);if(!o)return!1;n=o.id}s[n]=(s[n]||0)+1}for(const[e,t]of Object.entries(s)){const n=H(p,e),o=w(n);if(o!==1/0&&t>o)return!1}return!0},[E,p,F,F,I,$,w]),Q=i(e=>{const t=E.find(t=>t.tier===e);if(!t)return!1;const n=t.minimumQuantity,o=e-1,r={};for(let e=0;e<n;e++){const t=(F[o]?.[e]||p.productDetails.options.map(e=>e.values[0])).join(" / "),n=p?.productDetails?.variants?.edges?.find(e=>e.node.title===t);if(!n)return!1;const i=n.node.id;r[i]=(r[i]||0)+1}for(const[e,t]of Object.entries(r)){const n=H(p,e),o=w(n);if(o!==1/0&&t>o)return!1}return!0},[E,p,F,w]);n(()=>{x(e=>e+1)},[I]);const U=(e,t,n)=>{z(o=>({...o,[e]:{...o[e]||{},[t]:n}}))},Y=i(()=>p?.productDetails?.variants?.edges?.find(e=>w(e.node)>0)?.node||p?.productDetails?.variants?.edges?.[0]?.node,[p,w]),G=i(()=>new URLSearchParams(window.location.search).get("variant")||"",[]);n(()=>{V.current=T},[T]),n(()=>{L?(M(null),X()):X()},[T]),n(()=>{if(a){const e=Y();if(e)y(e.id),B(e.id);else{const e=p?.productDetails?.variants?.edges?.[0]?.node?.id||"";y(e),B(e)}}},[a,p,Y]);const X=()=>{const e=G();if(e){const t=p?.productDetails?.variants?.edges?.find(t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e));let n=t?.node;if(n)B(String(n.id)),x(e=>e+1);else{const e=Y();e&&(B(String(e.id)),n=e),x(e=>e+1)}if(n){0===w(n)?(M(null),setTimeout(()=>{M({tier:V.current,index:0,optionIndex:0,value:n.title})},0)):L&&M(null)}}};n(()=>{X();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,o=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(o.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",X),()=>{t=!1,window.removeEventListener("urlChange",X),window.history.pushState=n,window.history.replaceState=o}},[G,p?.id,Y,w]);const Z=e=>{const t=E.find(t=>t.tier===e);if(!t)return{original:0,discounted:0,discountedFromPrice:0,discountedFromCompare:0,diffAmountFromPrice:0,diffAmountFromCompare:0,diffPercentFromPrice:0,diffPercentFromCompare:0,discountValue:0};let n=0,o=0,r=0;const i=I[e]||{};for(let e=0;e<t.minimumQuantity;e++){const t=i[e]||$,a=H(p,t);if(!a)continue;const l=Number.parseFloat(a.price);n+=a.compareAtPrice?Number.parseFloat(a.compareAtPrice):l,o+=l,r+=l}if("percentOff"===a?.discountType){r*=1-t.discountValue/100}else"amountOff"===a?.discountType&&(r-=t.discountValue);const l=Math.max(0,r),c=o-l,d=n-l,s=o>0?c/o*100:0,u=n>0?d/n*100:0;return{original:n,discounted:l,discountedFromPrice:l,discountedFromCompare:l,diffAmountFromPrice:c,diffAmountFromCompare:d,diffPercentFromPrice:Math.round(s),diffPercentFromCompare:Math.round(u),discountValue:t.discountValue}},K=(e,t,n,o)=>{let r=H(e,t);if(o){const i=I[o]?.[n||0]||t;r=H(e,i)}return r?.image?.url?r.image.url:e.productDetails?.media?.edges[0]?.node?.preview?.image?.url||""};function J(e){if(e.startsWith("gid://")){const t=e.split("/");return t[t.length-1]}return e}n(()=>{const e=()=>{if(b.volumeBundle?.addtoCartMethod&&"shopify_atc_button"!==b.volumeBundle?.addtoCartMethod)return;const e=document.querySelector('form[action="/cart/add"]');if(!e)return;const t=e.querySelector(".sr-headless-checkout");t&&t?.setAttribute("style","display: none;");const n=document.querySelector("#Quantity-product-template")||document.querySelector('input[name="quantity"]')||document.querySelector('input[type="number"][min="1"]');let o=1;n&&n.value&&(o=parseInt(n.value,10)||1);const r=E.find(e=>e.tier===T);if(!r)return;e.querySelectorAll('.bundle-input-field, [name^="properties["], [name="id"], [name="quantity"], .t4s-quantity-wrapper').forEach(e=>e.remove());const i=r.minimumQuantity;let a={};const l=Math.max(i,o);if("vertical"===b.volumeBundle.cardStyle){const e=f||$;if(!e)return;a[e]=l}else if(o>i){const e=f||$;if(!e)return;a[e]=l}else{const e=I[r.tier]||{};for(let t=0;t<i;t++){let n=e[t];n||(n=$),n&&(a[n]=(a[n]||0)+1)}}const c=Z(r.tier),d=Object.fromEntries(Object.entries(a).map(([e,t])=>[J(e),Math.round(t)])),s=(t,n,o="bundle-input-field")=>{const r=document.createElement("input");r.type="hidden",r.name=t,r.value=n,r.className=o,e.appendChild(r)};if(o>i){const e=f||$;e&&s("id",J(e))}s("properties[_bundle_price]",String(c.original)),s("properties[_bundle_tier]",String(r.tier)),s("properties[_bundle_items]",JSON.stringify(d));let p=0;Object.entries(d).forEach(([e,t])=>{t>0&&(s(`items[${p}][id]`,e),s(`items[${p}][quantity]`,String(t)),p++)}),requestAnimationFrame(()=>{const t=e.querySelector('[type="submit"]'),n=e.querySelector(".noti-btn-main-wrap"),r=(e,t,n)=>{if(!e)return;e.disabled=t,e.classList.toggle("disabled",t);const o=e.querySelector("[data-add-to-cart-text]")||e.querySelector("span");o&&(o.textContent=n)};o<=i&&(L?(r(t,!0,"Sold out"),t&&t.classList.add("btn--sold-out","hidden"),n&&(n.style.display="block",n.classList.remove("hidden"),n.classList.add("block"))):(r(t,!1,"Add to cart"),t&&t.classList.remove("btn--sold-out","hidden"),n&&(n.style.display="none",n.classList.add("hidden"))))})};e();const t=document.querySelector("#Quantity-product-template")||document.querySelector('input[name="quantity"]')||document.querySelector('input[type="number"][min="1"]');if(t){const n=()=>{requestAnimationFrame(()=>{e()})};return t.addEventListener("input",n),t.addEventListener("change",n),()=>{t.removeEventListener("input",n),t.removeEventListener("change",n)}}return()=>{}},[T,JSON.stringify(I),$,b.volumeBundle?.cardStyle,c,f,L]);const ee=o(()=>E.find(e=>e.tier===T),[E,T]),te=o(()=>ee?Z(ee.tier):null,[ee,I,$]),ne=o(()=>{if(!ee||!te)return;const e=I[ee.tier]||{},t={};for(let n=0;n<ee.minimumQuantity;n++){const o=e[n]||$;t[o]=(t[o]||0)+1}return t},[ee?.minimumQuantity,$,I,te]),oe=o(()=>Object.entries(ne??{}).map(([e,t])=>({variantId:e,quantity:t})),[ne]);if(n(()=>{if(!ee||!te)return;const e={tier:T,items:ee.minimumQuantity,discountedPrice:te.discounted,originalPrice:te.original,variants:oe,productId:p?.id??null,tierMeta:{title:ee.title,subtitle:ee.subtitle,badgeTitle:ee.badgeTitle},productData:p,tierData:ee},t=m.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(u.current&&clearTimeout(u.current),u.current=window.setTimeout(()=>{m.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t),l&&(window.ytVolumeBundle={bundle:a,addToCart:l,currentTier:ee,selectedVariants:oe},window.dispatchEvent(new CustomEvent("yt-volume-bundle-updated",{detail:{...e,addToCart:l}})))},50),()=>{u.current&&clearTimeout(u.current)})},[T,ee?.tier,ee?.minimumQuantity,te?.discounted,te?.original,p?.id,JSON.stringify(oe),l,a]),n(()=>()=>{window.ytVolumeBundle=void 0,window.dispatchEvent(new CustomEvent("yt-volume-bundle-updated",{detail:void 0}))},[]),n(()=>{if(!$||!p)return;const e=H(p,$);if(!e)return;const t=e.title.split(" / "),n={},o={};E.forEach(e=>{const r=e.tier-1,i={};for(let t=0;t<e.minimumQuantity;t++)i[t]=$;n[e.tier]=i,o[r]=Array(e.minimumQuantity).fill(t)}),z(e=>({...e,...n})),N(e=>({...e,...o}))},[$,p?.id,E.length]),!l)return e.createElement(e.Fragment,null);const re=b.volumeBundle?.cardStyle,ie=b.general?.primaryColor,ae=b.general?.secondaryColor,le=b.general.primaryContrastColor,ce=b.general.secondaryContrastColor,de="high"===a.cornerRadiusType?"20px":"medium"===a.cornerRadiusType?"6px":"0px",se="bundles"==a.appName?a.pageHeader?.title:a?.title,pe="bundles"==a.appName?a.pageHeader?.description:a?.subtitle;return n(()=>{const e=Q(T);e?M(null):e||M({tier:T,index:0,optionIndex:0,value:""})},[T,oe,Q]),e.createElement(Qc,{verticalMargin:b.volumeBundle?.verticalMargin,$backgroundColor:b.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},e.createElement(Uc,{className:"yt-bundle-header"},se&&se.trim().length>0&&e.createElement(Yc,{fontSize:b.volumeBundle?.titleFontSize,$backgroundColor:b.volumeBundle?.titleBackgroundColor,textColor:b.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},se),e.createElement(Gc,{className:"yt-bundle-header-subtitle",fontSize:b.volumeBundle?.subtitleFontSize},pe)),"vertical"===re?e.createElement("div",{style:{display:"grid",gridTemplateColumns:A||4===E.length?"repeat(2, 1fr)":E.length>4?"repeat(3, 1fr)":`repeat(${E.length}, 1fr)`,justifyItems:"center",gap:A?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},E.map(t=>{const n=Z(t.tier),o=n.original-n.discounted,r=T===t.tier,i=!W(t.tier);return e.createElement(e.Fragment,{key:t.tier},e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:de||"24px",...r?{border:`2px solid ${ie}`}:{border:`1px solid ${ae}`},boxShadow:`6px 6px 0px -1px ${r?ie:ae}20`,...t.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 "+(r?"yt-volume-vertical-tier-item-active":""),"data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType,"data-minimum-quantity":t.minimumQuantity,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),onClick:()=>!i&&S(t.tier)},t.badgeTitle&&e.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:r?ie:ae,color:r?le:ce,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:r?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":t.tier,"data-badge-title":t.badgeTitle},t.badgeTitle),e.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},"Enabled"===b.volumeBundle?.discountBadgeVisibility&&A&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let i="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(i="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(i="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(i="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return i?e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},e.createElement(ed,{primaryBackgroundColorCta:r?ie:ae,isSelected:r,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:r?le:ce},className:"yt-volume-vertical-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},i)):null})(),t.imageUrl&&e.createElement("img",{src:Bp(t.imageUrl),style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:de||"24px",borderTopRightRadius:de||"24px"},className:"yt-volume-vertical-tier-badge"})),e.createElement("div",{style:{padding:"8px",paddingTop:"0"}},e.createElement(td,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},e.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},e.createElement(nd,{style:{fontSize:A?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},t.title?t.title:e.createElement(e.Fragment,null,"Buy ",t.minimumQuantity,", Get"," ",t.discountValue,"% Off")),"Enabled"===b.volumeBundle?.discountBadgeVisibility&&!A&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let i="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(i="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(i="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(i="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return i?e.createElement(ed,{primaryBackgroundColorCta:r?ie:ae,isSelected:r,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:r?le:ce},className:"yt-volume-vertical-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},i):null})(),r&&t.imageUrl&&e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},e.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:ie,color:le,padding:"2px"}},e.createElement(_e,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),e.createElement(od,{style:{lineHeight:"normal",fontSize:A?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},t.subtitle?t.subtitle:e.createElement(e.Fragment,null))),W(t.tier)?e.createElement(rd,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":t.tier,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),"data-savings":o.toFixed(h?0:2)},(()=>{const r=b?.volumeBundle?.tierPriceType||"tier-price";if("none"===r)return;let i="",l="";if("unit-price"===r){const e=n.discounted/t.minimumQuantity;i=(n.original/t.minimumQuantity).toFixed(h?0:2),l=e.toFixed(h?0:2)}else"tier-price"===r&&(i=n.original.toFixed(h?0:2),l=n.discounted.toFixed(h?0:2));return e.createElement(e.Fragment,null,e.createElement(id,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(l),"unit-price"===r?"/unit":""),o>0&&e.createElement(ad,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(i),"unit-price"===r?"/unit":""))})()):e.createElement("div",{style:{textAlign:"center",color:"#999",fontSize:"14px",fontWeight:"500",padding:"4px 0",lineHeight:"normal"}},"Out of Stock")),r&&!t.imageUrl&&e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},e.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:ie,color:le,padding:"2px"}},e.createElement(_e,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))})):e.createElement(e.Fragment,null,E.map(t=>{const n=Z(t.tier),o=n.original-n.discounted,r=!W(t.tier);return e.createElement(e.Fragment,{key:t.tier},t.badgeTitle&&e.createElement(Xc,{primaryTextColorCta:le,primaryBackgroundColorCta:ie,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":t.tier,"data-badge-title":t.badgeTitle},t.badgeTitle),e.createElement(Zc,{cornerRadiusType:a?.cornerRadiusType??"",key:t.tier,primaryBackgroundColorCta:ie??"",isSelected:T===t.tier,onClick:()=>S(t.tier),style:{borderRadius:de,cursor:"pointer",backgroundColor:r?"#f5f5f5":"white",opacity:r?.6:1},className:"yt-volume-horizontal-tier-container "+(T===t.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType,"data-minimum-quantity":t.minimumQuantity,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2)},e.createElement(Kc,{cornerRadiusType:a?.cornerRadiusType??"",style:{borderRadius:de,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},e.createElement(Jc,{className:"yt-volume-horizontal-tier-info"},e.createElement(pd,{"data-active":T===t.tier,accentColor:ie,className:"yt-volume-horizontal-tier-radio-wrapper"},e.createElement(ud,{name:"tier",checked:T===t.tier,onChange:()=>!r&&S(t.tier),disabled:r,className:"yt-volume-horizontal-tier-radio-hidden"}),e.createElement(md,{accentColor:ie,className:"yt-volume-horizontal-tier-radio-custom"})),e.createElement(td,{className:"yt-volume-horizontal-tier-details"},e.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},e.createElement(nd,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},t.title?t.title:e.createElement(e.Fragment,null,"Buy ",t.minimumQuantity,", Get"," ",t.discountValue,"% Off")),"Enabled"===b.volumeBundle?.discountBadgeVisibility&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let r="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(r="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(r="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(r="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return r?e.createElement(ed,{primaryBackgroundColorCta:ie,isSelected:T===t.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},r):null})()),e.createElement(od,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},t.subtitle?t.subtitle:e.createElement(e.Fragment,null)))),W(t.tier)?e.createElement(rd,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":t.tier,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),"data-savings":o.toFixed(0)},(()=>{const r=b?.volumeBundle?.tierPriceType||"tier-price";if("none"===r)return;let i="",l="";if("unit-price"===r){const e=n.discounted/t.minimumQuantity;i=(n.original/t.minimumQuantity).toFixed(h?0:2),l=e.toFixed(h?0:2)}else"tier-price"===r&&(i=n.original.toFixed(h?0:2),l=n.discounted.toFixed(h?0:2));return e.createElement(e.Fragment,null,o>0?e.createElement(ad,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(i),"unit-price"===r?"/unit":""):"",e.createElement(id,{className:"yt-volume-horizontal-tier-discounted-price"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(l),"unit-price"===r?"/unit":""))})()):e.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"normal"}},e.createElement("span",{style:{color:"#999",fontSize:"14px",fontWeight:"500"}},"Out of Stock"))),T===t.tier&&e.createElement(ld,{className:"yt-volume-horizontal-tier-product-grid",style:{padding:p.productDetails.variants.edges.length>1||1===p.productDetails.variants.edges.length&&"Default Title"!==p.productDetails.variants.edges[0].node.title?"10px 15px":"0",gap:p.productDetails.variants.edges.length>1||1===p.productDetails.variants.edges.length&&"Default Title"!==p.productDetails.variants.edges[0].node.title?"10px":"0"}},Array.from({length:t.minimumQuantity}).map((n,o)=>{const i=t.tier-1,l=(F[i]||[])[o]||p.productDetails.options?.map(e=>e.values[0])||[],c=p?.productDetails?.options.some(e=>e.values.length>1)||1===p?.productDetails?.variants?.edges?.length&&"Default Title"!==p?.productDetails?.variants?.edges[0]?.node?.title;return e.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},c&&e.createElement(gd,{src:Bp(K(p,$,o,t.tier)),alt:p?.productDetails?.title||"Product",className:"yt-volume-horizontal-tier-product-image"}),("auto"===b?.volumeBundle?.variantSelectorType||"dropdown"===b?.volumeBundle?.variantSelectorType)&&e.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},p?.productDetails?.options?.map((n,c)=>{const d=n.values.filter(e=>p.productDetails.variants.edges.some(t=>t.node.title.split(" / ")[c]===e));if(0===d.length||1===d.length&&"Default Title"===d[0])return null;const s=R?.tier===t.tier&&R?.index===o&&R?.optionIndex===c,u=a?.variantOptions?.options?.find(e=>e.name===n.name);let m="";return"color"===u?.type&&(m=u?.values?.find(e=>e.name===l[c])?.value||""),e.createElement(bd,{key:c,ref:e=>{j.current[o]||(j.current[o]=[]),j.current[o][c]=e},style:{zIndex:s?1e3:"auto",display:"flex"},isActive:s},e.createElement(hd,{onClick:e=>{e.stopPropagation(),O(s?null:{tier:t.tier,index:o,optionIndex:c})},isActive:s,disabled:r},"color"===u?.type&&m&&e.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[c],e.createElement(Te,{style:{display:"block"}})),s&&e.createElement(vd,{style:{zIndex:1001}},d.map((n,a)=>{const d=[...l];d[c]=n;const s=!q(t.tier,o,l,c,n)||r;p.productDetails.variants.edges.find(({node:e})=>e.title===d.join(" / "));const m=e=>{if(e.preventDefault(),e.stopPropagation(),N(e=>{const t={...e},n=[...t[i]||[]];return n[o]=d,t[i]=n,t}),s){M({tier:T,index:o,optionIndex:c,value:n}),O(null);const e=d.join(" / "),r=p.productDetails.variants.edges.find(t=>t.node.title===e)?.node.id||$;return void U(t.tier,o,r)}const r=d.join(" / "),a=p.productDetails.variants.edges.find(e=>e.node.title===r)?.node.id||$;U(t.tier,o,a),O(null)},g=u?.values.find(e=>e.name===n);return"image"===u?.type&&g?.value?e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},e.createElement(fd,{src:g.value,alt:n}),n):"color"===u?.type&&g?.value?e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},e.createElement(yd,{style:{backgroundColor:g.value}}),n):e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},n)})))})),"swatches"===b?.volumeBundle?.variantSelectorType&&e.createElement(cd,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},p?.productDetails?.options.map((n,c)=>{const d=n.values.filter(e=>p.productDetails.variants.edges.some(t=>t.node.title.split(" / ")[c]===e));if(0===d.length||1===d.length&&"Default Title"===d[0])return null;const s=a.variantOptions?.options?.find(e=>e.name===n.name)||null;return e.createElement("div",{key:n.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},d.map(n=>{const a=l[c]===n,d=!q(t.tier,o,l,c,n)||r,u=s?.values.find(e=>e.name===n),m=e=>{if(e.preventDefault(),e.stopPropagation(),d)return;const r=[...l];r[c]=n,N(e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t});const a=r.join(" / "),s=p.productDetails.variants.edges.find(e=>e.node.title===a)?.node.id||$;U(t.tier,o,s)},g={opacity:d?.5:1,cursor:d?"not-allowed":"pointer"};return"color"===s?.type&&u?.value?e.createElement("button",{key:n,onClick:m,style:{...g,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:d},e.createElement("div",{style:{width:a?"24px":"20px",height:a?"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"}},e.createElement("span",null))):"image"===s?.type&&u?.value?e.createElement("button",{key:n,onClick:m,style:{...g,border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:a?"#F7F7F7":"transparent",padding:"0px",width:a?"20px":"18px",height:a?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:d},e.createElement("img",{src:u.value,alt:n,style:{width:a?"26px":"24px",height:a?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):e.createElement(dd,{key:n,isSelected:a,onClick:m,style:{...g,padding:"4px 8px",border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:a?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:d},n)})))})))})),L&&L.tier===t.tier&&e.createElement("div",{style:{color:ie,textAlign:"center",fontSize:"14px",fontStyle:"normal",fontWeight:"500",lineHeight:"110%",background:`${ie}1A`,padding:"12px",borderBottomLeftRadius:de,borderBottomRightRadius:de}},"There aren’t enough items in our stock for select option, please select smaller bundle.")))})),a?.showCta&&"shopify_atc_button"!==b.volumeBundle?.addtoCartMethod&&e.createElement("div",{style:{position:"relative"}},e.createElement(sd,{bgColor:Q(T)?b.general?.ctaBackgroundColor:"#ccc",textColor:Q(T)?b.general?.ctaTextColor:"#666",border:`1px solid ${Q(T)?b.general?.ctaBorderColor||"#121212":"#999"}`,shadow:b.general.ctaShadowType,padding:b.general?.ctaPadding,width:b.general?.ctaWidth,hoverProperties:{customizeHoverState:!!Q(T)&&b.general?.customizeHoverState,backgroundColor:b.general?.ctaHoverBackgroundColor,textColor:b.general?.ctaHoverTextColor},onClick:async()=>{if(Q(T))try{D(!0);const e=E.find(e=>e.tier===T);if(!e)return;const t={},n=I[e.tier]||{};for(let o=0;o<e.minimumQuantity;o++){const e=n[o]||$;t[e]?t[e].quantity+=1:t[e]={quantity:1}}d?.({eventNameCustom:"bundle_add_to_cart",eventTypeCustom:"clicks",data:{bundleId:a._id,bundleType:"volume-bundle",selectedProducts:p?[{id:p?.productId,title:p?.productDetails?.title}]:[],selectedVariants:Object.values(n)}});const o=Z(e.tier),r=Array.from({length:e.minimumQuantity},(e,t)=>n[t]||$);l&&await l(o.original,r)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{D(!1)}else console.error("Selected tier is out of stock")},borderRadius:b.general.ctaBorderRadius??"",disabled:P||!Q(T),className:"yt-volume-add-to-cart-button"},Q(T)?e.createElement(e.Fragment,null,P?e.createElement(nt,{color:"white",loading:P,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):e.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},e.createElement("span",null,b.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",e.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const t=Z(T);return e.createElement(e.Fragment,null,$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(t.discounted.toFixed(h?0:2))," ",t?.original!==t.discounted&&e.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(t?.original.toFixed(h?0:2))," "))})()))):e.createElement(e.Fragment,null,"Out of Stock"))))}const Ed=c.div`
|
|
3494
|
+
`,wd=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function Cd({bundle:a,addToCartFunction:l,currentProductId:c,dispatchAnalyticsEvent:d}){const s=o(()=>{if(c){const e="gid://shopify/Product/"+c,t=a.products?.some(t=>t.productId===e);return t?e:a.products?.[0]?.productId}return a.products?.[0]?.productId},[c,a.products]),p=o(()=>wd(s,a.products),[s,a.products]),u=r(null),m=r(null);r({}),document.querySelector("#ProductSelect-product-template"),document.querySelector('form[action="/cart/add"]');const[g,x]=t(0),[f,y]=t(""),b=a.customizations??{},h=!1===b?.general?.showDecimalsInBundlePricing,v=o(()=>p?.productDetails?.tracksInventory??!0,[p?.productDetails?.tracksInventory]),w=i(e=>{if(!v)return 1/0;if(!e)return 0;if(!e.inventoryItem?.tracked)return 1/0;let t=e.inventoryQuantity??0;return t>0?t:"continue"===e.inventoryPolicy?.toLowerCase()?1/0:0},[v]),C=(o(()=>p?.productDetails?.variants?.edges?.reduce((e,{node:t})=>w(t)>0?e+1:e,0),[p,w]),o(()=>wd(s,a.products)?.id,[s,a.products]));o(()=>C?wd(s,a.products):void 0,[s,a.products,C]),o(()=>a.products?.some(e=>e.productDetails?.options?.some(e=>e.values.length>1))||!1,[a.products]),b.volumeBundle;const E=o(()=>a?.volumeTiers||[],[a?.volumeTiers]),k=E.findIndex(e=>e.isDefault),[T,S]=t(-1!==k?E[k].tier:E?.[0]?.tier||1),[$,B]=t(p?.productDetails?.variants?.edges?.find(e=>w(e?.node)>0)?.node?.id||p?.productDetails?.variants?.edges?.[0]?.node?.id||""),[I,z]=t({}),[F,N]=t(E.reduce((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},()=>p?.productDetails?.options?.map(e=>e.values[0])||[]),e),{})||{}),[P,D]=t(!1),[A,_]=t(window.innerWidth<550),[R,O]=t(null),[L,M]=t(null);r([]);const j=r([]),V=r(T);n(()=>{d?.({eventNameCustom:"block_visibility",eventTypeCustom:"views",data:{bundleId:a._id,bundleType:"volume-bundle"}});const e=()=>{_(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),n(()=>{const e=e=>{R&&j.current[R.index]&&j.current[R.index][R.optionIndex]&&!j.current[R.index][R.optionIndex]?.contains(e.target)&&O(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[R]),i(e=>{const t=E.find(t=>t.tier===e);if(!t)return null;const n=t.minimumQuantity,o=p?.productDetails?.variants?.edges||[];for(const e of o){const t=e.node;if(w(t)>=n){const e=t.title.split(" / ");return Array(n).fill(e)}}const r=[],i={},a=[...o].sort((e,t)=>{const n=w(e.node),o=w(t.node);return n===1/0&&o===1/0?0:n===1/0?-1:o===1/0?1:o-n});for(let e=0;e<n&&r.length<n;e++){let e=!1;for(const t of a){const n=t.node,o=i[n.id]||0;if(w(n)>o&&n.availableForSale){const t=n.title.split(" / ");r.push(t),i[n.id]=o+1,e=!0;break}}if(!e)return null}return r.length===n?r:null},[p,E,w]);const W=i(e=>{const t=E.find(t=>t.tier===e);if(!t)return!1;const n=t.minimumQuantity,o=p?.productDetails?.variants?.edges||[];let r=0;for(const e of o){const t=w(e.node);if(t===1/0){r=1/0;break}r+=t}return r>=n},[E,p,w]);n(()=>{const e={},t=p?.productDetails?.variants?.edges?.find(e=>w(e?.node)>0)?.node?.id||p?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&E.forEach(n=>{e[n.tier]={};for(let o=0;o<n.minimumQuantity;o++)e[n.tier][o]=t}),z(e)},[p?.id,E?.map(e=>`${e.tier}-${e.minimumQuantity}`).join("|"),w]);const H=(e,t)=>e?.productDetails?.variants?.edges?.find(e=>e.node.id===t)?.node,q=i((e,t,n,o,r)=>{const i=E.find(t=>t.tier===e);if(!i)return!1;const a=i.minimumQuantity,l=[...n];l[o]=r;const c=l.join(" / "),d=p?.productDetails?.variants?.edges?.find(e=>e.node.title===c)?.node;if(!d||0===w(d))return!1;const s={},u=I[e]||{};for(let e=0;e<a;e++){let n;if(e===t)n=d.id;else{const t=u[e]||$,o=H(p,t);if(!o)return!1;n=o.id}s[n]=(s[n]||0)+1}for(const[e,t]of Object.entries(s)){const n=H(p,e),o=w(n);if(o!==1/0&&t>o)return!1}return!0},[E,p,F,F,I,$,w]),Q=i(e=>{const t=E.find(t=>t.tier===e);if(!t)return!1;const n=t.minimumQuantity,o=e-1,r={};for(let e=0;e<n;e++){const t=(F[o]?.[e]||p.productDetails.options.map(e=>e.values[0])).join(" / "),n=p?.productDetails?.variants?.edges?.find(e=>e.node.title===t);if(!n)return!1;const i=n.node.id;r[i]=(r[i]||0)+1}for(const[e,t]of Object.entries(r)){const n=H(p,e),o=w(n);if(o!==1/0&&t>o)return!1}return!0},[E,p,F,w]);n(()=>{x(e=>e+1)},[I]);const U=(e,t,n)=>{z(o=>({...o,[e]:{...o[e]||{},[t]:n}}))},Y=i(()=>p?.productDetails?.variants?.edges?.find(e=>w(e.node)>0)?.node||p?.productDetails?.variants?.edges?.[0]?.node,[p,w]),G=i(()=>new URLSearchParams(window.location.search).get("variant")||"",[]);n(()=>{V.current=T},[T]),n(()=>{L?(M(null),X()):X()},[T]),n(()=>{if(a){const e=Y();if(e)y(e.id),B(e.id);else{const e=p?.productDetails?.variants?.edges?.[0]?.node?.id||"";y(e),B(e)}}},[a,p,Y]);const X=()=>{const e=G();if(e){const t=p?.productDetails?.variants?.edges?.find(t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e));let n=t?.node;if(n)B(String(n.id)),x(e=>e+1);else{const e=Y();e&&(B(String(e.id)),n=e),x(e=>e+1)}if(n){0===w(n)?(M(null),setTimeout(()=>{M({tier:V.current,index:0,optionIndex:0,value:n.title})},0)):L&&M(null)}}};n(()=>{X();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,o=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(o.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",X),()=>{t=!1,window.removeEventListener("urlChange",X),window.history.pushState=n,window.history.replaceState=o}},[G,p?.id,Y,w]);const Z=e=>{const t=E.find(t=>t.tier===e);if(!t)return{original:0,discounted:0,discountedFromPrice:0,discountedFromCompare:0,diffAmountFromPrice:0,diffAmountFromCompare:0,diffPercentFromPrice:0,diffPercentFromCompare:0,discountValue:0};let n=0,o=0,r=0;const i=I[e]||{};for(let e=0;e<t.minimumQuantity;e++){const t=i[e]||$,a=H(p,t);if(!a)continue;const l=Number.parseFloat(a.price);n+=a.compareAtPrice?Number.parseFloat(a.compareAtPrice):l,o+=l,r+=l}if("percentOff"===a?.discountType){r*=1-t.discountValue/100}else"amountOff"===a?.discountType&&(r-=t.discountValue);const l=Math.max(0,r),c=o-l,d=n-l,s=o>0?c/o*100:0,u=n>0?d/n*100:0;return{original:n,discounted:l,discountedFromPrice:l,discountedFromCompare:l,diffAmountFromPrice:c,diffAmountFromCompare:d,diffPercentFromPrice:Math.round(s),diffPercentFromCompare:Math.round(u),discountValue:t.discountValue}},K=(e,t,n,o)=>{let r=H(e,t);if(o){const i=I[o]?.[n||0]||t;r=H(e,i)}return r?.image?.url?r.image.url:e.productDetails?.media?.edges[0]?.node?.preview?.image?.url||""};function J(e){if(e.startsWith("gid://")){const t=e.split("/");return t[t.length-1]}return e}n(()=>{const e=()=>{if(b.volumeBundle?.addtoCartMethod&&"shopify_atc_button"!==b.volumeBundle?.addtoCartMethod)return;const e=document.querySelector('form[action="/cart/add"]');if(!e)return;const t=e.querySelector(".sr-headless-checkout");t&&t?.setAttribute("style","display: none;");const n=document.querySelector("#Quantity-product-template")||document.querySelector('input[name="quantity"]')||document.querySelector('input[type="number"][min="1"]');let o=1;n&&n.value&&(o=parseInt(n.value,10)||1);const r=E.find(e=>e.tier===T);if(!r)return;e.querySelectorAll('.bundle-input-field, [name^="properties["], [name="id"], [name="quantity"], .t4s-quantity-wrapper').forEach(e=>e.remove());const i=r.minimumQuantity;let a={};const l=Math.max(i,o);if("vertical"===b.volumeBundle.cardStyle){const e=f||$;if(!e)return;a[e]=l}else if(o>i){const e=f||$;if(!e)return;a[e]=l}else{const e=I[r.tier]||{};for(let t=0;t<i;t++){let n=e[t];n||(n=$),n&&(a[n]=(a[n]||0)+1)}}const c=Z(r.tier),d=Object.fromEntries(Object.entries(a).map(([e,t])=>[J(e),Math.round(t)])),s=(t,n,o="bundle-input-field")=>{const r=document.createElement("input");r.type="hidden",r.name=t,r.value=n,r.className=o,e.appendChild(r)};if(o>i){const e=f||$;e&&s("id",J(e))}s("properties[_bundle_price]",String(c.original)),s("properties[_bundle_tier]",String(r.tier)),s("properties[_bundle_items]",JSON.stringify(d));let p=0;Object.entries(d).forEach(([e,t])=>{t>0&&(s(`items[${p}][id]`,e),s(`items[${p}][quantity]`,String(t)),p++)}),requestAnimationFrame(()=>{const t=e.querySelector('[type="submit"]'),n=e.querySelector(".noti-btn-main-wrap"),r=(e,t,n)=>{if(!e)return;e.disabled=t,e.classList.toggle("disabled",t);const o=e.querySelector("[data-add-to-cart-text]")||e.querySelector("span");o&&(o.textContent=n)};o<=i&&(L?(r(t,!0,"Sold out"),t&&t.classList.add("btn--sold-out","hidden"),n&&(n.style.display="block",n.classList.remove("hidden"),n.classList.add("block"))):(r(t,!1,"Add to cart"),t&&t.classList.remove("btn--sold-out","hidden"),n&&(n.style.display="none",n.classList.add("hidden"))))})};e();const t=document.querySelector("#Quantity-product-template")||document.querySelector('input[name="quantity"]')||document.querySelector('input[type="number"][min="1"]');if(t){const n=()=>{requestAnimationFrame(()=>{e()})};return t.addEventListener("input",n),t.addEventListener("change",n),()=>{t.removeEventListener("input",n),t.removeEventListener("change",n)}}return()=>{}},[T,JSON.stringify(I),$,b.volumeBundle?.cardStyle,c,f,L]);const ee=o(()=>E.find(e=>e.tier===T),[E,T]),te=o(()=>ee?Z(ee.tier):null,[ee,I,$]),ne=o(()=>{if(!ee||!te)return;const e=I[ee.tier]||{},t={};for(let n=0;n<ee.minimumQuantity;n++){const o=e[n]||$;t[o]=(t[o]||0)+1}return t},[ee?.minimumQuantity,$,I,te]),oe=o(()=>Object.entries(ne??{}).map(([e,t])=>({variantId:e,quantity:t})),[ne]);if(n(()=>{if(!ee||!te)return;const e={tier:T,items:ee.minimumQuantity,discountedPrice:te.discounted,originalPrice:te.original,variants:oe,productId:p?.id??null,tierMeta:{title:ee.title,subtitle:ee.subtitle,badgeTitle:ee.badgeTitle},productData:p,tierData:ee},t=m.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(u.current&&clearTimeout(u.current),u.current=window.setTimeout(()=>{m.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t),l&&(window.ytVolumeBundle={bundle:a,addToCart:l,currentTier:ee,selectedVariants:oe},window.dispatchEvent(new CustomEvent("yt-volume-bundle-updated",{detail:{...e,addToCart:l}})))},50),()=>{u.current&&clearTimeout(u.current)})},[T,ee?.tier,ee?.minimumQuantity,te?.discounted,te?.original,p?.id,JSON.stringify(oe),l,a]),n(()=>()=>{window.ytVolumeBundle=void 0,window.dispatchEvent(new CustomEvent("yt-volume-bundle-updated",{detail:void 0}))},[]),n(()=>{if(!$||!p)return;const e=H(p,$);if(!e)return;const t=e.title.split(" / "),n={},o={};E.forEach(e=>{const r=e.tier-1,i={};for(let t=0;t<e.minimumQuantity;t++)i[t]=$;n[e.tier]=i,o[r]=Array(e.minimumQuantity).fill(t)}),z(e=>({...e,...n})),N(e=>({...e,...o}))},[$,p?.id,E.length]),!l)return e.createElement(e.Fragment,null);const re=b.volumeBundle?.cardStyle,ie=b.general?.primaryColor,ae=b.general?.secondaryColor,le=b.general.primaryContrastColor,ce=b.general.secondaryContrastColor,de="high"===a.cornerRadiusType?"20px":"medium"===a.cornerRadiusType?"6px":"0px",se="bundles"==a.appName?a.pageHeader?.title:a?.title,pe="bundles"==a.appName?a.pageHeader?.description:a?.subtitle;return n(()=>{const e=Q(T);e?M(null):e||M({tier:T,index:0,optionIndex:0,value:""})},[T,oe,Q]),e.createElement(Qc,{verticalMargin:b.volumeBundle?.verticalMargin,$backgroundColor:b.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},e.createElement(Uc,{className:"yt-bundle-header"},se&&se.trim().length>0&&e.createElement(Yc,{fontSize:b.volumeBundle?.titleFontSize,$backgroundColor:b.volumeBundle?.titleBackgroundColor,textColor:b.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},se),e.createElement(Gc,{className:"yt-bundle-header-subtitle",fontSize:b.volumeBundle?.subtitleFontSize},pe)),"vertical"===re?e.createElement("div",{style:{display:"grid",gridTemplateColumns:A||4===E.length?"repeat(2, 1fr)":E.length>4?"repeat(3, 1fr)":`repeat(${E.length}, 1fr)`,justifyItems:"center",gap:A?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},E.map(t=>{const n=Z(t.tier),o=n.original-n.discounted,r=T===t.tier,i=!W(t.tier);return e.createElement(e.Fragment,{key:t.tier},e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:de||"24px",...r?{border:`2px solid ${ie}`}:{border:`1px solid ${ae}`},boxShadow:`6px 6px 0px -1px ${r?ie:ae}20`,...t.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 "+(r?"yt-volume-vertical-tier-item-active":""),"data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType,"data-minimum-quantity":t.minimumQuantity,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),onClick:()=>!i&&S(t.tier)},t.badgeTitle&&e.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:r?ie:ae,color:r?le:ce,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:r?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":t.tier,"data-badge-title":t.badgeTitle},t.badgeTitle),e.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},"Enabled"===b.volumeBundle?.discountBadgeVisibility&&A&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let i="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(i="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(i="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(i="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return i?e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},e.createElement(ed,{primaryBackgroundColorCta:r?ie:ae,isSelected:r,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:r?le:ce},className:"yt-volume-vertical-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},i)):null})(),t.imageUrl&&e.createElement("img",{src:Bp(t.imageUrl),style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:de||"24px",borderTopRightRadius:de||"24px"},className:"yt-volume-vertical-tier-badge"})),e.createElement("div",{style:{padding:"8px",paddingTop:"0"}},e.createElement(td,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},e.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},e.createElement(nd,{style:{fontSize:A?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},t.title?t.title:e.createElement(e.Fragment,null,"Buy ",t.minimumQuantity,", Get"," ",t.discountValue,"% Off")),"Enabled"===b.volumeBundle?.discountBadgeVisibility&&!A&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let i="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(i="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(i="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(i="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return i?e.createElement(ed,{primaryBackgroundColorCta:r?ie:ae,isSelected:r,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:r?le:ce},className:"yt-volume-vertical-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},i):null})(),r&&t.imageUrl&&e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},e.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:ie,color:le,padding:"2px"}},e.createElement(_e,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),e.createElement(od,{style:{lineHeight:"normal",fontSize:A?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},t.subtitle?t.subtitle:e.createElement(e.Fragment,null))),W(t.tier)?e.createElement(rd,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":t.tier,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),"data-savings":o.toFixed(h?0:2)},(()=>{const r=b?.volumeBundle?.tierPriceType||"tier-price";if("none"===r)return;let i="",l="";if("unit-price"===r){const e=n.discounted/t.minimumQuantity;i=(n.original/t.minimumQuantity).toFixed(h?0:2),l=e.toFixed(h?0:2)}else"tier-price"===r&&(i=n.original.toFixed(h?0:2),l=n.discounted.toFixed(h?0:2));return e.createElement(e.Fragment,null,e.createElement(id,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(l),"unit-price"===r?"/unit":""),o>0&&e.createElement(ad,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(i),"unit-price"===r?"/unit":""))})()):e.createElement("div",{style:{textAlign:"center",color:"#999",fontSize:"14px",fontWeight:"500",padding:"4px 0",lineHeight:"normal"}},"Out of Stock")),r&&!t.imageUrl&&e.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},e.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:ie,color:le,padding:"2px"}},e.createElement(_e,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))})):e.createElement(e.Fragment,null,E.map(t=>{const n=Z(t.tier),o=n.original-n.discounted,r=!W(t.tier);return e.createElement(e.Fragment,{key:t.tier},t.badgeTitle&&e.createElement(Xc,{primaryTextColorCta:le,primaryBackgroundColorCta:ie,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":t.tier,"data-badge-title":t.badgeTitle},t.badgeTitle),e.createElement(Zc,{cornerRadiusType:a?.cornerRadiusType??"",key:t.tier,primaryBackgroundColorCta:ie??"",isSelected:T===t.tier,onClick:()=>S(t.tier),style:{borderRadius:de,cursor:"pointer",backgroundColor:r?"#f5f5f5":"white",opacity:r?.6:1},className:"yt-volume-horizontal-tier-container "+(T===t.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType,"data-minimum-quantity":t.minimumQuantity,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2)},e.createElement(Kc,{cornerRadiusType:a?.cornerRadiusType??"",style:{borderRadius:de,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},e.createElement(Jc,{className:"yt-volume-horizontal-tier-info"},e.createElement(pd,{"data-active":T===t.tier,accentColor:ie,className:"yt-volume-horizontal-tier-radio-wrapper"},e.createElement(ud,{name:"tier",checked:T===t.tier,onChange:()=>!r&&S(t.tier),disabled:r,className:"yt-volume-horizontal-tier-radio-hidden"}),e.createElement(md,{accentColor:ie,className:"yt-volume-horizontal-tier-radio-custom"})),e.createElement(td,{className:"yt-volume-horizontal-tier-details"},e.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},e.createElement(nd,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},t.title?t.title:e.createElement(e.Fragment,null,"Buy ",t.minimumQuantity,", Get"," ",t.discountValue,"% Off")),"Enabled"===b.volumeBundle?.discountBadgeVisibility&&(()=>{if(!((n?.diffAmountFromPrice>0||n?.diffAmountFromCompare>0)&&(n?.diffPercentFromPrice>0||n?.diffPercentFromCompare>0)))return null;const o=$p(b.general.currencySymbol,a.storeCurrencyCode);let r="";if(b?.volumeBundle?.discountBadgeDisplay&&b?.volumeBundle?.discountDisplayType){const{discountBadgeDisplay:e,discountDisplayType:t}=b.volumeBundle;"discount-on-compare"===e&&(r="percentage"===t?n.diffPercentFromCompare>0?`${Math.round(n.diffPercentFromCompare)}% Off`:"":n.diffAmountFromCompare>0?`Save ${o}${Sp(n.diffAmountFromCompare)}`:""),"discount-on-price"===e&&(r="percentage"===t?n.diffPercentFromPrice>0?`${Math.round(n.diffPercentFromPrice)}% Off`:"":n.diffAmountFromPrice>0?`Save ${o}${Sp(n.diffAmountFromPrice)}`:"")}else n?.discountValue>0&&(r="percentOff"===a?.discountType?`${n.discountValue}% Off`:`Save ${o}${Sp(n.discountValue)}`);return r?e.createElement(ed,{primaryBackgroundColorCta:ie,isSelected:T===t.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":t.tier,"data-discount-value":n.discountValue,"data-discount-type":a?.discountType},r):null})()),e.createElement(od,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},t.subtitle?t.subtitle:e.createElement(e.Fragment,null)))),W(t.tier)?e.createElement(rd,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":t.tier,"data-original-price":n.original.toFixed(h?0:2),"data-discounted-price":n.discounted.toFixed(h?0:2),"data-savings":o.toFixed(0)},(()=>{const r=b?.volumeBundle?.tierPriceType||"tier-price";if("none"===r)return;let i="",l="";if("unit-price"===r){const e=n.discounted/t.minimumQuantity;i=(n.original/t.minimumQuantity).toFixed(h?0:2),l=e.toFixed(h?0:2)}else"tier-price"===r&&(i=n.original.toFixed(h?0:2),l=n.discounted.toFixed(h?0:2));return e.createElement(e.Fragment,null,o>0?e.createElement(ad,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(i),"unit-price"===r?"/unit":""):"",e.createElement(id,{className:"yt-volume-horizontal-tier-discounted-price"},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(l),"unit-price"===r?"/unit":""))})()):e.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"normal"}},e.createElement("span",{style:{color:"#999",fontSize:"14px",fontWeight:"500"}},"Out of Stock"))),T===t.tier&&e.createElement(ld,{className:"yt-volume-horizontal-tier-product-grid",style:{padding:p.productDetails.variants.edges.length>1||1===p.productDetails.variants.edges.length&&"Default Title"!==p.productDetails.variants.edges[0].node.title?"10px 15px":"0",gap:p.productDetails.variants.edges.length>1||1===p.productDetails.variants.edges.length&&"Default Title"!==p.productDetails.variants.edges[0].node.title?"10px":"0"}},Array.from({length:t.minimumQuantity}).map((n,o)=>{const i=t.tier-1,l=(F[i]||[])[o]||p.productDetails.options?.map(e=>e.values[0])||[],c=p?.productDetails?.options.some(e=>e.values.length>1)||1===p?.productDetails?.variants?.edges?.length&&"Default Title"!==p?.productDetails?.variants?.edges[0]?.node?.title;return e.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},c&&e.createElement(gd,{src:Bp(K(p,$,o,t.tier)),alt:p?.productDetails?.title||"Product",style:{height:"64px",width:"auto"},className:"yt-volume-horizontal-tier-product-image"}),("auto"===b?.volumeBundle?.variantSelectorType||"dropdown"===b?.volumeBundle?.variantSelectorType)&&e.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},p?.productDetails?.options?.map((n,c)=>{const d=n.values.filter(e=>p.productDetails.variants.edges.some(t=>t.node.title.split(" / ")[c]===e));if(0===d.length||1===d.length&&"Default Title"===d[0])return null;const s=R?.tier===t.tier&&R?.index===o&&R?.optionIndex===c,u=a?.variantOptions?.options?.find(e=>e.name===n.name);let m="";return"color"===u?.type&&(m=u?.values?.find(e=>e.name===l[c])?.value||""),e.createElement(bd,{key:c,ref:e=>{j.current[o]||(j.current[o]=[]),j.current[o][c]=e},style:{zIndex:s?1e3:"auto",display:"flex"},isActive:s},e.createElement(hd,{onClick:e=>{e.stopPropagation(),O(s?null:{tier:t.tier,index:o,optionIndex:c})},isActive:s,disabled:r},"color"===u?.type&&m&&e.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[c],e.createElement(Te,{style:{display:"block"}})),s&&e.createElement(vd,{style:{zIndex:1001}},d.map((n,a)=>{const d=[...l];d[c]=n;const s=!q(t.tier,o,l,c,n)||r;p.productDetails.variants.edges.find(({node:e})=>e.title===d.join(" / "));const m=e=>{if(e.preventDefault(),e.stopPropagation(),N(e=>{const t={...e},n=[...t[i]||[]];return n[o]=d,t[i]=n,t}),s){M({tier:T,index:o,optionIndex:c,value:n}),O(null);const e=d.join(" / "),r=p.productDetails.variants.edges.find(t=>t.node.title===e)?.node.id||$;return void U(t.tier,o,r)}const r=d.join(" / "),a=p.productDetails.variants.edges.find(e=>e.node.title===r)?.node.id||$;U(t.tier,o,a),O(null)},g=u?.values.find(e=>e.name===n);return"image"===u?.type&&g?.value?e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},e.createElement(fd,{src:g.value,alt:n}),n):"color"===u?.type&&g?.value?e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},e.createElement(yd,{style:{backgroundColor:g.value}}),n):e.createElement(xd,{key:n,onClick:m,style:{cursor:"pointer"}},n)})))})),"swatches"===b?.volumeBundle?.variantSelectorType&&e.createElement(cd,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},p?.productDetails?.options.map((n,c)=>{const d=n.values.filter(e=>p.productDetails.variants.edges.some(t=>t.node.title.split(" / ")[c]===e));if(0===d.length||1===d.length&&"Default Title"===d[0])return null;const s=a.variantOptions?.options?.find(e=>e.name===n.name)||null;return e.createElement("div",{key:n.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},d.map(n=>{const a=l[c]===n,d=!q(t.tier,o,l,c,n)||r,u=s?.values.find(e=>e.name===n),m=e=>{if(e.preventDefault(),e.stopPropagation(),d)return;const r=[...l];r[c]=n,N(e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t});const a=r.join(" / "),s=p.productDetails.variants.edges.find(e=>e.node.title===a)?.node.id||$;U(t.tier,o,s)},g={opacity:d?.5:1,cursor:d?"not-allowed":"pointer"};return"color"===s?.type&&u?.value?e.createElement("button",{key:n,onClick:m,style:{...g,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:d},e.createElement("div",{style:{width:a?"24px":"20px",height:a?"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"}},e.createElement("span",null))):"image"===s?.type&&u?.value?e.createElement("button",{key:n,onClick:m,style:{...g,border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:a?"#F7F7F7":"transparent",padding:"0px",width:a?"20px":"18px",height:a?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:d},e.createElement("img",{src:u.value,alt:n,style:{width:a?"26px":"24px",height:a?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):e.createElement(dd,{key:n,isSelected:a,onClick:m,style:{...g,padding:"4px 8px",border:a?`1px solid ${b.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:a?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:d},n)})))})))})),L&&L.tier===t.tier&&e.createElement("div",{style:{color:ie,textAlign:"center",fontSize:"14px",fontStyle:"normal",fontWeight:"500",lineHeight:"110%",background:`${ie}1A`,padding:"12px",borderBottomLeftRadius:de,borderBottomRightRadius:de}},"There aren’t enough items in our stock for select option, please select smaller bundle.")))})),a?.showCta&&"shopify_atc_button"!==b.volumeBundle?.addtoCartMethod&&e.createElement("div",{style:{position:"relative"}},e.createElement(sd,{bgColor:Q(T)?b.general?.ctaBackgroundColor:"#ccc",textColor:Q(T)?b.general?.ctaTextColor:"#666",border:`1px solid ${Q(T)?b.general?.ctaBorderColor||"#121212":"#999"}`,shadow:b.general.ctaShadowType,padding:b.general?.ctaPadding,width:b.general?.ctaWidth,hoverProperties:{customizeHoverState:!!Q(T)&&b.general?.customizeHoverState,backgroundColor:b.general?.ctaHoverBackgroundColor,textColor:b.general?.ctaHoverTextColor},onClick:async()=>{if(Q(T))try{D(!0);const e=E.find(e=>e.tier===T);if(!e)return;const t={},n=I[e.tier]||{};for(let o=0;o<e.minimumQuantity;o++){const e=n[o]||$;t[e]?t[e].quantity+=1:t[e]={quantity:1}}d?.({eventNameCustom:"bundle_add_to_cart",eventTypeCustom:"clicks",data:{bundleId:a._id,bundleType:"volume-bundle",selectedProducts:p?[{id:p?.productId,title:p?.productDetails?.title}]:[],selectedVariants:Object.values(n)}});const o=Z(e.tier),r=Array.from({length:e.minimumQuantity},(e,t)=>n[t]||$);l&&await l(o.original,r)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{D(!1)}else console.error("Selected tier is out of stock")},borderRadius:b.general.ctaBorderRadius??"",disabled:P||!Q(T),className:"yt-volume-add-to-cart-button"},Q(T)?e.createElement(e.Fragment,null,P?e.createElement(nt,{color:"white",loading:P,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):e.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},e.createElement("span",null,b.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",e.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const t=Z(T);return e.createElement(e.Fragment,null,$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(t.discounted.toFixed(h?0:2))," ",t?.original!==t.discounted&&e.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},$p(b.general.currencySymbol,a.storeCurrencyCode),Sp(t?.original.toFixed(h?0:2))," "))})()))):e.createElement(e.Fragment,null,"Out of Stock"))))}const Ed=c.div`
|
|
3495
3495
|
container-type: inline-size;
|
|
3496
3496
|
border-radius: ${e=>e.borderRadius?e.borderRadius:"8px"};
|
|
3497
3497
|
max-width: 800px;
|