PageSourceSearch

https://www.tennis-point.pl/cdn/shop/t/1/assets/cart.js?v=10181865356837380421779261780

js tennis-point.pl collected 2026-10-08 19:25:29 UTC 21,157 bytes, 2 lines download raw bytes

1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault();const cartItems=this.closest("cart-items")||this.closest("cart-drawer-items"),cartItem=this.closest(".cart-item"),isMainBundleProduct=cartItem?.dataset.tpMainProductBundle==="true",bundleId=cartItem?.dataset.tpBundleId;isMainBundleProduct&&bundleId||bundleId&&this.isLastTournamentBallInBundle(cartItem)?cartItems.handleBundleRemoval(bundleId):cartItems.updateQuantity(this.dataset.index,0,event)})}isLastTournamentBallInBundle(cartItem){const isTournamentBallBundle=cartItem?.dataset.tpBundleType==="tournament-ball",isTournamentBall=cartItem?.dataset.tpBundleRole==="ball";if(!isTournamentBallBundle||!isTournamentBall)return!1;const bundleId=cartItem?.dataset.tpBundleId;return Array.from(document.querySelectorAll(`[data-tp-bundle-id="${bundleId}"][data-tp-bundle-type="tournament-ball"]`)).filter(e=>e.dataset.tpBundleRole==="ball").length<=1}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus"),this.errorMessages=new Map;const debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this)),this.addEventListener("keydown",event=>{event.key==="Enter"&&event.target?.classList.contains("quantity__input")&&event.target?.dataset?.quantityVariantId&&(event.preventDefault(),event.stopPropagation(),event.target.blur())})}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{if(event.source!=="cart-items")return this.onCartUpdate()}),this.initializeCartOnLoad()}async fetchCartOnLoad(){return(await fetch(`${routes.cart_url}.js`)).json()}async initializeCartOnLoad(){try{const cartData=await this.fetchCartOnLoad();this.cartValidateBasketLimits(cartData),await this.removeOrphanedServiceProductsOnLoad(cartData)}catch(e){console.error(e)}}async removeOrphanedServiceProductsOnLoad(cartDataOnLoad){const getMainCartItems=()=>document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems");let cartDisabled=!1;try{const cartData=cartDataOnLoad||await this.fetchCartOnLoad(),removableBundleTypes=["test-racket","strung-racket"],bundles=cartData.items?.reduce((acc,item)=>{const bundleId=item.properties?.["_bundle-id"];return bundleId&&removableBundleTypes.includes(item.properties?.["_bundle-type"])&&(acc[bundleId]=(acc[bundleId]||[]).concat(item)),acc},{})||{},itemsToRemove=Object.values(bundles).flatMap(bundleItems=>bundleItems.some(item=>item.properties?.["_main-product-bundle"]==="true")?[]:bundleItems);if(itemsToRemove.length===0)return;this.hideSwymSFLonBundleRemoval(),getMainCartItems()?.classList.add("cart__items--disabled"),cartDisabled=!0,itemsToRemove.forEach(item=>{const lineIndex=document.querySelector(`[data-key="${item.key}"]`)?.dataset.index;lineIndex&&[...document.querySelectorAll(`#CartItem-${lineIndex} .loading__spinner, #CartDrawer-Item-${lineIndex} .loading__spinner`)].forEach(el=>el.classList.remove("hidden"))});const updates=Object.fromEntries(itemsToRemove.map(item=>[item.key,0])),updateResponse=await fetch(routes.cart_update_url,{...fetchConfig(),body:JSON.stringify({updates,sections:this.getSectionsToRender().map(s=>s.section),sections_url:window.location.pathname})}),parsedState=JSON.parse(await updateResponse.text());if(parsedState.errors){this.updateLiveRegions(1,parsedState.errors);return}const items_removed=itemsToRemove.map(item=>({variant_id:item.variant_id,quantity:item.quantity,presentment_price:item.presentment_price,url:item.url}));this.applyParsedCartState(parsedState,{source:"cart-items",cartData:{...parsedState,items:parsedState.items||[],items_added:[],items_removed}})}catch(e){console.error("Error removing orphaned service products:",e)}finally{cartDisabled&&getMainCartItems()?.classList.remove("cart__items--disabled")}}async cartValidateBasketLimitsOnLoad(cartDataOnLoad){try{const cartData=cartDataOnLoad||await this.fetchCartOnLoad();this.cartValidateBasketLimits(cartData)}catch(e){console.error(e)}}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}
1resetQuantityInput(id){this.querySelectorAll(`input[id*="Quantity-${id}-"]`).forEach(inputElement=>{inputElement.value=inputElement.getAttribute("value")}),this.isEnterPressed=!1}setValidity(event,index,message){event.target.setCustomValidity(message),event.target.reportValidity(),this.resetQuantityInput(index),event.target.select()}validateQuantity(event){if(!event.target.dataset.quantityVariantId)return;const inputValue=parseInt(event.target.value),index=event.target.dataset.index;let message="";inputValue<event.target.dataset.min?message=window.quickOrderListStrings.min_error.replace("[min]",event.target.dataset.min):inputValue>parseInt(event.target.max)?message=window.quickOrderListStrings.max_error.replace("[max]",event.target.max):inputValue%parseInt(event.target.step)!==0&&(message=window.quickOrderListStrings.step_error.replace("[step]",event.target.step)),message?this.setValidity(event,index,message):(event.target.setCustomValidity(""),event.target.reportValidity(),this.updateQuantity(index,inputValue,event,document.activeElement.getAttribute("name"),event.target.dataset.quantityVariantId))}onChange(event){this.validateQuantity(event)}onCartUpdate(){return this.tagName==="CART-DRAWER-ITEMS"?fetch(`${routes.cart_url}?section_id=cart-drawer`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html"),selectors=["cart-drawer-items",".cart-drawer__footer"];for(const selector of selectors){const targetElement=document.querySelector(selector),sourceElement=html.querySelector(selector);targetElement&&sourceElement&&targetElement.replaceWith(sourceElement)}}).catch(e=>{console.error(e)}):fetch(`${routes.cart_url}?section_id=main-cart-items`).then(response=>response.text()).then(responseText=>{const sourceQty=new DOMParser().parseFromString(responseText,"text/html").querySelector("cart-items");this.innerHTML=sourceQty.innerHTML}).catch(e=>{console.error("Error updating cart items:",e)})}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-contents"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".js-contents"}]}applyParsedCartState(parsedState,cartUpdatePayload){this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),cartDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)}),this.updateCartHeaderCount(parsedState.item_count),this.updateCartReco(),this.cartValidateBasketLimits(parsedState),publish(PUB_SUB_EVENTS.cartUpdate,cartUpdatePayload||{source:"cart-items",cartData:parsedState})}handleBundleRemoval(bundleId){this.hideSwymSFLonBundleRemoval();const bundleItems=document.querySelectorAll(`.cart-item[data-tp-bundle-id="${bundleId}"]`);if(bundleItems.length===0){console.warn(`No bundle items found with bundleId: ${bundleId}`);return}bundleItems.forEach(item=>{const line=item.dataset.index||item.dataset.line;line&&this.enableLoading(line)});const updates={};bundleItems.forEach(item=>{const key=item.dataset.key;key&&(updates[key]=0)});const body=JSON.stringify({updates,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){this.updateLiveRegions(1,parsedState.errors);return}const items_removed=Array.from(bundleItems).map(item=>({variant_id:item.dataset.variantId,quantity:item.dataset.tpGtmItemQuantity,presentment_price:item.dataset.tpGtmItemPrice}));this.applyParsedCartState(parsedState,{source:"cart-items",cartData:{...parsedState,items_added:[],items_removed}})}).catch(e=>{console.error("Error removing bundle from cart:",e);const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors&&(errors.textContent=window.cartStrings.error)}).finally(()=>{bundleItems.forEach(item=>{const line=item.dataset.index||item.dataset.line;line&&this.disableLoading(line)})})}hideSwymSFLonBundleRemoval(){const swymModalContainer=document.querySelector(".swym-modals-container");swymModalContainer&&(swymModalContainer.style.display="none")}showSwymSFLonNonBundleRemoval(){const swymModalContainer=document.querySelector(".swym-modals-container");swymModalContainer&&(swymModalContainer.style.display="")}updateBundleQuantity(bundleId,quantity){const bundleItems=this.querySelectorAll(`[data-tp-bundle-id="${bundleId}"]`);if(bundleItems.length===0)return;const updates={},lineIndices=[];bundleItems.forEach(item=>{const lineKey=item.dataset.key,lineIndex=item.dataset.index,productType=item.dataset.tpProductType;lineKey&&(updates[lineKey]=productType==="String reels"?1:quantity),lineIndex&&(lineIndices.push(lineIndex),this.enableLoading(lineIndex))});const body=JSON.stringify({updates,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){lineIndices.forEach(lineIndex=>{this.updateLiveRegions(lineIndex,parsedState.errors)});return}this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),cartDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)}),lineIndices.forEach(lineIndex=>{this.updateLiveRegions(lineIndex,"")}),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cartData:parsedState})}).catch(error=>{console.error("Error updating bundle quantities:",error);const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors&&(errors.textContent=window.cartStrings.error)}).finally(()=>{lineIndices.forEach(lineIndex=>{this.disableLoading(lineIndex)})})}async updateQuantity(line,quantity,event,name,variantId){this.enableLoading(line);const cartItemElement=this.querySelector(`#CartItem-${line}`),isBundleItem=cartItemElement?.dataset.tpBundleId,bundleType=cartItemElement?.dataset.tpBundleType;if(isBundleItem&&quantity===0?this.hideSwymSFLonBundleRemoval():this.showSwymSFLonNonBundleRemoval(),isBundleItem&&bundleType==="test-racket"&&quantity>0){const currentCart=await window.cartApi.getCart(),testRacketsInCartCount=currentCart.items.reduce((count,item)=>item.properties&&item.properties["_bundle-type"]==="test-racket"&&item.properties["_main-product-bundle"]==="true"?count+item.quantity:count,0),previousLineItem=currentCart.items.find(item=>item.key===cartItemElement.dataset.key),previousQuantity=previousLineItem?previousLineItem.quantity:0,quantityDelta=quantity-previousQuantity,desiredTotalTestRackets=testRacketsInCartCount+quantityDelta,{testRacketMaxCount}=window.DEPT.shopMetafields,{cartValidationStrings}=window.DEPT;if(desiredTotalTestRackets>testRacketMaxCount){this.updateLiveRegions(line,`${cartValidationStrings.testRacketsLimitReachedErrorTemplate.replace("[limit]",testRacketMaxCount)}`),this.submitButton&&(this.submitButton.classList.remove("loading"),this.submitButton.removeAttribute("aria-disabled")),this.resetQuantityInput(line),this.disableLoading(line);return}this.updateBundleQuantity(isBundleItem,quantity);return}if(isBundleItem&&bundleType==="strung-racket"&&quantity>0){this.updateBundleQuantity(isBundleItem,quantity);return}const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname}),eventTarget=event.currentTarget instanceof CartRemoveButton?"clear":"change";fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);CartPerformance.measure(`${eventTarget}:paint-updated-sections"`,()=>{const items=document.querySelectorAll(".cart-item");if(parsedState.errors){const reportedAvailableQuantity=parsedState.errors.match(/\d+\.?\d*/g)?.[0],languageExceptionForSingleItem=parsedState.errors.includes("Un article")||parsedState.errors.includes("a\xF1adi\xF3 un art\xEDculo"),availableQuantity=reportedAvailableQuantity?parseInt(reportedAvailableQuantity,10):languageExceptionForSingleItem?1:void 0;if(availableQuantity?(this.errorMessages.set(variantId,parsedState.errors),this.updateQuantity(line,availableQuantity,event,name,variantId)):this.updateLiveRegions(line,parsedState.errors),!window.tracking.pushToDataLayer||!window.tracking.generateEventId)return;const payload={event:"error",event_id:window.tracking.generateEventId(),error:{code:"422",message:parsedState.errors,type:"basket_limit_exceeded"}};window.tracking.pushToDataLayer(payload);return}this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),cartDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)});const quantityElement=document.getElementById(`Quantity-${line}-desktop`)||document.getElementById(`Drawer-quantity-${line}`),updatedValue=parsedState.items[line-1]?parsedState.items[line-1].quantity:void 0;let message="";this.errorMessages.has(variantId)?(message=this.errorMessages.get(variantId),this.errorMessages.delete(variantId)):items.length===parsedState.items.length&&updatedValue!==parseInt(quantityElement.value)&&(typeof updatedValue>"u"?message=window.cartStrings.error:message=window.cartStrings.quantityError.replace("[quantity]",updatedValue)),this.updateLiveRegions(line,message),this.updateCartHeaderCount(parsedState.item_count),this.updateCartReco(),this.cartValidateBasketLimits(parsedState);const lineItemElement=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`);if(lineItemElement&&lineItemElement.querySelector(`[name="${name}"]`))cartDrawerWrapper?trapFocus(cartDrawerWrapper,lineItemElement.querySelector(`[name="${name}"]`)):lineItemElement.querySelector(`[name="${name}"]`).focus();else if(parsedState.item_count===0){const cartDrawerInnerElement=cartDrawerWrapper.querySelector(".drawer__inner-empty"),cartDrawerLinkElement=cartDrawerWrapper.querySelector("a");if(!cartDrawerWrapper||!cartDrawerInnerElement||!cartDrawerLinkElement)return;trapFocus(cartDrawerInnerElement,cartDrawerLinkElement)}else document.querySelector(".cart-item")&&cartDrawerWrapper&&trapFocus(cartDrawerWrapper,document.querySelector(".cart-item__name"))}),CartPerformance.measureFromEvent(`${eventTarget}:user-action`,event),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cartData:parsedState,variantId})}).catch(err=>{if(this.errorMessages.has(variantId))return;this.querySelectorAll(".loading__spinner").forEach(overlay=>overlay.classList.add("hidden"));const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors.textContent=window.cartStrings.error}).finally(()=>{this.errorMessages.has(variantId)||this.disableLoading(line)})}updateCartHeaderCount(itemCount){const cartCountElement=document.querySelector(".js-cart-count");if(cartCountElement&&itemCount!==void 0){const newText=cartCountElement.textContent.replace(/\d+/,itemCount);cartCountElement.textContent=newText}}updateCartReco(){document.querySelector(".tp-products-reco-slider")&&fetch(`${routes.cart_url}?section_id=tp-cart-reco`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html"),targetElement=document.querySelector(".tp-products-reco-slider"),sourceElement=html.querySelector(".tp-products-reco-slider");if(targetElement&&sourceElement){targetElement.replaceWith(sourceElement);const dataLoadedEvent=new CustomEvent("tp:cart-reco:update");document.dispatchEvent(dataLoadedEvent)}else targetElement&&targetElement.remove()}).catch(e=>{console.error(e)})}updateLiveRegions(line,message){const escapeHtml=(text=>new DOMParser().parseFromString(text,"text/html").documentElement.textContent||""),lineItemErrorMobile=document.getElementById(`Line-item-error-${line}-mobile`),lineItemErrorDesktop=document.getElementById(`Line-item-error-${line}-desktop`),lineItemErrorDrawer=document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemErrorMobile&&(lineItemErrorMobile.querySelector(".cart-item__error-text").textContent=escapeHtml(message)),lineItemErrorDesktop&&(lineItemErrorDesktop.querySelector(".cart-item__error-text").textContent=escapeHtml(message)),lineItemErrorDrawer&&(lineItemErrorDrawer.querySelector(".cart-item__error-text").textContent=escapeHtml(message)),this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text")||document.getElementById("CartDrawer-LiveRegionText");cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}cartValidateBasketLimits(cartData){if(!cartData)return;const cartTotal=cartData.total_price/100,basketLimitThreshold=window.DEPT?.shopMetafields?.basketLimitThreshold;if(!basketLimitThreshold)return;const currency=window.Shopify?.currency?.active;if(!currency)return;const countryCode=window.DEPT?.customerData?.defaultAddress?.country_code;if(!countryCode)return;if(!window.DEPT.cartValidateBasketLimit(cartTotal,basketLimitThreshold,currency,countryCode).valid&&document.querySelector('[id^="CartItem-1"]')){const threshold=basketLimitThreshold[currency],errorMessage=window.DEPT?.cartValidationStrings?.basketLimitErrorTemplate?.replace("[currency]",currency)?.replace("[amount]",threshold?.toLocaleStr
1ing()||"0")||"Cart limit exceeded";this.updateLiveRegions(1,errorMessage)}}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.add("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);[...cartItemElements,...cartDrawerItemElements].forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.remove("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);cartItemElements.forEach(overlay=>overlay.classList.add("hidden")),cartDrawerItemElements.forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("input",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(()=>CartPerformance.measureFromEvent("note-update:user-action",event))},ON_CHANGE_DEBOUNCE_TIMER))}});
2//# sourceMappingURL=/cdn/shop/t/1/assets/cart.js.map?v=10181865356837380421779261780

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.