1(function(){const T=window.Theme?.translations||{},SELECT_SIZE_TEXT=T.select_size||"Selecciona tu talla",ADDED_TEXT=T.added_to_cart||"Agregado a tu carrito",ADD_ERROR_TEXT=T.add_to_cart_error||"Error al agregar al carrito";let liveRegion=null;function announce(text){liveRegion||(liveRegion=document.createElement("div"),liveRegion.className="visually-hidden",liveRegion.setAttribute("aria-live","polite"),liveRegion.setAttribute("aria-atomic","true"),document.body.appendChild(liveRegion)),liveRegion.textContent=text}let sheet=null,sheetBackdrop=null,activeCard=null,activeTrigger=null;function buildSheet(){sheet=document.createElement("div"),sheet.className="brand-size-sheet",sheet.setAttribute("role","dialog"),sheet.setAttribute("aria-modal","true"),sheet.setAttribute("aria-labelledby","brand-size-sheet-label"),sheet.tabIndex=-1,sheet.innerHTML='<p class="brand-size-sheet__label" id="brand-size-sheet-label">'+SELECT_SIZE_TEXT+'</p><div class="brand-size-sheet__list"></div><div class="brand-size-sheet__confirm">'+ADDED_TEXT+"</div>",sheetBackdrop=document.createElement("div"),sheetBackdrop.className="brand-size-sheet-backdrop",sheetBackdrop.addEventListener("click",closeSheet),document.body.appendChild(sheetBackdrop),document.body.appendChild(sheet)}function openSheet(cardEl,triggerBtn){if(sheet||buildSheet(),!sheet||!sheetBackdrop)return;activeCard=cardEl,activeTrigger=triggerBtn||null,activeTrigger?.setAttribute("aria-expanded","true");const sourceList=cardEl.querySelector(".brand-product-card__sizes-list"),targetList=sheet.querySelector(".brand-size-sheet__list");targetList&&(targetList.innerHTML=sourceList?sourceList.innerHTML:""),sheet.classList.remove("brand-size-sheet--added"),sheet.classList.add("brand-size-sheet--open"),sheetBackdrop.classList.add("is-visible"),document.body.style.overflow="hidden",(targetList?.querySelector(".brand-product-card__size-btn:not(:disabled)")||sheet).focus()}function closeSheet(){!sheet||!sheetBackdrop||(sheet.classList.remove("brand-size-sheet--open"),sheetBackdrop.classList.remove("is-visible"),document.body.style.overflow="",activeTrigger?.setAttribute("aria-expanded","false"),activeTrigger?.focus(),activeCard=null,activeTrigger=null)}document.addEventListener("keydown",e=>{if(sheet?.classList.contains("brand-size-sheet--open")){if(e.key==="Escape"){e.preventDefault(),closeSheet();return}if(e.key==="Tab"){const focusables=sheet.querySelectorAll("button:not(:disabled)");if(!focusables.length)return;const first=focusables[0],last=focusables[focusables.length-1];e.shiftKey&&document.activeElement===first?(e.preventDefault(),last.focus()):!e.shiftKey&&document.activeElement===last&&(e.preventDefault(),first.focus())}}});function setSizesOverlayVisible(cardEl,visible){const panel=cardEl.querySelector(".brand-product-card__sizes");panel&&(panel.setAttribute("aria-hidden",visible?"false":"true"),panel.querySelectorAll(".brand-product-card__size-btn").forEach(b=>{b.tabIndex=visible?0:-1}))}document.addEventListener("mouseenter",e=>{const card=e.target.closest?.(".brand-product-card");card&&setSizesOverlayVisible(card,!0)},!0),document.addEventListener("mouseleave",e=>{const card=e.target.closest?.(".brand-product-card");card&&!card.contains(document.activeElement)&&setSizesOverlayVisible(card,!1)},!0),document.addEventListener("focusin",e=>{const card=e.target.closest?.(".brand-product-card");card&&setSizesOverlayVisible(card,!0)}),document.addEventListener("focusout",e=>{const card=e.target.closest?.(".brand-product-card");card&&requestAnimationFrame(()=>{card.contains(document.activeElement)||setSizesOverlayVisible(card,!1)})}),document.addEventListener("click",e=>{const btn=e.target.closest(".brand-product-card__quick-btn");if(!btn||window.innerWidth>=750)return;e.preventDefault(),e.stopPropagation();const cardEl=btn.closest(".brand-product-card");cardEl&&(activeCard===cardEl&&sheet?.classList.contains("brand-size-sheet--open")?closeSheet():openSheet(cardEl,btn))},!0),document.addEventListener("click",handleSizeClick,!0);async function handleSizeClick(e){const btn=e.target.closest(".brand-product-card__size-btn");if(!btn||btn.disabled)return;const inSheet=!!btn.closest(".brand-size-sheet"),inCard=!!btn.closest(".brand-product-card__sizes");if(!inSheet&&!inCard)return;e.preventDefault(),e.stopPropagation();const variantId=btn.dataset.variantId;if(!variantId)return;const secondaryBrand=(inSheet?activeCard:btn.closest(".brand-product-card"))?.dataset.secondaryBrand;btn.closest(".brand-size-sheet__list, .brand-product-card__sizes-list")?.querySelectorAll(".brand-product-card__size-btn--selected").forEach(b=>b.classList.remove("brand-product-card__size-btn--selected")),btn.classList.add("brand-product-card__size-btn--selected"),btn.setAttribute("aria-busy","true");const sizesEl=btn.closest(".brand-product-card__sizes");let closeTimeoutId=0;inSheet&&sheet?(sheet.classList.add("brand-size-sheet--added"),closeTimeoutId=setTimeout(closeSheet,1500)):(sizesEl?.classList.add("brand-product-card__sizes--added"),closeTimeoutId=setTimeout(()=>{sizesEl?.classList.remove("brand-product-card__sizes--added"),btn.classList.remove("brand-product-card__size-btn--selected")},1500));const formData=new FormData;formData.append("id",variantId),formData.append("quantity","1"),secondaryBrand&&formData.append("properties[_secondary_brand]",secondaryBrand);const cartAddUrl=window.Theme?.routes?.cart_add_url??"/cart/add.js";try{const res=await fetch(cartAddUrl,{method:"POST",headers:{Accept:"application/json"},body:formData}),data=await res.json();if(!res.ok||data.status){clearTimeout(closeTimeoutId),btn.classList.remove("brand-product-card__size-btn--selected"),inSheet&&sheet?sheet.classList.remove("brand-size-sheet--added"):sizesEl?.classList.remove("brand-product-card__sizes--added"),announce(ADD_ERROR_TEXT);return}announce(ADDED_TEXT);let cart;try{cart=await(await fetch("/cart.js")).json()}catch{cart=void 0}btn.dispatchEvent(new CustomEvent("cart:update",{bubbles:!0,composed:!0,detail:{resource:cart??data,sourceId:"brand-card-quick-add",data:{source:"product-form-component",itemCount:1,variantId}}}))}catch{clearTimeout(closeTimeoutId),btn.classList.remove("brand-product-card__size-btn--selected"),inSheet&&sheet?sheet.classList.remove("brand-size-sheet--added"):sizesEl?.classList.remove("brand-product-card__sizes--added"),announce(ADD_ERROR_TEXT)}finally{btn.removeAttribute("aria-busy")}}})(); 2//# sourceMappingURL=/cdn/shop/t/26/assets/custom_brand_card_quick_add.js.map?v=172538371833880732881788817976
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.