PageSourceSearch

https://www.wetsounds.com/cdn/shop/t/18/assets/cart-labels.js?v=13367033784411630591783331058

js wetsounds.com collected 2026-10-03 22:50:53 UTC 6,066 bytes, 2 lines download raw bytes

1import{fetchConfig}from"@lib/section-utils";import{PUB_SUB_EVENTS,publish,subscribe}from"@lib/pubsub";export const CART_LABEL_KEYS={PRE_ORDER_PROPERTY:"Pre-Order Now -",PRE_ORDER_PROPERTY_LEGACY:"Pre-order",PALLET_FREIGHT_FLAG_PROPERTY:"_Pallet Freight",PALLET_FREIGHT_PROPERTY_LEGACY:"Pallet Freight Required",PALLET_FREIGHT_ATTRIBUTE:"Pallet Freight"};const DEFAULT_PALLET_MESSAGE="This product ships via LTL freight and may require lift gate service at the time of delivery if a loading dock or forklift is not available. A Wet Sounds representative will contact you to confirm all shipping and delivery details prior to shipment. Please note that return freight shipping costs are the responsibility of the customer and are not covered by Wet Sounds.";function getPalletFreightMessage(){const messageFromDom=(document.querySelector("cart-drawer[data-pallet-freight-message]")||document.querySelector("[data-main-cart-items][data-pallet-freight-message]"))?.getAttribute("data-pallet-freight-message");return messageFromDom||(window.cartLabelConfig?.palletFreightMessage?window.cartLabelConfig.palletFreightMessage:window.cartStrings?.oversizedShippingMessage?window.cartStrings.oversizedShippingMessage:DEFAULT_PALLET_MESSAGE)}function lineItemNeedsPalletFreight(item){const properties=item?.properties||{};return!!(properties[CART_LABEL_KEYS.PALLET_FREIGHT_FLAG_PROPERTY]==="true"||properties[CART_LABEL_KEYS.PALLET_FREIGHT_PROPERTY_LEGACY]||properties["Pallet Freight"])}function domHasPalletFreightItems(){return document.querySelector('[data-cart-label-pallet-freight="true"]')!==null}function cartNeedsPalletFreightAttribute(cart){return cart?.items?.some(lineItemNeedsPalletFreight)?!0:domHasPalletFreightItems()}export async function syncCartLabelAttributes(options={}){try{const cartResponse=await fetch(`${Theme.routes.cart_url}.js`,{credentials:"same-origin"});if(!cartResponse.ok)return null;const cart=await cartResponse.json(),needsPalletFreight=cartNeedsPalletFreightAttribute(cart),palletFreightMessage=getPalletFreightMessage(),currentAttribute=cart.attributes?.[CART_LABEL_KEYS.PALLET_FREIGHT_ATTRIBUTE]||"",nextAttribute=needsPalletFreight?palletFreightMessage:"";if(!options.force&&currentAttribute===nextAttribute)return{changed:!1,cart};const attributes={...cart.attributes||{}};nextAttribute?attributes[CART_LABEL_KEYS.PALLET_FREIGHT_ATTRIBUTE]=nextAttribute:delete attributes[CART_LABEL_KEYS.PALLET_FREIGHT_ATTRIBUTE];const body={attributes};options.sections?.length&&(body.sections=options.sections,body.sections_url=window.location.pathname);const updateResponse=await fetch(`${Theme.routes.cart_update_url}`,{...fetchConfig("json"),credentials:"same-origin",body:JSON.stringify(body)});if(!updateResponse.ok)return console.error("[cart-labels] cart/update.js failed.",updateResponse.status),null;const updatedCart=await updateResponse.json();return publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-labels",cartData:updatedCart}),{changed:!0,cart:updatedCart}}catch(error){return console.error("[cart-labels] Failed to sync cart attributes.",error),null}}export function getCartLabelPropertiesFromElement(element){const properties={},palletFreightMessage=getPalletFreightMessage();return element?.dataset?.badgeLabel&&(properties[CART_LABEL_KEYS.PRE_ORDER_PROPERTY]=element.dataset.badgeLabel),element?.dataset?.palletFreight==="true"&&(properties[CART_LABEL_KEYS.PALLET_FREIGHT_FLAG_PROPERTY]="true",properties[CART_LABEL_KEYS.PALLET_FREIGHT_PROPERTY_LEGACY]=palletFreightMessage),properties}export function getCartLabelPropertiesFromForm(form){const properties={};return form?.querySelectorAll('input[name^="properties["]').forEach(input=>{const match=input.name.match(/^properties\[(.+)\]$/);match&&input.value!==""&&(properties[match[1]]=input.value)}),properties}let checkoutInProgress=!1;function getCheckoutForm(checkoutButton){if(checkoutButton?.form)return checkoutButton.form;const formId=checkoutButton?.getAttribute("form");return formId?document.getElementById(formId):document.getElementById("cart-drawer")||document.querySelector('form[action*="/cart"][main-cart-items]')}function ensureCheckoutField(form){let checkoutInput=form.querySelector('input[type="hidden"][name="checkout"]');return checkoutInput||(checkoutInput=document.createElement("input"),checkoutInput.type="hidden",checkoutInput.name="checkout",form.appendChild(checkoutInput)),checkoutInput}function ensurePalletFreightAttributeField(form){const needsPalletFreight=domHasPalletFreightItems(),message=getPalletFreightMessage();let attributeInput=form.querySelector('[data-cart-attribute="Pallet Freight"]');if(!needsPalletFreight||!message){attributeInput?.remove();return}attributeInput||(attributeInput=document.createElement("input"),attributeInput.type="hidden",attributeInput.name="attributes[Pallet Freight]",attributeInput.dataset.cartAttribute="Pallet Freight",form.appendChild(attributeInput)),attributeInput.value=message}async function handleCheckoutNavigation(event){const checkoutButton=event.target.closest('[name="checkout"]');if(!(!checkoutButton||checkoutInProgress)){event.preventDefault(),event.stopImmediatePropagation(),checkoutInProgress=!0,checkoutButton.setAttribute("aria-disabled","true");try{await syncCartLabelAttributes({force:!0});const form=getCheckoutForm(checkoutButton);form?(ensurePalletFreightAttributeField(form),ensureCheckoutField(form),form.submit()):window.location.assign("/checkout")}catch(error){console.error("[cart-labels] Checkout attribute sync failed.",error),window.location.assign("/checkout")}finally{checkoutInProgress=!1,checkoutButton.removeAttribute("aria-disabled")}}}function initCartLabelSync(){syncCartLabelAttributes(),subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source!=="cart-labels"&&syncCartLabelAttributes()}),document.addEventListener("click",handleCheckoutNavigation,!0)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initCartLabelSync):initCartLabelSync();
2//# sourceMappingURL=/cdn/shop/t/18/assets/cart-labels.js.map?v=13367033784411630591783331058

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.