1customElements.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.cart=document.querySelector("cart-notification")||document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog"),this.hideErrors=this.dataset.hideErrors==="true"}slugifyUpiValue(value){return String(value||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/®/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}mapProductTitleToUpi(productTitle){return{"kijimea-k53-advance":"k53a","kijimea-regularis":"kreg","kijimea-colon-irritable-pro":"krp","kijimea-floracare":"kfc"}[productTitle]||productTitle}extractUpiVariantValue(value){const normalizedValue=String(value||"").toLowerCase().trim(),multiPackMatch=normalizedValue.match(/(\d+)\s*x\s*(\d+(?:[.,]\d+)?)/);if(multiPackMatch)return`${multiPackMatch[1]}x${multiPackMatch[2].replace(",",".")}`;const matches=normalizedValue.match(/\d+(?:[.,]\d+)?/g);return!matches||!matches.length?this.slugifyUpiValue(value):matches[matches.length-1].replace(",",".")}buildUpiValue(){const formId=this.form.getAttribute("id");return Array.from(document.querySelectorAll(`input[type="radio"][form="${formId}"]:checked`))[0]?.getAttribute("upi-id")||""}getLineItemProperties(formData,extraProperties={}){const properties={...extraProperties};return formData.forEach((value,key)=>{const propertyMatch=key.match(/^properties\[(.+)\]$/);propertyMatch&&(properties[propertyMatch[1]]=value)}),properties}buildLineItemPayload(formData,extraProperties={}){const payload={id:formData.get("id"),quantity:formData.get("quantity")||1,properties:this.getLineItemProperties(formData,extraProperties)},sellingPlan=formData.get("selling_plan");return sellingPlan&&(payload.selling_plan=sellingPlan),payload}async onSubmitHandler(evt){setTimeout(function(){const surveyWidget=document.getElementById("reviews-io-survey-widget");surveyWidget&&(surveyWidget.style.display="block")},1e4);const button=document.querySelector(".R-Button.R-Button--sm.R-Button--sm--proportional.R-Button--primary.R-Button--flex.R-Button--fullwidth.u-marginBottom--none");if(button&&button.addEventListener("click",function(){const surveyWidget=document.getElementById("reviews-io-survey-widget");surveyWidget&&(surveyWidget.style.display="none")}),evt.preventDefault(),this.submitButton.getAttribute("aria-disabled")==="true")return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.classList.add("loading"),this.querySelector(".loading-overlay__spinner").classList.remove("hidden");const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest";const formData=new FormData(this.form),upiValue=this.buildUpiValue();formData.set("properties[_upi]",upiValue);const mainLineItem=this.buildLineItemPayload(formData,{_upi:upiValue}),sectionsToRender=this.cart?this.cart.getSectionsToRender().map(section=>section.id):void 0;this.cart&&(formData.append("sections",this.cart.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement));const existingFreeProducts=(await fetch("/cart.json").then(res=>res.json())).items.filter(item=>item.properties._free_product),freeProductId=this.dataset.freeProduct||47433404612956;this.dataset.freeProduct||document.cookie.split(";").some(item=>item.trim().startsWith("LiquidFree=true"))?config.body=JSON.stringify({items:[mainLineItem,{id:this.dataset.freeProduct||48055402430757,quantity:1,properties:{_free_product:!0}}],...sectionsToRender?{sections:sectionsToRender,sections_url:window.location.pathname}:{}}):config.body=JSON.stringify({items:[mainLineItem],...sectionsToRender?{sections:sectionsToRender,sections_url:window.location.pathname}:{}}),fetch(`${routes.cart_add_url}`,config).then(response2=>response2.json()).then(response2=>{if(response2.status){publish(PUB_SUB_EVENTS.cartError,{source:"product-form",productVariantId:formData.get("id"),errors:response2.errors||response2.description,message:response2.message}),this.handleErrorMessage(response2.description);const soldOutMessage=this.submitButton.querySelector(".sold-out-message");if(!soldOutMessage)return;this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span").classList.add("hidden"),soldOutMessage.classList.remove("hidden"),this.error=!0;return}else if(!this.cart){window.location=window.routes.cart_url;return}this.error||publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form",productVariantId:formData.get("id"),cartData:response2}),this.error=!1;const quickAddModal=this.closest("quick-add-modal");quickAddModal?(document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cart.renderContents(response2)})},{once:!0}),quickAddModal.hide(!0)):fetch("/cart.json").then(res=>res.json()).then(cart=>{const isRemoved=sessionStorage.getItem("removedFreeGift");if(!cart.items.find(item=>item.properties._free_gift)&&document.querySelector("body").classList.contains("ab-free-gift")&&!isRemoved){const giftProductConfig=fetchConfig("javascript");giftProductConfig.headers["X-Requested-With"]="XMLHttpRequest",g
1iftProductConfig.body=JSON.stringify({items:[{id:55872163643776,quantity:1,properties:{_free_gift:!0}}],sections:this.cart.getSectionsToRender().map(section=>section.id),sections_url:window.location.pathname}),fetch(`${routes.cart_add_url}`,giftProductConfig).then(res=>res.json()).then(newresponse=>{this.hasAttribute("data-disable-cart")?(document.querySelector("#cart-icon-bubble").innerHTML=this.cart.getSectionInnerHTML(newresponse.sections["cart-icon-bubble"]),document.querySelector("#CartDrawer").innerHTML=this.cart.getSectionInnerHTML(newresponse.sections["cart-drawer"],"#CartDrawer")):this.cart.renderContents(newresponse)})}else this.hasAttribute("data-disable-cart")?(document.querySelector("#cart-icon-bubble").innerHTML=this.cart.getSectionInnerHTML(response2.sections["cart-icon-bubble"]),document.querySelector("#CartDrawer").innerHTML=this.cart.getSectionInnerHTML(response2.sections["cart-drawer"],"#CartDrawer")):this.cart.renderContents(response2)})}).catch(e=>{console.error(e)}).finally(()=>{this.submitButton.classList.remove("loading"),this.cart&&this.cart.classList.contains("is-empty")&&this.cart.classList.remove("is-empty"),this.error||this.submitButton.removeAttribute("aria-disabled"),this.querySelector(".loading-overlay__spinner").classList.add("hidden")})}handleErrorMessage(errorMessage=!1){this.hideErrors||(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage)))}}),customElements.get("show-more-media-gallery")||customElements.define("show-more-media-gallery",class extends HTMLElement{constructor(){super(),this.isExpaned=!1,this.mediaGallery=this.querySelector("media-gallery > slider-component"),this.mediaGallery.style=`max-height: ${this.mediaGallery.offsetWidth}px; overflow: hidden;`,this.querySelector("#showMoreGallery").addEventListener("click",this.showMoreToggle.bind(this))}showMoreToggle(){this.isExpaned=!this.isExpaned,this.isExpaned?(this.mediaGallery.style="max-height: none; overflow: none;",this.querySelector("#showMoreGallery").textContent="VER MENOS"):(this.mediaGallery.style=`max-height: ${this.mediaGallery.offsetWidth}px; overflow: hidden;`,this.querySelector("#showMoreGallery").textContent="VER M\xC1S")}}),customElements.get("media-zommable")||customElements.define("media-zommable",class extends HTMLElement{constructor(){super(),this.zoomed=!1,this.element=this,this.config={initialZoom:3,minZoom:1.25,maxZoom:4,zoomSpeed:.01};const{initialZoom,minZoom,maxZoom}=this.config;this.initialZoom=Math.max(Math.min(initialZoom,maxZoom),minZoom),this.zoom=this.initialZoom,this.img=this.querySelector(".zoomable__img"),this.img.draggable=!1,this.element.style.setProperty("--zoom",this.initialZoom),this._addEventListeners()}static get Default(){return{initialZoom:3,minZoom:1.25,maxZoom:4,zoomSpeed:.01}}_addEventListeners(){this.element.addEventListener("click",()=>this._toggleZoom()),this.element.addEventListener("mousemove",evt=>this._handleMousemove(evt)),this.element.addEventListener("mouseout",()=>this._handleMouseout()),this.element.addEventListener("wheel",evt=>this._handleWheel(evt))}_handleMouseover(){this.zoomed||(this.element.classList.add("zoomable--zoomed"),this.zoomed=!0)}_toggleZoom(){this.zoomed=!this.zoomed,this.zoomed?this.element.classList.add("zoomable--zoomed"):(this.element.classList.remove("zoomable--zoomed"),this.element.style.setProperty("--zoom",this.initialZoom))}_handleMousemove(evt){if(!this.zoomed)return;const elPos=this.element.getBoundingClientRect(),percentageX=`${(evt.clientX-elPos.left)*100/elPos.width}%`,percentageY=`${(evt.clientY-elPos.top)*100/elPos.height}%`;this.element.style.setProperty("--zoom-pos-x",percentageX),this.element.style.setProperty("--zoom-pos-y",percentageY)}_handleMouseout(){this.zoomed&&(this.element.style.setProperty("--zoom",this.initialZoom),this.element.classList.remove("zoomable--zoomed"),this.zoomed=!1)}_handleWheel(evt){if(!this.zoomed)return;evt.preventDefault();
1const newZoom=this.zoom+evt.deltaY*(this.config.zoomSpeed*-1),{minZoom,maxZoom}=this.config;this.zoom=Math.max(Math.min(newZoom,maxZoom),minZoom),this.element.style.setProperty("--zoom",this.zoom)}_handleTouchstart(evt){evt.preventDefault(),this._handleMouseover()}_handleTouchmove(evt){if(!this.zoomed)return;const elPos=this.element.getBoundingClientRect();let percentageX=(evt.touches[0].clientX-elPos.left)*100/elPos.width,percentageY=(evt.touches[0].clientY-elPos.top)*100/elPos.height;percentageX=Math.max(Math.min(percentageX,100),0),percentageY=Math.max(Math.min(percentageY,100),0),this.element.style.setProperty("--zoom-pos-x",`${percentageX}%`),this.element.style.setProperty("--zoom-pos-y",`${percentageY}%`)}_handleTouchend(evt){this._handleMouseout()}_mergeConfig(config){return{...this.constructor.Default,...typeof config=="object"?config:{}}}});const updateCartSection=()=>{fetch("?section_id=peta-wrapper").then(response=>response.text()).then(htmlString=>{const html=new DOMParser().parseFromString(htmlString,"text/html"),cartItemsSection=html.querySelector(".discount-message--wrapper"),galleryItem=html.querySelector(".discount-message--wrapper-gallery");cartItemsSection&&(document.querySelector(".discount-message--wrapper").innerHTML=cartItemsSection.innerHTML),galleryItem&&(document.querySelector(".discount-message--wrapper-gallery").innerHTML=galleryItem.innerHTML)}).catch(error=>console.error("Error updating cart section:",error))};subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{document.querySelectorAll(".clp-product-atc-wrapper.open").forEach(el=>{el.classList.remove("open")}),updateCartSection()}); 2//# sourceMappingURL=/cdn/shop/t/37/assets/product-form.js.map?v=167280173405026085461774015976
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.