1const addButtonGuards=new WeakMap;window.ProductFormState=Object.assign(window.ProductFormState||{},{attribute:"data-no-variant-selected",apply(formIds,variantId){const unselected=!variantId;formIds.forEach(formId=>{document.querySelectorAll(`[id="${formId}"]`).forEach(form=>{const input=form.querySelector('input[name="id"]');input&&(input.value=variantId||"",input.dispatchEvent(new Event("change",{bubbles:!0}))),form.closest("product-form")?.toggleAttribute(this.attribute,unselected),form.querySelectorAll(".product__payment-terms").forEach(node=>{node.toggleAttribute(this.attribute,unselected)}),unselected&&this.setKlaviyoBisTrigger(form.closest("product-form")||form,!1)})})},setKlaviyoBisTrigger(root,enabled){if(!root)return;const guard=addButtonGuards.get(root.closest?.("product-form")||root);root.querySelectorAll('[name="add"]').forEach(button=>{button.classList.toggle("klaviyo-bis-trigger",enabled),enabled?button.setAttribute("klaviyo-bis-trigger",""):button.removeAttribute("klaviyo-bis-trigger"),enabled?guard?.suppressedKlaviyoHide&&button.style.setProperty("display","none","important"):button.style.display==="none"&&button.style.removeProperty("display")})},keepAddButtonVisible(productFormHost){if(!productFormHost||addButtonGuards.has(productFormHost))return;const guard={suppressedKlaviyoHide:!1};addButtonGuards.set(productFormHost,guard);const restore=()=>{this.isUnselected(productFormHost)&&productFormHost.querySelectorAll('[name="add"]').forEach(button=>{button.style.display==="none"&&(button.style.removeProperty("display"),guard.suppressedKlaviyoHide=!0)})};restore(),new MutationObserver(restore).observe(productFormHost,{subtree:!0,attributes:!0,attributeFilter:["style"]})},isUnselected(productFormHost){if(!productFormHost)return!1;if(productFormHost.hasAttribute(this.attribute))return!0;const idControl=productFormHost.querySelector('[name="id"]');return!!idControl&&!idControl.value},focusVariantPicker(fromEl){if(!fromEl||typeof fromEl.closest!="function")return;const picker=(fromEl.closest("[data-quick-view]")||fromEl.closest(".main-product")||document).querySelector("variant-radios, variant-selects, quick-view-radios");if(!picker)return;const firstGroup=this.incompleteOptionGroups(picker)[0]||picker,control=firstGroup.querySelector('input[type="radio"]:not(.combo-hidden
1):not(:disabled), select'),anchor=firstGroup.querySelector(".legend, legend, .option-label")||control||firstGroup,reducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,offscreen=this.isOutOfView(anchor),reveal=()=>this.focusControl(control,{visible:!0,preventScroll:!0});if(offscreen){anchor.scrollIntoView({behavior:reducedMotion?"auto":"smooth",block:"center",inline:"nearest"}),this.afterScroll(reveal,reducedMotion);return}reveal()},incompleteOptionGroups(picker){const groups=[...picker.querySelectorAll(".product-option")],incomplete=groups.filter(group=>{const radios=group.querySelectorAll('input[type="radio"]:not(.combo-hidden)');if(radios.length)return![...radios].some(input=>input.checked);const select=group.querySelector("select");return select?!select.value:!1});return incomplete.length?incomplete:groups},isOutOfView(el){if(!el||typeof el.getBoundingClientRect!="function")return!1;const rect=el.getBoundingClientRect(),bounds=this.visibleBounds(el),visibleH=Math.min(rect.bottom,bounds.bottom)-Math.max(rect.top,bounds.top),visibleW=Math.min(rect.right,bounds.right)-Math.max(rect.left,bounds.left);return visibleH<Math.min(rect.height,48)||visibleW<Math.min(rect.width,24)},visibleBounds(el){const port=this.scrollPort(el),header=document.querySelector("#shopify-section-header, header.header");return!port||port===document.scrollingElement||port===document.documentElement||port===document.body?{top:header?Math.max(0,header.getBoundingClientRect().bottom):0,left:0,bottom:window.innerHeight,right:window.innerWidth}:port.getBoundingClientRect()},scrollPort(el){let node=el.parentElement;for(;node&&node!==document.body;){const overflowY=window.getComputedStyle(node).overflowY;if((overflowY==="auto"||overflowY==="scroll"||overflowY==="overlay")&&node.scrollHeight>node.clientHeight+1)return node;node=node.parentElement}return document.scrollingElement},afterScroll(callback,reducedMotion){if(reducedMotion){callback();return}let done=!1;const finish=()=>{done||(done=!0,callback())};document.addEventListener("scrollend",finish,{once:!0,capture:!0}),window.setTimeout(finish,500)},focusControl(control,{visible,preventScroll}={}){if(!control||(control.focus({preventScroll:!!preventScroll,focusVisible:!!visible}),!visible||control.matches(":focus-visible")))return;const ringTarget=control.matches('input[type="radio"]')?control.labels&&control.labels[0]:control;ringTarget&&(ringTarget.classList.add("product-option--force-focus"),control.addEventListener("blur",()=>{ringTarget.classList.remove("product-option--force-focus")},{once:!0}))}});function bindProductFormFocusVariantPicker(proto){proto&&(proto.focusVariantPicker=function(){window.ProductFormState.focusVariantPicker(this)})}customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.submitButton=this.querySelector('[type="submit"]'),this.submitButton?.addEventListener("click",this.onUnselectedClick.bind(this),!0),window.ProductFormState.keepAddButtonVisible(this),this.cartNotification=document.getElementById("cart-notification"),this.cartNotificationItem=document.getElementById("cart-notification-item"),this.multi_item_request=!1,this.parentDrawer=this.dataset.parentDrawer||!1}onUnselectedClick(evt){window.ProductFormState.isUnselected(this)&&(evt.preventDefault(),evt.stopImmediatePropagation(),window.ProductFormState.focusVariantPicker(this))}async onSubmitHandler(evt){if(evt.preventDefault(),this.submitButton.getAttribute("aria-disabled")==="true")return;if(window.ProductFormState.isUnselected(this)){window.ProductFormState.focusVariantPicker(this);return}this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.classList.add("loading");const upsell_ids_nodes=document.querySelectorAll(`[data-form="${this.form.getAttribute("id")}"] .upsell-id`),upsell_quantities_nodes=document.querySelectorAll(`[data-form="${this.form.getAttribute("id")}"] .upsell-quantity`);let upsell_items=[];if(upsell_ids_nodes.length!==0){const upsell_ids=Array.from(upsell_ids_nodes).map(input=>parseInt(input.value)),upsell_quantities=Array.from(upsell_quantities_nodes).map(input=>parseInt(input.value));upsell_items=upsell_ids.map((id,index)=>{const item={id,quantity:upsell_quantities[index]},node=upsell_ids_nodes[index],backorderProperty=window.variantStrings?.inventory?.backorder_property,leadTime=node.tagName==="SELECT"?node.selectedOptions[0]?.dataset.backorderLeadTime:node.closest("upsell-card")?.dataset.backorderLeadTime;return leadTime&&(item.properties={_backorder_lead_time:leadTime},backorderProperty&&(item.properties[backorderProperty]=leadTime)),item}).filter(item=>item.quantity!==0)}const config={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/javascript"}};config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form);if(upsell_items.length>0){this.multi_item_request=!0;const items=upsell_items,id=parseInt(formData.get("id")),quantity=parseInt(formData.get("quantity"))||1,the_product_item={id,quantity};formData.forEach((value,key)=>{const propertyMatch=key.match(/^properties\[(.+)\]$/);propertyMatch&&(the_product_item.properties=the_product_item.properties||{},the_product_item.properties[propertyMatch[1]]=value)}),items.push(the_product_item);const itemsData={items};config.headers["Content-Type"]="application/json",config.body=JSON.stringify(itemsData)}else this.multi_item_request=!1,config.body=formData;try{const res=await fetch(routes.cart_add_url+".js",config),json=await res.json();if(res.status!==200){const errorMessage=typeof json.description=="str
1ing"?json.description:json.message;throw new Error(errorMessage)}if(this.cartNotification){const activeElement=document.activeElement,insideQuickBuy=activeElement&&activeElement.closest(".drawer--quick-buy"),fallbackFocusTarget=document.querySelector("#MainContent")||document.body;this.previouslyFocusedElement=insideQuickBuy?fallbackFocusTarget:activeElement,this.showCartNotification(json)}this.parentDrawer&&Woolman.ModalsAndDrawers.closeModalOrDrawer(this.parentDrawer);const event=new CustomEvent("ajaxProduct:added");document.dispatchEvent(event)}catch(error){this.handleErrorMessage(error)}this.submitButton.classList.remove("loading"),this.submitButton.removeAttribute("aria-disabled"),this.resetQuantityInput()}focusVariantPicker(){window.ProductFormState.focusVariantPicker(this)}handleErrorMessage(errorMessage=!1){this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".error-message-wrapper")||document.querySelector(`.error-message-wrapper[form="${this.form.getAttribute("id")}"]`),this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage))}resetQuantityInput(){const hidden_quantity_input=document.querySelector("[type=hidden][name=quantity]");hidden_quantity_input&&(hidden_quantity_input.value=1)}createNotificationItem(product,template){console.log(template);const filename=product.image.split("/").pop(),lastDotIndex=filename.lastIndexOf("."),newFilename=`${filename.substring(0,lastDotIndex)}_120x${filename.substring(lastDotIndex)}`,url=product.image.replace(filename,newFilename),image_elem=template.querySelector("[data-image]"),title_elem=template.querySelector("[data-title]"),properties_elem=template.querySelector("[data-properties]"),price_elem=template.querySelector("[data-price]");return image_elem.setAttribute("src",url),image_elem.classList.remove("hide"),title_elem.textContent=product.product_title,price_elem&&(price_elem.textContent=Woolman.Utils.formatMoney(product.price)),product.product_has_only_default_variant||product.options_with_values.forEach(item=>{const row=document.createElement("div"),nameCell=document.createElement("dt"),valueCell=document.createElement("dd");nameCell.textContent=item.name+":",valueCell.textContent=item.value,row.appendChild(nameCell),row.appendChild(valueCell),row.classList.add("product-option","size--tiny","style--subdued"),properties_elem.appendChild(row)}),template}showCartNotification(cartJson){const notificationTemplate=document.importNode(this.cartNotification.content,!0),notificationItemTemplate=document.importNode(this.cartNotificationItem.content,!0);if(this.multi_item_request){notificationTemplate.querySelector("[data-notification-title]").textContent=window.variantStrings.itemsAdded;let lastElement=cartJson.items.pop();cartJson.items.unshift(lastElement),cartJson.items.forEach(item=>{const notificationItemTemplate2=document.importNode(this.cartNotificationItem.content,!0),singleItem=this.createNotificationItem(item,notificationItemTemplate2);notificationTemplate.querySelector("[data-items]").appendChild(singleItem)})}else{notificationTemplate.querySelector("[data-notification-title]").textContent=window.variantStrings.itemAdded;const singleItem=this.createNotificationItem(cartJson,notificationItemTemplate);notificationTemplate.querySelector("[data-items]").appendChild(singleItem)}document.querySelector(".cart-notification")&&document.querySelector(".cart-notification").remove(),document.querySelector(".site-header").appendChild(notificationTemplate);const the_notification=document.querySelector(".cart-notification");the_notification.setAttribute("tabindex","-1"),the_notification.focus(),the_notification.querySelector(".notification-close").addEventListener("click",()=>{the_notification.classList.remove("anim-in"),this.previouslyFocusedElement&&this.previouslyFocusedElement.focus&&this.previouslyFocusedElement.focus()}),setTimeout(()=>{the_notification.classList.add("anim-in")},50)}}),bindProductFormFocusVariantPicker(customElements.get("product-form")?.prototype);class AddMultiplier extends HTMLElement{constructor(){super();const multiplyButton=this.querySelector("button");
1this.submitEvent=new SubmitEvent("submit",{submitter:multiplyButton}),this.multiplyBy=parseInt(this.querySelector("[name=multiplied-quantity]").value),this.productFormHost=this.closest("product-form"),this.productForm=this.productFormHost.querySelector("form");const formId=this.productForm.getAttribute("id");this.quantity_input=document.querySelector(`[name=quantity][form=${formId}]`),multiplyButton.addEventListener("click",this.submitProductForm.bind(this))}submitProductForm(){if(window.ProductFormState.isUnselected(this.productFormHost)){window.ProductFormState.focusVariantPicker(this.productFormHost);return}this.quantity_input.value=this.multiplyBy,this.productForm.dispatchEvent(this.submitEvent)}}customElements.define("add-multiplier",AddMultiplier); 2//# sourceMappingURL=/cdn/shop/t/15/assets/component-product-form.js.map?v=45228429565655691511790162068
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.