1document.addEventListener("DOMContentLoaded",()=>{const PRODUCT_HANDLE="donacion-libre-2",$amount=document.getElementById("donation-amount"),$note=document.getElementById("donation-note"),$btn=document.getElementById("donation-add");if(!$amount||!$btn)return;let VARIANT_ID=null,UNIT=null,busy=!1;const fmt=n=>n.toLocaleString("es-CO"),setBusy=v=>{busy=v,$btn.disabled=v,$btn.style.opacity=v?"0.6":"1",$btn.textContent=v?"Procesando\u2026":"Donar ahora"},updateNote=()=>{const val=parseInt($amount.value,10)||0;if(!UNIT){$note.textContent="Cargando\u2026";return}const qty=Math.max(1,Math.round(val/UNIT));$note.textContent=`Tu donaci\xF3n ser\xE1 de ${fmt(qty*UNIT)} COP`},fetchJSON=(url,opts)=>fetch(url,Object.assign({headers:{"Content-Type":"application/json"}},opts)).then(r=>r.ok?r.json():Promise.reject(r)),loadVariant=()=>fetchJSON(`/products/${PRODUCT_HANDLE}.json?ts=${Date.now()}`).then(d=>{const v=d&&d.product&&d.product.variants&&d.product.variants[0];if(!v)throw new Error("No se encontr\xF3 la variante del producto.");if(VARIANT_ID=v.id,UNIT=Math.round(parseFloat(v.price||"0")),!UNIT)throw new Error("Precio de donaci\xF3n no configurado.");updateNote()}),getCart=()=>fetchJSON("/cart.js"),removeExistingDonation=async()=>{const targets=(await getCart()).items.filter(it=>it.handle===PRODUCT_HANDLE||/donaci[oó]n/i.test(it.product_title));if(targets.length)for(const it of targets)await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:it.key,quantity:0})})},addDonationAndCheckout=async amount=>{const quantity=Math.max(1,Math.round(amount/UNIT));await removeExistingDonation(),await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:VARIANT_ID,quantity,properties:{"Monto ingresado":`${fmt(amount)} COP`}})}).then(r=>{if(!r.ok)throw new Error("add.js failed");return r.json()}),window.location.href="/checkout"};loadVariant().catch(()=>{$btn.disabled=!0,$note&&($note.textContent="Error cargando el producto de donaci\xF3n.")}),$amount.addEventListener("blur",()=>{const val=parseInt($amount.value,10)||0;if(UNIT){if(val<1e4)$amount.value=1e4;else if(val%UNIT!==0){const rounded=Math.round(val/UNIT)*UNIT;$amount.value=rounded}updateNote()}}),$amount.addEventListener("input",updateNote),$btn.addEventListener("click",async()=>{if(busy)return;const amount=parseInt($amount.value,10)||0;if(!UNIT||!VARIANT_ID){alert("No se pudo cargar la donaci\xF3n. Recarga la p\xE1gina.");return}if(amount<1e4){alert(`El m\xEDnimo es ${fmt(1e4)} COP`);return}if(!(amount>1e7&&!confirm(`Donaci\xF3n superior a ${fmt(1e7)} COP. \xBFContinuar?`)))try{setBusy(!0),await addDonationAndCheckout(amount)}catch(e){console.error(e),alert("Hubo un error al procesar la donaci\xF3n."),setBusy(!1)}})}); 2//# sourceMappingURL=/cdn/shop/t/1/assets/donation.js.map?v=65289754898666074761761597800
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.