PageSourceSearch

https://aiwachile.cl/cdn/shop/t/10/assets/shipping-calculator.js?v=106999688448598056621790795791

js aiwachile.cl collected 2026-10-06 06:23:37 UTC 5,656 bytes, 2 lines download raw bytes

1class ShippingCaculator extends HTMLElement{constructor(){super(),this.needEndLoading=!1,this.showingErrors=!1,this.generatedShipping=0,this.button=this.querySelector("button"),this.addressCountrySelect=this.querySelector("#AddressCountryCalculator"),this.addressProvinceSelect=this.querySelector("#AddressProvinceCalculator"),this.addressZipInput=this.querySelector("#AddressZipCalculator"),this.resultsTag=this.querySelector(".shipping-calculator__results"),this.resultsList=this.querySelector(".shipping-calculator__results-list"),this.resultsErrorHeading=this.querySelector(".shipping-calculator__error-heading"),this.resultsSuccessHeading=this.querySelector(".shipping-calculator__success-heading"),this.button.addEventListener("click",this.onButtonClick.bind(this)),this.addEventListener("change",this.hideErrorsTag.bind(this),!1),this.onCartChangeHandler=this.onCartChange.bind(this),document.addEventListener("afterCartChanged",this.onCartChangeHandler),document.addEventListener("afterUpdateQuantity",this.onCartChangeHandler)}connectedCallback(){this.setupCountries()}disconnectedCallback(){document.removeEventListener("afterCartChanged",this.onCartChangeHandler),document.removeEventListener("afterUpdateQuantity",this.onCartChangeHandler)}setupCountries(){Shopify&&Shopify.CountryProvinceSelector&&new Shopify.CountryProvinceSelector(this.addressCountrySelect.id,this.addressProvinceSelect.id,{hideElement:"AddressProvinceContainerCalculator"})}onCartChange(){this.resultsTag.classList.add("hidden")}serialize(obj,prefix){var str=[],p;for(p in obj)if(obj.hasOwnProperty(p)){var k=prefix?prefix+"["+p+"]":p,v=obj[p];str.push(v!==null&&typeof v=="object"?this.serialize(v,k):encodeURIComponent(k)+"="+encodeURIComponent(v))}return str.join("&")}startLoading(){this.needEndLoading=!1,this.button.setAttribute("aria-disabled",!0),this.button.classList.add("loading"),this.querySelector(".loading-overlay__spinner").classList.remove("hidden")}endLoading(){this.needEndLoading&&(this.needEndLoading=!1,this.button.setAttribute("aria-disabled",!1),this.button.classList.remove("loading"),this.querySelector(".loading-overlay__spinner").classList.add("hidden"))}appendResultNode(text){const li=document.createElement("li"),node=document.createTextNode(text);li.appendChild(node),this.resultsList.appendChild(li)}handleResultsList(list){if(this.resultsList.innerHTML="",list.shipping_rates.length==0){this.resultsSuccessHeading.classList.add("hidden"),this.appendResultNode(this.dataset.doNotShipMessage),this.resultsTag.classList.remove("hidden");return}for(var key in list)Array.isArray(list[key])?list[key].forEach(item=>{if(typeof item=="object"){const li=document.createElement("li"),spanPrice=document.createElement("span");spanPrice.classList.add("price");const span=document.createElement("span");span.classList.add("cart-item__price","heading-font");const text=item.presentment_name+": ";span.innerHTML=Shopify.showPrice(item.price*100),spanPrice.append(span);const node=document.createTextNode(text);if(li.appendChild(node),li.appendChild(spanPrice),item.delivery_days.length>0){const spanDate=document.createElement("span");spanDate.classList.add("caption","shipping-calculator__date");var spanDateText="( ";item.delivery_days[0]==item.delivery_days[1]?parseInt(item.delivery_days[0])<=1?spanDateText+=this.dataset.deliveryDateOne.replace("[count]",item.delivery_days[0]):spanDateText+=this.dataset.deliveryDateMany.replace("[count]",item.delivery_days[0]):spanDateText+=this.dataset.deliveryDateRange.replace("[minimum]",item.delivery_days[0]).replace("[maximum]",item.delivery_days[1]),spanDateText+=" )";const nodeSpanDateText=document.createTextNode(spanDateText);spanDate.appendChild(nodeSpanDateText),li.appendChild(spanDate)}this.resultsList.appendChild(li)}else this.appendResultNode(item)}):this.appendResultNode(list[key]);this.resultsTag.classList.remove("hidden")}handleErrorResponse(errors){this.generatedShipping=0,this.showingErrors=!0,this.resultsErrorHeading.classList.remove("hidden"),this.resultsSuccessHeading.classList.add("hidden"),this.handleResultsList(errors)}handleSuccessResponse(list){this.generatedShipping=0,this.showingErrors=!1,this.resultsSuccessHeading.classList.remove("hidden"),this.resultsErrorHeading.classList.add("hidden"),this.handleResultsList(list)}hideErrorsTag(){this.showingErrors&&(this.resultsTag.classList.add("hidden"),this.showingErrors=!1)}onButtonClick(event){if(this.button.classList.contains("loading"))return;this.startLoading();const params={shipping_address:{country:this.addressCountrySelect.value,province:this.addressProvinceSelect.value,zip:this.addressZipInput.value}},body=JSON.stringify(params);fetch(`${routes.cart_url}/prepare_shipping_rates.json`,{...fetchConfig("json","POST"),body}
1).then(response=>response.json()).then(response=>{response==null||response.ok?fetch(`${routes.cart_url}/async_shipping_rates.json?`+this.serialize(params),{...fetchConfig("json","GET")}).then(finalResponse=>finalResponse.json()).then(finalResponse=>{finalResponse!=null?(this.needEndLoading=!0,this.handleSuccessResponse(finalResponse)):this.generatedShipping<10&&(this.needEndLoading=!1,setTimeout(()=>{this.needEndLoading=!0,this.endLoading(),this.generatedShipping++,this.button.dispatchEvent(new MouseEvent("click"))},2300))}).finally(()=>{this.endLoading()}):(this.needEndLoading=!0,this.handleErrorResponse(response))}).catch(e=>{this.handleErrorResponse(e),this.needEndLoading=!0}).finally(()=>{this.endLoading()})}}customElements.define("shipping-calculator",ShippingCaculator);
2//# sourceMappingURL=/cdn/shop/t/10/assets/shipping-calculator.js.map?v=106999688448598056621790795791

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.