1(function(){if(window.__bushnellAjaxCart)return;window.__bushnellAjaxCart=!0;var ADD_URL="/cart/add.js",UNDO_TOAST_MS=5e3;function nativeSubmit(form){try{HTMLFormElement.prototype.submit.call(form)}catch{window.location.href="/cart"}}function openDrawer(drawer){if(drawer=drawer||document.querySelector("cart-drawer-component"),!!drawer){try{if(typeof drawer.open=="function"){drawer.open();return}}catch{}var trigger=drawer.querySelector('[data-testid="cart-drawer-trigger"]')||document.querySelector('[data-testid="cart-drawer-trigger"]');trigger&&trigger.click()}}function setBtnLoading(btn,loading){if(btn)if(loading){try{var c=getComputedStyle(btn).color;(!c||c==="transparent"||c.indexOf("rgba(0, 0, 0, 0)")!==-1)&&(c="#1c1c1c"),btn.style.setProperty("--bpdp-spin",c)}catch{}btn.classList.add("is-loading"),btn.disabled=!0}else btn.classList.remove("is-loading"),btn.disabled=!1,btn.style.removeProperty("--bpdp-spin")}async function refreshDrawer(){var live=document.querySelector("cart-drawer-component cart-items-component"),sectionId=live&&live.getAttribute("data-section-id");if(!sectionId||!live)return!1;try{var res=await fetch("/?section_id="+encodeURIComponent(sectionId),{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!res.ok)return!1;var html=await res.text(),doc=new DOMParser().parseFromString(html,"text/html"),freshItems=doc.querySelector("cart-items-component");freshItems&&(live.innerHTML=freshItems.innerHTML);var freshBubble=doc.querySelector(".header-actions__cart-icon .cart-bubble"),liveBubble=document.querySelector(".header-actions__cart-icon .cart-bubble");freshBubble&&liveBubble&&liveBubble.parentNode&&liveBubble.parentNode.replaceChild(freshBubble,liveBubble);var dialog=document.querySelector(".cart-drawer__dialog");dialog&&dialog.classList.remove("cart-drawer--empty");var icon=document.querySelector(".header-actions__cart-icon");return icon&&icon.classList.add("header-actions__cart-icon--has-cart"),bindDrawerControls(live),!0}catch{return!1}}function collapseRow(row){try{row.style.overflow="hidden",row.style.height=row.offsetHeight+"px",row.offsetHeight,row.style.transition="height .18s ease, opacity .18s ease, margin .18s ease, padding .18s ease, border-color .18s ease",row.style.height="0px",row.style.opacity="0",row.style.marginTop="0",row.style.marginBottom="0",row.style.paddingTop="0",row.style.paddingBottom="0",row.style.borderColor="transparent"}catch{row.style.display="none"}}function changeLine(key,quantity){return fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json"},body:JSON.stringify({id:key,quantity})}).then(function(res){if(!res.ok)throw new Error("change failed");return res.json()}).then(function(){return refreshDrawer()}).catch(function(){return refreshDrawer()})}function bindDrawerControls(root){root=root||document.querySelector("cart-drawer-component cart-items-component"),root&&root.querySelectorAll(".cart-items__table-row").forEach(function(row){var key=row.dataset.key;if(!key||row.classList.contains("cart-items__nested-line"))return;var input=row.querySelector('input[name="updates[]"], .quantity-selector input'),min=input&&input.getAttribute("min")&&parseInt(input.getAttribute("min"),10)||1,step=input&&input.getAttribute("step")&&parseInt(input.getAttribute("step"),10)||1,max=input&&input.getAttribute("max")?parseInt(input.getAttribute("max"),10):null;function current(){return input&&parseInt(input.value,10)||min}var removeBtn=row.querySelector(".cart-items__remove");removeBtn&&!removeBtn._bnBound&&(removeBtn._bnBound=!0,removeBtn.removeAttribute("on:click"),removeBtn.addEventListener("click",function(e){if(e.preventDefault(),!row._bnRemoving){row._bnRemoving=!0;var titleEl=row.querySelector(".cart-items__title");showUndoToast({variantId:String(key).split(":")[0],quantity:current(),title:titleEl?titleEl.textContent.trim():"item"}),collapseRow(row),changeLine(key,0)}}));var minus=row.querySelector(".quantity-minus");minus&&!minus._bnBound&&(minus._bnBound=!0,minus.removeAttribute("on:click"),minus.addEventListener("click",function(e){e.preventDefault();var q=current()-step;q<min&&(q=min),q!==current()&&changeLine(key,q)}));var plus=row.querySelector(".quantity-plus");
1plus&&!plus._bnBound&&(plus._bnBound=!0,plus.removeAttribute("on:click"),plus.addEventListener("click",function(e){e.preventDefault();var q=current()+step;max!=null&&q>max&&(q=max),q!==current()&&changeLine(key,q)})),input&&!input._bnBound&&(input._bnBound=!0,input.removeAttribute("on:blur"),input.addEventListener("change",function(){var q=parseInt(input.value,10);isNaN(q)||(q<min&&(q=min),max!=null&&q>max&&(q=max),changeLine(key,q))}))})}document.addEventListener("click",function(e){var t=e.target;if(!(!t||typeof t.closest!="function")){var btn=t.closest('form[action*="/cart/add"] [type="submit"], form[action*="/cart/add"] button[name="add"]');if(!(!btn||btn.disabled)){try{var c=getComputedStyle(btn).color;(!c||c==="transparent"||c.indexOf("rgba(0, 0, 0, 0)")!==-1)&&(c="#1c1c1c"),btn.style.setProperty("--bpdp-spin",c)}catch{}btn.classList.add("is-loading")}}},!0),document.addEventListener("submit",function(e){var form=e.target;if(!(!form||typeof form.matches!="function")&&form.matches('form[action*="/cart/add"]')){var idField=form.querySelector('[name="id"]');if(!(!idField||!idField.value||idField.disabled)){e.preventDefault(),e.stopImmediatePropagation();var loadingBtn=e.submitter||form.querySelector('[type="submit"]');setBtnLoading(loadingBtn,!0);var data=new FormData(form),scope=form.closest(".shopify-section")||document,addonIds=[];scope.querySelectorAll("[data-addon-variant-id]:checked").forEach(function(cb){var aid=parseInt(cb.dataset.addonVariantId,10);aid&&!isNaN(aid)&&addonIds.push(aid)});var fetchOpts;if(addonIds.length){var items=[{id:parseInt(idField.value,10),quantity:parseInt(data.get("quantity"),10)||1}];addonIds.forEach(function(aid){items.push({id:aid,quantity:1})}),fetchOpts={method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json"},body:JSON.stringify({items})}}else fetchOpts={method:"POST",body:data,headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}};fetch(ADD_URL,fetchOpts).then(function(res){if(!res.ok)throw new Error("add failed");return res.json()}).then(function(){var drawer=document.querySelector("cart-drawer-component");if(!drawer){window.location.href="/cart";return}return refreshDrawer().then(function(){setBtnLoading(loadingBtn,!1),openDrawer(drawer)})}).catch(function(){setBtnLoading(loadingBtn,!1),nativeSubmit(form)})}}},!0),document.addEventListener("click",function(e){try{var btn=e.target.closest&&e.target.closest(".cart-drawer .quantity-selector button");if(!btn)return;var selector=btn.closest(".quantity-selector");if(!selector)return;selector.classList.add("bn-qty-pending"),setTimeout(function(){try{selector.classList.remove("bn-qty-pending")}catch{}},1200)}catch{}},!0);var toastEl=null,toastTimer=null,lastRemoved=null;function getToast(){var dialog=document.querySelector(".cart-drawer__dialog");if(!dialog)return null;if(toastEl&&dialog.contains(toastEl))return toastEl;toastEl=document.createElement("div"),toastEl.className="bn-undo-toast",toastEl.setAttribute("role","status");var text=document.createElement("span");text.className="bn-undo-toast__text";var btn=document.createElement("button");return btn.type="button",btn.className="bn-undo-toast__btn",btn.textContent="Undo",btn.addEventListener("click",function(){var item=lastRemoved;hideToast(),item&&fetch(ADD_URL,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json"},body:JSON.stringify({id:item.variantId,quantity:item.quantity})}).then(function(res){if(!res.ok)throw new Error("undo failed");return res.json()}).then(function(){return refreshDrawer()}).catch(function(){})}),toastEl.appendChild(text),toastEl.appendChild(btn),dialog.appendChild(toastEl),toastEl}function hideToast(){clearTimeout(toastTimer),lastRemoved=null,toastEl&&toastEl.classList.remove("bn-undo-toast--visible")}function showUndoToast(item){var el=getToast();el&&(lastRemoved=item,el.querySelector(".bn-undo-toast__text").textContent="Removed "+item.title,el.classList.add("bn-undo-toast--visible"),clearTimeout(toastTimer),toastTimer=setTimeout(hideToast,UNDO_TOAST_MS))}document.addEventListener("click",function(e){try{var btn=e.target.closest&&e.target.closest(".cart-drawer .cart-items__remove");
1if(!btn||btn._bnBound)return;var row=btn.closest(".cart-items__table-row");if(!row||!row.dataset.key||row.classList.contains("cart-items__nested-line"))return;var variantId=String(row.dataset.key).split(":")[0];if(!variantId)return;var qtyInput=row.querySelector(".quantity-selector input"),quantity=qtyInput&&parseInt(qtyInput.value,10)||1,titleEl=row.querySelector(".cart-items__title"),title=titleEl?titleEl.textContent.trim():"item";showUndoToast({variantId,quantity,title})}catch{}},!0)})(); 2//# sourceMappingURL=/cdn/shop/t/127/assets/bushnell-ajax-cart.js.map?v=161944157569204579171790092425
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.