1if(!customElements.get("main-product-page")){class MainProductPage extends HTMLElement{connectedCallback(){try{const dataEl=this.querySelector("[data-pdp-variants]");this.variants=dataEl?JSON.parse(dataEl.textContent):{}}catch{this.variants={}}this.idInput=this.querySelector("[data-pdp-id]"),this.qtyInput=this.querySelector(".pdp__qty-input"),this.atc=this.querySelector(".pdp__atc"),this.priceEl=this.querySelector("[data-pdp-price]"),this.compareEl=this.querySelector("[data-pdp-compare]"),this.offPill=this.querySelector("[data-pdp-off]"),this.offNum=this.querySelector("[data-pdp-off-num]"),this.bindGallery(),this.bindZoom(),this.bindSizes(),this.bindPills(),this.bindRating(),this.bindQuantity(),this.bindPurchaseOptions(),this.bindZip(),this.bindWishlist(),this.bindBundle()}bindGallery(){const slider=this.querySelector("[data-pdp-slides]");if(!slider)return;const slides=Array.from(slider.children);if(slides.length<2)return;const thumbs=this.querySelectorAll("[data-pdp-thumb]"),dots=this.querySelectorAll("[data-pdp-dot]"),goTo=(index,smooth)=>{const slide=slides[index];slide&&slider.scrollTo({left:slide.offsetLeft,behavior:smooth===!1?"auto":"smooth"})};thumbs.forEach((thumb,i)=>thumb.addEventListener("click",()=>goTo(i))),dots.forEach((dot,i)=>dot.addEventListener("click",()=>goTo(i)));const sync=()=>{const index=Math.round(slider.scrollLeft/Math.max(1,slider.clientWidth));thumbs.forEach((t,i)=>t.classList.toggle("is-active",i===index)),dots.forEach((d,i)=>d.classList.toggle("is-active",i===index))};slider.addEventListener("scroll",()=>{clearTimeout(this._galleryTimer),this._galleryTimer=setTimeout(sync,80)});const start=parseInt(slider.dataset.pdpStart,10)||0;start>0&&goTo(start,!1),this.showMedia=mediaId=>{if(!mediaId)return;const index=slides.findIndex(s=>String(s.dataset.mediaId)===String(mediaId));index>=0&&goTo(index)}}bindZoom(){const media=this.querySelector("[data-pdp-zoom]");if(!media||!window.matchMedia("(hover: hover) and (pointer: fine)").matches)return;const LEVELS={medium:1.6,large:2.2},setting=media.dataset.pdpZoom||"medium";media.classList.add("pdp__main-media--zoom"),media.querySelectorAll(".pdp__slide").forEach(sli
1de=>{const img=slide.querySelector("img");if(!img)return;let zoomed=!1;const zoomLevel=rect=>setting==="original"&&img.naturalWidth?Math.min(4,Math.max(1.5,img.naturalWidth/rect.width)):LEVELS[setting]||LEVELS.medium,setOrigin=e=>{const rect=slide.getBoundingClientRect(),x=(e.clientX-rect.left)/rect.width*100,y=(e.clientY-rect.top)/rect.height*100;img.style.transformOrigin=x+"% "+y+"%"},reset=()=>{zoomed&&(zoomed=!1,slide.classList.remove("is-zoomed"),img.style.transform="",img.style.transformOrigin="")};slide.addEventListener("click",e=>{if(zoomed){reset();return}zoomed=!0,slide.classList.add("is-zoomed"),img.sizes="100vw",setOrigin(e);const rect=slide.getBoundingClientRect();img.style.transform="scale("+zoomLevel(rect)+")"}),slide.addEventListener("mousemove",e=>{zoomed&&setOrigin(e)}),slide.addEventListener("mouseleave",reset)})}bindRating(){const ratings=this.querySelectorAll("[data-pdp-rating]");if(!ratings.length)return;const target=document.querySelector(".jdgm-rev-widg, .jdgm-review-widget, .jdgm-widget");target&&ratings.forEach(rating=>{rating.classList.add("is-link"),rating.addEventListener("click",()=>{target.scrollIntoView({behavior:"smooth",block:"start"})})})}bindPills(){const wrap=this.querySelector(".pdp__pills");if(!wrap||wrap.children.length<3)return;const pills=Array.from(wrap.children),btn=document.createElement("button");btn.type="button",btn.className="pdp__pills-toggle",wrap.appendChild(btn);const rowCount=()=>{const base=wrap.getBoundingClientRect().top,tops=[];return Array.from(wrap.children).forEach(el=>{if(el.hidden||el.style.display==="none")return;const t=Math.round(el.getBoundingClientRect().top-base);tops.indexOf(t)===-1&&tops.push(t)}),tops.length};let expanded=!1;const apply=()=>{if(pills.forEach(pill=>{pill.style.display=""}),btn.hidden=!0,rowCount()<=2)return;if(btn.hidden=!1,expanded){btn.textContent="Show less";return}btn.textContent="+"+pills.length+" more";for(let i=pills.length-1;i>=0&&rowCount()>2;i--)pills[i].style.display="none";const hiddenCount=pills.filter(pill=>pill.style.display==="none").length;btn.textContent="+"+hiddenCount+" more"};btn.addEventListener("click",()=>{expanded=!expanded,apply()}),window.addEventListener("resize",()=>{clearTimeout(this._pillsTimer),this._pillsTimer=setTimeout(apply,150)}),window.addEventListener("load",apply,{once:!0}),apply()}bindSizes(){const sizes=this.querySelectorAll("[data-pdp-size]");
1sizes.forEach(card=>{card.addEventListener("click",()=>{card.classList.contains("is-active")||(sizes.forEach(c=>{const active=c===card;c.classList.toggle("is-active",active),c.setAttribute("aria-checked",active?"true":"false")}),this.setVariant(card.dataset.variantId))})})}setVariant(variantId){const v=this.variants[variantId];if(!v)return;this.idInput&&(this.idInput.value=variantId,this.idInput.dispatchEvent(new Event("change",{bubbles:!0}))),this.showMedia&&v.mediaId&&this.showMedia(v.mediaId),this.priceEl&&(this.priceEl.textContent=v.price),this.compareEl&&(v.compare?(this.compareEl.textContent=v.compare,this.compareEl.hidden=!1):this.compareEl.hidden=!0),this.offPill&&(v.savePercent>0?(this.offNum&&(this.offNum.textContent=v.savePercent),this.offPill.hidden=!1):this.offPill.hidden=!0);const onetime=this.querySelector("[data-pdp-onetime-price]");onetime&&(onetime.textContent=v.price);const subs=this.querySelector("[data-pdp-subs-price]");subs&&v.subsPrice&&(subs.textContent=v.subsPrice);const badge=this.querySelector("[data-pdp-subs-badge]");badge&&!badge.dataset.customText&&v.subsPercent>0&&(badge.textContent="SAVE "+v.subsPercent+"%",badge.hidden=!1),this.atc&&(this.atc.toggleAttribute("disabled",!v.available),v.available?(this.atc.removeAttribute("aria-disabled"),this.atc.textContent=this.atc.dataset.addToCartText||"Add to Cart"):(this.atc.setAttribute("aria-disabled","true"),this.atc.textContent="Sold out"));try{const url=new URL(window.location.href);url.searchParams.set("variant",variantId),window.history.replaceState({},"",url.toString())}catch{}this.updateBundleTotals()}bindQuantity(){if(!this.qtyInput)return;const min=parseInt(this.qtyInput.min,10)||1;this.querySelectorAll("[data-pdp-step]").forEach(btn=>{btn.addEventListener("click",()=>{const step=btn.dataset.pdpStep==="down"?-1:1,current=parseInt(this.qtyInput.value,10)||min;this.qtyInput.value=Math.max(min,current+step),this.qtyInput.dispatchEvent(new Event("change",{bubbles:!0}))})}),this.qtyInput.addEventListener("change",()=>{const val=parseInt(this.qtyInput.value,10);(Number.isNaN(val)||val<min)&&(this.qtyInput.value=min),this.updateBundleTotals()})}bindPurchaseOptions(){const wrap=this.querySelector("[data-pdp-purchase]");if(!wrap)return;const rows=wrap.querySelectorAll(".pdp__purchase-row"),freq=wrap.querySelector("[data-pdp-freq]"),planSelect=wrap.querySelector("[data-pdp-plan-select]"),badge=wrap.querySelector("[data-pdp-subs-badge]");badge&&badge.textContent.trim()&&!/^SAVE \d+%$/.test(badge.textContent.trim())&&(badge.dataset.customText="true");const neutralizeForeignPlanFields=()=>{!planSelect||!planSelect.form||Array.from(planSelect.form.elements).forEach(el=>{el.name==="selling_plan"&&el!==planSelect&&(el.disabled=!0)})};wrap.querySelectorAll(".pdp__purchase-radio").forEach(radio=>{radio.addEventListener("change",()=>{const subscribe=radio.value==="subscribe"&&radio.checked;rows.forEach(row=>{row.classList.toggle("is-active",row.dataset.purchase===(subscribe?"subscribe":"onetime"))}),freq&&(freq.hidden=!subscribe),planSelect&&(planSelect.disabled=!subscribe),neutralizeForeignPlanFields()})}),planSelect?.addEventListener("change",()=>{planSelect.classList.remove("is-error")});const atc=this.querySelector(".pdp__atc");atc&&planSelect&&atc.addEventListener("click",e=>{neutralizeForeignPlanFields(),!planSelect.disabled&&!planSelect.value&&(e.preventDefault(),freq&&(freq.hidden=!1),planSelect.classList.add("is-error"),planSelect.focus())}),window.addEventListener("load",neutralizeForeignPlanFields,{once:!0}),setTimeout(neutralizeForeignPlanFields,2500)}bindZip(){const zip=this.querySelector("[data-pdp-zip]");if(!zip)return;const input=zip.querySelector("[data-pdp-zip-input]"),check=zip.querySelector("[data-pdp-zip-check]"),row=zip.querySelector("[data-pdp-zip-row]"),hint=zip.querySelector("[data-pdp-zip-hint]"),error=zip.querySelector("[data-pdp-zip-error]"),orderLine=zip.querySelector("[data-pdp-zip-order]"),locationBtn=zip.querySelector("[data-pdp-zip-location]"),locationText=zip.querySelector("[data-pdp-zip-location-text]"),cutoff=zip.dataset.cutoff||"12:00",maxDays=parseInt(zip.dataset.maxdays,10)||1,showForm=open=>{row&&(row.hidden=!open),locationBtn&&locationBtn.classList.toggle("is-open",open),zip.classList.toggle("is-editing",open),open&&input&&input.focus()},stateTransitDays={NJ:2,NY:2,CT:3,PA:3,DE:3,MD:3,VA:3,WV:3,OH:3,DC:3,MA:3,RI:3,NH:3,VT:3,ME:4,MI:4,IN:4,KY:4,TN:4,NC:4,SC:4,GA:4,FL:4,AL:4,MS:4,LA:4,AR:4,MO:4,IL:4,WI:4,MN:4,IA:4,ND:5,SD:5,NE:5,KS:5,OK:5,CO:5,NM:5,AZ:5,UT:5,NV:5,TX:5,CA:6,OR:6,WA:6,ID:6,MT:6,WY:6,AK:8,HI:8},renderOrderWithin=()=>{const now=new Date,dow=now.getDay();if(dow===0||dow===6){orderLine.innerHTML="Ships <strong>Monday</strong>";return}const parts=cutoff.split(":").map(Number);let c=new Date(now);c.setHours(parts[0]||12,parts[1]||0,0,0),now>=c&&c.setDate(c.getDate()+1);const mins=Math.floor((c-now)/6e4),h=Math.floor(mins/60),m=mins%60;orderLine.innerHTML="Order within <strong>"+h+" hrs "+m+" mins.</strong>"},getShipDate=()=>{const now=new Date,parts=cutoff.split(":").map(Number),ship=new Date(now);for((now.getHours()>parts[0]||now.getHours()===parts[0]&&now.getMinutes()>
1=(parts[1]||0))&&ship.setDate(ship.getDate()+1);ship.getDay()===0||ship.getDay()===6;)ship.setDate(ship.getDate()+1);return ship},addBusinessDays=(date,days)=>{const result=new Date(date);let added=0;for(;added<days;)result.setDate(result.getDate()+1),result.getDay()!==0&&result.getDay()!==6&&added++;return result},estimate=async val=>{error.hidden=!0;let state="",city="";try{const res=await fetch("https://api.zippopotam.us/us/"+val);if(res.ok){const data=await res.json();data&&data.places&&data.places.length&&(city=data.places[0]["place name"],state=data.places[0]["state abbreviation"])}}catch{}const transit=stateTransitDays[state]||maxDays,deliverDate=addBusinessDays(getShipDate(),transit),oneDay=1440*60*1e3,now=new Date;let text;deliverDate-now>=oneDay&&deliverDate-now<2*oneDay?text="Tomorrow":text=deliverDate.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),hint.innerHTML="Estimated delivery by <strong>"+text+"</strong>",locationText&&(locationText.textContent=(city?city+" - ":"")+val),locationBtn&&(locationBtn.hidden=!1)},submit=()=>{const val=(input.value||"").trim();if(/^[0-9]{5}$/.test(val)){try{localStorage.setItem("ed_zip",val)}catch{}estimate(val),showForm(!1)}else error.textContent="Please enter a valid ZIP code.",error.hidden=!1,input.focus()};check.addEventListener("click",submit),input.addEventListener("keydown",e=>{e.key==="Enter"&&(e.preventDefault(),submit())}),locationBtn&&locationBtn.addEventListener("click",()=>showForm(row?row.hidden:!0)),renderOrderWithin(),this._zipTimer=setInterval(renderOrderWithin,6e4);const toZip5=v=>{const m=/^\s*([0-9]{5})(?:-[0-9]{4})?\s*$/.exec(String(v||""));return m?m[1]:""},apply=(val,persist)=>{if(persist)try{localStorage.setItem("ed_zip",val)}catch{}input.value=val,estimate(val),showForm(!1)};let saved="";try{saved=localStorage.getItem("ed_zip")||""}catch{}saved=toZip5(saved);const customerZip=toZip5(zip.dataset.customerZip);if(saved)apply(saved,!1);else if(customerZip)apply(customerZip,!0);else{const providers=[{url:"https://ipapi.co/json/",pick:d=>d&&d.country_code==="US"&&d.postal},{url:"https://ipwho.is/",pick:d=>d&&d.success!==!1&&d.country_code==="US"&&d.postal}],tryProvider=i=>{if(i>=providers.length||input.value.trim())return;const ctrl=typeof AbortController<"u"?new AbortController:null,timer=ctrl?setTimeout(()=>ctrl.abort(),5e3):null;fetch(providers[i].url,ctrl?{signal:ctrl.signal}:void 0).then(r=>r.ok?r.json():Promise.reject()).then(data=>{const geo=toZip5(providers[i].pick(data));geo?apply(geo,!0):tryProvider(i+1)}).catch(()=>tryProvider(i+1)).finally(()=>{timer&&clearTimeout(timer)})};tryProvider(0)}}bindWishlist(){const wish=this.querySelector("[data-pdp-wish]");if(!wish)return;const productId=this.dataset.productId,sync=()=>{if(window.cibFavorites&&productId){const active=window.cibFavorites.has(productId);wish.classList.toggle("is-active",!!active),wish.setAttribute("aria-pressed",active?"true":"false")}};sync(),this._onFavoritesChange=e=>{const d=e.detail||{};(d.productId===null||String(d.productId)===String(productId))&&sync()},document.addEventListener("cib:favorites:change",this._onFavoritesChange),wish.addEventListener("click",()=>{if(window.cibFavorites&&productId){const active=window.cibFavorites.toggle(productId);wish.classList.toggle("is-active",!!active),wish.setAttribute("aria-pressed",active?"true":"false")}else{const active=wish.classList.toggle("is-active");wish.setAttribute("aria-pressed",active?"true":"false")}})}bindBundle(){const bundle=this.querySelector("[data-pdp-bundle]");if(!bundle)return;this.bundle=bundle,this.bundleItems=[];const url=(bundle.dataset.recsUrl||"/recommendations/products")+".json?product_id="+this.dataset.productId+"&limit=3&intent=related";fetch(url,{headers:{Accept:"application/json"}}).then(r=>r.ok?r.json():null).then(data=>{const products=data&&data.products||[];products.length&&(this.renderBundle(products),bundle.hidden=!1)}).catch(()=>{})}formatMoney(cents){const currency=window.Shopify&&window.Shopify.currency&&window.Shopify.currency.active||"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency}).format(cents/100)}catch{return"$"+(cents/100).toFixed(2)}}renderBundle(products){const list=this.bundle.querySelector("[data-pdp-bundle-list]");
1list.innerHTML="",this.bundleItems=[],products.forEach(p=>{const variant=(p.variants||[]).find(v=>v.available)||(p.variants||[])[0];if(!variant)return;const row=document.createElement("div");row.className="pdp__bundle-row is-selected";const check=document.createElement("button");check.type="button",check.className="pdp__bundle-check",check.setAttribute("aria-label","Include "+p.title+" in bundle"),check.setAttribute("aria-pressed","true"),check.innerHTML='<svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';const img=document.createElement("img");img.className="pdp__bundle-thumb",img.loading="lazy",img.alt=p.title||"",p.featured_image&&(img.src=p.featured_image+(p.featured_image.indexOf("?")===-1?"?width=120":"&width=120"));const info=document.createElement("div");info.className="pdp__bundle-info";const name=document.createElement("a");name.className="pdp__bundle-name",name.href=p.url,name.textContent=p.title,info.appendChild(name);const prices=document.createElement("div");prices.className="pdp__bundle-prices";const wasCents=parseInt(variant.compare_at_price,10)||0;if(wasCents>variant.price){const was=document.createElement("span");was.className="pdp__bundle-was",was.textContent=this.formatMoney(wasCents),prices.appendChild(was)}const price=document.createElement("span");price.className="pdp__bundle-price",price.textContent=this.formatMoney(variant.price),prices.appendChild(price),row.appendChild(check),row.appendChild(img),row.appendChild(info),row.appendChild(prices),list.appendChild(row);const item={row,check,variantId:variant.id,priceCents:variant.price,selected:!0};this.bundleItems.push(item),check.addEventListener("click",()=>{item.selected=!item.selected,row.classList.toggle("is-selected",item.selected),check.setAttribute("aria-pressed",item.selected?"true":"false"),check.innerHTML=item.selected?'<svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>':"",this.updateBundleTotals()})}),this.bundle.querySelector("[data-pdp-bundle-atc]").addEventListener("click",()=>this.addBundleToCart()),this.updateBundleTotals()}updateBundleTotals(){if(!this.bundle||!this.bundleItems||!this.bundleItems.length)return;const variantId=this.idInput?this.idInput.value:null,v=variantId?this.variants[variantId]:null,qty=parseInt(this.qtyInput&&this.qtyInput.value,10)||1;let total=v?v.priceCents*qty:0,count=0;this.bundleItems.forEach(item=>{item.selected&&(total+=item.priceCents,count++)});const totalEl=this.bundle.querySelector("[data-pdp-bundle-total]"),totalBtn=this.bundle.querySelector("[data-pdp-bundle-total-btn]"),note=this.bundle.querySelector("[data-pdp-bundle-note]"),atc=this.bundle.querySelector("[data-pdp-bundle-atc]"),money=this.formatMoney(total);totalEl&&(totalEl.textContent=money),totalBtn&&(totalBtn.textContent=money),note&&(note.textContent=count>0?"Includes this product + "+count+" item"+(count===1?"":"s")+" above":"Select items above to build your bundle"),atc&&(atc.disabled=count===0&&!v)}async addBundleToCart(){const atc=this.bundle.querySelector("[data-pdp-bundle-atc]"),variantId=this.idInput?this.idInput.value:null,qty=parseInt(this.qtyInput&&this.qtyInput.value,10)||1,items=[];if(variantId&&items.push({id:Number(variantId),quantity:qty}),this.bundleItems.forEach(item=>{item.selected&&items.push({id:Number(item.variantId),quantity:1})}),!!items.length){atc.disabled=!0;try{const root=window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root||"/";if(!(await fetch(root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items})})).ok)throw new Error("Add to cart failed");window.cibCart&&window.cibCart.invalidate(),document.dispatchEvent(new CustomEvent("dispatch:cart-drawer:refresh",{bubbles:!0})),document.dispatchEvent(new CustomEvent("dispatch:cart-drawer:open",{bubbles:!0}))}catch(e){console.warn("[Main product] bundle add failed",e)}finally{atc.disabled=!1}}}disconnectedCallback(){this._zipTimer&&clearInterval(this._zipTimer),this._onFavoritesChange&&(document.removeEventListener("cib:favorites:change",this._onFavoritesChange),this._onFavoritesChange=null)}}customElements.define("main-product-page",MainProductPage)} 2//# sourceMappingURL=/cdn/shop/t/133/assets/main-product.js.map?v=76696255337531932051787698809
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.